heyio 1.2.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/server.js +267 -12
- package/dist/config.js +6 -0
- package/dist/copilot/agents.js +61 -4
- package/dist/copilot/ceremonies.js +12 -2
- package/dist/copilot/io-scheduler.js +9 -1
- package/dist/copilot/orchestrator.js +2 -0
- package/dist/copilot/scheduler.js +4 -0
- package/dist/copilot/skills.js +138 -6
- package/dist/copilot/token-tracker.js +89 -0
- package/dist/copilot/tools.js +27 -5
- package/dist/paths.js +1 -0
- package/dist/store/agent-events.js +19 -0
- package/dist/store/audit-log.js +71 -0
- package/dist/store/conversations.js +150 -0
- package/dist/store/db.js +111 -0
- package/dist/store/schedules.js +5 -1
- package/dist/store/squad-colors.js +21 -0
- package/dist/store/squads.js +6 -1
- package/dist/store/tasks.js +43 -0
- package/dist/store/token-usage.js +94 -0
- package/dist/wiki/backlinks.js +51 -0
- package/dist/wiki/fs.js +63 -1
- package/package.json +1 -1
- package/web-dist/assets/AuditLogView-xgSZ2MOJ.js +6 -0
- package/web-dist/assets/ChatView-BU3Jvu5y.js +11 -0
- package/web-dist/assets/FeedView-BwkWbe1p.js +6 -0
- package/web-dist/assets/HistoryView-Doh9Y3Na.js +1 -0
- package/web-dist/assets/LoginView-CoTEOrwE.js +1 -0
- package/web-dist/assets/{MarkdownContent.vue_vue_type_script_setup_true_lang-CEo_ckIb.js → MarkdownContent.vue_vue_type_script_setup_true_lang-CObjuCHH.js} +1 -1
- package/web-dist/assets/McpView-ByXoAnED.js +1 -0
- package/web-dist/assets/SchedulesView-BkUdRYwk.js +1 -0
- package/web-dist/assets/SettingsView-_q-IpzFy.js +1 -0
- package/web-dist/assets/SkillsView-_FkOdD2U.js +15 -0
- package/web-dist/assets/SquadDetailView-CV6_n_If.js +31 -0
- package/web-dist/assets/SquadHealthView-DmQqPq7H.js +11 -0
- package/web-dist/assets/SquadsView-Dkhtu5MQ.js +6 -0
- package/web-dist/assets/UsageView-CCS6pp6n.js +16 -0
- package/web-dist/assets/WikiView-CpXzff_L.js +31 -0
- package/web-dist/assets/api-CaqVk-rG.js +1 -0
- package/web-dist/assets/arrow-left-CkDjCT7Z.js +6 -0
- package/web-dist/assets/git-branch-Bu9s__XL.js +6 -0
- package/web-dist/assets/index-D3DNfwXI.css +1 -0
- package/web-dist/assets/{index-BQdXxKfc.js → index-DfdD_qE4.js} +56 -36
- package/web-dist/assets/{plus-Cvp1w2CO.js → plus-GvGwcjX5.js} +1 -1
- package/web-dist/assets/{x-O3fBd1Cr.js → save-fQ_rr5hX.js} +2 -7
- package/web-dist/assets/search-C3fxUixl.js +6 -0
- package/web-dist/assets/squad-colors-B8B_Y-lz.js +1 -0
- package/web-dist/assets/{trash-2-Cr3vrmL5.js → trash-2-Ba_1SAua.js} +1 -1
- package/web-dist/assets/triangle-alert-BTBlX3kg.js +6 -0
- package/web-dist/assets/x-CJifAZQa.js +6 -0
- package/web-dist/favicon.svg +9 -3
- package/web-dist/index.html +2 -2
- package/web-dist/logo.svg +10 -0
- package/web-dist/assets/ChatView-mZaaw3pd.js +0 -11
- package/web-dist/assets/FeedView-BHacQwXQ.js +0 -6
- package/web-dist/assets/LoginView-B6aSD9II.js +0 -1
- package/web-dist/assets/McpView-BAVRUHIE.js +0 -1
- package/web-dist/assets/SchedulesView-dOd1SQiP.js +0 -1
- package/web-dist/assets/SettingsView-CCDeEsVg.js +0 -1
- package/web-dist/assets/SkillsView-gCfQ35FQ.js +0 -1
- package/web-dist/assets/SquadDetailView-CQhFfZTc.js +0 -21
- package/web-dist/assets/SquadsView-CZFxtOao.js +0 -6
- package/web-dist/assets/WikiView-B0cuUFfm.js +0 -26
- package/web-dist/assets/api-DdW5uOZf.js +0 -1
- package/web-dist/assets/index-BbSJ0cfF.css +0 -1
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatView-
|
|
2
|
-
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function r(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(n){if(n.ep)return;n.ep=!0;const i=r(n);fetch(n.href,i)}})();const Rc="modulepreload",Oc=function(t){return"/"+t},Wi={},
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatView-BU3Jvu5y.js","assets/api-CaqVk-rG.js","assets/MarkdownContent.vue_vue_type_script_setup_true_lang-CObjuCHH.js","assets/SquadsView-Dkhtu5MQ.js","assets/squad-colors-B8B_Y-lz.js","assets/git-branch-Bu9s__XL.js","assets/SquadHealthView-DmQqPq7H.js","assets/triangle-alert-BTBlX3kg.js","assets/SquadDetailView-CV6_n_If.js","assets/x-CJifAZQa.js","assets/trash-2-Ba_1SAua.js","assets/arrow-left-CkDjCT7Z.js","assets/FeedView-BwkWbe1p.js","assets/SkillsView-_FkOdD2U.js","assets/plus-GvGwcjX5.js","assets/search-C3fxUixl.js","assets/save-fQ_rr5hX.js","assets/McpView-ByXoAnED.js","assets/SchedulesView-BkUdRYwk.js","assets/HistoryView-Doh9Y3Na.js","assets/WikiView-CpXzff_L.js","assets/UsageView-CCS6pp6n.js","assets/AuditLogView-xgSZ2MOJ.js","assets/SettingsView-_q-IpzFy.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function r(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(n){if(n.ep)return;n.ep=!0;const i=r(n);fetch(n.href,i)}})();const Rc="modulepreload",Oc=function(t){return"/"+t},Wi={},Re=function(e,r,s){let n=Promise.resolve();if(r&&r.length>0){let o=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=o(r.map(c=>{if(c=Oc(c),c in Wi)return;Wi[c]=!0;const u=c.endsWith(".css"),h=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Rc,u||(d.as="script"),d.crossOrigin="",d.href=c,l&&d.setAttribute("nonce",l),document.head.appendChild(d),u)return new Promise((f,m)=>{d.addEventListener("load",f),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})};/**
|
|
3
3
|
* @vue/shared v3.5.34
|
|
4
4
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
5
5
|
* @license MIT
|
|
6
|
-
**/function Si(t){const e=Object.create(null);for(const r of t.split(","))e[r]=1;return r=>r in e}const ne={},
|
|
6
|
+
**/function Si(t){const e=Object.create(null);for(const r of t.split(","))e[r]=1;return r=>r in e}const ne={},br=[],pt=()=>{},Aa=()=>!1,tn=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),rn=t=>t.startsWith("onUpdate:"),Ee=Object.assign,Ei=(t,e)=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)},Cc=Object.prototype.hasOwnProperty,te=(t,e)=>Cc.call(t,e),B=Array.isArray,wr=t=>ms(t)==="[object Map]",Pr=t=>ms(t)==="[object Set]",Gi=t=>ms(t)==="[object Date]",G=t=>typeof t=="function",ue=t=>typeof t=="string",ze=t=>typeof t=="symbol",re=t=>t!==null&&typeof t=="object",Ta=t=>(re(t)||G(t))&&G(t.then)&&G(t.catch),Ra=Object.prototype.toString,ms=t=>Ra.call(t),Pc=t=>ms(t).slice(8,-1),Oa=t=>ms(t)==="[object Object]",sn=t=>ue(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Fr=Si(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),nn=t=>{const e=Object.create(null);return(r=>e[r]||(e[r]=t(r)))},xc=/-\w/g,Ie=nn(t=>t.replace(xc,e=>e.slice(1).toUpperCase())),Ic=/\B([A-Z])/g,Vt=nn(t=>t.replace(Ic,"-$1").toLowerCase()),on=nn(t=>t.charAt(0).toUpperCase()+t.slice(1)),Tn=nn(t=>t?`on${on(t)}`:""),ft=(t,e)=>!Object.is(t,e),Ls=(t,...e)=>{for(let r=0;r<t.length;r++)t[r](...e)},Ca=(t,e,r,s=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:s,value:r})},an=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let zi;const ln=()=>zi||(zi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function ki(t){if(B(t)){const e={};for(let r=0;r<t.length;r++){const s=t[r],n=ue(s)?$c(s):ki(s);if(n)for(const i in n)e[i]=n[i]}return e}else if(ue(t)||re(t))return t}const jc=/;(?![^(]*\))/g,Nc=/:([^]+)/,Lc=/\/\*[^]*?\*\//g;function $c(t){const e={};return t.replace(Lc,"").split(jc).forEach(r=>{if(r){const s=r.split(Nc);s.length>1&&(e[s[0].trim()]=s[1].trim())}}),e}function cn(t){let e="";if(ue(t))e=t;else if(B(t))for(let r=0;r<t.length;r++){const s=cn(t[r]);s&&(e+=s+" ")}else if(re(t))for(const r in t)t[r]&&(e+=r+" ");return e.trim()}const Dc="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly",Uc=Si(Dc);function Pa(t){return!!t||t===""}function Mc(t,e){if(t.length!==e.length)return!1;let r=!0;for(let s=0;r&&s<t.length;s++)r=xr(t[s],e[s]);return r}function xr(t,e){if(t===e)return!0;let r=Gi(t),s=Gi(e);if(r||s)return r&&s?t.getTime()===e.getTime():!1;if(r=ze(t),s=ze(e),r||s)return t===e;if(r=B(t),s=B(e),r||s)return r&&s?Mc(t,e):!1;if(r=re(t),s=re(e),r||s){if(!r||!s)return!1;const n=Object.keys(t).length,i=Object.keys(e).length;if(n!==i)return!1;for(const o in t){const a=t.hasOwnProperty(o),l=e.hasOwnProperty(o);if(a&&!l||!a&&l||!xr(t[o],e[o]))return!1}}return String(t)===String(e)}function Ai(t,e){return t.findIndex(r=>xr(r,e))}const xa=t=>!!(t&&t.__v_isRef===!0),Wn=t=>ue(t)?t:t==null?"":B(t)||re(t)&&(t.toString===Ra||!G(t.toString))?xa(t)?Wn(t.value):JSON.stringify(t,Ia,2):String(t),Ia=(t,e)=>xa(e)?Ia(t,e.value):wr(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((r,[s,n],i)=>(r[Rn(s,i)+" =>"]=n,r),{})}:Pr(e)?{[`Set(${e.size})`]:[...e.values()].map(r=>Rn(r))}:ze(e)?Rn(e):re(e)&&!B(e)&&!Oa(e)?String(e):e,Rn=(t,e="")=>{var r;return ze(t)?`Symbol(${(r=t.description)!=null?r:e})`:t};/**
|
|
7
7
|
* @vue/reactivity v3.5.34
|
|
8
8
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
9
9
|
* @license MIT
|
|
10
|
-
**/let ye;class ja{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&ye&&(ye.active?(this.parent=ye,this.index=(ye.scopes||(ye.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,r;if(this.scopes)for(e=0,r=this.scopes.length;e<r;e++)this.scopes[e].pause();for(e=0,r=this.effects.length;e<r;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,r;if(this.scopes)for(e=0,r=this.scopes.length;e<r;e++)this.scopes[e].resume();for(e=0,r=this.effects.length;e<r;e++)this.effects[e].resume()}}run(e){if(this._active){const r=ye;try{return ye=this,e()}finally{ye=r}}}on(){++this._on===1&&(this.prevScope=ye,ye=this)}off(){if(this._on>0&&--this._on===0){if(ye===this)ye=this.prevScope;else{let e=ye;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let r,s;for(r=0,s=this.effects.length;r<s;r++)this.effects[r].stop();for(this.effects.length=0,r=0,s=this.cleanups.length;r<s;r++)this.cleanups[r]();if(this.cleanups.length=0,this.scopes){for(r=0,s=this.scopes.length;r<s;r++)this.scopes[r].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const n=this.parent.scopes.pop();n&&n!==this&&(this.parent.scopes[this.index]=n,n.index=this.index)}this.parent=void 0}}}function Na(t){return new ja(t)}function $a(){return ye}function Mc(t,e=!1){ye&&ye.cleanups.push(t)}let ae;const Rn=new WeakSet;class La{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,ye&&(ye.active?ye.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Rn.has(this)&&(Rn.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Ua(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Ji(this),Ba(this);const e=ae,r=Qe;ae=this,Qe=!0;try{return this.fn()}finally{Ma(this),ae=e,Qe=r,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Oi(e);this.deps=this.depsTail=void 0,Ji(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Rn.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Wn(this)&&this.run()}get dirty(){return Wn(this)}}let Da=0,qr,Vr;function Ua(t,e=!1){if(t.flags|=8,e){t.next=Vr,Vr=t;return}t.next=qr,qr=t}function Ti(){Da++}function Ri(){if(--Da>0)return;if(Vr){let e=Vr;for(Vr=void 0;e;){const r=e.next;e.next=void 0,e.flags&=-9,e=r}}let t;for(;qr;){let e=qr;for(qr=void 0;e;){const r=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(s){t||(t=s)}e=r}}if(t)throw t}function Ba(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Ma(t){let e,r=t.depsTail,s=r;for(;s;){const n=s.prevDep;s.version===-1?(s===r&&(r=n),Oi(s),Hc(s)):e=s,s.dep.activeLink=s.prevActiveLink,s.prevActiveLink=void 0,s=n}t.deps=e,t.depsTail=r}function Wn(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Ha(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Ha(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===rs)||(t.globalVersion=rs,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Wn(t))))return;t.flags|=2;const e=t.dep,r=ae,s=Qe;ae=t,Qe=!0;try{Ba(t);const n=t.fn(t._value);(e.version===0||ft(n,t._value))&&(t.flags|=128,t._value=n,e.version++)}catch(n){throw e.version++,n}finally{ae=r,Qe=s,Ma(t),t.flags&=-3}}function Oi(t,e=!1){const{dep:r,prevSub:s,nextSub:n}=t;if(s&&(s.nextSub=n,t.prevSub=void 0),n&&(n.prevSub=s,t.nextSub=void 0),r.subs===t&&(r.subs=s,!s&&r.computed)){r.computed.flags&=-5;for(let i=r.computed.deps;i;i=i.nextDep)Oi(i,!0)}!e&&!--r.sc&&r.map&&r.map.delete(r.key)}function Hc(t){const{prevDep:e,nextDep:r}=t;e&&(e.nextDep=r,t.prevDep=void 0),r&&(r.prevDep=e,t.nextDep=void 0)}let Qe=!0;const Fa=[];function Ot(){Fa.push(Qe),Qe=!1}function Ct(){const t=Fa.pop();Qe=t===void 0?!0:t}function Ji(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const r=ae;ae=void 0;try{e()}finally{ae=r}}}let rs=0;class Fc{constructor(e,r){this.sub=e,this.dep=r,this.version=r.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class Ci{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!ae||!Qe||ae===this.computed)return;let r=this.activeLink;if(r===void 0||r.sub!==ae)r=this.activeLink=new Fc(ae,this),ae.deps?(r.prevDep=ae.depsTail,ae.depsTail.nextDep=r,ae.depsTail=r):ae.deps=ae.depsTail=r,qa(r);else if(r.version===-1&&(r.version=this.version,r.nextDep)){const s=r.nextDep;s.prevDep=r.prevDep,r.prevDep&&(r.prevDep.nextDep=s),r.prevDep=ae.depsTail,r.nextDep=void 0,ae.depsTail.nextDep=r,ae.depsTail=r,ae.deps===r&&(ae.deps=s)}return r}trigger(e){this.version++,rs++,this.notify(e)}notify(e){Ti();try{for(let r=this.subs;r;r=r.prevSub)r.sub.notify()&&r.sub.dep.notify()}finally{Ri()}}}function qa(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let s=e.deps;s;s=s.nextDep)qa(s)}const r=t.dep.subs;r!==t&&(t.prevSub=r,r&&(r.nextSub=t)),t.dep.subs=t}}const Us=new WeakMap,tr=Symbol(""),Gn=Symbol(""),ss=Symbol("");function Ee(t,e,r){if(Qe&&ae){let s=Us.get(t);s||Us.set(t,s=new Map);let n=s.get(r);n||(s.set(r,n=new Ci),n.map=s,n.key=r),n.track()}}function kt(t,e,r,s,n,i){const o=Us.get(t);if(!o){rs++;return}const a=l=>{l&&l.trigger()};if(Ti(),e==="clear")o.forEach(a);else{const l=M(t),c=l&&tn(r);if(l&&r==="length"){const u=Number(s);o.forEach((h,d)=>{(d==="length"||d===ss||!Ke(d)&&d>=u)&&a(h)})}else switch((r!==void 0||o.has(void 0))&&a(o.get(r)),c&&a(o.get(ss)),e){case"add":l?c&&a(o.get("length")):(a(o.get(tr)),br(t)&&a(o.get(Gn)));break;case"delete":l||(a(o.get(tr)),br(t)&&a(o.get(Gn)));break;case"set":br(t)&&a(o.get(tr));break}}Ri()}function qc(t,e){const r=Us.get(t);return r&&r.get(e)}function ir(t){const e=Q(t);return e===t?e:(Ee(e,"iterate",ss),He(t)?e:e.map(Ze))}function ln(t){return Ee(t=Q(t),"iterate",ss),t}function ct(t,e){return Pt(t)?kr(Tt(t)?Ze(e):e):Ze(e)}const Vc={__proto__:null,[Symbol.iterator](){return On(this,Symbol.iterator,t=>ct(this,t))},concat(...t){return ir(this).concat(...t.map(e=>M(e)?ir(e):e))},entries(){return On(this,"entries",t=>(t[1]=ct(this,t[1]),t))},every(t,e){return yt(this,"every",t,e,void 0,arguments)},filter(t,e){return yt(this,"filter",t,e,r=>r.map(s=>ct(this,s)),arguments)},find(t,e){return yt(this,"find",t,e,r=>ct(this,r),arguments)},findIndex(t,e){return yt(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return yt(this,"findLast",t,e,r=>ct(this,r),arguments)},findLastIndex(t,e){return yt(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return yt(this,"forEach",t,e,void 0,arguments)},includes(...t){return Cn(this,"includes",t)},indexOf(...t){return Cn(this,"indexOf",t)},join(t){return ir(this).join(t)},lastIndexOf(...t){return Cn(this,"lastIndexOf",t)},map(t,e){return yt(this,"map",t,e,void 0,arguments)},pop(){return Nr(this,"pop")},push(...t){return Nr(this,"push",t)},reduce(t,...e){return Yi(this,"reduce",t,e)},reduceRight(t,...e){return Yi(this,"reduceRight",t,e)},shift(){return Nr(this,"shift")},some(t,e){return yt(this,"some",t,e,void 0,arguments)},splice(...t){return Nr(this,"splice",t)},toReversed(){return ir(this).toReversed()},toSorted(t){return ir(this).toSorted(t)},toSpliced(...t){return ir(this).toSpliced(...t)},unshift(...t){return Nr(this,"unshift",t)},values(){return On(this,"values",t=>ct(this,t))}};function On(t,e,r){const s=ln(t),n=s[e]();return s!==t&&!He(t)&&(n._next=n.next,n.next=()=>{const i=n._next();return i.done||(i.value=r(i.value)),i}),n}const Kc=Array.prototype;function yt(t,e,r,s,n,i){const o=ln(t),a=o!==t&&!He(t),l=o[e];if(l!==Kc[e]){const h=l.apply(t,i);return a?Ze(h):h}let c=r;o!==t&&(a?c=function(h,d){return r.call(this,ct(t,h),d,t)}:r.length>2&&(c=function(h,d){return r.call(this,h,d,t)}));const u=l.call(o,c,s);return a&&n?n(u):u}function Yi(t,e,r,s){const n=ln(t),i=n!==t&&!He(t);let o=r,a=!1;n!==t&&(i?(a=s.length===0,o=function(c,u,h){return a&&(a=!1,c=ct(t,c)),r.call(this,c,ct(t,u),h,t)}):r.length>3&&(o=function(c,u,h){return r.call(this,c,u,h,t)}));const l=n[e](o,...s);return a?ct(t,l):l}function Cn(t,e,r){const s=Q(t);Ee(s,"iterate",ss);const n=s[e](...r);return(n===-1||n===!1)&&cn(r[0])?(r[0]=Q(r[0]),s[e](...r)):n}function Nr(t,e,r=[]){Ot(),Ti();const s=Q(t)[e].apply(t,r);return Ri(),Ct(),s}const Wc=Si("__proto__,__v_isRef,__isVue"),Va=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Ke));function Gc(t){Ke(t)||(t=String(t));const e=Q(this);return Ee(e,"has",t),e.hasOwnProperty(t)}class Ka{constructor(e=!1,r=!1){this._isReadonly=e,this._isShallow=r}get(e,r,s){if(r==="__v_skip")return e.__v_skip;const n=this._isReadonly,i=this._isShallow;if(r==="__v_isReactive")return!n;if(r==="__v_isReadonly")return n;if(r==="__v_isShallow")return i;if(r==="__v_raw")return s===(n?i?su:Ja:i?za:Ga).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(s)?e:void 0;const o=M(e);if(!n){let l;if(o&&(l=Vc[r]))return l;if(r==="hasOwnProperty")return Gc}const a=Reflect.get(e,r,fe(e)?e:s);if((Ke(r)?Va.has(r):Wc(r))||(n||Ee(e,"get",r),i))return a;if(fe(a)){const l=o&&tn(r)?a:a.value;return n&&re(l)?Jn(l):l}return re(a)?n?Jn(a):ys(a):a}}class Wa extends Ka{constructor(e=!1){super(!1,e)}set(e,r,s,n){let i=e[r];const o=M(e)&&tn(r);if(!this._isShallow){const c=Pt(i);if(!He(s)&&!Pt(s)&&(i=Q(i),s=Q(s)),!o&&fe(i)&&!fe(s))return c||(i.value=s),!0}const a=o?Number(r)<e.length:te(e,r),l=Reflect.set(e,r,s,fe(e)?e:n);return e===Q(n)&&(a?ft(s,i)&&kt(e,"set",r,s):kt(e,"add",r,s)),l}deleteProperty(e,r){const s=te(e,r);e[r];const n=Reflect.deleteProperty(e,r);return n&&s&&kt(e,"delete",r,void 0),n}has(e,r){const s=Reflect.has(e,r);return(!Ke(r)||!Va.has(r))&&Ee(e,"has",r),s}ownKeys(e){return Ee(e,"iterate",M(e)?"length":tr),Reflect.ownKeys(e)}}class zc extends Ka{constructor(e=!1){super(!0,e)}set(e,r){return!0}deleteProperty(e,r){return!0}}const Jc=new Wa,Yc=new zc,Xc=new Wa(!0);const zn=t=>t,ws=t=>Reflect.getPrototypeOf(t);function Qc(t,e,r){return function(...s){const n=this.__v_raw,i=Q(n),o=br(i),a=t==="entries"||t===Symbol.iterator&&o,l=t==="keys"&&o,c=n[t](...s),u=r?zn:e?kr:Ze;return!e&&Ee(i,"iterate",l?Gn:tr),Se(Object.create(c),{next(){const{value:h,done:d}=c.next();return d?{value:h,done:d}:{value:a?[u(h[0]),u(h[1])]:u(h),done:d}}})}}function Ss(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Zc(t,e){const r={get(n){const i=this.__v_raw,o=Q(i),a=Q(n);t||(ft(n,a)&&Ee(o,"get",n),Ee(o,"get",a));const{has:l}=ws(o),c=e?zn:t?kr:Ze;if(l.call(o,n))return c(i.get(n));if(l.call(o,a))return c(i.get(a));i!==o&&i.get(n)},get size(){const n=this.__v_raw;return!t&&Ee(Q(n),"iterate",tr),n.size},has(n){const i=this.__v_raw,o=Q(i),a=Q(n);return t||(ft(n,a)&&Ee(o,"has",n),Ee(o,"has",a)),n===a?i.has(n):i.has(n)||i.has(a)},forEach(n,i){const o=this,a=o.__v_raw,l=Q(a),c=e?zn:t?kr:Ze;return!t&&Ee(l,"iterate",tr),a.forEach((u,h)=>n.call(i,c(u),c(h),o))}};return Se(r,t?{add:Ss("add"),set:Ss("set"),delete:Ss("delete"),clear:Ss("clear")}:{add(n){const i=Q(this),o=ws(i),a=Q(n),l=!e&&!He(n)&&!Pt(n)?a:n;return o.has.call(i,l)||ft(n,l)&&o.has.call(i,n)||ft(a,l)&&o.has.call(i,a)||(i.add(l),kt(i,"add",l,l)),this},set(n,i){!e&&!He(i)&&!Pt(i)&&(i=Q(i));const o=Q(this),{has:a,get:l}=ws(o);let c=a.call(o,n);c||(n=Q(n),c=a.call(o,n));const u=l.call(o,n);return o.set(n,i),c?ft(i,u)&&kt(o,"set",n,i):kt(o,"add",n,i),this},delete(n){const i=Q(this),{has:o,get:a}=ws(i);let l=o.call(i,n);l||(n=Q(n),l=o.call(i,n)),a&&a.call(i,n);const c=i.delete(n);return l&&kt(i,"delete",n,void 0),c},clear(){const n=Q(this),i=n.size!==0,o=n.clear();return i&&kt(n,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(n=>{r[n]=Qc(n,t,e)}),r}function Pi(t,e){const r=Zc(t,e);return(s,n,i)=>n==="__v_isReactive"?!t:n==="__v_isReadonly"?t:n==="__v_raw"?s:Reflect.get(te(r,n)&&n in s?r:s,n,i)}const eu={get:Pi(!1,!1)},tu={get:Pi(!1,!0)},ru={get:Pi(!0,!1)};const Ga=new WeakMap,za=new WeakMap,Ja=new WeakMap,su=new WeakMap;function nu(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function iu(t){return t.__v_skip||!Object.isExtensible(t)?0:nu(Pc(t))}function ys(t){return Pt(t)?t:xi(t,!1,Jc,eu,Ga)}function Ya(t){return xi(t,!1,Xc,tu,za)}function Jn(t){return xi(t,!0,Yc,ru,Ja)}function xi(t,e,r,s,n){if(!re(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const i=iu(t);if(i===0)return t;const o=n.get(t);if(o)return o;const a=new Proxy(t,i===2?s:r);return n.set(t,a),a}function Tt(t){return Pt(t)?Tt(t.__v_raw):!!(t&&t.__v_isReactive)}function Pt(t){return!!(t&&t.__v_isReadonly)}function He(t){return!!(t&&t.__v_isShallow)}function cn(t){return t?!!t.__v_raw:!1}function Q(t){const e=t&&t.__v_raw;return e?Q(e):t}function Ii(t){return!te(t,"__v_skip")&&Object.isExtensible(t)&&Ca(t,"__v_skip",!0),t}const Ze=t=>re(t)?ys(t):t,kr=t=>re(t)?Jn(t):t;function fe(t){return t?t.__v_isRef===!0:!1}function Kr(t){return Xa(t,!1)}function ou(t){return Xa(t,!0)}function Xa(t,e){return fe(t)?t:new au(t,e)}class au{constructor(e,r){this.dep=new Ci,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=r?e:Q(e),this._value=r?e:Ze(e),this.__v_isShallow=r}get value(){return this.dep.track(),this._value}set value(e){const r=this._rawValue,s=this.__v_isShallow||He(e)||Pt(e);e=s?e:Q(e),ft(e,r)&&(this._rawValue=e,this._value=s?e:Ze(e),this.dep.trigger())}}function Xe(t){return fe(t)?t.value:t}const lu={get:(t,e,r)=>e==="__v_raw"?t:Xe(Reflect.get(t,e,r)),set:(t,e,r,s)=>{const n=t[e];return fe(n)&&!fe(r)?(n.value=r,!0):Reflect.set(t,e,r,s)}};function Qa(t){return Tt(t)?t:new Proxy(t,lu)}function cu(t){const e=M(t)?new Array(t.length):{};for(const r in t)e[r]=hu(t,r);return e}class uu{constructor(e,r,s){this._object=e,this._defaultValue=s,this.__v_isRef=!0,this._value=void 0,this._key=Ke(r)?r:String(r),this._raw=Q(e);let n=!0,i=e;if(!M(e)||Ke(this._key)||!tn(this._key))do n=!cn(i)||He(i);while(n&&(i=i.__v_raw));this._shallow=n}get value(){let e=this._object[this._key];return this._shallow&&(e=Xe(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&fe(this._raw[this._key])){const r=this._object[this._key];if(fe(r)){r.value=e;return}}this._object[this._key]=e}get dep(){return qc(this._raw,this._key)}}function hu(t,e,r){return new uu(t,e,r)}class du{constructor(e,r,s){this.fn=e,this.setter=r,this._value=void 0,this.dep=new Ci(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=rs-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!r,this.isSSR=s}notify(){if(this.flags|=16,!(this.flags&8)&&ae!==this)return Ua(this,!0),!0}get value(){const e=this.dep.track();return Ha(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function fu(t,e,r=!1){let s,n;return G(t)?s=t:(s=t.get,n=t.set),new du(s,n,r)}const Es={},Bs=new WeakMap;let Xt;function pu(t,e=!1,r=Xt){if(r){let s=Bs.get(r);s||Bs.set(r,s=[]),s.push(t)}}function gu(t,e,r=ne){const{immediate:s,deep:n,once:i,scheduler:o,augmentJob:a,call:l}=r,c=O=>n?O:He(O)||n===!1||n===0?At(O,1):At(O);let u,h,d,f,m=!1,v=!1;if(fe(t)?(h=()=>t.value,m=He(t)):Tt(t)?(h=()=>c(t),m=!0):M(t)?(v=!0,m=t.some(O=>Tt(O)||He(O)),h=()=>t.map(O=>{if(fe(O))return O.value;if(Tt(O))return c(O);if(G(O))return l?l(O,2):O()})):G(t)?e?h=l?()=>l(t,2):t:h=()=>{if(d){Ot();try{d()}finally{Ct()}}const O=Xt;Xt=u;try{return l?l(t,3,[f]):t(f)}finally{Xt=O}}:h=pt,e&&n){const O=h,B=n===!0?1/0:n;h=()=>At(O(),B)}const A=$a(),E=()=>{u.stop(),A&&A.active&&Ei(A.effects,u)};if(i&&e){const O=e;e=(...B)=>{O(...B),E()}}let _=v?new Array(t.length).fill(Es):Es;const b=O=>{if(!(!(u.flags&1)||!u.dirty&&!O))if(e){const B=u.run();if(n||m||(v?B.some((W,q)=>ft(W,_[q])):ft(B,_))){d&&d();const W=Xt;Xt=u;try{const q=[B,_===Es?void 0:v&&_[0]===Es?[]:_,f];_=B,l?l(e,3,q):e(...q)}finally{Xt=W}}}else u.run()};return a&&a(b),u=new La(h),u.scheduler=o?()=>o(b,!1):b,f=O=>pu(O,!1,u),d=u.onStop=()=>{const O=Bs.get(u);if(O){if(l)l(O,4);else for(const B of O)B();Bs.delete(u)}},e?s?b(!0):_=u.run():o?o(b.bind(null,!0),!0):u.run(),E.pause=u.pause.bind(u),E.resume=u.resume.bind(u),E.stop=E,E}function At(t,e=1/0,r){if(e<=0||!re(t)||t.__v_skip||(r=r||new Map,(r.get(t)||0)>=e))return t;if(r.set(t,e),e--,fe(t))At(t.value,e,r);else if(M(t))for(let s=0;s<t.length;s++)At(t[s],e,r);else if(Pr(t)||br(t))t.forEach(s=>{At(s,e,r)});else if(Oa(t)){for(const s in t)At(t[s],e,r);for(const s of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,s)&&At(t[s],e,r)}return t}/**
|
|
10
|
+
**/let ye;class ja{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&ye&&(ye.active?(this.parent=ye,this.index=(ye.scopes||(ye.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,r;if(this.scopes)for(e=0,r=this.scopes.length;e<r;e++)this.scopes[e].pause();for(e=0,r=this.effects.length;e<r;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,r;if(this.scopes)for(e=0,r=this.scopes.length;e<r;e++)this.scopes[e].resume();for(e=0,r=this.effects.length;e<r;e++)this.effects[e].resume()}}run(e){if(this._active){const r=ye;try{return ye=this,e()}finally{ye=r}}}on(){++this._on===1&&(this.prevScope=ye,ye=this)}off(){if(this._on>0&&--this._on===0){if(ye===this)ye=this.prevScope;else{let e=ye;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let r,s;for(r=0,s=this.effects.length;r<s;r++)this.effects[r].stop();for(this.effects.length=0,r=0,s=this.cleanups.length;r<s;r++)this.cleanups[r]();if(this.cleanups.length=0,this.scopes){for(r=0,s=this.scopes.length;r<s;r++)this.scopes[r].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const n=this.parent.scopes.pop();n&&n!==this&&(this.parent.scopes[this.index]=n,n.index=this.index)}this.parent=void 0}}}function Na(t){return new ja(t)}function La(){return ye}function Bc(t,e=!1){ye&&ye.cleanups.push(t)}let ae;const On=new WeakSet;class $a{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,ye&&(ye.active?ye.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,On.has(this)&&(On.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Ua(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Ji(this),Ma(this);const e=ae,r=Qe;ae=this,Qe=!0;try{return this.fn()}finally{Ba(this),ae=e,Qe=r,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Oi(e);this.deps=this.depsTail=void 0,Ji(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?On.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Gn(this)&&this.run()}get dirty(){return Gn(this)}}let Da=0,qr,Vr;function Ua(t,e=!1){if(t.flags|=8,e){t.next=Vr,Vr=t;return}t.next=qr,qr=t}function Ti(){Da++}function Ri(){if(--Da>0)return;if(Vr){let e=Vr;for(Vr=void 0;e;){const r=e.next;e.next=void 0,e.flags&=-9,e=r}}let t;for(;qr;){let e=qr;for(qr=void 0;e;){const r=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(s){t||(t=s)}e=r}}if(t)throw t}function Ma(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Ba(t){let e,r=t.depsTail,s=r;for(;s;){const n=s.prevDep;s.version===-1?(s===r&&(r=n),Oi(s),Hc(s)):e=s,s.dep.activeLink=s.prevActiveLink,s.prevActiveLink=void 0,s=n}t.deps=e,t.depsTail=r}function Gn(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Ha(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Ha(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===rs)||(t.globalVersion=rs,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Gn(t))))return;t.flags|=2;const e=t.dep,r=ae,s=Qe;ae=t,Qe=!0;try{Ma(t);const n=t.fn(t._value);(e.version===0||ft(n,t._value))&&(t.flags|=128,t._value=n,e.version++)}catch(n){throw e.version++,n}finally{ae=r,Qe=s,Ba(t),t.flags&=-3}}function Oi(t,e=!1){const{dep:r,prevSub:s,nextSub:n}=t;if(s&&(s.nextSub=n,t.prevSub=void 0),n&&(n.prevSub=s,t.nextSub=void 0),r.subs===t&&(r.subs=s,!s&&r.computed)){r.computed.flags&=-5;for(let i=r.computed.deps;i;i=i.nextDep)Oi(i,!0)}!e&&!--r.sc&&r.map&&r.map.delete(r.key)}function Hc(t){const{prevDep:e,nextDep:r}=t;e&&(e.nextDep=r,t.prevDep=void 0),r&&(r.prevDep=e,t.nextDep=void 0)}let Qe=!0;const Fa=[];function Ct(){Fa.push(Qe),Qe=!1}function Pt(){const t=Fa.pop();Qe=t===void 0?!0:t}function Ji(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const r=ae;ae=void 0;try{e()}finally{ae=r}}}let rs=0;class Fc{constructor(e,r){this.sub=e,this.dep=r,this.version=r.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class Ci{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!ae||!Qe||ae===this.computed)return;let r=this.activeLink;if(r===void 0||r.sub!==ae)r=this.activeLink=new Fc(ae,this),ae.deps?(r.prevDep=ae.depsTail,ae.depsTail.nextDep=r,ae.depsTail=r):ae.deps=ae.depsTail=r,qa(r);else if(r.version===-1&&(r.version=this.version,r.nextDep)){const s=r.nextDep;s.prevDep=r.prevDep,r.prevDep&&(r.prevDep.nextDep=s),r.prevDep=ae.depsTail,r.nextDep=void 0,ae.depsTail.nextDep=r,ae.depsTail=r,ae.deps===r&&(ae.deps=s)}return r}trigger(e){this.version++,rs++,this.notify(e)}notify(e){Ti();try{for(let r=this.subs;r;r=r.prevSub)r.sub.notify()&&r.sub.dep.notify()}finally{Ri()}}}function qa(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let s=e.deps;s;s=s.nextDep)qa(s)}const r=t.dep.subs;r!==t&&(t.prevSub=r,r&&(r.nextSub=t)),t.dep.subs=t}}const Ms=new WeakMap,tr=Symbol(""),zn=Symbol(""),ss=Symbol("");function ke(t,e,r){if(Qe&&ae){let s=Ms.get(t);s||Ms.set(t,s=new Map);let n=s.get(r);n||(s.set(r,n=new Ci),n.map=s,n.key=r),n.track()}}function kt(t,e,r,s,n,i){const o=Ms.get(t);if(!o){rs++;return}const a=l=>{l&&l.trigger()};if(Ti(),e==="clear")o.forEach(a);else{const l=B(t),c=l&&sn(r);if(l&&r==="length"){const u=Number(s);o.forEach((h,d)=>{(d==="length"||d===ss||!ze(d)&&d>=u)&&a(h)})}else switch((r!==void 0||o.has(void 0))&&a(o.get(r)),c&&a(o.get(ss)),e){case"add":l?c&&a(o.get("length")):(a(o.get(tr)),wr(t)&&a(o.get(zn)));break;case"delete":l||(a(o.get(tr)),wr(t)&&a(o.get(zn)));break;case"set":wr(t)&&a(o.get(tr));break}}Ri()}function qc(t,e){const r=Ms.get(t);return r&&r.get(e)}function or(t){const e=Q(t);return e===t?e:(ke(e,"iterate",ss),Fe(t)?e:e.map(Ze))}function un(t){return ke(t=Q(t),"iterate",ss),t}function ct(t,e){return xt(t)?kr(Tt(t)?Ze(e):e):Ze(e)}const Vc={__proto__:null,[Symbol.iterator](){return Cn(this,Symbol.iterator,t=>ct(this,t))},concat(...t){return or(this).concat(...t.map(e=>B(e)?or(e):e))},entries(){return Cn(this,"entries",t=>(t[1]=ct(this,t[1]),t))},every(t,e){return yt(this,"every",t,e,void 0,arguments)},filter(t,e){return yt(this,"filter",t,e,r=>r.map(s=>ct(this,s)),arguments)},find(t,e){return yt(this,"find",t,e,r=>ct(this,r),arguments)},findIndex(t,e){return yt(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return yt(this,"findLast",t,e,r=>ct(this,r),arguments)},findLastIndex(t,e){return yt(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return yt(this,"forEach",t,e,void 0,arguments)},includes(...t){return Pn(this,"includes",t)},indexOf(...t){return Pn(this,"indexOf",t)},join(t){return or(this).join(t)},lastIndexOf(...t){return Pn(this,"lastIndexOf",t)},map(t,e){return yt(this,"map",t,e,void 0,arguments)},pop(){return Nr(this,"pop")},push(...t){return Nr(this,"push",t)},reduce(t,...e){return Yi(this,"reduce",t,e)},reduceRight(t,...e){return Yi(this,"reduceRight",t,e)},shift(){return Nr(this,"shift")},some(t,e){return yt(this,"some",t,e,void 0,arguments)},splice(...t){return Nr(this,"splice",t)},toReversed(){return or(this).toReversed()},toSorted(t){return or(this).toSorted(t)},toSpliced(...t){return or(this).toSpliced(...t)},unshift(...t){return Nr(this,"unshift",t)},values(){return Cn(this,"values",t=>ct(this,t))}};function Cn(t,e,r){const s=un(t),n=s[e]();return s!==t&&!Fe(t)&&(n._next=n.next,n.next=()=>{const i=n._next();return i.done||(i.value=r(i.value)),i}),n}const Kc=Array.prototype;function yt(t,e,r,s,n,i){const o=un(t),a=o!==t&&!Fe(t),l=o[e];if(l!==Kc[e]){const h=l.apply(t,i);return a?Ze(h):h}let c=r;o!==t&&(a?c=function(h,d){return r.call(this,ct(t,h),d,t)}:r.length>2&&(c=function(h,d){return r.call(this,h,d,t)}));const u=l.call(o,c,s);return a&&n?n(u):u}function Yi(t,e,r,s){const n=un(t),i=n!==t&&!Fe(t);let o=r,a=!1;n!==t&&(i?(a=s.length===0,o=function(c,u,h){return a&&(a=!1,c=ct(t,c)),r.call(this,c,ct(t,u),h,t)}):r.length>3&&(o=function(c,u,h){return r.call(this,c,u,h,t)}));const l=n[e](o,...s);return a?ct(t,l):l}function Pn(t,e,r){const s=Q(t);ke(s,"iterate",ss);const n=s[e](...r);return(n===-1||n===!1)&&hn(r[0])?(r[0]=Q(r[0]),s[e](...r)):n}function Nr(t,e,r=[]){Ct(),Ti();const s=Q(t)[e].apply(t,r);return Ri(),Pt(),s}const Wc=Si("__proto__,__v_isRef,__isVue"),Va=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(ze));function Gc(t){ze(t)||(t=String(t));const e=Q(this);return ke(e,"has",t),e.hasOwnProperty(t)}class Ka{constructor(e=!1,r=!1){this._isReadonly=e,this._isShallow=r}get(e,r,s){if(r==="__v_skip")return e.__v_skip;const n=this._isReadonly,i=this._isShallow;if(r==="__v_isReactive")return!n;if(r==="__v_isReadonly")return n;if(r==="__v_isShallow")return i;if(r==="__v_raw")return s===(n?i?su:Ja:i?za:Ga).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(s)?e:void 0;const o=B(e);if(!n){let l;if(o&&(l=Vc[r]))return l;if(r==="hasOwnProperty")return Gc}const a=Reflect.get(e,r,fe(e)?e:s);if((ze(r)?Va.has(r):Wc(r))||(n||ke(e,"get",r),i))return a;if(fe(a)){const l=o&&sn(r)?a:a.value;return n&&re(l)?Yn(l):l}return re(a)?n?Yn(a):ys(a):a}}class Wa extends Ka{constructor(e=!1){super(!1,e)}set(e,r,s,n){let i=e[r];const o=B(e)&&sn(r);if(!this._isShallow){const c=xt(i);if(!Fe(s)&&!xt(s)&&(i=Q(i),s=Q(s)),!o&&fe(i)&&!fe(s))return c||(i.value=s),!0}const a=o?Number(r)<e.length:te(e,r),l=Reflect.set(e,r,s,fe(e)?e:n);return e===Q(n)&&(a?ft(s,i)&&kt(e,"set",r,s):kt(e,"add",r,s)),l}deleteProperty(e,r){const s=te(e,r);e[r];const n=Reflect.deleteProperty(e,r);return n&&s&&kt(e,"delete",r,void 0),n}has(e,r){const s=Reflect.has(e,r);return(!ze(r)||!Va.has(r))&&ke(e,"has",r),s}ownKeys(e){return ke(e,"iterate",B(e)?"length":tr),Reflect.ownKeys(e)}}class zc extends Ka{constructor(e=!1){super(!0,e)}set(e,r){return!0}deleteProperty(e,r){return!0}}const Jc=new Wa,Yc=new zc,Xc=new Wa(!0);const Jn=t=>t,Ss=t=>Reflect.getPrototypeOf(t);function Qc(t,e,r){return function(...s){const n=this.__v_raw,i=Q(n),o=wr(i),a=t==="entries"||t===Symbol.iterator&&o,l=t==="keys"&&o,c=n[t](...s),u=r?Jn:e?kr:Ze;return!e&&ke(i,"iterate",l?zn:tr),Ee(Object.create(c),{next(){const{value:h,done:d}=c.next();return d?{value:h,done:d}:{value:a?[u(h[0]),u(h[1])]:u(h),done:d}}})}}function Es(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Zc(t,e){const r={get(n){const i=this.__v_raw,o=Q(i),a=Q(n);t||(ft(n,a)&&ke(o,"get",n),ke(o,"get",a));const{has:l}=Ss(o),c=e?Jn:t?kr:Ze;if(l.call(o,n))return c(i.get(n));if(l.call(o,a))return c(i.get(a));i!==o&&i.get(n)},get size(){const n=this.__v_raw;return!t&&ke(Q(n),"iterate",tr),n.size},has(n){const i=this.__v_raw,o=Q(i),a=Q(n);return t||(ft(n,a)&&ke(o,"has",n),ke(o,"has",a)),n===a?i.has(n):i.has(n)||i.has(a)},forEach(n,i){const o=this,a=o.__v_raw,l=Q(a),c=e?Jn:t?kr:Ze;return!t&&ke(l,"iterate",tr),a.forEach((u,h)=>n.call(i,c(u),c(h),o))}};return Ee(r,t?{add:Es("add"),set:Es("set"),delete:Es("delete"),clear:Es("clear")}:{add(n){const i=Q(this),o=Ss(i),a=Q(n),l=!e&&!Fe(n)&&!xt(n)?a:n;return o.has.call(i,l)||ft(n,l)&&o.has.call(i,n)||ft(a,l)&&o.has.call(i,a)||(i.add(l),kt(i,"add",l,l)),this},set(n,i){!e&&!Fe(i)&&!xt(i)&&(i=Q(i));const o=Q(this),{has:a,get:l}=Ss(o);let c=a.call(o,n);c||(n=Q(n),c=a.call(o,n));const u=l.call(o,n);return o.set(n,i),c?ft(i,u)&&kt(o,"set",n,i):kt(o,"add",n,i),this},delete(n){const i=Q(this),{has:o,get:a}=Ss(i);let l=o.call(i,n);l||(n=Q(n),l=o.call(i,n)),a&&a.call(i,n);const c=i.delete(n);return l&&kt(i,"delete",n,void 0),c},clear(){const n=Q(this),i=n.size!==0,o=n.clear();return i&&kt(n,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(n=>{r[n]=Qc(n,t,e)}),r}function Pi(t,e){const r=Zc(t,e);return(s,n,i)=>n==="__v_isReactive"?!t:n==="__v_isReadonly"?t:n==="__v_raw"?s:Reflect.get(te(r,n)&&n in s?r:s,n,i)}const eu={get:Pi(!1,!1)},tu={get:Pi(!1,!0)},ru={get:Pi(!0,!1)};const Ga=new WeakMap,za=new WeakMap,Ja=new WeakMap,su=new WeakMap;function nu(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function iu(t){return t.__v_skip||!Object.isExtensible(t)?0:nu(Pc(t))}function ys(t){return xt(t)?t:xi(t,!1,Jc,eu,Ga)}function Ya(t){return xi(t,!1,Xc,tu,za)}function Yn(t){return xi(t,!0,Yc,ru,Ja)}function xi(t,e,r,s,n){if(!re(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const i=iu(t);if(i===0)return t;const o=n.get(t);if(o)return o;const a=new Proxy(t,i===2?s:r);return n.set(t,a),a}function Tt(t){return xt(t)?Tt(t.__v_raw):!!(t&&t.__v_isReactive)}function xt(t){return!!(t&&t.__v_isReadonly)}function Fe(t){return!!(t&&t.__v_isShallow)}function hn(t){return t?!!t.__v_raw:!1}function Q(t){const e=t&&t.__v_raw;return e?Q(e):t}function Ii(t){return!te(t,"__v_skip")&&Object.isExtensible(t)&&Ca(t,"__v_skip",!0),t}const Ze=t=>re(t)?ys(t):t,kr=t=>re(t)?Yn(t):t;function fe(t){return t?t.__v_isRef===!0:!1}function Kr(t){return Xa(t,!1)}function ou(t){return Xa(t,!0)}function Xa(t,e){return fe(t)?t:new au(t,e)}class au{constructor(e,r){this.dep=new Ci,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=r?e:Q(e),this._value=r?e:Ze(e),this.__v_isShallow=r}get value(){return this.dep.track(),this._value}set value(e){const r=this._rawValue,s=this.__v_isShallow||Fe(e)||xt(e);e=s?e:Q(e),ft(e,r)&&(this._rawValue=e,this._value=s?e:Ze(e),this.dep.trigger())}}function Rt(t){return fe(t)?t.value:t}const lu={get:(t,e,r)=>e==="__v_raw"?t:Rt(Reflect.get(t,e,r)),set:(t,e,r,s)=>{const n=t[e];return fe(n)&&!fe(r)?(n.value=r,!0):Reflect.set(t,e,r,s)}};function Qa(t){return Tt(t)?t:new Proxy(t,lu)}function cu(t){const e=B(t)?new Array(t.length):{};for(const r in t)e[r]=hu(t,r);return e}class uu{constructor(e,r,s){this._object=e,this._defaultValue=s,this.__v_isRef=!0,this._value=void 0,this._key=ze(r)?r:String(r),this._raw=Q(e);let n=!0,i=e;if(!B(e)||ze(this._key)||!sn(this._key))do n=!hn(i)||Fe(i);while(n&&(i=i.__v_raw));this._shallow=n}get value(){let e=this._object[this._key];return this._shallow&&(e=Rt(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&fe(this._raw[this._key])){const r=this._object[this._key];if(fe(r)){r.value=e;return}}this._object[this._key]=e}get dep(){return qc(this._raw,this._key)}}function hu(t,e,r){return new uu(t,e,r)}class du{constructor(e,r,s){this.fn=e,this.setter=r,this._value=void 0,this.dep=new Ci(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=rs-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!r,this.isSSR=s}notify(){if(this.flags|=16,!(this.flags&8)&&ae!==this)return Ua(this,!0),!0}get value(){const e=this.dep.track();return Ha(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function fu(t,e,r=!1){let s,n;return G(t)?s=t:(s=t.get,n=t.set),new du(s,n,r)}const ks={},Bs=new WeakMap;let Xt;function pu(t,e=!1,r=Xt){if(r){let s=Bs.get(r);s||Bs.set(r,s=[]),s.push(t)}}function gu(t,e,r=ne){const{immediate:s,deep:n,once:i,scheduler:o,augmentJob:a,call:l}=r,c=O=>n?O:Fe(O)||n===!1||n===0?At(O,1):At(O);let u,h,d,f,m=!1,_=!1;if(fe(t)?(h=()=>t.value,m=Fe(t)):Tt(t)?(h=()=>c(t),m=!0):B(t)?(_=!0,m=t.some(O=>Tt(O)||Fe(O)),h=()=>t.map(O=>{if(fe(O))return O.value;if(Tt(O))return c(O);if(G(O))return l?l(O,2):O()})):G(t)?e?h=l?()=>l(t,2):t:h=()=>{if(d){Ct();try{d()}finally{Pt()}}const O=Xt;Xt=u;try{return l?l(t,3,[f]):t(f)}finally{Xt=O}}:h=pt,e&&n){const O=h,M=n===!0?1/0:n;h=()=>At(O(),M)}const A=La(),E=()=>{u.stop(),A&&A.active&&Ei(A.effects,u)};if(i&&e){const O=e;e=(...M)=>{O(...M),E()}}let v=_?new Array(t.length).fill(ks):ks;const b=O=>{if(!(!(u.flags&1)||!u.dirty&&!O))if(e){const M=u.run();if(n||m||(_?M.some((W,q)=>ft(W,v[q])):ft(M,v))){d&&d();const W=Xt;Xt=u;try{const q=[M,v===ks?void 0:_&&v[0]===ks?[]:v,f];v=M,l?l(e,3,q):e(...q)}finally{Xt=W}}}else u.run()};return a&&a(b),u=new $a(h),u.scheduler=o?()=>o(b,!1):b,f=O=>pu(O,!1,u),d=u.onStop=()=>{const O=Bs.get(u);if(O){if(l)l(O,4);else for(const M of O)M();Bs.delete(u)}},e?s?b(!0):v=u.run():o?o(b.bind(null,!0),!0):u.run(),E.pause=u.pause.bind(u),E.resume=u.resume.bind(u),E.stop=E,E}function At(t,e=1/0,r){if(e<=0||!re(t)||t.__v_skip||(r=r||new Map,(r.get(t)||0)>=e))return t;if(r.set(t,e),e--,fe(t))At(t.value,e,r);else if(B(t))for(let s=0;s<t.length;s++)At(t[s],e,r);else if(Pr(t)||wr(t))t.forEach(s=>{At(s,e,r)});else if(Oa(t)){for(const s in t)At(t[s],e,r);for(const s of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,s)&&At(t[s],e,r)}return t}/**
|
|
11
11
|
* @vue/runtime-core v3.5.34
|
|
12
12
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
13
13
|
* @license MIT
|
|
14
|
-
**/function vs(t,e,r,s){try{return s?t(...s):t()}catch(n){un(n,e,r)}}function gt(t,e,r,s){if(G(t)){const n=vs(t,e,r,s);return n&&Ta(n)&&n.catch(i=>{un(i,e,r)}),n}if(M(t)){const n=[];for(let i=0;i<t.length;i++)n.push(gt(t[i],e,r,s));return n}}function un(t,e,r,s=!0){const n=e?e.vnode:null,{errorHandler:i,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||ne;if(e){let a=e.parent;const l=e.proxy,c=`https://vuejs.org/error-reference/#runtime-${r}`;for(;a;){const u=a.ec;if(u){for(let h=0;h<u.length;h++)if(u[h](t,l,c)===!1)return}a=a.parent}if(i){Ot(),vs(i,null,10,[t,l,c]),Ct();return}}mu(t,r,n,s,o)}function mu(t,e,r,s=!0,n=!1){if(n)throw t;console.error(t)}const Ce=[];let at=-1;const wr=[];let Ut=null,dr=0;const Za=Promise.resolve();let Ms=null;function hn(t){const e=Ms||Za;return t?e.then(this?t.bind(this):t):e}function yu(t){let e=at+1,r=Ce.length;for(;e<r;){const s=e+r>>>1,n=Ce[s],i=ns(n);i<t||i===t&&n.flags&2?e=s+1:r=s}return e}function ji(t){if(!(t.flags&1)){const e=ns(t),r=Ce[Ce.length-1];!r||!(t.flags&2)&&e>=ns(r)?Ce.push(t):Ce.splice(yu(e),0,t),t.flags|=1,el()}}function el(){Ms||(Ms=Za.then(rl))}function vu(t){M(t)?wr.push(...t):Ut&&t.id===-1?Ut.splice(dr+1,0,t):t.flags&1||(wr.push(t),t.flags|=1),el()}function Xi(t,e,r=at+1){for(;r<Ce.length;r++){const s=Ce[r];if(s&&s.flags&2){if(t&&s.id!==t.uid)continue;Ce.splice(r,1),r--,s.flags&4&&(s.flags&=-2),s(),s.flags&4||(s.flags&=-2)}}}function tl(t){if(wr.length){const e=[...new Set(wr)].sort((r,s)=>ns(r)-ns(s));if(wr.length=0,Ut){Ut.push(...e);return}for(Ut=e,dr=0;dr<Ut.length;dr++){const r=Ut[dr];r.flags&4&&(r.flags&=-2),r.flags&8||r(),r.flags&=-2}Ut=null,dr=0}}const ns=t=>t.id==null?t.flags&2?-1:1/0:t.id;function rl(t){try{for(at=0;at<Ce.length;at++){const e=Ce[at];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),vs(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;at<Ce.length;at++){const e=Ce[at];e&&(e.flags&=-2)}at=-1,Ce.length=0,tl(),Ms=null,(Ce.length||wr.length)&&rl()}}let Be=null,sl=null;function Hs(t){const e=Be;return Be=t,sl=t&&t.type.__scopeId||null,e}function nl(t,e=Be,r){if(!e||t._n)return t;const s=(...n)=>{s._d&&Vs(-1);const i=Hs(e);let o;try{o=t(...n)}finally{Hs(i),s._d&&Vs(1)}return o};return s._n=!0,s._c=!0,s._d=!0,s}function Fm(t,e){if(Be===null)return t;const r=mn(Be),s=t.dirs||(t.dirs=[]);for(let n=0;n<e.length;n++){let[i,o,a,l=ne]=e[n];i&&(G(i)&&(i={mounted:i,updated:i}),i.deep&&At(o),s.push({dir:i,instance:r,value:o,oldValue:void 0,arg:a,modifiers:l}))}return t}function Gt(t,e,r,s){const n=t.dirs,i=e&&e.dirs;for(let o=0;o<n.length;o++){const a=n[o];i&&(a.oldValue=i[o].value);let l=a.dir[s];l&&(Ot(),gt(l,r,8,[t.el,a,t,e]),Ct())}}function $s(t,e){if(ke){let r=ke.provides;const s=ke.parent&&ke.parent.provides;s===r&&(r=ke.provides=Object.create(s)),r[t]=e}}function Ve(t,e,r=!1){const s=$l();if(s||rr){let n=rr?rr._context.provides:s?s.parent==null||s.ce?s.vnode.appContext&&s.vnode.appContext.provides:s.parent.provides:void 0;if(n&&t in n)return n[t];if(arguments.length>1)return r&&G(e)?e.call(s&&s.proxy):e}}function _u(){return!!($l()||rr)}const bu=Symbol.for("v-scx"),wu=()=>Ve(bu);function Wr(t,e,r){return il(t,e,r)}function il(t,e,r=ne){const{immediate:s,deep:n,flush:i,once:o}=r,a=Se({},r),l=e&&s||!e&&i!=="post";let c;if(os){if(i==="sync"){const f=wu();c=f.__watcherHandles||(f.__watcherHandles=[])}else if(!l){const f=()=>{};return f.stop=pt,f.resume=pt,f.pause=pt,f}}const u=ke;a.call=(f,m,v)=>gt(f,u,m,v);let h=!1;i==="post"?a.scheduler=f=>{Ne(f,u&&u.suspense)}:i!=="sync"&&(h=!0,a.scheduler=(f,m)=>{m?f():ji(f)}),a.augmentJob=f=>{e&&(f.flags|=4),h&&(f.flags|=2,u&&(f.id=u.uid,f.i=u))};const d=gu(t,e,a);return os&&(c?c.push(d):l&&d()),d}function Su(t,e,r){const s=this.proxy,n=ue(t)?t.includes(".")?ol(s,t):()=>s[t]:t.bind(s,s);let i;G(e)?i=e:(i=e.handler,r=e);const o=_s(this),a=il(n,i.bind(s),r);return o(),a}function ol(t,e){const r=e.split(".");return()=>{let s=t;for(let n=0;n<r.length&&s;n++)s=s[r[n]];return s}}const Eu=Symbol("_vte"),ku=t=>t.__isTeleport,Au=Symbol("_leaveCb");function Ni(t,e){t.shapeFlag&6&&t.component?(t.transition=e,Ni(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function dn(t,e){return G(t)?Se({name:t.name},e,{setup:t}):t}function al(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function Qi(t,e){let r;return!!((r=Object.getOwnPropertyDescriptor(t,e))&&!r.configurable)}const Fs=new WeakMap;function Gr(t,e,r,s,n=!1){if(M(t)){t.forEach((v,A)=>Gr(v,e&&(M(e)?e[A]:e),r,s,n));return}if(zr(s)&&!n){s.shapeFlag&512&&s.type.__asyncResolved&&s.component.subTree.component&&Gr(t,e,r,s.component.subTree);return}const i=s.shapeFlag&4?mn(s.component):s.el,o=n?null:i,{i:a,r:l}=t,c=e&&e.r,u=a.refs===ne?a.refs={}:a.refs,h=a.setupState,d=Q(h),f=h===ne?Aa:v=>Qi(u,v)?!1:te(d,v),m=(v,A)=>!(A&&Qi(u,A));if(c!=null&&c!==l){if(Zi(e),ue(c))u[c]=null,f(c)&&(h[c]=null);else if(fe(c)){const v=e;m(c,v.k)&&(c.value=null),v.k&&(u[v.k]=null)}}if(G(l))vs(l,a,12,[o,u]);else{const v=ue(l),A=fe(l);if(v||A){const E=()=>{if(t.f){const _=v?f(l)?h[l]:u[l]:m()||!t.k?l.value:u[t.k];if(n)M(_)&&Ei(_,i);else if(M(_))_.includes(i)||_.push(i);else if(v)u[l]=[i],f(l)&&(h[l]=u[l]);else{const b=[i];m(l,t.k)&&(l.value=b),t.k&&(u[t.k]=b)}}else v?(u[l]=o,f(l)&&(h[l]=o)):A&&(m(l,t.k)&&(l.value=o),t.k&&(u[t.k]=o))};if(o){const _=()=>{E(),Fs.delete(t)};_.id=-1,Fs.set(t,_),Ne(_,r)}else Zi(t),E()}}}function Zi(t){const e=Fs.get(t);e&&(e.flags|=8,Fs.delete(t))}on().requestIdleCallback;on().cancelIdleCallback;const zr=t=>!!t.type.__asyncLoader,ll=t=>t.type.__isKeepAlive;function Tu(t,e){cl(t,"a",e)}function Ru(t,e){cl(t,"da",e)}function cl(t,e,r=ke){const s=t.__wdc||(t.__wdc=()=>{let n=r;for(;n;){if(n.isDeactivated)return;n=n.parent}return t()});if(fn(e,s,r),r){let n=r.parent;for(;n&&n.parent;)ll(n.parent.vnode)&&Ou(s,e,r,n),n=n.parent}}function Ou(t,e,r,s){const n=fn(e,t,s,!0);ul(()=>{Ei(s[e],n)},r)}function fn(t,e,r=ke,s=!1){if(r){const n=r[t]||(r[t]=[]),i=e.__weh||(e.__weh=(...o)=>{Ot();const a=_s(r),l=gt(e,r,t,o);return a(),Ct(),l});return s?n.unshift(i):n.push(i),i}}const xt=t=>(e,r=ke)=>{(!os||t==="sp")&&fn(t,(...s)=>e(...s),r)},Cu=xt("bm"),Pu=xt("m"),xu=xt("bu"),Iu=xt("u"),ju=xt("bum"),ul=xt("um"),Nu=xt("sp"),$u=xt("rtg"),Lu=xt("rtc");function Du(t,e=ke){fn("ec",t,e)}const hl="components";function dl(t,e){return pl(hl,t,!0,e)||t}const fl=Symbol.for("v-ndc");function Uu(t){return ue(t)?pl(hl,t,!1)||t:t||fl}function pl(t,e,r=!0,s=!1){const n=Be||ke;if(n){const i=n.type;{const a=kh(i,!1);if(a&&(a===e||a===Pe(e)||a===sn(Pe(e))))return i}const o=eo(n[t]||i[t],e)||eo(n.appContext[t],e);return!o&&s?i:o}}function eo(t,e){return t&&(t[e]||t[Pe(e)]||t[sn(Pe(e))])}function Bu(t,e,r,s){let n;const i=r,o=M(t);if(o||ue(t)){const a=o&&Tt(t);let l=!1,c=!1;a&&(l=!He(t),c=Pt(t),t=ln(t)),n=new Array(t.length);for(let u=0,h=t.length;u<h;u++)n[u]=e(l?c?kr(Ze(t[u])):Ze(t[u]):t[u],u,void 0,i)}else if(typeof t=="number"){n=new Array(t);for(let a=0;a<t;a++)n[a]=e(a+1,a,void 0,i)}else if(re(t))if(t[Symbol.iterator])n=Array.from(t,(a,l)=>e(a,l,void 0,i));else{const a=Object.keys(t);n=new Array(a.length);for(let l=0,c=a.length;l<c;l++){const u=a[l];n[l]=e(t[u],u,l,i)}}else n=[];return n}const Yn=t=>t?Ll(t)?mn(t):Yn(t.parent):null,Jr=Se(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>Yn(t.parent),$root:t=>Yn(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>ml(t),$forceUpdate:t=>t.f||(t.f=()=>{ji(t.update)}),$nextTick:t=>t.n||(t.n=hn.bind(t.proxy)),$watch:t=>Su.bind(t)}),Pn=(t,e)=>t!==ne&&!t.__isScriptSetup&&te(t,e),Mu={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:r,setupState:s,data:n,props:i,accessCache:o,type:a,appContext:l}=t;if(e[0]!=="$"){const d=o[e];if(d!==void 0)switch(d){case 1:return s[e];case 2:return n[e];case 4:return r[e];case 3:return i[e]}else{if(Pn(s,e))return o[e]=1,s[e];if(n!==ne&&te(n,e))return o[e]=2,n[e];if(te(i,e))return o[e]=3,i[e];if(r!==ne&&te(r,e))return o[e]=4,r[e];Xn&&(o[e]=0)}}const c=Jr[e];let u,h;if(c)return e==="$attrs"&&Ee(t.attrs,"get",""),c(t);if((u=a.__cssModules)&&(u=u[e]))return u;if(r!==ne&&te(r,e))return o[e]=4,r[e];if(h=l.config.globalProperties,te(h,e))return h[e]},set({_:t},e,r){const{data:s,setupState:n,ctx:i}=t;return Pn(n,e)?(n[e]=r,!0):s!==ne&&te(s,e)?(s[e]=r,!0):te(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(i[e]=r,!0)},has({_:{data:t,setupState:e,accessCache:r,ctx:s,appContext:n,props:i,type:o}},a){let l;return!!(r[a]||t!==ne&&a[0]!=="$"&&te(t,a)||Pn(e,a)||te(i,a)||te(s,a)||te(Jr,a)||te(n.config.globalProperties,a)||(l=o.__cssModules)&&l[a])},defineProperty(t,e,r){return r.get!=null?t._.accessCache[e]=0:te(r,"value")&&this.set(t,e,r.value,null),Reflect.defineProperty(t,e,r)}};function to(t){return M(t)?t.reduce((e,r)=>(e[r]=null,e),{}):t}let Xn=!0;function Hu(t){const e=ml(t),r=t.proxy,s=t.ctx;Xn=!1,e.beforeCreate&&ro(e.beforeCreate,t,"bc");const{data:n,computed:i,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:h,mounted:d,beforeUpdate:f,updated:m,activated:v,deactivated:A,beforeDestroy:E,beforeUnmount:_,destroyed:b,unmounted:O,render:B,renderTracked:W,renderTriggered:q,errorCaptured:J,serverPrefetch:V,expose:ce,inheritAttrs:Te,components:Le,directives:xe,filters:Kt}=e;if(c&&Fu(c,s,null),o)for(const z in o){const Z=o[z];G(Z)&&(s[z]=Z.bind(r))}if(n){const z=n.call(r,r);re(z)&&(t.data=ys(z))}if(Xn=!0,i)for(const z in i){const Z=i[z],mt=G(Z)?Z.bind(r,r):G(Z.get)?Z.get.bind(r,r):pt,$t=!G(Z)&&G(Z.set)?Z.set.bind(r):pt,tt=$e({get:mt,set:$t});Object.defineProperty(s,z,{enumerable:!0,configurable:!0,get:()=>tt.value,set:Ie=>tt.value=Ie})}if(a)for(const z in a)gl(a[z],s,r,z);if(l){const z=G(l)?l.call(r):l;Reflect.ownKeys(z).forEach(Z=>{$s(Z,z[Z])})}u&&ro(u,t,"c");function le(z,Z){M(Z)?Z.forEach(mt=>z(mt.bind(r))):Z&&z(Z.bind(r))}if(le(Cu,h),le(Pu,d),le(xu,f),le(Iu,m),le(Tu,v),le(Ru,A),le(Du,J),le(Lu,W),le($u,q),le(ju,_),le(ul,O),le(Nu,V),M(ce))if(ce.length){const z=t.exposed||(t.exposed={});ce.forEach(Z=>{Object.defineProperty(z,Z,{get:()=>r[Z],set:mt=>r[Z]=mt,enumerable:!0})})}else t.exposed||(t.exposed={});B&&t.render===pt&&(t.render=B),Te!=null&&(t.inheritAttrs=Te),Le&&(t.components=Le),xe&&(t.directives=xe),V&&al(t)}function Fu(t,e,r=pt){M(t)&&(t=Qn(t));for(const s in t){const n=t[s];let i;re(n)?"default"in n?i=Ve(n.from||s,n.default,!0):i=Ve(n.from||s):i=Ve(n),fe(i)?Object.defineProperty(e,s,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):e[s]=i}}function ro(t,e,r){gt(M(t)?t.map(s=>s.bind(e.proxy)):t.bind(e.proxy),e,r)}function gl(t,e,r,s){let n=s.includes(".")?ol(r,s):()=>r[s];if(ue(t)){const i=e[t];G(i)&&Wr(n,i)}else if(G(t))Wr(n,t.bind(r));else if(re(t))if(M(t))t.forEach(i=>gl(i,e,r,s));else{const i=G(t.handler)?t.handler.bind(r):e[t.handler];G(i)&&Wr(n,i,t)}}function ml(t){const e=t.type,{mixins:r,extends:s}=e,{mixins:n,optionsCache:i,config:{optionMergeStrategies:o}}=t.appContext,a=i.get(e);let l;return a?l=a:!n.length&&!r&&!s?l=e:(l={},n.length&&n.forEach(c=>qs(l,c,o,!0)),qs(l,e,o)),re(e)&&i.set(e,l),l}function qs(t,e,r,s=!1){const{mixins:n,extends:i}=e;i&&qs(t,i,r,!0),n&&n.forEach(o=>qs(t,o,r,!0));for(const o in e)if(!(s&&o==="expose")){const a=qu[o]||r&&r[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const qu={data:so,props:no,emits:no,methods:Ur,computed:Ur,beforeCreate:Re,created:Re,beforeMount:Re,mounted:Re,beforeUpdate:Re,updated:Re,beforeDestroy:Re,beforeUnmount:Re,destroyed:Re,unmounted:Re,activated:Re,deactivated:Re,errorCaptured:Re,serverPrefetch:Re,components:Ur,directives:Ur,watch:Ku,provide:so,inject:Vu};function so(t,e){return e?t?function(){return Se(G(t)?t.call(this,this):t,G(e)?e.call(this,this):e)}:e:t}function Vu(t,e){return Ur(Qn(t),Qn(e))}function Qn(t){if(M(t)){const e={};for(let r=0;r<t.length;r++)e[t[r]]=t[r];return e}return t}function Re(t,e){return t?[...new Set([].concat(t,e))]:e}function Ur(t,e){return t?Se(Object.create(null),t,e):e}function no(t,e){return t?M(t)&&M(e)?[...new Set([...t,...e])]:Se(Object.create(null),to(t),to(e??{})):e}function Ku(t,e){if(!t)return e;if(!e)return t;const r=Se(Object.create(null),t);for(const s in e)r[s]=Re(t[s],e[s]);return r}function yl(){return{app:null,config:{isNativeTag:Aa,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let Wu=0;function Gu(t,e){return function(s,n=null){G(s)||(s=Se({},s)),n!=null&&!re(n)&&(n=null);const i=yl(),o=new WeakSet,a=[];let l=!1;const c=i.app={_uid:Wu++,_component:s,_props:n,_container:null,_context:i,_instance:null,version:Th,get config(){return i.config},set config(u){},use(u,...h){return o.has(u)||(u&&G(u.install)?(o.add(u),u.install(c,...h)):G(u)&&(o.add(u),u(c,...h))),c},mixin(u){return i.mixins.includes(u)||i.mixins.push(u),c},component(u,h){return h?(i.components[u]=h,c):i.components[u]},directive(u,h){return h?(i.directives[u]=h,c):i.directives[u]},mount(u,h,d){if(!l){const f=c._ceVNode||Ae(s,n);return f.appContext=i,d===!0?d="svg":d===!1&&(d=void 0),t(f,u,d),l=!0,c._container=u,u.__vue_app__=c,mn(f.component)}},onUnmount(u){a.push(u)},unmount(){l&&(gt(a,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,h){return i.provides[u]=h,c},runWithContext(u){const h=rr;rr=c;try{return u()}finally{rr=h}}};return c}}let rr=null;const zu=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${Pe(e)}Modifiers`]||t[`${Vt(e)}Modifiers`];function Ju(t,e,...r){if(t.isUnmounted)return;const s=t.vnode.props||ne;let n=r;const i=e.startsWith("update:"),o=i&&zu(s,e.slice(7));o&&(o.trim&&(n=r.map(u=>ue(u)?u.trim():u)),o.number&&(n=r.map(nn)));let a,l=s[a=An(e)]||s[a=An(Pe(e))];!l&&i&&(l=s[a=An(Vt(e))]),l&>(l,t,6,n);const c=s[a+"Once"];if(c){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,gt(c,t,6,n)}}const Yu=new WeakMap;function vl(t,e,r=!1){const s=r?Yu:e.emitsCache,n=s.get(t);if(n!==void 0)return n;const i=t.emits;let o={},a=!1;if(!G(t)){const l=c=>{const u=vl(c,e,!0);u&&(a=!0,Se(o,u))};!r&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!i&&!a?(re(t)&&s.set(t,null),null):(M(i)?i.forEach(l=>o[l]=null):Se(o,i),re(t)&&s.set(t,o),o)}function pn(t,e){return!t||!Zs(e)?!1:(e=e.slice(2).replace(/Once$/,""),te(t,e[0].toLowerCase()+e.slice(1))||te(t,Vt(e))||te(t,e))}function io(t){const{type:e,vnode:r,proxy:s,withProxy:n,propsOptions:[i],slots:o,attrs:a,emit:l,render:c,renderCache:u,props:h,data:d,setupState:f,ctx:m,inheritAttrs:v}=t,A=Hs(t);let E,_;try{if(r.shapeFlag&4){const O=n||s,B=O;E=ht(c.call(B,O,u,h,f,d,m)),_=a}else{const O=e;E=ht(O.length>1?O(h,{attrs:a,slots:o,emit:l}):O(h,null)),_=e.props?a:Xu(a)}}catch(O){Yr.length=0,un(O,t,1),E=Ae(qt)}let b=E;if(_&&v!==!1){const O=Object.keys(_),{shapeFlag:B}=b;O.length&&B&7&&(i&&O.some(en)&&(_=Qu(_,i)),b=Ar(b,_,!1,!0))}return r.dirs&&(b=Ar(b,null,!1,!0),b.dirs=b.dirs?b.dirs.concat(r.dirs):r.dirs),r.transition&&Ni(b,r.transition),E=b,Hs(A),E}const Xu=t=>{let e;for(const r in t)(r==="class"||r==="style"||Zs(r))&&((e||(e={}))[r]=t[r]);return e},Qu=(t,e)=>{const r={};for(const s in t)(!en(s)||!(s.slice(9)in e))&&(r[s]=t[s]);return r};function Zu(t,e,r){const{props:s,children:n,component:i}=t,{props:o,children:a,patchFlag:l}=e,c=i.emitsOptions;if(e.dirs||e.transition)return!0;if(r&&l>=0){if(l&1024)return!0;if(l&16)return s?oo(s,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let h=0;h<u.length;h++){const d=u[h];if(_l(o,s,d)&&!pn(c,d))return!0}}}else return(n||a)&&(!a||!a.$stable)?!0:s===o?!1:s?o?oo(s,o,c):!0:!!o;return!1}function oo(t,e,r){const s=Object.keys(e);if(s.length!==Object.keys(t).length)return!0;for(let n=0;n<s.length;n++){const i=s[n];if(_l(e,t,i)&&!pn(r,i))return!0}return!1}function _l(t,e,r){const s=t[r],n=e[r];return r==="style"&&re(s)&&re(n)?!xr(s,n):s!==n}function eh({vnode:t,parent:e,suspense:r},s){for(;e;){const n=e.subTree;if(n.suspense&&n.suspense.activeBranch===t&&(n.suspense.vnode.el=n.el=s,t=n),n===t)(t=e.vnode).el=s,e=e.parent;else break}r&&r.activeBranch===t&&(r.vnode.el=s)}const bl={},wl=()=>Object.create(bl),Sl=t=>Object.getPrototypeOf(t)===bl;function th(t,e,r,s=!1){const n={},i=wl();t.propsDefaults=Object.create(null),El(t,e,n,i);for(const o in t.propsOptions[0])o in n||(n[o]=void 0);r?t.props=s?n:Ya(n):t.type.props?t.props=n:t.props=i,t.attrs=i}function rh(t,e,r,s){const{props:n,attrs:i,vnode:{patchFlag:o}}=t,a=Q(n),[l]=t.propsOptions;let c=!1;if((s||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let h=0;h<u.length;h++){let d=u[h];if(pn(t.emitsOptions,d))continue;const f=e[d];if(l)if(te(i,d))f!==i[d]&&(i[d]=f,c=!0);else{const m=Pe(d);n[m]=Zn(l,a,m,f,t,!1)}else f!==i[d]&&(i[d]=f,c=!0)}}}else{El(t,e,n,i)&&(c=!0);let u;for(const h in a)(!e||!te(e,h)&&((u=Vt(h))===h||!te(e,u)))&&(l?r&&(r[h]!==void 0||r[u]!==void 0)&&(n[h]=Zn(l,a,h,void 0,t,!0)):delete n[h]);if(i!==a)for(const h in i)(!e||!te(e,h))&&(delete i[h],c=!0)}c&&kt(t.attrs,"set","")}function El(t,e,r,s){const[n,i]=t.propsOptions;let o=!1,a;if(e)for(let l in e){if(Fr(l))continue;const c=e[l];let u;n&&te(n,u=Pe(l))?!i||!i.includes(u)?r[u]=c:(a||(a={}))[u]=c:pn(t.emitsOptions,l)||(!(l in s)||c!==s[l])&&(s[l]=c,o=!0)}if(i){const l=Q(r),c=a||ne;for(let u=0;u<i.length;u++){const h=i[u];r[h]=Zn(n,l,h,c[h],t,!te(c,h))}}return o}function Zn(t,e,r,s,n,i){const o=t[r];if(o!=null){const a=te(o,"default");if(a&&s===void 0){const l=o.default;if(o.type!==Function&&!o.skipFactory&&G(l)){const{propsDefaults:c}=n;if(r in c)s=c[r];else{const u=_s(n);s=c[r]=l.call(null,e),u()}}else s=l;n.ce&&n.ce._setProp(r,s)}o[0]&&(i&&!a?s=!1:o[1]&&(s===""||s===Vt(r))&&(s=!0))}return s}const sh=new WeakMap;function kl(t,e,r=!1){const s=r?sh:e.propsCache,n=s.get(t);if(n)return n;const i=t.props,o={},a=[];let l=!1;if(!G(t)){const u=h=>{l=!0;const[d,f]=kl(h,e,!0);Se(o,d),f&&a.push(...f)};!r&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!i&&!l)return re(t)&&s.set(t,_r),_r;if(M(i))for(let u=0;u<i.length;u++){const h=Pe(i[u]);ao(h)&&(o[h]=ne)}else if(i)for(const u in i){const h=Pe(u);if(ao(h)){const d=i[u],f=o[h]=M(d)||G(d)?{type:d}:Se({},d),m=f.type;let v=!1,A=!0;if(M(m))for(let E=0;E<m.length;++E){const _=m[E],b=G(_)&&_.name;if(b==="Boolean"){v=!0;break}else b==="String"&&(A=!1)}else v=G(m)&&m.name==="Boolean";f[0]=v,f[1]=A,(v||te(f,"default"))&&a.push(h)}}const c=[o,a];return re(t)&&s.set(t,c),c}function ao(t){return t[0]!=="$"&&!Fr(t)}const $i=t=>t==="_"||t==="_ctx"||t==="$stable",Li=t=>M(t)?t.map(ht):[ht(t)],nh=(t,e,r)=>{if(e._n)return e;const s=nl((...n)=>Li(e(...n)),r);return s._c=!1,s},Al=(t,e,r)=>{const s=t._ctx;for(const n in t){if($i(n))continue;const i=t[n];if(G(i))e[n]=nh(n,i,s);else if(i!=null){const o=Li(i);e[n]=()=>o}}},Tl=(t,e)=>{const r=Li(e);t.slots.default=()=>r},Rl=(t,e,r)=>{for(const s in e)(r||!$i(s))&&(t[s]=e[s])},ih=(t,e,r)=>{const s=t.slots=wl();if(t.vnode.shapeFlag&32){const n=e._;n?(Rl(s,e,r),r&&Ca(s,"_",n,!0)):Al(e,s)}else e&&Tl(t,e)},oh=(t,e,r)=>{const{vnode:s,slots:n}=t;let i=!0,o=ne;if(s.shapeFlag&32){const a=e._;a?r&&a===1?i=!1:Rl(n,e,r):(i=!e.$stable,Al(e,n)),o=e}else e&&(Tl(t,e),o={default:1});if(i)for(const a in n)!$i(a)&&o[a]==null&&delete n[a]},Ne=hh;function ah(t){return lh(t)}function lh(t,e){const r=on();r.__VUE__=!0;const{insert:s,remove:n,patchProp:i,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:h,nextSibling:d,setScopeId:f=pt,insertStaticContent:m}=t,v=(p,g,y,w=null,T=null,S=null,I=void 0,P=null,C=!!g.dynamicChildren)=>{if(p===g)return;p&&!$r(p,g)&&(w=k(p),Ie(p,T,S,!0),p=null),g.patchFlag===-2&&(C=!1,g.dynamicChildren=null);const{type:R,ref:H,shapeFlag:N}=g;switch(R){case gn:A(p,g,y,w);break;case qt:E(p,g,y,w);break;case In:p==null&&_(g,y,w,I);break;case ut:Le(p,g,y,w,T,S,I,P,C);break;default:N&1?B(p,g,y,w,T,S,I,P,C):N&6?xe(p,g,y,w,T,S,I,P,C):(N&64||N&128)&&R.process(p,g,y,w,T,S,I,P,C,D)}H!=null&&T?Gr(H,p&&p.ref,S,g||p,!g):H==null&&p&&p.ref!=null&&Gr(p.ref,null,S,p,!0)},A=(p,g,y,w)=>{if(p==null)s(g.el=a(g.children),y,w);else{const T=g.el=p.el;g.children!==p.children&&c(T,g.children)}},E=(p,g,y,w)=>{p==null?s(g.el=l(g.children||""),y,w):g.el=p.el},_=(p,g,y,w)=>{[p.el,p.anchor]=m(p.children,g,y,w,p.el,p.anchor)},b=({el:p,anchor:g},y,w)=>{let T;for(;p&&p!==g;)T=d(p),s(p,y,w),p=T;s(g,y,w)},O=({el:p,anchor:g})=>{let y;for(;p&&p!==g;)y=d(p),n(p),p=y;n(g)},B=(p,g,y,w,T,S,I,P,C)=>{if(g.type==="svg"?I="svg":g.type==="math"&&(I="mathml"),p==null)W(g,y,w,T,S,I,P,C);else{const R=p.el&&p.el._isVueCE?p.el:null;try{R&&R._beginPatch(),V(p,g,T,S,I,P,C)}finally{R&&R._endPatch()}}},W=(p,g,y,w,T,S,I,P)=>{let C,R;const{props:H,shapeFlag:N,transition:U,dirs:K}=p;if(C=p.el=o(p.type,S,H&&H.is,H),N&8?u(C,p.children):N&16&&J(p.children,C,null,w,T,xn(p,S),I,P),K&&Gt(p,null,w,"created"),q(C,p,p.scopeId,I,w),H){for(const se in H)se!=="value"&&!Fr(se)&&i(C,se,null,H[se],S,w);"value"in H&&i(C,"value",null,H.value,S),(R=H.onVnodeBeforeMount)&&it(R,w,p)}K&&Gt(p,null,w,"beforeMount");const X=ch(T,U);X&&U.beforeEnter(C),s(C,g,y),((R=H&&H.onVnodeMounted)||X||K)&&Ne(()=>{try{R&&it(R,w,p),X&&U.enter(C),K&&Gt(p,null,w,"mounted")}finally{}},T)},q=(p,g,y,w,T)=>{if(y&&f(p,y),w)for(let S=0;S<w.length;S++)f(p,w[S]);if(T){let S=T.subTree;if(g===S||xl(S.type)&&(S.ssContent===g||S.ssFallback===g)){const I=T.vnode;q(p,I,I.scopeId,I.slotScopeIds,T.parent)}}},J=(p,g,y,w,T,S,I,P,C=0)=>{for(let R=C;R<p.length;R++){const H=p[R]=P?Et(p[R]):ht(p[R]);v(null,H,g,y,w,T,S,I,P)}},V=(p,g,y,w,T,S,I)=>{const P=g.el=p.el;let{patchFlag:C,dynamicChildren:R,dirs:H}=g;C|=p.patchFlag&16;const N=p.props||ne,U=g.props||ne;let K;if(y&&zt(y,!1),(K=U.onVnodeBeforeUpdate)&&it(K,y,g,p),H&&Gt(g,p,y,"beforeUpdate"),y&&zt(y,!0),(N.innerHTML&&U.innerHTML==null||N.textContent&&U.textContent==null)&&u(P,""),R?ce(p.dynamicChildren,R,P,y,w,xn(g,T),S):I||Z(p,g,P,null,y,w,xn(g,T),S,!1),C>0){if(C&16)Te(P,N,U,y,T);else if(C&2&&N.class!==U.class&&i(P,"class",null,U.class,T),C&4&&i(P,"style",N.style,U.style,T),C&8){const X=g.dynamicProps;for(let se=0;se<X.length;se++){const ie=X[se],pe=N[ie],_e=U[ie];(_e!==pe||ie==="value")&&i(P,ie,pe,_e,T,y)}}C&1&&p.children!==g.children&&u(P,g.children)}else!I&&R==null&&Te(P,N,U,y,T);((K=U.onVnodeUpdated)||H)&&Ne(()=>{K&&it(K,y,g,p),H&&Gt(g,p,y,"updated")},w)},ce=(p,g,y,w,T,S,I)=>{for(let P=0;P<g.length;P++){const C=p[P],R=g[P],H=C.el&&(C.type===ut||!$r(C,R)||C.shapeFlag&198)?h(C.el):y;v(C,R,H,null,w,T,S,I,!0)}},Te=(p,g,y,w,T)=>{if(g!==y){if(g!==ne)for(const S in g)!Fr(S)&&!(S in y)&&i(p,S,g[S],null,T,w);for(const S in y){if(Fr(S))continue;const I=y[S],P=g[S];I!==P&&S!=="value"&&i(p,S,P,I,T,w)}"value"in y&&i(p,"value",g.value,y.value,T)}},Le=(p,g,y,w,T,S,I,P,C)=>{const R=g.el=p?p.el:a(""),H=g.anchor=p?p.anchor:a("");let{patchFlag:N,dynamicChildren:U,slotScopeIds:K}=g;K&&(P=P?P.concat(K):K),p==null?(s(R,y,w),s(H,y,w),J(g.children||[],y,H,T,S,I,P,C)):N>0&&N&64&&U&&p.dynamicChildren&&p.dynamicChildren.length===U.length?(ce(p.dynamicChildren,U,y,T,S,I,P),(g.key!=null||T&&g===T.subTree)&&Ol(p,g,!0)):Z(p,g,y,H,T,S,I,P,C)},xe=(p,g,y,w,T,S,I,P,C)=>{g.slotScopeIds=P,p==null?g.shapeFlag&512?T.ctx.activate(g,y,w,I,C):Kt(g,y,w,T,S,I,C):Nt(p,g,C)},Kt=(p,g,y,w,T,S,I)=>{const P=p.component=_h(p,w,T);if(ll(p)&&(P.ctx.renderer=D),bh(P,!1,I),P.asyncDep){if(T&&T.registerDep(P,le,I),!p.el){const C=P.subTree=Ae(qt);E(null,C,g,y),p.placeholder=C.el}}else le(P,p,g,y,T,S,I)},Nt=(p,g,y)=>{const w=g.component=p.component;if(Zu(p,g,y))if(w.asyncDep&&!w.asyncResolved){z(w,g,y);return}else w.next=g,w.update();else g.el=p.el,w.vnode=g},le=(p,g,y,w,T,S,I)=>{const P=()=>{if(p.isMounted){let{next:N,bu:U,u:K,parent:X,vnode:se}=p;{const st=Cl(p);if(st){N&&(N.el=se.el,z(p,N,I)),st.asyncDep.then(()=>{Ne(()=>{p.isUnmounted||R()},T)});return}}let ie=N,pe;zt(p,!1),N?(N.el=se.el,z(p,N,I)):N=se,U&&Ns(U),(pe=N.props&&N.props.onVnodeBeforeUpdate)&&it(pe,X,N,se),zt(p,!0);const _e=io(p),rt=p.subTree;p.subTree=_e,v(rt,_e,h(rt.el),k(rt),p,T,S),N.el=_e.el,ie===null&&eh(p,_e.el),K&&Ne(K,T),(pe=N.props&&N.props.onVnodeUpdated)&&Ne(()=>it(pe,X,N,se),T)}else{let N;const{el:U,props:K}=g,{bm:X,m:se,parent:ie,root:pe,type:_e}=p,rt=zr(g);zt(p,!1),X&&Ns(X),!rt&&(N=K&&K.onVnodeBeforeMount)&&it(N,ie,g),zt(p,!0);{pe.ce&&pe.ce._hasShadowRoot()&&pe.ce._injectChildStyle(_e,p.parent?p.parent.type:void 0);const st=p.subTree=io(p);v(null,st,y,w,p,T,S),g.el=st.el}if(se&&Ne(se,T),!rt&&(N=K&&K.onVnodeMounted)){const st=g;Ne(()=>it(N,ie,st),T)}(g.shapeFlag&256||ie&&zr(ie.vnode)&&ie.vnode.shapeFlag&256)&&p.a&&Ne(p.a,T),p.isMounted=!0,g=y=w=null}};p.scope.on();const C=p.effect=new La(P);p.scope.off();const R=p.update=C.run.bind(C),H=p.job=C.runIfDirty.bind(C);H.i=p,H.id=p.uid,C.scheduler=()=>ji(H),zt(p,!0),R()},z=(p,g,y)=>{g.component=p;const w=p.vnode.props;p.vnode=g,p.next=null,rh(p,g.props,w,y),oh(p,g.children,y),Ot(),Xi(p),Ct()},Z=(p,g,y,w,T,S,I,P,C=!1)=>{const R=p&&p.children,H=p?p.shapeFlag:0,N=g.children,{patchFlag:U,shapeFlag:K}=g;if(U>0){if(U&128){$t(R,N,y,w,T,S,I,P,C);return}else if(U&256){mt(R,N,y,w,T,S,I,P,C);return}}K&8?(H&16&&Fe(R,T,S),N!==R&&u(y,N)):H&16?K&16?$t(R,N,y,w,T,S,I,P,C):Fe(R,T,S,!0):(H&8&&u(y,""),K&16&&J(N,y,w,T,S,I,P,C))},mt=(p,g,y,w,T,S,I,P,C)=>{p=p||_r,g=g||_r;const R=p.length,H=g.length,N=Math.min(R,H);let U;for(U=0;U<N;U++){const K=g[U]=C?Et(g[U]):ht(g[U]);v(p[U],K,y,null,T,S,I,P,C)}R>H?Fe(p,T,S,!0,!1,N):J(g,y,w,T,S,I,P,C,N)},$t=(p,g,y,w,T,S,I,P,C)=>{let R=0;const H=g.length;let N=p.length-1,U=H-1;for(;R<=N&&R<=U;){const K=p[R],X=g[R]=C?Et(g[R]):ht(g[R]);if($r(K,X))v(K,X,y,null,T,S,I,P,C);else break;R++}for(;R<=N&&R<=U;){const K=p[N],X=g[U]=C?Et(g[U]):ht(g[U]);if($r(K,X))v(K,X,y,null,T,S,I,P,C);else break;N--,U--}if(R>N){if(R<=U){const K=U+1,X=K<H?g[K].el:w;for(;R<=U;)v(null,g[R]=C?Et(g[R]):ht(g[R]),y,X,T,S,I,P,C),R++}}else if(R>U)for(;R<=N;)Ie(p[R],T,S,!0),R++;else{const K=R,X=R,se=new Map;for(R=X;R<=U;R++){const De=g[R]=C?Et(g[R]):ht(g[R]);De.key!=null&&se.set(De.key,R)}let ie,pe=0;const _e=U-X+1;let rt=!1,st=0;const jr=new Array(_e);for(R=0;R<_e;R++)jr[R]=0;for(R=K;R<=N;R++){const De=p[R];if(pe>=_e){Ie(De,T,S,!0);continue}let nt;if(De.key!=null)nt=se.get(De.key);else for(ie=X;ie<=U;ie++)if(jr[ie-X]===0&&$r(De,g[ie])){nt=ie;break}nt===void 0?Ie(De,T,S,!0):(jr[nt-X]=R+1,nt>=st?st=nt:rt=!0,v(De,g[nt],y,null,T,S,I,P,C),pe++)}const qi=rt?uh(jr):_r;for(ie=qi.length-1,R=_e-1;R>=0;R--){const De=X+R,nt=g[De],Vi=g[De+1],Ki=De+1<H?Vi.el||Pl(Vi):w;jr[R]===0?v(null,nt,y,Ki,T,S,I,P,C):rt&&(ie<0||R!==qi[ie]?tt(nt,y,Ki,2):ie--)}}},tt=(p,g,y,w,T=null)=>{const{el:S,type:I,transition:P,children:C,shapeFlag:R}=p;if(R&6){tt(p.component.subTree,g,y,w);return}if(R&128){p.suspense.move(g,y,w);return}if(R&64){I.move(p,g,y,D);return}if(I===ut){s(S,g,y);for(let N=0;N<C.length;N++)tt(C[N],g,y,w);s(p.anchor,g,y);return}if(I===In){b(p,g,y);return}if(w!==2&&R&1&&P)if(w===0)P.beforeEnter(S),s(S,g,y),Ne(()=>P.enter(S),T);else{const{leave:N,delayLeave:U,afterLeave:K}=P,X=()=>{p.ctx.isUnmounted?n(S):s(S,g,y)},se=()=>{S._isLeaving&&S[Au](!0),N(S,()=>{X(),K&&K()})};U?U(S,X,se):se()}else s(S,g,y)},Ie=(p,g,y,w=!1,T=!1)=>{const{type:S,props:I,ref:P,children:C,dynamicChildren:R,shapeFlag:H,patchFlag:N,dirs:U,cacheIndex:K,memo:X}=p;if(N===-2&&(T=!1),P!=null&&(Ot(),Gr(P,null,y,p,!0),Ct()),K!=null&&(g.renderCache[K]=void 0),H&256){g.ctx.deactivate(p);return}const se=H&1&&U,ie=!zr(p);let pe;if(ie&&(pe=I&&I.onVnodeBeforeUnmount)&&it(pe,g,p),H&6)Wt(p.component,y,w);else{if(H&128){p.suspense.unmount(y,w);return}se&&Gt(p,null,g,"beforeUnmount"),H&64?p.type.remove(p,g,y,D,w):R&&!R.hasOnce&&(S!==ut||N>0&&N&64)?Fe(R,g,y,!1,!0):(S===ut&&N&384||!T&&H&16)&&Fe(C,g,y),w&&sr(p)}const _e=X!=null&&K==null;(ie&&(pe=I&&I.onVnodeUnmounted)||se||_e)&&Ne(()=>{pe&&it(pe,g,p),se&&Gt(p,null,g,"unmounted"),_e&&(p.el=null)},y)},sr=p=>{const{type:g,el:y,anchor:w,transition:T}=p;if(g===ut){nr(y,w);return}if(g===In){O(p);return}const S=()=>{n(y),T&&!T.persisted&&T.afterLeave&&T.afterLeave()};if(p.shapeFlag&1&&T&&!T.persisted){const{leave:I,delayLeave:P}=T,C=()=>I(y,S);P?P(p.el,S,C):C()}else S()},nr=(p,g)=>{let y;for(;p!==g;)y=d(p),n(p),p=y;n(g)},Wt=(p,g,y)=>{const{bum:w,scope:T,job:S,subTree:I,um:P,m:C,a:R}=p;lo(C),lo(R),w&&Ns(w),T.stop(),S&&(S.flags|=8,Ie(I,p,g,y)),P&&Ne(P,g),Ne(()=>{p.isUnmounted=!0},g)},Fe=(p,g,y,w=!1,T=!1,S=0)=>{for(let I=S;I<p.length;I++)Ie(p[I],g,y,w,T)},k=p=>{if(p.shapeFlag&6)return k(p.component.subTree);if(p.shapeFlag&128)return p.suspense.next();const g=d(p.anchor||p.el),y=g&&g[Eu];return y?d(y):g};let $=!1;const j=(p,g,y)=>{let w;p==null?g._vnode&&(Ie(g._vnode,null,null,!0),w=g._vnode.component):v(g._vnode||null,p,g,null,null,null,y),g._vnode=p,$||($=!0,Xi(w),tl(),$=!1)},D={p:v,um:Ie,m:tt,r:sr,mt:Kt,mc:J,pc:Z,pbc:ce,n:k,o:t};return{render:j,hydrate:void 0,createApp:Gu(j)}}function xn({type:t,props:e},r){return r==="svg"&&t==="foreignObject"||r==="mathml"&&t==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:r}function zt({effect:t,job:e},r){r?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function ch(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Ol(t,e,r=!1){const s=t.children,n=e.children;if(M(s)&&M(n))for(let i=0;i<s.length;i++){const o=s[i];let a=n[i];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=n[i]=Et(n[i]),a.el=o.el),!r&&a.patchFlag!==-2&&Ol(o,a)),a.type===gn&&(a.patchFlag===-1&&(a=n[i]=Et(a)),a.el=o.el),a.type===qt&&!a.el&&(a.el=o.el)}}function uh(t){const e=t.slice(),r=[0];let s,n,i,o,a;const l=t.length;for(s=0;s<l;s++){const c=t[s];if(c!==0){if(n=r[r.length-1],t[n]<c){e[s]=n,r.push(s);continue}for(i=0,o=r.length-1;i<o;)a=i+o>>1,t[r[a]]<c?i=a+1:o=a;c<t[r[i]]&&(i>0&&(e[s]=r[i-1]),r[i]=s)}}for(i=r.length,o=r[i-1];i-- >0;)r[i]=o,o=e[o];return r}function Cl(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Cl(e)}function lo(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}function Pl(t){if(t.placeholder)return t.placeholder;const e=t.component;return e?Pl(e.subTree):null}const xl=t=>t.__isSuspense;function hh(t,e){e&&e.pendingBranch?M(t)?e.effects.push(...t):e.effects.push(t):vu(t)}const ut=Symbol.for("v-fgt"),gn=Symbol.for("v-txt"),qt=Symbol.for("v-cmt"),In=Symbol.for("v-stc"),Yr=[];let Me=null;function Sr(t=!1){Yr.push(Me=t?null:[])}function dh(){Yr.pop(),Me=Yr[Yr.length-1]||null}let is=1;function Vs(t,e=!1){is+=t,t<0&&Me&&e&&(Me.hasOnce=!0)}function Il(t){return t.dynamicChildren=is>0?Me||_r:null,dh(),is>0&&Me&&Me.push(t),t}function ei(t,e,r,s,n,i){return Il(ze(t,e,r,s,n,i,!0))}function Di(t,e,r,s,n){return Il(Ae(t,e,r,s,n,!0))}function Ks(t){return t?t.__v_isVNode===!0:!1}function $r(t,e){return t.type===e.type&&t.key===e.key}const jl=({key:t})=>t??null,Ls=({ref:t,ref_key:e,ref_for:r})=>(typeof t=="number"&&(t=""+t),t!=null?ue(t)||fe(t)||G(t)?{i:Be,r:t,k:e,f:!!r}:t:null);function ze(t,e=null,r=null,s=0,n=null,i=t===ut?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&jl(e),ref:e&&Ls(e),scopeId:sl,slotScopeIds:null,children:r,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:s,dynamicProps:n,dynamicChildren:null,appContext:null,ctx:Be};return a?(Ui(l,r),i&128&&t.normalize(l)):r&&(l.shapeFlag|=ue(r)?8:16),is>0&&!o&&Me&&(l.patchFlag>0||i&6)&&l.patchFlag!==32&&Me.push(l),l}const Ae=fh;function fh(t,e=null,r=null,s=0,n=null,i=!1){if((!t||t===fl)&&(t=qt),Ks(t)){const a=Ar(t,e,!0);return r&&Ui(a,r),is>0&&!i&&Me&&(a.shapeFlag&6?Me[Me.indexOf(t)]=a:Me.push(a)),a.patchFlag=-2,a}if(Ah(t)&&(t=t.__vccOpts),e){e=ph(e);let{class:a,style:l}=e;a&&!ue(a)&&(e.class=an(a)),re(l)&&(cn(l)&&!M(l)&&(l=Se({},l)),e.style=ki(l))}const o=ue(t)?1:xl(t)?128:ku(t)?64:re(t)?4:G(t)?2:0;return ze(t,e,r,s,n,o,i,!0)}function ph(t){return t?cn(t)||Sl(t)?Se({},t):t:null}function Ar(t,e,r=!1,s=!1){const{props:n,ref:i,patchFlag:o,children:a,transition:l}=t,c=e?mh(n||{},e):n,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&jl(c),ref:e&&e.ref?r&&i?M(i)?i.concat(Ls(e)):[i,Ls(e)]:Ls(e):i,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:a,target:t.target,targetStart:t.targetStart,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==ut?o===-1?16:o|16:o,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:l,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&Ar(t.ssContent),ssFallback:t.ssFallback&&Ar(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&s&&Ni(u,l.clone(u)),u}function Nl(t=" ",e=0){return Ae(gn,null,t,e)}function gh(t="",e=!1){return e?(Sr(),Di(qt,null,t)):Ae(qt,null,t)}function ht(t){return t==null||typeof t=="boolean"?Ae(qt):M(t)?Ae(ut,null,t.slice()):Ks(t)?Et(t):Ae(gn,null,String(t))}function Et(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Ar(t)}function Ui(t,e){let r=0;const{shapeFlag:s}=t;if(e==null)e=null;else if(M(e))r=16;else if(typeof e=="object")if(s&65){const n=e.default;n&&(n._c&&(n._d=!1),Ui(t,n()),n._c&&(n._d=!0));return}else{r=32;const n=e._;!n&&!Sl(e)?e._ctx=Be:n===3&&Be&&(Be.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else G(e)?(e={default:e,_ctx:Be},r=32):(e=String(e),s&64?(r=16,e=[Nl(e)]):r=8);t.children=e,t.shapeFlag|=r}function mh(...t){const e={};for(let r=0;r<t.length;r++){const s=t[r];for(const n in s)if(n==="class")e.class!==s.class&&(e.class=an([e.class,s.class]));else if(n==="style")e.style=ki([e.style,s.style]);else if(Zs(n)){const i=e[n],o=s[n];o&&i!==o&&!(M(i)&&i.includes(o))?e[n]=i?[].concat(i,o):o:o==null&&i==null&&!en(n)&&(e[n]=o)}else n!==""&&(e[n]=s[n])}return e}function it(t,e,r,s=null){gt(t,e,7,[r,s])}const yh=yl();let vh=0;function _h(t,e,r){const s=t.type,n=(e?e.appContext:t.appContext)||yh,i={uid:vh++,vnode:t,type:s,parent:e,appContext:n,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new ja(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(n.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:kl(s,n),emitsOptions:vl(s,n),emit:null,emitted:null,propsDefaults:ne,inheritAttrs:s.inheritAttrs,ctx:ne,data:ne,props:ne,attrs:ne,slots:ne,refs:ne,setupState:ne,setupContext:null,suspense:r,suspenseId:r?r.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return i.ctx={_:i},i.root=e?e.root:i,i.emit=Ju.bind(null,i),t.ce&&t.ce(i),i}let ke=null;const $l=()=>ke||Be;let Ws,ti;{const t=on(),e=(r,s)=>{let n;return(n=t[r])||(n=t[r]=[]),n.push(s),i=>{n.length>1?n.forEach(o=>o(i)):n[0](i)}};Ws=e("__VUE_INSTANCE_SETTERS__",r=>ke=r),ti=e("__VUE_SSR_SETTERS__",r=>os=r)}const _s=t=>{const e=ke;return Ws(t),t.scope.on(),()=>{t.scope.off(),Ws(e)}},co=()=>{ke&&ke.scope.off(),Ws(null)};function Ll(t){return t.vnode.shapeFlag&4}let os=!1;function bh(t,e=!1,r=!1){e&&ti(e);const{props:s,children:n}=t.vnode,i=Ll(t);th(t,s,i,e),ih(t,n,r||e);const o=i?wh(t,e):void 0;return e&&ti(!1),o}function wh(t,e){const r=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,Mu);const{setup:s}=r;if(s){Ot();const n=t.setupContext=s.length>1?Eh(t):null,i=_s(t),o=vs(s,t,0,[t.props,n]),a=Ta(o);if(Ct(),i(),(a||t.sp)&&!zr(t)&&al(t),a){if(o.then(co,co),e)return o.then(l=>{uo(t,l)}).catch(l=>{un(l,t,0)});t.asyncDep=o}else uo(t,o)}else Dl(t)}function uo(t,e,r){G(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:re(e)&&(t.setupState=Qa(e)),Dl(t)}function Dl(t,e,r){const s=t.type;t.render||(t.render=s.render||pt);{const n=_s(t);Ot();try{Hu(t)}finally{Ct(),n()}}}const Sh={get(t,e){return Ee(t,"get",""),t[e]}};function Eh(t){const e=r=>{t.exposed=r||{}};return{attrs:new Proxy(t.attrs,Sh),slots:t.slots,emit:t.emit,expose:e}}function mn(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(Qa(Ii(t.exposed)),{get(e,r){if(r in e)return e[r];if(r in Jr)return Jr[r](t)},has(e,r){return r in e||r in Jr}})):t.proxy}function kh(t,e=!0){return G(t)?t.displayName||t.name:t.name||e&&t.__name}function Ah(t){return G(t)&&"__vccOpts"in t}const $e=(t,e)=>fu(t,e,os);function as(t,e,r){try{Vs(-1);const s=arguments.length;return s===2?re(e)&&!M(e)?Ks(e)?Ae(t,null,[e]):Ae(t,e):Ae(t,null,e):(s>3?r=Array.prototype.slice.call(arguments,2):s===3&&Ks(r)&&(r=[r]),Ae(t,e,r))}finally{Vs(1)}}const Th="3.5.34";/**
|
|
14
|
+
**/function _s(t,e,r,s){try{return s?t(...s):t()}catch(n){dn(n,e,r)}}function gt(t,e,r,s){if(G(t)){const n=_s(t,e,r,s);return n&&Ta(n)&&n.catch(i=>{dn(i,e,r)}),n}if(B(t)){const n=[];for(let i=0;i<t.length;i++)n.push(gt(t[i],e,r,s));return n}}function dn(t,e,r,s=!0){const n=e?e.vnode:null,{errorHandler:i,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||ne;if(e){let a=e.parent;const l=e.proxy,c=`https://vuejs.org/error-reference/#runtime-${r}`;for(;a;){const u=a.ec;if(u){for(let h=0;h<u.length;h++)if(u[h](t,l,c)===!1)return}a=a.parent}if(i){Ct(),_s(i,null,10,[t,l,c]),Pt();return}}mu(t,r,n,s,o)}function mu(t,e,r,s=!0,n=!1){if(n)throw t;console.error(t)}const Pe=[];let at=-1;const Sr=[];let Ut=null,fr=0;const Za=Promise.resolve();let Hs=null;function fn(t){const e=Hs||Za;return t?e.then(this?t.bind(this):t):e}function yu(t){let e=at+1,r=Pe.length;for(;e<r;){const s=e+r>>>1,n=Pe[s],i=ns(n);i<t||i===t&&n.flags&2?e=s+1:r=s}return e}function ji(t){if(!(t.flags&1)){const e=ns(t),r=Pe[Pe.length-1];!r||!(t.flags&2)&&e>=ns(r)?Pe.push(t):Pe.splice(yu(e),0,t),t.flags|=1,el()}}function el(){Hs||(Hs=Za.then(rl))}function _u(t){B(t)?Sr.push(...t):Ut&&t.id===-1?Ut.splice(fr+1,0,t):t.flags&1||(Sr.push(t),t.flags|=1),el()}function Xi(t,e,r=at+1){for(;r<Pe.length;r++){const s=Pe[r];if(s&&s.flags&2){if(t&&s.id!==t.uid)continue;Pe.splice(r,1),r--,s.flags&4&&(s.flags&=-2),s(),s.flags&4||(s.flags&=-2)}}}function tl(t){if(Sr.length){const e=[...new Set(Sr)].sort((r,s)=>ns(r)-ns(s));if(Sr.length=0,Ut){Ut.push(...e);return}for(Ut=e,fr=0;fr<Ut.length;fr++){const r=Ut[fr];r.flags&4&&(r.flags&=-2),r.flags&8||r(),r.flags&=-2}Ut=null,fr=0}}const ns=t=>t.id==null?t.flags&2?-1:1/0:t.id;function rl(t){try{for(at=0;at<Pe.length;at++){const e=Pe[at];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),_s(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;at<Pe.length;at++){const e=Pe[at];e&&(e.flags&=-2)}at=-1,Pe.length=0,tl(),Hs=null,(Pe.length||Sr.length)&&rl()}}let Be=null,sl=null;function Fs(t){const e=Be;return Be=t,sl=t&&t.type.__scopeId||null,e}function nl(t,e=Be,r){if(!e||t._n)return t;const s=(...n)=>{s._d&&Ks(-1);const i=Fs(e);let o;try{o=t(...n)}finally{Fs(i),s._d&&Ks(1)}return o};return s._n=!0,s._c=!0,s._d=!0,s}function Ym(t,e){if(Be===null)return t;const r=yn(Be),s=t.dirs||(t.dirs=[]);for(let n=0;n<e.length;n++){let[i,o,a,l=ne]=e[n];i&&(G(i)&&(i={mounted:i,updated:i}),i.deep&&At(o),s.push({dir:i,instance:r,value:o,oldValue:void 0,arg:a,modifiers:l}))}return t}function Gt(t,e,r,s){const n=t.dirs,i=e&&e.dirs;for(let o=0;o<n.length;o++){const a=n[o];i&&(a.oldValue=i[o].value);let l=a.dir[s];l&&(Ct(),gt(l,r,8,[t.el,a,t,e]),Pt())}}function $s(t,e){if(Ae){let r=Ae.provides;const s=Ae.parent&&Ae.parent.provides;s===r&&(r=Ae.provides=Object.create(s)),r[t]=e}}function Ge(t,e,r=!1){const s=Ll();if(s||rr){let n=rr?rr._context.provides:s?s.parent==null||s.ce?s.vnode.appContext&&s.vnode.appContext.provides:s.parent.provides:void 0;if(n&&t in n)return n[t];if(arguments.length>1)return r&&G(e)?e.call(s&&s.proxy):e}}function vu(){return!!(Ll()||rr)}const bu=Symbol.for("v-scx"),wu=()=>Ge(bu);function Wr(t,e,r){return il(t,e,r)}function il(t,e,r=ne){const{immediate:s,deep:n,flush:i,once:o}=r,a=Ee({},r),l=e&&s||!e&&i!=="post";let c;if(os){if(i==="sync"){const f=wu();c=f.__watcherHandles||(f.__watcherHandles=[])}else if(!l){const f=()=>{};return f.stop=pt,f.resume=pt,f.pause=pt,f}}const u=Ae;a.call=(f,m,_)=>gt(f,u,m,_);let h=!1;i==="post"?a.scheduler=f=>{$e(f,u&&u.suspense)}:i!=="sync"&&(h=!0,a.scheduler=(f,m)=>{m?f():ji(f)}),a.augmentJob=f=>{e&&(f.flags|=4),h&&(f.flags|=2,u&&(f.id=u.uid,f.i=u))};const d=gu(t,e,a);return os&&(c?c.push(d):l&&d()),d}function Su(t,e,r){const s=this.proxy,n=ue(t)?t.includes(".")?ol(s,t):()=>s[t]:t.bind(s,s);let i;G(e)?i=e:(i=e.handler,r=e);const o=bs(this),a=il(n,i.bind(s),r);return o(),a}function ol(t,e){const r=e.split(".");return()=>{let s=t;for(let n=0;n<r.length&&s;n++)s=s[r[n]];return s}}const Eu=Symbol("_vte"),ku=t=>t.__isTeleport,Au=Symbol("_leaveCb");function Ni(t,e){t.shapeFlag&6&&t.component?(t.transition=e,Ni(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function vs(t,e){return G(t)?Ee({name:t.name},e,{setup:t}):t}function al(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function Qi(t,e){let r;return!!((r=Object.getOwnPropertyDescriptor(t,e))&&!r.configurable)}const qs=new WeakMap;function Gr(t,e,r,s,n=!1){if(B(t)){t.forEach((_,A)=>Gr(_,e&&(B(e)?e[A]:e),r,s,n));return}if(zr(s)&&!n){s.shapeFlag&512&&s.type.__asyncResolved&&s.component.subTree.component&&Gr(t,e,r,s.component.subTree);return}const i=s.shapeFlag&4?yn(s.component):s.el,o=n?null:i,{i:a,r:l}=t,c=e&&e.r,u=a.refs===ne?a.refs={}:a.refs,h=a.setupState,d=Q(h),f=h===ne?Aa:_=>Qi(u,_)?!1:te(d,_),m=(_,A)=>!(A&&Qi(u,A));if(c!=null&&c!==l){if(Zi(e),ue(c))u[c]=null,f(c)&&(h[c]=null);else if(fe(c)){const _=e;m(c,_.k)&&(c.value=null),_.k&&(u[_.k]=null)}}if(G(l))_s(l,a,12,[o,u]);else{const _=ue(l),A=fe(l);if(_||A){const E=()=>{if(t.f){const v=_?f(l)?h[l]:u[l]:m()||!t.k?l.value:u[t.k];if(n)B(v)&&Ei(v,i);else if(B(v))v.includes(i)||v.push(i);else if(_)u[l]=[i],f(l)&&(h[l]=u[l]);else{const b=[i];m(l,t.k)&&(l.value=b),t.k&&(u[t.k]=b)}}else _?(u[l]=o,f(l)&&(h[l]=o)):A&&(m(l,t.k)&&(l.value=o),t.k&&(u[t.k]=o))};if(o){const v=()=>{E(),qs.delete(t)};v.id=-1,qs.set(t,v),$e(v,r)}else Zi(t),E()}}}function Zi(t){const e=qs.get(t);e&&(e.flags|=8,qs.delete(t))}ln().requestIdleCallback;ln().cancelIdleCallback;const zr=t=>!!t.type.__asyncLoader,ll=t=>t.type.__isKeepAlive;function Tu(t,e){cl(t,"a",e)}function Ru(t,e){cl(t,"da",e)}function cl(t,e,r=Ae){const s=t.__wdc||(t.__wdc=()=>{let n=r;for(;n;){if(n.isDeactivated)return;n=n.parent}return t()});if(pn(e,s,r),r){let n=r.parent;for(;n&&n.parent;)ll(n.parent.vnode)&&Ou(s,e,r,n),n=n.parent}}function Ou(t,e,r,s){const n=pn(e,t,s,!0);ul(()=>{Ei(s[e],n)},r)}function pn(t,e,r=Ae,s=!1){if(r){const n=r[t]||(r[t]=[]),i=e.__weh||(e.__weh=(...o)=>{Ct();const a=bs(r),l=gt(e,r,t,o);return a(),Pt(),l});return s?n.unshift(i):n.push(i),i}}const It=t=>(e,r=Ae)=>{(!os||t==="sp")&&pn(t,(...s)=>e(...s),r)},Cu=It("bm"),Pu=It("m"),xu=It("bu"),Iu=It("u"),ju=It("bum"),ul=It("um"),Nu=It("sp"),Lu=It("rtg"),$u=It("rtc");function Du(t,e=Ae){pn("ec",t,e)}const hl="components";function dl(t,e){return pl(hl,t,!0,e)||t}const fl=Symbol.for("v-ndc");function Uu(t){return ue(t)?pl(hl,t,!1)||t:t||fl}function pl(t,e,r=!0,s=!1){const n=Be||Ae;if(n){const i=n.type;{const a=kh(i,!1);if(a&&(a===e||a===Ie(e)||a===on(Ie(e))))return i}const o=eo(n[t]||i[t],e)||eo(n.appContext[t],e);return!o&&s?i:o}}function eo(t,e){return t&&(t[e]||t[Ie(e)]||t[on(Ie(e))])}function Mu(t,e,r,s){let n;const i=r,o=B(t);if(o||ue(t)){const a=o&&Tt(t);let l=!1,c=!1;a&&(l=!Fe(t),c=xt(t),t=un(t)),n=new Array(t.length);for(let u=0,h=t.length;u<h;u++)n[u]=e(l?c?kr(Ze(t[u])):Ze(t[u]):t[u],u,void 0,i)}else if(typeof t=="number"){n=new Array(t);for(let a=0;a<t;a++)n[a]=e(a+1,a,void 0,i)}else if(re(t))if(t[Symbol.iterator])n=Array.from(t,(a,l)=>e(a,l,void 0,i));else{const a=Object.keys(t);n=new Array(a.length);for(let l=0,c=a.length;l<c;l++){const u=a[l];n[l]=e(t[u],u,l,i)}}else n=[];return n}const Xn=t=>t?$l(t)?yn(t):Xn(t.parent):null,Jr=Ee(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>Xn(t.parent),$root:t=>Xn(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>ml(t),$forceUpdate:t=>t.f||(t.f=()=>{ji(t.update)}),$nextTick:t=>t.n||(t.n=fn.bind(t.proxy)),$watch:t=>Su.bind(t)}),xn=(t,e)=>t!==ne&&!t.__isScriptSetup&&te(t,e),Bu={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:r,setupState:s,data:n,props:i,accessCache:o,type:a,appContext:l}=t;if(e[0]!=="$"){const d=o[e];if(d!==void 0)switch(d){case 1:return s[e];case 2:return n[e];case 4:return r[e];case 3:return i[e]}else{if(xn(s,e))return o[e]=1,s[e];if(n!==ne&&te(n,e))return o[e]=2,n[e];if(te(i,e))return o[e]=3,i[e];if(r!==ne&&te(r,e))return o[e]=4,r[e];Qn&&(o[e]=0)}}const c=Jr[e];let u,h;if(c)return e==="$attrs"&&ke(t.attrs,"get",""),c(t);if((u=a.__cssModules)&&(u=u[e]))return u;if(r!==ne&&te(r,e))return o[e]=4,r[e];if(h=l.config.globalProperties,te(h,e))return h[e]},set({_:t},e,r){const{data:s,setupState:n,ctx:i}=t;return xn(n,e)?(n[e]=r,!0):s!==ne&&te(s,e)?(s[e]=r,!0):te(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(i[e]=r,!0)},has({_:{data:t,setupState:e,accessCache:r,ctx:s,appContext:n,props:i,type:o}},a){let l;return!!(r[a]||t!==ne&&a[0]!=="$"&&te(t,a)||xn(e,a)||te(i,a)||te(s,a)||te(Jr,a)||te(n.config.globalProperties,a)||(l=o.__cssModules)&&l[a])},defineProperty(t,e,r){return r.get!=null?t._.accessCache[e]=0:te(r,"value")&&this.set(t,e,r.value,null),Reflect.defineProperty(t,e,r)}};function to(t){return B(t)?t.reduce((e,r)=>(e[r]=null,e),{}):t}let Qn=!0;function Hu(t){const e=ml(t),r=t.proxy,s=t.ctx;Qn=!1,e.beforeCreate&&ro(e.beforeCreate,t,"bc");const{data:n,computed:i,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:h,mounted:d,beforeUpdate:f,updated:m,activated:_,deactivated:A,beforeDestroy:E,beforeUnmount:v,destroyed:b,unmounted:O,render:M,renderTracked:W,renderTriggered:q,errorCaptured:J,serverPrefetch:V,expose:ce,inheritAttrs:Te,components:De,directives:je,filters:Kt}=e;if(c&&Fu(c,s,null),o)for(const z in o){const Z=o[z];G(Z)&&(s[z]=Z.bind(r))}if(n){const z=n.call(r,r);re(z)&&(t.data=ys(z))}if(Qn=!0,i)for(const z in i){const Z=i[z],mt=G(Z)?Z.bind(r,r):G(Z.get)?Z.get.bind(r,r):pt,Lt=!G(Z)&&G(Z.set)?Z.set.bind(r):pt,tt=xe({get:mt,set:Lt});Object.defineProperty(s,z,{enumerable:!0,configurable:!0,get:()=>tt.value,set:Ne=>tt.value=Ne})}if(a)for(const z in a)gl(a[z],s,r,z);if(l){const z=G(l)?l.call(r):l;Reflect.ownKeys(z).forEach(Z=>{$s(Z,z[Z])})}u&&ro(u,t,"c");function le(z,Z){B(Z)?Z.forEach(mt=>z(mt.bind(r))):Z&&z(Z.bind(r))}if(le(Cu,h),le(Pu,d),le(xu,f),le(Iu,m),le(Tu,_),le(Ru,A),le(Du,J),le($u,W),le(Lu,q),le(ju,v),le(ul,O),le(Nu,V),B(ce))if(ce.length){const z=t.exposed||(t.exposed={});ce.forEach(Z=>{Object.defineProperty(z,Z,{get:()=>r[Z],set:mt=>r[Z]=mt,enumerable:!0})})}else t.exposed||(t.exposed={});M&&t.render===pt&&(t.render=M),Te!=null&&(t.inheritAttrs=Te),De&&(t.components=De),je&&(t.directives=je),V&&al(t)}function Fu(t,e,r=pt){B(t)&&(t=Zn(t));for(const s in t){const n=t[s];let i;re(n)?"default"in n?i=Ge(n.from||s,n.default,!0):i=Ge(n.from||s):i=Ge(n),fe(i)?Object.defineProperty(e,s,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):e[s]=i}}function ro(t,e,r){gt(B(t)?t.map(s=>s.bind(e.proxy)):t.bind(e.proxy),e,r)}function gl(t,e,r,s){let n=s.includes(".")?ol(r,s):()=>r[s];if(ue(t)){const i=e[t];G(i)&&Wr(n,i)}else if(G(t))Wr(n,t.bind(r));else if(re(t))if(B(t))t.forEach(i=>gl(i,e,r,s));else{const i=G(t.handler)?t.handler.bind(r):e[t.handler];G(i)&&Wr(n,i,t)}}function ml(t){const e=t.type,{mixins:r,extends:s}=e,{mixins:n,optionsCache:i,config:{optionMergeStrategies:o}}=t.appContext,a=i.get(e);let l;return a?l=a:!n.length&&!r&&!s?l=e:(l={},n.length&&n.forEach(c=>Vs(l,c,o,!0)),Vs(l,e,o)),re(e)&&i.set(e,l),l}function Vs(t,e,r,s=!1){const{mixins:n,extends:i}=e;i&&Vs(t,i,r,!0),n&&n.forEach(o=>Vs(t,o,r,!0));for(const o in e)if(!(s&&o==="expose")){const a=qu[o]||r&&r[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const qu={data:so,props:no,emits:no,methods:Ur,computed:Ur,beforeCreate:Oe,created:Oe,beforeMount:Oe,mounted:Oe,beforeUpdate:Oe,updated:Oe,beforeDestroy:Oe,beforeUnmount:Oe,destroyed:Oe,unmounted:Oe,activated:Oe,deactivated:Oe,errorCaptured:Oe,serverPrefetch:Oe,components:Ur,directives:Ur,watch:Ku,provide:so,inject:Vu};function so(t,e){return e?t?function(){return Ee(G(t)?t.call(this,this):t,G(e)?e.call(this,this):e)}:e:t}function Vu(t,e){return Ur(Zn(t),Zn(e))}function Zn(t){if(B(t)){const e={};for(let r=0;r<t.length;r++)e[t[r]]=t[r];return e}return t}function Oe(t,e){return t?[...new Set([].concat(t,e))]:e}function Ur(t,e){return t?Ee(Object.create(null),t,e):e}function no(t,e){return t?B(t)&&B(e)?[...new Set([...t,...e])]:Ee(Object.create(null),to(t),to(e??{})):e}function Ku(t,e){if(!t)return e;if(!e)return t;const r=Ee(Object.create(null),t);for(const s in e)r[s]=Oe(t[s],e[s]);return r}function yl(){return{app:null,config:{isNativeTag:Aa,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let Wu=0;function Gu(t,e){return function(s,n=null){G(s)||(s=Ee({},s)),n!=null&&!re(n)&&(n=null);const i=yl(),o=new WeakSet,a=[];let l=!1;const c=i.app={_uid:Wu++,_component:s,_props:n,_container:null,_context:i,_instance:null,version:Th,get config(){return i.config},set config(u){},use(u,...h){return o.has(u)||(u&&G(u.install)?(o.add(u),u.install(c,...h)):G(u)&&(o.add(u),u(c,...h))),c},mixin(u){return i.mixins.includes(u)||i.mixins.push(u),c},component(u,h){return h?(i.components[u]=h,c):i.components[u]},directive(u,h){return h?(i.directives[u]=h,c):i.directives[u]},mount(u,h,d){if(!l){const f=c._ceVNode||Se(s,n);return f.appContext=i,d===!0?d="svg":d===!1&&(d=void 0),t(f,u,d),l=!0,c._container=u,u.__vue_app__=c,yn(f.component)}},onUnmount(u){a.push(u)},unmount(){l&&(gt(a,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,h){return i.provides[u]=h,c},runWithContext(u){const h=rr;rr=c;try{return u()}finally{rr=h}}};return c}}let rr=null;const zu=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${Ie(e)}Modifiers`]||t[`${Vt(e)}Modifiers`];function Ju(t,e,...r){if(t.isUnmounted)return;const s=t.vnode.props||ne;let n=r;const i=e.startsWith("update:"),o=i&&zu(s,e.slice(7));o&&(o.trim&&(n=r.map(u=>ue(u)?u.trim():u)),o.number&&(n=r.map(an)));let a,l=s[a=Tn(e)]||s[a=Tn(Ie(e))];!l&&i&&(l=s[a=Tn(Vt(e))]),l&>(l,t,6,n);const c=s[a+"Once"];if(c){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,gt(c,t,6,n)}}const Yu=new WeakMap;function _l(t,e,r=!1){const s=r?Yu:e.emitsCache,n=s.get(t);if(n!==void 0)return n;const i=t.emits;let o={},a=!1;if(!G(t)){const l=c=>{const u=_l(c,e,!0);u&&(a=!0,Ee(o,u))};!r&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!i&&!a?(re(t)&&s.set(t,null),null):(B(i)?i.forEach(l=>o[l]=null):Ee(o,i),re(t)&&s.set(t,o),o)}function gn(t,e){return!t||!tn(e)?!1:(e=e.slice(2).replace(/Once$/,""),te(t,e[0].toLowerCase()+e.slice(1))||te(t,Vt(e))||te(t,e))}function io(t){const{type:e,vnode:r,proxy:s,withProxy:n,propsOptions:[i],slots:o,attrs:a,emit:l,render:c,renderCache:u,props:h,data:d,setupState:f,ctx:m,inheritAttrs:_}=t,A=Fs(t);let E,v;try{if(r.shapeFlag&4){const O=n||s,M=O;E=ht(c.call(M,O,u,h,f,d,m)),v=a}else{const O=e;E=ht(O.length>1?O(h,{attrs:a,slots:o,emit:l}):O(h,null)),v=e.props?a:Xu(a)}}catch(O){Yr.length=0,dn(O,t,1),E=Se(qt)}let b=E;if(v&&_!==!1){const O=Object.keys(v),{shapeFlag:M}=b;O.length&&M&7&&(i&&O.some(rn)&&(v=Qu(v,i)),b=Ar(b,v,!1,!0))}return r.dirs&&(b=Ar(b,null,!1,!0),b.dirs=b.dirs?b.dirs.concat(r.dirs):r.dirs),r.transition&&Ni(b,r.transition),E=b,Fs(A),E}const Xu=t=>{let e;for(const r in t)(r==="class"||r==="style"||tn(r))&&((e||(e={}))[r]=t[r]);return e},Qu=(t,e)=>{const r={};for(const s in t)(!rn(s)||!(s.slice(9)in e))&&(r[s]=t[s]);return r};function Zu(t,e,r){const{props:s,children:n,component:i}=t,{props:o,children:a,patchFlag:l}=e,c=i.emitsOptions;if(e.dirs||e.transition)return!0;if(r&&l>=0){if(l&1024)return!0;if(l&16)return s?oo(s,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let h=0;h<u.length;h++){const d=u[h];if(vl(o,s,d)&&!gn(c,d))return!0}}}else return(n||a)&&(!a||!a.$stable)?!0:s===o?!1:s?o?oo(s,o,c):!0:!!o;return!1}function oo(t,e,r){const s=Object.keys(e);if(s.length!==Object.keys(t).length)return!0;for(let n=0;n<s.length;n++){const i=s[n];if(vl(e,t,i)&&!gn(r,i))return!0}return!1}function vl(t,e,r){const s=t[r],n=e[r];return r==="style"&&re(s)&&re(n)?!xr(s,n):s!==n}function eh({vnode:t,parent:e,suspense:r},s){for(;e;){const n=e.subTree;if(n.suspense&&n.suspense.activeBranch===t&&(n.suspense.vnode.el=n.el=s,t=n),n===t)(t=e.vnode).el=s,e=e.parent;else break}r&&r.activeBranch===t&&(r.vnode.el=s)}const bl={},wl=()=>Object.create(bl),Sl=t=>Object.getPrototypeOf(t)===bl;function th(t,e,r,s=!1){const n={},i=wl();t.propsDefaults=Object.create(null),El(t,e,n,i);for(const o in t.propsOptions[0])o in n||(n[o]=void 0);r?t.props=s?n:Ya(n):t.type.props?t.props=n:t.props=i,t.attrs=i}function rh(t,e,r,s){const{props:n,attrs:i,vnode:{patchFlag:o}}=t,a=Q(n),[l]=t.propsOptions;let c=!1;if((s||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let h=0;h<u.length;h++){let d=u[h];if(gn(t.emitsOptions,d))continue;const f=e[d];if(l)if(te(i,d))f!==i[d]&&(i[d]=f,c=!0);else{const m=Ie(d);n[m]=ei(l,a,m,f,t,!1)}else f!==i[d]&&(i[d]=f,c=!0)}}}else{El(t,e,n,i)&&(c=!0);let u;for(const h in a)(!e||!te(e,h)&&((u=Vt(h))===h||!te(e,u)))&&(l?r&&(r[h]!==void 0||r[u]!==void 0)&&(n[h]=ei(l,a,h,void 0,t,!0)):delete n[h]);if(i!==a)for(const h in i)(!e||!te(e,h))&&(delete i[h],c=!0)}c&&kt(t.attrs,"set","")}function El(t,e,r,s){const[n,i]=t.propsOptions;let o=!1,a;if(e)for(let l in e){if(Fr(l))continue;const c=e[l];let u;n&&te(n,u=Ie(l))?!i||!i.includes(u)?r[u]=c:(a||(a={}))[u]=c:gn(t.emitsOptions,l)||(!(l in s)||c!==s[l])&&(s[l]=c,o=!0)}if(i){const l=Q(r),c=a||ne;for(let u=0;u<i.length;u++){const h=i[u];r[h]=ei(n,l,h,c[h],t,!te(c,h))}}return o}function ei(t,e,r,s,n,i){const o=t[r];if(o!=null){const a=te(o,"default");if(a&&s===void 0){const l=o.default;if(o.type!==Function&&!o.skipFactory&&G(l)){const{propsDefaults:c}=n;if(r in c)s=c[r];else{const u=bs(n);s=c[r]=l.call(null,e),u()}}else s=l;n.ce&&n.ce._setProp(r,s)}o[0]&&(i&&!a?s=!1:o[1]&&(s===""||s===Vt(r))&&(s=!0))}return s}const sh=new WeakMap;function kl(t,e,r=!1){const s=r?sh:e.propsCache,n=s.get(t);if(n)return n;const i=t.props,o={},a=[];let l=!1;if(!G(t)){const u=h=>{l=!0;const[d,f]=kl(h,e,!0);Ee(o,d),f&&a.push(...f)};!r&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!i&&!l)return re(t)&&s.set(t,br),br;if(B(i))for(let u=0;u<i.length;u++){const h=Ie(i[u]);ao(h)&&(o[h]=ne)}else if(i)for(const u in i){const h=Ie(u);if(ao(h)){const d=i[u],f=o[h]=B(d)||G(d)?{type:d}:Ee({},d),m=f.type;let _=!1,A=!0;if(B(m))for(let E=0;E<m.length;++E){const v=m[E],b=G(v)&&v.name;if(b==="Boolean"){_=!0;break}else b==="String"&&(A=!1)}else _=G(m)&&m.name==="Boolean";f[0]=_,f[1]=A,(_||te(f,"default"))&&a.push(h)}}const c=[o,a];return re(t)&&s.set(t,c),c}function ao(t){return t[0]!=="$"&&!Fr(t)}const Li=t=>t==="_"||t==="_ctx"||t==="$stable",$i=t=>B(t)?t.map(ht):[ht(t)],nh=(t,e,r)=>{if(e._n)return e;const s=nl((...n)=>$i(e(...n)),r);return s._c=!1,s},Al=(t,e,r)=>{const s=t._ctx;for(const n in t){if(Li(n))continue;const i=t[n];if(G(i))e[n]=nh(n,i,s);else if(i!=null){const o=$i(i);e[n]=()=>o}}},Tl=(t,e)=>{const r=$i(e);t.slots.default=()=>r},Rl=(t,e,r)=>{for(const s in e)(r||!Li(s))&&(t[s]=e[s])},ih=(t,e,r)=>{const s=t.slots=wl();if(t.vnode.shapeFlag&32){const n=e._;n?(Rl(s,e,r),r&&Ca(s,"_",n,!0)):Al(e,s)}else e&&Tl(t,e)},oh=(t,e,r)=>{const{vnode:s,slots:n}=t;let i=!0,o=ne;if(s.shapeFlag&32){const a=e._;a?r&&a===1?i=!1:Rl(n,e,r):(i=!e.$stable,Al(e,n)),o=e}else e&&(Tl(t,e),o={default:1});if(i)for(const a in n)!Li(a)&&o[a]==null&&delete n[a]},$e=hh;function ah(t){return lh(t)}function lh(t,e){const r=ln();r.__VUE__=!0;const{insert:s,remove:n,patchProp:i,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:h,nextSibling:d,setScopeId:f=pt,insertStaticContent:m}=t,_=(p,g,y,w=null,T=null,S=null,I=void 0,P=null,C=!!g.dynamicChildren)=>{if(p===g)return;p&&!Lr(p,g)&&(w=k(p),Ne(p,T,S,!0),p=null),g.patchFlag===-2&&(C=!1,g.dynamicChildren=null);const{type:R,ref:H,shapeFlag:N}=g;switch(R){case mn:A(p,g,y,w);break;case qt:E(p,g,y,w);break;case jn:p==null&&v(g,y,w,I);break;case ut:De(p,g,y,w,T,S,I,P,C);break;default:N&1?M(p,g,y,w,T,S,I,P,C):N&6?je(p,g,y,w,T,S,I,P,C):(N&64||N&128)&&R.process(p,g,y,w,T,S,I,P,C,D)}H!=null&&T?Gr(H,p&&p.ref,S,g||p,!g):H==null&&p&&p.ref!=null&&Gr(p.ref,null,S,p,!0)},A=(p,g,y,w)=>{if(p==null)s(g.el=a(g.children),y,w);else{const T=g.el=p.el;g.children!==p.children&&c(T,g.children)}},E=(p,g,y,w)=>{p==null?s(g.el=l(g.children||""),y,w):g.el=p.el},v=(p,g,y,w)=>{[p.el,p.anchor]=m(p.children,g,y,w,p.el,p.anchor)},b=({el:p,anchor:g},y,w)=>{let T;for(;p&&p!==g;)T=d(p),s(p,y,w),p=T;s(g,y,w)},O=({el:p,anchor:g})=>{let y;for(;p&&p!==g;)y=d(p),n(p),p=y;n(g)},M=(p,g,y,w,T,S,I,P,C)=>{if(g.type==="svg"?I="svg":g.type==="math"&&(I="mathml"),p==null)W(g,y,w,T,S,I,P,C);else{const R=p.el&&p.el._isVueCE?p.el:null;try{R&&R._beginPatch(),V(p,g,T,S,I,P,C)}finally{R&&R._endPatch()}}},W=(p,g,y,w,T,S,I,P)=>{let C,R;const{props:H,shapeFlag:N,transition:U,dirs:K}=p;if(C=p.el=o(p.type,S,H&&H.is,H),N&8?u(C,p.children):N&16&&J(p.children,C,null,w,T,In(p,S),I,P),K&&Gt(p,null,w,"created"),q(C,p,p.scopeId,I,w),H){for(const se in H)se!=="value"&&!Fr(se)&&i(C,se,null,H[se],S,w);"value"in H&&i(C,"value",null,H.value,S),(R=H.onVnodeBeforeMount)&&it(R,w,p)}K&&Gt(p,null,w,"beforeMount");const X=ch(T,U);X&&U.beforeEnter(C),s(C,g,y),((R=H&&H.onVnodeMounted)||X||K)&&$e(()=>{try{R&&it(R,w,p),X&&U.enter(C),K&&Gt(p,null,w,"mounted")}finally{}},T)},q=(p,g,y,w,T)=>{if(y&&f(p,y),w)for(let S=0;S<w.length;S++)f(p,w[S]);if(T){let S=T.subTree;if(g===S||xl(S.type)&&(S.ssContent===g||S.ssFallback===g)){const I=T.vnode;q(p,I,I.scopeId,I.slotScopeIds,T.parent)}}},J=(p,g,y,w,T,S,I,P,C=0)=>{for(let R=C;R<p.length;R++){const H=p[R]=P?Et(p[R]):ht(p[R]);_(null,H,g,y,w,T,S,I,P)}},V=(p,g,y,w,T,S,I)=>{const P=g.el=p.el;let{patchFlag:C,dynamicChildren:R,dirs:H}=g;C|=p.patchFlag&16;const N=p.props||ne,U=g.props||ne;let K;if(y&&zt(y,!1),(K=U.onVnodeBeforeUpdate)&&it(K,y,g,p),H&&Gt(g,p,y,"beforeUpdate"),y&&zt(y,!0),(N.innerHTML&&U.innerHTML==null||N.textContent&&U.textContent==null)&&u(P,""),R?ce(p.dynamicChildren,R,P,y,w,In(g,T),S):I||Z(p,g,P,null,y,w,In(g,T),S,!1),C>0){if(C&16)Te(P,N,U,y,T);else if(C&2&&N.class!==U.class&&i(P,"class",null,U.class,T),C&4&&i(P,"style",N.style,U.style,T),C&8){const X=g.dynamicProps;for(let se=0;se<X.length;se++){const ie=X[se],pe=N[ie],ve=U[ie];(ve!==pe||ie==="value")&&i(P,ie,pe,ve,T,y)}}C&1&&p.children!==g.children&&u(P,g.children)}else!I&&R==null&&Te(P,N,U,y,T);((K=U.onVnodeUpdated)||H)&&$e(()=>{K&&it(K,y,g,p),H&&Gt(g,p,y,"updated")},w)},ce=(p,g,y,w,T,S,I)=>{for(let P=0;P<g.length;P++){const C=p[P],R=g[P],H=C.el&&(C.type===ut||!Lr(C,R)||C.shapeFlag&198)?h(C.el):y;_(C,R,H,null,w,T,S,I,!0)}},Te=(p,g,y,w,T)=>{if(g!==y){if(g!==ne)for(const S in g)!Fr(S)&&!(S in y)&&i(p,S,g[S],null,T,w);for(const S in y){if(Fr(S))continue;const I=y[S],P=g[S];I!==P&&S!=="value"&&i(p,S,P,I,T,w)}"value"in y&&i(p,"value",g.value,y.value,T)}},De=(p,g,y,w,T,S,I,P,C)=>{const R=g.el=p?p.el:a(""),H=g.anchor=p?p.anchor:a("");let{patchFlag:N,dynamicChildren:U,slotScopeIds:K}=g;K&&(P=P?P.concat(K):K),p==null?(s(R,y,w),s(H,y,w),J(g.children||[],y,H,T,S,I,P,C)):N>0&&N&64&&U&&p.dynamicChildren&&p.dynamicChildren.length===U.length?(ce(p.dynamicChildren,U,y,T,S,I,P),(g.key!=null||T&&g===T.subTree)&&Ol(p,g,!0)):Z(p,g,y,H,T,S,I,P,C)},je=(p,g,y,w,T,S,I,P,C)=>{g.slotScopeIds=P,p==null?g.shapeFlag&512?T.ctx.activate(g,y,w,I,C):Kt(g,y,w,T,S,I,C):Nt(p,g,C)},Kt=(p,g,y,w,T,S,I)=>{const P=p.component=vh(p,w,T);if(ll(p)&&(P.ctx.renderer=D),bh(P,!1,I),P.asyncDep){if(T&&T.registerDep(P,le,I),!p.el){const C=P.subTree=Se(qt);E(null,C,g,y),p.placeholder=C.el}}else le(P,p,g,y,T,S,I)},Nt=(p,g,y)=>{const w=g.component=p.component;if(Zu(p,g,y))if(w.asyncDep&&!w.asyncResolved){z(w,g,y);return}else w.next=g,w.update();else g.el=p.el,w.vnode=g},le=(p,g,y,w,T,S,I)=>{const P=()=>{if(p.isMounted){let{next:N,bu:U,u:K,parent:X,vnode:se}=p;{const st=Cl(p);if(st){N&&(N.el=se.el,z(p,N,I)),st.asyncDep.then(()=>{$e(()=>{p.isUnmounted||R()},T)});return}}let ie=N,pe;zt(p,!1),N?(N.el=se.el,z(p,N,I)):N=se,U&&Ls(U),(pe=N.props&&N.props.onVnodeBeforeUpdate)&&it(pe,X,N,se),zt(p,!0);const ve=io(p),rt=p.subTree;p.subTree=ve,_(rt,ve,h(rt.el),k(rt),p,T,S),N.el=ve.el,ie===null&&eh(p,ve.el),K&&$e(K,T),(pe=N.props&&N.props.onVnodeUpdated)&&$e(()=>it(pe,X,N,se),T)}else{let N;const{el:U,props:K}=g,{bm:X,m:se,parent:ie,root:pe,type:ve}=p,rt=zr(g);zt(p,!1),X&&Ls(X),!rt&&(N=K&&K.onVnodeBeforeMount)&&it(N,ie,g),zt(p,!0);{pe.ce&&pe.ce._hasShadowRoot()&&pe.ce._injectChildStyle(ve,p.parent?p.parent.type:void 0);const st=p.subTree=io(p);_(null,st,y,w,p,T,S),g.el=st.el}if(se&&$e(se,T),!rt&&(N=K&&K.onVnodeMounted)){const st=g;$e(()=>it(N,ie,st),T)}(g.shapeFlag&256||ie&&zr(ie.vnode)&&ie.vnode.shapeFlag&256)&&p.a&&$e(p.a,T),p.isMounted=!0,g=y=w=null}};p.scope.on();const C=p.effect=new $a(P);p.scope.off();const R=p.update=C.run.bind(C),H=p.job=C.runIfDirty.bind(C);H.i=p,H.id=p.uid,C.scheduler=()=>ji(H),zt(p,!0),R()},z=(p,g,y)=>{g.component=p;const w=p.vnode.props;p.vnode=g,p.next=null,rh(p,g.props,w,y),oh(p,g.children,y),Ct(),Xi(p),Pt()},Z=(p,g,y,w,T,S,I,P,C=!1)=>{const R=p&&p.children,H=p?p.shapeFlag:0,N=g.children,{patchFlag:U,shapeFlag:K}=g;if(U>0){if(U&128){Lt(R,N,y,w,T,S,I,P,C);return}else if(U&256){mt(R,N,y,w,T,S,I,P,C);return}}K&8?(H&16&&Ve(R,T,S),N!==R&&u(y,N)):H&16?K&16?Lt(R,N,y,w,T,S,I,P,C):Ve(R,T,S,!0):(H&8&&u(y,""),K&16&&J(N,y,w,T,S,I,P,C))},mt=(p,g,y,w,T,S,I,P,C)=>{p=p||br,g=g||br;const R=p.length,H=g.length,N=Math.min(R,H);let U;for(U=0;U<N;U++){const K=g[U]=C?Et(g[U]):ht(g[U]);_(p[U],K,y,null,T,S,I,P,C)}R>H?Ve(p,T,S,!0,!1,N):J(g,y,w,T,S,I,P,C,N)},Lt=(p,g,y,w,T,S,I,P,C)=>{let R=0;const H=g.length;let N=p.length-1,U=H-1;for(;R<=N&&R<=U;){const K=p[R],X=g[R]=C?Et(g[R]):ht(g[R]);if(Lr(K,X))_(K,X,y,null,T,S,I,P,C);else break;R++}for(;R<=N&&R<=U;){const K=p[N],X=g[U]=C?Et(g[U]):ht(g[U]);if(Lr(K,X))_(K,X,y,null,T,S,I,P,C);else break;N--,U--}if(R>N){if(R<=U){const K=U+1,X=K<H?g[K].el:w;for(;R<=U;)_(null,g[R]=C?Et(g[R]):ht(g[R]),y,X,T,S,I,P,C),R++}}else if(R>U)for(;R<=N;)Ne(p[R],T,S,!0),R++;else{const K=R,X=R,se=new Map;for(R=X;R<=U;R++){const Ue=g[R]=C?Et(g[R]):ht(g[R]);Ue.key!=null&&se.set(Ue.key,R)}let ie,pe=0;const ve=U-X+1;let rt=!1,st=0;const jr=new Array(ve);for(R=0;R<ve;R++)jr[R]=0;for(R=K;R<=N;R++){const Ue=p[R];if(pe>=ve){Ne(Ue,T,S,!0);continue}let nt;if(Ue.key!=null)nt=se.get(Ue.key);else for(ie=X;ie<=U;ie++)if(jr[ie-X]===0&&Lr(Ue,g[ie])){nt=ie;break}nt===void 0?Ne(Ue,T,S,!0):(jr[nt-X]=R+1,nt>=st?st=nt:rt=!0,_(Ue,g[nt],y,null,T,S,I,P,C),pe++)}const qi=rt?uh(jr):br;for(ie=qi.length-1,R=ve-1;R>=0;R--){const Ue=X+R,nt=g[Ue],Vi=g[Ue+1],Ki=Ue+1<H?Vi.el||Pl(Vi):w;jr[R]===0?_(null,nt,y,Ki,T,S,I,P,C):rt&&(ie<0||R!==qi[ie]?tt(nt,y,Ki,2):ie--)}}},tt=(p,g,y,w,T=null)=>{const{el:S,type:I,transition:P,children:C,shapeFlag:R}=p;if(R&6){tt(p.component.subTree,g,y,w);return}if(R&128){p.suspense.move(g,y,w);return}if(R&64){I.move(p,g,y,D);return}if(I===ut){s(S,g,y);for(let N=0;N<C.length;N++)tt(C[N],g,y,w);s(p.anchor,g,y);return}if(I===jn){b(p,g,y);return}if(w!==2&&R&1&&P)if(w===0)P.beforeEnter(S),s(S,g,y),$e(()=>P.enter(S),T);else{const{leave:N,delayLeave:U,afterLeave:K}=P,X=()=>{p.ctx.isUnmounted?n(S):s(S,g,y)},se=()=>{S._isLeaving&&S[Au](!0),N(S,()=>{X(),K&&K()})};U?U(S,X,se):se()}else s(S,g,y)},Ne=(p,g,y,w=!1,T=!1)=>{const{type:S,props:I,ref:P,children:C,dynamicChildren:R,shapeFlag:H,patchFlag:N,dirs:U,cacheIndex:K,memo:X}=p;if(N===-2&&(T=!1),P!=null&&(Ct(),Gr(P,null,y,p,!0),Pt()),K!=null&&(g.renderCache[K]=void 0),H&256){g.ctx.deactivate(p);return}const se=H&1&&U,ie=!zr(p);let pe;if(ie&&(pe=I&&I.onVnodeBeforeUnmount)&&it(pe,g,p),H&6)Wt(p.component,y,w);else{if(H&128){p.suspense.unmount(y,w);return}se&&Gt(p,null,g,"beforeUnmount"),H&64?p.type.remove(p,g,y,D,w):R&&!R.hasOnce&&(S!==ut||N>0&&N&64)?Ve(R,g,y,!1,!0):(S===ut&&N&384||!T&&H&16)&&Ve(C,g,y),w&&nr(p)}const ve=X!=null&&K==null;(ie&&(pe=I&&I.onVnodeUnmounted)||se||ve)&&$e(()=>{pe&&it(pe,g,p),se&&Gt(p,null,g,"unmounted"),ve&&(p.el=null)},y)},nr=p=>{const{type:g,el:y,anchor:w,transition:T}=p;if(g===ut){ir(y,w);return}if(g===jn){O(p);return}const S=()=>{n(y),T&&!T.persisted&&T.afterLeave&&T.afterLeave()};if(p.shapeFlag&1&&T&&!T.persisted){const{leave:I,delayLeave:P}=T,C=()=>I(y,S);P?P(p.el,S,C):C()}else S()},ir=(p,g)=>{let y;for(;p!==g;)y=d(p),n(p),p=y;n(g)},Wt=(p,g,y)=>{const{bum:w,scope:T,job:S,subTree:I,um:P,m:C,a:R}=p;lo(C),lo(R),w&&Ls(w),T.stop(),S&&(S.flags|=8,Ne(I,p,g,y)),P&&$e(P,g),$e(()=>{p.isUnmounted=!0},g)},Ve=(p,g,y,w=!1,T=!1,S=0)=>{for(let I=S;I<p.length;I++)Ne(p[I],g,y,w,T)},k=p=>{if(p.shapeFlag&6)return k(p.component.subTree);if(p.shapeFlag&128)return p.suspense.next();const g=d(p.anchor||p.el),y=g&&g[Eu];return y?d(y):g};let L=!1;const j=(p,g,y)=>{let w;p==null?g._vnode&&(Ne(g._vnode,null,null,!0),w=g._vnode.component):_(g._vnode||null,p,g,null,null,null,y),g._vnode=p,L||(L=!0,Xi(w),tl(),L=!1)},D={p:_,um:Ne,m:tt,r:nr,mt:Kt,mc:J,pc:Z,pbc:ce,n:k,o:t};return{render:j,hydrate:void 0,createApp:Gu(j)}}function In({type:t,props:e},r){return r==="svg"&&t==="foreignObject"||r==="mathml"&&t==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:r}function zt({effect:t,job:e},r){r?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function ch(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Ol(t,e,r=!1){const s=t.children,n=e.children;if(B(s)&&B(n))for(let i=0;i<s.length;i++){const o=s[i];let a=n[i];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=n[i]=Et(n[i]),a.el=o.el),!r&&a.patchFlag!==-2&&Ol(o,a)),a.type===mn&&(a.patchFlag===-1&&(a=n[i]=Et(a)),a.el=o.el),a.type===qt&&!a.el&&(a.el=o.el)}}function uh(t){const e=t.slice(),r=[0];let s,n,i,o,a;const l=t.length;for(s=0;s<l;s++){const c=t[s];if(c!==0){if(n=r[r.length-1],t[n]<c){e[s]=n,r.push(s);continue}for(i=0,o=r.length-1;i<o;)a=i+o>>1,t[r[a]]<c?i=a+1:o=a;c<t[r[i]]&&(i>0&&(e[s]=r[i-1]),r[i]=s)}}for(i=r.length,o=r[i-1];i-- >0;)r[i]=o,o=e[o];return r}function Cl(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Cl(e)}function lo(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}function Pl(t){if(t.placeholder)return t.placeholder;const e=t.component;return e?Pl(e.subTree):null}const xl=t=>t.__isSuspense;function hh(t,e){e&&e.pendingBranch?B(t)?e.effects.push(...t):e.effects.push(t):_u(t)}const ut=Symbol.for("v-fgt"),mn=Symbol.for("v-txt"),qt=Symbol.for("v-cmt"),jn=Symbol.for("v-stc"),Yr=[];let He=null;function sr(t=!1){Yr.push(He=t?null:[])}function dh(){Yr.pop(),He=Yr[Yr.length-1]||null}let is=1;function Ks(t,e=!1){is+=t,t<0&&He&&e&&(He.hasOnce=!0)}function Il(t){return t.dynamicChildren=is>0?He||br:null,dh(),is>0&&He&&He.push(t),t}function Ws(t,e,r,s,n,i){return Il(We(t,e,r,s,n,i,!0))}function Di(t,e,r,s,n){return Il(Se(t,e,r,s,n,!0))}function Gs(t){return t?t.__v_isVNode===!0:!1}function Lr(t,e){return t.type===e.type&&t.key===e.key}const jl=({key:t})=>t??null,Ds=({ref:t,ref_key:e,ref_for:r})=>(typeof t=="number"&&(t=""+t),t!=null?ue(t)||fe(t)||G(t)?{i:Be,r:t,k:e,f:!!r}:t:null);function We(t,e=null,r=null,s=0,n=null,i=t===ut?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&jl(e),ref:e&&Ds(e),scopeId:sl,slotScopeIds:null,children:r,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:s,dynamicProps:n,dynamicChildren:null,appContext:null,ctx:Be};return a?(Ui(l,r),i&128&&t.normalize(l)):r&&(l.shapeFlag|=ue(r)?8:16),is>0&&!o&&He&&(l.patchFlag>0||i&6)&&l.patchFlag!==32&&He.push(l),l}const Se=fh;function fh(t,e=null,r=null,s=0,n=null,i=!1){if((!t||t===fl)&&(t=qt),Gs(t)){const a=Ar(t,e,!0);return r&&Ui(a,r),is>0&&!i&&He&&(a.shapeFlag&6?He[He.indexOf(t)]=a:He.push(a)),a.patchFlag=-2,a}if(Ah(t)&&(t=t.__vccOpts),e){e=ph(e);let{class:a,style:l}=e;a&&!ue(a)&&(e.class=cn(a)),re(l)&&(hn(l)&&!B(l)&&(l=Ee({},l)),e.style=ki(l))}const o=ue(t)?1:xl(t)?128:ku(t)?64:re(t)?4:G(t)?2:0;return We(t,e,r,s,n,o,i,!0)}function ph(t){return t?hn(t)||Sl(t)?Ee({},t):t:null}function Ar(t,e,r=!1,s=!1){const{props:n,ref:i,patchFlag:o,children:a,transition:l}=t,c=e?mh(n||{},e):n,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&jl(c),ref:e&&e.ref?r&&i?B(i)?i.concat(Ds(e)):[i,Ds(e)]:Ds(e):i,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:a,target:t.target,targetStart:t.targetStart,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==ut?o===-1?16:o|16:o,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:l,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&Ar(t.ssContent),ssFallback:t.ssFallback&&Ar(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&s&&Ni(u,l.clone(u)),u}function Nl(t=" ",e=0){return Se(mn,null,t,e)}function gh(t="",e=!1){return e?(sr(),Di(qt,null,t)):Se(qt,null,t)}function ht(t){return t==null||typeof t=="boolean"?Se(qt):B(t)?Se(ut,null,t.slice()):Gs(t)?Et(t):Se(mn,null,String(t))}function Et(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Ar(t)}function Ui(t,e){let r=0;const{shapeFlag:s}=t;if(e==null)e=null;else if(B(e))r=16;else if(typeof e=="object")if(s&65){const n=e.default;n&&(n._c&&(n._d=!1),Ui(t,n()),n._c&&(n._d=!0));return}else{r=32;const n=e._;!n&&!Sl(e)?e._ctx=Be:n===3&&Be&&(Be.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else G(e)?(e={default:e,_ctx:Be},r=32):(e=String(e),s&64?(r=16,e=[Nl(e)]):r=8);t.children=e,t.shapeFlag|=r}function mh(...t){const e={};for(let r=0;r<t.length;r++){const s=t[r];for(const n in s)if(n==="class")e.class!==s.class&&(e.class=cn([e.class,s.class]));else if(n==="style")e.style=ki([e.style,s.style]);else if(tn(n)){const i=e[n],o=s[n];o&&i!==o&&!(B(i)&&i.includes(o))?e[n]=i?[].concat(i,o):o:o==null&&i==null&&!rn(n)&&(e[n]=o)}else n!==""&&(e[n]=s[n])}return e}function it(t,e,r,s=null){gt(t,e,7,[r,s])}const yh=yl();let _h=0;function vh(t,e,r){const s=t.type,n=(e?e.appContext:t.appContext)||yh,i={uid:_h++,vnode:t,type:s,parent:e,appContext:n,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new ja(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(n.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:kl(s,n),emitsOptions:_l(s,n),emit:null,emitted:null,propsDefaults:ne,inheritAttrs:s.inheritAttrs,ctx:ne,data:ne,props:ne,attrs:ne,slots:ne,refs:ne,setupState:ne,setupContext:null,suspense:r,suspenseId:r?r.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return i.ctx={_:i},i.root=e?e.root:i,i.emit=Ju.bind(null,i),t.ce&&t.ce(i),i}let Ae=null;const Ll=()=>Ae||Be;let zs,ti;{const t=ln(),e=(r,s)=>{let n;return(n=t[r])||(n=t[r]=[]),n.push(s),i=>{n.length>1?n.forEach(o=>o(i)):n[0](i)}};zs=e("__VUE_INSTANCE_SETTERS__",r=>Ae=r),ti=e("__VUE_SSR_SETTERS__",r=>os=r)}const bs=t=>{const e=Ae;return zs(t),t.scope.on(),()=>{t.scope.off(),zs(e)}},co=()=>{Ae&&Ae.scope.off(),zs(null)};function $l(t){return t.vnode.shapeFlag&4}let os=!1;function bh(t,e=!1,r=!1){e&&ti(e);const{props:s,children:n}=t.vnode,i=$l(t);th(t,s,i,e),ih(t,n,r||e);const o=i?wh(t,e):void 0;return e&&ti(!1),o}function wh(t,e){const r=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,Bu);const{setup:s}=r;if(s){Ct();const n=t.setupContext=s.length>1?Eh(t):null,i=bs(t),o=_s(s,t,0,[t.props,n]),a=Ta(o);if(Pt(),i(),(a||t.sp)&&!zr(t)&&al(t),a){if(o.then(co,co),e)return o.then(l=>{uo(t,l)}).catch(l=>{dn(l,t,0)});t.asyncDep=o}else uo(t,o)}else Dl(t)}function uo(t,e,r){G(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:re(e)&&(t.setupState=Qa(e)),Dl(t)}function Dl(t,e,r){const s=t.type;t.render||(t.render=s.render||pt);{const n=bs(t);Ct();try{Hu(t)}finally{Pt(),n()}}}const Sh={get(t,e){return ke(t,"get",""),t[e]}};function Eh(t){const e=r=>{t.exposed=r||{}};return{attrs:new Proxy(t.attrs,Sh),slots:t.slots,emit:t.emit,expose:e}}function yn(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(Qa(Ii(t.exposed)),{get(e,r){if(r in e)return e[r];if(r in Jr)return Jr[r](t)},has(e,r){return r in e||r in Jr}})):t.proxy}function kh(t,e=!0){return G(t)?t.displayName||t.name:t.name||e&&t.__name}function Ah(t){return G(t)&&"__vccOpts"in t}const xe=(t,e)=>fu(t,e,os);function as(t,e,r){try{Ks(-1);const s=arguments.length;return s===2?re(e)&&!B(e)?Gs(e)?Se(t,null,[e]):Se(t,e):Se(t,null,e):(s>3?r=Array.prototype.slice.call(arguments,2):s===3&&Gs(r)&&(r=[r]),Se(t,e,r))}finally{Ks(1)}}const Th="3.5.34";/**
|
|
15
15
|
* @vue/runtime-dom v3.5.34
|
|
16
16
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
17
17
|
* @license MIT
|
|
18
|
-
**/let ri;const ho=typeof window<"u"&&window.trustedTypes;if(ho)try{ri=ho.createPolicy("vue",{createHTML:t=>t})}catch{}const Ul=ri?t=>ri.createHTML(t):t=>t,Rh="http://www.w3.org/2000/svg",Oh="http://www.w3.org/1998/Math/MathML",bt=typeof document<"u"?document:null,fo=bt&&bt.createElement("template"),Ch={insert:(t,e,r)=>{e.insertBefore(t,r||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,r,s)=>{const n=e==="svg"?bt.createElementNS(Rh,t):e==="mathml"?bt.createElementNS(Oh,t):r?bt.createElement(t,{is:r}):bt.createElement(t);return t==="select"&&s&&s.multiple!=null&&n.setAttribute("multiple",s.multiple),n},createText:t=>bt.createTextNode(t),createComment:t=>bt.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>bt.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,r,s,n,i){const o=r?r.previousSibling:e.lastChild;if(n&&(n===i||n.nextSibling))for(;e.insertBefore(n.cloneNode(!0),r),!(n===i||!(n=n.nextSibling)););else{fo.innerHTML=Ul(s==="svg"?`<svg>${t}</svg>`:s==="mathml"?`<math>${t}</math>`:t);const a=fo.content;if(s==="svg"||s==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}e.insertBefore(a,r)}return[o?o.nextSibling:e.firstChild,r?r.previousSibling:e.lastChild]}},Ph=Symbol("_vtc");function xh(t,e,r){const s=t[Ph];s&&(e=(e?[e,...s]:[...s]).join(" ")),e==null?t.removeAttribute("class"):r?t.setAttribute("class",e):t.className=e}const po=Symbol("_vod"),Ih=Symbol("_vsh"),jh=Symbol(""),Nh=/(?:^|;)\s*display\s*:/;function
|
|
18
|
+
**/let ri;const ho=typeof window<"u"&&window.trustedTypes;if(ho)try{ri=ho.createPolicy("vue",{createHTML:t=>t})}catch{}const Ul=ri?t=>ri.createHTML(t):t=>t,Rh="http://www.w3.org/2000/svg",Oh="http://www.w3.org/1998/Math/MathML",bt=typeof document<"u"?document:null,fo=bt&&bt.createElement("template"),Ch={insert:(t,e,r)=>{e.insertBefore(t,r||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,r,s)=>{const n=e==="svg"?bt.createElementNS(Rh,t):e==="mathml"?bt.createElementNS(Oh,t):r?bt.createElement(t,{is:r}):bt.createElement(t);return t==="select"&&s&&s.multiple!=null&&n.setAttribute("multiple",s.multiple),n},createText:t=>bt.createTextNode(t),createComment:t=>bt.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>bt.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,r,s,n,i){const o=r?r.previousSibling:e.lastChild;if(n&&(n===i||n.nextSibling))for(;e.insertBefore(n.cloneNode(!0),r),!(n===i||!(n=n.nextSibling)););else{fo.innerHTML=Ul(s==="svg"?`<svg>${t}</svg>`:s==="mathml"?`<math>${t}</math>`:t);const a=fo.content;if(s==="svg"||s==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}e.insertBefore(a,r)}return[o?o.nextSibling:e.firstChild,r?r.previousSibling:e.lastChild]}},Ph=Symbol("_vtc");function xh(t,e,r){const s=t[Ph];s&&(e=(e?[e,...s]:[...s]).join(" ")),e==null?t.removeAttribute("class"):r?t.setAttribute("class",e):t.className=e}const po=Symbol("_vod"),Ih=Symbol("_vsh"),jh=Symbol(""),Nh=/(?:^|;)\s*display\s*:/;function Lh(t,e,r){const s=t.style,n=ue(r);let i=!1;if(r&&!n){if(e)if(ue(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();r[a]==null&&Mr(s,a,"")}else for(const o in e)r[o]==null&&Mr(s,o,"");for(const o in r){o==="display"&&(i=!0);const a=r[o];a!=null?Dh(t,o,!ue(e)&&e?e[o]:void 0,a)||Mr(s,o,a):Mr(s,o,"")}}else if(n){if(e!==r){const o=s[jh];o&&(r+=";"+o),s.cssText=r,i=Nh.test(r)}}else e&&t.removeAttribute("style");po in t&&(t[po]=i?s.display:"",t[Ih]&&(s.display="none"))}const go=/\s*!important$/;function Mr(t,e,r){if(B(r))r.forEach(s=>Mr(t,e,s));else if(r==null&&(r=""),e.startsWith("--"))t.setProperty(e,r);else{const s=$h(t,e);go.test(r)?t.setProperty(Vt(s),r.replace(go,""),"important"):t[s]=r}}const mo=["Webkit","Moz","ms"],Nn={};function $h(t,e){const r=Nn[e];if(r)return r;let s=Ie(e);if(s!=="filter"&&s in t)return Nn[e]=s;s=on(s);for(let n=0;n<mo.length;n++){const i=mo[n]+s;if(i in t)return Nn[e]=i}return e}function Dh(t,e,r,s){return t.tagName==="TEXTAREA"&&(e==="width"||e==="height")&&ue(s)&&r===s}const yo="http://www.w3.org/1999/xlink";function _o(t,e,r,s,n,i=Uc(e)){s&&e.startsWith("xlink:")?r==null?t.removeAttributeNS(yo,e.slice(6,e.length)):t.setAttributeNS(yo,e,r):r==null||i&&!Pa(r)?t.removeAttribute(e):t.setAttribute(e,i?"":ze(r)?String(r):r)}function vo(t,e,r,s,n){if(e==="innerHTML"||e==="textContent"){r!=null&&(t[e]=e==="innerHTML"?Ul(r):r);return}const i=t.tagName;if(e==="value"&&i!=="PROGRESS"&&!i.includes("-")){const a=i==="OPTION"?t.getAttribute("value")||"":t.value,l=r==null?t.type==="checkbox"?"on":"":String(r);(a!==l||!("_value"in t))&&(t.value=l),r==null&&t.removeAttribute(e),t._value=r;return}let o=!1;if(r===""||r==null){const a=typeof t[e];a==="boolean"?r=Pa(r):r==null&&a==="string"?(r="",o=!0):a==="number"&&(r=0,o=!0)}try{t[e]=r}catch{}o&&t.removeAttribute(n||e)}function Bt(t,e,r,s){t.addEventListener(e,r,s)}function Uh(t,e,r,s){t.removeEventListener(e,r,s)}const bo=Symbol("_vei");function Mh(t,e,r,s,n=null){const i=t[bo]||(t[bo]={}),o=i[e];if(s&&o)o.value=s;else{const[a,l]=Bh(e);if(s){const c=i[e]=qh(s,n);Bt(t,a,c,l)}else o&&(Uh(t,a,o,l),i[e]=void 0)}}const wo=/(?:Once|Passive|Capture)$/;function Bh(t){let e;if(wo.test(t)){e={};let s;for(;s=t.match(wo);)t=t.slice(0,t.length-s[0].length),e[s[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):Vt(t.slice(2)),e]}let Ln=0;const Hh=Promise.resolve(),Fh=()=>Ln||(Hh.then(()=>Ln=0),Ln=Date.now());function qh(t,e){const r=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=r.attached)return;gt(Vh(s,r.value),e,5,[s])};return r.value=t,r.attached=Fh(),r}function Vh(t,e){if(B(e)){const r=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{r.call(t),t._stopped=!0},e.map(s=>n=>!n._stopped&&s&&s(n))}else return e}const So=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,Kh=(t,e,r,s,n,i)=>{const o=n==="svg";e==="class"?xh(t,s,o):e==="style"?Lh(t,r,s):tn(e)?rn(e)||Mh(t,e,r,s,i):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Wh(t,e,s,o))?(vo(t,e,s),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&_o(t,e,s,o,i,e!=="value")):t._isVueCE&&(Gh(t,e)||t._def.__asyncLoader&&(/[A-Z]/.test(e)||!ue(s)))?vo(t,Ie(e),s,i,e):(e==="true-value"?t._trueValue=s:e==="false-value"&&(t._falseValue=s),_o(t,e,s,o))};function Wh(t,e,r,s){if(s)return!!(e==="innerHTML"||e==="textContent"||e in t&&So(e)&&G(r));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||e==="sandbox"&&t.tagName==="IFRAME"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const n=t.tagName;if(n==="IMG"||n==="VIDEO"||n==="CANVAS"||n==="SOURCE")return!1}return So(e)&&ue(r)?!1:e in t}function Gh(t,e){const r=t._def.props;if(!r)return!1;const s=Ie(e);return Array.isArray(r)?r.some(n=>Ie(n)===s):Object.keys(r).some(n=>Ie(n)===s)}const Tr=t=>{const e=t.props["onUpdate:modelValue"]||!1;return B(e)?r=>Ls(e,r):e};function zh(t){t.target.composing=!0}function Eo(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const Ot=Symbol("_assign");function ko(t,e,r){return e&&(t=t.trim()),r&&(t=an(t)),t}const Xm={created(t,{modifiers:{lazy:e,trim:r,number:s}},n){t[Ot]=Tr(n);const i=s||n.props&&n.props.type==="number";Bt(t,e?"change":"input",o=>{o.target.composing||t[Ot](ko(t.value,r,i))}),(r||i)&&Bt(t,"change",()=>{t.value=ko(t.value,r,i)}),e||(Bt(t,"compositionstart",zh),Bt(t,"compositionend",Eo),Bt(t,"change",Eo))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:r,modifiers:{lazy:s,trim:n,number:i}},o){if(t[Ot]=Tr(o),t.composing)return;const a=(i||t.type==="number")&&!/^0\d/.test(t.value)?an(t.value):t.value,l=e??"";if(a===l)return;const c=t.getRootNode();(c instanceof Document||c instanceof ShadowRoot)&&c.activeElement===t&&t.type!=="range"&&(s&&e===r||n&&t.value.trim()===l)||(t.value=l)}},Qm={deep:!0,created(t,e,r){t[Ot]=Tr(r),Bt(t,"change",()=>{const s=t._modelValue,n=ls(t),i=t.checked,o=t[Ot];if(B(s)){const a=Ai(s,n),l=a!==-1;if(i&&!l)o(s.concat(n));else if(!i&&l){const c=[...s];c.splice(a,1),o(c)}}else if(Pr(s)){const a=new Set(s);i?a.add(n):a.delete(n),o(a)}else o(Ml(t,i))})},mounted:Ao,beforeUpdate(t,e,r){t[Ot]=Tr(r),Ao(t,e,r)}};function Ao(t,{value:e,oldValue:r},s){t._modelValue=e;let n;if(B(e))n=Ai(e,s.props.value)>-1;else if(Pr(e))n=e.has(s.props.value);else{if(e===r)return;n=xr(e,Ml(t,!0))}t.checked!==n&&(t.checked=n)}const Zm={deep:!0,created(t,{value:e,modifiers:{number:r}},s){const n=Pr(e);Bt(t,"change",()=>{const i=Array.prototype.filter.call(t.options,o=>o.selected).map(o=>r?an(ls(o)):ls(o));t[Ot](t.multiple?n?new Set(i):i:i[0]),t._assigning=!0,fn(()=>{t._assigning=!1})}),t[Ot]=Tr(s)},mounted(t,{value:e}){To(t,e)},beforeUpdate(t,e,r){t[Ot]=Tr(r)},updated(t,{value:e}){t._assigning||To(t,e)}};function To(t,e){const r=t.multiple,s=B(e);if(!(r&&!s&&!Pr(e))){for(let n=0,i=t.options.length;n<i;n++){const o=t.options[n],a=ls(o);if(r)if(s){const l=typeof a;l==="string"||l==="number"?o.selected=e.some(c=>String(c)===String(a)):o.selected=Ai(e,a)>-1}else o.selected=e.has(a);else if(xr(ls(o),e)){t.selectedIndex!==n&&(t.selectedIndex=n);return}}!r&&t.selectedIndex!==-1&&(t.selectedIndex=-1)}}function ls(t){return"_value"in t?t._value:t.value}function Ml(t,e){const r=e?"_trueValue":"_falseValue";return r in t?t[r]:e}const Jh=["ctrl","shift","alt","meta"],Yh={stop:t=>t.stopPropagation(),prevent:t=>t.preventDefault(),self:t=>t.target!==t.currentTarget,ctrl:t=>!t.ctrlKey,shift:t=>!t.shiftKey,alt:t=>!t.altKey,meta:t=>!t.metaKey,left:t=>"button"in t&&t.button!==0,middle:t=>"button"in t&&t.button!==1,right:t=>"button"in t&&t.button!==2,exact:(t,e)=>Jh.some(r=>t[`${r}Key`]&&!e.includes(r))},ey=(t,e)=>{if(!t)return t;const r=t._withMods||(t._withMods={}),s=e.join(".");return r[s]||(r[s]=((n,...i)=>{for(let o=0;o<e.length;o++){const a=Yh[e[o]];if(a&&a(n,e))return}return t(n,...i)}))},Xh={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},ty=(t,e)=>{const r=t._withKeys||(t._withKeys={}),s=e.join(".");return r[s]||(r[s]=(n=>{if(!("key"in n))return;const i=Vt(n.key);if(e.some(o=>o===i||Xh[o]===i))return t(n)}))},Qh=Ee({patchProp:Kh},Ch);let Ro;function Zh(){return Ro||(Ro=ah(Qh))}const ed=((...t)=>{const e=Zh().createApp(...t),{mount:r}=e;return e.mount=s=>{const n=rd(s);if(!n)return;const i=e._component;!G(i)&&!i.render&&!i.template&&(i.template=n.innerHTML),n.nodeType===1&&(n.textContent="");const o=r(n,!1,td(n));return n instanceof Element&&(n.removeAttribute("v-cloak"),n.setAttribute("data-v-app","")),o},e});function td(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function rd(t){return ue(t)?document.querySelector(t):t}/*!
|
|
19
19
|
* pinia v3.0.4
|
|
20
20
|
* (c) 2025 Eduardo San Martin Morote
|
|
21
21
|
* @license MIT
|
|
22
|
-
*/let
|
|
22
|
+
*/let Bl;const _n=t=>Bl=t,Hl=Symbol();function si(t){return t&&typeof t=="object"&&Object.prototype.toString.call(t)==="[object Object]"&&typeof t.toJSON!="function"}var Xr;(function(t){t.direct="direct",t.patchObject="patch object",t.patchFunction="patch function"})(Xr||(Xr={}));function sd(){const t=Na(!0),e=t.run(()=>Kr({}));let r=[],s=[];const n=Ii({install(i){_n(n),n._a=i,i.provide(Hl,n),i.config.globalProperties.$pinia=n,s.forEach(o=>r.push(o)),s=[]},use(i){return this._a?r.push(i):s.push(i),this},_p:r,_a:null,_e:t,_s:new Map,state:e});return n}const Fl=()=>{};function Oo(t,e,r,s=Fl){t.add(e);const n=()=>{t.delete(e)&&s()};return!r&&La()&&Bc(n),n}function ar(t,...e){t.forEach(r=>{r(...e)})}const nd=t=>t(),Co=Symbol(),$n=Symbol();function ni(t,e){t instanceof Map&&e instanceof Map?e.forEach((r,s)=>t.set(s,r)):t instanceof Set&&e instanceof Set&&e.forEach(t.add,t);for(const r in e){if(!e.hasOwnProperty(r))continue;const s=e[r],n=t[r];si(n)&&si(s)&&t.hasOwnProperty(r)&&!fe(s)&&!Tt(s)?t[r]=ni(n,s):t[r]=s}return t}const id=Symbol();function od(t){return!si(t)||!Object.prototype.hasOwnProperty.call(t,id)}const{assign:Dt}=Object;function ad(t){return!!(fe(t)&&t.effect)}function ld(t,e,r,s){const{state:n,actions:i,getters:o}=e,a=r.state.value[t];let l;function c(){a||(r.state.value[t]=n?n():{});const u=cu(r.state.value[t]);return Dt(u,i,Object.keys(o||{}).reduce((h,d)=>(h[d]=Ii(xe(()=>{_n(r);const f=r._s.get(t);return o[d].call(f,f)})),h),{}))}return l=ql(t,c,e,r,s,!0),l}function ql(t,e,r={},s,n,i){let o;const a=Dt({actions:{}},r),l={deep:!0};let c,u,h=new Set,d=new Set,f;const m=s.state.value[t];!i&&!m&&(s.state.value[t]={});let _;function A(J){let V;c=u=!1,typeof J=="function"?(J(s.state.value[t]),V={type:Xr.patchFunction,storeId:t,events:f}):(ni(s.state.value[t],J),V={type:Xr.patchObject,payload:J,storeId:t,events:f});const ce=_=Symbol();fn().then(()=>{_===ce&&(c=!0)}),u=!0,ar(h,V,s.state.value[t])}const E=i?function(){const{state:V}=r,ce=V?V():{};this.$patch(Te=>{Dt(Te,ce)})}:Fl;function v(){o.stop(),h.clear(),d.clear(),s._s.delete(t)}const b=(J,V="")=>{if(Co in J)return J[$n]=V,J;const ce=function(){_n(s);const Te=Array.from(arguments),De=new Set,je=new Set;function Kt(z){De.add(z)}function Nt(z){je.add(z)}ar(d,{args:Te,name:ce[$n],store:M,after:Kt,onError:Nt});let le;try{le=J.apply(this&&this.$id===t?this:M,Te)}catch(z){throw ar(je,z),z}return le instanceof Promise?le.then(z=>(ar(De,z),z)).catch(z=>(ar(je,z),Promise.reject(z))):(ar(De,le),le)};return ce[Co]=!0,ce[$n]=V,ce},O={_p:s,$id:t,$onAction:Oo.bind(null,d),$patch:A,$reset:E,$subscribe(J,V={}){const ce=Oo(h,J,V.detached,()=>Te()),Te=o.run(()=>Wr(()=>s.state.value[t],De=>{(V.flush==="sync"?u:c)&&J({storeId:t,type:Xr.direct,events:f},De)},Dt({},l,V)));return ce},$dispose:v},M=ys(O);s._s.set(t,M);const q=(s._a&&s._a.runWithContext||nd)(()=>s._e.run(()=>(o=Na()).run(()=>e({action:b}))));for(const J in q){const V=q[J];if(fe(V)&&!ad(V)||Tt(V))i||(m&&od(V)&&(fe(V)?V.value=m[J]:ni(V,m[J])),s.state.value[t][J]=V);else if(typeof V=="function"){const ce=b(V,J);q[J]=ce,a.actions[J]=V}}return Dt(M,q),Dt(Q(M),q),Object.defineProperty(M,"$state",{get:()=>s.state.value[t],set:J=>{A(V=>{Dt(V,J)})}}),s._p.forEach(J=>{Dt(M,o.run(()=>J({store:M,app:s._a,pinia:s,options:a})))}),m&&i&&r.hydrate&&r.hydrate(M.$state,m),c=!0,u=!0,M}/*! #__NO_SIDE_EFFECTS__ */function cd(t,e,r){let s;const n=typeof e=="function";s=n?r:e;function i(o,a){const l=vu();return o=o||(l?Ge(Hl,null):null),o&&_n(o),o=Bl,o._s.has(t)||(n?ql(t,e,s,o):ld(t,s,o)),o._s.get(t)}return i.$id=t,i}/*!
|
|
23
23
|
* vue-router v4.6.4
|
|
24
24
|
* (c) 2025 Eduardo San Martin Morote
|
|
25
25
|
* @license MIT
|
|
26
|
-
*/const
|
|
26
|
+
*/const pr=typeof document<"u";function Vl(t){return typeof t=="object"||"displayName"in t||"props"in t||"__vccOpts"in t}function ud(t){return t.__esModule||t[Symbol.toStringTag]==="Module"||t.default&&Vl(t.default)}const ee=Object.assign;function Dn(t,e){const r={};for(const s in e){const n=e[s];r[s]=et(n)?n.map(t):t(n)}return r}const Qr=()=>{},et=Array.isArray;function Po(t,e){const r={};for(const s in t)r[s]=s in e?e[s]:t[s];return r}const Kl=/#/g,hd=/&/g,dd=/\//g,fd=/=/g,pd=/\?/g,Wl=/\+/g,gd=/%5B/g,md=/%5D/g,Gl=/%5E/g,yd=/%60/g,zl=/%7B/g,_d=/%7C/g,Jl=/%7D/g,vd=/%20/g;function Mi(t){return t==null?"":encodeURI(""+t).replace(_d,"|").replace(gd,"[").replace(md,"]")}function bd(t){return Mi(t).replace(zl,"{").replace(Jl,"}").replace(Gl,"^")}function ii(t){return Mi(t).replace(Wl,"%2B").replace(vd,"+").replace(Kl,"%23").replace(hd,"%26").replace(yd,"`").replace(zl,"{").replace(Jl,"}").replace(Gl,"^")}function wd(t){return ii(t).replace(fd,"%3D")}function Sd(t){return Mi(t).replace(Kl,"%23").replace(pd,"%3F")}function Ed(t){return Sd(t).replace(dd,"%2F")}function cs(t){if(t==null)return null;try{return decodeURIComponent(""+t)}catch{}return""+t}const kd=/\/$/,Ad=t=>t.replace(kd,"");function Un(t,e,r="/"){let s,n={},i="",o="";const a=e.indexOf("#");let l=e.indexOf("?");return l=a>=0&&l>a?-1:l,l>=0&&(s=e.slice(0,l),i=e.slice(l,a>0?a:e.length),n=t(i.slice(1))),a>=0&&(s=s||e.slice(0,a),o=e.slice(a,e.length)),s=Cd(s??e,r),{fullPath:s+i+o,path:s,query:n,hash:cs(o)}}function Td(t,e){const r=e.query?t(e.query):"";return e.path+(r&&"?")+r+(e.hash||"")}function xo(t,e){return!e||!t.toLowerCase().startsWith(e.toLowerCase())?t:t.slice(e.length)||"/"}function Rd(t,e,r){const s=e.matched.length-1,n=r.matched.length-1;return s>-1&&s===n&&Rr(e.matched[s],r.matched[n])&&Yl(e.params,r.params)&&t(e.query)===t(r.query)&&e.hash===r.hash}function Rr(t,e){return(t.aliasOf||t)===(e.aliasOf||e)}function Yl(t,e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(var r in t)if(!Od(t[r],e[r]))return!1;return!0}function Od(t,e){return et(t)?Io(t,e):et(e)?Io(e,t):(t==null?void 0:t.valueOf())===(e==null?void 0:e.valueOf())}function Io(t,e){return et(e)?t.length===e.length&&t.every((r,s)=>r===e[s]):t.length===1&&t[0]===e}function Cd(t,e){if(t.startsWith("/"))return t;if(!t)return e;const r=e.split("/"),s=t.split("/"),n=s[s.length-1];(n===".."||n===".")&&s.push("");let i=r.length-1,o,a;for(o=0;o<s.length;o++)if(a=s[o],a!==".")if(a==="..")i>1&&i--;else break;return r.slice(0,i).join("/")+"/"+s.slice(o).join("/")}const $t={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};let oi=(function(t){return t.pop="pop",t.push="push",t})({}),Mn=(function(t){return t.back="back",t.forward="forward",t.unknown="",t})({});function Pd(t){if(!t)if(pr){const e=document.querySelector("base");t=e&&e.getAttribute("href")||"/",t=t.replace(/^\w+:\/\/[^\/]+/,"")}else t="/";return t[0]!=="/"&&t[0]!=="#"&&(t="/"+t),Ad(t)}const xd=/^[^#]+#/;function Id(t,e){return t.replace(xd,"#")+e}function jd(t,e){const r=document.documentElement.getBoundingClientRect(),s=t.getBoundingClientRect();return{behavior:e.behavior,left:s.left-r.left-(e.left||0),top:s.top-r.top-(e.top||0)}}const vn=()=>({left:window.scrollX,top:window.scrollY});function Nd(t){let e;if("el"in t){const r=t.el,s=typeof r=="string"&&r.startsWith("#"),n=typeof r=="string"?s?document.getElementById(r.slice(1)):document.querySelector(r):r;if(!n)return;e=jd(n,t)}else e=t;"scrollBehavior"in document.documentElement.style?window.scrollTo(e):window.scrollTo(e.left!=null?e.left:window.scrollX,e.top!=null?e.top:window.scrollY)}function jo(t,e){return(history.state?history.state.position-e:-1)+t}const ai=new Map;function Ld(t,e){ai.set(t,e)}function $d(t){const e=ai.get(t);return ai.delete(t),e}function Dd(t){return typeof t=="string"||t&&typeof t=="object"}function Xl(t){return typeof t=="string"||typeof t=="symbol"}let he=(function(t){return t[t.MATCHER_NOT_FOUND=1]="MATCHER_NOT_FOUND",t[t.NAVIGATION_GUARD_REDIRECT=2]="NAVIGATION_GUARD_REDIRECT",t[t.NAVIGATION_ABORTED=4]="NAVIGATION_ABORTED",t[t.NAVIGATION_CANCELLED=8]="NAVIGATION_CANCELLED",t[t.NAVIGATION_DUPLICATED=16]="NAVIGATION_DUPLICATED",t})({});const Ql=Symbol("");he.MATCHER_NOT_FOUND+"",he.NAVIGATION_GUARD_REDIRECT+"",he.NAVIGATION_ABORTED+"",he.NAVIGATION_CANCELLED+"",he.NAVIGATION_DUPLICATED+"";function Or(t,e){return ee(new Error,{type:t,[Ql]:!0},e)}function _t(t,e){return t instanceof Error&&Ql in t&&(e==null||!!(t.type&e))}const Ud=["params","query","hash"];function Md(t){if(typeof t=="string")return t;if(t.path!=null)return t.path;const e={};for(const r of Ud)r in t&&(e[r]=t[r]);return JSON.stringify(e,null,2)}function Bd(t){const e={};if(t===""||t==="?")return e;const r=(t[0]==="?"?t.slice(1):t).split("&");for(let s=0;s<r.length;++s){const n=r[s].replace(Wl," "),i=n.indexOf("="),o=cs(i<0?n:n.slice(0,i)),a=i<0?null:cs(n.slice(i+1));if(o in e){let l=e[o];et(l)||(l=e[o]=[l]),l.push(a)}else e[o]=a}return e}function No(t){let e="";for(let r in t){const s=t[r];if(r=wd(r),s==null){s!==void 0&&(e+=(e.length?"&":"")+r);continue}(et(s)?s.map(n=>n&&ii(n)):[s&&ii(s)]).forEach(n=>{n!==void 0&&(e+=(e.length?"&":"")+r,n!=null&&(e+="="+n))})}return e}function Hd(t){const e={};for(const r in t){const s=t[r];s!==void 0&&(e[r]=et(s)?s.map(n=>n==null?null:""+n):s==null?s:""+s)}return e}const Fd=Symbol(""),Lo=Symbol(""),bn=Symbol(""),Bi=Symbol(""),li=Symbol("");function $r(){let t=[];function e(s){return t.push(s),()=>{const n=t.indexOf(s);n>-1&&t.splice(n,1)}}function r(){t=[]}return{add:e,list:()=>t.slice(),reset:r}}function Mt(t,e,r,s,n,i=o=>o()){const o=s&&(s.enterCallbacks[n]=s.enterCallbacks[n]||[]);return()=>new Promise((a,l)=>{const c=d=>{d===!1?l(Or(he.NAVIGATION_ABORTED,{from:r,to:e})):d instanceof Error?l(d):Dd(d)?l(Or(he.NAVIGATION_GUARD_REDIRECT,{from:e,to:d})):(o&&s.enterCallbacks[n]===o&&typeof d=="function"&&o.push(d),a())},u=i(()=>t.call(s&&s.instances[n],e,r,c));let h=Promise.resolve(u);t.length<3&&(h=h.then(c)),h.catch(d=>l(d))})}function Bn(t,e,r,s,n=i=>i()){const i=[];for(const o of t)for(const a in o.components){let l=o.components[a];if(!(e!=="beforeRouteEnter"&&!o.instances[a]))if(Vl(l)){const c=(l.__vccOpts||l)[e];c&&i.push(Mt(c,r,s,o,a,n))}else{let c=l();i.push(()=>c.then(u=>{if(!u)throw new Error(`Couldn't resolve component "${a}" at "${o.path}"`);const h=ud(u)?u.default:u;o.mods[a]=u,o.components[a]=h;const d=(h.__vccOpts||h)[e];return d&&Mt(d,r,s,o,a,n)()}))}}return i}function qd(t,e){const r=[],s=[],n=[],i=Math.max(e.matched.length,t.matched.length);for(let o=0;o<i;o++){const a=e.matched[o];a&&(t.matched.find(c=>Rr(c,a))?s.push(a):r.push(a));const l=t.matched[o];l&&(e.matched.find(c=>Rr(c,l))||n.push(l))}return[r,s,n]}/*!
|
|
27
27
|
* vue-router v4.6.4
|
|
28
28
|
* (c) 2025 Eduardo San Martin Morote
|
|
29
29
|
* @license MIT
|
|
30
|
-
*/let Vd=()=>location.protocol+"//"+location.host;function Zl(t,e){const{pathname:r,search:s,hash:n}=e,i=t.indexOf("#");if(i>-1){let o=n.includes(t.slice(i))?t.slice(i).length:1,a=n.slice(o);return a[0]!=="/"&&(a="/"+a),xo(a,"")}return xo(r,t)+s+n}function Kd(t,e,r,s){let n=[],i=[],o=null;const a=({state:d})=>{const f=Zl(t,location),m=r.value,v=e.value;let A=0;if(d){if(r.value=f,e.value=d,o&&o===m){o=null;return}A=v?d.position-v.position:0}else s(f);n.forEach(E=>{E(r.value,m,{delta:A,type:oi.pop,direction:A?A>0?Un.forward:Un.back:Un.unknown})})};function l(){o=r.value}function c(d){n.push(d);const f=()=>{const m=n.indexOf(d);m>-1&&n.splice(m,1)};return i.push(f),f}function u(){if(document.visibilityState==="hidden"){const{history:d}=window;if(!d.state)return;d.replaceState(ee({},d.state,{scroll:vn()}),"")}}function h(){for(const d of i)d();i=[],window.removeEventListener("popstate",a),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",u)}return window.addEventListener("popstate",a),window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",u),{pauseListeners:l,listen:c,destroy:h}}function Lo(t,e,r,s=!1,n=!1){return{back:t,current:e,forward:r,replaced:s,position:window.history.length,scroll:n?vn():null}}function Wd(t){const{history:e,location:r}=window,s={value:Zl(t,r)},n={value:e.state};n.value||i(s.value,{back:null,current:s.value,forward:null,position:e.length-1,replaced:!0,scroll:null},!0);function i(l,c,u){const h=t.indexOf("#"),d=h>-1?(r.host&&document.querySelector("base")?t:t.slice(h))+l:Vd()+t+l;try{e[u?"replaceState":"pushState"](c,"",d),n.value=c}catch(f){console.error(f),r[u?"replace":"assign"](d)}}function o(l,c){i(l,ee({},e.state,Lo(n.value.back,l,n.value.forward,!0),c,{position:n.value.position}),!0),s.value=l}function a(l,c){const u=ee({},n.value,e.state,{forward:l,scroll:vn()});i(u.current,u,!0),i(l,ee({},Lo(s.value,l,null),{position:u.position+1},c),!1),s.value=l}return{location:s,state:n,push:a,replace:o}}function Gd(t){t=Pd(t);const e=Wd(t),r=Kd(t,e.state,e.location,e.replace);function s(i,o=!0){o||r.pauseListeners(),history.go(i)}const n=ee({location:"",base:t,go:s,createHref:Id.bind(null,t)},e,r);return Object.defineProperty(n,"location",{enumerable:!0,get:()=>e.location.value}),Object.defineProperty(n,"state",{enumerable:!0,get:()=>e.state.value}),n}let Zt=(function(t){return t[t.Static=0]="Static",t[t.Param=1]="Param",t[t.Group=2]="Group",t})({});var me=(function(t){return t[t.Static=0]="Static",t[t.Param=1]="Param",t[t.ParamRegExp=2]="ParamRegExp",t[t.ParamRegExpEnd=3]="ParamRegExpEnd",t[t.EscapeNext=4]="EscapeNext",t})(me||{});const zd={type:Zt.Static,value:""},Jd=/[a-zA-Z0-9_]/;function Yd(t){if(!t)return[[]];if(t==="/")return[[zd]];if(!t.startsWith("/"))throw new Error(`Invalid path "${t}"`);function e(f){throw new Error(`ERR (${r})/"${c}": ${f}`)}let r=me.Static,s=r;const n=[];let i;function o(){i&&n.push(i),i=[]}let a=0,l,c="",u="";function h(){c&&(r===me.Static?i.push({type:Zt.Static,value:c}):r===me.Param||r===me.ParamRegExp||r===me.ParamRegExpEnd?(i.length>1&&(l==="*"||l==="+")&&e(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),i.push({type:Zt.Param,value:c,regexp:u,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):e("Invalid state to consume buffer"),c="")}function d(){c+=l}for(;a<t.length;){if(l=t[a++],l==="\\"&&r!==me.ParamRegExp){s=r,r=me.EscapeNext;continue}switch(r){case me.Static:l==="/"?(c&&h(),o()):l===":"?(h(),r=me.Param):d();break;case me.EscapeNext:d(),r=s;break;case me.Param:l==="("?r=me.ParamRegExp:Jd.test(l)?d():(h(),r=me.Static,l!=="*"&&l!=="?"&&l!=="+"&&a--);break;case me.ParamRegExp:l===")"?u[u.length-1]=="\\"?u=u.slice(0,-1)+l:r=me.ParamRegExpEnd:u+=l;break;case me.ParamRegExpEnd:h(),r=me.Static,l!=="*"&&l!=="?"&&l!=="+"&&a--,u="";break;default:e("Unknown state");break}}return r===me.ParamRegExp&&e(`Unfinished custom RegExp for param "${c}"`),h(),o(),n}const Do="[^/]+?",Xd={sensitive:!1,strict:!1,start:!0,end:!0};var Oe=(function(t){return t[t._multiplier=10]="_multiplier",t[t.Root=90]="Root",t[t.Segment=40]="Segment",t[t.SubSegment=30]="SubSegment",t[t.Static=40]="Static",t[t.Dynamic=20]="Dynamic",t[t.BonusCustomRegExp=10]="BonusCustomRegExp",t[t.BonusWildcard=-50]="BonusWildcard",t[t.BonusRepeatable=-20]="BonusRepeatable",t[t.BonusOptional=-8]="BonusOptional",t[t.BonusStrict=.7000000000000001]="BonusStrict",t[t.BonusCaseSensitive=.25]="BonusCaseSensitive",t})(Oe||{});const Qd=/[.+*?^${}()[\]/\\]/g;function Zd(t,e){const r=ee({},Xd,e),s=[];let n=r.start?"^":"";const i=[];for(const c of t){const u=c.length?[]:[Oe.Root];r.strict&&!c.length&&(n+="/");for(let h=0;h<c.length;h++){const d=c[h];let f=Oe.Segment+(r.sensitive?Oe.BonusCaseSensitive:0);if(d.type===Zt.Static)h||(n+="/"),n+=d.value.replace(Qd,"\\$&"),f+=Oe.Static;else if(d.type===Zt.Param){const{value:m,repeatable:v,optional:A,regexp:E}=d;i.push({name:m,repeatable:v,optional:A});const _=E||Do;if(_!==Do){f+=Oe.BonusCustomRegExp;try{`${_}`}catch(O){throw new Error(`Invalid custom RegExp for param "${m}" (${_}): `+O.message)}}let b=v?`((?:${_})(?:/(?:${_}))*)`:`(${_})`;h||(b=A&&c.length<2?`(?:/${b})`:"/"+b),A&&(b+="?"),n+=b,f+=Oe.Dynamic,A&&(f+=Oe.BonusOptional),v&&(f+=Oe.BonusRepeatable),_===".*"&&(f+=Oe.BonusWildcard)}u.push(f)}s.push(u)}if(r.strict&&r.end){const c=s.length-1;s[c][s[c].length-1]+=Oe.BonusStrict}r.strict||(n+="/?"),r.end?n+="$":r.strict&&!n.endsWith("/")&&(n+="(?:/|$)");const o=new RegExp(n,r.sensitive?"":"i");function a(c){const u=c.match(o),h={};if(!u)return null;for(let d=1;d<u.length;d++){const f=u[d]||"",m=i[d-1];h[m.name]=f&&m.repeatable?f.split("/"):f}return h}function l(c){let u="",h=!1;for(const d of t){(!h||!u.endsWith("/"))&&(u+="/"),h=!1;for(const f of d)if(f.type===Zt.Static)u+=f.value;else if(f.type===Zt.Param){const{value:m,repeatable:v,optional:A}=f,E=m in c?c[m]:"";if(et(E)&&!v)throw new Error(`Provided param "${m}" is an array but it is not repeatable (* or + modifiers)`);const _=et(E)?E.join("/"):E;if(!_)if(A)d.length<2&&(u.endsWith("/")?u=u.slice(0,-1):h=!0);else throw new Error(`Missing required param "${m}"`);u+=_}}return u||"/"}return{re:o,score:s,keys:i,parse:a,stringify:l}}function ef(t,e){let r=0;for(;r<t.length&&r<e.length;){const s=e[r]-t[r];if(s)return s;r++}return t.length<e.length?t.length===1&&t[0]===Oe.Static+Oe.Segment?-1:1:t.length>e.length?e.length===1&&e[0]===Oe.Static+Oe.Segment?1:-1:0}function ec(t,e){let r=0;const s=t.score,n=e.score;for(;r<s.length&&r<n.length;){const i=ef(s[r],n[r]);if(i)return i;r++}if(Math.abs(n.length-s.length)===1){if(Uo(s))return 1;if(Uo(n))return-1}return n.length-s.length}function Uo(t){const e=t[t.length-1];return t.length>0&&e[e.length-1]<0}const tf={strict:!1,end:!0,sensitive:!1};function rf(t,e,r){const s=Zd(Yd(t.path),r),n=ee(s,{record:t,parent:e,children:[],alias:[]});return e&&!n.record.aliasOf==!e.record.aliasOf&&e.children.push(n),n}function sf(t,e){const r=[],s=new Map;e=Po(tf,e);function n(h){return s.get(h)}function i(h,d,f){const m=!f,v=Mo(h);v.aliasOf=f&&f.record;const A=Po(e,h),E=[v];if("alias"in h){const O=typeof h.alias=="string"?[h.alias]:h.alias;for(const B of O)E.push(Mo(ee({},v,{components:f?f.record.components:v.components,path:B,aliasOf:f?f.record:v})))}let _,b;for(const O of E){const{path:B}=O;if(d&&B[0]!=="/"){const W=d.record.path,q=W[W.length-1]==="/"?"":"/";O.path=d.record.path+(B&&q+B)}if(_=rf(O,d,A),f?f.alias.push(_):(b=b||_,b!==_&&b.alias.push(_),m&&h.name&&!Ho(_)&&o(h.name)),tc(_)&&l(_),v.children){const W=v.children;for(let q=0;q<W.length;q++)i(W[q],_,f&&f.children[q])}f=f||_}return b?()=>{o(b)}:Qr}function o(h){if(Xl(h)){const d=s.get(h);d&&(s.delete(h),r.splice(r.indexOf(d),1),d.children.forEach(o),d.alias.forEach(o))}else{const d=r.indexOf(h);d>-1&&(r.splice(d,1),h.record.name&&s.delete(h.record.name),h.children.forEach(o),h.alias.forEach(o))}}function a(){return r}function l(h){const d=af(h,r);r.splice(d,0,h),h.record.name&&!Ho(h)&&s.set(h.record.name,h)}function c(h,d){let f,m={},v,A;if("name"in h&&h.name){if(f=s.get(h.name),!f)throw Or(he.MATCHER_NOT_FOUND,{location:h});A=f.record.name,m=ee(Bo(d.params,f.keys.filter(b=>!b.optional).concat(f.parent?f.parent.keys.filter(b=>b.optional):[]).map(b=>b.name)),h.params&&Bo(h.params,f.keys.map(b=>b.name))),v=f.stringify(m)}else if(h.path!=null)v=h.path,f=r.find(b=>b.re.test(v)),f&&(m=f.parse(v),A=f.record.name);else{if(f=d.name?s.get(d.name):r.find(b=>b.re.test(d.path)),!f)throw Or(he.MATCHER_NOT_FOUND,{location:h,currentLocation:d});A=f.record.name,m=ee({},d.params,h.params),v=f.stringify(m)}const E=[];let _=f;for(;_;)E.unshift(_.record),_=_.parent;return{name:A,path:v,params:m,matched:E,meta:of(E)}}t.forEach(h=>i(h));function u(){r.length=0,s.clear()}return{addRoute:i,resolve:c,removeRoute:o,clearRoutes:u,getRoutes:a,getRecordMatcher:n}}function Bo(t,e){const r={};for(const s of e)s in t&&(r[s]=t[s]);return r}function Mo(t){const e={path:t.path,redirect:t.redirect,name:t.name,meta:t.meta||{},aliasOf:t.aliasOf,beforeEnter:t.beforeEnter,props:nf(t),children:t.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in t?t.components||null:t.component&&{default:t.component}};return Object.defineProperty(e,"mods",{value:{}}),e}function nf(t){const e={},r=t.props||!1;if("component"in t)e.default=r;else for(const s in t.components)e[s]=typeof r=="object"?r[s]:r;return e}function Ho(t){for(;t;){if(t.record.aliasOf)return!0;t=t.parent}return!1}function of(t){return t.reduce((e,r)=>ee(e,r.meta),{})}function af(t,e){let r=0,s=e.length;for(;r!==s;){const i=r+s>>1;ec(t,e[i])<0?s=i:r=i+1}const n=lf(t);return n&&(s=e.lastIndexOf(n,s-1)),s}function lf(t){let e=t;for(;e=e.parent;)if(tc(e)&&ec(t,e)===0)return e}function tc({record:t}){return!!(t.name||t.components&&Object.keys(t.components).length||t.redirect)}function Fo(t){const e=Ve(_n),r=Ve(Mi),s=$e(()=>{const l=Xe(t.to);return e.resolve(l)}),n=$e(()=>{const{matched:l}=s.value,{length:c}=l,u=l[c-1],h=r.matched;if(!u||!h.length)return-1;const d=h.findIndex(Rr.bind(null,u));if(d>-1)return d;const f=qo(l[c-2]);return c>1&&qo(u)===f&&h[h.length-1].path!==f?h.findIndex(Rr.bind(null,l[c-2])):d}),i=$e(()=>n.value>-1&&ff(r.params,s.value.params)),o=$e(()=>n.value>-1&&n.value===r.matched.length-1&&Yl(r.params,s.value.params));function a(l={}){if(df(l)){const c=e[Xe(t.replace)?"replace":"push"](Xe(t.to)).catch(Qr);return t.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>c),c}return Promise.resolve()}return{route:s,href:$e(()=>s.value.href),isActive:i,isExactActive:o,navigate:a}}function cf(t){return t.length===1?t[0]:t}const uf=dn({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:Fo,setup(t,{slots:e}){const r=ys(Fo(t)),{options:s}=Ve(_n),n=$e(()=>({[Vo(t.activeClass,s.linkActiveClass,"router-link-active")]:r.isActive,[Vo(t.exactActiveClass,s.linkExactActiveClass,"router-link-exact-active")]:r.isExactActive}));return()=>{const i=e.default&&cf(e.default(r));return t.custom?i:as("a",{"aria-current":r.isExactActive?t.ariaCurrentValue:null,href:r.href,onClick:r.navigate,class:n.value},i)}}}),hf=uf;function df(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&!(t.button!==void 0&&t.button!==0)){if(t.currentTarget&&t.currentTarget.getAttribute){const e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function ff(t,e){for(const r in e){const s=e[r],n=t[r];if(typeof s=="string"){if(s!==n)return!1}else if(!et(n)||n.length!==s.length||s.some((i,o)=>i.valueOf()!==n[o].valueOf()))return!1}return!0}function qo(t){return t?t.aliasOf?t.aliasOf.path:t.path:""}const Vo=(t,e,r)=>t??e??r,pf=dn({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(t,{attrs:e,slots:r}){const s=Ve(li),n=$e(()=>t.route||s.value),i=Ve($o,0),o=$e(()=>{let c=Xe(i);const{matched:u}=n.value;let h;for(;(h=u[c])&&!h.components;)c++;return c}),a=$e(()=>n.value.matched[o.value]);$s($o,$e(()=>o.value+1)),$s(Fd,a),$s(li,n);const l=Kr();return Wr(()=>[l.value,a.value,t.name],([c,u,h],[d,f,m])=>{u&&(u.instances[h]=c,f&&f!==u&&c&&c===d&&(u.leaveGuards.size||(u.leaveGuards=f.leaveGuards),u.updateGuards.size||(u.updateGuards=f.updateGuards))),c&&u&&(!f||!Rr(u,f)||!d)&&(u.enterCallbacks[h]||[]).forEach(v=>v(c))},{flush:"post"}),()=>{const c=n.value,u=t.name,h=a.value,d=h&&h.components[u];if(!d)return Ko(r.default,{Component:d,route:c});const f=h.props[u],m=f?f===!0?c.params:typeof f=="function"?f(c):f:null,A=as(d,ee({},m,e,{onVnodeUnmounted:E=>{E.component.isUnmounted&&(h.instances[u]=null)},ref:l}));return Ko(r.default,{Component:A,route:c})||A}}});function Ko(t,e){if(!t)return null;const r=t(e);return r.length===1?r[0]:r}const gf=pf;function mf(t){const e=sf(t.routes,t),r=t.parseQuery||Md,s=t.stringifyQuery||No,n=t.history,i=Lr(),o=Lr(),a=Lr(),l=ou(Lt);let c=Lt;fr&&t.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=Ln.bind(null,k=>""+k),h=Ln.bind(null,Ed),d=Ln.bind(null,cs);function f(k,$){let j,D;return Xl(k)?(j=e.getRecordMatcher(k),D=$):D=k,e.addRoute(D,j)}function m(k){const $=e.getRecordMatcher(k);$&&e.removeRoute($)}function v(){return e.getRoutes().map(k=>k.record)}function A(k){return!!e.getRecordMatcher(k)}function E(k,$){if($=ee({},$||l.value),typeof k=="string"){const y=Dn(r,k,$.path),w=e.resolve({path:y.path},$),T=n.createHref(y.fullPath);return ee(y,w,{params:d(w.params),hash:cs(y.hash),redirectedFrom:void 0,href:T})}let j;if(k.path!=null)j=ee({},k,{path:Dn(r,k.path,$.path).path});else{const y=ee({},k.params);for(const w in y)y[w]==null&&delete y[w];j=ee({},k,{params:h(y)}),$.params=h($.params)}const D=e.resolve(j,$),Y=k.hash||"";D.params=u(d(D.params));const p=Td(s,ee({},k,{hash:bd(Y),path:D.path})),g=n.createHref(p);return ee({fullPath:p,hash:Y,query:s===No?Hd(k.query):k.query||{}},D,{redirectedFrom:void 0,href:g})}function _(k){return typeof k=="string"?Dn(r,k,l.value.path):ee({},k)}function b(k,$){if(c!==k)return Or(he.NAVIGATION_CANCELLED,{from:$,to:k})}function O(k){return q(k)}function B(k){return O(ee(_(k),{replace:!0}))}function W(k,$){const j=k.matched[k.matched.length-1];if(j&&j.redirect){const{redirect:D}=j;let Y=typeof D=="function"?D(k,$):D;return typeof Y=="string"&&(Y=Y.includes("?")||Y.includes("#")?Y=_(Y):{path:Y},Y.params={}),ee({query:k.query,hash:k.hash,params:Y.path!=null?{}:k.params},Y)}}function q(k,$){const j=c=E(k),D=l.value,Y=k.state,p=k.force,g=k.replace===!0,y=W(j,D);if(y)return q(ee(_(y),{state:typeof y=="object"?ee({},Y,y.state):Y,force:p,replace:g}),$||j);const w=j;w.redirectedFrom=$;let T;return!p&&Rd(s,D,j)&&(T=Or(he.NAVIGATION_DUPLICATED,{to:w,from:D}),tt(D,D,!0,!1)),(T?Promise.resolve(T):ce(w,D)).catch(S=>vt(S)?vt(S,he.NAVIGATION_GUARD_REDIRECT)?S:$t(S):Z(S,w,D)).then(S=>{if(S){if(vt(S,he.NAVIGATION_GUARD_REDIRECT))return q(ee({replace:g},_(S.to),{state:typeof S.to=="object"?ee({},Y,S.to.state):Y,force:p}),$||w)}else S=Le(w,D,!0,g,Y);return Te(w,D,S),S})}function J(k,$){const j=b(k,$);return j?Promise.reject(j):Promise.resolve()}function V(k){const $=nr.values().next().value;return $&&typeof $.runWithContext=="function"?$.runWithContext(k):k()}function ce(k,$){let j;const[D,Y,p]=qd(k,$);j=Bn(D.reverse(),"beforeRouteLeave",k,$);for(const y of D)y.leaveGuards.forEach(w=>{j.push(Bt(w,k,$))});const g=J.bind(null,k,$);return j.push(g),Fe(j).then(()=>{j=[];for(const y of i.list())j.push(Bt(y,k,$));return j.push(g),Fe(j)}).then(()=>{j=Bn(Y,"beforeRouteUpdate",k,$);for(const y of Y)y.updateGuards.forEach(w=>{j.push(Bt(w,k,$))});return j.push(g),Fe(j)}).then(()=>{j=[];for(const y of p)if(y.beforeEnter)if(et(y.beforeEnter))for(const w of y.beforeEnter)j.push(Bt(w,k,$));else j.push(Bt(y.beforeEnter,k,$));return j.push(g),Fe(j)}).then(()=>(k.matched.forEach(y=>y.enterCallbacks={}),j=Bn(p,"beforeRouteEnter",k,$,V),j.push(g),Fe(j))).then(()=>{j=[];for(const y of o.list())j.push(Bt(y,k,$));return j.push(g),Fe(j)}).catch(y=>vt(y,he.NAVIGATION_CANCELLED)?y:Promise.reject(y))}function Te(k,$,j){a.list().forEach(D=>V(()=>D(k,$,j)))}function Le(k,$,j,D,Y){const p=b(k,$);if(p)return p;const g=$===Lt,y=fr?history.state:{};j&&(D||g?n.replace(k.fullPath,ee({scroll:g&&y&&y.scroll},Y)):n.push(k.fullPath,Y)),l.value=k,tt(k,$,j,g),$t()}let xe;function Kt(){xe||(xe=n.listen((k,$,j)=>{if(!Wt.listening)return;const D=E(k),Y=W(D,Wt.currentRoute.value);if(Y){q(ee(Y,{replace:!0,force:!0}),D).catch(Qr);return}c=D;const p=l.value;fr&&$d(jo(p.fullPath,j.delta),vn()),ce(D,p).catch(g=>vt(g,he.NAVIGATION_ABORTED|he.NAVIGATION_CANCELLED)?g:vt(g,he.NAVIGATION_GUARD_REDIRECT)?(q(ee(_(g.to),{force:!0}),D).then(y=>{vt(y,he.NAVIGATION_ABORTED|he.NAVIGATION_DUPLICATED)&&!j.delta&&j.type===oi.pop&&n.go(-1,!1)}).catch(Qr),Promise.reject()):(j.delta&&n.go(-j.delta,!1),Z(g,D,p))).then(g=>{g=g||Le(D,p,!1),g&&(j.delta&&!vt(g,he.NAVIGATION_CANCELLED)?n.go(-j.delta,!1):j.type===oi.pop&&vt(g,he.NAVIGATION_ABORTED|he.NAVIGATION_DUPLICATED)&&n.go(-1,!1)),Te(D,p,g)}).catch(Qr)}))}let Nt=Lr(),le=Lr(),z;function Z(k,$,j){$t(k);const D=le.list();return D.length?D.forEach(Y=>Y(k,$,j)):console.error(k),Promise.reject(k)}function mt(){return z&&l.value!==Lt?Promise.resolve():new Promise((k,$)=>{Nt.add([k,$])})}function $t(k){return z||(z=!k,Kt(),Nt.list().forEach(([$,j])=>k?j(k):$()),Nt.reset()),k}function tt(k,$,j,D){const{scrollBehavior:Y}=t;if(!fr||!Y)return Promise.resolve();const p=!j&&Ld(jo(k.fullPath,0))||(D||!j)&&history.state&&history.state.scroll||null;return hn().then(()=>Y(k,$,p)).then(g=>g&&Nd(g)).catch(g=>Z(g,k,$))}const Ie=k=>n.go(k);let sr;const nr=new Set,Wt={currentRoute:l,listening:!0,addRoute:f,removeRoute:m,clearRoutes:e.clearRoutes,hasRoute:A,getRoutes:v,resolve:E,options:t,push:O,replace:B,go:Ie,back:()=>Ie(-1),forward:()=>Ie(1),beforeEach:i.add,beforeResolve:o.add,afterEach:a.add,onError:le.add,isReady:mt,install(k){k.component("RouterLink",hf),k.component("RouterView",gf),k.config.globalProperties.$router=Wt,Object.defineProperty(k.config.globalProperties,"$route",{enumerable:!0,get:()=>Xe(l)}),fr&&!sr&&l.value===Lt&&(sr=!0,O(n.location).catch(D=>{}));const $={};for(const D in Lt)Object.defineProperty($,D,{get:()=>l.value[D],enumerable:!0});k.provide(_n,Wt),k.provide(Mi,Ya($)),k.provide(li,l);const j=k.unmount;nr.add(k),k.unmount=function(){nr.delete(k),nr.size<1&&(c=Lt,xe&&xe(),xe=null,l.value=Lt,sr=!1,z=!1),j()}}};function Fe(k){return k.reduce(($,j)=>$.then(()=>V(j)),Promise.resolve())}return Wt}function yf(){return Ve(_n)}function rc(t){return Ve(Mi)}function bn(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r}function vf(t,e,r,s){function n(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(u){try{c(s.next(u))}catch(h){o(h)}}function l(u){try{c(s.throw(u))}catch(h){o(h)}}function c(u){u.done?i(u.value):n(u.value).then(a,l)}c((s=s.apply(t,e||[])).next())})}const _f=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class Hi extends Error{constructor(e,r="FunctionsError",s){super(e),this.name=r,this.context=s}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class bf extends Hi{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class Wo extends Hi{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class Go extends Hi{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var ci;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(ci||(ci={}));class wf{constructor(e,{headers:r={},customFetch:s,region:n=ci.Any}={}){this.url=e,this.headers=r,this.region=n,this.fetch=_f(s)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return vf(this,arguments,void 0,function*(r,s={}){var n;let i,o;try{const{headers:a,method:l,body:c,signal:u,timeout:h}=s;let d={},{region:f}=s;f||(f=this.region);const m=new URL(`${this.url}/${r}`);f&&f!=="any"&&(d["x-region"]=f,m.searchParams.set("forceFunctionRegion",f));let v;c&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(d["Content-Type"]="application/octet-stream",v=c):typeof c=="string"?(d["Content-Type"]="text/plain",v=c):typeof FormData<"u"&&c instanceof FormData?v=c:(d["Content-Type"]="application/json",v=JSON.stringify(c)):c&&typeof c!="string"&&!(typeof Blob<"u"&&c instanceof Blob)&&!(c instanceof ArrayBuffer)&&!(typeof FormData<"u"&&c instanceof FormData)?v=JSON.stringify(c):v=c;let A=u;h&&(o=new AbortController,i=setTimeout(()=>o.abort(),h),u?(A=o.signal,u.addEventListener("abort",()=>o.abort())):A=o.signal);const E=yield this.fetch(m.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},d),this.headers),a),body:v,signal:A}).catch(B=>{throw new bf(B)}),_=E.headers.get("x-relay-error");if(_&&_==="true")throw new Wo(E);if(!E.ok)throw new Go(E);let b=((n=E.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),O;return b==="application/json"?O=yield E.json():b==="application/octet-stream"||b==="application/pdf"?O=yield E.blob():b==="text/event-stream"?O=E:b==="multipart/form-data"?O=yield E.formData():O=yield E.text(),{data:O,error:null,response:E}}catch(a){return{data:null,error:a,response:a instanceof Go||a instanceof Wo?a.context:void 0}}finally{i&&clearTimeout(i)}})}}const sc=3,zo=t=>Math.min(1e3*2**t,3e4),Sf=[520,503],nc=["GET","HEAD","OPTIONS"];var Ef=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function Jo(t,e){return new Promise(r=>{if(e!=null&&e.aborted){r();return}const s=setTimeout(()=>{e==null||e.removeEventListener("abort",n),r()},t);function n(){clearTimeout(s),r()}e==null||e.addEventListener("abort",n)})}function kf(t,e,r,s){return!(!s||r>=sc||!nc.includes(t)||!Sf.includes(e))}var Af=class{constructor(t){var e,r,s,n,i;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(r=t.isMaybeSingle)!==null&&r!==void 0?r:!1,this.shouldStripNulls=(s=t.shouldStripNulls)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(n=t.urlLengthLimit)!==null&&n!==void 0?n:8e3,this.retryEnabled=(i=t.retry)!==null&&i!==void 0?i:!0,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}retry(t){return this.retryEnabled=t,this}then(t,e){var r=this;if(this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){const o=this.headers.get("Accept");o==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!o||o==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const s=this.fetch;let i=(async()=>{let o=0;for(;;){const c=new Headers(r.headers);o>0&&c.set("X-Retry-Count",String(o));let u;try{u=await s(r.url.toString(),{method:r.method,headers:c,body:JSON.stringify(r.body,(h,d)=>typeof d=="bigint"?d.toString():d),signal:r.signal})}catch(h){if((h==null?void 0:h.name)==="AbortError"||(h==null?void 0:h.code)==="ABORT_ERR"||!nc.includes(r.method))throw h;if(r.retryEnabled&&o<sc){const d=zo(o);o++,await Jo(d,r.signal);continue}throw h}if(kf(r.method,u.status,o,r.retryEnabled)){var a,l;const h=(a=(l=u.headers)===null||l===void 0?void 0:l.get("Retry-After"))!==null&&a!==void 0?a:null,d=h!==null?Math.max(0,parseInt(h,10)||0)*1e3:zo(o);await u.text(),o++,await Jo(d,r.signal);continue}return await r.processResponse(u)}})();return this.shouldThrowOnError||(i=i.catch(o=>{var a;let l="",c="",u="";const h=o==null?void 0:o.cause;if(h){var d,f,m,v;const _=(d=h==null?void 0:h.message)!==null&&d!==void 0?d:"",b=(f=h==null?void 0:h.code)!==null&&f!==void 0?f:"";l=`${(m=o==null?void 0:o.name)!==null&&m!==void 0?m:"FetchError"}: ${o==null?void 0:o.message}`,l+=`
|
|
30
|
+
*/let Vd=()=>location.protocol+"//"+location.host;function Zl(t,e){const{pathname:r,search:s,hash:n}=e,i=t.indexOf("#");if(i>-1){let o=n.includes(t.slice(i))?t.slice(i).length:1,a=n.slice(o);return a[0]!=="/"&&(a="/"+a),xo(a,"")}return xo(r,t)+s+n}function Kd(t,e,r,s){let n=[],i=[],o=null;const a=({state:d})=>{const f=Zl(t,location),m=r.value,_=e.value;let A=0;if(d){if(r.value=f,e.value=d,o&&o===m){o=null;return}A=_?d.position-_.position:0}else s(f);n.forEach(E=>{E(r.value,m,{delta:A,type:oi.pop,direction:A?A>0?Mn.forward:Mn.back:Mn.unknown})})};function l(){o=r.value}function c(d){n.push(d);const f=()=>{const m=n.indexOf(d);m>-1&&n.splice(m,1)};return i.push(f),f}function u(){if(document.visibilityState==="hidden"){const{history:d}=window;if(!d.state)return;d.replaceState(ee({},d.state,{scroll:vn()}),"")}}function h(){for(const d of i)d();i=[],window.removeEventListener("popstate",a),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",u)}return window.addEventListener("popstate",a),window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",u),{pauseListeners:l,listen:c,destroy:h}}function $o(t,e,r,s=!1,n=!1){return{back:t,current:e,forward:r,replaced:s,position:window.history.length,scroll:n?vn():null}}function Wd(t){const{history:e,location:r}=window,s={value:Zl(t,r)},n={value:e.state};n.value||i(s.value,{back:null,current:s.value,forward:null,position:e.length-1,replaced:!0,scroll:null},!0);function i(l,c,u){const h=t.indexOf("#"),d=h>-1?(r.host&&document.querySelector("base")?t:t.slice(h))+l:Vd()+t+l;try{e[u?"replaceState":"pushState"](c,"",d),n.value=c}catch(f){console.error(f),r[u?"replace":"assign"](d)}}function o(l,c){i(l,ee({},e.state,$o(n.value.back,l,n.value.forward,!0),c,{position:n.value.position}),!0),s.value=l}function a(l,c){const u=ee({},n.value,e.state,{forward:l,scroll:vn()});i(u.current,u,!0),i(l,ee({},$o(s.value,l,null),{position:u.position+1},c),!1),s.value=l}return{location:s,state:n,push:a,replace:o}}function Gd(t){t=Pd(t);const e=Wd(t),r=Kd(t,e.state,e.location,e.replace);function s(i,o=!0){o||r.pauseListeners(),history.go(i)}const n=ee({location:"",base:t,go:s,createHref:Id.bind(null,t)},e,r);return Object.defineProperty(n,"location",{enumerable:!0,get:()=>e.location.value}),Object.defineProperty(n,"state",{enumerable:!0,get:()=>e.state.value}),n}let Zt=(function(t){return t[t.Static=0]="Static",t[t.Param=1]="Param",t[t.Group=2]="Group",t})({});var me=(function(t){return t[t.Static=0]="Static",t[t.Param=1]="Param",t[t.ParamRegExp=2]="ParamRegExp",t[t.ParamRegExpEnd=3]="ParamRegExpEnd",t[t.EscapeNext=4]="EscapeNext",t})(me||{});const zd={type:Zt.Static,value:""},Jd=/[a-zA-Z0-9_]/;function Yd(t){if(!t)return[[]];if(t==="/")return[[zd]];if(!t.startsWith("/"))throw new Error(`Invalid path "${t}"`);function e(f){throw new Error(`ERR (${r})/"${c}": ${f}`)}let r=me.Static,s=r;const n=[];let i;function o(){i&&n.push(i),i=[]}let a=0,l,c="",u="";function h(){c&&(r===me.Static?i.push({type:Zt.Static,value:c}):r===me.Param||r===me.ParamRegExp||r===me.ParamRegExpEnd?(i.length>1&&(l==="*"||l==="+")&&e(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),i.push({type:Zt.Param,value:c,regexp:u,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):e("Invalid state to consume buffer"),c="")}function d(){c+=l}for(;a<t.length;){if(l=t[a++],l==="\\"&&r!==me.ParamRegExp){s=r,r=me.EscapeNext;continue}switch(r){case me.Static:l==="/"?(c&&h(),o()):l===":"?(h(),r=me.Param):d();break;case me.EscapeNext:d(),r=s;break;case me.Param:l==="("?r=me.ParamRegExp:Jd.test(l)?d():(h(),r=me.Static,l!=="*"&&l!=="?"&&l!=="+"&&a--);break;case me.ParamRegExp:l===")"?u[u.length-1]=="\\"?u=u.slice(0,-1)+l:r=me.ParamRegExpEnd:u+=l;break;case me.ParamRegExpEnd:h(),r=me.Static,l!=="*"&&l!=="?"&&l!=="+"&&a--,u="";break;default:e("Unknown state");break}}return r===me.ParamRegExp&&e(`Unfinished custom RegExp for param "${c}"`),h(),o(),n}const Do="[^/]+?",Xd={sensitive:!1,strict:!1,start:!0,end:!0};var Ce=(function(t){return t[t._multiplier=10]="_multiplier",t[t.Root=90]="Root",t[t.Segment=40]="Segment",t[t.SubSegment=30]="SubSegment",t[t.Static=40]="Static",t[t.Dynamic=20]="Dynamic",t[t.BonusCustomRegExp=10]="BonusCustomRegExp",t[t.BonusWildcard=-50]="BonusWildcard",t[t.BonusRepeatable=-20]="BonusRepeatable",t[t.BonusOptional=-8]="BonusOptional",t[t.BonusStrict=.7000000000000001]="BonusStrict",t[t.BonusCaseSensitive=.25]="BonusCaseSensitive",t})(Ce||{});const Qd=/[.+*?^${}()[\]/\\]/g;function Zd(t,e){const r=ee({},Xd,e),s=[];let n=r.start?"^":"";const i=[];for(const c of t){const u=c.length?[]:[Ce.Root];r.strict&&!c.length&&(n+="/");for(let h=0;h<c.length;h++){const d=c[h];let f=Ce.Segment+(r.sensitive?Ce.BonusCaseSensitive:0);if(d.type===Zt.Static)h||(n+="/"),n+=d.value.replace(Qd,"\\$&"),f+=Ce.Static;else if(d.type===Zt.Param){const{value:m,repeatable:_,optional:A,regexp:E}=d;i.push({name:m,repeatable:_,optional:A});const v=E||Do;if(v!==Do){f+=Ce.BonusCustomRegExp;try{`${v}`}catch(O){throw new Error(`Invalid custom RegExp for param "${m}" (${v}): `+O.message)}}let b=_?`((?:${v})(?:/(?:${v}))*)`:`(${v})`;h||(b=A&&c.length<2?`(?:/${b})`:"/"+b),A&&(b+="?"),n+=b,f+=Ce.Dynamic,A&&(f+=Ce.BonusOptional),_&&(f+=Ce.BonusRepeatable),v===".*"&&(f+=Ce.BonusWildcard)}u.push(f)}s.push(u)}if(r.strict&&r.end){const c=s.length-1;s[c][s[c].length-1]+=Ce.BonusStrict}r.strict||(n+="/?"),r.end?n+="$":r.strict&&!n.endsWith("/")&&(n+="(?:/|$)");const o=new RegExp(n,r.sensitive?"":"i");function a(c){const u=c.match(o),h={};if(!u)return null;for(let d=1;d<u.length;d++){const f=u[d]||"",m=i[d-1];h[m.name]=f&&m.repeatable?f.split("/"):f}return h}function l(c){let u="",h=!1;for(const d of t){(!h||!u.endsWith("/"))&&(u+="/"),h=!1;for(const f of d)if(f.type===Zt.Static)u+=f.value;else if(f.type===Zt.Param){const{value:m,repeatable:_,optional:A}=f,E=m in c?c[m]:"";if(et(E)&&!_)throw new Error(`Provided param "${m}" is an array but it is not repeatable (* or + modifiers)`);const v=et(E)?E.join("/"):E;if(!v)if(A)d.length<2&&(u.endsWith("/")?u=u.slice(0,-1):h=!0);else throw new Error(`Missing required param "${m}"`);u+=v}}return u||"/"}return{re:o,score:s,keys:i,parse:a,stringify:l}}function ef(t,e){let r=0;for(;r<t.length&&r<e.length;){const s=e[r]-t[r];if(s)return s;r++}return t.length<e.length?t.length===1&&t[0]===Ce.Static+Ce.Segment?-1:1:t.length>e.length?e.length===1&&e[0]===Ce.Static+Ce.Segment?1:-1:0}function ec(t,e){let r=0;const s=t.score,n=e.score;for(;r<s.length&&r<n.length;){const i=ef(s[r],n[r]);if(i)return i;r++}if(Math.abs(n.length-s.length)===1){if(Uo(s))return 1;if(Uo(n))return-1}return n.length-s.length}function Uo(t){const e=t[t.length-1];return t.length>0&&e[e.length-1]<0}const tf={strict:!1,end:!0,sensitive:!1};function rf(t,e,r){const s=Zd(Yd(t.path),r),n=ee(s,{record:t,parent:e,children:[],alias:[]});return e&&!n.record.aliasOf==!e.record.aliasOf&&e.children.push(n),n}function sf(t,e){const r=[],s=new Map;e=Po(tf,e);function n(h){return s.get(h)}function i(h,d,f){const m=!f,_=Bo(h);_.aliasOf=f&&f.record;const A=Po(e,h),E=[_];if("alias"in h){const O=typeof h.alias=="string"?[h.alias]:h.alias;for(const M of O)E.push(Bo(ee({},_,{components:f?f.record.components:_.components,path:M,aliasOf:f?f.record:_})))}let v,b;for(const O of E){const{path:M}=O;if(d&&M[0]!=="/"){const W=d.record.path,q=W[W.length-1]==="/"?"":"/";O.path=d.record.path+(M&&q+M)}if(v=rf(O,d,A),f?f.alias.push(v):(b=b||v,b!==v&&b.alias.push(v),m&&h.name&&!Ho(v)&&o(h.name)),tc(v)&&l(v),_.children){const W=_.children;for(let q=0;q<W.length;q++)i(W[q],v,f&&f.children[q])}f=f||v}return b?()=>{o(b)}:Qr}function o(h){if(Xl(h)){const d=s.get(h);d&&(s.delete(h),r.splice(r.indexOf(d),1),d.children.forEach(o),d.alias.forEach(o))}else{const d=r.indexOf(h);d>-1&&(r.splice(d,1),h.record.name&&s.delete(h.record.name),h.children.forEach(o),h.alias.forEach(o))}}function a(){return r}function l(h){const d=af(h,r);r.splice(d,0,h),h.record.name&&!Ho(h)&&s.set(h.record.name,h)}function c(h,d){let f,m={},_,A;if("name"in h&&h.name){if(f=s.get(h.name),!f)throw Or(he.MATCHER_NOT_FOUND,{location:h});A=f.record.name,m=ee(Mo(d.params,f.keys.filter(b=>!b.optional).concat(f.parent?f.parent.keys.filter(b=>b.optional):[]).map(b=>b.name)),h.params&&Mo(h.params,f.keys.map(b=>b.name))),_=f.stringify(m)}else if(h.path!=null)_=h.path,f=r.find(b=>b.re.test(_)),f&&(m=f.parse(_),A=f.record.name);else{if(f=d.name?s.get(d.name):r.find(b=>b.re.test(d.path)),!f)throw Or(he.MATCHER_NOT_FOUND,{location:h,currentLocation:d});A=f.record.name,m=ee({},d.params,h.params),_=f.stringify(m)}const E=[];let v=f;for(;v;)E.unshift(v.record),v=v.parent;return{name:A,path:_,params:m,matched:E,meta:of(E)}}t.forEach(h=>i(h));function u(){r.length=0,s.clear()}return{addRoute:i,resolve:c,removeRoute:o,clearRoutes:u,getRoutes:a,getRecordMatcher:n}}function Mo(t,e){const r={};for(const s of e)s in t&&(r[s]=t[s]);return r}function Bo(t){const e={path:t.path,redirect:t.redirect,name:t.name,meta:t.meta||{},aliasOf:t.aliasOf,beforeEnter:t.beforeEnter,props:nf(t),children:t.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in t?t.components||null:t.component&&{default:t.component}};return Object.defineProperty(e,"mods",{value:{}}),e}function nf(t){const e={},r=t.props||!1;if("component"in t)e.default=r;else for(const s in t.components)e[s]=typeof r=="object"?r[s]:r;return e}function Ho(t){for(;t;){if(t.record.aliasOf)return!0;t=t.parent}return!1}function of(t){return t.reduce((e,r)=>ee(e,r.meta),{})}function af(t,e){let r=0,s=e.length;for(;r!==s;){const i=r+s>>1;ec(t,e[i])<0?s=i:r=i+1}const n=lf(t);return n&&(s=e.lastIndexOf(n,s-1)),s}function lf(t){let e=t;for(;e=e.parent;)if(tc(e)&&ec(t,e)===0)return e}function tc({record:t}){return!!(t.name||t.components&&Object.keys(t.components).length||t.redirect)}function Fo(t){const e=Ge(bn),r=Ge(Bi),s=xe(()=>{const l=Rt(t.to);return e.resolve(l)}),n=xe(()=>{const{matched:l}=s.value,{length:c}=l,u=l[c-1],h=r.matched;if(!u||!h.length)return-1;const d=h.findIndex(Rr.bind(null,u));if(d>-1)return d;const f=qo(l[c-2]);return c>1&&qo(u)===f&&h[h.length-1].path!==f?h.findIndex(Rr.bind(null,l[c-2])):d}),i=xe(()=>n.value>-1&&ff(r.params,s.value.params)),o=xe(()=>n.value>-1&&n.value===r.matched.length-1&&Yl(r.params,s.value.params));function a(l={}){if(df(l)){const c=e[Rt(t.replace)?"replace":"push"](Rt(t.to)).catch(Qr);return t.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>c),c}return Promise.resolve()}return{route:s,href:xe(()=>s.value.href),isActive:i,isExactActive:o,navigate:a}}function cf(t){return t.length===1?t[0]:t}const uf=vs({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:Fo,setup(t,{slots:e}){const r=ys(Fo(t)),{options:s}=Ge(bn),n=xe(()=>({[Vo(t.activeClass,s.linkActiveClass,"router-link-active")]:r.isActive,[Vo(t.exactActiveClass,s.linkExactActiveClass,"router-link-exact-active")]:r.isExactActive}));return()=>{const i=e.default&&cf(e.default(r));return t.custom?i:as("a",{"aria-current":r.isExactActive?t.ariaCurrentValue:null,href:r.href,onClick:r.navigate,class:n.value},i)}}}),hf=uf;function df(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&!(t.button!==void 0&&t.button!==0)){if(t.currentTarget&&t.currentTarget.getAttribute){const e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function ff(t,e){for(const r in e){const s=e[r],n=t[r];if(typeof s=="string"){if(s!==n)return!1}else if(!et(n)||n.length!==s.length||s.some((i,o)=>i.valueOf()!==n[o].valueOf()))return!1}return!0}function qo(t){return t?t.aliasOf?t.aliasOf.path:t.path:""}const Vo=(t,e,r)=>t??e??r,pf=vs({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(t,{attrs:e,slots:r}){const s=Ge(li),n=xe(()=>t.route||s.value),i=Ge(Lo,0),o=xe(()=>{let c=Rt(i);const{matched:u}=n.value;let h;for(;(h=u[c])&&!h.components;)c++;return c}),a=xe(()=>n.value.matched[o.value]);$s(Lo,xe(()=>o.value+1)),$s(Fd,a),$s(li,n);const l=Kr();return Wr(()=>[l.value,a.value,t.name],([c,u,h],[d,f,m])=>{u&&(u.instances[h]=c,f&&f!==u&&c&&c===d&&(u.leaveGuards.size||(u.leaveGuards=f.leaveGuards),u.updateGuards.size||(u.updateGuards=f.updateGuards))),c&&u&&(!f||!Rr(u,f)||!d)&&(u.enterCallbacks[h]||[]).forEach(_=>_(c))},{flush:"post"}),()=>{const c=n.value,u=t.name,h=a.value,d=h&&h.components[u];if(!d)return Ko(r.default,{Component:d,route:c});const f=h.props[u],m=f?f===!0?c.params:typeof f=="function"?f(c):f:null,A=as(d,ee({},m,e,{onVnodeUnmounted:E=>{E.component.isUnmounted&&(h.instances[u]=null)},ref:l}));return Ko(r.default,{Component:A,route:c})||A}}});function Ko(t,e){if(!t)return null;const r=t(e);return r.length===1?r[0]:r}const gf=pf;function mf(t){const e=sf(t.routes,t),r=t.parseQuery||Bd,s=t.stringifyQuery||No,n=t.history,i=$r(),o=$r(),a=$r(),l=ou($t);let c=$t;pr&&t.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=Dn.bind(null,k=>""+k),h=Dn.bind(null,Ed),d=Dn.bind(null,cs);function f(k,L){let j,D;return Xl(k)?(j=e.getRecordMatcher(k),D=L):D=k,e.addRoute(D,j)}function m(k){const L=e.getRecordMatcher(k);L&&e.removeRoute(L)}function _(){return e.getRoutes().map(k=>k.record)}function A(k){return!!e.getRecordMatcher(k)}function E(k,L){if(L=ee({},L||l.value),typeof k=="string"){const y=Un(r,k,L.path),w=e.resolve({path:y.path},L),T=n.createHref(y.fullPath);return ee(y,w,{params:d(w.params),hash:cs(y.hash),redirectedFrom:void 0,href:T})}let j;if(k.path!=null)j=ee({},k,{path:Un(r,k.path,L.path).path});else{const y=ee({},k.params);for(const w in y)y[w]==null&&delete y[w];j=ee({},k,{params:h(y)}),L.params=h(L.params)}const D=e.resolve(j,L),Y=k.hash||"";D.params=u(d(D.params));const p=Td(s,ee({},k,{hash:bd(Y),path:D.path})),g=n.createHref(p);return ee({fullPath:p,hash:Y,query:s===No?Hd(k.query):k.query||{}},D,{redirectedFrom:void 0,href:g})}function v(k){return typeof k=="string"?Un(r,k,l.value.path):ee({},k)}function b(k,L){if(c!==k)return Or(he.NAVIGATION_CANCELLED,{from:L,to:k})}function O(k){return q(k)}function M(k){return O(ee(v(k),{replace:!0}))}function W(k,L){const j=k.matched[k.matched.length-1];if(j&&j.redirect){const{redirect:D}=j;let Y=typeof D=="function"?D(k,L):D;return typeof Y=="string"&&(Y=Y.includes("?")||Y.includes("#")?Y=v(Y):{path:Y},Y.params={}),ee({query:k.query,hash:k.hash,params:Y.path!=null?{}:k.params},Y)}}function q(k,L){const j=c=E(k),D=l.value,Y=k.state,p=k.force,g=k.replace===!0,y=W(j,D);if(y)return q(ee(v(y),{state:typeof y=="object"?ee({},Y,y.state):Y,force:p,replace:g}),L||j);const w=j;w.redirectedFrom=L;let T;return!p&&Rd(s,D,j)&&(T=Or(he.NAVIGATION_DUPLICATED,{to:w,from:D}),tt(D,D,!0,!1)),(T?Promise.resolve(T):ce(w,D)).catch(S=>_t(S)?_t(S,he.NAVIGATION_GUARD_REDIRECT)?S:Lt(S):Z(S,w,D)).then(S=>{if(S){if(_t(S,he.NAVIGATION_GUARD_REDIRECT))return q(ee({replace:g},v(S.to),{state:typeof S.to=="object"?ee({},Y,S.to.state):Y,force:p}),L||w)}else S=De(w,D,!0,g,Y);return Te(w,D,S),S})}function J(k,L){const j=b(k,L);return j?Promise.reject(j):Promise.resolve()}function V(k){const L=ir.values().next().value;return L&&typeof L.runWithContext=="function"?L.runWithContext(k):k()}function ce(k,L){let j;const[D,Y,p]=qd(k,L);j=Bn(D.reverse(),"beforeRouteLeave",k,L);for(const y of D)y.leaveGuards.forEach(w=>{j.push(Mt(w,k,L))});const g=J.bind(null,k,L);return j.push(g),Ve(j).then(()=>{j=[];for(const y of i.list())j.push(Mt(y,k,L));return j.push(g),Ve(j)}).then(()=>{j=Bn(Y,"beforeRouteUpdate",k,L);for(const y of Y)y.updateGuards.forEach(w=>{j.push(Mt(w,k,L))});return j.push(g),Ve(j)}).then(()=>{j=[];for(const y of p)if(y.beforeEnter)if(et(y.beforeEnter))for(const w of y.beforeEnter)j.push(Mt(w,k,L));else j.push(Mt(y.beforeEnter,k,L));return j.push(g),Ve(j)}).then(()=>(k.matched.forEach(y=>y.enterCallbacks={}),j=Bn(p,"beforeRouteEnter",k,L,V),j.push(g),Ve(j))).then(()=>{j=[];for(const y of o.list())j.push(Mt(y,k,L));return j.push(g),Ve(j)}).catch(y=>_t(y,he.NAVIGATION_CANCELLED)?y:Promise.reject(y))}function Te(k,L,j){a.list().forEach(D=>V(()=>D(k,L,j)))}function De(k,L,j,D,Y){const p=b(k,L);if(p)return p;const g=L===$t,y=pr?history.state:{};j&&(D||g?n.replace(k.fullPath,ee({scroll:g&&y&&y.scroll},Y)):n.push(k.fullPath,Y)),l.value=k,tt(k,L,j,g),Lt()}let je;function Kt(){je||(je=n.listen((k,L,j)=>{if(!Wt.listening)return;const D=E(k),Y=W(D,Wt.currentRoute.value);if(Y){q(ee(Y,{replace:!0,force:!0}),D).catch(Qr);return}c=D;const p=l.value;pr&&Ld(jo(p.fullPath,j.delta),vn()),ce(D,p).catch(g=>_t(g,he.NAVIGATION_ABORTED|he.NAVIGATION_CANCELLED)?g:_t(g,he.NAVIGATION_GUARD_REDIRECT)?(q(ee(v(g.to),{force:!0}),D).then(y=>{_t(y,he.NAVIGATION_ABORTED|he.NAVIGATION_DUPLICATED)&&!j.delta&&j.type===oi.pop&&n.go(-1,!1)}).catch(Qr),Promise.reject()):(j.delta&&n.go(-j.delta,!1),Z(g,D,p))).then(g=>{g=g||De(D,p,!1),g&&(j.delta&&!_t(g,he.NAVIGATION_CANCELLED)?n.go(-j.delta,!1):j.type===oi.pop&&_t(g,he.NAVIGATION_ABORTED|he.NAVIGATION_DUPLICATED)&&n.go(-1,!1)),Te(D,p,g)}).catch(Qr)}))}let Nt=$r(),le=$r(),z;function Z(k,L,j){Lt(k);const D=le.list();return D.length?D.forEach(Y=>Y(k,L,j)):console.error(k),Promise.reject(k)}function mt(){return z&&l.value!==$t?Promise.resolve():new Promise((k,L)=>{Nt.add([k,L])})}function Lt(k){return z||(z=!k,Kt(),Nt.list().forEach(([L,j])=>k?j(k):L()),Nt.reset()),k}function tt(k,L,j,D){const{scrollBehavior:Y}=t;if(!pr||!Y)return Promise.resolve();const p=!j&&$d(jo(k.fullPath,0))||(D||!j)&&history.state&&history.state.scroll||null;return fn().then(()=>Y(k,L,p)).then(g=>g&&Nd(g)).catch(g=>Z(g,k,L))}const Ne=k=>n.go(k);let nr;const ir=new Set,Wt={currentRoute:l,listening:!0,addRoute:f,removeRoute:m,clearRoutes:e.clearRoutes,hasRoute:A,getRoutes:_,resolve:E,options:t,push:O,replace:M,go:Ne,back:()=>Ne(-1),forward:()=>Ne(1),beforeEach:i.add,beforeResolve:o.add,afterEach:a.add,onError:le.add,isReady:mt,install(k){k.component("RouterLink",hf),k.component("RouterView",gf),k.config.globalProperties.$router=Wt,Object.defineProperty(k.config.globalProperties,"$route",{enumerable:!0,get:()=>Rt(l)}),pr&&!nr&&l.value===$t&&(nr=!0,O(n.location).catch(D=>{}));const L={};for(const D in $t)Object.defineProperty(L,D,{get:()=>l.value[D],enumerable:!0});k.provide(bn,Wt),k.provide(Bi,Ya(L)),k.provide(li,l);const j=k.unmount;ir.add(k),k.unmount=function(){ir.delete(k),ir.size<1&&(c=$t,je&&je(),je=null,l.value=$t,nr=!1,z=!1),j()}}};function Ve(k){return k.reduce((L,j)=>L.then(()=>V(j)),Promise.resolve())}return Wt}function yf(){return Ge(bn)}function rc(t){return Ge(Bi)}function wn(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r}function _f(t,e,r,s){function n(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(u){try{c(s.next(u))}catch(h){o(h)}}function l(u){try{c(s.throw(u))}catch(h){o(h)}}function c(u){u.done?i(u.value):n(u.value).then(a,l)}c((s=s.apply(t,e||[])).next())})}const vf=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class Hi extends Error{constructor(e,r="FunctionsError",s){super(e),this.name=r,this.context=s}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class bf extends Hi{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class Wo extends Hi{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class Go extends Hi{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var ci;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(ci||(ci={}));class wf{constructor(e,{headers:r={},customFetch:s,region:n=ci.Any}={}){this.url=e,this.headers=r,this.region=n,this.fetch=vf(s)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return _f(this,arguments,void 0,function*(r,s={}){var n;let i,o;try{const{headers:a,method:l,body:c,signal:u,timeout:h}=s;let d={},{region:f}=s;f||(f=this.region);const m=new URL(`${this.url}/${r}`);f&&f!=="any"&&(d["x-region"]=f,m.searchParams.set("forceFunctionRegion",f));let _;c&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(d["Content-Type"]="application/octet-stream",_=c):typeof c=="string"?(d["Content-Type"]="text/plain",_=c):typeof FormData<"u"&&c instanceof FormData?_=c:(d["Content-Type"]="application/json",_=JSON.stringify(c)):c&&typeof c!="string"&&!(typeof Blob<"u"&&c instanceof Blob)&&!(c instanceof ArrayBuffer)&&!(typeof FormData<"u"&&c instanceof FormData)?_=JSON.stringify(c):_=c;let A=u;h&&(o=new AbortController,i=setTimeout(()=>o.abort(),h),u?(A=o.signal,u.addEventListener("abort",()=>o.abort())):A=o.signal);const E=yield this.fetch(m.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},d),this.headers),a),body:_,signal:A}).catch(M=>{throw new bf(M)}),v=E.headers.get("x-relay-error");if(v&&v==="true")throw new Wo(E);if(!E.ok)throw new Go(E);let b=((n=E.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),O;return b==="application/json"?O=yield E.json():b==="application/octet-stream"||b==="application/pdf"?O=yield E.blob():b==="text/event-stream"?O=E:b==="multipart/form-data"?O=yield E.formData():O=yield E.text(),{data:O,error:null,response:E}}catch(a){return{data:null,error:a,response:a instanceof Go||a instanceof Wo?a.context:void 0}}finally{i&&clearTimeout(i)}})}}const sc=3,zo=t=>Math.min(1e3*2**t,3e4),Sf=[520,503],nc=["GET","HEAD","OPTIONS"];var Ef=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function Jo(t,e){return new Promise(r=>{if(e!=null&&e.aborted){r();return}const s=setTimeout(()=>{e==null||e.removeEventListener("abort",n),r()},t);function n(){clearTimeout(s),r()}e==null||e.addEventListener("abort",n)})}function kf(t,e,r,s){return!(!s||r>=sc||!nc.includes(t)||!Sf.includes(e))}var Af=class{constructor(t){var e,r,s,n,i;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(r=t.isMaybeSingle)!==null&&r!==void 0?r:!1,this.shouldStripNulls=(s=t.shouldStripNulls)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(n=t.urlLengthLimit)!==null&&n!==void 0?n:8e3,this.retryEnabled=(i=t.retry)!==null&&i!==void 0?i:!0,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}retry(t){return this.retryEnabled=t,this}then(t,e){var r=this;if(this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){const o=this.headers.get("Accept");o==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!o||o==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const s=this.fetch;let i=(async()=>{let o=0;for(;;){const c=new Headers(r.headers);o>0&&c.set("X-Retry-Count",String(o));let u;try{u=await s(r.url.toString(),{method:r.method,headers:c,body:JSON.stringify(r.body,(h,d)=>typeof d=="bigint"?d.toString():d),signal:r.signal})}catch(h){if((h==null?void 0:h.name)==="AbortError"||(h==null?void 0:h.code)==="ABORT_ERR"||!nc.includes(r.method))throw h;if(r.retryEnabled&&o<sc){const d=zo(o);o++,await Jo(d,r.signal);continue}throw h}if(kf(r.method,u.status,o,r.retryEnabled)){var a,l;const h=(a=(l=u.headers)===null||l===void 0?void 0:l.get("Retry-After"))!==null&&a!==void 0?a:null,d=h!==null?Math.max(0,parseInt(h,10)||0)*1e3:zo(o);await u.text(),o++,await Jo(d,r.signal);continue}return await r.processResponse(u)}})();return this.shouldThrowOnError||(i=i.catch(o=>{var a;let l="",c="",u="";const h=o==null?void 0:o.cause;if(h){var d,f,m,_;const v=(d=h==null?void 0:h.message)!==null&&d!==void 0?d:"",b=(f=h==null?void 0:h.code)!==null&&f!==void 0?f:"";l=`${(m=o==null?void 0:o.name)!==null&&m!==void 0?m:"FetchError"}: ${o==null?void 0:o.message}`,l+=`
|
|
31
31
|
|
|
32
|
-
Caused by: ${(
|
|
33
|
-
${h.stack}`)}else{var A;l=(A=o==null?void 0:o.stack)!==null&&A!==void 0?A:""}const E=this.url.toString().length;return(o==null?void 0:o.name)==="AbortError"||(o==null?void 0:o.code)==="ABORT_ERR"?(u="",c="Request was aborted (timeout or manual cancellation)",E>this.urlLengthLimit&&(c+=`. Note: Your request URL is ${E} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((h==null?void 0:h.name)==="HeadersOverflowError"||(h==null?void 0:h.code)==="UND_ERR_HEADERS_OVERFLOW")&&(u="",c="HTTP headers exceeded server limits (typically 16KB)",E>this.urlLengthLimit&&(c+=`. Your request URL is ${E} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${(a=o==null?void 0:o.name)!==null&&a!==void 0?a:"FetchError"}: ${o==null?void 0:o.message}`,details:l,hint:c,code:u},data:null,count:null,status:0,statusText:""}})),i.then(t,e)}async processResponse(t){var e=this;let r=null,s=null,n=null,i=t.status,o=t.statusText;if(t.ok){var a,l;if(e.method!=="HEAD"){var c;const d=await t.text();d===""||(e.headers.get("Accept")==="text/csv"||e.headers.get("Accept")&&(!((c=e.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text"))?s=d:s=JSON.parse(d))}const u=(a=e.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),h=(l=t.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");u&&h&&h.length>1&&(n=parseInt(h[1])),e.isMaybeSingle&&Array.isArray(s)&&(s.length>1?(r={code:"PGRST116",details:`Results contain ${s.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},s=null,n=null,i=406,o="Not Acceptable"):s.length===1?s=s[0]:s=null)}else{const u=await t.text();try{r=JSON.parse(u),Array.isArray(r)&&t.status===404&&(s=[],r=null,i=200,o="OK")}catch{t.status===404&&u===""?(i=204,o="No Content"):r={message:u}}if(r&&e.shouldThrowOnError)throw new Ef(r)}return{success:r===null,error:r,data:s,count:n,status:i,statusText:o}}returns(){return this}overrideTypes(){return this}},Tf=class extends Af{select(t){let e=!1;const r=(t??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){const i=n?`${n}.order`:"order",o=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${o?`${o},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){const s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:s=r}={}){const n=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${t}`),this.url.searchParams.set(i,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return 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:t=!1,verbose:e=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:i="text"}={}){var o;const a=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; options=${a};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const Yo=new RegExp("[,()]");var pr=class extends Tf{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&Yo.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}notIn(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&Yo.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`not.in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");const i=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${n}fts${i}.${e}`),this}match(t){return Object.entries(t).filter(([e,r])=>r!==void 0).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){const s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}},Rf=class{constructor(t,{headers:e={},schema:r,fetch:s,urlLengthLimit:n=8e3,retry:i}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=s,this.urlLengthLimit=n,this.retry=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:r=!1,count:s}=e??{},n=r?"HEAD":"GET";let i=!1;const o=(t??"*").split("").map(c=>/\s/.test(c)&&!i?"":(c==='"'&&(i=!i),c)).join(""),{url:a,headers:l}=this.cloneRequestState();return a.searchParams.set("select",o),s&&l.append("Prefer",`count=${s}`),new pr({method:n,url:a,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:e,defaultToNull:r=!0}={}){var s;const n="POST",{url:i,headers:o}=this.cloneRequestState();if(e&&o.append("Prefer",`count=${e}`),r||o.append("Prefer","missing=default"),Array.isArray(t)){const a=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(a.length>0){const l=[...new Set(a)].map(c=>`"${c}"`);i.searchParams.set("columns",l.join(","))}}return new pr({method:n,url:i,headers:o,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var i;const o="POST",{url:a,headers:l}=this.cloneRequestState();if(l.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&a.searchParams.set("on_conflict",e),s&&l.append("Prefer",`count=${s}`),n||l.append("Prefer","missing=default"),Array.isArray(t)){const c=t.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(c.length>0){const u=[...new Set(c)].map(h=>`"${h}"`);a.searchParams.set("columns",u.join(","))}}return new pr({method:o,url:a,headers:l,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(t,{count:e}={}){var r;const s="PATCH",{url:n,headers:i}=this.cloneRequestState();return e&&i.append("Prefer",`count=${e}`),new pr({method:s,url:n,headers:i,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:t}={}){var e;const r="DELETE",{url:s,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new pr({method:r,url:s,headers:n,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function us(t){"@babel/helpers - typeof";return us=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},us(t)}function Of(t,e){if(us(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(us(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Cf(t){var e=Of(t,"string");return us(e)=="symbol"?e:e+""}function Pf(t,e,r){return(e=Cf(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Xo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function ks(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Xo(Object(r),!0).forEach(function(s){Pf(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xo(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}var xf=class ic{constructor(e,{headers:r={},schema:s,fetch:n,timeout:i,urlLengthLimit:o=8e3,retry:a}={}){this.url=e,this.headers=new Headers(r),this.schemaName=s,this.urlLengthLimit=o;const l=n??globalThis.fetch;i!==void 0&&i>0?this.fetch=(c,u)=>{const h=new AbortController,d=setTimeout(()=>h.abort(),i),f=u==null?void 0:u.signal;if(f){if(f.aborted)return clearTimeout(d),l(c,u);const m=()=>{clearTimeout(d),h.abort()};return f.addEventListener("abort",m,{once:!0}),l(c,ks(ks({},u),{},{signal:h.signal})).finally(()=>{clearTimeout(d),f.removeEventListener("abort",m)})}return l(c,ks(ks({},u),{},{signal:h.signal})).finally(()=>clearTimeout(d))}:this.fetch=l,this.retry=a}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new Rf(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(e){return new ic(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e,r={},{head:s=!1,get:n=!1,count:i}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let c;const u=f=>f!==null&&typeof f=="object"&&(!Array.isArray(f)||f.some(u)),h=s&&Object.values(r).some(u);h?(a="POST",c=r):s||n?(a=s?"HEAD":"GET",Object.entries(r).filter(([f,m])=>m!==void 0).map(([f,m])=>[f,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([f,m])=>{l.searchParams.append(f,m)})):(a="POST",c=r);const d=new Headers(this.headers);return h?d.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&d.set("Prefer",`count=${i}`),new pr({method:a,url:l,headers:d,schema:this.schemaName,body:c,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class If{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",wsConstructor:WebSocket};const r=globalThis;if(typeof globalThis<"u"&&typeof r.WebSocket<"u")return{type:"native",wsConstructor:r.WebSocket};const s=typeof global<"u"?global:void 0;if(s&&typeof s.WebSocket<"u")return{type:"native",wsConstructor:s.WebSocket};if(typeof globalThis<"u"&&typeof r.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&r.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const n=globalThis.process;if(n){const i=n.versions;if(i&&i.node){const o=i.node,a=parseInt(o.replace(/^v/,"").split(".")[0]);return a>=22?typeof globalThis.WebSocket<"u"?{type:"native",wsConstructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${a} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${a} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
|
|
32
|
+
Caused by: ${(_=h==null?void 0:h.name)!==null&&_!==void 0?_:"Error"}: ${v}`,b&&(l+=` (${b})`),h!=null&&h.stack&&(l+=`
|
|
33
|
+
${h.stack}`)}else{var A;l=(A=o==null?void 0:o.stack)!==null&&A!==void 0?A:""}const E=this.url.toString().length;return(o==null?void 0:o.name)==="AbortError"||(o==null?void 0:o.code)==="ABORT_ERR"?(u="",c="Request was aborted (timeout or manual cancellation)",E>this.urlLengthLimit&&(c+=`. Note: Your request URL is ${E} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((h==null?void 0:h.name)==="HeadersOverflowError"||(h==null?void 0:h.code)==="UND_ERR_HEADERS_OVERFLOW")&&(u="",c="HTTP headers exceeded server limits (typically 16KB)",E>this.urlLengthLimit&&(c+=`. Your request URL is ${E} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${(a=o==null?void 0:o.name)!==null&&a!==void 0?a:"FetchError"}: ${o==null?void 0:o.message}`,details:l,hint:c,code:u},data:null,count:null,status:0,statusText:""}})),i.then(t,e)}async processResponse(t){var e=this;let r=null,s=null,n=null,i=t.status,o=t.statusText;if(t.ok){var a,l;if(e.method!=="HEAD"){var c;const d=await t.text();d===""||(e.headers.get("Accept")==="text/csv"||e.headers.get("Accept")&&(!((c=e.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text"))?s=d:s=JSON.parse(d))}const u=(a=e.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),h=(l=t.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");u&&h&&h.length>1&&(n=parseInt(h[1])),e.isMaybeSingle&&Array.isArray(s)&&(s.length>1?(r={code:"PGRST116",details:`Results contain ${s.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},s=null,n=null,i=406,o="Not Acceptable"):s.length===1?s=s[0]:s=null)}else{const u=await t.text();try{r=JSON.parse(u),Array.isArray(r)&&t.status===404&&(s=[],r=null,i=200,o="OK")}catch{t.status===404&&u===""?(i=204,o="No Content"):r={message:u}}if(r&&e.shouldThrowOnError)throw new Ef(r)}return{success:r===null,error:r,data:s,count:n,status:i,statusText:o}}returns(){return this}overrideTypes(){return this}},Tf=class extends Af{select(t){let e=!1;const r=(t??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){const i=n?`${n}.order`:"order",o=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${o?`${o},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){const s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:s=r}={}){const n=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${t}`),this.url.searchParams.set(i,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return 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:t=!1,verbose:e=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:i="text"}={}){var o;const a=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; options=${a};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const Yo=new RegExp("[,()]");var gr=class extends Tf{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&Yo.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}notIn(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&Yo.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`not.in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");const i=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${n}fts${i}.${e}`),this}match(t){return Object.entries(t).filter(([e,r])=>r!==void 0).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){const s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}},Rf=class{constructor(t,{headers:e={},schema:r,fetch:s,urlLengthLimit:n=8e3,retry:i}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=s,this.urlLengthLimit=n,this.retry=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:r=!1,count:s}=e??{},n=r?"HEAD":"GET";let i=!1;const o=(t??"*").split("").map(c=>/\s/.test(c)&&!i?"":(c==='"'&&(i=!i),c)).join(""),{url:a,headers:l}=this.cloneRequestState();return a.searchParams.set("select",o),s&&l.append("Prefer",`count=${s}`),new gr({method:n,url:a,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:e,defaultToNull:r=!0}={}){var s;const n="POST",{url:i,headers:o}=this.cloneRequestState();if(e&&o.append("Prefer",`count=${e}`),r||o.append("Prefer","missing=default"),Array.isArray(t)){const a=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(a.length>0){const l=[...new Set(a)].map(c=>`"${c}"`);i.searchParams.set("columns",l.join(","))}}return new gr({method:n,url:i,headers:o,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var i;const o="POST",{url:a,headers:l}=this.cloneRequestState();if(l.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&a.searchParams.set("on_conflict",e),s&&l.append("Prefer",`count=${s}`),n||l.append("Prefer","missing=default"),Array.isArray(t)){const c=t.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(c.length>0){const u=[...new Set(c)].map(h=>`"${h}"`);a.searchParams.set("columns",u.join(","))}}return new gr({method:o,url:a,headers:l,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(t,{count:e}={}){var r;const s="PATCH",{url:n,headers:i}=this.cloneRequestState();return e&&i.append("Prefer",`count=${e}`),new gr({method:s,url:n,headers:i,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:t}={}){var e;const r="DELETE",{url:s,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new gr({method:r,url:s,headers:n,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function us(t){"@babel/helpers - typeof";return us=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},us(t)}function Of(t,e){if(us(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(us(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Cf(t){var e=Of(t,"string");return us(e)=="symbol"?e:e+""}function Pf(t,e,r){return(e=Cf(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Xo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function As(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Xo(Object(r),!0).forEach(function(s){Pf(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xo(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}var xf=class ic{constructor(e,{headers:r={},schema:s,fetch:n,timeout:i,urlLengthLimit:o=8e3,retry:a}={}){this.url=e,this.headers=new Headers(r),this.schemaName=s,this.urlLengthLimit=o;const l=n??globalThis.fetch;i!==void 0&&i>0?this.fetch=(c,u)=>{const h=new AbortController,d=setTimeout(()=>h.abort(),i),f=u==null?void 0:u.signal;if(f){if(f.aborted)return clearTimeout(d),l(c,u);const m=()=>{clearTimeout(d),h.abort()};return f.addEventListener("abort",m,{once:!0}),l(c,As(As({},u),{},{signal:h.signal})).finally(()=>{clearTimeout(d),f.removeEventListener("abort",m)})}return l(c,As(As({},u),{},{signal:h.signal})).finally(()=>clearTimeout(d))}:this.fetch=l,this.retry=a}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new Rf(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(e){return new ic(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e,r={},{head:s=!1,get:n=!1,count:i}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let c;const u=f=>f!==null&&typeof f=="object"&&(!Array.isArray(f)||f.some(u)),h=s&&Object.values(r).some(u);h?(a="POST",c=r):s||n?(a=s?"HEAD":"GET",Object.entries(r).filter(([f,m])=>m!==void 0).map(([f,m])=>[f,Array.isArray(m)?`{${m.join(",")}}`:`${m}`]).forEach(([f,m])=>{l.searchParams.append(f,m)})):(a="POST",c=r);const d=new Headers(this.headers);return h?d.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&d.set("Prefer",`count=${i}`),new gr({method:a,url:l,headers:d,schema:this.schemaName,body:c,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class If{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",wsConstructor:WebSocket};const r=globalThis;if(typeof globalThis<"u"&&typeof r.WebSocket<"u")return{type:"native",wsConstructor:r.WebSocket};const s=typeof global<"u"?global:void 0;if(s&&typeof s.WebSocket<"u")return{type:"native",wsConstructor:s.WebSocket};if(typeof globalThis<"u"&&typeof r.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&r.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const n=globalThis.process;if(n){const i=n.versions;if(i&&i.node){const o=i.node,a=parseInt(o.replace(/^v/,"").split(".")[0]);return a>=22?typeof globalThis.WebSocket<"u"?{type:"native",wsConstructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${a} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${a} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
|
|
34
34
|
import ws from "ws"
|
|
35
35
|
new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;let r=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(r+=`
|
|
36
36
|
|
|
37
|
-
Suggested solution: ${e.workaround}`),new Error(r)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const jf="2.106.2",Nf=`realtime-js/${jf}`,$f="1.0.0",oc="2.0.0",Lf=oc,Df=1e4,Uf=100,Ht={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ac={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},ui={connecting:"connecting",closing:"closing",closed:"closed"};class Bf{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=e??[]}encode(e,r){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return r(this._binaryEncodeUserBroadcastPush(e));let s=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(s))}_binaryEncodeUserBroadcastPush(e){var r;return this._isArrayBuffer((r=e.payload)===null||r===void 0?void 0:r.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:{},o=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,o)}_encodeUserBroadcastPush(e,r,s){var n,i;const o=e.topic,a=(n=e.ref)!==null&&n!==void 0?n:"",l=(i=e.join_ref)!==null&&i!==void 0?i:"",c=e.payload.event,u=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},h=Object.keys(u).length===0?"":JSON.stringify(u);if(l.length>255)throw new Error(`joinRef length ${l.length} exceeds maximum of 255`);if(a.length>255)throw new Error(`ref length ${a.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`topic length ${o.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`userEvent length ${c.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`metadata length ${h.length} exceeds maximum of 255`);const d=this.USER_BROADCAST_PUSH_META_LENGTH+l.length+a.length+o.length+c.length+h.length,f=new ArrayBuffer(this.HEADER_LENGTH+d);let m=new DataView(f),v=0;m.setUint8(v++,this.KINDS.userBroadcastPush),m.setUint8(v++,l.length),m.setUint8(v++,a.length),m.setUint8(v++,o.length),m.setUint8(v++,c.length),m.setUint8(v++,h.length),m.setUint8(v++,r),Array.from(l,E=>m.setUint8(v++,E.charCodeAt(0))),Array.from(a,E=>m.setUint8(v++,E.charCodeAt(0))),Array.from(o,E=>m.setUint8(v++,E.charCodeAt(0))),Array.from(c,E=>m.setUint8(v++,E.charCodeAt(0))),Array.from(h,E=>m.setUint8(v++,E.charCodeAt(0)));var A=new Uint8Array(f.byteLength+s.byteLength);return A.set(new Uint8Array(f),0),A.set(new Uint8Array(s),f.byteLength),A.buffer}decode(e,r){if(this._isArrayBuffer(e)){let s=this._binaryDecode(e);return r(s)}if(typeof e=="string"){const s=JSON.parse(e),[n,i,o,a,l]=s;return r({join_ref:n,ref:i,topic:o,event:a,payload:l})}return r({})}_binaryDecode(e){const r=new DataView(e),s=r.getUint8(0),n=new TextDecoder;switch(s){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,r,n)}}_decodeUserBroadcast(e,r,s){const n=r.getUint8(1),i=r.getUint8(2),o=r.getUint8(3),a=r.getUint8(4);let l=this.HEADER_LENGTH+4;const c=s.decode(e.slice(l,l+n));l=l+n;const u=s.decode(e.slice(l,l+i));l=l+i;const h=s.decode(e.slice(l,l+o));l=l+o;const d=e.slice(l,e.byteLength),f=a===this.JSON_ENCODING?JSON.parse(s.decode(d)):d,m={type:this.BROADCAST_EVENT,event:u,payload:f};return o>0&&(m.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:m}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e==null?void 0:e.constructor)===null||r===void 0?void 0:r.name)==="ArrayBuffer"}_pick(e,r){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([s])=>r.includes(s)))}}var oe;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(oe||(oe={}));const Qo=(t,e,r={})=>{var s;const n=(s=r.skipTypes)!==null&&s!==void 0?s:[];return e?Object.keys(e).reduce((i,o)=>(i[o]=Mf(o,t,e,n),i),{}):{}},Mf=(t,e,r,s)=>{const n=e.find(a=>a.name===t),i=n==null?void 0:n.type,o=r[t];return i&&!s.includes(i)?lc(i,o):hi(o)},lc=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return Vf(e,r)}switch(t){case oe.bool:return Hf(e);case oe.float4:case oe.float8:case oe.int2:case oe.int4:case oe.int8:case oe.numeric:case oe.oid:return Ff(e);case oe.json:case oe.jsonb:return qf(e);case oe.timestamp:return Kf(e);case oe.abstime:case oe.date:case oe.daterange:case oe.int4range:case oe.int8range:case oe.money:case oe.reltime:case oe.text:case oe.time:case oe.timestamptz:case oe.timetz:case oe.tsrange:case oe.tstzrange:return hi(e);default:return hi(e)}},hi=t=>t,Hf=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Ff=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},qf=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},Vf=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,s=t[r];if(t[0]==="{"&&s==="}"){let i;const o=t.slice(1,r);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(a=>lc(e,a))}return t},Kf=t=>typeof t=="string"?t.replace(" ","T"):t,cc=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};var Zr=t=>typeof t=="function"?t:function(){return t},Wf=typeof self<"u"?self:null,gr=typeof window<"u"?window:null,lt=Wf||gr||globalThis,Gf="2.0.0",zf=1e4,Jf=1e3,dt={connecting:0,open:1,closing:2,closed:3},je={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},wt={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},di={longpoll:"longpoll",websocket:"websocket"},Yf={complete:4},fi="base64url.bearer.phx.",As=class{constructor(t,e,r,s){this.channel=t,this.event=e,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(t){this.timeout=t,this.reset(),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()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:t,response:e,_ref:r}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},uc=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Xf=class{constructor(t,e,r){this.state=je.closed,this.topic=t,this.params=Zr(e||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new As(this,wt.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new uc(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=je.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",s=>{this.state=je.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=je.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=je.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new As(this,wt.leave,Zr({}),this.timeout).send(),this.state=je.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(wt.reply,(s,n)=>{this.trigger(this.replyEventName(n),s)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=je.closed,this.bindings=[]}onClose(t){this.on(wt.close,t)}onError(t){return this.on(wt.error,e=>t(e))}on(t,e){let r=this.bindingRef++;return this.bindings.push({event:t,ref:r,callback:e}),r}off(t,e){this.bindings=this.bindings.filter(r=>!(r.event===t&&(typeof e>"u"||e===r.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,r=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new As(this,t,function(){return e},r);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=je.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(wt.close,"leave")},r=new As(this,wt.leave,Zr({}),t);return r.receive("ok",()=>e()).receive("timeout",()=>e()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(t,e,r){return e}filterBindings(t,e,r){return!0}isMember(t,e,r,s){return this.topic!==t?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:r,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=je.joining,this.joinPush.resend(t))}trigger(t,e,r,s){let n=this.onMessage(t,e,r,s);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(o=>o.event===t&&this.filterBindings(o,e,r));for(let o=0;o<i.length;o++)i[o].callback(n,r,s||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===je.closed}isErrored(){return this.state===je.errored}isJoined(){return this.state===je.joined}isJoining(){return this.state===je.joining}isLeaving(){return this.state===je.leaving}},Gs=class{static request(t,e,r,s,n,i,o){if(lt.XDomainRequest){let a=new lt.XDomainRequest;return this.xdomainRequest(a,t,e,s,n,i,o)}else if(lt.XMLHttpRequest){let a=new lt.XMLHttpRequest;return this.xhrRequest(a,t,e,r,s,n,i,o)}else{if(lt.fetch&<.AbortController)return this.fetchRequest(t,e,r,s,n,i,o);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,r,s,n,i,o){let a={method:t,headers:r,body:s},l=null;return n&&(l=new AbortController,setTimeout(()=>l.abort(),n),a.signal=l.signal),lt.fetch(e,a).then(c=>c.text()).then(c=>this.parseJSON(c)).then(c=>o&&o(c)).catch(c=>{c.name==="AbortError"&&i?i():o&&o(null)}),l}static xdomainRequest(t,e,r,s,n,i,o){return t.timeout=n,t.open(e,r),t.onload=()=>{let a=this.parseJSON(t.responseText);o&&o(a)},i&&(t.ontimeout=i),t.onprogress=()=>{},t.send(s),t}static xhrRequest(t,e,r,s,n,i,o,a){t.open(e,r,!0),t.timeout=i;for(let[l,c]of Object.entries(s))t.setRequestHeader(l,c);return t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===Yf.complete&&a){let l=this.parseJSON(t.responseText);a(l)}},o&&(t.ontimeout=o),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let r=[];for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let n=e?`${e}[${s}]`:s,i=t[s];typeof i=="object"?r.push(this.serialize(i,n)):r.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}return r.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let r=t.match(/\?/)?"&":"?";return`${t}${r}${this.serialize(e)}`}},Qf=t=>{let e="",r=new Uint8Array(t),s=r.byteLength;for(let n=0;n<s;n++)e+=String.fromCharCode(r[n]);return btoa(e)},ar=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(fi)&&(this.authToken=atob(e[1].slice(fi.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=dt.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+di.websocket),"$1/"+di.longpoll)}endpointURL(){return Gs.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,r){this.close(t,e,r),this.readyState=dt.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===dt.open||this.readyState===dt.connecting}poll(){const t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:r,token:s,messages:n}=e;if(r===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=s}else r=0;switch(r){case 200:n.forEach(i=>{setTimeout(()=>this.onmessage({data:i}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=dt.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${r}`)}})}send(t){typeof t!="string"&&(t=Qf(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},t.join(`
|
|
38
|
-
`),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,!e||e.status!==200?(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(t,e,r){for(let n of this.reqs)n.abort();this.readyState=dt.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(t,e,r,s,n){let i,o=()=>{this.reqs.delete(i),s()};i=Gs.request(t,this.endpointURL(),e,r,this.timeout,o,a=>{this.reqs.delete(i),this.isActive()&&n(a)}),this.reqs.add(i)}},Zf=class Mr{constructor(e,r={}){let s=r.events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=e,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(s.state,n=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel.joinRef(),this.state=Mr.syncState(this.state,n,i,o),this.pendingDiffs.forEach(l=>{this.state=Mr.syncDiff(this.state,l,i,o)}),this.pendingDiffs=[],a()}),this.channel.on(s.diff,n=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=Mr.syncDiff(this.state,n,i,o),a())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(e){return Mr.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,r,s,n){let i=this.clone(e),o={},a={};return this.map(i,(l,c)=>{r[l]||(a[l]=c)}),this.map(r,(l,c)=>{let u=i[l];if(u){let h=c.metas.map(v=>v.phx_ref),d=u.metas.map(v=>v.phx_ref),f=c.metas.filter(v=>d.indexOf(v.phx_ref)<0),m=u.metas.filter(v=>h.indexOf(v.phx_ref)<0);f.length>0&&(o[l]=c,o[l].metas=f),m.length>0&&(a[l]=this.clone(u),a[l].metas=m)}else o[l]=c}),this.syncDiff(i,{joins:o,leaves:a},s,n)}static syncDiff(e,r,s,n){let{joins:i,leaves:o}=this.clone(r);return s||(s=function(){}),n||(n=function(){}),this.map(i,(a,l)=>{let c=e[a];if(e[a]=this.clone(l),c){let u=e[a].metas.map(d=>d.phx_ref),h=c.metas.filter(d=>u.indexOf(d.phx_ref)<0);e[a].metas.unshift(...h)}s(a,c,l)}),this.map(o,(a,l)=>{let c=e[a];if(!c)return;let u=l.metas.map(h=>h.phx_ref);c.metas=c.metas.filter(h=>u.indexOf(h.phx_ref)<0),n(a,c,l),c.metas.length===0&&delete e[a]}),e}static list(e,r){return r||(r=function(s,n){return n}),this.map(e,(s,n)=>r(s,n))}static map(e,r){return Object.getOwnPropertyNames(e).map(s=>r(s,e[s]))}static clone(e){return JSON.parse(JSON.stringify(e))}},Ts={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let r=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(r))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[r,s,n,i,o]=JSON.parse(t);return e({join_ref:r,ref:s,topic:n,event:i,payload:o})}},binaryEncode(t){let{join_ref:e,ref:r,event:s,topic:n,payload:i}=t,o=this.META_LENGTH+e.length+r.length+n.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),c=0;l.setUint8(c++,this.KINDS.push),l.setUint8(c++,e.length),l.setUint8(c++,r.length),l.setUint8(c++,n.length),l.setUint8(c++,s.length),Array.from(e,h=>l.setUint8(c++,h.charCodeAt(0))),Array.from(r,h=>l.setUint8(c++,h.charCodeAt(0))),Array.from(n,h=>l.setUint8(c++,h.charCodeAt(0))),Array.from(s,h=>l.setUint8(c++,h.charCodeAt(0)));var u=new Uint8Array(a.byteLength+i.byteLength);return u.set(new Uint8Array(a),0),u.set(new Uint8Array(i),a.byteLength),u.buffer},binaryDecode(t){let e=new DataView(t),r=e.getUint8(0),s=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(t,e,s);case this.KINDS.reply:return this.decodeReply(t,e,s);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,s)}},decodePush(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),i=e.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=r.decode(t.slice(o,o+s));o=o+s;let l=r.decode(t.slice(o,o+n));o=o+n;let c=r.decode(t.slice(o,o+i));o=o+i;let u=t.slice(o,t.byteLength);return{join_ref:a,ref:null,topic:l,event:c,payload:u}},decodeReply(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),i=e.getUint8(3),o=e.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(t.slice(a,a+s));a=a+s;let c=r.decode(t.slice(a,a+n));a=a+n;let u=r.decode(t.slice(a,a+i));a=a+i;let h=r.decode(t.slice(a,a+o));a=a+o;let d=t.slice(a,t.byteLength),f={status:h,response:d};return{join_ref:l,ref:c,topic:u,event:wt.reply,payload:f}},decodeBroadcast(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),i=this.HEADER_LENGTH+2,o=r.decode(t.slice(i,i+s));i=i+s;let a=r.decode(t.slice(i,i+n));i=i+n;let l=t.slice(i,t.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},ep=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||zf,this.transport=e.transport||lt.WebSocket||ar,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=lt&<.sessionStorage}catch{}this.sessionStore=e.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=Ts.encode.bind(Ts),this.defaultDecoder=Ts.decode.bind(Ts),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==ar?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let s=null;gr&&gr.addEventListener&&(gr.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),s=this.connectClock)}),gr.addEventListener("pageshow",n=>{s===this.connectClock&&(s=null,this.connect())}),gr.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=e.autoSendHeartbeat??!0,this.heartbeatCallback=e.heartbeatCallback??(()=>{}),this.rejoinAfterMs=n=>e.rejoinAfterMs?e.rejoinAfterMs(n):[1e3,2e3,5e3][n-1]||1e4,this.reconnectAfterMs=n=>e.reconnectAfterMs?e.reconnectAfterMs(n):[10,50,100,150,200,250,500,1e3,2e3][n-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(n,i,o)=>{console.log(`${n}: ${i}`,o)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=Zr(e.params||{}),this.endPoint=`${t}/${di.websocket}`,this.vsn=e.vsn||Gf,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new uc(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{e.beforeReconnect&&await e.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=e.authToken}getLongPollTransport(){return ar}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=Gs.appendParams(Gs.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,r){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,r)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Zr(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==ar?this.connectWithFallback(ar,this.longPollFallbackMs):this.transportConnect())}log(t,e,r){this.logger&&this.logger(t,e,r)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}onHeartbeat(t){this.heartbeatCallback=t}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let s=this.onMessage(n=>{n.ref===e&&(this.off([s]),t(Date.now()-r))});return!0}transportName(t){switch(t){case ar:return"LongPoll";default:return t.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${fi}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,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)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let r=!1,s=!0,n,i,o=this.transportName(t),a=l=>{this.log("transport",`falling back to ${o}...`,l),this.off([n,i]),s=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${o}`))return a("memorized");this.fallbackTimer=setTimeout(a,e),i=this.onError(l=>{this.log("transport","error",l),s&&!r&&(clearTimeout(this.fallbackTimer),a(l))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(r=!0,!s){let l=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${l}`,"true"),this.log("transport",`established ${l} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(a,e),this.ping(l=>{this.log("transport","connected to primary after",l),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(t){this.log("error","error in heartbeat callback",t)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Jf,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,r){if(!this.conn)return t&&t();const s=this.conn;this.waitForBufferDone(s,()=>{e?s.close(e,r||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e,r=1){if(r===5||!t.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(t,e,r+1)},150*r)}waitForSocketClosed(t,e,r=1){if(r===5||t.readyState===dt.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(t,e,r+1)},150*r)}onConnClose(t){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(t),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",t)}onConnError(t){this.hasLogger()&&this.log("transport","error",t);let e=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",t,e,r),(e===this.transport||r>0)&&this.triggerChanError(t)}triggerChanError(t){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(wt.error,t)})}connectionState(){switch(this.conn&&this.conn.readyState){case dt.connecting:return"connecting";case dt.open:return"open";case dt.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([r])=>t.indexOf(r)===-1)}channel(t,e={}){let r=new Xf(t,e,this);return this.channels.push(r),r}push(t){if(this.hasLogger()){let{topic:e,event:r,payload:s,ref:n,join_ref:i}=t;this.log("push",`${e} ${r} (${i}, ${n})`,s)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(t){this.log("error","error in heartbeat callback",t)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(t){this.log("error","error in heartbeat callback",t)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:r,event:s,payload:n,ref:i,join_ref:o}=e;if(i&&i===this.pendingHeartbeatRef){const a=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(n.status==="ok"?"ok":"error",a)}catch(l){this.log("error","error in heartbeat callback",l)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${n.status||""} ${r} ${s} ${i&&"("+i+")"||""}`.trim(),n);for(let a=0;a<this.channels.length;a++){const l=this.channels[a];l.isMember(r,s,n,o)&&l.trigger(s,n,i,o)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(t,...e){try{this.stateChangeCallbacks[t].forEach(([r,s])=>{try{s(...e)}catch(n){this.log("error",`error in ${t} callback`,n)}})}catch(r){this.log("error",`error triggering ${t} callbacks`,r)}}leaveOpenTopic(t){let e=this.channels.find(r=>r.topic===t&&(r.isJoined()||r.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}};class es{constructor(e,r){const s=rp(r);this.presence=new Zf(e.getChannel(),s),this.presence.onJoin((n,i,o)=>{const a=es.onJoinPayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onLeave((n,i,o)=>{const a=es.onLeavePayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return es.transformState(this.presence.state)}static transformState(e){return e=tp(e),Object.getOwnPropertyNames(e).reduce((r,s)=>{const n=e[s];return r[s]=Ds(n),r},{})}static onJoinPayload(e,r,s){const n=Zo(r),i=Ds(s);return{event:"join",key:e,currentPresences:n,newPresences:i}}static onLeavePayload(e,r,s){const n=Zo(r),i=Ds(s);return{event:"leave",key:e,currentPresences:n,leftPresences:i}}}function Ds(t){return t.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function tp(t){return JSON.parse(JSON.stringify(t))}function rp(t){return(t==null?void 0:t.events)&&{events:t.events}}function Zo(t){return t!=null&&t.metas?Ds(t):[]}var ea;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(ea||(ea={}));class sp{get state(){return this.presenceAdapter.state}constructor(e,r){this.channel=e,this.presenceAdapter=new es(this.channel.channelAdapter,r)}}function np(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t&&typeof t=="object"){const e=t;if(typeof e.code=="number"){const r=typeof e.reason=="string"&&e.reason?` (${e.reason})`:"";return new Error(`socket closed: ${e.code}${r}`,{cause:t})}return new Error("channel error: transport failure",{cause:t})}return new Error("channel error: connection lost")}class ip{constructor(e,r,s){const n=op(s);this.channel=e.getSocket().channel(r,n),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,r){return this.channel.on(e,r)}off(e,r){this.channel.off(e,r)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,r,s){let n;try{n=this.channel.push(e,r,s)}catch{throw new Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>Uf){const i=this.channel.pushBuffer.shift();i.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${i.event}`,i.payload())}return n}updateJoinPayload(e){const r=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},r),e)}canPush(){return this.socket.isConnected()&&this.state===Ht.joined}isJoined(){return this.state===Ht.joined}isJoining(){return this.state===Ht.joining}isClosed(){return this.state===Ht.closed}isLeaving(){return this.state===Ht.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}function op(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}var ta;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(ta||(ta={}));var vr;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(vr||(vr={}));var St;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(St||(St={}));class ts{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,r={config:{}},s){var n,i;if(this.topic=e,this.params=r,this.socket=s,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.channelAdapter=new ip(this.socket.socketAdapter,e,this.params),this.presence=new sp(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=cc(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((i=(n=this.params.config)===null||n===void 0?void 0:n.broadcast)===null||i===void 0)&&i.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,r=this.timeout){var s,n,i;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:o,presence:a,private:l}}=this.params,c=(n=(s=this.bindings.postgres_changes)===null||s===void 0?void 0:s.map(f=>f.filter))!==null&&n!==void 0?n:[],u=!!this.bindings[vr.PRESENCE]&&this.bindings[vr.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,h={},d={broadcast:o,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:c,private:l};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(f=>{e==null||e(St.CHANNEL_ERROR,np(f))}),this._onClose(()=>e==null?void 0:e(St.CLOSED)),this.updateJoinPayload(Object.assign({config:d},h)),this._updateFilterMessage(),this.channelAdapter.subscribe(r).receive("ok",async({postgres_changes:f})=>{if(this.socket._isManualToken()||this.socket.setAuth(),f===void 0){e==null||e(St.SUBSCRIBED);return}this._updatePostgresBindings(f,e)}).receive("error",f=>{this.state=Ht.errored;const m=Object.values(f).join(", ")||"error";e==null||e(St.CHANNEL_ERROR,new Error(m,{cause:f}))}).receive("timeout",()=>{e==null||e(St.TIMED_OUT)})}return this}_updatePostgresBindings(e,r){var s;const n=this.bindings.postgres_changes,i=(s=n==null?void 0:n.length)!==null&&s!==void 0?s:0,o=[];for(let a=0;a<i;a++){const l=n[a],{filter:{event:c,schema:u,table:h,filter:d}}=l,f=e&&e[a];if(f&&f.event===c&&ts.isFilterValueEqual(f.schema,u)&&ts.isFilterValueEqual(f.table,h)&&ts.isFilterValueEqual(f.filter,d))o.push(Object.assign(Object.assign({},l),{id:f.id}));else{this.unsubscribe(),this.state=Ht.errored,r==null||r(St.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=o,this.state!=Ht.errored&&r&&r(St.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,s){const n=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),i=e===vr.PRESENCE||e===vr.POSTGRES_CHANGES;if(n&&i)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,r,s)}async httpSend(e,r,s={}){var n;if(r==null)return Promise.reject(new Error("Payload is required for httpSend()"));const i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(i.Authorization=`Bearer ${this.socket.accessTokenValue}`);const o={method:"POST",headers:i,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:r,private:this.private}]})},a=await this._fetchWithTimeout(this.broadcastEndpointURL,o,(n=s.timeout)!==null&&n!==void 0?n:this.timeout);if(a.status===202)return{success:!0};let l=a.statusText;try{const c=await a.json();l=c.error||c.message||l}catch{}return Promise.reject(new Error(l))}async send(e,r={}){var s,n;if(!this.channelAdapter.canPush()&&e.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:i,payload:o}=e,a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);const l={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const c=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(s=r.timeout)!==null&&s!==void 0?s:this.timeout);return await((n=c.body)===null||n===void 0?void 0:n.cancel()),c.ok?"ok":"error"}catch(c){return c instanceof Error&&c.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var o,a,l;const c=this.channelAdapter.push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(a=(o=this.params)===null||o===void 0?void 0:o.config)===null||a===void 0?void 0:a.broadcast)===null||l===void 0)&&l.ack)&&i("ok"),c.receive("ok",()=>i("ok")),c.receive("error",()=>i("error")),c.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(r=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>r("ok")).receive("timeout",()=>r("timed out")).receive("error",()=>r("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,r,s){const n=new AbortController,i=setTimeout(()=>n.abort(),s),o=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:n.signal}));return clearTimeout(i),o}_on(e,r,s){const n=e.toLocaleLowerCase(),i=this.channelAdapter.on(e,s),o={type:n,filter:r,callback:s,ref:i};return this.bindings[n]?this.bindings[n].push(o):this.bindings[n]=[o],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,r,s)=>{var n,i,o,a,l,c,u;const h=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(h,s))return!1;const d=(n=this.bindings[h])===null||n===void 0?void 0:n.find(f=>f.ref===e.ref);if(!d)return!0;if(["broadcast","presence","postgres_changes"].includes(h))if("id"in d){const f=d.id,m=(i=d.filter)===null||i===void 0?void 0:i.event;return f&&((o=r.ids)===null||o===void 0?void 0:o.includes(f))&&(m==="*"||(m==null?void 0:m.toLocaleLowerCase())===((a=r.data)===null||a===void 0?void 0:a.type.toLocaleLowerCase()))}else{const f=(c=(l=d==null?void 0:d.filter)===null||l===void 0?void 0:l.event)===null||c===void 0?void 0:c.toLocaleLowerCase();return f==="*"||f===((u=r==null?void 0:r.event)===null||u===void 0?void 0:u.toLocaleLowerCase())}else return d.type.toLocaleLowerCase()===h})}_notThisChannelEvent(e,r){const{close:s,error:n,leave:i,join:o}=ac;return r&&[s,n,i,o].includes(e)&&r!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,r,s)=>{if(typeof r=="object"&&"ids"in r){const n=r.data,{schema:i,table:o,commit_timestamp:a,type:l,errors:c}=n;return Object.assign(Object.assign({},{schema:i,table:o,commit_timestamp:a,eventType:l,new:{},old:{},errors:c}),this._getPayloadRecords(n))}return r})}copyBindings(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const r in e.bindings)for(const s of e.bindings[r])this._on(s.type,s.filter,s.callback)}static isFilterValueEqual(e,r){return(e??void 0)===(r??void 0)}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=Qo(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=Qo(e.columns,e.old_record)),r}}class ap{constructor(e,r){this.socket=new ep(e,r)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,r,s,n=1e4){return new Promise(i=>{setTimeout(()=>i("timeout"),n),this.socket.disconnect(()=>{e(),i("ok")},r,s)})}push(e){this.socket.push(e)}log(e,r,s){this.socket.log(e,r,s)}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==ui.connecting}isDisconnecting(){return this.socket.connectionState()==ui.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const ra={HEARTBEAT_INTERVAL:25e3},lp=[1e3,2e3,5e3,1e4],cp=1e4;function up(){const t=new Map;return{get length(){return t.size},clear(){t.clear()},getItem(e){return t.has(e)?t.get(e):null},key(e){var r;return(r=Array.from(t.keys())[e])!==null&&r!==void 0?r:null},removeItem(e){t.delete(e)},setItem(e,r){t.set(e,String(r))}}}function hp(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return up()}const dp=`
|
|
37
|
+
Suggested solution: ${e.workaround}`),new Error(r)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const jf="2.106.2",Nf=`realtime-js/${jf}`,Lf="1.0.0",oc="2.0.0",$f=oc,Df=1e4,Uf=100,Ht={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ac={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},ui={connecting:"connecting",closing:"closing",closed:"closed"};class Mf{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=e??[]}encode(e,r){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return r(this._binaryEncodeUserBroadcastPush(e));let s=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(s))}_binaryEncodeUserBroadcastPush(e){var r;return this._isArrayBuffer((r=e.payload)===null||r===void 0?void 0:r.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:{},o=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,o)}_encodeUserBroadcastPush(e,r,s){var n,i;const o=e.topic,a=(n=e.ref)!==null&&n!==void 0?n:"",l=(i=e.join_ref)!==null&&i!==void 0?i:"",c=e.payload.event,u=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},h=Object.keys(u).length===0?"":JSON.stringify(u);if(l.length>255)throw new Error(`joinRef length ${l.length} exceeds maximum of 255`);if(a.length>255)throw new Error(`ref length ${a.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`topic length ${o.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`userEvent length ${c.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`metadata length ${h.length} exceeds maximum of 255`);const d=this.USER_BROADCAST_PUSH_META_LENGTH+l.length+a.length+o.length+c.length+h.length,f=new ArrayBuffer(this.HEADER_LENGTH+d);let m=new DataView(f),_=0;m.setUint8(_++,this.KINDS.userBroadcastPush),m.setUint8(_++,l.length),m.setUint8(_++,a.length),m.setUint8(_++,o.length),m.setUint8(_++,c.length),m.setUint8(_++,h.length),m.setUint8(_++,r),Array.from(l,E=>m.setUint8(_++,E.charCodeAt(0))),Array.from(a,E=>m.setUint8(_++,E.charCodeAt(0))),Array.from(o,E=>m.setUint8(_++,E.charCodeAt(0))),Array.from(c,E=>m.setUint8(_++,E.charCodeAt(0))),Array.from(h,E=>m.setUint8(_++,E.charCodeAt(0)));var A=new Uint8Array(f.byteLength+s.byteLength);return A.set(new Uint8Array(f),0),A.set(new Uint8Array(s),f.byteLength),A.buffer}decode(e,r){if(this._isArrayBuffer(e)){let s=this._binaryDecode(e);return r(s)}if(typeof e=="string"){const s=JSON.parse(e),[n,i,o,a,l]=s;return r({join_ref:n,ref:i,topic:o,event:a,payload:l})}return r({})}_binaryDecode(e){const r=new DataView(e),s=r.getUint8(0),n=new TextDecoder;switch(s){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,r,n)}}_decodeUserBroadcast(e,r,s){const n=r.getUint8(1),i=r.getUint8(2),o=r.getUint8(3),a=r.getUint8(4);let l=this.HEADER_LENGTH+4;const c=s.decode(e.slice(l,l+n));l=l+n;const u=s.decode(e.slice(l,l+i));l=l+i;const h=s.decode(e.slice(l,l+o));l=l+o;const d=e.slice(l,e.byteLength),f=a===this.JSON_ENCODING?JSON.parse(s.decode(d)):d,m={type:this.BROADCAST_EVENT,event:u,payload:f};return o>0&&(m.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:m}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e==null?void 0:e.constructor)===null||r===void 0?void 0:r.name)==="ArrayBuffer"}_pick(e,r){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([s])=>r.includes(s)))}}var oe;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(oe||(oe={}));const Qo=(t,e,r={})=>{var s;const n=(s=r.skipTypes)!==null&&s!==void 0?s:[];return e?Object.keys(e).reduce((i,o)=>(i[o]=Bf(o,t,e,n),i),{}):{}},Bf=(t,e,r,s)=>{const n=e.find(a=>a.name===t),i=n==null?void 0:n.type,o=r[t];return i&&!s.includes(i)?lc(i,o):hi(o)},lc=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return Vf(e,r)}switch(t){case oe.bool:return Hf(e);case oe.float4:case oe.float8:case oe.int2:case oe.int4:case oe.int8:case oe.numeric:case oe.oid:return Ff(e);case oe.json:case oe.jsonb:return qf(e);case oe.timestamp:return Kf(e);case oe.abstime:case oe.date:case oe.daterange:case oe.int4range:case oe.int8range:case oe.money:case oe.reltime:case oe.text:case oe.time:case oe.timestamptz:case oe.timetz:case oe.tsrange:case oe.tstzrange:return hi(e);default:return hi(e)}},hi=t=>t,Hf=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Ff=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},qf=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},Vf=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,s=t[r];if(t[0]==="{"&&s==="}"){let i;const o=t.slice(1,r);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(a=>lc(e,a))}return t},Kf=t=>typeof t=="string"?t.replace(" ","T"):t,cc=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};var Zr=t=>typeof t=="function"?t:function(){return t},Wf=typeof self<"u"?self:null,mr=typeof window<"u"?window:null,lt=Wf||mr||globalThis,Gf="2.0.0",zf=1e4,Jf=1e3,dt={connecting:0,open:1,closing:2,closed:3},Le={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},wt={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},di={longpoll:"longpoll",websocket:"websocket"},Yf={complete:4},fi="base64url.bearer.phx.",Ts=class{constructor(t,e,r,s){this.channel=t,this.event=e,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(t){this.timeout=t,this.reset(),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()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:t,response:e,_ref:r}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},uc=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Xf=class{constructor(t,e,r){this.state=Le.closed,this.topic=t,this.params=Zr(e||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Ts(this,wt.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new uc(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=Le.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",s=>{this.state=Le.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=Le.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=Le.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new Ts(this,wt.leave,Zr({}),this.timeout).send(),this.state=Le.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(wt.reply,(s,n)=>{this.trigger(this.replyEventName(n),s)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Le.closed,this.bindings=[]}onClose(t){this.on(wt.close,t)}onError(t){return this.on(wt.error,e=>t(e))}on(t,e){let r=this.bindingRef++;return this.bindings.push({event:t,ref:r,callback:e}),r}off(t,e){this.bindings=this.bindings.filter(r=>!(r.event===t&&(typeof e>"u"||e===r.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,r=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new Ts(this,t,function(){return e},r);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=Le.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(wt.close,"leave")},r=new Ts(this,wt.leave,Zr({}),t);return r.receive("ok",()=>e()).receive("timeout",()=>e()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(t,e,r){return e}filterBindings(t,e,r){return!0}isMember(t,e,r,s){return this.topic!==t?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:r,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=Le.joining,this.joinPush.resend(t))}trigger(t,e,r,s){let n=this.onMessage(t,e,r,s);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(o=>o.event===t&&this.filterBindings(o,e,r));for(let o=0;o<i.length;o++)i[o].callback(n,r,s||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===Le.closed}isErrored(){return this.state===Le.errored}isJoined(){return this.state===Le.joined}isJoining(){return this.state===Le.joining}isLeaving(){return this.state===Le.leaving}},Js=class{static request(t,e,r,s,n,i,o){if(lt.XDomainRequest){let a=new lt.XDomainRequest;return this.xdomainRequest(a,t,e,s,n,i,o)}else if(lt.XMLHttpRequest){let a=new lt.XMLHttpRequest;return this.xhrRequest(a,t,e,r,s,n,i,o)}else{if(lt.fetch&<.AbortController)return this.fetchRequest(t,e,r,s,n,i,o);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,r,s,n,i,o){let a={method:t,headers:r,body:s},l=null;return n&&(l=new AbortController,setTimeout(()=>l.abort(),n),a.signal=l.signal),lt.fetch(e,a).then(c=>c.text()).then(c=>this.parseJSON(c)).then(c=>o&&o(c)).catch(c=>{c.name==="AbortError"&&i?i():o&&o(null)}),l}static xdomainRequest(t,e,r,s,n,i,o){return t.timeout=n,t.open(e,r),t.onload=()=>{let a=this.parseJSON(t.responseText);o&&o(a)},i&&(t.ontimeout=i),t.onprogress=()=>{},t.send(s),t}static xhrRequest(t,e,r,s,n,i,o,a){t.open(e,r,!0),t.timeout=i;for(let[l,c]of Object.entries(s))t.setRequestHeader(l,c);return t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===Yf.complete&&a){let l=this.parseJSON(t.responseText);a(l)}},o&&(t.ontimeout=o),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let r=[];for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let n=e?`${e}[${s}]`:s,i=t[s];typeof i=="object"?r.push(this.serialize(i,n)):r.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}return r.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let r=t.match(/\?/)?"&":"?";return`${t}${r}${this.serialize(e)}`}},Qf=t=>{let e="",r=new Uint8Array(t),s=r.byteLength;for(let n=0;n<s;n++)e+=String.fromCharCode(r[n]);return btoa(e)},lr=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(fi)&&(this.authToken=atob(e[1].slice(fi.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=dt.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+di.websocket),"$1/"+di.longpoll)}endpointURL(){return Js.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,r){this.close(t,e,r),this.readyState=dt.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===dt.open||this.readyState===dt.connecting}poll(){const t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:r,token:s,messages:n}=e;if(r===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=s}else r=0;switch(r){case 200:n.forEach(i=>{setTimeout(()=>this.onmessage({data:i}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=dt.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${r}`)}})}send(t){typeof t!="string"&&(t=Qf(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},t.join(`
|
|
38
|
+
`),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,!e||e.status!==200?(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(t,e,r){for(let n of this.reqs)n.abort();this.readyState=dt.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(t,e,r,s,n){let i,o=()=>{this.reqs.delete(i),s()};i=Js.request(t,this.endpointURL(),e,r,this.timeout,o,a=>{this.reqs.delete(i),this.isActive()&&n(a)}),this.reqs.add(i)}},Zf=class Br{constructor(e,r={}){let s=r.events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=e,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(s.state,n=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel.joinRef(),this.state=Br.syncState(this.state,n,i,o),this.pendingDiffs.forEach(l=>{this.state=Br.syncDiff(this.state,l,i,o)}),this.pendingDiffs=[],a()}),this.channel.on(s.diff,n=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=Br.syncDiff(this.state,n,i,o),a())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(e){return Br.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,r,s,n){let i=this.clone(e),o={},a={};return this.map(i,(l,c)=>{r[l]||(a[l]=c)}),this.map(r,(l,c)=>{let u=i[l];if(u){let h=c.metas.map(_=>_.phx_ref),d=u.metas.map(_=>_.phx_ref),f=c.metas.filter(_=>d.indexOf(_.phx_ref)<0),m=u.metas.filter(_=>h.indexOf(_.phx_ref)<0);f.length>0&&(o[l]=c,o[l].metas=f),m.length>0&&(a[l]=this.clone(u),a[l].metas=m)}else o[l]=c}),this.syncDiff(i,{joins:o,leaves:a},s,n)}static syncDiff(e,r,s,n){let{joins:i,leaves:o}=this.clone(r);return s||(s=function(){}),n||(n=function(){}),this.map(i,(a,l)=>{let c=e[a];if(e[a]=this.clone(l),c){let u=e[a].metas.map(d=>d.phx_ref),h=c.metas.filter(d=>u.indexOf(d.phx_ref)<0);e[a].metas.unshift(...h)}s(a,c,l)}),this.map(o,(a,l)=>{let c=e[a];if(!c)return;let u=l.metas.map(h=>h.phx_ref);c.metas=c.metas.filter(h=>u.indexOf(h.phx_ref)<0),n(a,c,l),c.metas.length===0&&delete e[a]}),e}static list(e,r){return r||(r=function(s,n){return n}),this.map(e,(s,n)=>r(s,n))}static map(e,r){return Object.getOwnPropertyNames(e).map(s=>r(s,e[s]))}static clone(e){return JSON.parse(JSON.stringify(e))}},Rs={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let r=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(r))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[r,s,n,i,o]=JSON.parse(t);return e({join_ref:r,ref:s,topic:n,event:i,payload:o})}},binaryEncode(t){let{join_ref:e,ref:r,event:s,topic:n,payload:i}=t,o=this.META_LENGTH+e.length+r.length+n.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),c=0;l.setUint8(c++,this.KINDS.push),l.setUint8(c++,e.length),l.setUint8(c++,r.length),l.setUint8(c++,n.length),l.setUint8(c++,s.length),Array.from(e,h=>l.setUint8(c++,h.charCodeAt(0))),Array.from(r,h=>l.setUint8(c++,h.charCodeAt(0))),Array.from(n,h=>l.setUint8(c++,h.charCodeAt(0))),Array.from(s,h=>l.setUint8(c++,h.charCodeAt(0)));var u=new Uint8Array(a.byteLength+i.byteLength);return u.set(new Uint8Array(a),0),u.set(new Uint8Array(i),a.byteLength),u.buffer},binaryDecode(t){let e=new DataView(t),r=e.getUint8(0),s=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(t,e,s);case this.KINDS.reply:return this.decodeReply(t,e,s);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,s)}},decodePush(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),i=e.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=r.decode(t.slice(o,o+s));o=o+s;let l=r.decode(t.slice(o,o+n));o=o+n;let c=r.decode(t.slice(o,o+i));o=o+i;let u=t.slice(o,t.byteLength);return{join_ref:a,ref:null,topic:l,event:c,payload:u}},decodeReply(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),i=e.getUint8(3),o=e.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(t.slice(a,a+s));a=a+s;let c=r.decode(t.slice(a,a+n));a=a+n;let u=r.decode(t.slice(a,a+i));a=a+i;let h=r.decode(t.slice(a,a+o));a=a+o;let d=t.slice(a,t.byteLength),f={status:h,response:d};return{join_ref:l,ref:c,topic:u,event:wt.reply,payload:f}},decodeBroadcast(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),i=this.HEADER_LENGTH+2,o=r.decode(t.slice(i,i+s));i=i+s;let a=r.decode(t.slice(i,i+n));i=i+n;let l=t.slice(i,t.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},ep=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||zf,this.transport=e.transport||lt.WebSocket||lr,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=lt&<.sessionStorage}catch{}this.sessionStore=e.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=Rs.encode.bind(Rs),this.defaultDecoder=Rs.decode.bind(Rs),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==lr?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let s=null;mr&&mr.addEventListener&&(mr.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),s=this.connectClock)}),mr.addEventListener("pageshow",n=>{s===this.connectClock&&(s=null,this.connect())}),mr.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=e.autoSendHeartbeat??!0,this.heartbeatCallback=e.heartbeatCallback??(()=>{}),this.rejoinAfterMs=n=>e.rejoinAfterMs?e.rejoinAfterMs(n):[1e3,2e3,5e3][n-1]||1e4,this.reconnectAfterMs=n=>e.reconnectAfterMs?e.reconnectAfterMs(n):[10,50,100,150,200,250,500,1e3,2e3][n-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(n,i,o)=>{console.log(`${n}: ${i}`,o)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=Zr(e.params||{}),this.endPoint=`${t}/${di.websocket}`,this.vsn=e.vsn||Gf,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new uc(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{e.beforeReconnect&&await e.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=e.authToken}getLongPollTransport(){return lr}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=Js.appendParams(Js.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,r){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,r)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Zr(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==lr?this.connectWithFallback(lr,this.longPollFallbackMs):this.transportConnect())}log(t,e,r){this.logger&&this.logger(t,e,r)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}onHeartbeat(t){this.heartbeatCallback=t}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let s=this.onMessage(n=>{n.ref===e&&(this.off([s]),t(Date.now()-r))});return!0}transportName(t){switch(t){case lr:return"LongPoll";default:return t.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${fi}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,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)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let r=!1,s=!0,n,i,o=this.transportName(t),a=l=>{this.log("transport",`falling back to ${o}...`,l),this.off([n,i]),s=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${o}`))return a("memorized");this.fallbackTimer=setTimeout(a,e),i=this.onError(l=>{this.log("transport","error",l),s&&!r&&(clearTimeout(this.fallbackTimer),a(l))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(r=!0,!s){let l=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${l}`,"true"),this.log("transport",`established ${l} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(a,e),this.ping(l=>{this.log("transport","connected to primary after",l),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(t){this.log("error","error in heartbeat callback",t)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Jf,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,r){if(!this.conn)return t&&t();const s=this.conn;this.waitForBufferDone(s,()=>{e?s.close(e,r||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e,r=1){if(r===5||!t.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(t,e,r+1)},150*r)}waitForSocketClosed(t,e,r=1){if(r===5||t.readyState===dt.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(t,e,r+1)},150*r)}onConnClose(t){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(t),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",t)}onConnError(t){this.hasLogger()&&this.log("transport","error",t);let e=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",t,e,r),(e===this.transport||r>0)&&this.triggerChanError(t)}triggerChanError(t){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(wt.error,t)})}connectionState(){switch(this.conn&&this.conn.readyState){case dt.connecting:return"connecting";case dt.open:return"open";case dt.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([r])=>t.indexOf(r)===-1)}channel(t,e={}){let r=new Xf(t,e,this);return this.channels.push(r),r}push(t){if(this.hasLogger()){let{topic:e,event:r,payload:s,ref:n,join_ref:i}=t;this.log("push",`${e} ${r} (${i}, ${n})`,s)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(t){this.log("error","error in heartbeat callback",t)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(t){this.log("error","error in heartbeat callback",t)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:r,event:s,payload:n,ref:i,join_ref:o}=e;if(i&&i===this.pendingHeartbeatRef){const a=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(n.status==="ok"?"ok":"error",a)}catch(l){this.log("error","error in heartbeat callback",l)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${n.status||""} ${r} ${s} ${i&&"("+i+")"||""}`.trim(),n);for(let a=0;a<this.channels.length;a++){const l=this.channels[a];l.isMember(r,s,n,o)&&l.trigger(s,n,i,o)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(t,...e){try{this.stateChangeCallbacks[t].forEach(([r,s])=>{try{s(...e)}catch(n){this.log("error",`error in ${t} callback`,n)}})}catch(r){this.log("error",`error triggering ${t} callbacks`,r)}}leaveOpenTopic(t){let e=this.channels.find(r=>r.topic===t&&(r.isJoined()||r.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}};class es{constructor(e,r){const s=rp(r);this.presence=new Zf(e.getChannel(),s),this.presence.onJoin((n,i,o)=>{const a=es.onJoinPayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onLeave((n,i,o)=>{const a=es.onLeavePayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return es.transformState(this.presence.state)}static transformState(e){return e=tp(e),Object.getOwnPropertyNames(e).reduce((r,s)=>{const n=e[s];return r[s]=Us(n),r},{})}static onJoinPayload(e,r,s){const n=Zo(r),i=Us(s);return{event:"join",key:e,currentPresences:n,newPresences:i}}static onLeavePayload(e,r,s){const n=Zo(r),i=Us(s);return{event:"leave",key:e,currentPresences:n,leftPresences:i}}}function Us(t){return t.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function tp(t){return JSON.parse(JSON.stringify(t))}function rp(t){return(t==null?void 0:t.events)&&{events:t.events}}function Zo(t){return t!=null&&t.metas?Us(t):[]}var ea;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(ea||(ea={}));class sp{get state(){return this.presenceAdapter.state}constructor(e,r){this.channel=e,this.presenceAdapter=new es(this.channel.channelAdapter,r)}}function np(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t&&typeof t=="object"){const e=t;if(typeof e.code=="number"){const r=typeof e.reason=="string"&&e.reason?` (${e.reason})`:"";return new Error(`socket closed: ${e.code}${r}`,{cause:t})}return new Error("channel error: transport failure",{cause:t})}return new Error("channel error: connection lost")}class ip{constructor(e,r,s){const n=op(s);this.channel=e.getSocket().channel(r,n),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,r){return this.channel.on(e,r)}off(e,r){this.channel.off(e,r)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,r,s){let n;try{n=this.channel.push(e,r,s)}catch{throw new Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>Uf){const i=this.channel.pushBuffer.shift();i.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${i.event}`,i.payload())}return n}updateJoinPayload(e){const r=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},r),e)}canPush(){return this.socket.isConnected()&&this.state===Ht.joined}isJoined(){return this.state===Ht.joined}isJoining(){return this.state===Ht.joining}isClosed(){return this.state===Ht.closed}isLeaving(){return this.state===Ht.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}function op(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}var ta;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(ta||(ta={}));var vr;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(vr||(vr={}));var St;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(St||(St={}));class ts{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,r={config:{}},s){var n,i;if(this.topic=e,this.params=r,this.socket=s,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.channelAdapter=new ip(this.socket.socketAdapter,e,this.params),this.presence=new sp(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=cc(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((i=(n=this.params.config)===null||n===void 0?void 0:n.broadcast)===null||i===void 0)&&i.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,r=this.timeout){var s,n,i;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:o,presence:a,private:l}}=this.params,c=(n=(s=this.bindings.postgres_changes)===null||s===void 0?void 0:s.map(f=>f.filter))!==null&&n!==void 0?n:[],u=!!this.bindings[vr.PRESENCE]&&this.bindings[vr.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,h={},d={broadcast:o,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:c,private:l};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(f=>{e==null||e(St.CHANNEL_ERROR,np(f))}),this._onClose(()=>e==null?void 0:e(St.CLOSED)),this.updateJoinPayload(Object.assign({config:d},h)),this._updateFilterMessage(),this.channelAdapter.subscribe(r).receive("ok",async({postgres_changes:f})=>{if(this.socket._isManualToken()||this.socket.setAuth(),f===void 0){e==null||e(St.SUBSCRIBED);return}this._updatePostgresBindings(f,e)}).receive("error",f=>{this.state=Ht.errored;const m=Object.values(f).join(", ")||"error";e==null||e(St.CHANNEL_ERROR,new Error(m,{cause:f}))}).receive("timeout",()=>{e==null||e(St.TIMED_OUT)})}return this}_updatePostgresBindings(e,r){var s;const n=this.bindings.postgres_changes,i=(s=n==null?void 0:n.length)!==null&&s!==void 0?s:0,o=[];for(let a=0;a<i;a++){const l=n[a],{filter:{event:c,schema:u,table:h,filter:d}}=l,f=e&&e[a];if(f&&f.event===c&&ts.isFilterValueEqual(f.schema,u)&&ts.isFilterValueEqual(f.table,h)&&ts.isFilterValueEqual(f.filter,d))o.push(Object.assign(Object.assign({},l),{id:f.id}));else{this.unsubscribe(),this.state=Ht.errored,r==null||r(St.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=o,this.state!=Ht.errored&&r&&r(St.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,s){const n=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),i=e===vr.PRESENCE||e===vr.POSTGRES_CHANGES;if(n&&i)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,r,s)}async httpSend(e,r,s={}){var n;if(r==null)return Promise.reject(new Error("Payload is required for httpSend()"));const i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(i.Authorization=`Bearer ${this.socket.accessTokenValue}`);const o={method:"POST",headers:i,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:r,private:this.private}]})},a=await this._fetchWithTimeout(this.broadcastEndpointURL,o,(n=s.timeout)!==null&&n!==void 0?n:this.timeout);if(a.status===202)return{success:!0};let l=a.statusText;try{const c=await a.json();l=c.error||c.message||l}catch{}return Promise.reject(new Error(l))}async send(e,r={}){var s,n;if(!this.channelAdapter.canPush()&&e.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:i,payload:o}=e,a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);const l={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const c=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(s=r.timeout)!==null&&s!==void 0?s:this.timeout);return await((n=c.body)===null||n===void 0?void 0:n.cancel()),c.ok?"ok":"error"}catch(c){return c instanceof Error&&c.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var o,a,l;const c=this.channelAdapter.push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(a=(o=this.params)===null||o===void 0?void 0:o.config)===null||a===void 0?void 0:a.broadcast)===null||l===void 0)&&l.ack)&&i("ok"),c.receive("ok",()=>i("ok")),c.receive("error",()=>i("error")),c.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(r=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>r("ok")).receive("timeout",()=>r("timed out")).receive("error",()=>r("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,r,s){const n=new AbortController,i=setTimeout(()=>n.abort(),s),o=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:n.signal}));return clearTimeout(i),o}_on(e,r,s){const n=e.toLocaleLowerCase(),i=this.channelAdapter.on(e,s),o={type:n,filter:r,callback:s,ref:i};return this.bindings[n]?this.bindings[n].push(o):this.bindings[n]=[o],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,r,s)=>{var n,i,o,a,l,c,u;const h=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(h,s))return!1;const d=(n=this.bindings[h])===null||n===void 0?void 0:n.find(f=>f.ref===e.ref);if(!d)return!0;if(["broadcast","presence","postgres_changes"].includes(h))if("id"in d){const f=d.id,m=(i=d.filter)===null||i===void 0?void 0:i.event;return f&&((o=r.ids)===null||o===void 0?void 0:o.includes(f))&&(m==="*"||(m==null?void 0:m.toLocaleLowerCase())===((a=r.data)===null||a===void 0?void 0:a.type.toLocaleLowerCase()))}else{const f=(c=(l=d==null?void 0:d.filter)===null||l===void 0?void 0:l.event)===null||c===void 0?void 0:c.toLocaleLowerCase();return f==="*"||f===((u=r==null?void 0:r.event)===null||u===void 0?void 0:u.toLocaleLowerCase())}else return d.type.toLocaleLowerCase()===h})}_notThisChannelEvent(e,r){const{close:s,error:n,leave:i,join:o}=ac;return r&&[s,n,i,o].includes(e)&&r!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,r,s)=>{if(typeof r=="object"&&"ids"in r){const n=r.data,{schema:i,table:o,commit_timestamp:a,type:l,errors:c}=n;return Object.assign(Object.assign({},{schema:i,table:o,commit_timestamp:a,eventType:l,new:{},old:{},errors:c}),this._getPayloadRecords(n))}return r})}copyBindings(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const r in e.bindings)for(const s of e.bindings[r])this._on(s.type,s.filter,s.callback)}static isFilterValueEqual(e,r){return(e??void 0)===(r??void 0)}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=Qo(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=Qo(e.columns,e.old_record)),r}}class ap{constructor(e,r){this.socket=new ep(e,r)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,r,s,n=1e4){return new Promise(i=>{setTimeout(()=>i("timeout"),n),this.socket.disconnect(()=>{e(),i("ok")},r,s)})}push(e){this.socket.push(e)}log(e,r,s){this.socket.log(e,r,s)}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==ui.connecting}isDisconnecting(){return this.socket.connectionState()==ui.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const ra={HEARTBEAT_INTERVAL:25e3},lp=[1e3,2e3,5e3,1e4],cp=1e4;function up(){const t=new Map;return{get length(){return t.size},clear(){t.clear()},getItem(e){return t.has(e)?t.get(e):null},key(e){var r;return(r=Array.from(t.keys())[e])!==null&&r!==void 0?r:null},removeItem(e){t.delete(e)},setItem(e,r){t.set(e,String(r))}}}function hp(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return up()}const dp=`
|
|
39
39
|
addEventListener("message", (e) => {
|
|
40
40
|
if (e.data.event === "start") {
|
|
41
41
|
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
|
|
42
42
|
}
|
|
43
|
-
});`;class fp{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,r){var s;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new
|
|
43
|
+
});`;class fp{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,r){var s;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new Mf,this._manuallySetToken=!1,this._authPromise=null,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=i=>i?(...o)=>i(...o):(...o)=>fetch(...o),!(!((s=r==null?void 0:r.params)===null||s===void 0)&&s.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey;const n=this._initializeOptions(r);this.socketAdapter=new ap(e,n),this.httpEndpoint=cc(e),this.fetch=this._resolveFetch(r==null?void 0:r.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(e){const r=e.message;throw r.includes("Node.js")?new Error(`${r}
|
|
44
44
|
|
|
45
45
|
To use Realtime in Node.js, you need to provide a WebSocket implementation:
|
|
46
46
|
|
|
@@ -53,86 +53,106 @@ Option 2: Install and provide the "ws" package:
|
|
|
53
53
|
const client = new RealtimeClient(url, {
|
|
54
54
|
...options,
|
|
55
55
|
transport: ws
|
|
56
|
-
})`):new Error(`WebSocket not available: ${r}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,r){return this._cancelPendingDisconnect(),this.isDisconnecting()?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,r)}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return r==="ok"&&e.teardown(),r}async removeAllChannels(){const e=this.channels.map(async s=>{const n=await s.unsubscribe();return s.teardown(),n}),r=await Promise.all(e);return await this.disconnect(),r}log(e,r,s){this.socketAdapter.log(e,r,s)}connectionState(){return this.socketAdapter.connectionState()||ui.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,r={config:{}}){const s=`realtime:${e}`,n=this.getChannels().find(i=>i.topic===s);if(n)return n;{const i=new ts(`realtime:${e}`,r,this);return this._cancelPendingDisconnect(),this.channels.push(i),i}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(r=>r.topic!==e.topic),this.channels.length===0&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),this._disconnectOnEmptyChannelsAfterMs===0){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,this.channels.length===0&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){this._pendingDisconnectTimer!==null&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e=null){let r,s=!1;if(e)r=e,s=!0;else if(this.accessToken)try{r=await this.accessToken()}catch(n){this.log("error","Error fetching access token from callback",n),r=this.accessTokenValue}else r=this.accessTokenValue;s?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{const i={access_token:r,version:Nf};r&&n.updateJoinPayload(i),n.joinedOnce&&n.channelAdapter.isJoined()&&n.channelAdapter.push(ac.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(r=>{this.log("error",`Error setting auth in ${e}`,r)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(r=>{this.log("error","error waiting for auth on connect",r)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(r,s)=>{r=="sent"&&this._setAuthSafely(),e&&e(r,s)}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let r;if(e)r=e;else{const s=new Blob([dp],{type:"application/javascript"});r=URL.createObjectURL(s)}return r}_initializeOptions(e){var r,s,n,i,o,a,l,c,u,h,d,f;this.worker=(r=e==null?void 0:e.worker)!==null&&r!==void 0?r:!1,this.accessToken=(s=e==null?void 0:e.accessToken)!==null&&s!==void 0?s:null;const m={};m.timeout=(n=e==null?void 0:e.timeout)!==null&&n!==void 0?n:Df,m.heartbeatIntervalMs=(i=e==null?void 0:e.heartbeatIntervalMs)!==null&&i!==void 0?i:ra.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=(o=e==null?void 0:e.disconnectOnEmptyChannelsAfterMs)!==null&&o!==void 0?o:2*((a=e==null?void 0:e.heartbeatIntervalMs)!==null&&a!==void 0?a:ra.HEARTBEAT_INTERVAL),m.transport=(l=e==null?void 0:e.transport)!==null&&l!==void 0?l:If.getWebSocketConstructor(),m.params=e==null?void 0:e.params,m.logger=e==null?void 0:e.logger,m.heartbeatCallback=this._wrapHeartbeatCallback(e==null?void 0:e.heartbeatCallback),m.sessionStorage=(c=e==null?void 0:e.sessionStorage)!==null&&c!==void 0?c:hp(),m.reconnectAfterMs=(u=e==null?void 0:e.reconnectAfterMs)!==null&&u!==void 0?u:(_=>lp[_-1]||cp);let v,A;const E=(h=e==null?void 0:e.vsn)!==null&&h!==void 0?h:Lf;switch(E){case $f:v=(_,b)=>b(JSON.stringify(_)),A=(_,b)=>b(JSON.parse(_));break;case oc:v=this.serializer.encode.bind(this.serializer),A=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${m.vsn}`)}if(m.vsn=E,m.encode=(d=e==null?void 0:e.encode)!==null&&d!==void 0?d:v,m.decode=(f=e==null?void 0:e.decode)!==null&&f!==void 0?f:A,m.beforeReconnect=this._reconnectAuth.bind(this),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,m.params=Object.assign(Object.assign({},m.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl,m.autoSendHeartbeat=!this.worker}return m}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var hs=class extends Error{constructor(t,e){var r;super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&((r=e.icebergType)==null?void 0:r.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function pp(t,e,r){const s=new URL(e,t);if(r)for(const[n,i]of Object.entries(r))i!==void 0&&s.searchParams.set(n,i);return s.toString()}async function gp(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function mp(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:r,path:s,query:n,body:i,headers:o}){const a=pp(t.baseUrl,s,n),l=await gp(t.auth),c=await e(a,{method:r,headers:{...i?{"Content-Type":"application/json"}:{},...l,...o},body:i?JSON.stringify(i):void 0}),u=await c.text(),h=(c.headers.get("content-type")||"").includes("application/json"),d=h&&u?JSON.parse(u):u;if(!c.ok){const f=h?d:void 0,m=f==null?void 0:f.error;throw new hs((m==null?void 0:m.message)??`Request failed with status ${c.status}`,{status:c.status,icebergType:m==null?void 0:m.type,icebergCode:m==null?void 0:m.code,details:f})}return{status:c.status,headers:c.headers,data:d}}}}function Rs(t){return t.join("")}var yp=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Rs(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(s=>({namespace:s}))}async createNamespace(t,e){const r={namespace:t.namespace,properties:e==null?void 0:e.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Rs(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Rs(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Rs(t.namespace)}`}),!0}catch(e){if(e instanceof hs&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(r){if(r instanceof hs&&r.status===409)return;throw r}}};function lr(t){return t.join("")}var vp=class{constructor(t,e="",r){this.client=t,this.prefix=e,this.accessDelegation=r}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${lr(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${lr(t.namespace)}/tables`,body:e,headers:r})).data.metadata}async updateTable(t,e){const r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${lr(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${lr(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String((e==null?void 0:e.purge)??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${lr(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${lr(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(r){if(r instanceof hs&&r.status===404)return!1;throw r}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(r){if(r instanceof hs&&r.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw r}}},_p=class{constructor(t){var s;let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const r=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=mp({baseUrl:r,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=(s=t.accessDelegation)==null?void 0:s.join(","),this.namespaceOps=new yp(this.client,e),this.tableOps=new vp(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}};function ds(t){"@babel/helpers - typeof";return ds=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ds(t)}function bp(t,e){if(ds(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(ds(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function wp(t){var e=bp(t,"string");return ds(e)=="symbol"?e:e+""}function Sp(t,e,r){return(e=wp(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function sa(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function F(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?sa(Object(r),!0).forEach(function(s){Sp(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):sa(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}var wn=class extends Error{constructor(t,e="storage",r,s){super(t),this.__isStorageError=!0,this.namespace=e,this.name=e==="vectors"?"StorageVectorsError":"StorageError",this.status=r,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function Sn(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var pi=class extends wn{constructor(t,e,r,s="storage"){super(t,s,e,r),this.name=s==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=e,this.statusCode=r}toJSON(){return F({},super.toJSON())}},hc=class extends wn{constructor(t,e,r="storage"){super(t,r),this.name=r==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};function zs(t,e,r){const s=F({},t),n=e.toLowerCase();for(const i of Object.keys(s))i.toLowerCase()===n&&delete s[i];return s[n]=r,s}function Ep(t){const e={};for(const[r,s]of Object.entries(t))e[r.toLowerCase()]=s;return e}const kp=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Ap=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},gi=t=>{if(Array.isArray(t))return t.map(r=>gi(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,s])=>{const n=r.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[n]=gi(s)}),e},Tp=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),na=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error;if(typeof e.error=="object"&&e.error!==null){const r=e.error;if(typeof r.message=="string")return r.message}}return JSON.stringify(t)},Rp=async(t,e,r,s)=>{if(t!==null&&typeof t=="object"&&"json"in t&&typeof t.json=="function"){const n=t;let i=parseInt(String(n.status),10);Number.isFinite(i)||(i=500),n.json().then(o=>{const a=(o==null?void 0:o.statusCode)||(o==null?void 0:o.code)||i+"";e(new pi(na(o),i,a,s))}).catch(()=>{const o=i+"";e(new pi(n.statusText||`HTTP ${i} error`,i,o,s))})}else e(new hc(na(t),t,s))},Op=(t,e,r,s)=>{const n={method:t,headers:(e==null?void 0:e.headers)||{}};if(t==="GET"||t==="HEAD"||!s)return F(F({},n),r);if(Ap(s)){var i;const o=(e==null?void 0:e.headers)||{};let a;for(const[l,c]of Object.entries(o))l.toLowerCase()==="content-type"&&(a=c);n.headers=zs(o,"Content-Type",(i=a)!==null&&i!==void 0?i:"application/json"),n.body=JSON.stringify(s)}else n.body=s;return e!=null&&e.duplex&&(n.duplex=e.duplex),F(F({},n),r)};async function Dr(t,e,r,s,n,i,o){return new Promise((a,l)=>{t(r,Op(e,s,n,i)).then(c=>{if(!c.ok)throw c;if(s!=null&&s.noResolveJson)return c;if(o==="vectors"){const u=c.headers.get("content-type");if(c.headers.get("content-length")==="0"||c.status===204)return{};if(!u||!u.includes("application/json"))return{}}return c.json()}).then(c=>a(c)).catch(c=>Rp(c,l,s,o))})}function dc(t="storage"){return{get:async(e,r,s,n)=>Dr(e,"GET",r,s,n,void 0,t),post:async(e,r,s,n,i)=>Dr(e,"POST",r,n,i,s,t),put:async(e,r,s,n,i)=>Dr(e,"PUT",r,n,i,s,t),head:async(e,r,s,n)=>Dr(e,"HEAD",r,F(F({},s),{},{noResolveJson:!0}),n,void 0,t),remove:async(e,r,s,n,i)=>Dr(e,"DELETE",r,n,i,s,t)}}const Cp=dc("storage"),{get:fs,post:Je,put:mi,head:Pp,remove:Fi}=Cp,Ue=dc("vectors");var Ir=class{constructor(t,e={},r,s="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=Ep(e),this.fetch=kp(r),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=zs(this.headers,t,e),this}async handleOperation(t){var e=this;try{return{data:await t(),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(Sn(r))return{data:null,error:r};throw r}}};let fc;fc=Symbol.toStringTag;var xp=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[fc]="StreamDownloadBuilder",this.promise=null}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(Sn(e))return{data:null,error:e};throw e}}};let pc;pc=Symbol.toStringTag;var Ip=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[pc]="BlobDownloadBuilder",this.promise=null}asStream(){return new xp(this.downloadFn,this.shouldThrowOnError)}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(Sn(e))return{data:null,error:e};throw e}}};const jp={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},ia={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var Np=class extends Ir{constructor(t,e={},r,s){super(t,e,s,"storage"),this.bucketId=r}async uploadOrUpdate(t,e,r,s){var n=this;return n.handleOperation(async()=>{let i;const o=F(F({},ia),s);let a=F(F({},n.headers),t==="POST"&&{"x-upsert":String(o.upsert)});const l=o.metadata;if(typeof Blob<"u"&&r instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),l&&i.append("metadata",n.encodeMetadata(l)),i.append("",r)):typeof FormData<"u"&&r instanceof FormData?(i=r,i.has("cacheControl")||i.append("cacheControl",o.cacheControl),l&&!i.has("metadata")&&i.append("metadata",n.encodeMetadata(l))):(i=r,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType,l&&(a["x-metadata"]=n.toBase64(n.encodeMetadata(l))),(typeof ReadableStream<"u"&&i instanceof ReadableStream||i&&typeof i=="object"&&"pipe"in i&&typeof i.pipe=="function")&&!o.duplex&&(o.duplex="half")),s!=null&&s.headers)for(const[d,f]of Object.entries(s.headers))a=zs(a,d,f);const c=n._removeEmptyFolders(e),u=n._getFinalPath(c),h=await(t=="PUT"?mi:Je)(n.fetch,`${n.url}/object/${u}`,i,F({headers:a},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{path:c,id:h.Id,fullPath:h.Key}})}async upload(t,e,r){return this.uploadOrUpdate("POST",t,e,r)}async uploadToSignedUrl(t,e,r,s){var n=this;const i=n._removeEmptyFolders(t),o=n._getFinalPath(i),a=new URL(n.url+`/object/upload/sign/${o}`);return a.searchParams.set("token",e),n.handleOperation(async()=>{let l;const c=F(F({},ia),s);let u=F(F({},n.headers),{"x-upsert":String(c.upsert)});const h=c.metadata;if(typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),h&&l.append("metadata",n.encodeMetadata(h)),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.has("cacheControl")||l.append("cacheControl",c.cacheControl),h&&!l.has("metadata")&&l.append("metadata",n.encodeMetadata(h))):(l=r,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType,h&&(u["x-metadata"]=n.toBase64(n.encodeMetadata(h))),(typeof ReadableStream<"u"&&l instanceof ReadableStream||l&&typeof l=="object"&&"pipe"in l&&typeof l.pipe=="function")&&!c.duplex&&(c.duplex="half")),s!=null&&s.headers)for(const[d,f]of Object.entries(s.headers))u=zs(u,d,f);return{path:i,fullPath:(await mi(n.fetch,a.toString(),l,F({headers:u},c!=null&&c.duplex?{duplex:c.duplex}:{}))).Key}})}async createSignedUploadUrl(t,e){var r=this;return r.handleOperation(async()=>{let s=r._getFinalPath(t);const n=F({},r.headers);e!=null&&e.upsert&&(n["x-upsert"]="true");const i=await Je(r.fetch,`${r.url}/object/upload/sign/${s}`,{},{headers:n}),o=new URL(r.url+i.url),a=o.searchParams.get("token");if(!a)throw new wn("No token returned by API");return{signedUrl:o.toString(),path:t,token:a}})}async update(t,e,r){return this.uploadOrUpdate("PUT",t,e,r)}async move(t,e,r){var s=this;return s.handleOperation(async()=>await Je(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r==null?void 0:r.destinationBucket},{headers:s.headers}))}async copy(t,e,r){var s=this;return s.handleOperation(async()=>({path:(await Je(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r==null?void 0:r.destinationBucket},{headers:s.headers})).Key}))}async createSignedUrl(t,e,r){var s=this;return s.handleOperation(async()=>{let n=s._getFinalPath(t);const i=typeof(r==null?void 0:r.transform)=="object"&&r.transform!==null&&Object.keys(r.transform).length>0;let o=await Je(s.fetch,`${s.url}/object/sign/${n}`,F({expiresIn:e},i?{transform:r.transform}:{}),{headers:s.headers});const a=new URLSearchParams;r!=null&&r.download&&a.set("download",r.download===!0?"":r.download),(r==null?void 0:r.cacheNonce)!=null&&a.set("cacheNonce",String(r.cacheNonce));const l=a.toString();return{signedUrl:encodeURI(`${s.url}${o.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(t,e,r){var s=this;return s.handleOperation(async()=>{const n=await Je(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:e,paths:t},{headers:s.headers}),i=new URLSearchParams;r!=null&&r.download&&i.set("download",r.download===!0?"":r.download),(r==null?void 0:r.cacheNonce)!=null&&i.set("cacheNonce",String(r.cacheNonce));const o=i.toString();return n.map(a=>F(F({},a),{},{signedUrl:a.signedURL?encodeURI(`${s.url}${a.signedURL}${o?`&${o}`:""}`):null}))})}download(t,e,r){const s=typeof(e==null?void 0:e.transform)=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image/authenticated":"object",n=new URLSearchParams;e!=null&&e.transform&&this.applyTransformOptsToQuery(n,e.transform),(e==null?void 0:e.cacheNonce)!=null&&n.set("cacheNonce",String(e.cacheNonce));const i=n.toString(),o=this._getFinalPath(t),a=()=>fs(this.fetch,`${this.url}/${s}/${o}${i?`?${i}`:""}`,{headers:this.headers,noResolveJson:!0},r);return new Ip(a,this.shouldThrowOnError)}async info(t){var e=this;const r=e._getFinalPath(t);return e.handleOperation(async()=>gi(await fs(e.fetch,`${e.url}/object/info/${r}`,{headers:e.headers})))}async exists(t){var e=this;const r=e._getFinalPath(t);try{return await Pp(e.fetch,`${e.url}/object/${r}`,{headers:e.headers}),{data:!0,error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(Sn(n)){var s;const i=n instanceof pi?n.status:n instanceof hc?(s=n.originalError)===null||s===void 0?void 0:s.status:void 0;if(i!==void 0&&[400,404].includes(i))return{data:!1,error:n}}throw n}}getPublicUrl(t,e){const r=this._getFinalPath(t),s=new URLSearchParams;e!=null&&e.download&&s.set("download",e.download===!0?"":e.download),e!=null&&e.transform&&this.applyTransformOptsToQuery(s,e.transform),(e==null?void 0:e.cacheNonce)!=null&&s.set("cacheNonce",String(e.cacheNonce));const n=s.toString(),i=typeof(e==null?void 0:e.transform)=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${r}`)+(n?`?${n}`:"")}}}async remove(t){var e=this;return e.handleOperation(async()=>await Fi(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async list(t,e,r){var s=this;return s.handleOperation(async()=>{const n=F(F(F({},jp),e),{},{prefix:t||""});return await Je(s.fetch,`${s.url}/object/list/${s.bucketId}`,n,{headers:s.headers},r)})}async listV2(t,e){var r=this;return r.handleOperation(async()=>{const s=F({},t);return await Je(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,s,{headers:r.headers},e)})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(t,e){return e.width&&t.set("width",e.width.toString()),e.height&&t.set("height",e.height.toString()),e.resize&&t.set("resize",e.resize),e.format&&t.set("format",e.format),e.quality&&t.set("quality",e.quality.toString()),t}};const $p="2.106.2",bs={"X-Client-Info":`storage-js/${$p}`};var Lp=class extends Ir{constructor(t,e={},r,s){const n=new URL(t);s!=null&&s.useNewHostname&&/supabase\.(co|in|red)$/.test(n.hostname)&&!n.hostname.includes("storage.supabase.")&&(n.hostname=n.hostname.replace("supabase.","storage.supabase."));const i=n.href.replace(/\/$/,""),o=F(F({},bs),e);super(i,o,r,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=e.listBucketOptionsToQueryString(t);return await fs(e.fetch,`${e.url}/bucket${r}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await fs(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var r=this;return r.handleOperation(async()=>await Je(r.fetch,`${r.url}/bucket`,{id:t,name:t,type:e.type,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:r.headers}))}async updateBucket(t,e){var r=this;return r.handleOperation(async()=>await mi(r.fetch,`${r.url}/bucket/${t}`,{id:t,name:t,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:r.headers}))}async emptyBucket(t){var e=this;return e.handleOperation(async()=>await Je(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Fi(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}listBucketOptionsToQueryString(t){const e={};return t&&("limit"in t&&(e.limit=String(t.limit)),"offset"in t&&(e.offset=String(t.offset)),t.search&&(e.search=t.search),t.sortColumn&&(e.sortColumn=t.sortColumn),t.sortOrder&&(e.sortOrder=t.sortOrder)),Object.keys(e).length>0?"?"+new URLSearchParams(e).toString():""}},Dp=class extends Ir{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=F(F({},bs),e);super(s,n,r,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await Je(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}))}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&r.set("limit",t.limit.toString()),(t==null?void 0:t.offset)!==void 0&&r.set("offset",t.offset.toString()),t!=null&&t.sortColumn&&r.set("sortColumn",t.sortColumn),t!=null&&t.sortOrder&&r.set("sortOrder",t.sortOrder),t!=null&&t.search&&r.set("search",t.search);const s=r.toString(),n=s?`${e.url}/bucket?${s}`:`${e.url}/bucket`;return await fs(e.fetch,n,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Fi(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!Tp(t))throw new wn("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const r=new _p({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),s=this.shouldThrowOnError;return new Proxy(r,{get(n,i){const o=n[i];return typeof o!="function"?o:async(...a)=>{try{return{data:await o.apply(n,a),error:null}}catch(l){if(s)throw l;return{data:null,error:l}}}}})}},Up=class extends Ir{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=F(F({},bs),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var r=this;return r.handleOperation(async()=>await Ue.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var r=this;return r.handleOperation(async()=>await Ue.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers})||{})}},Bp=class extends Ir{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=F(F({},bs),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async putVectors(t){var e=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}))}async listVectors(t){var e=this;if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}))}async deleteVectors(t){var e=this;if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},Mp=class extends Ir{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=F(F({},bs),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Ue.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},Hp=class extends Mp{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new Fp(this.url,this.headers,t,this.fetch)}async createBucket(t){var e=()=>super.createBucket,r=this;return e().call(r,t)}async getBucket(t){var e=()=>super.getBucket,r=this;return e().call(r,t)}async listBuckets(t={}){var e=()=>super.listBuckets,r=this;return e().call(r,t)}async deleteBucket(t){var e=()=>super.deleteBucket,r=this;return e().call(r,t)}},Fp=class extends Up{constructor(t,e,r,s){super(t,e,s),this.vectorBucketName=r}async createIndex(t){var e=()=>super.createIndex,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName}))}async getIndex(t){var e=()=>super.getIndex,r=this;return e().call(r,r.vectorBucketName,t)}async deleteIndex(t){var e=()=>super.deleteIndex,r=this;return e().call(r,r.vectorBucketName,t)}index(t){return new qp(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},qp=class extends Bp{constructor(t,e,r,s,n){super(t,e,n),this.vectorBucketName=r,this.indexName=s}async putVectors(t){var e=()=>super.putVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async getVectors(t){var e=()=>super.getVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}},Vp=class extends Lp{constructor(t,e={},r,s){super(t,e,r,s)}from(t){return new Np(this.url,this.headers,t,this.fetch)}get vectors(){return new Hp(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Dp(this.url+"/iceberg",this.headers,this.fetch)}};const gc="2.106.2",mr=30*1e3,yi=3,Mn=yi*mr,Kp="http://localhost:9999",Wp="supabase.auth.token",Gp={"X-Client-Info":`gotrue-js/${gc}`},vi="X-Supabase-Api-Version",mc={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},zp=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Jp=600*1e3;class Cr extends Error{constructor(e,r,s){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=s}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function x(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Yp extends Cr{constructor(e,r,s){super(e,r,s),this.name="AuthApiError",this.status=r,this.code=s}}function Xp(t){return x(t)&&t.name==="AuthApiError"}class Ye extends Cr{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class It extends Cr{constructor(e,r,s,n){super(e,s,n),this.name=r,this.status=s}}class ve extends It{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Os(t){return x(t)&&t.name==="AuthSessionMissingError"}class cr extends It{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Cs extends It{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Ps extends It{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}function Qp(t){return x(t)&&t.name==="AuthImplicitGrantRedirectError"}class oa extends It{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class Zp extends It{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class _i extends It{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function Hn(t){return x(t)&&t.name==="AuthRetryableFetchError"}class aa extends It{constructor(e,r,s){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class bi extends It{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const Js="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),la=`
|
|
57
|
-
\r=`.split(""),eg=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<la.length;e+=1)t[la[e].charCodeAt(0)]=-2;for(let e=0;e<Js.length;e+=1)t[Js[e].charCodeAt(0)]=e;return t})();function ca(t,e,r){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(Js[s]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(Js[s]),e.queuedBits-=6}}function yc(t,e,r){const s=eg[t];if(s>-1)for(e.queue=e.queue<<6|s,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(s===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function ua(t){const e=[],r=o=>{e.push(String.fromCodePoint(o))},s={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},i=o=>{sg(o,s,r)};for(let o=0;o<t.length;o+=1)yc(t.charCodeAt(o),n,i);return e.join("")}function tg(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function rg(t,e){for(let r=0;r<t.length;r+=1){let s=t.charCodeAt(r);if(s>55295&&s<=56319){const n=(s-55296)*1024&65535;s=(t.charCodeAt(r+1)-56320&65535|n)+65536,r+=1}tg(s,e)}}function sg(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let s=1;s<6;s+=1)if((t>>7-s&1)===0){e.utf8seq=s;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function Er(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};for(let n=0;n<t.length;n+=1)yc(t.charCodeAt(n),r,s);return new Uint8Array(e)}function ng(t){const e=[];return rg(t,r=>e.push(r)),new Uint8Array(e)}function er(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};return t.forEach(n=>ca(n,r,s)),ca(null,r,s),e.join("")}function ig(t){return Math.round(Date.now()/1e3)+t}function og(){return Symbol("auth-callback")}const we=()=>typeof window<"u"&&typeof document<"u",Jt={tested:!1,writable:!1},vc=()=>{if(!we())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Jt.tested)return Jt.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Jt.tested=!0,Jt.writable=!0}catch{Jt.tested=!0,Jt.writable=!1}return Jt.writable};function ag(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((n,i)=>{e[i]=n})}catch{}return r.searchParams.forEach((s,n)=>{e[n]=s}),e}const _c=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),lg=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",yr=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},Yt=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return null}},be=async(t,e)=>{await t.removeItem(e)};class En{constructor(){this.promise=new En.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}En.promiseConstructor=Promise;function xs(t){const e=t.split(".");if(e.length!==3)throw new bi("Invalid JWT structure");for(let s=0;s<e.length;s++)if(!zp.test(e[s]))throw new bi("JWT not in base64url format");return{header:JSON.parse(ua(e[0])),payload:JSON.parse(ua(e[1])),signature:Er(e[2]),raw:{header:e[0],payload:e[1]}}}async function cg(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function ug(t,e){return new Promise((s,n)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await t(i);if(!e(i,null,o)){s(o);return}}catch(o){if(!e(i,o)){n(o);return}}})()})}function hg(t){return("0"+t.toString(16)).substr(-2)}function dg(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",s=r.length;let n="";for(let i=0;i<56;i++)n+=r.charAt(Math.floor(Math.random()*s));return n}return crypto.getRandomValues(e),Array.from(e,hg).join("")}async function fg(t){const r=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",r),n=new Uint8Array(s);return Array.from(n).map(i=>String.fromCharCode(i)).join("")}async function pg(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await fg(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function ur(t,e,r=!1){const s=dg();let n=s;r&&(n+="/recovery"),await yr(t,`${e}-code-verifier`,n);const i=await pg(s);return[i,s===i?"plain":"s256"]}const gg=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function mg(t){const e=t.headers.get(vi);if(!e||!e.match(gg))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function yg(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function vg(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const _g=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function _t(t){if(!_g.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Ge(t){if(!t.passkey)throw new Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function Fn(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const s=r.toString();if(s==="Symbol(Symbol.toPrimitive)"||s==="Symbol(Symbol.toStringTag)"||s==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function bg(t,e){return new Proxy(t,{get:(r,s,n)=>{if(s==="__isInsecureUserWarningProxy")return!0;if(typeof s=="symbol"){const i=s.toString();if(i==="Symbol(Symbol.toPrimitive)"||i==="Symbol(Symbol.toStringTag)"||i==="Symbol(util.inspect.custom)"||i==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,s,n)}return!e.value&&typeof s=="string"&&(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."),e.value=!0),Reflect.get(r,s,n)}})}function ha(t){return JSON.parse(JSON.stringify(t))}const Qt=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error}return JSON.stringify(t)},wg=[502,503,504,520,521,522,523,524,530];async function da(t){var e;if(!lg(t))throw new _i(Qt(t),0);if(wg.includes(t.status))throw new _i(Qt(t),t.status);let r;try{r=await t.json()}catch(i){throw new Ye(Qt(i),i)}let s;const n=mg(t);if(n&&n.getTime()>=mc["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?s=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(s=r.error_code),s){if(s==="weak_password")throw new aa(Qt(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(s==="session_not_found")throw new ve}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((i,o)=>i&&typeof o=="string",!0))throw new aa(Qt(r),t.status,r.weak_password.reasons);throw new Yp(Qt(r),t.status||500,s)}const Sg=(t,e,r,s)=>{const n={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),n.body=JSON.stringify(s),Object.assign(Object.assign({},n),r))};async function L(t,e,r,s){var n;const i=Object.assign({},s==null?void 0:s.headers);i[vi]||(i[vi]=mc["2024-01-01"].name),s!=null&&s.jwt&&(i.Authorization=`Bearer ${s.jwt}`);const o=(n=s==null?void 0:s.query)!==null&&n!==void 0?n:{};s!=null&&s.redirectTo&&(o.redirect_to=s.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await Eg(t,e,r+a,{headers:i,noResolveJson:s==null?void 0:s.noResolveJson},{},s==null?void 0:s.body);return s!=null&&s.xform?s==null?void 0:s.xform(l):{data:Object.assign({},l),error:null}}async function Eg(t,e,r,s,n,i){const o=Sg(e,s,n,i);let a;try{a=await t(r,Object.assign({},o))}catch(l){throw console.error(l),new _i(Qt(l),0)}if(a.ok||await da(a),s!=null&&s.noResolveJson)return a;try{return await a.json()}catch(l){await da(l)}}function qe(t){var e;let r=null;Tg(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=ig(t.expires_in)));const s=(e=t.user)!==null&&e!==void 0?e:typeof(t==null?void 0:t.id)=="string"?t:null;return{data:{session:r,user:s},error:null}}function fa(t){const e=qe(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,s)=>r&&typeof s=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Ft(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function kg(t){return{data:t,error:null}}function Ag(t){const{action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:i}=t,o=bn(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:i},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function pa(t){return t}function Tg(t){return!!t.access_token&&!!t.refresh_token&&!!t.expires_in}const qn=["global","local","others"];class Rg{_encodePathSegment(e){if(e==="."||e==="..")throw new Cr("Invalid path segment");return encodeURIComponent(e)}constructor({url:e="",headers:r={},fetch:s,experimental:n}){this.url=e,this.headers=r,this.fetch=_c(s),this.experimental=n??{},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)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(e,r=qn[0]){if(qn.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${qn.join(", ")}`);try{return await L(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(s){if(x(s))return{data:null,error:s};throw s}}async inviteUserByEmail(e,r={}){try{return await L(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:Ft})}catch(s){if(x(s))return{data:{user:null},error:s};throw s}}async generateLink(e){try{const{options:r}=e,s=bn(e,["options"]),n=Object.assign(Object.assign({},s),r);return"newEmail"in s&&(n.new_email=s==null?void 0:s.newEmail,delete n.newEmail),await L(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:n,headers:this.headers,xform:Ag,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(x(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await L(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Ft})}catch(r){if(x(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,s,n,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await L(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(i=(n=e==null?void 0:e.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:pa});if(u.error)throw u.error;const h=await u.json(),d=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(m=>{const v=parseInt(m.split(";")[0].split("=")[1].substring(0,1)),A=JSON.parse(m.split(";")[1].split("=")[1]);c[`${A}Page`]=v}),c.total=parseInt(d)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(x(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){_t(e);try{return await L(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Ft})}catch(r){if(x(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){_t(e);try{return await L(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:Ft})}catch(s){if(x(s))return{data:{user:null},error:s};throw s}}async deleteUser(e,r=!1){_t(e);try{return await L(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:Ft})}catch(s){if(x(s))return{data:{user:null},error:s};throw s}}async _listFactors(e){_t(e.userId);try{const{data:r,error:s}=await L(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:r,error:s}}catch(r){if(x(r))return{data:null,error:r};throw r}}async _deleteFactor(e){_t(e.userId),_t(e.id);try{return{data:await L(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(x(r))return{data:null,error:r};throw r}}async _listOAuthClients(e){var r,s,n,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await L(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(i=(n=e==null?void 0:e.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:pa});if(u.error)throw u.error;const h=await u.json(),d=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(m=>{const v=parseInt(m.split(";")[0].split("=")[1].substring(0,1)),A=JSON.parse(m.split(";")[1].split("=")[1]);c[`${A}Page`]=v}),c.total=parseInt(d)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(x(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await L(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _getOAuthClient(e){try{const r=this._encodePathSegment(e);return await L(this.fetch,"GET",`${this.url}/admin/oauth/clients/${r}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _updateOAuthClient(e,r){try{const s=this._encodePathSegment(e);return await L(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(s){if(x(s))return{data:null,error:s};throw s}}async _deleteOAuthClient(e){try{const r=this._encodePathSegment(e);return await L(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${r}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(x(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(e){try{const r=this._encodePathSegment(e);return await L(this.fetch,"POST",`${this.url}/admin/oauth/clients/${r}/regenerate_secret`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _listCustomProviders(e){try{const r={};return e!=null&&e.type&&(r.type=e.type),await L(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:r,xform:s=>{var n;return{data:{providers:(n=s==null?void 0:s.providers)!==null&&n!==void 0?n:[]},error:null}}})}catch(r){if(x(r))return{data:{providers:[]},error:r};throw r}}async _createCustomProvider(e){try{return await L(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _getCustomProvider(e){try{const r=this._encodePathSegment(e);return await L(this.fetch,"GET",`${this.url}/admin/custom-providers/${r}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _updateCustomProvider(e,r){try{const s=this._encodePathSegment(e);return await L(this.fetch,"PUT",`${this.url}/admin/custom-providers/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(s){if(x(s))return{data:null,error:s};throw s}}async _deleteCustomProvider(e){try{const r=this._encodePathSegment(e);return await L(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${r}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(x(r))return{data:null,error:r};throw r}}async _adminListPasskeys(e){Ge(this.experimental),_t(e.userId);try{return await L(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _adminDeletePasskey(e){Ge(this.experimental),_t(e.userId),_t(e.passkeyId);try{return await L(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(x(r))return{data:null,error:r};throw r}}}function ga(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}const ot={debug:!!(globalThis&&vc()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class bc extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class ma extends bc{}async function Og(t,e,r){ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const s=new globalThis.AbortController;let n;e>0&&(n=setTimeout(()=>{s.abort(),ot.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e)),await Promise.resolve();try{return await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:s.signal},async i=>{if(i){clearTimeout(n),ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,i.name);try{return await r()}finally{ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,i.name)}}else{if(e===0)throw ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new ma(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(ot.debug)try{const o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}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"),clearTimeout(n),await r()}})}catch(i){if(e>0&&clearTimeout(n),i!==null&&typeof i=="object"&&"name"in i&&i.name==="AbortError"&&e>0){if(s.signal.aborted)return ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",t),console.warn(`@supabase/gotrue-js: Lock "${t}" was not released within ${e}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,{mode:"exclusive",steal:!0},async o=>{if(o){ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",t,o.name);try{return await r()}finally{ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",t,o.name)}}else return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await r()}));throw ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",t),new ma(`Lock "${t}" was released because another request stole it`)}throw i}}function Cg(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function wc(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Pg(t){return parseInt(t,16)}function xg(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,s=>s.toString(16).padStart(2,"0")).join("")}function Ig(t){var e;const{chainId:r,domain:s,expirationTime:n,issuedAt:i=new Date,nonce:o,notBefore:a,requestId:l,resources:c,scheme:u,uri:h,version:d}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!h)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(d!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${d}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
|
|
58
|
-
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const f=wc(t.address),m=u?`${u}://${s}`:s,
|
|
56
|
+
})`):new Error(`WebSocket not available: ${r}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,r){return this._cancelPendingDisconnect(),this.isDisconnecting()?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,r)}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return r==="ok"&&e.teardown(),r}async removeAllChannels(){const e=this.channels.map(async s=>{const n=await s.unsubscribe();return s.teardown(),n}),r=await Promise.all(e);return await this.disconnect(),r}log(e,r,s){this.socketAdapter.log(e,r,s)}connectionState(){return this.socketAdapter.connectionState()||ui.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,r={config:{}}){const s=`realtime:${e}`,n=this.getChannels().find(i=>i.topic===s);if(n)return n;{const i=new ts(`realtime:${e}`,r,this);return this._cancelPendingDisconnect(),this.channels.push(i),i}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(r=>r.topic!==e.topic),this.channels.length===0&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),this._disconnectOnEmptyChannelsAfterMs===0){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,this.channels.length===0&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){this._pendingDisconnectTimer!==null&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e=null){let r,s=!1;if(e)r=e,s=!0;else if(this.accessToken)try{r=await this.accessToken()}catch(n){this.log("error","Error fetching access token from callback",n),r=this.accessTokenValue}else r=this.accessTokenValue;s?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{const i={access_token:r,version:Nf};r&&n.updateJoinPayload(i),n.joinedOnce&&n.channelAdapter.isJoined()&&n.channelAdapter.push(ac.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(r=>{this.log("error",`Error setting auth in ${e}`,r)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(r=>{this.log("error","error waiting for auth on connect",r)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(r,s)=>{r=="sent"&&this._setAuthSafely(),e&&e(r,s)}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let r;if(e)r=e;else{const s=new Blob([dp],{type:"application/javascript"});r=URL.createObjectURL(s)}return r}_initializeOptions(e){var r,s,n,i,o,a,l,c,u,h,d,f;this.worker=(r=e==null?void 0:e.worker)!==null&&r!==void 0?r:!1,this.accessToken=(s=e==null?void 0:e.accessToken)!==null&&s!==void 0?s:null;const m={};m.timeout=(n=e==null?void 0:e.timeout)!==null&&n!==void 0?n:Df,m.heartbeatIntervalMs=(i=e==null?void 0:e.heartbeatIntervalMs)!==null&&i!==void 0?i:ra.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=(o=e==null?void 0:e.disconnectOnEmptyChannelsAfterMs)!==null&&o!==void 0?o:2*((a=e==null?void 0:e.heartbeatIntervalMs)!==null&&a!==void 0?a:ra.HEARTBEAT_INTERVAL),m.transport=(l=e==null?void 0:e.transport)!==null&&l!==void 0?l:If.getWebSocketConstructor(),m.params=e==null?void 0:e.params,m.logger=e==null?void 0:e.logger,m.heartbeatCallback=this._wrapHeartbeatCallback(e==null?void 0:e.heartbeatCallback),m.sessionStorage=(c=e==null?void 0:e.sessionStorage)!==null&&c!==void 0?c:hp(),m.reconnectAfterMs=(u=e==null?void 0:e.reconnectAfterMs)!==null&&u!==void 0?u:(v=>lp[v-1]||cp);let _,A;const E=(h=e==null?void 0:e.vsn)!==null&&h!==void 0?h:$f;switch(E){case Lf:_=(v,b)=>b(JSON.stringify(v)),A=(v,b)=>b(JSON.parse(v));break;case oc:_=this.serializer.encode.bind(this.serializer),A=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${m.vsn}`)}if(m.vsn=E,m.encode=(d=e==null?void 0:e.encode)!==null&&d!==void 0?d:_,m.decode=(f=e==null?void 0:e.decode)!==null&&f!==void 0?f:A,m.beforeReconnect=this._reconnectAuth.bind(this),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,m.params=Object.assign(Object.assign({},m.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl,m.autoSendHeartbeat=!this.worker}return m}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var hs=class extends Error{constructor(t,e){var r;super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&((r=e.icebergType)==null?void 0:r.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function pp(t,e,r){const s=new URL(e,t);if(r)for(const[n,i]of Object.entries(r))i!==void 0&&s.searchParams.set(n,i);return s.toString()}async function gp(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function mp(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:r,path:s,query:n,body:i,headers:o}){const a=pp(t.baseUrl,s,n),l=await gp(t.auth),c=await e(a,{method:r,headers:{...i?{"Content-Type":"application/json"}:{},...l,...o},body:i?JSON.stringify(i):void 0}),u=await c.text(),h=(c.headers.get("content-type")||"").includes("application/json"),d=h&&u?JSON.parse(u):u;if(!c.ok){const f=h?d:void 0,m=f==null?void 0:f.error;throw new hs((m==null?void 0:m.message)??`Request failed with status ${c.status}`,{status:c.status,icebergType:m==null?void 0:m.type,icebergCode:m==null?void 0:m.code,details:f})}return{status:c.status,headers:c.headers,data:d}}}}function Os(t){return t.join("")}var yp=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Os(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(s=>({namespace:s}))}async createNamespace(t,e){const r={namespace:t.namespace,properties:e==null?void 0:e.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Os(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Os(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Os(t.namespace)}`}),!0}catch(e){if(e instanceof hs&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(r){if(r instanceof hs&&r.status===409)return;throw r}}};function cr(t){return t.join("")}var _p=class{constructor(t,e="",r){this.client=t,this.prefix=e,this.accessDelegation=r}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${cr(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${cr(t.namespace)}/tables`,body:e,headers:r})).data.metadata}async updateTable(t,e){const r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${cr(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${cr(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String((e==null?void 0:e.purge)??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${cr(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${cr(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(r){if(r instanceof hs&&r.status===404)return!1;throw r}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(r){if(r instanceof hs&&r.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw r}}},vp=class{constructor(t){var s;let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const r=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=mp({baseUrl:r,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=(s=t.accessDelegation)==null?void 0:s.join(","),this.namespaceOps=new yp(this.client,e),this.tableOps=new _p(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}};function ds(t){"@babel/helpers - typeof";return ds=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ds(t)}function bp(t,e){if(ds(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(ds(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function wp(t){var e=bp(t,"string");return ds(e)=="symbol"?e:e+""}function Sp(t,e,r){return(e=wp(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function sa(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function F(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?sa(Object(r),!0).forEach(function(s){Sp(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):sa(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}var Sn=class extends Error{constructor(t,e="storage",r,s){super(t),this.__isStorageError=!0,this.namespace=e,this.name=e==="vectors"?"StorageVectorsError":"StorageError",this.status=r,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function En(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var pi=class extends Sn{constructor(t,e,r,s="storage"){super(t,s,e,r),this.name=s==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=e,this.statusCode=r}toJSON(){return F({},super.toJSON())}},hc=class extends Sn{constructor(t,e,r="storage"){super(t,r),this.name=r==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};function Ys(t,e,r){const s=F({},t),n=e.toLowerCase();for(const i of Object.keys(s))i.toLowerCase()===n&&delete s[i];return s[n]=r,s}function Ep(t){const e={};for(const[r,s]of Object.entries(t))e[r.toLowerCase()]=s;return e}const kp=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Ap=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},gi=t=>{if(Array.isArray(t))return t.map(r=>gi(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,s])=>{const n=r.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[n]=gi(s)}),e},Tp=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),na=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error;if(typeof e.error=="object"&&e.error!==null){const r=e.error;if(typeof r.message=="string")return r.message}}return JSON.stringify(t)},Rp=async(t,e,r,s)=>{if(t!==null&&typeof t=="object"&&"json"in t&&typeof t.json=="function"){const n=t;let i=parseInt(String(n.status),10);Number.isFinite(i)||(i=500),n.json().then(o=>{const a=(o==null?void 0:o.statusCode)||(o==null?void 0:o.code)||i+"";e(new pi(na(o),i,a,s))}).catch(()=>{const o=i+"";e(new pi(n.statusText||`HTTP ${i} error`,i,o,s))})}else e(new hc(na(t),t,s))},Op=(t,e,r,s)=>{const n={method:t,headers:(e==null?void 0:e.headers)||{}};if(t==="GET"||t==="HEAD"||!s)return F(F({},n),r);if(Ap(s)){var i;const o=(e==null?void 0:e.headers)||{};let a;for(const[l,c]of Object.entries(o))l.toLowerCase()==="content-type"&&(a=c);n.headers=Ys(o,"Content-Type",(i=a)!==null&&i!==void 0?i:"application/json"),n.body=JSON.stringify(s)}else n.body=s;return e!=null&&e.duplex&&(n.duplex=e.duplex),F(F({},n),r)};async function Dr(t,e,r,s,n,i,o){return new Promise((a,l)=>{t(r,Op(e,s,n,i)).then(c=>{if(!c.ok)throw c;if(s!=null&&s.noResolveJson)return c;if(o==="vectors"){const u=c.headers.get("content-type");if(c.headers.get("content-length")==="0"||c.status===204)return{};if(!u||!u.includes("application/json"))return{}}return c.json()}).then(c=>a(c)).catch(c=>Rp(c,l,s,o))})}function dc(t="storage"){return{get:async(e,r,s,n)=>Dr(e,"GET",r,s,n,void 0,t),post:async(e,r,s,n,i)=>Dr(e,"POST",r,n,i,s,t),put:async(e,r,s,n,i)=>Dr(e,"PUT",r,n,i,s,t),head:async(e,r,s,n)=>Dr(e,"HEAD",r,F(F({},s),{},{noResolveJson:!0}),n,void 0,t),remove:async(e,r,s,n,i)=>Dr(e,"DELETE",r,n,i,s,t)}}const Cp=dc("storage"),{get:fs,post:Ye,put:mi,head:Pp,remove:Fi}=Cp,Me=dc("vectors");var Ir=class{constructor(t,e={},r,s="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=Ep(e),this.fetch=kp(r),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=Ys(this.headers,t,e),this}async handleOperation(t){var e=this;try{return{data:await t(),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(En(r))return{data:null,error:r};throw r}}};let fc;fc=Symbol.toStringTag;var xp=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[fc]="StreamDownloadBuilder",this.promise=null}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(En(e))return{data:null,error:e};throw e}}};let pc;pc=Symbol.toStringTag;var Ip=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[pc]="BlobDownloadBuilder",this.promise=null}asStream(){return new xp(this.downloadFn,this.shouldThrowOnError)}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(En(e))return{data:null,error:e};throw e}}};const jp={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},ia={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var Np=class extends Ir{constructor(t,e={},r,s){super(t,e,s,"storage"),this.bucketId=r}async uploadOrUpdate(t,e,r,s){var n=this;return n.handleOperation(async()=>{let i;const o=F(F({},ia),s);let a=F(F({},n.headers),t==="POST"&&{"x-upsert":String(o.upsert)});const l=o.metadata;if(typeof Blob<"u"&&r instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),l&&i.append("metadata",n.encodeMetadata(l)),i.append("",r)):typeof FormData<"u"&&r instanceof FormData?(i=r,i.has("cacheControl")||i.append("cacheControl",o.cacheControl),l&&!i.has("metadata")&&i.append("metadata",n.encodeMetadata(l))):(i=r,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType,l&&(a["x-metadata"]=n.toBase64(n.encodeMetadata(l))),(typeof ReadableStream<"u"&&i instanceof ReadableStream||i&&typeof i=="object"&&"pipe"in i&&typeof i.pipe=="function")&&!o.duplex&&(o.duplex="half")),s!=null&&s.headers)for(const[d,f]of Object.entries(s.headers))a=Ys(a,d,f);const c=n._removeEmptyFolders(e),u=n._getFinalPath(c),h=await(t=="PUT"?mi:Ye)(n.fetch,`${n.url}/object/${u}`,i,F({headers:a},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{path:c,id:h.Id,fullPath:h.Key}})}async upload(t,e,r){return this.uploadOrUpdate("POST",t,e,r)}async uploadToSignedUrl(t,e,r,s){var n=this;const i=n._removeEmptyFolders(t),o=n._getFinalPath(i),a=new URL(n.url+`/object/upload/sign/${o}`);return a.searchParams.set("token",e),n.handleOperation(async()=>{let l;const c=F(F({},ia),s);let u=F(F({},n.headers),{"x-upsert":String(c.upsert)});const h=c.metadata;if(typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),h&&l.append("metadata",n.encodeMetadata(h)),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.has("cacheControl")||l.append("cacheControl",c.cacheControl),h&&!l.has("metadata")&&l.append("metadata",n.encodeMetadata(h))):(l=r,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType,h&&(u["x-metadata"]=n.toBase64(n.encodeMetadata(h))),(typeof ReadableStream<"u"&&l instanceof ReadableStream||l&&typeof l=="object"&&"pipe"in l&&typeof l.pipe=="function")&&!c.duplex&&(c.duplex="half")),s!=null&&s.headers)for(const[d,f]of Object.entries(s.headers))u=Ys(u,d,f);return{path:i,fullPath:(await mi(n.fetch,a.toString(),l,F({headers:u},c!=null&&c.duplex?{duplex:c.duplex}:{}))).Key}})}async createSignedUploadUrl(t,e){var r=this;return r.handleOperation(async()=>{let s=r._getFinalPath(t);const n=F({},r.headers);e!=null&&e.upsert&&(n["x-upsert"]="true");const i=await Ye(r.fetch,`${r.url}/object/upload/sign/${s}`,{},{headers:n}),o=new URL(r.url+i.url),a=o.searchParams.get("token");if(!a)throw new Sn("No token returned by API");return{signedUrl:o.toString(),path:t,token:a}})}async update(t,e,r){return this.uploadOrUpdate("PUT",t,e,r)}async move(t,e,r){var s=this;return s.handleOperation(async()=>await Ye(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r==null?void 0:r.destinationBucket},{headers:s.headers}))}async copy(t,e,r){var s=this;return s.handleOperation(async()=>({path:(await Ye(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r==null?void 0:r.destinationBucket},{headers:s.headers})).Key}))}async createSignedUrl(t,e,r){var s=this;return s.handleOperation(async()=>{let n=s._getFinalPath(t);const i=typeof(r==null?void 0:r.transform)=="object"&&r.transform!==null&&Object.keys(r.transform).length>0;let o=await Ye(s.fetch,`${s.url}/object/sign/${n}`,F({expiresIn:e},i?{transform:r.transform}:{}),{headers:s.headers});const a=new URLSearchParams;r!=null&&r.download&&a.set("download",r.download===!0?"":r.download),(r==null?void 0:r.cacheNonce)!=null&&a.set("cacheNonce",String(r.cacheNonce));const l=a.toString();return{signedUrl:encodeURI(`${s.url}${o.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(t,e,r){var s=this;return s.handleOperation(async()=>{const n=await Ye(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:e,paths:t},{headers:s.headers}),i=new URLSearchParams;r!=null&&r.download&&i.set("download",r.download===!0?"":r.download),(r==null?void 0:r.cacheNonce)!=null&&i.set("cacheNonce",String(r.cacheNonce));const o=i.toString();return n.map(a=>F(F({},a),{},{signedUrl:a.signedURL?encodeURI(`${s.url}${a.signedURL}${o?`&${o}`:""}`):null}))})}download(t,e,r){const s=typeof(e==null?void 0:e.transform)=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image/authenticated":"object",n=new URLSearchParams;e!=null&&e.transform&&this.applyTransformOptsToQuery(n,e.transform),(e==null?void 0:e.cacheNonce)!=null&&n.set("cacheNonce",String(e.cacheNonce));const i=n.toString(),o=this._getFinalPath(t),a=()=>fs(this.fetch,`${this.url}/${s}/${o}${i?`?${i}`:""}`,{headers:this.headers,noResolveJson:!0},r);return new Ip(a,this.shouldThrowOnError)}async info(t){var e=this;const r=e._getFinalPath(t);return e.handleOperation(async()=>gi(await fs(e.fetch,`${e.url}/object/info/${r}`,{headers:e.headers})))}async exists(t){var e=this;const r=e._getFinalPath(t);try{return await Pp(e.fetch,`${e.url}/object/${r}`,{headers:e.headers}),{data:!0,error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(En(n)){var s;const i=n instanceof pi?n.status:n instanceof hc?(s=n.originalError)===null||s===void 0?void 0:s.status:void 0;if(i!==void 0&&[400,404].includes(i))return{data:!1,error:n}}throw n}}getPublicUrl(t,e){const r=this._getFinalPath(t),s=new URLSearchParams;e!=null&&e.download&&s.set("download",e.download===!0?"":e.download),e!=null&&e.transform&&this.applyTransformOptsToQuery(s,e.transform),(e==null?void 0:e.cacheNonce)!=null&&s.set("cacheNonce",String(e.cacheNonce));const n=s.toString(),i=typeof(e==null?void 0:e.transform)=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${r}`)+(n?`?${n}`:"")}}}async remove(t){var e=this;return e.handleOperation(async()=>await Fi(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async list(t,e,r){var s=this;return s.handleOperation(async()=>{const n=F(F(F({},jp),e),{},{prefix:t||""});return await Ye(s.fetch,`${s.url}/object/list/${s.bucketId}`,n,{headers:s.headers},r)})}async listV2(t,e){var r=this;return r.handleOperation(async()=>{const s=F({},t);return await Ye(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,s,{headers:r.headers},e)})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(t,e){return e.width&&t.set("width",e.width.toString()),e.height&&t.set("height",e.height.toString()),e.resize&&t.set("resize",e.resize),e.format&&t.set("format",e.format),e.quality&&t.set("quality",e.quality.toString()),t}};const Lp="2.106.2",ws={"X-Client-Info":`storage-js/${Lp}`};var $p=class extends Ir{constructor(t,e={},r,s){const n=new URL(t);s!=null&&s.useNewHostname&&/supabase\.(co|in|red)$/.test(n.hostname)&&!n.hostname.includes("storage.supabase.")&&(n.hostname=n.hostname.replace("supabase.","storage.supabase."));const i=n.href.replace(/\/$/,""),o=F(F({},ws),e);super(i,o,r,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=e.listBucketOptionsToQueryString(t);return await fs(e.fetch,`${e.url}/bucket${r}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await fs(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var r=this;return r.handleOperation(async()=>await Ye(r.fetch,`${r.url}/bucket`,{id:t,name:t,type:e.type,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:r.headers}))}async updateBucket(t,e){var r=this;return r.handleOperation(async()=>await mi(r.fetch,`${r.url}/bucket/${t}`,{id:t,name:t,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:r.headers}))}async emptyBucket(t){var e=this;return e.handleOperation(async()=>await Ye(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Fi(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}listBucketOptionsToQueryString(t){const e={};return t&&("limit"in t&&(e.limit=String(t.limit)),"offset"in t&&(e.offset=String(t.offset)),t.search&&(e.search=t.search),t.sortColumn&&(e.sortColumn=t.sortColumn),t.sortOrder&&(e.sortOrder=t.sortOrder)),Object.keys(e).length>0?"?"+new URLSearchParams(e).toString():""}},Dp=class extends Ir{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=F(F({},ws),e);super(s,n,r,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await Ye(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}))}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&r.set("limit",t.limit.toString()),(t==null?void 0:t.offset)!==void 0&&r.set("offset",t.offset.toString()),t!=null&&t.sortColumn&&r.set("sortColumn",t.sortColumn),t!=null&&t.sortOrder&&r.set("sortOrder",t.sortOrder),t!=null&&t.search&&r.set("search",t.search);const s=r.toString(),n=s?`${e.url}/bucket?${s}`:`${e.url}/bucket`;return await fs(e.fetch,n,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Fi(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!Tp(t))throw new Sn("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const r=new vp({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),s=this.shouldThrowOnError;return new Proxy(r,{get(n,i){const o=n[i];return typeof o!="function"?o:async(...a)=>{try{return{data:await o.apply(n,a),error:null}}catch(l){if(s)throw l;return{data:null,error:l}}}}})}},Up=class extends Ir{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=F(F({},ws),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var r=this;return r.handleOperation(async()=>await Me.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var r=this;return r.handleOperation(async()=>await Me.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers})||{})}},Mp=class extends Ir{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=F(F({},ws),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async putVectors(t){var e=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}))}async listVectors(t){var e=this;if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}))}async deleteVectors(t){var e=this;if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},Bp=class extends Ir{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=F(F({},ws),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Me.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},Hp=class extends Bp{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new Fp(this.url,this.headers,t,this.fetch)}async createBucket(t){var e=()=>super.createBucket,r=this;return e().call(r,t)}async getBucket(t){var e=()=>super.getBucket,r=this;return e().call(r,t)}async listBuckets(t={}){var e=()=>super.listBuckets,r=this;return e().call(r,t)}async deleteBucket(t){var e=()=>super.deleteBucket,r=this;return e().call(r,t)}},Fp=class extends Up{constructor(t,e,r,s){super(t,e,s),this.vectorBucketName=r}async createIndex(t){var e=()=>super.createIndex,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName}))}async getIndex(t){var e=()=>super.getIndex,r=this;return e().call(r,r.vectorBucketName,t)}async deleteIndex(t){var e=()=>super.deleteIndex,r=this;return e().call(r,r.vectorBucketName,t)}index(t){return new qp(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},qp=class extends Mp{constructor(t,e,r,s,n){super(t,e,n),this.vectorBucketName=r,this.indexName=s}async putVectors(t){var e=()=>super.putVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async getVectors(t){var e=()=>super.getVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,r=this;return e().call(r,F(F({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}},Vp=class extends $p{constructor(t,e={},r,s){super(t,e,r,s)}from(t){return new Np(this.url,this.headers,t,this.fetch)}get vectors(){return new Hp(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Dp(this.url+"/iceberg",this.headers,this.fetch)}};const gc="2.106.2",yr=30*1e3,yi=3,Hn=yi*yr,Kp="http://localhost:9999",Wp="supabase.auth.token",Gp={"X-Client-Info":`gotrue-js/${gc}`},_i="X-Supabase-Api-Version",mc={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},zp=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Jp=600*1e3;class Cr extends Error{constructor(e,r,s){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=s}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function x(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Yp extends Cr{constructor(e,r,s){super(e,r,s),this.name="AuthApiError",this.status=r,this.code=s}}function Xp(t){return x(t)&&t.name==="AuthApiError"}class Xe extends Cr{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class jt extends Cr{constructor(e,r,s,n){super(e,s,n),this.name=r,this.status=s}}class _e extends jt{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Cs(t){return x(t)&&t.name==="AuthSessionMissingError"}class ur extends jt{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Ps extends jt{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class xs extends jt{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}function Qp(t){return x(t)&&t.name==="AuthImplicitGrantRedirectError"}class oa extends jt{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class Zp extends jt{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class vi extends jt{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function Fn(t){return x(t)&&t.name==="AuthRetryableFetchError"}class aa extends jt{constructor(e,r,s){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class bi extends jt{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const Xs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),la=`
|
|
57
|
+
\r=`.split(""),eg=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<la.length;e+=1)t[la[e].charCodeAt(0)]=-2;for(let e=0;e<Xs.length;e+=1)t[Xs[e].charCodeAt(0)]=e;return t})();function ca(t,e,r){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(Xs[s]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(Xs[s]),e.queuedBits-=6}}function yc(t,e,r){const s=eg[t];if(s>-1)for(e.queue=e.queue<<6|s,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(s===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function ua(t){const e=[],r=o=>{e.push(String.fromCodePoint(o))},s={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},i=o=>{sg(o,s,r)};for(let o=0;o<t.length;o+=1)yc(t.charCodeAt(o),n,i);return e.join("")}function tg(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function rg(t,e){for(let r=0;r<t.length;r+=1){let s=t.charCodeAt(r);if(s>55295&&s<=56319){const n=(s-55296)*1024&65535;s=(t.charCodeAt(r+1)-56320&65535|n)+65536,r+=1}tg(s,e)}}function sg(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let s=1;s<6;s+=1)if((t>>7-s&1)===0){e.utf8seq=s;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function Er(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};for(let n=0;n<t.length;n+=1)yc(t.charCodeAt(n),r,s);return new Uint8Array(e)}function ng(t){const e=[];return rg(t,r=>e.push(r)),new Uint8Array(e)}function er(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};return t.forEach(n=>ca(n,r,s)),ca(null,r,s),e.join("")}function ig(t){return Math.round(Date.now()/1e3)+t}function og(){return Symbol("auth-callback")}const we=()=>typeof window<"u"&&typeof document<"u",Jt={tested:!1,writable:!1},_c=()=>{if(!we())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Jt.tested)return Jt.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Jt.tested=!0,Jt.writable=!0}catch{Jt.tested=!0,Jt.writable=!1}return Jt.writable};function ag(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((n,i)=>{e[i]=n})}catch{}return r.searchParams.forEach((s,n)=>{e[n]=s}),e}const vc=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),lg=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",_r=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},Yt=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return null}},be=async(t,e)=>{await t.removeItem(e)};class kn{constructor(){this.promise=new kn.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}kn.promiseConstructor=Promise;function Is(t){const e=t.split(".");if(e.length!==3)throw new bi("Invalid JWT structure");for(let s=0;s<e.length;s++)if(!zp.test(e[s]))throw new bi("JWT not in base64url format");return{header:JSON.parse(ua(e[0])),payload:JSON.parse(ua(e[1])),signature:Er(e[2]),raw:{header:e[0],payload:e[1]}}}async function cg(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function ug(t,e){return new Promise((s,n)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await t(i);if(!e(i,null,o)){s(o);return}}catch(o){if(!e(i,o)){n(o);return}}})()})}function hg(t){return("0"+t.toString(16)).substr(-2)}function dg(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",s=r.length;let n="";for(let i=0;i<56;i++)n+=r.charAt(Math.floor(Math.random()*s));return n}return crypto.getRandomValues(e),Array.from(e,hg).join("")}async function fg(t){const r=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",r),n=new Uint8Array(s);return Array.from(n).map(i=>String.fromCharCode(i)).join("")}async function pg(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await fg(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function hr(t,e,r=!1){const s=dg();let n=s;r&&(n+="/recovery"),await _r(t,`${e}-code-verifier`,n);const i=await pg(s);return[i,s===i?"plain":"s256"]}const gg=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function mg(t){const e=t.headers.get(_i);if(!e||!e.match(gg))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function yg(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function _g(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const vg=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function vt(t){if(!vg.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Je(t){if(!t.passkey)throw new Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function qn(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const s=r.toString();if(s==="Symbol(Symbol.toPrimitive)"||s==="Symbol(Symbol.toStringTag)"||s==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function bg(t,e){return new Proxy(t,{get:(r,s,n)=>{if(s==="__isInsecureUserWarningProxy")return!0;if(typeof s=="symbol"){const i=s.toString();if(i==="Symbol(Symbol.toPrimitive)"||i==="Symbol(Symbol.toStringTag)"||i==="Symbol(util.inspect.custom)"||i==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,s,n)}return!e.value&&typeof s=="string"&&(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."),e.value=!0),Reflect.get(r,s,n)}})}function ha(t){return JSON.parse(JSON.stringify(t))}const Qt=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error}return JSON.stringify(t)},wg=[502,503,504,520,521,522,523,524,530];async function da(t){var e;if(!lg(t))throw new vi(Qt(t),0);if(wg.includes(t.status))throw new vi(Qt(t),t.status);let r;try{r=await t.json()}catch(i){throw new Xe(Qt(i),i)}let s;const n=mg(t);if(n&&n.getTime()>=mc["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?s=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(s=r.error_code),s){if(s==="weak_password")throw new aa(Qt(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(s==="session_not_found")throw new _e}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((i,o)=>i&&typeof o=="string",!0))throw new aa(Qt(r),t.status,r.weak_password.reasons);throw new Yp(Qt(r),t.status||500,s)}const Sg=(t,e,r,s)=>{const n={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),n.body=JSON.stringify(s),Object.assign(Object.assign({},n),r))};async function $(t,e,r,s){var n;const i=Object.assign({},s==null?void 0:s.headers);i[_i]||(i[_i]=mc["2024-01-01"].name),s!=null&&s.jwt&&(i.Authorization=`Bearer ${s.jwt}`);const o=(n=s==null?void 0:s.query)!==null&&n!==void 0?n:{};s!=null&&s.redirectTo&&(o.redirect_to=s.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await Eg(t,e,r+a,{headers:i,noResolveJson:s==null?void 0:s.noResolveJson},{},s==null?void 0:s.body);return s!=null&&s.xform?s==null?void 0:s.xform(l):{data:Object.assign({},l),error:null}}async function Eg(t,e,r,s,n,i){const o=Sg(e,s,n,i);let a;try{a=await t(r,Object.assign({},o))}catch(l){throw console.error(l),new vi(Qt(l),0)}if(a.ok||await da(a),s!=null&&s.noResolveJson)return a;try{return await a.json()}catch(l){await da(l)}}function Ke(t){var e;let r=null;Tg(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=ig(t.expires_in)));const s=(e=t.user)!==null&&e!==void 0?e:typeof(t==null?void 0:t.id)=="string"?t:null;return{data:{session:r,user:s},error:null}}function fa(t){const e=Ke(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,s)=>r&&typeof s=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Ft(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function kg(t){return{data:t,error:null}}function Ag(t){const{action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:i}=t,o=wn(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:i},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function pa(t){return t}function Tg(t){return!!t.access_token&&!!t.refresh_token&&!!t.expires_in}const Vn=["global","local","others"];class Rg{_encodePathSegment(e){if(e==="."||e==="..")throw new Cr("Invalid path segment");return encodeURIComponent(e)}constructor({url:e="",headers:r={},fetch:s,experimental:n}){this.url=e,this.headers=r,this.fetch=vc(s),this.experimental=n??{},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)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(e,r=Vn[0]){if(Vn.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Vn.join(", ")}`);try{return await $(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(s){if(x(s))return{data:null,error:s};throw s}}async inviteUserByEmail(e,r={}){try{return await $(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:Ft})}catch(s){if(x(s))return{data:{user:null},error:s};throw s}}async generateLink(e){try{const{options:r}=e,s=wn(e,["options"]),n=Object.assign(Object.assign({},s),r);return"newEmail"in s&&(n.new_email=s==null?void 0:s.newEmail,delete n.newEmail),await $(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:n,headers:this.headers,xform:Ag,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(x(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await $(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Ft})}catch(r){if(x(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,s,n,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await $(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(i=(n=e==null?void 0:e.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:pa});if(u.error)throw u.error;const h=await u.json(),d=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(m=>{const _=parseInt(m.split(";")[0].split("=")[1].substring(0,1)),A=JSON.parse(m.split(";")[1].split("=")[1]);c[`${A}Page`]=_}),c.total=parseInt(d)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(x(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){vt(e);try{return await $(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Ft})}catch(r){if(x(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){vt(e);try{return await $(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:Ft})}catch(s){if(x(s))return{data:{user:null},error:s};throw s}}async deleteUser(e,r=!1){vt(e);try{return await $(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:Ft})}catch(s){if(x(s))return{data:{user:null},error:s};throw s}}async _listFactors(e){vt(e.userId);try{const{data:r,error:s}=await $(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:r,error:s}}catch(r){if(x(r))return{data:null,error:r};throw r}}async _deleteFactor(e){vt(e.userId),vt(e.id);try{return{data:await $(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(x(r))return{data:null,error:r};throw r}}async _listOAuthClients(e){var r,s,n,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await $(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(i=(n=e==null?void 0:e.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:pa});if(u.error)throw u.error;const h=await u.json(),d=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(m=>{const _=parseInt(m.split(";")[0].split("=")[1].substring(0,1)),A=JSON.parse(m.split(";")[1].split("=")[1]);c[`${A}Page`]=_}),c.total=parseInt(d)),{data:Object.assign(Object.assign({},h),c),error:null}}catch(c){if(x(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await $(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _getOAuthClient(e){try{const r=this._encodePathSegment(e);return await $(this.fetch,"GET",`${this.url}/admin/oauth/clients/${r}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _updateOAuthClient(e,r){try{const s=this._encodePathSegment(e);return await $(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(s){if(x(s))return{data:null,error:s};throw s}}async _deleteOAuthClient(e){try{const r=this._encodePathSegment(e);return await $(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${r}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(x(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(e){try{const r=this._encodePathSegment(e);return await $(this.fetch,"POST",`${this.url}/admin/oauth/clients/${r}/regenerate_secret`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _listCustomProviders(e){try{const r={};return e!=null&&e.type&&(r.type=e.type),await $(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:r,xform:s=>{var n;return{data:{providers:(n=s==null?void 0:s.providers)!==null&&n!==void 0?n:[]},error:null}}})}catch(r){if(x(r))return{data:{providers:[]},error:r};throw r}}async _createCustomProvider(e){try{return await $(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _getCustomProvider(e){try{const r=this._encodePathSegment(e);return await $(this.fetch,"GET",`${this.url}/admin/custom-providers/${r}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _updateCustomProvider(e,r){try{const s=this._encodePathSegment(e);return await $(this.fetch,"PUT",`${this.url}/admin/custom-providers/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(s){if(x(s))return{data:null,error:s};throw s}}async _deleteCustomProvider(e){try{const r=this._encodePathSegment(e);return await $(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${r}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(x(r))return{data:null,error:r};throw r}}async _adminListPasskeys(e){Je(this.experimental),vt(e.userId);try{return await $(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(x(r))return{data:null,error:r};throw r}}async _adminDeletePasskey(e){Je(this.experimental),vt(e.userId),vt(e.passkeyId);try{return await $(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(x(r))return{data:null,error:r};throw r}}}function ga(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}const ot={debug:!!(globalThis&&_c()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class bc extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class ma extends bc{}async function Og(t,e,r){ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const s=new globalThis.AbortController;let n;e>0&&(n=setTimeout(()=>{s.abort(),ot.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e)),await Promise.resolve();try{return await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:s.signal},async i=>{if(i){clearTimeout(n),ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,i.name);try{return await r()}finally{ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,i.name)}}else{if(e===0)throw ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new ma(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(ot.debug)try{const o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}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"),clearTimeout(n),await r()}})}catch(i){if(e>0&&clearTimeout(n),i!==null&&typeof i=="object"&&"name"in i&&i.name==="AbortError"&&e>0){if(s.signal.aborted)return ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",t),console.warn(`@supabase/gotrue-js: Lock "${t}" was not released within ${e}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,{mode:"exclusive",steal:!0},async o=>{if(o){ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",t,o.name);try{return await r()}finally{ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",t,o.name)}}else return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await r()}));throw ot.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",t),new ma(`Lock "${t}" was released because another request stole it`)}throw i}}function Cg(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function wc(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Pg(t){return parseInt(t,16)}function xg(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,s=>s.toString(16).padStart(2,"0")).join("")}function Ig(t){var e;const{chainId:r,domain:s,expirationTime:n,issuedAt:i=new Date,nonce:o,notBefore:a,requestId:l,resources:c,scheme:u,uri:h,version:d}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!h)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(d!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${d}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
|
|
58
|
+
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const f=wc(t.address),m=u?`${u}://${s}`:s,_=t.statement?`${t.statement}
|
|
59
59
|
`:"",A=`${m} wants you to sign in with your Ethereum account:
|
|
60
60
|
${f}
|
|
61
61
|
|
|
62
|
-
${
|
|
62
|
+
${_}`;let E=`URI: ${h}
|
|
63
63
|
Version: ${d}
|
|
64
64
|
Chain ID: ${r}${o?`
|
|
65
65
|
Nonce: ${o}`:""}
|
|
66
66
|
Issued At: ${i.toISOString()}`;if(n&&(E+=`
|
|
67
67
|
Expiration Time: ${n.toISOString()}`),a&&(E+=`
|
|
68
68
|
Not Before: ${a.toISOString()}`),l&&(E+=`
|
|
69
|
-
Request ID: ${l}`),c){let
|
|
70
|
-
Resources:`;for(const b of c){if(!b||typeof b!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${b}`);
|
|
71
|
-
- ${b}`}E+=
|
|
72
|
-
${E}`}class ge extends Error{constructor({message:e,code:r,cause:s,name:n}){var i;super(e,{cause:s}),this.__isWebAuthnError=!0,this.name=(i=n??(s instanceof Error?s.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=r}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class Ys extends ge{constructor(e,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}),this.name="WebAuthnUnknownError",this.originalError=r}}function jg({error:t,options:e}){var r,s,n;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new ge({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=i.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new ge({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((s=i.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new ge({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new ge({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new ge({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new ge({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(a=>a.type==="public-key").length===0?new ge({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new ge({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const o=window.location.hostname;if(Sc(o)){if(i.rp.id!==o)return new ge({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new ge({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new ge({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new ge({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new ge({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Ng({error:t,options:e}){const{publicKey:r}=e;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new ge({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new ge({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const s=window.location.hostname;if(Sc(s)){if(r.rpId!==s)return new ge({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new ge({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new ge({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new ge({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class $g{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const wi=new $g;function ya(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:r,excludeCredentials:s}=t,n=bn(t,["challenge","user","excludeCredentials"]),i=Er(e).buffer,o=Object.assign(Object.assign({},r),{id:Er(r.id).buffer}),a=Object.assign(Object.assign({},n),{challenge:i,user:o});if(s&&s.length>0){a.excludeCredentials=new Array(s.length);for(let l=0;l<s.length;l++){const c=s[l];a.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:Er(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return a}function va(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:r}=t,s=bn(t,["challenge","allowCredentials"]),n=Er(e).buffer,i=Object.assign(Object.assign({},s),{challenge:n});if(r&&r.length>0){i.allowCredentials=new Array(r.length);for(let o=0;o<r.length;o++){const a=r[o];i.allowCredentials[o]=Object.assign(Object.assign({},a),{id:Er(a.id).buffer,type:a.type||"public-key",transports:a.transports})}}return i}function _a(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t;return{id:t.id,rawId:t.id,response:{attestationObject:er(new Uint8Array(t.response.attestationObject)),clientDataJSON:er(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function ba(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t,s=t.getClientExtensionResults(),n=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:er(new Uint8Array(n.authenticatorData)),clientDataJSON:er(new Uint8Array(n.clientDataJSON)),signature:er(new Uint8Array(n.signature)),userHandle:n.userHandle?er(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:s,authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Sc(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function Xs(){var t,e;return!!(we()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.get)=="function")}async function Ec(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Ys("Browser returned unexpected credential type",e)}:{data:null,error:new Ys("Empty credential response",e)}}catch(e){return{data:null,error:jg({error:e,options:t})}}}async function kc(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Ys("Browser returned unexpected credential type",e)}:{data:null,error:new Ys("Empty credential response",e)}}catch(e){return{data:null,error:Ng({error:e,options:t})}}}const Lg={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},Dg={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function Qs(...t){const e=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),r=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),s={};for(const n of t)if(n)for(const i in n){const o=n[i];if(o!==void 0)if(Array.isArray(o))s[i]=o;else if(r(o))s[i]=o;else if(e(o)){const a=s[i];e(a)?s[i]=Qs(a,o):s[i]=Qs(o)}else s[i]=o}return s}function Ug(t,e){return Qs(Lg,t,e||{})}function Bg(t,e){return Qs(Dg,t,e||{})}class Mg{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:r,friendlyName:s,signal:n},i){var o;try{const{data:a,error:l}=await this.client.mfa.challenge({factorId:e,webauthn:r});if(!a)return{data:null,error:l};const c=n??wi.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:u}=a.webauthn.credential_options.publicKey;if(!u.name){const h=s;if(h)u.name=`${u.id}:${h}`;else{const f=(await this.client.getUser()).data.user,m=((o=f==null?void 0:f.user_metadata)===null||o===void 0?void 0:o.name)||(f==null?void 0:f.email)||(f==null?void 0:f.id)||"User";u.name=`${u.id}:${m}`}}u.displayName||(u.displayName=u.name)}switch(a.webauthn.type){case"create":{const u=Ug(a.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:h,error:d}=await Ec({publicKey:u,signal:c});return h?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:h}},error:null}:{data:null,error:d}}case"request":{const u=Bg(a.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:h,error:d}=await kc(Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:u,signal:c}));return h?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:h}},error:null}:{data:null,error:d}}}}catch(a){return x(a)?{data:null,error:a}:{data:null,error:new Ye("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:r,webauthn:s}){return this.client.mfa.verify({factorId:r,challengeId:e,webauthn:s})}async _authenticate({factorId:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!r)return{data:null,error:new Cr("rpId is required for WebAuthn authentication")};try{if(!Xs())return{data:null,error:new Ye("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this.challenge({factorId:e,webauthn:{rpId:r,rpOrigins:s},signal:n},{request:i});if(!o)return{data:null,error:a};const{webauthn:l}=o;return this._verify({factorId:e,challengeId:o.challengeId,webauthn:{type:l.type,rpId:r,rpOrigins:s,credential_response:l.credential_response}})}catch(o){return x(o)?{data:null,error:o}:{data:null,error:new Ye("Unexpected error in authenticate",o)}}}async _register({friendlyName:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!r)return{data:null,error:new Cr("rpId is required for WebAuthn registration")};try{if(!Xs())return{data:null,error:new Ye("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this._enroll({friendlyName:e});if(!o)return await this.client.mfa.listFactors().then(u=>{var h;return(h=u.data)===null||h===void 0?void 0:h.all.find(d=>d.factor_type==="webauthn"&&d.friendly_name===e&&d.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u==null?void 0:u.id}):void 0),{data:null,error:a};const{data:l,error:c}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:r,rpOrigins:s},signal:n},{create:i});return l?this._verify({factorId:o.id,challengeId:l.challengeId,webauthn:{rpId:r,rpOrigins:s,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(o){return x(o)?{data:null,error:o}:{data:null,error:new Ye("Unexpected error in register",o)}}}}Cg();const Hg={url:Kp,storageKey:Wp,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Gp,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function wa(t,e,r){return await r()}const hr={};class ps{get jwks(){var e,r;return(r=(e=hr[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){hr[this.storageKey]=Object.assign(Object.assign({},hr[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=hr[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){hr[this.storageKey]=Object.assign(Object.assign({},hr[this.storageKey]),{cachedAt:e})}constructor(e){var r,s,n,i;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=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;const o=Object.assign(Object.assign({},Hg),e);if(this.storageKey=o.storageKey,this.instanceID=(r=ps.nextInstanceID[this.storageKey])!==null&&r!==void 0?r:0,ps.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!o.debug,typeof o.debug=="function"&&(this.logger=o.debug),this.instanceID>0&&we()){const a=`${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(a),this.logDebugMessages&&console.trace(a)}if(this.persistSession=o.persistSession,this.autoRefreshToken=o.autoRefreshToken,this.experimental=(s=o.experimental)!==null&&s!==void 0?s:{},this.admin=new Rg({url:o.url,headers:o.headers,fetch:o.fetch,experimental:this.experimental}),this.url=o.url,this.headers=o.headers,this.fetch=_c(o.fetch),this.lock=o.lock||wa,this.detectSessionInUrl=o.detectSessionInUrl,this.flowType=o.flowType,this.hasCustomAuthorizationHeader=o.hasCustomAuthorizationHeader,this.throwOnError=o.throwOnError,this.lockAcquireTimeout=o.lockAcquireTimeout,o.lock?this.lock=o.lock:this.persistSession&&we()&&(!((n=globalThis==null?void 0:globalThis.navigator)===null||n===void 0)&&n.locks)?this.lock=Og:this.lock=wa,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 Mg(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.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(o.storage?this.storage=o.storage:vc()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=ga(this.memoryStorage)),o.userStorage&&(this.userStorage=o.userStorage)):(this.memoryStorage={},this.storage=ga(this.memoryStorage)),we()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(i=this.broadcastChannel)===null||i===void 0||i.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a);try{await this._notifyAllSubscribers(a.data.event,a.data.session,!1)}catch(l){this._debug("#broadcastChannel","error",l)}})}o.skipAutoInitialize||this.initialize().catch(a=>{this._debug("#initialize()","error",a)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${gc}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let r={},s="none";if(we()&&(r=ag(window.location.href),this._isImplicitGrantCallback(r)?s="implicit":await this._isPKCECallback(r)&&(s="pkce")),we()&&this.detectSessionInUrl&&s!=="none"){const{data:n,error:i}=await this._getSessionFromURL(r,s);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),Qp(i)){const l=(e=i.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:i}}return{error:i}}const{session:o,redirectType:a}=n;return this._debug("#_initialize()","detected session in URL",o,"redirect type",a),await this._saveSession(o),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return x(r)?this._returnResult({error:r}):this._returnResult({error:new Ye("Unexpected error during initialization",r)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,s,n;try{const i=await L(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(s=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:(n=e==null?void 0:e.options)===null||n===void 0?void 0:n.captchaToken}},xform:qe}),{data:o,error:a}=i;if(a||!o)return this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(x(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(e){var r,s,n;try{let i;if("email"in e){const{email:u,password:h,options:d}=e;let f=null,m=null;this.flowType==="pkce"&&([f,m]=await ur(this.storage,this.storageKey)),i=await L(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:d==null?void 0:d.emailRedirectTo,body:{email:u,password:h,data:(r=d==null?void 0:d.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:f,code_challenge_method:m},xform:qe})}else if("phone"in e){const{phone:u,password:h,options:d}=e;i=await L(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:h,data:(s=d==null?void 0:d.data)!==null&&s!==void 0?s:{},channel:(n=d==null?void 0:d.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken}},xform:qe})}else throw new Cs("You must provide either an email or phone number and a password");const{data:o,error:a}=i;if(a||!o)return await be(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithPassword(e){try{let r;if("email"in e){const{email:i,password:o,options:a}=e;r=await L(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:fa})}else if("phone"in e){const{phone:i,password:o,options:a}=e;r=await L(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:fa})}else throw new Cs("You must provide either an email or phone number and a password");const{data:s,error:n}=r;if(n)return this._returnResult({data:{user:null,session:null},error:n});if(!s||!s.session||!s.user){const i=new cr;return this._returnResult({data:{user:null,session:null},error:i})}return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),this._returnResult({data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:n})}catch(r){if(x(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOAuth(e){var r,s,n,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(s=e.options)===null||s===void 0?void 0:s.scopes,queryParams:(n=e.options)===null||n===void 0?void 0:n.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:r}=e;switch(r){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(e){var r,s,n,i,o,a,l,c,u,h,d;let f,m;if("message"in e)f=e.message,m=e.signature;else{const{chain:v,wallet:A,statement:E,options:_}=e;let b;if(we())if(typeof A=="object")b=A;else{const V=window;if("ethereum"in V&&typeof V.ethereum=="object"&&"request"in V.ethereum&&typeof V.ethereum.request=="function")b=V.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof A!="object"||!(_!=null&&_.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");b=A}const O=new URL((r=_==null?void 0:_.url)!==null&&r!==void 0?r:window.location.href),B=await b.request({method:"eth_requestAccounts"}).then(V=>V).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!B||B.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const W=wc(B[0]);let q=(s=_==null?void 0:_.signInWithEthereum)===null||s===void 0?void 0:s.chainId;if(!q){const V=await b.request({method:"eth_chainId"});q=Pg(V)}const J={domain:O.host,address:W,statement:E,uri:O.href,version:"1",chainId:q,nonce:(n=_==null?void 0:_.signInWithEthereum)===null||n===void 0?void 0:n.nonce,issuedAt:(o=(i=_==null?void 0:_.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(a=_==null?void 0:_.signInWithEthereum)===null||a===void 0?void 0:a.expirationTime,notBefore:(l=_==null?void 0:_.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=_==null?void 0:_.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=_==null?void 0:_.signInWithEthereum)===null||u===void 0?void 0:u.resources};f=Ig(J),m=await b.request({method:"personal_sign",params:[xg(f),W]})}try{const{data:v,error:A}=await L(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:m},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(d=e.options)===null||d===void 0?void 0:d.captchaToken}}:null),xform:qe});if(A)throw A;if(!v||!v.session||!v.user){const E=new cr;return this._returnResult({data:{user:null,session:null},error:E})}return v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),this._returnResult({data:Object.assign({},v),error:A})}catch(v){if(x(v))return this._returnResult({data:{user:null,session:null},error:v});throw v}}async signInWithSolana(e){var r,s,n,i,o,a,l,c,u,h,d,f;let m,v;if("message"in e)m=e.message,v=e.signature;else{const{chain:A,wallet:E,statement:_,options:b}=e;let O;if(we())if(typeof E=="object")O=E;else{const W=window;if("solana"in W&&typeof W.solana=="object"&&("signIn"in W.solana&&typeof W.solana.signIn=="function"||"signMessage"in W.solana&&typeof W.solana.signMessage=="function"))O=W.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof E!="object"||!(b!=null&&b.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");O=E}const B=new URL((r=b==null?void 0:b.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in O&&O.signIn){const W=await O.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},b==null?void 0:b.signInWithSolana),{version:"1",domain:B.host,uri:B.href}),_?{statement:_}:null));let q;if(Array.isArray(W)&&W[0]&&typeof W[0]=="object")q=W[0];else if(W&&typeof W=="object"&&"signedMessage"in W&&"signature"in W)q=W;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in q&&"signature"in q&&(typeof q.signedMessage=="string"||q.signedMessage instanceof Uint8Array)&&q.signature instanceof Uint8Array)m=typeof q.signedMessage=="string"?q.signedMessage:new TextDecoder().decode(q.signedMessage),v=q.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in O)||typeof O.signMessage!="function"||!("publicKey"in O)||typeof O!="object"||!O.publicKey||!("toBase58"in O.publicKey)||typeof O.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");m=[`${B.host} wants you to sign in with your Solana account:`,O.publicKey.toBase58(),..._?["",_,""]:[""],"Version: 1",`URI: ${B.href}`,`Issued At: ${(n=(s=b==null?void 0:b.signInWithSolana)===null||s===void 0?void 0:s.issuedAt)!==null&&n!==void 0?n:new Date().toISOString()}`,...!((i=b==null?void 0:b.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${b.signInWithSolana.notBefore}`]:[],...!((o=b==null?void 0:b.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${b.signInWithSolana.expirationTime}`]:[],...!((a=b==null?void 0:b.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${b.signInWithSolana.chainId}`]:[],...!((l=b==null?void 0:b.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${b.signInWithSolana.nonce}`]:[],...!((c=b==null?void 0:b.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${b.signInWithSolana.requestId}`]:[],...!((h=(u=b==null?void 0:b.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||h===void 0)&&h.length?["Resources",...b.signInWithSolana.resources.map(q=>`- ${q}`)]:[]].join(`
|
|
73
|
-
`);const W=await O.signMessage(new TextEncoder().encode(m),"utf8");if(!W||!(W instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");v=W}}try{const{data:A,error:E}=await L(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:m,signature:er(v)},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:qe});if(E)throw E;if(!A||!A.session||!A.user){const _=new cr;return this._returnResult({data:{user:null,session:null},error:_})}return A.session&&(await this._saveSession(A.session),await this._notifyAllSubscribers("SIGNED_IN",A.session)),this._returnResult({data:Object.assign({},A),error:E})}catch(A){if(x(A))return this._returnResult({data:{user:null,session:null},error:A});throw A}}async _exchangeCodeForSession(e){const r=await Yt(this.storage,`${this.storageKey}-code-verifier`),[s,n]=(r??"").split("/");try{if(!s&&this.flowType==="pkce")throw new Zp;const{data:i,error:o}=await L(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:s},xform:qe});if(await be(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!i||!i.session||!i.user){const a=new cr;return this._returnResult({data:{user:null,session:null,redirectType:null},error:a})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers(n==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:n??null}),error:o})}catch(i){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(e){try{const{options:r,provider:s,token:n,access_token:i,nonce:o}=e,a=await L(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:n,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:qe}),{data:l,error:c}=a;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l||!l.session||!l.user){const u=new cr;return this._returnResult({data:{user:null,session:null},error:u})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),this._returnResult({data:l,error:c})}catch(r){if(x(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,s,n,i,o;try{if("email"in e){const{email:a,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await ur(this.storage,this.storageKey));const{error:h}=await L(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=l==null?void 0:l.data)!==null&&r!==void 0?r:{},create_user:(s=l==null?void 0:l.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l==null?void 0:l.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:h})}if("phone"in e){const{phone:a,options:l}=e,{data:c,error:u}=await L(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(n=l==null?void 0:l.data)!==null&&n!==void 0?n:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:u})}throw new Cs("You must provide either an email or phone number.")}catch(a){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async verifyOtp(e){var r,s;try{let n,i;"options"in e&&(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo,i=(s=e.options)===null||s===void 0?void 0:s.captchaToken);const{data:o,error:a}=await L(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:n,xform:qe});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,c=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(n){if(x(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithSSO(e){var r,s,n,i,o;try{let a=null,l=null;this.flowType==="pkce"&&([a,l]=await ur(this.storage,this.storageKey));const c=await L(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:(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&s!==void 0?s:void 0}),!((n=e==null?void 0:e.options)===null||n===void 0)&&n.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:l}),headers:this.headers,xform:kg});return!((i=c.data)===null||i===void 0)&&i.url&&we()&&!(!((o=e.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(a){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(a))return this._returnResult({data:null,error:a});throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)throw s;if(!r)throw new ve;const{error:n}=await L(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:n})})}catch(e){if(x(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:s,type:n,options:i}=e,{error:o}=await L(this.fetch,"POST",r,{headers:this.headers,body:{email:s,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in e){const{phone:s,type:n,options:i}=e,{data:o,error:a}=await L(this.fetch,"POST",r,{headers:this.headers,body:{phone:s,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a})}throw new Cs("You must provide either an email or phone number and a type")}catch(r){if(x(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const s=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await s,await r()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const s=r();for(this.pendingInLock.push((async()=>{try{await s}catch{}})()),await s;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await s}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await Yt(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const s=e.expires_at?e.expires_at*1e3-Date.now()<Mn:!1;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",e.expires_at),!s){if(this.userStorage){const o=await Yt(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=Fn()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};e.user=bg(e.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{session:null},error:i}):this._returnResult({data:{session:n},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const r=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await L(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Ft}):await this._useSession(async r=>{var s,n,i;const{data:o,error:a}=r;if(a)throw a;return!(!((s=o.session)===null||s===void 0)&&s.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new ve}:await L(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0,xform:Ft})})}catch(r){if(x(r))return Os(r)&&(await this._removeSession(),await be(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:r});throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async s=>{const{data:n,error:i}=s;if(i)throw i;if(!n.session)throw new ve;const o=n.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await ur(this.storage,this.storageKey));const{data:c,error:u}=await L(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:Ft});if(u)throw u;return o.user=c.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(s){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(s))return this._returnResult({data:{user:null},error:s});throw s}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new ve;const r=Date.now()/1e3;let s=r,n=!0,i=null;const{payload:o}=xs(e.access_token);if(o.exp&&(s=o.exp,n=s<=r),n){const{data:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:s-r,expires_at:s},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(r){if(x(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var s;if(!e){const{data:o,error:a}=r;if(a)throw a;e=(s=o.session)!==null&&s!==void 0?s:void 0}if(!(e!=null&&e.refresh_token))throw new ve;const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):n?this._returnResult({data:{user:n.user,session:n},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(x(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){var s;try{if(!we())throw new Ps("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Ps(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new oa("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Ps("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new oa("No code detected.");const{data:b,error:O}=await this._exchangeCodeForSession(e.code);if(O)throw O;const B=new URL(window.location.href);return B.searchParams.delete("code"),window.history.replaceState(window.history.state,"",B.toString()),{data:{session:b.session,redirectType:(s=b.redirectType)!==null&&s!==void 0?s:null},error:null}}const{provider_token:n,provider_refresh_token:i,access_token:o,refresh_token:a,expires_in:l,expires_at:c,token_type:u}=e;if(!o||!l||!a||!u)throw new Ps("No session defined in URL");const h=Math.round(Date.now()/1e3),d=parseInt(l);let f=h+d;c&&(f=parseInt(c));const m=f-h;m*1e3<=mr&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${m}s, should have been closer to ${d}s`);const v=f-d;h-v>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",v,f,h):h-v<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",v,f,h);const{data:A,error:E}=await this._getUser(o);if(E)throw E;const _={provider_token:n,provider_refresh_token:i,access_token:o,expires_in:d,expires_at:f,refresh_token:a,token_type:u,user:A.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:_,redirectType:e.type},error:null})}catch(n){if(x(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const r=await Yt(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var s;const{data:n,error:i}=r;if(i&&!Os(i))return this._returnResult({error:i});const o=(s=n.session)===null||s===void 0?void 0:s.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(Xp(a)&&(a.status===404||a.status===401||a.status===403)||Os(a)))return this._returnResult({error:a})}return e!=="others"&&(await this._removeSession(),await be(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const r=og(),s={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,s),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:s}}}async _emitInitialSession(e){return await this._useSession(async r=>{var s,n;try{const{data:{session:i},error:o}=r;if(o)throw o;await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),Os(i)?console.warn(i):console.error(i)}})}async resetPasswordForEmail(e,r={}){let s=null,n=null;this.flowType==="pkce"&&([s,n]=await ur(this.storage,this.storageKey,!0));try{return await L(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:s,code_challenge_method:n,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:r,error:s}=await this.getUser();if(s)throw s;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var r;try{const{data:s,error:n}=await this._useSession(async i=>{var o,a,l,c,u;const{data:h,error:d}=i;if(d)throw d;const f=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await L(this.fetch,"GET",f,{headers:this.headers,jwt:(u=(c=h.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(n)throw n;return we()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(s==null?void 0:s.url),this._returnResult({data:{provider:e.provider,url:s==null?void 0:s.url},error:null})}catch(s){if(x(s))return this._returnResult({data:{provider:e.provider,url:null},error:s});throw s}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var s;try{const{error:n,data:{session:i}}=r;if(n)throw n;const{options:o,provider:a,token:l,access_token:c,nonce:u}=e,h=await L(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(s=i==null?void 0:i.access_token)!==null&&s!==void 0?s:void 0,body:{provider:a,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:qe}),{data:d,error:f}=h;return f?this._returnResult({data:{user:null,session:null},error:f}):!d||!d.session||!d.user?this._returnResult({data:{user:null,session:null},error:new cr}):(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("USER_UPDATED",d.session)),this._returnResult({data:d,error:f}))}catch(n){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var s,n;const{data:i,error:o}=r;if(o)throw o;return await L(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(s=i.session)===null||s===void 0?void 0:s.access_token)!==null&&n!==void 0?n:void 0})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const s=Date.now();return await ug(async n=>(n>0&&await cg(200*Math.pow(2,n-1)),this._debug(r,"refreshing attempt",n),await L(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:qe})),(n,i)=>{const o=200*Math.pow(2,n);return i&&Hn(i)&&Date.now()+o-s<mr})}catch(s){if(this._debug(r,"error",s),x(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const s=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",s),we()&&!r.skipBrowserRedirect&&window.location.assign(s),{data:{provider:e,url:s},error:null}}async _recoverAndRefresh(){var e,r;const s="#_recoverAndRefresh()";this._debug(s,"begin");try{const n=await Yt(this.storage,this.storageKey);if(n&&this.userStorage){let o=await Yt(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:n.user},await yr(this.userStorage,this.storageKey+"-user",o)),n.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:Fn()}else if(n&&!n.user&&!n.user){const o=await Yt(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(n.user=o.user,await be(this.storage,this.storageKey+"-user"),await yr(this.storage,this.storageKey,n)):n.user=Fn()}if(this._debug(s,"session from storage",n),!this._isValidSession(n)){this._debug(s,"session is not valid"),n!==null&&await this._removeSession();return}const i=((r=n.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<Mn;if(this._debug(s,`session has${i?"":" not"} expired with margin of ${Mn}s`),i){if(this.autoRefreshToken&&n.refresh_token){const{error:o}=await this._callRefreshToken(n.refresh_token);o&&(console.error(o),Hn(o)||(this._debug(s,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(n.user&&n.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:a}=await this._getUser(n.access_token);!a&&(o!=null&&o.user)?(n.user=o.user,await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)):this._debug(s,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(s,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(s,"error",n),console.error(n);return}finally{this._debug(s,"end")}}async _callRefreshToken(e){var r,s;if(!e)throw new ve;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const n=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{this.refreshingDeferred=new En;const{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new ve;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const a={data:i.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(i){if(this._debug(n,"error",i),x(i)){const o={data:null,error:i};return Hn(i)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(o),o}throw(s=this.refreshingDeferred)===null||s===void 0||s.reject(i),i}finally{this.refreshingDeferred=null,this._debug(n,"end")}}async _notifyAllSubscribers(e,r,s=!0){const n=`#_notifyAllSubscribers(${e})`;this._debug(n,"begin",r,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:e,session:r});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,r)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;a<i.length;a+=1)console.error(i[a]);throw i[0]}}finally{this._debug(n,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await be(this.storage,`${this.storageKey}-code-verifier`);const r=Object.assign({},e),s=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!s&&r.user&&await yr(this.userStorage,this.storageKey+"-user",{user:r.user});const n=Object.assign({},r);delete n.user;const i=ha(n);await yr(this.storage,this.storageKey,i)}else{const n=ha(r);await yr(this.storage,this.storageKey,n)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await be(this.storage,this.storageKey),await be(this.storage,this.storageKey+"-code-verifier"),await be(this.storage,this.storageKey+"-user"),this.userStorage&&await be(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&we()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),mr);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const r=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=r,r&&typeof r=="object"&&typeof r.unref=="function"?r.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(r)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const r=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,r&&clearTimeout(r)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:s}}=r;if(!s||!s.refresh_token||!s.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((s.expires_at*1e3-e)/mr);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${mr}ms, refresh threshold is ${yi} ticks`),n<=yi&&await this._callRefreshToken(s.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof bc)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!we()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,s){const n=[`provider=${encodeURIComponent(r)}`];if(s!=null&&s.redirectTo&&n.push(`redirect_to=${encodeURIComponent(s.redirectTo)}`),s!=null&&s.scopes&&n.push(`scopes=${encodeURIComponent(s.scopes)}`),this.flowType==="pkce"){const[i,o]=await ur(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});n.push(a.toString())}if(s!=null&&s.queryParams){const i=new URLSearchParams(s.queryParams);n.push(i.toString())}return s!=null&&s.skipBrowserRedirect&&n.push(`skip_http_redirect=${s.skipBrowserRedirect}`),`${e}?${n.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var s;const{data:n,error:i}=r;return i?this._returnResult({data:null,error:i}):await L(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(s=n==null?void 0:n.session)===null||s===void 0?void 0:s.access_token})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var s,n;const{data:i,error:o}=r;if(o)return this._returnResult({data:null,error:o});const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await L(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(s=i==null?void 0:i.session)===null||s===void 0?void 0:s.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((n=l==null?void 0:l.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async r=>{var s;const{data:n,error:i}=r;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?_a(e.webauthn.credential_response):ba(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:l}=await L(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(s=n==null?void 0:n.session)===null||s===void 0?void 0:s.access_token});return l?this._returnResult({data:null,error:l}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),this._returnResult({data:a,error:l}))})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async r=>{var s;const{data:n,error:i}=r;if(i)return this._returnResult({data:null,error:i});const o=await L(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(s=n==null?void 0:n.session)===null||s===void 0?void 0:s.access_token});if(o.error)return o;const{data:a}=o;if(a.type!=="webauthn")return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:ya(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:va(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}})}async _challengeAndVerify(e){const{data:r,error:s}=await this._challenge({factorId:e.factorId});return s?this._returnResult({data:null,error:s}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:s}=await this.getUser();if(s)return{data:null,error:s};const n={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=r==null?void 0:r.factors)!==null&&e!==void 0?e:[])n.all.push(i),i.status==="verified"&&n[i.factor_type].push(i);return{data:n,error:null}}async _getAuthenticatorAssuranceLevel(e){var r,s,n,i;if(e)try{const{payload:f}=xs(e);let m=null;f.aal&&(m=f.aal);let v=m;const{data:{user:A},error:E}=await this.getUser(e);if(E)return this._returnResult({data:null,error:E});((s=(r=A==null?void 0:A.factors)===null||r===void 0?void 0:r.filter(O=>O.status==="verified"))!==null&&s!==void 0?s:[]).length>0&&(v="aal2");const b=f.amr||[];return{data:{currentLevel:m,nextLevel:v,currentAuthenticationMethods:b},error:null}}catch(f){if(x(f))return this._returnResult({data:null,error:f});throw f}const{data:{session:o},error:a}=await this.getSession();if(a)return this._returnResult({data:null,error:a});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=xs(o.access_token);let c=null;l.aal&&(c=l.aal);let u=c;((i=(n=o.user.factors)===null||n===void 0?void 0:n.filter(f=>f.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(u="aal2");const d=l.amr||[];return{data:{currentLevel:c,nextLevel:u,currentAuthenticationMethods:d},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?await L(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:s.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new ve})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:i}=s;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new ve});const o=await L(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"approve"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&we()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(s){if(x(s))return this._returnResult({data:null,error:s});throw s}}async _denyAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:i}=s;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new ve});const o=await L(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"deny"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&we()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(s){if(x(s))return this._returnResult({data:null,error:s});throw s}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;return s?this._returnResult({data:null,error:s}):r?await L(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:n=>({data:n,error:null})}):this._returnResult({data:null,error:new ve})})}catch(e){if(x(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?(await L(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new ve})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let s=r.keys.find(a=>a.kid===e);if(s)return s;const n=Date.now();if(s=this.jwks.keys.find(a=>a.kid===e),s&&this.jwks_cached_at+Jp>n)return s;const{data:i,error:o}=await L(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=n,s=i.keys.find(a=>a.kid===e),!s)?null:s}async getClaims(e,r={}){try{let s=e;if(!s){const{data:f,error:m}=await this.getSession();if(m||!f.session)return this._returnResult({data:null,error:m});s=f.session.access_token}const{header:n,payload:i,signature:o,raw:{header:a,payload:l}}=xs(s);r!=null&&r.allowExpired||yg(i.exp);const c=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!c){const{error:f}=await this.getUser(s);if(f)throw f;return{data:{claims:i,header:n,signature:o},error:null}}const u=vg(n.alg),h=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,h,o,ng(`${a}.${l}`)))throw new bi("Invalid JWT signature");return{data:{claims:i,header:n,signature:o},error:null}}catch(s){if(x(s))return this._returnResult({data:null,error:s});throw s}}async signInWithPasskey(e){var r,s,n;Ge(this.experimental);try{if(!Xs())return this._returnResult({data:null,error:new Ye("Browser does not support WebAuthn",null)});const{data:i,error:o}=await this._startPasskeyAuthentication({options:{captchaToken:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}});if(o||!i)return this._returnResult({data:null,error:o});const a=va(i.options),l=(n=(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.signal)!==null&&n!==void 0?n:wi.createNewAbortSignal(),{data:c,error:u}=await kc({publicKey:a,signal:l});if(u||!c)return this._returnResult({data:null,error:u??new Ye("WebAuthn ceremony failed",null)});const h=ba(c);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:h})}catch(i){if(x(i))return this._returnResult({data:null,error:i});throw i}}async registerPasskey(e){var r,s;Ge(this.experimental);try{if(!Xs())return this._returnResult({data:null,error:new Ye("Browser does not support WebAuthn",null)});const{data:n,error:i}=await this._startPasskeyRegistration();if(i||!n)return this._returnResult({data:null,error:i});const o=ya(n.options),a=(s=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.signal)!==null&&s!==void 0?s:wi.createNewAbortSignal(),{data:l,error:c}=await Ec({publicKey:o,signal:a});if(c||!l)return this._returnResult({data:null,error:c??new Ye("WebAuthn ceremony failed",null)});const u=_a(l);return this._verifyPasskeyRegistration({challengeId:n.challenge_id,credential:u})}catch(n){if(x(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyRegistration(){Ge(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new ve});const{data:n,error:i}=await L(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:r.access_token,body:{}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(x(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){Ge(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new ve});const{data:i,error:o}=await L(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:s.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _startPasskeyAuthentication(e){var r;Ge(this.experimental);try{const{data:s,error:n}=await L(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:s,error:null})}catch(s){if(x(s))return this._returnResult({data:null,error:s});throw s}}async _verifyPasskeyAuthentication(e){Ge(this.experimental);try{const{data:r,error:s}=await L(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:qe});return s?this._returnResult({data:null,error:s}):(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:r,error:null}))}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _listPasskeys(){Ge(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new ve});const{data:n,error:i}=await L(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:r.access_token,xform:o=>({data:o,error:null})});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(x(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){Ge(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new ve});const{data:i,error:o}=await L(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,body:{friendly_name:e.friendlyName}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _deletePasskey(e){Ge(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new ve});const{error:i}=await L(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,noResolveJson:!0});return i?this._returnResult({data:null,error:i}):this._returnResult({data:null,error:null})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}}ps.nextInstanceID={};const Fg=ps,qg="2.106.2";let Hr="";typeof Deno<"u"?Hr="deno":typeof document<"u"?Hr="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Hr="react-native":Hr="node";const Vg={"X-Client-Info":`supabase-js-${Hr}/${qg}`},Kg={headers:Vg},Wg={schema:"public"},Gg={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},zg={},Jg={enabled:!1,respectSamplingDecision:!0};function Yg(t,e,r,s){function n(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(u){try{c(s.next(u))}catch(h){o(h)}}function l(u){try{c(s.throw(u))}catch(h){o(h)}}function c(u){u.done?i(u.value):n(u.value).then(a,l)}c((s=s.apply(t,[])).next())})}let Vn=null;const Xg="@opentelemetry/api";function Qg(){return Vn===null&&(Vn=import(Xg).catch(()=>null)),Vn}function Zg(){return Yg(this,void 0,void 0,function*(){try{const t=yield Qg();if(!t||!t.propagation||!t.context)return null;const e={};t.propagation.inject(t.context.active(),e);const r=e.traceparent;return r?{traceparent:r,tracestate:e.tracestate,baggage:e.baggage}:null}catch{return null}})}function em(t){if(!t||typeof t!="string")return null;const e=t.split("-");if(e.length!==4)return null;const[r,s,n,i]=e;if(r.length!==2||s.length!==32||n.length!==16||i.length!==2)return null;const o=/^[0-9a-f]+$/i;return!o.test(r)||!o.test(s)||!o.test(n)||!o.test(i)||s==="00000000000000000000000000000000"||n==="0000000000000000"?null:{version:r,traceId:s,parentId:n,traceFlags:i,isSampled:(parseInt(i,16)&1)===1}}function tm(t,e){if(!t||!e||e.length===0)return!1;let r;if(t instanceof URL)r=t;else try{r=new URL(t)}catch{return!1}for(const s of e)try{if(typeof s=="string"){if(rm(r.hostname,s))return!0}else if(s instanceof RegExp){if(s.test(r.hostname))return!0}else if(typeof s=="function"&&s(r))return!0}catch{continue}return!1}function rm(t,e){if(e===t)return!0;if(e.startsWith("*.")){const r=e.slice(2);if(t.endsWith(r)&&(t===r||t.endsWith("."+r)))return!0}return!1}function sm(t){const e=[];try{const r=new URL(t);e.push(r.hostname)}catch{}return e.push("*.supabase.co","*.supabase.in"),e.push("localhost","127.0.0.1","[::1]"),e}function gs(t){"@babel/helpers - typeof";return gs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gs(t)}function nm(t,e){if(gs(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(gs(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function im(t){var e=nm(t,"string");return gs(e)=="symbol"?e:e+""}function om(t,e,r){return(e=im(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sa(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function de(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Sa(Object(r),!0).forEach(function(s){om(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Sa(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}const am=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),lm=()=>Headers,cm=(t,e,r,s,n)=>{const i=am(s),o=lm(),a=(n==null?void 0:n.enabled)===!0,l=(n==null?void 0:n.respectSamplingDecision)!==!1,c=a?sm(e):null;return async(u,h)=>{var d;const f=(d=await r())!==null&&d!==void 0?d:t;let m=new o(h==null?void 0:h.headers);if(m.has("apikey")||m.set("apikey",t),m.has("Authorization")||m.set("Authorization",`Bearer ${f}`),c){const v=await um(u,c,l);v&&(v.traceparent&&!m.has("traceparent")&&m.set("traceparent",v.traceparent),v.tracestate&&!m.has("tracestate")&&m.set("tracestate",v.tracestate),v.baggage&&!m.has("baggage")&&m.set("baggage",v.baggage))}return i(u,de(de({},h),{},{headers:m}))}};async function um(t,e,r){if(!tm(typeof t=="string"||t instanceof URL?t:t.url,e))return null;const s=await Zg();if(!s||!s.traceparent)return null;if(r){const n=em(s.traceparent);if(n&&!n.isSampled)return null}return s}function Ea(t){return typeof t=="boolean"?{enabled:t}:t}function hm(t){return t.endsWith("/")?t:t+"/"}function dm(t,e){var r,s,n,i,o,a;const{db:l,auth:c,realtime:u,global:h}=t,{db:d,auth:f,realtime:m,global:v}=e,A=Ea(t.tracePropagation),E=Ea(e.tracePropagation),_={db:de(de({},d),l),auth:de(de({},f),c),realtime:de(de({},m),u),storage:{},global:de(de(de({},v),h),{},{headers:de(de({},(r=v==null?void 0:v.headers)!==null&&r!==void 0?r:{}),(s=h==null?void 0:h.headers)!==null&&s!==void 0?s:{})}),tracePropagation:{enabled:(n=(i=A==null?void 0:A.enabled)!==null&&i!==void 0?i:E==null?void 0:E.enabled)!==null&&n!==void 0?n:!1,respectSamplingDecision:(o=(a=A==null?void 0:A.respectSamplingDecision)!==null&&a!==void 0?a:E==null?void 0:E.respectSamplingDecision)!==null&&o!==void 0?o:!0},accessToken:async()=>""};return t.accessToken?_.accessToken=t.accessToken:delete _.accessToken,_}function fm(t){const e=t==null?void 0:t.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(hm(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var pm=class extends Fg{constructor(t){super(t)}},gm=class{constructor(t,e,r){var s,n;this.supabaseUrl=t,this.supabaseKey=e;const i=fm(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const o=`sb-${i.hostname.split(".")[0]}-auth-token`,a={db:Wg,realtime:zg,auth:de(de({},Gg),{},{storageKey:o}),global:Kg,tracePropagation:Jg},l=dm(r??{},a);if(this.settings=l,this.storageKey=(s=l.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(n=l.global.headers)!==null&&n!==void 0?n:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(u,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}});else{var c;this.auth=this._initSupabaseAuthClient((c=l.auth)!==null&&c!==void 0?c:{},this.headers,l.global.fetch)}this.fetch=cm(e,t,this._getAccessToken.bind(this),l.global.fetch,l.tracePropagation),this.realtime=this._initRealtimeClient(de({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(u=>this.realtime.setAuth(u)).catch(u=>console.warn("Failed to set initial Realtime auth token:",u)),this.rest=new xf(new URL("rest/v1",i).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new Vp(this.storageUrl.href,this.headers,this.fetch,r==null?void 0:r.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new wf(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,r)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,r;if(t.accessToken)return await t.accessToken();const{data:s}=await t.auth.getSession();return(e=(r=s.session)===null||r===void 0?void 0:r.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:s,userStorage:n,storageKey:i,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,lockAcquireTimeout:h,skipAutoInitialize:d},f,m){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new pm({url:this.authUrl.href,headers:de(de({},v),f),storageKey:i,autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:s,userStorage:n,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,fetch:m,lockAcquireTimeout:h,skipAutoInitialize:d,hasCustomAuthorizationHeader:Object.keys(this.headers).some(A=>A.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new fp(this.realtimeUrl.href,de(de({},t),{},{params:de(de({},{apikey:this.supabaseKey}),t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e==null?void 0:e.access_token)})}_handleTokenChanged(t,e,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const mm=(t,e,r)=>new gm(t,e,r);function ym(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const r=e.match(/^v(\d+)\./);return r?parseInt(r[1],10)<=18:!1}ym()&&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");let Ac=null,ka=!1;async function vm(){if(!ka){ka=!0;try{const t=await fetch("/api/auth/config");if(!t.ok)return;const{supabaseUrl:e,supabaseAnonKey:r}=await t.json();e&&r&&(Ac=mm(e,r))}catch{}}}function Is(){return Ac}const kn=cd("auth",()=>{const t=Kr(localStorage.getItem("io_token")),e=Kr(localStorage.getItem("io_email")),r=Kr(!1),s=$e(()=>!!t.value);function n(){const l=Is();l&&l.auth.onAuthStateChange((c,u)=>{var h,d;u?(t.value=u.access_token,e.value=((h=u.user)==null?void 0:h.email)??null,localStorage.setItem("io_token",u.access_token),(d=u.user)!=null&&d.email&&localStorage.setItem("io_email",u.user.email)):(t.value=null,e.value=null,localStorage.removeItem("io_token"),localStorage.removeItem("io_email"))})}async function i(l,c){var h,d;const u=Is();if(!u)throw new Error("Auth not configured");r.value=!0;try{const{data:f,error:m}=await u.auth.signInWithPassword({email:l,password:c});if(m)throw m;t.value=((h=f.session)==null?void 0:h.access_token)??null,e.value=((d=f.user)==null?void 0:d.email)??null,t.value&&localStorage.setItem("io_token",t.value),e.value&&localStorage.setItem("io_email",e.value)}finally{r.value=!1}}async function o(){const l=Is();l&&await l.auth.signOut(),t.value=null,e.value=null,localStorage.removeItem("io_token"),localStorage.removeItem("io_email")}async function a(){const l=Is();if(!l)return;const{data:c,error:u}=await l.auth.refreshSession();if(u||!c.session){t.value=null,localStorage.removeItem("io_token");return}t.value=c.session.access_token,localStorage.setItem("io_token",c.session.access_token)}return{token:t,email:e,loading:r,isAuthenticated:s,login:i,logout:o,refreshToken:a,initAuthListener:n}}),_m=Object.freeze(Object.defineProperty({__proto__:null,useAuthStore:kn},Symbol.toStringTag,{value:"Module"}));/**
|
|
69
|
+
Request ID: ${l}`),c){let v=`
|
|
70
|
+
Resources:`;for(const b of c){if(!b||typeof b!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${b}`);v+=`
|
|
71
|
+
- ${b}`}E+=v}return`${A}
|
|
72
|
+
${E}`}class ge extends Error{constructor({message:e,code:r,cause:s,name:n}){var i;super(e,{cause:s}),this.__isWebAuthnError=!0,this.name=(i=n??(s instanceof Error?s.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=r}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class Qs extends ge{constructor(e,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}),this.name="WebAuthnUnknownError",this.originalError=r}}function jg({error:t,options:e}){var r,s,n;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new ge({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=i.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new ge({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((s=i.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new ge({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new ge({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new ge({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new ge({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(a=>a.type==="public-key").length===0?new ge({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new ge({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const o=window.location.hostname;if(Sc(o)){if(i.rp.id!==o)return new ge({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new ge({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new ge({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new ge({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new ge({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Ng({error:t,options:e}){const{publicKey:r}=e;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new ge({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new ge({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const s=window.location.hostname;if(Sc(s)){if(r.rpId!==s)return new ge({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new ge({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new ge({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new ge({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class Lg{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const wi=new Lg;function ya(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:r,excludeCredentials:s}=t,n=wn(t,["challenge","user","excludeCredentials"]),i=Er(e).buffer,o=Object.assign(Object.assign({},r),{id:Er(r.id).buffer}),a=Object.assign(Object.assign({},n),{challenge:i,user:o});if(s&&s.length>0){a.excludeCredentials=new Array(s.length);for(let l=0;l<s.length;l++){const c=s[l];a.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:Er(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return a}function _a(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:r}=t,s=wn(t,["challenge","allowCredentials"]),n=Er(e).buffer,i=Object.assign(Object.assign({},s),{challenge:n});if(r&&r.length>0){i.allowCredentials=new Array(r.length);for(let o=0;o<r.length;o++){const a=r[o];i.allowCredentials[o]=Object.assign(Object.assign({},a),{id:Er(a.id).buffer,type:a.type||"public-key",transports:a.transports})}}return i}function va(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t;return{id:t.id,rawId:t.id,response:{attestationObject:er(new Uint8Array(t.response.attestationObject)),clientDataJSON:er(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function ba(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t,s=t.getClientExtensionResults(),n=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:er(new Uint8Array(n.authenticatorData)),clientDataJSON:er(new Uint8Array(n.clientDataJSON)),signature:er(new Uint8Array(n.signature)),userHandle:n.userHandle?er(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:s,authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Sc(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function Zs(){var t,e;return!!(we()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.get)=="function")}async function Ec(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Qs("Browser returned unexpected credential type",e)}:{data:null,error:new Qs("Empty credential response",e)}}catch(e){return{data:null,error:jg({error:e,options:t})}}}async function kc(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Qs("Browser returned unexpected credential type",e)}:{data:null,error:new Qs("Empty credential response",e)}}catch(e){return{data:null,error:Ng({error:e,options:t})}}}const $g={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},Dg={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function en(...t){const e=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),r=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),s={};for(const n of t)if(n)for(const i in n){const o=n[i];if(o!==void 0)if(Array.isArray(o))s[i]=o;else if(r(o))s[i]=o;else if(e(o)){const a=s[i];e(a)?s[i]=en(a,o):s[i]=en(o)}else s[i]=o}return s}function Ug(t,e){return en($g,t,e||{})}function Mg(t,e){return en(Dg,t,e||{})}class Bg{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:r,friendlyName:s,signal:n},i){var o;try{const{data:a,error:l}=await this.client.mfa.challenge({factorId:e,webauthn:r});if(!a)return{data:null,error:l};const c=n??wi.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:u}=a.webauthn.credential_options.publicKey;if(!u.name){const h=s;if(h)u.name=`${u.id}:${h}`;else{const f=(await this.client.getUser()).data.user,m=((o=f==null?void 0:f.user_metadata)===null||o===void 0?void 0:o.name)||(f==null?void 0:f.email)||(f==null?void 0:f.id)||"User";u.name=`${u.id}:${m}`}}u.displayName||(u.displayName=u.name)}switch(a.webauthn.type){case"create":{const u=Ug(a.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:h,error:d}=await Ec({publicKey:u,signal:c});return h?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:h}},error:null}:{data:null,error:d}}case"request":{const u=Mg(a.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:h,error:d}=await kc(Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:u,signal:c}));return h?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:h}},error:null}:{data:null,error:d}}}}catch(a){return x(a)?{data:null,error:a}:{data:null,error:new Xe("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:r,webauthn:s}){return this.client.mfa.verify({factorId:r,challengeId:e,webauthn:s})}async _authenticate({factorId:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!r)return{data:null,error:new Cr("rpId is required for WebAuthn authentication")};try{if(!Zs())return{data:null,error:new Xe("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this.challenge({factorId:e,webauthn:{rpId:r,rpOrigins:s},signal:n},{request:i});if(!o)return{data:null,error:a};const{webauthn:l}=o;return this._verify({factorId:e,challengeId:o.challengeId,webauthn:{type:l.type,rpId:r,rpOrigins:s,credential_response:l.credential_response}})}catch(o){return x(o)?{data:null,error:o}:{data:null,error:new Xe("Unexpected error in authenticate",o)}}}async _register({friendlyName:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!r)return{data:null,error:new Cr("rpId is required for WebAuthn registration")};try{if(!Zs())return{data:null,error:new Xe("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this._enroll({friendlyName:e});if(!o)return await this.client.mfa.listFactors().then(u=>{var h;return(h=u.data)===null||h===void 0?void 0:h.all.find(d=>d.factor_type==="webauthn"&&d.friendly_name===e&&d.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u==null?void 0:u.id}):void 0),{data:null,error:a};const{data:l,error:c}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:r,rpOrigins:s},signal:n},{create:i});return l?this._verify({factorId:o.id,challengeId:l.challengeId,webauthn:{rpId:r,rpOrigins:s,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(o){return x(o)?{data:null,error:o}:{data:null,error:new Xe("Unexpected error in register",o)}}}}Cg();const Hg={url:Kp,storageKey:Wp,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Gp,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function wa(t,e,r){return await r()}const dr={};class ps{get jwks(){var e,r;return(r=(e=dr[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){dr[this.storageKey]=Object.assign(Object.assign({},dr[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=dr[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){dr[this.storageKey]=Object.assign(Object.assign({},dr[this.storageKey]),{cachedAt:e})}constructor(e){var r,s,n,i;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=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;const o=Object.assign(Object.assign({},Hg),e);if(this.storageKey=o.storageKey,this.instanceID=(r=ps.nextInstanceID[this.storageKey])!==null&&r!==void 0?r:0,ps.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!o.debug,typeof o.debug=="function"&&(this.logger=o.debug),this.instanceID>0&&we()){const a=`${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(a),this.logDebugMessages&&console.trace(a)}if(this.persistSession=o.persistSession,this.autoRefreshToken=o.autoRefreshToken,this.experimental=(s=o.experimental)!==null&&s!==void 0?s:{},this.admin=new Rg({url:o.url,headers:o.headers,fetch:o.fetch,experimental:this.experimental}),this.url=o.url,this.headers=o.headers,this.fetch=vc(o.fetch),this.lock=o.lock||wa,this.detectSessionInUrl=o.detectSessionInUrl,this.flowType=o.flowType,this.hasCustomAuthorizationHeader=o.hasCustomAuthorizationHeader,this.throwOnError=o.throwOnError,this.lockAcquireTimeout=o.lockAcquireTimeout,o.lock?this.lock=o.lock:this.persistSession&&we()&&(!((n=globalThis==null?void 0:globalThis.navigator)===null||n===void 0)&&n.locks)?this.lock=Og:this.lock=wa,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 Bg(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.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(o.storage?this.storage=o.storage:_c()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=ga(this.memoryStorage)),o.userStorage&&(this.userStorage=o.userStorage)):(this.memoryStorage={},this.storage=ga(this.memoryStorage)),we()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(i=this.broadcastChannel)===null||i===void 0||i.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a);try{await this._notifyAllSubscribers(a.data.event,a.data.session,!1)}catch(l){this._debug("#broadcastChannel","error",l)}})}o.skipAutoInitialize||this.initialize().catch(a=>{this._debug("#initialize()","error",a)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${gc}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let r={},s="none";if(we()&&(r=ag(window.location.href),this._isImplicitGrantCallback(r)?s="implicit":await this._isPKCECallback(r)&&(s="pkce")),we()&&this.detectSessionInUrl&&s!=="none"){const{data:n,error:i}=await this._getSessionFromURL(r,s);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),Qp(i)){const l=(e=i.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:i}}return{error:i}}const{session:o,redirectType:a}=n;return this._debug("#_initialize()","detected session in URL",o,"redirect type",a),await this._saveSession(o),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return x(r)?this._returnResult({error:r}):this._returnResult({error:new Xe("Unexpected error during initialization",r)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,s,n;try{const i=await $(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(s=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:(n=e==null?void 0:e.options)===null||n===void 0?void 0:n.captchaToken}},xform:Ke}),{data:o,error:a}=i;if(a||!o)return this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(x(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(e){var r,s,n;try{let i;if("email"in e){const{email:u,password:h,options:d}=e;let f=null,m=null;this.flowType==="pkce"&&([f,m]=await hr(this.storage,this.storageKey)),i=await $(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:d==null?void 0:d.emailRedirectTo,body:{email:u,password:h,data:(r=d==null?void 0:d.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:f,code_challenge_method:m},xform:Ke})}else if("phone"in e){const{phone:u,password:h,options:d}=e;i=await $(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:h,data:(s=d==null?void 0:d.data)!==null&&s!==void 0?s:{},channel:(n=d==null?void 0:d.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken}},xform:Ke})}else throw new Ps("You must provide either an email or phone number and a password");const{data:o,error:a}=i;if(a||!o)return await be(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithPassword(e){try{let r;if("email"in e){const{email:i,password:o,options:a}=e;r=await $(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:fa})}else if("phone"in e){const{phone:i,password:o,options:a}=e;r=await $(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:fa})}else throw new Ps("You must provide either an email or phone number and a password");const{data:s,error:n}=r;if(n)return this._returnResult({data:{user:null,session:null},error:n});if(!s||!s.session||!s.user){const i=new ur;return this._returnResult({data:{user:null,session:null},error:i})}return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),this._returnResult({data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:n})}catch(r){if(x(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOAuth(e){var r,s,n,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(s=e.options)===null||s===void 0?void 0:s.scopes,queryParams:(n=e.options)===null||n===void 0?void 0:n.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:r}=e;switch(r){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(e){var r,s,n,i,o,a,l,c,u,h,d;let f,m;if("message"in e)f=e.message,m=e.signature;else{const{chain:_,wallet:A,statement:E,options:v}=e;let b;if(we())if(typeof A=="object")b=A;else{const V=window;if("ethereum"in V&&typeof V.ethereum=="object"&&"request"in V.ethereum&&typeof V.ethereum.request=="function")b=V.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof A!="object"||!(v!=null&&v.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");b=A}const O=new URL((r=v==null?void 0:v.url)!==null&&r!==void 0?r:window.location.href),M=await b.request({method:"eth_requestAccounts"}).then(V=>V).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!M||M.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const W=wc(M[0]);let q=(s=v==null?void 0:v.signInWithEthereum)===null||s===void 0?void 0:s.chainId;if(!q){const V=await b.request({method:"eth_chainId"});q=Pg(V)}const J={domain:O.host,address:W,statement:E,uri:O.href,version:"1",chainId:q,nonce:(n=v==null?void 0:v.signInWithEthereum)===null||n===void 0?void 0:n.nonce,issuedAt:(o=(i=v==null?void 0:v.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(a=v==null?void 0:v.signInWithEthereum)===null||a===void 0?void 0:a.expirationTime,notBefore:(l=v==null?void 0:v.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=v==null?void 0:v.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=v==null?void 0:v.signInWithEthereum)===null||u===void 0?void 0:u.resources};f=Ig(J),m=await b.request({method:"personal_sign",params:[xg(f),W]})}try{const{data:_,error:A}=await $(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:m},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(d=e.options)===null||d===void 0?void 0:d.captchaToken}}:null),xform:Ke});if(A)throw A;if(!_||!_.session||!_.user){const E=new ur;return this._returnResult({data:{user:null,session:null},error:E})}return _.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers("SIGNED_IN",_.session)),this._returnResult({data:Object.assign({},_),error:A})}catch(_){if(x(_))return this._returnResult({data:{user:null,session:null},error:_});throw _}}async signInWithSolana(e){var r,s,n,i,o,a,l,c,u,h,d,f;let m,_;if("message"in e)m=e.message,_=e.signature;else{const{chain:A,wallet:E,statement:v,options:b}=e;let O;if(we())if(typeof E=="object")O=E;else{const W=window;if("solana"in W&&typeof W.solana=="object"&&("signIn"in W.solana&&typeof W.solana.signIn=="function"||"signMessage"in W.solana&&typeof W.solana.signMessage=="function"))O=W.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof E!="object"||!(b!=null&&b.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");O=E}const M=new URL((r=b==null?void 0:b.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in O&&O.signIn){const W=await O.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},b==null?void 0:b.signInWithSolana),{version:"1",domain:M.host,uri:M.href}),v?{statement:v}:null));let q;if(Array.isArray(W)&&W[0]&&typeof W[0]=="object")q=W[0];else if(W&&typeof W=="object"&&"signedMessage"in W&&"signature"in W)q=W;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in q&&"signature"in q&&(typeof q.signedMessage=="string"||q.signedMessage instanceof Uint8Array)&&q.signature instanceof Uint8Array)m=typeof q.signedMessage=="string"?q.signedMessage:new TextDecoder().decode(q.signedMessage),_=q.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in O)||typeof O.signMessage!="function"||!("publicKey"in O)||typeof O!="object"||!O.publicKey||!("toBase58"in O.publicKey)||typeof O.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");m=[`${M.host} wants you to sign in with your Solana account:`,O.publicKey.toBase58(),...v?["",v,""]:[""],"Version: 1",`URI: ${M.href}`,`Issued At: ${(n=(s=b==null?void 0:b.signInWithSolana)===null||s===void 0?void 0:s.issuedAt)!==null&&n!==void 0?n:new Date().toISOString()}`,...!((i=b==null?void 0:b.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${b.signInWithSolana.notBefore}`]:[],...!((o=b==null?void 0:b.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${b.signInWithSolana.expirationTime}`]:[],...!((a=b==null?void 0:b.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${b.signInWithSolana.chainId}`]:[],...!((l=b==null?void 0:b.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${b.signInWithSolana.nonce}`]:[],...!((c=b==null?void 0:b.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${b.signInWithSolana.requestId}`]:[],...!((h=(u=b==null?void 0:b.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||h===void 0)&&h.length?["Resources",...b.signInWithSolana.resources.map(q=>`- ${q}`)]:[]].join(`
|
|
73
|
+
`);const W=await O.signMessage(new TextEncoder().encode(m),"utf8");if(!W||!(W instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");_=W}}try{const{data:A,error:E}=await $(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:m,signature:er(_)},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:Ke});if(E)throw E;if(!A||!A.session||!A.user){const v=new ur;return this._returnResult({data:{user:null,session:null},error:v})}return A.session&&(await this._saveSession(A.session),await this._notifyAllSubscribers("SIGNED_IN",A.session)),this._returnResult({data:Object.assign({},A),error:E})}catch(A){if(x(A))return this._returnResult({data:{user:null,session:null},error:A});throw A}}async _exchangeCodeForSession(e){const r=await Yt(this.storage,`${this.storageKey}-code-verifier`),[s,n]=(r??"").split("/");try{if(!s&&this.flowType==="pkce")throw new Zp;const{data:i,error:o}=await $(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:s},xform:Ke});if(await be(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!i||!i.session||!i.user){const a=new ur;return this._returnResult({data:{user:null,session:null,redirectType:null},error:a})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers(n==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:n??null}),error:o})}catch(i){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(e){try{const{options:r,provider:s,token:n,access_token:i,nonce:o}=e,a=await $(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:n,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Ke}),{data:l,error:c}=a;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l||!l.session||!l.user){const u=new ur;return this._returnResult({data:{user:null,session:null},error:u})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),this._returnResult({data:l,error:c})}catch(r){if(x(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,s,n,i,o;try{if("email"in e){const{email:a,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await hr(this.storage,this.storageKey));const{error:h}=await $(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=l==null?void 0:l.data)!==null&&r!==void 0?r:{},create_user:(s=l==null?void 0:l.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l==null?void 0:l.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:h})}if("phone"in e){const{phone:a,options:l}=e,{data:c,error:u}=await $(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(n=l==null?void 0:l.data)!==null&&n!==void 0?n:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:u})}throw new Ps("You must provide either an email or phone number.")}catch(a){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async verifyOtp(e){var r,s;try{let n,i;"options"in e&&(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo,i=(s=e.options)===null||s===void 0?void 0:s.captchaToken);const{data:o,error:a}=await $(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:n,xform:Ke});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,c=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(n){if(x(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithSSO(e){var r,s,n,i,o;try{let a=null,l=null;this.flowType==="pkce"&&([a,l]=await hr(this.storage,this.storageKey));const c=await $(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:(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&s!==void 0?s:void 0}),!((n=e==null?void 0:e.options)===null||n===void 0)&&n.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:l}),headers:this.headers,xform:kg});return!((i=c.data)===null||i===void 0)&&i.url&&we()&&!(!((o=e.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(a){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(a))return this._returnResult({data:null,error:a});throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)throw s;if(!r)throw new _e;const{error:n}=await $(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:n})})}catch(e){if(x(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:s,type:n,options:i}=e,{error:o}=await $(this.fetch,"POST",r,{headers:this.headers,body:{email:s,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in e){const{phone:s,type:n,options:i}=e,{data:o,error:a}=await $(this.fetch,"POST",r,{headers:this.headers,body:{phone:s,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a})}throw new Ps("You must provide either an email or phone number and a type")}catch(r){if(x(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const s=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await s,await r()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const s=r();for(this.pendingInLock.push((async()=>{try{await s}catch{}})()),await s;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await s}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await Yt(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const s=e.expires_at?e.expires_at*1e3-Date.now()<Hn:!1;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",e.expires_at),!s){if(this.userStorage){const o=await Yt(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=qn()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};e.user=bg(e.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{session:null},error:i}):this._returnResult({data:{session:n},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const r=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await $(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Ft}):await this._useSession(async r=>{var s,n,i;const{data:o,error:a}=r;if(a)throw a;return!(!((s=o.session)===null||s===void 0)&&s.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new _e}:await $(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0,xform:Ft})})}catch(r){if(x(r))return Cs(r)&&(await this._removeSession(),await be(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:r});throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async s=>{const{data:n,error:i}=s;if(i)throw i;if(!n.session)throw new _e;const o=n.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await hr(this.storage,this.storageKey));const{data:c,error:u}=await $(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:Ft});if(u)throw u;return o.user=c.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(s){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(s))return this._returnResult({data:{user:null},error:s});throw s}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new _e;const r=Date.now()/1e3;let s=r,n=!0,i=null;const{payload:o}=Is(e.access_token);if(o.exp&&(s=o.exp,n=s<=r),n){const{data:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:s-r,expires_at:s},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(r){if(x(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var s;if(!e){const{data:o,error:a}=r;if(a)throw a;e=(s=o.session)!==null&&s!==void 0?s:void 0}if(!(e!=null&&e.refresh_token))throw new _e;const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):n?this._returnResult({data:{user:n.user,session:n},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(x(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){var s;try{if(!we())throw new xs("No browser detected.");if(e.error||e.error_description||e.error_code)throw new xs(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new oa("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new xs("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new oa("No code detected.");const{data:b,error:O}=await this._exchangeCodeForSession(e.code);if(O)throw O;const M=new URL(window.location.href);return M.searchParams.delete("code"),window.history.replaceState(window.history.state,"",M.toString()),{data:{session:b.session,redirectType:(s=b.redirectType)!==null&&s!==void 0?s:null},error:null}}const{provider_token:n,provider_refresh_token:i,access_token:o,refresh_token:a,expires_in:l,expires_at:c,token_type:u}=e;if(!o||!l||!a||!u)throw new xs("No session defined in URL");const h=Math.round(Date.now()/1e3),d=parseInt(l);let f=h+d;c&&(f=parseInt(c));const m=f-h;m*1e3<=yr&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${m}s, should have been closer to ${d}s`);const _=f-d;h-_>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",_,f,h):h-_<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",_,f,h);const{data:A,error:E}=await this._getUser(o);if(E)throw E;const v={provider_token:n,provider_refresh_token:i,access_token:o,expires_in:d,expires_at:f,refresh_token:a,token_type:u,user:A.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:v,redirectType:e.type},error:null})}catch(n){if(x(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const r=await Yt(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var s;const{data:n,error:i}=r;if(i&&!Cs(i))return this._returnResult({error:i});const o=(s=n.session)===null||s===void 0?void 0:s.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(Xp(a)&&(a.status===404||a.status===401||a.status===403)||Cs(a)))return this._returnResult({error:a})}return e!=="others"&&(await this._removeSession(),await be(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const r=og(),s={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,s),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:s}}}async _emitInitialSession(e){return await this._useSession(async r=>{var s,n;try{const{data:{session:i},error:o}=r;if(o)throw o;await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),Cs(i)?console.warn(i):console.error(i)}})}async resetPasswordForEmail(e,r={}){let s=null,n=null;this.flowType==="pkce"&&([s,n]=await hr(this.storage,this.storageKey,!0));try{return await $(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:s,code_challenge_method:n,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:r,error:s}=await this.getUser();if(s)throw s;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var r;try{const{data:s,error:n}=await this._useSession(async i=>{var o,a,l,c,u;const{data:h,error:d}=i;if(d)throw d;const f=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await $(this.fetch,"GET",f,{headers:this.headers,jwt:(u=(c=h.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(n)throw n;return we()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(s==null?void 0:s.url),this._returnResult({data:{provider:e.provider,url:s==null?void 0:s.url},error:null})}catch(s){if(x(s))return this._returnResult({data:{provider:e.provider,url:null},error:s});throw s}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var s;try{const{error:n,data:{session:i}}=r;if(n)throw n;const{options:o,provider:a,token:l,access_token:c,nonce:u}=e,h=await $(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(s=i==null?void 0:i.access_token)!==null&&s!==void 0?s:void 0,body:{provider:a,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:Ke}),{data:d,error:f}=h;return f?this._returnResult({data:{user:null,session:null},error:f}):!d||!d.session||!d.user?this._returnResult({data:{user:null,session:null},error:new ur}):(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("USER_UPDATED",d.session)),this._returnResult({data:d,error:f}))}catch(n){if(await be(this.storage,`${this.storageKey}-code-verifier`),x(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var s,n;const{data:i,error:o}=r;if(o)throw o;return await $(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(s=i.session)===null||s===void 0?void 0:s.access_token)!==null&&n!==void 0?n:void 0})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const s=Date.now();return await ug(async n=>(n>0&&await cg(200*Math.pow(2,n-1)),this._debug(r,"refreshing attempt",n),await $(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Ke})),(n,i)=>{const o=200*Math.pow(2,n);return i&&Fn(i)&&Date.now()+o-s<yr})}catch(s){if(this._debug(r,"error",s),x(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const s=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",s),we()&&!r.skipBrowserRedirect&&window.location.assign(s),{data:{provider:e,url:s},error:null}}async _recoverAndRefresh(){var e,r;const s="#_recoverAndRefresh()";this._debug(s,"begin");try{const n=await Yt(this.storage,this.storageKey);if(n&&this.userStorage){let o=await Yt(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:n.user},await _r(this.userStorage,this.storageKey+"-user",o)),n.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:qn()}else if(n&&!n.user&&!n.user){const o=await Yt(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(n.user=o.user,await be(this.storage,this.storageKey+"-user"),await _r(this.storage,this.storageKey,n)):n.user=qn()}if(this._debug(s,"session from storage",n),!this._isValidSession(n)){this._debug(s,"session is not valid"),n!==null&&await this._removeSession();return}const i=((r=n.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<Hn;if(this._debug(s,`session has${i?"":" not"} expired with margin of ${Hn}s`),i){if(this.autoRefreshToken&&n.refresh_token){const{error:o}=await this._callRefreshToken(n.refresh_token);o&&(console.error(o),Fn(o)||(this._debug(s,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(n.user&&n.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:a}=await this._getUser(n.access_token);!a&&(o!=null&&o.user)?(n.user=o.user,await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)):this._debug(s,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(s,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(s,"error",n),console.error(n);return}finally{this._debug(s,"end")}}async _callRefreshToken(e){var r,s;if(!e)throw new _e;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const n=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{this.refreshingDeferred=new kn;const{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new _e;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const a={data:i.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(i){if(this._debug(n,"error",i),x(i)){const o={data:null,error:i};return Fn(i)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(o),o}throw(s=this.refreshingDeferred)===null||s===void 0||s.reject(i),i}finally{this.refreshingDeferred=null,this._debug(n,"end")}}async _notifyAllSubscribers(e,r,s=!0){const n=`#_notifyAllSubscribers(${e})`;this._debug(n,"begin",r,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:e,session:r});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,r)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;a<i.length;a+=1)console.error(i[a]);throw i[0]}}finally{this._debug(n,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await be(this.storage,`${this.storageKey}-code-verifier`);const r=Object.assign({},e),s=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!s&&r.user&&await _r(this.userStorage,this.storageKey+"-user",{user:r.user});const n=Object.assign({},r);delete n.user;const i=ha(n);await _r(this.storage,this.storageKey,i)}else{const n=ha(r);await _r(this.storage,this.storageKey,n)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await be(this.storage,this.storageKey),await be(this.storage,this.storageKey+"-code-verifier"),await be(this.storage,this.storageKey+"-user"),this.userStorage&&await be(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&we()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),yr);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const r=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=r,r&&typeof r=="object"&&typeof r.unref=="function"?r.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(r)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const r=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,r&&clearTimeout(r)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:s}}=r;if(!s||!s.refresh_token||!s.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((s.expires_at*1e3-e)/yr);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${yr}ms, refresh threshold is ${yi} ticks`),n<=yi&&await this._callRefreshToken(s.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof bc)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!we()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,s){const n=[`provider=${encodeURIComponent(r)}`];if(s!=null&&s.redirectTo&&n.push(`redirect_to=${encodeURIComponent(s.redirectTo)}`),s!=null&&s.scopes&&n.push(`scopes=${encodeURIComponent(s.scopes)}`),this.flowType==="pkce"){const[i,o]=await hr(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});n.push(a.toString())}if(s!=null&&s.queryParams){const i=new URLSearchParams(s.queryParams);n.push(i.toString())}return s!=null&&s.skipBrowserRedirect&&n.push(`skip_http_redirect=${s.skipBrowserRedirect}`),`${e}?${n.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var s;const{data:n,error:i}=r;return i?this._returnResult({data:null,error:i}):await $(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(s=n==null?void 0:n.session)===null||s===void 0?void 0:s.access_token})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var s,n;const{data:i,error:o}=r;if(o)return this._returnResult({data:null,error:o});const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await $(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(s=i==null?void 0:i.session)===null||s===void 0?void 0:s.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((n=l==null?void 0:l.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async r=>{var s;const{data:n,error:i}=r;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?va(e.webauthn.credential_response):ba(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:l}=await $(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(s=n==null?void 0:n.session)===null||s===void 0?void 0:s.access_token});return l?this._returnResult({data:null,error:l}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),this._returnResult({data:a,error:l}))})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async r=>{var s;const{data:n,error:i}=r;if(i)return this._returnResult({data:null,error:i});const o=await $(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(s=n==null?void 0:n.session)===null||s===void 0?void 0:s.access_token});if(o.error)return o;const{data:a}=o;if(a.type!=="webauthn")return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:ya(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:_a(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}})}async _challengeAndVerify(e){const{data:r,error:s}=await this._challenge({factorId:e.factorId});return s?this._returnResult({data:null,error:s}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:s}=await this.getUser();if(s)return{data:null,error:s};const n={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=r==null?void 0:r.factors)!==null&&e!==void 0?e:[])n.all.push(i),i.status==="verified"&&n[i.factor_type].push(i);return{data:n,error:null}}async _getAuthenticatorAssuranceLevel(e){var r,s,n,i;if(e)try{const{payload:f}=Is(e);let m=null;f.aal&&(m=f.aal);let _=m;const{data:{user:A},error:E}=await this.getUser(e);if(E)return this._returnResult({data:null,error:E});((s=(r=A==null?void 0:A.factors)===null||r===void 0?void 0:r.filter(O=>O.status==="verified"))!==null&&s!==void 0?s:[]).length>0&&(_="aal2");const b=f.amr||[];return{data:{currentLevel:m,nextLevel:_,currentAuthenticationMethods:b},error:null}}catch(f){if(x(f))return this._returnResult({data:null,error:f});throw f}const{data:{session:o},error:a}=await this.getSession();if(a)return this._returnResult({data:null,error:a});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=Is(o.access_token);let c=null;l.aal&&(c=l.aal);let u=c;((i=(n=o.user.factors)===null||n===void 0?void 0:n.filter(f=>f.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(u="aal2");const d=l.amr||[];return{data:{currentLevel:c,nextLevel:u,currentAuthenticationMethods:d},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?await $(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:s.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new _e})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:i}=s;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new _e});const o=await $(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"approve"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&we()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(s){if(x(s))return this._returnResult({data:null,error:s});throw s}}async _denyAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:i}=s;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new _e});const o=await $(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"deny"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&we()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(s){if(x(s))return this._returnResult({data:null,error:s});throw s}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;return s?this._returnResult({data:null,error:s}):r?await $(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:n=>({data:n,error:null})}):this._returnResult({data:null,error:new _e})})}catch(e){if(x(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?(await $(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new _e})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let s=r.keys.find(a=>a.kid===e);if(s)return s;const n=Date.now();if(s=this.jwks.keys.find(a=>a.kid===e),s&&this.jwks_cached_at+Jp>n)return s;const{data:i,error:o}=await $(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=n,s=i.keys.find(a=>a.kid===e),!s)?null:s}async getClaims(e,r={}){try{let s=e;if(!s){const{data:f,error:m}=await this.getSession();if(m||!f.session)return this._returnResult({data:null,error:m});s=f.session.access_token}const{header:n,payload:i,signature:o,raw:{header:a,payload:l}}=Is(s);r!=null&&r.allowExpired||yg(i.exp);const c=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!c){const{error:f}=await this.getUser(s);if(f)throw f;return{data:{claims:i,header:n,signature:o},error:null}}const u=_g(n.alg),h=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,h,o,ng(`${a}.${l}`)))throw new bi("Invalid JWT signature");return{data:{claims:i,header:n,signature:o},error:null}}catch(s){if(x(s))return this._returnResult({data:null,error:s});throw s}}async signInWithPasskey(e){var r,s,n;Je(this.experimental);try{if(!Zs())return this._returnResult({data:null,error:new Xe("Browser does not support WebAuthn",null)});const{data:i,error:o}=await this._startPasskeyAuthentication({options:{captchaToken:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}});if(o||!i)return this._returnResult({data:null,error:o});const a=_a(i.options),l=(n=(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.signal)!==null&&n!==void 0?n:wi.createNewAbortSignal(),{data:c,error:u}=await kc({publicKey:a,signal:l});if(u||!c)return this._returnResult({data:null,error:u??new Xe("WebAuthn ceremony failed",null)});const h=ba(c);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:h})}catch(i){if(x(i))return this._returnResult({data:null,error:i});throw i}}async registerPasskey(e){var r,s;Je(this.experimental);try{if(!Zs())return this._returnResult({data:null,error:new Xe("Browser does not support WebAuthn",null)});const{data:n,error:i}=await this._startPasskeyRegistration();if(i||!n)return this._returnResult({data:null,error:i});const o=ya(n.options),a=(s=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.signal)!==null&&s!==void 0?s:wi.createNewAbortSignal(),{data:l,error:c}=await Ec({publicKey:o,signal:a});if(c||!l)return this._returnResult({data:null,error:c??new Xe("WebAuthn ceremony failed",null)});const u=va(l);return this._verifyPasskeyRegistration({challengeId:n.challenge_id,credential:u})}catch(n){if(x(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyRegistration(){Je(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new _e});const{data:n,error:i}=await $(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:r.access_token,body:{}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(x(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){Je(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new _e});const{data:i,error:o}=await $(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:s.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _startPasskeyAuthentication(e){var r;Je(this.experimental);try{const{data:s,error:n}=await $(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:s,error:null})}catch(s){if(x(s))return this._returnResult({data:null,error:s});throw s}}async _verifyPasskeyAuthentication(e){Je(this.experimental);try{const{data:r,error:s}=await $(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:Ke});return s?this._returnResult({data:null,error:s}):(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:r,error:null}))}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _listPasskeys(){Je(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new _e});const{data:n,error:i}=await $(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:r.access_token,xform:o=>({data:o,error:null})});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(x(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){Je(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new _e});const{data:i,error:o}=await $(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,body:{friendly_name:e.friendlyName}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}async _deletePasskey(e){Je(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new _e});const{error:i}=await $(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,noResolveJson:!0});return i?this._returnResult({data:null,error:i}):this._returnResult({data:null,error:null})})}catch(r){if(x(r))return this._returnResult({data:null,error:r});throw r}}}ps.nextInstanceID={};const Fg=ps,qg="2.106.2";let Hr="";typeof Deno<"u"?Hr="deno":typeof document<"u"?Hr="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Hr="react-native":Hr="node";const Vg={"X-Client-Info":`supabase-js-${Hr}/${qg}`},Kg={headers:Vg},Wg={schema:"public"},Gg={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},zg={},Jg={enabled:!1,respectSamplingDecision:!0};function Yg(t,e,r,s){function n(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(u){try{c(s.next(u))}catch(h){o(h)}}function l(u){try{c(s.throw(u))}catch(h){o(h)}}function c(u){u.done?i(u.value):n(u.value).then(a,l)}c((s=s.apply(t,[])).next())})}let Kn=null;const Xg="@opentelemetry/api";function Qg(){return Kn===null&&(Kn=import(Xg).catch(()=>null)),Kn}function Zg(){return Yg(this,void 0,void 0,function*(){try{const t=yield Qg();if(!t||!t.propagation||!t.context)return null;const e={};t.propagation.inject(t.context.active(),e);const r=e.traceparent;return r?{traceparent:r,tracestate:e.tracestate,baggage:e.baggage}:null}catch{return null}})}function em(t){if(!t||typeof t!="string")return null;const e=t.split("-");if(e.length!==4)return null;const[r,s,n,i]=e;if(r.length!==2||s.length!==32||n.length!==16||i.length!==2)return null;const o=/^[0-9a-f]+$/i;return!o.test(r)||!o.test(s)||!o.test(n)||!o.test(i)||s==="00000000000000000000000000000000"||n==="0000000000000000"?null:{version:r,traceId:s,parentId:n,traceFlags:i,isSampled:(parseInt(i,16)&1)===1}}function tm(t,e){if(!t||!e||e.length===0)return!1;let r;if(t instanceof URL)r=t;else try{r=new URL(t)}catch{return!1}for(const s of e)try{if(typeof s=="string"){if(rm(r.hostname,s))return!0}else if(s instanceof RegExp){if(s.test(r.hostname))return!0}else if(typeof s=="function"&&s(r))return!0}catch{continue}return!1}function rm(t,e){if(e===t)return!0;if(e.startsWith("*.")){const r=e.slice(2);if(t.endsWith(r)&&(t===r||t.endsWith("."+r)))return!0}return!1}function sm(t){const e=[];try{const r=new URL(t);e.push(r.hostname)}catch{}return e.push("*.supabase.co","*.supabase.in"),e.push("localhost","127.0.0.1","[::1]"),e}function gs(t){"@babel/helpers - typeof";return gs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gs(t)}function nm(t,e){if(gs(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(gs(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function im(t){var e=nm(t,"string");return gs(e)=="symbol"?e:e+""}function om(t,e,r){return(e=im(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sa(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function de(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Sa(Object(r),!0).forEach(function(s){om(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Sa(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}const am=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),lm=()=>Headers,cm=(t,e,r,s,n)=>{const i=am(s),o=lm(),a=(n==null?void 0:n.enabled)===!0,l=(n==null?void 0:n.respectSamplingDecision)!==!1,c=a?sm(e):null;return async(u,h)=>{var d;const f=(d=await r())!==null&&d!==void 0?d:t;let m=new o(h==null?void 0:h.headers);if(m.has("apikey")||m.set("apikey",t),m.has("Authorization")||m.set("Authorization",`Bearer ${f}`),c){const _=await um(u,c,l);_&&(_.traceparent&&!m.has("traceparent")&&m.set("traceparent",_.traceparent),_.tracestate&&!m.has("tracestate")&&m.set("tracestate",_.tracestate),_.baggage&&!m.has("baggage")&&m.set("baggage",_.baggage))}return i(u,de(de({},h),{},{headers:m}))}};async function um(t,e,r){if(!tm(typeof t=="string"||t instanceof URL?t:t.url,e))return null;const s=await Zg();if(!s||!s.traceparent)return null;if(r){const n=em(s.traceparent);if(n&&!n.isSampled)return null}return s}function Ea(t){return typeof t=="boolean"?{enabled:t}:t}function hm(t){return t.endsWith("/")?t:t+"/"}function dm(t,e){var r,s,n,i,o,a;const{db:l,auth:c,realtime:u,global:h}=t,{db:d,auth:f,realtime:m,global:_}=e,A=Ea(t.tracePropagation),E=Ea(e.tracePropagation),v={db:de(de({},d),l),auth:de(de({},f),c),realtime:de(de({},m),u),storage:{},global:de(de(de({},_),h),{},{headers:de(de({},(r=_==null?void 0:_.headers)!==null&&r!==void 0?r:{}),(s=h==null?void 0:h.headers)!==null&&s!==void 0?s:{})}),tracePropagation:{enabled:(n=(i=A==null?void 0:A.enabled)!==null&&i!==void 0?i:E==null?void 0:E.enabled)!==null&&n!==void 0?n:!1,respectSamplingDecision:(o=(a=A==null?void 0:A.respectSamplingDecision)!==null&&a!==void 0?a:E==null?void 0:E.respectSamplingDecision)!==null&&o!==void 0?o:!0},accessToken:async()=>""};return t.accessToken?v.accessToken=t.accessToken:delete v.accessToken,v}function fm(t){const e=t==null?void 0:t.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(hm(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var pm=class extends Fg{constructor(t){super(t)}},gm=class{constructor(t,e,r){var s,n;this.supabaseUrl=t,this.supabaseKey=e;const i=fm(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const o=`sb-${i.hostname.split(".")[0]}-auth-token`,a={db:Wg,realtime:zg,auth:de(de({},Gg),{},{storageKey:o}),global:Kg,tracePropagation:Jg},l=dm(r??{},a);if(this.settings=l,this.storageKey=(s=l.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(n=l.global.headers)!==null&&n!==void 0?n:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(u,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}});else{var c;this.auth=this._initSupabaseAuthClient((c=l.auth)!==null&&c!==void 0?c:{},this.headers,l.global.fetch)}this.fetch=cm(e,t,this._getAccessToken.bind(this),l.global.fetch,l.tracePropagation),this.realtime=this._initRealtimeClient(de({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(u=>this.realtime.setAuth(u)).catch(u=>console.warn("Failed to set initial Realtime auth token:",u)),this.rest=new xf(new URL("rest/v1",i).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new Vp(this.storageUrl.href,this.headers,this.fetch,r==null?void 0:r.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new wf(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,r)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,r;if(t.accessToken)return await t.accessToken();const{data:s}=await t.auth.getSession();return(e=(r=s.session)===null||r===void 0?void 0:r.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:s,userStorage:n,storageKey:i,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,lockAcquireTimeout:h,skipAutoInitialize:d},f,m){const _={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new pm({url:this.authUrl.href,headers:de(de({},_),f),storageKey:i,autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:s,userStorage:n,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,fetch:m,lockAcquireTimeout:h,skipAutoInitialize:d,hasCustomAuthorizationHeader:Object.keys(this.headers).some(A=>A.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new fp(this.realtimeUrl.href,de(de({},t),{},{params:de(de({},{apikey:this.supabaseKey}),t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e==null?void 0:e.access_token)})}_handleTokenChanged(t,e,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const mm=(t,e,r)=>new gm(t,e,r);function ym(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const r=e.match(/^v(\d+)\./);return r?parseInt(r[1],10)<=18:!1}ym()&&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");let Ac=null,ka=!1;async function _m(){if(!ka){ka=!0;try{const t=await fetch("/api/auth/config");if(!t.ok)return;const{supabaseUrl:e,supabaseAnonKey:r}=await t.json();e&&r&&(Ac=mm(e,r))}catch{}}}function js(){return Ac}const An=cd("auth",()=>{const t=Kr(localStorage.getItem("io_token")),e=Kr(localStorage.getItem("io_email")),r=Kr(!1),s=xe(()=>!!t.value);function n(){const l=js();l&&l.auth.onAuthStateChange((c,u)=>{var h,d;u?(t.value=u.access_token,e.value=((h=u.user)==null?void 0:h.email)??null,localStorage.setItem("io_token",u.access_token),(d=u.user)!=null&&d.email&&localStorage.setItem("io_email",u.user.email)):(t.value=null,e.value=null,localStorage.removeItem("io_token"),localStorage.removeItem("io_email"))})}async function i(l,c){var h,d;const u=js();if(!u)throw new Error("Auth not configured");r.value=!0;try{const{data:f,error:m}=await u.auth.signInWithPassword({email:l,password:c});if(m)throw m;t.value=((h=f.session)==null?void 0:h.access_token)??null,e.value=((d=f.user)==null?void 0:d.email)??null,t.value&&localStorage.setItem("io_token",t.value),e.value&&localStorage.setItem("io_email",e.value)}finally{r.value=!1}}async function o(){const l=js();l&&await l.auth.signOut(),t.value=null,e.value=null,localStorage.removeItem("io_token"),localStorage.removeItem("io_email")}async function a(){const l=js();if(!l)return;const{data:c,error:u}=await l.auth.refreshSession();if(u||!c.session){t.value=null,localStorage.removeItem("io_token");return}t.value=c.session.access_token,localStorage.setItem("io_token",c.session.access_token)}return{token:t,email:e,loading:r,isAuthenticated:s,login:i,logout:o,refreshToken:a,initAuthListener:n}}),vm=Object.freeze(Object.defineProperty({__proto__:null,useAuthStore:An},Symbol.toStringTag,{value:"Module"})),bm="/logo.svg",wm=["width","height"],Sm=vs({__name:"LogoIcon",props:{size:{}},setup(t){return(e,r)=>(sr(),Ws("img",{src:bm,alt:"IO",width:t.size??32,height:t.size??32,class:"inline-block"},null,8,wm))}});/**
|
|
74
74
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
75
75
|
*
|
|
76
76
|
* This source code is licensed under the ISC license.
|
|
77
77
|
* See the LICENSE file in the root directory of this source tree.
|
|
78
|
-
*/const
|
|
78
|
+
*/const Em=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
79
79
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
80
80
|
*
|
|
81
81
|
* This source code is licensed under the ISC license.
|
|
82
82
|
* See the LICENSE file in the root directory of this source tree.
|
|
83
|
-
*/var
|
|
83
|
+
*/var Ns={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/**
|
|
84
84
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
85
85
|
*
|
|
86
86
|
* This source code is licensed under the ISC license.
|
|
87
87
|
* See the LICENSE file in the root directory of this source tree.
|
|
88
|
-
*/const
|
|
88
|
+
*/const km=({size:t,strokeWidth:e=2,absoluteStrokeWidth:r,color:s,iconNode:n,name:i,class:o,...a},{slots:l})=>as("svg",{...Ns,width:t||Ns.width,height:t||Ns.height,stroke:s||Ns.stroke,"stroke-width":r?Number(e)*24/Number(t):e,class:["lucide",`lucide-${Em(i??"icon")}`],...a},[...n.map(c=>as(...c)),...l.default?[l.default()]:[]]);/**
|
|
89
89
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
90
90
|
*
|
|
91
91
|
* This source code is licensed under the ISC license.
|
|
92
92
|
* See the LICENSE file in the root directory of this source tree.
|
|
93
|
-
*/const
|
|
93
|
+
*/const qe=(t,e)=>(r,{slots:s})=>as(km,{...r,iconNode:e,name:t},s);/**
|
|
94
94
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
95
95
|
*
|
|
96
96
|
* This source code is licensed under the ISC license.
|
|
97
97
|
* See the LICENSE file in the root directory of this source tree.
|
|
98
|
-
*/const
|
|
98
|
+
*/const Am=qe("ActivityIcon",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
|
|
99
99
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
100
100
|
*
|
|
101
101
|
* This source code is licensed under the ISC license.
|
|
102
102
|
* See the LICENSE file in the root directory of this source tree.
|
|
103
|
-
*/const
|
|
103
|
+
*/const Tm=qe("BookOpenIcon",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
|
|
104
104
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
105
105
|
*
|
|
106
106
|
* This source code is licensed under the ISC license.
|
|
107
107
|
* See the LICENSE file in the root directory of this source tree.
|
|
108
|
-
*/const
|
|
108
|
+
*/const Rm=qe("ChartColumnIcon",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
|
|
109
109
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
110
110
|
*
|
|
111
111
|
* This source code is licensed under the ISC license.
|
|
112
112
|
* See the LICENSE file in the root directory of this source tree.
|
|
113
|
-
*/const
|
|
113
|
+
*/const Om=qe("ClipboardListIcon",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
|
|
114
114
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
115
115
|
*
|
|
116
116
|
* This source code is licensed under the ISC license.
|
|
117
117
|
* See the LICENSE file in the root directory of this source tree.
|
|
118
|
-
*/const
|
|
118
|
+
*/const Cm=qe("ClockIcon",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
|
|
119
119
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
120
120
|
*
|
|
121
121
|
* This source code is licensed under the ISC license.
|
|
122
122
|
* See the LICENSE file in the root directory of this source tree.
|
|
123
|
-
*/const
|
|
123
|
+
*/const Pm=qe("HistoryIcon",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
|
124
124
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
125
125
|
*
|
|
126
126
|
* This source code is licensed under the ISC license.
|
|
127
127
|
* See the LICENSE file in the root directory of this source tree.
|
|
128
|
-
*/const
|
|
128
|
+
*/const xm=qe("InboxIcon",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
|
|
129
129
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
130
130
|
*
|
|
131
131
|
* This source code is licensed under the ISC license.
|
|
132
132
|
* See the LICENSE file in the root directory of this source tree.
|
|
133
|
-
*/const
|
|
133
|
+
*/const Im=qe("LogOutIcon",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
|
134
134
|
* @license lucide-vue-next v0.474.0 - ISC
|
|
135
135
|
*
|
|
136
136
|
* This source code is licensed under the ISC license.
|
|
137
137
|
* See the LICENSE file in the root directory of this source tree.
|
|
138
|
-
*/const
|
|
138
|
+
*/const jm=qe("MessageSquareIcon",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
|
|
139
|
+
* @license lucide-vue-next v0.474.0 - ISC
|
|
140
|
+
*
|
|
141
|
+
* This source code is licensed under the ISC license.
|
|
142
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
143
|
+
*/const Nm=qe("PuzzleIcon",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/**
|
|
144
|
+
* @license lucide-vue-next v0.474.0 - ISC
|
|
145
|
+
*
|
|
146
|
+
* This source code is licensed under the ISC license.
|
|
147
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
148
|
+
*/const Lm=qe("ServerIcon",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
|
|
149
|
+
* @license lucide-vue-next v0.474.0 - ISC
|
|
150
|
+
*
|
|
151
|
+
* This source code is licensed under the ISC license.
|
|
152
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
153
|
+
*/const $m=qe("SettingsIcon",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
154
|
+
* @license lucide-vue-next v0.474.0 - ISC
|
|
155
|
+
*
|
|
156
|
+
* This source code is licensed under the ISC license.
|
|
157
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
158
|
+
*/const Dm=qe("UsersIcon",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),Um={class:"w-64 border-r border-border bg-card flex flex-col h-full shrink-0"},Mm={class:"p-4 border-b border-border flex items-center gap-3"},Bm={class:"flex-1 p-2 space-y-0.5 overflow-y-auto"},Hm={class:"p-3 border-t border-border"},Fm={class:"flex items-center justify-between"},qm={class:"text-xs text-muted-foreground truncate"},Vm=vs({__name:"AppSidebar",setup(t){const e=rc(),r=yf(),s=An(),n=[{name:"Chat",icon:jm,path:"/"},{name:"History",icon:Pm,path:"/history"},{name:"Squads",icon:Dm,path:"/squads"},{name:"Health",icon:Am,path:"/squads/health"},{name:"Feed",icon:xm,path:"/feed"},{name:"Usage",icon:Rm,path:"/usage"},{name:"Audit Log",icon:Om,path:"/audit-log"},{name:"Skills",icon:Nm,path:"/skills"},{name:"MCP Servers",icon:Lm,path:"/mcp"},{name:"Schedules",icon:Cm,path:"/schedules"},{name:"Wiki",icon:Tm,path:"/wiki"},{name:"Settings",icon:$m,path:"/settings"}],i=xe(()=>{let a="";for(const l of n){const c=l.path;(c==="/"?e.path==="/":e.path===c||e.path.startsWith(c+"/"))&&c.length>a.length&&(a=c)}return a});async function o(){await s.logout(),r.push("/login")}return(a,l)=>{const c=dl("router-link");return sr(),Ws("aside",Um,[We("div",Mm,[Se(Sm,{size:28}),l[0]||(l[0]=We("div",null,[We("h1",{class:"text-lg font-bold tracking-tight bg-gradient-brand bg-clip-text text-transparent"},"IO"),We("p",{class:"text-[10px] text-muted-foreground leading-none"},"Personal AI Assistant")],-1))]),We("nav",Bm,[(sr(),Ws(ut,null,Mu(n,u=>Se(c,{key:u.path,to:u.path,class:cn(["flex items-center gap-3 px-3 py-2 rounded-md text-sm transition-colors",[i.value===u.path?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"]])},{default:nl(()=>[(sr(),Di(Uu(u.icon),{class:"w-4 h-4"})),Nl(" "+Wn(u.name),1)]),_:2},1032,["to","class"])),64))]),We("div",Hm,[We("div",Fm,[We("span",qm,Wn(Rt(s).email),1),We("button",{onClick:o,class:"p-1.5 rounded-md hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Sign out"},[Se(Rt(Im),{class:"w-4 h-4"})])])])])}}}),Km={class:"flex h-screen overflow-hidden"},Wm={class:"flex-1 overflow-auto"},Gm=vs({__name:"App",setup(t){const e=An(),r=rc(),s=xe(()=>e.isAuthenticated&&r.name!=="login");return(n,i)=>{const o=dl("router-view");return sr(),Ws("div",Km,[s.value?(sr(),Di(Vm,{key:0})):gh("",!0),We("main",Wm,[Se(o)])])}}}),zm=[{path:"/login",name:"login",component:()=>Re(()=>import("./LoginView-CoTEOrwE.js"),[]),meta:{public:!0}},{path:"/",name:"chat",component:()=>Re(()=>import("./ChatView-BU3Jvu5y.js"),__vite__mapDeps([0,1,2]))},{path:"/squads",name:"squads",component:()=>Re(()=>import("./SquadsView-Dkhtu5MQ.js"),__vite__mapDeps([3,1,4,5]))},{path:"/squads/health",name:"squad-health",component:()=>Re(()=>import("./SquadHealthView-DmQqPq7H.js"),__vite__mapDeps([6,1,7,5]))},{path:"/squads/:id",name:"squad-detail",component:()=>Re(()=>import("./SquadDetailView-CV6_n_If.js"),__vite__mapDeps([8,1,4,2,9,5,10,11]))},{path:"/feed",name:"feed",component:()=>Re(()=>import("./FeedView-BwkWbe1p.js"),__vite__mapDeps([12,1,2,4,10]))},{path:"/skills",name:"skills",component:()=>Re(()=>import("./SkillsView-_FkOdD2U.js"),__vite__mapDeps([13,1,2,14,15,16,9,10]))},{path:"/mcp",name:"mcp",component:()=>Re(()=>import("./McpView-ByXoAnED.js"),__vite__mapDeps([17,1,14,10]))},{path:"/schedules",name:"schedules",component:()=>Re(()=>import("./SchedulesView-BkUdRYwk.js"),__vite__mapDeps([18,1,4,14,10]))},{path:"/history",name:"history",component:()=>Re(()=>import("./HistoryView-Doh9Y3Na.js"),__vite__mapDeps([19,1,2,15,11,10]))},{path:"/wiki",name:"wiki",component:()=>Re(()=>import("./WikiView-CpXzff_L.js"),__vite__mapDeps([20,1,2,15,14,16,10,9]))},{path:"/usage",name:"usage",component:()=>Re(()=>import("./UsageView-CCS6pp6n.js"),__vite__mapDeps([21,1,7]))},{path:"/audit-log",name:"audit-log",component:()=>Re(()=>import("./AuditLogView-xgSZ2MOJ.js"),__vite__mapDeps([22,1]))},{path:"/settings",name:"settings",component:()=>Re(()=>import("./SettingsView-_q-IpzFy.js"),__vite__mapDeps([23,1]))}],Tc=mf({history:Gd(),routes:zm});Tc.beforeEach(t=>{const e=An();if(!t.meta.public&&!e.isAuthenticated)return{name:"login"}});async function Jm(){await _m();const t=ed(Gm);t.use(sd()),t.use(Tc);const{useAuthStore:e}=await Re(async()=>{const{useAuthStore:s}=await Promise.resolve().then(()=>vm);return{useAuthStore:s}},void 0),r=e();r.initAuthListener(),r.token&&await r.refreshToken(),t.mount("#app")}Jm();export{Am as A,Tm as B,Rm as C,yf as D,Qm as E,ut as F,Zm as G,Pm as H,xm as I,Xm as J,Wr as K,nl as L,jm as M,Ym as N,ty as O,Nm as P,ey as Q,Lm as S,Dm as U,Sm as _,Om as a,Cm as b,xe as c,We as d,Di as e,gh as f,Ws as g,qe as h,Nl as i,Se as j,vs as k,cd as l,cn as m,fn as n,ki as o,Pu as p,ul as q,sr as r,Kr as s,Mu as t,dl as u,Tc as v,Wn as w,Rt as x,An as y,rc as z};
|