function __vite__mapDeps(indexes) {
  if (!__vite__mapDeps.viteFileDeps) {
    __vite__mapDeps.viteFileDeps = ["assets/Landing-CbO8p12i.js","assets/card-BldX7XA0.js","assets/Auth-DGRCOpc3.js","assets/label-CngIGhLv.js","assets/Account-Ba6XJyg9.js","assets/StripeCustomerPortalButton-CIgxomOp.js","assets/Journal-C6MolKL1.js"]
  }
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const $={context:void 0,registry:void 0};function It(t){$.context=t}const di=(t,e)=>t===e,Kt=Symbol("solid-proxy"),fi=Symbol("solid-track"),cn={equals:di};let Ks=Vs;const Re=1,un=2,Us={owned:null,cleanups:null,context:null,owner:null},Ln={};var U=null;let Rn=null,hi=null,V=null,ee=null,Ae=null,wn=0;function pt(t,e){const n=V,r=U,s=t.length===0,o=e===void 0?r:e,i=s?Us:{owned:null,cleanups:null,context:o?o.context:null,owner:o},a=s?t:()=>t(()=>G(()=>xn(i)));U=i,V=null;try{return Se(a,!0)}finally{V=n,U=r}}function A(t,e){e=e?Object.assign({},cn,e):cn;const n={value:t,observers:null,observerSlots:null,comparator:e.equals||void 0},r=s=>(typeof s=="function"&&(s=s(n.value)),zs(n,s));return[Bs.bind(n),r]}function Wn(t,e,n){const r=_n(t,e,!0,Re);_t(r)}function _e(t,e,n){const r=_n(t,e,!1,Re);_t(r)}function I(t,e,n){Ks=wi;const r=_n(t,e,!1,Re);(!n||!n.render)&&(r.user=!0),Ae?Ae.push(r):_t(r)}function O(t,e,n){n=n?Object.assign({},cn,n):cn;const r=_n(t,e,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,_t(r),Bs.bind(r)}function gi(t){return t&&typeof t=="object"&&"then"in t}function pi(t,e,n){let r,s,o;arguments.length===2&&typeof e=="object"||arguments.length===1?(r=!0,s=t,o=e||{}):(r=t,s=e,o=n||{});let i=null,a=Ln,l=null,c=!1,u="initialValue"in o,d=typeof r=="function"&&O(r);const f=new Set,[p,h]=(o.storage||A)(o.initialValue),[g,m]=A(void 0),[y,v]=A(void 0,{equals:!1}),[w,b]=A(u?"ready":"unresolved");if($.context){l=`${$.context.id}${$.context.count++}`;let P;o.ssrLoadFrom==="initial"?a=o.initialValue:$.load&&(P=$.load(l))&&(a=P)}function k(P,D,L,E){return i===P&&(i=null,E!==void 0&&(u=!0),(P===a||D===a)&&o.onHydrated&&queueMicrotask(()=>o.onHydrated(E,{value:D})),a=Ln,T(D,L)),D}function T(P,D){Se(()=>{D===void 0&&h(()=>P),b(D!==void 0?"errored":u?"ready":"unresolved"),m(D);for(const L of f.keys())L.decrement();f.clear()},!1)}function S(){const P=yi,D=p(),L=g();if(L!==void 0&&!i)throw L;return V&&!V.user&&P&&Wn(()=>{y(),i&&(P.resolved||f.has(P)||(P.increment(),f.add(P)))}),D}function C(P=!0){if(P!==!1&&c)return;c=!1;const D=d?d():r;if(D==null||D===!1){k(i,G(p));return}const L=a!==Ln?a:G(()=>s(D,{value:p(),refetching:P}));return gi(L)?(i=L,"value"in L?(L.status==="success"?k(i,L.value,void 0,D):k(i,void 0,void 0,D),L):(c=!0,queueMicrotask(()=>c=!1),Se(()=>{b(u?"refreshing":"pending"),v()},!1),L.then(E=>k(L,E,void 0,D),E=>k(L,void 0,qs(E),D)))):(k(i,L,void 0,D),L)}return Object.defineProperties(S,{state:{get:()=>w()},error:{get:()=>g()},loading:{get(){const P=w();return P==="pending"||P==="refreshing"}},latest:{get(){if(!u)return S();const P=g();if(P&&!i)throw P;return p()}}}),d?Wn(()=>C(!1)):C(!1),[S,{refetch:C,mutate:h}]}function vh(t){return Se(t,!1)}function G(t){if(V===null)return t();const e=V;V=null;try{return t()}finally{V=e}}function xe(t,e,n){const r=Array.isArray(t);let s,o=n&&n.defer;return i=>{let a;if(r){a=Array(t.length);for(let c=0;c<t.length;c++)a[c]=t[c]()}else a=t();if(o)return o=!1,i;const l=G(()=>e(a,s,i));return s=a,l}}function dr(t){I(()=>G(t))}function z(t){return U===null||(U.cleanups===null?U.cleanups=[t]:U.cleanups.push(t)),t}function dn(){return U}function fr(t,e){const n=U,r=V;U=t,V=null;try{return Se(e,!0)}catch(s){hr(s)}finally{U=n,V=r}}function mi(t){const e=V,n=U;return Promise.resolve().then(()=>{V=e,U=n;let r;return Se(t,!1),V=U=null,r?r.done:void 0})}function ne(t,e){const n=Symbol("context");return{id:n,Provider:_i(n),defaultValue:t}}function fe(t){return U&&U.context&&U.context[t.id]!==void 0?U.context[t.id]:t.defaultValue}function qt(t){const e=O(t),n=O(()=>Gn(e()));return n.toArray=()=>{const r=n();return Array.isArray(r)?r:r!=null?[r]:[]},n}let yi;function Bs(){if(this.sources&&this.state)if(this.state===Re)_t(this);else{const t=ee;ee=null,Se(()=>hn(this),!1),ee=t}if(V){const t=this.observers?this.observers.length:0;V.sources?(V.sources.push(this),V.sourceSlots.push(t)):(V.sources=[this],V.sourceSlots=[t]),this.observers?(this.observers.push(V),this.observerSlots.push(V.sources.length-1)):(this.observers=[V],this.observerSlots=[V.sources.length-1])}return this.value}function zs(t,e,n){let r=t.value;return(!t.comparator||!t.comparator(r,e))&&(t.value=e,t.observers&&t.observers.length&&Se(()=>{for(let s=0;s<t.observers.length;s+=1){const o=t.observers[s],i=Rn&&Rn.running;i&&Rn.disposed.has(o),(i?!o.tState:!o.state)&&(o.pure?ee.push(o):Ae.push(o),o.observers&&Hs(o)),i||(o.state=Re)}if(ee.length>1e6)throw ee=[],new Error},!1)),e}function _t(t){if(!t.fn)return;xn(t);const e=wn;vi(t,t.value,e)}function vi(t,e,n){let r;const s=U,o=V;V=U=t;try{r=t.fn(e)}catch(i){return t.pure&&(t.state=Re,t.owned&&t.owned.forEach(xn),t.owned=null),t.updatedAt=n+1,hr(i)}finally{V=o,U=s}(!t.updatedAt||t.updatedAt<=n)&&(t.updatedAt!=null&&"observers"in t?zs(t,r):t.value=r,t.updatedAt=n)}function _n(t,e,n,r=Re,s){const o={fn:t,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:e,owner:U,context:U?U.context:null,pure:n};return U===null||U!==Us&&(U.owned?U.owned.push(o):U.owned=[o]),o}function fn(t){if(t.state===0)return;if(t.state===un)return hn(t);if(t.suspense&&G(t.suspense.inFallback))return t.suspense.effects.push(t);const e=[t];for(;(t=t.owner)&&(!t.updatedAt||t.updatedAt<wn);)t.state&&e.push(t);for(let n=e.length-1;n>=0;n--)if(t=e[n],t.state===Re)_t(t);else if(t.state===un){const r=ee;ee=null,Se(()=>hn(t,e[0]),!1),ee=r}}function Se(t,e){if(ee)return t();let n=!1;e||(ee=[]),Ae?n=!0:Ae=[],wn++;try{const r=t();return bi(n),r}catch(r){n||(Ae=null),ee=null,hr(r)}}function bi(t){if(ee&&(Vs(ee),ee=null),t)return;const e=Ae;Ae=null,e.length&&Se(()=>Ks(e),!1)}function Vs(t){for(let e=0;e<t.length;e++)fn(t[e])}function wi(t){let e,n=0;for(e=0;e<t.length;e++){const r=t[e];r.user?t[n++]=r:fn(r)}if($.context){if($.count){$.effects||($.effects=[]),$.effects.push(...t.slice(0,n));return}else $.effects&&(t=[...$.effects,...t],n+=$.effects.length,delete $.effects);It()}for(e=0;e<n;e++)fn(t[e])}function hn(t,e){t.state=0;for(let n=0;n<t.sources.length;n+=1){const r=t.sources[n];if(r.sources){const s=r.state;s===Re?r!==e&&(!r.updatedAt||r.updatedAt<wn)&&fn(r):s===un&&hn(r,e)}}}function Hs(t){for(let e=0;e<t.observers.length;e+=1){const n=t.observers[e];n.state||(n.state=un,n.pure?ee.push(n):Ae.push(n),n.observers&&Hs(n))}}function xn(t){let e;if(t.sources)for(;t.sources.length;){const n=t.sources.pop(),r=t.sourceSlots.pop(),s=n.observers;if(s&&s.length){const o=s.pop(),i=n.observerSlots.pop();r<s.length&&(o.sourceSlots[i]=r,s[r]=o,n.observerSlots[r]=i)}}if(t.owned){for(e=t.owned.length-1;e>=0;e--)xn(t.owned[e]);t.owned=null}if(t.cleanups){for(e=t.cleanups.length-1;e>=0;e--)t.cleanups[e]();t.cleanups=null}t.state=0}function qs(t){return t instanceof Error?t:new Error(typeof t=="string"?t:"Unknown error",{cause:t})}function hr(t,e=U){throw qs(t)}function Gn(t){if(typeof t=="function"&&!t.length)return Gn(t());if(Array.isArray(t)){const e=[];for(let n=0;n<t.length;n++){const r=Gn(t[n]);Array.isArray(r)?e.push.apply(e,r):e.push(r)}return e}return t}function _i(t,e){return function(r){let s;return _e(()=>s=G(()=>(U.context={...U.context,[t]:r.value},qt(()=>r.children))),void 0),s}}const xi=Symbol("fallback");function Mr(t){for(let e=0;e<t.length;e++)t[e]()}function Si(t,e,n={}){let r=[],s=[],o=[],i=0,a=e.length>1?[]:null;return z(()=>Mr(o)),()=>{let l=t()||[],c,u;return l[fi],G(()=>{let f=l.length,p,h,g,m,y,v,w,b,k;if(f===0)i!==0&&(Mr(o),o=[],r=[],s=[],i=0,a&&(a=[])),n.fallback&&(r=[xi],s[0]=pt(T=>(o[0]=T,n.fallback())),i=1);else if(i===0){for(s=new Array(f),u=0;u<f;u++)r[u]=l[u],s[u]=pt(d);i=f}else{for(g=new Array(f),m=new Array(f),a&&(y=new Array(f)),v=0,w=Math.min(i,f);v<w&&r[v]===l[v];v++);for(w=i-1,b=f-1;w>=v&&b>=v&&r[w]===l[b];w--,b--)g[b]=s[w],m[b]=o[w],a&&(y[b]=a[w]);for(p=new Map,h=new Array(b+1),u=b;u>=v;u--)k=l[u],c=p.get(k),h[u]=c===void 0?-1:c,p.set(k,u);for(c=v;c<=w;c++)k=r[c],u=p.get(k),u!==void 0&&u!==-1?(g[u]=s[c],m[u]=o[c],a&&(y[u]=a[c]),u=h[u],p.set(k,u)):o[c]();for(u=v;u<f;u++)u in g?(s[u]=g[u],o[u]=m[u],a&&(a[u]=y[u],a[u](u))):s[u]=pt(d);s=s.slice(0,i=f),r=l.slice(0)}return s});function d(f){if(o[u]=f,a){const[p,h]=A(u);return a[u]=h,e(l[u],p)}return e(l[u])}}}function x(t,e){return G(()=>t(e||{}))}function Yt(){return!0}const Jn={get(t,e,n){return e===Kt?n:t.get(e)},has(t,e){return e===Kt?!0:t.has(e)},set:Yt,deleteProperty:Yt,getOwnPropertyDescriptor(t,e){return{configurable:!0,enumerable:!0,get(){return t.get(e)},set:Yt,deleteProperty:Yt}},ownKeys(t){return t.keys()}};function In(t){return(t=typeof t=="function"?t():t)?t:{}}function Ei(){for(let t=0,e=this.length;t<e;++t){const n=this[t]();if(n!==void 0)return n}}function B(...t){let e=!1;for(let i=0;i<t.length;i++){const a=t[i];e=e||!!a&&Kt in a,t[i]=typeof a=="function"?(e=!0,O(a)):a}if(e)return new Proxy({get(i){for(let a=t.length-1;a>=0;a--){const l=In(t[a])[i];if(l!==void 0)return l}},has(i){for(let a=t.length-1;a>=0;a--)if(i in In(t[a]))return!0;return!1},keys(){const i=[];for(let a=0;a<t.length;a++)i.push(...Object.keys(In(t[a])));return[...new Set(i)]}},Jn);const n={},r=Object.create(null);for(let i=t.length-1;i>=0;i--){const a=t[i];if(!a)continue;const l=Object.getOwnPropertyNames(a);for(let c=l.length-1;c>=0;c--){const u=l[c];if(u==="__proto__"||u==="constructor")continue;const d=Object.getOwnPropertyDescriptor(a,u);if(!r[u])r[u]=d.get?{enumerable:!0,configurable:!0,get:Ei.bind(n[u]=[d.get.bind(a)])}:d.value!==void 0?d:void 0;else{const f=n[u];f&&(d.get?f.push(d.get.bind(a)):d.value!==void 0&&f.push(()=>d.value))}}}const s={},o=Object.keys(r);for(let i=o.length-1;i>=0;i--){const a=o[i],l=r[a];l&&l.get?Object.defineProperty(s,a,l):s[a]=l?l.value:void 0}return s}function J(t,...e){if(Kt in t){const s=new Set(e.length>1?e.flat():e[0]),o=e.map(i=>new Proxy({get(a){return i.includes(a)?t[a]:void 0},has(a){return i.includes(a)&&a in t},keys(){return i.filter(a=>a in t)}},Jn));return o.push(new Proxy({get(i){return s.has(i)?void 0:t[i]},has(i){return s.has(i)?!1:i in t},keys(){return Object.keys(t).filter(i=>!s.has(i))}},Jn)),o}const n={},r=e.map(()=>({}));for(const s of Object.getOwnPropertyNames(t)){const o=Object.getOwnPropertyDescriptor(t,s),i=!o.get&&!o.set&&o.enumerable&&o.writable&&o.configurable;let a=!1,l=0;for(const c of e)c.includes(s)&&(a=!0,i?r[l][s]=o.value:Object.defineProperty(r[l],s,o)),++l;a||(i?n[s]=o.value:Object.defineProperty(n,s,o))}return[...r,n]}function Sn(t){let e,n;const r=s=>{const o=$.context;if(o){const[a,l]=A();$.count||($.count=0),$.count++,(n||(n=t())).then(c=>{It(o),$.count--,l(()=>c.default),It()}),e=a}else if(!e){const[a]=pi(()=>(n||(n=t())).then(l=>l.default));e=a}let i;return O(()=>(i=e())&&G(()=>{if(!o)return i(s);const a=$.context;It(o);const l=i(s);return It(a),l}))};return r.preload=()=>n||((n=t()).then(s=>e=()=>s.default),n),r}let ki=0;function xt(){const t=$.context;return t?`${t.id}${t.count++}`:`cl-${ki++}`}const Ws=t=>`Stale read from <${t}>.`;function Ti(t){const e="fallback"in t&&{fallback:()=>t.fallback};return O(Si(()=>t.each,t.children,e||void 0))}function Ze(t){const e=t.keyed,n=O(()=>t.when,void 0,{equals:(r,s)=>e?r===s:!r==!s});return O(()=>{const r=n();if(r){const s=t.children;return typeof s=="function"&&s.length>0?G(()=>s(e?r:()=>{if(!G(n))throw Ws("Show");return t.when})):s}return t.fallback},void 0,void 0)}function bh(t){let e=!1;const n=(o,i)=>(e?o[1]===i[1]:!o[1]==!i[1])&&o[2]===i[2],r=qt(()=>t.children),s=O(()=>{let o=r();Array.isArray(o)||(o=[o]);for(let i=0;i<o.length;i++){const a=o[i].when;if(a)return e=!!o[i].keyed,[i,a,o[i]]}return[-1]},void 0,{equals:n});return O(()=>{const[o,i,a]=s();if(o<0)return t.fallback;const l=a.children;return typeof l=="function"&&l.length>0?G(()=>l(e?i:()=>{if(G(s)[0]!==o)throw Ws("Match");return a.when})):l},void 0,void 0)}function wh(t){return t}const Pi=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],Ai=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...Pi]),Oi=new Set(["innerHTML","textContent","innerText","children"]),Ci=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),Li=Object.assign(Object.create(null),{class:"className",formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function Ri(t,e){const n=Li[t];return typeof n=="object"?n[e]?n.$:void 0:n}const Ii=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),$i=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),Di={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function Mi(t,e,n){let r=n.length,s=e.length,o=r,i=0,a=0,l=e[s-1].nextSibling,c=null;for(;i<s||a<o;){if(e[i]===n[a]){i++,a++;continue}for(;e[s-1]===n[o-1];)s--,o--;if(s===i){const u=o<r?a?n[a-1].nextSibling:n[o-a]:l;for(;a<o;)t.insertBefore(n[a++],u)}else if(o===a)for(;i<s;)(!c||!c.has(e[i]))&&e[i].remove(),i++;else if(e[i]===n[o-1]&&n[a]===e[s-1]){const u=e[--s].nextSibling;t.insertBefore(n[a++],e[i++].nextSibling),t.insertBefore(n[--o],u),e[s]=n[o]}else{if(!c){c=new Map;let d=a;for(;d<o;)c.set(n[d],d++)}const u=c.get(e[i]);if(u!=null)if(a<u&&u<o){let d=i,f=1,p;for(;++d<s&&d<o&&!((p=c.get(e[d]))==null||p!==u+f);)f++;if(f>u-a){const h=e[i];for(;a<u;)t.insertBefore(n[a++],h)}else t.replaceChild(n[a++],e[i++])}else i++;else e[i++].remove()}}}const jr="_$DX_DELEGATE";function ji(t,e,n,r={}){let s;return pt(o=>{s=o,e===document?t():Oe(e,t(),e.firstChild?null:void 0,n)},r.owner),()=>{s(),e.textContent=""}}function et(t,e,n){let r;const s=()=>{const i=document.createElement("template");return i.innerHTML=t,n?i.content.firstChild.firstChild:i.content.firstChild},o=e?()=>G(()=>document.importNode(r||(r=s()),!0)):()=>(r||(r=s())).cloneNode(!0);return o.cloneNode=o,o}function Gs(t,e=window.document){const n=e[jr]||(e[jr]=new Set);for(let r=0,s=t.length;r<s;r++){const o=t[r];n.has(o)||(n.add(o),e.addEventListener(o,qi))}}function gn(t,e,n){$.context&&t.isConnected||(n==null?t.removeAttribute(e):t.setAttribute(e,n))}function Fi(t,e,n,r){$.context&&t.isConnected||(r==null?t.removeAttributeNS(e,n):t.setAttributeNS(e,n,r))}function Ni(t,e){$.context&&t.isConnected||(e==null?t.removeAttribute("class"):t.className=e)}function Ki(t,e,n,r){if(r)Array.isArray(n)?(t[`$$${e}`]=n[0],t[`$$${e}Data`]=n[1]):t[`$$${e}`]=n;else if(Array.isArray(n)){const s=n[0];t.addEventListener(e,n[0]=o=>s.call(t,n[1],o))}else t.addEventListener(e,n)}function Ui(t,e,n={}){const r=Object.keys(e||{}),s=Object.keys(n);let o,i;for(o=0,i=s.length;o<i;o++){const a=s[o];!a||a==="undefined"||e[a]||(Fr(t,a,!1),delete n[a])}for(o=0,i=r.length;o<i;o++){const a=r[o],l=!!e[a];!a||a==="undefined"||n[a]===l||!l||(Fr(t,a,!0),n[a]=l)}return n}function Bi(t,e,n){if(!e)return n?gn(t,"style"):e;const r=t.style;if(typeof e=="string")return r.cssText=e;typeof n=="string"&&(r.cssText=n=void 0),n||(n={}),e||(e={});let s,o;for(o in n)e[o]==null&&r.removeProperty(o),delete n[o];for(o in e)s=e[o],s!==n[o]&&(r.setProperty(o,s),n[o]=s);return n}function En(t,e={},n,r){const s={};return r||_e(()=>s.children=vt(t,e.children,s.children)),_e(()=>e.ref&&e.ref(t)),_e(()=>zi(t,e,n,!0,s,!0)),s}function _h(t,e,n){return G(()=>t(e,n))}function Oe(t,e,n,r){if(n!==void 0&&!r&&(r=[]),typeof e!="function")return vt(t,e,r,n);_e(s=>vt(t,e(),s,n),r)}function zi(t,e,n,r,s={},o=!1){e||(e={});for(const i in s)if(!(i in e)){if(i==="children")continue;s[i]=Nr(t,i,null,s[i],n,o)}for(const i in e){if(i==="children"){r||vt(t,e.children);continue}const a=e[i];s[i]=Nr(t,i,a,s[i],n,o)}}function Vi(t){let e,n;return!$.context||!(e=$.registry.get(n=Wi()))?t():($.completed&&$.completed.add(e),$.registry.delete(n),e)}function Hi(t){return t.toLowerCase().replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}function Fr(t,e,n){const r=e.trim().split(/\s+/);for(let s=0,o=r.length;s<o;s++)t.classList.toggle(r[s],n)}function Nr(t,e,n,r,s,o){let i,a,l,c,u;if(e==="style")return Bi(t,n,r);if(e==="classList")return Ui(t,n,r);if(n===r)return r;if(e==="ref")o||n(t);else if(e.slice(0,3)==="on:"){const d=e.slice(3);r&&t.removeEventListener(d,r),n&&t.addEventListener(d,n)}else if(e.slice(0,10)==="oncapture:"){const d=e.slice(10);r&&t.removeEventListener(d,r,!0),n&&t.addEventListener(d,n,!0)}else if(e.slice(0,2)==="on"){const d=e.slice(2).toLowerCase(),f=Ii.has(d);if(!f&&r){const p=Array.isArray(r)?r[0]:r;t.removeEventListener(d,p)}(f||n)&&(Ki(t,d,n,f),f&&Gs([d]))}else if(e.slice(0,5)==="attr:")gn(t,e.slice(5),n);else if((u=e.slice(0,5)==="prop:")||(l=Oi.has(e))||!s&&((c=Ri(e,t.tagName))||(a=Ai.has(e)))||(i=t.nodeName.includes("-"))){if(u)e=e.slice(5),a=!0;else if($.context&&t.isConnected)return n;e==="class"||e==="className"?Ni(t,n):i&&!a&&!l?t[Hi(e)]=n:t[c||e]=n}else{const d=s&&e.indexOf(":")>-1&&Di[e.split(":")[0]];d?Fi(t,d,e,n):gn(t,Ci[e]||e,n)}return n}function qi(t){const e=`$$${t.type}`;let n=t.composedPath&&t.composedPath()[0]||t.target;for(t.target!==n&&Object.defineProperty(t,"target",{configurable:!0,value:n}),Object.defineProperty(t,"currentTarget",{configurable:!0,get(){return n||document}}),$.registry&&!$.done&&($.done=_$HY.done=!0);n;){const r=n[e];if(r&&!n.disabled){const s=n[`${e}Data`];if(s!==void 0?r.call(n,s,t):r.call(n,t),t.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function vt(t,e,n,r,s){const o=!!$.context&&t.isConnected;if(o){!n&&(n=[...t.childNodes]);let l=[];for(let c=0;c<n.length;c++){const u=n[c];u.nodeType===8&&u.data.slice(0,2)==="!$"?u.remove():l.push(u)}n=l}for(;typeof n=="function";)n=n();if(e===n)return n;const i=typeof e,a=r!==void 0;if(t=a&&n[0]&&n[0].parentNode||t,i==="string"||i==="number"){if(o)return n;if(i==="number"&&(e=e.toString()),a){let l=n[0];l&&l.nodeType===3?l.data!==e&&(l.data=e):l=document.createTextNode(e),n=ot(t,n,r,l)}else n!==""&&typeof n=="string"?n=t.firstChild.data=e:n=t.textContent=e}else if(e==null||i==="boolean"){if(o)return n;n=ot(t,n,r)}else{if(i==="function")return _e(()=>{let l=e();for(;typeof l=="function";)l=l();n=vt(t,l,n,r)}),()=>n;if(Array.isArray(e)){const l=[],c=n&&Array.isArray(n);if(Xn(l,e,n,s))return _e(()=>n=vt(t,l,n,r,!0)),()=>n;if(o){if(!l.length)return n;if(r===void 0)return[...t.childNodes];let u=l[0],d=[u];for(;(u=u.nextSibling)!==r;)d.push(u);return n=d}if(l.length===0){if(n=ot(t,n,r),a)return n}else c?n.length===0?Kr(t,l,r):Mi(t,n,l):(n&&ot(t),Kr(t,l));n=l}else if(e.nodeType){if(o&&e.parentNode)return n=a?[e]:e;if(Array.isArray(n)){if(a)return n=ot(t,n,r,e);ot(t,n,null,e)}else n==null||n===""||!t.firstChild?t.appendChild(e):t.replaceChild(e,t.firstChild);n=e}}return n}function Xn(t,e,n,r){let s=!1;for(let o=0,i=e.length;o<i;o++){let a=e[o],l=n&&n[t.length],c;if(!(a==null||a===!0||a===!1))if((c=typeof a)=="object"&&a.nodeType)t.push(a);else if(Array.isArray(a))s=Xn(t,a,l)||s;else if(c==="function")if(r){for(;typeof a=="function";)a=a();s=Xn(t,Array.isArray(a)?a:[a],Array.isArray(l)?l:[l])||s}else t.push(a),s=!0;else{const u=String(a);l&&l.nodeType===3&&l.data===u?t.push(l):t.push(document.createTextNode(u))}}return s}function Kr(t,e,n=null){for(let r=0,s=e.length;r<s;r++)t.insertBefore(e[r],n)}function ot(t,e,n,r){if(n===void 0)return t.textContent="";const s=r||document.createTextNode("");if(e.length){let o=!1;for(let i=e.length-1;i>=0;i--){const a=e[i];if(s!==a){const l=a.parentNode===t;!o&&!i?l?t.replaceChild(s,a):t.insertBefore(s,n):l&&a.remove()}else o=!0}}else t.insertBefore(s,n);return[s]}function Wi(){const t=$.context;return`${t.id}${t.count++}`}const Gi=!1,Ji="http://www.w3.org/2000/svg";function Js(t,e=!1){return e?document.createElementNS(Ji,t):document.createElement(t)}function Xi(t){const{useShadow:e}=t,n=document.createTextNode(""),r=()=>t.mount||document.body,s=dn();let o,i=!!$.context;return I(()=>{i&&(dn().user=i=!1),o||(o=fr(s,()=>O(()=>t.children)));const a=r();if(a instanceof HTMLHeadElement){const[l,c]=A(!1),u=()=>c(!0);pt(d=>Oe(a,()=>l()?d():o(),null)),z(u)}else{const l=Js(t.isSVG?"g":"div",t.isSVG),c=e&&l.attachShadow?l.attachShadow({mode:"open"}):l;Object.defineProperty(l,"_$host",{get(){return n.parentNode},configurable:!0}),Oe(c,o),a.appendChild(l),t.ref&&t.ref(l),z(()=>a.removeChild(l))}},void 0,{render:!i}),n}function $n(t){const[e,n]=J(t,["component"]),r=O(()=>e.component);return O(()=>{const s=r();switch(typeof s){case"function":return G(()=>s(n));case"string":const o=$i.has(s),i=$.context?Vi():Js(s,o);return En(i,n,o),i}})}const Yi="modulepreload",Qi=function(t){return"/"+t},Ur={},Ee=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link"),i=document.querySelector("meta[property=csp-nonce]"),a=i?.nonce||i?.getAttribute("nonce");s=Promise.all(n.map(l=>{if(l=Qi(l),l in Ur)return;Ur[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(!!r)for(let p=o.length-1;p>=0;p--){const h=o[p];if(h.href===l&&(!c||h.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${u}`))return;const f=document.createElement("link");if(f.rel=c?"stylesheet":Yi,c||(f.as="script",f.crossOrigin=""),f.href=l,a&&f.setAttribute("nonce",a),document.head.appendChild(f),c)return new Promise((p,h)=>{f.addEventListener("load",p),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${l}`)))})}))}return s.then(()=>e()).catch(o=>{const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=o,window.dispatchEvent(i),!i.defaultPrevented)throw o})},Zi=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>Ee(()=>Promise.resolve().then(()=>Wt),void 0).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)};class gr extends Error{constructor(e,n="FunctionsError",r){super(e),this.name=n,this.context=r}}class ea extends gr{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class ta extends gr{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class na extends gr{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var ra=function(t,e,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(d){i(d)}}function l(u){try{c(r.throw(u))}catch(d){i(d)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})};class sa{constructor(e,{headers:n={},customFetch:r}={}){this.url=e,this.headers=n,this.fetch=Zi(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,n={}){var r;return ra(this,void 0,void 0,function*(){try{const{headers:s,method:o,body:i}=n;let a={},l;i&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob<"u"&&i instanceof Blob||i instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",l=i):typeof i=="string"?(a["Content-Type"]="text/plain",l=i):typeof FormData<"u"&&i instanceof FormData?l=i:(a["Content-Type"]="application/json",l=JSON.stringify(i)));const c=yield this.fetch(`${this.url}/${e}`,{method:o||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),s),body:l}).catch(p=>{throw new ea(p)}),u=c.headers.get("x-relay-error");if(u&&u==="true")throw new ta(c);if(!c.ok)throw new na(c);let d=((r=c.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim(),f;return d==="application/json"?f=yield c.json():d==="application/octet-stream"?f=yield c.blob():d==="multipart/form-data"?f=yield c.formData():f=yield c.text(),{data:f,error:null}}catch(s){return{data:null,error:s}}})}}var oa=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},bt=oa();const ia=bt.fetch,pr=bt.fetch.bind(bt),Xs=bt.Headers,aa=bt.Request,la=bt.Response,Wt=Object.freeze(Object.defineProperty({__proto__:null,Headers:Xs,Request:aa,Response:la,default:pr,fetch:ia},Symbol.toStringTag,{value:"Module"}));class ca extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}}class ua{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=pr:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,n){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const r=this.fetch;let s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var i,a,l;let c=null,u=null,d=null,f=o.status,p=o.statusText;if(o.ok){if(this.method!=="HEAD"){const y=await o.text();y===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?u=y:u=JSON.parse(y))}const g=(i=this.headers.Prefer)===null||i===void 0?void 0:i.match(/count=(exact|planned|estimated)/),m=(a=o.headers.get("content-range"))===null||a===void 0?void 0:a.split("/");g&&m&&m.length>1&&(d=parseInt(m[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(u)&&(u.length>1?(c={code:"PGRST116",details:`Results contain ${u.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},u=null,d=null,f=406,p="Not Acceptable"):u.length===1?u=u[0]:u=null)}else{const g=await o.text();try{c=JSON.parse(g),Array.isArray(c)&&o.status===404&&(u=[],c=null,f=200,p="OK")}catch{o.status===404&&g===""?(f=204,p="No Content"):c={message:g}}if(c&&this.isMaybeSingle&&(!((l=c?.details)===null||l===void 0)&&l.includes("0 rows"))&&(c=null,f=200,p="OK"),c&&this.shouldThrowOnError)throw new ca(c)}return{error:c,data:u,count:d,status:f,statusText:p}});return this.shouldThrowOnError||(s=s.catch(o=>{var i,a,l;return{error:{message:`${(i=o?.name)!==null&&i!==void 0?i:"FetchError"}: ${o?.message}`,details:`${(a=o?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(l=o?.code)!==null&&l!==void 0?l:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,n)}}class da extends ua{select(e){let n=!1;const r=(e??"*").split("").map(s=>/\s/.test(s)&&!n?"":(s==='"'&&(n=!n),s)).join("");return this.url.searchParams.set("select",r),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:n=!0,nullsFirst:r,foreignTable:s,referencedTable:o=s}={}){const i=o?`${o}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${a?`${a},`:""}${e}.${n?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:n,referencedTable:r=n}={}){const s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,n,{foreignTable:r,referencedTable:s=r}={}){const o=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(i,`${n-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:n=!1,settings:r=!1,buffers:s=!1,wal:o=!1,format:i="text"}={}){var a;const l=[e?"analyze":null,n?"verbose":null,r?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),c=(a=this.headers.Accept)!==null&&a!==void 0?a:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${i}; for="${c}"; options=${l};`,i==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class dt extends da{eq(e,n){return this.url.searchParams.append(e,`eq.${n}`),this}neq(e,n){return this.url.searchParams.append(e,`neq.${n}`),this}gt(e,n){return this.url.searchParams.append(e,`gt.${n}`),this}gte(e,n){return this.url.searchParams.append(e,`gte.${n}`),this}lt(e,n){return this.url.searchParams.append(e,`lt.${n}`),this}lte(e,n){return this.url.searchParams.append(e,`lte.${n}`),this}like(e,n){return this.url.searchParams.append(e,`like.${n}`),this}likeAllOf(e,n){return this.url.searchParams.append(e,`like(all).{${n.join(",")}}`),this}likeAnyOf(e,n){return this.url.searchParams.append(e,`like(any).{${n.join(",")}}`),this}ilike(e,n){return this.url.searchParams.append(e,`ilike.${n}`),this}ilikeAllOf(e,n){return this.url.searchParams.append(e,`ilike(all).{${n.join(",")}}`),this}ilikeAnyOf(e,n){return this.url.searchParams.append(e,`ilike(any).{${n.join(",")}}`),this}is(e,n){return this.url.searchParams.append(e,`is.${n}`),this}in(e,n){const r=n.map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,n){return typeof n=="string"?this.url.searchParams.append(e,`cs.${n}`):Array.isArray(n)?this.url.searchParams.append(e,`cs.{${n.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(n)}`),this}containedBy(e,n){return typeof n=="string"?this.url.searchParams.append(e,`cd.${n}`):Array.isArray(n)?this.url.searchParams.append(e,`cd.{${n.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(n)}`),this}rangeGt(e,n){return this.url.searchParams.append(e,`sr.${n}`),this}rangeGte(e,n){return this.url.searchParams.append(e,`nxl.${n}`),this}rangeLt(e,n){return this.url.searchParams.append(e,`sl.${n}`),this}rangeLte(e,n){return this.url.searchParams.append(e,`nxr.${n}`),this}rangeAdjacent(e,n){return this.url.searchParams.append(e,`adj.${n}`),this}overlaps(e,n){return typeof n=="string"?this.url.searchParams.append(e,`ov.${n}`):this.url.searchParams.append(e,`ov.{${n.join(",")}}`),this}textSearch(e,n,{config:r,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");const i=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${o}fts${i}.${n}`),this}match(e){return Object.entries(e).forEach(([n,r])=>{this.url.searchParams.append(n,`eq.${r}`)}),this}not(e,n,r){return this.url.searchParams.append(e,`not.${n}.${r}`),this}or(e,{foreignTable:n,referencedTable:r=n}={}){const s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,n,r){return this.url.searchParams.append(e,`${n}.${r}`),this}}class fa{constructor(e,{headers:n={},schema:r,fetch:s}){this.url=e,this.headers=n,this.schema=r,this.fetch=s}select(e,{head:n=!1,count:r}={}){const s=n?"HEAD":"GET";let o=!1;const i=(e??"*").split("").map(a=>/\s/.test(a)&&!o?"":(a==='"'&&(o=!o),a)).join("");return this.url.searchParams.set("select",i),r&&(this.headers.Prefer=`count=${r}`),new dt({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:n,defaultToNull:r=!0}={}){const s="POST",o=[];if(this.headers.Prefer&&o.push(this.headers.Prefer),n&&o.push(`count=${n}`),r||o.push("missing=default"),this.headers.Prefer=o.join(","),Array.isArray(e)){const i=e.reduce((a,l)=>a.concat(Object.keys(l)),[]);if(i.length>0){const a=[...new Set(i)].map(l=>`"${l}"`);this.url.searchParams.set("columns",a.join(","))}}return new dt({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:n,ignoreDuplicates:r=!1,count:s,defaultToNull:o=!0}={}){const i="POST",a=[`resolution=${r?"ignore":"merge"}-duplicates`];if(n!==void 0&&this.url.searchParams.set("on_conflict",n),this.headers.Prefer&&a.push(this.headers.Prefer),s&&a.push(`count=${s}`),o||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){const l=e.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(l.length>0){const c=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new dt({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:n}={}){const r="PATCH",s=[];return this.headers.Prefer&&s.push(this.headers.Prefer),n&&s.push(`count=${n}`),this.headers.Prefer=s.join(","),new dt({method:r,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const n="DELETE",r=[];return e&&r.push(`count=${e}`),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new dt({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const ha="1.9.2",ga={"X-Client-Info":`postgrest-js/${ha}`};class mr{constructor(e,{headers:n={},schema:r,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},ga),n),this.schemaName=r,this.fetch=s}from(e){const n=new URL(`${this.url}/${e}`);return new fa(n,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new mr(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,n={},{head:r=!1,count:s}={}){let o;const i=new URL(`${this.url}/rpc/${e}`);let a;r?(o="HEAD",Object.entries(n).forEach(([c,u])=>{i.searchParams.append(c,`${u}`)})):(o="POST",a=n);const l=Object.assign({},this.headers);return s&&(l.Prefer=`count=${s}`),new dt({method:o,url:i,headers:l,schema:this.schemaName,body:a,fetch:this.fetch,allowEmpty:!1})}}const pa="2.9.3",ma={"X-Client-Info":`realtime-js/${pa}`},ya="1.0.0",Ys=1e4,va=1e3;var mt;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(mt||(mt={}));var oe;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(oe||(oe={}));var me;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(me||(me={}));var Yn;(function(t){t.websocket="websocket"})(Yn||(Yn={}));var Xe;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Xe||(Xe={}));class Qs{constructor(e,n){this.callback=e,this.timerCalc=n,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=n}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))}}class ba{constructor(){this.HEADER_LENGTH=1}decode(e,n){return e.constructor===ArrayBuffer?n(this._binaryDecode(e)):n(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const n=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,n,r)}_decodeBroadcast(e,n,r){const s=n.getUint8(1),o=n.getUint8(2);let i=this.HEADER_LENGTH+2;const a=r.decode(e.slice(i,i+s));i=i+s;const l=r.decode(e.slice(i,i+o));i=i+o;const c=JSON.parse(r.decode(e.slice(i,e.byteLength)));return{ref:null,topic:a,event:l,payload:c}}}class Dn{constructor(e,n,r={},s=Ys){this.channel=e,this.event=n,this.payload=r,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,n){var r;return this._hasReceived(e)&&n((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:n}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=n=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=n,this._matchReceive(n)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,n){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:n})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:n}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(n))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var Br;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(Br||(Br={}));class jt{constructor(e,n){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=n?.events||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},s=>{const{onJoin:o,onLeave:i,onSync:a}=this.caller;this.joinRef=this.channel._joinRef(),this.state=jt.syncState(this.state,s,o,i),this.pendingDiffs.forEach(l=>{this.state=jt.syncDiff(this.state,l,o,i)}),this.pendingDiffs=[],a()}),this.channel._on(r.diff,{},s=>{const{onJoin:o,onLeave:i,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=jt.syncDiff(this.state,s,o,i),a())}),this.onJoin((s,o,i)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:o,newPresences:i})}),this.onLeave((s,o,i)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:o,leftPresences:i})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,n,r,s){const o=this.cloneDeep(e),i=this.transformState(n),a={},l={};return this.map(o,(c,u)=>{i[c]||(l[c]=u)}),this.map(i,(c,u)=>{const d=o[c];if(d){const f=u.map(m=>m.presence_ref),p=d.map(m=>m.presence_ref),h=u.filter(m=>p.indexOf(m.presence_ref)<0),g=d.filter(m=>f.indexOf(m.presence_ref)<0);h.length>0&&(a[c]=h),g.length>0&&(l[c]=g)}else a[c]=u}),this.syncDiff(o,{joins:a,leaves:l},r,s)}static syncDiff(e,n,r,s){const{joins:o,leaves:i}={joins:this.transformState(n.joins),leaves:this.transformState(n.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(o,(a,l)=>{var c;const u=(c=e[a])!==null&&c!==void 0?c:[];if(e[a]=this.cloneDeep(l),u.length>0){const d=e[a].map(p=>p.presence_ref),f=u.filter(p=>d.indexOf(p.presence_ref)<0);e[a].unshift(...f)}r(a,u,l)}),this.map(i,(a,l)=>{let c=e[a];if(!c)return;const u=l.map(d=>d.presence_ref);c=c.filter(d=>u.indexOf(d.presence_ref)<0),e[a]=c,s(a,c,l),c.length===0&&delete e[a]}),e}static map(e,n){return Object.getOwnPropertyNames(e).map(r=>n(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((n,r)=>{const s=e[r];return"metas"in s?n[r]=s.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):n[r]=s,n},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var H;(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"})(H||(H={}));const zr=(t,e,n={})=>{var r;const s=(r=n.skipTypes)!==null&&r!==void 0?r:[];return Object.keys(e).reduce((o,i)=>(o[i]=wa(i,t,e,s),o),{})},wa=(t,e,n,r)=>{const s=e.find(a=>a.name===t),o=s?.type,i=n[t];return o&&!r.includes(o)?Zs(o,i):Qn(i)},Zs=(t,e)=>{if(t.charAt(0)==="_"){const n=t.slice(1,t.length);return Ea(e,n)}switch(t){case H.bool:return _a(e);case H.float4:case H.float8:case H.int2:case H.int4:case H.int8:case H.numeric:case H.oid:return xa(e);case H.json:case H.jsonb:return Sa(e);case H.timestamp:return ka(e);case H.abstime:case H.date:case H.daterange:case H.int4range:case H.int8range:case H.money:case H.reltime:case H.text:case H.time:case H.timestamptz:case H.timetz:case H.tsrange:case H.tstzrange:return Qn(e);default:return Qn(e)}},Qn=t=>t,_a=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},xa=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},Sa=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},Ea=(t,e)=>{if(typeof t!="string")return t;const n=t.length-1,r=t[n];if(t[0]==="{"&&r==="}"){let o;const i=t.slice(1,n);try{o=JSON.parse("["+i+"]")}catch{o=i?i.split(","):[]}return o.map(a=>Zs(e,a))}return t},ka=t=>typeof t=="string"?t.replace(" ","T"):t;var Vr;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(Vr||(Vr={}));var Hr;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes"})(Hr||(Hr={}));var qr;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(qr||(qr={}));class yr{constructor(e,n={config:{}},r){this.topic=e,this.params=n,this.socket=r,this.bindings={},this.state=oe.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},n.config),this.timeout=this.socket.timeout,this.joinPush=new Dn(this,me.join,this.params,this.timeout),this.rejoinTimer=new Qs(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=oe.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=oe.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=oe.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=oe.errored,this.rejoinTimer.scheduleTimeout())}),this._on(me.reply,{},(s,o)=>{this._trigger(this._replyEventName(o),s)}),this.presence=new jt(this),this.broadcastEndpointURL=this._broadcastEndpointURL()}subscribe(e,n=this.timeout){var r,s;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:o,presence:i}}=this.params;this._onError(c=>e&&e("CHANNEL_ERROR",c)),this._onClose(()=>e&&e("CLOSED"));const a={},l={broadcast:o,presence:i,postgres_changes:(s=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(c=>c.filter))!==null&&s!==void 0?s:[]};this.socket.accessToken&&(a.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:l},a)),this.joinedOnce=!0,this._rejoin(n),this.joinPush.receive("ok",({postgres_changes:c})=>{var u;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),c===void 0){e&&e("SUBSCRIBED");return}else{const d=this.bindings.postgres_changes,f=(u=d?.length)!==null&&u!==void 0?u:0,p=[];for(let h=0;h<f;h++){const g=d[h],{filter:{event:m,schema:y,table:v,filter:w}}=g,b=c&&c[h];if(b&&b.event===m&&b.schema===y&&b.table===v&&b.filter===w)p.push(Object.assign(Object.assign({},g),{id:b.id}));else{this.unsubscribe(),e&&e("CHANNEL_ERROR",new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=p,e&&e("SUBSCRIBED");return}}).receive("error",c=>{e&&e("CHANNEL_ERROR",new Error(JSON.stringify(Object.values(c).join(", ")||"error")))}).receive("timeout",()=>{e&&e("TIMED_OUT")})}return this}presenceState(){return this.presence.state}async track(e,n={}){return await this.send({type:"presence",event:"track",payload:e},n.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,n,r){return this._on(e,n,r)}async send(e,n={}){var r,s;if(!this._canPush()&&e.type==="broadcast"){const{event:o,payload:i}=e,a={method:"POST",headers:{apikey:(r=this.socket.apiKey)!==null&&r!==void 0?r:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:i}]})};try{return(await this._fetchWithTimeout(this.broadcastEndpointURL,a,(s=n.timeout)!==null&&s!==void 0?s:this.timeout)).ok?"ok":"error"}catch(l){return l.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var i,a,l;const c=this._push(e.type,e,n.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(a=(i=this.params)===null||i===void 0?void 0:i.config)===null||a===void 0?void 0:a.broadcast)===null||l===void 0)&&l.ack)&&o("ok"),c.receive("ok",()=>o("ok")),c.receive("timeout",()=>o("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=oe.leaving;const n=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(me.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(r=>{const s=new Dn(this,me.leave,{},e);s.receive("ok",()=>{n(),r("ok")}).receive("timeout",()=>{n(),r("timed out")}).receive("error",()=>{r("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}_broadcastEndpointURL(){let e=this.socket.endPoint;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"}async _fetchWithTimeout(e,n,r){const s=new AbortController,o=setTimeout(()=>s.abort(),r),i=await this.socket.fetch(e,Object.assign(Object.assign({},n),{signal:s.signal}));return clearTimeout(o),i}_push(e,n,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new Dn(this,e,n,r);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,n,r){return n}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,n,r){var s,o;const i=e.toLocaleLowerCase(),{close:a,error:l,leave:c,join:u}=me;if(r&&[a,l,c,u].indexOf(i)>=0&&r!==this._joinRef())return;let f=this._onMessage(i,n,r);if(n&&!f)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(i)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(p=>{var h,g,m;return((h=p.filter)===null||h===void 0?void 0:h.event)==="*"||((m=(g=p.filter)===null||g===void 0?void 0:g.event)===null||m===void 0?void 0:m.toLocaleLowerCase())===i}).map(p=>p.callback(f,r)):(o=this.bindings[i])===null||o===void 0||o.filter(p=>{var h,g,m,y,v,w;if(["broadcast","presence","postgres_changes"].includes(i))if("id"in p){const b=p.id,k=(h=p.filter)===null||h===void 0?void 0:h.event;return b&&((g=n.ids)===null||g===void 0?void 0:g.includes(b))&&(k==="*"||k?.toLocaleLowerCase()===((m=n.data)===null||m===void 0?void 0:m.type.toLocaleLowerCase()))}else{const b=(v=(y=p?.filter)===null||y===void 0?void 0:y.event)===null||v===void 0?void 0:v.toLocaleLowerCase();return b==="*"||b===((w=n?.event)===null||w===void 0?void 0:w.toLocaleLowerCase())}else return p.type.toLocaleLowerCase()===i}).map(p=>{if(typeof f=="object"&&"ids"in f){const h=f.data,{schema:g,table:m,commit_timestamp:y,type:v,errors:w}=h;f=Object.assign(Object.assign({},{schema:g,table:m,commit_timestamp:y,eventType:v,new:{},old:{},errors:w}),this._getPayloadRecords(h))}p.callback(f,r)})}_isClosed(){return this.state===oe.closed}_isJoined(){return this.state===oe.joined}_isJoining(){return this.state===oe.joining}_isLeaving(){return this.state===oe.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,n,r){const s=e.toLocaleLowerCase(),o={type:s,filter:n,callback:r};return this.bindings[s]?this.bindings[s].push(o):this.bindings[s]=[o],this}_off(e,n){const r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter(s=>{var o;return!(((o=s.type)===null||o===void 0?void 0:o.toLocaleLowerCase())===r&&yr.isEqual(s.filter,n))}),this}static isEqual(e,n){if(Object.keys(e).length!==Object.keys(n).length)return!1;for(const r in e)if(e[r]!==n[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(me.close,{},e)}_onError(e){this._on(me.error,{},n=>e(n))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=oe.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const n={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(n.new=zr(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(n.old=zr(e.columns,e.old_record)),n}}const Ta=()=>{},Pa=typeof WebSocket<"u";class Aa{constructor(e,n){var r;this.accessToken=null,this.apiKey=null,this.channels=[],this.endPoint="",this.headers=ma,this.params={},this.timeout=Ys,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=Ta,this.conn=null,this.sendBuffer=[],this.serializer=new ba,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this._resolveFetch=o=>{let i;return o?i=o:typeof fetch>"u"?i=(...a)=>Ee(()=>Promise.resolve().then(()=>Wt),void 0).then(({default:l})=>l(...a)):i=fetch,(...a)=>i(...a)},this.endPoint=`${e}/${Yn.websocket}`,n?.transport?this.transport=n.transport:this.transport=null,n?.params&&(this.params=n.params),n?.headers&&(this.headers=Object.assign(Object.assign({},this.headers),n.headers)),n?.timeout&&(this.timeout=n.timeout),n?.logger&&(this.logger=n.logger),n?.heartbeatIntervalMs&&(this.heartbeatIntervalMs=n.heartbeatIntervalMs);const s=(r=n?.params)===null||r===void 0?void 0:r.apikey;s&&(this.accessToken=s,this.apiKey=s),this.reconnectAfterMs=n?.reconnectAfterMs?n.reconnectAfterMs:o=>[1e3,2e3,5e3,1e4][o-1]||1e4,this.encode=n?.encode?n.encode:(o,i)=>i(JSON.stringify(o)),this.decode=n?.decode?n.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new Qs(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(n?.fetch)}connect(){if(!this.conn){if(this.transport){this.conn=new this.transport(this._endPointURL(),void 0,{headers:this.headers});return}if(Pa){this.conn=new WebSocket(this._endPointURL()),this.setupConnection();return}this.conn=new Oa(this._endPointURL(),void 0,{close:()=>{this.conn=null}}),Ee(()=>import("./browser-BImCA5dO.js").then(e=>e.b),__vite__mapDeps([])).then(({default:e})=>{this.conn=new e(this._endPointURL(),void 0,{headers:this.headers}),this.setupConnection()})}}disconnect(e,n){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,n??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){const n=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),n}async removeAllChannels(){const e=await Promise.all(this.channels.map(n=>n.unsubscribe()));return this.disconnect(),e}log(e,n,r){this.logger(e,n,r)}connectionState(){switch(this.conn&&this.conn.readyState){case mt.connecting:return Xe.Connecting;case mt.open:return Xe.Open;case mt.closing:return Xe.Closing;default:return Xe.Closed}}isConnected(){return this.connectionState()===Xe.Open}channel(e,n={config:{}}){const r=new yr(`realtime:${e}`,n,this);return this.channels.push(r),r}push(e){const{topic:n,event:r,payload:s,ref:o}=e,i=()=>{this.encode(e,a=>{var l;(l=this.conn)===null||l===void 0||l.send(a)})};this.log("push",`${n} ${r} (${o})`,s),this.isConnected()?i():this.sendBuffer.push(i)}setAuth(e){this.accessToken=e,this.channels.forEach(n=>{e&&n.updateJoinPayload({access_token:e}),n.joinedOnce&&n._isJoined()&&n._push(me.access_token,{access_token:e})})}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let n=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));n&&(this.log("transport",`leaving duplicate topic "${e}"`),n.unsubscribe())}_remove(e){this.channels=this.channels.filter(n=>n._joinRef()!==e._joinRef())}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:ya}))}_onConnMessage(e){this.decode(e.data,n=>{let{topic:r,event:s,payload:o,ref:i}=n;(i&&i===this.pendingHeartbeatRef||s===o?.type)&&(this.pendingHeartbeatRef=null),this.log("receive",`${o.status||""} ${r} ${s} ${i&&"("+i+")"||""}`,o),this.channels.filter(a=>a._isMember(r)).forEach(a=>a._trigger(s,o,i)),this.stateChangeCallbacks.message.forEach(a=>a(n))})}_onConnOpen(){this.log("transport",`connected to ${this._endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this._sendHeartbeat(),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(n=>n(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(n=>n(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(me.error))}_appendParams(e,n){if(Object.keys(n).length===0)return e;const r=e.match(/\?/)?"&":"?",s=new URLSearchParams(n);return`${e}${r}${s}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(va,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}}class Oa{constructor(e,n,r){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=mt.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=r.close}}class vr extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function Z(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class Ca extends vr{constructor(e,n){super(e),this.name="StorageApiError",this.status=n}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class Wr extends vr{constructor(e,n){super(e),this.name="StorageUnknownError",this.originalError=n}}var La=function(t,e,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(d){i(d)}}function l(u){try{c(r.throw(u))}catch(d){i(d)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})};const eo=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>Ee(()=>Promise.resolve().then(()=>Wt),void 0).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)},Ra=()=>La(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Ee(()=>Promise.resolve().then(()=>Wt),void 0)).Response:Response});var St=function(t,e,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(d){i(d)}}function l(u){try{c(r.throw(u))}catch(d){i(d)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})};const Mn=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Ia=(t,e)=>St(void 0,void 0,void 0,function*(){const n=yield Ra();t instanceof n?t.json().then(r=>{e(new Ca(Mn(r),t.status||500))}).catch(r=>{e(new Wr(Mn(r),r))}):e(new Wr(Mn(t),t))}),$a=(t,e,n,r)=>{const s={method:t,headers:e?.headers||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json"},e?.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),n))};function kn(t,e,n,r,s,o){return St(this,void 0,void 0,function*(){return new Promise((i,a)=>{t(n,$a(e,r,s,o)).then(l=>{if(!l.ok)throw l;return r?.noResolveJson?l:l.json()}).then(l=>i(l)).catch(l=>Ia(l,a))})})}function Zn(t,e,n,r){return St(this,void 0,void 0,function*(){return kn(t,"GET",e,n,r)})}function je(t,e,n,r,s){return St(this,void 0,void 0,function*(){return kn(t,"POST",e,r,s,n)})}function Da(t,e,n,r,s){return St(this,void 0,void 0,function*(){return kn(t,"PUT",e,r,s,n)})}function to(t,e,n,r,s){return St(this,void 0,void 0,function*(){return kn(t,"DELETE",e,r,s,n)})}var ce=function(t,e,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(d){i(d)}}function l(u){try{c(r.throw(u))}catch(d){i(d)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})};const Ma={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Gr={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class ja{constructor(e,n={},r,s){this.url=e,this.headers=n,this.bucketId=r,this.fetch=eo(s)}uploadOrUpdate(e,n,r,s){return ce(this,void 0,void 0,function*(){try{let o;const i=Object.assign(Object.assign({},Gr),s),a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(i.upsert)});typeof Blob<"u"&&r instanceof Blob?(o=new FormData,o.append("cacheControl",i.cacheControl),o.append("",r)):typeof FormData<"u"&&r instanceof FormData?(o=r,o.append("cacheControl",i.cacheControl)):(o=r,a["cache-control"]=`max-age=${i.cacheControl}`,a["content-type"]=i.contentType);const l=this._removeEmptyFolders(n),c=this._getFinalPath(l),u=yield this.fetch(`${this.url}/object/${c}`,Object.assign({method:e,body:o,headers:a},i?.duplex?{duplex:i.duplex}:{})),d=yield u.json();return u.ok?{data:{path:l,id:d.Id,fullPath:d.Key},error:null}:{data:null,error:d}}catch(o){if(Z(o))return{data:null,error:o};throw o}})}upload(e,n,r){return ce(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,n,r)})}uploadToSignedUrl(e,n,r,s){return ce(this,void 0,void 0,function*(){const o=this._removeEmptyFolders(e),i=this._getFinalPath(o),a=new URL(this.url+`/object/upload/sign/${i}`);a.searchParams.set("token",n);try{let l;const c=Object.assign({upsert:Gr.upsert},s),u=Object.assign(Object.assign({},this.headers),{"x-upsert":String(c.upsert)});typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.append("cacheControl",c.cacheControl)):(l=r,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType);const d=yield this.fetch(a.toString(),{method:"PUT",body:l,headers:u}),f=yield d.json();return d.ok?{data:{path:o,fullPath:f.Key},error:null}:{data:null,error:f}}catch(l){if(Z(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e){return ce(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e);const r=yield je(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:this.headers}),s=new URL(this.url+r.url),o=s.searchParams.get("token");if(!o)throw new vr("No token returned by API");return{data:{signedUrl:s.toString(),path:e,token:o},error:null}}catch(n){if(Z(n))return{data:null,error:n};throw n}})}update(e,n,r){return ce(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,n,r)})}move(e,n){return ce(this,void 0,void 0,function*(){try{return{data:yield je(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:n},{headers:this.headers}),error:null}}catch(r){if(Z(r))return{data:null,error:r};throw r}})}copy(e,n){return ce(this,void 0,void 0,function*(){try{return{data:{path:(yield je(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:n},{headers:this.headers})).Key},error:null}}catch(r){if(Z(r))return{data:null,error:r};throw r}})}createSignedUrl(e,n,r){return ce(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),o=yield je(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:n},r?.transform?{transform:r.transform}:{}),{headers:this.headers});const i=r?.download?`&download=${r.download===!0?"":r.download}`:"";return o={signedUrl:encodeURI(`${this.url}${o.signedURL}${i}`)},{data:o,error:null}}catch(s){if(Z(s))return{data:null,error:s};throw s}})}createSignedUrls(e,n,r){return ce(this,void 0,void 0,function*(){try{const s=yield je(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:n,paths:e},{headers:this.headers}),o=r?.download?`&download=${r.download===!0?"":r.download}`:"";return{data:s.map(i=>Object.assign(Object.assign({},i),{signedUrl:i.signedURL?encodeURI(`${this.url}${i.signedURL}${o}`):null})),error:null}}catch(s){if(Z(s))return{data:null,error:s};throw s}})}download(e,n){return ce(this,void 0,void 0,function*(){const s=typeof n?.transform<"u"?"render/image/authenticated":"object",o=this.transformOptsToQueryString(n?.transform||{}),i=o?`?${o}`:"";try{const a=this._getFinalPath(e);return{data:yield(yield Zn(this.fetch,`${this.url}/${s}/${a}${i}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if(Z(a))return{data:null,error:a};throw a}})}getPublicUrl(e,n){const r=this._getFinalPath(e),s=[],o=n?.download?`download=${n.download===!0?"":n.download}`:"";o!==""&&s.push(o);const a=typeof n?.transform<"u"?"render/image":"object",l=this.transformOptsToQueryString(n?.transform||{});l!==""&&s.push(l);let c=s.join("&");return c!==""&&(c=`?${c}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${r}${c}`)}}}remove(e){return ce(this,void 0,void 0,function*(){try{return{data:yield to(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(n){if(Z(n))return{data:null,error:n};throw n}})}list(e,n,r){return ce(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},Ma),n),{prefix:e||""});return{data:yield je(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(s){if(Z(s))return{data:null,error:s};throw s}})}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const n=[];return e.width&&n.push(`width=${e.width}`),e.height&&n.push(`height=${e.height}`),e.resize&&n.push(`resize=${e.resize}`),e.format&&n.push(`format=${e.format}`),e.quality&&n.push(`quality=${e.quality}`),n.join("&")}}const Fa="2.5.5",Na={"X-Client-Info":`storage-js/${Fa}`};var it=function(t,e,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(d){i(d)}}function l(u){try{c(r.throw(u))}catch(d){i(d)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})};class Ka{constructor(e,n={},r){this.url=e,this.headers=Object.assign(Object.assign({},Na),n),this.fetch=eo(r)}listBuckets(){return it(this,void 0,void 0,function*(){try{return{data:yield Zn(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(Z(e))return{data:null,error:e};throw e}})}getBucket(e){return it(this,void 0,void 0,function*(){try{return{data:yield Zn(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(n){if(Z(n))return{data:null,error:n};throw n}})}createBucket(e,n={public:!1}){return it(this,void 0,void 0,function*(){try{return{data:yield je(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(Z(r))return{data:null,error:r};throw r}})}updateBucket(e,n){return it(this,void 0,void 0,function*(){try{return{data:yield Da(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(Z(r))return{data:null,error:r};throw r}})}emptyBucket(e){return it(this,void 0,void 0,function*(){try{return{data:yield je(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(n){if(Z(n))return{data:null,error:n};throw n}})}deleteBucket(e){return it(this,void 0,void 0,function*(){try{return{data:yield to(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(n){if(Z(n))return{data:null,error:n};throw n}})}}class Ua extends Ka{constructor(e,n={},r){super(e,n,r)}from(e){return new ja(this.url,this.headers,e,this.fetch)}}const Ba="2.40.0";let $t="";typeof Deno<"u"?$t="deno":typeof document<"u"?$t="web":typeof navigator<"u"&&navigator.product==="ReactNative"?$t="react-native":$t="node";const za={"X-Client-Info":`supabase-js-${$t}/${Ba}`},Va={headers:za},Ha={schema:"public"},qa={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Wa={};var Ga=function(t,e,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(d){i(d)}}function l(u){try{c(r.throw(u))}catch(d){i(d)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})};const Ja=t=>{let e;return t?e=t:typeof fetch>"u"?e=pr:e=fetch,(...n)=>e(...n)},Xa=()=>typeof Headers>"u"?Xs:Headers,Ya=(t,e,n)=>{const r=Ja(n),s=Xa();return(o,i)=>Ga(void 0,void 0,void 0,function*(){var a;const l=(a=yield e())!==null&&a!==void 0?a:t;let c=new s(i?.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),r(o,Object.assign(Object.assign({},i),{headers:c}))})};function Qa(t){return t.replace(/\/$/,"")}function Za(t,e){const{db:n,auth:r,realtime:s,global:o}=t,{db:i,auth:a,realtime:l,global:c}=e;return{db:Object.assign(Object.assign({},i),n),auth:Object.assign(Object.assign({},a),r),realtime:Object.assign(Object.assign({},l),s),global:Object.assign(Object.assign({},c),o)}}function el(t){return Math.round(Date.now()/1e3)+t}function tl(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}const ge=()=>typeof document<"u",We={tested:!1,writable:!1},Ft=()=>{if(!ge())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(We.tested)return We.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),We.tested=!0,We.writable=!0}catch{We.tested=!0,We.writable=!1}return We.writable};function jn(t){const e={},n=new URL(t);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((s,o)=>{e[o]=s})}catch{}return n.searchParams.forEach((r,s)=>{e[s]=r}),e}const no=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>Ee(()=>Promise.resolve().then(()=>Wt),void 0).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)},nl=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Ge=async(t,e,n)=>{await t.setItem(e,JSON.stringify(n))},Qt=async(t,e)=>{const n=await t.getItem(e);if(!n)return null;try{return JSON.parse(n)}catch{return n}},Fn=async(t,e)=>{await t.removeItem(e)};function rl(t){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let n="",r,s,o,i,a,l,c,u=0;for(t=t.replace("-","+").replace("_","/");u<t.length;)i=e.indexOf(t.charAt(u++)),a=e.indexOf(t.charAt(u++)),l=e.indexOf(t.charAt(u++)),c=e.indexOf(t.charAt(u++)),r=i<<2|a>>4,s=(a&15)<<4|l>>2,o=(l&3)<<6|c,n=n+String.fromCharCode(r),l!=64&&s!=0&&(n=n+String.fromCharCode(s)),c!=64&&o!=0&&(n=n+String.fromCharCode(o));return n}class Tn{constructor(){this.promise=new Tn.promiseConstructor((e,n)=>{this.resolve=e,this.reject=n})}}Tn.promiseConstructor=Promise;function Jr(t){const e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,n=t.split(".");if(n.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(n[1]))throw new Error("JWT is not valid: payload is not in base64url format");const r=n[1];return JSON.parse(rl(r))}async function sl(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function ol(t,e){return new Promise((r,s)=>{(async()=>{for(let o=0;o<1/0;o++)try{const i=await t(o);if(!e(o,null,i)){r(i);return}}catch(i){if(!e(o,i)){s(i);return}}})()})}function il(t){return("0"+t.toString(16)).substr(-2)}function at(){const e=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=n.length;let s="";for(let o=0;o<56;o++)s+=n.charAt(Math.floor(Math.random()*r));return s}return crypto.getRandomValues(e),Array.from(e,il).join("")}async function al(t){const n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),s=new Uint8Array(r);return Array.from(s).map(o=>String.fromCharCode(o)).join("")}function ll(t){return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function lt(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 n=await al(t);return ll(n)}class br extends Error{constructor(e,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=n}}function M(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class cl extends br{constructor(e,n){super(e,n),this.name="AuthApiError",this.status=n}toJSON(){return{name:this.name,message:this.message,status:this.status}}}function ul(t){return M(t)&&t.name==="AuthApiError"}class ro extends br{constructor(e,n){super(e),this.name="AuthUnknownError",this.originalError=n}}class tt extends br{constructor(e,n,r){super(e),this.name=n,this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class ct extends tt{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class Nn extends tt{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500)}}class Zt extends tt{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}class en extends tt{constructor(e,n=null){super(e,"AuthImplicitGrantRedirectError",500),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Xr extends tt{constructor(e,n=null){super(e,"AuthPKCEGrantCodeExchangeError",500),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class er extends tt{constructor(e,n){super(e,"AuthRetryableFetchError",n)}}function Kn(t){return M(t)&&t.name==="AuthRetryableFetchError"}class dl extends tt{constructor(e,n,r){super(e,"AuthWeakPasswordError",n),this.reasons=r}}var fl=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};const ft=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),hl=[502,503,504];async function Yr(t){if(!nl(t))throw new er(ft(t),0);if(hl.includes(t.status))throw new er(ft(t),t.status);let e;try{e=await t.json()}catch(n){throw new ro(ft(n),n)}throw typeof e=="object"&&e&&typeof e.weak_password=="object"&&e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.reasons.reduce((n,r)=>n&&typeof r=="string",!0)?new dl(ft(e),t.status,e.weak_password.reasons):new cl(ft(e),t.status||500)}const gl=(t,e,n,r)=>{const s={method:t,headers:e?.headers||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),n))};async function F(t,e,n,r){var s;const o=Object.assign({},r?.headers);r?.jwt&&(o.Authorization=`Bearer ${r.jwt}`);const i=(s=r?.query)!==null&&s!==void 0?s:{};r?.redirectTo&&(i.redirect_to=r.redirectTo);const a=Object.keys(i).length?"?"+new URLSearchParams(i).toString():"",l=await pl(t,e,n+a,{headers:o,noResolveJson:r?.noResolveJson},{},r?.body);return r?.xform?r?.xform(l):{data:Object.assign({},l),error:null}}async function pl(t,e,n,r,s,o){const i=gl(e,r,s,o);let a;try{a=await t(n,i)}catch(l){throw console.error(l),new er(ft(l),0)}if(a.ok||await Yr(a),r?.noResolveJson)return a;try{return await a.json()}catch(l){await Yr(l)}}function Je(t){var e;let n=null;bl(t)&&(n=Object.assign({},t),t.expires_at||(n.expires_at=el(t.expires_in)));const r=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:n,user:r},error:null}}function Qr(t){const e=Je(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((n,r)=>n&&typeof r=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Fe(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function ml(t){return{data:t,error:null}}function yl(t){const{action_link:e,email_otp:n,hashed_token:r,redirect_to:s,verification_type:o}=t,i=fl(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:n,hashed_token:r,redirect_to:s,verification_type:o},l=Object.assign({},i);return{data:{properties:a,user:l},error:null}}function vl(t){return t}function bl(t){return t.access_token&&t.refresh_token&&t.expires_in}var wl=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};class _l{constructor({url:e="",headers:n={},fetch:r}){this.url=e,this.headers=n,this.fetch=no(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,n="global"){try{return await F(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(M(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,n={}){try{return await F(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:Fe})}catch(r){if(M(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:n}=e,r=wl(e,["options"]),s=Object.assign(Object.assign({},r),n);return"newEmail"in r&&(s.new_email=r?.newEmail,delete s.newEmail),await F(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:yl,redirectTo:n?.redirectTo})}catch(n){if(M(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(e){try{return await F(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Fe})}catch(n){if(M(n))return{data:{user:null},error:n};throw n}}async listUsers(e){var n,r,s,o,i,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await F(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=e?.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(o=(s=e?.perPage)===null||s===void 0?void 0:s.toString())!==null&&o!==void 0?o:""},xform:vl});if(u.error)throw u.error;const d=await u.json(),f=(i=u.headers.get("x-total-count"))!==null&&i!==void 0?i:0,p=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return p.length>0&&(p.forEach(h=>{const g=parseInt(h.split(";")[0].split("=")[1].substring(0,1)),m=JSON.parse(h.split(";")[1].split("=")[1]);c[`${m}Page`]=g}),c.total=parseInt(f)),{data:Object.assign(Object.assign({},d),c),error:null}}catch(c){if(M(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){try{return await F(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Fe})}catch(n){if(M(n))return{data:{user:null},error:n};throw n}}async updateUserById(e,n){try{return await F(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:n,headers:this.headers,xform:Fe})}catch(r){if(M(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,n=!1){try{return await F(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:n},xform:Fe})}catch(r){if(M(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){try{const{data:n,error:r}=await F(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:n,error:r}}catch(n){if(M(n))return{data:null,error:n};throw n}}async _deleteFactor(e){try{return{data:await F(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(n){if(M(n))return{data:null,error:n};throw n}}}const so="0.0.0",xl="http://localhost:9999",Sl="supabase.auth.token",El={"X-Client-Info":`gotrue-js/${so}`},Zr=10,kl={getItem:t=>Ft()?globalThis.localStorage.getItem(t):null,setItem:(t,e)=>{Ft()&&globalThis.localStorage.setItem(t,e)},removeItem:t=>{Ft()&&globalThis.localStorage.removeItem(t)}};function es(t={}){return{getItem:e=>t[e]||null,setItem:(e,n)=>{t[e]=n},removeItem:e=>{delete t[e]}}}function Tl(){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)}}const ut={debug:!!(globalThis&&Ft()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class oo extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class Pl extends oo{}async function Al(t,e,n){ut.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),ut.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async s=>{if(s){ut.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await n()}finally{ut.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw ut.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new Pl(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(ut.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"),await n()}})}Tl();const Ol={url:xl,storageKey:Sl,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:El,flowType:"implicit",debug:!1},At=30*1e3,ts=3;async function ns(t,e,n){return await n()}class Ut{constructor(e){var n,r;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Ut.nextInstanceID,Ut.nextInstanceID+=1,this.instanceID>0&&ge()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const s=Object.assign(Object.assign({},Ol),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new _l({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=no(s.fetch),this.lock=s.lock||ns,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,s.lock?this.lock=s.lock:ge()&&(!((n=globalThis?.navigator)===null||n===void 0)&&n.locks)?this.lock=Al:this.lock=ns,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?s.storage?this.storage=s.storage:Ft()?this.storage=kl:(this.memoryStorage={},this.storage=es(this.memoryStorage)):(this.memoryStorage={},this.storage=es(this.memoryStorage)),ge()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o),await this._notifyAllSubscribers(o.data.event,o.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${so}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){try{const e=ge()?await this._isPKCEFlow():!1;if(this._debug("#_initialize()","begin","is PKCE flow",e),e||this.detectSessionInUrl&&this._isImplicitGrantFlow()){const{data:n,error:r}=await this._getSessionFromURL(e);if(r)return this._debug("#_initialize()","error detecting session from URL",r),r?.message==="Identity is already linked"||r?.message==="Identity is already linked to another user"?{error:r}:(await this._removeSession(),{error:r});const{session:s,redirectType:o}=n;return this._debug("#_initialize()","detected session in URL",s,"redirect type",o),await this._saveSession(s),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",s):await this._notifyAllSubscribers("SIGNED_IN",s)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){return M(e)?{error:e}:{error:new ro("Unexpected error during initialization",e)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signUp(e){var n,r,s;try{await this._removeSession();let o;if("email"in e){const{email:u,password:d,options:f}=e;let p=null,h=null;if(this.flowType==="pkce"){const g=at();await Ge(this.storage,`${this.storageKey}-code-verifier`,g),p=await lt(g),h=g===p?"plain":"s256"}o=await F(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f?.emailRedirectTo,body:{email:u,password:d,data:(n=f?.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:f?.captchaToken},code_challenge:p,code_challenge_method:h},xform:Je})}else if("phone"in e){const{phone:u,password:d,options:f}=e;o=await F(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:d,data:(r=f?.data)!==null&&r!==void 0?r:{},channel:(s=f?.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:f?.captchaToken}},xform:Je})}else throw new Zt("You must provide either an email or phone number and a password");const{data:i,error:a}=o;if(a||!i)return{data:{user:null,session:null},error:a};const l=i.session,c=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(o){if(M(o))return{data:{user:null,session:null},error:o};throw o}}async signInWithPassword(e){try{await this._removeSession();let n;if("email"in e){const{email:o,password:i,options:a}=e;n=await F(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:i,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:Qr})}else if("phone"in e){const{phone:o,password:i,options:a}=e;n=await F(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:i,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:Qr})}else throw new Zt("You must provide either an email or phone number and a password");const{data:r,error:s}=n;return s?{data:{user:null,session:null},error:s}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new Nn}:(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(n){if(M(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOAuth(e){var n,r,s,o;return await this._removeSession(),await this._handleProviderSignIn(e.provider,{redirectTo:(n=e.options)===null||n===void 0?void 0:n.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(o=e.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){const n=await Qt(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(n??"").split("/"),{data:o,error:i}=await F(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:Je});return await Fn(this.storage,`${this.storageKey}-code-verifier`),i?{data:{user:null,session:null,redirectType:null},error:i}:!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new Nn}:(o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",o.session)),{data:Object.assign(Object.assign({},o),{redirectType:s??null}),error:i})}async signInWithIdToken(e){await this._removeSession();try{const{options:n,provider:r,token:s,access_token:o,nonce:i}=e,a=await F(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:o,nonce:i,gotrue_meta_security:{captcha_token:n?.captchaToken}},xform:Je}),{data:l,error:c}=a;return c?{data:{user:null,session:null},error:c}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new Nn}:(l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:c})}catch(n){if(M(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOtp(e){var n,r,s,o,i;try{if(await this._removeSession(),"email"in e){const{email:a,options:l}=e;let c=null,u=null;if(this.flowType==="pkce"){const f=at();await Ge(this.storage,`${this.storageKey}-code-verifier`,f),c=await lt(f),u=f===c?"plain":"s256"}const{error:d}=await F(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(n=l?.data)!==null&&n!==void 0?n:{},create_user:(r=l?.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l?.emailRedirectTo});return{data:{user:null,session:null},error:d}}if("phone"in e){const{phone:a,options:l}=e,{data:c,error:u}=await F(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(s=l?.data)!==null&&s!==void 0?s:{},create_user:(o=l?.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},channel:(i=l?.channel)!==null&&i!==void 0?i:"sms"}});return{data:{user:null,session:null,messageId:c?.message_id},error:u}}throw new Zt("You must provide either an email or phone number.")}catch(a){if(M(a))return{data:{user:null,session:null},error:a};throw a}}async verifyOtp(e){var n,r;try{e.type!=="email_change"&&e.type!=="phone_change"&&await this._removeSession();let s,o;"options"in e&&(s=(n=e.options)===null||n===void 0?void 0:n.redirectTo,o=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:i,error:a}=await F(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:o}}),redirectTo:s,xform:Je});if(a)throw a;if(!i)throw new Error("An error occurred on token verification.");const l=i.session,c=i.user;return l?.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(s){if(M(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var n,r,s;try{await this._removeSession();let o=null,i=null;if(this.flowType==="pkce"){const a=at();await Ge(this.storage,`${this.storageKey}-code-verifier`,a),o=await lt(a),i=a===o?"plain":"s256"}return await F(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(r=(n=e.options)===null||n===void 0?void 0:n.redirectTo)!==null&&r!==void 0?r:void 0}),!((s=e?.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:i}),headers:this.headers,xform:ml})}catch(o){if(M(o))return{data:null,error:o};throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:n},error:r}=e;if(r)throw r;if(!n)throw new ct;const{error:s}=await F(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(M(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{e.type!="email_change"&&e.type!="phone_change"&&await this._removeSession();const n=`${this.url}/resend`;if("email"in e){const{email:r,type:s,options:o}=e,{error:i}=await F(this.fetch,"POST",n,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:o?.captchaToken}},redirectTo:o?.emailRedirectTo});return{data:{user:null,session:null},error:i}}else if("phone"in e){const{phone:r,type:s,options:o}=e,{data:i,error:a}=await F(this.fetch,"POST",n,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:o?.captchaToken}}});return{data:{user:null,session:null,messageId:i?.message_id},error:a}}throw new Zt("You must provide either an email or phone number and a type")}catch(n){if(M(n))return{data:{user:null,session:null},error:n};throw n}}async getSession(){return await this.initializePromise,this._acquireLock(-1,async()=>this._useSession(async e=>e))}async _acquireLock(e,n){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await r,await n()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=n();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const n=await this.__loadSession();return await e(n)}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 n=await Qt(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?e=n:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r)return{data:{session:e},error:null};const{session:s,error:o}=await this._callRefreshToken(e.refresh_token);return o?{data:{session:null},error:o}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await F(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Fe}):await this._useSession(async n=>{var r,s;const{data:o,error:i}=n;if(i)throw i;return await F(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(s=(r=o.session)===null||r===void 0?void 0:r.access_token)!==null&&s!==void 0?s:void 0,xform:Fe})})}catch(n){if(M(n))return{data:{user:null},error:n};throw n}}async updateUser(e,n={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,n))}async _updateUser(e,n={}){try{return await this._useSession(async r=>{const{data:s,error:o}=r;if(o)throw o;if(!s.session)throw new ct;const i=s.session;let a=null,l=null;if(this.flowType==="pkce"&&e.email!=null){const d=at();await Ge(this.storage,`${this.storageKey}-code-verifier`,d),a=await lt(d),l=d===a?"plain":"s256"}const{data:c,error:u}=await F(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:i.access_token,xform:Fe});if(u)throw u;return i.user=c.user,await this._saveSession(i),await this._notifyAllSubscribers("USER_UPDATED",i),{data:{user:i.user},error:null}})}catch(r){if(M(r))return{data:{user:null},error:r};throw r}}_decodeJWT(e){return Jr(e)}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new ct;const n=Date.now()/1e3;let r=n,s=!0,o=null;const i=Jr(e.access_token);if(i.exp&&(r=i.exp,s=r<=n),s){const{session:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!a)return{data:{user:null,session:null},error:null};o=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)throw l;o={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:r-n,expires_at:r},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(n){if(M(n))return{data:{session:null,user:null},error:n};throw n}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async n=>{var r;if(!e){const{data:i,error:a}=n;if(a)throw a;e=(r=i.session)!==null&&r!==void 0?r:void 0}if(!e?.refresh_token)throw new ct;const{session:s,error:o}=await this._callRefreshToken(e.refresh_token);return o?{data:{user:null,session:null},error:o}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(n){if(M(n))return{data:{user:null,session:null},error:n};throw n}}async _getSessionFromURL(e){try{if(!ge())throw new en("No browser detected.");if(this.flowType==="implicit"&&!this._isImplicitGrantFlow())throw new en("Not a valid implicit grant flow url.");if(this.flowType=="pkce"&&!e)throw new Xr("Not a valid PKCE flow url.");const n=jn(window.location.href);if(e){if(!n.code)throw new Xr("No code detected.");const{data:v,error:w}=await this._exchangeCodeForSession(n.code);if(w)throw w;const b=new URL(window.location.href);return b.searchParams.delete("code"),window.history.replaceState(window.history.state,"",b.toString()),{data:{session:v.session,redirectType:null},error:null}}if(n.error||n.error_description||n.error_code)throw new en(n.error_description||"Error in URL with unspecified error_description",{error:n.error||"unspecified_error",code:n.error_code||"unspecified_code"});const{provider_token:r,provider_refresh_token:s,access_token:o,refresh_token:i,expires_in:a,expires_at:l,token_type:c}=n;if(!o||!a||!i||!c)throw new en("No session defined in URL");const u=Math.round(Date.now()/1e3),d=parseInt(a);let f=u+d;l&&(f=parseInt(l));const p=f-u;p*1e3<=At&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${p}s, should have been closer to ${d}s`);const h=f-d;u-h>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",h,f,u):u-h<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clok for skew",h,f,u);const{data:g,error:m}=await this._getUser(o);if(m)throw m;const y={provider_token:r,provider_refresh_token:s,access_token:o,expires_in:d,expires_at:f,refresh_token:i,token_type:c,user:g.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:y,redirectType:n.type},error:null}}catch(n){if(M(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantFlow(){const e=jn(window.location.href);return!!(ge()&&(e.access_token||e.error_description))}async _isPKCEFlow(){const e=jn(window.location.href),n=await Qt(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&n)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async n=>{var r;const{data:s,error:o}=n;if(o)return{error:o};const i=(r=s.session)===null||r===void 0?void 0:r.access_token;if(i){const{error:a}=await this.admin.signOut(i,e);if(a&&!(ul(a)&&(a.status===404||a.status===401)))return{error:a}}return e!=="others"&&(await this._removeSession(),await Fn(this.storage,`${this.storageKey}-code-verifier`),await this._notifyAllSubscribers("SIGNED_OUT",null)),{error:null}})}onAuthStateChange(e){const n=tl(),r={id:n,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",n),this.stateChangeEmitters.delete(n)}};return this._debug("#onAuthStateChange()","registered callback with id",n),this.stateChangeEmitters.set(n,r),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(n)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async n=>{var r,s;try{const{data:{session:o},error:i}=n;if(i)throw i;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",e,"session",o)}catch(o){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",o),console.error(o)}})}async resetPasswordForEmail(e,n={}){let r=null,s=null;if(this.flowType==="pkce"){const o=at();await Ge(this.storage,`${this.storageKey}-code-verifier`,`${o}/PASSWORD_RECOVERY`),r=await lt(o),s=o===r?"plain":"s256"}try{return await F(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(o){if(M(o))return{data:null,error:o};throw o}}async getUserIdentities(){var e;try{const{data:n,error:r}=await this.getUser();if(r)throw r;return{data:{identities:(e=n.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(n){if(M(n))return{data:null,error:n};throw n}}async linkIdentity(e){var n;try{const{data:r,error:s}=await this._useSession(async o=>{var i,a,l,c,u;const{data:d,error:f}=o;if(f)throw f;const p=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(i=e.options)===null||i===void 0?void 0:i.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 F(this.fetch,"GET",p,{headers:this.headers,jwt:(u=(c=d.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(s)throw s;return ge()&&!(!((n=e.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(r?.url),{data:{provider:e.provider,url:r?.url},error:null}}catch(r){if(M(r))return{data:{provider:e.provider,url:null},error:r};throw r}}async unlinkIdentity(e){try{return await this._useSession(async n=>{var r,s;const{data:o,error:i}=n;if(i)throw i;return await F(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(r=o.session)===null||r===void 0?void 0:r.access_token)!==null&&s!==void 0?s:void 0})})}catch(n){if(M(n))return{data:null,error:n};throw n}}async _refreshAccessToken(e){const n=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{const r=Date.now();return await ol(async s=>(await sl(s*200),this._debug(n,"refreshing attempt",s),await F(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Je})),(s,o,i)=>i&&i.error&&Kn(i.error)&&Date.now()+(s+1)*200-r<At)}catch(r){if(this._debug(n,"error",r),M(r))return{data:{session:null,user:null},error:r};throw r}finally{this._debug(n,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,n){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:n.redirectTo,scopes:n.scopes,queryParams:n.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",n,"url",r),ge()&&!n.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e;const n="#_recoverAndRefresh()";this._debug(n,"begin");try{const r=await Qt(this.storage,this.storageKey);if(this._debug(n,"session from storage",r),!this._isValidSession(r)){this._debug(n,"session is not valid"),r!==null&&await this._removeSession();return}const s=Math.round(Date.now()/1e3),o=((e=r.expires_at)!==null&&e!==void 0?e:1/0)<s+Zr;if(this._debug(n,`session has${o?"":" not"} expired with margin of ${Zr}s`),o){if(this.autoRefreshToken&&r.refresh_token){const{error:i}=await this._callRefreshToken(r.refresh_token);i&&(console.error(i),Kn(i)||(this._debug(n,"refresh failed with a non-retryable error, removing the session",i),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",r)}catch(r){this._debug(n,"error",r),console.error(r);return}finally{this._debug(n,"end")}}async _callRefreshToken(e){var n,r;if(!e)throw new ct;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new Tn;const{data:o,error:i}=await this._refreshAccessToken(e);if(i)throw i;if(!o.session)throw new ct;await this._saveSession(o.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",o.session);const a={session:o.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(o){if(this._debug(s,"error",o),M(o)){const i={session:null,error:o};return Kn(o)||(await this._removeSession(),await this._notifyAllSubscribers("SIGNED_OUT",null)),(n=this.refreshingDeferred)===null||n===void 0||n.resolve(i),i}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(o),o}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,n,r=!0){const s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",n,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:n});const o=[],i=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,n)}catch(l){o.push(l)}});if(await Promise.all(i),o.length>0){for(let a=0;a<o.length;a+=1)console.error(o[a]);throw o[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),await Ge(this.storage,this.storageKey,e)}async _removeSession(){this._debug("#_removeSession()"),await Fn(this.storage,this.storageKey)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ge()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(n){console.error("removing visibilitychange callback failed",n)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),At);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async n=>{const{data:{session:r}}=n;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((r.expires_at*1e3-e)/At);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${At}ms, refresh threshold is ${ts} ticks`),s<=ts&&await this._callRefreshToken(r.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof oo)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ge()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const n=`#_onVisibilityChanged(${e})`;this._debug(n,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(n,"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,n,r){const s=[`provider=${encodeURIComponent(n)}`];if(r?.redirectTo&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r?.scopes&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const o=at();await Ge(this.storage,`${this.storageKey}-code-verifier`,o);const i=await lt(o),a=o===i?"plain":"s256";this._debug("PKCE","code verifier",`${o.substring(0,5)}...`,"code challenge",i,"method",a);const l=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(a)}`});s.push(l.toString())}if(r?.queryParams){const o=new URLSearchParams(r.queryParams);s.push(o.toString())}return r?.skipBrowserRedirect&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async n=>{var r;const{data:s,error:o}=n;return o?{data:null,error:o}:await F(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if(M(n))return{data:null,error:n};throw n}}async _enroll(e){try{return await this._useSession(async n=>{var r,s;const{data:o,error:i}=n;if(i)return{data:null,error:i};const{data:a,error:l}=await F(this.fetch,"POST",`${this.url}/factors`,{body:{friendly_name:e.friendlyName,factor_type:e.factorType,issuer:e.issuer},headers:this.headers,jwt:(r=o?.session)===null||r===void 0?void 0:r.access_token});return l?{data:null,error:l}:(!((s=a?.totp)===null||s===void 0)&&s.qr_code&&(a.totp.qr_code=`data:image/svg+xml;utf-8,${a.totp.qr_code}`),{data:a,error:null})})}catch(n){if(M(n))return{data:null,error:n};throw n}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:o}=n;if(o)return{data:null,error:o};const{data:i,error:a}=await F(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+i.expires_in},i)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",i),{data:i,error:a})})}catch(n){if(M(n))return{data:null,error:n};throw n}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:o}=n;return o?{data:null,error:o}:await F(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if(M(n))return{data:null,error:n};throw n}})}async _challengeAndVerify(e){const{data:n,error:r}=await this._challenge({factorId:e.factorId});return r?{data:null,error:r}:await this._verify({factorId:e.factorId,challengeId:n.id,code:e.code})}async _listFactors(){const{data:{user:e},error:n}=await this.getUser();if(n)return{data:null,error:n};const r=e?.factors||[],s=r.filter(o=>o.factor_type==="totp"&&o.status==="verified");return{data:{all:r,totp:s},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var n,r;const{data:{session:s},error:o}=e;if(o)return{data:null,error:o};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const i=this._decodeJWT(s.access_token);let a=null;i.aal&&(a=i.aal);let l=a;((r=(n=s.user.factors)===null||n===void 0?void 0:n.filter(d=>d.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(l="aal2");const u=i.amr||[];return{data:{currentLevel:a,nextLevel:l,currentAuthenticationMethods:u},error:null}}))}}Ut.nextInstanceID=0;class Cl extends Ut{constructor(e){super(e)}}var Ll=function(t,e,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(d){i(d)}}function l(u){try{c(r.throw(u))}catch(d){i(d)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})};class Rl{constructor(e,n,r){var s,o,i,a,l,c,u,d;if(this.supabaseUrl=e,this.supabaseKey=n,!e)throw new Error("supabaseUrl is required.");if(!n)throw new Error("supabaseKey is required.");const f=Qa(e);this.realtimeUrl=`${f}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${f}/auth/v1`,this.storageUrl=`${f}/storage/v1`,this.functionsUrl=`${f}/functions/v1`;const p=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,h={db:Ha,realtime:Wa,auth:Object.assign(Object.assign({},qa),{storageKey:p}),global:Va},g=Za(r??{},h);this.storageKey=(o=(s=g.auth)===null||s===void 0?void 0:s.storageKey)!==null&&o!==void 0?o:"",this.headers=(a=(i=g.global)===null||i===void 0?void 0:i.headers)!==null&&a!==void 0?a:{},this.auth=this._initSupabaseAuthClient((l=g.auth)!==null&&l!==void 0?l:{},this.headers,(c=g.global)===null||c===void 0?void 0:c.fetch),this.fetch=Ya(n,this._getAccessToken.bind(this),(u=g.global)===null||u===void 0?void 0:u.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},g.realtime)),this.rest=new mr(`${f}/rest/v1`,{headers:this.headers,schema:(d=g.db)===null||d===void 0?void 0:d.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new sa(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new Ua(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,n={},r={}){return this.rest.rpc(e,n,r)}channel(e,n={config:{}}){return this.realtime.channel(e,n)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,n;return Ll(this,void 0,void 0,function*(){const{data:r}=yield this.auth.getSession();return(n=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&n!==void 0?n:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:n,detectSessionInUrl:r,storage:s,storageKey:o,flowType:i,debug:a},l,c){const u={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Cl({url:this.authUrl,headers:Object.assign(Object.assign({},u),l),storageKey:o,autoRefreshToken:e,persistSession:n,detectSessionInUrl:r,storage:s,flowType:i,debug:a,fetch:c})}_initRealtimeClient(e){return new Aa(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((n,r)=>{this._handleTokenChanged(n,"CLIENT",r?.access_token)})}_handleTokenChanged(e,n,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==r?(this.realtime.setAuth(r??null),this.changedAccessToken=r):e==="SIGNED_OUT"&&(this.realtime.setAuth(this.supabaseKey),n=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const Il=(t,e,n)=>new Rl(t,e,n),io=ne(),$l=t=>{const[e,n]=A(null),r=t.client;return x(io.Provider,{value:{supabase:r,session:e,setSession:n},get children(){return t.children}})};function wr(){return fe(io)}const ao=ne(),Dl=t=>{const[e,n]=A(null);return x(ao.Provider,{value:{userProfile:e,setUserProfile:n},get children(){return t.children}})};function lo(){return fe(ao)}function co(){let t=new Set;function e(s){return t.add(s),()=>t.delete(s)}let n=!1;function r(s,o){if(n)return!(n=!1);const i={to:s,options:o,defaultPrevented:!1,preventDefault:()=>i.defaultPrevented=!0};for(const a of t)a.listener({...i,from:a.location,retry:l=>{l&&(n=!0),a.navigate(s,{...o,resolve:!1})}});return!i.defaultPrevented}return{subscribe:e,confirm:r}}let tr;function _r(){(!window.history.state||window.history.state._depth==null)&&window.history.replaceState({...window.history.state,_depth:window.history.length-1},""),tr=window.history.state._depth}_r();function Ml(t){return{...t,_depth:window.history.state&&window.history.state._depth}}function jl(t,e){let n=!1;return()=>{const r=tr;_r();const s=r==null?null:tr-r;if(n){n=!1;return}s&&e(s)?(n=!0,window.history.go(-s)):t()}}const Fl=/^(?:[a-z0-9]+:)?\/\//i,Nl=/^\/+|(\/)\/+$/g,uo="http://sr";function Nt(t,e=!1){const n=t.replace(Nl,"$1");return n?e||/^[?#]/.test(n)?n:"/"+n:""}function ln(t,e,n){if(Fl.test(e))return;const r=Nt(t),s=n&&Nt(n);let o="";return!s||e.startsWith("/")?o=r:s.toLowerCase().indexOf(r.toLowerCase())!==0?o=r+s:o=s,(o||"/")+Nt(e,!o)}function Kl(t,e){if(t==null)throw new Error(e);return t}function Ul(t,e){return Nt(t).replace(/\/*(\*.*)?$/g,"")+Nt(e)}function fo(t){const e={};return t.searchParams.forEach((n,r)=>{e[r]=n}),e}function Bl(t,e,n){const[r,s]=t.split("/*",2),o=r.split("/").filter(Boolean),i=o.length;return a=>{const l=a.split("/").filter(Boolean),c=l.length-i;if(c<0||c>0&&s===void 0&&!e)return null;const u={path:i?"":"/",params:{}},d=f=>n===void 0?void 0:n[f];for(let f=0;f<i;f++){const p=o[f],h=l[f],g=p[0]===":",m=g?p.slice(1):p;if(g&&Un(h,d(m)))u.params[m]=h;else if(g||!Un(h,p))return null;u.path+=`/${h}`}if(s){const f=c?l.slice(-c).join("/"):"";if(Un(f,d(s)))u.params[s]=f;else return null}return u}}function Un(t,e){const n=r=>r.localeCompare(t,void 0,{sensitivity:"base"})===0;return e===void 0?!0:typeof e=="string"?n(e):typeof e=="function"?e(t):Array.isArray(e)?e.some(n):e instanceof RegExp?e.test(t):!1}function zl(t){const[e,n]=t.pattern.split("/*",2),r=e.split("/").filter(Boolean);return r.reduce((s,o)=>s+(o.startsWith(":")?2:3),r.length-(n===void 0?0:1))}function ho(t){const e=new Map,n=dn();return new Proxy({},{get(r,s){return e.has(s)||fr(n,()=>e.set(s,O(()=>t()[s]))),e.get(s)()},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}},ownKeys(){return Reflect.ownKeys(t())}})}function Vl(t,e){const n=new URLSearchParams(t);Object.entries(e).forEach(([s,o])=>{o==null||o===""?n.delete(s):n.set(s,String(o))});const r=n.toString();return r?`?${r}`:""}function go(t){let e=/(\/?\:[^\/]+)\?/.exec(t);if(!e)return[t];let n=t.slice(0,e.index),r=t.slice(e.index+e[0].length);const s=[n,n+=e[1]];for(;e=/^(\/\:[^\/]+)\?/.exec(r);)s.push(n+=e[1]),r=r.slice(e[0].length);return go(r).reduce((o,i)=>[...o,...s.map(a=>a+i)],[])}const Hl=100,po=ne(),mo=ne(),yo=()=>Kl(fe(po),"<A> and 'use' router primitives can be only used inside a Route."),xr=()=>yo().navigatorFactory(),ql=()=>yo().location,xh=()=>{const t=ql(),e=xr(),n=(r,s)=>{const o=G(()=>t.pathname+Vl(t.search,r)+t.hash);e(o,{scroll:!1,resolve:!1,...s})};return[t.query,n]};function Wl(t,e=""){const{component:n,load:r,children:s,info:o}=t,i=!s||Array.isArray(s)&&!s.length,a={key:t,component:n,load:r,info:o};return vo(t.path).reduce((l,c)=>{for(const u of go(c)){const d=Ul(e,u);let f=i?d:d.split("/*",1)[0];f=f.split("/").map(p=>p.startsWith(":")||p.startsWith("*")?p:encodeURIComponent(p)).join("/"),l.push({...a,originalPath:u,pattern:f,matcher:Bl(f,!i,t.matchFilters)})}return l},[])}function Gl(t,e=0){return{routes:t,score:zl(t[t.length-1])*1e4-e,matcher(n){const r=[];for(let s=t.length-1;s>=0;s--){const o=t[s],i=o.matcher(n);if(!i)return null;r.unshift({...i,route:o})}return r}}}function vo(t){return Array.isArray(t)?t:[t]}function bo(t,e="",n=[],r=[]){const s=vo(t);for(let o=0,i=s.length;o<i;o++){const a=s[o];if(a&&typeof a=="object"){a.hasOwnProperty("path")||(a.path="");const l=Wl(a,e);for(const c of l){n.push(c);const u=Array.isArray(a.children)&&a.children.length===0;if(a.children&&!u)bo(a.children,c.pattern,n,r);else{const d=Gl([...n],r.length);r.push(d)}n.pop()}}}return n.length?r:r.sort((o,i)=>i.score-o.score)}function rs(t,e){for(let n=0,r=t.length;n<r;n++){const s=t[n].matcher(e);if(s)return s}return[]}function Jl(t,e){const n=new URL(uo),r=O(l=>{const c=t();try{return new URL(c,n)}catch{return console.error(`Invalid path ${c}`),l}},n,{equals:(l,c)=>l.href===c.href}),s=O(()=>r().pathname),o=O(()=>r().search,!0),i=O(()=>r().hash),a=()=>"";return{get pathname(){return s()},get search(){return o()},get hash(){return i()},get state(){return e()},get key(){return a()},query:ho(xe(o,()=>fo(r())))}}let Me;function Xl(t,e,n,r={}){const{signal:[s,o],utils:i={}}=t,a=i.parsePath||(E=>E),l=i.renderPath||(E=>E),c=i.beforeLeave||co(),u=ln("",r.base||"");if(u===void 0)throw new Error(`${u} is not a valid base path`);u&&!s().value&&o({value:u,replace:!0,scroll:!1});const[d,f]=A(!1),p=async E=>{f(!0);try{await mi(E)}finally{f(!1)}},[h,g]=A(s().value),[m,y]=A(s().state),v=Jl(h,m),w=[],b=A([]),k=O(()=>rs(e(),v.pathname)),T=ho(()=>{const E=k(),j={};for(let K=0;K<E.length;K++)Object.assign(j,E[K].params);return j}),S={pattern:u,path:()=>u,outlet:()=>null,resolvePath(E){return ln(u,E)}};return _e(()=>{const{value:E,state:j}=s();G(()=>{E!==h()&&p(()=>{Me="native",g(E),y(j),b[1]([])}).then(()=>{Me=void 0})})}),{base:S,location:v,params:T,isRouting:d,renderPath:l,parsePath:a,navigatorFactory:P,matches:k,beforeLeave:c,preloadRoute:L,singleFlight:r.singleFlight===void 0?!0:r.singleFlight,submissions:b};function C(E,j,K){G(()=>{if(typeof j=="number"){j&&(i.go?i.go(j):console.warn("Router integration does not support relative routing"));return}const{replace:Y,resolve:X,scroll:W,state:re}={replace:!1,resolve:!0,scroll:!0,...K},Q=X?E.resolvePath(j):ln("",j);if(Q===void 0)throw new Error(`Path '${j}' is not a routable path`);if(w.length>=Hl)throw new Error("Too many redirects");const qe=h();if((Q!==qe||re!==m())&&!Gi){if(c.confirm(Q,K)){const Te=w.push({value:qe,replace:Y,scroll:W,state:m()});p(()=>{Me="navigate",g(Q),y(re),b[1]([])}).then(()=>{w.length===Te&&(Me=void 0,D({value:Q,state:re}))})}}})}function P(E){return E=E||fe(mo)||S,(j,K)=>C(E,j,K)}function D(E){const j=w[0];j&&((E.value!==j.value||E.state!==j.state)&&o({...E,replace:j.replace,scroll:j.scroll}),w.length=0)}function L(E,j){const K=rs(e(),E.pathname),Y=Me;Me="preload";for(let X in K){const{route:W,params:re}=K[X];W.component&&W.component.preload&&W.component.preload();const{load:Q}=W;j&&Q&&fr(n(),()=>Q({params:re,location:{pathname:E.pathname,search:E.search,hash:E.hash,query:fo(E),state:null,key:""},intent:"preload"}))}Me=Y}}function Yl(t,e,n,r){const{base:s,location:o,params:i}=t,{pattern:a,component:l,load:c}=r().route,u=O(()=>r().path);l&&l.preload&&l.preload();const d=c?c({params:i,location:o,intent:Me||"initial"}):void 0;return{parent:e,pattern:a,path:u,outlet:()=>l?x(l,{params:i,location:o,data:d,get children(){return n()}}):n(),resolvePath(p){return ln(s.path(),p,u())}}}const Ql=t=>e=>{const{base:n}=e,r=qt(()=>e.children),s=O(()=>bo(r(),e.base||""));let o;const i=Xl(t,s,()=>o,{base:n,singleFlight:e.singleFlight});return t.create&&t.create(i),x(po.Provider,{value:i,get children(){return x(Zl,{routerState:i,get root(){return e.root},get load(){return e.rootLoad},get children(){return[O(()=>(o=dn())&&null),x(ec,{routerState:i,get branches(){return s()}})]}})}})};function Zl(t){const e=t.routerState.location,n=t.routerState.params,r=O(()=>t.load&&G(()=>t.load({params:n,location:e,intent:"preload"})));return x(Ze,{get when(){return t.root},keyed:!0,get fallback(){return t.children},children:s=>x(s,{params:n,location:e,get data(){return r()},get children(){return t.children}})})}function ec(t){const e=[];let n;const r=O(xe(t.routerState.matches,(s,o,i)=>{let a=o&&s.length===o.length;const l=[];for(let c=0,u=s.length;c<u;c++){const d=o&&o[c],f=s[c];i&&d&&f.route.key===d.route.key?l[c]=i[c]:(a=!1,e[c]&&e[c](),pt(p=>{e[c]=p,l[c]=Yl(t.routerState,l[c-1]||t.routerState.base,ss(()=>r()[c+1]),()=>t.routerState.matches()[c])}))}return e.splice(s.length).forEach(c=>c()),i&&a?i:(n=l[0],l)}));return ss(()=>r()&&n)()}const ss=t=>()=>x(Ze,{get when(){return t()},keyed:!0,children:e=>x(mo.Provider,{value:e,get children(){return e.outlet()}})}),pn=t=>{const e=qt(()=>t.children);return B(t,{get children(){return e()}})};function tc([t,e],n,r){return[n?()=>n(t()):t,r?s=>e(r(s)):e]}function nc(t){if(t==="#")return null;try{return document.querySelector(t)}catch{return null}}function rc(t){let e=!1;const n=s=>typeof s=="string"?{value:s}:s,r=tc(A(n(t.get()),{equals:(s,o)=>s.value===o.value}),void 0,s=>(!e&&t.set(s),s));return t.init&&z(t.init((s=t.get())=>{e=!0,r[1](n(s)),e=!1})),Ql({signal:r,create:t.create,utils:t.utils})}function sc(t,e,n){return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}function oc(t,e){const n=nc(`#${t}`);n?n.scrollIntoView():e&&window.scrollTo(0,0)}const ic=new Map;function ac(t=!0,e=!1,n="/_server"){return r=>{const s=r.base.path(),o=r.navigatorFactory(r.base);let i={};function a(h){return h.namespaceURI==="http://www.w3.org/2000/svg"}function l(h){if(h.defaultPrevented||h.button!==0||h.metaKey||h.altKey||h.ctrlKey||h.shiftKey)return;const g=h.composedPath().find(k=>k instanceof Node&&k.nodeName.toUpperCase()==="A");if(!g||e&&!g.hasAttribute("link"))return;const m=a(g),y=m?g.href.baseVal:g.href;if((m?g.target.baseVal:g.target)||!y&&!g.hasAttribute("state"))return;const w=(g.getAttribute("rel")||"").split(/\s+/);if(g.hasAttribute("download")||w&&w.includes("external"))return;const b=m?new URL(y,document.baseURI):new URL(y);if(!(b.origin!==window.location.origin||s&&b.pathname&&!b.pathname.toLowerCase().startsWith(s.toLowerCase())))return[g,b]}function c(h){const g=l(h);if(!g)return;const[m,y]=g,v=r.parsePath(y.pathname+y.search+y.hash),w=m.getAttribute("state");h.preventDefault(),o(v,{resolve:!1,replace:m.hasAttribute("replace"),scroll:!m.hasAttribute("noscroll"),state:w&&JSON.parse(w)})}function u(h){const g=l(h);if(!g)return;const[m,y]=g;i[y.pathname]||r.preloadRoute(y,m.getAttribute("preload")!=="false")}function d(h){const g=l(h);if(!g)return;const[m,y]=g;i[y.pathname]||(i[y.pathname]=setTimeout(()=>{r.preloadRoute(y,m.getAttribute("preload")!=="false"),delete i[y.pathname]},200))}function f(h){const g=l(h);if(!g)return;const[,m]=g;i[m.pathname]&&(clearTimeout(i[m.pathname]),delete i[m.pathname])}function p(h){let g=h.submitter&&h.submitter.hasAttribute("formaction")?h.submitter.getAttribute("formaction"):h.target.getAttribute("action");if(!g)return;if(!g.startsWith("https://action/")){const y=new URL(g,uo);if(g=r.parsePath(y.pathname+y.search),!g.startsWith(n))return}if(h.target.method.toUpperCase()!=="POST")throw new Error("Only POST forms are supported for Actions");const m=ic.get(g);if(m){h.preventDefault();const y=new FormData(h.target);h.submitter&&h.submitter.name&&y.append(h.submitter.name,h.submitter.value),m.call({r,f:h.target},y)}}Gs(["click","submit"]),document.addEventListener("click",c),t&&(document.addEventListener("mouseover",d),document.addEventListener("mouseout",f),document.addEventListener("focusin",u),document.addEventListener("touchstart",u)),document.addEventListener("submit",p),z(()=>{document.removeEventListener("click",c),t&&(document.removeEventListener("mouseover",d),document.removeEventListener("mouseout",f),document.removeEventListener("focusin",u),document.removeEventListener("touchstart",u)),document.removeEventListener("submit",p)})}}function lc(t){const e=()=>({value:window.location.pathname+window.location.search+window.location.hash,state:window.history.state}),n=co();return rc({get:e,set({value:r,replace:s,scroll:o,state:i}){s?window.history.replaceState(Ml(i),"",r):window.history.pushState(i,"",r),oc(window.location.hash.slice(1),o),_r()},init:r=>sc(window,"popstate",jl(r,s=>{if(s&&s<0)return!n.confirm(s);{const o=e();return!n.confirm(o.value,{state:o.state})}})),create:ac(t.preload,t.explicitLinks,t.actionBase),utils:{go:r=>window.history.go(r),beforeLeave:n}})(t)}function wo(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t))for(e=0;e<t.length;e++)t[e]&&(n=wo(t[e]))&&(r&&(r+=" "),r+=n);else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function cc(){for(var t,e,n=0,r="";n<arguments.length;)(t=arguments[n++])&&(e=wo(t))&&(r&&(r+=" "),r+=e);return r}const os=t=>typeof t=="boolean"?"".concat(t):t===0?"0":t,is=cc,uc=(t,e)=>n=>{var r;if(e?.variants==null)return is(t,n?.class,n?.className);const{variants:s,defaultVariants:o}=e,i=Object.keys(s).map(c=>{const u=n?.[c],d=o?.[c];if(u===null)return null;const f=os(u)||os(d);return s[c][f]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...p}=u;return Object.entries(p).every(h=>{let[g,m]=h;return Array.isArray(m)?m.includes({...o,...a}[g]):{...o,...a}[g]===m})?[...c,d,f]:c},[]);return is(t,i,l,n?.class,n?.className)};function _o(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(n=_o(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function dc(){for(var t,e,n=0,r="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=_o(t))&&(r&&(r+=" "),r+=e);return r}const Sr="-";function fc(t){const e=gc(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;function s(i){const a=i.split(Sr);return a[0]===""&&a.length!==1&&a.shift(),xo(a,e)||hc(i)}function o(i,a){const l=n[i]||[];return a&&r[i]?[...l,...r[i]]:l}return{getClassGroupId:s,getConflictingClassGroupIds:o}}function xo(t,e){if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),s=r?xo(t.slice(1),r):void 0;if(s)return s;if(e.validators.length===0)return;const o=t.join(Sr);return e.validators.find(({validator:i})=>i(o))?.classGroupId}const as=/^\[(.+)\]$/;function hc(t){if(as.test(t)){const e=as.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}}function gc(t){const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return mc(Object.entries(t.classGroups),n).forEach(([o,i])=>{nr(i,r,o,e)}),r}function nr(t,e,n,r){t.forEach(s=>{if(typeof s=="string"){const o=s===""?e:ls(e,s);o.classGroupId=n;return}if(typeof s=="function"){if(pc(s)){nr(s(r),e,n,r);return}e.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(([o,i])=>{nr(i,ls(e,o),n,r)})})}function ls(t,e){let n=t;return e.split(Sr).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n}function pc(t){return t.isThemeGetter}function mc(t,e){return e?t.map(([n,r])=>{const s=r.map(o=>typeof o=="string"?e+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([i,a])=>[e+i,a])):o);return[n,s]}):t}function yc(t){if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;function s(o,i){n.set(o,i),e++,e>t&&(e=0,r=n,n=new Map)}return{get(o){let i=n.get(o);if(i!==void 0)return i;if((i=r.get(o))!==void 0)return s(o,i),i},set(o,i){n.has(o)?n.set(o,i):s(o,i)}}}const So="!";function vc(t){const e=t.separator,n=e.length===1,r=e[0],s=e.length;return function(i){const a=[];let l=0,c=0,u;for(let g=0;g<i.length;g++){let m=i[g];if(l===0){if(m===r&&(n||i.slice(g,g+s)===e)){a.push(i.slice(c,g)),c=g+s;continue}if(m==="/"){u=g;continue}}m==="["?l++:m==="]"&&l--}const d=a.length===0?i:i.substring(c),f=d.startsWith(So),p=f?d.substring(1):d,h=u&&u>c?u-c:void 0;return{modifiers:a,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:h}}}function bc(t){if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e}function wc(t){return{cache:yc(t.cacheSize),splitModifiers:vc(t),...fc(t)}}const _c=/\s+/;function xc(t,e){const{splitModifiers:n,getClassGroupId:r,getConflictingClassGroupIds:s}=e,o=new Set;return t.trim().split(_c).map(i=>{const{modifiers:a,hasImportantModifier:l,baseClassName:c,maybePostfixModifierPosition:u}=n(i);let d=r(u?c.substring(0,u):c),f=!!u;if(!d){if(!u)return{isTailwindClass:!1,originalClassName:i};if(d=r(c),!d)return{isTailwindClass:!1,originalClassName:i};f=!1}const p=bc(a).join(":");return{isTailwindClass:!0,modifierId:l?p+So:p,classGroupId:d,originalClassName:i,hasPostfixModifier:f}}).reverse().filter(i=>{if(!i.isTailwindClass)return!0;const{modifierId:a,classGroupId:l,hasPostfixModifier:c}=i,u=a+l;return o.has(u)?!1:(o.add(u),s(l,c).forEach(d=>o.add(a+d)),!0)}).reverse().map(i=>i.originalClassName).join(" ")}function Sc(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=Eo(e))&&(r&&(r+=" "),r+=n);return r}function Eo(t){if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=Eo(t[r]))&&(n&&(n+=" "),n+=e);return n}function Ec(t,...e){let n,r,s,o=i;function i(l){const c=e.reduce((u,d)=>d(u),t());return n=wc(c),r=n.cache.get,s=n.cache.set,o=a,a(l)}function a(l){const c=r(l);if(c)return c;const u=xc(l,n);return s(l,u),u}return function(){return o(Sc.apply(null,arguments))}}function q(t){const e=n=>n[t]||[];return e.isThemeGetter=!0,e}const ko=/^\[(?:([a-z-]+):)?(.+)\]$/i,kc=/^\d+\/\d+$/,Tc=new Set(["px","full","screen"]),Pc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ac=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Oc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Cc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Lc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/;function Pe(t){return Ye(t)||Tc.has(t)||kc.test(t)}function $e(t){return Et(t,"length",Nc)}function Ye(t){return!!t&&!Number.isNaN(Number(t))}function tn(t){return Et(t,"number",Ye)}function Ot(t){return!!t&&Number.isInteger(Number(t))}function Rc(t){return t.endsWith("%")&&Ye(t.slice(0,-1))}function R(t){return ko.test(t)}function De(t){return Pc.test(t)}const Ic=new Set(["length","size","percentage"]);function $c(t){return Et(t,Ic,To)}function Dc(t){return Et(t,"position",To)}const Mc=new Set(["image","url"]);function jc(t){return Et(t,Mc,Uc)}function Fc(t){return Et(t,"",Kc)}function Ct(){return!0}function Et(t,e,n){const r=ko.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1}function Nc(t){return Ac.test(t)&&!Oc.test(t)}function To(){return!1}function Kc(t){return Cc.test(t)}function Uc(t){return Lc.test(t)}function Bc(){const t=q("colors"),e=q("spacing"),n=q("blur"),r=q("brightness"),s=q("borderColor"),o=q("borderRadius"),i=q("borderSpacing"),a=q("borderWidth"),l=q("contrast"),c=q("grayscale"),u=q("hueRotate"),d=q("invert"),f=q("gap"),p=q("gradientColorStops"),h=q("gradientColorStopPositions"),g=q("inset"),m=q("margin"),y=q("opacity"),v=q("padding"),w=q("saturate"),b=q("scale"),k=q("sepia"),T=q("skew"),S=q("space"),C=q("translate"),P=()=>["auto","contain","none"],D=()=>["auto","hidden","clip","visible","scroll"],L=()=>["auto",R,e],E=()=>[R,e],j=()=>["",Pe,$e],K=()=>["auto",Ye,R],Y=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],X=()=>["solid","dashed","dotted","double","none"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter"],re=()=>["start","end","center","between","around","evenly","stretch"],Q=()=>["","0",R],qe=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Te=()=>[Ye,tn],st=()=>[Ye,R];return{cacheSize:500,separator:":",theme:{colors:[Ct],spacing:[Pe,$e],blur:["none","",De,R],brightness:Te(),borderColor:[t],borderRadius:["none","","full",De,R],borderSpacing:E(),borderWidth:j(),contrast:Te(),grayscale:Q(),hueRotate:st(),invert:Q(),gap:E(),gradientColorStops:[t],gradientColorStopPositions:[Rc,$e],inset:L(),margin:L(),opacity:Te(),padding:E(),saturate:Te(),scale:Te(),sepia:Q(),skew:st(),space:E(),translate:E()},classGroups:{aspect:[{aspect:["auto","square","video",R]}],container:["container"],columns:[{columns:[De]}],"break-after":[{"break-after":qe()}],"break-before":[{"break-before":qe()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Y(),R]}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Ot,R]}],basis:[{basis:L()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",R]}],grow:[{grow:Q()}],shrink:[{shrink:Q()}],order:[{order:["first","last","none",Ot,R]}],"grid-cols":[{"grid-cols":[Ct]}],"col-start-end":[{col:["auto",{span:["full",Ot,R]},R]}],"col-start":[{"col-start":K()}],"col-end":[{"col-end":K()}],"grid-rows":[{"grid-rows":[Ct]}],"row-start-end":[{row:["auto",{span:[Ot,R]},R]}],"row-start":[{"row-start":K()}],"row-end":[{"row-end":K()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",R]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",R]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...re()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...re(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...re(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[m]}],mx:[{mx:[m]}],my:[{my:[m]}],ms:[{ms:[m]}],me:[{me:[m]}],mt:[{mt:[m]}],mr:[{mr:[m]}],mb:[{mb:[m]}],ml:[{ml:[m]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",R,e]}],"min-w":[{"min-w":[R,e,"min","max","fit"]}],"max-w":[{"max-w":[R,e,"none","full","min","max","fit","prose",{screen:[De]},De]}],h:[{h:[R,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[R,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[R,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[R,e,"auto","min","max","fit"]}],"font-size":[{text:["base",De,$e]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",tn]}],"font-family":[{font:[Ct]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",R]}],"line-clamp":[{"line-clamp":["none",Ye,tn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Pe,R]}],"list-image":[{"list-image":["none",R]}],"list-style-type":[{list:["none","disc","decimal",R]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[y]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...X(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Pe,$e]}],"underline-offset":[{"underline-offset":["auto",Pe,R]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:E()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",R]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",R]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[y]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Y(),Dc]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",$c]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},jc]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[y]}],"border-style":[{border:[...X(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[y]}],"divide-style":[{divide:X()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:["",...X()]}],"outline-offset":[{"outline-offset":[Pe,R]}],"outline-w":[{outline:[Pe,$e]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:j()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[y]}],"ring-offset-w":[{"ring-offset":[Pe,$e]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",De,Fc]}],"shadow-color":[{shadow:[Ct]}],opacity:[{opacity:[y]}],"mix-blend":[{"mix-blend":W()}],"bg-blend":[{"bg-blend":W()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",De,R]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[w]}],sepia:[{sepia:[k]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[y]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[k]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",R]}],duration:[{duration:st()}],ease:[{ease:["linear","in","out","in-out",R]}],delay:[{delay:st()}],animate:[{animate:["none","spin","ping","pulse","bounce",R]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[Ot,R]}],"translate-x":[{"translate-x":[C]}],"translate-y":[{"translate-y":[C]}],"skew-x":[{"skew-x":[T]}],"skew-y":[{"skew-y":[T]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",R]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",R]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",R]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Pe,$e,tn]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}const zc=Ec(Bc);function ze(...t){return zc(dc(t))}var Vc=et("<button>");const Hc=uc("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Po=t=>{const[,e]=J(t,["variant","size","class"]);return(()=>{var n=Vc();return En(n,B({get class(){return ze(Hc({variant:t.variant,size:t.size}),t.class)}},e),!1,!1),n})()};var qc=et('<nav class="ml-auto flex items-center gap-4 sm:gap-6"><a href=#features target=_self class="text-sm font-medium hover:underline underline-offset-4">Features</a><a href=#testimonials target=_self class="text-sm font-medium hover:underline underline-offset-4">Testimonials</a><a href=#pricing target=_self class="text-sm font-medium hover:underline underline-offset-4">Pricing');const Wc=()=>{const t=xr();return(()=>{var e=qc(),n=e.firstChild,r=n.nextSibling;return r.nextSibling,Oe(e,x(Po,{variant:"secondary",onClick:()=>t("/open"),children:"Open"}),null),e})()};function Ao(t){return(...e)=>{for(const n of t)n&&n(...e)}}function Gc(t){return(...e)=>{for(let n=t.length-1;n>=0;n--){const r=t[n];r&&r(...e)}}}var _=t=>typeof t=="function"&&!t.length?t():t,cs=t=>Array.isArray(t)?t:t?[t]:[];function Jc(t,...e){return typeof t=="function"?t(...e):t}var Xc=z;function Yc(t,e,n,r){return t.addEventListener(e,n,r),Xc(t.removeEventListener.bind(t,e,n,r))}function Qc(t,e,n,r){const s=()=>{cs(_(t)).forEach(o=>{o&&cs(_(e)).forEach(i=>Yc(o,i,n,r))})};typeof t=="function"?I(s):_e(s)}function nn(){return!0}var Zc={get(t,e,n){return e===Kt?n:t.get(e)},has(t,e){return t.has(e)},set:nn,deleteProperty:nn,getOwnPropertyDescriptor(t,e){return{configurable:!0,enumerable:!0,get(){return t.get(e)},set:nn,deleteProperty:nn}},ownKeys(t){return t.keys()}},eu=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function us(t){const e={};let n;for(;n=eu.exec(t);)e[n[1]]=n[2];return e}function tu(t,e){if(typeof t=="string"){if(typeof e=="string")return`${t};${e}`;t=us(t)}else typeof e=="string"&&(e=us(e));return{...t,...e}}var Bn=(t,e,n)=>{let r;for(const s of t){const o=_(s)[e];r?o&&(r=n(r,o)):r=o}return r};function nu(...t){const e=Array.isArray(t[0]),n=e?t[0]:t;if(n.length===1)return n[0];const r=e&&t[1]?.reverseEventHandlers?Gc:Ao,s={};for(const i of n){const a=_(i);for(const l in a)if(l[0]==="o"&&l[1]==="n"&&l[2]){const c=a[l],u=l.toLowerCase(),d=typeof c=="function"?c:Array.isArray(c)?c.length===1?c[0]:c[0].bind(void 0,c[1]):void 0;d?s[u]?s[u].push(d):s[u]=[d]:delete s[u]}}const o=B(...n);return new Proxy({get(i){if(typeof i!="string")return Reflect.get(o,i);if(i==="style")return Bn(n,"style",tu);if(i==="ref"){const a=[];for(const l of n){const c=_(l)[i];typeof c=="function"&&a.push(c)}return r(a)}if(i[0]==="o"&&i[1]==="n"&&i[2]){const a=s[i.toLowerCase()];return a?r(a):Reflect.get(o,i)}return i==="class"||i==="className"?Bn(n,i,(a,l)=>`${a} ${l}`):i==="classList"?Bn(n,i,(a,l)=>({...a,...l})):Reflect.get(o,i)},has(i){return Reflect.has(o,i)},keys(){return Object.keys(o)}},Zc)}function Ve(...t){return Ao(t)}function ru(t,e,n=-1){return n in t?[...t.slice(0,n),e,...t.slice(n)]:[...t,e]}function rr(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function su(t){return typeof t=="number"}function ou(t){return Array.isArray(t)}function ht(t){return Object.prototype.toString.call(t)==="[object String]"}function iu(t){return typeof t=="function"}function Er(t){return e=>`${t()}-${e}`}function we(t,e){return t?t===e||t.contains(e):!1}function Dt(t,e=!1){const{activeElement:n}=Ce(t);if(!n?.nodeName)return null;if(Oo(n)&&n.contentDocument)return Dt(n.contentDocument.body,e);if(e){const r=n.getAttribute("aria-activedescendant");if(r){const s=Ce(n).getElementById(r);if(s)return s}}return n}function Ce(t){return t?t.ownerDocument||t:document}function Oo(t){return t.tagName==="IFRAME"}var Co=(t=>(t.Escape="Escape",t.Enter="Enter",t.Tab="Tab",t.Space=" ",t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.ArrowUp="ArrowUp",t.End="End",t.Home="Home",t.PageDown="PageDown",t.PageUp="PageUp",t))(Co||{});function kr(t){return typeof window<"u"&&window.navigator!=null?t.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function Pn(){return kr(/^Mac/i)}function au(){return kr(/^iPhone/i)}function lu(){return kr(/^iPad/i)||Pn()&&navigator.maxTouchPoints>1}function cu(){return au()||lu()}function uu(){return Pn()||cu()}function ae(t,e){return e&&(iu(e)?e(t):e[0](e[1],t)),t?.defaultPrevented}function de(t){return e=>{for(const n of t)ae(e,n)}}function du(t){return Pn()?t.metaKey&&!t.ctrlKey:t.ctrlKey&&!t.metaKey}function te(t){if(t)if(fu())t.focus({preventScroll:!0});else{const e=hu(t);t.focus(),gu(e)}}var rn=null;function fu(){if(rn==null){rn=!1;try{document.createElement("div").focus({get preventScroll(){return rn=!0,!0}})}catch{}}return rn}function hu(t){let e=t.parentNode;const n=[],r=document.scrollingElement||document.documentElement;for(;e instanceof HTMLElement&&e!==r;)(e.offsetHeight<e.scrollHeight||e.offsetWidth<e.scrollWidth)&&n.push({element:e,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft}),e=e.parentNode;return r instanceof HTMLElement&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),n}function gu(t){for(const{element:e,scrollTop:n,scrollLeft:r}of t)e.scrollTop=n,e.scrollLeft=r}var Lo=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],pu=[...Lo,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Tr=Lo.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])",mu=pu.join(':not([hidden]):not([tabindex="-1"]),');function Ro(t,e){const r=Array.from(t.querySelectorAll(Tr)).filter(ds);return e&&ds(t)&&r.unshift(t),r.forEach((s,o)=>{if(Oo(s)&&s.contentDocument){const i=s.contentDocument.body,a=Ro(i,!1);r.splice(o,1,...a)}}),r}function ds(t){return Io(t)&&!yu(t)}function Io(t){return t.matches(Tr)&&Pr(t)}function yu(t){return parseInt(t.getAttribute("tabindex")||"0",10)<0}function Pr(t,e){return t.nodeName!=="#comment"&&vu(t)&&bu(t,e)&&(!t.parentElement||Pr(t.parentElement,t))}function vu(t){if(!(t instanceof HTMLElement)&&!(t instanceof SVGElement))return!1;const{display:e,visibility:n}=t.style;let r=e!=="none"&&n!=="hidden"&&n!=="collapse";if(r){if(!t.ownerDocument.defaultView)return r;const{getComputedStyle:s}=t.ownerDocument.defaultView,{display:o,visibility:i}=s(t);r=o!=="none"&&i!=="hidden"&&i!=="collapse"}return r}function bu(t,e){return!t.hasAttribute("hidden")&&(t.nodeName==="DETAILS"&&e&&e.nodeName!=="SUMMARY"?t.hasAttribute("open"):!0)}function wu(t,e){return e.some(n=>n.contains(t))}function _u(t,e,n){const r=e?.tabbable?mu:Tr,s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode(o){return e?.from?.contains(o)?NodeFilter.FILTER_REJECT:o.matches(r)&&Pr(o)&&(!n||wu(o,n))&&(!e?.accept||e.accept(o))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return e?.from&&(s.currentNode=e.from),s}function fs(t){for(;t&&!xu(t);)t=t.parentElement;return t||document.scrollingElement||document.documentElement}function xu(t){const e=window.getComputedStyle(t);return/(auto|scroll)/.test(e.overflow+e.overflowX+e.overflowY)}function Su(){}function Eu(t,e){const[n,r]=t;let s=!1;const o=e.length;for(let i=o,a=0,l=i-1;a<i;l=a++){const[c,u]=e[a],[d,f]=e[l],[,p]=e[l===0?i-1:l-1]||[0,0],h=(u-f)*(n-c)-(c-d)*(r-u);if(f<u){if(r>=f&&r<u){if(h===0)return!0;h>0&&(r===f?r>p&&(s=!s):s=!s)}}else if(u<f){if(r>u&&r<=f){if(h===0)return!0;h<0&&(r===f?r<p&&(s=!s):s=!s)}}else if(r==u&&(n>=d&&n<=c||n>=c&&n<=d))return!0}return s}function he(t,e){return B(t,e)}var Lt=new Map,hs=new Set;function gs(){if(typeof window>"u")return;const t=n=>{if(!n.target)return;let r=Lt.get(n.target);r||(r=new Set,Lt.set(n.target,r),n.target.addEventListener("transitioncancel",e)),r.add(n.propertyName)},e=n=>{if(!n.target)return;const r=Lt.get(n.target);if(r&&(r.delete(n.propertyName),r.size===0&&(n.target.removeEventListener("transitioncancel",e),Lt.delete(n.target)),Lt.size===0)){for(const s of hs)s();hs.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",e)}typeof document<"u"&&(document.readyState!=="loading"?gs():document.addEventListener("DOMContentLoaded",gs));function sr(t,e){const n=ps(t,e,"left"),r=ps(t,e,"top"),s=e.offsetWidth,o=e.offsetHeight;let i=t.scrollLeft,a=t.scrollTop;const l=i+t.offsetWidth,c=a+t.offsetHeight;n<=i?i=n:n+s>l&&(i+=n+s-l),r<=a?a=r:r+o>c&&(a+=r+o-c),t.scrollLeft=i,t.scrollTop=a}function ps(t,e,n){const r=n==="left"?"offsetLeft":"offsetTop";let s=0;for(;e.offsetParent&&(s+=e[r],e.offsetParent!==t);){if(e.offsetParent.contains(t)){s-=t[r];break}e=e.offsetParent}return s}function ku(t,e){if(document.contains(t)){const n=document.scrollingElement||document.documentElement;if(window.getComputedStyle(n).overflow==="hidden"){let s=fs(t);for(;t&&s&&t!==n&&s!==n;)sr(s,t),t=s,s=fs(t)}else{const{left:s,top:o}=t.getBoundingClientRect();t?.scrollIntoView?.({block:"nearest"});const{left:i,top:a}=t.getBoundingClientRect();(Math.abs(s-i)>1||Math.abs(o-a)>1)&&(e?.containingElement?.scrollIntoView?.({block:"center",inline:"center"}),t.scrollIntoView?.({block:"nearest"}))}}}var Tu={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"};function or(t){let e=t.startIndex??0;const n=t.startLevel??0,r=[],s=l=>{if(l==null)return"";const c=t.getKey??"key",u=ht(c)?l[c]:c(l);return u!=null?String(u):""},o=l=>{if(l==null)return"";const c=t.getTextValue??"textValue",u=ht(c)?l[c]:c(l);return u!=null?String(u):""},i=l=>{if(l==null)return!1;const c=t.getDisabled??"disabled";return(ht(c)?l[c]:c(l))??!1},a=l=>{if(l!=null)return ht(t.getSectionChildren)?l[t.getSectionChildren]:t.getSectionChildren?.(l)};for(const l of t.dataSource){if(ht(l)||su(l)){r.push({type:"item",rawValue:l,key:String(l),textValue:String(l),disabled:i(l),level:n,index:e}),e++;continue}if(a(l)!=null){r.push({type:"section",rawValue:l,key:"",textValue:"",disabled:!1,level:n,index:e}),e++;const c=a(l)??[];if(c.length>0){const u=or({dataSource:c,getKey:t.getKey,getTextValue:t.getTextValue,getDisabled:t.getDisabled,getSectionChildren:t.getSectionChildren,startIndex:e,startLevel:n+1});r.push(...u),e+=u.length}}else r.push({type:"item",rawValue:l,key:s(l),textValue:o(l),disabled:i(l),level:n,index:e}),e++}return r}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/bfce84fee12a027d9cbc38b43e1747e3e4b4b169/packages/@react-stately/collections/src/useCollection.ts
 */function Pu(t,e=[]){const n=or({dataSource:_(t.dataSource),getKey:_(t.getKey),getTextValue:_(t.getTextValue),getDisabled:_(t.getDisabled),getSectionChildren:_(t.getSectionChildren)}),[r,s]=A(t.factory(n));return I(xe([()=>_(t.dataSource),()=>_(t.getKey),()=>_(t.getTextValue),()=>_(t.getDisabled),()=>_(t.getSectionChildren),()=>t.factory,...e],([o,i,a,l,c,u])=>{const d=or({dataSource:o,getKey:i,getTextValue:a,getDisabled:l,getSectionChildren:c});s(()=>u(d))},{defer:!0})),r}function Ar(t){const[e,n]=A(t.defaultValue?.()),r=O(()=>t.value?.()!==void 0),s=O(()=>r()?t.value?.():e());return[s,i=>{G(()=>{const a=Jc(i,s());return Object.is(a,s())||(r()||n(a),t.onChange?.(a)),a})}]}function Au(t){const[e,n]=Ar(t);return[()=>e()??!1,n]}function Ou(t){const[e,n]=Ar(t);return[()=>e()??[],n]}function $o(t={}){const[e,n]=Au({value:()=>_(t.open),defaultValue:()=>!!_(t.defaultOpen),onChange:i=>t.onOpenChange?.(i)}),r=()=>{n(!0)},s=()=>{n(!1)};return{isOpen:e,setIsOpen:n,open:r,close:s,toggle:()=>{e()?s():r()}}}function Cu(t){const e=n=>{n.key===Co.Escape&&t.onEscapeKeyDown?.(n)};I(()=>{if(_(t.isDisabled))return;const n=t.ownerDocument?.()??Ce();n.addEventListener("keydown",e),z(()=>{n.removeEventListener("keydown",e)})})}/*!
 * Portions of this file are based on code from radix-ui-primitives.
 * MIT Licensed, Copyright (c) 2022 WorkOS.
 *
 * Credits to the Radix UI team:
 * https://github.com/radix-ui/primitives/blob/81b25f4b40c54f72aeb106ca0e64e1e09655153e/packages/react/dismissable-layer/src/DismissableLayer.tsx
 *
 * Portions of this file are based on code from zag.
 * MIT Licensed, Copyright (c) 2021 Chakra UI.
 *
 * Credits to the Chakra UI team:
 * https://github.com/chakra-ui/zag/blob/d1dbf9e240803c9e3ed81ebef363739be4273de0/packages/utilities/dismissable/src/layer-stack.ts
 */const mn="data-kb-top-layer";let Do,ir=!1;const Le=[];function Bt(t){return Le.findIndex(e=>e.node===t)}function Lu(t){return Le[Bt(t)]}function Ru(t){return Le[Le.length-1].node===t}function Mo(){return Le.filter(t=>t.isPointerBlocking)}function Iu(){return[...Mo()].slice(-1)[0]}function Or(){return Mo().length>0}function jo(t){const e=Bt(Iu()?.node);return Bt(t)<e}function $u(t){Le.push(t)}function Du(t){const e=Bt(t);e<0||Le.splice(e,1)}function Mu(){for(const{node:t}of Le)t.style.pointerEvents=jo(t)?"none":"auto"}function ju(t){if(Or()&&!ir){const e=Ce(t);Do=document.body.style.pointerEvents,e.body.style.pointerEvents="none",ir=!0}}function Fu(t){if(Or())return;const e=Ce(t);e.body.style.pointerEvents=Do,e.body.style.length===0&&e.body.removeAttribute("style"),ir=!1}const se={layers:Le,isTopMostLayer:Ru,hasPointerBlockingLayer:Or,isBelowPointerBlockingLayer:jo,addLayer:$u,removeLayer:Du,indexOf:Bt,find:Lu,assignPointerEventToLayers:Mu,disableBodyPointerEvents:ju,restoreBodyPointerEvents:Fu};/*!
 * Portions of this file are based on code from radix-ui-primitives.
 * MIT Licensed, Copyright (c) 2022 WorkOS.
 *
 * Credits to the Radix UI team:
 * https://github.com/radix-ui/primitives/blob/81b25f4b40c54f72aeb106ca0e64e1e09655153e/packages/react/focus-scope/src/FocusScope.tsx
 *
 * Portions of this file are based on code from zag.
 * MIT Licensed, Copyright (c) 2021 Chakra UI.
 *
 * Credits to the Chakra UI team:
 * https://github.com/chakra-ui/zag/blob/d1dbf9e240803c9e3ed81ebef363739be4273de0/packages/utilities/focus-scope/src/focus-on-child-unmount.ts
 * https://github.com/chakra-ui/zag/blob/d1dbf9e240803c9e3ed81ebef363739be4273de0/packages/utilities/focus-scope/src/focus-containment.ts
 */const zn="focusScope.autoFocusOnMount",Vn="focusScope.autoFocusOnUnmount",ms={bubbles:!1,cancelable:!0},ys={stack:[],active(){return this.stack[0]},add(t){t!==this.active()&&this.active()?.pause(),this.stack=rr(this.stack,t),this.stack.unshift(t)},remove(t){this.stack=rr(this.stack,t),this.active()?.resume()}};function Nu(t,e){const[n,r]=A(!1),s={pause(){r(!0)},resume(){r(!1)}};let o=null;const i=h=>t.onMountAutoFocus?.(h),a=h=>t.onUnmountAutoFocus?.(h),l=()=>Ce(e()),c=()=>{const h=l().createElement("span");return h.setAttribute("data-focus-trap",""),h.tabIndex=0,Object.assign(h.style,Tu),h},u=()=>{const h=e();return h?Ro(h,!0).filter(g=>!g.hasAttribute("data-focus-trap")):[]},d=()=>{const h=u();return h.length>0?h[0]:null},f=()=>{const h=u();return h.length>0?h[h.length-1]:null},p=()=>{const h=e();if(!h)return!1;const g=Dt(h);return!g||we(h,g)?!1:Io(g)};I(()=>{const h=e();if(!h)return;ys.add(s);const g=Dt(h);if(!we(h,g)){const y=new CustomEvent(zn,ms);h.addEventListener(zn,i),h.dispatchEvent(y),y.defaultPrevented||setTimeout(()=>{te(d()),Dt(h)===g&&te(h)},0)}z(()=>{h.removeEventListener(zn,i),setTimeout(()=>{const y=new CustomEvent(Vn,ms);p()&&y.preventDefault(),h.addEventListener(Vn,a),h.dispatchEvent(y),y.defaultPrevented||te(g??l().body),h.removeEventListener(Vn,a),ys.remove(s)},0)})}),I(()=>{const h=e();if(!h||!_(t.trapFocus)||n())return;const g=y=>{const v=y.target;v?.closest(`[${mn}]`)||(we(h,v)?o=v:te(o))},m=y=>{const w=y.relatedTarget??Dt(h);w?.closest(`[${mn}]`)||we(h,w)||te(o)};l().addEventListener("focusin",g),l().addEventListener("focusout",m),z(()=>{l().removeEventListener("focusin",g),l().removeEventListener("focusout",m)})}),I(()=>{const h=e();if(!h||!_(t.trapFocus)||n())return;const g=c();h.insertAdjacentElement("afterbegin",g);const m=c();h.insertAdjacentElement("beforeend",m);function y(w){const b=d(),k=f();w.relatedTarget===b?te(k):te(b)}g.addEventListener("focusin",y),m.addEventListener("focusin",y);const v=new MutationObserver(w=>{for(const b of w)b.previousSibling===m&&(m.remove(),h.insertAdjacentElement("beforeend",m)),b.nextSibling===g&&(g.remove(),h.insertAdjacentElement("afterbegin",g))});v.observe(h,{childList:!0,subtree:!1}),z(()=>{g.removeEventListener("focusin",y),m.removeEventListener("focusin",y),g.remove(),m.remove(),v.disconnect()})})}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/15e101b74966bd5eb719c6529ce71ce57eaed430/packages/@react-aria/live-announcer/src/LiveAnnouncer.tsx
 */const Ku="data-live-announcer";/*!
 * This file is based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/810579b671791f1593108f62cdc1893de3a220e3/packages/@react-aria/overlays/src/ariaHideOutside.ts
 */function Uu(t){I(()=>{_(t.isDisabled)||z(Bu(_(t.targets),_(t.root)))})}const Rt=new WeakMap,ue=[];function Bu(t,e=document.body){const n=new Set(t),r=new Set,s=l=>{for(const f of l.querySelectorAll(`[${Ku}], [${mn}]`))n.add(f);const c=f=>{if(n.has(f)||f.parentElement&&r.has(f.parentElement)&&f.parentElement.getAttribute("role")!=="row")return NodeFilter.FILTER_REJECT;for(const p of n)if(f.contains(p))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},u=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,{acceptNode:c}),d=c(l);if(d===NodeFilter.FILTER_ACCEPT&&o(l),d!==NodeFilter.FILTER_REJECT){let f=u.nextNode();for(;f!=null;)o(f),f=u.nextNode()}},o=l=>{const c=Rt.get(l)??0;l.getAttribute("aria-hidden")==="true"&&c===0||(c===0&&l.setAttribute("aria-hidden","true"),r.add(l),Rt.set(l,c+1))};ue.length&&ue[ue.length-1].disconnect(),s(e);const i=new MutationObserver(l=>{for(const c of l)if(!(c.type!=="childList"||c.addedNodes.length===0)&&![...n,...r].some(u=>u.contains(c.target))){for(const u of c.removedNodes)u instanceof Element&&(n.delete(u),r.delete(u));for(const u of c.addedNodes)(u instanceof HTMLElement||u instanceof SVGElement)&&(u.dataset.liveAnnouncer==="true"||u.dataset.reactAriaTopLayer==="true")?n.add(u):u instanceof Element&&s(u)}});i.observe(e,{childList:!0,subtree:!0});const a={observe(){i.observe(e,{childList:!0,subtree:!0})},disconnect(){i.disconnect()}};return ue.push(a),()=>{i.disconnect();for(const l of r){const c=Rt.get(l);if(c==null)return;c===1?(l.removeAttribute("aria-hidden"),Rt.delete(l)):Rt.set(l,c-1)}a===ue[ue.length-1]?(ue.pop(),ue.length&&ue[ue.length-1].observe()):ue.splice(ue.indexOf(a),1)}}/*!
 * Portions of this file are based on code from radix-ui-primitives.
 * MIT Licensed, Copyright (c) 2022 WorkOS.
 *
 * Credits to the Radix UI team:
 * https://github.com/radix-ui/primitives/blob/81b25f4b40c54f72aeb106ca0e64e1e09655153e/packages/react/dismissable-layer/src/DismissableLayer.tsx
 *
 * Portions of this file are based on code from zag.
 * MIT Licensed, Copyright (c) 2021 Chakra UI.
 *
 * Credits to the Chakra UI team:
 * https://github.com/chakra-ui/zag/blob/d1dbf9e240803c9e3ed81ebef363739be4273de0/packages/utilities/interact-outside/src/index.ts
 */const vs="interactOutside.pointerDownOutside",bs="interactOutside.focusOutside";function zu(t,e){let n,r=Su;const s=()=>Ce(e()),o=d=>t.onPointerDownOutside?.(d),i=d=>t.onFocusOutside?.(d),a=d=>t.onInteractOutside?.(d),l=d=>{const f=d.target;return!(f instanceof HTMLElement)||f.closest(`[${mn}]`)||!we(s(),f)||we(e(),f)?!1:!t.shouldExcludeElement?.(f)},c=d=>{function f(){const p=e(),h=d.target;if(!p||!h||!l(d))return;const g=de([o,a]);h.addEventListener(vs,g,{once:!0});const m=new CustomEvent(vs,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:d.button===2||du(d)&&d.button===0}});h.dispatchEvent(m)}d.pointerType==="touch"?(s().removeEventListener("click",f),r=f,s().addEventListener("click",f,{once:!0})):f()},u=d=>{const f=e(),p=d.target;if(!f||!p||!l(d))return;const h=de([i,a]);p.addEventListener(bs,h,{once:!0});const g=new CustomEvent(bs,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:!1}});p.dispatchEvent(g)};I(()=>{_(t.isDisabled)||(n=window.setTimeout(()=>{s().addEventListener("pointerdown",c,!0)},0),s().addEventListener("focusin",u,!0),z(()=>{window.clearTimeout(n),s().removeEventListener("click",r),s().removeEventListener("pointerdown",c,!0),s().removeEventListener("focusin",u,!0)}))})}/*!
 * Portions of this file are based on code from radix-ui-primitives.
 * MIT Licensed, Copyright (c) 2022 WorkOS.
 *
 * Credits to the Radix UI team:
 * https://github.com/radix-ui/primitives/blob/21a7c97dc8efa79fecca36428eec49f187294085/packages/react/presence/src/Presence.tsx
 * https://github.com/radix-ui/primitives/blob/21a7c97dc8efa79fecca36428eec49f187294085/packages/react/presence/src/useStateMachine.tsx
 */function Vu(t){const[e,n]=A();let r={},s=t(),o="none";const[i,a]=Hu(t()?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return I(xe(i,l=>{const c=sn(r);o=l==="mounted"?c:"none"})),I(xe(t,l=>{if(s===l)return;const c=sn(r);l?a("MOUNT"):r?.display==="none"?a("UNMOUNT"):a(s&&o!==c?"ANIMATION_OUT":"UNMOUNT"),s=l})),I(xe(e,l=>{if(l){const c=d=>{const p=sn(r).includes(d.animationName);d.target===l&&p&&a("ANIMATION_END")},u=d=>{d.target===l&&(o=sn(r))};l.addEventListener("animationstart",u),l.addEventListener("animationcancel",c),l.addEventListener("animationend",c),z(()=>{l.removeEventListener("animationstart",u),l.removeEventListener("animationcancel",c),l.removeEventListener("animationend",c)})}else a("ANIMATION_END")})),{isPresent:()=>["mounted","unmountSuspended"].includes(i()),setRef:l=>{l&&(r=getComputedStyle(l)),n(l)}}}function sn(t){return t?.animationName||"none"}function Hu(t,e){const n=(i,a)=>e[i][a]??i,[r,s]=A(t);return[r,i=>{s(a=>n(a,i))}]}function zt(t){return e=>(t(e),()=>t(void 0))}/*!
 * Portions of this file are based on code from ariakit.
 * MIT Licensed, Copyright (c) Diego Haz.
 *
 * Credits to the ariakit team:
 * https://github.com/ariakit/ariakit/blob/8a13899ff807bbf39f3d89d2d5964042ba4d5287/packages/ariakit-react-utils/src/hooks.ts
 */function Fo(t,e){const[n,r]=A(ws(e?.()));return I(()=>{r(t()?.tagName.toLowerCase()||ws(e?.()))}),n}function ws(t){return ht(t)?t:void 0}function He(t){const[e,n]=J(t,["asChild","as","children"]);if(!e.asChild)return x($n,B({get component(){return e.as}},n,{get children(){return e.children}}));const r=qt(()=>e.children);if(_s(r())){const s=xs(n,r()?.props??{});return x($n,s)}if(ou(r())){const s=r().find(_s);if(s){const o=()=>x(Ti,{get each(){return r()},children:a=>x(Ze,{when:a===s,fallback:a,get children(){return s.props.children}})}),i=xs(n,s?.props??{});return x($n,B(i,{children:o}))}}throw new Error("[kobalte]: Component is expected to render `asChild` but no children `As` component was found.")}const No=Symbol("$$KobalteAsComponent");function qu(t){return{[No]:!0,props:t}}function _s(t){return t?.[No]===!0}function xs(t,e){return nu([t,e],{reverseEventHandlers:!0})}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/b35d5c02fe900badccd0cf1a8f23bb593419f238/packages/@react-aria/i18n/src/utils.ts
 */const Wu=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),Gu=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function Ju(t){if(Intl.Locale){const n=new Intl.Locale(t).maximize().script??"";return Wu.has(n)}const e=t.split("-")[0];return Gu.has(e)}function Xu(t){return Ju(t)?"rtl":"ltr"}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/b35d5c02fe900badccd0cf1a8f23bb593419f238/packages/@react-aria/i18n/src/useDefaultLocale.ts
 */function Ko(){let t=typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{t="en-US"}return{locale:t,direction:Xu(t)}}let ar=Ko();const Mt=new Set;function Ss(){ar=Ko();for(const t of Mt)t(ar)}function Yu(){const[t,e]=A(ar),n=O(()=>t());return dr(()=>{Mt.size===0&&window.addEventListener("languagechange",Ss),Mt.add(e),z(()=>{Mt.delete(e),Mt.size===0&&window.removeEventListener("languagechange",Ss)})}),{locale:()=>n().locale,direction:()=>n().direction}}const Qu=ne();function Cr(){const t=Yu();return fe(Qu)||t}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/b35d5c02fe900badccd0cf1a8f23bb593419f238/packages/@react-aria/i18n/src/useCollator.ts
 */const Hn=new Map;function Zu(t){const{locale:e}=Cr(),n=O(()=>e()+(t?Object.entries(t).sort((r,s)=>r[0]<s[0]?-1:1).join():""));return O(()=>{const r=n();let s;return Hn.has(r)&&(s=Hn.get(r)),s||(s=new Intl.Collator(e(),t),Hn.set(r,s)),s})}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/bfce84fee12a027d9cbc38b43e1747e3e4b4b169/packages/@react-stately/selection/src/Selection.ts
 * https://github.com/adobe/react-spectrum/blob/bfce84fee12a027d9cbc38b43e1747e3e4b4b169/packages/@react-stately/selection/src/types.ts
 * https://github.com/adobe/react-spectrum/blob/bfce84fee12a027d9cbc38b43e1747e3e4b4b169/packages/@react-types/shared/src/selection.d.ts
 */class ye extends Set{anchorKey;currentKey;constructor(e,n,r){super(e),e instanceof ye?(this.anchorKey=n||e.anchorKey,this.currentKey=r||e.currentKey):(this.anchorKey=n,this.currentKey=r)}}function ed(t){const[e,n]=Ar(t);return[()=>e()??new ye,n]}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/8f2f2acb3d5850382ebe631f055f88c704aa7d17/packages/@react-aria/selection/src/utils.ts
 */function Uo(t){return uu()?t.altKey:t.ctrlKey}function gt(t){return Pn()?t.metaKey:t.ctrlKey}function Es(t){return new ye(t)}function td(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/bfce84fee12a027d9cbc38b43e1747e3e4b4b169/packages/@react-stately/selection/src/useMultipleSelectionState.ts
 */function nd(t){const e=he({selectionMode:"none",selectionBehavior:"toggle"},t),[n,r]=A(!1),[s,o]=A(),i=O(()=>{const g=_(e.selectedKeys);return g!=null?Es(g):g}),a=O(()=>{const g=_(e.defaultSelectedKeys);return g!=null?Es(g):new ye}),[l,c]=ed({value:i,defaultValue:a,onChange:g=>e.onSelectionChange?.(g)}),[u,d]=A(_(e.selectionBehavior)),f=()=>_(e.selectionMode),p=()=>_(e.disallowEmptySelection)??!1,h=g=>{(_(e.allowDuplicateSelectionEvents)||!td(g,l()))&&c(g)};return I(()=>{const g=l();_(e.selectionBehavior)==="replace"&&u()==="toggle"&&typeof g=="object"&&g.size===0&&d("replace")}),I(()=>{d(_(e.selectionBehavior)??"toggle")}),{selectionMode:f,disallowEmptySelection:p,selectionBehavior:u,setSelectionBehavior:d,isFocused:n,setFocused:r,focusedKey:s,setFocusedKey:o,selectedKeys:l,setSelectedKeys:h}}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/8f2f2acb3d5850382ebe631f055f88c704aa7d17/packages/@react-aria/selection/src/useTypeSelect.ts
 */function rd(t){const[e,n]=A(""),[r,s]=A(-1);return{typeSelectHandlers:{onKeyDown:i=>{if(_(t.isDisabled))return;const a=_(t.keyboardDelegate),l=_(t.selectionManager);if(!a.getKeyForSearch)return;const c=sd(i.key);if(!c||i.ctrlKey||i.metaKey)return;c===" "&&e().trim().length>0&&(i.preventDefault(),i.stopPropagation());let u=n(f=>f+c),d=a.getKeyForSearch(u,l.focusedKey())??a.getKeyForSearch(u);d==null&&od(u)&&(u=u[0],d=a.getKeyForSearch(u,l.focusedKey())??a.getKeyForSearch(u)),d!=null&&(l.setFocusedKey(d),t.onTypeSelect?.(d)),clearTimeout(r()),s(window.setTimeout(()=>n(""),500))}}}}function sd(t){return t.length===1||!/^[A-Z]/i.test(t)?t:""}function od(t){return t.split("").every(e=>e===t[0])}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/8f2f2acb3d5850382ebe631f055f88c704aa7d17/packages/@react-aria/selection/src/useSelectableCollection.ts
 */function id(t,e,n){const s=B({selectOnFocus:()=>_(t.selectionManager).selectionBehavior()==="replace"},t),o=()=>n?.()??e(),{direction:i}=Cr();let a={top:0,left:0};Qc(()=>_(s.isVirtualized)?void 0:o(),"scroll",()=>{const g=o();g&&(a={top:g.scrollTop,left:g.scrollLeft})});const{typeSelectHandlers:l}=rd({isDisabled:()=>_(s.disallowTypeAhead),keyboardDelegate:()=>_(s.keyboardDelegate),selectionManager:()=>_(s.selectionManager)}),c=g=>{ae(g,l.onKeyDown),g.altKey&&g.key==="Tab"&&g.preventDefault();const m=e();if(!m?.contains(g.target))return;const y=_(s.selectionManager),v=_(s.selectOnFocus),w=S=>{S!=null&&(y.setFocusedKey(S),g.shiftKey&&y.selectionMode()==="multiple"?y.extendSelection(S):v&&!Uo(g)&&y.replaceSelection(S))},b=_(s.keyboardDelegate),k=_(s.shouldFocusWrap),T=y.focusedKey();switch(g.key){case"ArrowDown":{if(b.getKeyBelow){g.preventDefault();let S;T!=null?S=b.getKeyBelow(T):S=b.getFirstKey?.(),S==null&&k&&(S=b.getFirstKey?.(T)),w(S)}break}case"ArrowUp":{if(b.getKeyAbove){g.preventDefault();let S;T!=null?S=b.getKeyAbove(T):S=b.getLastKey?.(),S==null&&k&&(S=b.getLastKey?.(T)),w(S)}break}case"ArrowLeft":{if(b.getKeyLeftOf){g.preventDefault();const S=i()==="rtl";let C;T!=null?C=b.getKeyLeftOf(T):C=S?b.getFirstKey?.():b.getLastKey?.(),w(C)}break}case"ArrowRight":{if(b.getKeyRightOf){g.preventDefault();const S=i()==="rtl";let C;T!=null?C=b.getKeyRightOf(T):C=S?b.getLastKey?.():b.getFirstKey?.(),w(C)}break}case"Home":if(b.getFirstKey){g.preventDefault();const S=b.getFirstKey(T,gt(g));S!=null&&(y.setFocusedKey(S),gt(g)&&g.shiftKey&&y.selectionMode()==="multiple"?y.extendSelection(S):v&&y.replaceSelection(S))}break;case"End":if(b.getLastKey){g.preventDefault();const S=b.getLastKey(T,gt(g));S!=null&&(y.setFocusedKey(S),gt(g)&&g.shiftKey&&y.selectionMode()==="multiple"?y.extendSelection(S):v&&y.replaceSelection(S))}break;case"PageDown":if(b.getKeyPageBelow&&T!=null){g.preventDefault();const S=b.getKeyPageBelow(T);w(S)}break;case"PageUp":if(b.getKeyPageAbove&&T!=null){g.preventDefault();const S=b.getKeyPageAbove(T);w(S)}break;case"a":gt(g)&&y.selectionMode()==="multiple"&&_(s.disallowSelectAll)!==!0&&(g.preventDefault(),y.selectAll());break;case"Escape":g.defaultPrevented||(g.preventDefault(),_(s.disallowEmptySelection)||y.clearSelection());break;case"Tab":if(!_(s.allowsTabNavigation)){if(g.shiftKey)m.focus();else{const S=_u(m,{tabbable:!0});let C,P;do P=S.lastChild(),P&&(C=P);while(P);C&&!C.contains(document.activeElement)&&te(C)}break}}},u=g=>{const m=_(s.selectionManager),y=_(s.keyboardDelegate),v=_(s.selectOnFocus);if(m.isFocused()){g.currentTarget.contains(g.target)||m.setFocused(!1);return}if(g.currentTarget.contains(g.target)){if(m.setFocused(!0),m.focusedKey()==null){const w=k=>{k!=null&&(m.setFocusedKey(k),v&&m.replaceSelection(k))},b=g.relatedTarget;b&&g.currentTarget.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_FOLLOWING?w(m.lastSelectedKey()??y.getLastKey?.()):w(m.firstSelectedKey()??y.getFirstKey?.())}else if(!_(s.isVirtualized)){const w=o();if(w){w.scrollTop=a.top,w.scrollLeft=a.left;const b=w.querySelector(`[data-key="${m.focusedKey()}"]`);b&&(te(b),sr(w,b))}}}},d=g=>{const m=_(s.selectionManager);g.currentTarget.contains(g.relatedTarget)||m.setFocused(!1)},f=g=>{o()===g.target&&g.preventDefault()},p=()=>{const g=_(s.autoFocus);if(!g)return;const m=_(s.selectionManager),y=_(s.keyboardDelegate);let v;g==="first"&&(v=y.getFirstKey?.()),g==="last"&&(v=y.getLastKey?.());const w=m.selectedKeys();w.size&&(v=w.values().next().value),m.setFocused(!0),m.setFocusedKey(v);const b=e();b&&v==null&&!_(s.shouldUseVirtualFocus)&&te(b)};return dr(()=>{s.deferAutoFocus?setTimeout(p,0):p()}),I(xe([o,()=>_(s.isVirtualized),()=>_(s.selectionManager).focusedKey()],g=>{const[m,y,v]=g;if(y)v&&s.scrollToKey?.(v);else if(v&&m){const w=m.querySelector(`[data-key="${v}"]`);w&&sr(m,w)}})),{tabIndex:O(()=>{if(!_(s.shouldUseVirtualFocus))return _(s.selectionManager).focusedKey()==null?0:-1}),onKeyDown:c,onMouseDown:f,onFocusIn:u,onFocusOut:d}}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/8f2f2acb3d5850382ebe631f055f88c704aa7d17/packages/@react-aria/selection/src/useSelectableItem.ts
 */function ad(t,e){const n=()=>_(t.selectionManager),r=()=>_(t.key),s=()=>_(t.shouldUseVirtualFocus),o=v=>{n().selectionMode()!=="none"&&(n().selectionMode()==="single"?n().isSelected(r())&&!n().disallowEmptySelection()?n().toggleSelection(r()):n().replaceSelection(r()):v?.shiftKey?n().extendSelection(r()):n().selectionBehavior()==="toggle"||gt(v)||"pointerType"in v&&v.pointerType==="touch"?n().toggleSelection(r()):n().replaceSelection(r()))},i=()=>n().isSelected(r()),a=()=>_(t.disabled)||n().isDisabled(r()),l=()=>!a()&&n().canSelectItem(r());let c=null;const u=v=>{l()&&(c=v.pointerType,v.pointerType==="mouse"&&v.button===0&&!_(t.shouldSelectOnPressUp)&&o(v))},d=v=>{l()&&v.pointerType==="mouse"&&v.button===0&&_(t.shouldSelectOnPressUp)&&_(t.allowsDifferentPressOrigin)&&o(v)},f=v=>{l()&&(_(t.shouldSelectOnPressUp)&&!_(t.allowsDifferentPressOrigin)||c!=="mouse")&&o(v)},p=v=>{!l()||!["Enter"," "].includes(v.key)||(Uo(v)?n().toggleSelection(r()):o(v))},h=v=>{a()&&v.preventDefault()},g=v=>{const w=e();s()||a()||!w||v.target===w&&n().setFocusedKey(r())},m=O(()=>{if(!(s()||a()))return r()===n().focusedKey()?0:-1}),y=O(()=>_(t.virtualized)?void 0:r());return I(xe([e,r,s,()=>n().focusedKey(),()=>n().isFocused()],([v,w,b,k,T])=>{v&&w===k&&T&&!b&&document.activeElement!==v&&(t.focus?t.focus():te(v))})),{isSelected:i,isDisabled:a,allowsSelection:l,tabIndex:m,dataKey:y,onPointerDown:u,onPointerUp:d,onClick:f,onKeyDown:p,onMouseDown:h,onFocus:g}}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/bfce84fee12a027d9cbc38b43e1747e3e4b4b169/packages/@react-stately/selection/src/SelectionManager.ts
 */class ld{collection;state;constructor(e,n){this.collection=e,this.state=n}selectionMode(){return this.state.selectionMode()}disallowEmptySelection(){return this.state.disallowEmptySelection()}selectionBehavior(){return this.state.selectionBehavior()}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}isFocused(){return this.state.isFocused()}setFocused(e){this.state.setFocused(e)}focusedKey(){return this.state.focusedKey()}setFocusedKey(e){(e==null||this.collection().getItem(e))&&this.state.setFocusedKey(e)}selectedKeys(){return this.state.selectedKeys()}isSelected(e){if(this.state.selectionMode()==="none")return!1;const n=this.getKey(e);return n==null?!1:this.state.selectedKeys().has(n)}isEmpty(){return this.state.selectedKeys().size===0}isSelectAll(){if(this.isEmpty())return!1;const e=this.state.selectedKeys();return this.getAllSelectableKeys().every(n=>e.has(n))}firstSelectedKey(){let e;for(const n of this.state.selectedKeys()){const r=this.collection().getItem(n),s=r?.index!=null&&e?.index!=null&&r.index<e.index;(!e||s)&&(e=r)}return e?.key}lastSelectedKey(){let e;for(const n of this.state.selectedKeys()){const r=this.collection().getItem(n),s=r?.index!=null&&e?.index!=null&&r.index>e.index;(!e||s)&&(e=r)}return e?.key}extendSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"){this.replaceSelection(e);return}const n=this.getKey(e);if(n==null)return;const r=this.state.selectedKeys(),s=r.anchorKey||n,o=new ye(r,s,n);for(const i of this.getKeyRange(s,r.currentKey||n))o.delete(i);for(const i of this.getKeyRange(n,s))this.canSelectItem(i)&&o.add(i);this.state.setSelectedKeys(o)}getKeyRange(e,n){const r=this.collection().getItem(e),s=this.collection().getItem(n);return r&&s?r.index!=null&&s.index!=null&&r.index<=s.index?this.getKeyRangeInternal(e,n):this.getKeyRangeInternal(n,e):[]}getKeyRangeInternal(e,n){const r=[];let s=e;for(;s!=null;){const o=this.collection().getItem(s);if(o&&o.type==="item"&&r.push(s),s===n)return r;s=this.collection().getKeyAfter(s)}return[]}getKey(e){const n=this.collection().getItem(e);return n?!n||n.type!=="item"?null:n.key:e}toggleSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"&&!this.isSelected(e)){this.replaceSelection(e);return}const n=this.getKey(e);if(n==null)return;const r=new ye(this.state.selectedKeys());r.has(n)?r.delete(n):this.canSelectItem(n)&&(r.add(n),r.anchorKey=n,r.currentKey=n),!(this.disallowEmptySelection()&&r.size===0)&&this.state.setSelectedKeys(r)}replaceSelection(e){if(this.selectionMode()==="none")return;const n=this.getKey(e);if(n==null)return;const r=this.canSelectItem(n)?new ye([n],n,n):new ye;this.state.setSelectedKeys(r)}setSelectedKeys(e){if(this.selectionMode()==="none")return;const n=new ye;for(const r of e){const s=this.getKey(r);if(s!=null&&(n.add(s),this.selectionMode()==="single"))break}this.state.setSelectedKeys(n)}selectAll(){this.selectionMode()==="multiple"&&this.state.setSelectedKeys(new Set(this.getAllSelectableKeys()))}clearSelection(){const e=this.state.selectedKeys();!this.disallowEmptySelection()&&e.size>0&&this.state.setSelectedKeys(new ye)}toggleSelectAll(){this.isSelectAll()?this.clearSelection():this.selectAll()}select(e,n){this.selectionMode()!=="none"&&(this.selectionMode()==="single"?this.isSelected(e)&&!this.disallowEmptySelection()?this.toggleSelection(e):this.replaceSelection(e):this.selectionBehavior()==="toggle"||n&&n.pointerType==="touch"?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys())return!0;const n=this.selectedKeys();if(e.size!==n.size)return!1;for(const r of e)if(!n.has(r))return!1;for(const r of n)if(!e.has(r))return!1;return!0}canSelectItem(e){if(this.state.selectionMode()==="none")return!1;const n=this.collection().getItem(e);return n!=null&&!n.disabled}isDisabled(e){const n=this.collection().getItem(e);return!n||n.disabled}getAllSelectableKeys(){const e=[];return(r=>{for(;r!=null;){if(this.canSelectItem(r)){const s=this.collection().getItem(r);if(!s)continue;s.type==="item"&&e.push(r)}r=this.collection().getKeyAfter(r)}})(this.collection().getFirstKey()),e}}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/bfce84fee12a027d9cbc38b43e1747e3e4b4b169/packages/@react-stately/list/src/ListCollection.ts
 */class ks{keyMap=new Map;iterable;firstKey;lastKey;constructor(e){this.iterable=e;for(const s of e)this.keyMap.set(s.key,s);if(this.keyMap.size===0)return;let n,r=0;for(const[s,o]of this.keyMap)n?(n.nextKey=s,o.prevKey=n.key):(this.firstKey=s,o.prevKey=void 0),o.type==="item"&&(o.index=r++),n=o,n.nextKey=void 0;this.lastKey=n.key}*[Symbol.iterator](){yield*this.iterable}getSize(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(e){return this.keyMap.get(e)?.prevKey}getKeyAfter(e){return this.keyMap.get(e)?.nextKey}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(e){return this.keyMap.get(e)}at(e){const n=[...this.getKeys()];return this.getItem(n[e])}}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/bfce84fee12a027d9cbc38b43e1747e3e4b4b169/packages/@react-stately/list/src/useListState.ts
 */function cd(t){const e=nd(t),r=Pu({dataSource:()=>_(t.dataSource),getKey:()=>_(t.getKey),getTextValue:()=>_(t.getTextValue),getDisabled:()=>_(t.getDisabled),getSectionChildren:()=>_(t.getSectionChildren),factory:o=>t.filter?new ks(t.filter(o)):new ks(o)},[()=>t.filter]),s=new ld(r,e);return Wn(()=>{const o=e.focusedKey();o!=null&&!r().getItem(o)&&e.setFocusedKey(void 0)}),{collection:r,selectionManager:()=>s}}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/8f2f2acb3d5850382ebe631f055f88c704aa7d17/packages/@react-aria/selection/src/ListKeyboardDelegate.ts
 */class ud{collection;ref;collator;constructor(e,n,r){this.collection=e,this.ref=n,this.collator=r}getKeyBelow(e){let n=this.collection().getKeyAfter(e);for(;n!=null;){const r=this.collection().getItem(n);if(r&&r.type==="item"&&!r.disabled)return n;n=this.collection().getKeyAfter(n)}}getKeyAbove(e){let n=this.collection().getKeyBefore(e);for(;n!=null;){const r=this.collection().getItem(n);if(r&&r.type==="item"&&!r.disabled)return n;n=this.collection().getKeyBefore(n)}}getFirstKey(){let e=this.collection().getFirstKey();for(;e!=null;){const n=this.collection().getItem(e);if(n&&n.type==="item"&&!n.disabled)return e;e=this.collection().getKeyAfter(e)}}getLastKey(){let e=this.collection().getLastKey();for(;e!=null;){const n=this.collection().getItem(e);if(n&&n.type==="item"&&!n.disabled)return e;e=this.collection().getKeyBefore(e)}}getItem(e){return this.ref?.()?.querySelector(`[data-key="${e}"]`)??null}getKeyPageAbove(e){const n=this.ref?.();let r=this.getItem(e);if(!n||!r)return;const s=Math.max(0,r.offsetTop+r.offsetHeight-n.offsetHeight);let o=e;for(;o&&r&&r.offsetTop>s;)o=this.getKeyAbove(o),r=o!=null?this.getItem(o):null;return o}getKeyPageBelow(e){const n=this.ref?.();let r=this.getItem(e);if(!n||!r)return;const s=Math.min(n.scrollHeight,r.offsetTop-r.offsetHeight+n.offsetHeight);let o=e;for(;o&&r&&r.offsetTop<s;)o=this.getKeyBelow(o),r=o!=null?this.getItem(o):null;return o}getKeyForSearch(e,n){const r=this.collator?.();if(!r)return;let s=n!=null?this.getKeyBelow(n):this.getFirstKey();for(;s!=null;){const o=this.collection().getItem(s);if(o){const i=o.textValue.slice(0,e.length);if(o.textValue&&r.compare(i,e)===0)return s}s=this.getKeyBelow(s)}}}/*!
 * Portions of this file are based on code from react-spectrum.
 * Apache License Version 2.0, Copyright 2020 Adobe.
 *
 * Credits to the React Spectrum team:
 * https://github.com/adobe/react-spectrum/blob/8f2f2acb3d5850382ebe631f055f88c704aa7d17/packages/@react-aria/selection/src/useSelectableList.ts
 */function dd(t,e,n){const r=Zu({usage:"search",sensitivity:"base"}),s=O(()=>{const o=_(t.keyboardDelegate);return o||new ud(t.collection,e,r)});return id({selectionManager:()=>_(t.selectionManager),keyboardDelegate:s,autoFocus:()=>_(t.autoFocus),deferAutoFocus:()=>_(t.deferAutoFocus),shouldFocusWrap:()=>_(t.shouldFocusWrap),disallowEmptySelection:()=>_(t.disallowEmptySelection),selectOnFocus:()=>_(t.selectOnFocus),disallowTypeAhead:()=>_(t.disallowTypeAhead),shouldUseVirtualFocus:()=>_(t.shouldUseVirtualFocus),allowsTabNavigation:()=>_(t.allowsTabNavigation),isVirtualized:()=>_(t.isVirtualized),scrollToKey:o=>_(t.scrollToKey)?.(o)},e,n)}/*!
 * Portions of this file are based on code from ariakit
 * MIT Licensed, Copyright (c) Diego Haz.
 *
 * Credits to the ariakit team:
 * https://github.com/hope-ui/hope-ui/blob/54125b130195f37161dbeeea0c21dc3b198bc3ac/packages/core/src/button/is-button.ts
 */const fd=["button","color","file","image","reset","submit"];function hd(t){const e=t.tagName.toLowerCase();return e==="button"?!0:e==="input"&&t.type?fd.indexOf(t.type)!==-1:!1}function gd(t){let e;const n=he({type:"button"},t),[r,s]=J(n,["ref","type","disabled"]),o=Fo(()=>e,()=>"button"),i=O(()=>{const c=o();return c==null?!1:hd({tagName:c,type:r.type})}),a=O(()=>o()==="input"),l=O(()=>o()==="a"&&e?.getAttribute("href")!=null);return x(He,B({as:"button",ref(c){var u=Ve(d=>e=d,r.ref);typeof u=="function"&&u(c)},get type(){return i()||a()?r.type:void 0},get role(){return!i()&&!l()?"button":void 0},get tabIndex(){return!i()&&!l()&&!r.disabled?0:void 0},get disabled(){return i()||a()?r.disabled:void 0},get"aria-disabled"(){return!i()&&!a()&&r.disabled?!0:void 0},get"data-disabled"(){return r.disabled?"":void 0}},s))}const Bo=ne();function zo(){return fe(Bo)}function pd(){const t=zo();if(t===void 0)throw new Error("[kobalte]: `useDomCollectionContext` must be used within a `DomCollectionProvider` component");return t}/*!
 * Portions of this file are based on code from ariakit.
 * MIT Licensed, Copyright (c) Diego Haz.
 *
 * Credits to the Ariakit team:
 * https://github.com/ariakit/ariakit/blob/da142672eddefa99365773ced72171facc06fdcb/packages/ariakit/src/collection/collection-state.ts
 */function Vo(t,e){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}function md(t,e){const n=e.ref();if(!n)return-1;let r=t.length;if(!r)return-1;for(;r--;){const s=t[r]?.ref();if(s&&Vo(s,n))return r+1}return 0}function yd(t){const e=t.map((r,s)=>[s,r]);let n=!1;return e.sort(([r,s],[o,i])=>{const a=s.ref(),l=i.ref();return a===l||!a||!l?0:Vo(a,l)?(r>o&&(n=!0),-1):(r<o&&(n=!0),1)}),n?e.map(([r,s])=>s):t}function Ho(t,e){const n=yd(t);t!==n&&e(n)}function vd(t){const e=t[0],n=t[t.length-1]?.ref();let r=e?.ref()?.parentElement;for(;r;){if(n&&r.contains(n))return r;r=r.parentElement}return Ce(r).body}function bd(t,e){I(()=>{const n=setTimeout(()=>{Ho(t(),e)});z(()=>clearTimeout(n))})}function wd(t,e){if(typeof IntersectionObserver!="function"){bd(t,e);return}let n=[];I(()=>{const r=()=>{const i=!!n.length;n=t(),i&&Ho(t(),e)},s=vd(t()),o=new IntersectionObserver(r,{root:s});for(const i of t()){const a=i.ref();a&&o.observe(a)}z(()=>o.disconnect())})}/*!
 * Portions of this file are based on code from ariakit.
 * MIT Licensed, Copyright (c) Diego Haz.
 *
 * Credits to the Ariakit team:
 * https://github.com/ariakit/ariakit/blob/da142672eddefa99365773ced72171facc06fdcb/packages/ariakit/src/collection/collection.tsx
 * https://github.com/ariakit/ariakit/blob/da142672eddefa99365773ced72171facc06fdcb/packages/ariakit/src/collection/collection-state.ts
 * https://github.com/ariakit/ariakit/blob/da142672eddefa99365773ced72171facc06fdcb/packages/ariakit/src/collection/collection-item.ts
 */function _d(t={}){const[e,n]=Ou({value:()=>_(t.items),onChange:o=>t.onItemsChange?.(o)});wd(e,n);const r=o=>(n(i=>{const a=md(i,o);return ru(i,o,a)}),()=>{n(i=>{const a=i.filter(l=>l.ref()!==o.ref());return i.length===a.length?i:a})});return{DomCollectionProvider:o=>x(Bo.Provider,{value:{registerItem:r},get children(){return o.children}})}}function xd(t){const e=pd(),n=he({shouldRegisterItem:!0},t);I(()=>{if(!n.shouldRegisterItem)return;const r=e.registerItem(n.getItem());z(r)})}var pe=t=>typeof t=="function"?t():t,on=new Map,Sd=t=>{I(()=>{const e=pe(t.style)??{},n=pe(t.properties)??[],r={};for(const o in e)r[o]=t.element.style[o];const s=on.get(t.key);s?s.activeCount++:on.set(t.key,{activeCount:1,originalStyles:r,properties:n.map(o=>o.key)}),Object.assign(t.element.style,t.style);for(const o of n)t.element.style.setProperty(o.key,o.value);z(()=>{const o=on.get(t.key);if(o){if(o.activeCount!==1){o.activeCount--;return}on.delete(t.key);for(const[i,a]of Object.entries(o.originalStyles))t.element.style[i]=a;for(const i of o.properties)t.element.style.removeProperty(i);t.element.style.length===0&&t.element.removeAttribute("style"),t.cleanup?.()}})})},Ts=Sd,Ed=(t,e)=>{switch(e){case"x":return[t.clientWidth,t.scrollLeft,t.scrollWidth];case"y":return[t.clientHeight,t.scrollTop,t.scrollHeight]}},kd=(t,e)=>{const n=getComputedStyle(t),r=e==="x"?n.overflowX:n.overflowY;return r==="auto"||r==="scroll"||t.tagName==="HTML"&&r==="visible"},Td=(t,e,n)=>{const r=e==="x"&&window.getComputedStyle(t).direction==="rtl"?-1:1;let s=t,o=0,i=0,a=!1;do{const[l,c,u]=Ed(s,e),d=u-l-r*c;(c!==0||d!==0)&&kd(s,e)&&(o+=d,i+=c),s===(n??document.documentElement)?a=!0:s=s._$host??s.parentElement}while(s&&!a);return[o,i]},[Ps,As]=A([]),Pd=t=>Ps().indexOf(t)===Ps().length-1,Ad=t=>{const e=B({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",allowPinchZoom:!1},t),n=xt();let r=[0,0],s=null,o=null;I(()=>{pe(e.enabled)&&(As(c=>[...c,n]),z(()=>{As(c=>c.filter(u=>u!==n))}))}),I(()=>{if(!pe(e.enabled)||!pe(e.hideScrollbar))return;const{body:c}=document,u=window.innerWidth-c.offsetWidth;if(Ts({key:"prevent-scroll-overflow",element:c,style:{overflow:"hidden"}}),pe(e.preventScrollbarShift)){const d={},f=[];u>0&&(pe(e.preventScrollbarShiftMode)==="padding"?d.paddingRight=`calc(${window.getComputedStyle(c).paddingRight} + ${u}px)`:d.marginRight=`calc(${window.getComputedStyle(c).marginRight} + ${u}px)`,f.push({key:"--scrollbar-width",value:`${u}px`}));const p=window.scrollY,h=window.scrollX;Ts({key:"prevent-scroll-scrollbar",element:c,style:d,properties:f,cleanup:()=>{u>0&&window.scrollTo(h,p)}})}}),I(()=>{!Pd(n)||!pe(e.enabled)||(document.addEventListener("wheel",a,{passive:!1}),document.addEventListener("touchstart",i,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),z(()=>{document.removeEventListener("wheel",a),document.removeEventListener("touchstart",i),document.removeEventListener("touchmove",l)}))});const i=c=>{r=Os(c),s=null,o=null},a=c=>{const u=c.target,d=pe(e.element),f=Od(c),p=Math.abs(f[0])>Math.abs(f[1])?"x":"y",h=p==="x"?f[0]:f[1],g=Cs(u,p,h,d);let m;d&&lr(d,u)?m=!g:m=!0,m&&c.cancelable&&c.preventDefault()},l=c=>{const u=pe(e.element),d=c.target;let f;if(c.touches.length===2)f=!pe(e.allowPinchZoom);else{if(s==null||o===null){const p=Os(c).map((g,m)=>r[m]-g),h=Math.abs(p[0])>Math.abs(p[1])?"x":"y";s=h,o=h==="x"?p[0]:p[1]}if(d.type==="range")f=!1;else{const p=Cs(d,s,o,u);u&&lr(u,d)?f=!p:f=!0}}f&&c.cancelable&&c.preventDefault()}},Od=t=>[t.deltaX,t.deltaY],Os=t=>t.changedTouches[0]?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0],Cs=(t,e,n,r)=>{const s=r&&lr(r,t),[o,i]=Td(t,e,s?r:void 0);return!(n>0&&Math.abs(o)<=1||n<0&&Math.abs(i)<1)},lr=(t,e)=>{if(t.contains(e))return!0;let n=e;for(;n;){if(n===t)return!0;n=n._$host??n.parentElement}return!1},Cd=Ad,Ld=Cd;const qo=ne();function Rd(){return fe(qo)}function Id(t){let e;const n=Rd(),[r,s]=J(t,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),o=new Set([]),i=d=>{o.add(d);const f=n?.registerNestedLayer(d);return()=>{o.delete(d),f?.()}};zu({shouldExcludeElement:d=>e?r.excludedElements?.some(f=>we(f(),d))||[...o].some(f=>we(f,d)):!1,onPointerDownOutside:d=>{!e||se.isBelowPointerBlockingLayer(e)||!r.bypassTopMostLayerCheck&&!se.isTopMostLayer(e)||(r.onPointerDownOutside?.(d),r.onInteractOutside?.(d),d.defaultPrevented||r.onDismiss?.())},onFocusOutside:d=>{r.onFocusOutside?.(d),r.onInteractOutside?.(d),d.defaultPrevented||r.onDismiss?.()}},()=>e),Cu({ownerDocument:()=>Ce(e),onEscapeKeyDown:d=>{!e||!se.isTopMostLayer(e)||(r.onEscapeKeyDown?.(d),!d.defaultPrevented&&r.onDismiss&&(d.preventDefault(),r.onDismiss()))}}),dr(()=>{if(!e)return;se.addLayer({node:e,isPointerBlocking:r.disableOutsidePointerEvents,dismiss:r.onDismiss});const d=n?.registerNestedLayer(e);se.assignPointerEventToLayers(),se.disableBodyPointerEvents(e),z(()=>{e&&(se.removeLayer(e),d?.(),se.assignPointerEventToLayers(),se.restoreBodyPointerEvents(e))})}),I(xe([()=>e,()=>r.disableOutsidePointerEvents],([d,f])=>{if(!d)return;const p=se.find(d);p&&p.isPointerBlocking!==f&&(p.isPointerBlocking=f,se.assignPointerEventToLayers()),f&&se.disableBodyPointerEvents(d),z(()=>{se.restoreBodyPointerEvents(d)})},{defer:!0}));const u={registerNestedLayer:i};return x(qo.Provider,{value:u,get children(){return x(He,B({as:"div",ref(d){var f=Ve(p=>e=p,r.ref);typeof f=="function"&&f(d)}},s))}})}const Wo=ne();function $d(){const t=fe(Wo);if(t===void 0)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return t}function Dd(t){const e=$d(),[n,r]=J(t,["ref","style"]);return x(He,B({as:"div",ref(s){var o=Ve(e.setPositionerRef,n.ref);typeof o=="function"&&o(s)},"data-popper-positioner":"",get style(){return{position:"absolute",top:0,left:0,"min-width":"max-content",...n.style}}},r))}const Md=["top","right","bottom","left"],Ne=Math.min,ie=Math.max,yn=Math.round,an=Math.floor,Ke=t=>({x:t,y:t}),jd={left:"right",right:"left",bottom:"top",top:"bottom"},Fd={start:"end",end:"start"};function cr(t,e,n){return ie(t,Ne(e,n))}function nt(t,e){return typeof t=="function"?t(e):t}function Ue(t){return t.split("-")[0]}function kt(t){return t.split("-")[1]}function Go(t){return t==="x"?"y":"x"}function Lr(t){return t==="y"?"height":"width"}function Gt(t){return["top","bottom"].includes(Ue(t))?"y":"x"}function Rr(t){return Go(Gt(t))}function Nd(t,e,n){n===void 0&&(n=!1);const r=kt(t),s=Rr(t),o=Lr(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(i=vn(i)),[i,vn(i)]}function Kd(t){const e=vn(t);return[ur(t),e,ur(e)]}function ur(t){return t.replace(/start|end/g,e=>Fd[e])}function Ud(t,e,n){const r=["left","right"],s=["right","left"],o=["top","bottom"],i=["bottom","top"];switch(t){case"top":case"bottom":return n?e?s:r:e?r:s;case"left":case"right":return e?o:i;default:return[]}}function Bd(t,e,n,r){const s=kt(t);let o=Ud(Ue(t),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),e&&(o=o.concat(o.map(ur)))),o}function vn(t){return t.replace(/left|right|bottom|top/g,e=>jd[e])}function zd(t){return{top:0,right:0,bottom:0,left:0,...t}}function Jo(t){return typeof t!="number"?zd(t):{top:t,right:t,bottom:t,left:t}}function bn(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function Ls(t,e,n){let{reference:r,floating:s}=t;const o=Gt(e),i=Rr(e),a=Lr(i),l=Ue(e),c=o==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,f=r[a]/2-s[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-s.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-s.width,y:d};break;default:p={x:r.x,y:r.y}}switch(kt(e)){case"start":p[i]-=f*(n&&c?-1:1);break;case"end":p[i]+=f*(n&&c?-1:1);break}return p}const Vd=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=o.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:d}=Ls(c,r,l),f=r,p={},h=0;for(let g=0;g<a.length;g++){const{name:m,fn:y}=a[g],{x:v,y:w,data:b,reset:k}=await y({x:u,y:d,initialPlacement:r,placement:f,strategy:s,middlewareData:p,rects:c,platform:i,elements:{reference:t,floating:e}});u=v??u,d=w??d,p={...p,[m]:{...p[m],...b}},k&&h<=50&&(h++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(c=k.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:s}):k.rects),{x:u,y:d}=Ls(c,f,l)),g=-1)}return{x:u,y:d,placement:f,strategy:s,middlewareData:p}};async function Vt(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:o,rects:i,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=nt(e,t),h=Jo(p),m=a[f?d==="floating"?"reference":"floating":d],y=bn(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(m)))==null||n?m:m.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{...i.floating,x:r,y:s}:i.reference,w=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),b=await(o.isElement==null?void 0:o.isElement(w))?await(o.getScale==null?void 0:o.getScale(w))||{x:1,y:1}:{x:1,y:1},k=bn(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:w,strategy:l}):v);return{top:(y.top-k.top+h.top)/b.y,bottom:(k.bottom-y.bottom+h.bottom)/b.y,left:(y.left-k.left+h.left)/b.x,right:(k.right-y.right+h.right)/b.x}}const Hd=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:o,platform:i,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=nt(t,e)||{};if(c==null)return{};const d=Jo(u),f={x:n,y:r},p=Rr(s),h=Lr(p),g=await i.getDimensions(c),m=p==="y",y=m?"top":"left",v=m?"bottom":"right",w=m?"clientHeight":"clientWidth",b=o.reference[h]+o.reference[p]-f[p]-o.floating[h],k=f[p]-o.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let S=T?T[w]:0;(!S||!await(i.isElement==null?void 0:i.isElement(T)))&&(S=a.floating[w]||o.floating[h]);const C=b/2-k/2,P=S/2-g[h]/2-1,D=Ne(d[y],P),L=Ne(d[v],P),E=D,j=S-g[h]-L,K=S/2-g[h]/2+C,Y=cr(E,K,j),X=!l.arrow&&kt(s)!=null&&K!==Y&&o.reference[h]/2-(K<E?D:L)-g[h]/2<0,W=X?K<E?K-E:K-j:0;return{[p]:f[p]+W,data:{[p]:Y,centerOffset:K-Y-W,...X&&{alignmentOffset:W}},reset:X}}}),qd=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:g=!0,...m}=nt(t,e);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const y=Ue(s),v=Ue(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),b=f||(v||!g?[vn(a)]:Kd(a));!f&&h!=="none"&&b.push(...Bd(a,g,h,w));const k=[a,...b],T=await Vt(e,m),S=[];let C=((r=o.flip)==null?void 0:r.overflows)||[];if(u&&S.push(T[y]),d){const E=Nd(s,i,w);S.push(T[E[0]],T[E[1]])}if(C=[...C,{placement:s,overflows:S}],!S.every(E=>E<=0)){var P,D;const E=(((P=o.flip)==null?void 0:P.index)||0)+1,j=k[E];if(j)return{data:{index:E,overflows:C},reset:{placement:j}};let K=(D=C.filter(Y=>Y.overflows[0]<=0).sort((Y,X)=>Y.overflows[1]-X.overflows[1])[0])==null?void 0:D.placement;if(!K)switch(p){case"bestFit":{var L;const Y=(L=C.map(X=>[X.placement,X.overflows.filter(W=>W>0).reduce((W,re)=>W+re,0)]).sort((X,W)=>X[1]-W[1])[0])==null?void 0:L[0];Y&&(K=Y);break}case"initialPlacement":K=a;break}if(s!==K)return{reset:{placement:K}}}return{}}}};function Rs(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Is(t){return Md.some(e=>t[e]>=0)}const Wd=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...s}=nt(t,e);switch(r){case"referenceHidden":{const o=await Vt(e,{...s,elementContext:"reference"}),i=Rs(o,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Is(i)}}}case"escaped":{const o=await Vt(e,{...s,altBoundary:!0}),i=Rs(o,n.floating);return{data:{escapedOffsets:i,escaped:Is(i)}}}default:return{}}}}};async function Gd(t,e){const{placement:n,platform:r,elements:s}=t,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=Ue(n),a=kt(n),l=Gt(n)==="y",c=["left","top"].includes(i)?-1:1,u=o&&l?-1:1,d=nt(e,t);let{mainAxis:f,crossAxis:p,alignmentAxis:h}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return a&&typeof h=="number"&&(p=a==="end"?h*-1:h),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}const Jd=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:o,placement:i,middlewareData:a}=e,l=await Gd(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:i}}}}},Xd=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:o=!0,crossAxis:i=!1,limiter:a={fn:m=>{let{x:y,y:v}=m;return{x:y,y:v}}},...l}=nt(t,e),c={x:n,y:r},u=await Vt(e,l),d=Gt(Ue(s)),f=Go(d);let p=c[f],h=c[d];if(o){const m=f==="y"?"top":"left",y=f==="y"?"bottom":"right",v=p+u[m],w=p-u[y];p=cr(v,p,w)}if(i){const m=d==="y"?"top":"left",y=d==="y"?"bottom":"right",v=h+u[m],w=h-u[y];h=cr(v,h,w)}const g=a.fn({...e,[f]:p,[d]:h});return{...g,data:{x:g.x-n,y:g.y-r}}}}},Yd=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:r,platform:s,elements:o}=e,{apply:i=()=>{},...a}=nt(t,e),l=await Vt(e,a),c=Ue(n),u=kt(n),d=Gt(n)==="y",{width:f,height:p}=r.floating;let h,g;c==="top"||c==="bottom"?(h=c,g=u===(await(s.isRTL==null?void 0:s.isRTL(o.floating))?"start":"end")?"left":"right"):(g=c,h=u==="end"?"top":"bottom");const m=p-l[h],y=f-l[g],v=!e.middlewareData.shift;let w=m,b=y;if(d){const T=f-l.left-l.right;b=u||v?Ne(y,T):T}else{const T=p-l.top-l.bottom;w=u||v?Ne(m,T):T}if(v&&!u){const T=ie(l.left,0),S=ie(l.right,0),C=ie(l.top,0),P=ie(l.bottom,0);d?b=f-2*(T!==0||S!==0?T+S:ie(l.left,l.right)):w=p-2*(C!==0||P!==0?C+P:ie(l.top,l.bottom))}await i({...e,availableWidth:b,availableHeight:w});const k=await s.getDimensions(o.floating);return f!==k.width||p!==k.height?{reset:{rects:!0}}:{}}}};function Tt(t){return Xo(t)?(t.nodeName||"").toLowerCase():"#document"}function le(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ie(t){var e;return(e=(Xo(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Xo(t){return t instanceof Node||t instanceof le(t).Node}function ve(t){return t instanceof Element||t instanceof le(t).Element}function ke(t){return t instanceof HTMLElement||t instanceof le(t).HTMLElement}function $s(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof le(t).ShadowRoot}function Jt(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=be(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(s)}function Qd(t){return["table","td","th"].includes(Tt(t))}function An(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function Ir(t){const e=$r(),n=ve(t)?be(t):t;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Zd(t){let e=Be(t);for(;ke(e)&&!wt(e);){if(Ir(e))return e;if(An(e))return null;e=Be(e)}return null}function $r(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function wt(t){return["html","body","#document"].includes(Tt(t))}function be(t){return le(t).getComputedStyle(t)}function On(t){return ve(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Be(t){if(Tt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||$s(t)&&t.host||Ie(t);return $s(e)?e.host:e}function Yo(t){const e=Be(t);return wt(e)?t.ownerDocument?t.ownerDocument.body:t.body:ke(e)&&Jt(e)?e:Yo(e)}function Ht(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=Yo(t),o=s===((r=t.ownerDocument)==null?void 0:r.body),i=le(s);return o?e.concat(i,i.visualViewport||[],Jt(s)?s:[],i.frameElement&&n?Ht(i.frameElement):[]):e.concat(s,Ht(s,[],n))}function Qo(t){const e=be(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=ke(t),o=s?t.offsetWidth:n,i=s?t.offsetHeight:r,a=yn(n)!==o||yn(r)!==i;return a&&(n=o,r=i),{width:n,height:r,$:a}}function Dr(t){return ve(t)?t:t.contextElement}function yt(t){const e=Dr(t);if(!ke(e))return Ke(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:o}=Qo(e);let i=(o?yn(n.width):n.width)/r,a=(o?yn(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const ef=Ke(0);function Zo(t){const e=le(t);return!$r()||!e.visualViewport?ef:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function tf(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==le(t)?!1:e}function Qe(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),o=Dr(t);let i=Ke(1);e&&(r?ve(r)&&(i=yt(r)):i=yt(t));const a=tf(o,n,r)?Zo(o):Ke(0);let l=(s.left+a.x)/i.x,c=(s.top+a.y)/i.y,u=s.width/i.x,d=s.height/i.y;if(o){const f=le(o),p=r&&ve(r)?le(r):r;let h=f,g=h.frameElement;for(;g&&r&&p!==h;){const m=yt(g),y=g.getBoundingClientRect(),v=be(g),w=y.left+(g.clientLeft+parseFloat(v.paddingLeft))*m.x,b=y.top+(g.clientTop+parseFloat(v.paddingTop))*m.y;l*=m.x,c*=m.y,u*=m.x,d*=m.y,l+=w,c+=b,h=le(g),g=h.frameElement}}return bn({width:u,height:d,x:l,y:c})}function nf(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const o=s==="fixed",i=Ie(r),a=e?An(e.floating):!1;if(r===i||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=Ke(1);const u=Ke(0),d=ke(r);if((d||!d&&!o)&&((Tt(r)!=="body"||Jt(i))&&(l=On(r)),ke(r))){const f=Qe(r);c=yt(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x,y:n.y*c.y-l.scrollTop*c.y+u.y}}function rf(t){return Array.from(t.getClientRects())}function ei(t){return Qe(Ie(t)).left+On(t).scrollLeft}function sf(t){const e=Ie(t),n=On(t),r=t.ownerDocument.body,s=ie(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=ie(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ei(t);const a=-n.scrollTop;return be(r).direction==="rtl"&&(i+=ie(e.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:a}}function of(t,e){const n=le(t),r=Ie(t),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,a=0,l=0;if(s){o=s.width,i=s.height;const c=$r();(!c||c&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:o,height:i,x:a,y:l}}function af(t,e){const n=Qe(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,o=ke(t)?yt(t):Ke(1),i=t.clientWidth*o.x,a=t.clientHeight*o.y,l=s*o.x,c=r*o.y;return{width:i,height:a,x:l,y:c}}function Ds(t,e,n){let r;if(e==="viewport")r=of(t,n);else if(e==="document")r=sf(Ie(t));else if(ve(e))r=af(e,n);else{const s=Zo(t);r={...e,x:e.x-s.x,y:e.y-s.y}}return bn(r)}function ti(t,e){const n=Be(t);return n===e||!ve(n)||wt(n)?!1:be(n).position==="fixed"||ti(n,e)}function lf(t,e){const n=e.get(t);if(n)return n;let r=Ht(t,[],!1).filter(a=>ve(a)&&Tt(a)!=="body"),s=null;const o=be(t).position==="fixed";let i=o?Be(t):t;for(;ve(i)&&!wt(i);){const a=be(i),l=Ir(i);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||Jt(i)&&!l&&ti(t,i))?r=r.filter(u=>u!==i):s=a,i=Be(i)}return e.set(t,r),r}function cf(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const i=[...n==="clippingAncestors"?An(e)?[]:lf(e,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const d=Ds(e,u,s);return c.top=ie(d.top,c.top),c.right=Ne(d.right,c.right),c.bottom=Ne(d.bottom,c.bottom),c.left=ie(d.left,c.left),c},Ds(e,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function uf(t){const{width:e,height:n}=Qo(t);return{width:e,height:n}}function df(t,e,n){const r=ke(e),s=Ie(e),o=n==="fixed",i=Qe(t,!0,o,e);let a={scrollLeft:0,scrollTop:0};const l=Ke(0);if(r||!r&&!o)if((Tt(e)!=="body"||Jt(s))&&(a=On(e)),r){const d=Qe(e,!0,o,e);l.x=d.x+e.clientLeft,l.y=d.y+e.clientTop}else s&&(l.x=ei(s));const c=i.left+a.scrollLeft-l.x,u=i.top+a.scrollTop-l.y;return{x:c,y:u,width:i.width,height:i.height}}function qn(t){return be(t).position==="static"}function Ms(t,e){return!ke(t)||be(t).position==="fixed"?null:e?e(t):t.offsetParent}function ni(t,e){const n=le(t);if(An(t))return n;if(!ke(t)){let s=Be(t);for(;s&&!wt(s);){if(ve(s)&&!qn(s))return s;s=Be(s)}return n}let r=Ms(t,e);for(;r&&Qd(r)&&qn(r);)r=Ms(r,e);return r&&wt(r)&&qn(r)&&!Ir(r)?n:r||Zd(t)||n}const ff=async function(t){const e=this.getOffsetParent||ni,n=this.getDimensions,r=await n(t.floating);return{reference:df(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function hf(t){return be(t).direction==="rtl"}const ri={convertOffsetParentRelativeRectToViewportRelativeRect:nf,getDocumentElement:Ie,getClippingRect:cf,getOffsetParent:ni,getElementRects:ff,getClientRects:rf,getDimensions:uf,getScale:yt,isElement:ve,isRTL:hf};function gf(t,e){let n=null,r;const s=Ie(t);function o(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),o();const{left:c,top:u,width:d,height:f}=t.getBoundingClientRect();if(a||e(),!d||!f)return;const p=an(u),h=an(s.clientWidth-(c+d)),g=an(s.clientHeight-(u+f)),m=an(c),v={rootMargin:-p+"px "+-h+"px "+-g+"px "+-m+"px",threshold:ie(0,Ne(1,l))||1};let w=!0;function b(k){const T=k[0].intersectionRatio;if(T!==l){if(!w)return i();T?i(!1,T):r=setTimeout(()=>{i(!1,1e-7)},1e3)}w=!1}try{n=new IntersectionObserver(b,{...v,root:s.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(t)}return i(!0),o}function pf(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Dr(t),u=s||o?[...c?Ht(c):[],...Ht(e)]:[];u.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),o&&y.addEventListener("resize",n)});const d=c&&a?gf(c,n):null;let f=-1,p=null;i&&(p=new ResizeObserver(y=>{let[v]=y;v&&v.target===c&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(e)})),n()}),c&&!l&&p.observe(c),p.observe(e));let h,g=l?Qe(t):null;l&&m();function m(){const y=Qe(t);g&&(y.x!==g.x||y.y!==g.y||y.width!==g.width||y.height!==g.height)&&n(),g=y,h=requestAnimationFrame(m)}return n(),()=>{var y;u.forEach(v=>{s&&v.removeEventListener("scroll",n),o&&v.removeEventListener("resize",n)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(h)}}const mf=Jd,yf=Xd,vf=qd,bf=Yd,wf=Wd,_f=Hd,xf=(t,e,n)=>{const r=new Map,s={platform:ri,...n},o={...s.platform,_c:r};return Vd(t,e,{...s,platform:o})};function js(t){const{x:e=0,y:n=0,width:r=0,height:s=0}=t??{};if(typeof DOMRect=="function")return new DOMRect(e,n,r,s);const o={x:e,y:n,width:r,height:s,top:n,right:e+r,bottom:n+s,left:e};return{...o,toJSON:()=>o}}function Sf(t,e){return{contextElement:t,getBoundingClientRect:()=>{const r=e(t);return r?js(r):t?t.getBoundingClientRect():js()}}}function Ef(t){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(t)}const kf={top:"bottom",right:"left",bottom:"top",left:"right"};function Tf(t,e){const[n,r]=t.split("-"),s=kf[n];return r?n==="left"||n==="right"?`${s} ${r==="start"?"top":"bottom"}`:r==="start"?`${s} ${e==="rtl"?"right":"left"}`:`${s} ${e==="rtl"?"left":"right"}`:`${s} center`}function Pf(t){const e=he({getAnchorRect:f=>f?.getBoundingClientRect(),placement:"bottom",gutter:0,shift:0,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,hideWhenDetached:!1,detachedPadding:0,arrowPadding:4,overflowPadding:8},t),[n,r]=A(),[s,o]=A(),[i,a]=A(e.placement),l=()=>Sf(e.anchorRef(),e.getAnchorRect),{direction:c}=Cr();async function u(){const f=l(),p=n(),h=s();if(!f||!p)return;const g=(h?.clientHeight||0)/2,m=typeof e.gutter=="number"?e.gutter+g:e.gutter??g;p.style.setProperty("--kb-popper-content-overflow-padding",`${e.overflowPadding}px`),f.getBoundingClientRect();const y=[mf(({placement:T})=>{const S=!!T.split("-")[1];return{mainAxis:m,crossAxis:S?void 0:e.shift,alignmentAxis:e.shift}})];if(e.flip!==!1){const T=typeof e.flip=="string"?e.flip.split(" "):void 0;if(T!==void 0&&!T.every(Ef))throw new Error("`flip` expects a spaced-delimited list of placements");y.push(vf({padding:e.overflowPadding,fallbackPlacements:T}))}(e.slide||e.overlap)&&y.push(yf({mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding})),y.push(bf({padding:e.overflowPadding,apply({availableWidth:T,availableHeight:S,rects:C}){const P=Math.round(C.reference.width);T=Math.floor(T),S=Math.floor(S),p.style.setProperty("--kb-popper-anchor-width",`${P}px`),p.style.setProperty("--kb-popper-content-available-width",`${T}px`),p.style.setProperty("--kb-popper-content-available-height",`${S}px`),e.sameWidth&&(p.style.width=`${P}px`),e.fitViewport&&(p.style.maxWidth=`${T}px`,p.style.maxHeight=`${S}px`)}})),e.hideWhenDetached&&y.push(wf({padding:e.detachedPadding})),h&&y.push(_f({element:h,padding:e.arrowPadding}));const v=await xf(f,p,{placement:e.placement,strategy:"absolute",middleware:y,platform:{...ri,isRTL:()=>c()==="rtl"}});if(a(v.placement),e.onCurrentPlacementChange?.(v.placement),!p)return;p.style.setProperty("--kb-popper-content-transform-origin",Tf(v.placement,c()));const w=Math.round(v.x),b=Math.round(v.y);let k;if(e.hideWhenDetached&&(k=v.middlewareData.hide?.referenceHidden?"hidden":"visible"),Object.assign(p.style,{top:"0",left:"0",transform:`translate3d(${w}px, ${b}px, 0)`,visibility:k}),h&&v.middlewareData.arrow){const{x:T,y:S}=v.middlewareData.arrow,C=v.placement.split("-")[0];Object.assign(h.style,{left:T!=null?`${T}px`:"",top:S!=null?`${S}px`:"",[C]:"100%"})}}I(()=>{const f=l(),p=n();if(!f||!p)return;const h=pf(f,p,u,{elementResize:typeof ResizeObserver=="function"});z(h)}),I(()=>{const f=n(),p=e.contentRef();!f||!p||queueMicrotask(()=>{f.style.zIndex=getComputedStyle(p).zIndex})});const d={currentPlacement:i,contentRef:()=>e.contentRef(),setPositionerRef:r,setArrowRef:o};return x(Wo.Provider,{value:d,get children(){return e.children}})}const si=ne();function oi(){return fe(si)}function Pt(){const t=oi();if(t===void 0)throw new Error("[kobalte]: `useMenuContext` must be used within a `Menu` component");return t}const ii=ne();function rt(){const t=fe(ii);if(t===void 0)throw new Error("[kobalte]: `useMenuRootContext` must be used within a `MenuRoot` component");return t}/*!
 * Portions of this file are based on code from radix-ui-primitives.
 * MIT Licensed, Copyright (c) 2022 WorkOS.
 *
 * Credits to the Radix UI team:
 * https://github.com/radix-ui/primitives/blob/81b25f4b40c54f72aeb106ca0e64e1e09655153e/packages/react/menu/src/Menu.tsx
 */function Af(t,e){return e?Eu([t.clientX,t.clientY],e):!1}function Of(t){const e=rt(),n=zo(),r=oi(),s=he({placement:"bottom-start"},t),[o,i]=J(s,["open","defaultOpen","onOpenChange"]);let a=0,l=null,c="right";const[u,d]=A(),[f,p]=A(),[h,g]=A(),[m,y]=A(),[v,w]=A(!0),[b,k]=A(i.placement),[T,S]=A([]),[C,P]=A([]),{DomCollectionProvider:D}=_d({items:C,onItemsChange:P}),L=$o({open:()=>o.open,defaultOpen:()=>o.defaultOpen,onOpenChange:N=>o.onOpenChange?.(N)}),E=Vu(()=>e.forceMount()||L.isOpen()),j=cd({selectionMode:"none",dataSource:C}),K=N=>{w(N),L.open()},Y=(N=!1)=>{L.close(),N&&r&&r.close(!0)},X=N=>{w(N),L.toggle()},W=()=>{const N=m();N&&(te(N),j.selectionManager().setFocused(!0),j.selectionManager().setFocusedKey(void 0))},re=N=>{S(Cn=>[...Cn,N]);const Xt=r?.registerNestedMenu(N);return()=>{S(Cn=>rr(Cn,N)),Xt?.()}},Q=N=>c===l?.side&&Af(N,l?.area),qe=N=>{Q(N)&&N.preventDefault()},Te=N=>{Q(N)||W()},st=N=>{Q(N)&&N.preventDefault()};Uu({isDisabled:()=>!(r==null&&L.isOpen()&&e.isModal()),targets:()=>[m(),...T()].filter(Boolean)}),I(()=>{const N=m();if(!N||!r)return;const Xt=r.registerNestedMenu(N);z(()=>{Xt()})});const ui={dataset:O(()=>({"data-expanded":L.isOpen()?"":void 0,"data-closed":L.isOpen()?void 0:""})),isOpen:L.isOpen,contentPresence:E,nestedMenus:T,currentPlacement:b,pointerGraceTimeoutId:()=>a,autoFocus:v,listState:()=>j,parentMenuContext:()=>r,triggerRef:h,contentRef:m,triggerId:u,contentId:f,setTriggerRef:g,setContentRef:y,open:K,close:Y,toggle:X,focusContent:W,onItemEnter:qe,onItemLeave:Te,onTriggerLeave:st,setPointerDir:N=>c=N,setPointerGraceTimeoutId:N=>a=N,setPointerGraceIntent:N=>l=N,registerNestedMenu:re,registerItemToParentDomCollection:n?.registerItem,registerTriggerId:zt(d),registerContentId:zt(p)};return x(D,{get children(){return x(si.Provider,{value:ui,get children(){return x(Pf,B({anchorRef:h,contentRef:m,onCurrentPlacementChange:k},i))}})}})}const Cf=ne();function Lf(t){let e;const n=rt(),r=Pt(),s=he({id:n.generateId(`item-${xt()}`)},t),[o,i]=J(s,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[a,l]=A(),[c,u]=A(),[d,f]=A(),p=()=>r.listState().selectionManager(),h=()=>i.id,g=()=>p().focusedKey()===h(),m=()=>{o.onSelect?.(),o.closeOnSelect&&r.close(!0)};xd({getItem:()=>({ref:()=>e,type:"item",key:h(),textValue:o.textValue??d()?.textContent??e?.textContent??"",disabled:o.disabled??!1})});const y=ad({key:h,selectionManager:p,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>o.disabled},()=>e),v=P=>{ae(P,o.onPointerMove),P.pointerType==="mouse"&&(o.disabled?r.onItemLeave(P):(r.onItemEnter(P),P.defaultPrevented||(te(P.currentTarget),r.listState().selectionManager().setFocused(!0),r.listState().selectionManager().setFocusedKey(h()))))},w=P=>{ae(P,o.onPointerLeave),P.pointerType==="mouse"&&r.onItemLeave(P)},b=P=>{ae(P,o.onPointerUp),!o.disabled&&P.button===0&&m()},k=P=>{if(ae(P,o.onKeyDown),!P.repeat&&!o.disabled)switch(P.key){case"Enter":case" ":m();break}},T=O(()=>{if(o.indeterminate)return"mixed";if(o.checked!=null)return o.checked}),S=O(()=>({"data-indeterminate":o.indeterminate?"":void 0,"data-checked":o.checked&&!o.indeterminate?"":void 0,"data-disabled":o.disabled?"":void 0,"data-highlighted":g()?"":void 0})),C={isChecked:()=>o.checked,dataset:S,setLabelRef:f,generateId:Er(()=>i.id),registerLabel:zt(l),registerDescription:zt(u)};return x(Cf.Provider,{value:C,get children(){return x(He,B({as:"div",ref(P){var D=Ve(L=>e=L,o.ref);typeof D=="function"&&D(P)},get tabIndex(){return y.tabIndex()},get"aria-checked"(){return T()},get"aria-disabled"(){return o.disabled},get"aria-labelledby"(){return a()},get"aria-describedby"(){return c()},get"data-key"(){return y.dataKey()},get onPointerDown(){return de([o.onPointerDown,y.onPointerDown])},get onPointerUp(){return de([b,y.onPointerUp])},get onClick(){return de([o.onClick,y.onClick])},get onKeyDown(){return de([k,y.onKeyDown])},get onMouseDown(){return de([o.onMouseDown,y.onMouseDown])},get onFocus(){return de([o.onFocus,y.onFocus])},onPointerMove:v,onPointerLeave:w},S,i))}})}const Rf=ne();function ai(){return fe(Rf)}function If(t){let e;const n=rt(),r=Pt(),s=ai(),o=he({id:n.generateId(`content-${xt()}`)},t),[i,a]=J(o,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let l=0;const c=()=>r.parentMenuContext()==null&&s===void 0&&n.isModal(),u=dd({selectionManager:r.listState().selectionManager,collection:r.listState().collection,autoFocus:r.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!r.listState().selectionManager().isFocused()},()=>e);Nu({trapFocus:()=>c()&&r.isOpen(),onMountAutoFocus:m=>{s===void 0&&i.onOpenAutoFocus?.(m)},onUnmountAutoFocus:i.onCloseAutoFocus},()=>e);const d=m=>{if(we(m.currentTarget,m.target)&&(m.key==="Tab"&&r.isOpen()&&m.preventDefault(),s!==void 0&&m.currentTarget.getAttribute("aria-haspopup")!=="true"))switch(m.key){case"ArrowRight":m.stopPropagation(),m.preventDefault(),r.close(!0),s.setAutoFocusMenu(!0),s.nextMenu();break;case"ArrowLeft":if(m.currentTarget.hasAttribute("data-closed"))break;m.stopPropagation(),m.preventDefault(),r.close(!0),s.setAutoFocusMenu(!0),s.previousMenu();break}},f=m=>{i.onEscapeKeyDown?.(m),s?.setAutoFocusMenu(!1),r.close(!0)},p=m=>{i.onFocusOutside?.(m),n.isModal()&&m.preventDefault()},h=m=>{ae(m,i.onPointerEnter),r.isOpen()&&(r.parentMenuContext()?.listState().selectionManager().setFocused(!1),r.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},g=m=>{if(ae(m,i.onPointerMove),m.pointerType!=="mouse")return;const y=m.target,v=l!==m.clientX;we(m.currentTarget,y)&&v&&(r.setPointerDir(m.clientX>l?"right":"left"),l=m.clientX)};return I(()=>z(r.registerContentId(i.id))),x(Ze,{get when(){return r.contentPresence.isPresent()},get children(){return x(Dd,{get children(){return x(Id,B({ref(m){var y=Ve(v=>{r.setContentRef(v),r.contentPresence.setRef(v),e=v},i.ref);typeof y=="function"&&y(m)},role:"menu",get id(){return i.id},get tabIndex(){return u.tabIndex()},get disableOutsidePointerEvents(){return O(()=>!!c())()&&r.isOpen()},get excludedElements(){return[r.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return{"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative",...i.style}},get"aria-labelledby"(){return r.triggerId()},onEscapeKeyDown:f,onFocusOutside:p,get onDismiss(){return r.close},get onKeyDown(){return de([i.onKeyDown,u.onKeyDown,d])},get onMouseDown(){return de([i.onMouseDown,u.onMouseDown])},get onFocusIn(){return de([i.onFocusIn,u.onFocusIn])},get onFocusOut(){return de([i.onFocusOut,u.onFocusOut])},onPointerEnter:h,onPointerMove:g},()=>r.dataset(),a))}})}})}function $f(t){let e;const n=rt(),r=Pt(),[s,o]=J(t,["ref"]);return Ld({element:()=>e??null,enabled:()=>r.isOpen()&&n.preventScroll()}),x(If,B({ref(i){var a=Ve(l=>{e=l},s.ref);typeof a=="function"&&a(i)}},o))}const Df=ne();function Mf(t){const e=rt(),n=he({id:e.generateId(`group-${xt()}`)},t),[r,s]=A(),o={generateId:Er(()=>n.id),registerLabelId:zt(s)};return x(Df.Provider,{value:o,get children(){return x(He,B({as:"div",role:"group",get"aria-labelledby"(){return r()}},n))}})}function jf(t){return x(Lf,B({role:"menuitem",closeOnSelect:!0},t))}function Ff(t){const e=Pt();return x(Ze,{get when(){return e.contentPresence.isPresent()},get children(){return x(Xi,t)}})}function Nf(t){const e=`menu-${xt()}`,n=he({id:e,modal:!0},t),[r,s]=J(n,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value"]),o=$o({open:()=>r.open,defaultOpen:()=>r.defaultOpen,onOpenChange:a=>r.onOpenChange?.(a)}),i={isModal:()=>r.modal??!0,preventScroll:()=>r.preventScroll??i.isModal(),forceMount:()=>r.forceMount??!1,generateId:Er(()=>r.id),value:()=>r.value};return x(ii.Provider,{value:i,get children(){return x(Of,B({get open(){return o.isOpen()},get onOpenChange(){return o.setIsOpen}},s))}})}function Kf(t){const e=rt(),n=Pt(),r=ai(),s=he({id:e.generateId("trigger")},t),[o,i]=J(s,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let a;r!==void 0&&(a=e.value()??o.id,I(()=>{r.registerMenu(a,[n.contentRef(),...n.nestedMenus()])}),I(()=>{r.value()===a?(n.triggerRef()?.focus(),r.autoFocusMenu()&&n.open(!0)):n.close(!0)}),I(()=>{n.isOpen()&&r.setValue(a)}),z(()=>{r.unregisterMenu(a)}),r.lastValue()===void 0&&r.setLastValue(a));const l=()=>{r?.setAutoFocusMenu(!0),r!==void 0?n.toggle(!1):n.toggle(!0),r!==void 0&&!n.isOpen()&&r.value()===a&&r.closeMenu()},c=h=>{ae(h,o.onPointerDown),h.currentTarget.dataset.pointerType=h.pointerType,!o.disabled&&h.pointerType!=="touch"&&h.button===0&&l()},u=h=>{ae(h,o.onClick),o.disabled||h.currentTarget.dataset.pointerType==="touch"&&l()},d=h=>{if(ae(h,o.onKeyDown),!o.disabled)switch(h.key){case"Enter":case" ":case"ArrowDown":h.stopPropagation(),h.preventDefault(),ku(h.currentTarget),n.toggle("first");break;case"ArrowUp":h.stopPropagation(),h.preventDefault(),n.toggle("last");break;case"ArrowRight":if(r===void 0)break;h.stopPropagation(),h.preventDefault(),r.nextMenu();break;case"ArrowLeft":if(r===void 0)break;h.stopPropagation(),h.preventDefault(),r.previousMenu();break}},f=h=>{ae(h,o.onMouseOver),!o.disabled&&r!==void 0&&r.value()!==void 0&&r.setValue(a)},p=h=>{ae(h,o.onFocus),r!==void 0&&r.setValue(a)};return I(()=>z(n.registerTriggerId(o.id))),x(gd,B({ref(h){var g=Ve(n.setTriggerRef,o.ref);typeof g=="function"&&g(h)},get id(){return o.id},get disabled(){return o.disabled},"aria-haspopup":"true",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return O(()=>!!n.isOpen())()?n.contentId():void 0},get"data-highlighted"(){return a!==void 0&&r?.value()===a?!0:void 0},get tabIndex(){return r!==void 0?r.value()===a||r.lastValue()===a?0:-1:void 0},onPointerDown:c,onMouseOver:f,onClick:u,onKeyDown:d,onFocus:p,role:r!==void 0?"menuitem":void 0},()=>n.dataset(),i))}function Uf(t){let e;const n=he({orientation:"horizontal"},t),[r,s]=J(n,["ref","orientation"]),o=Fo(()=>e,()=>"hr");return x(He,B({as:"hr",ref(i){var a=Ve(l=>e=l,r.ref);typeof a=="function"&&a(i)},get role(){return o()!=="hr"?"separator":void 0},get"aria-orientation"(){return r.orientation==="vertical"?"vertical":void 0},get"data-orientation"(){return r.orientation}},s))}function Bf(t){const e=rt(),n=Pt(),[r,s]=J(t,["onCloseAutoFocus","onInteractOutside"]);let o=!1;return x($f,B({onCloseAutoFocus:l=>{r.onCloseAutoFocus?.(l),o||te(n.triggerRef()),o=!1,l.preventDefault()},onInteractOutside:l=>{r.onInteractOutside?.(l),(!e.isModal()||l.detail.isContextMenu)&&(o=!0)}},s))}function zf(t){const e=`dropdownmenu-${xt()}`,n=he({id:e},t);return x(Nf,n)}const li=ne();function ci(){const t=fe(li);if(t===void 0)throw new Error("[kobalte]: `useImageContext` must be used within an `Image.Root` component");return t}function Vf(t){const e=ci(),[n,r]=A(e.fallbackDelay()===void 0);return I(()=>{const s=e.fallbackDelay();if(s!==void 0){const o=window.setTimeout(()=>r(!0),s);z(()=>window.clearTimeout(o))}}),x(Ze,{get when(){return O(()=>!!n())()&&e.imageLoadingStatus()!=="loaded"},get children(){return x(He,B({as:"span"},t))}})}var Hf=et("<img>");function qf(t){const e=ci(),[n,r]=A("idle");return I(xe(()=>t.src,s=>{if(!s){r("error");return}let o=!0;const i=new window.Image,a=l=>()=>{o&&r(l)};r("loading"),i.onload=a("loaded"),i.onerror=a("error"),i.src=s,z(()=>{o=!1})})),I(()=>{const s=n();s!=="idle"&&e.onImageLoadingStatusChange(s)}),x(Ze,{get when(){return n()==="loaded"},get children(){var s=Hf();return En(s,t,!1,!1),s}})}function Wf(t){const[e,n]=J(t,["fallbackDelay","onLoadingStatusChange"]),[r,s]=A("idle"),o={fallbackDelay:()=>e.fallbackDelay,imageLoadingStatus:r,onImageLoadingStatusChange:i=>{s(i),e.onLoadingStatusChange?.(i)}};return x(li.Provider,{value:o,get children(){return x(He,B({as:"span"},n))}})}const Gf=t=>{const[,e]=J(t,["class"]);return x(Wf,B({get class(){return ze("relative flex size-10 shrink-0 overflow-hidden rounded-full",t.class)}},e))},Jf=t=>{const[,e]=J(t,["class"]);return x(qf,B({get class(){return ze("aspect-square size-full",t.class)}},e))},Xf=t=>{const[,e]=J(t,["class"]);return x(Vf,B({get class(){return ze("flex size-full items-center justify-center rounded-full bg-muted",t.class)}},e))};var Yf=et("<div>");const Qf=t=>x(zf,B({gutter:4},t)),Zf=Kf,eh=t=>{const[,e]=J(t,["class"]);return x(Ff,{get children(){return x(Bf,B({get class(){return ze("z-50 min-w-[8rem] origin-[var(--kb-menu-content-transform-origin)] animate-content-hide overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[expanded]:animate-content-show",t.class)}},e))}})},Fs=t=>{const[,e]=J(t,["class"]);return x(jf,B({get class(){return ze("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t.class)}},e))},th=t=>{const[,e]=J(t,["class","inset"]);return(()=>{var n=Yf();return En(n,B({get class(){return ze("px-2 py-1.5 text-sm font-semibold",t.inset&&"pl-8",t.class)}},e),!1,!1),n})()},Ns=t=>{const[,e]=J(t,["class"]);return x(Uf,B({get class(){return ze("-mx-1 my-1 h-px bg-muted",t.class)}},e))},nh=Mf;var rh=et('<div class="flex flex-col space-y-1"><p class="text-sm font-medium leading-none"></p><p class="text-xs leading-none text-muted-foreground">'),sh=et('<nav class="ml-auto flex items-center gap-4 sm:gap-6">');const oh=()=>{const t=xr(),{userProfile:e}=lo(),{supabase:n,session:r}=wr(),{user:s}=r();return(()=>{var o=sh();return Oe(o,x(Qf,{placement:"bottom-end",get children(){return[x(Zf,{asChild:!0,get children(){return x(qu,{component:Po,variant:"ghost",class:"relative size-8 rounded-full",get children(){return x(Gf,{class:"size-8",get children(){return[x(Jf,{get src(){return e()?.avatar_url_public},alt:"user-profile-pic"}),x(Xf,{get children(){return(e()?.full_name||"-").slice(0,1)}})]}})}})}}),x(eh,{class:"w-56",get children(){return[x(th,{class:"font-normal",get children(){var i=rh(),a=i.firstChild,l=a.nextSibling;return Oe(a,()=>e()?.full_name||"Name"),Oe(l,()=>s.email),i}}),x(Ns,{}),x(nh,{get children(){return x(Fs,{onClick:()=>t("/profile"),children:"Profile"})}}),x(Ns,{}),x(Fs,{onClick:()=>n.auth.signOut(),children:"Log out"})]}})]}})),o})()};var ih=et('<div class="flex flex-col h-screen"><header class="flex h-14 px-4 lg:px-6 items-center"><a href=/ class="flex items-center justify-center"><img alt=Logo width=42 height=42><span class=sr-only>JournalWith');const ah=t=>{const{supabase:e,session:n,setSession:r}=wr(),{setUserProfile:s}=lo(),[o,i]=A(null),a=async l=>{try{const{data:c}=await e.storage.from("public_assets").getPublicUrl(l);i(c.publicUrl)}catch(c){c instanceof Error&&console.log("Error downloading image: ",c.message)}};return I(()=>{a("logo1.png")}),I(()=>{e.auth.getSession().then(({data:{session:l}})=>{if(r(l),!l)return;const{user:c}=l;c&&e.from("user_profiles").select("*").limit(1).single().then(({data:u,error:d})=>{if(d)console.error("Error fetching profile:",d.message);else{s({...u});const f=e.storage.from("avatars").getPublicUrl(u.avatar_url);f&&s(p=>p?{...p,avatar_url_public:f.data.publicUrl}:null)}})}),e.auth.onAuthStateChange((l,c)=>{r(c)})}),(()=>{var l=ih(),c=l.firstChild,u=c.firstChild,d=u.firstChild;return Oe(c,(()=>{var f=O(()=>!!n());return()=>f()?x(oh,{}):x(Wc,{})})(),null),Oe(l,()=>t.children,null),_e(()=>gn(d,"src",o()??"/logo.svg")),l})()},lh=Sn(()=>Ee(()=>import("./Landing-CbO8p12i.js"),__vite__mapDeps([0,1]))),ch=Sn(()=>Ee(()=>import("./Auth-DGRCOpc3.js"),__vite__mapDeps([2,1,3])));function uh(){return[x(pn,{path:"/",component:lh}),x(pn,{path:"/open",component:ch})]}const dh=Sn(()=>Ee(()=>import("./Account-Ba6XJyg9.js"),__vite__mapDeps([4,3,1,5]))),fh=Sn(()=>Ee(()=>import("./Journal-C6MolKL1.js"),__vite__mapDeps([6,1,5])));function hh(){return[x(pn,{path:"/",component:fh}),x(pn,{path:"/profile",component:dh})]}const gh=t=>{const{session:e}=wr();return x(lc,{root:ah,get children(){return O(()=>!e())()?x(uh,{}):x(hh,{})}})},ph=Il("https://hdoltzpgqdoivgvnjeya.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imhkb2x0enBncWRvaXZndm5qZXlhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTE1NzkyMTgsImV4cCI6MjAyNzE1NTIxOH0.iF7kFdA6uinsPeZ9QmawpUEPdCMckh6Ag0T2VB-a1HY"),mh=document.getElementById("root");ji(()=>x($l,{client:ph,get children(){return x(Dl,{get children(){return x(gh,{})}})}}),mh);export{Jf as A,Po as B,vh as C,$n as D,pi as E,Ti as F,gn as G,bh as H,wh as M,Ze as S,z as a,I as b,A as c,xe as d,Gs as e,O as f,x as g,En as h,ze as i,Oe as j,ne as k,fe as l,B as m,wr as n,dr as o,xr as p,xh as q,Xf as r,J as s,et as t,_h as u,Gf as v,_e as w,lo as x,G as y,xt as z};
