1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2071],{1818:(e,t,r)=>{"use strict";r.d(t,{n:()=>l});var s=r(12115),i=r(7069),n=r(74268),a=r(34049),o=r(99776);function l(e,t){let r=(0,o.jE)(t),[l]=s.useState(()=>new i._(r,e));s.useEffect(()=>{l.setOptions(e)},[l,e]);let u=s.useSyncExternalStore(s.useCallback(e=>l.subscribe(n.jG.batchCalls(e)),[l]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),h=s.useCallback((e,t)=>{l.mutate(e,t).catch(a.lQ)},[l]);if(u.error&&(0,a.GU)(l.options.throwOnError,[u.error]))throw u.error;return{...u,mutate:h,mutateAsync:u.mutate}}},2954:(e,t,r)=>{"use strict";r.d(t,{$:()=>h});var s=r(56195),i=r(74268),n=r(31668),a=r(38445),o=r(83515),l=r(34049),u=r(37126),h=class extends a.Q{constructor(e,t){super(),this.options=t,this.#e=e,this.#t=null,this.#r=(0,o.T)(),this.bindMethods(),this.setOptions(t)}#e;#s=void 0;#i=void 0;#n=void 0;#a;#o;#r;#t;#l;#u;#h;#c;#d;#f;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#s.addObserver(this),c(this.#s,this.options)?this.#g():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return d(this.#s,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return d(this.#s,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#w(),this.#s.removeObserver(this)}setOptions(e){let t=this.options,r=this.#s;if(this.options=this.#e.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,l.Eh)(this.options.enabled,this.#s))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#b(),this.#s.setOptions(this.options),t._defaulted&&!(0,l.f8)(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#s,observer:this});let s=this.hasListeners();s&&f(this.#s,r,this.options,t)&&this.#g(),this.updateResult(),s&&(this.#s!==r||(0,l.Eh)(this.options.enabled,this.#s)!==(0,l.Eh)(t.enabled,this.#s)||(0,l.d2)(this.options.staleTime,this.#s)!==(0,l.d2)(t.staleTime,this.#s))&&this.#v();let i=this.#_();s&&(this.#s!==r||(0,l.Eh)(this.options.enabled,this.#s)!==(0,l.Eh)(t.enabled,this.#s)||i!==this.#f)&&this.#E(i)}getOptimisticResult(e){var t,r;let s=this.#e.getQueryCache().build(this.#e,e),i=this.createResult(s,e);return t=this,r=i,(0,l.f8)(t.getCurrentResult(),r)||(this.#n=i,this.#o=this.options,this.#a=this.#s.state),i}getCurrentResult(){return this.#n}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#r.status||this.#r.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#s}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),r=this.#e.getQueryCache().build(this.#e,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#g({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#n))}#g(e){this.#b();let t=this.#s.fetch(this.options,e);return e?.throwOnError||(t=t.catch(l.lQ)),t}#v(){this.#m();let e=(0,l.d2)(this.options.staleTime,this.#s);if(l.S$||this.#n.isStale||!(0,l.gn)(e))return;let t=(0,l.j3)(this.#n.dataUpdatedAt,e);this.#c=u.zs.setTimeout(()=>{this.#n.isStale||this.updateResult()},t+1)}#_(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#s):this.options.refetchInterval)??!1}#E(e){this.#w(),this.#f=e,!l.S$&&!1!==(0,l.Eh)(this.options.enabled,this.#s)&&(0,l.gn)(this.#f)&&0!==this.#f&&(this.#d=u.zs.setInterval(()=>{(this.options.refetchIntervalInBackground||s.m.isFocused())&&this.#g()},this.#f))}#y(){this.#v(),this.#E(this.#_())}#m(){this.#c&&(u.zs.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#d&&(u.zs.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let r,s=this.#s,i=this.options,a=this.#n,u=this.#a,h=this.#o,d=e!==s?e.state:this.#i,{state:g}=e,y={...g},m=!1;if(t._optimisticResults){let r=this.hasListeners(),a=!r&&c(e,t),o=r&&f(e,s,t,i);(a||o)&&(y={...y,...(0,n.k)(g.data,e.options)}),"isRestoring"===t._optimisticResults&&(y.fetchStatus="idle")}let{error:w,errorUpdatedAt:b,status:v}=y;r=y.data;let _=!1;if(void 0!==t.placeholderData&&void 0===r&&"pending"===v){let e;a?.isPlaceholderData&&t.placeholderData===h?.placeholderData?(e=a.data,_=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#h?.state.data,this.#h):t.placeholderData,void 0!==e&&(v="success",r=(0,l.pl)(a?.data,e,t),m=!0)}if(t.select&&void 0!==r&&!_)if(a&&r===u?.data&&t.select===this.#l)r=this.#u;else try{this.#l=t.select,r=t.select(r),r=(0,l.pl)(a?.data,r,t),this.#u=r,this.#t=null}catch(e){this.#t=e}this.#t&&(w=this.#t,r=this.#u,b=Date.now(),v="error");let E="fetching"===y.fetchStatus,S="pending"===v,O="error"===v,T=S&&E,R=void 0!==r,k={status:v,fetchStatus:y.fetchStatus,isPending:S,isSuccess:"success"===v,isError:O,isInitialLoading:T,isLoading:T,data:r,dataUpdatedAt:y.dataUpdatedAt,error:w,errorUpdatedAt:b,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdate
1Count:y.errorUpdateCount,isFetched:y.dataUpdateCount>0||y.errorUpdateCount>0,isFetchedAfterMount:y.dataUpdateCount>d.dataUpdateCount||y.errorUpdateCount>d.errorUpdateCount,isFetching:E,isRefetching:E&&!S,isLoadingError:O&&!R,isPaused:"paused"===y.fetchStatus,isPlaceholderData:m,isRefetchError:O&&R,isStale:p(e,t),refetch:this.refetch,promise:this.#r,isEnabled:!1!==(0,l.Eh)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=e=>{"error"===k.status?e.reject(k.error):void 0!==k.data&&e.resolve(k.data)},r=()=>{t(this.#r=k.promise=(0,o.T)())},i=this.#r;switch(i.status){case"pending":e.queryHash===s.queryHash&&t(i);break;case"fulfilled":("error"===k.status||k.data!==i.value)&&r();break;case"rejected":("error"!==k.status||k.error!==i.reason)&&r()}}return k}updateResult(){let e=this.#n,t=this.createResult(this.#s,this.options);if(this.#a=this.#s.state,this.#o=this.options,void 0!==this.#a.data&&(this.#h=this.#s),(0,l.f8)(t,e))return;this.#n=t;let r=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#p.size)return!0;let s=new Set(r??this.#p);return this.options.throwOnError&&s.add("error"),Object.keys(this.#n).some(t=>this.#n[t]!==e[t]&&s.has(t))};this.#S({listeners:r()})}#b(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#s)return;let t=this.#s;this.#s=e,this.#i=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(e){i.jG.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#n)}),this.#e.getQueryCache().notify({query:this.#s,type:"observerResultsUpdated"})})}};function c(e,t){return!1!==(0,l.Eh)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==t.retryOnMount)||void 0!==e.state.data&&d(e,t,t.refetchOnMount)}function d(e,t,r){if(!1!==(0,l.Eh)(t.enabled,e)&&"static"!==(0,l.d2)(t.staleTime,e)){let s="function"==typeof r?r(e):r;return"always"===s||!1!==s&&p(e,t)}return!1}function f(e,t,r,s){return(e!==t||!1===(0,l.Eh)(s.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&p(e,r)}function p(e,t){return!1!==(0,l.Eh)(t.enabled,e)&&e.isStaleByTime((0,l.d2)(t.staleTime,e))}},3913:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(71450).__importDefault(r(5732));class i{constructor(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!=(t=e.shouldThrowOnError)&&t,this.signal=e.signal,this.isMaybeSingle=null!=(r=e.isMaybeSingle)&&r,e.fetch?this.fetch=e.fetch: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 r=(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,r,i,n;let a=null,o=null,l=null,u=e.status,h=e.statusText;if(e.ok){if("HEAD"!==this.method){let r=await e.text();""===r||(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"))?r:JSON.parse(r))}let s=null==(r=this.headers.get("Prefer"))?void 0:r.match(/count=(exact|planned|estimated)/),n=null==(i=e.headers.get("content-range"))?void 0:i.split("/");s&&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,h="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,h="OK")}catch(r){404===e.status&&""===t?(u=204,h="No Content"):a={message:t}}if(a&&this.isMaybeSingle&&(null==(n=null==a?void 0:a.details)?void 0:n.includes("0 rows"))&&(a=null,u=200,h="OK"),a&&this.shouldThrowOnError)throw new s.default(a)}return{error:a,data:o,count:l,status:u,statusText:h}});return this.shouldThrowOnError||(r=r.catch(e=>{var t,r,s,i,n,a;let o="",l=null==e?void 0:e.cause;if(l){let n=null!=(t=null==l?void 0:l.message)?t:"",a=null!=(r=null==l?void 0:l.code)?r:"";o=`${null!=(s=null==e?void 0:e.name)?s:"FetchError"}: ${null==e?void 0:e.message} 2 3Caused by: ${null!=(i=null==l?void 0:l.name)?i:"Error"}: ${n}`,a&&(o+=` (${a})`),(null==l?void 0:l.stack)&&(o+=` 4${l.stack}`)}else o=null!=(n=null==e?void 0:e.stack)?n:"";return{error:{message:`${null!=(a=null==e?void 0:e.name)?a:"FetchError"}: ${null==e?void 0:e.message}`,details:o,hint:"",code:""},data:null,count:null,status:0,statusText:""}}
4)),r.then(e,t)}returns(){return this}overrideTypes(){return this}}t.default=i},5732:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class r extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}}t.default=r},7069:(e,t,r)=>{"use strict";r.d(t,{_:()=>o});var s=r(38559),i=r(74268),n=r(38445),a=r(34049),o=class extends n.Q{#e;#n=void 0;#O;#T;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#R()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),(0,a.f8)(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#O,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,a.EN)(t.mutationKey)!==(0,a.EN)(this.options.mutationKey)?this.reset():this.#O?.state.status==="pending"&&this.#O.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#O?.removeObserver(this)}onMutationUpdate(e){this.#R(),this.#S(e)}getCurrentResult(){return this.#n}reset(){this.#O?.removeObserver(this),this.#O=void 0,this.#R(),this.#S()}mutate(e,t){return this.#T=t,this.#O?.removeObserver(this),this.#O=this.#e.getMutationCache().build(this.#e,this.options),this.#O.addObserver(this),this.#O.execute(e)}#R(){let e=this.#O?.state??(0,s.$)();this.#n={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#S(e){i.jG.batch(()=>{if(this.#T&&this.hasListeners()){let t=this.#n.variables,r=this.#n.context,s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#T.onSuccess?.(e.data,t,r,s),this.#T.onSettled?.(e.data,null,t,r,s)):e?.type==="error"&&(this.#T.onError?.(e.error,t,r,s),this.#T.onSettled?.(void 0,e.error,t,r,s))}this.listeners.forEach(e=>{e(this.#n)})})}}},9052:(e,t,r)=>{"use strict";r.r(t),r.d(t,{StorageAnalyticsClient:()=>U,StorageApiError:()=>l,StorageClient:()=>Z,StorageError:()=>a,StorageUnknownError:()=>u,StorageVectorsApiError:()=>L,StorageVectorsClient:()=>Q,StorageVectorsError:()=>N,StorageVectorsErrorCode:()=>i,StorageVectorsUnknownError:()=>D,VectorBucketApi:()=>J,VectorBucketScope:()=>Y,VectorDataApi:()=>z,VectorIndexApi:()=>G,VectorIndexScope:()=>X,isPlainObject:()=>M,isStorageError:()=>o,isStorageVectorsError:()=>B,normalizeToFloat32:()=>K,resolveFetch:()=>F,resolveResponse:()=>q,validateVectorDimension:()=>W});var s,i,n=r(71450);class a extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function o(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}class l extends a{constructor(e,t,r){super(e),this.name="StorageApiError",this.status=t,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class u extends a{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}let h=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),c=e=>{if(Array.isArray(e))return e.map(e=>c(e));if("function"==typeof e||e!==Object(e))return e;let t={};return Object.entries(e).forEach(([e,r])=>{t[e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""))]=c(r)}),t},d=e=>{var t;return e.msg||e.message||e.error_description||("string"==typeof e.error?e.error:null==(t=e.error)?void 0:t.message)||JSON.stringify(e)};function f(e,t,r,s,i,a){return(0,n.__awaiter)(this,void 0,void 0,function*(){return new Promise((o,h)=>{e(r,((e,t,r,s)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"!==e&&s?((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)})(s)?(i.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),i.body=JSON.stringify(s)):i.body=s,(null==t?void 0:t.duplex)&&(i.duplex=t.duplex),Object.assign(Object.assign({},i),r)):i})(t,s,i,a)).then(e=>{if(!e.ok)throw e;return(null==s?void 0:s.noResolveJson)?e:e.json()}).then(e=>o(e)).catch(e=>(0,n.__awaiter)(void 0,void 0,void 0,function*(){e instanceof(yield Response)&&!(null==s?void 0:s.noResolveJson)?e.json().then(t=>{let r=e.status||500,s=(null==t?void 0:t.statusCode)||r+"";h(new l(d(t),r,s))}).catch(e=>{h(new u(d(e),e))}):h(new u(d(e),e))}))})})}function p(e,t,r,s){return(0,n.__awaiter)(this,void 0,void 0,function*(){return f(e,"GET",t,r,s)})}function g(e,t,r,s,i){return(0,n.__awaiter)(this,void 0,void 0,function*(){return f(e,"POST",t,s,i,r)})}function y(e,t,r,s,i){return(0,n.__awaiter)(this,void 0,void 0,function*(){return f(e,"PUT",t,s,i,r)})}function m(e,t,r,s,i){return(0,n.__awaiter)(this,void 0,void 0,function*(){return f(e,"DELETE",t,s,i,r)})}class w{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t}then(e,t){return this.execute().then(e,t)}execute(){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}}class b{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[s]="BlobDownloadBuilder",this.promise=null}asStream(){return new w(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}execute(){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{let e=yield this.downloadFn();return{data:yield e.blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}}s=Symbol.toStringTag;var v=r(81029).hp;let _={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},E={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class S{constructor(e,t={},r,s){this.shouldThrowOnError=!1,this.url=e,this.headers=t,this.bucketId=r,this.fetch=h(s)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(e,t,r,s){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{let i,n=Object.assign(Object.assign({},E),s),a=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(n.upsert)}),o=n.metadata;"undefined"!=typeof Blob&&r instanceof Blob?((i=new FormData).append("cacheControl",n.cacheControl),o&&i.append("metadata",this.encodeMetadata(o)),i.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?((i=r).has("cacheControl")||i.append("cacheControl",n.cacheControl),o&&!i.has("metadata")&&i.append("metadata",this.encodeMetadata(o))):(i=r,a["cache-control"]=`max-age=${n.cacheControl}`,a["content-type"]=n.contentType,o&&(a["x-metadata"]=this.toBase64(this.encodeMetadata(o))),("undefined"!=typeof ReadableStream&&i instanceof ReadableStream||i&&"object"==typeof i&&"pipe"in i&&"function"==typeof i.pipe)&&!n.duplex&&(n.duplex="half")),(null==s?void 0:s.headers)&&(a=Object.assign(Object.assign({},a),s.headers));let l=this._removeEmptyFolders(t),u=this._getFinalPath(l),h=yield("PUT"==e?y:g)(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:h.Id,fullPath:h.Key},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}upload(e,t,r){return(0,n.__awaiter)(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}uploadToSignedUrl(e,t,r,s){return(0,n.__awaiter)(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:E.upsert},s),n=Object.assign(Object.assign({},this.headers),{"x-upsert":String(t.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?((e=new FormData).append("cacheControl",t.cacheControl),e.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(e=r).append("cacheControl",t.cacheControl):(e=r,n["cache-control"]=`max-age=${t.cacheControl}`,n["content-type"]=t.contentType);let o=yield y(this.fetch,a.toString(),e,{headers:n});return{data:{path:i,fullPath:o.Key},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}createSignedUploadUrl(e,t){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e),s=Object.assign({},this.headers);(null==t?void 0:t.upsert)&&(s["x-upsert"]="true");let i=yield g(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:s}),n=new URL(this.url+i.url),o=n.searchParams.get("token");if(!o)throw new a("No token returned by API");return{data:{signedUrl:n.toString(),path:e,token:o},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}update(e,t,r){return(0,n.__awaiter)(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t,r){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield g(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,de
4stinationBucket:null==r?void 0:r.destinationBucket},{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}copy(e,t,r){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:{path:(yield g(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:this.headers})).Key},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}createSignedUrl(e,t,r){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield g(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:t},(null==r?void 0:r.transform)?{transform:r.transform}:{}),{headers:this.headers}),n=(null==r?void 0:r.download)?`&download=${!0===r.download?"":r.download}`:"";return{data:i={signedUrl:encodeURI(`${this.url}${i.signedURL}${n}`)},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}createSignedUrls(e,t,r){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{let s=yield g(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=(null==r?void 0:r.download)?`&download=${!0===r.download?"":r.download}`:"";return{data:s.map(e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}${i}`):null})),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}download(e,t){let r=void 0!==(null==t?void 0:t.transform)?"render/image/authenticated":"object",s=this.transformOptsToQueryString((null==t?void 0:t.transform)||{}),i=s?`?${s}`:"",n=this._getFinalPath(e);return new b(()=>p(this.fetch,`${this.url}/${r}/${n}${i}`,{headers:this.headers,noResolveJson:!0}),this.shouldThrowOnError)}info(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{let e=yield p(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:c(e),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}exists(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{return yield function(e,t,r,s){return(0,n.__awaiter)(this,void 0,void 0,function*(){return f(e,"HEAD",t,Object.assign(Object.assign({},r),{noResolveJson:!0}),void 0)})}(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e)&&e instanceof u){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 r=this._getFinalPath(e),s=[],i=(null==t?void 0:t.download)?`download=${!0===t.download?"":t.download}`:"";""!==i&&s.push(i);let n=void 0!==(null==t?void 0:t.transform),a=this.transformOptsToQueryString((null==t?void 0:t.transform)||{});""!==a&&s.push(a);let o=s.join("&");return""!==o&&(o=`?${o}`),{data:{publicUrl:encodeURI(`${this.url}/${n?"render/image":"object"}/public/${r}${o}`)}}}remove(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield m(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}list(e,t,r){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{let s=Object.assign(Object.assign(Object.assign({},_),t),{prefix:e||""});return{data:yield g(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}listV2(e,t){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{let r=Object.assign({},e);return{data:yield g(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,r,{headers:this.headers},t),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return void 0!==v?v.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 O="2.87.1",T={"X-Client-Info":`storage-js/${O}`};class R{constructor(e,t={},r,s){this.shouldThrowOnError=!1;let i=new URL(e);(null==s?void 0:s.useNewHostname)&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase.")),this.url=i.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},T),t),this.fetch=h(r)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{let t=this.listBucketOptionsToQueryString(e);return{data:yield p(this.fetch,`${this.url}/bucket${t}`,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}getBucket(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield p(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}createBucket(e){return(0,n.__awaiter)(this,arguments,void 0,function*(e,t={public:!1}){try{return{data:yield g(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(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}updateBucket(e,t){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield y(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(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}emptyBucket(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield g(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}deleteBucket(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield m(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}listBucketOptionsToQueryString(e){let t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}}
4var k=class extends Error{constructor(e,t){super(e),this.name="IcebergError",this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown="CommitStateUnknownException"===t.icebergType||[500,502,504].includes(t.status)&&t.icebergType?.includes("CommitState")===!0}isNotFound(){return 404===this.status}isConflict(){return 409===this.status}isAuthenticationTimeout(){return 419===this.status}};async function A(e){return e&&"none"!==e.type?"bearer"===e.type?{Authorization:`Bearer ${e.token}`}:"header"===e.type?{[e.name]:e.value}:"custom"===e.type?await e.getHeaders():{}:{}}function j(e){return e.join("\x1f")}var C=class{constructor(e,t=""){this.client=e,this.prefix=t}async listNamespaces(e){let t=e?{parent:j(e.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:t})).data.namespaces.map(e=>({namespace:e}))}async createNamespace(e,t){let r={namespace:e.namespace,properties:t?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${j(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${j(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${j(e.namespace)}`}),!0}catch(e){if(e instanceof k&&404===e.status)return!1;throw e}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(e){if(e instanceof k&&409===e.status)return;throw e}}};function I(e){return e.join("\x1f")}var P=class{constructor(e,t="",r){this.client=e,this.prefix=t,this.accessDelegation=r}async listTables(e){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${I(e.namespace)}/tables`})).data.identifiers}async createTable(e,t){let r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${I(e.namespace)}/tables`,body:t,headers:r})).data.metadata}async updateTable(e,t){let r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${I(e.namespace)}/tables/${e.name}`,body:t});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(e,t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${I(e.namespace)}/tables/${e.name}`,query:{purgeRequested:String(t?.purge??!1)}})}async loadTable(e){let t={};return this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${I(e.namespace)}/tables/${e.name}`,headers:t})).data.metadata}async tableExists(e){let t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${I(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(e){if(e instanceof k&&404===e.status)return!1;throw e}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(r){if(r instanceof k&&409===r.status)return await this.loadTable({namespace:e.namespace,name:t.name});throw r}}},x=class{constructor(e){let t="v1";e.catalogName&&(t+=`/${e.catalogName}`);let r=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.client=function(e){let t=e.fetchImpl??globalThis.fetch;return{async request({method:r,path:s,query:i,body:n,headers:a}){let o=function(e,t,r){let s=new URL(t,e);if(r)for(let[e,t]of Object.entries(r))void 0!==t&&s.searchParams.set(e,t);return s.toString()}(e.baseUrl,s,i),l=await A(e.auth),u=await t(o,{method:r,headers:{...n?{"Content-Type":"application/json"}:{},...l,...a},body:n?JSON.stringify(n):void 0}),h=await u.text(),c=(u.headers.get("content-type")||"").includes("application/json"),d=c&&h?JSON.parse(h):h;if(!u.ok){let e=c?d:void 0,t=e?.error;throw new k(t?.message??`Request failed with status ${u.status}`,{status:u.status,icebergType:t?.type,icebergCode:t?.code,details:e})}return{status:u.status,headers:u.headers,data:d}}}}({baseUrl:r,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=e.accessDelegation?.join(","),this.namespaceOps=new C(this.client,t),this.tableOps=new P(this.client,t,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}
4async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}};class U{constructor(e,t={},r){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},T),t),this.fetch=h(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield g(this.fetch,`${this.url}/bucket`,{name:e},{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}listBuckets(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{let t=new URLSearchParams;(null==e?void 0:e.limit)!==void 0&&t.set("limit",e.limit.toString()),(null==e?void 0:e.offset)!==void 0&&t.set("offset",e.offset.toString()),(null==e?void 0:e.sortColumn)&&t.set("sortColumn",e.sortColumn),(null==e?void 0:e.sortOrder)&&t.set("sortOrder",e.sortOrder),(null==e?void 0:e.search)&&t.set("search",e.search);let r=t.toString(),s=r?`${this.url}/bucket?${r}`:`${this.url}/bucket`;return{data:yield p(this.fetch,s,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}deleteBucket(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield m(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(o(e))return{data:null,error:e};throw e}})}from(e){if(!(!(!e||"string"!=typeof e||0===e.length||e.length>100||e.trim()!==e||e.includes("/")||e.includes("\\"))&&/^[\w!.\*'() &$@=;:+,?-]+$/.test(e)))throw new a("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");let t=new x({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:()=>(0,n.__awaiter)(this,void 0,void 0,function*(){return this.headers})},fetch:this.fetch}),r=this.shouldThrowOnError;return new Proxy(t,{get(e,t){let s=e[t];return"function"!=typeof s?s:(...t)=>(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield s.apply(e,t),error:null}}catch(e){if(r)throw e;return{data:null,error:e}}})}})}}let $={"X-Client-Info":`storage-js/${O}`,"Content-Type":"application/json"};class N extends Error{constructor(e){super(e),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function B(e){return"object"==typeof e&&null!==e&&"__isStorageVectorsError"in e}class L extends N{constructor(e,t,r){super(e),this.name="StorageVectorsApiError",this.status=t,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class D extends N{constructor(e,t){super(e),this.name="StorageVectorsUnknownError",this.originalError=t}}!function(e){e.InternalError="InternalError",e.S3VectorConflictException="S3VectorConflictException",e.S3VectorNotFoundException="S3VectorNotFoundException",e.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",e.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",e.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"}(i||(i={}));let F=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),q=()=>Response,M=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)},K=e=>Array.from(new Float32Array(e)),W=(e,t)=>{if(void 0!==t&&e.float32.length!==t)throw Error(`Vector dimension mismatch: expected ${t}, got ${e.float32.length}`)},V=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e);function H(e,t,r,s,i){return(0,n.__awaiter)(this,void 0,void 0,function*(){return function(e,t,r,s,i,a){return(0,n.__awaiter)(this,void 0,void 0,function*(){return new Promise((o,l)=>{e(r,((e,t,r,s)=>{let i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"!==e&&s?(M(s)?(i.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),i.body=JSON.stringify(s)):i.body=s,Object.assign(Object.assign({},i),r)):i})(t,s,i,a)).then(e=>{if(!e.ok)throw e;if(null==s?void 0:s.noResolveJson)return e;let t=e.headers.get("content-type");return t&&t.includes("application/json")?e.json():{}}).then(e=>o(e)).catch(e=>(0,n.__awaiter)(void 0,void 0,void 0,function*(){if(!(e&&"object"==typeof e&&"status"in e&&"ok"in e&&"number"==typeof e.status)||(null==s?void 0:s.noResolveJson))l(new D(V(e),e));else{let t=e.status||500;"function"==typeof e.json?e.json().then(e=>{let r=(null==e?void 0:e.statusCode)||(null==e?void 0:e.code)||t+"";l(new L(V(e),t,r))}).catch(()=>{l(new L(e.statusText||`HTTP ${t} error`,t,t+""))}):l(new L(e.statusText||`HTTP ${t} error`,t,t+""))}}))})})}(e,"POST",t,s,i,r)})}class G{constructor(e,t={},r){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},$),t),this.fetch=F(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:(yield H(this.fetch,`${this.url}/CreateIndex`,e,{headers:this.headers}))||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}getIndex(e,t){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield H(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}listIndexes(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield H(this.fetch,`${this.url}/ListIndexes`,e,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}deleteIndex(e,t){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:(yield H(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:this.headers}))||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}}class z{constructor(e,t={},r){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},$),t),this.fetch=F(r)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{if(e.vectors.length<1||e.vectors.length>500)throw Error("Vector batch size must be between 1 and 500 items");return{data:(yield H(this.fetch,`${this.url}/PutVectors`,e,{headers:this.headers}))||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}getVectors(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield H(this.fetch,`${this.url}/GetVectors`,e,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}listVectors(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{if(void 0!==e.segmentCount){if(e.segmentCount<1||e.segmentCount>16)throw Error("segmentCount must be between 1 and 16");
4if(void 0!==e.segmentIndex&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return{data:yield H(this.fetch,`${this.url}/ListVectors`,e,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}queryVectors(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield H(this.fetch,`${this.url}/QueryVectors`,e,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}deleteVectors(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{if(e.keys.length<1||e.keys.length>500)throw Error("Keys batch size must be between 1 and 500 items");return{data:(yield H(this.fetch,`${this.url}/DeleteVectors`,e,{headers:this.headers}))||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}}class J{constructor(e,t={},r){this.shouldThrowOnError=!1,this.url=e.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},$),t),this.fetch=F(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:(yield H(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:this.headers}))||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}getBucket(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:yield H(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:e},{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}listBuckets(){return(0,n.__awaiter)(this,arguments,void 0,function*(e={}){try{return{data:yield H(this.fetch,`${this.url}/ListVectorBuckets`,e,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}deleteBucket(e){return(0,n.__awaiter)(this,void 0,void 0,function*(){try{return{data:(yield H(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:this.headers}))||{},error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(B(e))return{data:null,error:e};throw e}})}}class Q extends J{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new Y(this.url,this.headers,e,this.fetch)}createBucket(e){let t=Object.create(null,{createBucket:{get:()=>super.createBucket}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.createBucket.call(this,e)})}getBucket(e){let t=Object.create(null,{getBucket:{get:()=>super.getBucket}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.getBucket.call(this,e)})}listBuckets(){let e=Object.create(null,{listBuckets:{get:()=>super.listBuckets}});return(0,n.__awaiter)(this,arguments,void 0,function*(t={}){return e.listBuckets.call(this,t)})}deleteBucket(e){let t=Object.create(null,{deleteBucket:{get:()=>super.deleteBucket}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.deleteBucket.call(this,e)})}}class Y extends G{constructor(e,t,r,s){super(e,t,s),this.vectorBucketName=r}createIndex(e){let t=Object.create(null,{createIndex:{get:()=>super.createIndex}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.createIndex.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName}))})}listIndexes(){let e=Object.create(null,{listIndexes:{get:()=>super.listIndexes}});return(0,n.__awaiter)(this,arguments,void 0,function*(t={}){return e.listIndexes.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName}))})}getIndex(e){let t=Object.create(null,{getIndex:{get:()=>super.getIndex}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.getIndex.call(this,this.vectorBucketName,e)})}deleteIndex(e){let t=Object.create(null,{deleteIndex:{get:()=>super.deleteIndex}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.deleteIndex.call(this,this.vectorBucketName,e)})}index(e){return new X(this.url,this.headers,this.vectorBucketName,e,this.fetch)}}class X extends z{constructor(e,t,r,s,i){super(e,t,i),this.vectorBucketName=r,this.indexName=s}putVectors(e){let t=Object.create(null,{putVectors:{get:()=>super.putVectors}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.putVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}getVectors(e){let t=Object.create(null,{getVectors:{get:()=>super.getVectors}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.getVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}listVectors(){let e=Object.create(null,{listVectors:{get:()=>super.listVectors}});return(0,n.__awaiter)(this,arguments,void 0,function*(t={}){return e.listVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}queryVectors(e){let t=Object.create(null,{queryVectors:{get:()=>super.queryVectors}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.queryVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}deleteVectors(e){let t=Object.create(null,{deleteVectors:{get:()=>super.deleteVectors}});return(0,n.__awaiter)(this,void 0,void 0,function*(){return t.deleteVectors.call(this,Object.assign(Object.assign({},e),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class Z extends R{constructor(e,t={},r,s){super(e,t,r,s)}from(e){return new S(this.url,this.headers,e,this.fetch)}get vectors(){return new Q(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new U(this.url+"/iceberg",this.headers,this.fetch)}}},21786:(e,t,r)=>{"use strict";
4Object.defineProperty(t,"__esModule",{value:!0}),t.SupabaseAuthClient=void 0;let s=r(44703);class i extends s.AuthClient{constructor(e){super(e)}}t.SupabaseAuthClient=i},28202:(e,t)=>{"use strict";function r(e){return e.endsWith("/")?e:e+"/"}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=void 0,t.uuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})},t.ensureTrailingSlash=r,t.applySettingDefaults=function(e,t){var r,s;let{db:i,auth:n,realtime:a,global:o}=e,{db:l,auth:u,realtime:h,global:c}=t,d={db:Object.assign(Object.assign({},l),i),auth:Object.assign(Object.assign({},u),n),realtime:Object.assign(Object.assign({},h),a),storage:{},global:Object.assign(Object.assign(Object.assign({},c),o),{headers:Object.assign(Object.assign({},null!=(r=null==c?void 0:c.headers)?r:{}),null!=(s=null==o?void 0:o.headers)?s:{})}),accessToken:async()=>""};return e.accessToken?d.accessToken=e.accessToken:delete d.accessToken,d},t.validateSupabaseUrl=function(e){let t=null==e?void 0:e.trim();if(!t)throw Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(r(t))}catch(e){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}},t.isBrowser=()=>"undefined"!=typeof window},31668:(e,t,r)=>{"use strict";r.d(t,{X:()=>o,k:()=>l});var s=r(34049),i=r(74268),n=r(93049),a=r(69781),o=class extends a.k{#k;#A;#j;#e;#C;#I;#P;constructor(e){super(),this.#P=!1,this.#I=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#e=e.client,this.#j=this.#e.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#k=h(this.options),this.state=e.state??this.#k,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#C?.promise}setOptions(e){if(this.options={...this.#I,...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let e=h(this.options);void 0!==e.data&&(this.setState(u(e.data,e.dataUpdatedAt)),this.#k=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#j.remove(this)}setData(e,t){let r=(0,s.pl)(this.state.data,e,this.options);return this.#x({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#x({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#C?.promise;return this.#C?.cancel(e),t?t.then(s.lQ).catch(s.lQ):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#k)}isActive(){return this.observers.some(e=>!1!==(0,s.Eh)(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===s.hT||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===(0,s.d2)(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!(0,s.j3)(this.state.dataUpdatedAt,e))}onFocus(){let e=this.observers.find(e=>e.shouldFetchOnWindowFocus());e?.refetch({cancelRefetch:!1}),this.#C?.continue()}onOnline(){let e=this.observers.find(e=>e.shouldFetchOnReconnect());e?.refetch({cancelRefetch:!1}),this.#C?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#j.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#C&&(this.#P?this.#C.cancel({revert:!0}):this.#C.cancelRetry()),this.scheduleGc()),this.#j.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#x({type:"invalidate"})}async fetch(e,t){if("idle"!==this.state.fetchStatus&&this.#C?.status()!=="rejected"){if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#C)return this.#C.continueRetry(),this.#C.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let r=new AbortController,i=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#P=!0,r.signal)}
4)},a=()=>{let e=(0,s.ZM)(this.options,t),r=(()=>{let e={client:this.#e,queryKey:this.queryKey,meta:this.meta};return i(e),e})();return(this.#P=!1,this.options.persister)?this.options.persister(e,r,this):e(r)},o=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#e,state:this.state,fetchFn:a};return i(e),e})();this.options.behavior?.onFetch(o,this),this.#A=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#x({type:"fetch",meta:o.fetchOptions?.meta}),this.#C=(0,n.II)({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:e=>{e instanceof n.cc&&e.revert&&this.setState({...this.#A,fetchStatus:"idle"}),r.abort()},onFail:(e,t)=>{this.#x({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#x({type:"pause"})},onContinue:()=>{this.#x({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{let e=await this.#C.start();if(void 0===e)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#j.config.onSuccess?.(e,this),this.#j.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof n.cc){if(e.silent)return this.#C.promise;else if(e.revert){if(void 0===this.state.data)throw e;return this.state.data}}throw this.#x({type:"error",error:e}),this.#j.config.onError?.(e,this),this.#j.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#x(e){let t=t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...l(t.data,this.options),fetchMeta:e.meta??null};case"success":let r={...t,...u(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#A=e.manual?r:void 0,r;case"error":let s=e.error;return{...t,error:s,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),i.jG.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#j.notify({query:this,type:"updated",action:e})})}};function l(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:(0,n.v_)(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function u(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function h(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,s=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}},33742:(e,t,r)=>{"use strict";r.d(t,{d:()=>a,w:()=>n});var s=r(12115),i=s.createContext(!1),n=()=>s.useContext(i),a=i.Provider},34049:(e,t,r)=>{"use strict";r.d(t,{BH:()=>m,Cp:()=>g,EN:()=>p,Eh:()=>h,F$:()=>f,GU:()=>j,MK:()=>c,S$:()=>i,ZM:()=>A,ZZ:()=>R,Zw:()=>a,d2:()=>u,f8:()=>w,gn:()=>o,hT:()=>k,j3:()=>l,lQ:()=>n,nJ:()=>d,pl:()=>S,rX:()=>O,y9:()=>T,yy:()=>E});var s=r(37126),i="undefined"==typeof window||"Deno"in globalThis;function n(){}function a(e,t){return"function"==typeof e?e(t):e}function o(e){return"number"==typeof e&&e>=0&&e!==1/0}function l(e,t){return Math.max(e+(t||0)-Date.now(),0)}function u(e,t){return"function"==typeof e?e(t):e}function h(e,t){return"function"==typeof e?e(t):e}function c(e,t){let{type:r="all",exact:s,fetchStatus:i,predicate:n,queryKey:a,stale:o}=e;if(a){if(s){if(t.queryHash!==f(a,t.options))return!1}else if(!g(t.queryKey,a))return!1}if("all"!==r){let e=t.isActive();if("active"===r&&!e||"inactive"===r&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&(!i||i===t.state.fetchStatus)&&(!n||!!n(t))}function d(e,t){let{exact:r,status:s,predicate:i,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(r){if(p(t.options.mutationKey)!==p(n))return!1}else if(!g(t.options.mutationKey,n))return!1}return(!s||t.state.status===s)&&(!i||!!i(t))}function f(e,t){return(t?.queryKeyHashFn||p)(e)}function p(e){return JSON.stringify(e,(e,t)=>v(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function g(e,t){return e===t||typeof e==typeof t&&!!e&&!!t&&"object"==typeof e&&"object"==typeof t&&Object.keys(t).every(r=>g(e[r],t[r]))}var y=Object.prototype.hasOwnProperty;function m(e,t){if(e===t)return e;let r=b(e)&&b(t);if(!r&&!(v(e)&&v(t)))return t;let s=(r?e:Object.keys(e)).length,i=r?t:Object.keys(t),n=i.length,a=r?Array(n):{},o=0;for(let l=0;l<n;l++){let n=r?l:i[l],u=e[n],h=t[n];if(u===h){a[n]=u,(r?l<s:y.call(e,n))&&o++;continue}if(null===u||null===h||"object"!=typeof u||"object"!=typeof h){a[n]=h;continue}let c=m(u,h);a[n]=c,c===u&&o++}return s===n&&o===s?e:a}function w(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}function b(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function v(e){if(!_(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!!_(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function _(e){return"[object Object]"===Object.prototype.toString.call(e)}function E(e){return new Promise(t=>{s.zs.setTimeout(t,e)})}function S(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?m(e,t):t}function O(e){return e}function T(e,t,r=0){let s=[...e,t];return r&&s.length>r?s.slice(1):s}function R(e,t,r=0){let s=[t,...e];return r&&s.length>r?s.slice(0,-1):s}var k=Symbol();function A(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==k?e.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`))}function j(e,t){return"function"==typeof e?e(...t):!!e}},36347:(e,t,r)=>{"use strict";r.d(t,{UU:()=>d});var s,i=r(59639);let{PostgrestError:n,FunctionsHttpError:a,FunctionsFetchError:o,FunctionsRelayError:l,FunctionsError:u,FunctionRegion:h,SupabaseClient:c,createClient:d,GoTrueAdminApi:f,GoTrueClient:p,AuthAdminApi:g,AuthClient:y,navigatorLock:m,NavigatorLockAcquireTimeoutError:w,lockInternals:b,processLock:v,SIGN_OUT_SCOPES:_,AuthError:E,AuthApiError:S,AuthUnknownError:O,CustomAuthError:T,AuthSessionMissingError:R,AuthInvalidToken
4ResponseError:k,AuthInvalidCredentialsError:A,AuthImplicitGrantRedirectError:j,AuthPKCEGrantCodeExchangeError:C,AuthRetryableFetchError:I,AuthWeakPasswordError:P,AuthInvalidJwtError:x,isAuthError:U,isAuthApiError:$,isAuthSessionMissingError:N,isAuthImplicitGrantRedirectError:B,isAuthRetryableFetchError:L,isAuthWeakPasswordError:D,RealtimePresence:F,RealtimeChannel:q,RealtimeClient:M,REALTIME_LISTEN_TYPES:K,REALTIME_POSTGRES_CHANGES_LISTEN_EVENT:W,REALTIME_PRESENCE_LISTEN_EVENTS:V,REALTIME_SUBSCRIBE_STATES:H,REALTIME_CHANNEL_STATES:G}=i||s||(s=r.t(i,2));i||s||(s=r.t(i,2))},36687:(e,t,r)=>{"use strict";r.d(t,{$1:()=>o,LJ:()=>n,wZ:()=>a});var s=r(12115),i=r(34049),n=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&!t.isReset()&&(e.retryOnMount=!1)},a=e=>{s.useEffect(()=>{e.clearReset()},[e])},o=e=>{let{result:t,errorResetBoundary:r,throwOnError:s,query:n,suspense:a}=e;return t.isError&&!r.isReset()&&!t.isFetching&&n&&(a&&void 0===t.data||(0,i.GU)(s,[t.error,n]))}},37126:(e,t,r)=>{"use strict";r.d(t,{Zq:()=>n,zs:()=>i});var s={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},i=new class{#U=s;#$=!1;setTimeoutProvider(e){this.#U=e}setTimeout(e,t){return this.#U.setTimeout(e,t)}clearTimeout(e){this.#U.clearTimeout(e)}setInterval(e,t){return this.#U.setInterval(e,t)}clearInterval(e){this.#U.clearInterval(e)}};function n(e){setTimeout(e,0)}},37977:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(71450),i=s.__importDefault(r(72901)),n=s.__importDefault(r(54419));class a{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.fetch=s}from(e){if(!e||"string"!=typeof e||""===e.trim())throw Error("Invalid relation name: relation must be a non-empty string.");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:r=!1,get:s=!1,count:i}={}){var a;let o,l,u=new URL(`${this.url}/rpc/${e}`);r||s?(o=r?"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 h=new Headers(this.headers);return i&&h.set("Prefer",`count=${i}`),new n.default({method:o,url:u,headers:h,schema:this.schemaName,body:l,fetch:null!=(a=this.fetch)?a:fetch})}}t.default=a},38445:(e,t,r)=>{"use strict";r.d(t,{Q:()=>s});var s=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}}},38559:(e,t,r)=>{"use strict";r.d(t,{$:()=>o,s:()=>a});var s=r(74268),i=r(69781),n=r(93049),a=class extends i.k{#e;#N;#B;#C;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#B=e.mutationCache,this.#N=[],this.state=e.state||o(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#N.includes(e)||(this.#N.push(e),this.clearGcTimeout(),this.#B.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#N=this.#N.filter(t=>t!==e),this.scheduleGc(),this.#B.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#N.length||("pending"===this.state.status?this.scheduleGc():this.#B.remove(this))}continue(){return this.#C?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#x({type:"continue"})},r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#C=(0,n.II)({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#x({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#x({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#B.canRun(this)});let s="pending"===this.state.status,i=!this.#C.canStart();try{if(s)t();else{this.#x({type:"pending",variables:e,isPaused:i}),await this.#B.config.onMutate?.(e,this,r);let t=await this.options.onMutate?.(e,r);t!==this.state.context&&this.#x({type:"pending",context:t,variables:e,isPaused:i})}let n=await this.#C.start();return await this.#B.config.onSuccess?.(n,e,this.state.context,this,r),await this.options.onSuccess?.(n,e,this.state.context,r),await this.#B.config.onSettled?.(n,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(n,null,e,this.state.context,r),this.#x({type:"success",data:n}),n}catch(t){try{throw await this.#B.config.onError?.(t,e,this.state.context,this,r),await this.options.onError?.(t,e,this.state.context,r),await this.#B.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(void 0,t,e,this.state.context,r),t}finally{this.#x({type:"error",error:t})}}finally{this.#B.runNext(this)}}#x(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};
4case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),s.jG.batch(()=>{this.#N.forEach(t=>{t.onMutationUpdate(e)}),this.#B.notify({mutation:this,type:"updated",action:e})})}};function o(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}},44703:(e,t,r)=>{"use strict";r.r(t),r.d(t,{AuthAdminApi:()=>eD,AuthApiError:()=>c,AuthClient:()=>eF,AuthError:()=>u,AuthImplicitGrantRedirectError:()=>b,AuthInvalidCredentialsError:()=>w,AuthInvalidJwtError:()=>R,AuthInvalidTokenResponseError:()=>m,AuthPKCEGrantCodeExchangeError:()=>_,AuthRetryableFetchError:()=>E,AuthSessionMissingError:()=>g,AuthUnknownError:()=>f,AuthWeakPasswordError:()=>O,CustomAuthError:()=>p,GoTrueAdminApi:()=>ed,GoTrueClient:()=>eL,NavigatorLockAcquireTimeoutError:()=>ey,SIGN_OUT_SCOPES:()=>ec,isAuthApiError:()=>d,isAuthError:()=>h,isAuthImplicitGrantRedirectError:()=>v,isAuthRetryableFetchError:()=>S,isAuthSessionMissingError:()=>y,isAuthWeakPasswordError:()=>T,lockInternals:()=>ep,navigatorLock:()=>ew,processLock:()=>ev});var s=r(71450);let i="2.87.1",n={"X-Client-Info":`gotrue-js/${i}`},a="X-Supabase-Api-Version",o={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},l=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i;class u extends Error{constructor(e,t,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=r}}function h(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class c extends u{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}function d(e){return h(e)&&"AuthApiError"===e.name}class f extends u{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class p extends u{constructor(e,t,r,s){super(e,r,s),this.name=t,this.status=r}}class g extends p{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function y(e){return h(e)&&"AuthSessionMissingError"===e.name}class m extends p{constructor(){super("Auth session or user missing","AuthInvalidToken
4ResponseError",500,void 0)}}class w extends p{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class b extends p{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function v(e){return h(e)&&"AuthImplicitGrantRedirectError"===e.name}class _ extends p{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 E extends p{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function S(e){return h(e)&&"AuthRetryableFetchError"===e.name}class O extends p{constructor(e,t,r){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=r}}function T(e){return h(e)&&"AuthWeakPasswordError"===e.name}class R extends p{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}let k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),A=" \n\r=".split(""),j=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<A.length;t+=1)e[A[t].charCodeAt(0)]=-2;for(let t=0;t<k.length;t+=1)e[k[t].charCodeAt(0)]=t;return e})();function C(e,t,r){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)r(k[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;)r(k[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function I(e,t,r){let s=j[e];if(s>-1)for(t.queue=t.queue<<6|s,t.queuedBits+=6;t.queuedBits>=8;)r(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else if(-2===s)return;else throw Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}function P(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},s={utf8seq:0,codepoint:0},i={queue:0,queuedBits:0},n=e=>{!function(e,t,r){if(0===t.utf8seq){if(e<=127)return r(e);for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;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&&r(t.codepoint)}}(e,s,r)};for(let t=0;t<e.length;t+=1)I(e.charCodeAt(t),i,n);return t.join("")}function x(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)I(e.charCodeAt(t),r,s);return new Uint8Array(t)}function U(e){let t=[],r={queue:0,queuedBits:0},s=e=>{t.push(e)};return e.forEach(e=>C(e,r,s)),C(null,r,s),t.join("")}let $=()=>"undefined"!=typeof window&&"undefined"!=typeof document,N={tested:!1,writable:!1},B=()=>{if(!$())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(N.tested)return N.writable;let e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),N.tested=!0,N.writable=!0}catch(e){N.tested=!0,N.writable=!1}return N.writable},L=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),D=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},F=async(e,t)=>{let r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return r}},q=async(e,t)=>{await e.removeItem(t)};class M{constructor(){this.promise=new M.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function K(e){let t=e.split(".");if(3!==t.length)throw new R("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!l.test(t[e]))throw new R("JWT not in base64url format");return{header:JSON.parse(P(t[0])),payload:JSON.parse(P(t[1])),signature:x(t[2]),raw:{header:t[0],payload:t[1]}}}async function W(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function V(e){return("0"+e.toString(16)).substr(-2)}async function H(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 G(e){return"undefined"==typeof crypto||void 0===crypto.subtle||"undefined"==typeof TextEncoder?(console.warn("WebCrypto API is not supported. Code
4challenge method will default to use plain instead of sha256."),e):btoa(await H(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function z(e,t,r=!1){let s=function(){let e=new Uint32Array(56);if("undefined"==typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,r="";for(let s=0;s<56;s++)r+=e.charAt(Math.floor(Math.random()*t));return r}return crypto.getRandomValues(e),Array.from(e,V).join("")}(),i=s;r&&(i+="/PASSWORD_RECOVERY"),await D(e,`${t}-code-verifier`,i);let n=await G(s),a=s===n?"plain":"s256";return[n,a]}M.promiseConstructor=Promise;let J=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i,Q=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Y(e){if(!Q.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function X(){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 Z(e){return JSON.parse(JSON.stringify(e))}let ee=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),et=[502,503,504];async function er(e){var t;let r,s;if(!("object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json))throw new E(ee(e),0);if(et.includes(e.status))throw new E(ee(e),e.status);try{r=await e.json()}catch(e){throw new f(ee(e),e)}let i=function(e){let t=e.headers.get(a);if(!t||!t.match(J))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch(e){return null}}(e);if(i&&i.getTime()>=o["2024-01-01"].timestamp&&"object"==typeof r&&r&&"string"==typeof r.code?s=r.code:"object"==typeof r&&r&&"string"==typeof r.error_code&&(s=r.error_code),s){if("weak_password"===s)throw new O(ee(r),e.status,(null==(t=r.weak_password)?void 0:t.reasons)||[]);else if("session_not_found"===s)throw new g}else if("object"==typeof r&&r&&"object"==typeof r.weak_password&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0))throw new O(ee(r),e.status,r.weak_password.reasons);throw new c(ee(r),e.status||500,s)}async function es(e,t,r,s){var i;let n=Object.assign({},null==s?void 0:s.headers);n[a]||(n[a]=o["2024-01-01"].name),(null==s?void 0:s.jwt)&&(n.Authorization=`Bearer ${s.jwt}`);let l=null!=(i=null==s?void 0:s.query)?i:{};(null==s?void 0:s.redirectTo)&&(l.redirect_to=s.redirectTo);let u=Object.keys(l).length?"?"+new URLSearchParams(l).toString():"",h=await ei(e,t,r+u,{headers:n,noResolveJson:null==s?void 0:s.noResolveJson},{},null==s?void 0:s.body);return(null==s?void 0:s.xform)?null==s?void 0:s.xform(h):{data:Object.assign({},h),error:null}}async function ei(e,t,r,s,i,n){let a,o=((e,t,r,s)=>{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(s),Object.assign(Object.assign({},i),r))})(t,s,i,n);try{a=await e(r,Object.assign({},o))}catch(e){throw console.error(e),new E(ee(e),0)}if(a.ok||await er(a),null==s?void 0:s.noResolveJson)return a;try{return await a.json()}catch(e){await er(e)}}function en(e){var t,r,s;let i=null;(s=e).access_token&&s.refresh_token&&s.expires_in&&(i=Object.assign({},e),e.expires_at||(i.expires_at=(r=e.expires_in,Math.round(Date.now()/1e3)+r)));return{data:{session:i,user:null!=(t=e.user)?t:e},error:null}}function ea(e){let t=en(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)=>
4e&&"string"==typeof t,!0)&&(t.data.weak_password=e.weak_password),t}function eo(e){var t;return{data:{user:null!=(t=e.user)?t:e},error:null}}function el(e){return{data:e,error:null}}function eu(e){let{action_link:t,email_otp:r,hashed_token:i,redirect_to:n,verification_type:a}=e;return{data:{properties:{action_link:t,email_otp:r,hashed_token:i,redirect_to:n,verification_type:a},user:Object.assign({},(0,s.__rest)(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function eh(e){return e}let ec=["global","local","others"];class ed{constructor({url:e="",headers:t={},fetch:r}){this.url=e,this.headers=t,this.fetch=L(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(e,t=ec[0]){if(0>ec.indexOf(t))throw Error(`@supabase/auth-js: Parameter scope must be one of ${ec.join(", ")}`);try{return await es(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if(h(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e,t={}){try{return await es(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:eo})}catch(e){if(h(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,r=(0,s.__rest)(e,["options"]),i=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(i.new_email=null==r?void 0:r.newEmail,delete i.newEmail),await es(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:i,headers:this.headers,xform:eu,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if(h(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await es(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:eo})}catch(e){if(h(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,r,s,i,n,a,o;try{let l={nextPage:null,lastPage:0,total:0},u=await es(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:null!=(r=null==(t=null==e?void 0:e.page)?void 0:t.toString())?r:"",per_page:null!=(i=null==(s=null==e?void 0:e.perPage)?void 0:s.toString())?i:""},xform:eh});if(u.error)throw u.error;let h=await u.json(),c=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)),r=JSON.parse(e.split(";")[1].split("=")[1]);l[`${r}Page`]=t}),l.total=parseInt(c)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(h(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){Y(e);try{return await es(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:eo})}catch(e){if(h(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){Y(e);try{return await es(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:eo})}catch(e){if(h(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){Y(e);try{return await es(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:eo})}catch(e){if(h(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){Y(e.userId);try{let{data:t,error:r}=await es(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:r}}catch(e){if(h(e))return{data:null,error:e};throw e}}async _deleteFactor(e){Y(e.userId),Y(e.id);try{return{data:await es(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(e){if(h(e))return{data:null,error:e};throw e}}async _listOAuthClients(e){var t,r,s,i,n,a,o;try{let l={nextPage:null,lastPage:0,total:0},u=await es(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:null!=(r=null==(t=null==e?void 0:e.page)?void 0:t.toString())?r:"",per_page:null!=(i=null==(s=null==e?void 0:e.perPage)?void 0:s.toString())?i:""},xform:eh});if(u.error)throw u.error;let h=await u.json(),c=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>
40&&(d.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);l[`${r}Page`]=t}),l.total=parseInt(c)),{data:Object.assign(Object.assign({},h),l),error:null}}catch(e){if(h(e))return{data:{clients:[]},error:e};throw e}}async _createOAuthClient(e){try{return await es(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(h(e))return{data:null,error:e};throw e}}async _getOAuthClient(e){try{return await es(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(h(e))return{data:null,error:e};throw e}}async _updateOAuthClient(e,t){try{return await es(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(h(e))return{data:null,error:e};throw e}}async _deleteOAuthClient(e){try{return await es(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if(h(e))return{data:null,error:e};throw e}}async _regenerateOAuthClientSecret(e){try{return await es(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if(h(e))return{data:null,error:e};throw e}}}function ef(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}let ep={debug:!!(globalThis&&B()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"))};class eg extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class ey extends eg{}class em extends eg{}async function ew(e,t,r){ep.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);let s=new globalThis.AbortController;return t>0&&setTimeout(()=>{s.abort(),ep.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:s.signal},async s=>{if(s){ep.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,s.name);try{return await r()}finally{ep.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,s.name)}}if(0===t)throw ep.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new ey(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(ep.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 r()}))}let eb={};async function ev(e,t,r){var s;let i=null!=(s=eb[e])?s:Promise.resolve(),n=Promise.race([i.catch(()=>null),t>=0?new Promise((r,s)=>{setTimeout(()=>{s(new em(`Acquring process lock with name "${e}" timed out`))},t)}):null].filter(e=>e)).catch(e=>{if(e&&e.isAcquireTimeout)throw e;return null}).then(async()=>await r());return eb[e]=n.catch(async e=>{if(e&&e.isAcquireTimeout)return await i,null;throw e}),await n}function e_(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}class eE extends Error{constructor({message:e,code:t,cause:r,name:s}){var i;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=null!=(i=null!=s?s:r instanceof Error?r.name:void 0)?i:"Unknown Error",this.code=t}}class eS extends eE{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}class eO{createNewAbortSignal(){if(this.controller){let e=Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}let eT=new eO;function eR(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function ek(){var e,t;return!!($()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&"function"==typeof(null==(e=null==navigator?void 0:navigator.credentials)?void 0:e.create)&&"function"==typeof(null==(t=null==navigator?void 0:navigator.credentials)?void 0:t.get))}async function eA(e){try{let t=await navigator.credentials.create(e);if(!t)return{data:null,error:new eS("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new eS("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function({error:e,options:t}){var r,s,i;let{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new eE({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if((null==(r=n.authenticatorSelection)?void 0:r.requireResidentKey)===!0)return new eE({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});else if("conditional"===t.mediation&&(null==(s=n.authenticatorSelection)?void 0:s.userVerification)==="required")return new eE({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});else if((null==(i=n.authenticatorSelection)?void 0:i.userVerification)==="required")return new eE({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else if("InvalidStateError"===e.name)return new eE({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});else if("NotAllowedError"===e.name)return new eE({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("NotSupportedError"===e.name)return new eE(0===n.pubKeyCredParams.filter(e=>"public-key"===e.type).length?{message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}:{message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!eR(t))return new eE({message:`${window.location.hostname}
4 is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rp.id!==t)return new eE({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new eE({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new eE({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new eE({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}async function ej(e){try{let t=await navigator.credentials.get(e);if(!t)return{data:null,error:new eS("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new eS("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function({error:e,options:t}){let{publicKey:r}=t;if(!r)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new eE({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("NotAllowedError"===e.name)return new eE({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!eR(t))return new eE({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(r.rpId!==t)return new eE({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new eE({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new eE({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}let eC={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},eI={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function eP(...e){let t=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),r=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),s={};for(let i of e)if(i)for(let e in i){let n=i[e];if(void 0!==n)if(Array.isArray(n))s[e]=n;else if(r(n))s[e]=n;else if(t(n)){let r=s[e];t(r)?s[e]=eP(r,n):s[e]=eP(n)}else s[e]=n}return s}class ex{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:t,friendlyName:r,signal:s},i){try{var n,a,o,l;let{data:u,error:h}=await this.client.mfa.challenge({factorId:e,webauthn:t});if(!u)return{data:null,error:h};let c=null!=s?s:eT.createNewAbortSignal();if("create"===u.webauthn.type){let{user:e}=u.webauthn.credential_options.publicKey;e.name||(e.name=`${e.id}:${r}`),e.displayName||(e.displayName=e.name)}switch(u.webauthn.type){case"create":{let t=(n=u.webauthn.credential_options.publicKey,a=null==i?void 0:i.create,eP(eC,n,a||{})),{data:r,error:s}=await eA({publicKey:t,signal:c});if(r)return{data:{factorId:e,challengeId:u.id,webauthn:{type:u.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}case"request":{let t=(o=u.webauthn.credential_options.publicKey,l=null==i?void 0:i.request,eP(eI,o,l||{})),{data:r,error:s}=await ej(Object.assign(Object.assign({},u.webauthn.credential_options),{publicKey:t,signal:c}));if(r)return{data:{factorId:e,challengeId:u.id,webauthn:{type:u.webauthn.type,credential_response:r}},error:null};return{data:null,error:s}}}}catch(e){if(h(e))return{data:null,error:e};return{data:null,error:new f("Unexpected error in challenge",e)}}}async _verify({challengeId:e,factorId:t,webauthn:r}){return this.client.mfa.verify({factorId:t,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:t="undefined"!=typeof window?window.location.hostname:void 0,rpOrigins:r="undefined"!=typeof window?[window.location.origin]:void 0,signal:s}={}},i){if(!t)return{data:null,error:new u("rpId is required for WebAuthn authentication")};try{if(!ek())return{data:null,error:new f("Browser does not support WebAuthn",null)};let{data:n,error:a}=await this.challenge({factorId:e,webauthn:{rpId:t,rpOrigins:r},signal:s},{request:i});if(!n)return{data:null,error:a};let{webauthn:o}=n;return this._verify({factorId:e,challengeId:n.challengeId,webauthn:{type:o.type,rpId:t,rpOrigins:r,credential_response:o.credential_response}})}catch(e){if(h(e))return{data:null,error:e};return{data:null,error:new f("Unexpected error in authenticate",e)}}}async _register({friendlyName:e,webauthn:{rpId:t="undefined"!=typeof window?window.location.hostname:void 0,rpOrigins:r="undefined"!=typeof window?[window.location.origin]:void 0,signal:s}={}},i){if(!t)return{data:null,error:new u("rpId is required for WebAuthn registration")};try{if(!ek())return{data:null,error:new f("Browser does not support WebAuthn",null)};let{data:n,error:a}=await this._enroll({friendlyName:e});if(!n)return await this.client.mfa.listFactors().then(t=>{var r;return null==(r=t.data)?void 0:r.all.find(t=>"webauthn"===t.factor_type&&t.friendly_name===e&&"unverified"!==t.status)}).then(e=>e?this.client.mfa.unenroll({factorId:null==e?void 0:e.id}):void 0),{data:null,error:a};let{data:o,error:l}=await this._challenge({factorId:n.id,friendlyName:n.friendly_name,webauthn:{rpId:t,rpOrigins:r},signal:s},{create:i});if(!o)return{data:null,error:l};return this._verify({factorId:n.id,challengeId:o.challengeId,webauthn:{rpId:t,rpOrigins:r,type:o.webauthn.type,credential_response:o.webauthn.credential_response}})}catch(e){if(h(e))return{data:null,error:e};return{data:null,error:new f("Unexpected error in register",e)}}}}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 eU={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:n,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1};async function e$(e,t,r){return await r()}let eN={};class eB{get jwks(){var e,t;return null!=(t=null==(e=eN[this.storageKey])?void 0:e.jwks)?t:{keys:[]}}set jwks(e){eN[this.storageKey]=Object.assign(Object.assign({},eN[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!=(t=null==(e=eN[this.storageKey])?void 0:e.cachedAt)?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){eN[this.storageKey]=Object.assign(Object.assign({},eN[this.storageKey]),{cachedAt:e})}constructor(e){var t,r,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;let i=Object.assign(Object.assign({},eU),e);
4if(this.storageKey=i.storageKey,this.instanceID=null!=(t=eB.nextInstanceID[this.storageKey])?t:0,eB.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!i.debug,"function"==typeof i.debug&&(this.logger=i.debug),this.instanceID>0&&$()){let e=`${this._logPrefix()} 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.`;console.warn(e),this.logDebugMessages&&console.trace(e)}if(this.persistSession=i.persistSession,this.autoRefreshToken=i.autoRefreshToken,this.admin=new ed({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=L(i.fetch),this.lock=i.lock||e$,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,this.throwOnError=i.throwOnError,i.lock?this.lock=i.lock:this.persistSession&&$()&&(null==(r=null==globalThis?void 0:globalThis.navigator)?void 0:r.locks)?this.lock=ew:this.lock=e$,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new ex(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(i.storage?this.storage=i.storage:B()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=ef(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=ef(this.memoryStorage)),$()&&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()}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${i}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...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={},r="none";if($()&&(t=function(e){let t={},r=new URL(e);if(r.hash&&"#"===r.hash[0])try{new URLSearchParams(r.hash.substring(1)).forEach((e,r)=>{t[r]=e})}catch(e){}return r.searchParams.forEach((e,r)=>{t[r]=e}),t}(window.location.href),this._isImplicitGrantCallback(t)?r="implicit":await this._isPKCECallback(t)&&(r="pkce")),$()&&this.detectSessionInUrl&&"none"!==r){let{data:s,error:i}=await this._getSessionFromURL(t,r);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),v(i)){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}=s;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(h(e))return this._returnResult({error:e});return this._returnResult({error:new f("Unexpected error during initialization",e)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,r,s;try{let{data:i,error:n}=await es(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:null!=(r=null==(t=null==e?void 0:e.options)?void 0:t.data)?r:{},gotrue_meta_security:{captcha_token:null==(s=null==e?void 0:e.options)?void 0:s.captchaToken}},xform:en});if(n||!i)return this._returnResult({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)),this._returnResult({data:{user:o,session:a},error:null})}catch(e){if(h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signUp(e){var t,r,s;try{let i;if("email"in e){let{email:r,password:s,options:n}=e,a=null,o=null;"pkce"===this.flowType&&([a,o]=await z(this.storage,this.storageKey)),i=await es(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:null==n?void 0:n.emailRedirectTo,body:{email:r,password:s,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:en})}else if("phone"in e){let{phone:t,password:n,options:a}=e;i=await es(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:n,data:null!=(r=null==a?void 0:a.data)?r:{},channel:null!=(s=null==a?void 0:a.channel)?s:"sms",gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken}},xform:en})}else throw new w("You must provide either an email or phone number and a password");let{data:n,error:a}=i;if(a||!n)return await q(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({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)),this._returnResult({data:{user:l,session:o},error:null})}catch(e){if(await q(this.storage,`${this.storageKey}-code-verifier`),h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithPassword(e){try{let t;if("email"in e){let{email:r,password:s,options:i}=e;t=await es(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:r,password:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:ea})}else if("phone"in e){let{phone:r,password:s,options:i}=e;t=await es(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:r,password:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:ea})}else throw new w("You must provide either an email or phone number and a password");let{data:r,error:s}=t;if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!r||!r.session||!r.user){let e=new m;return this._returnResult({data:{user:null,session:null},error:e})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(e){if(h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOAuth(e){var t,r,s,i;return await this._handleProviderSignIn(e.provider,{redirectTo:null==(t=e.options)?void 0:t.redirectTo,scopes:null==(r=e.options)?void 0:r.scopes,queryParams:null==(s=e.options)?void 0:s.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;switch(t){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw Error(`@supabase/auth-js: Unsupported chain "${t}"`)}}async signInWithEthereum(e){var t,r,s,i,n,a,o,l,u,c,d,f;let p,g;if("message"in e)p=e.message,g=e.signature;else{let h,{chain:c,wallet:d,statement:y,options:m}=e;if($())if("object"==typeof d)h=d;else{let e=window;if("ethereum"in e&&"object"==typeof e.ethereum&&"request"in e.ethereum&&"function"==typeof e.ethereum.request)h=e.ethereum;else throw Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if("object"!=typeof d||!(null==m?void 0:m.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");h=d}let w=new URL(null!=(t=null==m?void 0:m.url)?t:window.location.href),b=await h.request({method:"eth_requestAccounts"}).then(e=>e).catch(()=>{throw Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!b||0===b.length)throw Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");let v=e_(b[0]),_=null==(r=null==m?void 0:m.signInWithEthereum)?void 0:r.chainId;_||(_=parseInt(await h.request({method:"eth_chainId"}),16)),p=function(e){var t;let{chainId:r,domain:s,expirationTime:i,issuedAt:n=new Date,nonce:a,notBefore:o,requestId:l,resources:u,scheme:h,uri:c,version:d}=e;if(!Number.isInteger(r))throw Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(a&&a.length<8)throw Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${a}`);if(!c)throw Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if("1"!==d)throw Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${d}`);if(null==(t=e.statement)?void 0:t.includes("\n"))throw Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`);let f=e_(e.address),p=h?`${h}://${s}`:s,g=e.statement?`${e.statement} 5`:"",y=`${p} wants you to sign in with your Ethereum account: 6${f} 7 8${g}`,m=`URI: ${c} 9Version: ${d}
10Chain ID: ${r}${a?` 11Nonce: ${a}`:""} 12Issued At: ${n.toISOString()}`;if(i&&(m+=` 13Expiration Time: ${i.toISOString()}`),o&&(m+=` 14Not Before: ${o.toISOString()}`),l&&(m+=` 15Request ID: ${l}`),u){let e="\nResources:";for(let t of u){if(!t||"string"!=typeof t)throw Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${t}`);e+=` 16- ${t}`}m+=e}return`${y} 17${m}`}({domain:w.host,address:v,statement:y,uri:w.href,version:"1",chainId:_,nonce:null==(s=null==m?void 0:m.signInWithEthereum)?void 0:s.nonce,issuedAt:null!=(n=null==(i=null==m?void 0:m.signInWithEthereum)?void 0:i.issuedAt)?n:new Date,expirationTime:null==(a=null==m?void 0:m.signInWithEthereum)?void 0:a.expirationTime,notBefore:null==(o=null==m?void 0:m.signInWithEthereum)?void 0:o.notBefore,requestId:null==(l=null==m?void 0:m.signInWithEthereum)?void 0:l.requestId,resources:null==(u=null==m?void 0:m.signInWithEthereum)?void 0:u.resources}),g=await h.request({method:"personal_sign",params:[(f=p,"0x"+Array.from(new TextEncoder().encode(f),e=>e.toString(16).padStart(2,"0")).join("")),v]})}try{let{data:t,error:r}=await es(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:p,signature:g},(null==(c=e.options)?void 0:c.captchaToken)?{gotrue_meta_security:{captcha_token:null==(d=e.options)?void 0:d.captchaToken}}:null),xform:en});if(r)throw r;if(!t||!t.session||!t.user){let e=new m;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:r})}catch(e){if(h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSolana(e){var t,r,s,i,n,a,o,l,u,c,d,f;let p,g;if("message"in e)p=e.message,g=e.signature;else{let h,{chain:d,wallet:f,statement:y,options:m}=e;if($())if("object"==typeof f)h=f;else{let e=window;if("solana"in e&&"object"==typeof e.solana&&("signIn"in e.solana&&"function"==typeof e.solana.signIn||"signMessage"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 f||!(null==m?void 0:m.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");h=f}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)p="string"==typeof e.signedMessage?e.signedMessage:new TextDecoder().decode(e.signedMessage),g=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");p=[`${w.host} wants you to sign in with your Solana account:`,h.publicKey.toBase58(),...y?["",y,""]:[""],"Version: 1",`URI: ${w.href}`,`Issued At: ${null!=(s=null==(r=null==m?void 0:m.signInWithSolana)?void 0:r.issuedAt)?s: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(p),"utf8");if(!e||!(e instanceof Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");g=e}}try{let{data:t,error:r}=await es(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:p,signature:U(g)},(null==(d=e.options)?void 0:d.captchaToken)?{gotrue_meta_security:{captcha_token:null==(f=e.options)?void 0:f.captchaToken}}:null),xform:en});if(r)throw r;if(!t||!t.session||!t.user){let e=new m;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:r})}catch(e){if(h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _exchangeCodeForSession(e){let t=await F(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(null!=t?t:"").split("/");try{let{data:t,error:i}=await es(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:en});if(await q(this.storage,`${this.storageKey}-code-verifier`),i)throw i;if(!t||!t.session||!t.user){let e=new m;return this._returnResult({data:{user:null,session:null,redirectType:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign(Object.assign({},t),{redirectType:null!=s?s:null}),error:i})}catch(e){if(await q(this.storage,`${this.storageKey}-code-verifier`),h(e))return this._returnResult({data:{user:null,session:null,redirectType:null},error:e});throw e}}async signInWithIdToken(e){try{let{options:t,provider:r,token:s,access_token:i,nonce:n}=e,{data:a,error:o}=await es(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:i,nonce:n,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:en});if(o)return this._returnResult({data:{user:null,session:null},error:o});if(!a||!a.session||!a.user){let e=new m;return this._returnResult({data:{user:null,session:null},error:e})}return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),this._returnResult({data:a,error:o})}catch(e){if(h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOtp(e){var t,r,s,i,n;try{if("email"in e){let{email:s,options:i}=e,n=null,a=null;"pkce"===this.flowType&&([n,a]=await z(this.storage,this.storageKey));let{error:o}=await es(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:s,data:null!=(t=null==i?void 0:i.data)?t:{},create_user:null==(r=null==i?void 0:i.shouldCreateUser)||r,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 this._returnResult({data:{user:null,session:null},error:o})}if("phone"in e){let{phone:t,options:r}=e,{data:a,error:o}=await es(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:t,data:null!=(s=null==r?void 0:r.data)?s:{},create_user:null==(i=null==r?void 0:r.shouldCreateUser)||i,gotrue_meta_security:{captcha_token:null==r?void 0:r.captchaToken},channel:null!=(n=null==r?void 0:r.channel)?n:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:null==a?void 0:a.message_id},error:o})}throw new w("You must provide either an email or phone number.")}catch(e){if(await q(this.storage,`${this.storageKey}-code-verifier`),h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async verifyOtp(e){var t,r;try{let s,i;"options"in e&&(s=null==(t=e.options)?void 0:t.redirectTo,i=null==(r=e.options)?void 0:r.captchaToken);let{data:n,error:a}=await es(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:en});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)),this._returnResult({data:{user:l,session:o},error:null})}catch(e){if(h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSSO(e){var t,r,s,i,n;try{let a=null,o=null;"pkce"===this.flowType&&([a,o]=await z(this.storage,this.storageKey));let l=await es(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!=(r=null==(t=e.options)?void 0:t.redirectTo)?r:void 0}),(null==(s=null==e?void 0:e.options)?void 0:s.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:o}),headers:this.headers,xform:el});return(null==(i=l.data)?void 0:i.url)&&$()&&!(null==(n=e.options)?void 0:n.skipBrowserRedirect)&&window.location.assign(l.data.url),this._returnResult(l)}catch(e){if(await q(this.storage,`${this.storageKey}-code-verifier`),h(e))return this._returnResult({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:r}=e;if(r)throw r;if(!t)throw new g;let{error:s}=await es(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return this._returnResult({data:{user:null,session:null},error:s})})}catch(e){if(h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:r,type:s,options:i}=e,{error:n}=await es(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},redirectTo:null==i?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:n})}if("phone"in e){let{phone:r,type:s,options:i}=e,{data:n,error:a}=await es(this.fetch,"POST",t,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:null==n?void 0:n.message_id},error:a})}throw new w("You must provide either an email or phone number and a type")}catch(e){if(h(e))return this._returnResult({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(),r=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await r}catch(e){}})()),r}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 t=null,r=await F(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),null!==r&&(this._isValidSession(r)?t=r:(this._debug("#getSession()","session from storage is not val
17id"),await this._removeSession())),!t)return{data:{session:null},error:null};let s=!!t.expires_at&&1e3*t.expires_at-Date.now()<9e4;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",t.expires_at),!s){if(this.userStorage){let e=await F(this.userStorage,this.storageKey+"-user");(null==e?void 0:e.user)?t.user=e.user:t.user=X()}if(this.storage.isServer&&t.user&&!t.user.__isUserNotAvailableProxy){var e;let r={value:this.suppressGetSessionWarning};t.user=(e=t.user,new Proxy(e,{get:(e,t,s)=>{if("__isInsecureUserWarningProxy"===t)return!0;if("symbol"==typeof t){let r=t.toString();if("Symbol(Symbol.toPrimitive)"===r||"Symbol(Symbol.toStringTag)"===r||"Symbol(util.inspect.custom)"===r||"Symbol(nodejs.util.inspect.custom)"===r)return Reflect.get(e,t,s)}return r.value||"string"!=typeof t||(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."),r.value=!0),Reflect.get(e,t,s)}})),r.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:t},error:null}}let{data:i,error:n}=await this._callRefreshToken(t.refresh_token);if(n)return this._returnResult({data:{session:null},error:n});return this._returnResult({data:{session:i},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;let t=await this._acquireLock(-1,async()=>await this._getUser());return t.data.user&&(this.suppressGetSessionWarning=!0),t}async _getUser(e){try{if(e)return await es(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:eo});return await this._useSession(async e=>{var t,r,s;let{data:i,error:n}=e;if(n)throw n;return(null==(t=i.session)?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await es(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:null!=(s=null==(r=i.session)?void 0:r.access_token)?s:void 0,xform:eo}):{data:{user:null},error:new g}})}catch(e){if(h(e))return y(e)&&(await this._removeSession(),await q(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({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 r=>{let{data:s,error:i}=r;if(i)throw i;if(!s.session)throw new g;let n=s.session,a=null,o=null;"pkce"===this.flowType&&null!=e.email&&([a,o]=await z(this.storage,this.storageKey));let{data:l,error:u}=await es(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:eo});if(u)throw u;return n.user=l.user,await this._saveSession(n),await this._notifyAllSubscribers("USER_UPDATED",n),this._returnResult({data:{user:n.user},error:null})})}catch(e){if(await q(this.storage,`${this.storageKey}-code-verifier`),h(e))return this._returnResult({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 g;let t=Date.now()/1e3,r=t,s=!0,i=null,{payload:n}=K(e.access_token);if(n.exp&&(s=(r=n.exp)<=t),s){let{data:t,error:r}=await this._callRefreshToken(e.refresh_token);if(r)return this._returnResult({data:{user:null,session:null},error:r});if(!t)return{data:{user:null,session:null},error:null};i=t}else{let{data:s,error:n}=await this._getUser(e.access_token);if(n)throw n;i={access_token:e.access_token,refresh_token:e.refresh_token,user:s.user,token_type:"bearer",expires_in:r-t,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(e){if(h(e))return this._returnResult({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 r;if(!e){let{data:s,error:i}=t;if(i)throw i;e=null!=(r=s.session)?r:void 0}if(!(null==e?void 0:e.refresh_token))throw new g;let{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(e){if(h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _getSessionFromURL(e,t){try{if(!$())throw new b("No browser detected.");
17if(e.error||e.error_description||e.error_code)throw new b(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 _("Not a valid PKCE flow url.");break;case"pkce":if("implicit"===this.flowType)throw new b("Not a valid implicit grant flow url.")}if("pkce"===t){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new _("No code detected.");let{data:t,error:r}=await this._exchangeCodeForSession(e.code);if(r)throw r;let s=new URL(window.location.href);return s.searchParams.delete("code"),window.history.replaceState(window.history.state,"",s.toString()),{data:{session:t.session,redirectType:null},error:null}}let{provider_token:r,provider_refresh_token:s,access_token:i,refresh_token:n,expires_in:a,expires_at:o,token_type:l}=e;if(!i||!a||!n||!l)throw new b("No session defined in URL");let u=Math.round(Date.now()/1e3),h=parseInt(a),c=u+h;o&&(c=parseInt(o));let d=c-u;1e3*d<=3e4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${d}s, should have been closer to ${h}s`);let f=c-h;u-f>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",f,c,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,c,u);let{data:p,error:g}=await this._getUser(i);if(g)throw g;let y={provider_token:r,provider_refresh_token:s,access_token:i,expires_in:h,expires_at:c,refresh_token:n,token_type:l,user:p.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:y,redirectType:e.type},error:null})}catch(e){if(h(e))return this._returnResult({data:{session:null,redirectType:null},error:e});throw e}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){let t=await F(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var r;let{data:s,error:i}=t;if(i)return this._returnResult({error:i});let n=null==(r=s.session)?void 0:r.access_token;if(n){let{error:t}=await this.admin.signOut(n,e);if(t&&!(d(t)&&(404===t.status||401===t.status||403===t.status)))return this._returnResult({error:t})}return"others"!==e&&(await this._removeSession(),await q(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){let t=Symbol("auth-callback"),r={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,r),(async()=>{await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})})(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async t=>{var r,s;try{let{data:{session:s},error:i}=t;if(i)throw i;await (null==(r=this.stateChangeEmitters.get(e))?void 0:r.callback("INITIAL_SESSION",s)),this._debug("INITIAL_SESSION","callback id",e,"session",s)}catch(t){await (null==(s=this.stateChangeEmitters.get(e))?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",t),console.error(t)}})}async resetPasswordForEmail(e,t={}){let r=null,s=null;"pkce"===this.flowType&&([r,s]=await z(this.storage,this.storageKey,!0));try{return await es(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(e){if(await q(this.storage,`${this.storageKey}-code-verifier`),h(e))return this._returnResult({data:null,error:e});throw e}}async getUserIdentities(){var e;try{let{data:t,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:null!=(e=t.user.identities)?e:[]},error:null})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var t;try{let{data:r,error:s}=await this._useSession(async t=>{var r,s,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==(r=e.options)?void 0:r.redirectTo,scopes:null==(s=e.options)?void 0:s.scopes,queryParams:null==(i=e.options)?void 0:i.queryParams,skipBrowserRedirect:!0});return await es(this.fetch,"GET",u,{headers:this.headers,jwt:null!=(a=null==(n=o.session)?void 0:n.access_token)?a:void 0})});if(s)throw s;return!$()||(null==(t=e.options)?void 0:t.skipBrowserRedirect)||window.location.assign(null==r?void 0:r.url),this._returnResult({data:{provider:e.provider,url:null==r?void 0:r.url},error:null})}catch(t){if(h(t))return this._returnResult({data:{provider:e.provider,url:null},error:t});throw t}}async linkIdentityIdToken(e){return await this._useSession(async t=>{var r;try{let{error:s,data:{session:i}}=t;if(s)throw s;let{options:n,provider:a,token:o,access_token:l,nonce:u}=e,{data:h,error:c}=await es(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:null!=(r=null==i?void 0:i.access_token)?r:void 0,body:{provider:a,id_token:o,access_token:l,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},xform:en});if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!h||!h.session||!h.user)return this._returnResult({data:{user:null,session:null},error:new m});return h.session&&(await this._saveSession(h.session),await this._notifyAllSubscribers("USER_UPDATED",h.session)),this._returnResult({data:h,error:c})}catch(e){if(await q(this.storage,`${this.storageKey}-code-verifier`),h(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}})}async unlinkIdentity(e){try{return await this._useSession(async t=>{var r,s;let{data:i,error:n}=t;if(n)throw n;
17return await es(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:null!=(s=null==(r=i.session)?void 0:r.access_token)?s:void 0})})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{var r,s;let i=Date.now();return await (r=async r=>(r>0&&await W(200*Math.pow(2,r-1)),this._debug(t,"refreshing attempt",r),await es(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:en})),s=(e,t)=>{let r=200*Math.pow(2,e);return t&&S(t)&&Date.now()+r-i<3e4},new Promise((e,t)=>{(async()=>{for(let i=0;i<1/0;i++)try{let t=await r(i);if(!s(i,null,t))return void e(t)}catch(e){if(!s(i,e))return void t(e)}})()}))}catch(e){if(this._debug(t,"error",e),h(e))return this._returnResult({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 r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",r),$()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,t;let r="#_recoverAndRefresh()";this._debug(r,"begin");try{let s=await F(this.storage,this.storageKey);if(s&&this.userStorage){let t=await F(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!t&&(t={user:s.user},await D(this.userStorage,this.storageKey+"-user",t)),s.user=null!=(e=null==t?void 0:t.user)?e:X()}else if(s&&!s.user&&!s.user){let e=await F(this.storage,this.storageKey+"-user");e&&(null==e?void 0:e.user)?(s.user=e.user,await q(this.storage,this.storageKey+"-user"),await D(this.storage,this.storageKey,s)):s.user=X()}if(this._debug(r,"session from storage",s),!this._isValidSession(s)){this._debug(r,"session is not valid"),null!==s&&await this._removeSession();return}let i=(null!=(t=s.expires_at)?t:1/0)*1e3-Date.now()<9e4;if(this._debug(r,`session has${i?"":" not"} expired with margin of 90000s`),i){if(this.autoRefreshToken&&s.refresh_token){let{error:e}=await this._callRefreshToken(s.refresh_token);e&&(console.error(e),S(e)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",e),await this._removeSession()))}}else if(s.user&&!0===s.user.__isUserNotAvailableProxy)try{let{data:e,error:t}=await this._getUser(s.access_token);!t&&(null==e?void 0:e.user)?(s.user=e.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(e){console.error("Error getting user data:",e),this._debug(r,"error getting user data, skipping SIGNED_IN notification",e)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(e){this._debug(r,"error",e),console.error(e);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var t,r;if(!e)throw new g;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new M;let{data:t,error:r}=await this._refreshAccessToken(e);if(r)throw r;if(!t.session)throw new g;await this._saveSession(t.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);let s={data:t.session,error:null};return this.refreshingDeferred.resolve(s),s}catch(e){if(this._debug(s,"error",e),h(e)){let r={data:null,error:e};return S(e)||await this._removeSession(),null==(t=this.refreshingDeferred)||t.resolve(r),r}throw null==(r=this.refreshingDeferred)||r.reject(e),e}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,r=!0){let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t});let s=[],i=Array.from(this.stateChangeEmitters.values()).map(async r=>{try{await r.callback(e,t)}catch(e){s.push(e)}});if(await Promise.all(i),s.length>0){for(let e=0;e<s.length;e+=1)console.error(s[e]);throw s[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await q(this.storage,`${this.storageKey}-code-verifier`);let t=Object.assign({},e),r=t.user&&!0===t.user.__isUserNotAvailableProxy;if(this.userStorage){!r&&t.user&&await D(this.userStorage,this.storageKey+"-user",{user:t.user});let e=Object.assign({},t);delete e.user;let s=Z(e);await D(this.storage,this.storageKey,s)}else{let e=Z(t);await D(this.storage,this.storageKey,e)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await q(this.storage,this.storageKey),await q(this.storage,this.storageKey+"-code-verifier"),await q(this.storage,this.storageKey+"-user"),this.userStorage&&await q(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&$()&&(null==window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}
17catch(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:r}}=t;if(!r||!r.refresh_token||!r.expires_at)return void this._debug("#_autoRefreshTokenTick()","no session");let s=Math.floor((1e3*r.expires_at-e)/3e4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts 30000ms, refresh threshold is 3 ticks`),s<=3&&await this._callRefreshToken(r.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 eg)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!$()||!(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,r){let s=[`provider=${encodeURIComponent(t)}`];if((null==r?void 0:r.redirectTo)&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),(null==r?void 0:r.scopes)&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),"pkce"===this.flowType){let[e,t]=await z(this.storage,this.storageKey),r=new URLSearchParams({code_challenge:`${encodeURIComponent(e)}`,code_challenge_method:`${encodeURIComponent(t)}`});s.push(r.toString())}if(null==r?void 0:r.queryParams){let e=new URLSearchParams(r.queryParams);s.push(e.toString())}return(null==r?void 0:r.skipBrowserRedirect)&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var r;let{data:s,error:i}=t;return i?this._returnResult({data:null,error:i}):await es(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:null==(r=null==s?void 0:s.session)?void 0:r.access_token})})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async _enroll(e){try{return await this._useSession(async t=>{var r,s;let{data:i,error:n}=t;if(n)return this._returnResult({data:null,error:n});let a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},"phone"===e.factorType?{phone:e.phone}:"totp"===e.factorType?{issuer:e.issuer}:{}),{data:o,error:l}=await es(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:null==(r=null==i?void 0:i.session)?void 0:r.access_token});return l?this._returnResult({data:null,error:l}):("totp"===e.factorType&&"totp"===o.type&&(null==(s=null==o?void 0:o.totp)?void 0:s.qr_code)&&(o.totp.qr_code=`data:image/svg+xml;utf-8,${o.totp.qr_code}`),this._returnResult({data:o,error:null}))})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r,s,i;let{data:n,error:a}=t;if(a)return this._returnResult({data:null,error:a});let o=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:"create"===e.webauthn.type?(s=e.webauthn.credential_response,"toJSON"in s&&"function"==typeof s.toJSON?s.toJSON():{id:s.id,rawId:s.id,response:{attestationObject:U(new Uint8Array(s.response.attestationObject)),clientDataJSON:U(new Uint8Array(s.response.clientDataJSON))},type:"public-key",clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:null!=(i=s.authenticatorAttachment)?i:void 0}):function(e){var t;if("toJSON"in e&&"function"==typeof e.toJSON)return e.toJSON();let r=e.getClientExtensionResults(),s=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:U(new Uint8Array(s.authenticatorData)),clientDataJSON:U(new Uint8Array(s.clientDataJSON)),signature:U(new Uint8Array(s.signature)),userHandle:s.userHandle?U(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}(e.webauthn.credential_response)})}:{code:e.code}),{data:l,error:u}=await es(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:null==(r=null==n?void 0:n.session)?void 0:r.access_token});return u?this._returnResult({data:null,error:u}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+l.expires_in},l)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",l),this._returnResult({data:l,error:u}))})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var r;let{data:i,error:n}=t;if(n)return this._returnResult({data:null,error:n});let a=await es(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:null==(r=null==i?void 0:i.session)?void 0:r.access_token});if(a.error)return a;let{data:o}=a;if("webauthn"!==o.type)return{data:o,error:null};switch(o.webauthn.type){case"create":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:function(e){if(!e)throw Error("Credential creation options are required");if("undefined"!=typeof PublicKeyCredential&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseCreationOptionsFromJSON)return PublicKeyCredential.parseCreationOptionsFromJSON(e);let{challenge:t,user:r,excludeCredentials:i}=e,n=(0,s.__rest)(e,["challenge","user","excludeCredentials"]),a=x(t).buffer,o=Object.assign(Object.assign({},r),{id:x(r.id).buffer}),l=Object.assign(Object.assign({}
17,n),{challenge:a,user:o});if(i&&i.length>0){l.excludeCredentials=Array(i.length);for(let e=0;e<i.length;e++){let t=i[e];l.excludeCredentials[e]=Object.assign(Object.assign({},t),{id:x(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return l}(o.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:function(e){if(!e)throw Error("Credential request options are required");if("undefined"!=typeof PublicKeyCredential&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseRequestOptionsFromJSON)return PublicKeyCredential.parseRequestOptionsFromJSON(e);let{challenge:t,allowCredentials:r}=e,i=(0,s.__rest)(e,["challenge","allowCredentials"]),n=x(t).buffer,a=Object.assign(Object.assign({},i),{challenge:n});if(r&&r.length>0){a.allowCredentials=Array(r.length);for(let e=0;e<r.length;e++){let t=r[e];a.allowCredentials[e]=Object.assign(Object.assign({},t),{id:x(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return a}(o.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}})}async _challengeAndVerify(e){let{data:t,error:r}=await this._challenge({factorId:e.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){var e;let{data:{user:t},error:r}=await this.getUser();if(r)return{data:null,error:r};let s={all:[],phone:[],totp:[],webauthn:[]};for(let r of null!=(e=null==t?void 0:t.factors)?e:[])s.all.push(r),"verified"===r.status&&s[r.factor_type].push(r);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(){var e,t;let{data:{session:r},error:s}
17=await this.getSession();if(s)return this._returnResult({data:null,error:s});if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let{payload:i}=K(r.access_token),n=null;i.aal&&(n=i.aal);let a=n;return(null!=(t=null==(e=r.user.factors)?void 0:e.filter(e=>"verified"===e.status))?t:[]).length>0&&(a="aal2"),{data:{currentLevel:n,nextLevel:a,currentAuthenticationMethods:i.amr||[]},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;return s?this._returnResult({data:null,error:s}):r?await es(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new g})})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async _approveAuthorization(e,t){try{return await this._useSession(async r=>{let{data:{session:s},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new g});let n=await es(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url&&$()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(n.data.redirect_url),n})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async _denyAuthorization(e,t){try{return await this._useSession(async r=>{let{data:{session:s},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new g});let n=await es(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url&&$()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(n.data.redirect_url),n})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async _listOAuthGrants(){try{return await this._useSession(async e=>{let{data:{session:t},error:r}=e;return r?this._returnResult({data:null,error:r}):t?await es(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:t.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new g})})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async t=>{let{data:{session:r},error:s}=t;return s?this._returnResult({data:null,error:s}):r?(await es(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new g})})}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}async fetchJwk(e,t={keys:[]}){let r=t.keys.find(t=>t.kid===e);if(r)return r;let s=Date.now();if((r=this.jwks.keys.find(t=>t.kid===e))&&this.jwks_cached_at+6e5>s)return r;let{data:i,error:n}=await es(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=s,r=i.keys.find(t=>t.kid===e))?r:null}async getClaims(e,t={}){try{let r=e;if(!r){let{data:e,error:t}
17=await this.getSession();if(t||!e.session)return this._returnResult({data:null,error:t});r=e.session.access_token}let{header:s,payload:i,signature:n,raw:{header:a,payload:o}}=K(r);(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=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,(null==t?void 0:t.keys)?{keys:t.keys}:null==t?void 0:t.jwks);if(!l){let{error:e}=await this.getUser(r);if(e)throw e;return{data:{claims:i,header:s,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")}}(s.alg),h=await crypto.subtle.importKey("jwk",l,u,!0,["verify"]);if(!await crypto.subtle.verify(u,h,n,function(e){let t=[];return!function(e,t){for(let r=0;r<e.length;r+=1){let s=e.charCodeAt(r);if(s>55295&&s<=56319){let t=(s-55296)*1024&65535;s=(e.charCodeAt(r+1)-56320&65535|t)+65536,r+=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)}`)}(s,t)}}(e,e=>t.push(e)),new Uint8Array(t)}(`${a}.${o}`)))throw new R("Invalid JWT signature");return{data:{claims:i,header:s,signature:n},error:null}}catch(e){if(h(e))return this._returnResult({data:null,error:e});throw e}}}eB.nextInstanceID={};let eL=eB,eD=ed,eF=eL},47785:(e,t,r)=>{"use strict";r.d(t,{U:()=>l,h:()=>o});var s=r(12115),i=r(95155);function n(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var a=s.createContext(n()),o=()=>s.useContext(a),l=e=>{let{children:t}=e,[r]=s.useState(()=>n());return(0,i.jsx)(a.Provider,{value:r,children:"function"==typeof t?t(r):t})}},51746:(e,t)=>{"use strict";t.byteLength=function(e){var t=l(e),r=t[0],s=t[1];return(r+s)*3/4-s},t.toByteArray=function(e){var t,r,n=l(e),a=n[0],o=n[1],u=new i((a+o)*3/4-o),h=0,c=o>0?a-4:a;for(r=0;r<c;r+=4)t=s[e.charCodeAt(r)]<<18|s[e.charCodeAt(r+1)]<<12|s[e.charCodeAt(r+2)]<<6|s[e.charCodeAt(r+3)],u[h++]=t>>16&255,u[h++]=t>>8&255,u[h++]=255&t;return 2===o&&(t=s[e.charCodeAt(r)]<<2|s[e.charCodeAt(r+1)]>>4,u[h++]=255&t),1===o&&(t=s[e.charCodeAt(r)]<<10|s[e.charCodeAt(r+1)]<<4|s[e.charCodeAt(r+2)]>>2,u[h++]=t>>8&255,u[h++]=255&t),u},t.fromByteArray=function(e){for(var t,s=e.length,i=s%3,n=[],a=0,o=s-i;a<o;a+=16383)n.push(function(e,t,s){for(var i,n=[],a=t;a<s;a+=3)i=(e[a]<<16&0xff0000)+(e[a+1]<<8&65280)+(255&e[a+2]),n.push(r[i>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return n.join("")}(e,a,a+16383>o?o:a+16383));return 1===i?n.push(r[(t=e[s-1])>>2]+r[t<<4&63]+"=="):2===i&&n.push(r[(t=(e[s-2]<<8)+e[s-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),n.join("")};for(var r=[],s=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,o=n.length;a<o;++a)r[a]=n[a],s[n.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var s=r===t?0:4-r%4;return[r,s]}s[45]=62,s[95]=63},53455:(e,t,r)=>{"use strict";r.d(t,{I:()=>n});var s=r(2954),i=r(56384);function n(e,t){return(0,i.t)(e,s.$,t)}},54419:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(71450).__importDefault(r(76373)),i=RegExp("[,()]");class n extends s.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}regexMatch(e,t){return this.url.searchParams.append(e,`match.${t}`),this}regexIMatch(e,t){return this.url.searchParams.append(e,`imatch.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}isDistinct(e,t){return this.url.searchParams.append(e,`isdistinct.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(e=>"string"==typeof e&&i.test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),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:r,type:s}={}){let i="";"plain"===s?i="pl":"phrase"===s?i="ph":"websearch"===s&&(i="w");let n=void 0===r?"":`(${r})`;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,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}}t.default=n},55459:(e,t)=>{t.read=function(e,t,r,s,i){var n,a,o=8*i-s-1,l=(1<<o)-1,u=l>>1,h=-7,c=r?i-1:0,d=r?-1:1,f=e[t+c];for(c+=d,n=f&(1<<-h)-1,f>>=-h,h+=o;h>0;n=256*n+e[t+c],c+=d,h-=8);for(a=n&(1<<-h)-1,n>>=-h,h+=s;h>0;a=256*a+e[t+c],c+=d,h-=8);if(0===n)n=1-u;else{if(n===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,s),n-=u}return(f?-1:1)*a*Math.pow(2,n-s)},t.write=function(e,t,r,s,i,n){var a,o,l,u=8*n-i-1,h=(1<<u)-1,c=h>>1,d=5960464477539062e-23*(23===i),f=s?0:n-1,p=s?1:-1,g=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(o=+!!isNaN(t),a=h):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+c>=1?t+=d/l:t+=d*Math.pow(2,1-c),t*l>=2&&(a++,l/=2),a+c>=h?(o=0,a=h):a+c>=1?(o=(t*l-1)*Math.pow(2,i),a+=c):(o=t*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;e[r+f]=255&o,f+=p,o/=256,i-=8);for(a=a<<i|o,u+=i;u>0;e[r+f]=255&a,f+=p,a/=256,u-=8);e[r+f-p]|=128*g}},56195:(e,t,r)=>{"use strict";r.d(t,{m:()=>n});var s=r(38445),i=r(34049),n=new class extends s.Q{#L;#D;#F;constructor(){super(),this.#F=e=>{if(!i.S$&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#D||this.setEventListener(this.#F)}onUnsubscribe(){this.hasListeners()||(this.#D?.(),this.#D=void 0)}setEventListener(e){this.#F=e,this.#D?.(),this.#D=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#L!==e&&(this.#L=e,this.onFocus())}onFocus(){let e=this.isFocused();
17this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#L?this.#L:globalThis.document?.visibilityState!=="hidden"}}},56384:(e,t,r)=>{"use strict";r.d(t,{t:()=>c});var s=r(12115),i=r(74268),n=r(34049),a=r(99776),o=r(47785),l=r(36687),u=r(33742),h=r(95822);function c(e,t,r){var c,d,f,p,g;let y=(0,u.w)(),m=(0,o.h)(),w=(0,a.jE)(r),b=w.defaultQueryOptions(e);null==(d=w.getDefaultOptions().queries)||null==(c=d._experimental_beforeQuery)||c.call(d,b),b._optimisticResults=y?"isRestoring":"optimistic",(0,h.jv)(b),(0,l.LJ)(b,m),(0,l.wZ)(m);let v=!w.getQueryCache().get(b.queryHash),[_]=s.useState(()=>new t(w,b)),E=_.getOptimisticResult(b),S=!y&&!1!==e.subscribed;if(s.useSyncExternalStore(s.useCallback(e=>{let t=S?_.subscribe(i.jG.batchCalls(e)):n.lQ;return _.updateResult(),t},[_,S]),()=>_.getCurrentResult(),()=>_.getCurrentResult()),s.useEffect(()=>{_.setOptions(b)},[b,_]),(0,h.EU)(b,E))throw(0,h.iL)(b,_,m);if((0,l.$1)({result:E,errorResetBoundary:m,throwOnError:b.throwOnError,query:w.getQueryCache().get(b.queryHash),suspense:b.suspense}))throw E.error;if(null==(p=w.getDefaultOptions().queries)||null==(f=p._experimental_afterQuery)||f.call(p,b,E),b.experimental_prefetchInRender&&!n.S$&&(0,h.nE)(E,y)){let e=v?(0,h.iL)(b,_,m):null==(g=w.getQueryCache().get(b.queryHash))?void 0:g.promise;null==e||e.catch(n.lQ).finally(()=>{_.updateResult()})}return b.notifyOnChangeProps?E:_.trackResult(E)}},59639:(e,t,r)=>{"use strict";var s=r(95704),i=Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]},n=function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)},a=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createClient=t.SupabaseClient=t.FunctionRegion=t.FunctionsError=t.FunctionsRelayError=t.FunctionsFetchError=t.FunctionsHttpError=t.PostgrestError=void 0;let o=a(r(78208));n(r(44703),t);var l=r(87843);Object.defineProperty(t,"PostgrestError",{enumerable:!0,get:function(){return l.PostgrestError}});var u=r(92758);Object.defineProperty(t,"FunctionsHttpError",{enumerable:!0,get:function(){return u.FunctionsHttpError}}),Object.defineProperty(t,"FunctionsFetchError",{enumerable:!0,get:function(){return u.FunctionsFetchError}}),Object.defineProperty(t,"FunctionsRelayError",{enumerable:!0,get:function(){return u.FunctionsRelayError}}),Object.defineProperty(t,"FunctionsError",{enumerable:!0,get:function(){return u.FunctionsError}}),Object.defineProperty(t,"FunctionRegion",{enumerable:!0,get:function(){return u.FunctionRegion}}),n(r(64323),t);var h=r(78208);Object.defineProperty(t,"SupabaseClient",{enumerable:!0,get:function(){return a(h).default}}),t.createClient=(e,t,r)=>new o.default(e,t,r),function(){if("undefined"!=typeof window||void 0===s)return!1;let e=s.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")},63122:(e,t,r)=>{"use strict";r.d(t,{t:()=>n});var s=r(38445),i=r(34049),n=new class extends s.Q{#q=!0;#D;#F;constructor(){super(),this.#F=e=>{if(!i.S$&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#D||this.setEventListener(this.#F)}onUnsubscribe(){this.hasListeners()||(this.#D?.(),this.#D=void 0)}setEventListener(e){this.#F=e,this.#D?.(),this.#D=e(this.setOnline.bind(this))}setOnline(e){this.#q!==e&&(this.#q=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#q}}},64323:(e,t,r)=>{"use strict";r.r(t),r.d(t,{REALTIME_CHANNEL_STATES:()=>I,REALTIME_LISTEN_TYPES:()=>c,REALTIME_POSTGRES_CHANGES_LISTEN_EVENT:()=>h,REALTIME_PRESENCE_LISTEN_EVENTS:()=>u,REALTIME_SUBSCRIBE_STATES:()=>d,RealtimeChannel:()=>P,RealtimeClient:()=>B,RealtimePresence:()=>C,WebSocketFactory:()=>g});var s,i,n,a,o,l,u,h,c,d,f=r(95704);class p{constructor(){}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!==r.g&&void 0!==r.g.WebSocket)return{type:"native",constructor:r.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!==f){let e=f.versions;if(e&&e.node){let t=parseInt(e.node.replace(/^v/,"").split(".")[0]);return t>=22?void 0!==globalThis.WebSocket?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${t} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${t} 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+=` 18 19Suggested 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}}}let g=p,y="1.0.0";!function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"}(s||(s={})),function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"}(i||(i={})),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"}(n||(n={})),(a||(a={})).websocket="websocket",function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"}(o||(o={}));class m{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=null!=e?e:[]}encode(e,t){return e.event!==this.BROADCAST_EVENT||e.payload instanceof ArrayBuffer||"string"!=typeof e.payload.event?t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload])):t(this._binaryEncodeUserBroadcastPush(e))}_binaryEncodeUserBroadcastPush(e){var t;return this._isArrayBuffer(null==(t=e.payload)?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var t,r;let s=null!=(r=null==(t=e.payload)?void 0:t.payload)?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,s)}_encodeJsonUserBroadcastPush(e){var t,r;let s=null!=(r=null==(t=e.payload)?void 0:t.payload)?r:{},i=new TextEncoder().encode(JSON.stringify(s)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,i)}_encodeUserBroadcastPush(e,t,r){let s=e.topic,i=null!=(f=e.ref)?f:"",n=null!=(p=e.join_ref)?p:"",a=e.payload.event,o=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},l=0===Object.keys(o).length?"":JSON.stringify(o);if(n.length>255)throw Error(`joinRef length ${n.length} exceeds maximum of 255`);if(i.length>255)throw Error(`ref length ${i.length} exceeds maximum of 255`);if(s.length>255)throw Error(`topic length ${s.length} exceeds maximum of 255`);if(a.length>255)throw Error(`userEvent length ${a.length} exceeds maximum of 255`);if(l.length>255)throw Error(`metadata length ${l.length} exceeds maximum of 255`);let u=this.USER_BROADCAST_PUSH_META_LENGTH+n.length+i.length+s.length+a.length+l.length,h=new ArrayBuffer(this.HEADER_LENGTH+u),c=new DataView(
19h),d=0;c.setUint8(d++,this.KINDS.userBroadcastPush),c.setUint8(d++,n.length),c.setUint8(d++,i.length),c.setUint8(d++,s.length),c.setUint8(d++,a.length),c.setUint8(d++,l.length),c.setUint8(d++,t),Array.from(n,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(i,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(s,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(a,e=>c.setUint8(d++,e.charCodeAt(0))),Array.from(l,e=>c.setUint8(d++,e.charCodeAt(0)));var f,p,g=new Uint8Array(h.byteLength+r.byteLength);return g.set(new Uint8Array(h),0),g.set(new Uint8Array(r),h.byteLength),g.buffer}decode(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){let[r,s,i,n,a]=JSON.parse(e);return t({join_ref:r,ref:s,topic:i,event:n,payload:a})}return t({})}_binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),s=new TextDecoder;if(r===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,t,s)}_decodeUserBroadcast(e,t,r){let s=t.getUint8(1),i=t.getUint8(2),n=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+4,l=r.decode(e.slice(o,o+s));o+=s;let u=r.decode(e.slice(o,o+i));o+=i;let h=r.decode(e.slice(o,o+n));o+=n;let c=e.slice(o,e.byteLength),d=a===this.JSON_ENCODING?JSON.parse(r.decode(c)):c,f={type:this.BROADCAST_EVENT,event:u,payload:d};return n>0&&(f.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST_EVENT,payload:f}}_isArrayBuffer(e){var t;return e instanceof ArrayBuffer||(null==(t=null==e?void 0:e.constructor)?void 0:t.name)==="ArrayBuffer"}_pick(e,t){return e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([e])=>t.includes(e))):{}}}class w{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"}(l||(l={}));let b=(e,t,r={})=>{var s;let i=null!=(s=r.skipTypes)?s:[];return t?Object.keys(t).reduce((r,s)=>(r[s]=v(s,e,t,i),r),{}):{}},v=(e,t,r,s)=>{let i=t.find(t=>t.name===e),n=null==i?void 0:i.type,a=r[e];return n&&!s.includes(n)?_(n,a):E(a)},_=(e,t)=>{if("_"===e.charAt(0))return R(t,e.slice(1,e.length));switch(e){case l.bool:return S(t);case l.float4:case l.float8:case l.int2:case l.int4:case l.int8:case l.numeric:case l.oid:return O(t);case l.json:case l.jsonb:return T(t);case l.timestamp:return k(t);case l.abstime:case l.date:case l.daterange:case l.int4range:case l.int8range:case l.money:case l.reltime:case l.text:case l.time:case l.timestamptz:case l.timetz:case l.tsrange:case l.tstzrange:default:return E(t)}},E=e=>e,S=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},O=e=>{if("string"==typeof e){let t=parseFloat(e);if(!Number.isNaN(t))return t}return e},T=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){console.log(`JSON parse error: ${e}`)}return e},R=(e,t)=>{if("string"!=typeof e)return e;let r=e.length-1,s=e[r];if("{"===e[0]&&"}"===s){let s,i=e.slice(1,r);try{s=JSON.parse("["+i+"]")}catch(e){s=i?i.split(","):[]}return s.map(e=>_(t,e))}return e},k=e=>"string"==typeof e?e.replace(" ","T"):e,A=e=>{let t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),""===t.pathname||"/"===t.pathname?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};class j{constructor(e,t,r={},s=1e4){this.channel=e,this.event=t,this.payload=r,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHo
19oks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t(null==(r=this.receivedResp)?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);let e=e=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=e,this._matchReceive(e)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(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"}(u||(u={}));class C{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let r=(null==t?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},e=>{let{onJoin:t,onLeave:r,onSync:s}=this.caller;this.joinRef=this.channel._joinRef(),this.state=C.syncState(this.state,e,t,r),this.pendingDiffs.forEach(e=>{this.state=C.syncDiff(this.state,e,t,r)}),this.pendingDiffs=[],s()}),this.channel._on(r.diff,{},e=>{let{onJoin:t,onLeave:r,onSync:s}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=C.syncDiff(this.state,e,t,r),s())}),this.onJoin((e,t,r)=>{this.channel._trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:r})}),this.onLeave((e,t,r)=>{this.channel._trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:r})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,s){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 r=i[e];if(r){let s=t.map(e=>e.presence_ref),i=r.map(e=>e.presence_ref),n=t.filter(e=>0>i.indexOf(e.presence_ref)),l=r.filter(e=>0>s.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},r,s)}static syncDiff(e,t,r,s){let{joins:i,leaves:n}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(i,(t,s)=>{var i;let n=null!=(i=e[t])?i:[];if(e[t]=this.cloneDeep(s),n.length>0){let r=e[t].map(e=>e.presence_ref),s=n.filter(e=>0>r.indexOf(e.presence_ref));e[t].unshift(...s)}r(t,n,s)}),this.map(n,(t,r)=>{let i=e[t];if(!i)return;let n=r.map(e=>e.presence_ref);i=i.filter(e=>0>n.indexOf(e.presence_ref)),e[t]=i,s(t,i,r),0===i.length&&delete e[t]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return Object.getOwnPropertyNames(e=this.cloneDeep(e)).reduce((t,r)=>{let s=e[r];return"metas"in s?t[r]=s.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e)):t[r]=s,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"}(h||(h={})),function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"}(c||(c={})),function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"}(d||(d={}));let I=i;class P{constructor(e,t={config:{}},r){var s,a;if(this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=i.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 j(this,n.join,this.params,this.timeout),this.rejoinTimer=new w(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=i.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e
19=>e.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=i.closed,this.socket._remove(this)}),this._onError(e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=i.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=i.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=i.errored,this.rejoinTimer.scheduleTimeout())}),this._on(n.reply,{},(e,t)=>{this._trigger(this._replyEventName(t),e)}),this.presence=new C(this),this.broadcastEndpointURL=A(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(null==(a=null==(s=this.params.config)?void 0:s.broadcast)?void 0:a.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,t=this.timeout){var r,s,n;if(this.socket.isConnected()||this.socket.connect(),this.state==i.closed){let{config:{broadcast:a,presence:o,private:l}}=this.params,u=null!=(s=null==(r=this.bindings.postgres_changes)?void 0:r.map(e=>e.filter))?s:[],h=!!this.bindings[c.PRESENCE]&&this.bindings[c.PRESENCE].length>0||(null==(n=this.params.config.presence)?void 0:n.enabled)===!0,f={},p={broadcast:a,presence:Object.assign(Object.assign({},o),{enabled:h}),postgres_changes:u,private:l};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(t=>null==e?void 0:e(d.CHANNEL_ERROR,t)),this._onClose(()=>null==e?void 0:e(d.CLOSED)),this.updateJoinPayload(Object.assign({config:p},f)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:t})=>{var r;if(this.socket._isManualToken()||this.socket.setAuth(),void 0===t){null==e||e(d.SUBSCRIBED);return}{let s=this.bindings.postgres_changes,n=null!=(r=null==s?void 0:s.length)?r:0,a=[];for(let r=0;r<n;r++){let n=s[r],{filter:{event:o,schema:l,table:u,filter:h}}=n,c=t&&t[r];if(c&&c.event===o&&P.isFilterValueEqual(c.schema,l)&&P.isFilterValueEqual(c.table,u)&&P.isFilterValueEqual(c.filter,h))a.push(Object.assign(Object.assign({},n),{id:c.id}));else{this.unsubscribe(),this.state=i.errored,null==e||e(d.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=a,e&&e(d.SUBSCRIBED);return}}).receive("error",t=>{this.state=i.errored,null==e||e(d.CHANNEL_ERROR,Error(JSON.stringify(Object.values(t).join(", ")||"error")))}).receive("timeout",()=>{null==e||e(d.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){return this.state===i.joined&&e===c.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(async()=>await this.subscribe())),this._on(e,t,r)}async httpSend(e,t,r={}){var s;let i=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(null==t)return Promise.reject("Payload is required for httpSend()");let n={method:"POST",headers:{Authorization:i,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:t,private:this.private}]})},a=await this._fetchWithTimeout(this.broadcastEndpointURL,n,null!=(s=r.timeout)?s:this.timeout);if(202===a.status)return{success:!0};let o=a.statusText;try{let e=await a.json();o=e.error||e.message||o}catch(e){}return Promise.reject(Error(o))}async send(e,t={}){var r,s;if(this._canPush()||"broadcast"!==e.type)return new Promise(r=>{var s,i,n;let a=this._push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null==(n=null==(i=null==(s=this.params)?void 0:s.config)?void 0:i.broadcast)?void 0:n.ack)||r("ok"),a.receive("ok",()=>r("ok")),a.receive("error",()=>r("error")),a.receive("timeout",()=>r("timed out"))});{console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated
19in the future. Please use httpSend() explicitly for REST delivery.");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!=(r=t.timeout)?r:this.timeout);return await (null==(s=e.body)?void 0:s.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=i.leaving;let t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(n.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(s=>{(r=new j(this,n.leave,{},e)).receive("ok",()=>{t(),s("ok")}).receive("timeout",()=>{t(),s("timed out")}).receive("error",()=>{s("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{null==r||r.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=i.closed,this.bindings={}}async _fetchWithTimeout(e,t,r){let s=new AbortController,i=setTimeout(()=>s.abort(),r),n=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(i),n}_push(e,t,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new j(this,e,t,r);return this._canPush()?s.send():this._addToPushBuffer(s),s}_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,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var s,i;let a=e.toLocaleLowerCase(),{close:o,error:l,leave:u,join:h}=n;if(r&&[o,l,u,h].indexOf(a)>=0&&r!==this._joinRef())return;let c=this._onMessage(a,t,r);if(t&&!c)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(a)?null==(s=this.bindings.postgres_changes)||s.filter(e=>{var t,r,s;return(null==(t=e.filter)?void 0:t.event)==="*"||(null==(s=null==(r=e.filter)?void 0:r.event)?void 0:s.toLocaleLowerCase())===a}).map(e=>e.callback(c,r)):null==(i=this.bindings[a])||i.filter(e=>{var r,s,i,n,o,l;if(!["broadcast","presence","postgres_changes"].includes(a))return e.type.toLocaleLowerCase()===a;if("id"in e){let n=e.id,a=null==(r=e.filter)?void 0:r.event;return n&&(null==(s=t.ids)?void 0:s.includes(n))&&("*"===a||(null==a?void 0:a.toLocaleLowerCase())===(null==(i=t.data)?void 0:i.type.toLocaleLowerCase()))}{let r=null==(o=null==(n=null==e?void 0:e.filter)?void 0:n.event)?void 0:o.toLocaleLowerCase();return"*"===r||r===(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:r,commit_timestamp:s,type:i,errors:n}=e;c=Object.assign(Object.assign({},{schema:t,table:r,commit_timestamp:s,eventType:i,new:{},old:{},errors:n}),this._getPayloadRecords(e))}e.callback(c,r)})}_isClosed(){return this.state===i.closed}_isJoined(){return this.state===i.joined}_isJoining(){return this.state===i.joining}_isLeaving(){return this.state===i.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){let s=e.toLocaleLowerCase(),i={type:s,filter:t,callback:r};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(e,t){let r=e.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(e=>{var s;return!((null==(s=e.type)?void 0:s.toLocaleLowerCase())===r&&P.isEqual(e.filter,t))})),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}static isFilterValueEqual(e,t){return(null!=e?e:void 0)===(null!=t?t:void 0)}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(n.close,{},e)}_onError(e){this._on(n.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=i.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=b(e.columns,e.record)),("UPDATE"===e.type||"DELET
19E"===e.type)&&(t.old=b(e.columns,e.old_record)),t}}let x=()=>{},U={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},$=[1e3,2e3,5e3,1e4],N=` 20 addEventListener("message", (e) => { 21 if (e.data.event === "start") { 22 setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); 23 } 24 });`;class B{constructor(e,t){var r;if(this.accessTokenValue=null,this.apiKey=null,this._manuallySetToken=!1,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=1e4,this.transport=null,this.heartbeatIntervalMs=U.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=x,this.ref=0,this.reconnectTimer=null,this.vsn=y,this.logger=x,this.conn=null,this.sendBuffer=[],this.serializer=new m,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...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}/${a.websocket}`,this.httpEndpoint=A(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.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=g.createWebSocket(this.endpointURL())}catch(t){this._setConnectionState("disconnected");let e=t.message;if(e.includes("Node.js"))throw Error(`${e} 25 26To use Realtime in Node.js, you need to provide a WebSocket implementation: 27 28Option 1: Use Node.js 22+ which has native WebSocket support 29Option 2: Install and provide the "ws" package: 30 31 npm install ws 32 33 import ws from "ws" 34 const client = new RealtimeClient(url, { 35 ...options, 36 transport: ws 37 })`);throw Error(`WebSocket not available: ${e}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}disconnect(e,t){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){let r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},"function"==typeof this.conn.close&&(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,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case s.connecting:return o.Connecting;case s.open:return o.Open;case s.closing:return o.Closing;default:return o.Closed}}isConnected(){return this.connectionState()===o.Open}isConnecting(){return"connecting"===this._connectionState}isDisconnecting(){return"disconnecting"===this._connectionState}channel(e,t={config:{}}){let r=`realtime:${e}`,s=this.getChannels().find(e=>e.topic===r);if(s)return s;{let r=new P(`realtime:${e}`,t,this);return this.channels.push(r),r}}push(e){let{topic:t,event:r,payload:s,ref:i}=e,n=()=>{this.encode(e,e=>{var t;null==(t=this.conn)||t.send(e)})};this.log("push",`${t} ${r} (${i})`,s),this.isConnected()?n():this.sendBuffer.push(n)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}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()},U.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>
370&&(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:r,payload:s,ref:i}=e,n=i?`(${i})`:"",a=s.status||"";this.log("receive",`${a} ${t} ${r} ${n}`.trim(),s),this.channels.filter(e=>e._isMember(t)).forEach(e=>e._trigger(r,s,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(){if(this.conn){if(this.conn.readyState===s.open||this.conn.readyState===s.connecting)try{this.conn.close()}catch(e){this.log("error","Error closing connection",e)}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._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).then(()=>{this.flushSendBuffer()}).catch(e=>{this.log("error","error waiting for auth on connect",e),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)}_triggerChanError(){this.channels.forEach(e=>e._trigger(n.error))}_appendParams(e,t){if(0===Object.keys(t).length)return e;let r=e.match(/\?/)?"&":"?",s=new URLSearchParams(t);return`${e}${r}${s}`}_workerObjectUrl(e){let t;if(e)t=e;else{let e=new Blob([N],{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,r=!1;if(e)t=e,r=!0;else if(this.accessToken)try{t=await this.accessToken()}catch(e){this.log("error","Error fetching access token from callback",e),t=this.accessTokenValue}else t=this.accessTokenValue;r?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEac
37h(e=>{let r={access_token:t,version:"realtime-js/2.87.1"};t&&e.updateJoinPayload(r),e.joinedOnce&&e._isJoined()&&e._push(n.access_token,{access_token:t})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(t=>{this.log("error",`Error setting auth in ${e}`,t)})}_triggerStateCallbacks(e,t){try{this.stateChangeCallbacks[e].forEach(r=>{try{r(t)}catch(t){this.log("error",`error in ${e} callback`,t)}})}catch(t){this.log("error",`error triggering ${e} callbacks`,t)}}_setupReconnectionTimer(){this.reconnectTimer=new w(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},U.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var t,r,s,i,n,a,o,l,u,h,c,d;switch(this.transport=null!=(t=null==e?void 0:e.transport)?t:null,this.timeout=null!=(r=null==e?void 0:e.timeout)?r:1e4,this.heartbeatIntervalMs=null!=(s=null==e?void 0:e.heartbeatIntervalMs)?s:U.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:x,this.vsn=null!=(o=null==e?void 0:e.vsn)?o:y,(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!=(l=null==e?void 0:e.reconnectAfterMs)?l:e=>$[e-1]||1e4,this.vsn){case y:this.encode=null!=(u=null==e?void 0:e.encode)?u:(e,t)=>t(JSON.stringify(e)),this.decode=null!=(h=null==e?void 0:e.decode)?h:(e,t)=>t(JSON.parse(e));break;case"2.0.0":this.encode=null!=(c=null==e?void 0:e.encode)?c:this.serializer.encode.bind(this.serializer),this.decode=null!=(d=null==e?void 0:e.decode)?d:this.serializer.decode.bind(this.serializer);break;default:throw Error(`Unsupported serializer version: ${this.vsn}`)}if(this.worker){if("undefined"!=typeof window&&!window.Worker)throw Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl}}}},67111:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fetchWithAuth=t.resolveHeadersConstructor=t.resolveFetch=void 0,t.resolveFetch=e=>e?function(){for(var t=arguments.length,r=Array(t),s=0;s<t;s++)r[s]=arguments[s];return e(...r)}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch(...t)},t.resolveHeadersConstructor=()=>Headers,t.fetchWithAuth=(e,r,s)=>{let i=(0,t.resolveFetch)(s),n=(0,t.resolveHeadersConstructor)();return async(t,s)=>{var a;let o=null!=(a=await r())?a:e,l=new n(null==s?void 0:s.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization","Bearer ".concat(o)),i(t,Object.assign(Object.assign({},s),{headers:l}))}}},69781:(e,t,r)=>{"use strict";r.d(t,{k:()=>n});var s=r(37126),i=r(34049),n=class{#M;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),(0,i.gn)(this.gcTime)&&(this.#M=s.zs.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(i.S$?1/0:3e5))}clearGcTimeout(){this.#M&&(s.zs.clearTimeout(this.#M),this.#M=void 0)}}},72378:(e,t,r)=>{"use strict";function s(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)e[s]=r[s]}return e}r.d(t,{A:()=>i});var i=function e(t,r){function i(e,i,n){if("undefined"!=typeof document){"number"==typeof(n=s({},r,n)).expires&&(n.expires=new Date(Date.now()+864e5*n.expires)),n.expires&&(n.expires=n.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var o in n)n[o]&&(a+="; "+o,!0!==n[o]&&(a+="="+n[o].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+a}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var r=document.cookie?document.cookie.split("; "):[],s={},i=0;i<r.length;i++){var n=r[i].split("="),a=n.slice(1).join("=");try{var o=decodeURIComponent(n[0]);if(s[o]=t.read(a,o),e===o)break}catch(e){}}return e?s[e]:s}},remove:function(e,t){i(e,"",s({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,s({},this.attributes,t))},withConverter:function(t){return e(s({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decode
37URIComponent)}},{path:"/"})},72901:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(71450).__importDefault(r(54419));class i{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s}select(e,t){let{head:r=!1,count:i}=null!=t?t:{},n=!1,a=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!n?"":('"'===e&&(n=!n),e)).join("");return this.url.searchParams.set("select",a),i&&this.headers.append("Prefer",`count=${i}`),new s.default({method:r?"HEAD":"GET",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(e,{count:t,defaultToNull:r=!0}={}){var i;if(t&&this.headers.append("Prefer",`count=${t}`),r||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 s.default({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!=(i=this.fetch)?i:fetch})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:i,defaultToNull:n=!0}={}){var a;if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),void 0!==t&&this.url.searchParams.set("on_conflict",t),i&&this.headers.append("Prefer",`count=${i}`),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 s.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 r;return t&&this.headers.append("Prefer",`count=${t}`),new s.default({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!=(r=this.fetch)?r:fetch})}delete({count:e}={}){var t;return e&&this.headers.append("Prefer",`count=${e}`),new s.default({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:null!=(t=this.fetch)?t:fetch})}}t.default=i},74268:(e,t,r)=>{"use strict";r.d(t,{jG:()=>i,x3:()=>s});var s=r(37126).Zq,i=function(){let e=[],t=0,r=e=>{e()},i=e=>{e()},n=s,a=s=>{t?e.push(s):n(()=>{r(s)})};return{batch:s=>{let a;t++;try{a=s()}finally{--t||(()=>{let t=e;e=[],t.length&&n(()=>{i(()=>{t.forEach(e=>{r(e)})})})})()}return a},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{r=e},setBatchNotifyFunction:e=>{i=e},setScheduler:e=>{n=e}}}()},76373:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(71450).__importDefault(r(3913));class i extends s.default{select(e){let t=!1,r=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:i=s}={}){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===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let s=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){let i=void 0===s?"offset":`${s}.offset`,n=void 0===s?"limit":`${s}.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}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:n="text"}={}){var a;let o=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(
37Boolean).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=i},78208:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let s=r(92758),i=r(87843),n=r(64323),a=r(9052),o=r(98762),l=r(67111),u=r(28202),h=r(21786);class c{get functions(){return new s.FunctionsClient(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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{head:!1,get:!1,count:void 0};return this.rest.rpc(e,t,r)}channel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}};return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var e,t;if(this.accessToken)return await this.accessToken();let{data:r}=await this.auth.getSession();return null!=(t=null==(e=r.session)?void 0:e.access_token)?t:this.supabaseKey}_initSupabaseAuthClient(e,t,r){let{autoRefreshToken:s,persistSession:i,detectSessionInUrl:n,storage:a,userStorage:o,storageKey:l,flowType:u,lock:c,debug:d,throwOnError:f}=e,p={Authorization:"Bearer ".concat(this.supabaseKey),apikey:"".concat(this.supabaseKey)};return new h.SupabaseAuthClient({url:this.authUrl.href,headers:Object.assign(Object.assign({},p),t),storageKey:l,autoRefreshToken:s,persistSession:i,detectSessionInUrl:n,storage:a,userStorage:o,flowType:u,lock:c,debug:d,throwOnError:f,fetch:r,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new n.RealtimeClient(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,r){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e)&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0)}constructor(e,t,r){var s,n,h;this.supabaseUrl=e,this.supabaseKey=t;let c=(0,u.validateSupabaseUrl)(e);if(!t)throw Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",c),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",c),this.storageUrl=new URL("storage/v1",c),this.functionsUrl=new URL("functions/v1",c);let d="sb-".concat(c.hostname.split(".")[0],"-auth-token"),f={db:o.DEFAULT_DB_OPTIONS,realtime:o.DEFAULT_REALTIME_OPTIONS,auth:Object.assign(Object.assign({},o.DEFAULT_AUTH_OPTIONS),{storageKey:d}),global:o.DEFAULT_GLOBAL_OPTIONS},p=(0,u.applySettingDefaults)(null!=r?r:{},f);this.storageKey=null!=(s=p.auth.storageKey)?s:"",this.headers=null!=(n=p.global.headers)?n:{},p.accessToken?(this.accessToken=p.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw Error("@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.".concat(String(t)," is not possible"))}})):this.auth=this._initSupabaseAuthClient(null!=(h=p.auth)?h:{},this.headers,p.global.fetch),this.fetch=(0,l.fetchWithAuth)(t,this._getAccessToken.bind(this),p.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},p.realtime)),this.accessToken&&this.accessToken().then(e=>this.realtime.setAuth(e)).catch(e=>console.warn("Failed to set initial Realtime auth token:",e)),this.rest=new i.PostgrestClient(new URL("rest/v1",c).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new a.StorageClient(this.storageUrl.href,this.headers,this.fetch,null==r?void 0:r.storage),p.accessToken||this._listenForAuthEvents()}}t.default=c},81029:(e,t,r)=>{"use strict";let s=r(51746),i=r(55459),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function a(e){if(e>
vendor: 21,072 bytes, line 37
370x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return h(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var s=e,i=t;if(("string"!=typeof i||""===i)&&(i="utf8"),!o.isEncoding(i))throw TypeError("Unknown encoding: "+i);let r=0|p(s,i),n=a(r),l=n.write(s,i);return l!==r&&(n=n.slice(0,l)),n}if(ArrayBuffer.isView(e)){var n=e;if(B(n,Uint8Array)){let e=new Uint8Array(n);return d(e.buffer,e.byteOffset,e.byteLength)}return c(n)}if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(B(e,ArrayBuffer)||e&&B(e.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(B(e,SharedArrayBuffer)||e&&B(e.buffer,SharedArrayBuffer)))return d(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');let l=e.valueOf&&e.valueOf();if(null!=l&&l!==e)return o.from(l,t,r);let u=function(e){if(o.isBuffer(e)){let t=0|f(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||function(e){return e!=e}(e.length)?a(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(u)return u;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return u(e),a(e<0?0:0|f(e))}function c(e){let t=e.length<0?0:0|f(e.length),r=a(t);for(let s=0;s<t;s+=1)r[s]=255&e[s];return r}function d(e,t,r){let s;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(s=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),o.prototype),s}function f(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function p(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||B(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===r)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(e).length;default:if(i)return s?-1:U(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t,r){let i=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){let s=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>s)&&(r=s);let i="";for(let s=t;s<r;++s)i+=L[e[s]];return i}(this,t,r);case"utf8":case"utf-8":return b(this,t,r);case"ascii":return function(e,t,r){let s="";r=Math.min(e.length,r);for(let i=t;i<r;++i)s+=String.fromCharCode(127&e[i]);return s}(this,t,r);case"latin1":case"binary":return function(e,t,r){let s="";r=Math.min(e.length,r);for(let i=t;i<r;++i)s+=String.fromCharCode(e[i]);return s}(this,t,r);case"base64":var n,a,o;return n=this,a=t,o=r,0===a&&o===n.length?s.fromByteArray(n):s.fromByteArray(n.slice(a,o));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){let s=e.slice(t,r),i="";for(let e=0;e<s.length-1;e+=2)i+=String.fromCharCode(s[e]+256*s[e+1]);return i}(this,t,r);default:if(i)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function y(e,t,r){let s=e[t];e[t]=e[r],e[r]=s}function m(e,t,r,s,i){var n;if(0===e.length)return -1;if("string"==typeof r?(s=r,r=0):r>0x7fffffff?r=0x7fffffff:r<-0x80000000&&(r=-0x80000000),(n=r*=1)!=n&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length)if(i)return -1;else r=e.length-1;else if(r<0)if(!i)return -1;else r=0;if("string"==typeof t&&(t=o.from(t,s)),o.isBuffer(t))return 0===t.length?-1:w(e,t,r,s,i);if("number"==typeof t){if(t&=255,"function"==typeof Uint8Array.prototype.indexOf)if(i)return Uint8Array.prototype.indexOf.call(e,t,r);else return Uint8Array.prototype.lastIndexOf.call(e,t,r);return w(e,[t],r,s,i)}throw TypeError("val must be string, number or Buffer")}function w(e,t,r,s,i){let n,a=1,o=e.length,l=t.length;if(void 0!==s&&("ucs2"===(s=String(s).toLowerCase())||"ucs-2"===s||"utf16le"===s||"utf-16le"===s)){if(e.length<2||t.length<2)return -1;a=2,o/=2,l/=2,r/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){let s=-1;for(n=r;n<o;n++)if(u(e,n)===u(t,-1===s?0:n-s)){if(-1===s&&(s=n),n-s+1===l)return s*a}else -1!==s&&(n-=n-s),s=-1}else for(r+l>o&&(r=o-l),n=r;n>=0;n--){let r=!0;for(let s=0;s<l;s++)if(u(e,n+s)!==u(t,s)){r=!1;break}if(r)return n}return -1}function b(e,t,r){r=Math.min(e.length,r);let s=[],i=t;for(;i<r;){let t=e[i],n=null,a=t>239?4:t>223?3:t>191?2:1;if(i+a<=r){let r,s,o,l;switch(a){case 1:t<128&&(n=t);break;case 2:(192&(r=e[i+1]))==128&&(l=(31&t)<<6|63&r)>127&&(n=l);break;case 3:r=e[i+1],s=e[i+2],(192&r)==128&&(192&s)==128&&(l=(15&t)<<12|(63&r)<<6|63&s)>2047&&(l<55296||l>57343)&&(n=l);break;case 4:r=e[i+1],s=e[i+2],o=e[i+3],(192&r)==128&&(192&s)==128&&(192&o)==128&&(l=(15&t)<<18|(63&r)<<12|(63&s)<<6|63&o)>65535&&l<1114112&&(n=l)}}null===n?(n=65533,a=1):n>65535&&(n-=65536,s.push(n>>>10&1023|55296),n=56320|1023&n),s.push(n),i+=a}var n=s;let a=n.length;if(a<=4096)return String.fromCharCode.apply(String,n);let o="",l=0;for(;l<a;)o+=String.fromCharCode.apply(String,n.slice(l,l+=4096));return o}function v(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function _(e,t,r,s,i,n){if(!o.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<n)throw RangeError('"value" argument is out of bounds');if(r+s>e.length)throw RangeError("Index out of range")}function E(e,t,r,s,i){C(t,s,i,e,r,7);let n=Number(t&BigInt(0xffffffff));e[r++]=n,n>>=8,e[r++]=n,n>>=8,e[r++]=n,n>>=8,e[r++]=n;let a=Number(t>>BigInt(32)&BigInt(0xffffffff));return e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,r}function S(e,t,r,s,i){C(t,s,i,e,r,7);let n=Number(t&BigInt(0xffffffff));e[r+7]=n,n>>=8,e[r+6]=n,n>>=8,e[r+5]=n,n>>=8,e[r+4]=n;let a=Number(t>>BigInt(32)&BigInt(0xffffffff));return e[r+3]=a,a>>=8,e[r+2]=a,a>>=8,e[r+1]=a,a>>=8,e[r]=a,r+8}function O(e,t,r,s,i,n){if(r+s>e.length||r<0)throw RangeError("Index out of range")}function T(e,t,r,s,n){return t*=1,r>>>=0,n||O(e,t,r,4,34028234663852886e22,-34028234663852886e22),i.write(e,t,r,s,23,4),r+4}function R(e,t,r,s,n){return t*=1,r>>>=0,n||O(e,t,r,8,17976931348623157e292,-17976931348623157e292),i.write(e,t,r,s,52,8),r+8}t.hp=o,t.IS=50,o.TYPED_ARRAY_SUPPORT=function(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,r){return(u(e),e<=0)?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)},o.allocUnsafe=function(e){return h(e)},o.allocUnsafeSlow=function(e){return h(e)},o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(B(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),B(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,s=t.length;for(let i=0,n=Math.min(r,s);i<n;++i)if(e[i]!==t[i]){r=e[i],s=t[i];break}return r<s?-1:+(s<r)},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){let r;if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;let s=o.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){let t=e[r];if(B(t,Uint8Array))i+t.length>s.length?(o.isBuffer(t)||(t=o.from(t)),t.copy(s,i)):Uint8Array.prototype.set.call(s,t,i);else if(o.isBuffer(t))t.copy(s,i);else throw TypeError('"list" argument must be an Array of Buffers');i+=t.length}return s},o.byteLength=p,o.prototype._isBuffer=!0,o.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)y(this,t,t+1);return this},o.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},o.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},o.prototype.toString=function(){let e=this.length;return 0===e?"":0==arguments.length?b(this,0,e):g.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){let e="",r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(e,t,r,s,i){if(B(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===s&&(s=0),void 0===i&&(i=this.length),t<0||r>e.length||s<0||i>this.length)throw RangeError("out of range index");if(s>=i&&t>=r)return 0;if(s>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,s>>>=0,i>>>=0,this===e)return 0;let n=i-s,a=r-t,l=Math.min(n,a),u=this.slice(s,i),h=e.slice(t,r);for(let e=0;e<l;++e)if(u[e]!==h[e]){n=u[e],a=h[e];break}return n<a?-1:+(a<n)},o.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},o.prototype.write=function(e,t,r,s){var i,n,a,o,l,u,h,c;if(void 0===t)s="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)s=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===s&&(s="utf8")):(s=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let d=this.length-t;if((void 0===r||r>d)&&(r=d),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");s||(s="utf8");let f=!1;for(;;)switch(s){case"hex":return function(e,t,r,s){let i;r=Number(r)||0;let n=e.length-r;s?(s=Number(s))>n&&(s=n):s=n;let a=t.length;for(s>a/2&&(s=a/2),i=0;i<s;++i){var o;let s=parseInt(t.substr(2*i,2),16);if((o=s)!=o)break;e[r+i]=s}return i}(this,e,t,r);case"utf8":case"utf-8":return i=t,n=r,N(U(e,this.length-i),this,i,n);case"ascii":case"latin1":case"binary":return a=t,o=r,N(function(e){let t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(e),this,a,o);case"base64":return l=t,u=r,N($(e),this,l,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h=t,c=r,N(function(e,t){let r,s,i=[];for(let n=0;n<e.length&&!((t-=2)<0);++n)s=(r=e.charCodeAt(n))>>8,i.push(r%256),i.push(s);return i}(e,this.length-h),this,h,c);default:if(f)throw TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),f=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){let r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);let s=this.subarray(e,t);return Object.setPrototypeOf(s,o.prototype),s},o.prototype.readUintLE=o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);let s=this[e],i=1,n=0;for(;++n<t&&(i*=256);)s+=this[e+n]*i;return s},o.prototype.readUintBE=o.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);let s=this[e+--t],i=1;for(;t>0&&(i*=256);)s+=this[e+--t]*i;return s},o.prototype.readUint8=o.prototype.readUInt8=function(e,t){return e>>>=0,t||v(e,1,this.length),this[e]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||v(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||v(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||v(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||v(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readBigUInt64LE=D(function(e){I(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&P(e,this.length-8);let s=t+256*this[++e]+65536*this[++e]+0x1000000*this[++e],i=this[++e]+256*this[++e]+65536*this[++e]+0x1000000*r;return BigInt(s)+(BigInt(i)<<BigInt(32))}),o.prototype.readBigUInt64BE=D(function(e){I(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&P(e,this.length-8);let s=0x1000000*t+65536*this[++e]+256*this[++e]+this[++e],i=0x1000000*this[++e]+65536*this[++e]+256*this[++e]+r;return(BigInt(s)<<BigInt(32))+BigInt(i)}),o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);let s=this[e],i=1,n=0;for(;++n<t&&(i*=256);)s+=this[e+n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);let s=t,i=1,n=this[e+--s];for(;s>0&&(i*=256);)n+=this[e+--s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},o.prototype.readInt8=function(e,t){return(e>>>=0,t||v(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||v(e,2,this.length);let r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||v(e,2,this.length);let r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||v(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||v(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readBigInt64LE=D(function(e){I(e>>>=0,"offset");let t=this[e],r=this[e+7];return(void 0===t||void 0===r)&&P(e,this.length-8),(BigInt(this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24))<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+0x1000000*this[++e])}),o.prototype.readBigInt64BE=D(function(e){I(e>>>=0,"offset");let t=this[e],r=this[e+7];return(void 0===t||void 0===r)&&P(e,this.length-8),(BigInt((t<<24)+65536*this[++e]+256*this[++e]+this[++e])<<BigInt(32))+BigInt(0x1000000*this[++e]+65536*this[++e]+256*this[++e]+r)}),o.prototype.readFloatLE=function(e,t){return e>>>=0,t||v(e,4,this.length),i.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||v(e,4,this.length),i.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||v(e,8,this.length),i.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||v(e,8,this.length),i.read(this,e,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(e,t,r,s){if(e*=1,t>>>=0,r>>>=0,!s){let s=Math.pow(2,8*r)-1;_(this,e,t,r,s,0)}let i=1,n=0;for(this[t]=255&e;++n<r&&(i*=256);)this[t+n]=e/i&255;return t+r},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(e,t,r,s){if(e*=1,t>>>=0,r>>>=0,!s){let s=Math.pow(2,8*r)-1;_(this,e,t,r,s,0)}let i=r-1,n=1;for(this[t+i]=255&e;--i>=0&&(n*=256);)this[t+i]=e/n&255;return t+r},o.prototype.writeUint8=o.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0xffffffff,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0xffffffff,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeBigUInt64LE=D(function(e,t=0){return E(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=D(function(e,t=0){return S(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(e,t,r,s){if(e*=1,t>>>=0,!s){let s=Math.pow(2,8*r-1);_(this,e,t,r,s-1,-s)}let i=0,n=1,a=0;for(this[t]=255&e;++i<r&&(n*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/n|0)-a&255;return t+r},o.prototype.writeIntBE=function(e,t,r,s){if(e*=1,t>>>=0,!s){let s=Math.pow(2,8*r-1);_(this,e,t,r,s-1,-s)}let i=r-1,n=1,a=0;for(this[t+i]=255&e;--i>=0&&(n*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/n|0)-a&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0x7fffffff,-0x80000000),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||_(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeBigInt64LE=D(function(e,t=0){return E(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=D(function(e,t=0){return S(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeFloatLE=function(e,t,r){return T(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return T(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return R(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return R(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,s){if(!o.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),s||0===s||(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<r&&(s=r),s===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(s<0)throw RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-r&&(s=e.length-t+r);let i=s-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,s):Uint8Array.prototype.set.call(e,this.subarray(r,s),t),i},o.prototype.fill=function(e,t,r,s){let i;if("string"==typeof e){if("string"==typeof t?(s=t,t=0,r=this.length):"string"==typeof r&&(s=r,r=this.length),void 0!==s&&"string"!=typeof s)throw TypeError("encoding must be a string");if("string"==typeof s&&!o.isEncoding(s))throw TypeError("Unknown encoding: "+s);if(1===e.length){let t=e.charCodeAt(0);("utf8"===s&&t<128||"latin1"===s)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{let n=o.isBuffer(e)?e:o.from(e,s),a=n.length;
37if(0===a)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=n[i%a]}return this};let k={};function A(e,t,r){k[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function j(e){let t="",r=e.length,s=+("-"===e[0]);for(;r>=s+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function C(e,t,r,s,i,n){if(e>r||e<t){let s,i="bigint"==typeof t?"n":"";throw s=n>3?0===t||t===BigInt(0)?`>= 0${i} and < 2${i} ** ${(n+1)*8}${i}`:`>= -(2${i} ** ${(n+1)*8-1}${i}) and < 2 ** ${(n+1)*8-1}${i}`:`>= ${t}${i} and <= ${r}${i}`,new k.ERR_OUT_OF_RANGE("value",s,e)}I(i,"offset"),(void 0===s[i]||void 0===s[i+n])&&P(i,s.length-(n+1))}function I(e,t){if("number"!=typeof e)throw new k.ERR_INVALID_ARG_TYPE(t,"number",e)}function P(e,t,r){if(Math.floor(e)!==e)throw I(e,r),new k.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new k.ERR_BUFFER_OUT_OF_BOUNDS;throw new k.ERR_OUT_OF_RANGE(r||"offset",`>= ${+!!r} and <= ${t}`,e)}A("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),A("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),A("ERR_OUT_OF_RANGE",function(e,t,r){let s=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>0x100000000?i=j(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=j(i)),i+="n"),s+=` It must be ${t}. Received ${i}`},RangeError);let x=/[^+/0-9A-Za-z-_]/g;function U(e,t){let r;t=t||1/0;let s=e.length,i=null,n=[];for(let a=0;a<s;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319||a+1===s){(t-=3)>-1&&n.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&n.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&n.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;n.push(r)}else if(r<2048){if((t-=2)<0)break;n.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;n.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;n.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return n}function $(e){return s.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(x,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function N(e,t,r,s){let i;for(i=0;i<s&&!(i+r>=t.length)&&!(i>=e.length);++i)t[i+r]=e[i];return i}function B(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}let L=function(){let e="0123456789abcdef",t=Array(256);for(let r=0;r<16;++r){let s=16*r;for(let i=0;i<16;++i)t[s+i]=e[r]+e[i]}return t}();function D(e){return"undefined"==typeof BigInt?F:e}function F(){throw Error("BigInt not supported")}},83515:(e,t,r)=>{"use strict";r.d(t,{T:()=>i,b:()=>n});var s=r(34049);function i(){let e,t,r=new Promise((r,s)=>{e=r,t=s});function s(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{s({status:"fulfilled",value:t}),e(t)},r.reject=e=>{s({status:"rejected",reason:e}),t(e)},r}function n(e){let t;if(e.then(e=>(t=e,e),s.lQ)?.catch(s.lQ),void 0!==t)return{data:t}}},87843:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;let s=r(71450),i=s.__importDefault(r(37977));t.PostgrestClient=i.default;let n=s.__importDefault(r(72901));t.PostgrestQueryBuilder=n.default;let a=s.__importDefault(r(54419));t.PostgrestFilterBuilder=a.default;let o=s.__importDefault(r(76373));t.PostgrestTransformBuilder=o.default;let l=s.__importDefault(r(3913));t.PostgrestBuilder=l.default;let u=s.__importDefault(r(5732));t.PostgrestError=u.default,t.default={PostgrestClient:i.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:
37a.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:l.default,PostgrestError:u.default}},91511:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="2.87.1"},92758:(e,t,r)=>{"use strict";r.r(t),r.d(t,{FunctionRegion:()=>s,FunctionsClient:()=>u,FunctionsError:()=>n,FunctionsFetchError:()=>a,FunctionsHttpError:()=>l,FunctionsRelayError:()=>o});var s,i=r(71450);class n extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}}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"}(s||(s={}));class u{constructor(e,{headers:t={},customFetch:r,region:i=s.Any}={}){this.url=e,this.headers=t,this.region=i,this.fetch=(e=>e?(...t)=>e(...t):(...e)=>fetch(...e))(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return(0,i.__awaiter)(this,arguments,void 0,function*(e,t={}){var r;let s,i;try{let n,{headers:u,method:h,body:c,signal:d,timeout:f}=t,p={},{region:g}=t;g||(g=this.region);let y=new URL(`${this.url}/${e}`);g&&"any"!==g&&(p["x-region"]=g,y.searchParams.set("forceFunctionRegion",g)),c&&(u&&!Object.prototype.hasOwnProperty.call(u,"Content-Type")||!u)?"undefined"!=typeof Blob&&c instanceof Blob||c instanceof ArrayBuffer?(p["Content-Type"]="application/octet-stream",n=c):"string"==typeof c?(p["Content-Type"]="text/plain",n=c):"undefined"!=typeof FormData&&c instanceof FormData?n=c:(p["Content-Type"]="application/json",n=JSON.stringify(c)):n=c;let m=d;f&&(i=new AbortController,s=setTimeout(()=>i.abort(),f),d?(m=i.signal,d.addEventListener("abort",()=>i.abort())):m=i.signal);let w=yield this.fetch(y.toString(),{method:h||"POST",headers:Object.assign(Object.assign(Object.assign({},p),this.headers),u),body:n,signal:m}).catch(e=>{throw new a(e)}),b=w.headers.get("x-relay-error");if(b&&"true"===b)throw new o(w);if(!w.ok)throw new l(w);let v=(null!=(r=w.headers.get("Content-Type"))?r:"text/plain").split(";")[0].trim();return{data:"application/json"===v?yield w.json():"application/octet-stream"===v||"application/pdf"===v?yield w.blob():"text/event-stream"===v?w:"multipart/form-data"===v?yield w.formData():yield w.text(),error:null,response:w}}catch(e){return{data:null,error:e,response:e instanceof l||e instanceof o?e.context:void 0}}finally{s&&clearTimeout(s)}})}}},93049:(e,t,r)=>{"use strict";r.d(t,{II:()=>c,cc:()=>u,v_:()=>l,wm:()=>h});var s=r(56195),i=r(63122),n=r(83515),a=r(34049);function o(e){return Math.min(1e3*2**e,3e4)}function l(e){return(e??"online")!=="online"||i.t.isOnline()}var u=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function h(e){return e instanceof u}function c(e){let t,r=!1,h=0,c=(0,n.T)(),d=()=>s.m.isFocused()&&("always"===e.networkMode||i.t.isOnline())&&e.canRun(),f=()=>l(e.networkMode)&&e.canRun(),p=e=>{"pending"===c.status&&(t?.(),c.resolve(e))},g=e=>{"pending"===c.status&&(t?.(),c.reject(e))},y=()=>new Promise(r=>{t=e=>{("pending"!==c.status||d())&&r(e)},e.onPause?.()}).then(()=>{t=void 0,"pending"===c.status&&e.onContinue?.()}),m=()=>{let t;if("pending"!==c.status)return;let s=0===h?e.initialPromise:void 0;try{t=s??e.fn()}catch(e){t=Promise.reject(e)}Promise.resolve(t).then(p).catch(t=>{if("pending"!==c.status)return;let s=e.retry??3*!a.S$,i=e.retryDelay??o,n="function"==typeof i?i(h,t):i,l=!0===s||"number"==typeof s&&h<s||"function"==typeof s&&s(h,t);if(r||!l)return void g(t);h++,e.onFail?.(h,t),(0,a.yy)(n).then(()=>d()?void 0:y()).then(()=>{r?g(t):m()})})};return{promise:c,status:()=>c.status,cancel:t=>{if("pending"===c.status){let r=new u(t);g(r),e.onCancel?.(r)}},continue:()=>(t?.(),c),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:f,start:()=>(f()?m():y().then(m),c)}}},95125:(e,t,r)=>{"use strict";r.d(t,{A:()=>ti});var s,i,n={};function a(e,t){return function(){return e.apply(t,arguments)}}r.r(n),r.d(n,{hasBrowserEnv:()=>ec,hasStandardBrowserEnv:()=>ef,hasStandardBrowserWebWorkerEnv:()=>ep,navigator:()=>ed,origin:()=>eg});var o=r(95704);let{toString:l}=Object.prototype,{getPrototypeOf:u}=Object,{iterator:h,toStringTag:c}=Symbol,d=(e=>t=>{let r=l.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),f=e=>(e=e.toLowerCase(),t=>d(t)===e),p=e=>t=>typeof t===e,{isArray:g}=Array,y=p("undefined");function m(e){return null!==e&&!y(e)&&null!==e.constructor&&!y(e.constructor)&&v(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}let w=f("ArrayBuffer"),b=p("string"),v=p("function"),_=p("number"),E=e=>null!==e&&"object"==typeof e,S=e=>{if("object"!==d(e))return!1;let t=u(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(c in e)&&!(h in e)},O=f("Date"),T=f("File"),R=f("Blob"),k=f("FileList"),A=f("URLSearchParams"),[j,C,I,P]=["ReadableStream","Request","Response","Headers"].map(f);function x(e,t){let r,s,{allOwnKeys:i=!1}
37=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null!=e)if("object"!=typeof e&&(e=[e]),g(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{let s;if(m(e))return;let n=i?Object.getOwnPropertyNames(e):Object.keys(e),a=n.length;for(r=0;r<a;r++)s=n[r],t.call(null,e[s],s,e)}}function U(e,t){let r;if(m(e))return null;t=t.toLowerCase();let s=Object.keys(e),i=s.length;for(;i-- >0;)if(t===(r=s[i]).toLowerCase())return r;return null}let $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,N=e=>!y(e)&&e!==$,B=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&u(Uint8Array)),L=f("HTMLFormElement"),D=(e=>{let{hasOwnProperty:t}=e;return(e,r)=>t.call(e,r)})(Object.prototype),F=f("RegExp"),q=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),s={};x(r,(r,i)=>{let n;!1!==(n=t(r,i,e))&&(s[i]=n||r)}),Object.defineProperties(e,s)},M=f("AsyncFunction"),K=(s="function"==typeof setImmediate,i=v($.postMessage),s?setImmediate:i?((e,t)=>($.addEventListener("message",r=>{let{source:s,data:i}=r;s===$&&i===e&&t.length&&t.shift()()},!1),r=>{t.push(r),$.postMessage(e,"*")}))("axios@".concat(Math.random()),[]):e=>setTimeout(e)),W="undefined"!=typeof queueMicrotask?queueMicrotask.bind($):void 0!==o&&o.nextTick||K,V={isArray:g,isArrayBuffer:w,isBuffer:m,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||v(e.append)&&("formdata"===(t=d(e))||"object"===t&&v(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&w(e.buffer)},isString:b,isNumber:_,isBoolean:e=>!0===e||!1===e,isObject:E,isPlainObject:S,isEmptyObject:e=>{if(!E(e)||m(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:j,isRequest:C,isResponse:I,isHeaders:P,isUndefined:y,isDate:O,isFile:T,isBlob:R,isRegExp:F,isFunction:v,isStream:e=>E(e)&&v(e.pipe),isURLSearchParams:A,isTypedArray:B,isFileList:k,forEach:x,merge:function e(){let{caseless:t,skipUndefined:r}=N(this)&&this||{},s={},i=(i,n)=>{let a=t&&U(s,n)||n;S(s[a])&&S(i)?s[a]=e(s[a],i):S(i)?s[a]=e({},i):g(i)?s[a]=i.slice():r&&y(i)||(s[a]=i)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&x(arguments[e],i);return s},extend:function(e,t,r){let{allOwnKeys:s}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return x(t,(t,s)=>{r&&v(t)?e[s]=a(t,r):e[s]=t},{allOwnKeys:s}),e},trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,s)=>{e.prototype=Object.create(t.prototype,s),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,s)=>{let i,n,a,o={};if(t=t||{},null==e)return t;do{for(n=(i=Object.getOwnPropertyNames(e)).length;n-- >0;)a=i[n],(!s||s(a,e,t))&&!o[a]&&(t[a]=e[a],o[a]=!0);e=!1!==r&&u(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:d,kindOfTest:f,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;let s=e.indexOf(t,r);return -1!==s&&s===r},toArray:e=>{if(!e)return null;if(g(e))return e;let t=e.length;if(!_(t))return null;let r=Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{let r,s=(e&&e[h]).call(e);for(;(r=s.next())&&!r.done;){let s=r.value;t.call(e,s[0],s[1])}},matchAll:(e,t)=>{let r,s=[];for(;null!==(r=e.exec(t));)s.push(r);return s},isHTMLForm:L,hasOwnProperty:D,hasOwnProp:D,reduceDescriptors:q,freezeMethods:e=>{q(e,(t,r)=>{if(v(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;if(v(e[r])){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},toObjectSet:(e,t)=>{let r={};return(g(e)?e:String(e).split(t)).forEach(e=>{r[e]=!0}),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e*=1)?e:t,findKey:U,global:$,isContextDefined:N,isSpecCompliantForm:function(e){return!!(e&&v(e.append)&&"FormData"===e[c]&&e[h])},toJSONObject:e=>{let t=Array(10),r=(e,s)=>{if(E(e)){if(t.indexOf(e)>=0)return;if(m(e))return e;if(!("toJSON"in e)){t[s]=e;let i=g(e)?[]:{};return x(e,(e,t)=>{let n=r(e,s+1);y(n)||(i[t]=n)}),t[s]=void 0,i}}return e};return r(e,0)},isAsyncFn:M,isThenable:e=>e&&(E(e)||v(e))&&v(e.then)&&v(e.catch),setImmediate:K,asap:W,isIterable:e=>null!=e&&v(e[h])};function H(e,t,r,s,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),s&&(this.request=s),i&&(this.response=i,this.status=i.status?i.status:null)}V.inherits(H,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});let G=H.prototype,z={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","E
37RR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{z[e]={value:e}}),Object.defineProperties(H,z),Object.defineProperty(G,"isAxiosError",{value:!0}),H.from=(e,t,r,s,i,n)=>{let a=Object.create(G);V.toFlatObject(e,a,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);let o=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return H.call(a,o,l,r,s,i),e&&null==a.cause&&Object.defineProperty(a,"cause",{value:e,configurable:!0}),a.name=e&&e.name||"Error",n&&Object.assign(a,n),a};var J=r(81029).hp;function Q(e){return V.isPlainObject(e)||V.isArray(e)}function Y(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function X(e,t,r){return e?e.concat(t).map(function(e,t){return e=Y(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}let Z=V.toFlatObject(V,{},null,function(e){return/^is[A-Z]/.test(e)}),ee=function(e,t,r){if(!V.isObject(e))throw TypeError("target must be an object");t=t||new FormData;let s=(r=V.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!V.isUndefined(t[e])})).metaTokens,i=r.visitor||u,n=r.dots,a=r.indexes,o=(r.Blob||"undefined"!=typeof Blob&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(i))throw TypeError("visitor must be a function");function l(e){if(null===e)return"";if(V.isDate(e))return e.toISOString();if(V.isBoolean(e))return e.toString();if(!o&&V.isBlob(e))throw new H("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(e)||V.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):J.from(e):e}function u(e,r,i){let o=e;if(e&&!i&&"object"==typeof e)if(V.endsWith(r,"{}"))r=s?r:r.slice(0,-2),e=JSON.stringify(e);else{var u;if(V.isArray(e)&&(u=e,V.isArray(u)&&!u.some(Q))||(V.isFileList(e)||V.endsWith(r,"[]"))&&(o=V.toArray(e)))return r=Y(r),o.forEach(function(e,s){V.isUndefined(e)||null===e||t.append(!0===a?X([r],s,n):null===a?r:r+"[]",l(e))}),!1}return!!Q(e)||(t.append(X(i,r,n),l(e)),!1)}let h=[],c=Object.assign(Z,{defaultVisitor:u,convertValue:l,isVisitable:Q});if(!V.isObject(e))throw TypeError("data must be an object");return!function e(r,s){if(!V.isUndefined(r)){if(-1!==h.indexOf(r))throw Error("Circular reference detected in "+s.join("."));h.push(r),V.forEach(r,function(r,n){!0===(!(V.isUndefined(r)||null===r)&&i.call(t,r,V.isString(n)?n.trim():n,s,c))&&e(r,s?s.concat(n):[n])}),h.pop()}}(e),t};function et(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function er(e,t){this._pairs=[],e&&ee(e,this,t)}let es=er.prototype;function ei(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function en(e,t,r){let s;if(!t)return e;let i=r&&r.encode||ei;V.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize;if(s=n?n(t,r):V.isURLSearchParams(t)?t.toString():new er(t,r).toString(i)){let t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}es.append=function(e,t){this._pairs.push([e,t])},es.toString=function(e){let t=e?function(t){return e.call(this,t,et)}:et;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class ea{use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){V.forEach(this.handlers,function(t){null!==t&&e(t)})}constructor(){this.handlers=[]}}let eo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},el="undefined"!=typeof URLSearchParams?URLSearchParams:er,eu="undefined"!=typeof FormData?FormData:null,eh="undefined"!=typeof Blob?Blob:null,ec="undefined"!=typeof window&&"undefined"!=typeof document,ed="object"==typeof navigator&&navigator||void 0,ef=ec&&(!ed||0>["ReactNative","NativeScript","NS"].indexOf(ed.product)),ep="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,eg=ec&&window.location.href||"http://localhost",ey={...n,isBrowser:!0,classes:{URLSearchParams:el,FormData:eu,Blob:eh},protocols:["http","https","file","blob","url","data"]},em=function(e){if(V.isFormData(e)&&V.isFunction(e.entries)){let t={};
37return V.forEachEntry(e,(e,r)=>{!function e(t,r,s,i){let n=t[i++];if("__proto__"===n)return!0;let a=Number.isFinite(+n),o=i>=t.length;return(n=!n&&V.isArray(s)?s.length:n,o)?V.hasOwnProp(s,n)?s[n]=[s[n],r]:s[n]=r:(s[n]&&V.isObject(s[n])||(s[n]=[]),e(t,r,s[n],i)&&V.isArray(s[n])&&(s[n]=function(e){let t,r,s={},i=Object.keys(e),n=i.length;for(t=0;t<n;t++)s[r=i[t]]=e[r];return s}(s[n]))),!a}(V.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0]),r,t,0)}),t}return null},ew={transitional:eo,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){let r,s=t.getContentType()||"",i=s.indexOf("application/json")>-1,n=V.isObject(e);if(n&&V.isHTMLForm(e)&&(e=new FormData(e)),V.isFormData(e))return i?JSON.stringify(em(e)):e;if(V.isArrayBuffer(e)||V.isBuffer(e)||V.isStream(e)||V.isFile(e)||V.isBlob(e)||V.isReadableStream(e))return e;if(V.isArrayBufferView(e))return e.buffer;if(V.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();if(n){if(s.indexOf("application/x-www-form-urlencoded")>-1){var a,o;return(a=e,o=this.formSerializer,ee(a,new ey.classes.URLSearchParams,{visitor:function(e,t,r,s){return ey.isNode&&V.isBuffer(e)?(this.append(t,e.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...o})).toString()}if((r=V.isFileList(e))||s.indexOf("multipart/form-data")>-1){let t=this.env&&this.env.FormData;return ee(r?{"files[]":e}:e,t&&new t,this.formSerializer)}}if(n||i){t.setContentType("application/json",!1);var l=e;if(V.isString(l))try{return(0,JSON.parse)(l),V.trim(l)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(l)}return e}],transformResponse:[function(e){let t=this.transitional||ew.transitional,r=t&&t.forcedJSONParsing,s="json"===this.responseType;if(V.isResponse(e)||V.isReadableStream(e))return e;if(e&&V.isString(e)&&(r&&!this.responseType||s)){let r=t&&t.silentJSONParsing;try{return JSON.parse(e,this.parseReviver)}catch(e){if(!r&&s){if("SyntaxError"===e.name)throw H.from(e,H.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ey.classes.FormData,Blob:ey.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{ew.headers[e]={}});let eb=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ev=Symbol("internals");function e_(e){return e&&String(e).trim().toLowerCase()}function eE(e){return!1===e||null==e?e:V.isArray(e)?e.map(eE):String(e)}function eS(e,t,r,s,i){if(V.isFunction(s))return s.call(this,t,r);if(i&&(t=r),V.isString(t)){if(V.isString(s))return -1!==t.indexOf(s);if(V.isRegExp(s))return s.test(t)}}class eO{set(e,t,r){let s=this;function i(e,t,r){let i=e_(t);if(!i)throw Error("header name must be a non-empty string");let n=V.findKey(s,i);n&&void 0!==s[n]&&!0!==r&&(void 0!==r||!1===s[n])||(s[n||t]=eE(e))}let n=(e,t)=>V.forEach(e,(e,r)=>i(e,r,t));if(V.isPlainObject(e)||e instanceof this.constructor)n(e,t);else{let s;if(V.isString(e)&&(e=e.trim())&&(s=e,!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim())))n((e=>{let t,r,s,i={};return e&&e.split("\n").forEach(function(e){s=e.indexOf(":"),t=e.substring(0,s).trim().toLowerCase(),r=e.substring(s+1).trim(),!t||i[t]&&eb[t]||("set-cookie"===t?i[t]?i[t].push(r):i[t]=[r]:i[t]=i[t]?i[t]+", "+r:r)}),i})(e),t);else if(V.isObject(e)&&V.isIterable(e)){let r={},s,i;for(let t of e){if(!V.isArray(t))throw TypeError("Object iterator must return a key-value pair");r[i=t[0]]=(s=r[i])?V.isArray(s)?[...s,t[1]]:[s,t[1]]:t[1]}n(r,t)}else null!=e&&i(t,e,r)}return this}get(e,t){if(e=e_(e)){let r=V.findKey(this,e);if(r){let e=this[r];if(!t)return e;if(!0===t){let t,r=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
37for(;t=s.exec(e);)r[t[1]]=t[2];return r}if(V.isFunction(t))return t.call(this,e,r);if(V.isRegExp(t))return t.exec(e);throw TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=e_(e)){let r=V.findKey(this,e);return!!(r&&void 0!==this[r]&&(!t||eS(this,this[r],r,t)))}return!1}delete(e,t){let r=this,s=!1;function i(e){if(e=e_(e)){let i=V.findKey(r,e);i&&(!t||eS(r,r[i],i,t))&&(delete r[i],s=!0)}}return V.isArray(e)?e.forEach(i):i(e),s}clear(e){let t=Object.keys(this),r=t.length,s=!1;for(;r--;){let i=t[r];(!e||eS(this,this[i],i,e,!0))&&(delete this[i],s=!0)}return s}normalize(e){let t=this,r={};return V.forEach(this,(s,i)=>{let n=V.findKey(r,i);if(n){t[n]=eE(s),delete t[i];return}let a=e?i.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r):String(i).trim();a!==i&&delete t[i],t[a]=eE(s),r[a]=!0}),this}concat(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.constructor.concat(this,...t)}toJSON(e){let t=Object.create(null);return V.forEach(this,(r,s)=>{null!=r&&!1!==r&&(t[s]=e&&V.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(e=>{let[t,r]=e;return t+": "+r}).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e){for(var t=arguments.length,r=Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];let i=new this(e);return r.forEach(e=>i.set(e)),i}static accessor(e){let t=(this[ev]=this[ev]={accessors:{}}).accessors,r=this.prototype;function s(e){let s=e_(e);if(!t[s]){let i=V.toCamelCase(" "+e);["get","set","has"].forEach(t=>{Object.defineProperty(r,t+i,{value:function(r,s,i){return this[t].call(this,e,r,s,i)},configurable:!0})}),t[s]=!0}}return V.isArray(e)?e.forEach(s):s(e),this}constructor(e){e&&this.set(e)}}function eT(e,t){let r=this||ew,s=t||r,i=eO.from(s.headers),n=s.data;return V.forEach(e,function(e){n=e.call(r,n,i.normalize(),t?t.status:void 0)}),i.normalize(),n}function eR(e){return!!(e&&e.__CANCEL__)}function ek(e,t,r){H.call(this,null==e?"canceled":e,H.ERR_CANCELED,t,r),this.name="CanceledError"}function eA(e,t,r){let s=r.config.validateStatus;!r.status||!s||s(r.status)?e(r):t(new H("Request failed with status code "+r.status,[H.ERR_BAD_REQUEST,H.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}eO.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(eO.prototype,(e,t)=>{let{value:r}=e,s=t[0].toUpperCase()+t.slice(1);return{get:()=>r,set(e){this[s]=e}}}),V.freezeMethods(eO),V.inherits(ek,H,{__CANCEL__:!0});let ej=function(e,t){let r,s=Array(e=e||10),i=Array(e),n=0,a=0;return t=void 0!==t?t:1e3,function(o){let l=Date.now(),u=i[a];r||(r=l),s[n]=o,i[n]=l;let h=a,c=0;for(;h!==n;)c+=s[h++],h%=e;if((n=(n+1)%e)===a&&(a=(a+1)%e),l-r<t)return;let d=u&&l-u;return d?Math.round(1e3*c/d):void 0}},eC=function(e,t){let r,s,i=0,n=1e3/t,a=function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();i=n,r=null,s&&(clearTimeout(s),s=null),e(...t)};return[function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];let l=Date.now(),u=l-i;u>=n?a(t,l):(r=t,s||(s=setTimeout(()=>{s=null,a(r)},n-u)))},()=>r&&a(r)]},eI=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,s=0,i=ej(50,250);return eC(r=>{let n=r.loaded,a=r.lengthComputable?r.total:void 0,o=n-s,l=i(o);s=n,e({loaded:n,total:a,progress:a?n/a:void 0,bytes:o,rate:l||void 0,estimated:l&&a&&n<=a?(a-n)/l:void 0,event:r,lengthComputable:null!=a,[t?"download":"upload"]:!0})},r)},eP=(e,t)=>{let r=null!=e;return[s=>t[0]({lengthComputable:r,total:e,loaded:s}),t[1]]},ex=e=>function(){for(var t=arguments.length,r=Array(t),s=0;s<t;s++)r[s]=arguments[s];return V.asap(()=>e(...r))},eU=ey.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ey.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ey.origin),ey.navigator&&/(msie|trident)/i.test(ey.navigator.userAgent)):()=>!0,e$=ey.hasStandardBrowserEnv?{write(e,t,r,s,i,n,a){if("undefined"==typeof document)return;let o=["".concat(e,"=").concat(encodeURIComponent(t))];V.isNumber(r)&&o.push("expires=".concat(new Date(r).toUTCString())),V.isString(s)&&o.push("path=".concat(s)),V.isString(i)&&o.push("domain=".concat(i)),!0===n&&o.push("secure"),V.isString(a)&&o.push("SameSite=".concat(a)),document.cookie=o.join("; ")},read(e){if("undefined"==typeof document)return null;let t=document.cookie.match(RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function eN(e,t,r){let s=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(s||!1==r)?t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e:t}let eB=e=>e instanceof eO?{...e}:e;
37function eL(e,t){t=t||{};let r={};function s(e,t,r,s){return V.isPlainObject(e)&&V.isPlainObject(t)?V.merge.call({caseless:s},e,t):V.isPlainObject(t)?V.merge({},t):V.isArray(t)?t.slice():t}function i(e,t,r,i){return V.isUndefined(t)?V.isUndefined(e)?void 0:s(void 0,e,r,i):s(e,t,r,i)}function n(e,t){if(!V.isUndefined(t))return s(void 0,t)}function a(e,t){return V.isUndefined(t)?V.isUndefined(e)?void 0:s(void 0,e):s(void 0,t)}function o(r,i,n){return n in t?s(r,i):n in e?s(void 0,r):void 0}let l={url:n,method:n,data:n,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(e,t,r)=>i(eB(e),eB(t),r,!0)};return V.forEach(Object.keys({...e,...t}),function(s){let n=l[s]||i,a=n(e[s],t[s],s);V.isUndefined(a)&&n!==o||(r[s]=a)}),r}let eD=e=>{let t=eL({},e),{data:r,withXSRFToken:s,xsrfHeaderName:i,xsrfCookieName:n,headers:a,auth:o}=t;if(t.headers=a=eO.from(a),t.url=en(eN(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),V.isFormData(r)){if(ey.hasStandardBrowserEnv||ey.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(V.isFunction(r.getHeaders)){let e=r.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(e=>{let[r,s]=e;t.includes(r.toLowerCase())&&a.set(r,s)})}}if(ey.hasStandardBrowserEnv&&(s&&V.isFunction(s)&&(s=s(t)),s||!1!==s&&eU(t.url))){let e=i&&n&&e$.read(n);e&&a.set(i,e)}return t},eF="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,r){let s,i,n,a,o,l=eD(e),u=l.data,h=eO.from(l.headers).normalize(),{responseType:c,onUploadProgress:d,onDownloadProgress:f}=l;function p(){a&&a(),o&&o(),l.cancelToken&&l.cancelToken.unsubscribe(s),l.signal&&l.signal.removeEventListener("abort",s)}let g=new XMLHttpRequest;function y(){if(!g)return;let s=eO.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());eA(function(e){t(e),p()},function(e){r(e),p()},{data:c&&"text"!==c&&"json"!==c?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:s,config:e,request:g}),g=null}g.open(l.method.toUpperCase(),l.url,!0),g.timeout=l.timeout,"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(y)},g.onabort=function(){g&&(r(new H("Request aborted",H.ECONNABORTED,e,g)),g=null)},g.onerror=function(t){let s=new H(t&&t.message?t.message:"Network Error",H.ERR_NETWORK,e,g);s.event=t||null,r(s),g=null},g.ontimeout=function(){let t=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded",s=l.transitional||eo;l.timeoutErrorMessage&&(t=l.timeoutErrorMessage),r(new H(t,s.clarifyTimeoutError?H.ETIMEDOUT:H.ECONNABORTED,e,g)),g=null},void 0===u&&h.setContentType(null),"setRequestHeader"in g&&V.forEach(h.toJSON(),function(e,t){g.setRequestHeader(t,e)}),V.isUndefined(l.withCredentials)||(g.withCredentials=!!l.withCredentials),c&&"json"!==c&&(g.responseType=l.responseType),f&&([n,o]=eI(f,!0),g.addEventListener("progress",n)),d&&g.upload&&([i,a]=eI(d),g.upload.addEventListener("progress",i),g.upload.addEventListener("loadend",a)),(l.cancelToken||l.signal)&&(s=t=>{g&&(r(!t||t.type?new ek(null,e,g):t),g.abort(),g=null)},l.cancelToken&&l.cancelToken.subscribe(s),l.signal&&(l.signal.aborted?s():l.signal.addEventListener("abort",s)));let m=function(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(l.url);if(m&&-1===ey.protocols.indexOf(m))return void r(new H("Unsupported protocol "+m+":",H.ERR_BAD_REQUEST,e));g.send(u||null)})},eq=function*(e,t){let r,s=e.byteLength;if(!t||s<t)return void(yield e);let i=0;for(;i<s;)r=i+t,yield e.slice(i,r),i=r},eM=async function*(e,t){for await(let r of eK(e))yield*eq(r,t)},eK=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);let t=e.getReader();try{for(;;){let{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},eW=(e,t,r,s)=>{let i,n=eM(e,t),a=0,o=e=>{!i&&(i=!0,s&&s(e))};return new ReadableStream({async pull(e){try{let{done:t,value:s}=await n.next();if(t){o(),e.close();return}let i=s.byteLength;if(r){let e=a+=i;r(e)}e.enqueue(new Uint8Array(s))}catch(e){throw o(e),e}},cancel:e=>(o(e),n.return())},{highWaterMark:2})},{isFunction:eV}=V,eH=(e=>{let{Request:t,Response:r}=e;return{Request:t,Response:r}})(V.global),{ReadableStream:eG,TextEncoder:ez}=V.global,eJ=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];try{return!!e(...r)}catch(e){return!1}},eQ=e=>{let t,{fetch:r,Request:s,Response:i}=e=V.merge.call({skipUndefined:!0},eH,e),n=r?eV(r):"function"==typeof fetch,a=eV(s),o=eV(i);if(!n)return!1;let l=n&&eV(eG),u=n&&("function"==typeof ez?(t=new ez,e=>t.encode(e)):async e=>new Uint8Array(await new s(e).arrayBuffer())),h=a&&l&&eJ(()=>{let e=!1,t=new s(ey.origin,{body:new eG,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),c=o&&l&&eJ(()=>V.isReadableStream(new i("").body)),d={stream:c&&(e=>e.body)};
37n&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{d[e]||(d[e]=(t,r)=>{let s=t&&t[e];if(s)return s.call(t);throw new H("Response type '".concat(e,"' is not supported"),H.ERR_NOT_SUPPORT,r)})});let f=async e=>{if(null==e)return 0;if(V.isBlob(e))return e.size;if(V.isSpecCompliantForm(e)){let t=new s(ey.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return V.isArrayBufferView(e)||V.isArrayBuffer(e)?e.byteLength:(V.isURLSearchParams(e)&&(e+=""),V.isString(e))?(await u(e)).byteLength:void 0},p=async(e,t)=>{let r=V.toFiniteNumber(e.getContentLength());return null==r?f(t):r};return async e=>{let t,{url:n,method:o,data:l,signal:u,cancelToken:f,timeout:g,onDownloadProgress:y,onUploadProgress:m,responseType:w,headers:b,withCredentials:v="same-origin",fetchOptions:_}=eD(e),E=r||fetch;w=w?(w+"").toLowerCase():"text";let S=((e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,s=new AbortController,i=function(e){if(!r){r=!0,a();let t=e instanceof Error?e:this.reason;s.abort(t instanceof H?t:new ek(t instanceof Error?t.message:t))}},n=t&&setTimeout(()=>{n=null,i(new H("timeout ".concat(t," of ms exceeded"),H.ETIMEDOUT))},t),a=()=>{e&&(n&&clearTimeout(n),n=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i));let{signal:o}=s;return o.unsubscribe=()=>V.asap(a),o}})([u,f&&f.toAbortSignal()],g),O=null,T=S&&S.unsubscribe&&(()=>{S.unsubscribe()});try{if(m&&h&&"get"!==o&&"head"!==o&&0!==(t=await p(b,l))){let e,r=new s(n,{method:"POST",body:l,duplex:"half"});if(V.isFormData(l)&&(e=r.headers.get("content-type"))&&b.setContentType(e),r.body){let[e,s]=eP(t,eI(ex(m)));l=eW(r.body,65536,e,s)}}V.isString(v)||(v=v?"include":"omit");let r=a&&"credentials"in s.prototype,u={..._,signal:S,method:o.toUpperCase(),headers:b.normalize().toJSON(),body:l,duplex:"half",credentials:r?v:void 0};O=a&&new s(n,u);let f=await (a?E(O,_):E(n,u)),g=c&&("stream"===w||"response"===w);if(c&&(y||g&&T)){let e={};["status","statusText","headers"].forEach(t=>{e[t]=f[t]});let t=V.toFiniteNumber(f.headers.get("content-length")),[r,s]=y&&eP(t,eI(ex(y),!0))||[];f=new i(eW(f.body,65536,r,()=>{s&&s(),T&&T()}),e)}w=w||"text";let R=await d[V.findKey(d,w)||"text"](f,e);return!g&&T&&T(),await new Promise((t,r)=>{eA(t,r,{data:R,headers:eO.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:O})})}catch(t){if(T&&T(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new H("Network Error",H.ERR_NETWORK,e,O),{cause:t.cause||t});throw H.from(t,t&&t.code,e,O)}}},eY=new Map,eX=e=>{let t=e&&e.env||{},{fetch:r,Request:s,Response:i}=t,n=[s,i,r],a=n.length,o,l,u=eY;for(;a--;)o=n[a],void 0===(l=u.get(o))&&u.set(o,l=a?new Map:eQ(t)),u=l;return l};eX();let eZ={http:null,xhr:eF,fetch:{get:eX}};V.forEach(eZ,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});let e0=e=>"- ".concat(e),e1=e=>V.isFunction(e)||null===e||!1===e,e2={getAdapter:function(e,t){let r,s,{length:i}=e=V.isArray(e)?e:[e],n={};for(let a=0;a<i;a++){let i;if(s=r=e[a],!e1(r)&&void 0===(s=eZ[(i=String(r)).toLowerCase()]))throw new H("Unknown adapter '".concat(i,"'"));if(s&&(V.isFunction(s)||(s=s.get(t))))break;n[i||"#"+a]=s}if(!s){let e=Object.entries(n).map(e=>{let[t,r]=e;return"adapter ".concat(t," ")+(!1===r?"is not supported by the environment":"is not available in the build")});throw new H("There is no suitable adapter to dispatch the request "+(i?e.length>1?"since :\n"+e.map(e0).join("\n"):" "+e0(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return s}};function e5(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ek(null,e)}function e3(e){return e5(e),e.headers=eO.from(e.headers),e.data=eT.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),e2.getAdapter(e.adapter||ew.adapter,e)(e).then(function(t){return e5(e),t.data=eT.call(e,e.transformResponse,t),t.headers=eO.from(t.headers),t},function(t){return!eR(t)&&(e5(e),t&&t.response&&(t.response.data=eT.call(e,e.transformResponse,t.response),t.response.headers=eO.from(t.response.headers))),Promise.reject(t)})}let e8="1.13.2",e6={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{e6[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});let e4={};e6.transitional=function(e,t,r){function s(e,t){return"[Axios v"+e8+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,n)=>{if(!1===e)throw new H(s(i," has been removed"+(t?" in "+t:"")),H.ERR_DEPRECATED);return t&&!e4[i]&&(e4[i]=!0,console.warn(s(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,n)}},e6.spelling=function(e){return(t,r)=>(console.warn("".concat(r," is likely a misspelling of ").concat(e)),!0)};let e7={assertOptions:function(e,t,r){if("object"!=typeof e)throw new H("options must be an object",H.ERR_BAD_OPTION_VALUE);let s=Object.keys(e),i=s.length;for(;i-- >0;){let n=s[i],a=t[n];if(a){let t=e[n],r=void 0===t||a(t,n,e);if(!0!==r)throw new H("option "+n+" must be "+r,H.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new H("Unknown option "+n,H.ERR_BAD_OPTION)}},validators:e6},e9=e7.validators;class te{async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){let r,s;"string"==typeof e?(t=t||{}).url=e:t=e||{};let{transitional:i,paramsSerializer:n,headers:a}=t=eL(this.defaults,t);void 0!==i&&e7.assertOptions(i,{silentJSONParsing:e9.transitional(e9.boolean),forcedJSONParsing:e9.transitional(e9.boolean),clarifyTimeoutError:e9.transitional(e9.boolean)}
37,!1),null!=n&&(V.isFunction(n)?t.paramsSerializer={serialize:n}:e7.assertOptions(n,{encode:e9.function,serialize:e9.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),e7.assertOptions(t,{baseUrl:e9.spelling("baseURL"),withXsrfToken:e9.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=a&&V.merge(a.common,a[t.method]);a&&V.forEach(["delete","get","head","post","put","patch","common"],e=>{delete a[e]}),t.headers=eO.concat(o,a);let l=[],u=!0;this.interceptors.request.forEach(function(e){("function"!=typeof e.runWhen||!1!==e.runWhen(t))&&(u=u&&e.synchronous,l.unshift(e.fulfilled,e.rejected))});let h=[];this.interceptors.response.forEach(function(e){h.push(e.fulfilled,e.rejected)});let c=0;if(!u){let e=[e3.bind(this),void 0];for(e.unshift(...l),e.push(...h),s=e.length,r=Promise.resolve(t);c<s;)r=r.then(e[c++],e[c++]);return r}s=l.length;let d=t;for(;c<s;){let e=l[c++],t=l[c++];try{d=e(d)}catch(e){t.call(this,e);break}}try{r=e3.call(this,d)}catch(e){return Promise.reject(e)}for(c=0,s=h.length;c<s;)r=r.then(h[c++],h[c++]);return r}getUri(e){return en(eN((e=eL(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}constructor(e){this.defaults=e||{},this.interceptors={request:new ea,response:new ea}}}V.forEach(["delete","get","head","options"],function(e){te.prototype[e]=function(t,r){return this.request(eL(r||{},{method:e,url:t,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(e){function t(t){return function(r,s,i){return this.request(eL(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}te.prototype[e]=t(),te.prototype[e+"Form"]=t(!0)});class tt{throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason)return void e(this.reason);this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new tt(function(t){e=t}),cancel:e}}constructor(e){let t;if("function"!=typeof e)throw TypeError("executor must be a function.");this.promise=new Promise(function(e){t=e});let r=this;this.promise.then(e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null}),this.promise.then=e=>{let t,s=new Promise(e=>{r.subscribe(e),t=e}).then(e);return s.cancel=function(){r.unsubscribe(t)},s},e(function(e,s,i){r.reason||(r.reason=new ek(e,s,i),t(r.reason))})}}let tr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,Parti
37alContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(tr).forEach(e=>{let[t,r]=e;tr[r]=t});let ts=function e(t){let r=new te(t),s=a(te.prototype.request,r);return V.extend(s,te.prototype,r,{allOwnKeys:!0}),V.extend(s,r,null,{allOwnKeys:!0}),s.create=function(r){return e(eL(t,r))},s}(ew);ts.Axios=te,ts.CanceledError=ek,ts.CancelToken=tt,ts.isCancel=eR,ts.VERSION=e8,ts.toFormData=ee,ts.AxiosError=H,ts.Cancel=ts.CanceledError,ts.all=function(e){return Promise.all(e)},ts.spread=function(e){return function(t){return e.apply(null,t)}},ts.isAxiosError=function(e){return V.isObject(e)&&!0===e.isAxiosError},ts.mergeConfig=eL,ts.AxiosHeaders=eO,ts.formToJSON=e=>em(V.isHTMLForm(e)?new FormData(e):e),ts.getAdapter=e2.getAdapter,ts.HttpStatusCode=tr,ts.default=ts;let ti=ts},95822:(e,t,r)=>{"use strict";r.d(t,{EU:()=>a,R3:()=>s,iL:()=>o,jv:()=>i,nE:()=>n});var s=(e,t)=>void 0===t.state.data,i=e=>{if(e.suspense){let t=e=>"static"===e?e:Math.max(null!=e?e:1e3,1e3),r=e.staleTime;e.staleTime="function"==typeof r?function(){for(var e=arguments.length,s=Array(e),i=0;i<e;i++)s[i]=arguments[i];return t(r(...s))}:t(r),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,1e3))}},n=(e,t)=>e.isLoading&&e.isFetching&&!t,a=(e,t)=>(null==e?void 0:e.suspense)&&t.isPending,o=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()})},98762:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_REALTIME_OPTIONS=t.DEFAULT_AUTH_OPTIONS=t.DEFAULT_DB_OPTIONS=t.DEFAULT_GLOBAL_OPTIONS=t.DEFAULT_HEADERS=void 0;let s=r(91511),i="";i="undefined"!=typeof Deno?"deno":"undefined"!=typeof document?"web":"undefined"!=typeof navigator&&"ReactNative"===navigator.product?"react-native":"node",t.DEFAULT_HEADERS={"X-Client-Info":"supabase-js-".concat(i,"/").concat(s.version)},t.DEFAULT_GLOBAL_OPTIONS={headers:t.DEFAULT_HEADERS},t.DEFAULT_DB_OPTIONS={schema:"public"},t.DEFAULT_AUTH_OPTIONS={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},t.DEFAULT_REALTIME_OPTIONS={}},99776:(e,t,r)=>{"use strict";r.d(t,{Ht:()=>o,jE:()=>a,v4:()=>n});var s=r(12115),i=r(95155),n=s.createContext(void 0),a=e=>{let t=s.useContext(n);if(e)return e;if(!t)throw Error("No QueryClient set, use QueryClientProvider to set one");return t},o=e=>{let{client:t,children:r}=e;return s.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,i.jsx)(n.Provider,{value:t,children:r})}}}]);
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.