1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4018],{4018:(e,t,n)=>{let r;n.d(t,{$G:()=>l,M3:()=>C,ND:()=>O,getSessionWithTimeout:()=>T,m8:()=>U});var s=n(76297);let a="https://amyeqvyzjncbxajsuqum.supabase.co",o="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFteWVxdnl6am5jYnhhanN1cXVtIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njc5MjQ2NjUsImV4cCI6MjA4MzUwMDY2NX0.b2tiObwEjFQt1CBedZai7LdI6wDF66QzKs8xlCvj5lM",i=a?`${window.location.origin.replace(/\/+$/g,"")}/__supabase`:a,l=!!(a&&o);if(a&&o)("string"!=typeof o||3!==o.split(".").length)&&console.warn("[Supabase] NEXT_PUBLIC_SUPABASE_ANON_KEY doesn't look like a JWT. Please use the 'anon' public key from Supabase settings, not a publishable key.");else console.warn("[Supabase] Missing env: NEXT_PUBLIC_SUPABASE_URL or NEXT_PUBLIC_SUPABASE_ANON_KEY");function u(e){return new Promise(t=>setTimeout(t,e))}function c(){try{return"1"===window.localStorage.getItem("library.debug")||"1"===window.localStorage.getItem("library.supabase.debug")}catch{return!1}}async function f(e){var t;let n="string"==typeof(t=e.input)?t:t instanceof URL?t.toString():t.url;if(!((n.includes("/__supabase/")||a&&n.startsWith(a))&&(e.res.status>=500||c())))return;let r="";try{r=function(e){let t=e.trim();if(!t)return"";let n=t.length>1200?`${t.slice(0,1200)}...<truncated>`:t;try{return JSON.stringify(JSON.parse(n))}catch{return n}}(await e.res.clone().text())}catch{r=""}console.error("[Supabase] request failed",{method:e.method,url:n,status:e.res.status,statusText:e.res.statusText,attempt:e.attempt,elapsedMs:Date.now()-e.startedAt,requestId:e.res.headers.get("x-request-id")??e.res.headers.get("cf-ray")??e.res.headers.get("x-vercel-id")??null,contentType:e.res.headers.get("content-type"),responseBody:r})}let d=0,h=0,m=null,p=null,w=null,g=null,b="__aipersona_membership_cache_v1",y="__aipersona_rt_v1",_=new Map;function k(e,t){if("u"<typeof document)return;let n=function(){let e=(window.location.hostname??"").toString().trim().toLowerCase();if(!e||"localhost"===e||e.endsWith(".vercel.app")||/^\d{1,3}(\.\d{1,3}){3}$/.test(e))return;if(e.startsWith("www."))return e.slice(4);let t=e.split(".").filter(Boolean);return t.length>=2?t.slice(-2).join("."):e}(),r="https:"===window.location.protocol,s=t?encodeURIComponent(t):"",a=["path=/","samesite=lax"];r&&a.push("secure"),n&&a.push(`domain=${n}`),t||a.push("max-age=0"),document.cookie=`${e}=${s}; ${a.join("; ")}`}function S(e){let t="string"==typeof e?.refresh_token?e.refresh_token:"";t&&k(y,t)}function M(e){try{if(!e)return void window.localStorage.removeItem(b);window.localStorage.setItem(b,JSON.stringify(e))}catch{}}function A(e){try{return JSON.parse(e)}catch{return null}}function I(e){return!!(e&&"object"==typeof e&&!Array.isArray(e))}function E(e){if(!I(e))return null;let t="string"==typeof e.access_token?e.access_token:"",n=I(e.user)?e.user:null,r="string"==typeof n?.id?n.id:"",s=n||null,a="number"==typeof e.expires_at?e.expires_at:null;return t&&r&&s?{...e,access_token:t,token_type:"bearer",user:s,expires_at:a??void 0}:null}function N(){if(!i)return null;try{let e=new URL(i).hostname.split(".")[0]??"";if(!e)return null;let t=`sb-${e}-auth-token`,n=`sb-${e}-auth-token-storage`,r=[window.localStorage,window.sessionStorage],s=[t,n],a=[];for(let e of r)for(let t of s){let n=e.getItem(t);n&&a.push({storage:e,key:t,raw:n})}if(0===a.length)for(let e of r)for(let t=0;t<e.length;t++){let n=e.key(t);if(!n||!n.startsWith("sb-")||!n.endsWith("-auth-token"))continue;let r=e.getItem(n);r&&a.push({storage:e,key:n,raw:r})}for(let e of a){let t=A(e.raw),n=E(t);if(n)return n;if(I(t)){let e=E(t.currentSession);if(e)return e;let n=E(t.session);if(n)return n}}return null}catch{return null}}let v=async(e,t)=>{let n=(t?.method??"GET").toUpperCase(),r="GET"===n||"HEAD"===n,s=2*!!r,a=null;for(let o=0;o<=s;o++){if(t?.signal?.aborted)throw new DOMException("Aborted","AbortError");try{let a=new AbortController,i=Date.now(),l=setTimeout(()=>{let e=Date.now()-i,t=Error(`Fetch timeout after ${e}ms`);t.name="AbortError",a.abort(t)},15e3),c=function(e,t){if(!e)return t??null;if(!t)return e??null;if(e.aborted)return e;if(t.aborted)return t;let n=new AbortController,r=()=>n.abort();return e.addEventListener("abort",r,{once:!0}),t.addEventListener("abort",r,{once:!0}),n.signal}(t?.signal??null,a.signal),d=await fetch(e,{...t??{},signal:c??void 0});if(clearTimeout(l),d.ok||await f({input:e,method:n,res:d,attempt:o,startedAt:i}),!r||!(d&&(408===d.status||429===d.status||d.status>=500&&d.status<=599))||o>=s)return d;let h=d.headers.get("retry-after"),m=h?Number.parseInt(h,10):NaN,p=Number.isFinite(m)?1e3*Math.max(0,m):null,w=180*Math.pow(2,o),g=Math.floor(120*Math.random()),b=p??Math.min(1800,w+g);await u(b);continue}catch(l){if(l instanceof Error&&"AbortError"===l.name){let t=Date.now();t-d>8e3&&(d=t,console.warn("[Supabase] fetch aborted (timeout)",{url:"string"==typeof e?e:"",method:n,attempt:o}))}if(a=l,!r||l&&"object"==typeof l&&("AbortError"===l.name||"The user aborted a request."===l.message)||o>=s)throw l;let t=180*Math.pow(2,o),i=Math.floor(160*Math.random());await u(Math.min(1800,t+i))}}throw a??Error("Failed to fetch")},x=globalThis,D=globalThis;if(x.__aipersona_supabase)r=x.__aipersona_supabase;else if(i&&o){let e=(0,s.UU)(i,o,{global:{fetch:v},auth:{persistSession:!0,autoRefreshToken:!0,lock:async(e,t,n)=>await n()}});x.__aipersona_supabase=e,r=e}else console.warn("Supabase credentials missing (NEXT_PUBLIC_SUPABASE_URL or NEXT_PUBLIC_SUPABASE_ANON_KEY), using mock client."),r={auth:{getUser:async()=>({data:{user:null},error:null}),onAuthStateChange:()=>({data:{subscription:{unsubscribe(){}}}}),getSession:async()=>({data:{session:null},error:null}),signOut:async()=>({error:null}
1),signInWithOAuth:async e=>({data:{url:null},error:{message:"Supabase not configured"}}),signInWithOtp:async e=>({data:{user:null,session:null},error:{message:"Supabase not configured"}}),exchangeCodeForSession:async e=>({data:{user:null,session:null},error:{message:"Supabase not configured"}})},functions:{invoke:async()=>({data:null,error:{message:"Supabase not configured"}})},from:e=>({select:()=>({eq:()=>({order:async()=>({data:[],error:null}),single:async()=>({data:null,error:null})}),order:async()=>({data:[],error:null}),single:async()=>({data:null,error:null})}),insert:()=>({select:()=>({single:async()=>({data:null,error:{message:"Supabase not configured"}})})})}),storage:{from:e=>({upload:async()=>({data:null,error:null}),getPublicUrl:()=>({data:{publicUrl:""}})})}};let O=r;if(!D.__aipersona_auth_listener){let{data:e}=r.auth.onAuthStateChange((e,t)=>{p=null,g=null,m=null,w=null,("INITIAL_SESSION"===e||"SIGNED_IN"===e||"TOKEN_REFRESHED"===e)&&S(t??null),"SIGNED_OUT"===e&&(M(null),k(y,null))});D.__aipersona_auth_listener=e?.subscription??null}async function T(e){let t="number"==typeof e?.timeoutMs&&e.timeoutMs>0?Math.floor(e.timeoutMs):4e3,n="number"==typeof e?.retries&&e.retries>=0?Math.floor(e.retries):3,s="number"==typeof e?.retryDelayMs&&e.retryDelayMs>0?Math.floor(e.retryDelayMs):200,a=e?.signal??null;if(a?.aborted)return{session:null,timedOut:!1};let o=e=>!!(e&&!function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60;if(!e)return!0;let n="number"==typeof e.expires_at?e.expires_at:null,r=function(e){let t="string"==typeof e?e:"";if(!t)return null;let n=t.split(".");if(3!==n.length)return null;try{let e=n[1]??"";if(!e)return null;let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,s=t+"=".repeat(r),a=JSON.parse(atob(s)),o=a&&"object"==typeof a?a.exp:void 0;return"number"==typeof o&&Number.isFinite(o)?o:null}catch{return null}}(e.access_token),s="number"==typeof n?n:r;return!("number"==typeof s&&Number.isFinite(s))||function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60;return"number"==typeof e&&!!Number.isFinite(e)&&Math.floor(Date.now()/1e3)>=e-Math.max(0,Math.floor(t))}(s,t)}(e,60)),i=e=>new Promise(t=>{if(e.aborted)return t({kind:"abort"});e.addEventListener("abort",()=>t({kind:"abort"}),{once:!0})});if(p){if(o(p.session))return S(p.session),{session:p.session,timedOut:!1};p=null}if(m){let e=await (a?Promise.race([m,i(a)]):m);if("abort"===e.kind)return{session:null,timedOut:!1};if(e.session&&o(e.session))return e}let l=N();if(l&&o(l))return S(l),p={session:l,cachedAtMs:Date.now()},{session:l,timedOut:!1};let c=async()=>{let e=((function(e){if("u"<typeof document)return null;for(let t of document.cookie?document.cookie.split(";"):[]){let n=t.trim();if(!n)continue;let r=n.indexOf("=");if((r>=0?n.slice(0,r).trim():n)!==e)continue;let s=r>=0?n.slice(r+1):"";try{return decodeURIComponent(s)}catch{return s}}return null})(y)??"").trim();if(!e)return null;let n=Date.now(),s=null,a=new Promise(e=>{s=setTimeout(()=>e({kind:"timeout"}),t)}),i=r.auth.refreshSession({refresh_token:e}).then(e=>(s&&clearTimeout(s),s=null,{kind:"ok",value:e})).catch(()=>(s&&clearTimeout(s),s=null,{kind:"ok",value:{data:{session:null,user:null},error:null}})),l=await Promise.race([i,a]);if("timeout"===l.kind){let e=Date.now();return e-h>8e3&&(h=e,console.warn("[Supabase] cookie refresh timed out",{timeoutMs:t,elapsedMs:e-n})),null}let u=l.value?.data?.session??null;return o(u)?(S(u),u):(u||k(y,null),null)},f=async()=>{if(!m)return null;if(!a)return await m;let e=await Promise.race([m,i(a)]);return"abort"===e.kind?{session:null,timedOut:!1}:e},d=await f();if(d)return d.session&&o(d.session)&&(p={session:d.session,cachedAtMs:Date.now()}),d;m=(async()=>{let e=!1,a=Math.min(3,Math.max(0,n));for(let t=0;t<=a;t++){let n=N();if(n&&o(n))return{session:n,timedOut:e};t<a&&await u(Math.max(0,s))}for(let t=0;t<=Math.min(1,Math.max(0,n));t++){let r=await c();if(r&&o(r))return{session:r,timedOut:e};t<Math.min(1,Math.max(0,n))&&await u(Math.max(0,s))}let i=Date.now(),l=null,f=new Promise(e=>{l=setTimeout(()=>e({kind:"timeout"}),t)}),d=r.auth.getSession().then(e=>(l&&clearTimeout(l),l=null,{kind:"ok",value:e})).catch(()=>(l&&clearTimeout(l),l=null,{kind:"ok",value:{data:{session:null},error:null}})),m=await Promise.race([d,f]);if("timeout"===m.kind){e=!0;let n=Date.now();n-h>8e3&&(h=n,console.warn("[Supabase] auth.getSession timed out",{timeoutMs:t,attempt:0,elapsedMs:n-i}));let r=N();if(r&&o(r)){let e="number"==typeof r.expires_at?r.expires_at:null;return console.warn("[Supabase] using stored session snapshot after getSession timeouts",{expired:e?Date.now()/1e3>=e:null,hasExpiresAt:!!e}),{session:r,timedOut:!0}}return{session:null,timedOut:!0}}let p=m.value?.data?.session??null;if(o(p))return S(p),{session:p,timedOut:e};if(!o(p)){let n=Date.now(),s=null,a=new Promise(e=>{s=setTimeout(()=>e({kind:"timeout"}),t)}),i=r.auth.refreshSession().then(e=>(s&&clearTimeout(s),s=null,{kind:"ok",value:e})).catch(()=>(s&&clearTimeout(s),s=null,{kind:"ok",value:{data:{session:null,user:null},error:null}})),l=await Promise.race([i,a]);if("timeout"===l.kind){e=!0;let r=Date.now();r-h>8e3&&(h=r,console.warn("[Supabase] auth.refreshSession timed out",{timeoutMs:t,attempt:0,elapsedMs:r-n}))}else{let t=l.value?.data?.session??null;if(o(t))return S(t),{session:t,timedOut:e}}}let w=e?N():null;if(w&&o(w)){let e="number"==typeof w.expires_at?w.expires_at:null;return console.warn("[Supabase] using stored session snapshot after getSession timeouts",{expired:e?Date.now()/1e3>=e:null,hasExpiresAt:!!e}),{session:w,timedOut:!0}}return{session:null,timedOut:e}})().then(e=>(e.session&&o(e.session)&&(p={session:e.session,cachedAtMs:Date.now()}),e)).finally(()=>{m=null});let w=await (a?Promise.race([m,i(a)]):m);return"abort"===w.kind?{session:null,timedOut:!1}:w}async function C(e){if(!l)return"free";let t="number"==typeof e?.maxAgeMs&&e.maxAgeMs>=0?Math.floor(e.maxAgeMs):15e3,n=!!e?.forceRefresh,r=Date.now();if(!g){let e=function(){try{let e=window.localStorage.getItem(b);if(!e)return null;let t=A(e);if(!t||"object"!=typeof t)return null;let n="string"==typeof t.userId?t.userId:"",r="string"==typeof t.status?t.status:"",s="number"==typeof t.cac
1hedAtMs?t.cachedAtMs:NaN;if(!n||!r||!Number.isFinite(s)||"free"===r.toLowerCase()||Date.now()-s>72e5)return null;return{userId:n,status:r,cachedAtMs:s}}catch{return null}}();e&&(g=e)}let a=g;return!n&&g&&r-g.cachedAtMs<t?g.status:(w&&!n||(w=(async()=>{let l=null,u=null;try{let{session:t}=await T({timeoutMs:e?.sessionTimeoutMs??2500,retries:e?.sessionRetries??2,retryDelayMs:e?.sessionRetryDelayMs??120});l=t?.user?.id??null,u=t?.access_token??null}catch{l=null,u=null}if(!l){if(g){let e=(g.status??"").toString().toLowerCase(),t=r-g.cachedAtMs;if(e&&"free"!==e&&"unknown"!==e&&t<18e5)return g.status}return"unknown"}if(!n&&g&&g.userId===l&&r-g.cachedAtMs<t)return g.status;try{let e=u?function(e){let t=_.get(e);if(t)return t;let n=(0,s.UU)(i,o,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storageKey:"__aipersona_authed_data_v1"},global:{headers:{Authorization:`Bearer ${e}`}}});if(_.size>=2){let e=_.keys().next().value;void 0!==e&&_.delete(e)}return _.set(e,n),n}(u):O,{data:t,error:n}=await e.from("users").select("membership_status").eq("id",l).maybeSingle();if(n||!t){if(g&&g.userId===l){let e=(g.status??"").toString().toLowerCase(),t=r-g.cachedAtMs;if(e&&"free"!==e&&"unknown"!==e&&t<18e5)return g.status}return"unknown"}let c="string"==typeof t?.membership_status?t.membership_status.toLowerCase():"unknown";if("unknown"===c){if(g&&g.userId===l){let e=(g.status??"").toString().toLowerCase(),t=r-g.cachedAtMs;if(e&&"free"!==e&&"unknown"!==e&&t<18e5)return g.status}return"unknown"}let f="free"===c?"free":c;if("free"===f&&a&&a.userId===l){let e=(a.status??"").toString().toLowerCase(),t=r-a.cachedAtMs;if(e&&"free"!==e&&"unknown"!==e&&t<18e5)return g={userId:l,status:"unknown",cachedAtMs:Date.now()},"unknown"}return g={userId:l,status:f,cachedAtMs:Date.now()},"free"===f?M(null):M(g),f}catch{if(g&&g.userId===l){let e=(g.status??"").toString().toLowerCase(),t=r-g.cachedAtMs;if(e&&"free"!==e&&"unknown"!==e&&t<18e5)return g.status}return"unknown"}})().finally(()=>{w=null})),await w)}async function U(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{session:n}=await T({timeoutMs:1e3,retries:1,retryDelayMs:80}),s=n?.access_token;c()&&(s?console.debug(`[invokeEdgeFunction] Invoking ${e} with active session token.`):console.debug(`[invokeEdgeFunction] No active session found for function: ${e}. Request might fail with 401 if 'verify_jwt' is enabled.`));let a={...t.headers,...s?{Authorization:`Bearer ${s}`}:{}};return r.functions.invoke(e,{...t,headers:a})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.