import{w as N,a as K}from"./with-props-B2QDd-XH.js";import{o as n,p as T,q as O,t as Y,n as r,M as B,L as $,S as D,v as J,O as H}from"./chunk-K6CSEXPM-C7aLO__S.js";import{C as m,J as V,z as q,T as z,c as W,P as Z}from"./index-xrLT-zdx.js";import{L as G}from"./loading-E8nFTuxK.js";import"./index-7k95swv0.js";var i=e=>`🔒 Clerk: ${e.trim()} For more info, check out the docs: https://clerk.com/docs, or come say hi in our discord server: https://clerk.com/discord `,f=`Use 'rootAuthLoader' as your root loader. Then, add to your app. Example: import { rootAuthLoader } from '@clerk/react-router/ssr.server' import { ClerkProvider } from '@clerk/react-router' export async function loader(args: Route.LoaderArgs) { return rootAuthLoader(args) } export default function App({ loaderData }: Route.ComponentProps) { return ( ) } `,Q=i(` You're trying to pass an invalid object in "". ${f} `),h=i(` Looks like you didn't pass 'clerkState' to "". ${f} `);i(` You're calling 'getAuth()' from a loader, without providing the loader args object. Example: export async function loader(args: Route.LoaderArgs) { const { userId } = await getAuth(args) // Your code here } `);i(` You're returning an invalid response from the 'rootAuthLoader' inside root.tsx. You can only return plain objects, Responses created using the React Router 'data()'helper or custom redirect 'Response' instances (status codes in the range of 300 to 400). If you want to return a primitive value or an array, you can always wrap the response with an object. Example: export async function loader(args: Route.LoaderArgs) { return rootAuthLoader(args, async ({ auth }) => { const { userId } = auth; const posts = await database.getPostsByUserId(userId); return { data: posts } // Or return data(posts, { headers: { 'Content-Type': 'application/json' } }) }) } `);i(` A secretKey must be provided in order to use SSR and the exports from @clerk/react-router/api.'); If your runtime supports environment variables, you can add a CLERK_SECRET_KEY variable to your config. Otherwise, you can pass a secretKey parameter to rootAuthLoader or getAuth. `);i("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl");i(` Invalid signInUrl. A satellite application requires a signInUrl for development instances. Check if signInUrl is missing from your configuration or if it is not an absolute URL.`);var X=i(` You're trying to use Clerk in React Router SPA Mode without providing a Publishable Key. Please provide the publishableKey prop on the component. Example: `);function ee(e){(!e||!e.__internal_clerk_state)&&console.warn(h)}function re(e){if(!e)throw new Error(h);if(e&&!e.__internal_clerk_state)throw new Error(Q)}function te(e){if(!e||typeof e!="string")throw new Error(X)}var x=()=>{var e;if(typeof window<"u"&&typeof((e=window.__reactRouterContext)==null?void 0:e.isSpaMode)<"u")return window.__reactRouterContext.isSpaMode},y=n.createContext(void 0);y.displayName="ClerkReactRouterOptionsCtx";var oe=e=>{const{children:t,options:o}=e;return n.createElement(y.Provider,{value:{value:o}},t)},ae=()=>{const e=T(),t=O(),o=n.useRef([]),s=()=>{o.current.forEach(a=>a()),o.current.splice(0,o.current.length)};return n.useEffect(()=>{s()},[t]),(a,d)=>new Promise(u=>{o.current.push(u),e(a,d)})},se={name:"@clerk/react-router",version:"1.1.5"},c={current:void 0};function ne({children:e,...t}){const o=ae(),s=x();n.useEffect(()=>{c.current=o},[o]);const{clerkState:a,...d}=t;m.displayName="ReactClerkProvider",typeof s<"u"&&!s&&re(a);const{__clerk_ssr_state:u,__publishableKey:v,__proxyUrl:_,__domain:k,__isSatellite:b,__clerk_debug:w,__signInUrl:R,__signUpUrl:S,__afterSignInUrl:C,__afterSignUpUrl:U,__signInForceRedirectUrl:j,__signUpForceRedirectUrl:E,__signInFallbackRedirectUrl:P,__signUpFallbackRedirectUrl:A,__clerkJSUrl:I,__clerkJSVersion:L,__telemetryDisabled:F,__telemetryDebug:M}=(a==null?void 0:a.__internal_clerk_state)||{};n.useEffect(()=>{typeof s<"u"&&!s&&ee(a)},[]),n.useEffect(()=>{window.__clerk_debug=w},[]);const g={publishableKey:v,proxyUrl:_,domain:k,isSatellite:b,signInUrl:R,signUpUrl:S,afterSignInUrl:C,afterSignUpUrl:U,signInForceRedirectUrl:j,signUpForceRedirectUrl:E,signInFallbackRedirectUrl:P,signUpFallbackRedirectUrl:A,clerkJSUrl:I,clerkJSVersion:L,telemetry:{disabled:F,debug:M}};return n.createElement(oe,{options:g},n.createElement(m,{routerPush:p=>{var l;return(l=c.current)==null?void 0:l.call(c,p)},routerReplace:p=>{var l;return(l=c.current)==null?void 0:l.call(c,p,{replace:!0})},initialState:u,sdkMetadata:se,...g,...d},e))}var ie=({children:e,loaderData:t,...o})=>{let s;const a=x();return!a&&(t!=null&&t.clerkState)&&(s=t.clerkState),typeof a<"u"&&a&&te(o.publishableKey),n.createElement(ne,{...o,clerkState:s},e)};const he=({error:e})=>{let t="Oops!",o="An unexpected error occurred.",s;return Y(e)&&(t=e.status===404?"404":"Error",o=e.status===404?"The requested page could not be found.":e.statusText||o),r.jsx("div",{className:"h-screen w-screen flex flex-col items-center justify-center bg-gray-200",children:r.jsx("div",{className:"w-full px-16 md:px-0 flex items-center justify-center",children:r.jsxs("div",{className:"bg-white border border-gray-200 flex flex-col items-center justify-center px-4 md:px-8 lg:px-24 py-8 rounded-lg shadow-2xl",children:[r.jsx("p",{className:"text-6xl md:text-7xl lg:text-9xl font-bold tracking-wider text-gray-300",children:r.jsx("img",{src:"/feeling_blue.svg",alt:"Something went wrong",width:400,height:400})}),r.jsx("h1",{className:"text-2xl md:text-3xl lg:text-5xl font-bold tracking-wider text-gray-500 mt-4",children:"Client Error"}),r.jsx("h1",{children:t}),r.jsx("p",{className:"text-gray-500 max-w-[700px] mt-8 py-2 border-y-2 text-center",children:"Whoops, Something went wrong."}),s]})})})};function le({children:e,...t}){return r.jsx(V,{...t,children:e})}const ce=({...e})=>{const{theme:t="system"}=q();return r.jsx(z,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground font-medium",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground font-medium"}},...e})},xe=({children:e})=>r.jsxs("html",{lang:"en",children:[r.jsxs("head",{children:[r.jsx(B,{}),r.jsx($,{})]}),r.jsx("body",{className:W("font-sans antialiased"),children:r.jsxs(le,{attribute:"class",defaultTheme:"dark",children:[r.jsx("main",{children:e}),r.jsx(ce,{richColors:!0}),r.jsx(D,{}),r.jsx(J,{})]})})]}),ye=()=>[{charSet:"utf-8"},{name:"viewport",content:"width=device-width,initial-scale=1"},{title:"PolyChat - The AI Chat App"}],ve=()=>[{rel:"preconnect",href:"https://fonts.googleapis.com"},{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"},{rel:"stylesheet",href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap"},{rel:"icon",href:"/favicon.ico"},{rel:"theme-color",href:"#AD46FF"},{rel:"manifest",href:"/manifest.webmanifest"}],_e=N(G),de=({})=>r.jsx(ie,{publishableKey:"pk_test_cmlnaHQtc3RhZy02MC5jbGVyay5hY2NvdW50cy5kZXYk",children:r.jsx(Z,{children:r.jsx(H,{})})}),ke=K(de);export{he as ErrorBoundary,_e as HydrateFallback,xe as Layout,ke as default,ve as links,ye as meta};