(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,26732,e=>{"use strict";var t=e.i(47167),n=e.i(43476),s=e.i(71645);class r extends Error{constructor(e,t){e instanceof Error?super(void 0,{cause:{err:e,...e.cause,...t}}):"string"==typeof e?(t instanceof Error&&(t={err:t,...t.cause}),super(e,t)):super(void 0,e),this.name=this.constructor.name,this.type=this.constructor.type??"AuthError",this.kind=this.constructor.kind??"error",Error.captureStackTrace?.(this,this.constructor);const n=`https://errors.authjs.dev#${this.type.toLowerCase()}`;this.message+=`${this.message?". ":""}Read more at ${n}`}}class o extends r{}class a extends r{}async function i(e,t,n,s={}){let r=`${l(t)}/${e}`;try{let e={headers:{"Content-Type":"application/json",...s?.headers?.cookie?{cookie:s.headers.cookie}:{}}};s?.body&&(e.body=JSON.stringify(s.body),e.method="POST");let t=await fetch(r,e),n=await t.json();if(!t.ok)throw n;return n}catch(e){return n.error(new o(e.message,e)),null}}function l(e){return"undefined"==typeof window?`${e.baseUrlServer}${e.basePathServer}`:e.basePath}function c(){return Math.floor(Date.now()/1e3)}function u(e){let t=new URL("http://localhost:3000/api/auth");e&&!e.startsWith("http")&&(e=`https://${e}`);let n=new URL(e||t),s=("/"===n.pathname?t.pathname:n.pathname).replace(/\/$/,""),r=`${n.origin}${s}`;return{origin:n.origin,host:n.host,path:s,base:r,toString:()=>r}}let d={baseUrl:u(t.default.env.NEXTAUTH_URL??t.default.env.VERCEL_URL).origin,basePath:u(t.default.env.NEXTAUTH_URL).path,baseUrlServer:u(t.default.env.NEXTAUTH_URL_INTERNAL??t.default.env.NEXTAUTH_URL??t.default.env.VERCEL_URL).origin,basePathServer:u(t.default.env.NEXTAUTH_URL_INTERNAL??t.default.env.NEXTAUTH_URL).path,_lastSync:0,_session:void 0,_getSession:()=>{}},h=null;function f(){return"undefined"==typeof BroadcastChannel?{postMessage:()=>{},addEventListener:()=>{},removeEventListener:()=>{},name:"next-auth",onmessage:null,onmessageerror:null,close:()=>{},dispatchEvent:()=>!1}:new BroadcastChannel("next-auth")}function v(){return null===h&&(h=f()),h}let w={debug:console.debug,error:console.error,warn:console.warn},g=s.createContext?.(void 0);async function p(e){let t=await i("session",d,w,e);return(e?.broadcast??!0)&&f().postMessage({event:"session",data:{trigger:"getSession"}}),t}async function y(){let e=await i("csrf",d,w);return e?.csrfToken??""}async function m(){return i("providers",d,w)}async function S(e,t,n){let{callbackUrl:s,...r}=t??{},{redirect:o=!0,redirectTo:a=s??window.location.href,...i}=r,c=l(d),u=await m();if(!u){let e=`${c}/error`;window.location.href=e;return}if(!e||!u[e]){let e=`${c}/signin?${new URLSearchParams({callbackUrl:a})}`;window.location.href=e;return}let h=u[e].type;if("webauthn"===h)throw TypeError(`Provider id "${e}" refers to a WebAuthn provider.
Please use \`import { signIn } from "next-auth/webauthn"\` instead.`);let f=`${c}/${"credentials"===h?"callback":"signin"}/${e}`,v=await y(),w=await fetch(`${f}?${new URLSearchParams(n)}`,{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Auth-Return-Redirect":"1"},body:new URLSearchParams({...i,csrfToken:v,callbackUrl:a})}),g=await w.json();if(o){let e=g.url??a;window.location.href=e,e.includes("#")&&window.location.reload();return}let p=new URL(g.url).searchParams.get("error")??void 0,S=new URL(g.url).searchParams.get("code")??void 0;return w.ok&&await d._getSession({event:"storage"}),{error:p,code:S,status:w.status,ok:w.ok,url:p?null:g.url}}async function b(e){let{redirect:t=!0,redirectTo:n=e?.callbackUrl??window.location.href}=e??{},s=l(d),r=await y(),o=await fetch(`${s}/signout`,{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Auth-Return-Redirect":"1"},body:new URLSearchParams({csrfToken:r,callbackUrl:n})}),a=await o.json();if(v().postMessage({event:"session",data:{trigger:"signout"}}),t){let e=a.url??n;window.location.href=e,e.includes("#")&&window.location.reload();return}return await d._getSession({event:"storage"}),a}function E(e){if(!g)throw Error("React Context is unavailable in Server Components");let{children:t,basePath:r,refetchInterval:o,refetchWhenOffline:l}=e;r&&(d.basePath=r);let u=void 0!==e.session;d._lastSync=u?c():0;let[h,f]=s.useState(()=>(u&&(d._session=e.session),e.session)),[m,S]=s.useState(!u);s.useEffect(()=>(d._getSession=async({event:e}={})=>{try{let t="storage"===e;if(t||void 0===d._session){d._lastSync=c(),d._session=await p({broadcast:!t}),f(d._session);return}if(!e||null===d._session||c()<d._lastSync)return;d._lastSync=c(),d._session=await p(),f(d._session)}catch(e){w.error(new a(e.message,e))}finally{S(!1)}},d._getSession(),()=>{d._lastSync=0,d._session=void 0,d._getSession=()=>{}}),[]),s.useEffect(()=>{let e=()=>d._getSession({event:"storage"});return v().addEventListener("message",e),()=>v().removeEventListener("message",e)},[]),s.useEffect(()=>{let{refetchOnWindowFocus:t=!0}=e,n=()=>{t&&"visible"===document.visibilityState&&d._getSession({event:"visibilitychange"})};return document.addEventListener("visibilitychange",n,!1),()=>document.removeEventListener("visibilitychange",n,!1)},[e.refetchOnWindowFocus]);let b=function(){let[e,t]=s.useState("undefined"!=typeof navigator&&navigator.onLine),n=()=>t(!0),r=()=>t(!1);return s.useEffect(()=>(window.addEventListener("online",n),window.addEventListener("offline",r),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}),[]),e}(),E=!1!==l||b;s.useEffect(()=>{if(o&&E){let e=setInterval(()=>{d._session&&d._getSession({event:"poll"})},1e3*o);return()=>clearInterval(e)}},[o,E]);let _=s.useMemo(()=>({data:h,status:m?"loading":h?"authenticated":"unauthenticated",async update(e){if(m)return;S(!0);let t=await i("session",d,w,void 0===e?void 0:{body:{csrfToken:await y(),data:e}});return S(!1),t&&(f(t),v().postMessage({event:"session",data:{trigger:"getSession"}})),t}}),[h,m]);return(0,n.jsx)(g.Provider,{value:_,children:t})}e.s(["SessionProvider",()=>E,"signIn",()=>S,"signOut",()=>b],26732)},1661,e=>{"use strict";var t=e.i(43476),n=e.i(26732);function s({children:e}){return(0,t.jsx)(n.SessionProvider,{children:e})}e.s(["Providers",()=>s])}]);