PageSourceSearch

https://www.ladu.co/_app/immutable/nodes/0.Co_pkllO.js

js ladu.co collected 2026-10-04 02:47:12 UTC 165,464 bytes, 87 lines download raw bytes

1import{a as yr,c as U}from"../chunks/BosuxZz1.js";import{_ as Se}from"../chunks/C1FmrZbK.js";import mr from"../chunks/DAbwvvdc.js";import{b as ht,c as dt}from"../chunks/BW4MNh7s.js";import{S as br,i as kr,s as Er,x as Sr,d as x,t as Or,b as Tr,y as Ar,z as Rr,A as jr,f as q,e as ft,g as O,$ as Cr,h as M,o as gt,l as pt,p as F,r as wt,w as Pr}from"../chunks/Dx3CyPqA.js";import"../chunks/IHki7fMi.js";/* empty css                */import{c as Ir,d as $r}from"../chunks/D6Ldu7dc.js";const xr=s=>{let e;return s?e=s:typeof fetch>"u"?e=(...t)=>Se(async()=>{const{default:r}=await Promise.resolve().then(()=>pe);return{default:r}},void 0,import.meta.url).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)};class at extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}}class _t extends at{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class vt extends at{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class yt extends at{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var Ye;(function(s){s.Any="any",s.ApNortheast1="ap-northeast-1",s.ApNortheast2="ap-northeast-2",s.ApSouth1="ap-south-1",s.ApSoutheast1="ap-southeast-1",s.ApSoutheast2="ap-southeast-2",s.CaCentral1="ca-central-1",s.EuCentral1="eu-central-1",s.EuWest1="eu-west-1",s.EuWest2="eu-west-2",s.EuWest3="eu-west-3",s.SaEast1="sa-east-1",s.UsEast1="us-east-1",s.UsWest1="us-west-1",s.UsWest2="us-west-2"})(Ye||(Ye={}));var Ur=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,e||[])).next())})};class Lr{constructor(e,{headers:t={},customFetch:r,region:n=Ye.Any}={}){this.url=e,this.headers=t,this.region=n,this.fetch=xr(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return Ur(this,arguments,void 0,function*(t,r={}){var n;try{const{headers:i,method:o,body:a,signal:l}=r;let u={},{region:c}=r;c||(c=this.region);const h=new URL(`${this.url}/${t}`);c&&c!=="any"&&(u["x-region"]=c,h.searchParams.set("forceFunctionRegion",c));let d;a&&(i&&!Object.prototype.hasOwnProperty.call(i,"Content-Type")||!i)&&(typeof Blob<"u"&&a instanceof Blob||a instanceof ArrayBuffer?(u["Content-Type"]="application/octet-stream",d=a):typeof a=="string"?(u["Content-Type"]="text/plain",d=a):typeof FormData<"u"&&a instanceof FormData?d=a:(u["Content-Type"]="application/json",d=JSON.stringify(a)));const f=yield this.fetch(h.toString(),{method:o||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),i),body:d,signal:l}).catch(_=>{throw _.name==="AbortError"?_:new _t(_)}),p=f.headers.get("x-relay-error");if(p&&p==="true")throw new vt(f);if(!f.ok)throw new yt(f);let y=((n=f.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),g;return y==="application/json"?g=yield f.json():y==="application/octet-stream"?g=yield f.blob():y==="text/event-stream"?g=f:y==="multipart/form-data"?g=yield f.formData():g=yield f.text(),{data:g,error:null,response:f}}catch(i){return i instanceof Error&&i.name==="AbortError"?{data:null,error:new _t(i)}:{data:null,error:i,response:i instanceof yt||i instanceof vt?i.context:void 0}}})}}var I={},lt={},Le={},Oe={},Ne={},De={},Nr=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},ge=Nr();const Dr=ge.fetch,Ft=ge.fetch.bind(ge),Wt=ge.Headers,Br=ge.Request,qr=ge.Response,pe=Object.freeze(Object.defineProperty({__proto__:null,Headers:Wt,Request:Br,Response:qr,default:Ft,fetch:Dr},Symbol.toStringTag,{value:"Module"})),Mr=yr(pe);var Be={};Object.defineProperty(Be,"__esModule",{value:!0});let Fr=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.co
1de=e.code}};Be.default=Fr;var Kt=U&&U.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(De,"__esModule",{value:!0});const Wr=Kt(Mr),Kr=Kt(Be);let Hr=class{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(r=e.isMaybeSingle)!==null&&r!==void 0?r:!1,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=Wr.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const r=this.fetch;let n=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,l,u;let c=null,h=null,d=null,f=i.status,p=i.statusText;if(i.ok){if(this.method!=="HEAD"){const w=await i.text();w===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?h=w:h=JSON.parse(w))}const g=(a=this.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),_=(l=i.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");g&&_&&_.length>1&&(d=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(h)&&(h.length>1?(c={code:"PGRST116",details:`Results contain ${h.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},h=null,d=null,f=406,p="Not Acceptable"):h.length===1?h=h[0]:h=null)}else{const g=await i.text();try{c=JSON.parse(g),Array.isArray(c)&&i.status===404&&(h=[],c=null,f=200,p="OK")}catch{i.status===404&&g===""?(f=204,p="No Content"):c={message:g}}if(c&&this.isMaybeSingle&&(!((u=c==null?void 0:c.details)===null||u===void 0)&&u.includes("0 rows"))&&(c=null,f=200,p="OK"),c&&this.shouldThrowOnError)throw new Kr.default(c)}return{error:c,data:h,count:d,status:f,statusText:p}});return this.shouldThrowOnError||(n=n.catch(i=>{var o,a,l;return{error:{message:`${(o=i==null?void 0:i.name)!==null&&o!==void 0?o:"FetchError"}: ${i==null?void 0:i.message}`,details:`${(a=i==null?void 0:i.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(l=i==null?void 0:i.code)!==null&&l!==void 0?l:""}`},data:null,count:null,status:0,statusText:""}})),n.then(e,t)}returns(){return this}overrideTypes(){return this}};De.default=Hr;var Gr=U&&U.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ne,"__esModule",{value:!0});const zr=Gr(De);let Jr=class extends zr.default{select(e){let t=!1;const r=(e??"*").split("").map(n=>/\s/.test(n)&&!t?"":(n==='"'&&(t=!t),n)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:i=n}={}){const o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){const n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){const i=typeof n>"u"?"offset":`${n}.offset`,o=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}
1explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:i=!1,format:o="text"}={}){var a;const l=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,i?"wal":null].filter(Boolean).join("|"),u=(a=this.headers.get("Accept"))!==null&&a!==void 0?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${u}"; options=${l};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};Ne.default=Jr;var Vr=U&&U.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Oe,"__esModule",{value:!0});const Yr=Vr(Ne);let Qr=class extends Yr.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const r=Array.from(new Set(t)).map(n=>typeof n=="string"&&new RegExp("[,()]").test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let i="";n==="plain"?i="pl":n==="phrase"?i="ph":n==="websearch"&&(i="w");const o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){const n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}};Oe.default=Qr;var Xr=U&&U.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Le,"__esModule",{value:!0});const _e=Xr(Oe);let Zr=class{constructor(e,{headers:t={},schema:r,fetch:n}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=n}select(e,t){const{head:r=!1,count:n}=t??{},i=r?"HEAD":"GET";let o=!1;const a=(e??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),n&&this.headers.append("Prefer",`count=${n}`),new _e.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;const i="POST";if(t&&this.headers.append("Prefer",`count=${t}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(e)){const o=e.reduce((a,l)=>a.concat(Object.keys(l)),[]);if(o.length>
10){const a=[...new Set(o)].map(l=>`"${l}"`);this.url.searchParams.set("columns",a.join(","))}}return new _e.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:i=!0}={}){var o;const a="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),t!==void 0&&this.url.searchParams.set("on_conflict",t),n&&this.headers.append("Prefer",`count=${n}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(e)){const l=e.reduce((u,c)=>u.concat(Object.keys(c)),[]);if(l.length>0){const u=[...new Set(l)].map(c=>`"${c}"`);this.url.searchParams.set("columns",u.join(","))}}return new _e.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(e,{count:t}={}){var r;const n="PATCH";return t&&this.headers.append("Prefer",`count=${t}`),new _e.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:e}={}){var t;const r="DELETE";return e&&this.headers.append("Prefer",`count=${e}`),new _e.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch})}};Le.default=Zr;var Ht=U&&U.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(lt,"__esModule",{value:!0});const es=Ht(Le),ts=Ht(Oe);let rs=class Gt{constructor(e,{headers:t={},schema:r,fetch:n}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=n}from(e){const t=new URL(`${this.url}/${e}`);return new es.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new Gt(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:r=!1,get:n=!1,count:i}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let u;r||n?(a=r?"HEAD":"GET",Object.entries(t).filter(([h,d])=>d!==void 0).map(([h,d])=>[h,Array.isArray(d)?`{${d.join(",")}}`:`${d}`]).forEach(([h,d])=>{l.searchParams.append(h,d)})):(a="POST",u=t);const c=new Headers(this.headers);return i&&c.set("Prefer",`count=${i}`),new ts.default({method:a,url:l,headers:c,schema:this.schemaName,body:u,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};lt.default=rs;var we=U&&U.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(I,"__esModule",{value:!0});I.PostgrestError=I.PostgrestBuilder=I.PostgrestTransformBuilder=I.PostgrestFilterBuilder=I.PostgrestQueryBuilder=I.PostgrestClient=void 0;const zt=we(lt);I.PostgrestClient=zt.default;const Jt=we(Le);I.PostgrestQueryBuilder=Jt.default;const Vt=we(Oe);I.PostgrestFilterBuilder=Vt.default;const Yt=we(Ne);I.PostgrestTransformBuilder=Yt.default;const Qt=we(De);I.PostgrestBuilder=Qt.default;const Xt=we(Be);I.PostgrestError=Xt.default;var ss=I.default={PostgrestClient:zt.default,PostgrestQueryBuilder:Jt.default,PostgrestFilterBuilder:Vt.default,PostgrestTransformBuilder:Yt.default,PostgrestBuilder:Qt.default,PostgrestError:Xt.default};const{PostgrestClient:ns,PostgrestQueryBuilder:Xi,PostgrestFilterBuilder:Zi,PostgrestTransformBuilder:eo,PostgrestBuilder:to,PostgrestError:ro}=ss;class is{static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const t=process.versions;
1if(t&&t.node){const r=t.node,n=parseInt(r.replace(/^v/,"").split(".")[0]);return n>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${n} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${n} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
2import ws from "ws"
3new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+=`
4
5Suggested solution: ${e.workaround}`),new Error(t)}static createWebSocket(e,t){const r=this.getWebSocketConstructor();return new r(e,t)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const os="2.75.0",as=`realtime-js/${os}`,ls="1.0.0",Qe=1e4,cs=1e3,us=100;var ye;(function(s){s[s.connecting=0]="connecting",s[s.open=1]="open",s[s.closing=2]="closing",s[s.closed=3]="closed"})(ye||(ye={}));var j;(function(s){s.closed="closed",s.errored="errored",s.joined="joined",s.joining="joining",s.leaving="leaving"})(j||(j={}));var N;(function(s){s.close="phx_close",s.error="phx_error",s.join="phx_join",s.reply="phx_reply",s.leave="phx_leave",s.access_token="access_token"})(N||(N={}));var Xe;(function(s){s.websocket="websocket"})(Xe||(Xe={}));var X;(function(s){s.Connecting="connecting",s.Open="open",s.Closing="closing",s.Closed="closed"})(X||(X={}));class hs{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){const n=t.getUint8(1),i=t.getUint8(2);let o=this.HEADER_LENGTH+2;const a=r.decode(e.slice(o,o+n));o=o+n;const l=r.decode(e.slice(o,o+i));o=o+i;const u=JSON.parse(r.decode(e.slice(o,e.byteLength)));return{ref:null,topic:a,event:l,payload:u}}}class Zt{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var S;(function(s){s.abstime="abstime",s.bool="bool",s.date="date",s.daterange="daterange",s.float4="float4",s.float8="float8",s.int2="int2",s.int4="int4",s.int4range="int4range",s.int8="int8",s.int8range="int8range",s.json="json",s.jsonb="jsonb",s.money="money",s.numeric="numeric",s.oid="oid",s.reltime="reltime",s.text="text",s.time="time",s.timestamp="timestamp",s.timestamptz="timestamptz",s.timetz="timetz",s.tsrange="tsrange",s.tstzrange="tstzrange"})(S||(S={}));const mt=(s,e,t={})=>{var r;const n=(r=t.skipTypes)!==null&&r!==void 0?r:[];return e?Object.keys(e).reduce((i,o)=>(i[o]=ds(o,s,e,n),i),{}):{}},ds=(s,e,t,r)=>{const n=e.find(a=>a.name===s),i=n==null?void 0:n.type,o=t[s];return i&&!r.includes(i)?er(i,o):Ze(o)},er=(s,e)=>{if(s.charAt(0)==="_"){const t=s.slice(1,s.length);return ws(e,t)}switch(s){case S.bool:return fs(e);case S.float4:case S.float8:case S.int2:case S.int4:case S.int8:case S.numeric:case S.oid:return gs(e);case S.json:case S.jsonb:return ps(e);case S.timestamp:return _s(e);case S.abstime:case S.date:case S.daterange:case S.int4range:case S.int8range:case S.money:case S.reltime:case S.text:case S.time:case S.timestamptz:case S.timetz:case S.tsrange:case S.tstzrange:return Ze(e);default:return Ze(e)}},Ze=s=>s,fs=s=>{switch(s){case"t":return!0;case"f":return!1;default:return s}},gs=s=>{if(typeof s=="string"){const e=parseFloat(s);if(!Number.isNaN(e))return e}return s},ps=s=>{if(typeof s=="string")try{return JSON.parse(s)}catch(e){return console.log(`JSON parse error: ${e}`),s}return s},ws=(s,e)=>
5{if(typeof s!="string")return s;const t=s.length-1,r=s[t];if(s[0]==="{"&&r==="}"){let i;const o=s.slice(1,t);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(a=>er(e,a))}return s},_s=s=>typeof s=="string"?s.replace(" ","T"):s,tr=s=>{let e=s;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"};class Me{constructor(e,t,r={},n=Qe){this.channel=e,this.event=t,this.payload=r,this.timeout=n,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var bt;(function(s){s.SYNC="sync",s.JOIN="join",s.LEAVE="leave"})(bt||(bt={}));class me{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},n=>{const{onJoin:i,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel._joinRef(),this.state=me.syncState(this.state,n,i,o),this.pendingDiffs.forEach(l=>{this.state=me.syncDiff(this.state,l,i,o)}),this.pendingDiffs=[],a()}),this.channel._on(r.diff,{},n=>{const{onJoin:i,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=me.syncDiff(this.state,n,i,o),a())}),this.onJoin((n,i,o)=>{this.channel._trigger("presence",{event:"join",key:n,currentPresences:i,newPresences:o})}),this.onLeave((n,i,o)=>{this.channel._trigger("presence",{event:"leave",key:n,currentPresences:i,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,n){const i=this.cloneDeep(e),o=this.transformState(t),a={},l={};return this.map(i,(u,c)=>{o[u]||(l[u]=c)}),this.map(o,(u,c)=>{const h=i[u];if(h){const d=c.map(g=>g.presence_ref),f=h.map(g=>g.presence_ref),p=c.filter(g=>f.indexOf(g.presence_ref)<0),y=h.filter(g=>d.indexOf(g.presence_ref)<0);p.length>0&&(a[u]=p),y.length>0&&(l[u]=y)}else a[u]=c}),this.syncDiff(i,{joins:a,leaves:l},r,n)}static syncDiff(e,t,r,n){const{joins:i,leaves:o}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),n||(n=()=>{}),this.map(i,(a,l)=>{var u;const c=(u=e[a])!==null&&u!==void 0?u:[];if(e[a]=this.cloneDeep(l),c.length>0){const h=e[a].map(f=>f.presence_ref),d=c.filter(f=>h.indexOf(f.presence_ref)<0);e[a].unshift(...d)}r(a,c,l)}),this.map(o,(a,l)=>{let u=e[a];if(!u)return;const c=l.map(h=>h.presence_ref);u=u.filter(h=>c.indexOf(h.presence_ref)<0),e[a]=u,n(a,u,l),u.length===0&&delete e[a]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,r)=>{const n=e[r];return"metas"in n?t[r]=n.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):t[r]=n,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var kt;(function(s){s.ALL="*",s.INSERT="INSERT",s.UPDATE="UPDATE",s.DELETE="DELETE"})(kt||(kt={}));var be;(function(s){s.BROADCAST="broadcast",s.PRESENCE="presence",s.POSTGRES_CHANGES="postgres_changes",s.SYSTEM="system"})(be||(be={}));var W;(function(s){s.SUBSCRIBED="SUBSCRIBED",s.TIMED_OUT="TIMED_OUT",s.CLOSED="CLOSED",s.CHANNEL_ERROR="CHANNEL_ERROR"})(W||(W={}));class ct{constructor(e,t={config:{}},r){var n,i;if(this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=j.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config),this.timeout=this.socket.timeout,this.joinPush=new Me(this,N.join,this.params,this.timeout),this.rejoinTimer=new Zt(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=j.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(o=>o.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=j.closed,this.socket._remove(this)}),this._onError(o=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,o),this.state=j.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=j.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",o=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,o),this.state=j.errored,this.rejoinTimer.scheduleTimeout())}),this._on(N.reply,{},(o,a)=>{this._trigger(this._replyEventName(a),o)}),this.presence=new me(this),this.broadcastEndpointURL=tr(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((i=(n=this.params.config)===null||n===void 0?void 0:n.broadcast)===null||i===void 0)&&i.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,t=this.timeout){var r,n,i;if(this.socket.isConnected()||this.socket.connect(),this.state==j.closed){const{config:{broadcast:o,presence:a,private:l}}=this.params,u=(n=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(f=>f.filter))!==null&&n!==void 0?n:[],c=!!this.bindings[be.PRESENCE]&&this.bindings[be.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,h={},d={broadcast:o,presence:Object.assign(Object.assign({},a),{enabled:c}),postgres_changes:u,private:l};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(f=>e==null?void 0:e(W.CHANNEL_ERROR,f)),this._onClose(()=>e==null?void 0:e(W.CLOSED)),this.updateJoinPayload(Object.assign({config:d},h)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:f})=>{var p;if(this.socket.setAuth(),f===void 0){e==null||e(W.SUBSCRIBED);return}else{const y=this.bindings.postgres_changes,g=(p=y==null?void 0:y.length)!==null&&p!==void 0?p:0,_=[];for(let w=0;w<g;w++){const v=y[w],{filter:{event:k,schema:C,table:E,filter:R}}=v,K=f&&f[w];if(K&&K.event===k&&K.schema===C&&K.table===E&&K.filter===R)_.push(Object.assign(Object.assign({},v),{id:K.id}));else{this.unsubscribe(),this.state=j.errored,e==null||e(W.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=_,e&&e(W.SUBSCRIBED);return}}).receive("error",f=>{this.state=j.errored,e==null||e(W.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(f).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(W.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){return this.state===j.joined&&e===be.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(e,t,r)}async send(e,t={}){var r,n;if(!this._canPush()&&e.type==="broadcast"){const{event:i,payload:o}=e,l={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(r=t.timeout)!==null&&r!==void 0?r:this.timeout);return await((n=u.body)===null||n===void 0?void 0:n.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var o,a,l;const u=this._push(e.type,e,t.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(a=(o=this.params)===null||o===void 0?void 0:o.config)===null||a===void 0?void 0:a.broadcast)===null||l===void 0)&&l.ack)&&i("ok"),u.receive("ok",()=>i("ok")),u.receive("error",()=>i("error")),u.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=j.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(N.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(n=>{r=new Me(this,N.leave,{},e),r.receive("ok",()=>{t(),n("ok")}).receive("timeout",()=>{t(),n("timed out")}).receive("error",()=>{n("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{r==null||r.destroy()})}
5teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=j.closed,this.bindings={}}async _fetchWithTimeout(e,t,r){const n=new AbortController,i=setTimeout(()=>n.abort(),r),o=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}));return clearTimeout(i),o}_push(e,t,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let n=new Me(this,e,t,r);return this._canPush()?n.send():this._addToPushBuffer(n),n}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>us){const t=this.pushBuffer.shift();t&&(t.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${t.event}`,t.payload))}}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var n,i;const o=e.toLocaleLowerCase(),{close:a,error:l,leave:u,join:c}=N;if(r&&[a,l,u,c].indexOf(o)>=0&&r!==this._joinRef())return;let d=this._onMessage(o,t,r);if(t&&!d)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(n=this.bindings.postgres_changes)===null||n===void 0||n.filter(f=>{var p,y,g;return((p=f.filter)===null||p===void 0?void 0:p.event)==="*"||((g=(y=f.filter)===null||y===void 0?void 0:y.event)===null||g===void 0?void 0:g.toLocaleLowerCase())===o}).map(f=>f.callback(d,r)):(i=this.bindings[o])===null||i===void 0||i.filter(f=>{var p,y,g,_,w,v;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in f){const k=f.id,C=(p=f.filter)===null||p===void 0?void 0:p.event;return k&&((y=t.ids)===null||y===void 0?void 0:y.includes(k))&&(C==="*"||(C==null?void 0:C.toLocaleLowerCase())===((g=t.data)===null||g===void 0?void 0:g.type.toLocaleLowerCase()))}else{const k=(w=(_=f==null?void 0:f.filter)===null||_===void 0?void 0:_.event)===null||w===void 0?void 0:w.toLocaleLowerCase();return k==="*"||k===((v=t==null?void 0:t.event)===null||v===void 0?void 0:v.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===o}).map(f=>{if(typeof d=="object"&&"ids"in d){const p=d.data,{schema:y,table:g,commit_timestamp:_,type:w,errors:v}=p;d=Object.assign(Object.assign({},{schema:y,table:g,commit_timestamp:_,eventType:w,new:{},old:{},errors:v}),this._getPayloadRecords(p))}f.callback(d,r)})}_isClosed(){return this.state===j.closed}_isJoined(){return this.state===j.joined}_isJoining(){return this.state===j.joining}_isLeaving(){return this.state===j.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){const n=e.toLocaleLowerCase(),i={type:n,filter:t,callback:r};return this.bindings[n]?this.bindings[n].push(i):this.bindings[n]=[i],this}_off(e,t){const r=e.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(n=>{var i;return!(((i=n.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===r&&ct.isEqual(n.filter,t))})),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(N.close,{},e)}_onError(e){this._on(N.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=j.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=mt(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=mt(e.columns,e.old_record)),t}}const Fe=()=>{},Ae={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},vs=[1e3,2e3,5e3,1e4],ys=1e4,ms=`
6  addEventListener("message", (e) => {
7    if (e.data.event === "start") {
8      setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
9    }
10  });`;class bs{constructor(e,t){var r;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=Qe,this.transport=null,this.heartbeatIntervalMs=Ae.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Fe,this.ref=0,this.reconnectTimer=null,this.logger=Fe,this.conn=null,this.sendBuffer=[],this.serializer
10=new hs,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=n=>{let i;return n?i=n:typeof fetch>"u"?i=(...o)=>Se(async()=>{const{default:a}=await Promise.resolve().then(()=>pe);return{default:a}},void 0,import.meta.url).then(({default:a})=>a(...o)).catch(a=>{throw new Error(`Failed to load @supabase/node-fetch: ${a.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):i=fetch,(...o)=>i(...o)},!(!((r=t==null?void 0:t.params)===null||r===void 0)&&r.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey,this.endPoint=`${e}/${Xe.websocket}`,this.httpEndpoint=tr(e),this._initializeOptions(t),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(t==null?void 0:t.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=is.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const t=e.message;throw t.includes("Node.js")?new Error(`${t}
11
12To use Realtime in Node.js, you need to provide a WebSocket implementation:
13
14Option 1: Use Node.js 22+ which has native WebSocket support
15Option 2: Install and provide the "ws" package:
16
17  npm install ws
18
19  import ws from "ws"
20  const client = new RealtimeClient(url, {
21    ...options,
22    transport: ws
23  })`):new Error(`WebSocket not available: ${t}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:ls}))}disconnect(e,t){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},e?this.conn.close(e,t??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const t=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),t}async removeAllChannels(){const e=await Promise.all(this.channels.map(t=>t.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case ye.connecting:return X.Connecting;case ye.open:return X.Open;case ye.closing:return X.Closing;default:return X.Closed}}isConnected(){return this.connectionState()===X.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,t={config:{}}){const r=`realtime:${e}`,n=this.getChannels().find(i=>i.topic===r);if(n)return n;{const i=new ct(`realtime:${e}`,t,this);return this.channels.push(i),i}}push(e){const{topic:t,event:r,payload:n,ref:i}=e,o=()=>{this.encode(e,a=>{var l;(l=this.conn)===null||l===void 0||l.send(a)})};this.log("push",`${t} ${r} (${i})`,n),this.isConnected()?o():this.sendBuffer.push(o)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(t){this.log("error","error in heartbeat callback",t)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(t){this.log("error","error in heartbeat callback",t)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(cs,"heartbeat timeout"),setTimeout(()=>{var t;this.isConnected()||(t=this.reconnectTimer)===null||t===void 0||t.scheduleTimeout()},Ae.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(t){this.log("error","error in heartbeat callback",t)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>
230&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,t=>{if(t.topic==="phoenix"&&t.event==="phx_reply")try{this.heartbeatCallback(t.payload.status==="ok"?"ok":"error")}catch(u){this.log("error","error in heartbeat callback",u)}t.ref&&t.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:r,event:n,payload:i,ref:o}=t,a=o?`(${o})`:"",l=i.status||"";this.log("receive",`${l} ${r} ${n} ${a}`.trim(),i),this.channels.filter(u=>u._isMember(r)).forEach(u=>u._trigger(n,i,o)),this._triggerStateCallbacks("message",t)})}_clearTimer(e){var t;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((t=this.reconnectTimer)===null||t===void 0||t.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=t=>{this.log("worker","worker error",t.message),this.workerRef.terminate()},this.workerRef.onmessage=t=>{t.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(e){var t;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(t=this.reconnectTimer)===null||t===void 0||t.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(N.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;const r=e.match(/\?/)?"&":"?",n=new URLSearchParams(t);return`${e}${r}${n}`}_workerObjectUrl(e){let t;if(e)t=e;else{const r=new Blob([ms],{type:"application/javascript"});t=URL.createObjectURL(r)}return t}_setConnectionState(e,t=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=t)}async _performAuth(e=null){let t;e?t=e:this.accessToken?t=await this.accessToken():t=this.accessTokenValue,this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEach(r=>{const n={access_token:t,version:as};t&&r.updateJoinPayload(n),r.joinedOnce&&r._isJoined()&&r._push(N.access_token,{access_token:t})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this.setAuth().catch(t=>{this.log("error",`error setting auth in ${e}`,t)})}_triggerStateCallbacks(e,t){try{this.stateChangeCallbacks[e].forEach(r=>{try{r(t)}catch(n){this.log("error",`error in ${e} callback`,n)}})}catch(r){this.log("error",`error triggering ${e} callbacks`,r)}}_setupReconnectionTimer(){this.reconnectTimer=new Zt(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Ae.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var t,r,n,i,o,a,l,u,c;if(this.transport=(t=e==null?void 0:e.transport)!==null&&t!==void 0?t:null,this.timeout=(r=e==null?void 0:e.timeout)!==null&&r!==void 0?r:Qe,this.heartbeatIntervalMs=(n=e==null?void 0:e.heartbeatIntervalMs)!==null&&n!==void 0?n:Ae.HEARTBEAT_INTERVAL,this.worker=(i=e==null?void 0:e.worker)!==null&&i!==void 0?i:!1,this.accessToken=(o=e==null?void 0:e.accessToken)!==null&&o!==void 0?o:null,this.heartbeatCallback=(a=e==null?void 0:e.heartbeatCallback)!==null&&a!==void 0?a:Fe,e!=null&&e.params&&(this.params=e.params),e!=null&&e.logger&&(this.logger=e.logger),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(l=e==null?void 0:e.reconnectAfterMs)!==null&&l!==void 0?l:h=>vs[h-1]||ys,this.encode=(u=e==null?void 0:e.encode)!==null&&u!==void 0?u:(h,d)=>d(JSON.stringify(h)),this.decode=(c=e==null?void 0:e.decode)!==null&&c!==void 0?c:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl}}}
23class ut extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function A(s){return typeof s=="object"&&s!==null&&"__isStorageError"in s}class ks extends ut{constructor(e,t,r){super(e),this.name="StorageApiError",this.status=t,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class et extends ut{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var Es=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,e||[])).next())})};const rr=s=>{let e;return s?e=s:typeof fetch>"u"?e=(...t)=>Se(async()=>{const{default:r}=await Promise.resolve().then(()=>pe);return{default:r}},void 0,import.meta.url).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},Ss=()=>Es(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Se(()=>Promise.resolve().then(()=>pe),void 0,import.meta.url)).Response:Response}),tt=s=>{if(Array.isArray(s))return s.map(t=>tt(t));if(typeof s=="function"||s!==Object(s))return s;const e={};return Object.entries(s).forEach(([t,r])=>{const n=t.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[n]=tt(r)}),e},Os=s=>{if(typeof s!="object"||s===null)return!1;const e=Object.getPrototypeOf(s);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in s)&&!(Symbol.iterator in s)};var re=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,e||[])).next())})};const We=s=>s.msg||s.message||s.error_description||s.error||JSON.stringify(s),Ts=(s,e,t)=>re(void 0,void 0,void 0,function*(){const r=yield Ss();s instanceof r&&!(t!=null&&t.noResolveJson)?s.json().then(n=>{const i=s.status||500,o=(n==null?void 0:n.statusCode)||i+"";e(new ks(We(n),i,o))}).catch(n=>{e(new et(We(n),n))}):e(new et(We(s),s))}),As=(s,e,t,r)=>{const n={method:s,headers:(e==null?void 0:e.headers)||{}};return s==="GET"||!r?n:(Os(r)?(n.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),n.body=JSON.stringify(r)):n.body=r,e!=null&&e.duplex&&(n.duplex=e.duplex),Object.assign(Object.assign({},n),t))};function Te(s,e,t,r,n,i){return re(this,void 0,void 0,function*(){return new Promise((o,a)=>{s(t,As(e,r,n,i)).then(l=>{if(!l.ok)throw l;return r!=null&&r.noResolveJson?l:l.json()}).then(l=>o(l)).catch(l=>Ts(l,a,r))})})}function Ce(s,e,t,r){return re(this,void 0,void 0,function*(){return Te(s,"GET",e,t,r)})}function D(s,e,t,r,n){return re(this,void 0,void 0,function*(){return Te(s,"POST",e,r,n,t)})}function rt(s,e,t,r,n){return re(this,void 0,void 0,function*(){return Te(s,"PUT",e,r,n,t)})}function Rs(s,e,t,r){return re(this,void 0,void 0,function*(){return Te(s,"HEAD",e,Object.assign(Object.assign({},t),{noResolveJson:!0}),r)})}function sr(s,e,t,r,n){return re(this,void 0,void 0,function*(){return Te(s,"DELETE",e,r,n,t)})}var js=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,e||[])).next())})};class Cs{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t}then(e,t){return this.execute().then(e,t)}execute(){return js(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(A(e))return{data:null,error:e};throw e}})}}var Ps=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,e||[])).next())})};class Is{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t}asStream(){return new Cs(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.execute().then(e,t)}execute(){return Ps(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(A(e))return{data:null,error:e};throw e}})}}var Et=["buffer","Buffer"],P=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,[])).next())})};const $s={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},St={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class xs{constructor(e,t={},r,n){this.shouldThrowOnError=!1,this.url=e,this.headers=t,this.bucketId=r,this.fetch=rr(n)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(e,t,r,n){return P(this,void 0,void 0,function*(){try{let i;const o=Object.assign(Object.assign({},St),n);let a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(o.upsert)});const l=o.metadata;typeof Blob<"u"&&r instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),l&&i.append("metadata",this.encodeMetadata(l)),i.append("",r)):typeof FormData<"u"&&r instanceof FormData?(i=r,i.append("cacheControl",o.cacheControl),l&&i.append("metadata",this.encodeMetadata(l))):(i=r,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType,l&&(a["x-metadata"]=this.toBase64(this.encodeMetadata(l)))),n!=null&&n.headers&&(a=Object.assign(Object.assign({},a),n.headers));const u=this._removeEmptyFolders(t),c=this._getFinalPath(u),h=yield(e=="PUT"?rt:D)(this.fetch,`${this.url}/object/${c}`,i,Object.assign({headers:a},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{data:{path:u,id:h.Id,fullPath:h.Key},error:null}}catch(i){if(this.shouldThrowOnError)throw i;if(A(i))return{data:null,error:i};throw i}})}upload(e,t,r){return P(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}uploadToSignedUrl(e,t,r,n){return P(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(e),o=this._getFinalPath(i),a=new URL(this.url+`/object/upload/sign/${o}`);a.searchParams.set("token",t);try{let l;const u=Object.assign({upsert:St.upsert},n),c=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",u.cacheControl),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.append("cacheControl",u.cacheControl)):(l=r,c["cac
23he-control"]=`max-age=${u.cacheControl}`,c["content-type"]=u.contentType);const h=yield rt(this.fetch,a.toString(),l,{headers:c});return{data:{path:i,fullPath:h.Key},error:null}}catch(l){if(this.shouldThrowOnError)throw l;if(A(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e,t){return P(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e);const n=Object.assign({},this.headers);t!=null&&t.upsert&&(n["x-upsert"]="true");const i=yield D(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:n}),o=new URL(this.url+i.url),a=o.searchParams.get("token");if(!a)throw new ut("No token returned by API");return{data:{signedUrl:o.toString(),path:e,token:a},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(A(r))return{data:null,error:r};throw r}})}update(e,t,r){return P(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t,r){return P(this,void 0,void 0,function*(){try{return{data:yield D(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,de
23stinationBucket:r==null?void 0:r.destinationBucket},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(A(n))return{data:null,error:n};throw n}})}copy(e,t,r){return P(this,void 0,void 0,function*(){try{return{data:{path:(yield D(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:r==null?void 0:r.destinationBucket},{headers:this.headers})).Key},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(A(n))return{data:null,error:n};throw n}})}createSignedUrl(e,t,r){return P(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e),i=yield D(this.fetch,`${this.url}/object/sign/${n}`,Object.assign({expiresIn:t},r!=null&&r.transform?{transform:r.transform}:{}),{headers:this.headers});const o=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${o}`)},{data:i,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(A(n))return{data:null,error:n};throw n}})}createSignedUrls(e,t,r){return P(this,void 0,void 0,function*(){try{const n=yield D(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return{data:n.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${i}`):null})),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(A(n))return{data:null,error:n};throw n}})}download(e,t){const n=typeof(t==null?void 0:t.transform)<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),o=i?`?${i}`:"",a=this._getFinalPath(e),l=()=>Ce(this.fetch,`${this.url}/${n}/${a}${o}`,{headers:this.headers,noResolveJson:!0});return new Is(l,this.shouldThrowOnError)}info(e){return P(this,void 0,void 0,function*(){const t=this._getFinalPath(e);try{const r=yield Ce(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:tt(r),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(A(r))return{data:null,error:r};throw r}})}exists(e){return P(this,void 0,void 0,function*(){const t=this._getFinalPath(e);try{return yield Rs(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(A(r)&&r instanceof et){const n=r.originalError;if([400,404].includes(n==null?void 0:n.status))return{data:!1,error:r}}throw r}})}getPublicUrl(e,t){const r=this._getFinalPath(e),n=[],i=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";i!==""&&n.push(i);const a=typeof(t==null?void 0:t.transform)<"u"?"render/image":"object",l=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});l!==""&&n.push(l);let u=n.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${r}${u}`)}}}remove(e){return P(this,void 0,void 0,function*(){try{return{data:yield sr(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(A(t))return{data:null,error:t};throw t}})}list(e,t,r){return P(this,void 0,void 0,function*(){try{const n=Object.assign(Object.assign(Object.assign({},$s),t),{prefix:e||""});return{data:yield D(this.fetch,`${this.url}/object/list/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(A(n))return{data:null,error:n};throw n}})}listV2(e,t){return P(this,void 0,void 0,function*(){try{const r=Object.assign({},e);return{data:yield D(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,r,{headers:this.headers},t),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(A(r))return{data:null,error:r};throw r}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Et<"u"?Et.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}}const Us="2.75.0",Ls={"X-Client-Info":`storage-js/${Us}`};var se=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,e||[])).next())})};class Ns{constructor(e,t={},r,n){this.shouldThrowOnError=!1;const i=new URL(e);n!=null&&n.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase.")),this.url=i.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Ls),t),this.fetch=rr(r)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(){return se(this,void 0,void 0,function*(){try{return{data:yield Ce(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(A(e))return{data:null,error:e};throw e}})}getBucket(e){return se(this,void 0,void 0,function*(){try{return{data:yield Ce(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(A(t))return{data:null,error:t};throw t}})}createBucket(e){return se(this,arguments,void 0,function*(t,r={public:!1}){try{return{data:yield D(this.fetch,`${this.url}/bucket`,{id:t,name:t,type:r.type,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(A(n))return{data:null,error:n};throw n}})}updateBucket(e,t){return se(this,void 0,void 0,function*(){try{return{data:yield rt(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(A(r))return{data:null,error:r};throw r}})}emptyBucket(e){return se(this,void 0,void 0,function*(){try{return{data:yield D(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(A(t))return{data:null,error:t};throw t}})}deleteBucket(e){return se(this,void 0,void 0,function*(){try{return{data:yield sr(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(A(t))return{data:null,error:t};throw t}})}}class Ds extends Ns{constructor(e,t={},r,n){super(e,t,r,n)}from(e){return new xs(this.url,this.headers,e,this.fetch)}}const Bs="2.75.0";let ve="";typeof Deno<"u"?ve="deno":typeof document<"u"?ve="web":typeof navigator<"u"&&navigator.product==="ReactNative"?ve="react-native":ve="node";const qs={"X-Client-Info":`supabase-js-${ve}/${Bs}`},Ms={headers:qs},Fs={schema:"public"},Ws={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Ks={};var Hs=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,e||[])).next())})};const Gs=s=>{let e;return s?e=s:typeof fetch>"u"?e=Ft:e=fetch,(...t)=>e(...t)},zs=()=>typeof Headers>"u"?Wt:Headers,Js=(s,e,t)=>{const r=Gs(t),n=zs();return(i,o)=>Hs(void 0,void 0,void 0,function*(){var a;const l=(a=yield e())!==null&&a!==void 0?a:s;let u=new n(o==null?void 0:o.headers);return u.has("apikey")||u.set("apikey",s),u.has("Authorization")||u.set("Authorization",`Bearer ${l}`),r(i,Object.assign(Object.assign({},o),{headers:u}))})};var Vs=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,e||[])).next())})};function Ys(s){return s.endsWith("/")?s:s+"/"}function Qs(s,e){var t,r;const{db:n,auth:i,realtime:o,global:a}=s,{db:l,auth:u,realtime:c,global:h}=e,d={db:Object.assign(Object.assign({},l),n),auth:Object.assign(Object.assign({},u),i),realtime:Object.assign(Object.assign({},c),o),storage:{},global:Object.assign(Object.assign(Object.assign({},h),a),{headers:Object.assign(Object.assign({},(t=h==null?void 0:h.headers)!==null&&t!==void 0?t:{}),(r=a==null?void 0:a.headers)!==null&&r!==void 0?r:{})}),accessToken:()=>Vs(this,void 0,void 0,function*(){return""})};return s.accessToken?d.accessToken=s.accessToken:delete d.accessToken,d}function Xs(s){const e=s==null?void 0:s.trim();if(!e)throw new Error("supabaseUrl is required.");
23if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(Ys(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const nr="2.75.0",ce=30*1e3,st=3,Ke=st*ce,Zs="http://localhost:9999",en="supabase.auth.token",tn={"X-Client-Info":`gotrue-js/${nr}`},nt="X-Supabase-Api-Version",ir={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},rn=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,sn=10*60*1e3;class ke extends Error{constructor(e,t,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=r}}function m(s){return typeof s=="object"&&s!==null&&"__isAuthError"in s}class nn extends ke{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}function on(s){return m(s)&&s.name==="AuthApiError"}class Z extends ke{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class J extends ke{constructor(e,t,r,n){super(e,r,n),this.name=t,this.status=r}}class G extends J{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function an(s){return m(s)&&s.name==="AuthSessionMissingError"}class ne extends J{constructor(){super("Auth session or user missing","AuthInvalidToken
23ResponseError",500,void 0)}}class Re extends J{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class je extends J{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function ln(s){return m(s)&&s.name==="AuthImplicitGrantRedirectError"}class Ot extends J{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class it extends J{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function He(s){return m(s)&&s.name==="AuthRetryableFetchError"}class Tt extends J{constructor(e,t,r){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=r}}class ot extends J{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const Pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),At=` 	
24\r=`.split(""),cn=(()=>{const s=new Array(128);for(let e=0;e<s.length;e+=1)s[e]=-1;for(let e=0;e<At.length;e+=1)s[At[e].charCodeAt(0)]=-2;for(let e=0;e<Pe.length;e+=1)s[Pe[e].charCodeAt(0)]=e;return s})();function Rt(s,e,t){if(s!==null)for(e.queue=e.queue<<8|s,e.queuedBits+=8;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;t(Pe[r]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;t(Pe[r]),e.queuedBits-=6}}function or(s,e,t){const r=cn[s];if(r>-1)for(e.queue=e.queue<<6|r,e.queuedBits+=6;e.queuedBits>=8;)t(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(s)}"`)}}function jt(s){const e=[],t=o=>{e.push(String.fromCodePoint(o))},r={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},i=o=>{dn(o,r,t)};for(let o=0;o<s.length;o+=1)or(s.charCodeAt(o),n,i);return e.join("")}function un(s,e){if(s<=127){e(s);return}else if(s<=2047){e(192|s>>6),e(128|s&63);return}else if(s<=65535){e(224|s>>12),e(128|s>>6&63),e(128|s&63);return}else if(s<=1114111){e(240|s>>18),e(128|s>>12&63),e(128|s>>6&63),e(128|s&63);return}throw new Error(`Unrecognized Unicode codepoint: ${s.toString(16)}`)}function hn(s,e){for(let t=0;t<s.length;t+=1){let r=s.charCodeAt(t);if(r>55295&&r<=56319){const n=(r-55296)*1024&65535;r=(s.charCodeAt(t+1)-56320&65535|n)+65536,t+=1}un(r,e)}}function dn(s,e,t){if(e.utf8seq===0){if(s<=127){t(s);return}for(let r=1;r<6;r+=1)if(!(s>>7-r&1)){e.utf8seq=r;break}if(e.utf8seq===2)e.codepoint=s&31;else if(e.utf8seq===3)e.codepoint=s&15;else if(e.utf8seq===4)e.codepoint=s&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(s<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|s&63,e.utf8seq-=1,e.utf8seq===0&&t(e.codepoint)}}function de(s){const e=[],t={queue:0,queuedBits:0},r=n=>{e.push(n)};for(let n=0;n<s.length;n+=1)or(s.charCodeAt(n),t,r);return new Uint8Array(e)}function fn(s){const e=[];return hn(s,t=>e.push(t)),new Uint8Array(e)}function ee(s){const e=[],t={queue:0,queuedBits:0},r=n=>{e.push(n)};return s.forEach(n=>Rt(n,t,r)),Rt(null,t,r),e.join("")}function gn(s){return Math.round(Date.now()/1e3)+s}function pn(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){const e=Math.random()*16|0;return(s=="x"?e:e&3|8).toString(16)})}const $=()=>typeof window<"u"&&typeof document<"u",V={tested:!1,writable:!1},ar=()=>{if(!$())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(V.tested)return V.writable;const s=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(s,s),globalThis.localStorage.removeItem(s),V.tested=!0,V.writable=!0}catch{V.tested=!0,V.writable=!1}return V.writable};function wn(s){const e={},t=new URL(s);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((n,i)=>{e[i]=n})}catch{}return t.searchParams.forEach((r,n)=>{e[n]=r}),e}const lr=s=>{let e;return s?e=s:typeof fetch>"u"?e=(...t)=>Se(async()=>{const{default:r}=await Promise.resolve().then(()=>pe);return{default:r}},void 0,import.meta.url).then(({default:r})=>r(...t)):e=fetch,(...t)=>e(...t)},_n=s=>typeof s=="object"&&s!==null&&"status"in s&&"ok"in s&&"json"in s&&typeof s.json=="function",ue=async(s,e,t)=>{await s.setItem(e,JSON.stringify(t))},Y=async(s,e)=>{const t=await s.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}},H=async(s,e)=>{await s.removeItem(e)};class qe{constructor(){this.promise=new qe.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}qe.promiseConstructor=Promise;function Ge(s){const e=s.split(".");if(e.length!==3)throw new ot("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!rn.test(e[r]))throw new ot("JWT not in base64url format");return{header:JSON.parse(jt(e[0])),payload:JSON.parse(jt(e[1])),signature:de(e[2]),raw:{header:e[0],payload:e[1]}}}async function vn(s){return await new Promise(e=>{setTimeout(()=>e(null),s)})}function yn(s,e){return new Promise((r,n)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await s(i);if(!e(i,null,o)){r(o);return}}catch(o){if(!e(i,o)){n(o);return}}})()})}function mn(s){return("0"+s.toString(16)).substr(-2)}function bn(){const e=new Uint32Array(56);if(typeof crypto>"u"){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=t.length;let n="";for(let i=0;i<56;i++)n+=t.charAt(Math.floor(Math.random()*r));return n}return crypto.getRandomValues(e),Array.from(e,mn).join("")}async function kn(s){const t=new TextEncoder().encode(s),r=await crypto.subtle.digest("SHA-256",t),n=new Uint8Array(r);return Array.from(n).map(i=>String.fromCharCode(i)).join("")}async function En(s){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code 
24challenge method will default to use plain instead of sha256."),s;const t=await kn(s);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function ie(s,e,t=!1){const r=bn();let n=r;t&&(n+="/PASSWORD_RECOVERY"),await ue(s,`${e}-code-verifier`,n);const i=await En(r);return[i,r===i?"plain":"s256"]}const Sn=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function On(s){const e=s.headers.get(nt);if(!e||!e.match(Sn))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function Tn(s){if(!s)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(s<=e)throw new Error("JWT has expired")}function An(s){switch(s){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const Rn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function oe(s){if(!Rn.test(s))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function ze(){const s={};return new Proxy(s,{get:(e,t)=>{if(t==="__isUserNotAvailableProxy")return!0;if(typeof t=="symbol"){const r=t.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${t}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,t)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,t)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function Ct(s){return JSON.parse(JSON.stringify(s))}var jn=function(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t};const Q=s=>s.msg||s.message||s.error_description||s.error||JSON.stringify(s),Cn=[502,503,504];async function Pt(s){var e;if(!_n(s))throw new it(Q(s),0);if(Cn.includes(s.status))throw new it(Q(s),s.status);let t;try{t=await s.json()}catch(i){throw new Z(Q(i),i)}let r;const n=On(s);if(n&&n.getTime()>=ir["2024-01-01"].timestamp&&typeof t=="object"&&t&&typeof t.code=="string"?r=t.code:typeof t=="object"&&t&&typeof t.error_code=="string"&&(r=t.error_code),r){if(r==="weak_password")throw new Tt(Q(t),s.status,((e=t.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new G}else if(typeof t=="object"&&t&&typeof t.weak_password=="object"&&t.weak_password&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.reasons.reduce((i,o)=>i&&typeof o=="string",!0))throw new Tt(Q(t),s.status,t.weak_password.reasons);throw new nn(Q(t),s.status||500,r)}const Pn=(s,e,t,r)=>{const n={method:s,headers:(e==null?void 0:e.headers)||{}};return s==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),n.body=JSON.stringify(r),Object.assign(Object.assign({},n),t))};async function b(s,e,t,r){var n;const i=Object.assign({},r==null?void 0:r.headers);i[nt]||(i[nt]=ir["2024-01-01"].name),r!=null&&r.jwt&&(i.Authorization=`Bearer ${r.jwt}`);const o=(n=r==null?void 0:r.query)!==null&&n!==void 0?n:{};r!=null&&r.redirectTo&&(o.redirect_to=r.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await In(s,e,t+a,{headers:i,noResolveJson:r==null?void 0:r.noResolveJson},{},r==null?void 0:r.body);return r!=null&&r.xform?r==null?void 0:r.xform(l):{data:Object.assign({},l),error:null}}async function In(s,e,t,r,n,i){const o=Pn(e,r,n,i);let a;try{a=await s(t,Object.assign({},o))}catch(l){throw console.error(l),new it(Q(l),0)}if(a.ok||await Pt(a),r!=null&&r.noResolveJson)return a;try{return await a.json()}catch(l){await Pt(l)}}function L(s){var e;let t=null;Un(s)&&(t=Object.assign({},s),s.expires_at||(t.expires_at=gn(s.expires_in)));const r=(e=s.user)!==null&&e!==void 0?e:s;return{data:{session:t,user:r},error:null}}function It(s){const e=L(s);return!e.error&&s.weak_password&&typeof s.weak_password=="object"&&Array.isArray(s.weak_password.reasons)&&s.weak_password.reasons.length&&s.weak_password.message&&typeof s.weak_password.message=="string"&&s.weak_password.reasons.reduce((t,r)=>t&&typeof r=="string",!0)&&(e.data.weak_password=s.weak_password),e}function z(s){var e;return{data:{user:(e=s.user)!==null&&e!==void 0?e:s},error:null}}function $n(s){return{data:s,error:null}}function xn(s){const{action_link:e,email_otp:t,hashed_token:r,redirect_to:n,verification_type:i}=s,o=jn(s,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:t,hashed_token:r,redirect_to:n,verification_type:i},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function $t(s){return s}function Un(s){return s.access_token&&s.refresh_token&&s.expires_in}const Je=["global","local","others"];var Ln=function(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t};class Nn{constructor({url:e="",headers:t={},fetch:r}){this.url=e,this.headers=t,this.fetch=lr(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(e,t=Je[0]){if(Je.indexOf(t)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Je.join(", ")}`);try{return await b(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(m(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,t={}){try{return await b(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:z})}catch(r){if(m(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:t}=e,r=Ln(e,["options"]),n=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(n.new_email=r==null?void 0:r.newEmail,delete n.newEmail),await b(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:n,headers:this.headers,xform:xn,redirectTo:t==null?void 0:t.redirectTo})}catch(t){if(m(t))return{data:{properties:null,user:null},error:t};throw t}}async createUser(e){try{return await b(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:z})}catch(t){if(m(t))return{data:{user:null},error:t};throw t}}async listUsers(e){var t,r,n,i,o,a,l;try{const u={nextPage:null,lastPage:0,total:0},c=await b(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(t=e==null?void 0:e.page)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:"",per_page:(i=(n=e==null?void 0:e.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:$t});if(c.error)throw c.error;const h=await c.json(),d=(o=c.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=c.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(p=>{const y=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),g=JSON.parse(p.split(";")[1].split("=")[1]);u[`${g}Page`]=y}),u.total=parseInt(d)),{data:Object.assign(Object.assign({},h),u),error:null}}catch(u){if(m(u))return{data:{users:[]},error:u};throw u}}async getUserById(e){oe(e);try{return await b(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:z})}catch(t){if(m(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){oe(e);try{return await b(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:z})}catch(r){if(m(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,t=!1){oe(e);
24try{return await b(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:z})}catch(r){if(m(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){oe(e.userId);try{const{data:t,error:r}=await b(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:t,error:r}}catch(t){if(m(t))return{data:null,error:t};throw t}}async _deleteFactor(e){oe(e.userId),oe(e.id);try{return{data:await b(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(m(t))return{data:null,error:t};throw t}}async _listOAuthClients(e){var t,r,n,i,o,a,l;try{const u={nextPage:null,lastPage:0,total:0},c=await b(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(t=e==null?void 0:e.page)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:"",per_page:(i=(n=e==null?void 0:e.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:$t});if(c.error)throw c.error;const h=await c.json(),d=(o=c.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=c.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(p=>{const y=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),g=JSON.parse(p.split(";")[1].split("=")[1]);u[`${g}Page`]=y}),u.total=parseInt(d)),{data:Object.assign(Object.assign({},h),u),error:null}}catch(u){if(m(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(e){try{return await b(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if(m(t))return{data:null,error:t};throw t}}async _getOAuthClient(e){try{return await b(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if(m(t))return{data:null,error:t};throw t}}async _deleteOAuthClient(e){try{return await b(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if(m(t))return{data:null,error:t};throw t}}async _regenerateOAuthClientSecret(e){try{return await b(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if(m(t))return{data:null,error:t};throw t}}}function xt(s={}){return{getItem:e=>s[e]||null,setItem:(e,t)=>{s[e]=t},removeItem:e=>{delete s[e]}}}const ae={debug:!!(globalThis&&ar()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class cr extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class Dn extends cr{}async function Bn(s,e,t){ae.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",s,e);const r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),ae.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",s)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(s,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async n=>{if(n){ae.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",s,n.name);try{return await t()}finally{ae.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",s,n.name)}}else{if(e===0)throw ae.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",s),new Dn(`Acquiring an exclusive Navigator LockManager lock "${s}" immediately failed`);if(ae.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null,"  "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await t()}}))}function qn(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function ur(s){if(!/^0x[a-fA-F0-9]{40}$/.test(s))throw new Error(`@supabase/auth-js: Address "${s}
24" is invalid.`);return s.toLowerCase()}function Mn(s){return parseInt(s,16)}function Fn(s){const e=new TextEncoder().encode(s);return"0x"+Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}function Wn(s){var e;const{chainId:t,domain:r,expirationTime:n,issuedAt:i=new Date,nonce:o,notBefore:a,requestId:l,resources:u,scheme:c,uri:h,version:d}=s;{if(!Number.isInteger(t))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${t}`);if(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!h)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(d!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${d}`);if(!((e=s.statement)===null||e===void 0)&&e.includes(`
25`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${s.statement}`)}const f=ur(s.address),p=c?`${c}://${r}`:r,y=s.statement?`${s.statement}
26`:"",g=`${p} wants you to sign in with your Ethereum account:
27${f}
28
29${y}`;let _=`URI: ${h}
30Version: ${d}
31Chain ID: ${t}${o?`
32Nonce: ${o}`:""}
33Issued At: ${i.toISOString()}`;if(n&&(_+=`
34Expiration Time: ${n.toISOString()}`),a&&(_+=`
35Not Before: ${a.toISOString()}`),l&&(_+=`
36Request ID: ${l}`),u){let w=`
37Resources:`;for(const v of u){if(!v||typeof v!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${v}`);w+=`
38- ${v}`}_+=w}return`${g}
39${_}`}class T extends Error{constructor({message:e,code:t,cause:r,name:n}){var i;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=(i=n??(r instanceof Error?r.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=t}}class Ie extends T{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}function Kn({error:s,options:e}){var t,r,n;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(s.name==="AbortError"){if(e.signal instanceof AbortSignal)return new T({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:s})}else if(s.name==="ConstraintError"){if(((t=i.authenticatorSelection)===null||t===void 0?void 0:t.requireResidentKey)===!0)return new T({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:s});if(e.mediation==="conditional"&&((r=i.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new T({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:s});if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new T({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:s})}else{if(s.name==="InvalidStateError")return new T({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:s});if(s.name==="NotAllowedError")return new T({message:s.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s});if(s.name==="NotSupportedError")return i.pubKeyCredParams.filter(a=>a.type==="public-key").length===0?new T({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:s}):new T({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:s});if(s.name==="SecurityError"){const o=window.location.hostname;if(dr(o)){if(i.rp.id!==o)return new T({message:`The RP ID "${i.rp.id}
39" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:s})}else return new T({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:s})}else if(s.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new T({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:s})}else if(s.name==="UnknownError")return new T({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:s})}return new T({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s})}function Hn({error:s,options:e}){const{publicKey:t}=e;if(!t)throw Error("options was missing required publicKey property");if(s.name==="AbortError"){if(e.signal instanceof AbortSignal)return new T({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:s})}else{if(s.name==="NotAllowedError")return new T({message:s.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s});if(s.name==="SecurityError"){const r=window.location.hostname;if(dr(r)){if(t.rpId!==r)return new T({message:`The RP ID "${t.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:s})}else return new T({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:s})}else if(s.name==="UnknownError")return new T({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:s})}return new T({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s})}var hr=function(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t};class Gn{createNewAbortSignal(){if(this.controller){const t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const zn=new Gn;function Jn(s){if(!s)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(s);const{challenge:e,user:t,excludeCredentials:r}=s,n=hr(s,["challenge","user","excludeCredentials"]),i=de(e).buffer,o=Object.assign(Object.assign({},t),{id:de(t.id).buffer}),a=Object.assign(Object.assign({},n),{challenge:i,user:o});if(r&&r.length>0){a.excludeCredentials=new Array(r.length);for(let l=0;l<r.length;l++){const u=r[l];a.excludeCredentials[l]=Object.assign(Object.assign({},u),{id:de(u.id).buffer,type:u.type||"public-key",transports:u.transports})}}return a}function Vn(s){if(!s)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(s);const{challenge:e,allowCredentials:t}=s,r=hr(s,["challenge","allowCredentials"]),n=de(e).buffer,i=Object.assign(Object.assign({},r),{challenge:n});if(t&&t.length>0){i.allowCredentials=new Array(t.length);for(let o=0;o<t.length;o++){const a=t[o];i.allowCredentials[o]=Object.assign(Object.assign({},a),{id:de(a.id).buffer,type:a.type||"public-key",transports:a.transports})}}return i}function Yn(s){var e;if("toJSON"in s&&typeof s.toJSON=="function")return s.toJSON();const t=s;return{id:s.id,rawId:s.id,response:{attestationObject:ee(new Uint8Array(s.response.attestationObject)),clientDataJSON:ee(new 
39Uint8Array(s.response.clientDataJSON))},type:"public-key",clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:(e=t.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Qn(s){var e;if("toJSON"in s&&typeof s.toJSON=="function")return s.toJSON();const t=s,r=s.getClientExtensionResults(),n=s.response;return{id:s.id,rawId:s.id,response:{authenticatorData:ee(new Uint8Array(n.authenticatorData)),clientDataJSON:ee(new Uint8Array(n.clientDataJSON)),signature:ee(new Uint8Array(n.signature)),userHandle:n.userHandle?ee(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=t.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function dr(s){return s==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(s)}function Ut(){var s,e;return!!($()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((s=navigator==null?void 0:navigator.credentials)===null||s===void 0?void 0:s.create)=="function"&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.get)=="function")}async function Xn(s){try{const e=await navigator.credentials.create(s);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Ie("Browser returned unexpected credential type",e)}:{data:null,error:new Ie("Empty credential response",e)}}catch(e){return{data:null,error:Kn({error:e,options:s})}}}async function Zn(s){try{const e=await navigator.credentials.get(s);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Ie("Browser returned unexpected credential type",e)}:{data:null,error:new Ie("Empty credential response",e)}}catch(e){return{data:null,error:Hn({error:e,options:s})}}}const ei={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"none"},ti={userVerification:"preferred",hints:["security-key"]};function $e(...s){const e=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),t=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),r={};for(const n of s)if(n)for(const i in n){const o=n[i];if(o!==void 0)if(Array.isArray(o))r[i]=o;else if(t(o))r[i]=o;else if(e(o)){const a=r[i];e(a)?r[i]=$e(a,o):r[i]=$e(o)}else r[i]=o}return r}function ri(s,e){return $e(ei,s,e||{})}function si(s,e){return $e(ti,s,e||{})}class ni{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:t,friendlyName:r,signal:n},i){try{const{data:o,error:a}=await this.client.mfa.challenge({factorId:e,webauthn:t});if(!o)return{data:null,error:a};const l=n??zn.createNewAbortSignal();if(o.webauthn.type==="create"){const{user:u}=o.webauthn.credential_options.publicKey;u.name||(u.name=`${u.id}:${r}`),u.displayName||(u.displayName=u.name)}switch(o.webauthn.type){case"create":{const u=ri(o.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:c,error:h}=await Xn({publicKey:u,signal:l});return c?{data:{factorId:e,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:c}},error:null}:{data:null,error:h}}case"request":{const u=si(o.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:c,error:h}=await Zn(Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:u,signal:l}));return c?{data:{factorId:e,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:c}},error:null}:{data:null,error:h}}}}catch(o){return m(o)?{data:null,error:o}:{data:null,error:new Z("Unexpected error in challenge",o)}}}async _verify({challengeId:e,factorId:t,webauthn:r}){return this.client.mfa.verify({factorId:t,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:t=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:n}},i){if(!t)return{data:null,error:new ke("rpId is required for WebAuthn authentication")};try{if(!Ut())return{data:null,error:new Z("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this.challenge({factorId:e,webauthn:{rpId:t,rpOrigins:r},signal:n},{request:i});if(!o)return{data:null,error:a};const{webauthn:l}=o;return this._verify({factorId:e,challengeId:o.challengeId,webauthn:{type:l.type,rpId:t,rpOrigins:r,credential_response:l.credential_response}})}catch(o){return m(o)?{data:null,error:o}:{data:null,error:new Z("Unexpected error in authenticate",o)}}}async _register({friendlyName:e,rpId:t=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:n},i){if(!t)return{data:null,error:new ke("rpId is required for WebAuthn registration")};try{if(!Ut())return{data:null,error:new Z("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this._enroll({friendlyName:e});if(!o)return await this.client.mfa.listFactors().then(c=>{var h;
39return(h=c.data)===null||h===void 0?void 0:h.all.find(d=>d.factor_type==="webauthn"&&d.friendly_name===e&&d.status!=="unverified")}).then(c=>c?this.client.mfa.unenroll({factorId:c==null?void 0:c.id}):void 0),{data:null,error:a};const{data:l,error:u}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:t,rpOrigins:r},signal:n},{create:i});return l?this._verify({factorId:o.id,challengeId:l.challengeId,webauthn:{rpId:t,rpOrigins:r,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:u}}catch(o){return m(o)?{data:null,error:o}:{data:null,error:new Z("Unexpected error in register",o)}}}}qn();const ii={url:Zs,storageKey:en,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:tn,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function Lt(s,e,t){return await t()}const le={};class Ee{get jwks(){var e,t;return(t=(e=le[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&t!==void 0?t:{keys:[]}}set jwks(e){le[this.storageKey]=Object.assign(Object.assign({},le[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return(t=(e=le[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&t!==void 0?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){le[this.storageKey]=Object.assign(Object.assign({},le[this.storageKey]),{cachedAt:e})}constructor(e){var t,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Ee.nextInstanceID,Ee.nextInstanceID+=1,this.instanceID>0&&$()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const n=Object.assign(Object.assign({},ii),e);if(this.logDebugMessages=!!n.debug,typeof n.debug=="function"&&(this.logger=n.debug),this.persistSession=n.persistSession,this.storageKey=n.storageKey,this.autoRefreshToken=n.autoRefreshToken,this.admin=new Nn({url:n.url,headers:n.headers,fetch:n.fetch}),this.url=n.url,this.headers=n.headers,this.fetch=lr(n.fetch),this.lock=n.lock||Lt,this.detectSessionInUrl=n.detectSessionInUrl,this.flowType=n.flowType,this.hasCustomAuthorizationHeader=n.hasCustomAuthorizationHeader,n.lock?this.lock=n.lock:$()&&(!((t=globalThis==null?void 0:globalThis.navigator)===null||t===void 0)&&t.locks)?this.lock=Bn:this.lock=Lt,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new ni(this)},this.persistSession?(n.storage?this.storage=n.storage:ar()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=xt(this.memoryStorage)),n.userStorage&&(this.userStorage=n.userStorage)):(this.memoryStorage={},this.storage=xt(this.memoryStorage)),$()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${nr}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{const t=wn(window.location.href);let r="none";if(this._isImplicitGrantCallback(t)?r="implicit":await this._isPKCECallback(t)&&(r="pkce"),$()&&this.detectSessionInUrl&&r!=="none"){const{data:n,error:i}=await this._getSessionFromURL(t,r);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),ln(i)){const l=(e=i.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:o,redirectType:a}=n;return this._debug("#_initialize()","detected session in URL",o,"redirect type",a),await this._saveSession(o),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(t){return m(t)?{error:t}:{error:new Z("Unexpected error during initialization",t)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,r,n;try{const i=await b(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(t=e==null?void 0:e.options)===null||t===void 0?void 0:t.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(n=e==null?void 0:e.options)===null||n===void 0?void 0:n.captchaToken}},xform:L}),{data:o,error:a}=i;if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(i){if(m(i))return{data:{user:null,session:null},error:i};throw i}}async signUp(e){var t,r,n;try{let i;if("email"in e){const{email:c,password:h,options:d}=e;let f=null,p=null;this.flowType==="pkce"&&([f,p]=await ie(this.storage,this.storageKey)),i=await b(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:d==null?void 0:d.emailRedirectTo,body:{email:c,password:h,data:(t=d==null?void 0:d.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:f,code_challenge_method:p},xform:L})}else if("phone"in e){const{phone:c,password:h,options:d}=e;i=await b(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:c,password:h,data:(r=d==null?void 0:d.data)!==null&&r!==void 0?r:{},channel:(n=d==null?void 0:d.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken}},xform:L})}else throw new Re("You must provide either an email or phone number and a password");const{data:o,error:a}=i;if(a||!o)return{data:{user:null,session:null},error:a};const l=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(i){if(m(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithPassword(e){try{let t;if("email"in e){const{email:i,password:o,options:a}=e;t=await b(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:It})}else if("phone"in e){const{phone:i,password:o,options:a}=e;t=await b(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:It})}else throw new Re("You must provide either an email or phone number and a password");const{data:r,error:n}=t;return n?{data:{user:null,session:null},error:n}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new ne}:(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:n})}catch(t){if(m(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOAuth(e){var t,r,n,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(n=e.options)===null||n===void 0?void 0:n.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:t}=e;switch(t){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${t}"`)}}async signInWithEthereum(e){var t,r,n,i,o,a,l,u,c,h,d;let f,p;if("message"in e)f=e.message,p=e.signature;else{const{chain:y,wallet:g,statement:_,options:w}=e;let v;if($())if(typeof g=="object")v=g;else{const B=window;if("ethereum"in B&&typeof B.ethereum=="object"&&"request"in B.ethereum&&typeof B.ethereum.request=="function")v=B.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof g!="object"||!(w!=null&&w.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");v=g}const k=new URL((t=w==null?void 0:w.url)!==null&&t!==void 0?t:window.location.href),C=await v.request({method:"eth_requestAccounts"}).then(B=>B).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!C||C.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const E=ur(C[0]);let R=(r=w==null?void 0:w.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!R){const B=await v.request({method:"eth_chainId"});R=Mn(B)}const K={domain:k.host,address:E,statement:_,uri:k.href,version:"1",chainId:R,nonce:(n=w==null?void 0:w.signInWithEthereum)===null||n===void 0?void 0:n.nonce,issuedAt:(o=(i=w==null?void 0:w.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(a=w==null?void 0:w.signInWithEthereum)===null||a===void 0?void 0:a.expirationTime,notBefore:(l=w==null?void 0:w.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(u=w==null?void 0:w.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(c=w==null?void 0:w.signInWithEthereum)===null||c===void 0?void 0:c.resources};f=Wn(K),p=await v.request({method:"personal_sign",params:[Fn(f),E]})}try{const{data:y,error:g}=await b(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:p}
39,!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(d=e.options)===null||d===void 0?void 0:d.captchaToken}}:null),xform:L});if(g)throw g;return!y||!y.session||!y.user?{data:{user:null,session:null},error:new ne}:(y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("SIGNED_IN",y.session)),{data:Object.assign({},y),error:g})}catch(y){if(m(y))return{data:{user:null,session:null},error:y};throw y}}async signInWithSolana(e){var t,r,n,i,o,a,l,u,c,h,d,f;let p,y;if("message"in e)p=e.message,y=e.signature;else{const{chain:g,wallet:_,statement:w,options:v}=e;let k;if($())if(typeof _=="object")k=_;else{const E=window;if("solana"in E&&typeof E.solana=="object"&&("signIn"in E.solana&&typeof E.solana.signIn=="function"||"signMessage"in E.solana&&typeof E.solana.signMessage=="function"))k=E.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof _!="object"||!(v!=null&&v.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");k=_}const C=new URL((t=v==null?void 0:v.url)!==null&&t!==void 0?t:window.location.href);
39if("signIn"in k&&k.signIn){const E=await k.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},v==null?void 0:v.signInWithSolana),{version:"1",domain:C.host,uri:C.href}),w?{statement:w}:null));let R;if(Array.isArray(E)&&E[0]&&typeof E[0]=="object")R=E[0];else if(E&&typeof E=="object"&&"signedMessage"in E&&"signature"in E)R=E;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in R&&"signature"in R&&(typeof R.signedMessage=="string"||R.signedMessage instanceof Uint8Array)&&R.signature instanceof Uint8Array)p=typeof R.signedMessage=="string"?R.signedMessage:new TextDecoder().decode(R.signedMessage),y=R.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in k)||typeof k.signMessage!="function"||!("publicKey"in k)||typeof k!="object"||!k.publicKey||!("toBase58"in k.publicKey)||typeof k.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");p=[`${C.host} wants you to sign in with your Solana account:`,k.publicKey.toBase58(),...w?["",w,""]:[""],"Version: 1",`URI: ${C.href}`,`Issued At: ${(n=(r=v==null?void 0:v.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&n!==void 0?n:new Date().toISOString()}`,...!((i=v==null?void 0:v.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${v.signInWithSolana.notBefore}`]:[],...!((o=v==null?void 0:v.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${v.signInWithSolana.expirationTime}`]:[],...!((a=v==null?void 0:v.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${v.signInWithSolana.chainId}`]:[],...!((l=v==null?void 0:v.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${v.signInWithSolana.nonce}`]:[],...!((u=v==null?void 0:v.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${v.signInWithSolana.requestId}`]:[],...!((h=(c=v==null?void 0:v.signInWithSolana)===null||c===void 0?void 0:c.resources)===null||h===void 0)&&h.length?["Resources",...v.signInWithSolana.resources.map(R=>`- ${R}`)]:[]].join(`
40`);const E=await k.signMessage(new TextEncoder().encode(p),"utf8");if(!E||!(E instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");y=E}}try{const{data:g,error:_}=await b(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:p,signature:ee(y)},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:L});if(_)throw _;return!g||!g.session||!g.user?{data:{user:null,session:null},error:new ne}:(g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("SIGNED_IN",g.session)),{data:Object.assign({},g),error:_})}catch(g){if(m(g))return{data:{user:null,session:null},error:g};throw g}}async _exchangeCodeForSession(e){const t=await Y(this.storage,`${this.storageKey}-code-verifier`),[r,n]=(t??"").split("/");try{const{data:i,error:o}=await b(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:L});if(await H(this.storage,`${this.storageKey}-code-verifier`),o)throw o;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new ne}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign(Object.assign({},i),{redirectType:n??null}),error:o})}catch(i){if(m(i))return{data:{user:null,session:null,redirectType:null},error:i};throw i}}async signInWithIdToken(e){try{const{options:t,provider:r,token:n,access_token:i,nonce:o}=e,a=await b(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:n,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:L}),{data:l,error:u}=a;return u?{data:{user:null,session:null},error:u}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new ne}:(l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:u})}catch(t){if(m(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOtp(e){var t,r,n,i,o;try{if("email"in e){const{email:a,options:l}=e;let u=null,c=null;this.flowType==="pkce"&&([u,c]=await ie(this.storage,this.storageKey));const{error:h}=await b(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(t=l==null?void 0:l.data)!==null&&t!==void 0?t:{},create_user:(r=l==null?void 0:l.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:u,code_challenge_method:c},redirectTo:l==null?void 0:l.emailRedirectTo});return{data:{user:null,session:null},error:h}}if("phone"in e){const{phone:a,options:l}=e,{data:u,error:c}=await b(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(n=l==null?void 0:l.data)!==null&&n!==void 0?n:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:c}}throw new Re("You must provide either an email or phone number.")}catch(a){if(m(a))return{data:{user:null,session:null},error:a};throw a}}async verifyOtp(e){var t,r;try{let n,i;"options"in e&&(n=(t=e.options)===null||t===void 0?void 0:t.redirectTo,i=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:o,error:a}=await b(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:n,xform:L});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,u=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:u,session:l},error:null}}catch(n){if(m(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithSSO(e){var t,r,n;try{let i=null,o=null;return this.flowType==="pkce"&&([i,o]=await ie(this.storage,this.storageKey)),await b(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(r=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&r!==void 0?r:void 0}),!((n=e==null?void 0:e.options)===null||n===void 0)&&n.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:o}),headers:this.headers,xform:$n})}catch(i){if(m(i))return{data:null,error:i};throw i}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:t},error:r}=e;if(r)throw r;if(!t)throw new G;const{error:n}=await b(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:n}})}catch(e){if(m(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const t=`${this.url}/resend`;if("email"in e){const{email:r,type:n,options:i}=e,{error:o}=await b(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in e){const{phone:r,type:n,options:i}=e,{data:o,error:a}=await b(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a}}throw new Re("You must provide either an email or phone number and a type")}catch(t){if(m(t))return{data:{user:null,session:null},error:t};throw t}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async t=>t))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await r,await t()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=t();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const t=await Y(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not val
40id"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<Ke:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const o=await Y(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=ze()}if(this.storage.isServer&&e.user){let o=this.suppressGetSessionWarning;e=new Proxy(e,{get:(l,u,c)=>(!o&&u==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),o=!0,this.suppressGetSessionWarning=!0),Reflect.get(l,u,c))})}return{data:{session:e},error:null}}const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{session:null},error:i}:{data:{session:n},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await b(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:z}):await this._useSession(async t=>{var r,n,i;const{data:o,error:a}=t;if(a)throw a;return!(!((r=o.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new G}:await b(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0,xform:z})})}catch(t){if(m(t))return an(t)&&(await this._removeSession(),await H(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:t};throw t}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async r=>{const{data:n,error:i}=r;if(i)throw i;if(!n.session)throw new G;const o=n.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await ie(this.storage,this.storageKey));const{data:u,error:c}=await b(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:z});if(c)throw c;return o.user=u.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),{data:{user:o.user},error:null}})}catch(r){if(m(r))return{data:{user:null},error:r};throw r}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new G;const t=Date.now()/1e3;let r=t,n=!0,i=null;const{payload:o}=Ge(e.access_token);if(o.exp&&(r=o.exp,n=r<=t),n){const{data:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)throw l;i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:r-t,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(t){if(m(t))return{data:{session:null,user:null},error:t};throw t}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async t=>{var r;if(!e){const{data:o,error:a}=t;if(a)throw a;e=(r=o.session)!==null&&r!==void 0?r:void 0}if(!(e!=null&&e.refresh_token))throw new G;const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:n?{data:{user:n.user,session:n},error:null}:{data:{user:null,session:null},error:null}})}catch(t){if(m(t))return{data:{user:null,session:null},error:t};throw t}}async _getSessionFromURL(e,t){try{if(!$())throw new je("No browser detected.");
40if(e.error||e.error_description||e.error_code)throw new je(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if(this.flowType==="pkce")throw new Ot("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new je("Not a valid implicit grant flow url.");break;default:}if(t==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Ot("No code detected.");const{data:w,error:v}=await this._exchangeCodeForSession(e.code);if(v)throw v;const k=new URL(window.location.href);return k.searchParams.delete("code"),window.history.replaceState(window.history.state,"",k.toString()),{data:{session:w.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:n,access_token:i,refresh_token:o,expires_in:a,expires_at:l,token_type:u}=e;if(!i||!a||!o||!u)throw new je("No session defined in URL");const c=Math.round(Date.now()/1e3),h=parseInt(a);let d=c+h;l&&(d=parseInt(l));const f=d-c;f*1e3<=ce&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${h}s`);const p=d-h;c-p>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",p,d,c):c-p<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",p,d,c);const{data:y,error:g}=await this._getUser(i);if(g)throw g;const _={provider_token:r,provider_refresh_token:n,access_token:i,expires_in:h,expires_at:d,refresh_token:o,token_type:u,user:y.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:_,redirectType:e.type},error:null}}catch(r){if(m(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const t=await Y(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var r;const{data:n,error:i}=t;if(i)return{error:i};const o=(r=n.session)===null||r===void 0?void 0:r.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(on(a)&&(a.status===404||a.status===401||a.status===403)))return{error:a}}return e!=="others"&&(await this._removeSession(),await H(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const t=pn(),r={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,r),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async t=>{var r,n;try{const{data:{session:i},error:o}=t;if(o)throw o;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),console.error(i)}})}async resetPasswordForEmail(e,t={}){let r=null,n=null;this.flowType==="pkce"&&([r,n]=await ie(this.storage,this.storageKey,!0));try{return await b(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:n,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(i){if(m(i))return{data:null,error:i};throw i}}async getUserIdentities(){var e;try{const{data:t,error:r}=await this.getUser();if(r)throw r;return{data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(t){if(m(t))return{data:null,error:t};throw t}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var t;try{const{data:r,error:n}=await this._useSession(async i=>{var o,a,l,u,c;const{data:h,error:d}=i;if(d)throw d;const f=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await b(this.fetch,"GET",f,{headers:this.headers,jwt:(c=(u=h.session)===null||u===void 0?void 0:u.access_token)!==null&&c!==void 0?c:void 0})});if(n)throw n;return $()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),{data:{provider:e.provider,url:r==null?void 0:r.url},error:null}}catch(r){if(m(r))return{data:{provider:e.provider,url:null},error:r};throw r}}async linkIdentityIdToken(e){return await this._useSession(async t=>{var r;try{const{error:n,data:{session:i}}=t;if(n)throw n;const{options:o,provider:a,token:l,access_token:u,nonce:c}=e,h=await b(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=i==null?void 0:i.access_token)!==null&&r!==void 0?r:void 0,body:{provider:a,id_token:l,access_token:u,nonce:c,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:L}),{data:d,error:f}=h;return f?{data:{user:null,session:null},error:f}:!d||!d.session||!d.user?{data:{user:null,session:null},error:new ne}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("USER_UPDATED",d.session)),{data:d,error:f})}catch(n){if(m(n))return{data:{user:null,session:null},error:n};throw n}})}async unlinkIdentity(e){try{return await this._useSession(async t=>{var r,n;const{data:i,error:o}=t;if(o)throw o;
40return await b(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(r=i.session)===null||r===void 0?void 0:r.access_token)!==null&&n!==void 0?n:void 0})})}catch(t){if(m(t))return{data:null,error:t};throw t}}async _refreshAccessToken(e){const t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{const r=Date.now();return await yn(async n=>(n>0&&await vn(200*Math.pow(2,n-1)),this._debug(t,"refreshing attempt",n),await b(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:L})),(n,i)=>{const o=200*Math.pow(2,n);return i&&He(i)&&Date.now()+o-r<ce})}catch(r){if(this._debug(t,"error",r),m(r))return{data:{session:null,user:null},error:r};throw r}finally{this._debug(t,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",r),$()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,t;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const n=await Y(this.storage,this.storageKey);if(n&&this.userStorage){let o=await Y(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:n.user},await ue(this.userStorage,this.storageKey+"-user",o)),n.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:ze()}else if(n&&!n.user&&!n.user){const o=await Y(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(n.user=o.user,await H(this.storage,this.storageKey+"-user"),await ue(this.storage,this.storageKey,n)):n.user=ze()}if(this._debug(r,"session from storage",n),!this._isValidSession(n)){this._debug(r,"session is not valid"),n!==null&&await this._removeSession();return}const i=((t=n.expires_at)!==null&&t!==void 0?t:1/0)*1e3-Date.now()<Ke;if(this._debug(r,`session has${i?"":" not"} expired with margin of ${Ke}s`),i){if(this.autoRefreshToken&&n.refresh_token){const{error:o}=await this._callRefreshToken(n.refresh_token);o&&(console.error(o),He(o)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(n.user&&n.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:a}=await this._getUser(n.access_token);!a&&(o!=null&&o.user)?(n.user=o.user,await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(r,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(r,"error",n),console.error(n);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new G;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const n=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{this.refreshingDeferred=new qe;const{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new G;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const a={data:i.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(i){if(this._debug(n,"error",i),m(i)){const o={data:null,error:i};return He(i)||await this._removeSession(),(t=this.refreshingDeferred)===null||t===void 0||t.resolve(o),o}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(i),i}finally{this.refreshingDeferred=null,this._debug(n,"end")}}async _notifyAllSubscribers(e,t,r=!0){const n=`#_notifyAllSubscribers(${e})`;this._debug(n,"begin",t,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,t)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;a<i.length;a+=1)console.error(i[a]);throw i[0]}}finally{this._debug(n,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;const t=Object.assign({},e),r=t.user&&t.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&t.user&&await ue(this.userStorage,this.storageKey+"-user",{user:t.user});const n=Object.assign({},t);delete n.user;const i=Ct(n);await ue(this.storage,this.storageKey,i)}else{const n=Ct(t);await ue(this.storage,this.storageKey,n)}}async _removeSession(){this._debug("#_removeSession()"),await H(this.storage,this.storageKey),await H(this.storage,this.storageKey+"-code-verifier"),await H(this.storage,this.storageKey+"-user"),this.userStorage&&await H(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&$()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}
40catch(t){console.error("removing visibilitychange callback failed",t)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),ce);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async t=>{const{data:{session:r}}=t;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((r.expires_at*1e3-e)/ce);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${ce}ms, refresh threshold is ${st} ticks`),n<=st&&await this._callRefreshToken(r.refresh_token)})}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof cr)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!$()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,r){const n=[`provider=${encodeURIComponent(t)}`];if(r!=null&&r.redirectTo&&n.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r!=null&&r.scopes&&n.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[i,o]=await ie(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});n.push(a.toString())}if(r!=null&&r.queryParams){const i=new URLSearchParams(r.queryParams);n.push(i.toString())}return r!=null&&r.skipBrowserRedirect&&n.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${n.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var r;const{data:n,error:i}=t;return i?{data:null,error:i}:await b(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token})})}catch(t){if(m(t))return{data:null,error:t};throw t}}async _enroll(e){try{return await this._useSession(async t=>{var r,n;const{data:i,error:o}=t;if(o)return{data:null,error:o};const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:u}=await b(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token});return u?{data:null,error:u}:(e.factorType==="totp"&&l.type==="totp"&&(!((n=l==null?void 0:l.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),{data:l,error:null})})}catch(t){if(m(t))return{data:null,error:t};throw t}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;const{data:n,error:i}=t;if(i)return{data:null,error:i};const o=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?Yn(e.webauthn.credential_response):Qn(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:l}=await b(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});return l?{data:null,error:l}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),{data:a,error:l})})}catch(t){if(m(t))return{data:null,error:t};throw t}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;const{data:n,error:i}=t;if(i)return{data:null,error:i};const o=await b(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});if(o.error)return o;const{data:a}=o;if(a.type!=="webauthn")return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:Jn(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:Vn(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(t){if(m(t))return{data:null,error:t};throw t}})}async _challengeAndVerify(e){const{data:t,error:r}=await this._challenge({factorId:e.factorId});return r?{data:null,error:r}:await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){var e;const{data:{user:t},error:r}=await this.getUser();if(r)return{data:null,error:r};const n={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=t==null?void 0:t.factors)!==null&&e!==void 0?e:[])n.all.push(i),i.status==="verified"&&n[i.factor_type].push(i);return{data:n,error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,r;const{data:{session:n},error:i}=e;if(i)return{data:null,error:i};if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=Ge(n.access_token);let a=null;o.aal&&(a=o.aal);let l=a;((r=(t=n.user.factors)===null||t===void 0?void 0:t.filter(h=>h.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(l="aal2");const c=o.amr||[];return{data:{currentLevel:a,nextLevel:l,currentAuthenticationMethods:c},error:null}}))}async fetchJwk(e,t={keys:[]}){let r=t.keys.find(a=>a.kid===e);if(r)return r;const n=Date.now();if(r=this.jwks.keys.find(a=>a.kid===e),r&&this.jwks_cached_at+sn>n)return r;const{data:i,error:o}=await b(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=n,r=i.keys.find(a=>a.kid===e),!r)?null:r}async getClaims(e,t={}){try{let r=e;if(!r){const{data:f,error:p}
40=await this.getSession();if(p||!f.session)return{data:null,error:p};r=f.session.access_token}const{header:n,payload:i,signature:o,raw:{header:a,payload:l}}=Ge(r);t!=null&&t.allowExpired||Tn(i.exp);const u=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,t!=null&&t.keys?{keys:t.keys}:t==null?void 0:t.jwks);if(!u){const{error:f}=await this.getUser(r);if(f)throw f;return{data:{claims:i,header:n,signature:o},error:null}}const c=An(n.alg),h=await crypto.subtle.importKey("jwk",u,c,!0,["verify"]);if(!await crypto.subtle.verify(c,h,o,fn(`${a}.${l}`)))throw new ot("Invalid JWT signature");return{data:{claims:i,header:n,signature:o},error:null}}catch(r){if(m(r))return{data:null,error:r};throw r}}}Ee.nextInstanceID=0;const oi=Ee;class ai extends oi{constructor(e){super(e)}}var li=function(s,e,t,r){function n(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(c){try{u(r.next(c))}catch(h){o(h)}}function l(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?i(c.value):n(c.value).then(a,l)}u((r=r.apply(s,e||[])).next())})};class ci{constructor(e,t,r){var n,i,o;this.supabaseUrl=e,this.supabaseKey=t;const a=Xs(e);if(!t)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",a),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",a),this.storageUrl=new URL("storage/v1",a),this.functionsUrl=new URL("functions/v1",a);const l=`sb-${a.hostname.split(".")[0]}-auth-token`,u={db:Fs,realtime:Ks,auth:Object.assign(Object.assign({},Ws),{storageKey:l}),global:Ms},c=Qs(r??{},u);this.storageKey=(n=c.auth.storageKey)!==null&&n!==void 0?n:"",this.headers=(i=c.global.headers)!==null&&i!==void 0?i:{},c.accessToken?(this.accessToken=c.accessToken,this.auth=new Proxy({},{get:(h,d)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(d)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((o=c.auth)!==null&&o!==void 0?o:{},this.headers,c.global.fetch),this.fetch=Js(t,this._getAccessToken.bind(this),c.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},c.realtime)),this.rest=new ns(new URL("rest/v1",a).href,{headers:this.headers,schema:c.db.schema,fetch:this.fetch}),this.storage=new Ds(this.storageUrl.href,this.headers,this.fetch,r==null?void 0:r.storage),c.accessToken||this._listenForAuthEvents()}get functions(){return new Lr(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,t,r)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){return li(this,void 0,void 0,function*(){var e,t;if(this.accessToken)return yield this.accessToken();const{data:r}=yield this.auth.getSession();return(t=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:this.supabaseKey})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,userStorage:i,storageKey:o,flowType:a,lock:l,debug:u},c,h){const d={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new ai({url:this.authUrl.href,headers:Object.assign(Object.assign({},d),c),storageKey:o,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,userStorage:i,flowType:a,lock:l,debug:u,fetch:h,hasCustomAuthorizationHeader:Object.keys(this.headers).some(f=>f.toLowerCase()==="authorization")})}_initRealtimeClient(e){return new bs(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,r)=>{this._handleTokenChanged(t,"CLIENT",r==null?void 0:r.access_token)})}_handleTokenChanged(e,t,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):e==="SIGNED_OUT"&&(this.realtime.setAuth(),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const fr=(s,e,t)=>new ci(s,e,t);function ui(){if(typeof window<"u"||typeof process>"u")return!1;const s=process.version;if(s==null)return!1;const e=s.match(/^v(\d+)\./);return e?parseInt(e[1],10)<=18:!1}ui()&&console.warn("⚠️  Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to N
40ode.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const gr="0.5.2";/*!
41 * cookie
42 * Copyright(c) 2012-2014 Roman Shtylman
43 * Copyright(c) 2015 Douglas Christopher Wilson
44 * MIT Licensed
45 */var hi=yi,di=mi,fi=Object.prototype.toString,gi=Object.prototype.hasOwnProperty,pi=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,wi=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,_i=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,vi=/^[\u0020-\u003A\u003D-\u007E]*$/;function yi(s,e){if(typeof s!="string")throw new TypeError("argument str must be a string");var t={},r=s.length;if(r<2)return t;var n=e&&e.decode||bi,i=0,o=0,a=0;do{if(o=s.indexOf("=",i),o===-1)break;if(a=s.indexOf(";",i),a===-1)a=r;else if(o>a){i=s.lastIndexOf(";",o-1)+1;continue}var l=Nt(s,i,o),u=Dt(s,o,l),c=s.slice(l,u);if(!gi.call(t,c)){var h=Nt(s,o+1,a),d=Dt(s,a,h);s.charCodeAt(h)===34&&s.charCodeAt(d-1)===34&&(h++,d--);var f=s.slice(h,d);t[c]=Ei(f,n)}i=a+1}while(i<r);return t}function Nt(s,e,t){do{var r=s.charCodeAt(e);if(r!==32&&r!==9)return e}while(++e<t);return t}function Dt(s,e,t){for(;e>t;){var r=s.charCodeAt(--e);if(r!==32&&r!==9)return e+1}return t}function mi(s,e,t){var r=t&&t.encode||encodeURIComponent;if(typeof r!="function")throw new TypeError("option encode is invalid");if(!pi.test(s))throw new TypeError("argument name is invalid");var n=r(e);if(!wi.test(n))throw new TypeError("argument val is invalid");var i=s+"="+n;if(!t)return i;if(t.maxAge!=null){var o=Math.floor(t.maxAge);if(!isFinite(o))throw new TypeError("option maxAge is invalid");i+="; Max-Age="+o}if(t.domain){if(!_i.test(t.domain))throw new TypeError("option domain is invalid");i+="; Domain="+t.domain}if(t.path){if(!vi.test(t.path))throw new TypeError("option path is invalid");i+="; Path="+t.path}if(t.expires){var a=t.expires;if(!ki(a)||isNaN(a.valueOf()))throw new TypeError("option expires is invali
45d");i+="; Expires="+a.toUTCString()}if(t.httpOnly&&(i+="; HttpOnly"),t.secure&&(i+="; Secure"),t.partitioned&&(i+="; Partitioned"),t.priority){var l=typeof t.priority=="string"?t.priority.toLowerCase():t.priority;switch(l){case"low":i+="; Priority=Low";break;case"medium":i+="; Priority=Medium";break;case"high":i+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(t.sameSite){var u=typeof t.sameSite=="string"?t.sameSite.toLowerCase():t.sameSite;switch(u){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return i}function bi(s){return s.indexOf("%")!==-1?decodeURIComponent(s):s}function ki(s){return fi.call(s)==="[object Date]"}function Ei(s,e){try{return e(s)}catch{return s}}function fe(){return typeof window<"u"&&typeof window.document<"u"}const te={path:"/",sameSite:"lax",httpOnly:!1,maxAge:400*24*60*60},Si=3180,Oi=/^(.*)[.](0|[1-9][0-9]*)$/;function xe(s,e){if(s===e)return!0;const t=s.match(Oi);return!!(t&&t[1]===e)}function pr(s,e,t){const r=Si;let n=encodeURIComponent(e);if(n.length<=r)return[{name:s,value:e}];const i=[];for(;n.length>0;){let o=n.slice(0,r);const a=o.lastIndexOf("%");a>r-3&&(o=o.slice(0,a));let l="";for(;o.length>0;)try{l=decodeURIComponent(o);break}catch(u){if(u instanceof URIError&&o.at(-3)==="%"&&o.length>3)o=o.slice(0,o.length-3);else throw u}i.push(l),n=n.slice(o.length)}return i.map((o,a)=>({name:`${s}.${a}`,value:o}))}async function Bt(s,e){const t=await e(s);if(t)return t;let r=[];for(let n=0;;n++){const i=`${s}.${n}`,o=await e(i);if(!o)break;r.push(o)}return r.length>0?r.join(""):null}const Ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),qt=` 	
46\r=`.split(""),Ti=(()=>{const s=new Array(128);for(let e=0;e<s.length;e+=1)s[e]=-1;for(let e=0;e<qt.length;e+=1)s[qt[e].charCodeAt(0)]=-2;for(let e=0;e<Ue.length;e+=1)s[Ue[e].charCodeAt(0)]=e;return s})();function wr(s){const e=[];let t=0,r=0;if(Ri(s,i=>{for(t=t<<8|i,r+=8;r>=6;){const o=t>>r-6&63;e.push(Ue[o]),r-=6}}),r>0)for(t=t<<6-r,r=6;r>=6;){const i=t>>r-6&63;e.push(Ue[i]),r-=6}return e.join("")}function Mt(s){const e=[],t=o=>{e.push(String.fromCodePoint(o))},r={utf8seq:0,codepoint:0};let n=0,i=0;for(let o=0;o<s.length;o+=1){const a=s.charCodeAt(o),l=Ti[a];if(l>-1)for(n=n<<6|l,i+=6;i>=8;)ji(n>>i-8&255,r,t),i-=8;else{if(l===-2)continue;throw new Error(`Invalid Base64-URL character "${s.at(o)}" at position ${o}`)}}return e.join("")}function Ai(s,e){if(s<=127){e(s);return}else if(s<=2047){e(192|s>>6),e(128|s&63);return}else if(s<=65535){e(224|s>>12),e(128|s>>6&63),e(128|s&63);return}else if(s<=1114111){e(240|s>>18),e(128|s>>12&63),e(128|s>>6&63),e(128|s&63);return}throw new Error(`Unrecognized Unicode codepoint: ${s.toString(16)}`)}function Ri(s,e){for(let t=0;t<s.length;t+=1){let r=s.charCodeAt(t);if(r>55295&&r<=56319){const n=(r-55296)*1024&65535;r=(s.charCodeAt(t+1)-56320&65535|n)+65536,t+=1}Ai(r,e)}}function ji(s,e,t){if(e.utf8seq===0){if(s<=127){t(s);return}for(let r=1;r<6;r+=1)if(!(s>>7-r&1)){e.utf8seq=r;break}if(e.utf8seq===2)e.codepoint=s&31;else if(e.utf8seq===3)e.codepoint=s&15;else if(e.utf8seq===4)e.codepoint=s&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(s<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|s&63,e.utf8seq-=1,e.utf8seq===0&&t(e.codepoint)}}const he="base64-";function _r(s,e){const t=s.cookies??null,r=s.cookieEncoding,n={},i={};let o,a;if(t)if("get"in t){const l=async u=>{const c=u.flatMap(d=>[d,...Array.from({length:5}).map((f,p)=>`${d}.${p}`)]),h=[];for(let d=0;d<c.length;d+=1){const f=await t.get(c[d]);!f&&typeof f!="string"||h.push({name:c[d],value:f})}return h};if(o=async u=>await l(u),"set"in t&&"remove"in t)a=async u=>{for(let c=0;c<u.length;c+=1){const{name:h,value:d,options:f}=u[c];d?await t.set(h,d,f):await t.remove(h,f)}};else if(e)a=async()=>{console.warn("@supabase/ssr: createServerClient was configured without set and remove cookie methods, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for c
46orrectness. Consider switching to the getAll and setAll cookie methods instead of get, set and remove which are deprecated and can be difficult to use correctly.")};else throw new Error("@supabase/ssr: createBrowserClient requires configuring a getAll and setAll cookie method (deprecated: alternatively both get, set and remove can be used)")}else if("getAll"in t)if(o=async()=>await t.getAll(),"setAll"in t)a=t.setAll;else if(e)a=async()=>{console.warn("@supabase/ssr: createServerClient was configured without the setAll cookie method, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness.")};else throw new Error("@supabase/ssr: createBrowserClient requires configuring both getAll and setAll cookie methods (deprecated: alternatively both get, set and remove can be used)");else throw new Error(`@supabase/ssr: ${e?"createServerClient":"createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).${fe()?" As this is called in a browser runtime, consider removing the cookies option object to use the document.cookie API automatically.":""}`);else if(!e&&fe()){const l=()=>{const u=hi(document.cookie);return Object.keys(u).map(c=>({name:c,value:u[c]}))};o=()=>l(),a=u=>{u.forEach(({name:c,value:h,options:d})=>{document.cookie=di(c,h,d)})}}else{if(e)throw new Error("@supabase/ssr: createServerClient must be initialized with cookie options that specify getAll and setAll functions (deprecated, not recommended: alternatively use get, set and remove)");o=()=>[],a=()=>{throw new Error("@supabase/ssr: createBrowserClient in non-browser runtimes (including Next.js pre-rendering mode) was not initialized cookie options that specify getAll and setAll functions (deprecated: alternatively use get, set and remove), but they were needed")}}return e?{getAll:o,setAll:a,setItems:n,removedItems:i,storage:{isServer:!0,getItem:async l=>{if(typeof n[l]=="string")return n[l];if(i[l])return null;const u=await o([l]),c=await Bt(l,async d=>{const f=(u==null?void 0:u.find(({name:p})=>p===d))||null;return f?f.value:null});if(!c)return null;let h=c;return typeof c=="string"&&c.startsWith(he)&&(h=Mt(c.substring(he.length))),h},setItem:async(l,u)=>{l.endsWith("-code-verifier")&&await vr({getAll:o,setAll:a,setItems:{[l]:u},removedItems:{}},{cookieOptions:(s==null?void 0:s.cookieOptions)??null,cookieEncoding:r}),n[l]=u,delete i[l]},removeItem:async l=>{delete n[l],i[l]=!0}}}:{getAll:o,setAll:a,setItems:n,removedItems:i,storage:{isServer:!1,getItem:async l=>{const u=await o([l]),c=await Bt(l,async d=>{const f=(u==null?void 0:u.find(({name:p})=>p===d))||null;return f?f.value:null});if(!c)return null;let h=c;return c.startsWith(he)&&(h=Mt(c.substring(he.length))),h},setItem:async(l,u)=>{const c=await o([l]),h=(c==null?void 0:c.map(({name:w})=>w))||[],d=new Set(h.filter(w=>xe(w,l)));let f=u;r==="base64url"&&(f=he+wr(u));const p=pr(l,f);p.forEach(({name:w})=>{d.delete(w)});const y={...te,...s==null?void 0:s.cookieOptions,maxAge:0},g={...te,...s==null?void 0:s.cookieOptions,maxAge:te.maxAge};delete y.name,delete g.name;const _=[...[...d].map(w=>({name:w,value:"",options:y})),...p.map(({name:w,value:v})=>({name:w,value:v,options:g}))];_.length>0&&await a(_)},removeItem:async l=>{const u=await o([l]),h=((u==null?void 0:u.map(({name:f})=>f))||[]).filter(f=>xe(f,l)),d={...te,...s==null?void 0:s.cookieOptions,maxAge:0};delete d.name,h.length>0&&await a(h.map(f=>({name:f,value:"",options:d})))}}}}async function vr({getAll:s,setAll:e,setItems:t,removedItems:r},n){const i=n.cookieEncoding,o=n.cookieOptions??null,a=await s([...t?Object.keys(t):[],...r?Object.keys(r):[]]),l=(a==null?void 0:a.map(({name:f})=>f))||[],u=Object.keys(r).flatMap(f=>l.filter(p=>xe(p,f))),c=Object.keys(t).flatMap(f=>{const p=new Set(l.filter(_=>xe(_,f)));let y=t[f];i==="base64url"&&(y=he+wr(y));const g=pr(f,y);return g.forEach(_=>{p.delete(_.name)}),u.push(...p),g}),h={...te,...o,maxAge:0},d={...te,...o,maxAge:te.maxAge};delete h.name,delete d.name,await e([...u.map(f=>({name:f,value:"",options:h})),...c.map(({name:f,value:p})=>({name:f,value:p,options:d}))])}let Ve;function Ci(s,e,t){var o,a;const r=(t==null?void 0:t.isSingleton)===!0||(!t||!("isSingleton"in t))&&fe();if(r&&Ve)return Ve;const{storage:n}
46=_r({...t,cookieEncoding:(t==null?void 0:t.cookieEncoding)??"base64url"},!1),i=fr(s,e,{...t,global:{...t==null?void 0:t.global,headers:{...(o=t==null?void 0:t.global)==null?void 0:o.headers,"X-Client-Info":`supabase-ssr/${gr}`}},auth:{...t==null?void 0:t.auth,...(a=t==null?void 0:t.cookieOptions)!=null&&a.name?{storageKey:t.cookieOptions.name}:null,flowType:"pkce",autoRefreshToken:fe(),detectSessionInUrl:fe(),persistSession:!0,storage:n}});return r&&(Ve=i),i}function Pi(s,e,t){var u,c;const{storage:r,getAll:n,setAll:i,setItems:o,removedItems:a}=_r({...t,cookieEncoding:(t==null?void 0:t.cookieEncoding)??"base64url"},!0),l=fr(s,e,{...t,global:{...t==null?void 0:t.global,headers:{...(u=t==null?void 0:t.global)==null?void 0:u.headers,"X-Client-Info":`supabase-ssr/${gr}`}},auth:{...(c=t==null?void 0:t.cookieOptions)!=null&&c.name?{storageKey:t.cookieOptions.name}:null,...t==null?void 0:t.auth,flowType:"pkce",autoRefreshToken:!1,detectSessionInUrl:!1,persistSession:!0,storage:r}});return l.auth.onAuthStateChange(async h=>{(Object.keys(o).length>0||Object.keys(a).length>0)&&(h==="SIGNED_IN"||h==="TOKEN_REFRESHED"||h==="USER_UPDATED"||h==="PASSWORD_RECOVERY"||h==="SIGNED_OUT"||h==="MFA_CHALLENGE_VERIFIED")&&await vr({getAll:n,setAll:i,setItems:o,removedItems:a},{cookieOptions:(t==null?void 0:t.cookieOptions)??null,cookieEncoding:(t==null?void 0:t.cookieEncoding)??"base64url"})}),l}const Ii=60*60*24*90;function $i(s,e){document.cookie=`${s}=${encodeURIComponent(e)}; Path=/; Max-Age=${Ii}; SameSite=Lax`}const xi=async({url:s,data:e,depends:t,fetch:r})=>{var c;mr.init("phc_5NmQl3rIOUm4DfgssRopS5uEZRCJl9of6KV2eDosOjb",{api_host:"https://p.ladu.co",defaults:"2026-01-30",person_profiles:"always",capture_pageview:"history_change"});let n=null,i=null,o=null,a=null,l=null;n=s.searchParams.get("utm_medium"),i=s.searchParams.get("utm_source"),o=s.searchParams.get("utm_campaign"),a=s.searchParams.get("utm_content"),l=s.searchParams.get("utm_term");{const h=document.referrer;[["utm_medium",n],["utm_source",i],["utm_campaign",o],["utm_content",a],["utm_term",l],["referring_domain",h]].forEach(([f,p])=>{p&&$i(f,p)})}t("supabase:auth");const u=fe()?Ci(dt,ht,{global:{fetch:r}}):Pi(dt,ht,{global:{fetch:r},cookies:{getAll(){return e.cookies}}});return{session:e.session,supabase:u,user:((c=e.session)==null?void 0:c.user)??null}},so=Object.freeze(Object.defineProperty({__proto__:null,load:xi},Symbol.toStringTag,{value:"Module"})),Ui=""+new URL("../assets/nunito-sans-latin-wght-italic.B3URO7Ca.woff2",import.meta.url).href,Li=""+new URL("../assets/nunito-sans-latin-wght-normal.BWQ3gi2K.woff2",import.meta.url).href;function Ni(s){let e,t,r,n,i=`(function (e, t, o, n, p, r, i) {
47      e.visitorGlobalObjectAlias = n;
48      e[e.visitorGlobalObjectAlias] =
49        e[e.visitorGlobalObjectAlias] ||
50        function () {
51          (e[e.visitorGlobalObjectAlias].q =
52            e[e.visitorGlobalObjectAlias].q || []).push(arguments);
53        };
54      e[e.visitorGlobalObjectAlias].l = new Date().getTime();
55      r = t.createElement("script");
56      r.src = o;
57      r.async = true;
58      i = t.getElementsByTagName("script")[0];
59      i.parentNode.insertBefore(r, i);
60    })(
61      window,
62      document,
63      "https://diffuser-cdn.app-us1.com/diffuser/diffuser.js",
64      "vgo",
65    );
66    vgo("setAccount", "1003205358");
67    vgo("setTrackByDefault", true);
68    vgo("process");
69  `,o,a,l,u,c,h=`window.dataLayer = window.dataLayer || [];
70    (function () {
71      function injectGtm() {
72        (function (w, d, s, l, i) {
73          w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
74          var f = d.getElementsByTagName(s)[0],
75            j = d.createElement(s),
76            dl = l != "dataLayer" ? "&l=" + l : "";
77          j.async = true;
78          j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
79          f.parentNode.insertBefore(j, f);
80        })(window, document, "script", "dataLayer", "GTM-TRWJ2MBC");
81      }
82      if ("requestIdleCallback" in window) {
83        requestIdleCallback(injectGtm, { timeout: 4000 });
84      } else {
85        window.addEventListener("load", injectGtm);
86      }
87    })();`,d,f,p;const y=s[2].default,g=Sr(y,s,s[1],null);return{c(){e=F("link"),t=F("link"),r=F("link"),n=F("script"),n.textContent=i,o=F("link"),a=F("link"),l=F("link"),u=F("link"),
87c=F("script"),c.textContent=h,d=wt(),f=wt(),g&&g.c(),this.h()},l(_){const w=Cr("svelte-17snc1e",document.head);e=M(w,"LINK",{rel:!0,href:!0,as:!0,type:!0,crossorigin:!0}),t=M(w,"LINK",{rel:!0,href:!0,as:!0,type:!0,crossorigin:!0}),r=M(w,"LINK",{rel:!0,href:!0,crossorigin:!0}),n=M(w,"SCRIPT",{"data-svelte-h":!0}),gt(n)!=="svelte-zgvmuk"&&(n.textContent=i),o=M(w,"LINK",{rel:!0,href:!0}),a=M(w,"LINK",{rel:!0,href:!0,crossorigin:!0}),l=M(w,"LINK",{rel:!0,href:!0}),u=M(w,"LINK",{rel:!0,href:!0,crossorigin:!0}),c=M(w,"SCRIPT",{"data-svelte-h":!0}),gt(c)!=="svelte-oxnty6"&&(c.textContent=h),w.forEach(x),d=pt(_),f=pt(_),g&&g.l(_),this.h()},h(){O(e,"rel","preload"),O(e,"href",Li),O(e,"as","font"),O(e,"type","font/woff2"),O(e,"crossorigin","anonymous"),O(t,"rel","preload"),O(t,"href",Ui),O(t,"as","font"),O(t,"type","font/woff2"),O(t,"crossorigin","anonymous"),O(r,"rel","dns-prefetch"),O(r,"href","https://diffuser-cdn.app-us1.com"),O(r,"crossorigin","anonymous"),O(o,"rel","preconnect"),O(o,"href","https://us.i.posthog.com"),O(a,"rel","dns-prefetch"),O(a,"href","https://us.i.posthog.com"),O(a,"crossorigin","anonymous"),O(l,"rel","preconnect"),O(l,"href","https://www.googletagmanager.com"),O(u,"rel","dns-prefetch"),O(u,"href","https://www.googletagmanager.com"),O(u,"crossorigin","anonymous")},m(_,w){q(document.head,e),q(document.head,t),q(document.head,r),q(document.head,n),q(document.head,o),q(document.head,a),q(document.head,l),q(document.head,u),q(document.head,c),ft(_,d,w),ft(_,f,w),g&&g.m(_,w),p=!0},p(_,[w]){g&&g.p&&(!p||w&2)&&Ar(g,y,_,_[1],p?jr(y,_[1],w,null):Rr(_[1]),null)},i(_){p||(Tr(g,_),p=!0)},o(_){Or(g,_),p=!1},d(_){_&&(x(d),x(f)),x(e),x(t),x(r),x(n),x(o),x(a),x(l),x(u),x(c),g&&g.d(_)}}}function Di(s,e,t){let r,n,{$$slots:i={},$$scope:o}=e,{data:a}=e;return Pr(()=>{const{data:l}=n.auth.onAuthStateChange((u,c)=>{(c==null?void 0:c.expires_at)!==(r==null?void 0:r.expires_at)&&Ir("supabase:auth")});return()=>l.subscription.unsubscribe()}),$r(()=>{var u,c;console.log("afterNavigate");const l=window.vgo;typeof l=="function"&&(console.log("session?.user?.email",(u=r==null?void 0:r.user)==null?void 0:u.email),(c=r==null?void 0:r.user)!=null&&c.email&&l("setEmail",r.user.email),l("process"))}),s.$$set=l=>{"data"in l&&t(0,a=l.data),"$$scope"in l&&t(1,o=l.$$scope)},s.$$.update=()=>{s.$$.dirty&1&&({session:r,supabase:n}=a)},[a,o,i]}class no extends br{constructor(e){super(),kr(this,e,Di,Ni,Er,{data:0})}}export{no as component,so as universal};

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.