PageSourceSearch

https://brightonseo.com/_next/static/chunks/4927-f773b56264886198.js?dpl=dpl_5TPawbRudeLcFHpdjHjU8TKQai9x

js brightonseo.com collected 2026-09-24 08:52:50 UTC 146,898 bytes, 25 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4927],{54:(e,t,s)=>{var r=s(13127),i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},n=r.useState,a=r.useEffect,o=r.useLayoutEffect,l=r.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!i(e,s)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var s=t(),r=n({inst:{value:s,getSnapshot:t}}),i=r[0].inst,c=r[1];return o(function(){i.value=s,i.getSnapshot=t,u(i)&&c({inst:i})},[e,s,t]),a(function(){return u(i)&&c({inst:i}),e(function(){u(i)&&c({inst:i})})},[e]),l(s),s};t.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:c},4872:(e,t,s)=>{let r;s.d(t,{createBrowserClient:()=>t1});let i=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(s.bind(s,38936)).then(({default:t})=>t(...e)):fetch),(...e)=>t(...e)};class n extends 
1Error{constructor(e,t="FunctionsError",s){super(e),this.name=t,this.context=s}}class a extends n{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class o extends n{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class l extends n{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}!function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"}(y||(y={}));class u{constructor(e,{headers:t={},customFetch:s,region:r=y.Any}={}){this.url=e,this.headers=t,this.region=r,this.fetch=i(s)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var s,r,i,n,u;return r=this,i=void 0,n=void 0,u=function*(){try{let r,i,{headers:n,method:u,body:c}=t,h={},{region:d}=t;d||(d=this.region);let f=new URL(`${this.url}/${e}`);d&&"any"!==d&&(h["x-region"]=d,f.searchParams.set("forceFunctionRegion",d)),c&&(n&&!Object.prototype.hasOwnProperty.call(n,"Content-Type")||!n)&&("undefined"!=typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",r=c):"string"==typeof c?(h["Content-Type"]="text/plain",r=c):"undefined"!=typeof FormData&&c instanceof FormData?r=c:(h["Content-Type"]="application/json",r=JSON.stringify(c)));let p=yield this.fetch(f.toString(),{method:u||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),n),body:r}).catch(e=>{throw new a(e)}),g=p.headers.get("x-relay-error");if(g&&"true"===g)throw new o(p);if(!p.ok)throw new l(p);let y=(null!=(s=p.headers.get("Content-Type"))?s:"text/plain").split(";")[0].trim();return{data:"application/json"===y?yield p.json():"application/octet-stream"===y?yield p.blob():"text/event-stream"===y?p:"multipart/form-data"===y?yield p.formData():yield p.text(),error:null,response:p}}catch(e){return{data:null,error:e,response:e instanceof l||e instanceof o?e.context:void 0}}},new(n||(n=Promise))(function(e,t){function s(e){try{o(u.next(e))}catch(e){t(e)}}function a(e){try{o(u.throw(e))}catch(e){t(e)}}function o(t){var r;t.done?e(t.value):((r=t.value)instanceof n?r:new n(function(e){e(r)})).then(s,a)}o((u=u.apply(r,i||[])).next())})}}let{PostgrestClient:c,PostgrestQueryBuilder:h,PostgrestFilterBuilder:d,PostgrestTransformBuilder:f,PostgrestBuilder:p,PostgrestError:g}=s(61815);var y,m,w,v,_,b,k,S,T,E,j,O=s(55036);class P{static detectEnvironment(){var e;if("undefined"!=typeof WebSocket)return{type:"native",constructor:WebSocket};if("undefined"!=typeof globalThis&&void 0!==globalThis.WebSocket)return{type:"native",constructor:globalThis.WebSocket};if(void 0!==s.g&&void 0!==s.g.WebSocket)return{type:"native",constructor:s.g.WebSocket};if("undefined"!=typeof globalThis&&void 0!==globalThis.WebSocketPair&&void 0===globalThis.WebSocket)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("undefined"!=typeof globalThis&&globalThis.EdgeRuntime||"undefined"!=typeof navigator&&(null==(e=navigator.userAgent)?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(void 0!==O&&O.versions&&O.versions.node){let e=parseInt(O.versions.node.split(".")[0]);return e>=22?void 0!==globalThis.WebSocket?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${e} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${e} detected without native WebSocket support.`,workaround:'For Node.js < 22, install "ws" package and provide it via the transport option:\nimport ws from "ws"\nnew 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(){let e=this.detectEnvironment();if(e.constructor)return e.constructor;let t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+=`
2
3Suggested solution: ${e.workaround}`),Error(t)}static createWebSocket(e,t){return new(this.getWebSocketConstructor())(e,t)}static isWebSocketSupported(){try{let e=this.detectEnvironment();return"native"===e.type||"ws"===e.type}catch(e){return!1}}}!function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"}(m||(m={})),function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"}(w||(w={})),function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"}(v||(v={})),(_||(_={})).websocket="websocket",function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"}(b||(b={}));class A{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):"string"==typeof e?t(JSON.parse(e)):t({})}
3_binaryDecode(e){let t=new DataView(e),s=new TextDecoder;return this._decodeBroadcast(e,t,s)}_decodeBroadcast(e,t,s){let r=t.getUint8(1),i=t.getUint8(2),n=this.HEADER_LENGTH+2,a=s.decode(e.slice(n,n+r));n+=r;let o=s.decode(e.slice(n,n+i));return n+=i,{ref:null,topic:a,event:o,payload:JSON.parse(s.decode(e.slice(n,e.byteLength)))}}}class C{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))}}!function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(k||(k={}));let $=(e,t,s={})=>{var r;let i=null!=(r=s.skipTypes)?r:[];return Object.keys(t).reduce((s,r)=>(s[r]=I(r,e,t,i),s),{})},I=(e,t,s,r)=>{let i=t.find(t=>t.name===e),n=null==i?void 0:i.type,a=s[e];return n&&!r.includes(n)?R(n,a):x(a)},R=(e,t)=>{if("_"===e.charAt(0))return D(t,e.slice(1,e.length));switch(e){case k.bool:return U(t);case k.float4:case k.float8:case k.int2:case k.int4:case k.int8:case k.numeric:case k.oid:return L(t);case k.json:case k.jsonb:return N(t);case k.timestamp:return q(t);case k.abstime:case k.date:case k.daterange:case k.int4range:case k.int8range:case k.money:case k.reltime:case k.text:case k.time:case k.timestamptz:case k.timetz:case k.tsrange:case k.tstzrange:default:return x(t)}},x=e=>e,U=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},L=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},N=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){console.log(`JSON parse error: ${e}`)}return e},D=(e,t)=>{if("string"!=typeof e)return e;let s=e.length-1,r=e[s];if("{"===e[0]&&"}"===r){let r,i=e.slice(1,s);try{r=JSON.parse("["+i+"]")}catch(e){r=i?i.split(","):[]}return r.map(e=>R(t,e))}return e},q=e=>"string"==typeof e?e.replace(" ","T"):e,M=e=>{let t=e;return(t=(t=t.replace(/^ws/i,"http")).replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,"")).replace(/\/+$/,"")+"/api/broadcast"};class B{constructor(e,t,s={},r=1e4){this.channel=e,this.event=t,this.payload=s,this.timeout=r,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 s;return this._hasReceived(e)&&t(null==(s=this.receivedResp)?void 0:s.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){this.timeoutTimer||(this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref),this.channel._on(this.refEvent,{},e=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=e,this._matchReceive(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(t=>t.status===e).forEach(e=>e.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}!function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"}(S||(S={}));class z{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let s=(null==t?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(s.state,{},e=>{let{onJoin:t,onLeave:s,onSync:r}=this.caller;this.joinRef=this.channel._joinRef(),this.state=z.syncState(this.state,e,t,s),this.pendingDiffs.forEac
3h(e=>{this.state=z.syncDiff(this.state,e,t,s)}),this.pendingDiffs=[],r()}),this.channel._on(s.diff,{},e=>{let{onJoin:t,onLeave:s,onSync:r}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=z.syncDiff(this.state,e,t,s),r())}),this.onJoin((e,t,s)=>{this.channel._trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:s})}),this.onLeave((e,t,s)=>{this.channel._trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:s})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,s,r){let i=this.cloneDeep(e),n=this.transformState(t),a={},o={};return this.map(i,(e,t)=>{n[e]||(o[e]=t)}),this.map(n,(e,t)=>{let s=i[e];if(s){let r=t.map(e=>e.presence_ref),i=s.map(e=>e.presence_ref),n=t.filter(e=>0>i.indexOf(e.presence_ref)),l=s.filter(e=>0>r.indexOf(e.presence_ref));n.length>0&&(a[e]=n),l.length>0&&(o[e]=l)}else a[e]=t}),this.syncDiff(i,{joins:a,leaves:o},s,r)}static syncDiff(e,t,s,r){let{joins:i,leaves:n}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return s||(s=()=>{}),r||(r=()=>{}),this.map(i,(t,r)=>{var i;let n=null!=(i=e[t])?i:[];if(e[t]=this.cloneDeep(r),n.length>0){let s=e[t].map(e=>e.presence_ref),r=n.filter(e=>0>s.indexOf(e.presence_ref));e[t].unshift(...r)}s(t,n,r)}),this.map(n,(t,s)=>{let i=e[t];if(!i)return;let n=s.map(e=>e.presence_ref);i=i.filter(e=>0>n.indexOf(e.presence_ref)),e[t]=i,r(t,i,s),0===i.length&&delete e[t]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(s=>t(s,e[s]))}static transformState(e){return Object.getOwnPropertyNames(e=this.cloneDeep(e)).reduce((t,s)=>{let r=e[s];return"metas"in r?t[s]=r.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e)):t[s]=r,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()}}!function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"}(T||(T={})),function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"}(E||(E={})),function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"}(j||(j={}));class F{constructor(e,t={config:{}},s){this.topic=e,this.params=t,this.socket=s,this.bindings={},this.state=w.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 B(this,v.join,this.params,this.timeout),this.rejoinTimer=new C(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=w.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=w.closed,this.socket._remove(this)}),this._onError(e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=w.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=w.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=w.errored,this.rejoinTimer.scheduleTimeout())}),this._on(v.reply,{},(e,t)=>{this._trigger(this._replyEventName(t),e)}),this.presence=new z(this),this.broadcastEndpointURL=M(this.socket.endPoint),this.private=this.params.config.private||!1}subscribe(e,t=this.timeout){var s,r,i;if(this.socket.isConnected()||this.socket.connect(),this.state==w.closed){let{config:{broadcast:n,presence:a,private:o}}=this.params,l=null!=(r=null==(s=this.bindings.postgres_changes)?void 0:s.map(e=>e.filter))?r:[],u=!!this.bindings[E.PRESENCE]&&this.bindings[E.PRESENCE].length>0||(null==(i=this.params.config.presence)?void 0:i.enabled)===!0,c={},h={broadcast:n,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:l,private:o};this.socket.accessTokenValue&&(c.access_token=this.socket.accessTokenValue),this._onError(t=>null==e?void 0:e(j.CHANNEL_ERROR,t)),this._onClose(()=>null==e?void 0:e(j.CLOSED)),this.updateJoinPayload(Object.assign({config:h}
3,c)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:t})=>{var s;if(this.socket.setAuth(),void 0===t){null==e||e(j.SUBSCRIBED);return}{let r=this.bindings.postgres_changes,i=null!=(s=null==r?void 0:r.length)?s:0,n=[];for(let s=0;s<i;s++){let i=r[s],{filter:{event:a,schema:o,table:l,filter:u}}=i,c=t&&t[s];if(c&&c.event===a&&c.schema===o&&c.table===l&&c.filter===u)n.push(Object.assign(Object.assign({},i),{id:c.id}));else{this.unsubscribe(),this.state=w.errored,null==e||e(j.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=n,e&&e(j.SUBSCRIBED);return}}).receive("error",t=>{this.state=w.errored,null==e||e(j.CHANNEL_ERROR,Error(JSON.stringify(Object.values(t).join(", ")||"error")))}).receive("timeout",()=>{null==e||e(j.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,s){return this.state===w.joined&&e===E.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,s)}async send(e,t={}){var s,r;if(this._canPush()||"broadcast"!==e.type)return new Promise(s=>{var r,i,n;let a=this._push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null==(n=null==(i=null==(r=this.params)?void 0:r.config)?void 0:i.broadcast)?void 0:n.ack)||s("ok"),a.receive("ok",()=>s("ok")),a.receive("error",()=>s("error")),a.receive("timeout",()=>s("timed out"))});{let{event:i,payload:n}=e,a={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:n,private:this.private}]})};try{let e=await this._fetchWithTimeout(this.broadcastEndpointURL,a,null!=(s=t.timeout)?s:this.timeout);return await (null==(r=e.body)?void 0:r.cancel()),e.ok?"ok":"error"}catch(e){if("AbortError"===e.name)return"timed out";return"error"}}}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=w.leaving;let t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(v.close,"leave",this._joinRef())};this.joinPush.destroy();let s=null;return new Promise(r=>{(s=new B(this,v.leave,{},e)).receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),s.send(),this._canPush()||s.trigger("ok",{})}).finally(()=>{null==s||s.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=w.closed,this.bindings={}}async _fetchWithTimeout(e,t,s){let r=new AbortController,i=setTimeout(()=>r.abort(),s),n=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:r.signal}));return clearTimeout(i),n}_push(e,t,s=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let r=new B(this,e,t,s);return this._canPush()?r.send():this._addToPushBuffer(r),r}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>100){let e=this.pushBuffer.shift();e&&(e.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${e.event}`,e.payload))}}_onMessage(e,t,s){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,s){var r,i;let n=e.toLocaleLowerCase(),{close:a,error:o,leave:l,join:u}=v;if(s&&[a,o,l,u].indexOf(n)>=0&&s!==this._joinRef())return;let c=this._onMessage(n,t,s);if(t&&!c)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(n)?null==(r=this.bindings.postgres_changes)||r.filter(e=>{var t,s,r;return(null==(t=e.filter)?void 0:t.event)==="*"||(null==(r=null==(s=e.filter)?void 0:s.event)?void 0:r.toLocaleLowerCase())===n}).map(e=>e.callback(c,s)):null==(i=this.bindings[n])||i.filter(e=>{var s,r,i,a,o,l;if(!["broadcast","presence","postgres_changes"].includes(n))return e.type.toLocaleLowerCase()===n;if("id"in e){let n=e.id,a=null==(s=e.filter)?void 0:s.event;return n&&(null==(r=t.ids)?void 0:r.includes(n))&&("*"===a||(null==a?void 0:a.toLocaleLowerCase())===(null==(i=t.data)?void 0:i.type.toLocaleLowerCase()))}{let s=null==(o=null==(a=null==e?void 0:e.filter)?void 0:a.event)?void 0:o.toLocaleLowerCase();return"*"===s||s===(null==(l=null==t?void 0:t.event)?void 0:l.toLocaleLowerCase())}}).map(e=>{if("object"==typeof c&&"ids"in c){let e=c.data,{schema:t,table:s,commit_timestamp:r,type:i,errors:n}=e;c=Object.assign(Object.assign({},{schema:t,table:s,commit_timestamp:r,eventType:i,new:{},old:{},errors:n}),this._getPayloadRecords(e))}e.callback(c,s)})}_isClosed(){return this.state===w.closed}_isJoined(){return this.state===w.joined}_isJoining(){return this.state===w.joining}_isLeaving(){return this.state===w.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,s){let r=e.toLocaleLowerCase(),i={type:r,filter:t,callback:s};return this.bindings[r]?this.bindings[r].push(i):this.bindings[r]=[i],this}_off(e,t){let s=e.toLocaleLowerCase();return this.bindings[s]&&(this.bindings[s]=this.bindings[s].filter(e=>{var r;return!((null==(r=e.type)?void 0:r.toLocaleLowerCase())===s&&F.isEqual(e.filter,t))})),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let s in e)if(e[s]!==t[s])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(v.close,{},e)}_onError(e){this._on(v.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=w.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=$(e.columns,e.record)),("UPDATE"===e.type||"DELET
3E"===e.type)&&(t.old=$(e.columns,e.old_record)),t}}let W=()=>{},K={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},H=[1e3,2e3,5e3,1e4],J=`
4  addEventListener("message", (e) => {
5    if (e.data.event === "start") {
6      setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
7    }
8  });`;class G{constructor(e,t){var r;if(this.accessTokenValue=null,this.apiKey=null,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=1e4,this.transport=null,this.heartbeatIntervalMs=K.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=W,this.ref=0,this.reconnectTimer=null,this.logger=W,this.conn=null,this.sendBuffer=[],this.serializer=new A,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(s.bind(s,38936)).then(({default:t})=>t(...e)).catch(e=>{throw Error(`Failed to load @supabase/node-fetch: ${e.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):fetch),(...e)=>t(...e)},!(null==(r=null==t?void 0:t.params)?void 0:r.apikey))throw Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey,this.endPoint=`${e}/${_.websocket}`,this.httpEndpoint=M(e),this._initializeOptions(t),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||null!==this.conn&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=P.createWebSocket(this.endpointURL())}catch(t){this._setConnectionState("disconnected");let e=t.message;if(e.includes("Node.js"))throw Error(`${e}
9
10To use Realtime in Node.js, you need to provide a WebSocket implementation:
11
12Option 1: Use Node.js 22+ which has native WebSocket support
13Option 2: Install and provide the "ws" package:
14
15  npm install ws
16
17  import ws from "ws"
18  const client = new RealtimeClient(url, {
19    ...options,
20    transport: ws
21  })`);throw Error(`WebSocket not available: ${e}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:"1.0.0"}))}disconnect(e,t){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){let s=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(s),this._setConnectionState("disconnected")},e?this.conn.close(e,null!=t?t:""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return 0===this.channels.length&&this.disconnect(),t}async removeAllChannels(){let e=await Promise.all(this.channels.map(e=>e.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,t,s){this.logger(e,t,s)}connectionState(){switch(this.conn&&this.conn.readyState){case m.connecting:return b.Connecting;
21case m.open:return b.Open;case m.closing:return b.Closing;default:return b.Closed}}isConnected(){return this.connectionState()===b.Open}isConnecting(){return"connecting"===this._connectionState}isDisconnecting(){return"disconnecting"===this._connectionState}channel(e,t={config:{}}){let s=`realtime:${e}`,r=this.getChannels().find(e=>e.topic===s);if(r)return r;{let s=new F(`realtime:${e}`,t,this);return this.channels.push(s),s}}push(e){let{topic:t,event:s,payload:r,ref:i}=e,n=()=>{this.encode(e,e=>{var t;null==(t=this.conn)||t.send(e)})};this.log("push",`${t} ${s} (${i})`,r),this.isConnected()?n():this.sendBuffer.push(n)}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(e){this.log("error","error in heartbeat callback",e)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this._wasManualDisconnect=!1,null==(e=this.conn)||e.close(1e3,"heartbeat timeout"),setTimeout(()=>{var e;this.isConnected()||null==(e=this.reconnectTimer)||e.scheduleTimeout()},K.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(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(t=>t.topic===e&&(t._isJoined()||t._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,e=>{if("phoenix"===e.topic&&"phx_reply"===e.event)try{this.heartbeatCallback("ok"===e.payload.status?"ok":"error")}catch(e){this.log("error","error in heartbeat callback",e)}e.ref&&e.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);let{topic:t,event:s,payload:r,ref:i}=e,n=i?`(${i})`:"",a=r.status||"";this.log("receive",`${a} ${t} ${s} ${n}`.trim(),r),this.channels.filter(e=>e._isMember(t)).forEach(e=>e._trigger(s,r,i)),this._triggerStateCallbacks("message",e)})}_clearTimer(e){var t;"heartbeat"===e&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):"reconnect"===e&&(null==(t=this.reconnectTimer)||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");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log("worker","worker error",e.message),this.workerRef.terminate()},this.workerRef.onmessage=e=>{"keepAlive"===e.data.event&&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||null==(t=this.reconnectTimer)||t.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}
21_triggerChanError(){this.channels.forEach(e=>e._trigger(v.error))}_appendParams(e,t){if(0===Object.keys(t).length)return e;let s=e.match(/\?/)?"&":"?",r=new URLSearchParams(t);return`${e}${s}${r}`}_workerObjectUrl(e){let t;if(e)t=e;else{let e=new Blob([J],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}_setConnectionState(e,t=!1){this._connectionState=e,"connecting"===e?this._wasManualDisconnect=!1:"disconnecting"===e&&(this._wasManualDisconnect=t)}async _performAuth(e=null){let t;t=e||(this.accessToken?await this.accessToken():this.accessTokenValue),this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEach(e=>{t&&e.updateJoinPayload({access_token:t,version:"realtime-js/2.15.4"}),e.joinedOnce&&e._isJoined()&&e._push(v.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(s=>{try{s(t)}catch(t){this.log("error",`error in ${e} callback`,t)}})}catch(t){this.log("error",`error triggering ${e} callbacks`,t)}}_setupReconnectionTimer(){this.reconnectTimer=new C(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},K.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var t,s,r,i,n,a,o,l,u;if(this.transport=null!=(t=null==e?void 0:e.transport)?t:null,this.timeout=null!=(s=null==e?void 0:e.timeout)?s:1e4,this.heartbeatIntervalMs=null!=(r=null==e?void 0:e.heartbeatIntervalMs)?r:K.HEARTBEAT_INTERVAL,this.worker=null!=(i=null==e?void 0:e.worker)&&i,this.accessToken=null!=(n=null==e?void 0:e.accessToken)?n:null,this.heartbeatCallback=null!=(a=null==e?void 0:e.heartbeatCallback)?a:W,(null==e?void 0:e.params)&&(this.params=e.params),(null==e?void 0:e.logger)&&(this.logger=e.logger),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=null!=(o=null==e?void 0:e.reconnectAfterMs)?o:e=>H[e-1]||1e4,this.encode=null!=(l=null==e?void 0:e.encode)?l:(e,t)=>t(JSON.stringify(e)),this.decode=null!=(u=null==e?void 0:e.decode)?u:this.serializer.decode.bind(this.serializer),this.worker){if("undefined"!=typeof window&&!window.Worker)throw Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl}}}class V extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function Y(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}class Q extends V{constructor(e,t,s){super(e),this.name="StorageApiError",this.status=t,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class X extends V{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}let Z=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(s.bind(s,38936)).then(({default:t})=>t(...e)):fetch),(...e)=>t(...e)},ee=()=>(function(e,t,s,r){return new(s||(s=Promise))(function(i,n){function a(e){try{l(r.next(e))}catch(e){n(e)}}function o(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(a,o)}l((r=r.apply(e,t||[])).next())})})(void 0,void 0,void 0,function*(){return"undefined"==typeof Response?(yield Promise.resolve().then(s.bind(s,38936))).Response:Response}),et=e=>{if(Array.isArray(e))return e.map(e=>et(e));if("function"==typeof e||e!==Object(e))return e;let t={};return Object.entries(e).forEach(([e,s])=>{t[e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""))]=et(s)}),t},es=e=>{if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)};var er=function(e,t,s,r){return new(s||(s=Promise))(function(i,n){function a(e){try{l(r.next(e))}catch(e){n(e)}}function o(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(a,o)}l((r=r.apply(e,t||[])).next())})};let ei=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),en=(e,t,s)=>er(void 0,void 0,void 0,function*(){e instanceof(yield ee())&&!(null==s?void 0:s.noResolveJson)?e.json().then(s=>{let r=e.status||500,i=(null==s?void 0:s.statusCode)||r+"";t(new Q(ei(s),r,i))}).catch(e=>{t(new X(ei(e),e))}):t(new X(ei(e),e))}),ea=(e,t,s,r)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"!==e&&r?(es(r)?(i.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),i.body=JSON.stringify(r)):i.body=r,(null==t?void 0:t.duplex)&&(i.duplex=t.duplex),Object.assign(Object.assign({},i),s)):i};function eo(e,t,s,r,i,n){return er(this,void 0,void 0,function*(){return new Promise((a,o)=>{e(s,ea(t,r,i,n)).then(e=>{if(!e.ok)throw e;return(null==r?void 0:r.noResolveJson)?e:e.json()}).then(e=>a(e)).catch(e=>en(e,o,r))})})}function el(e,t,s,r){return er(this,void 0,void 0,function*(){return eo(e,"GET",t,s,r)})}function eu(e,t,s,r,i){return er(this,void 0,void 0,function*(){return eo(e,"POST",t,r,i,s)})}function ec(e,t,s,r,i){return er(this,void 0,void 0,function*(){return eo(e,"PUT",t,r,i,s)})}function eh(e,t,s,r,i){return er(this,void 0,void 0,function*(){return eo(e,"DELETE",t,r,i,s)})}
21var ed=s(50887).hp,ef=function(e,t,s,r){return new(s||(s=Promise))(function(i,n){function a(e){try{l(r.next(e))}catch(e){n(e)}}function o(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(a,o)}l((r=r.apply(e,t||[])).next())})};let ep={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},eg={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class ey{constructor(e,t={},s,r){this.url=e,this.headers=t,this.bucketId=s,this.fetch=Z(r)}uploadOrUpdate(e,t,s,r){return ef(this,void 0,void 0,function*(){try{let i,n=Object.assign(Object.assign({},eg),r),a=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(n.upsert)}),o=n.metadata;"undefined"!=typeof Blob&&s instanceof Blob?((i=new FormData).append("cacheControl",n.cacheControl),o&&i.append("metadata",this.encodeMetadata(o)),i.append("",s)):"undefined"!=typeof FormData&&s instanceof FormData?((i=s).append("cacheControl",n.cacheControl),o&&i.append("metadata",this.encodeMetadata(o))):(i=s,a["cache-control"]=`max-age=${n.cacheControl}`,a["content-type"]=n.contentType,o&&(a["x-metadata"]=this.toBase64(this.encodeMetadata(o)))),(null==r?void 0:r.headers)&&(a=Object.assign(Object.assign({},a),r.headers));let l=this._removeEmptyFolders(t),u=this._getFinalPath(l),c=yield("PUT"==e?ec:eu)(this.fetch,`${this.url}/object/${u}`,i,Object.assign({headers:a},(null==n?void 0:n.duplex)?{duplex:n.duplex}:{}));return{data:{path:l,id:c.Id,fullPath:c.Key},error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}upload(e,t,s){return ef(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,s)})}uploadToSignedUrl(e,t,s,r){return ef(this,void 0,void 0,function*(){let i=this._removeEmptyFolders(e),n=this._getFinalPath(i),a=new URL(this.url+`/object/upload/sign/${n}`);a.searchParams.set("token",t);try{let e,t=Object.assign({upsert:eg.upsert},r),n=Object.assign(Object.assign({},this.headers),{"x-upsert":String(t.upsert)});"undefined"!=typeof Blob&&s instanceof Blob?((e=new FormData).append("cacheControl",t.cacheControl),e.append("",s)):"undefined"!=typeof FormData&&s instanceof FormData?(e=s).append("cacheControl",t.cacheControl):(e=s,n["cache-control"]=`max-age=${t.cacheControl}`,n["content-type"]=t.contentType);let o=yield ec(this.fetch,a.toString(),e,{headers:n});return{data:{path:i,fullPath:o.Key},error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}createSignedUploadUrl(e,t){return ef(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),r=Object.assign({},this.headers);(null==t?void 0:t.upsert)&&(r["x-upsert"]="true");let i=yield eu(this.fetch,`${this.url}/object/upload/sign/${s}`,{},{headers:r}),n=new URL(this.url+i.url),a=n.searchParams.get("token");if(!a)throw new V("No token returned by API");return{data:{signedUrl:n.toString(),path:e,token:a},error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}update(e,t,s){return ef(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,s)})}move(e,t,s){return ef(this,void 0,void 0,function*(){try{return{data:yield eu(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,de
21stinationBucket:null==s?void 0:s.destinationBucket},{headers:this.headers}),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}copy(e,t,s){return ef(this,void 0,void 0,function*(){try{return{data:{path:(yield eu(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==s?void 0:s.destinationBucket},{headers:this.headers})).Key},error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}createSignedUrl(e,t,s){return ef(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e),i=yield eu(this.fetch,`${this.url}/object/sign/${r}`,Object.assign({expiresIn:t},(null==s?void 0:s.transform)?{transform:s.transform}:{}),{headers:this.headers}),n=(null==s?void 0:s.download)?`&download=${!0===s.download?"":s.download}`:"";return{data:i={signedUrl:encodeURI(`${this.url}${i.signedURL}${n}`)},error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}createSignedUrls(e,t,s){return ef(this,void 0,void 0,function*(){try{let r=yield eu(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=(null==s?void 0:s.download)?`&download=${!0===s.download?"":s.download}`:"";return{data:r.map(e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}${i}`):null})),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}download(e,t){return ef(this,void 0,void 0,function*(){let s=void 0!==(null==t?void 0:t.transform),r=this.transformOptsToQueryString((null==t?void 0:t.transform)||{}),i=r?`?${r}`:"";try{let t=this._getFinalPath(e),r=yield el(this.fetch,`${this.url}/${s?"render/image/authenticated":"object"}/${t}${i}`,{headers:this.headers,noResolveJson:!0});return{data:yield r.blob(),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}info(e){return ef(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{let e=yield el(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:et(e),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}exists(e){return ef(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{return yield function(e,t,s,r){return er(this,void 0,void 0,function*(){return eo(e,"HEAD",t,Object.assign(Object.assign({},s),{noResolveJson:!0}),void 0)})}(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(Y(e)&&e instanceof X){let t=e.originalError;if([400,404].includes(null==t?void 0:t.status))return{data:!1,error:e}}throw e}})}getPublicUrl(e,t){let s=this._getFinalPath(e),r=[],i=(null==t?void 0:t.download)?`download=${!0===t.download?"":t.download}`:"";""!==i&&r.push(i);let n=void 0!==(null==t?void 0:t.transform),a=this.transformOptsToQueryString((null==t?void 0:t.transform)||{});""!==a&&r.push(a);let o=r.join("&");return""!==o&&(o=`?${o}`),{data:{publicUrl:encodeURI(`${this.url}/${n?"render/image":"object"}/public/${s}${o}`)}}}remove(e){return ef(this,void 0,void 0,function*(){try{return{data:yield eh(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}list(e,t,s){return ef(this,void 0,void 0,function*(){try{let r=Object.assign(Object.assign(Object.assign({},ep),t),{prefix:e||""});return{data:yield eu(this.fetch,`${this.url}/object/list/${this.bucketId}`,r,{headers:this.headers},s),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}listV2(e,t){return ef(this,void 0,void 0,function*(){try{let s=Object.assign({},e);return{data:yield eu(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,s,{headers:this.headers},t),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return void 0!==ed?ed.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){let 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("&")}}let em={"X-Client-Info":"storage-js/2.11.0"};
21var ew=function(e,t,s,r){return new(s||(s=Promise))(function(i,n){function a(e){try{l(r.next(e))}catch(e){n(e)}}function o(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(a,o)}l((r=r.apply(e,t||[])).next())})};class ev{constructor(e,t={},s,r){let i=new URL(e);(null==r?void 0:r.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,this.headers=Object.assign(Object.assign({},em),t),this.fetch=Z(s)}listBuckets(){return ew(this,void 0,void 0,function*(){try{return{data:yield el(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}getBucket(e){return ew(this,void 0,void 0,function*(){try{return{data:yield el(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}createBucket(e,t={public:!1}){return ew(this,void 0,void 0,function*(){try{return{data:yield eu(this.fetch,`${this.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}updateBucket(e,t){return ew(this,void 0,void 0,function*(){try{return{data:yield ec(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(e){if(Y(e))return{data:null,error:e};throw e}})}emptyBucket(e){return ew(this,void 0,void 0,function*(){try{return{data:yield eu(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}deleteBucket(e){return ew(this,void 0,void 0,function*(){try{return{data:yield eh(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(e){if(Y(e))return{data:null,error:e};throw e}})}}class e_ extends ev{constructor(e,t={},s,r){super(e,t,s,r)}from(e){return new ey(this.url,this.headers,e,this.fetch)}}let eb="";eb="undefined"!=typeof Deno?"deno":"undefined"!=typeof document?"web":"undefined"!=typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";let ek={headers:{"X-Client-Info":`supabase-js-${eb}/2.56.1`}},eS={schema:"public"},eT={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},eE={};var ej=s(38936);let eO=e=>{let t;return t=e||("undefined"==typeof fetch?ej.default:fetch),(...e)=>t(...e)},eP=()=>"undefined"==typeof Headers?ej.Headers:Headers,eA=(e,t,s)=>{let r=eO(s),i=eP();return(s,n)=>(function(e,t,s,r){return new(s||(s=Promise))(function(i,n){function a(e){try{l(r.next(e))}catch(e){n(e)}}function o(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(a,o)}l((r=r.apply(e,t||[])).next())})})(void 0,void 0,void 0,function*(){var a;let o=null!=(a=yield t())?a:e,l=new i(null==n?void 0:n.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization",`Bearer ${o}`),r(s,Object.assign(Object.assign({},n),{headers:l}))})},eC="2.71.1",e$={"X-Client-Info":`gotrue-js/${eC}`},eI="X-Supabase-Api-Version",eR={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},ex=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i;class eU extends Error{constructor(e,t,s){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=s}}function eL(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class eN extends eU{constructor(e,t,s){super(e,t,s),this.name="AuthApiError",this.status=t,this.code=s}}class eD extends eU{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class eq extends eU{constructor(e,t,s,r){super(e,s,r),this.name=t,this.status=s}}class eM extends eq{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}class eB extends eq{constructor(){super("Auth session or user missing","AuthInvalidToken
21ResponseError",500,void 0)}}class ez extends eq{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class eF extends eq{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}}}class eW extends eq{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 eK extends eq{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function eH(e){return eL(e)&&"AuthRetryableFetchError"===e.name}class eJ extends eq{constructor(e,t,s){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=s}}class eG extends eq{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}let eV="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),eY=" 	\n\r=".split(""),eQ=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<eY.length;t+=1)e[eY[t].charCodeAt(0)]=-2;for(let t=0;t<eV.length;t+=1)e[eV[t].charCodeAt(0)]=t;return e})();function eX(e,t,s){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)s(eV[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6;else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;)s(eV[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function eZ(e,t,s){let r=eQ[e];if(r>-1)for(t.queue=t.queue<<6|r,t.queuedBits+=6;t.queuedBits>=8;)s(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else if(-2===r)return;else throw Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}function e0(e){let t=[],s=e=>{t.push(String.fromCodePoint(e))},r={utf8seq:0,codepoint:0},i={queue:0,queuedBits:0},n=e=>{!function(e,t,s){if(0===t.utf8seq){if(e<=127)return s(e);for(let s=1;s<6;s+=1)if((e>>7-s&1)==0){t.utf8seq=s;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&s(t.codepoint)}}(e,r,s)};for(let t=0;t<e.length;t+=1)eZ(e.charCodeAt(t),i,n);return t.join("")}let e1=()=>"undefined"!=typeof window&&"undefined"!=typeof document,e2={tested:!1,writable:!1},e3=()=>{if(!e1())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(e2.tested)return e2.writable;let e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),e2.tested=!0,e2.writable=!0}catch(e){e2.tested=!0,e2.writable=!1}return e2.writable},e6=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(s.bind(s,38936)).then(({default:t})=>t(...e)):fetch),(...e)=>t(...e)},e5=e=>"object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json,e8=async(e,t,s)=>{await e.setItem(t,JSON.stringify(s))},e4=async(e,t)=>{let s=await e.getItem(t);if(!s)return null;try{return JSON.parse(s)}catch(e){return s}},e9=async(e,t)=>{await e.removeItem(t)};class e7{constructor(){this.promise=new e7.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function te(e){let t=e.split(".");if(3!==t.length)throw new eG("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!ex.test(t[e]))throw new eG("JWT not in base64url format");return{header:JSON.parse(e0(t[0])),payload:JSON.parse(e0(t[1])),signature:function(e){let t=[],s={queue:0,queuedBits:0},r=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)eZ(e.charCodeAt(t),s,r);return new Uint8Array(t)}(t[2]),raw:{header:t[0],payload:t[1]}}}async function tt(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function ts(e){return("0"+e.toString(16)).substr(-2)}async function tr(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>String.fromCharCode(e)).join("")}async function ti(e){return"undefined"==typeof crypto||void 0===crypto.subtle||"undefined"==typeof TextEncoder?(console.warn("WebCrypto API is not supported. Code 
21challenge method will default to use plain instead of sha256."),e):btoa(await tr(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function tn(e,t,s=!1){let r=function(){let e=new Uint32Array(56);if("undefined"==typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,s="";for(let r=0;r<56;r++)s+=e.charAt(Math.floor(Math.random()*t));return s}return crypto.getRandomValues(e),Array.from(e,ts).join("")}(),i=r;s&&(i+="/PASSWORD_RECOVERY"),await e8(e,`${t}-code-verifier`,i);let n=await ti(r),a=r===n?"plain":"s256";return[n,a]}e7.promiseConstructor=Promise;let ta=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i,to=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function tl(e){if(!to.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function tu(){return new Proxy({},{get:(e,t)=>{if("__isUserNotAvailableProxy"===t)return!0;if("symbol"==typeof t){let e=t.toString();if("Symbol(Symbol.toPrimitive)"===e||"Symbol(Symbol.toStringTag)"===e||"Symbol(util.inspect.custom)"===e)return}throw 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 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 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 tc(e){return JSON.parse(JSON.stringify(e))}var th=function(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(s[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)0>t.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(s[r[i]]=e[r[i]]);return s};let td=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),tf=[502,503,504];async function tp(e){var t;let s,r;if(!e5(e))throw new eK(td(e),0);if(tf.includes(e.status))throw new eK(td(e),e.status);try{s=await e.json()}catch(e){throw new eD(td(e),e)}let i=function(e){let t=e.headers.get(eI);if(!t||!t.match(ta))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch(e){return null}}(e);if(i&&i.getTime()>=eR["2024-01-01"].timestamp&&"object"==typeof s&&s&&"string"==typeof s.code?r=s.code:"object"==typeof s&&s&&"string"==typeof s.error_code&&(r=s.error_code),r){if("weak_password"===r)throw new eJ(td(s),e.status,(null==(t=s.weak_password)?void 0:t.reasons)||[]);else if("session_not_found"===r)throw new eM}else if("object"==typeof s&&s&&"object"==typeof s.weak_password&&s.weak_password&&Array.isArray(s.weak_password.reasons)&&s.weak_password.reasons.length&&s.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0))throw new eJ(td(s),e.status,s.weak_password.reasons);throw new eN(td(s),e.status||500,r)}let tg=(e,t,s,r)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?i:(i.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null==t?void 0:t.headers),i.body=JSON.stringify(r),Object.assign(Object.assign({},i),s))};async function ty(e,t,s,r){var i;let n=Object.assign({},null==r?void 0:r.headers);n[eI]||(n[eI]=eR["2024-01-01"].name),(null==r?void 0:r.jwt)&&(n.Authorization=`Bearer ${r.jwt}`);let a=null!=(i=null==r?void 0:r.query)?i:{};(null==r?void 0:r.redirectTo)&&(a.redirect_to=r.redirectTo);let o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",l=await tm(e,t,s+o,{headers:n,noResolveJson:null==r?void 0:r.noResolveJson},{},null==r?void 0:r.body);return(null==r?void 0:r.xform)?null==r?void 0:r.xform(l):{data:Object.assign({},l),error:null}}async function tm(e,t,s,r,i,n){let a,o=tg(t,r,i,n);try{a=await e(s,Object.assign({},o))}catch(e){throw console.error(e),new eK(td(e),0)}if(a.ok||await tp(a),null==r?void 0:r.noResolveJson)return a;try{return await a.json()}catch(e){await tp(e)}}function tw(e){var t,s,r;let i=null;(r=e).access_token&&r.refresh_token&&r.expires_in&&(i=Object.assign({},e),e.expires_at||(i.expires_at=(s=e.expires_in,Math.round(Date.now()/1e3)+s))
21);return{data:{session:i,user:null!=(t=e.user)?t:e},error:null}}function tv(e){let t=tw(e);return!t.error&&e.weak_password&&"object"==typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&"string"==typeof e.weak_password.message&&e.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0)&&(t.data.weak_password=e.weak_password),t}function t_(e){var t;return{data:{user:null!=(t=e.user)?t:e},error:null}}function tb(e){return{data:e,error:null}}function tk(e){let{action_link:t,email_otp:s,hashed_token:r,redirect_to:i,verification_type:n}=e;return{data:{properties:{action_link:t,email_otp:s,hashed_token:r,redirect_to:i,verification_type:n},user:Object.assign({},th(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function tS(e){return e}let tT=["global","local","others"];var tE=function(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(s[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)0>t.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(s[r[i]]=e[r[i]]);return s};class tj{constructor({url:e="",headers:t={},fetch:s}){this.url=e,this.headers=t,this.fetch=e6(s),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,t=tT[0]){if(0>tT.indexOf(t))throw Error(`@supabase/auth-js: Parameter scope must be one of ${tT.join(", ")}`);try{return await ty(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if(eL(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e,t={}){try{return await ty(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:t_})}catch(e){if(eL(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,s=tE(e,["options"]),r=Object.assign(Object.assign({},s),t);return"newEmail"in s&&(r.new_email=null==s?void 0:s.newEmail,delete r.newEmail),await ty(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:r,headers:this.headers,xform:tk,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(eL(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await ty(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:t_})}catch(e){if(eL(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,s,r,i,n,a,o;try{let l={nextPage:null,lastPage:0,total:0},u=await ty(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:null!=(s=null==(t=null==e?void 0:e.page)?void 0:t.toString())?s:"",per_page:null!=(i=null==(r=null==e?void 0:e.perPage)?void 0:r.toString())?i:""},xform:tS});if(u.error)throw u.error;let c=await u.json(),h=null!=(n=u.headers.get("x-total-count"))?n:0,d=null!=(o=null==(a=u.headers.get("link"))?void 0:a.split(","))?o:[];return d.length>0&&(d.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),s=JSON.parse(e.split(";")[1].split("=")[1]);l[`${s}Page`]=t}),l.total=parseInt(h)),{data:Object.assign(Object.assign({},c),l),error:null}}catch(e){if(eL(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){tl(e);try{return await ty(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:t_})}catch(e){if(eL(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){tl(e);try{return await ty(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:t_})}catch(e){if(eL(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){tl(e);try{return await ty(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:t_})}catch(e){if(eL(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){tl(e.userId);try{let{data:t,error:s}=await ty(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:s}}catch(e){if(eL(e))return{data:null,error:e};throw e}}async _deleteFactor(e){tl(e.userId),tl(e.id);
21try{return{data:await ty(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(e){if(eL(e))return{data:null,error:e};throw e}}}function tO(e={}){return{getItem:t=>e[t]||null,setItem:(t,s)=>{e[t]=s},removeItem:t=>{delete e[t]}}}let tP={debug:!!(globalThis&&e3()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"))};class tA extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class tC extends tA{}async function t$(e,t,s){tP.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);let r=new globalThis.AbortController;return t>0&&setTimeout(()=>{r.abort(),tP.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,0===t?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async r=>{if(r){tP.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,r.name);try{return await s()}finally{tP.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,r.name)}}if(0===t)throw tP.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new tC(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(tP.debug)try{let e=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(e,null,"  "))}catch(e){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",e)}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 s()}))}if("object"!=typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"undefined"!=typeof self&&(self.globalThis=self)}let tI={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:e$,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function tR(e,t,s){return await s()}let tx={};class tU{constructor(e){var t,s;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=tU.nextInstanceID,tU.nextInstanceID+=1,this.instanceID>0&&e1()&&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.");let r=Object.assign(Object.assign({},tI),e);if(this.logDebugMessages=!!r.debug,"function"==typeof r.debug&&(this.logger=r.debug),this.persistSession=r.persistSession,this.storageKey=r.storageKey,this.autoRefreshToken=r.autoRefreshToken,this.admin=new tj({url:r.url,headers:r.headers,fetch:r.fetch}),this.url=r.url,this.headers=r.headers,this.fetch=e6(r.fetch),this.lock=r.lock||tR,this.detectSessionInUrl=r.detectSessionInUrl,this.flowType=r.flowType,this.hasCustomAuthorizationHeader=r.hasCustomAuthorizationHeader,r.lock?this.lock=r.lock:e1()&&(null==(t=null==globalThis?void 0:globalThis.navigator)?void 0:t.locks)?this.lock=t$:this.lock=tR,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)},this.persistSession?(r.storage?this.storage=r.storage:e3()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=tO(this.memoryStorage)),r.userStorage&&(this.userStorage=r.userStorage)):(this.memoryStorage={},this.storage=tO(this.memoryStorage)),e1()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(e){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",e)}null==(s=this.broadcastChannel)||s.addEventListener("message",async e=>{this._debug("received broadcast notification from other tab or client",e),await this._notifyAllSubscribers(e.data.event,e.data.session,!1)})}this.initialize()}get jwks(){var e,t;return null!=(t=null==(e=tx[this.storageKey])?void 0:e.jwks)?t:{keys:[]}}set jwks(e){tx[this.storageKey]=Object.assign(Object.assign({},tx[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!=(t=null==(e=tx[this.storageKey])?void 0:e.cachedAt)?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){tx[this.storageKey]=Object.assign(Object.assign({},tx[this.storageKey]),{cachedAt:e})}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${eC}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise||(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))()),await this.initializePromise}async _initialize(){var e;try{let t=function(e){let t={},s=new URL(e);if(s.hash&&"#"===s.hash[0])try{new URLSearchParams(s.hash.substring(1)).forEac
21h((e,s)=>{t[s]=e})}catch(e){}return s.searchParams.forEach((e,s)=>{t[s]=e}),t}(window.location.href),s="none";if(this._isImplicitGrantCallback(t)?s="implicit":await this._isPKCECallback(t)&&(s="pkce"),e1()&&this.detectSessionInUrl&&"none"!==s){let{data:r,error:i}=await this._getSessionFromURL(t,s);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),eL(i)&&"AuthImplicitGrantRedirectError"===i.name){let t=null==(e=i.details)?void 0:e.code;if("identity_already_exists"===t||"identity_not_found"===t||"single_identity_not_deletable"===t)return{error:i}}return await this._removeSession(),{error:i}}let{session:n,redirectType:a}=r;return this._debug("#_initialize()","detected session in URL",n,"redirect type",a),await this._saveSession(n),setTimeout(async()=>{"recovery"===a?await this._notifyAllSubscribers("PASSWORD_RECOVERY",n):await this._notifyAllSubscribers("SIGNED_IN",n)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){if(eL(e))return{error:e};return{error:new eD("Unexpected error during initialization",e)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,s,r;try{let{data:i,error:n}=await ty(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:null!=(s=null==(t=null==e?void 0:e.options)?void 0:t.data)?s:{},gotrue_meta_security:{captcha_token:null==(r=null==e?void 0:e.options)?void 0:r.captchaToken}},xform:tw});if(n||!i)return{data:{user:null,session:null},error:n};let a=i.session,o=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",a)),{data:{user:o,session:a},error:null}}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async signUp(e){var t,s,r;try{let i;if("email"in e){let{email:s,password:r,options:n}=e,a=null,o=null;"pkce"===this.flowType&&([a,o]=await tn(this.storage,this.storageKey)),i=await ty(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:null==n?void 0:n.emailRedirectTo,body:{email:s,password:r,data:null!=(t=null==n?void 0:n.data)?t:{},gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken},code_challenge:a,code_challenge_method:o},xform:tw})}else if("phone"in e){let{phone:t,password:n,options:a}=e;i=await ty(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:n,data:null!=(s=null==a?void 0:a.data)?s:{},channel:null!=(r=null==a?void 0:a.channel)?r:"sms",gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken}},xform:tw})}else throw new ez("You must provide either an email or phone number and a password");let{data:n,error:a}=i;if(a||!n)return{data:{user:null,session:null},error:a};let o=n.session,l=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",o)),{data:{user:l,session:o},error:null}}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithPassword(e){try{let t;if("email"in e){let{email:s,password:r,options:i}=e;t=await ty(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:s,password:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:tv})}else if("phone"in e){let{phone:s,password:r,options:i}=e;t=await ty(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:s,password:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:tv})}else throw new ez("You must provide either an email or phone number and a password");let{data:s,error:r}=t;if(r)return{data:{user:null,session:null},error:r};if(!s||!s.session||!s.user)return{data:{user:null,session:null},error:new eB};return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:r}}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithOAuth(e){var t,s,r,i;return await this._handleProviderSignIn(e.provider,{redirectTo:null==(t=e.options)?void 0:t.redirectTo,scopes:null==(s=e.options)?void 0:s.scopes,queryParams:null==(r=e.options)?void 0:r.queryParams,skipBrowserRedirect:null==(i=e.options)?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){let{chain:t}=e;if("solana"===t)return await this.signInWithSolana(e);throw Error(`@supabase/auth-js: Unsupported chain "${t}"`)}async signInWithSolana(e){var t,s,r,i,n,a,o,l,u,c,h,d;let f,p;if("message"in e)f=e.message,p=e.signature;else{let h,{chain:d,wallet:g,statement:y,options:m}=e;if(e1())if("object"==typeof g)h=g;else{let e=window;if("solana"in e&&"object"==typeof e.solana&&("signIn"in e.solana&&"function"==typeof e.solana.signIn||"sign
21Message"in e.solana&&"function"==typeof e.solana.signMessage))h=e.solana;else throw 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("object"!=typeof g||!(null==m?void 0:m.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");h=g}let w=new URL(null!=(t=null==m?void 0:m.url)?t:window.location.href);if("signIn"in h&&h.signIn){let e,t=await h.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},null==m?void 0:m.signInWithSolana),{version:"1",domain:w.host,uri:w.href}),y?{statement:y}:null));if(Array.isArray(t)&&t[0]&&"object"==typeof t[0])e=t[0];else if(t&&"object"==typeof t&&"signedMessage"in t&&"signature"in t)e=t;else throw Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in e&&"signature"in e&&("string"==typeof e.signedMessage||e.signedMessage instanceof Uint8Array)&&e.signature instanceof Uint8Array)f="string"==typeof e.signedMessage?e.signedMessage:new TextDecoder().decode(e.signedMessage),p=e.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in h)||"function"!=typeof h.signMessage||!("publicKey"in h)||"object"!=typeof h||!h.publicKey||!("toBase58"in h.publicKey)||"function"!=typeof h.publicKey.toBase58)throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");f=[`${w.host} wants you to sign in with your Solana account:`,h.publicKey.toBase58(),...y?["",y,""]:[""],"Version: 1",`URI: ${w.href}`,`Issued At: ${null!=(r=null==(s=null==m?void 0:m.signInWithSolana)?void 0:s.issuedAt)?r:new Date().toISOString()}`,...(null==(i=null==m?void 0:m.signInWithSolana)?void 0:i.notBefore)?[`Not Before: ${m.signInWithSolana.notBefore}`]:[],...(null==(n=null==m?void 0:m.signInWithSolana)?void 0:n.expirationTime)?[`Expiration Time: ${m.signInWithSolana.expirationTime}`]:[],...(null==(a=null==m?void 0:m.signInWithSolana)?void 0:a.chainId)?[`Chain ID: ${m.signInWithSolana.chainId}`]:[],...(null==(o=null==m?void 0:m.signInWithSolana)?void 0:o.nonce)?[`Nonce: ${m.signInWithSolana.nonce}`]:[],...(null==(l=null==m?void 0:m.signInWithSolana)?void 0:l.requestId)?[`Request ID: ${m.signInWithSolana.requestId}`]:[],...(null==(c=null==(u=null==m?void 0:m.signInWithSolana)?void 0:u.resources)?void 0:c.length)?["Resources",...m.signInWithSolana.resources.map(e=>`- ${e}`)]:[]].join("\n");let e=await h.signMessage(new TextEncoder().encode(f),"utf8");if(!e||!(e instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");p=e}}try{let{data:t,error:s}=await ty(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:f,signature:function(e){let t=[],s={queue:0,queuedBits:0},r=e=>{t.push(e)};return e.forEach(e=>eX(e,s,r)),eX(null,s,r),t.join("")}(p)},(null==(h=e.options)?void 0:h.captchaToken)?{gotrue_meta_security:{captcha_token:null==(d=e.options)?void 0:d.captchaToken}}:null),xform:tw});if(s)throw s;if(!t||!t.session||!t.user)return{data:{user:null,session:null},error:new eB};return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),{data:Object.assign({},t),error:s}}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async _exchangeCodeForSession(e){let t=await e4(this.storage,`${this.storageKey}-code-verifier`),[s,r]=(null!=t?t:"").split("/");try{let{data:t,error:i}=await ty(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:s},xform:tw});if(await e9(this.storage,`${this.storageKey}-code-verifier`),i)throw i;if(!t||!t.session||!t.user)return{data:{user:null,session:null,redirectType:null},error:new eB};return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),{data:Object.assign(Object.assign({},t),{redirectType:null!=r?r:null}),error:i}}catch(e){if(eL(e))return{data:{user:null,session:null,redirectType:null},error:e};throw e}}async signInWithIdToken(e){try{let{options:t,provider:s,token:r,access_token:i,nonce:n}=e,{data:a,error:o}=await ty(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:r,access_token:i,nonce:n,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:tw});if(o)return{data:{user:null,session:null},error:o};if(!a||!a.session||!a.user)return{data:{user:null,session:null},error:new eB};return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:a,error:o}}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithOtp(e){var t,s,r,i,n;try{if("email"in e){let{email:r,options:i}=e,n=null,a=null;"pkce"===this.flowType&&([n,a]=await tn(this.storage,this.storageKey));let{error:o}=await ty(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:r,data:null!=(t=null==i?void 0:i.data)?t:{},create_user:null==(s=null==i?void 0:i.shouldCreateUser)||s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken},code_challenge:n,code_challenge_method:a},redirectTo:null==i?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:o}}if("phone"in e){let{phone:t,options:s}=e,{data:a,error:o}=await ty(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:t,data:null!=(r=null==s?void 0:s.data)?r:{},create_user:null==(i=null==s?void 0:s.shouldCreateUser)||i,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken},channel:null!=(n=null==s?void 0:s.channel)?n:"sms"}});return{data:{user:null,session:null,messageId:null==a?void 0:a.message_id},error:o}}throw new ez("You must provide either an email or phone number.")}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async verifyOtp(e){var t,s;try{let r,i;"options"in e&&(r=null==(t=e.options)?void 0:t.redirectTo,i=null==(s=e.options)?void 0:s.captchaToken);let{data:n,error:a}=await ty(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:r,xform:tw});if(a)throw a;if(!n)throw Error("An error occurred on token verification.");let o=n.session,l=n.user;return(null==o?void 0:o.access_token)&&(await this._saveSession(o),await this._notifyAllSubscribers("recovery"==e.type?"PASSWORD_RECOVERY":"SIGNED_IN",o)),{data:{user:l,session:o},error:null}}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async signInWithSSO(e){var t,s,r;try{let i=null,n=null;return"pkce"===this.flowType&&([i,n]=await tn(this.storage,this.storageKey)),await ty(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:null!=(s=null==(t=e.options)?void 0:t.redirectTo)?s:void 0}),(null==(r=null==e?void 0:e.options)?void 0:r.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:n}),headers:this.headers,xform:tb})}catch(e){if(eL(e))return{data:null,error:e};throw e}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:t},error:s}=e;if(s)throw s;if(!t)throw new eM;let{error:r}=await ty(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:r}})}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:s,type:r,options:i}=e,{error:n}=await ty(this.fetch,"POST",t,{headers:this.headers,body:{email:s,type:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},redirectTo:null==i?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:n}}if("phone"in e){let{phone:s,type:r,options:i}=e,{data:n,error:a}=await ty(this.fetch,"POST",t,{headers:this.headers,body:{phone:s,type:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}}});return{data:{user:null,session:null,messageId:null==n?void 0:n.message_id},error:a}}throw new ez("You must provide either an email or phone number and a type")}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async e=>e))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let e=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await s}catch(e){}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let e=t();for(this.pendingInLock.push((async()=>{try{await e}catch(e){}})()),await e;this.pendingInLock.length;){let e=[...this.pendingInLock];await Promise.all(e),this.pendingInLock.splice(0,e.length)}return await e}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{let 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!",Error().stack);try{let e=null,t=await e4(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),null!==t&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not val
21id"),await this._removeSession())),!e)return{data:{session:null},error:null};let s=!!e.expires_at&&1e3*e.expires_at-Date.now()<9e4;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",e.expires_at),!s){if(this.userStorage){let t=await e4(this.userStorage,this.storageKey+"-user");(null==t?void 0:t.user)?e.user=t.user:e.user=tu()}if(this.storage.isServer&&e.user){let t=this.suppressGetSessionWarning;e=new Proxy(e,{get:(e,s,r)=>(t||"user"!==s||(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."),t=!0,this.suppressGetSessionWarning=!0),Reflect.get(e,s,r))})}return{data:{session:e},error:null}}let{session:r,error:i}=await this._callRefreshToken(e.refresh_token);if(i)return{data:{session:null},error:i};return{data:{session:r},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{if(e)return await ty(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:t_});return await this._useSession(async e=>{var t,s,r;let{data:i,error:n}=e;if(n)throw n;return(null==(t=i.session)?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await ty(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:null!=(r=null==(s=i.session)?void 0:s.access_token)?r:void 0,xform:t_}):{data:{user:null},error:new eM}})}catch(e){if(eL(e))return eL(e)&&"AuthSessionMissingError"===e.name&&(await this._removeSession(),await e9(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:e};throw e}}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 s=>{let{data:r,error:i}=s;if(i)throw i;if(!r.session)throw new eM;let n=r.session,a=null,o=null;"pkce"===this.flowType&&null!=e.email&&([a,o]=await tn(this.storage,this.storageKey));let{data:l,error:u}=await ty(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:null==t?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:o}),jwt:n.access_token,xform:t_});if(u)throw u;return n.user=l.user,await this._saveSession(n),await this._notifyAllSubscribers("USER_UPDATED",n),{data:{user:n.user},error:null}})}catch(e){if(eL(e))return{data:{user:null},error:e};throw e}}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 eM;let t=Date.now()/1e3,s=t,r=!0,i=null,{payload:n}=te(e.access_token);if(n.exp&&(r=(s=n.exp)<=t),r){let{session:t,error:s}=await this._callRefreshToken(e.refresh_token);if(s)return{data:{user:null,session:null},error:s};if(!t)return{data:{user:null,session:null},error:null};i=t}else{let{data:r,error:n}=await this._getUser(e.access_token);if(n)throw n;i={access_token:e.access_token,refresh_token:e.refresh_token,user:r.user,token_type:"bearer",expires_in:s-t,expires_at:s},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(e){if(eL(e))return{data:{session:null,user:null},error:e};throw e}}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 s;if(!e){let{data:r,error:i}=t;if(i)throw i;e=null!=(s=r.session)?s:void 0}if(!(null==e?void 0:e.refresh_token))throw new eM;let{session:r,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:r?{data:{user:r.user,session:r},error:null}:{data:{user:null,session:null},error:null}})}catch(e){if(eL(e))return{data:{user:null,session:null},error:e};throw e}}async _getSessionFromURL(e,t){try{if(!e1())throw new eF("No browser detected.");
21if(e.error||e.error_description||e.error_code)throw new eF(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("pkce"===this.flowType)throw new eW("Not a valid PKCE flow url.");break;case"pkce":if("implicit"===this.flowType)throw new eF("Not a valid implicit grant flow url.")}if("pkce"===t){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new eW("No code detected.");let{data:t,error:s}=await this._exchangeCodeForSession(e.code);if(s)throw s;let r=new URL(window.location.href);return r.searchParams.delete("code"),window.history.replaceState(window.history.state,"",r.toString()),{data:{session:t.session,redirectType:null},error:null}}let{provider_token:s,provider_refresh_token:r,access_token:i,refresh_token:n,expires_in:a,expires_at:o,token_type:l}=e;if(!i||!a||!n||!l)throw new eF("No session defined in URL");let u=Math.round(Date.now()/1e3),c=parseInt(a),h=u+c;o&&(h=parseInt(o));let d=h-u;1e3*d<=3e4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${d}s, should have been closer to ${c}s`);let f=h-c;u-f>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",f,h,u):u-f<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",f,h,u);let{data:p,error:g}=await this._getUser(i);if(g)throw g;let y={provider_token:s,provider_refresh_token:r,access_token:i,expires_in:c,expires_at:h,refresh_token:n,token_type:l,user:p.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:y,redirectType:e.type},error:null}}catch(e){if(eL(e))return{data:{session:null,redirectType:null},error:e};throw e}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){let t=await e4(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 s;let{data:r,error:i}=t;if(i)return{error:i};let n=null==(s=r.session)?void 0:s.access_token;if(n){let{error:t}=await this.admin.signOut(n,e);if(t&&!(eL(t)&&"AuthApiError"===t.name&&(404===t.status||401===t.status||403===t.status)))return{error:t}}return"others"!==e&&(await this._removeSession(),await e9(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){let t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}),s={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,s),(async()=>{await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})})(),{data:{subscription:s}}}async _emitInitialSession(e){return await this._useSession(async t=>{var s,r;try{let{data:{session:r},error:i}=t;if(i)throw i;await (null==(s=this.stateChangeEmitters.get(e))?void 0:s.callback("INITIAL_SESSION",r)),this._debug("INITIAL_SESSION","callback id",e,"session",r)}catch(t){await (null==(r=this.stateChangeEmitters.get(e))?void 0:r.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",t),console.error(t)}})}async resetPasswordForEmail(e,t={}){let s=null,r=null;"pkce"===this.flowType&&([s,r]=await tn(this.storage,this.storageKey,!0));try{return await ty(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:s,code_challenge_method:r,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(e){if(eL(e))return{data:null,error:e};throw e}}async getUserIdentities(){var e;try{let{data:t,error:s}=await this.getUser();if(s)throw s;return{data:{identities:null!=(e=t.user.identities)?e:[]},error:null}}catch(e){if(eL(e))return{data:null,error:e};throw e}}async linkIdentity(e){var t;try{let{data:s,error:r}=await this._useSession(async t=>{var s,r,i,n,a;let{data:o,error:l}=t;if(l)throw l;let u=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:null==(s=e.options)?void 0:s.redirectTo,scopes:null==(r=e.options)?void 0:r.scopes,queryParams:null==(i=e.options)?void 0:i.queryParams,skipBrowserRedirect:!0});return await ty(this.fetch,"GET",u,{headers:this.headers,jwt:null!=(a=null==(n=o.session)?void 0:n.access_token)?a:void 0})});if(r)throw r;return!e1()||(null==(t=e.options)?void 0:t.skipBrowserRedirect)||window.location.assign(null==s?void 0:s.url),{data:{provider:e.provider,url:null==s?void 0:s.url},error:null}}catch(t){if(eL(t))return{data:{provider:e.provider,url:null},error:t};throw t}}async unlinkIdentity(e){try{return await this._useSession(async t=>{var s,r;let{data:i,error:n}=t;if(n)throw n;
21return await ty(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:null!=(r=null==(s=i.session)?void 0:s.access_token)?r:void 0})})}catch(e){if(eL(e))return{data:null,error:e};throw e}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{var s,r;let i=Date.now();return await (s=async s=>(s>0&&await tt(200*Math.pow(2,s-1)),this._debug(t,"refreshing attempt",s),await ty(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:tw})),r=(e,t)=>{let s=200*Math.pow(2,e);return t&&eH(t)&&Date.now()+s-i<3e4},new Promise((e,t)=>{(async()=>{for(let i=0;i<1/0;i++)try{let t=await s(i);if(!r(i,null,t))return void e(t)}catch(e){if(!r(i,e))return void t(e)}})()}))}catch(e){if(this._debug(t,"error",e),eL(e))return{data:{session:null,user:null},error:e};throw e}finally{this._debug(t,"end")}}_isValidSession(e){return"object"==typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){let s=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",s),e1()&&!t.skipBrowserRedirect&&window.location.assign(s),{data:{provider:e,url:s},error:null}}async _recoverAndRefresh(){var e,t;let s="#_recoverAndRefresh()";this._debug(s,"begin");try{let r=await e4(this.storage,this.storageKey);if(r&&this.userStorage){let t=await e4(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!t&&(t={user:r.user},await e8(this.userStorage,this.storageKey+"-user",t)),r.user=null!=(e=null==t?void 0:t.user)?e:tu()}else if(r&&!r.user&&!r.user){let e=await e4(this.storage,this.storageKey+"-user");e&&(null==e?void 0:e.user)?(r.user=e.user,await e9(this.storage,this.storageKey+"-user"),await e8(this.storage,this.storageKey,r)):r.user=tu()}if(this._debug(s,"session from storage",r),!this._isValidSession(r)){this._debug(s,"session is not valid"),null!==r&&await this._removeSession();return}let i=(null!=(t=r.expires_at)?t:1/0)*1e3-Date.now()<9e4;if(this._debug(s,`session has${i?"":" not"} expired with margin of 90000s`),i){if(this.autoRefreshToken&&r.refresh_token){let{error:e}=await this._callRefreshToken(r.refresh_token);e&&(console.error(e),eH(e)||(this._debug(s,"refresh failed with a non-retryable error, removing the session",e),await this._removeSession()))}}else if(r.user&&!0===r.user.__isUserNotAvailableProxy)try{let{data:e,error:t}=await this._getUser(r.access_token);!t&&(null==e?void 0:e.user)?(r.user=e.user,await this._saveSession(r),await this._notifyAllSubscribers("SIGNED_IN",r)):this._debug(s,"could not get user data, skipping SIGNED_IN notification")}catch(e){console.error("Error getting user data:",e),this._debug(s,"error getting user data, skipping SIGNED_IN notification",e)}else await this._notifyAllSubscribers("SIGNED_IN",r)}catch(e){this._debug(s,"error",e),console.error(e);return}finally{this._debug(s,"end")}}async _callRefreshToken(e){var t,s;if(!e)throw new eM;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let r=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{this.refreshingDeferred=new e7;let{data:t,error:s}=await this._refreshAccessToken(e);if(s)throw s;if(!t.session)throw new eM;await this._saveSession(t.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);let r={session:t.session,error:null};return this.refreshingDeferred.resolve(r),r}catch(e){if(this._debug(r,"error",e),eL(e)){let s={session:null,error:e};return eH(e)||await this._removeSession(),null==(t=this.refreshingDeferred)||t.resolve(s),s}throw null==(s=this.refreshingDeferred)||s.reject(e),e}finally{this.refreshingDeferred=null,this._debug(r,"end")}}async _notifyAllSubscribers(e,t,s=!0){let r=`#_notifyAllSubscribers(${e})`;this._debug(r,"begin",t,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:e,session:t});let r=[],i=Array.from(this.stateChangeEmitters.values()).map(async s=>{try{await s.callback(e,t)}catch(e){r.push(e)}});if(await Promise.all(i),r.length>0){for(let e=0;e<r.length;e+=1)console.error(r[e]);throw r[0]}}finally{this._debug(r,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;let t=Object.assign({},e),s=t.user&&!0===t.user.__isUserNotAvailableProxy;if(this.userStorage){!s&&t.user&&await e8(this.userStorage,this.storageKey+"-user",{user:t.user});let e=Object.assign({},t);delete e.user;let r=tc(e);await e8(this.storage,this.storageKey,r)}else{let e=tc(t);await e8(this.storage,this.storageKey,e)}}async _removeSession(){this._debug("#_removeSession()"),await e9(this.storage,this.storageKey),await e9(this.storage,this.storageKey+"-code-verifier"),await e9(this.storage,this.storageKey+"-user"),this.userStorage&&await e9(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&e1()&&(null==window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}
21catch(e){console.error("removing visibilitychange callback failed",e)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),3e4);this.autoRefreshTicker=e,e&&"object"==typeof e&&"function"==typeof e.unref?e.unref():"undefined"!=typeof Deno&&"function"==typeof Deno.unrefTimer&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let 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{let e=Date.now();try{return await this._useSession(async t=>{let{data:{session:s}}=t;if(!s||!s.refresh_token||!s.expires_at)return void this._debug("#_autoRefreshTokenTick()","no session");let r=Math.floor((1e3*s.expires_at-e)/3e4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${r} ticks, a tick lasts 30000ms, refresh threshold is 3 ticks`),r<=3&&await this._callRefreshToken(s.refresh_token)})}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof tA)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!e1()||!(null==window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),null==window||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),"visible"===document.visibilityState?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if("visible"!==document.visibilityState)return void this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");await this._recoverAndRefresh()}))):"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,s){let r=[`provider=${encodeURIComponent(t)}`];if((null==s?void 0:s.redirectTo)&&r.push(`redirect_to=${encodeURIComponent(s.redirectTo)}`),(null==s?void 0:s.scopes)&&r.push(`scopes=${encodeURIComponent(s.scopes)}`),"pkce"===this.flowType){let[e,t]=await tn(this.storage,this.storageKey),s=new URLSearchParams({code_challenge:`${encodeURIComponent(e)}`,code_challenge_method:`${encodeURIComponent(t)}`});r.push(s.toString())}if(null==s?void 0:s.queryParams){let e=new URLSearchParams(s.queryParams);r.push(e.toString())}return(null==s?void 0:s.skipBrowserRedirect)&&r.push(`skip_http_redirect=${s.skipBrowserRedirect}`),`${e}?${r.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var s;let{data:r,error:i}=t;return i?{data:null,error:i}:await ty(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:null==(s=null==r?void 0:r.session)?void 0:s.access_token})})}catch(e){if(eL(e))return{data:null,error:e};throw e}}async _enroll(e){try{return await this._useSession(async t=>{var s,r;let{data:i,error:n}=t;if(n)return{data:null,error:n};let a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},"phone"===e.factorType?{phone:e.phone}:{issuer:e.issuer}),{data:o,error:l}=await ty(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:null==(s=null==i?void 0:i.session)?void 0:s.access_token});return l?{data:null,error:l}:("totp"===e.factorType&&(null==(r=null==o?void 0:o.totp)?void 0:r.qr_code)&&(o.totp.qr_code=`data:image/svg+xml;utf-8,${o.totp.qr_code}`),{data:o,error:null})})}catch(e){if(eL(e))return{data:null,error:e};throw e}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var s;let{data:r,error:i}=t;if(i)return{data:null,error:i};let{data:n,error:a}=await ty(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:null==(s=null==r?void 0:r.session)?void 0:s.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+n.expires_in},n)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",n),{data:n,error:a})})}catch(e){if(eL(e))return{data:null,error:e};throw e}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var s;let{data:r,error:i}=t;return i?{data:null,error:i}:await ty(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:null==(s=null==r?void 0:r.session)?void 0:s.access_token})})}catch(e){if(eL(e))return{data:null,error:e};throw e}})}async _challengeAndVerify(e){let{data:t,error:s}=await this._challenge({factorId:e.factorId});return s?{data:null,error:s}:await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){let{data:{user:e},error:t}=await this.getUser();if(t)return{data:null,error:t};let s=(null==e?void 0:e.factors)||[],r=s.filter(e=>"totp"===e.factor_type&&"verified"===e.status),i=s.filter(e=>"phone"===e.factor_type&&"verified"===e.status);return{data:{all:s,totp:r,phone:i},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,s;let{data:{session:r},error:i}=e;if(i)return{data:null,error:i};if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:n}=te(r.access_token),a=null;n.aal&&(a=n.aal);let o=a;return(null!=(s=null==(t=r.user.factors)?void 0:t.filter(e=>"verified"===e.status))?s:[]).length>0&&(o="aal2"),{data:{currentLevel:a,nextLevel:o,currentAuthenticationMethods:n.amr||[]},error:null}}))}async fetchJwk(e,t={keys:[]}){let s=t.keys.find(t=>t.kid===e);if(s)return s;let r=Date.now();if((s=this.jwks.keys.find(t=>t.kid===e))&&this.jwks_cached_at+6e5>r)return s;let{data:i,error:n}=await ty(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(n)throw n;return i.keys&&0!==i.keys.length&&(this.jwks=i,this.jwks_cached_at=r,s=i.keys.find(t=>t.kid===e))?s:null}async getClaims(e,t={}){try{let s=e;if(!s){let{data:e,error:t}
21=await this.getSession();if(t||!e.session)return{data:null,error:t};s=e.session.access_token}let{header:r,payload:i,signature:n,raw:{header:a,payload:o}}=te(s);(null==t?void 0:t.allowExpired)||function(e){if(!e)throw Error("Missing exp claim");if(e<=Math.floor(Date.now()/1e3))throw Error("JWT has expired")}(i.exp);let l=!r.alg||r.alg.startsWith("HS")||!r.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(r.kid,(null==t?void 0:t.keys)?{keys:t.keys}:null==t?void 0:t.jwks);if(!l){let{error:e}=await this.getUser(s);if(e)throw e;return{data:{claims:i,header:r,signature:n},error:null}}let u=function(e){switch(e){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 Error("Invalid alg claim")}}(r.alg),c=await crypto.subtle.importKey("jwk",l,u,!0,["verify"]);if(!await crypto.subtle.verify(u,c,n,function(e){let t=[];return function(e,t){for(let s=0;s<e.length;s+=1){let r=e.charCodeAt(s);if(r>55295&&r<=56319){let t=(r-55296)*1024&65535;r=(e.charCodeAt(s+1)-56320&65535|t)+65536,s+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(r,t)}}(e,e=>t.push(e)),new Uint8Array(t)}(`${a}.${o}`)))throw new eG("Invalid JWT signature");return{data:{claims:i,header:r,signature:n},error:null}}catch(e){if(eL(e))return{data:null,error:e};throw e}}}tU.nextInstanceID=0;let tL=tU;class tN extends tL{constructor(e){super(e)}}class tD{constructor(e,t,s){var r,i,n;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw Error("supabaseUrl is required.");if(!t)throw Error("supabaseKey is required.");let a=new URL(function(e){return e.endsWith("/")?e:e+"/"}(e));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);let o=`sb-${a.hostname.split(".")[0]}-auth-token`,l=function(e,t){var s,r;let{db:i,auth:n,realtime:a,global:o}=e,{db:l,auth:u,realtime:c,global:h}=t,d={db:Object.assign(Object.assign({},l),i),auth:Object.assign(Object.assign({},u),n),realtime:Object.assign(Object.assign({},c),a),storage:{},global:Object.assign(Object.assign(Object.assign({},h),o),{headers:Object.assign(Object.assign({},null!=(s=null==h?void 0:h.headers)?s:{}),null!=(r=null==o?void 0:o.headers)?r:{})}),accessToken:()=>{var e,t,s,r;return e=this,t=void 0,r=function*(){return""},new(s=void 0,s=Promise)(function(i,n){function a(e){try{l(r.next(e))}catch(e){n(e)}}function o(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(a,o)}l((r=r.apply(e,t||[])).next())})}};return e.accessToken?d.accessToken=e.accessToken:delete d.accessToken,d}(null!=s?s:{},{db:eS,realtime:eE,auth:Object.assign(Object.assign({},eT),{storageKey:o}),global:ek});this.storageKey=null!=(r=l.auth.storageKey)?r:"",this.headers=null!=(i=l.global.headers)?i:{},l.accessToken?(this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(t)} is not possible`)}})):this.auth=this._initSupabaseAuthClient(null!=(n=l.auth)?n:{},this.headers,l.global.fetch),this.fetch=eA(t,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},l.realtime)),this.rest=new c(new URL("rest/v1",a).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch}),this.storage=new e_(this.storageUrl.href,this.headers,this.fetch,null==s?void 0:s.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new u(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={},s={}){return this.rest.rpc(e,t,s)}
21channel(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(){var e,t,s,r,i,n;return s=this,r=void 0,i=void 0,n=function*(){if(this.accessToken)return yield this.accessToken();let{data:s}=yield this.auth.getSession();return null!=(t=null==(e=s.session)?void 0:e.access_token)?t:this.supabaseKey},new(i||(i=Promise))(function(e,t){function a(e){try{l(n.next(e))}catch(e){t(e)}}function o(e){try{l(n.throw(e))}catch(e){t(e)}}function l(t){var s;t.done?e(t.value):((s=t.value)instanceof i?s:new i(function(e){e(s)})).then(a,o)}l((n=n.apply(s,r||[])).next())})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:s,storage:r,storageKey:i,flowType:n,lock:a,debug:o},l,u){let c={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new tN({url:this.authUrl.href,headers:Object.assign(Object.assign({},c),l),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:s,storage:r,flowType:n,lock:a,debug:o,fetch:u,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new G(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",null==t?void 0:t.access_token)})}_handleTokenChanged(e,t,s){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e)&&this.changedAccessToken!==s?this.changedAccessToken=s:"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0)}}var tq=s(55036);let tM=(e,t,s)=>new tD(e,t,s);(function(){if("undefined"!=typeof window||void 0===tq)return!1;let e=tq.version;if(null==e)return!1;let t=e.match(/^v(\d+)\./);return!!t&&18>=parseInt(t[1],10)})()&&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 Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217`);var tB=s(46483);function tz(){return"undefined"!=typeof window&&void 0!==window.document}let tF={path:"/",sameSite:"lax",httpOnly:!1,maxAge:3456e4},tW=/^(.*)[.](0|[1-9][0-9]*)$/;function tK(e,t){if(e===t)return!0;let s=e.match(tW);return!!s&&s[1]===t}function tH(e,t,s){let r=s??3180,i=encodeURIComponent(t);if(i.length<=r)return[{name:e,value:t}];let n=[];for(;i.length>0;){let e=i.slice(0,r),t=e.lastIndexOf("%");t>r-3&&(e=e.slice(0,t));let s="";for(;e.length>0;)try{s=decodeURIComponent(e);break}catch(t){if(t instanceof URIError&&"%"===e.at(-3)&&e.length>3)e=e.slice(0,e.length-3);else throw t}n.push(s),i=i.slice(e.length)}return n.map((t,s)=>({name:`${e}.${s}`,value:t}))}async function tJ(e,t){let s=await t(e);if(s)return s;let r=[];for(let s=0;;s++){let i=`${e}.${s}`,n=await t(i);if(!n)break;r.push(n)}return r.length>0?r.join(""):null}let tG="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),tV=" 	\n\r=".split(""),tY=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<tV.length;t+=1)e[tV[t].charCodeAt(0)]=-2;for(let t=0;t<tG.length;t+=1)e[tG[t].charCodeAt(0)]=t;return e})();function tQ(e){let t=[],s=0,r=0;if(function(e,t){for(let s=0;s<e.length;s+=1){let r=e.charCodeAt(s);if(r>55295&&r<=56319){let t=(r-55296)*1024&65535;r=(e.charCodeAt(s+1)-56320&65535|t)+65536,s+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(r,t)}}(e,e=>{for(s=s<<8|e,r+=8;r>=6;){let e=s>>r-6&63;t.push(tG[e]),r-=6}}),r>0)for(s<<=6-r,r=6;r>=6;){let e=s>>r-6&63;t.push(tG[e]),r-=6}return t.join("")}function tX(e){let t=[],s=e=>{t.push(String.fromCodePoint(e))},r={utf8seq:0,codepoint:0},i=0,n=0;for(let t=0;t<e.length;t+=1){let a=tY[e.charCodeAt(t)];if(a>-1)for(i=i<<6|a,n+=6;n>=8;)(function(e,t,s){if(0===t.utf8seq){if(e<=127)return s(e);for(let s=1;s<6;s+=1)if((e>>7-s&1)==0){t.utf8seq=s;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&s(t.codepoint)}})(i>>n-8&255,r,s),n-=8;else if(-2===a)continue;else throw Error(`Invalid Base64-URL character "${e.at(t)}" at position ${t}`)}return t.join("")}let tZ="base64-";async function t0({getAll:e,setAll:t,setItems:s,removedItems:r},i){let n=i.cookieEncoding,a=i.cookieOptions??null,o=await e([...s?Object.keys(s):[],...r?Object.keys(r):[]]),l=o?.map(({name:e})=>e)||[],u=Object.keys(r).flatMap(e=>l.filter(t=>tK(t,e))),c=Object.keys(s).flatMap(e=>{let t=new Set(l.filter(t=>
21tK(t,e))),r=s[e];"base64url"===n&&(r=tZ+tQ(r));let i=tH(e,r);return i.forEach(e=>{t.delete(e.name)}),u.push(...t),i}),h={...tF,...a,maxAge:0},d={...tF,...a,maxAge:tF.maxAge};delete h.name,delete d.name,await t([...u.map(e=>({name:e,value:"",options:h})),...c.map(({name:e,value:t})=>({name:e,value:t,options:d}))])}function t1(e,t,s){let i=s?.isSingleton===!0||(!s||!("isSingleton"in s))&&tz();if(i&&r)return r;if(!e||!t)throw Error(`@supabase/ssr: Your project's URL and API key are required to create a Supabase client!
22
23Check your Supabase project's API settings to find these values
24
25https://supabase.com/dashboard/project/_/settings/api`);let{storage:n}=function(e,t){let s,r,i=e.cookies??null,n=e.cookieEncoding,a={},o={};if(i)if("get"in i){let e=async e=>{let t=e.flatMap(e=>[e,...Array.from({length:5}).map((t,s)=>`${e}.${s}`)]),s=[];for(let e=0;e<t.length;e+=1){let r=await i.get(t[e]);(r||"string"==typeof r)&&s.push({name:t[e],value:r})}return s};if(s=async t=>await e(t),"set"in i&&"remove"in i)r=async e=>{for(let t=0;t<e.length;t+=1){let{name:s,value:r,options:n}=e[t];r?await i.set(s,r,n):await i.remove(s,n)}};else if(t)r=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 correctness. 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 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 i)if(s=async()=>await i.getAll(),"setAll"in i)r=i.setAll;else if(t)r=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 Error("@supabase/ssr: createBrowserClient requires configuring both getAll and setAll cookie methods (deprecated: alternatively both get, set and remove can be used)");else throw Error(`@supabase/ssr: ${t?"createServerClient":"createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).${tz()?" As this is called in a browser runtime, consider removing the cookies option object to use the document.cookie API automatically.":""}`);else if(!t&&tz()){let e=()=>{let e=(0,tB.q)(document.cookie);return Object.keys(e).map(t=>({name:t,value:e[t]}))};s=()=>e(),r=e=>{e.forEach(({name:e,value:t,options:s})=>{document.cookie=(0,tB.l)(e,t,s)})}}else if(t)throw 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)");else s=()=>[],r=()=>{throw 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 t?{getAll:s,setAll:r,setItems:a,removedItems:o,storage:{isServer:!0,getItem:async e=>{if("string"==typeof a[e])return a[e];if(o[e])return null;let t=await s([e]),r=await tJ(e,async e=>{let s=t?.find(({name:t})=>t===e)||null;return s?s.value:null});if(!r)return null;let i=r;return"string"==typeof r&&r.startsWith(tZ)&&(i=tX(r.substring(tZ.length))),i},setItem:async(t,i)=>{t.endsWith("-code-verifier")&&await t0({getAll:s,setAll:r,setItems:{[t]:i},removedItems:{}},{cookieOptions:e?.cookieOptions??null,cookieEncoding:n}),a[t]=i,delete o[t]},removeItem:async e=>{delete a[e],o[e]=!0}}}:{getAll:s,setAll:r,setItems:a,removedItems:o,storage:{isServer:!1,getItem:async e=>{let t=await s([e]),r=await tJ(e,async e=>{let s=t?.find(({name:t})=>t===e)||null;return s?s.value:null});if(!r)return null;let i=r;return r.startsWith(tZ)&&(i=tX(r.substring(tZ.length))),i},setItem:async(t,i)=>{let a=await s([t]),o=new Set((a?.map(({name:e})=>e)||[]).filter(e=>tK(e,t))),l=i;"base64url"===n&&(l=tZ+tQ(i));let u=tH(t,l);u.forEach(({name:e})=>{o.delete(e)});let c={...tF,...e?.cookieOptions,maxAge:0},h={...tF,...e?.cookieOptions,maxAge:tF.maxAge};delete c.name,delete h.name;let d=[...[...o].map(e=>({name:e,value:"",options:c})),...u.map(({name:e,value:t})=>({name:e,value:t,options:h}))];d.length>0&&await r(d)},removeItem:async t=>{let i=await s([t]),n=(i?.map(({name:e})=>e)||[]).filter(e=>tK(e,t)),a={...tF,...e?.cookieOptions,maxAge:0};delete a.name,n.length>0&&await r(n.map(e=>({name:e,value:"",options:a})))}}}}({...s,cookieEncoding:s?.cookieEncoding??"base64url"},!1),a=tM(e,t,{...s,global:{...s?.global,headers:{...s?.global?.headers,"X-Client-Info":"supabase-ssr/0.5.2"}},auth:{...s?.auth,...s?.cookieOptions?.name?{storageKey:s.cookieOptions.name}:null,flowType:"pkce",autoRefreshToken:tz(),detectSessionInUrl:tz(),persistSession:!0,storage:n}});return i&&(r=a),a}},9933:(e,t,s)=>
25{e.exports=s(39741)},10557:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});let i=r(s(21673)),n=r(s(37743));class a{constructor(e,{headers:t={},schema:s,fetch:r}={}){this.url=e,this.headers=new Headers(t),this.schemaName=s,this.fetch=r}from(e){let t=new URL(`${this.url}/${e}`);return new i.default(t,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new a(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:s=!1,get:r=!1,count:i}={}){var a;let o,l,u=new URL(`${this.url}/rpc/${e}`);s||r?(o=s?"HEAD":"GET",Object.entries(t).filter(([e,t])=>void 0!==t).map(([e,t])=>[e,Array.isArray(t)?`{${t.join(",")}}`:`${t}`]).forEach(([e,t])=>{u.searchParams.append(e,t)})):(o="POST",l=t);let c=new Headers(this.headers);return i&&c.set("Prefer",`count=${i}`),new n.default({method:o,url:u,headers:c,schema:this.schemaName,body:l,fetch:null!=(a=this.fetch)?a:fetch})}}t.default=a},21673:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});let i=r(s(37743));class n{constructor(e,{headers:t={},schema:s,fetch:r}){this.url=e,this.headers=new Headers(t),this.schema=s,this.fetch=r}select(e,{head:t=!1,count:s}={}){let r=!1,n=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!r?"":('"'===e&&(r=!r),e)).join("");return this.url.searchParams.set("select",n),s&&this.headers.append("Prefer",`count=${s}`),new i.default({method:t?"HEAD":"GET",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:s=!0}={}){var r;if(t&&this.headers.append("Prefer",`count=${t}`),s||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);this.url.searchParams.set("columns",e.join(","))}}return new i.default({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!=(r=this.fetch)?r:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:s=!1,count:r,defaultToNull:n=!0}={}){var a;if(this.headers.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),void 0!==t&&this.url.searchParams.set("on_conflict",t),r&&this.headers.append("Prefer",`count=${r}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);this.url.searchParams.set("columns",e.join(","))}}return new i.default({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!=(a=this.fetch)?a:fetch})}update(e,{count:t}={}){var s;return t&&this.headers.append("Prefer",`count=${t}`),new i.default({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!=(s=this.fetch)?s:fetch})}delete({count:e}={}){var t;return e&&this.headers.append("Prefer",`count=${e}`),new i.default({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:null!=(t=this.fetch)?t:fetch})}}t.default=n},25771:(e,t,s)=>{e.exports=s(54)},37743:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});let i=r(s(95457));class n extends i.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){let s=Array.from(new Set(t)).map(e=>"string"==typeof e&&RegExp("[,()]").test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`in.(${s})`),this}contains(e,t){return"string"==typeof t?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"string"==typeof t?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"string"==typeof t?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:s,type:r}={}){let i="";"plain"===r?i="pl":"phrase"===r?i="ph":"websearch"===r&&(i="w");let n=void 0===s?"":`(${s})`;return this.url.searchParams.append(e,`${i}fts${n}.${t}`),this}match(e){return Object.entries(e).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(e,t,s){return this.url.searchParams.append(e,`not.${t}.${s}`),this}or(e,{foreignTable:t,referencedTable:s=t}={}){let r=s?`${s}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}filter(e,t,s){return this.url.searchParams.append(e,`${t}.${s}`),this}}t.default=n},38936:(e,t,s)=>{s.r(t),s.d(t,{Headers:()=>a,Request:()=>o,Response:()=>l,default:()=>n,fetch:()=>i});var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==s.g)return s.g;throw Error("unable to locate global object")}();let i=r.fetch,n=r.fetch.bind(r),a=r.Headers,o=r.Request,l=r.Response},38974:(e,t,s)=>{s.d(t,{vt:()=>d});let r=e=>{let t,s=new Set,r=(e,r)=>{let i="function"==typeof e?e(t):e;if(!Object.is(i,t)){let e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({}
25,t,i),s.forEach(s=>s(t,e))}},i=()=>t,n={setState:r,getState:i,getInitialState:()=>a,subscribe:e=>(s.add(e),()=>s.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),s.clear()}},a=t=e(r,i,n);return n},i=e=>e?r(e):r;var n=s(13127),a=s(9933);let{useDebugValue:o}=n,{useSyncExternalStoreWithSelector:l}=a,u=!1,c=e=>e,h=e=>{"function"!=typeof e&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");let t="function"==typeof e?i(e):e,s=(e,s)=>(function(e,t=c,s){s&&!u&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),u=!0);let r=l(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,s);return o(r),r})(t,e,s);return Object.assign(s,t),s},d=e=>e?h(e):h},39741:(e,t,s)=>{var r=s(13127),i=s(25771),n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=i.useSyncExternalStore,o=r.useRef,l=r.useEffect,u=r.useMemo,c=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,s,r,i){var h=o(null);if(null===h.current){var d={hasValue:!1,value:null};h.current=d}else d=h.current;var f=a(e,(h=u(function(){function e(e){if(!l){if(l=!0,a=e,e=r(e),void 0!==i&&d.hasValue){var t=d.value;if(i(t,e))return o=t}return o=e}if(t=o,n(a,e))return t;var s=r(e);return void 0!==i&&i(t,s)?(a=e,t):(a=e,o=s)}var a,o,l=!1,u=void 0===s?null:s;return[function(){return e(t())},null===u?void 0:function(){return e(u())}]},[t,s,r,i]))[0],h[1]);return l(function(){d.hasValue=!0,d.value=f},[f]),c(f),f}},46483:(e,t)=>
25{t.q=function(e,t){if("string"!=typeof e)throw TypeError("argument str must be a string");var s={},i=e.length;if(i<2)return s;var n=t&&t.decode||c,a=0,o=0,h=0;do{if(-1===(o=e.indexOf("=",a)))break;if(-1===(h=e.indexOf(";",a)))h=i;else if(o>h){a=e.lastIndexOf(";",o-1)+1;continue}var d=l(e,a,o),f=u(e,o,d),p=e.slice(d,f);if(!r.call(s,p)){var g=l(e,o+1,h),y=u(e,h,g);34===e.charCodeAt(g)&&34===e.charCodeAt(y-1)&&(g++,y--);var m=e.slice(g,y);s[p]=function(e,t){try{return t(e)}catch(t){return e}}(m,n)}a=h+1}while(a<i);return s},t.l=function(e,t,r){var l=r&&r.encode||encodeURIComponent;if("function"!=typeof l)throw TypeError("option encode is invalid");if(!i.test(e))throw TypeError("argument name is invalid");var u=l(t);if(!n.test(u))throw TypeError("argument val is invalid");var c=e+"="+u;if(!r)return c;if(null!=r.maxAge){var h=Math.floor(r.maxAge);if(!isFinite(h))throw TypeError("option maxAge is invalid");c+="; Max-Age="+h}if(r.domain){if(!a.test(r.domain))throw TypeError("option domain is invalid");c+="; Domain="+r.domain}if(r.path){if(!o.test(r.path))throw TypeError("option path is invalid");c+="; Path="+r.path}if(r.expires){var d,f=r.expires;if(d=f,"[object Date]"!==s.call(d)||isNaN(f.valueOf()))throw TypeError("option expires is invali
25d");c+="; Expires="+f.toUTCString()}if(r.httpOnly&&(c+="; HttpOnly"),r.secure&&(c+="; Secure"),r.partitioned&&(c+="; Partitioned"),r.priority)switch("string"==typeof r.priority?r.priority.toLowerCase():r.priority){case"low":c+="; Priority=Low";break;case"medium":c+="; Priority=Medium";break;case"high":c+="; Priority=High";break;default:throw TypeError("option priority is invalid")}if(r.sameSite)switch("string"==typeof r.sameSite?r.sameSite.toLowerCase():r.sameSite){case!0:case"strict":c+="; SameSite=Strict";break;case"lax":c+="; SameSite=Lax";break;case"none":c+="; SameSite=None";break;default:throw TypeError("option sameSite is invalid")}return c};var s=Object.prototype.toString,r=Object.prototype.hasOwnProperty,i=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,n=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,a=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,o=/^[\u0020-\u003A\u003D-\u007E]*$/;function l(e,t,s){do{var r=e.charCodeAt(t);if(32!==r&&9!==r)return t}while(++t<s);return s}function u(e,t,s){for(;t>s;){var r=e.charCodeAt(--t);if(32!==r&&9!==r)return t+1}return s}
25function c(e){return -1!==e.indexOf("%")?decodeURIComponent(e):e}},59415:(e,t,s)=>{s.d(t,{Zr:()=>a});let r=e=>t=>{try{let s=e(t);if(s instanceof Promise)return s;return{then:e=>r(e)(s),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>r(t)(e)}}},i=(e,t)=>(s,i,n)=>{let a,o,l={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},u=!1,c=new Set,h=new Set;try{a=l.getStorage()}catch(e){}if(!a)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),s(...e)},i,n);let d=r(l.serialize),f=()=>{let e,t=d({state:l.partialize({...i()}),version:l.version}).then(e=>a.setItem(l.name,e)).catch(t=>{e=t});if(e)throw e;return t},p=n.setState;n.setState=(e,t)=>{p(e,t),f()};let g=e((...e)=>{s(...e),f()},i,n),y=()=>{var e;if(!a)return;u=!1,c.forEach(e=>e(i()));let t=(null==(e=l.onRehydrateStorage)?void 0:e.call(l,i()))||void 0;return r(a.getItem.bind(a))(l.name).then(e=>{if(e)return l.deserialize(e)}).then(e=>{if(e)if("number"!=typeof e.version||e.version===l.version)return e.state;else{if(l.migrate)return l.migrate(e.state,e.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}}).then(e=>{var t;return s(o=l.merge(e,null!=(t=i())?t:g),!0),f()}).then(()=>{null==t||t(o,void 0),u=!0,h.forEach(e=>e(o))}).catch(e=>{null==t||t(void 0,e)})};return n.persist={setOptions:e=>{l={...l,...e},e.getStorage&&(a=e.getStorage())},clearStorage:()=>{null==a||a.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>y(),hasHydrated:()=>u,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(h.add(e),()=>{h.delete(e)})},y(),o||g},n=(e,t)=>(s,i,n)=>{let a,o={storage:function(e,t){let s;try{s=e()}catch(e){return}return{getItem:e=>{var t;let r=e=>null===e?null:JSON.parse(e,void 0),i=null!=(t=s.getItem(e))?t:null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,t)=>s.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>s.removeItem(e)}}(()=>localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},l=!1,u=new Set,c=new Set,h=o.storage;if(!h)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),s(...e)},i,n);let d=()=>{let e=o.partialize({...i()});return h.setItem(o.name,{state:e,version:o.version})},f=n.setState;n.setState=(e,t)=>{f(e,t),d()};let p=e((...e)=>{s(...e),d()},i,n);n.getInitialState=()=>p;let g=()=>{var e,t;if(!h)return;l=!1,u.forEach(e=>{var t;return e(null!=(t=i())?t:p)});let n=(null==(t=o.onRehydrateStorage)?void 0:t.call(o,null!=(e=i())?e:p))||void 0;return r(h.getItem.bind(h))(o.name).then(e=>{if(e)if("number"!=typeof e.version||e.version===o.version)return[!1,e.state];else{if(o.migrate)return[!0,o.migrate(e.state,e.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;let[r,n]=e;if(s(a=o.merge(n,null!=(t=i())?t:p),!0),r)return d()}).then(()=>{null==n||n(a,void 0),a=i(),l=!0,c.forEach(e=>e(a))}).catch(e=>{null==n||n(void 0,e)})};return n.persist={setOptions:e=>{o={...o,...e},e.storage&&(h=e.storage)},clearStorage:()=>{null==h||h.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:e=>(u.add(e),()=>{u.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},o.skipHydration||g(),a||p},a=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?(console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),i(e,t)):n(e,t)},60989:(e,t,s)=>{s.d(t,{D:()=>ep});var r,i=Symbol.for("immer-nothing"),n=Symbol.for("immer-draftable"),a=Symbol.for("immer-state");function o(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var l=Object,u=l.getPrototypeOf,c="constructor",h="prototype",d="configurable",f="enumerable",p="writable",g="value",y=e=>!!e&&!!e[a];function m(e){return!!e&&(_(e)||j(e)||!!e[n]||!!e[c]?.[n]||O(e)||P(e))}var w=l[h][c].toString(),v=new WeakMap;function _(e){if(!e||!A(e))return!1;let t=u(e);if(null===t||t===l[h])return!0;let s=l.hasOwnProperty.call(t,c)&&t[c];if(s===Object)return!0;
25if(!C(s))return!1;let r=v.get(s);return void 0===r&&(r=Function.toString.call(s),v.set(s,r)),r===w}function b(e,t,s=!0){0===k(e)?(s?Reflect.ownKeys(e):l.keys(e)).forEach(s=>{t(s,e[s],e)}):e.forEach((s,r)=>t(r,s,e))}function k(e){let t=e[a];return t?t.type_:j(e)?1:O(e)?2:3*!!P(e)}var S=(e,t,s=k(e))=>2===s?e.has(t):l[h].hasOwnProperty.call(e,t),T=(e,t,s=k(e))=>2===s?e.get(t):e[t],E=(e,t,s,r=k(e))=>{2===r?e.set(t,s):3===r?e.add(s):e[t]=s},j=Array.isArray,O=e=>e instanceof Map,P=e=>e instanceof Set,A=e=>"object"==typeof e,C=e=>"function"==typeof e,$=e=>"boolean"==typeof e,I=e=>A(e)?e?.[a]:null,R=e=>e.copy_||e.base_,x=e=>e.modified_?e.copy_:e.base_;function U(e,t){if(O(e))return new Map(e);if(P(e))return new Set(e);if(j(e))return Array[h].slice.call(e);let s=_(e);if(!0!==t&&("class_only"!==t||s)){let t=u(e);if(null!==t&&s)return{...e};let r=l.create(t);return l.assign(r,e)}{let t=l.getOwnPropertyDescriptors(e);delete t[a];let s=Reflect.ownKeys(t);for(let r=0;r<s.length;r++){let i=s[r],n=t[i];!1===n[p]&&(n[p]=!0,n[d]=!0),(n.get||n.set)&&(t[i]={[d]:!0,[p]:!0,[f]:n[f],[g]:e[i]})}return l.create(u(e),t)}}function L(e,t=!1){return D(e)||y(e)||!m(e)||(k(e)>1&&l.defineProperties(e,{set:N,add:N,clear:N,delete:N}),l.freeze(e),t&&b(e,(e,t)=>{L(t,!0)},!1)),e}var N={[g]:function(){o(2)}};function D(e){return!(null!==e&&A(e))||l.isFrozen(e)}var q="MapSet",M="Patches",B="ArrayMethods",z={};function F(e){let t=z[e];return t||o(0,e),t}var W=e=>!!z[e],K=()=>r,H=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:W(q)?F(q):void 0,arrayMethodsPlugin_:W(B)?F(B):void 0});function J(e,t){t&&(e.patchPlugin_=F(M),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function G(e){V(e),e.drafts_.forEach(Q),e.drafts_=null}function V(e){e===r&&(r=e.parent_)}var Y=e=>r=H(r,e);function Q(e){let t=e[a];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function X(e,t){t.unfinalizedDrafts_=t.drafts_.length;let s=t.drafts_[0];if(void 0!==e&&e!==s){s[a].modified_&&(G(t),o(4)),m(e)&&(e=Z(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(s[a].base_,e,t)}else e=Z(t,s);return function(e,t,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&L(t,s)}(t,e,!0),G(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==i?e:void 0}function Z(e,t){if(D(t))return t;let s=t[a];if(!s)return en(t,e.handledSet_,e);if(!et(s,e))return t;if(!s.modified_)return s.base_;if(!s.finalized_){let{callbacks_:t}=s;if(t)for(;t.length>0;)t.pop()(e);ei(s,e)}return s.copy_}function ee(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var et=(e,t)=>e.scope_===t,es=[];function er(e,t,s,r){let i=R(e),n=e.type_;if(void 0!==r&&T(i,r,n)===t)return void E(i,r,s,n);if(!e.draftLocations_){let t=e.draftLocations_=new Map;b(i,(e,s)=>{if(y(s)){let r=t.get(s)||[];r.push(e),t.set(s,r)}})}for(let r of e.draftLocations_.get(t)??es)E(i,r,s,n)}function ei(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||1===e.type_&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:s}=t;if(s){let r=s.getPath(e);r&&s.generatePatches_(e,r,t)}ee(e)}}function en(e,t,s){return!s.immer_.autoFreeze_&&s.unfinalizedDrafts_<1||y(e)||t.has(e)||!m(e)||D(e)||(t.add(e),b(e,(r,i)=>{if(y(i)){let t=i[a];et(t,s)&&(E(e,r,x(t),e.type_),ee(t))}else m(i)&&en(i,t,s)})),e}var ea={get(e,t){if(t===a)return e;let s=e.scope_.arrayMethodsPlugin_,r=1===e.type_&&"string"==typeof t;if(r&&s?.isArrayOperationMethod(t))return s.createMethodInterceptor(e,t);let i=R(e);if(!S(i,t,e.type_)){var n=e,o=i,l=t;let s=eu(o,l);return s?g in s?s[g]:s.get?.call(n.draft_):void 0}let u=i[t];if(e.finalized_||!m(u)||r&&e.operationMethod&&s?.isMutatingArrayMethod(e.operationMethod)&&function(e){let t=+e;return Number.isInteger(t)&&String(t)===e}(t))return u;if(u===el(e.base_,t)){eh(e);let s=1===e.type_?+t:t,r=ed(e.scope_,u,e,s);return e.copy_[s]=r}return u},has:(e,t)=>t in R(e),ownKeys:e=>Reflect.ownKeys(R(e)),set(e,t,s){let r=eu(R(e),t);if(r?.set)return r.set.call(e.draft_,s),!0;if(!e.modified_){let r=el(R(e),t),i=r?.[a];if(i&&i.base_===s)return e.copy_[t]=s,e.assigned_.set(t,!1),!0;if((s===r?0!==s||1/s==1/r:s!=s&&r!=r)&&(void 0!==s||S(e.base_,t,e.type_)))return!0;eh(e),ec(e)}return!!(e.copy_[t]===s&&(void 0!==s||t in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[t]))||
25(e.copy_[t]=s,e.assigned_.set(t,!0),function(e,t,s){let{scope_:r}=e;if(y(s)){let i=s[a];et(i,r)&&i.callbacks_.push(function(){eh(e),er(e,s,x(i),t)})}else m(s)&&e.callbacks_.push(function(){let i=R(e);3===e.type_?i.has(s)&&en(s,r.handledSet_,r):T(i,t,e.type_)===s&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&en(T(e.copy_,t,e.type_),r.handledSet_,r)})}(e,t,s),!0)},deleteProperty:(e,t)=>(eh(e),void 0!==el(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),ec(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){let s=R(e),r=Reflect.getOwnPropertyDescriptor(s,t);return r?{[p]:!0,[d]:1!==e.type_||"length"!==t,[f]:r[f],[g]:s[t]}:r},defineProperty(){o(11)},getPrototypeOf:e=>u(e.base_),setPrototypeOf(){o(12)}},eo={};for(let e in ea){let t=ea[e];eo[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}function el(e,t){let s=e[a];return(s?R(s):e)[t]}function eu(e,t){if(!(t in e))return;let s=u(e);for(;s;){let e=Object.getOwnPropertyDescriptor(s,t);if(e)return e;s=u(s)}}function ec(e){!e.modified_&&(e.modified_=!0,e.parent_&&ec(e.parent_))}function eh(e){e.copy_||(e.assigned_=new Map,e.copy_=U(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function ed(e,t,s,r){let[i,n]=O(t)?F(q).proxyMap_(t,s):P(t)?F(q).proxySet_(t,s):function(e,t){let s=j(e),r={type_:+!!s,scope_:t?t.scope_:K(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,n=ea;s&&(i=[r],n=eo);let{revoke:a,proxy:o}=Proxy.revocable(i,n);return r.draft_=o,r.revoke_=a,[o,r]}(t,s);if((s?.scope_??K()).drafts_.push(i),n.callbacks_=s?.callbacks_??[],n.key_=r,
25s&&void 0!==r)s.callbacks_.push(function(e){if(!n||!et(n,e))return;e.mapSetPlugin_?.fixSetContents(n);let t=x(n);er(s,n.draft_??n,t,r),ei(n,e)});else n.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(n);let{patchPlugin_:t}=e;n.modified_&&t&&t.generatePatches_(n,[],e)});return i}eo.deleteProperty=function(e,t){return eo.set.call(this,e,t,void 0)},eo.set=function(e,t,s){return ea.set.call(this,e[0],t,s,e[0])};var ef=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,s)=>{let r;if(C(e)&&!C(t)){let s=t;t=e;let r=this;return function(e=s,...i){return r.produce(e,e=>t.call(this,e,...i))}}if(C(t)||o(6),void 0===s||C(s)||o(7),m(e)){let i=Y(this),n=ed(i,e,void 0),a=!0;try{r=t(n),a=!1}finally{a?G(i):V(i)}return J(i,s),X(r,i)}if(e&&A(e))o(1,e);else{if(void 0===(r=t(e))&&(r=e),r===i&&(r=void 0),this.autoFreeze_&&L(r,!0),s){let t=[],i=[];F(M).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),s(t,i)}return r}},this.produceWithPatches=(e,t)=>{let s,r;return C(e)?(t,...s)=>this.produceWithPatches(t,t=>e(t,...s)):[this.produce(e,t,(e,t)=>{s=e,r=t}),s,r]},$(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),$(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),$(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){var t;m(e)||o(8),y(e)&&(y(t=e)||o(10,t),e=function e(t){let s;if(!m(t)||D(t))return t;let r=t[a],i=!0;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,s=U(t,r.scope_.immer_.useStrictShallowCopy_),i=r.scope_.immer_.shouldUseStrictIteration()}else s=U(t,!0);return b(s,(t,r)=>{E(s,t,e(r))},i),r&&(r.finalized_=!1),s}(t));let s=Y(this),r=ed(s,e,void 0);return r[a].isManual_=!0,V(s),r}finishDraft(e,t){let s=e&&e[a];s&&s.isManual_||o(9);let{scope_:r}=s;return J(r,t),X(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let s;for(s=t.length-1;s>=0;s--){let r=t[s];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}s>-1&&(t=t.slice(s+1));let r=F(M).applyPatches_;return y(e)?r(e,t):this.produce(e,e=>r(e,t))}}().produce;let ep=e=>(t,s,r)=>(r.setState=(e,s,...r)=>t("function"==typeof e?ef(e):e,s,...r),e(r.setState,s,r))},61815:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;let i=r(s(10557));t.PostgrestClient=i.default;let n=r(s(21673));t.PostgrestQueryBuilder=n.default;let a=r(s(37743));t.PostgrestFilterBuilder=a.default;let o=r(s(95457));t.PostgrestTransformBuilder=o.default;let l=r(s(77189));t.PostgrestBuilder=l.default;let u=r(s(70592));t.PostgrestError=u.default,t.default={PostgrestClient:i.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:l.default,PostgrestError:u.default}},70592:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class s extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.co
25de=e.code}}t.default=s},77189:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});let i=r(s(38936)),n=r(s(70592));class a{constructor(e){var t,s;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=null!=(t=e.shouldThrowOnError)&&t,this.signal=e.signal,this.isMaybeSingle=null!=(s=e.isMaybeSingle)&&s,e.fetch?this.fetch=e.fetch:"undefined"==typeof fetch?this.fetch=i.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){void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json");let s=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async e=>{var t,s,r,i;let a=null,o=null,l=null,u=e.status,c=e.statusText;if(e.ok){if("HEAD"!==this.method){let s=await e.text();""===s||(o="text/csv"===this.headers.get("Accept")||this.headers.get("Accept")&&(null==(t=this.headers.get("Accept"))?void 0:t.includes("application/vnd.pgrst.plan+text"))?s:JSON.parse(s))}let i=null==(s=this.headers.get("Prefer"))?void 0:s.match(/count=(exact|planned|estimated)/),n=null==(r=e.headers.get("content-range"))?void 0:r.split("/");i&&n&&n.length>1&&(l=parseInt(n[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(o)&&(o.length>1?(a={code:"PGRST116",details:`Results contain ${o.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},o=null,l=null,u=406,c="Not Acceptable"):o=1===o.length?o[0]:null)}else{let t=await e.text();try{a=JSON.parse(t),Array.isArray(a)&&404===e.status&&(o=[],a=null,u=200,c="OK")}catch(s){404===e.status&&""===t?(u=204,c="No Content"):a={message:t}}if(a&&this.isMaybeSingle&&(null==(i=null==a?void 0:a.details)?void 0:i.includes("0 rows"))&&(a=null,u=200,c="OK"),a&&this.shouldThrowOnError)throw new n.default(a)}return{error:a,data:o,count:l,status:u,statusText:c}});return this.shouldThrowOnError||(s=s.catch(e=>{var t,s,r;return{error:{message:`${null!=(t=null==e?void 0:e.name)?t:"FetchError"}: ${null==e?void 0:e.message}`,details:`${null!=(s=null==e?void 0:e.stack)?s:""}`,hint:"",code:`${null!=(r=null==e?void 0:e.code)?r:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}}t.default=a},95457:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});let i=r(s(77189));class n extends i.default{select(e){let t=!1,s=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:s,foreignTable:r,referencedTable:i=r}={}){let n=i?`${i}.order`:"order",a=this.url.searchParams.get(n);return this.url.searchParams.set(n,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${void 0===s?"":s?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:s=t}={}){let r=void 0===s?"limit":`${s}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:s,referencedTable:r=s}={}){let i=void 0===r?"offset":`${r}.offset`,n=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(n,`${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"GET"===this.method?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}
25explain({analyze:e=!1,verbose:t=!1,settings:s=!1,buffers:r=!1,wal:i=!1,format:n="text"}={}){var a;let o=[e?"analyze":null,t?"verbose":null,s?"settings":null,r?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=null!=(a=this.headers.get("Accept"))?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${n}; for="${l}"; options=${o};`),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}}t.default=n}}]);

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.