function vL(e,t){for(var n=0;nr[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const s of a)if(s.type==="childList")for(const l of s.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(a){const s={};return a.integrity&&(s.integrity=a.integrity),a.referrerPolicy&&(s.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?s.credentials="include":a.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(a){if(a.ep)return;a.ep=!0;const s=n(a);fetch(a.href,s)}})();function sa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function EC(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){var a=!1;try{a=this instanceof r}catch{}return a?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}),n}var Ng={exports:{}},du={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var WS;function yL(){if(WS)return du;WS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,s){var l=null;if(s!==void 0&&(l=""+s),a.key!==void 0&&(l=""+a.key),"key"in a){s={};for(var c in a)c!=="key"&&(s[c]=a[c])}else s=a;return a=s.ref,{$$typeof:e,type:r,key:l,ref:a!==void 0?a:null,props:s}}return du.Fragment=t,du.jsx=n,du.jsxs=n,du}var YS;function bL(){return YS||(YS=1,Ng.exports=yL()),Ng.exports}var x=bL(),Pg={exports:{}},Pe={};/** * @license React * react.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var XS;function xL(){if(XS)return Pe;XS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),y=Symbol.iterator;function v(D){return D===null||typeof D!="object"?null:(D=y&&D[y]||D["@@iterator"],typeof D=="function"?D:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,S={};function A(D,K,le){this.props=D,this.context=K,this.refs=S,this.updater=le||w}A.prototype.isReactComponent={},A.prototype.setState=function(D,K){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,K,"setState")},A.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function j(){}j.prototype=A.prototype;function T(D,K,le){this.props=D,this.context=K,this.refs=S,this.updater=le||w}var N=T.prototype=new j;N.constructor=T,E(N,A.prototype),N.isPureReactComponent=!0;var k=Array.isArray;function P(){}var $={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function J(D,K,le){var de=le.ref;return{$$typeof:e,type:D,key:K,ref:de!==void 0?de:null,props:le}}function oe(D,K){return J(D.type,K,D.props)}function ne(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function ee(D){var K={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(le){return K[le]})}var ae=/\/+/g;function ce(D,K){return typeof D=="object"&&D!==null&&D.key!=null?ee(""+D.key):K.toString(36)}function ve(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(P,P):(D.status="pending",D.then(function(K){D.status==="pending"&&(D.status="fulfilled",D.value=K)},function(K){D.status==="pending"&&(D.status="rejected",D.reason=K)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function z(D,K,le,de,be){var De=typeof D;(De==="undefined"||De==="boolean")&&(D=null);var Ue=!1;if(D===null)Ue=!0;else switch(De){case"bigint":case"string":case"number":Ue=!0;break;case"object":switch(D.$$typeof){case e:case t:Ue=!0;break;case p:return Ue=D._init,z(Ue(D._payload),K,le,de,be)}}if(Ue)return be=be(D),Ue=de===""?"."+ce(D,0):de,k(be)?(le="",Ue!=null&&(le=Ue.replace(ae,"$&/")+"/"),z(be,K,le,"",function(ke){return ke})):be!=null&&(ne(be)&&(be=oe(be,le+(be.key==null||D&&D.key===be.key?"":(""+be.key).replace(ae,"$&/")+"/")+Ue)),K.push(be)),1;Ue=0;var St=de===""?".":de+":";if(k(D))for(var X=0;X>>1,Ce=z[ye];if(0>>1;yea(le,fe))dea(be,le)?(z[ye]=be,z[de]=fe,ye=de):(z[ye]=le,z[K]=fe,ye=K);else if(dea(be,fe))z[ye]=be,z[de]=fe,ye=de;else break e}}return F}function a(z,F){var fe=z.sortIndex-F.sortIndex;return fe!==0?fe:z.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var f=[],h=[],p=1,m=null,y=3,v=!1,w=!1,E=!1,S=!1,A=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function N(z){for(var F=n(h);F!==null;){if(F.callback===null)r(h);else if(F.startTime<=z)r(h),F.sortIndex=F.expirationTime,t(f,F);else break;F=n(h)}}function k(z){if(E=!1,N(z),!w)if(n(f)!==null)w=!0,P||(P=!0,ee());else{var F=n(h);F!==null&&ve(k,F.startTime-z)}}var P=!1,$=-1,W=5,J=-1;function oe(){return S?!0:!(e.unstable_now()-Jz&&oe());){var ye=m.callback;if(typeof ye=="function"){m.callback=null,y=m.priorityLevel;var Ce=ye(m.expirationTime<=z);if(z=e.unstable_now(),typeof Ce=="function"){m.callback=Ce,N(z),F=!0;break t}m===n(f)&&r(f),N(z)}else r(f);m=n(f)}if(m!==null)F=!0;else{var D=n(h);D!==null&&ve(k,D.startTime-z),F=!1}}break e}finally{m=null,y=fe,v=!1}F=void 0}}finally{F?ee():P=!1}}}var ee;if(typeof T=="function")ee=function(){T(ne)};else if(typeof MessageChannel<"u"){var ae=new MessageChannel,ce=ae.port2;ae.port1.onmessage=ne,ee=function(){ce.postMessage(null)}}else ee=function(){A(ne,0)};function ve(z,F){$=A(function(){z(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125ye?(z.sortIndex=fe,t(h,z),n(f)===null&&z===n(h)&&(E?(j($),$=-1):E=!0,ve(k,fe-ye))):(z.sortIndex=Ce,t(f,z),w||v||(w=!0,P||(P=!0,ee()))),z},e.unstable_shouldYield=oe,e.unstable_wrapCallback=function(z){var F=y;return function(){var fe=y;y=F;try{return z.apply(this,arguments)}finally{y=fe}}}})(Mg)),Mg}var eE;function SL(){return eE||(eE=1,Dg.exports=_L()),Dg.exports}var $g={exports:{}},mn={};/** * @license React * react-dom.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var tE;function EL(){if(tE)return mn;tE=1;var e=nl();function t(f){var h="https://react.dev/errors/"+f;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),$g.exports=EL(),$g.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var rE;function OL(){if(rE)return hu;rE=1;var e=SL(),t=nl(),n=OC();function r(i){var o="https://react.dev/errors/"+i;if(1Ce||(i.current=ye[Ce],ye[Ce]=null,Ce--)}function le(i,o){Ce++,ye[Ce]=i.current,i.current=o}var de=D(null),be=D(null),De=D(null),Ue=D(null);function St(i,o){switch(le(De,o),le(be,i),le(de,null),o.nodeType){case 9:case 11:i=(i=o.documentElement)&&(i=i.namespaceURI)?yS(i):0;break;default:if(i=o.tagName,o=o.namespaceURI)o=yS(o),i=bS(o,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(de),le(de,i)}function X(){K(de),K(be),K(De)}function ke(i){i.memoizedState!==null&&le(Ue,i);var o=de.current,u=bS(o,i.type);o!==u&&(le(be,i),le(de,u))}function ze(i){be.current===i&&(K(de),K(be)),Ue.current===i&&(K(Ue),lu._currentValue=fe)}var ie,Ut;function Be(i){if(ie===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);ie=o&&o[1]||"",Ut=-1)":-1g||R[d]!==B[g]){var Z=` `+R[d].replace(" at new "," at ");return i.displayName&&Z.includes("")&&(Z=Z.replace("",i.displayName)),Z}while(1<=d&&0<=g);break}}}finally{kt=!1,Error.prepareStackTrace=u}return(u=i?i.displayName||i.name:"")?Be(u):""}function Pr(i,o){switch(i.tag){case 26:case 27:case 5:return Be(i.type);case 16:return Be("Lazy");case 13:return i.child!==o&&o!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return Bt(i.type,!1);case 11:return Bt(i.type.render,!1);case 1:return Bt(i.type,!0);case 31:return Be("Activity");default:return""}}function Is(i){try{var o="",u=null;do o+=Pr(i,u),u=i,i=i.return;while(i);return o}catch(d){return` Error generating stack: `+d.message+` `+d.stack}}var zs=Object.prototype.hasOwnProperty,M=e.unstable_scheduleCallback,q=e.unstable_cancelCallback,Y=e.unstable_shouldYield,he=e.unstable_requestPaint,se=e.unstable_now,ue=e.unstable_getCurrentPriorityLevel,_e=e.unstable_ImmediatePriority,Ge=e.unstable_UserBlockingPriority,Xe=e.unstable_NormalPriority,jn=e.unstable_LowPriority,Ui=e.unstable_IdlePriority,Gr=e.log,vp=e.unstable_setDisableYieldValue,la=null,rn=null;function Zr(i){if(typeof Gr=="function"&&vp(i),rn&&typeof rn.setStrictMode=="function")try{rn.setStrictMode(la,i)}catch{}}var pn=Math.clz32?Math.clz32:rM,yp=Math.log,wc=Math.LN2;function rM(i){return i>>>=0,i===0?32:31-(yp(i)/wc|0)|0}var _c=256,Sc=262144,Ec=4194304;function Bi(i){var o=i&42;if(o!==0)return o;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Oc(i,o,u){var d=i.pendingLanes;if(d===0)return 0;var g=0,b=i.suspendedLanes,O=i.pingedLanes;i=i.warmLanes;var C=d&134217727;return C!==0?(d=C&~b,d!==0?g=Bi(d):(O&=C,O!==0?g=Bi(O):u||(u=C&~i,u!==0&&(g=Bi(u))))):(C=d&~b,C!==0?g=Bi(C):O!==0?g=Bi(O):u||(u=d&~i,u!==0&&(g=Bi(u)))),g===0?0:o!==0&&o!==g&&(o&b)===0&&(b=g&-g,u=o&-o,b>=u||b===32&&(u&4194048)!==0)?o:g}function wl(i,o){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&o)===0}function aM(i,o){switch(i){case 1:case 2:case 4:case 8:case 64:return o+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Qx(){var i=Ec;return Ec<<=1,(Ec&62914560)===0&&(Ec=4194304),i}function bp(i){for(var o=[],u=0;31>u;u++)o.push(i);return o}function _l(i,o){i.pendingLanes|=o,o!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function iM(i,o,u,d,g,b){var O=i.pendingLanes;i.pendingLanes=u,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=u,i.entangledLanes&=u,i.errorRecoveryDisabledLanes&=u,i.shellSuspendCounter=0;var C=i.entanglements,R=i.expirationTimes,B=i.hiddenUpdates;for(u=O&~u;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var fM=/[\n"\\]/g;function cr(i){return i.replace(fM,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function Op(i,o,u,d,g,b,O,C){i.name="",O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?i.type=O:i.removeAttribute("type"),o!=null?O==="number"?(o===0&&i.value===""||i.value!=o)&&(i.value=""+ur(o)):i.value!==""+ur(o)&&(i.value=""+ur(o)):O!=="submit"&&O!=="reset"||i.removeAttribute("value"),o!=null?Ap(i,O,ur(o)):u!=null?Ap(i,O,ur(u)):d!=null&&i.removeAttribute("value"),g==null&&b!=null&&(i.defaultChecked=!!b),g!=null&&(i.checked=g&&typeof g!="function"&&typeof g!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+ur(C):i.removeAttribute("name")}function dw(i,o,u,d,g,b,O,C){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(i.type=b),o!=null||u!=null){if(!(b!=="submit"&&b!=="reset"||o!=null)){Ep(i);return}u=u!=null?""+ur(u):"",o=o!=null?""+ur(o):u,C||o===i.value||(i.value=o),i.defaultValue=o}d=d??g,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=C?i.checked:!!d,i.defaultChecked=!!d,O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(i.name=O),Ep(i)}function Ap(i,o,u){o==="number"&&Tc(i.ownerDocument)===i||i.defaultValue===""+u||(i.defaultValue=""+u)}function Fs(i,o,u,d){if(i=i.options,o){o={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Np=!1;if(fa)try{var Al={};Object.defineProperty(Al,"passive",{get:function(){Np=!0}}),window.addEventListener("test",Al,Al),window.removeEventListener("test",Al,Al)}catch{Np=!1}var Ja=null,Pp=null,kc=null;function bw(){if(kc)return kc;var i,o=Pp,u=o.length,d,g="value"in Ja?Ja.value:Ja.textContent,b=g.length;for(i=0;i=Cl),Ow=" ",Aw=!1;function jw(i,o){switch(i){case"keyup":return zM.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Tw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ws=!1;function BM(i,o){switch(i){case"compositionend":return Tw(o);case"keypress":return o.which!==32?null:(Aw=!0,Ow);case"textInput":return i=o.data,i===Ow&&Aw?null:i;default:return null}}function qM(i,o){if(Ws)return i==="compositionend"||!Lp&&jw(i,o)?(i=bw(),kc=Pp=Ja=null,Ws=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1=o)return{node:u,offset:o-i};i=d}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=$w(u)}}function Iw(i,o){return i&&o?i===o?!0:i&&i.nodeType===3?!1:o&&o.nodeType===3?Iw(i,o.parentNode):"contains"in i?i.contains(o):i.compareDocumentPosition?!!(i.compareDocumentPosition(o)&16):!1:!1}function zw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var o=Tc(i.document);o instanceof i.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch{u=!1}if(u)i=o.contentWindow;else break;o=Tc(i.document)}return o}function Up(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o&&(o==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||o==="textarea"||i.contentEditable==="true")}var YM=fa&&"documentMode"in document&&11>=document.documentMode,Ys=null,Bp=null,Rl=null,qp=!1;function Uw(i,o,u){var d=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;qp||Ys==null||Ys!==Tc(d)||(d=Ys,"selectionStart"in d&&Up(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),Rl&&Pl(Rl,d)||(Rl=d,d=Ef(Bp,"onSelect"),0>=O,g-=O,Wr=1<<32-pn(o)+g|u<Le?(Fe=xe,xe=null):Fe=xe.sibling;var We=H(I,xe,U[Le],Q);if(We===null){xe===null&&(xe=Fe);break}i&&xe&&We.alternate===null&&o(I,xe),L=b(We,L,Le),Ze===null?Se=We:Ze.sibling=We,Ze=We,xe=Fe}if(Le===U.length)return u(I,xe),Ke&&ha(I,Le),Se;if(xe===null){for(;LeLe?(Fe=xe,xe=null):Fe=xe.sibling;var xi=H(I,xe,We.value,Q);if(xi===null){xe===null&&(xe=Fe);break}i&&xe&&xi.alternate===null&&o(I,xe),L=b(xi,L,Le),Ze===null?Se=xi:Ze.sibling=xi,Ze=xi,xe=Fe}if(We.done)return u(I,xe),Ke&&ha(I,Le),Se;if(xe===null){for(;!We.done;Le++,We=U.next())We=te(I,We.value,Q),We!==null&&(L=b(We,L,Le),Ze===null?Se=We:Ze.sibling=We,Ze=We);return Ke&&ha(I,Le),Se}for(xe=d(xe);!We.done;Le++,We=U.next())We=V(xe,I,Le,We.value,Q),We!==null&&(i&&We.alternate!==null&&xe.delete(We.key===null?Le:We.key),L=b(We,L,Le),Ze===null?Se=We:Ze.sibling=We,Ze=We);return i&&xe.forEach(function(gL){return o(I,gL)}),Ke&&ha(I,Le),Se}function it(I,L,U,Q){if(typeof U=="object"&&U!==null&&U.type===E&&U.key===null&&(U=U.props.children),typeof U=="object"&&U!==null){switch(U.$$typeof){case v:e:{for(var Se=U.key;L!==null;){if(L.key===Se){if(Se=U.type,Se===E){if(L.tag===7){u(I,L.sibling),Q=g(L,U.props.children),Q.return=I,I=Q;break e}}else if(L.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===W&&Ji(Se)===L.type){u(I,L.sibling),Q=g(L,U.props),zl(Q,U),Q.return=I,I=Q;break e}u(I,L);break}else o(I,L);L=L.sibling}U.type===E?(Q=Gi(U.props.children,I.mode,Q,U.key),Q.return=I,I=Q):(Q=Uc(U.type,U.key,U.props,null,I.mode,Q),zl(Q,U),Q.return=I,I=Q)}return O(I);case w:e:{for(Se=U.key;L!==null;){if(L.key===Se)if(L.tag===4&&L.stateNode.containerInfo===U.containerInfo&&L.stateNode.implementation===U.implementation){u(I,L.sibling),Q=g(L,U.children||[]),Q.return=I,I=Q;break e}else{u(I,L);break}else o(I,L);L=L.sibling}Q=Wp(U,I.mode,Q),Q.return=I,I=Q}return O(I);case W:return U=Ji(U),it(I,L,U,Q)}if(ve(U))return me(I,L,U,Q);if(ee(U)){if(Se=ee(U),typeof Se!="function")throw Error(r(150));return U=Se.call(U),je(I,L,U,Q)}if(typeof U.then=="function")return it(I,L,Gc(U),Q);if(U.$$typeof===T)return it(I,L,Hc(I,U),Q);Zc(I,U)}return typeof U=="string"&&U!==""||typeof U=="number"||typeof U=="bigint"?(U=""+U,L!==null&&L.tag===6?(u(I,L.sibling),Q=g(L,U),Q.return=I,I=Q):(u(I,L),Q=Zp(U,I.mode,Q),Q.return=I,I=Q),O(I)):u(I,L)}return function(I,L,U,Q){try{Il=0;var Se=it(I,L,U,Q);return oo=null,Se}catch(xe){if(xe===so||xe===Fc)throw xe;var Ze=qn(29,xe,null,I.mode);return Ze.lanes=Q,Ze.return=I,Ze}finally{}}}var es=u_(!0),c_=u_(!1),ri=!1;function om(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lm(i,o){i=i.updateQueue,o.updateQueue===i&&(o.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ai(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ii(i,o,u){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(Je&2)!==0){var g=d.pending;return g===null?o.next=o:(o.next=g.next,g.next=o),d.pending=o,o=zc(i),Gw(i,null,u),o}return Ic(i,d,o,u),zc(i)}function Ul(i,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194048)!==0)){var d=o.lanes;d&=i.pendingLanes,u|=d,o.lanes=u,tw(i,u)}}function um(i,o){var u=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,u===d)){var g=null,b=null;if(u=u.firstBaseUpdate,u!==null){do{var O={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};b===null?g=b=O:b=b.next=O,u=u.next}while(u!==null);b===null?g=b=o:b=b.next=o}else g=b=o;u={baseState:d.baseState,firstBaseUpdate:g,lastBaseUpdate:b,shared:d.shared,callbacks:d.callbacks},i.updateQueue=u;return}i=u.lastBaseUpdate,i===null?u.firstBaseUpdate=o:i.next=o,u.lastBaseUpdate=o}var cm=!1;function Bl(){if(cm){var i=io;if(i!==null)throw i}}function ql(i,o,u,d){cm=!1;var g=i.updateQueue;ri=!1;var b=g.firstBaseUpdate,O=g.lastBaseUpdate,C=g.shared.pending;if(C!==null){g.shared.pending=null;var R=C,B=R.next;R.next=null,O===null?b=B:O.next=B,O=R;var Z=i.alternate;Z!==null&&(Z=Z.updateQueue,C=Z.lastBaseUpdate,C!==O&&(C===null?Z.firstBaseUpdate=B:C.next=B,Z.lastBaseUpdate=R))}if(b!==null){var te=g.baseState;O=0,Z=B=R=null,C=b;do{var H=C.lane&-536870913,V=H!==C.lane;if(V?(Ve&H)===H:(d&H)===H){H!==0&&H===ao&&(cm=!0),Z!==null&&(Z=Z.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var me=i,je=C;H=o;var it=u;switch(je.tag){case 1:if(me=je.payload,typeof me=="function"){te=me.call(it,te,H);break e}te=me;break e;case 3:me.flags=me.flags&-65537|128;case 0:if(me=je.payload,H=typeof me=="function"?me.call(it,te,H):me,H==null)break e;te=m({},te,H);break e;case 2:ri=!0}}H=C.callback,H!==null&&(i.flags|=64,V&&(i.flags|=8192),V=g.callbacks,V===null?g.callbacks=[H]:V.push(H))}else V={lane:H,tag:C.tag,payload:C.payload,callback:C.callback,next:null},Z===null?(B=Z=V,R=te):Z=Z.next=V,O|=H;if(C=C.next,C===null){if(C=g.shared.pending,C===null)break;V=C,C=V.next,V.next=null,g.lastBaseUpdate=V,g.shared.pending=null}}while(!0);Z===null&&(R=te),g.baseState=R,g.firstBaseUpdate=B,g.lastBaseUpdate=Z,b===null&&(g.shared.lanes=0),ci|=O,i.lanes=O,i.memoizedState=te}}function f_(i,o){if(typeof i!="function")throw Error(r(191,i));i.call(o)}function d_(i,o){var u=i.callbacks;if(u!==null)for(i.callbacks=null,i=0;ib?b:8;var O=z.T,C={};z.T=C,Cm(i,!1,o,u);try{var R=g(),B=z.S;if(B!==null&&B(C,R),R!==null&&typeof R=="object"&&typeof R.then=="function"){var Z=i$(R,d);Fl(i,o,Z,Gn(i))}else Fl(i,o,d,Gn(i))}catch(te){Fl(i,o,{then:function(){},status:"rejected",reason:te},Gn())}finally{F.p=b,O!==null&&C.types!==null&&(O.types=C.types),z.T=O}}function f$(){}function jm(i,o,u,d){if(i.tag!==5)throw Error(r(476));var g=V_(i).queue;H_(i,g,o,fe,u===null?f$:function(){return F_(i),u(d)})}function V_(i){var o=i.memoizedState;if(o!==null)return o;o={memoizedState:fe,baseState:fe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:va,lastRenderedState:fe},next:null};var u={};return o.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:va,lastRenderedState:u},next:null},i.memoizedState=o,i=i.alternate,i!==null&&(i.memoizedState=o),o}function F_(i){var o=V_(i);o.next===null&&(o=i.alternate.memoizedState),Fl(i,o.next.queue,{},Gn())}function Tm(){return on(lu)}function K_(){return jt().memoizedState}function G_(){return jt().memoizedState}function d$(i){for(var o=i.return;o!==null;){switch(o.tag){case 24:case 3:var u=Gn();i=ai(u);var d=ii(o,i,u);d!==null&&(Dn(d,o,u),Ul(d,o,u)),o={cache:rm()},i.payload=o;return}o=o.return}}function h$(i,o,u){var d=Gn();u={lane:d,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},af(i)?W_(o,u):(u=Kp(i,o,u,d),u!==null&&(Dn(u,i,d),Y_(u,o,d)))}function Z_(i,o,u){var d=Gn();Fl(i,o,u,d)}function Fl(i,o,u,d){var g={lane:d,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(af(i))W_(o,g);else{var b=i.alternate;if(i.lanes===0&&(b===null||b.lanes===0)&&(b=o.lastRenderedReducer,b!==null))try{var O=o.lastRenderedState,C=b(O,u);if(g.hasEagerState=!0,g.eagerState=C,Bn(C,O))return Ic(i,o,g,0),st===null&&Lc(),!1}catch{}finally{}if(u=Kp(i,o,g,d),u!==null)return Dn(u,i,d),Y_(u,o,d),!0}return!1}function Cm(i,o,u,d){if(d={lane:2,revertLane:og(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},af(i)){if(o)throw Error(r(479))}else o=Kp(i,u,d,2),o!==null&&Dn(o,i,2)}function af(i){var o=i.alternate;return i===Me||o!==null&&o===Me}function W_(i,o){uo=Xc=!0;var u=i.pending;u===null?o.next=o:(o.next=u.next,u.next=o),i.pending=o}function Y_(i,o,u){if((u&4194048)!==0){var d=o.lanes;d&=i.pendingLanes,u|=d,o.lanes=u,tw(i,u)}}var Kl={readContext:on,use:ef,useCallback:Et,useContext:Et,useEffect:Et,useImperativeHandle:Et,useLayoutEffect:Et,useInsertionEffect:Et,useMemo:Et,useReducer:Et,useRef:Et,useState:Et,useDebugValue:Et,useDeferredValue:Et,useTransition:Et,useSyncExternalStore:Et,useId:Et,useHostTransitionStatus:Et,useFormState:Et,useActionState:Et,useOptimistic:Et,useMemoCache:Et,useCacheRefresh:Et};Kl.useEffectEvent=Et;var X_={readContext:on,use:ef,useCallback:function(i,o){return xn().memoizedState=[i,o===void 0?null:o],i},useContext:on,useEffect:D_,useImperativeHandle:function(i,o,u){u=u!=null?u.concat([i]):null,nf(4194308,4,I_.bind(null,o,i),u)},useLayoutEffect:function(i,o){return nf(4194308,4,i,o)},useInsertionEffect:function(i,o){nf(4,2,i,o)},useMemo:function(i,o){var u=xn();o=o===void 0?null:o;var d=i();if(ts){Zr(!0);try{i()}finally{Zr(!1)}}return u.memoizedState=[d,o],d},useReducer:function(i,o,u){var d=xn();if(u!==void 0){var g=u(o);if(ts){Zr(!0);try{u(o)}finally{Zr(!1)}}}else g=o;return d.memoizedState=d.baseState=g,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:g},d.queue=i,i=i.dispatch=h$.bind(null,Me,i),[d.memoizedState,i]},useRef:function(i){var o=xn();return i={current:i},o.memoizedState=i},useState:function(i){i=_m(i);var o=i.queue,u=Z_.bind(null,Me,o);return o.dispatch=u,[i.memoizedState,u]},useDebugValue:Om,useDeferredValue:function(i,o){var u=xn();return Am(u,i,o)},useTransition:function(){var i=_m(!1);return i=H_.bind(null,Me,i.queue,!0,!1),xn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,o,u){var d=Me,g=xn();if(Ke){if(u===void 0)throw Error(r(407));u=u()}else{if(u=o(),st===null)throw Error(r(349));(Ve&127)!==0||y_(d,o,u)}g.memoizedState=u;var b={value:u,getSnapshot:o};return g.queue=b,D_(x_.bind(null,d,b,i),[i]),d.flags|=2048,fo(9,{destroy:void 0},b_.bind(null,d,b,u,o),null),u},useId:function(){var i=xn(),o=st.identifierPrefix;if(Ke){var u=Yr,d=Wr;u=(d&~(1<<32-pn(d)-1)).toString(32)+u,o="_"+o+"R_"+u,u=Jc++,0<\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof d.is=="string"?O.createElement("select",{is:d.is}):O.createElement("select"),d.multiple?b.multiple=!0:d.size&&(b.size=d.size);break;default:b=typeof d.is=="string"?O.createElement(g,{is:d.is}):O.createElement(g)}}b[an]=o,b[Tn]=d;e:for(O=o.child;O!==null;){if(O.tag===5||O.tag===6)b.appendChild(O.stateNode);else if(O.tag!==4&&O.tag!==27&&O.child!==null){O.child.return=O,O=O.child;continue}if(O===o)break e;for(;O.sibling===null;){if(O.return===null||O.return===o)break e;O=O.return}O.sibling.return=O.return,O=O.sibling}o.stateNode=b;e:switch(un(b,g,d),g){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&ba(o)}}return pt(o),Hm(o,o.type,i===null?null:i.memoizedProps,o.pendingProps,u),null;case 6:if(i&&o.stateNode!=null)i.memoizedProps!==d&&ba(o);else{if(typeof d!="string"&&o.stateNode===null)throw Error(r(166));if(i=De.current,no(o)){if(i=o.stateNode,u=o.memoizedProps,d=null,g=sn,g!==null)switch(g.tag){case 27:case 5:d=g.memoizedProps}i[an]=o,i=!!(i.nodeValue===u||d!==null&&d.suppressHydrationWarning===!0||gS(i.nodeValue,u)),i||ti(o,!0)}else i=Of(i).createTextNode(d),i[an]=o,o.stateNode=i}return pt(o),null;case 31:if(u=o.memoizedState,i===null||i.memoizedState!==null){if(d=no(o),u!==null){if(i===null){if(!d)throw Error(r(318));if(i=o.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[an]=o}else Zi(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;pt(o),i=!1}else u=Qp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),i=!0;if(!i)return o.flags&256?(Vn(o),o):(Vn(o),null);if((o.flags&128)!==0)throw Error(r(558))}return pt(o),null;case 13:if(d=o.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(g=no(o),d!==null&&d.dehydrated!==null){if(i===null){if(!g)throw Error(r(318));if(g=o.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(r(317));g[an]=o}else Zi(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;pt(o),g=!1}else g=Qp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=g),g=!0;if(!g)return o.flags&256?(Vn(o),o):(Vn(o),null)}return Vn(o),(o.flags&128)!==0?(o.lanes=u,o):(u=d!==null,i=i!==null&&i.memoizedState!==null,u&&(d=o.child,g=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(g=d.alternate.memoizedState.cachePool.pool),b=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(b=d.memoizedState.cachePool.pool),b!==g&&(d.flags|=2048)),u!==i&&u&&(o.child.flags|=8192),cf(o,o.updateQueue),pt(o),null);case 4:return X(),i===null&&fg(o.stateNode.containerInfo),pt(o),null;case 10:return ma(o.type),pt(o),null;case 19:if(K(At),d=o.memoizedState,d===null)return pt(o),null;if(g=(o.flags&128)!==0,b=d.rendering,b===null)if(g)Zl(d,!1);else{if(Ot!==0||i!==null&&(i.flags&128)!==0)for(i=o.child;i!==null;){if(b=Yc(i),b!==null){for(o.flags|=128,Zl(d,!1),i=b.updateQueue,o.updateQueue=i,cf(o,i),o.subtreeFlags=0,i=u,u=o.child;u!==null;)Zw(u,i),u=u.sibling;return le(At,At.current&1|2),Ke&&ha(o,d.treeForkCount),o.child}i=i.sibling}d.tail!==null&&se()>mf&&(o.flags|=128,g=!0,Zl(d,!1),o.lanes=4194304)}else{if(!g)if(i=Yc(b),i!==null){if(o.flags|=128,g=!0,i=i.updateQueue,o.updateQueue=i,cf(o,i),Zl(d,!0),d.tail===null&&d.tailMode==="hidden"&&!b.alternate&&!Ke)return pt(o),null}else 2*se()-d.renderingStartTime>mf&&u!==536870912&&(o.flags|=128,g=!0,Zl(d,!1),o.lanes=4194304);d.isBackwards?(b.sibling=o.child,o.child=b):(i=d.last,i!==null?i.sibling=b:o.child=b,d.last=b)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=se(),i.sibling=null,u=At.current,le(At,g?u&1|2:u&1),Ke&&ha(o,d.treeForkCount),i):(pt(o),null);case 22:case 23:return Vn(o),dm(),d=o.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(o.flags|=8192):d&&(o.flags|=8192),d?(u&536870912)!==0&&(o.flags&128)===0&&(pt(o),o.subtreeFlags&6&&(o.flags|=8192)):pt(o),u=o.updateQueue,u!==null&&cf(o,u.retryQueue),u=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(u=i.memoizedState.cachePool.pool),d=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(d=o.memoizedState.cachePool.pool),d!==u&&(o.flags|=2048),i!==null&&K(Xi),null;case 24:return u=null,i!==null&&(u=i.memoizedState.cache),o.memoizedState.cache!==u&&(o.flags|=2048),ma(Nt),pt(o),null;case 25:return null;case 30:return null}throw Error(r(156,o.tag))}function y$(i,o){switch(Xp(o),o.tag){case 1:return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 3:return ma(Nt),X(),i=o.flags,(i&65536)!==0&&(i&128)===0?(o.flags=i&-65537|128,o):null;case 26:case 27:case 5:return ze(o),null;case 31:if(o.memoizedState!==null){if(Vn(o),o.alternate===null)throw Error(r(340));Zi()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 13:if(Vn(o),i=o.memoizedState,i!==null&&i.dehydrated!==null){if(o.alternate===null)throw Error(r(340));Zi()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 19:return K(At),null;case 4:return X(),null;case 10:return ma(o.type),null;case 22:case 23:return Vn(o),dm(),i!==null&&K(Xi),i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 24:return ma(Nt),null;case 25:return null;default:return null}}function w1(i,o){switch(Xp(o),o.tag){case 3:ma(Nt),X();break;case 26:case 27:case 5:ze(o);break;case 4:X();break;case 31:o.memoizedState!==null&&Vn(o);break;case 13:Vn(o);break;case 19:K(At);break;case 10:ma(o.type);break;case 22:case 23:Vn(o),dm(),i!==null&&K(Xi);break;case 24:ma(Nt)}}function Wl(i,o){try{var u=o.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var g=d.next;u=g;do{if((u.tag&i)===i){d=void 0;var b=u.create,O=u.inst;d=b(),O.destroy=d}u=u.next}while(u!==g)}}catch(C){tt(o,o.return,C)}}function li(i,o,u){try{var d=o.updateQueue,g=d!==null?d.lastEffect:null;if(g!==null){var b=g.next;d=b;do{if((d.tag&i)===i){var O=d.inst,C=O.destroy;if(C!==void 0){O.destroy=void 0,g=o;var R=u,B=C;try{B()}catch(Z){tt(g,R,Z)}}}d=d.next}while(d!==b)}}catch(Z){tt(o,o.return,Z)}}function _1(i){var o=i.updateQueue;if(o!==null){var u=i.stateNode;try{d_(o,u)}catch(d){tt(i,i.return,d)}}}function S1(i,o,u){u.props=ns(i.type,i.memoizedProps),u.state=i.memoizedState;try{u.componentWillUnmount()}catch(d){tt(i,o,d)}}function Yl(i,o){try{var u=i.ref;if(u!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof u=="function"?i.refCleanup=u(d):u.current=d}}catch(g){tt(i,o,g)}}function Xr(i,o){var u=i.ref,d=i.refCleanup;if(u!==null)if(typeof d=="function")try{d()}catch(g){tt(i,o,g)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(g){tt(i,o,g)}else u.current=null}function E1(i){var o=i.type,u=i.memoizedProps,d=i.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":u.autoFocus&&d.focus();break e;case"img":u.src?d.src=u.src:u.srcSet&&(d.srcset=u.srcSet)}}catch(g){tt(i,i.return,g)}}function Vm(i,o,u){try{var d=i.stateNode;U$(d,i.type,u,o),d[Tn]=o}catch(g){tt(i,i.return,g)}}function O1(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&mi(i.type)||i.tag===4}function Fm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||O1(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&mi(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Km(i,o,u){var d=i.tag;if(d===5||d===6)i=i.stateNode,o?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(i,o):(o=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,o.appendChild(i),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=ca));else if(d!==4&&(d===27&&mi(i.type)&&(u=i.stateNode,o=null),i=i.child,i!==null))for(Km(i,o,u),i=i.sibling;i!==null;)Km(i,o,u),i=i.sibling}function ff(i,o,u){var d=i.tag;if(d===5||d===6)i=i.stateNode,o?u.insertBefore(i,o):u.appendChild(i);else if(d!==4&&(d===27&&mi(i.type)&&(u=i.stateNode),i=i.child,i!==null))for(ff(i,o,u),i=i.sibling;i!==null;)ff(i,o,u),i=i.sibling}function A1(i){var o=i.stateNode,u=i.memoizedProps;try{for(var d=i.type,g=o.attributes;g.length;)o.removeAttributeNode(g[0]);un(o,d,u),o[an]=i,o[Tn]=u}catch(b){tt(i,i.return,b)}}var xa=!1,Dt=!1,Gm=!1,j1=typeof WeakSet=="function"?WeakSet:Set,Xt=null;function b$(i,o){if(i=i.containerInfo,pg=Pf,i=zw(i),Up(i)){if("selectionStart"in i)var u={start:i.selectionStart,end:i.selectionEnd};else e:{u=(u=i.ownerDocument)&&u.defaultView||window;var d=u.getSelection&&u.getSelection();if(d&&d.rangeCount!==0){u=d.anchorNode;var g=d.anchorOffset,b=d.focusNode;d=d.focusOffset;try{u.nodeType,b.nodeType}catch{u=null;break e}var O=0,C=-1,R=-1,B=0,Z=0,te=i,H=null;t:for(;;){for(var V;te!==u||g!==0&&te.nodeType!==3||(C=O+g),te!==b||d!==0&&te.nodeType!==3||(R=O+d),te.nodeType===3&&(O+=te.nodeValue.length),(V=te.firstChild)!==null;)H=te,te=V;for(;;){if(te===i)break t;if(H===u&&++B===g&&(C=O),H===b&&++Z===d&&(R=O),(V=te.nextSibling)!==null)break;te=H,H=te.parentNode}te=V}u=C===-1||R===-1?null:{start:C,end:R}}else u=null}u=u||{start:0,end:0}}else u=null;for(mg={focusedElem:i,selectionRange:u},Pf=!1,Xt=o;Xt!==null;)if(o=Xt,i=o.child,(o.subtreeFlags&1028)!==0&&i!==null)i.return=o,Xt=i;else for(;Xt!==null;){switch(o=Xt,b=o.alternate,i=o.flags,o.tag){case 0:if((i&4)!==0&&(i=o.updateQueue,i=i!==null?i.events:null,i!==null))for(u=0;u title"))),un(b,d,u),b[an]=i,Yt(b),d=b;break e;case"link":var O=RS("link","href",g).get(d+(u.href||""));if(O){for(var C=0;Cit&&(O=it,it=je,je=O);var I=Lw(C,je),L=Lw(C,it);if(I&&L&&(V.rangeCount!==1||V.anchorNode!==I.node||V.anchorOffset!==I.offset||V.focusNode!==L.node||V.focusOffset!==L.offset)){var U=te.createRange();U.setStart(I.node,I.offset),V.removeAllRanges(),je>it?(V.addRange(U),V.extend(L.node,L.offset)):(U.setEnd(L.node,L.offset),V.addRange(U))}}}}for(te=[],V=C;V=V.parentNode;)V.nodeType===1&&te.push({element:V,left:V.scrollLeft,top:V.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;Cu?32:u,z.T=null,u=eg,eg=null;var b=di,O=Oa;if(qt=0,vo=di=null,Oa=0,(Je&6)!==0)throw Error(r(331));var C=Je;if(Je|=4,I1(b.current),M1(b,b.current,O,u),Je=C,nu(0,!1),rn&&typeof rn.onPostCommitFiberRoot=="function")try{rn.onPostCommitFiberRoot(la,b)}catch{}return!0}finally{F.p=g,z.T=d,nS(i,o)}}function aS(i,o,u){o=dr(u,o),o=Rm(i.stateNode,o,2),i=ii(i,o,2),i!==null&&(_l(i,2),Jr(i))}function tt(i,o,u){if(i.tag===3)aS(i,i,u);else for(;o!==null;){if(o.tag===3){aS(o,i,u);break}else if(o.tag===1){var d=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(fi===null||!fi.has(d))){i=dr(u,i),u=i1(2),d=ii(o,u,2),d!==null&&(s1(u,d,o,i),_l(d,2),Jr(d));break}}o=o.return}}function ag(i,o,u){var d=i.pingCache;if(d===null){d=i.pingCache=new _$;var g=new Set;d.set(o,g)}else g=d.get(o),g===void 0&&(g=new Set,d.set(o,g));g.has(u)||(Ym=!0,g.add(u),i=j$.bind(null,i,o,u),o.then(i,i))}function j$(i,o,u){var d=i.pingCache;d!==null&&d.delete(o),i.pingedLanes|=i.suspendedLanes&u,i.warmLanes&=~u,st===i&&(Ve&u)===u&&(Ot===4||Ot===3&&(Ve&62914560)===Ve&&300>se()-pf?(Je&2)===0&&yo(i,0):Xm|=u,go===Ve&&(go=0)),Jr(i)}function iS(i,o){o===0&&(o=Qx()),i=Ki(i,o),i!==null&&(_l(i,o),Jr(i))}function T$(i){var o=i.memoizedState,u=0;o!==null&&(u=o.retryLane),iS(i,u)}function C$(i,o){var u=0;switch(i.tag){case 31:case 13:var d=i.stateNode,g=i.memoizedState;g!==null&&(u=g.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(o),iS(i,u)}function k$(i,o){return M(i,o)}var wf=null,xo=null,ig=!1,_f=!1,sg=!1,pi=0;function Jr(i){i!==xo&&i.next===null&&(xo===null?wf=xo=i:xo=xo.next=i),_f=!0,ig||(ig=!0,P$())}function nu(i,o){if(!sg&&_f){sg=!0;do for(var u=!1,d=wf;d!==null;){if(i!==0){var g=d.pendingLanes;if(g===0)var b=0;else{var O=d.suspendedLanes,C=d.pingedLanes;b=(1<<31-pn(42|i)+1)-1,b&=g&~(O&~C),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(u=!0,uS(d,b))}else b=Ve,b=Oc(d,d===st?b:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(b&3)===0||wl(d,b)||(u=!0,uS(d,b));d=d.next}while(u);sg=!1}}function N$(){sS()}function sS(){_f=ig=!1;var i=0;pi!==0&&q$()&&(i=pi);for(var o=se(),u=null,d=wf;d!==null;){var g=d.next,b=oS(d,o);b===0?(d.next=null,u===null?wf=g:u.next=g,g===null&&(xo=u)):(u=d,(i!==0||(b&3)!==0)&&(_f=!0)),d=g}qt!==0&&qt!==5||nu(i),pi!==0&&(pi=0)}function oS(i,o){for(var u=i.suspendedLanes,d=i.pingedLanes,g=i.expirationTimes,b=i.pendingLanes&-62914561;0C)break;var Z=R.transferSize,te=R.initiatorType;Z&&vS(te)&&(R=R.responseEnd,O+=Z*(R"u"?null:document;function CS(i,o,u){var d=wo;if(d&&typeof o=="string"&&o){var g=cr(o);g='link[rel="'+i+'"][href="'+g+'"]',typeof u=="string"&&(g+='[crossorigin="'+u+'"]'),TS.has(g)||(TS.add(g),i={rel:i,crossOrigin:u,href:o},d.querySelector(g)===null&&(o=d.createElement("link"),un(o,"link",i),Yt(o),d.head.appendChild(o)))}}function X$(i){Aa.D(i),CS("dns-prefetch",i,null)}function J$(i,o){Aa.C(i,o),CS("preconnect",i,o)}function Q$(i,o,u){Aa.L(i,o,u);var d=wo;if(d&&i&&o){var g='link[rel="preload"][as="'+cr(o)+'"]';o==="image"&&u&&u.imageSrcSet?(g+='[imagesrcset="'+cr(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(g+='[imagesizes="'+cr(u.imageSizes)+'"]')):g+='[href="'+cr(i)+'"]';var b=g;switch(o){case"style":b=_o(i);break;case"script":b=So(i)}yr.has(b)||(i=m({rel:"preload",href:o==="image"&&u&&u.imageSrcSet?void 0:i,as:o},u),yr.set(b,i),d.querySelector(g)!==null||o==="style"&&d.querySelector(su(b))||o==="script"&&d.querySelector(ou(b))||(o=d.createElement("link"),un(o,"link",i),Yt(o),d.head.appendChild(o)))}}function eL(i,o){Aa.m(i,o);var u=wo;if(u&&i){var d=o&&typeof o.as=="string"?o.as:"script",g='link[rel="modulepreload"][as="'+cr(d)+'"][href="'+cr(i)+'"]',b=g;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=So(i)}if(!yr.has(b)&&(i=m({rel:"modulepreload",href:i},o),yr.set(b,i),u.querySelector(g)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(ou(b)))return}d=u.createElement("link"),un(d,"link",i),Yt(d),u.head.appendChild(d)}}}function tL(i,o,u){Aa.S(i,o,u);var d=wo;if(d&&i){var g=Hs(d).hoistableStyles,b=_o(i);o=o||"default";var O=g.get(b);if(!O){var C={loading:0,preload:null};if(O=d.querySelector(su(b)))C.loading=5;else{i=m({rel:"stylesheet",href:i,"data-precedence":o},u),(u=yr.get(b))&&_g(i,u);var R=O=d.createElement("link");Yt(R),un(R,"link",i),R._p=new Promise(function(B,Z){R.onload=B,R.onerror=Z}),R.addEventListener("load",function(){C.loading|=1}),R.addEventListener("error",function(){C.loading|=2}),C.loading|=4,jf(O,o,d)}O={type:"stylesheet",instance:O,count:1,state:C},g.set(b,O)}}}function nL(i,o){Aa.X(i,o);var u=wo;if(u&&i){var d=Hs(u).hoistableScripts,g=So(i),b=d.get(g);b||(b=u.querySelector(ou(g)),b||(i=m({src:i,async:!0},o),(o=yr.get(g))&&Sg(i,o),b=u.createElement("script"),Yt(b),un(b,"link",i),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},d.set(g,b))}}function rL(i,o){Aa.M(i,o);var u=wo;if(u&&i){var d=Hs(u).hoistableScripts,g=So(i),b=d.get(g);b||(b=u.querySelector(ou(g)),b||(i=m({src:i,async:!0,type:"module"},o),(o=yr.get(g))&&Sg(i,o),b=u.createElement("script"),Yt(b),un(b,"link",i),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},d.set(g,b))}}function kS(i,o,u,d){var g=(g=De.current)?Af(g):null;if(!g)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(o=_o(u.href),u=Hs(g).hoistableStyles,d=u.get(o),d||(d={type:"style",instance:null,count:0,state:null},u.set(o,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){i=_o(u.href);var b=Hs(g).hoistableStyles,O=b.get(i);if(O||(g=g.ownerDocument||g,O={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(i,O),(b=g.querySelector(su(i)))&&!b._p&&(O.instance=b,O.state.loading=5),yr.has(i)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},yr.set(i,u),b||aL(g,i,u,O.state))),o&&d===null)throw Error(r(528,""));return O}if(o&&d!==null)throw Error(r(529,""));return null;case"script":return o=u.async,u=u.src,typeof u=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=So(u),u=Hs(g).hoistableScripts,d=u.get(o),d||(d={type:"script",instance:null,count:0,state:null},u.set(o,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function _o(i){return'href="'+cr(i)+'"'}function su(i){return'link[rel="stylesheet"]['+i+"]"}function NS(i){return m({},i,{"data-precedence":i.precedence,precedence:null})}function aL(i,o,u,d){i.querySelector('link[rel="preload"][as="style"]['+o+"]")?d.loading=1:(o=i.createElement("link"),d.preload=o,o.addEventListener("load",function(){return d.loading|=1}),o.addEventListener("error",function(){return d.loading|=2}),un(o,"link",u),Yt(o),i.head.appendChild(o))}function So(i){return'[src="'+cr(i)+'"]'}function ou(i){return"script[async]"+i}function PS(i,o,u){if(o.count++,o.instance===null)switch(o.type){case"style":var d=i.querySelector('style[data-href~="'+cr(u.href)+'"]');if(d)return o.instance=d,Yt(d),d;var g=m({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Yt(d),un(d,"style",g),jf(d,u.precedence,i),o.instance=d;case"stylesheet":g=_o(u.href);var b=i.querySelector(su(g));if(b)return o.state.loading|=4,o.instance=b,Yt(b),b;d=NS(u),(g=yr.get(g))&&_g(d,g),b=(i.ownerDocument||i).createElement("link"),Yt(b);var O=b;return O._p=new Promise(function(C,R){O.onload=C,O.onerror=R}),un(b,"link",d),o.state.loading|=4,jf(b,u.precedence,i),o.instance=b;case"script":return b=So(u.src),(g=i.querySelector(ou(b)))?(o.instance=g,Yt(g),g):(d=u,(g=yr.get(b))&&(d=m({},u),Sg(d,g)),i=i.ownerDocument||i,g=i.createElement("script"),Yt(g),un(g,"link",d),i.head.appendChild(g),o.instance=g);case"void":return null;default:throw Error(r(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(d=o.instance,o.state.loading|=4,jf(d,u.precedence,i));return o.instance}function jf(i,o,u){for(var d=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=d.length?d[d.length-1]:null,b=g,O=0;O title"):null)}function iL(i,o,u){if(u===1||o.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;switch(o.rel){case"stylesheet":return i=o.disabled,typeof o.precedence=="string"&&i==null;default:return!0}case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function MS(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function sL(i,o,u,d){if(u.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var g=_o(d.href),b=o.querySelector(su(g));if(b){o=b._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(i.count++,i=Cf.bind(i),o.then(i,i)),u.state.loading|=4,u.instance=b,Yt(b);return}b=o.ownerDocument||o,d=NS(d),(g=yr.get(g))&&_g(d,g),b=b.createElement("link"),Yt(b);var O=b;O._p=new Promise(function(C,R){O.onload=C,O.onerror=R}),un(b,"link",d),u.instance=b}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(u,o),(o=u.state.preload)&&(u.state.loading&3)===0&&(i.count++,u=Cf.bind(i),o.addEventListener("load",u),o.addEventListener("error",u))}}var Eg=0;function oL(i,o){return i.stylesheets&&i.count===0&&Nf(i,i.stylesheets),0Eg?50:800)+o);return i.unsuspend=u,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(g)}}:null}function Cf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Nf(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var kf=null;function Nf(i,o){i.stylesheets=null,i.unsuspend!==null&&(i.count++,kf=new Map,o.forEach(lL,i),kf=null,Cf.call(i))}function lL(i,o){if(!(o.state.loading&4)){var u=kf.get(i);if(u)var d=u.get(null);else{u=new Map,kf.set(i,u);for(var g=i.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Rg.exports=OL(),Rg.exports}var jL=AL();const TL=sa(jL),Ne=e=>typeof e=="string",pu=()=>{let e,t;const n=new Promise((r,a)=>{e=r,t=a});return n.resolve=e,n.reject=t,n},iE=e=>e==null?"":""+e,CL=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},kL=/###/g,sE=e=>e&&e.indexOf("###")>-1?e.replace(kL,"."):e,oE=e=>!e||Ne(e),Cu=(e,t,n)=>{const r=Ne(t)?t.split("."):t;let a=0;for(;a{const{obj:r,k:a}=Cu(e,t,Object);if(r!==void 0||t.length===1){r[a]=n;return}let s=t[t.length-1],l=t.slice(0,t.length-1),c=Cu(e,l,Object);for(;c.obj===void 0&&l.length;)s=`${l[l.length-1]}.${s}`,l=l.slice(0,l.length-1),c=Cu(e,l,Object),c?.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},NL=(e,t,n,r)=>{const{obj:a,k:s}=Cu(e,t,Object);a[s]=a[s]||[],a[s].push(n)},_d=(e,t)=>{const{obj:n,k:r}=Cu(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},PL=(e,t,n)=>{const r=_d(e,n);return r!==void 0?r:_d(t,n)},AC=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?Ne(e[r])||e[r]instanceof String||Ne(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):AC(e[r],t[r],n):e[r]=t[r]);return e},Oo=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var RL={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const DL=e=>Ne(e)?e.replace(/[&<>"'\/]/g,t=>RL[t]):e;class ML{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const r=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,r),this.regExpQueue.push(t),r}}const $L=[" ",",","?","!",";"],LL=new ML(20),IL=(e,t,n)=>{t=t||"",n=n||"";const r=$L.filter(l=>t.indexOf(l)<0&&n.indexOf(l)<0);if(r.length===0)return!0;const a=LL.getRegExp(`(${r.map(l=>l==="?"?"\\?":l).join("|")})`);let s=!a.test(e);if(!s){const l=e.indexOf(n);l>0&&!a.test(e.substring(0,l))&&(s=!0)}return s},Ay=(e,t,n=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const r=t.split(n);let a=e;for(let s=0;s-1&&fe?.replace("_","-"),zL={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class Sd{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||zL,this.options=n,this.debug=n.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,a){return a&&!this.debug?null:(Ne(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Sd(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Sd(this.logger,t)}}var ea=new Sd;let _h=class{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const a=this.observers[r].get(n)||0;this.observers[r].set(n,a+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t,...n){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([a,s])=>{for(let l=0;l{for(let l=0;l-1&&this.options.ns.splice(n,1)}getResource(t,n,r,a={}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,l=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;t.indexOf(".")>-1?c=t.split("."):(c=[t,n],r&&(Array.isArray(r)?c.push(...r):Ne(r)&&s?c.push(...r.split(s)):c.push(r)));const f=_d(this.data,c);return!f&&!n&&!r&&t.indexOf(".")>-1&&(t=c[0],n=c[1],r=c.slice(2).join(".")),f||!l||!Ne(r)?f:Ay(this.data?.[t]?.[n],r,s)}addResource(t,n,r,a,s={silent:!1}){const l=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[t,n];r&&(c=c.concat(l?r.split(l):r)),t.indexOf(".")>-1&&(c=t.split("."),a=n,n=c[1]),this.addNamespaces(n),lE(this.data,c,a),s.silent||this.emit("added",t,n,r,a)}addResources(t,n,r,a={silent:!1}){for(const s in r)(Ne(r[s])||Array.isArray(r[s]))&&this.addResource(t,n,s,r[s],{silent:!0});a.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,a,s,l={silent:!1,skipCopy:!1}){let c=[t,n];t.indexOf(".")>-1&&(c=t.split("."),a=r,r=n,n=c[1]),this.addNamespaces(n);let f=_d(this.data,c)||{};l.skipCopy||(r=JSON.parse(JSON.stringify(r))),a?AC(f,r,s):f={...f,...r},lE(this.data,c,f),l.silent||this.emit("added",t,n,r)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(a=>n[a]&&Object.keys(n[a]).length>0)}toJSON(){return this.data}}var jC={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,a){return e.forEach(s=>{t=this.processors[s]?.process(t,n,r,a)??t}),t}};const TC=Symbol("i18next/PATH_KEY");function UL(){const e=[],t=Object.create(null);let n;return t.get=(r,a)=>(n?.revoke?.(),a===TC?e:(e.push(a),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function jy(e,t){const{[TC]:n}=e(UL());return n.join(t?.keySeparator??".")}const cE={},Lg=e=>!Ne(e)&&typeof e!="boolean"&&typeof e!="number";class Ed extends _h{constructor(t,n={}){super(),CL(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ea.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const r={...n};if(t==null)return!1;const a=this.resolve(t,r);if(a?.res===void 0)return!1;const s=Lg(a.res);return!(r.returnObjects===!1&&s)}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const l=r&&t.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!IL(t,r,a);if(l&&!c){const f=t.match(this.interpolator.nestingRegexp);if(f&&f.length>0)return{key:t,namespaces:Ne(s)?[s]:s};const h=t.split(r);(r!==a||r===a&&this.options.ns.indexOf(h[0])>-1)&&(s=h.shift()),t=h.join(a)}return{key:t,namespaces:Ne(s)?[s]:s}}translate(t,n,r){let a=typeof n=="object"?{...n}:n;if(typeof a!="object"&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a=="object"&&(a={...a}),a||(a={}),t==null)return"";typeof t=="function"&&(t=jy(t,{...this.options,...a})),Array.isArray(t)||(t=[String(t)]);const s=a.returnDetails!==void 0?a.returnDetails:this.options.returnDetails,l=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,{key:c,namespaces:f}=this.extractFromKey(t[t.length-1],a),h=f[f.length-1];let p=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;p===void 0&&(p=":");const m=a.lng||this.language,y=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(m?.toLowerCase()==="cimode")return y?s?{res:`${h}${p}${c}`,usedKey:c,exactUsedKey:c,usedLng:m,usedNS:h,usedParams:this.getUsedParamsDetails(a)}:`${h}${p}${c}`:s?{res:c,usedKey:c,exactUsedKey:c,usedLng:m,usedNS:h,usedParams:this.getUsedParamsDetails(a)}:c;const v=this.resolve(t,a);let w=v?.res;const E=v?.usedKey||c,S=v?.exactUsedKey||c,A=["[object Number]","[object Function]","[object RegExp]"],j=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,T=!this.i18nFormat||this.i18nFormat.handleAsObject,N=a.count!==void 0&&!Ne(a.count),k=Ed.hasDefaultValue(a),P=N?this.pluralResolver.getSuffix(m,a.count,a):"",$=a.ordinal&&N?this.pluralResolver.getSuffix(m,a.count,{ordinal:!1}):"",W=N&&!a.ordinal&&a.count===0,J=W&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${P}`]||a[`defaultValue${$}`]||a.defaultValue;let oe=w;T&&!w&&k&&(oe=J);const ne=Lg(oe),ee=Object.prototype.toString.apply(oe);if(T&&oe&&ne&&A.indexOf(ee)<0&&!(Ne(j)&&Array.isArray(oe))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const ae=this.options.returnedObjectHandler?this.options.returnedObjectHandler(E,oe,{...a,ns:f}):`key '${c} (${this.language})' returned an object instead of string.`;return s?(v.res=ae,v.usedParams=this.getUsedParamsDetails(a),v):ae}if(l){const ae=Array.isArray(oe),ce=ae?[]:{},ve=ae?S:E;for(const z in oe)if(Object.prototype.hasOwnProperty.call(oe,z)){const F=`${ve}${l}${z}`;k&&!w?ce[z]=this.translate(F,{...a,defaultValue:Lg(J)?J[z]:void 0,joinArrays:!1,ns:f}):ce[z]=this.translate(F,{...a,joinArrays:!1,ns:f}),ce[z]===F&&(ce[z]=oe[z])}w=ce}}else if(T&&Ne(j)&&Array.isArray(w))w=w.join(j),w&&(w=this.extendTranslation(w,t,a,r));else{let ae=!1,ce=!1;!this.isValidLookup(w)&&k&&(ae=!0,w=J),this.isValidLookup(w)||(ce=!0,w=c);const z=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&ce?void 0:w,F=k&&J!==w&&this.options.updateMissing;if(ce||ae||F){if(this.logger.log(F?"updateKey":"missingKey",m,h,c,F?J:w),l){const D=this.resolve(c,{...a,keySeparator:!1});D&&D.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let fe=[];const ye=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ye&&ye[0])for(let D=0;D{const de=k&&le!==w?le:z;this.options.missingKeyHandler?this.options.missingKeyHandler(D,h,K,de,F,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(D,h,K,de,F,a),this.emit("missingKey",D,h,K,w)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?fe.forEach(D=>{const K=this.pluralResolver.getSuffixes(D,a);W&&a[`defaultValue${this.options.pluralSeparator}zero`]&&K.indexOf(`${this.options.pluralSeparator}zero`)<0&&K.push(`${this.options.pluralSeparator}zero`),K.forEach(le=>{Ce([D],c+le,a[`defaultValue${le}`]||J)})}):Ce(fe,c,J))}w=this.extendTranslation(w,t,a,v,r),ce&&w===c&&this.options.appendNamespaceToMissingKey&&(w=`${h}${p}${c}`),(ce||ae)&&this.options.parseMissingKeyHandler&&(w=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${h}${p}${c}`:c,ae?w:void 0,a))}return s?(v.res=w,v.usedParams=this.getUsedParamsDetails(a),v):w}extendTranslation(t,n,r,a,s){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const f=Ne(t)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let h;if(f){const m=t.match(this.interpolator.nestingRegexp);h=m&&m.length}let p=r.replace&&!Ne(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(p={...this.options.interpolation.defaultVariables,...p}),t=this.interpolator.interpolate(t,p,r.lng||this.language||a.usedLng,r),f){const m=t.match(this.interpolator.nestingRegexp),y=m&&m.length;hs?.[0]===m[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${m[0]} in key: ${n[0]}`),null):this.translate(...m,n),r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=Ne(l)?[l]:l;return t!=null&&c?.length&&r.applyPostProcessor!==!1&&(t=jC.handle(c,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t,n={}){let r,a,s,l,c;return Ne(t)&&(t=[t]),t.forEach(f=>{if(this.isValidLookup(r))return;const h=this.extractFromKey(f,n),p=h.key;a=p;let m=h.namespaces;this.options.fallbackNS&&(m=m.concat(this.options.fallbackNS));const y=n.count!==void 0&&!Ne(n.count),v=y&&!n.ordinal&&n.count===0,w=n.context!==void 0&&(Ne(n.context)||typeof n.context=="number")&&n.context!=="",E=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);m.forEach(S=>{this.isValidLookup(r)||(c=S,!cE[`${E[0]}-${S}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(c)&&(cE[`${E[0]}-${S}`]=!0,this.logger.warn(`key "${a}" for languages "${E.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),E.forEach(A=>{if(this.isValidLookup(r))return;l=A;const j=[p];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(j,p,A,S,n);else{let N;y&&(N=this.pluralResolver.getSuffix(A,n.count,n));const k=`${this.options.pluralSeparator}zero`,P=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(y&&(n.ordinal&&N.indexOf(P)===0&&j.push(p+N.replace(P,this.options.pluralSeparator)),j.push(p+N),v&&j.push(p+k)),w){const $=`${p}${this.options.contextSeparator||"_"}${n.context}`;j.push($),y&&(n.ordinal&&N.indexOf(P)===0&&j.push($+N.replace(P,this.options.pluralSeparator)),j.push($+N),v&&j.push($+k))}}let T;for(;T=j.pop();)this.isValidLookup(r)||(s=T,r=this.getResource(A,S,T,n))}))})}),{res:r,usedKey:a,exactUsedKey:s,usedLng:l,usedNS:c}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r,a={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,n,r,a):this.resourceStore.getResource(t,n,r,a)}getUsedParamsDetails(t={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!Ne(t.replace);let a=r?t.replace:t;if(r&&typeof t.count<"u"&&(a.count=t.count),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!r){a={...a};for(const s of n)delete a[s]}return a}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}class fE{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ea.create("languageUtils")}getScriptPartFromCode(t){if(t=$u(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=$u(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(Ne(t)&&t.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(t)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(r=>{if(n)return;const a=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(a))&&(n=a)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const a=this.getScriptPartFromCode(r);if(this.isSupportedCode(a))return n=a;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(l=>{if(l===s)return l;if(!(l.indexOf("-")<0&&s.indexOf("-")<0)&&(l.indexOf("-")>0&&s.indexOf("-")<0&&l.substring(0,l.indexOf("-"))===s||l.indexOf(s)===0&&s.length>1))return l})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),Ne(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),a=[],s=l=>{l&&(this.isSupportedCode(l)?a.push(l):this.logger.warn(`rejecting language code not found in supportedLngs: ${l}`))};return Ne(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(t))):Ne(t)&&s(this.formatLanguageCode(t)),r.forEach(l=>{a.indexOf(l)<0&&s(this.formatLanguageCode(l))}),a}}const dE={zero:0,one:1,two:2,few:3,many:4,other:5},hE={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class BL{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=ea.create("pluralResolver"),this.pluralRulesCache={}}addRule(t,n){this.rules[t]=n}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const r=$u(t==="dev"?"en":t),a=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:a});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let l;try{l=new Intl.PluralRules(r,{type:a})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),hE;if(!t.match(/-|_/))return hE;const f=this.languageUtils.getLanguagePartFromCode(t);l=this.getRule(f,n)}return this.pluralRulesCache[s]=l,l}needsPlural(t,n={}){let r=this.getRule(t,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,n,r={}){return this.getSuffixes(t,r).map(a=>`${n}${a}`)}getSuffixes(t,n={}){let r=this.getRule(t,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((a,s)=>dE[a]-dE[s]).map(a=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(t,n,r={}){const a=this.getRule(t,r);return a?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${a.select(n)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",n,r))}}const pE=(e,t,n,r=".",a=!0)=>{let s=PL(e,t,n);return!s&&a&&Ne(n)&&(s=Ay(e,n,r),s===void 0&&(s=Ay(t,n,r))),s},Ig=e=>e.replace(/\$/g,"$$$$");class qL{constructor(t={}){this.logger=ea.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(n=>n),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:a,prefix:s,prefixEscaped:l,suffix:c,suffixEscaped:f,formatSeparator:h,unescapeSuffix:p,unescapePrefix:m,nestingPrefix:y,nestingPrefixEscaped:v,nestingSuffix:w,nestingSuffixEscaped:E,nestingOptionsSeparator:S,maxReplaces:A,alwaysFormat:j}=t.interpolation;this.escape=n!==void 0?n:DL,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=a!==void 0?a:!1,this.prefix=s?Oo(s):l||"{{",this.suffix=c?Oo(c):f||"}}",this.formatSeparator=h||",",this.unescapePrefix=p?"":m||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=y?Oo(y):v||Oo("$t("),this.nestingSuffix=w?Oo(w):E||Oo(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=A||1e3,this.alwaysFormat=j!==void 0?j:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,n,r,a){let s,l,c;const f=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},h=v=>{if(v.indexOf(this.formatSeparator)<0){const A=pE(n,f,v,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(A,void 0,r,{...a,...n,interpolationkey:v}):A}const w=v.split(this.formatSeparator),E=w.shift().trim(),S=w.join(this.formatSeparator).trim();return this.format(pE(n,f,E,this.options.keySeparator,this.options.ignoreJSONStructure),S,r,{...a,...n,interpolationkey:E})};this.resetRegExp();const p=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,m=a?.interpolation?.skipOnVariables!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:v=>Ig(v)},{regex:this.regexp,safeValue:v=>this.escapeValue?Ig(this.escape(v)):Ig(v)}].forEach(v=>{for(c=0;s=v.regex.exec(t);){const w=s[1].trim();if(l=h(w),l===void 0)if(typeof p=="function"){const S=p(t,s,a);l=Ne(S)?S:""}else if(a&&Object.prototype.hasOwnProperty.call(a,w))l="";else if(m){l=s[0];continue}else this.logger.warn(`missed to pass in variable ${w} for interpolating ${t}`),l="";else!Ne(l)&&!this.useRawValueToEscape&&(l=iE(l));const E=v.safeValue(l);if(t=t.replace(s[0],E),m?(v.regex.lastIndex+=l.length,v.regex.lastIndex-=s[0].length):v.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),t}nest(t,n,r={}){let a,s,l;const c=(f,h)=>{const p=this.nestingOptionsSeparator;if(f.indexOf(p)<0)return f;const m=f.split(new RegExp(`${p}[ ]*{`));let y=`{${m[1]}`;f=m[0],y=this.interpolate(y,l);const v=y.match(/'/g),w=y.match(/"/g);((v?.length??0)%2===0&&!w||w.length%2!==0)&&(y=y.replace(/'/g,'"'));try{l=JSON.parse(y),h&&(l={...h,...l})}catch(E){return this.logger.warn(`failed parsing options string in nesting for key ${f}`,E),`${f}${p}${y}`}return l.defaultValue&&l.defaultValue.indexOf(this.prefix)>-1&&delete l.defaultValue,f};for(;a=this.nestingRegexp.exec(t);){let f=[];l={...r},l=l.replace&&!Ne(l.replace)?l.replace:l,l.applyPostProcessor=!1,delete l.defaultValue;const h=/{.*}/.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(h!==-1&&(f=a[1].slice(h).split(this.formatSeparator).map(p=>p.trim()).filter(Boolean),a[1]=a[1].slice(0,h)),s=n(c.call(this,a[1].trim(),l),l),s&&a[0]===t&&!Ne(s))return s;Ne(s)||(s=iE(s)),s||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${t}`),s=""),f.length&&(s=f.reduce((p,m)=>this.format(p,m,r.lng,{...r,interpolationkey:a[1].trim()}),s.trim())),t=t.replace(a[0],s),this.regexp.lastIndex=0}return t}}const HL=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const a=r[1].substring(0,r[1].length-1);t==="currency"&&a.indexOf(":")<0?n.currency||(n.currency=a.trim()):t==="relativetime"&&a.indexOf(":")<0?n.range||(n.range=a.trim()):a.split(";").forEach(l=>{if(l){const[c,...f]=l.split(":"),h=f.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();n[p]||(n[p]=h),h==="false"&&(n[p]=!1),h==="true"&&(n[p]=!0),isNaN(h)||(n[p]=parseInt(h,10))}})}return{formatName:t,formatOptions:n}},mE=e=>{const t={};return(n,r,a)=>{let s=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(s={...s,[a.interpolationkey]:void 0});const l=r+JSON.stringify(s);let c=t[l];return c||(c=e($u(r),a),t[l]=c),c(n)}},VL=e=>(t,n,r)=>e($u(n),r)(t);class FL{constructor(t={}){this.logger=ea.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?mE:VL;this.formats={number:r((a,s)=>{const l=new Intl.NumberFormat(a,{...s});return c=>l.format(c)}),currency:r((a,s)=>{const l=new Intl.NumberFormat(a,{...s,style:"currency"});return c=>l.format(c)}),datetime:r((a,s)=>{const l=new Intl.DateTimeFormat(a,{...s});return c=>l.format(c)}),relativetime:r((a,s)=>{const l=new Intl.RelativeTimeFormat(a,{...s});return c=>l.format(c,s.range||"day")}),list:r((a,s)=>{const l=new Intl.ListFormat(a,{...s});return c=>l.format(c)})}}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=mE(n)}format(t,n,r,a={}){const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(c=>c.indexOf(")")>-1)){const c=s.findIndex(f=>f.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,c)].join(this.formatSeparator)}return s.reduce((c,f)=>{const{formatName:h,formatOptions:p}=HL(f);if(this.formats[h]){let m=c;try{const y=a?.formatParams?.[a.interpolationkey]||{},v=y.locale||y.lng||a.locale||a.lng||r;m=this.formats[h](c,v,{...p,...a,...y})}catch(y){this.logger.warn(y)}return m}else this.logger.warn(`there was no format function for ${h}`);return c},t)}}const KL=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class GL extends _h{constructor(t,n,r,a={}){super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=a,this.logger=ea.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,a.backend,a)}queueLoad(t,n,r,a){const s={},l={},c={},f={};return t.forEach(h=>{let p=!0;n.forEach(m=>{const y=`${h}|${m}`;!r.reload&&this.store.hasResourceBundle(h,m)?this.state[y]=2:this.state[y]<0||(this.state[y]===1?l[y]===void 0&&(l[y]=!0):(this.state[y]=1,p=!1,l[y]===void 0&&(l[y]=!0),s[y]===void 0&&(s[y]=!0),f[m]===void 0&&(f[m]=!0)))}),p||(c[h]=!0)}),(Object.keys(s).length||Object.keys(l).length)&&this.queue.push({pending:l,pendingCount:Object.keys(l).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(s),pending:Object.keys(l),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(f)}}loaded(t,n,r){const a=t.split("|"),s=a[0],l=a[1];n&&this.emit("failedLoading",s,l,n),!n&&r&&this.store.addResourceBundle(s,l,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const c={};this.queue.forEach(f=>{NL(f.loaded,[s],l),KL(f,t),n&&f.errors.push(n),f.pendingCount===0&&!f.done&&(Object.keys(f.loaded).forEach(h=>{c[h]||(c[h]={});const p=f.loaded[h];p.length&&p.forEach(m=>{c[h][m]===void 0&&(c[h][m]=!0)})}),f.done=!0,f.errors.length?f.callback(f.errors):f.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(f=>!f.done)}read(t,n,r,a=0,s=this.retryTimeout,l){if(!t.length)return l(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:a,wait:s,callback:l});return}this.readingCalls++;const c=(h,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const m=this.waitingReads.shift();this.read(m.lng,m.ns,m.fcName,m.tried,m.wait,m.callback)}if(h&&p&&a{this.read.call(this,t,n,r,a+1,s*2,l)},s);return}l(h,p)},f=this.backend[r].bind(this.backend);if(f.length===2){try{const h=f(t,n);h&&typeof h.then=="function"?h.then(p=>c(null,p)).catch(c):c(null,h)}catch(h){c(h)}return}return f(t,n,c)}prepareLoading(t,n,r={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();Ne(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Ne(n)&&(n=[n]);const s=this.queueLoad(t,n,r,a);if(!s.toLoad.length)return s.pending.length||a(),null;s.toLoad.forEach(l=>{this.loadOne(l)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t,n=""){const r=t.split("|"),a=r[0],s=r[1];this.read(a,s,"read",void 0,void 0,(l,c)=>{l&&this.logger.warn(`${n}loading namespace ${s} for language ${a} failed`,l),!l&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${a}`,c),this.loaded(t,l,c)})}saveMissing(t,n,r,a,s,l={},c=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const f={...l,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let p;h.length===5?p=h(t,n,r,a,f):p=h(t,n,r,a),p&&typeof p.then=="function"?p.then(m=>c(null,m)).catch(c):c(null,p)}catch(p){c(p)}else h(t,n,r,a,c,f)}!t||!t[0]||this.store.addResource(t[0],n,r,a)}}}const gE=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),Ne(e[1])&&(t.defaultValue=e[1]),Ne(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),vE=e=>(Ne(e.ns)&&(e.ns=[e.ns]),Ne(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Ne(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),zf=()=>{},ZL=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Lu extends _h{constructor(t={},n){if(super(),this.options=vE(t),this.services={},this.logger=ea,this.modules={external:[]},ZL(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(t={},n){this.isInitializing=!0,typeof t=="function"&&(n=t,t={}),t.defaultNS==null&&t.ns&&(Ne(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const r=gE();this.options={...r,...this.options,...vE(t)},this.options.interpolation={...r.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator);const a=h=>h?typeof h=="function"?new h:h:null;if(!this.options.isClone){this.modules.logger?ea.init(a(this.modules.logger),this.options):ea.init(null,this.options);let h;this.modules.formatter?h=this.modules.formatter:h=FL;const p=new fE(this.options);this.store=new uE(this.options.resources,this.options);const m=this.services;m.logger=ea,m.resourceStore=this.store,m.languageUtils=p,m.pluralResolver=new BL(p,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),h&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(m.formatter=a(h),m.formatter.init&&m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new qL(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new GL(a(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",(v,...w)=>{this.emit(v,...w)}),this.modules.languageDetector&&(m.languageDetector=a(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=a(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new Ed(this.services,this.options),this.translator.on("*",(v,...w)=>{this.emit(v,...w)}),this.modules.external.forEach(v=>{v.init&&v.init(this)})}if(this.format=this.options.interpolation.format,n||(n=zf),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const h=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);h.length>0&&h[0]!=="dev"&&(this.options.lng=h[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(h=>{this[h]=(...p)=>this.store[h](...p)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(h=>{this[h]=(...p)=>(this.store[h](...p),this)});const c=pu(),f=()=>{const h=(p,m)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(m),n(p,m)};if(this.languages&&!this.isInitialized)return h(null,this.t.bind(this));this.changeLanguage(this.options.lng,h)};return this.options.resources||!this.options.initAsync?f():setTimeout(f,0),c}loadResources(t,n=zf){let r=n;const a=Ne(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(a?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],l=c=>{if(!c||c==="cimode")return;this.services.languageUtils.toResolveHierarchy(c).forEach(h=>{h!=="cimode"&&s.indexOf(h)<0&&s.push(h)})};a?l(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(f=>l(f)),this.options.preload?.forEach?.(c=>l(c)),this.services.backendConnector.load(s,this.options.ns,c=>{!c&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(c)})}else r(null)}reloadResources(t,n,r){const a=pu();return typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),r||(r=zf),this.services.backendConnector.reload(t,n,s=>{a.resolve(),r(s)}),a}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&jC.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1)){for(let n=0;n-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,n){this.isLanguageChangingTo=t;const r=pu();this.emit("languageChanging",t);const a=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},s=(c,f)=>{f?this.isLanguageChangingTo===t&&(a(f),this.translator.changeLanguage(f),this.isLanguageChangingTo=void 0,this.emit("languageChanged",f),this.logger.log("languageChanged",f)):this.isLanguageChangingTo=void 0,r.resolve((...h)=>this.t(...h)),n&&n(c,(...h)=>this.t(...h))},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const f=Ne(c)?c:c&&c[0],h=this.store.hasLanguageSomeTranslations(f)?f:this.services.languageUtils.getBestMatchFromCodes(Ne(c)?[c]:c);h&&(this.language||a(h),this.translator.language||this.translator.changeLanguage(h),this.services.languageDetector?.cacheUserLanguage?.(h)),this.loadResources(h,p=>{s(p,h)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),r}getFixedT(t,n,r){const a=(s,l,...c)=>{let f;typeof l!="object"?f=this.options.overloadTranslationOptionHandler([s,l].concat(c)):f={...l},f.lng=f.lng||a.lng,f.lngs=f.lngs||a.lngs,f.ns=f.ns||a.ns,f.keyPrefix!==""&&(f.keyPrefix=f.keyPrefix||r||a.keyPrefix);const h=this.options.keySeparator||".";let p;return f.keyPrefix&&Array.isArray(s)?p=s.map(m=>(typeof m=="function"&&(m=jy(m,{...this.options,...l})),`${f.keyPrefix}${h}${m}`)):(typeof s=="function"&&(s=jy(s,{...this.options,...l})),p=f.keyPrefix?`${f.keyPrefix}${h}${s}`:s),this.t(p,f)};return Ne(t)?a.lng=t:a.lngs=t,a.ns=n,a.keyPrefix=r,a}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const l=(c,f)=>{const h=this.services.backendConnector.state[`${c}|${f}`];return h===-1||h===0||h===2};if(n.precheck){const c=n.precheck(this,l);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||l(r,t)&&(!a||l(s,t)))}loadNamespaces(t,n){const r=pu();return this.options.ns?(Ne(t)&&(t=[t]),t.forEach(a=>{this.options.ns.indexOf(a)<0&&this.options.ns.push(a)}),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=pu();Ne(t)&&(t=[t]);const a=this.options.preload||[],s=t.filter(l=>a.indexOf(l)<0&&this.services.languageUtils.isSupportedCode(l));return s.length?(this.options.preload=a.concat(s),this.loadResources(l=>{r.resolve(),n&&n(l)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const a=new Intl.Locale(t);if(a&&a.getTextInfo){const s=a.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new fE(gE());return t.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){return new Lu(t,n)}cloneInstance(t={},n=zf){const r=t.forkResourceStore;r&&delete t.forkResourceStore;const a={...this.options,...t,isClone:!0},s=new Lu(a);if((t.debug!==void 0||t.prefix!==void 0)&&(s.logger=s.logger.clone(t)),["store","services","language"].forEach(c=>{s[c]=this[c]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const c=Object.keys(this.store.data).reduce((f,h)=>(f[h]={...this.store.data[h]},f[h]=Object.keys(f[h]).reduce((p,m)=>(p[m]={...f[h][m]},p),f[h]),f),{});s.store=new uE(c,a),s.services.resourceStore=s.store}return s.translator=new Ed(s.services,a),s.translator.on("*",(c,...f)=>{s.emit(c,...f)}),s.init(a,n),s.translator.options=a,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const bn=Lu.createInstance();bn.createInstance=Lu.createInstance;bn.createInstance;bn.dir;bn.init;bn.loadResources;bn.reloadResources;bn.use;bn.changeLanguage;bn.getFixedT;bn.t;bn.exists;bn.setDefaultNamespace;bn.hasLoadedNamespace;bn.loadNamespaces;bn.loadLanguages;const WL=(e,t,n,r)=>{const a=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(a,"warn","react-i18next::",!0);ys(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...a):console?.warn&&console.warn(...a)},yE={},Ty=(e,t,n,r)=>{ys(n)&&yE[n]||(ys(n)&&(yE[n]=new Date),WL(e,t,n,r))},CC=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},Cy=(e,t,n)=>{e.loadNamespaces(t,CC(e,n))},bE=(e,t,n,r)=>{if(ys(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Cy(e,n,r);n.forEach(a=>{e.options.ns.indexOf(a)<0&&e.options.ns.push(a)}),e.loadLanguages(t,CC(e,r))},YL=(e,t,n={})=>!t.languages||!t.languages.length?(Ty(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(r,a)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!a(r.isLanguageChangingTo,e))return!1}}),ys=e=>typeof e=="string",XL=e=>typeof e=="object"&&e!==null,JL=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,QL={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},eI=e=>QL[e],tI=e=>e.replace(JL,eI);let ky={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:tI};const nI=(e={})=>{ky={...ky,...e}},rI=()=>ky;let kC;const aI=e=>{kC=e},iI=()=>kC,sI={type:"3rdParty",init(e){nI(e.options.react),aI(e)}},oI=_.createContext();class lI{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const uI=(e,t)=>{const n=_.useRef();return _.useEffect(()=>{n.current=e},[e,t]),n.current},NC=(e,t,n,r)=>e.getFixedT(t,n,r),cI=(e,t,n,r)=>_.useCallback(NC(e,t,n,r),[e,t,n,r]),Ps=(e,t={})=>{const{i18n:n}=t,{i18n:r,defaultNS:a}=_.useContext(oI)||{},s=n||r||iI();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new lI),!s){Ty(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const N=(P,$)=>ys($)?$:XL($)&&ys($.defaultValue)?$.defaultValue:Array.isArray(P)?P[P.length-1]:P,k=[N,{},!1];return k.t=N,k.i18n={},k.ready=!1,k}s.options.react?.wait&&Ty(s,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const l={...rI(),...s.options.react,...t},{useSuspense:c,keyPrefix:f}=l;let h=a||s.options?.defaultNS;h=ys(h)?[h]:h||["translation"],s.reportNamespaces.addUsedNamespaces?.(h);const p=(s.isInitialized||s.initializedStoreOnce)&&h.every(N=>YL(N,s,l)),m=cI(s,t.lng||null,l.nsMode==="fallback"?h:h[0],f),y=()=>m,v=()=>NC(s,t.lng||null,l.nsMode==="fallback"?h:h[0],f),[w,E]=_.useState(y);let S=h.join();t.lng&&(S=`${t.lng}${S}`);const A=uI(S),j=_.useRef(!0);_.useEffect(()=>{const{bindI18n:N,bindI18nStore:k}=l;j.current=!0,!p&&!c&&(t.lng?bE(s,t.lng,h,()=>{j.current&&E(v)}):Cy(s,h,()=>{j.current&&E(v)})),p&&A&&A!==S&&j.current&&E(v);const P=()=>{j.current&&E(v)};return N&&s?.on(N,P),k&&s?.store.on(k,P),()=>{j.current=!1,s&&N&&N?.split(" ").forEach($=>s.off($,P)),k&&s&&k.split(" ").forEach($=>s.store.off($,P))}},[s,S]),_.useEffect(()=>{j.current&&p&&E(y)},[s,f,p]);const T=[w,s,p];if(T.t=w,T.i18n=s,T.ready=p,p||!p&&!c)return T;throw new Promise(N=>{t.lng?bE(s,t.lng,h,()=>N()):Cy(s,h,()=>N())})},fI={basicInfo:{title:"基本資料設定",role:"選擇您的身分",family:"我是家屬",caregiver:"我是看護",userNickname:"您的暱稱",userNicknamePlace:"請輸入您的暱稱",patientNickname:"病人暱稱",patientNicknamePlace:"請輸入病人暱稱",patientGender:"病人性別",male:"男",female:"女",patientWeight:"病人體重(公斤)",patientAge:"病人年齡(歲)"},modules:{title:"選擇照護紀錄模組",description:"請勾選您需要的照護紀錄項目,系統將自動生成專屬表單。",basic:"基本模組",advanced:"進階模組"},invitation:{title:"邀請加入照護組合",familyTitle:"邀請看護加入",familyDescription:"請將下方連結分享給看護,對方點擊後即可加入同組照護資料。",caregiverTitle:"分享給家屬",caregiverDescription:"請將下方連結分享給家屬,對方點擊後即可加入同組照護資料。",copyLink:"複製邀請連結",copied:"已複製到剪貼簿"},tutorial:{title:"操作教學",description:"請觀看以下教學影片,快速了解系統功能。",watchVideo:"觀看教學影片",skip:"略過教學"},completion:{title:"設定完成",description:"您已成功建立專屬照護組合,現在可以開始紀錄照護資料。",start:"立即開始紀錄",watchTutorial:"觀看完整教學影片",complete:"完成"},previous:"上一步",next:"下一步",complete:"完成"},dI={name:"好看護日誌",description:"智慧照護紀錄平台"},hI={login:"登入",loginError:"電子郵件或密碼錯誤",logout:"登出",register:"註冊",email:"電子郵件",password:"密碼",confirmPassword:"確認密碼"},pI={logout:"登出",signedInAs:"已登入為"},mI={title:"媒體牆",upload:"上傳",refresh:"重新整理",loading:"讀取中…",error:"發生錯誤:",empty:"目前沒有媒體檔案。",copyLink:"複製連結",copied:"已複製",share:"分享",delete:"刪除",deleteConfirm:"確定要刪除此媒體?這將一併刪除雲端檔案。",deleteFail:"刪除失敗:",save:"儲存",saving:"儲存中…",file:"檔案",caption:"說明(可選)",categoryLabel:"分類",category:{all:"全部分類",body:"身體",rehab:"復健",meal:"飲食"}},gI={physical:{title:"身體照顧",position:"姿勢",bedHeight:"床高"},nursing:{title:"護理相關",vitalSigns:"生命徵象",bloodPressure:"血壓",heartRate:"心跳",temperature:"體溫",spo2:"血氧飽和度"},diet:{title:"飲食相關",waterIntake:"飲水量",foodIntake:"食物攝取"}},vI={required:"此欄位為必填",invalidEmail:"無效的電子郵件格式",passwordMismatch:"密碼不相符"},yI={save:"儲存",cancel:"取消",submit:"送出",loading:"載入中...",success:"成功",error:"錯誤",out_of_range:"超範圍",backHome:"返回主頁"},bI={main_actions:"主要功能",secondary_actions:"管理功能",today_summary:"今日摘要",alert_title:"今日異常警示",alert_note:"* 異常值來自最新一次量測;請依臨床指引判讀並視情況通知醫護。"},xI={systolic_avg:"平均收縮壓",diastolic_avg:"平均舒張壓",heart_rate_avg:"平均心跳",glucose_avg:"平均血糖"},wI={title:"新增身體照顧",patient:"病人",occurred_at:"執行時間",posture:"姿勢",head_elevation:"床頭高度",hygiene:"個人清潔",change:"更換",course:"課程/復健",note:"補充說明",none:"無",choose:"請選擇",create:"建立紀錄",back:"返回",created_ok:"已新增一筆身體照顧紀錄",err_choose_patient:"請選擇病人",err_choose_time:"請輸入執行時間",err_fill_any:"請至少填寫一項(姿勢/床頭高度/個人清潔/更換/課程/補充說明)"},_I={title:"預備金管理(精簡版)",loginTime:"登入時系統現在時間",executedAt:"實際執行時間(可修正)",now:"現在時間",prevBalance:"前次結餘",income:"預備金收入",expense:"支出金額",balance:"預備金結餘",items:"購買項目(可複選/可自行新增)",addSelect:"新增/選擇",searchOrAdd:"輸入關鍵字以搜尋,或輸入新項目名稱",noOption:"無符合選項",note:"備註(可母語輸入)",smartOCR:"智慧拍照辨識(模擬)",clear:"清空",save:"儲存(僅示範)",preview:"提交資料預覽(可直接作為 API payload)",appTitle:"預備金管理",toForm:"新增記錄",toHistory:"歷史記錄",toReport:"月報表",executedAtTH:"執行日期時間",incomeTH:"預備金收入",expenseTH:"支出",balanceTH:"結額",itemsTH:"項目",noteTH:"備註",count:"數量",totalIncome:"總收入",totalExpense:"總支出",netAmount:"淨金額",filterRecords:"篩選記錄",startDate:"開始日期",endDate:"結束日期",searching:"搜尋中...",searchBtn:"搜尋",noRecords:"查無記錄",today:"今天",thisWeek:"這週",thisMonth:"這月",custom:"自訂",generateReport:"產生月報表",year:"年份",month:"月份",generating:"產生中...",generateBtn:"產生報表",monthlyTransactions:"月交易記錄",noTransactions:"此期間無交易記錄",expenseByItem:"按項目分類的支出摘要"},SI={features:"系統總覽",title:"好看護日誌",subtitle1:"智慧照護平台",subtitle2:"React + Supabase + PWA 全功能系統",login:"登入系統",website:"官方網站",appTitle:"CareTide",mobileOptimized:"手機優化版本",mobileOptimizedDesc:"建議安裝App以獲得最佳體驗",iosInstallTitle:"iOS 安裝說明",iosInstallBody:"使用 Safari 打開 → 點選分享按鈕 → 加到主畫面 以安裝 App。",iosInstallDismiss:"不再顯示",offlineTitle:"離線模式",offlineDesc:"未設定後端環境,僅提供展示功能",installApp:"安裝App"},EI={purchase:{title:"代買預備金管理系統",balance:"前次結餘",addExpense:"新增支出",deposit:"存入/儲值",welcome:"歡迎使用 CareTide 系統!"},tabs:{visit:"登入資料",record:"記錄查詢",trend:"趨勢圖表",body:"身體",nursing:"護理",diet:"飲食",excretion:"排泄",rehab:"復健",visitor:"訪客",purchase:"代買",shareTitle:"分享媒體",mediaLink:"媒體連結",noSignedUrl:"無法產生簽名網址",saveFail:"儲存失敗:",progress:{queued:"待上傳",uploading:"上傳中…",done:"完成",error:"錯誤"},submit:"上傳",selectFileFirst:"請選擇檔案",notLoggedIn:"尚未登入",noContext:"找不到照護組合,請先建立一個。",other:"其他"}},OI={title:"功能導覽",subtitle:"以下是 CareTide 的核心功能模組,提供家屬/照護者/專業人員完整的照護記錄與追蹤。",back:"回到主頁",footer:"© 2025 CareTide 智慧照護",items:{body:{title:"身體照護",desc:"洗澡、翻身、口腔清潔等日常照護紀錄。"},nursing:{title:"護理紀錄",desc:"生命徵象、傷口照護、用藥管理與交班。"},diet:{title:"飲食紀錄",desc:"飲水量、餐食內容、熱量與營養追蹤。"},rehab:{title:"復健訓練",desc:"運動處方、訓練次數與成效追蹤。"},bp:{title:"血壓追蹤",desc:"量測血壓/心跳並產生趨勢圖表。"},excretion:{title:"排泄紀錄",desc:"大小便時間、性狀與異常提醒。"},purchase:{title:"物資採購",desc:"耗材庫存、採購清單與到貨確認。"},multiPatient:{title:"多人照護",desc:"支援多位成員與多名個案切換管理。"}}},AI={title:"CareTide 主面板",subtitle:"選擇要記錄或管理的模組",status:{ready:"可用",soon:"即將推出"}},jI={bp:{title:"血壓紀錄",subtitle:"請輸入當前量測值"},body:{title:"身體紀錄",subtitle:"請輸入身高、體重"},nursing:{title:"護理紀錄",subtitle:"請填寫護理內容"},diet:{title:"飲食紀錄",subtitle:"請記錄餐食內容"},rehab:{title:"復健紀錄",subtitle:"請記錄運動項目"},excretion:{title:"排泄紀錄",subtitle:"請記錄排泄資訊"},purchase:{title:"採購紀錄",subtitle:"請記錄採購項目"},multi:{title:"多成員紀錄",subtitle:"選擇成員後填寫內容"}},TI={title:{bp:"血壓紀錄列表",body:"身體紀錄列表",nursing:"護理紀錄列表",diet:"飲食紀錄列表",rehab:"復健紀錄列表",excretion:"排泄紀錄列表",purchase:"採購紀錄列表",multi:"多成員紀錄列表"},subtitle:"依日期查詢與排序",rangeFrom:"起日",rangeTo:"迄日",count:"共 {{count}} 筆",prev:"上一頁",next:"下一頁",page:"第 {{page}} / {{pages}} 頁",empty:"尚無資料"},CI={bp:{title:"血壓趨勢",subtitle:"最近資料的 SYS/DIA 走勢"},body:{title:"體重 / BMI 趨勢",subtitle:"最近紀錄的體重與 BMI"},coming:"圖表即將推出"},kI={onboarding:fI,app:dI,auth:hI,nav:pI,mediaWall:mI,forms:gI,validation:vI,common:yI,dashboard:bI,vitals:xI,care:wI,pettyCash:_I,welcome:SI,mobile:EI,features:OI,home:AI,records:jI,list:TI,charts:CI},NI={basicInfo:{title:"Pengaturan Informasi Dasar",role:"Pilih peran Anda",family:"Saya adalah keluarga",caregiver:"Saya adalah perawat",userNickname:"Nama panggilan Anda",userNicknamePlace:"Masukkan nama panggilan Anda",patientNickname:"Nama panggilan pasien",patientNicknamePlace:"Masukkan nama panggilan pasien",patientGender:"Jenis kelamin pasien",male:"Laki-laki",female:"Perempuan",patientWeight:"Berat pasien (kg)",patientAge:"Usia pasien (tahun)"},modules:{title:"Pilih Modul Catatan Perawatan",description:"Silakan pilih item catatan perawatan yang Anda butuhkan. Sistem akan membuat formulir khusus.",basic:"Modul Dasar",advanced:"Modul Lanjutan"},invitation:{title:"Undang ke Grup Perawatan",familyTitle:"Undang perawat untuk bergabung",familyDescription:"Bagikan tautan di bawah ini dengan perawat. Mereka dapat bergabung dengan grup perawatan yang sama.",caregiverTitle:"Bagikan dengan keluarga",caregiverDescription:"Bagikan tautan di bawah ini dengan keluarga. Mereka dapat bergabung dengan grup perawatan yang sama.",copyLink:"Salin tautan undangan"},tutorial:{title:"Tutorial",description:"Silakan tonton video tutorial di bawah ini untuk memahami fitur sistem dengan cepat.",watchVideo:"Tonton video tutorial",skip:"Lewati tutorial"},completion:{title:"Pengaturan Selesai",description:"Anda telah berhasil membuat grup perawatan. Anda sekarang dapat mulai mencatat data perawatan.",start:"Mulai mencatat sekarang",watchTutorial:"Tonton tutorial lengkap",complete:"Selesai"},previous:"Sebelumnya",next:"Berikutnya",complete:"Selesai"},PI={name:"CareLog",description:"Platform Pencatatan Perawatan Cerdas"},RI={login:"Masuk",loginError:"Email atau kata sandi salah",logout:"Keluar",register:"Daftar",email:"Email",password:"Kata Sandi",confirmPassword:"Konfirmasi Kata Sandi"},DI={dashboard:"Dasbor",record:"Tambah Catatan",charts:"Grafik Tren",export:"Ekspor Data",mediaWall:"Media Wall"},MI={physical:{title:"Perawatan Fisik",position:"Posisi",bedHeight:"Tinggi Tempat Tidur"},nursing:{title:"Perawatan Keperawatan",vitalSigns:"Tanda Vital",bloodPressure:"Tekanan Darah",heartRate:"Detak Jantung",temperature:"Suhu Tubuh",spo2:"Saturasi Oksigen"},diet:{title:"Asupan Makanan",waterIntake:"Asupan Air",foodIntake:"Asupan Makanan"}},$I={title:"Media Wall",upload:"Upload",refresh:"Refresh",loading:"Loading…",error:"Error: ",empty:"No media yet.",copyLink:"Copy link",copied:"Copied",share:"Share",delete:"Delete",deleteConfirm:"Delete this media? The cloud file will also be removed.",deleteFail:"Delete failed: ",save:"Save",saving:"Saving…",file:"File",caption:"Caption (optional)",categoryLabel:"Category",shareTitle:"Share Media",mediaLink:"Media Link",noSignedUrl:"Failed to create signed URL",saveFail:"Save failed: ",progress:{queued:"Queued",uploading:"Uploading…",done:"Done",error:"Error"},submit:"Upload","submit.uploading":"Uploading…",selectFileFirst:"Please select file(s)",notLoggedIn:"Not logged in",noContext:"No care context found. Please create one first.",category:{all:"All categories",body:"Body",rehab:"Rehab",meal:"Meal"}},LI={required:"Bidang ini wajib diisi",invalidEmail:"Format email tidak valid",passwordMismatch:"Kata sandi tidak cocok"},II={save:"Simpan",cancel:"Batal",submit:"Kirim",loading:"Memuat...",success:"Berhasil",error:"Error",backHome:"Kembali ke Beranda"},zI={title:"Catatan Perawatan Tubuh",patient:"Pasien",occurred_at:"Waktu Tindakan",posture:"Posisi",head_elevation:"Ketinggian Sandaran",hygiene:"Kebersihan Pribadi",change:"Penggantian",course:"Latihan/Rehabilitasi",note:"Catatan Tambahan",none:"Tidak ada",choose:"Pilih",create:"Simpan Catatan",back:"Kembali",created_ok:"Catatan perawatan berhasil disimpan",err_choose_patient:"Silakan pilih pasien",err_choose_time:"Silakan isi waktu tindakan",err_fill_any:"Isi minimal satu bidang (Posisi/Sandaran/Kebersihan/Penggantian/Latihan/Catatan)"},UI={title:"Manajemen Uang Kecil (Ringkas)",loginTime:"Waktu sistem saat login",executedAt:"Dilaksanakan pada (dapat diubah)",now:"Sekarang",prevBalance:"Saldo sebelumnya",income:"Pemasukan",expense:"Pengeluaran",balance:"Saldo",items:"Barang (multi-pilih / dapat dibuat baru)",addSelect:"Tambah / Pilih",searchOrAdd:"Ketik untuk mencari atau tambahkan barang baru",noOption:"Tidak ada pilihan",note:"Catatan (dalam bahasa apa saja)",smartOCR:"Pengenalan gambar cerdas (simulasi)",clear:"Bersihkan",save:"Simpan (demo)",preview:"Pratinjau data yang dikirim (dapat digunakan sebagai payload API)",appTitle:"Manajemen Uang Kecil",toForm:"Entri Baru",toHistory:"Riwayat",toReport:"Laporan Bulanan",executedAtTH:"Waktu",incomeTH:"Pemasukan",expenseTH:"Pengeluaran",balanceTH:"Saldo",itemsTH:"Barang",noteTH:"Catatan",count:"Jumlah",totalIncome:"Total Pemasukan",totalExpense:"Total Pengeluaran",netAmount:"Jumlah Bersih"},BI={title:"CareLog",subtitle1:"Platform Perawatan Cerdas",subtitle2:"Sistem Lengkap React + Supabase + PWA",login:"Masuk Sistem",website:"Situs Resmi",appTitle:"CareTide",mobileOptimized:"Mobile Optimized",mobileOptimizedDesc:"Install the App for the best experience",iosInstallTitle:"Instalasi iOS",iosInstallBody:"Buka di Safari → Ketuk Bagikan → Tambahkan ke Layar Utama.",iosInstallDismiss:"Jangan tampilkan lagi",offlineTitle:"Mode Offline",offlineDesc:"Backend belum dikonfigurasi. Hanya demo.",installApp:"Instal Aplikasi"},qI={purchase:{title:"Sistem Manajemen Uang Kecil Pembelian",balance:"Saldo Sebelumnya",addExpense:"Tambah Pengeluaran",deposit:"Setor Tunai",welcome:"Selamat datang di sistem CareTide!"},tabs:{visit:"Data Login",record:"Catatan",trend:"Tren",body:"Tubuh",nursing:"Keperawatan",diet:"Makanan",excretion:"Buang Air",rehab:"Rehabilitasi",visitor:"Pengunjung",purchase:"Pembelian",other:"Lainnya"}},HI={title:"Ringkasan Fitur",subtitle:"Berikut adalah modul fungsional inti CareTide, menyediakan pencatatan dan pelacakan perawatan yang komprehensif untuk anggota keluarga, perawat, dan profesional.",back:"Kembali ke Beranda",footer:"© 2025 CareTide Smart Care",items:{body:{title:"Perawatan Tubuh",desc:"Catatan perawatan harian termasuk mandi, berganti posisi, dan kebersihan mulut."},nursing:{title:"Catatan Keperawatan",desc:"Tanda vital, perawatan luka, manajemen obat dan serah terima."},diet:{title:"Catatan Makanan",desc:"Asupan air, isi makanan, kalori dan pelacakan nutrisi."},rehab:{title:"Latihan Rehabilitasi",desc:"Resep olahraga, frekuensi latihan dan pelacakan efektivitas."},bp:{title:"Pelacakan Tekanan Darah",desc:"Pengukuran tekanan darah/detak jantung dan grafik tren."},excretion:{title:"Catatan Buang Air",desc:"Waktu buang air besar/kecil, karakteristik dan peringatan abnormal."},purchase:{title:"Pengadaan Bahan",desc:"Inventarisasi pasokan medis, daftar pembelian dan konfirmasi pengiriman."},multiPatient:{title:"Perawatan Multi-Pasien",desc:"Dukungan untuk beberapa anggota dan pengalihan manajemen pasien."}}},VI={onboarding:NI,app:PI,auth:RI,nav:DI,forms:MI,mediaWall:$I,validation:LI,common:II,care:zI,pettyCash:UI,welcome:BI,mobile:qI,features:HI},FI={basicInfo:{title:"Basic Information Setup",role:"Select your role",family:"I am a family member",caregiver:"I am a caregiver",userNickname:"Your nickname",userNicknamePlaceholder:"Enter your nickname",patientNickname:"Patient's nickname",patientNicknamePlaceholder:"Enter patient's nickname",agePlaceholder:"Enter patient's age",patientGender:"Patient's gender",male:"Male",female:"Female",patientWeight:"Patient's weight (kg)",patientAge:"Patient's age (years)"},modules:{title:"Select Care Record Modules",description:"Please select the care record items you need. The system will generate a customized form.",basic:"Basic Modules",advanced:"Advanced Modules"},invitation:{title:"Invite to Care Group",familyTitle:"Invite caregiver to join",familyDescription:"Share the link below with the caregiver. They can join the same care group.",caregiverTitle:"Share with family",caregiverDescription:"Share the link below with the family. They can join the same care group.",copyLink:"Copy invitation link",copied:"Copied to clipboard"},tutorial:{title:"Tutorial",description:"Please watch the tutorial video below to quickly understand the system features.",watchVideo:"Watch tutorial video",skip:"Skip tutorial"},completion:{title:"Setup Complete",description:"You have successfully created a care group. You can now start recording care data.",start:"Start recording now",watchTutorial:"Watch full tutorial",complete:"Complete"},previous:"Previous",next:"Next",complete:"Complete"},KI={name:"Good Care Diary",description:"Intelligent Care Record Platform"},GI={login:"Login",loginError:"Invalid login credentials",logout:"Logout",register:"Register",email:"Email",password:"Password",confirmPassword:"Confirm Password"},ZI={physical:{title:"Physical Care",position:"Position",bedHeight:"Bed Height"},nursing:{title:"Nursing",vitalSigns:"Vital Signs",bloodPressure:"Blood Pressure",heartRate:"Heart Rate",temperature:"Temperature",spo2:"SpO2"},diet:{title:"Diet",waterIntake:"Water Intake",foodIntake:"Food Intake"}},WI={required:"This field is required",invalidEmail:"Invalid email format",passwordMismatch:"Passwords do not match"},YI={save:"Save",cancel:"Cancel",submit:"Submit",loading:"Loading...",success:"Success",error:"Error",out_of_range:"Out of range",backHome:"Back to Home"},XI={main_actions:"Main Actions",secondary_actions:"Management Actions",today_summary:"Today's Summary",alert_title:"Today's Abnormal Alerts",alert_note:"* Abnormal values from the latest measurement; please interpret according to clinical guidelines and notify medical staff if necessary."},JI={systolic_avg:"Average Systolic",diastolic_avg:"Average Diastolic",heart_rate_avg:"Average Heart Rate",glucose_avg:"Average Glucose"},QI={title:"Add Body Care",patient:"Patient",occurred_at:"Executed At",posture:"Posture",head_elevation:"Head Elevation",hygiene:"Hygiene",change:"Change",course:"Course/Rehab",note:"Additional Notes",none:"None",choose:"Please choose",create:"Create Record",back:"Back",created_ok:"Body care record created successfully",err_choose_patient:"Please select a patient",err_choose_time:"Please enter execution time",err_fill_any:"Please fill at least one item (position/head elevation/hygiene/change/course/additional notes)"},ez={title:"Petty Cash Management (Lite)",loginTime:"System time at login",executedAt:"Executed at (editable)",now:"Now",prevBalance:"Previous balance",income:"Income",expense:"Expense",balance:"Balance",items:"Items (multi-select / creatable)",addSelect:"Add / Select",searchOrAdd:"Type to search or add a new item",noOption:"No options",note:"Note (any language)",smartOCR:"Smart Capture (mock)",clear:"Clear",save:"Save (demo)",preview:"Submitted payload preview",appTitle:"Petty Cash",toForm:"New Entry",toHistory:"History",toReport:"Monthly Report",executedAtTH:"Executed Date Time",incomeTH:"Petty Cash Income",expenseTH:"Expense",balanceTH:"Balance Amount",itemsTH:"Items",noteTH:"Notes",count:"Count",totalIncome:"Total Income",totalExpense:"Total Expense",netAmount:"Net Amount",filterRecords:"Filter Records",startDate:"Start Date",endDate:"End Date",searching:"Searching...",searchBtn:"Search",noRecords:"No records found",today:"Today",thisWeek:"This Week",thisMonth:"This Month",custom:"Custom",generateReport:"Generate Monthly Report",year:"Year",month:"Month",generating:"Generating...",generateBtn:"Generate Report",monthlyTransactions:"Monthly Transactions",noTransactions:"No transactions found for this period",expenseByItem:"Expense Summary by Item"},tz={features:"System Overview",title:"Good Care Diary",subtitle1:"Intelligent Care Platform",subtitle2:"React + Supabase + PWA Full-featured System",login:"Login System",website:"Official Website",appTitle:"CareTide",mobileOptimized:"Mobile Optimized",mobileOptimizedDesc:"Install the App for the best experience",iosInstallTitle:"iOS Installation",iosInstallBody:"Open in Safari → Tap Share → Add to Home Screen.",iosInstallDismiss:"Don’t show again",offlineTitle:"Offline Mode",offlineDesc:"Backend not configured. Demo features only.",installApp:"Install App"},nz={purchase:{title:"Purchase Petty Cash Management System",balance:"Previous Balance",addExpense:"Add Expense",deposit:"Deposit/Top-up",welcome:"Welcome to CareTide system!"},tabs:{visit:"Input Data",record:"Records",trend:"Trends",body:"Body",nursing:"Nursing",diet:"Diet",excretion:"Excretion",rehab:"Rehab",visitor:"Visitor",purchase:"Purchase",other:"Other"}},rz={title:"Media Wall",upload:"Upload",refresh:"Refresh",loading:"Loading…",error:"Error: ",empty:"No media yet.",copyLink:"Copy link",copied:"Copied",share:"Share",delete:"Delete",deleteConfirm:"Delete this media? The cloud file will also be removed.",deleteFail:"Delete failed: ",save:"Save",saving:"Saving…",file:"File",caption:"Caption (optional)",categoryLabel:"Category",shareTitle:"Share Media",mediaLink:"Media Link",noSignedUrl:"Failed to create signed URL",saveFail:"Save failed: ",progress:{queued:"Queued",uploading:"Uploading…",done:"Done",error:"Error"},submit:"Upload","submit.uploading":"Uploading…",selectFileFirst:"Please select file(s)",notLoggedIn:"Not logged in",noContext:"No care context found. Please create one first.",category:{all:"All categories",body:"Body",rehab:"Rehab",meal:"Meal"}},az={title:"Features Overview",subtitle:"Here are CareTide's core functional modules, providing comprehensive care recording and tracking for family members, caregivers, and professionals.",back:"Back to Home",footer:"© 2025 CareTide Smart Care",items:{body:{title:"Body Care",desc:"Daily care records including bathing, turning, and oral hygiene."},nursing:{title:"Nursing Records",desc:"Vital signs, wound care, medication management and handovers."},diet:{title:"Diet Records",desc:"Water intake, meal content, calorie and nutrition tracking."},rehab:{title:"Rehab Training",desc:"Exercise prescriptions, training frequency and effectiveness tracking."},bp:{title:"Blood Pressure Tracking",desc:"Blood pressure/heart rate measurement and trend charts."},excretion:{title:"Excretion Records",desc:"Bowel movement timing, characteristics and abnormality alerts."},purchase:{title:"Material Procurement",desc:"Medical supplies inventory, purchase lists and delivery confirmation."},multiPatient:{title:"Multi-Patient Care",desc:"Support for multiple members and patient management switching."}}},iz={onboarding:FI,app:KI,auth:GI,forms:ZI,validation:WI,common:YI,dashboard:XI,vitals:JI,care:QI,pettyCash:ez,welcome:tz,mobile:nz,mediaWall:rz,features:az},sz={basicInfo:{title:"Thiết lập thông tin cơ bản",role:"Chọn vai trò của bạn",family:"Tôi là người thân",caregiver:"Tôi là người chăm sóc",userNickname:"Biệt danh của bạn",userNicknamePlaceholder:"Nhập biệt danh của bạn",patientNickname:"Biệt danh của bệnh nhân",patientNicknamePlaceholder:"Nhập biệt danh của bệnh nhân",agePlaceholder:"Nhập tuổi bệnh nhân",patientGender:"Giới tính của bệnh nhân",male:"Nam",female:"Nữ",patientWeight:"Cân nặng của bệnh nhân (kg)",patientAge:"Tuổi của bệnh nhân (năm)"},modules:{title:"Chọn các mô-đun ghi chú chăm sóc",description:"Vui lòng chọn các mục ghi chú chăm sóc bạn cần. Hệ thống sẽ tạo biểu mẫu tùy chỉnh.",basic:"Mô-đun cơ bản",advanced:"Mô-đun nâng cao"},invitation:{title:"Mời vào nhóm chăm sóc",familyTitle:"Mời người chăm sóc tham gia",familyDescription:"Chia sẻ liên kết bên dưới với người chăm sóc. Họ có thể tham gia cùng nhóm chăm sóc.",caregiverTitle:"Chia sẻ với người thân",caregiverDescription:"Chia sẻ liên kết bên dưới với người thân. Họ có thể tham gia cùng nhóm chăm sóc.",copyLink:"Sao chép liên kết mời"},tutorial:{title:"Hướng dẫn sử dụng",description:"Vui lòng xem video hướng dẫn bên dưới để nhanh chóng hiểu các tính năng của hệ thống.",watchVideo:"Xem video hướng dẫn",skip:"Bỏ qua hướng dẫn"},completion:{title:"Thiết lập hoàn tất",description:"Bạn đã tạo nhóm chăm sóc thành công. Bây giờ bạn có thể bắt đầu ghi chú chăm sóc.",start:"Bắt đầu ghi chú ngay",watchTutorial:"Xem hướng dẫn đầy đủ",complete:"Hoàn tất"},previous:"Trước",next:"Tiếp theo",complete:"Hoàn tất"},oz={name:"Nhật ký Chăm sóc Tốt",description:"Nền tảng Ghi chép Chăm sóc Thông minh"},lz={login:"Đăng nhập",loginError:"Email hoặc mật khẩu không đúng",logout:"Đăng xuất",register:"Đăng ký",email:"Email",password:"Mật khẩu",confirmPassword:"Xác nhận mật khẩu"},uz={dashboard:"Bảng điều khiển",record:"Thêm bản ghi",charts:"Biểu đồ",export:"Xuất dữ liệu",mediaWall:"Media Wall"},cz={title:"Media Wall",upload:"Upload",refresh:"Refresh",loading:"Loading…",error:"Error: ",empty:"No media yet.",copyLink:"Copy link",copied:"Copied",share:"Share",delete:"Delete",deleteConfirm:"Delete this media? The cloud file will also be removed.",deleteFail:"Delete failed: ",save:"Save",saving:"Saving…",file:"File",caption:"Caption (optional)",categoryLabel:"Category",shareTitle:"Share Media",mediaLink:"Media Link",noSignedUrl:"Failed to create signed URL",saveFail:"Save failed: ",progress:{queued:"Queued",uploading:"Uploading…",done:"Done",error:"Error"},submit:"Upload",submitUploading:"Uploading…",selectFileFirst:"Please select file(s)",notLoggedIn:"Not logged in",noContext:"No care context found. Please create one first.",category:{all:"All categories",body:"Body",rehab:"Rehab",meal:"Meal"}},fz={vitals:"Sinh hiệu",care:"Chăm sóc cơ thể",nutrition:"Dinh dưỡng",rehab:"Phục hồi",patients:"Bệnh nhân",reports:"Báo cáo",settings:"Cài đặt"},dz={loginTime:"Thời gian hệ thống khi đăng nhập",executedAt:"Thực hiện tại (có thể chỉnh sửa)",now:"Bây giờ",prevBalance:"Số dư trước",income:"Thu nhập",expense:"Chi phí",balance:"Số dư",items:"Mặt hàng (chọn nhiều / có thể tạo mới)",addSelect:"Thêm / Chọn",searchOrAdd:"Gõ để tìm kiếm hoặc thêm mặt hàng mới",noOption:"Không có lựa chọn",note:"Ghi chú (bất kỳ ngôn ngữ nào)",smartOCR:"Chụp thông minh (mô phỏng)",clear:"Xóa",save:"Lưu (demo)",preview:"Xem trước dữ liệu đã gửi",appTitle:"Tiền mặt Nhỏ",toForm:"Mục mới",toHistory:"Lịch sử",toReport:"Báo cáo Tháng",executedAtTH:"Ngày",incomeTH:"Thu nhập",expenseTH:"Chi phí",balanceTH:"Số dư",itemsTH:"Mặt hàng",noteTH:"Ghi chú",count:"Số lượng",totalIncome:"Tổng thu nhập",totalExpense:"Tổng chi phí",netAmount:"Số tiền ròng"},hz={features:"Tổng quan hệ thống",title:"Nhật ký Chăm sóc Tốt",subtitle1:"Nền tảng Chăm sóc Thông minh",subtitle2:"Hệ thống Đầy đủ React + Supabase + PWA",login:"Đăng nhập Hệ thống",website:"Trang Chính thức",appTitle:"CareTide",mobileOptimized:"Mobile Optimized",mobileOptimizedDesc:"Install the App for the best experience",iosInstallTitle:"Cài đặt iOS",iosInstallBody:"Mở bằng Safari → Chạm Chia sẻ → Thêm vào Màn hình chính.",iosInstallDismiss:"Không hiển thị lại",offlineTitle:"Chế độ ngoại tuyến",offlineDesc:"Chưa cấu hình backend. Chỉ chế độ demo.",installApp:"Cài đặt App"},pz={purchase:{title:"Hệ thống Quản lý Tiền mặt Mua hàng",balance:"Số dư Trước",addExpense:"Thêm Chi phí",deposit:"Nạp tiền",welcome:"Chào mừng đến với hệ thống CareTide!"},tabs:{visit:"Dữ liệu Đăng nhập",record:"Bản ghi",trend:"Xu hướng",body:"Cơ thể",nursing:"Điều dưỡng",diet:"Chế độ ăn",excretion:"Bài tiết",rehab:"Phục hồi",visitor:"Khách thăm",purchase:"Mua hàng",other:"Khác"}},mz={backHome:"Về Trang chủ"},gz={onboarding:sz,app:oz,auth:lz,nav:uz,mediaWall:cz,navExtra:fz,pettyCash:dz,welcome:hz,mobile:pz,common:mz},vz={title:"Magdagdag ng Pangangalaga sa Katawan",patient:"Pasyente",occurred_at:"Oras ng Pagpapatupad",posture:"Postura",head_elevation:"Elevation ng Ulo",hygiene:"Personal na Kalinisan",change:"Palitan",course:"Kurso/Rehab",note:"Karagdagang Paliwanag",none:"Wala",choose:"Pumili",create:"Gumawa ng Rekord",back:"Bumalik",created_ok:"Matagumpay na naidagdag ang isang rekord ng pangangalaga sa katawan",err_choose_patient:"Pumili ng pasyente",err_choose_time:"Ilagay ang oras ng pagpapatupad",err_fill_any:"Pumili ng kahit isa (postura/elevation ng ulo/personal na kalinisan/palitan/kurso/karagdagang paliwanag)",options:{posture:["Baliktad sa kaliwa","Baliktad sa kanan","Supine","Prone","Sa kama","Upuin","Sa wheelchair","Tumayo","Iba pa"],head_elevation:["Flat","Head 30 degrees","Head 45 degrees","Head 60 degrees","Head 90 degrees","Foot elevation","Iba pa"],hygiene:["Hugasan ang mukha","Magtoothbrush","Punasan ang katawan","Hugasan ang kamay","Hugasan ang paa","Gupitin ang kuko","Mag-ahit","Hugasan ang buhok","Maligo","Palitan ang bedsheet","Palitan ang upper clothes","Palitan ang lower clothes","Iba pa"],change:["Palitan ang upper clothes","Palitan ang lower clothes","Palitan ang pantalon","Palitan ang skirt","Palitan ang jacket","Palitan ang sombrero","Iba pa"],course:["Occupational Therapy OT","Physical Therapy PT","Iba pa"]}},yz={basicInfo:{title:"Pag-setup ng Pangunahing Impormasyon",role:"Piliin ang iyong papel",family:"Ako ay pamilya",caregiver:"Ako ay tagapag-alaga",userNickname:"Iyong palayaw",userNicknamePlaceholder:"Ipasok ang iyong palayaw",patientNickname:"Palayaw ng pasyente",patientNicknamePlaceholder:"Ipasok ang palayaw ng pasyente",agePlaceholder:"Ilagay ang edad ng pasyente",patientGender:"Kasarian ng pasyente",male:"Lalaki",female:"Babae",patientWeight:"Timbang ng pasyente (kg)",patientAge:"Edad ng pasyente (taon)"},modules:{title:"Piliin ang mga module ng talaan ng pangangalaga",description:"Piliin ang mga item ng talaan ng pangangalaga na kailangan mo. Gagawa ang sistema ng customized na form.",basic:"Pangunahing Module",advanced:"Advanced na Module"},invitation:{title:"Imbitahan sa Care Group",familyTitle:"Imbitahan ang tagapag-alaga na sumali",familyDescription:"Ibahagi ang link sa ibaba sa tagapag-alaga. Maaari silang sumali sa parehong care group.",caregiverTitle:"Ibahagi sa pamilya",caregiverDescription:"Ibahagi ang link sa ibaba sa pamilya. Maaari silang sumali sa parehong care group.",copyLink:"Kopyahin ang link ng imbitasyon"},tutorial:{title:"Tutorial",description:"Panoorin ang tutorial video sa ibaba upang mabilis na maunawaan ang mga tampok ng sistema.",watchVideo:"Panoorin ang tutorial video",skip:"Laktawan ang tutorial"},completion:{title:"Setup Kumpleto",description:"Matagumpay kang nakagawa ng care group. Maaari ka nang magsimulang mag-record ng data ng pangangalaga.",start:"Simulan ang pag-record ngayon",watchTutorial:"Panoorin ang buong tutorial",complete:"Kumpleto"},previous:"Nakaraan",next:"Susunod",complete:"Kumpleto"},bz={name:"Magandang Arawang Pangangalaga",description:"Intelihenteng Platform ng Rekord ng Pangangalaga"},xz={login:"Mag-log in",loginError:"Maling email o password",logout:"Mag-log out",register:"Magrehistro",email:"Email",password:"Password",confirmPassword:"Kumpirmahin ang Password"},wz={dashboard:"Dashboard",record:"Magdagdag ng Rekord",charts:"Charts",export:"I-export ang Data",vitals:"Mga Vital Signs",care:"Pangangalaga sa Katawan",nutrition:"Nutrisyon",rehab:"Rehab",patients:"Mga Pasiyente",reports:"Mga Ulat",settings:"Mga Setting",mediaWall:"Media Wall"},_z={title:"Pamamahala ng Maliit na Salapi (Lite)",loginTime:"Oras ng sistema sa pag-log in",executedAt:"Isinagawa sa (maaaring baguhin)",now:"Ngayon",prevBalance:"Nakaraang balanse",income:"Kita",expense:"Gastos",balance:"Balanse",items:"Mga item (multi-select / maaaring lumikha)",addSelect:"Magdagdag / Pumili",searchOrAdd:"Mag-type upang maghanap o magdagdag ng bagong item",noOption:"Walang mga opsyon",note:"Tala (anumang wika)",smartOCR:"Smart Capture (mock)",clear:"Burahin",save:"I-save (demo)",preview:"Preview ng submitted na data",appTitle:"Maliit na Salapi",toForm:"Bagong Entry",toHistory:"Kasaysayan",toReport:"Buong Buwan na Ulat",executedAtTH:"Petsa",incomeTH:"Kita",expenseTH:"Gastos",balanceTH:"Balanse",itemsTH:"Mga Item",noteTH:"Mga Tala",count:"Bilang",totalIncome:"Kabuuang Kita",totalExpense:"Kabuuang Gastos",netAmount:"Net na Halaga"},Sz={features:"Pangkalahatang-ideya ng System",title:"Magandang Arawang Pangangalaga",subtitle1:"Intelihenteng Platform ng Pangangalaga",subtitle2:"Buong Sistema ng React + Supabase + PWA",login:"Mag-log in sa Sistema",website:"Opisyal na Website",appTitle:"CareTide",mobileOptimized:"Mobile Optimized",mobileOptimizedDesc:"Install the App for the best experience",iosInstallTitle:"iOS Installation",iosInstallBody:"Open in Safari → Tap Share → Add to Home Screen.",iosInstallDismiss:"Don't show again",offlineTitle:"Offline Mode",offlineDesc:"Backend not configured. Demo features only.",installApp:"Install App"},Ez={purchase:{title:"Sistema ng Pamamahala ng Salapi para sa Pagbili",balance:"Nakaraang Balanse",addExpense:"Magdagdag ng Gastos",deposit:"Magdeposito",welcome:"Maligayang pagdating sa sistemang CareTide!"},tabs:{visit:"Data ng Pag-log in",record:"Mga Rekord",trend:"Mga Trend",body:"Katawan",nursing:"Nursing",diet:"Dieta",excretion:"Pagdumi",rehab:"Rehab"}},Oz={title:"Media Wall",upload:"Upload",refresh:"Refresh",loading:"Loading…",error:"Error: ",empty:"No media yet.",copyLink:"Copy link",copied:"Copied",share:"Share",delete:"Delete",deleteConfirm:"Delete this media? The cloud file will also be removed.",deleteFail:"Delete failed: ",save:"Save",saving:"Saving…",file:"File",caption:"Caption (optional)",categoryLabel:"Category",shareTitle:"Share Media",mediaLink:"Media Link",noSignedUrl:"Failed to create signed URL",saveFail:"Save failed: ",progress:{queued:"Queued",uploading:"Uploading…",done:"Done",error:"Error"},submit:"Upload",submitUploading:"Uploading…",selectFileFirst:"Please select file(s)",notLoggedIn:"Not logged in",noContext:"No care context found. Please create one first.",category:{all:"All categories",body:"Body",rehab:"Rehab",meal:"Meal"}},Az={backHome:"Back to Home"},jz={care:vz,onboarding:yz,app:bz,auth:xz,nav:wz,pettyCash:_z,welcome:Sz,mobile:Ez,mediaWall:Oz,common:Az},Tz={basicInfo:{title:"ตั้งค่าข้อมูลพื้นฐาน",role:"เลือกบทบาทของคุณ",family:"ฉันเป็นญาติ",caregiver:"ฉันเป็นผู้ดูแล",userNickname:"ชื่อเล่นของคุณ",userNicknamePlace:"กรุณาใส่ชื่อเล่นของคุณ",patientNickname:"ชื่อเล่นของผู้ป่วย",patientNicknamePlace:"กรุณาใส่ชื่อเล่นของผู้ป่วย",patientGender:"เพศของผู้ป่วย",male:"ชาย",female:"หญิง",patientWeight:"น้ำหนักผู้ป่วย (กก.)",patientAge:"อายุผู้ป่วย (ปี)"},modules:{title:"เลือกโมดูลบันทึกการดูแล",description:"กรุณาเลือกหัวข้อบันทึกการดูแลที่คุณต้องการ ระบบจะสร้างฟอร์มเฉพาะให้คุณ",basic:"โมดูลพื้นฐาน",advanced:"โมดูลขั้นสูง"},invitation:{title:"เชิญเข้าร่วมกลุ่มดูแล",familyTitle:"เชิญผู้ดูแลเข้าร่วม",familyDescription:"แชร์ลิงก์ด้านล่างกับผู้ดูแล พวกเขาสามารถเข้าร่วมกลุ่มดูแลเดียวกันได้",caregiverTitle:"แชร์ให้ญาติ",caregiverDescription:"แชร์ลิงก์ด้านล่างกับญาติ พวกเขาสามารถเข้าร่วมกลุ่มดูแลเดียวกันได้",copyLink:"คัดลอกลิงก์เชิญ"},tutorial:{title:"คู่มือการใช้งาน",description:"กรุณาดูวิดีโอคู่มือด้านล่างเพื่อเข้าใจฟีเจอร์ของระบบอย่างรวดเร็ว",watchVideo:"ดูวิดีโอคู่มือ",skip:"ข้ามคู่มือ"},completion:{title:"ตั้งค่าเสร็จสมบูรณ์",description:"คุณได้สร้างกลุ่มดูแลเรียบร้อยแล้ว สามารถเริ่มบันทึกข้อมูลการดูแลได้ทันที",start:"เริ่มบันทึกทันที",watchTutorial:"ดูคู่มือฉบับเต็ม",complete:"เสร็จสมบูรณ์"},previous:"ก่อนหน้า",next:"ถัดไป",complete:"เสร็จสมบูรณ์"},Cz={name:"บันทึกการดูแลที่ดี",description:"แพลตฟอร์มบันทึกการดูแลอัจฉริยะ"},kz={login:"เข้าสู่ระบบ",loginError:"อีเมลหรือรหัสผ่านไม่ถูกต้อง",logout:"ออกจากระบบ",register:"ลงทะเบียน",email:"อีเมล",password:"รหัสผ่าน",confirmPassword:"ยืนยันรหัสผ่าน"},Nz={dashboard:"แดชบอร์ด",record:"เพิ่มบันทึก",charts:"แผนภูมิ",export:"ส่งออกข้อมูล",vitals:"เครื่องหมายชีพ",care:"การดูแลร่างกาย",nutrition:"โภชนาการ",rehab:"ฟื้นฟู",patients:"ผู้ป่วย",reports:"รายงาน",settings:"การตั้งค่า",mediaWall:"Media Wall"},Pz={title:"การจัดการเงินสดเล็กน้อย (Lite)",loginTime:"เวลาของระบบเมื่อเข้าสู่ระบบ",executedAt:"ดำเนินการเมื่อ (แก้ไขได้)",now:"ตอนนี้",prevBalance:"ยอดคงเหลือก่อนหน้า",income:"รายได้",expense:"ค่าใช้จ่าย",balance:"ยอดคงเหลือ",items:"รายการ (เลือกหลายรายการ / สร้างได้)",addSelect:"เพิ่ม / เลือก",searchOrAdd:"พิมพ์เพื่อค้นหาหรือเพิ่มรายการใหม่",noOption:"ไม่มีตัวเลือก",note:"หมายเหตุ (ภาษาใดก็ได้)",smartOCR:"จับภาพอัจฉริยะ (จำลอง)",clear:"ล้าง",save:"บันทึก (ตัวอย่าง)",preview:"ดูตัวอย่างข้อมูลที่ส่ง",appTitle:"เงินสดเล็กน้อย",toForm:"รายการใหม่",toHistory:"ประวัติ",toReport:"รายงานประจำเดือน",executedAtTH:"วันที่",incomeTH:"รายได้",expenseTH:"ค่าใช้จ่าย",balanceTH:"ยอดคงเหลือ",itemsTH:"รายการ",noteTH:"หมายเหตุ",count:"จำนวน",totalIncome:"รายได้รวม",totalExpense:"ค่าใช้จ่ายรวม",netAmount:"จำนวนสุทธิ"},Rz={title:"บันทึกการดูแลที่ดี",subtitle1:"แพลตฟอร์มการดูแลอัจฉริยะ",subtitle2:"ระบบครบครัน React + Supabase + PWA",login:"เข้าสู่ระบบ",website:"เว็บไซต์ทางการ",appTitle:"CareTide",mobileOptimized:"Mobile Optimized",mobileOptimizedDesc:"Install the App for the best experience",iosInstallTitle:"การติดตั้ง iOS",iosInstallBody:"เปิดด้วย Safari → แตะ แชร์ → เพิ่มไปยังหน้าจอหลัก",iosInstallDismiss:"ไม่ต้องแสดงอีก",offlineTitle:"โหมดออฟไลน์",offlineDesc:"ยังไม่ได้กำหนดค่าแบ็กเอนด์ ใช้งานเดโมเท่านั้น",installApp:"ติดตั้งแอป"},Dz={purchase:{title:"ระบบจัดการเงินสดสำหรับการซื้อ",balance:"ยอดคงเหลือก่อนหน้า",addExpense:"เพิ่มค่าใช้จ่าย",deposit:"ฝากเงิน",welcome:"ยินดีต้อนรับสู่ระบบ CareTide!"},tabs:{visit:"ข้อมูลเข้าสู่ระบบ",record:"บันทึก",trend:"แนวโน้ม",body:"ร่างกาย",nursing:"การพยาบาล",diet:"อาหาร",excretion:"การขับถ่าย",rehab:"ฟื้นฟู",visitor:"ผู้เยี่ยมชม",purchase:"การซื้อ",other:"อื่นๆ"}},Mz={title:"Media Wall",upload:"Upload",refresh:"Refresh",loading:"Loading…",error:"Error: ",empty:"No media yet.",copyLink:"Copy link",copied:"Copied",share:"Share",delete:"Delete",deleteConfirm:"Delete this media? The cloud file will also be removed.",deleteFail:"Delete failed: ",save:"Save",saving:"Saving…",file:"File",caption:"Caption (optional)",categoryLabel:"Category",shareTitle:"Share Media",mediaLink:"Media Link",noSignedUrl:"Failed to create signed URL",saveFail:"Save failed: ",progress:{queued:"Queued",uploading:"Uploading…",done:"Done",error:"Error"},submit:"Upload",submitUploading:"Uploading…",selectFileFirst:"Please select file(s)",notLoggedIn:"Not logged in",noContext:"No care context found. Please create one first.",category:{all:"All categories",body:"Body",rehab:"Rehab",meal:"Meal"}},$z={backHome:"Back to Home"},Lz={onboarding:Tz,app:Cz,auth:kz,nav:Nz,pettyCash:Pz,welcome:Rz,mobile:Dz,mediaWall:Mz,common:$z},Iz={"zh-TW":{translation:kI},id:{translation:VI},en:{translation:iz},vi:{translation:gz},fil:{translation:jz},th:{translation:Lz}};bn.use(sI).init({resources:Iz,lng:localStorage.getItem("pc_lang")||"zh-TW",fallbackLng:"zh-TW",interpolation:{escapeValue:!1}});var Ny=function(e,t){return Ny=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(n[a]=r[a])},Ny(e,t)};function PC(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Ny(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Od=function(){return Od=Object.assign||function(t){for(var n,r=1,a=arguments.length;r=0;c--)(l=e[c])&&(s=(a<3?l(s):a>3?l(t,n,s):l(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function DC(e,t){return function(n,r){t(n,r,e)}}function MC(e,t,n,r,a,s){function l(A){if(A!==void 0&&typeof A!="function")throw new TypeError("Function expected");return A}for(var c=r.kind,f=c==="getter"?"get":c==="setter"?"set":"value",h=!t&&e?r.static?e:e.prototype:null,p=t||(h?Object.getOwnPropertyDescriptor(h,r.name):{}),m,y=!1,v=n.length-1;v>=0;v--){var w={};for(var E in r)w[E]=E==="access"?{}:r[E];for(var E in r.access)w.access[E]=r.access[E];w.addInitializer=function(A){if(y)throw new TypeError("Cannot add initializers after decoration has completed");s.push(l(A||null))};var S=(0,n[v])(c==="accessor"?{get:p.get,set:p.set}:p[f],w);if(c==="accessor"){if(S===void 0)continue;if(S===null||typeof S!="object")throw new TypeError("Object expected");(m=l(S.get))&&(p.get=m),(m=l(S.set))&&(p.set=m),(m=l(S.init))&&a.unshift(m)}else(m=l(S))&&(c==="field"?a.unshift(m):p[f]=m)}h&&Object.defineProperty(h,r.name,p),y=!0}function $C(e,t,n){for(var r=arguments.length>2,a=0;a0&&s[s.length-1])&&(h[0]===6||h[0]===2)){n=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Vb(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),a,s=[],l;try{for(;(t===void 0||t-- >0)&&!(a=r.next()).done;)s.push(a.value)}catch(c){l={error:c}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(l)throw l.error}}return s}function qC(){for(var e=[],t=0;t1||f(v,E)})},w&&(a[v]=w(a[v])))}function f(v,w){try{h(r[v](w))}catch(E){y(s[0][3],E)}}function h(v){v.value instanceof Ko?Promise.resolve(v.value.v).then(p,m):y(s[0][2],v)}function p(v){f("next",v)}function m(v){f("throw",v)}function y(v,w){v(w),s.shift(),s.length&&f(s[0][0],s[0][1])}}function KC(e){var t,n;return t={},r("next"),r("throw",function(a){throw a}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(a,s){t[a]=e[a]?function(l){return(n=!n)?{value:Ko(e[a](l)),done:!1}:s?s(l):l}:s}}function GC(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Ad=="function"?Ad(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(l){return new Promise(function(c,f){l=e[s](l),a(c,f,l.done,l.value)})}}function a(s,l,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},l)}}function ZC(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var zz=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},Py=function(e){return Py=Object.getOwnPropertyNames||function(t){var n=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[n.length]=r);return n},Py(e)};function WC(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=Py(e),r=0;r0){let h=function(p){return Promise.all(p.map(m=>Promise.resolve(m).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};var l=h;document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),f=c?.nonce||c?.getAttribute("nonce");a=h(n.map(p=>{if(p=Vz(p),p in xE)return;xE[p]=!0;const m=p.endsWith(".css"),y=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${y}`))return;const v=document.createElement("link");if(v.rel=m?"stylesheet":Hz,m||(v.as="script"),v.crossOrigin="",v.href=p,f&&v.setAttribute("nonce",f),document.head.appendChild(v),m)return new Promise((w,E)=>{v.addEventListener("load",w),v.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${p}`)))})}))}function s(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return a.then(c=>{for(const f of c||[])f.status==="rejected"&&s(f.reason);return t().catch(s)})},Fz=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...n)=>al(async()=>{const{default:r}=await Promise.resolve().then(()=>Rs);return{default:r}},[]).then(({default:r})=>r(...n)):t=fetch,(...n)=>t(...n)};class Fb extends Error{constructor(t,n="FunctionsError",r){super(t),this.name=n,this.context=r}}class wE extends Fb{constructor(t){super("Failed to send a request to the Edge Function","FunctionsFetchError",t)}}class _E extends Fb{constructor(t){super("Relay Error invoking the Edge Function","FunctionsRelayError",t)}}class SE extends Fb{constructor(t){super("Edge Function returned a non-2xx status code","FunctionsHttpError",t)}}var Ry;(function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"})(Ry||(Ry={}));class Kz{constructor(t,{headers:n={},customFetch:r,region:a=Ry.Any}={}){this.url=t,this.headers=n,this.region=a,this.fetch=Fz(r)}setAuth(t){this.headers.Authorization=`Bearer ${t}`}invoke(t){return we(this,arguments,void 0,function*(n,r={}){var a;try{const{headers:s,method:l,body:c,signal:f}=r;let h={},{region:p}=r;p||(p=this.region);const m=new URL(`${this.url}/${n}`);p&&p!=="any"&&(h["x-region"]=p,m.searchParams.set("forceFunctionRegion",p));let y;c&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)?typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",y=c):typeof c=="string"?(h["Content-Type"]="text/plain",y=c):typeof FormData<"u"&&c instanceof FormData?y=c:(h["Content-Type"]="application/json",y=JSON.stringify(c)):y=c;const v=yield this.fetch(m.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),s),body:y,signal:f}).catch(A=>{throw A.name==="AbortError"?A:new wE(A)}),w=v.headers.get("x-relay-error");if(w&&w==="true")throw new _E(v);if(!v.ok)throw new SE(v);let E=((a=v.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),S;return E==="application/json"?S=yield v.json():E==="application/octet-stream"||E==="application/pdf"?S=yield v.blob():E==="text/event-stream"?S=v:E==="multipart/form-data"?S=yield v.formData():S=yield v.text(),{data:S,error:null,response:v}}catch(s){return s instanceof Error&&s.name==="AbortError"?{data:null,error:new wE(s)}:{data:null,error:s,response:s instanceof SE||s instanceof _E?s.context:void 0}}})}}var gn={};const il=EC(qz);var Uf={},Bf={},qf={},Hf={},Vf={},Gz=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")},Go=Gz();const Zz=Go.fetch,rk=Go.fetch.bind(Go),ak=Go.Headers,Wz=Go.Request,Yz=Go.Response,Rs=Object.freeze(Object.defineProperty({__proto__:null,Headers:ak,Request:Wz,Response:Yz,default:rk,fetch:Zz},Symbol.toStringTag,{value:"Module"})),Xz=EC(Rs);var Ff={},EE;function ik(){if(EE)return Ff;EE=1,Object.defineProperty(Ff,"__esModule",{value:!0});class e extends Error{constructor(n){super(n.message),this.name="PostgrestError",this.details=n.details,this.hint=n.hint,this.code=n.code}}return Ff.default=e,Ff}var OE;function sk(){if(OE)return Vf;OE=1,Object.defineProperty(Vf,"__esModule",{value:!0});const e=il,t=e.__importDefault(Xz),n=e.__importDefault(ik());class r{constructor(s){var l,c;this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=new Headers(s.headers),this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=(l=s.shouldThrowOnError)!==null&&l!==void 0?l:!1,this.signal=s.signal,this.isMaybeSingle=(c=s.isMaybeSingle)!==null&&c!==void 0?c:!1,s.fetch?this.fetch=s.fetch:typeof fetch>"u"?this.fetch=t.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,l){return this.headers=new Headers(this.headers),this.headers.set(s,l),this}then(s,l){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const c=this.fetch;let f=c(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async h=>{var p,m,y,v;let w=null,E=null,S=null,A=h.status,j=h.statusText;if(h.ok){if(this.method!=="HEAD"){const P=await h.text();P===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((p=this.headers.get("Accept"))===null||p===void 0)&&p.includes("application/vnd.pgrst.plan+text"))?E=P:E=JSON.parse(P))}const N=(m=this.headers.get("Prefer"))===null||m===void 0?void 0:m.match(/count=(exact|planned|estimated)/),k=(y=h.headers.get("content-range"))===null||y===void 0?void 0:y.split("/");N&&k&&k.length>1&&(S=parseInt(k[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(E)&&(E.length>1?(w={code:"PGRST116",details:`Results contain ${E.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},E=null,S=null,A=406,j="Not Acceptable"):E.length===1?E=E[0]:E=null)}else{const N=await h.text();try{w=JSON.parse(N),Array.isArray(w)&&h.status===404&&(E=[],w=null,A=200,j="OK")}catch{h.status===404&&N===""?(A=204,j="No Content"):w={message:N}}if(w&&this.isMaybeSingle&&(!((v=w?.details)===null||v===void 0)&&v.includes("0 rows"))&&(w=null,A=200,j="OK"),w&&this.shouldThrowOnError)throw new n.default(w)}return{error:w,data:E,count:S,status:A,statusText:j}});return this.shouldThrowOnError||(f=f.catch(h=>{var p,m,y;return{error:{message:`${(p=h?.name)!==null&&p!==void 0?p:"FetchError"}: ${h?.message}`,details:`${(m=h?.stack)!==null&&m!==void 0?m:""}`,hint:"",code:`${(y=h?.code)!==null&&y!==void 0?y:""}`},data:null,count:null,status:0,statusText:""}})),f.then(s,l)}returns(){return this}overrideTypes(){return this}}return Vf.default=r,Vf}var AE;function ok(){if(AE)return Hf;AE=1,Object.defineProperty(Hf,"__esModule",{value:!0});const t=il.__importDefault(sk());class n extends t.default{select(a){let s=!1;const l=(a??"*").split("").map(c=>/\s/.test(c)&&!s?"":(c==='"'&&(s=!s),c)).join("");return this.url.searchParams.set("select",l),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:s=!0,nullsFirst:l,foreignTable:c,referencedTable:f=c}={}){const h=f?`${f}.order`:"order",p=this.url.searchParams.get(h);return this.url.searchParams.set(h,`${p?`${p},`:""}${a}.${s?"asc":"desc"}${l===void 0?"":l?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:s,referencedTable:l=s}={}){const c=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(c,`${a}`),this}range(a,s,{foreignTable:l,referencedTable:c=l}={}){const f=typeof c>"u"?"offset":`${c}.offset`,h=typeof c>"u"?"limit":`${c}.limit`;return this.url.searchParams.set(f,`${a}`),this.url.searchParams.set(h,`${s-a+1}`),this}abortSignal(a){return this.signal=a,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:a=!1,verbose:s=!1,settings:l=!1,buffers:c=!1,wal:f=!1,format:h="text"}={}){var p;const m=[a?"analyze":null,s?"verbose":null,l?"settings":null,c?"buffers":null,f?"wal":null].filter(Boolean).join("|"),y=(p=this.headers.get("Accept"))!==null&&p!==void 0?p:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${h}; for="${y}"; options=${m};`),h==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}}return Hf.default=n,Hf}var jE;function Kb(){if(jE)return qf;jE=1,Object.defineProperty(qf,"__esModule",{value:!0});const t=il.__importDefault(ok());class n extends t.default{eq(a,s){return this.url.searchParams.append(a,`eq.${s}`),this}neq(a,s){return this.url.searchParams.append(a,`neq.${s}`),this}gt(a,s){return this.url.searchParams.append(a,`gt.${s}`),this}gte(a,s){return this.url.searchParams.append(a,`gte.${s}`),this}lt(a,s){return this.url.searchParams.append(a,`lt.${s}`),this}lte(a,s){return this.url.searchParams.append(a,`lte.${s}`),this}like(a,s){return this.url.searchParams.append(a,`like.${s}`),this}likeAllOf(a,s){return this.url.searchParams.append(a,`like(all).{${s.join(",")}}`),this}likeAnyOf(a,s){return this.url.searchParams.append(a,`like(any).{${s.join(",")}}`),this}ilike(a,s){return this.url.searchParams.append(a,`ilike.${s}`),this}ilikeAllOf(a,s){return this.url.searchParams.append(a,`ilike(all).{${s.join(",")}}`),this}ilikeAnyOf(a,s){return this.url.searchParams.append(a,`ilike(any).{${s.join(",")}}`),this}is(a,s){return this.url.searchParams.append(a,`is.${s}`),this}in(a,s){const l=Array.from(new Set(s)).map(c=>typeof c=="string"&&new RegExp("[,()]").test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(a,`in.(${l})`),this}contains(a,s){return typeof s=="string"?this.url.searchParams.append(a,`cs.${s}`):Array.isArray(s)?this.url.searchParams.append(a,`cs.{${s.join(",")}}`):this.url.searchParams.append(a,`cs.${JSON.stringify(s)}`),this}containedBy(a,s){return typeof s=="string"?this.url.searchParams.append(a,`cd.${s}`):Array.isArray(s)?this.url.searchParams.append(a,`cd.{${s.join(",")}}`):this.url.searchParams.append(a,`cd.${JSON.stringify(s)}`),this}rangeGt(a,s){return this.url.searchParams.append(a,`sr.${s}`),this}rangeGte(a,s){return this.url.searchParams.append(a,`nxl.${s}`),this}rangeLt(a,s){return this.url.searchParams.append(a,`sl.${s}`),this}rangeLte(a,s){return this.url.searchParams.append(a,`nxr.${s}`),this}rangeAdjacent(a,s){return this.url.searchParams.append(a,`adj.${s}`),this}overlaps(a,s){return typeof s=="string"?this.url.searchParams.append(a,`ov.${s}`):this.url.searchParams.append(a,`ov.{${s.join(",")}}`),this}textSearch(a,s,{config:l,type:c}={}){let f="";c==="plain"?f="pl":c==="phrase"?f="ph":c==="websearch"&&(f="w");const h=l===void 0?"":`(${l})`;return this.url.searchParams.append(a,`${f}fts${h}.${s}`),this}match(a){return Object.entries(a).forEach(([s,l])=>{this.url.searchParams.append(s,`eq.${l}`)}),this}not(a,s,l){return this.url.searchParams.append(a,`not.${s}.${l}`),this}or(a,{foreignTable:s,referencedTable:l=s}={}){const c=l?`${l}.or`:"or";return this.url.searchParams.append(c,`(${a})`),this}filter(a,s,l){return this.url.searchParams.append(a,`${s}.${l}`),this}}return qf.default=n,qf}var TE;function lk(){if(TE)return Bf;TE=1,Object.defineProperty(Bf,"__esModule",{value:!0});const t=il.__importDefault(Kb());class n{constructor(a,{headers:s={},schema:l,fetch:c}){this.url=a,this.headers=new Headers(s),this.schema=l,this.fetch=c}select(a,s){const{head:l=!1,count:c}=s??{},f=l?"HEAD":"GET";let h=!1;const p=(a??"*").split("").map(m=>/\s/.test(m)&&!h?"":(m==='"'&&(h=!h),m)).join("");return this.url.searchParams.set("select",p),c&&this.headers.append("Prefer",`count=${c}`),new t.default({method:f,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:s,defaultToNull:l=!0}={}){var c;const f="POST";if(s&&this.headers.append("Prefer",`count=${s}`),l||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const h=a.reduce((p,m)=>p.concat(Object.keys(m)),[]);if(h.length>0){const p=[...new Set(h)].map(m=>`"${m}"`);this.url.searchParams.set("columns",p.join(","))}}return new t.default({method:f,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(c=this.fetch)!==null&&c!==void 0?c:fetch})}upsert(a,{onConflict:s,ignoreDuplicates:l=!1,count:c,defaultToNull:f=!0}={}){var h;const p="POST";if(this.headers.append("Prefer",`resolution=${l?"ignore":"merge"}-duplicates`),s!==void 0&&this.url.searchParams.set("on_conflict",s),c&&this.headers.append("Prefer",`count=${c}`),f||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const m=a.reduce((y,v)=>y.concat(Object.keys(v)),[]);if(m.length>0){const y=[...new Set(m)].map(v=>`"${v}"`);this.url.searchParams.set("columns",y.join(","))}}return new t.default({method:p,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}update(a,{count:s}={}){var l;const c="PATCH";return s&&this.headers.append("Prefer",`count=${s}`),new t.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}delete({count:a}={}){var s;const l="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new t.default({method:l,url:this.url,headers:this.headers,schema:this.schema,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}}return Bf.default=n,Bf}var CE;function Jz(){if(CE)return Uf;CE=1,Object.defineProperty(Uf,"__esModule",{value:!0});const e=il,t=e.__importDefault(lk()),n=e.__importDefault(Kb());class r{constructor(s,{headers:l={},schema:c,fetch:f}={}){this.url=s,this.headers=new Headers(l),this.schemaName=c,this.fetch=f}from(s){const l=new URL(`${this.url}/${s}`);return new t.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(s){return new r(this.url,{headers:this.headers,schema:s,fetch:this.fetch})}rpc(s,l={},{head:c=!1,get:f=!1,count:h}={}){var p;let m;const y=new URL(`${this.url}/rpc/${s}`);let v;c||f?(m=c?"HEAD":"GET",Object.entries(l).filter(([E,S])=>S!==void 0).map(([E,S])=>[E,Array.isArray(S)?`{${S.join(",")}}`:`${S}`]).forEach(([E,S])=>{y.searchParams.append(E,S)})):(m="POST",v=l);const w=new Headers(this.headers);return h&&w.set("Prefer",`count=${h}`),new n.default({method:m,url:y,headers:w,schema:this.schemaName,body:v,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return Uf.default=r,Uf}var kE;function Qz(){if(kE)return gn;kE=1,Object.defineProperty(gn,"__esModule",{value:!0}),gn.PostgrestError=gn.PostgrestBuilder=gn.PostgrestTransformBuilder=gn.PostgrestFilterBuilder=gn.PostgrestQueryBuilder=gn.PostgrestClient=void 0;const e=il,t=e.__importDefault(Jz());gn.PostgrestClient=t.default;const n=e.__importDefault(lk());gn.PostgrestQueryBuilder=n.default;const r=e.__importDefault(Kb());gn.PostgrestFilterBuilder=r.default;const a=e.__importDefault(ok());gn.PostgrestTransformBuilder=a.default;const s=e.__importDefault(sk());gn.PostgrestBuilder=s.default;const l=e.__importDefault(ik());return gn.PostgrestError=l.default,gn.default={PostgrestClient:t.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:r.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:s.default,PostgrestError:l.default},gn}var e3=Qz();const t3=sa(e3),{PostgrestClient:n3,PostgrestQueryBuilder:qae,PostgrestFilterBuilder:Hae,PostgrestTransformBuilder:Vae,PostgrestBuilder:Fae,PostgrestError:Kae}=t3;class r3{static detectEnvironment(){var t;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((t=navigator.userAgent)===null||t===void 0)&&t.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const n=process.versions;if(n&&n.node){const r=n.node,a=parseInt(r.replace(/^v/,"").split(".")[0]);return a>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${a} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${a} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: import ws from "ws" new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const t=this.detectEnvironment();if(t.constructor)return t.constructor;let n=t.error||"WebSocket not supported in this environment.";throw t.workaround&&(n+=` Suggested solution: ${t.workaround}`),new Error(n)}static createWebSocket(t,n){const r=this.getWebSocketConstructor();return new r(t,n)}static isWebSocketSupported(){try{const t=this.detectEnvironment();return t.type==="native"||t.type==="ws"}catch{return!1}}}const a3="2.76.1",i3=`realtime-js/${a3}`,s3="1.0.0",Dy=1e4,o3=1e3,l3=100;var ku;(function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"})(ku||(ku={}));var Ht;(function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"})(Ht||(Ht={}));var Ir;(function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"})(Ir||(Ir={}));var My;(function(e){e.websocket="websocket"})(My||(My={}));var fs;(function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"})(fs||(fs={}));class u3{constructor(){this.HEADER_LENGTH=1}decode(t,n){return t.constructor===ArrayBuffer?n(this._binaryDecode(t)):n(typeof t=="string"?JSON.parse(t):{})}_binaryDecode(t){const n=new DataView(t),r=new TextDecoder;return this._decodeBroadcast(t,n,r)}_decodeBroadcast(t,n,r){const a=n.getUint8(1),s=n.getUint8(2);let l=this.HEADER_LENGTH+2;const c=r.decode(t.slice(l,l+a));l=l+a;const f=r.decode(t.slice(l,l+s));l=l+s;const h=JSON.parse(r.decode(t.slice(l,t.byteLength)));return{ref:null,topic:c,event:f,payload:h}}}class uk{constructor(t,n){this.callback=t,this.timerCalc=n,this.timer=void 0,this.tries=0,this.callback=t,this.timerCalc=n}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var ct;(function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"})(ct||(ct={}));const NE=(e,t,n={})=>{var r;const a=(r=n.skipTypes)!==null&&r!==void 0?r:[];return t?Object.keys(t).reduce((s,l)=>(s[l]=c3(l,e,t,a),s),{}):{}},c3=(e,t,n,r)=>{const a=t.find(c=>c.name===e),s=a?.type,l=n[e];return s&&!r.includes(s)?ck(s,l):$y(l)},ck=(e,t)=>{if(e.charAt(0)==="_"){const n=e.slice(1,e.length);return p3(t,n)}switch(e){case ct.bool:return f3(t);case ct.float4:case ct.float8:case ct.int2:case ct.int4:case ct.int8:case ct.numeric:case ct.oid:return d3(t);case ct.json:case ct.jsonb:return h3(t);case ct.timestamp:return m3(t);case ct.abstime:case ct.date:case ct.daterange:case ct.int4range:case ct.int8range:case ct.money:case ct.reltime:case ct.text:case ct.time:case ct.timestamptz:case ct.timetz:case ct.tsrange:case ct.tstzrange:return $y(t);default:return $y(t)}},$y=e=>e,f3=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},d3=e=>{if(typeof e=="string"){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},h3=e=>{if(typeof e=="string")try{return JSON.parse(e)}catch(t){return console.log(`JSON parse error: ${t}`),e}return e},p3=(e,t)=>{if(typeof e!="string")return e;const n=e.length-1,r=e[n];if(e[0]==="{"&&r==="}"){let s;const l=e.slice(1,n);try{s=JSON.parse("["+l+"]")}catch{s=l?l.split(","):[]}return s.map(c=>ck(t,c))}return e},m3=e=>typeof e=="string"?e.replace(" ","T"):e,fk=e=>{const t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),t.pathname===""||t.pathname==="/"?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};class zg{constructor(t,n,r={},a=Dy){this.channel=t,this.event=n,this.payload=r,this.timeout=a,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(t){this.timeout=t,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(t){this.payload=Object.assign(Object.assign({},this.payload),t)}receive(t,n){var r;return this._hasReceived(t)&&n((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:t,callback:n}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const t=n=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=n,this._matchReceive(n)};this.channel._on(this.refEvent,{},t),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(t,n){this.refEvent&&this.channel._trigger(this.refEvent,{status:t,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:t,response:n}){this.recHooks.filter(r=>r.status===t).forEach(r=>r.callback(n))}_hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}}var PE;(function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"})(PE||(PE={}));class Nu{constructor(t,n){this.channel=t,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=n?.events||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},a=>{const{onJoin:s,onLeave:l,onSync:c}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Nu.syncState(this.state,a,s,l),this.pendingDiffs.forEach(f=>{this.state=Nu.syncDiff(this.state,f,s,l)}),this.pendingDiffs=[],c()}),this.channel._on(r.diff,{},a=>{const{onJoin:s,onLeave:l,onSync:c}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(a):(this.state=Nu.syncDiff(this.state,a,s,l),c())}),this.onJoin((a,s,l)=>{this.channel._trigger("presence",{event:"join",key:a,currentPresences:s,newPresences:l})}),this.onLeave((a,s,l)=>{this.channel._trigger("presence",{event:"leave",key:a,currentPresences:s,leftPresences:l})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(t,n,r,a){const s=this.cloneDeep(t),l=this.transformState(n),c={},f={};return this.map(s,(h,p)=>{l[h]||(f[h]=p)}),this.map(l,(h,p)=>{const m=s[h];if(m){const y=p.map(S=>S.presence_ref),v=m.map(S=>S.presence_ref),w=p.filter(S=>v.indexOf(S.presence_ref)<0),E=m.filter(S=>y.indexOf(S.presence_ref)<0);w.length>0&&(c[h]=w),E.length>0&&(f[h]=E)}else c[h]=p}),this.syncDiff(s,{joins:c,leaves:f},r,a)}static syncDiff(t,n,r,a){const{joins:s,leaves:l}={joins:this.transformState(n.joins),leaves:this.transformState(n.leaves)};return r||(r=()=>{}),a||(a=()=>{}),this.map(s,(c,f)=>{var h;const p=(h=t[c])!==null&&h!==void 0?h:[];if(t[c]=this.cloneDeep(f),p.length>0){const m=t[c].map(v=>v.presence_ref),y=p.filter(v=>m.indexOf(v.presence_ref)<0);t[c].unshift(...y)}r(c,p,f)}),this.map(l,(c,f)=>{let h=t[c];if(!h)return;const p=f.map(m=>m.presence_ref);h=h.filter(m=>p.indexOf(m.presence_ref)<0),t[c]=h,a(c,h,f),h.length===0&&delete t[c]}),t}static map(t,n){return Object.getOwnPropertyNames(t).map(r=>n(r,t[r]))}static transformState(t){return t=this.cloneDeep(t),Object.getOwnPropertyNames(t).reduce((n,r)=>{const a=t[r];return"metas"in a?n[r]=a.metas.map(s=>(s.presence_ref=s.phx_ref,delete s.phx_ref,delete s.phx_ref_prev,s)):n[r]=a,n},{})}static cloneDeep(t){return JSON.parse(JSON.stringify(t))}onJoin(t){this.caller.onJoin=t}onLeave(t){this.caller.onLeave=t}onSync(t){this.caller.onSync=t}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var RE;(function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"})(RE||(RE={}));var Pu;(function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"})(Pu||(Pu={}));var Ta;(function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"})(Ta||(Ta={}));class Gb{constructor(t,n={config:{}},r){var a,s;if(this.topic=t,this.params=n,this.socket=r,this.bindings={},this.state=Ht.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=t.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.timeout=this.socket.timeout,this.joinPush=new zg(this,Ir.join,this.params,this.timeout),this.rejoinTimer=new uk(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Ht.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(l=>l.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Ht.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Ht.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Ht.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Ht.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Ir.reply,{},(l,c)=>{this._trigger(this._replyEventName(c),l)}),this.presence=new Nu(this),this.broadcastEndpointURL=fk(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((s=(a=this.params.config)===null||a===void 0?void 0:a.broadcast)===null||s===void 0)&&s.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(t,n=this.timeout){var r,a,s;if(this.socket.isConnected()||this.socket.connect(),this.state==Ht.closed){const{config:{broadcast:l,presence:c,private:f}}=this.params,h=(a=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(v=>v.filter))!==null&&a!==void 0?a:[],p=!!this.bindings[Pu.PRESENCE]&&this.bindings[Pu.PRESENCE].length>0||((s=this.params.config.presence)===null||s===void 0?void 0:s.enabled)===!0,m={},y={broadcast:l,presence:Object.assign(Object.assign({},c),{enabled:p}),postgres_changes:h,private:f};this.socket.accessTokenValue&&(m.access_token=this.socket.accessTokenValue),this._onError(v=>t?.(Ta.CHANNEL_ERROR,v)),this._onClose(()=>t?.(Ta.CLOSED)),this.updateJoinPayload(Object.assign({config:y},m)),this.joinedOnce=!0,this._rejoin(n),this.joinPush.receive("ok",async({postgres_changes:v})=>{var w;if(this.socket.setAuth(),v===void 0){t?.(Ta.SUBSCRIBED);return}else{const E=this.bindings.postgres_changes,S=(w=E?.length)!==null&&w!==void 0?w:0,A=[];for(let j=0;j{this.state=Ht.errored,t?.(Ta.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(v).join(", ")||"error")))}).receive("timeout",()=>{t?.(Ta.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(t,n={}){return await this.send({type:"presence",event:"track",payload:t},n.timeout||this.timeout)}async untrack(t={}){return await this.send({type:"presence",event:"untrack"},t)}on(t,n,r){return this.state===Ht.joined&&t===Pu.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(t,n,r)}async httpSend(t,n,r={}){var a;const s=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(n==null)return Promise.reject("Payload is required for httpSend()");const l={method:"POST",headers:{Authorization:s,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:t,payload:n,private:this.private}]})},c=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(a=r.timeout)!==null&&a!==void 0?a:this.timeout);if(c.status===202)return{success:!0};let f=c.statusText;try{const h=await c.json();f=h.error||h.message||f}catch{}return Promise.reject(new Error(f))}async send(t,n={}){var r,a;if(!this._canPush()&&t.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:s,payload:l}=t,f={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:l,private:this.private}]})};try{const h=await this._fetchWithTimeout(this.broadcastEndpointURL,f,(r=n.timeout)!==null&&r!==void 0?r:this.timeout);return await((a=h.body)===null||a===void 0?void 0:a.cancel()),h.ok?"ok":"error"}catch(h){return h.name==="AbortError"?"timed out":"error"}}else return new Promise(s=>{var l,c,f;const h=this._push(t.type,t,n.timeout||this.timeout);t.type==="broadcast"&&!(!((f=(c=(l=this.params)===null||l===void 0?void 0:l.config)===null||c===void 0?void 0:c.broadcast)===null||f===void 0)&&f.ack)&&s("ok"),h.receive("ok",()=>s("ok")),h.receive("error",()=>s("error")),h.receive("timeout",()=>s("timed out"))})}updateJoinPayload(t){this.joinPush.updatePayload(t)}unsubscribe(t=this.timeout){this.state=Ht.leaving;const n=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Ir.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(a=>{r=new zg(this,Ir.leave,{},t),r.receive("ok",()=>{n(),a("ok")}).receive("timeout",()=>{n(),a("timed out")}).receive("error",()=>{a("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{r?.destroy()})}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Ht.closed,this.bindings={}}async _fetchWithTimeout(t,n,r){const a=new AbortController,s=setTimeout(()=>a.abort(),r),l=await this.socket.fetch(t,Object.assign(Object.assign({},n),{signal:a.signal}));return clearTimeout(s),l}_push(t,n,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${t}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let a=new zg(this,t,n,r);return this._canPush()?a.send():this._addToPushBuffer(a),a}_addToPushBuffer(t){if(t.startTimeout(),this.pushBuffer.push(t),this.pushBuffer.length>l3){const n=this.pushBuffer.shift();n&&(n.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${n.event}`,n.payload))}}_onMessage(t,n,r){return n}_isMember(t){return this.topic===t}_joinRef(){return this.joinPush.ref}_trigger(t,n,r){var a,s;const l=t.toLocaleLowerCase(),{close:c,error:f,leave:h,join:p}=Ir;if(r&&[c,f,h,p].indexOf(l)>=0&&r!==this._joinRef())return;let y=this._onMessage(l,n,r);if(n&&!y)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(l)?(a=this.bindings.postgres_changes)===null||a===void 0||a.filter(v=>{var w,E,S;return((w=v.filter)===null||w===void 0?void 0:w.event)==="*"||((S=(E=v.filter)===null||E===void 0?void 0:E.event)===null||S===void 0?void 0:S.toLocaleLowerCase())===l}).map(v=>v.callback(y,r)):(s=this.bindings[l])===null||s===void 0||s.filter(v=>{var w,E,S,A,j,T;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in v){const N=v.id,k=(w=v.filter)===null||w===void 0?void 0:w.event;return N&&((E=n.ids)===null||E===void 0?void 0:E.includes(N))&&(k==="*"||k?.toLocaleLowerCase()===((S=n.data)===null||S===void 0?void 0:S.type.toLocaleLowerCase()))}else{const N=(j=(A=v?.filter)===null||A===void 0?void 0:A.event)===null||j===void 0?void 0:j.toLocaleLowerCase();return N==="*"||N===((T=n?.event)===null||T===void 0?void 0:T.toLocaleLowerCase())}else return v.type.toLocaleLowerCase()===l}).map(v=>{if(typeof y=="object"&&"ids"in y){const w=y.data,{schema:E,table:S,commit_timestamp:A,type:j,errors:T}=w;y=Object.assign(Object.assign({},{schema:E,table:S,commit_timestamp:A,eventType:j,new:{},old:{},errors:T}),this._getPayloadRecords(w))}v.callback(y,r)})}_isClosed(){return this.state===Ht.closed}_isJoined(){return this.state===Ht.joined}_isJoining(){return this.state===Ht.joining}_isLeaving(){return this.state===Ht.leaving}_replyEventName(t){return`chan_reply_${t}`}_on(t,n,r){const a=t.toLocaleLowerCase(),s={type:a,filter:n,callback:r};return this.bindings[a]?this.bindings[a].push(s):this.bindings[a]=[s],this}_off(t,n){const r=t.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(a=>{var s;return!(((s=a.type)===null||s===void 0?void 0:s.toLocaleLowerCase())===r&&Gb.isEqual(a.filter,n))})),this}static isEqual(t,n){if(Object.keys(t).length!==Object.keys(n).length)return!1;for(const r in t)if(t[r]!==n[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(t){this._on(Ir.close,{},t)}_onError(t){this._on(Ir.error,{},n=>t(n))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(t=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Ht.joining,this.joinPush.resend(t))}_getPayloadRecords(t){const n={new:{},old:{}};return(t.type==="INSERT"||t.type==="UPDATE")&&(n.new=NE(t.columns,t.record)),(t.type==="UPDATE"||t.type==="DELETE")&&(n.old=NE(t.columns,t.old_record)),n}}const Ug=()=>{},Kf={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},g3=[1e3,2e3,5e3,1e4],v3=1e4,y3=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class b3{constructor(t,n){var r;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=Dy,this.transport=null,this.heartbeatIntervalMs=Kf.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Ug,this.ref=0,this.reconnectTimer=null,this.logger=Ug,this.conn=null,this.sendBuffer=[],this.serializer=new u3,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=a=>{let s;return a?s=a:typeof fetch>"u"?s=(...l)=>al(async()=>{const{default:c}=await Promise.resolve().then(()=>Rs);return{default:c}},void 0).then(({default:c})=>c(...l)).catch(c=>{throw new Error(`Failed to load @supabase/node-fetch: ${c.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):s=fetch,(...l)=>s(...l)},!(!((r=n?.params)===null||r===void 0)&&r.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey,this.endPoint=`${t}/${My.websocket}`,this.httpEndpoint=fk(t),this._initializeOptions(n),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(n?.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=r3.createWebSocket(this.endpointURL())}catch(t){this._setConnectionState("disconnected");const n=t.message;throw n.includes("Node.js")?new Error(`${n} To use Realtime in Node.js, you need to provide a WebSocket implementation: Option 1: Use Node.js 22+ which has native WebSocket support Option 2: Install and provide the "ws" package: npm install ws import ws from "ws" const client = new RealtimeClient(url, { ...options, transport: ws })`):new Error(`WebSocket not available: ${n}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:s3}))}disconnect(t,n){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},t?this.conn.close(t,n??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(t){const n=await t.unsubscribe();return this.channels.length===0&&this.disconnect(),n}async removeAllChannels(){const t=await Promise.all(this.channels.map(n=>n.unsubscribe()));return this.channels=[],this.disconnect(),t}log(t,n,r){this.logger(t,n,r)}connectionState(){switch(this.conn&&this.conn.readyState){case ku.connecting:return fs.Connecting;case ku.open:return fs.Open;case ku.closing:return fs.Closing;default:return fs.Closed}}isConnected(){return this.connectionState()===fs.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(t,n={config:{}}){const r=`realtime:${t}`,a=this.getChannels().find(s=>s.topic===r);if(a)return a;{const s=new Gb(`realtime:${t}`,n,this);return this.channels.push(s),s}}push(t){const{topic:n,event:r,payload:a,ref:s}=t,l=()=>{this.encode(t,c=>{var f;(f=this.conn)===null||f===void 0||f.send(c)})};this.log("push",`${n} ${r} (${s})`,a),this.isConnected()?l():this.sendBuffer.push(l)}async setAuth(t=null){this._authPromise=this._performAuth(t);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var t;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(n){this.log("error","error in heartbeat callback",n)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(n){this.log("error","error in heartbeat callback",n)}this._wasManualDisconnect=!1,(t=this.conn)===null||t===void 0||t.close(o3,"heartbeat timeout"),setTimeout(()=>{var n;this.isConnected()||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout()},Kf.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(n){this.log("error","error in heartbeat callback",n)}this._setAuthSafely("heartbeat")}onHeartbeat(t){this.heartbeatCallback=t}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}_makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}_leaveOpenTopic(t){let n=this.channels.find(r=>r.topic===t&&(r._isJoined()||r._isJoining()));n&&(this.log("transport",`leaving duplicate topic "${t}"`),n.unsubscribe())}_remove(t){this.channels=this.channels.filter(n=>n.topic!==t.topic)}_onConnMessage(t){this.decode(t.data,n=>{if(n.topic==="phoenix"&&n.event==="phx_reply")try{this.heartbeatCallback(n.payload.status==="ok"?"ok":"error")}catch(h){this.log("error","error in heartbeat callback",h)}n.ref&&n.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:r,event:a,payload:s,ref:l}=n,c=l?`(${l})`:"",f=s.status||"";this.log("receive",`${f} ${r} ${a} ${c}`.trim(),s),this.channels.filter(h=>h._isMember(r)).forEach(h=>h._trigger(a,s,l)),this._triggerStateCallbacks("message",n)})}_clearTimer(t){var n;t==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):t==="reconnect"&&((n=this.reconnectTimer)===null||n===void 0||n.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=t=>this._onConnError(t),this.conn.onmessage=t=>this._onConnMessage(t),this.conn.onclose=t=>this._onConnClose(t))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(t=>t.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this.workerRef.terminate()},this.workerRef.onmessage=n=>{n.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(t){var n;this._setConnectionState("disconnected"),this.log("transport","close",t),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout(),this._triggerStateCallbacks("close",t)}_onConnError(t){this._setConnectionState("disconnected"),this.log("transport",`${t}`),this._triggerChanError(),this._triggerStateCallbacks("error",t)}_triggerChanError(){this.channels.forEach(t=>t._trigger(Ir.error))}_appendParams(t,n){if(Object.keys(n).length===0)return t;const r=t.match(/\?/)?"&":"?",a=new URLSearchParams(n);return`${t}${r}${a}`}_workerObjectUrl(t){let n;if(t)n=t;else{const r=new Blob([y3],{type:"application/javascript"});n=URL.createObjectURL(r)}return n}_setConnectionState(t,n=!1){this._connectionState=t,t==="connecting"?this._wasManualDisconnect=!1:t==="disconnecting"&&(this._wasManualDisconnect=n)}async _performAuth(t=null){let n;t?n=t:this.accessToken?n=await this.accessToken():n=this.accessTokenValue,this.accessTokenValue!=n&&(this.accessTokenValue=n,this.channels.forEach(r=>{const a={access_token:n,version:i3};n&&r.updateJoinPayload(a),r.joinedOnce&&r._isJoined()&&r._push(Ir.access_token,{access_token:n})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(t="general"){this.setAuth().catch(n=>{this.log("error",`error setting auth in ${t}`,n)})}_triggerStateCallbacks(t,n){try{this.stateChangeCallbacks[t].forEach(r=>{try{r(n)}catch(a){this.log("error",`error in ${t} callback`,a)}})}catch(r){this.log("error",`error triggering ${t} callbacks`,r)}}_setupReconnectionTimer(){this.reconnectTimer=new uk(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Kf.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(t){var n,r,a,s,l,c,f,h,p;if(this.transport=(n=t?.transport)!==null&&n!==void 0?n:null,this.timeout=(r=t?.timeout)!==null&&r!==void 0?r:Dy,this.heartbeatIntervalMs=(a=t?.heartbeatIntervalMs)!==null&&a!==void 0?a:Kf.HEARTBEAT_INTERVAL,this.worker=(s=t?.worker)!==null&&s!==void 0?s:!1,this.accessToken=(l=t?.accessToken)!==null&&l!==void 0?l:null,this.heartbeatCallback=(c=t?.heartbeatCallback)!==null&&c!==void 0?c:Ug,t?.params&&(this.params=t.params),t?.logger&&(this.logger=t.logger),(t?.logLevel||t?.log_level)&&(this.logLevel=t.logLevel||t.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(f=t?.reconnectAfterMs)!==null&&f!==void 0?f:(m=>g3[m-1]||v3),this.encode=(h=t?.encode)!==null&&h!==void 0?h:((m,y)=>y(JSON.stringify(m))),this.decode=(p=t?.decode)!==null&&p!==void 0?p:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=t?.workerUrl}}}class Zb extends Error{constructor(t){super(t),this.__isStorageError=!0,this.name="StorageError"}}function wt(e){return typeof e=="object"&&e!==null&&"__isStorageError"in e}class x3 extends Zb{constructor(t,n,r){super(t),this.name="StorageApiError",this.status=n,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class Ly extends Zb{constructor(t,n){super(t),this.name="StorageUnknownError",this.originalError=n}}const Wb=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...n)=>al(async()=>{const{default:r}=await Promise.resolve().then(()=>Rs);return{default:r}},void 0).then(({default:r})=>r(...n)):t=fetch,(...n)=>t(...n)},w3=()=>we(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield al(()=>Promise.resolve().then(()=>Rs),void 0)).Response:Response}),Iy=e=>{if(Array.isArray(e))return e.map(n=>Iy(n));if(typeof e=="function"||e!==Object(e))return e;const t={};return Object.entries(e).forEach(([n,r])=>{const a=n.replace(/([-_][a-z])/gi,s=>s.toUpperCase().replace(/[-_]/g,""));t[a]=Iy(r)}),t},_3=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Bg=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),S3=(e,t,n)=>we(void 0,void 0,void 0,function*(){const r=yield w3();e instanceof r&&!n?.noResolveJson?e.json().then(a=>{const s=e.status||500,l=a?.statusCode||s+"";t(new x3(Bg(a),s,l))}).catch(a=>{t(new Ly(Bg(a),a))}):t(new Ly(Bg(e),e))}),E3=(e,t,n,r)=>{const a={method:e,headers:t?.headers||{}};return e==="GET"||!r?a:(_3(r)?(a.headers=Object.assign({"Content-Type":"application/json"},t?.headers),a.body=JSON.stringify(r)):a.body=r,t?.duplex&&(a.duplex=t.duplex),Object.assign(Object.assign({},a),n))};function tc(e,t,n,r,a,s){return we(this,void 0,void 0,function*(){return new Promise((l,c)=>{e(n,E3(t,r,a,s)).then(f=>{if(!f.ok)throw f;return r?.noResolveJson?f:f.json()}).then(f=>l(f)).catch(f=>S3(f,c,r))})})}function Iu(e,t,n,r){return we(this,void 0,void 0,function*(){return tc(e,"GET",t,n,r)})}function Lr(e,t,n,r,a){return we(this,void 0,void 0,function*(){return tc(e,"POST",t,r,a,n)})}function zy(e,t,n,r,a){return we(this,void 0,void 0,function*(){return tc(e,"PUT",t,r,a,n)})}function O3(e,t,n,r){return we(this,void 0,void 0,function*(){return tc(e,"HEAD",t,Object.assign(Object.assign({},n),{noResolveJson:!0}),r)})}function Yb(e,t,n,r,a){return we(this,void 0,void 0,function*(){return tc(e,"DELETE",t,r,a,n)})}class A3{constructor(t,n){this.downloadFn=t,this.shouldThrowOnError=n}then(t,n){return this.execute().then(t,n)}execute(){return we(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(wt(t))return{data:null,error:t};throw t}})}}var dk;class j3{constructor(t,n){this.downloadFn=t,this.shouldThrowOnError=n,this[dk]="BlobDownloadBuilder",this.promise=null}asStream(){return new A3(this.downloadFn,this.shouldThrowOnError)}then(t,n){return this.getPromise().then(t,n)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}execute(){return we(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(wt(t))return{data:null,error:t};throw t}})}}dk=Symbol.toStringTag;const T3={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},DE={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class C3{constructor(t,n={},r,a){this.shouldThrowOnError=!1,this.url=t,this.headers=n,this.bucketId=r,this.fetch=Wb(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(t,n,r,a){return we(this,void 0,void 0,function*(){try{let s;const l=Object.assign(Object.assign({},DE),a);let c=Object.assign(Object.assign({},this.headers),t==="POST"&&{"x-upsert":String(l.upsert)});const f=l.metadata;typeof Blob<"u"&&r instanceof Blob?(s=new FormData,s.append("cacheControl",l.cacheControl),f&&s.append("metadata",this.encodeMetadata(f)),s.append("",r)):typeof FormData<"u"&&r instanceof FormData?(s=r,s.append("cacheControl",l.cacheControl),f&&s.append("metadata",this.encodeMetadata(f))):(s=r,c["cache-control"]=`max-age=${l.cacheControl}`,c["content-type"]=l.contentType,f&&(c["x-metadata"]=this.toBase64(this.encodeMetadata(f)))),a?.headers&&(c=Object.assign(Object.assign({},c),a.headers));const h=this._removeEmptyFolders(n),p=this._getFinalPath(h),m=yield(t=="PUT"?zy:Lr)(this.fetch,`${this.url}/object/${p}`,s,Object.assign({headers:c},l?.duplex?{duplex:l.duplex}:{}));return{data:{path:h,id:m.Id,fullPath:m.Key},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(wt(s))return{data:null,error:s};throw s}})}upload(t,n,r){return we(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",t,n,r)})}uploadToSignedUrl(t,n,r,a){return we(this,void 0,void 0,function*(){const s=this._removeEmptyFolders(t),l=this._getFinalPath(s),c=new URL(this.url+`/object/upload/sign/${l}`);c.searchParams.set("token",n);try{let f;const h=Object.assign({upsert:DE.upsert},a),p=Object.assign(Object.assign({},this.headers),{"x-upsert":String(h.upsert)});typeof Blob<"u"&&r instanceof Blob?(f=new FormData,f.append("cacheControl",h.cacheControl),f.append("",r)):typeof FormData<"u"&&r instanceof FormData?(f=r,f.append("cacheControl",h.cacheControl)):(f=r,p["cache-control"]=`max-age=${h.cacheControl}`,p["content-type"]=h.contentType);const m=yield zy(this.fetch,c.toString(),f,{headers:p});return{data:{path:s,fullPath:m.Key},error:null}}catch(f){if(this.shouldThrowOnError)throw f;if(wt(f))return{data:null,error:f};throw f}})}createSignedUploadUrl(t,n){return we(this,void 0,void 0,function*(){try{let r=this._getFinalPath(t);const a=Object.assign({},this.headers);n?.upsert&&(a["x-upsert"]="true");const s=yield Lr(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:a}),l=new URL(this.url+s.url),c=l.searchParams.get("token");if(!c)throw new Zb("No token returned by API");return{data:{signedUrl:l.toString(),path:t,token:c},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wt(r))return{data:null,error:r};throw r}})}update(t,n,r){return we(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",t,n,r)})}move(t,n,r){return we(this,void 0,void 0,function*(){try{return{data:yield Lr(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:t,destinationKey:n,destinationBucket:r?.destinationBucket},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(wt(a))return{data:null,error:a};throw a}})}copy(t,n,r){return we(this,void 0,void 0,function*(){try{return{data:{path:(yield Lr(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:t,destinationKey:n,destinationBucket:r?.destinationBucket},{headers:this.headers})).Key},error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(wt(a))return{data:null,error:a};throw a}})}createSignedUrl(t,n,r){return we(this,void 0,void 0,function*(){try{let a=this._getFinalPath(t),s=yield Lr(this.fetch,`${this.url}/object/sign/${a}`,Object.assign({expiresIn:n},r?.transform?{transform:r.transform}:{}),{headers:this.headers});const l=r?.download?`&download=${r.download===!0?"":r.download}`:"";return s={signedUrl:encodeURI(`${this.url}${s.signedURL}${l}`)},{data:s,error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(wt(a))return{data:null,error:a};throw a}})}createSignedUrls(t,n,r){return we(this,void 0,void 0,function*(){try{const a=yield Lr(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:n,paths:t},{headers:this.headers}),s=r?.download?`&download=${r.download===!0?"":r.download}`:"";return{data:a.map(l=>Object.assign(Object.assign({},l),{signedUrl:l.signedURL?encodeURI(`${this.url}${l.signedURL}${s}`):null})),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(wt(a))return{data:null,error:a};throw a}})}download(t,n){const a=typeof n?.transform<"u"?"render/image/authenticated":"object",s=this.transformOptsToQueryString(n?.transform||{}),l=s?`?${s}`:"",c=this._getFinalPath(t),f=()=>Iu(this.fetch,`${this.url}/${a}/${c}${l}`,{headers:this.headers,noResolveJson:!0});return new j3(f,this.shouldThrowOnError)}info(t){return we(this,void 0,void 0,function*(){const n=this._getFinalPath(t);try{const r=yield Iu(this.fetch,`${this.url}/object/info/${n}`,{headers:this.headers});return{data:Iy(r),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wt(r))return{data:null,error:r};throw r}})}exists(t){return we(this,void 0,void 0,function*(){const n=this._getFinalPath(t);try{return yield O3(this.fetch,`${this.url}/object/${n}`,{headers:this.headers}),{data:!0,error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wt(r)&&r instanceof Ly){const a=r.originalError;if([400,404].includes(a?.status))return{data:!1,error:r}}throw r}})}getPublicUrl(t,n){const r=this._getFinalPath(t),a=[],s=n?.download?`download=${n.download===!0?"":n.download}`:"";s!==""&&a.push(s);const c=typeof n?.transform<"u"?"render/image":"object",f=this.transformOptsToQueryString(n?.transform||{});f!==""&&a.push(f);let h=a.join("&");return h!==""&&(h=`?${h}`),{data:{publicUrl:encodeURI(`${this.url}/${c}/public/${r}${h}`)}}}remove(t){return we(this,void 0,void 0,function*(){try{return{data:yield Yb(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:t},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wt(n))return{data:null,error:n};throw n}})}list(t,n,r){return we(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},T3),n),{prefix:t||""});return{data:yield Lr(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},r),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(wt(a))return{data:null,error:a};throw a}})}listV2(t,n){return we(this,void 0,void 0,function*(){try{const r=Object.assign({},t);return{data:yield Lr(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,r,{headers:this.headers},n),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wt(r))return{data:null,error:r};throw r}})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(t){const n=[];return t.width&&n.push(`width=${t.width}`),t.height&&n.push(`height=${t.height}`),t.resize&&n.push(`resize=${t.resize}`),t.format&&n.push(`format=${t.format}`),t.quality&&n.push(`quality=${t.quality}`),n.join("&")}}const hk="2.76.1",pk={"X-Client-Info":`storage-js/${hk}`};class k3{constructor(t,n={},r,a){this.shouldThrowOnError=!1;const s=new URL(t);a?.useNewHostname&&/supabase\.(co|in|red)$/.test(s.hostname)&&!s.hostname.includes("storage.supabase.")&&(s.hostname=s.hostname.replace("supabase.","storage.supabase.")),this.url=s.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},pk),n),this.fetch=Wb(r)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(){return we(this,void 0,void 0,function*(){try{return{data:yield Iu(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(wt(t))return{data:null,error:t};throw t}})}getBucket(t){return we(this,void 0,void 0,function*(){try{return{data:yield Iu(this.fetch,`${this.url}/bucket/${t}`,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wt(n))return{data:null,error:n};throw n}})}createBucket(t){return we(this,arguments,void 0,function*(n,r={public:!1}){try{return{data:yield Lr(this.fetch,`${this.url}/bucket`,{id:n,name:n,type:r.type,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(wt(a))return{data:null,error:a};throw a}})}updateBucket(t,n){return we(this,void 0,void 0,function*(){try{return{data:yield zy(this.fetch,`${this.url}/bucket/${t}`,{id:t,name:t,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(wt(r))return{data:null,error:r};throw r}})}emptyBucket(t){return we(this,void 0,void 0,function*(){try{return{data:yield Lr(this.fetch,`${this.url}/bucket/${t}/empty`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wt(n))return{data:null,error:n};throw n}})}deleteBucket(t){return we(this,void 0,void 0,function*(){try{return{data:yield Yb(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wt(n))return{data:null,error:n};throw n}})}}class N3{constructor(t,n={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},pk),n),this.fetch=Wb(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(t){return we(this,void 0,void 0,function*(){try{return{data:yield Lr(this.fetch,`${this.url}/bucket`,{name:t},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wt(n))return{data:null,error:n};throw n}})}listBuckets(t){return we(this,void 0,void 0,function*(){try{const n=new URLSearchParams;t?.limit!==void 0&&n.set("limit",t.limit.toString()),t?.offset!==void 0&&n.set("offset",t.offset.toString()),t?.sortColumn&&n.set("sortColumn",t.sortColumn),t?.sortOrder&&n.set("sortOrder",t.sortOrder),t?.search&&n.set("search",t.search);const r=n.toString(),a=r?`${this.url}/bucket?${r}`:`${this.url}/bucket`,s=yield Iu(this.fetch,a,{headers:this.headers});return{data:Array.isArray(s)?s.filter(c=>c.type==="ANALYTICS"):[],error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wt(n))return{data:null,error:n};throw n}})}deleteBucket(t){return we(this,void 0,void 0,function*(){try{return{data:yield Yb(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(wt(n))return{data:null,error:n};throw n}})}}const Xb={"X-Client-Info":`storage-js/${hk}`,"Content-Type":"application/json"};class mk extends Error{constructor(t){super(t),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function Qn(e){return typeof e=="object"&&e!==null&&"__isStorageVectorsError"in e}class qg extends mk{constructor(t,n,r){super(t),this.name="StorageVectorsApiError",this.status=n,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class P3 extends mk{constructor(t,n){super(t),this.name="StorageVectorsUnknownError",this.originalError=n}}var ME;(function(e){e.InternalError="InternalError",e.S3VectorConflictException="S3VectorConflictException",e.S3VectorNotFoundException="S3VectorNotFoundException",e.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",e.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",e.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(ME||(ME={}));const Jb=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...n)=>al(async()=>{const{default:r}=await Promise.resolve().then(()=>Rs);return{default:r}},void 0).then(({default:r})=>r(...n)):t=fetch,(...n)=>t(...n)},R3=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},$E=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),D3=(e,t,n)=>we(void 0,void 0,void 0,function*(){if(e&&typeof e=="object"&&"status"in e&&"ok"in e&&typeof e.status=="number"&&!n?.noResolveJson){const a=e.status||500,s=e;if(typeof s.json=="function")s.json().then(l=>{const c=l?.statusCode||l?.code||a+"";t(new qg($E(l),a,c))}).catch(()=>{const l=a+"",c=s.statusText||`HTTP ${a} error`;t(new qg(c,a,l))});else{const l=a+"",c=s.statusText||`HTTP ${a} error`;t(new qg(c,a,l))}}else t(new P3($E(e),e))}),M3=(e,t,n,r)=>{const a={method:e,headers:t?.headers||{}};return r?(R3(r)?(a.headers=Object.assign({"Content-Type":"application/json"},t?.headers),a.body=JSON.stringify(r)):a.body=r,Object.assign(Object.assign({},a),n)):a};function $3(e,t,n,r,a,s){return we(this,void 0,void 0,function*(){return new Promise((l,c)=>{e(n,M3(t,r,a,s)).then(f=>{if(!f.ok)throw f;if(r?.noResolveJson)return f;const h=f.headers.get("content-type");return!h||!h.includes("application/json")?{}:f.json()}).then(f=>l(f)).catch(f=>D3(f,c,r))})})}function er(e,t,n,r,a){return we(this,void 0,void 0,function*(){return $3(e,"POST",t,r,a,n)})}class L3{constructor(t,n={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Xb),n),this.fetch=Jb(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(t){return we(this,void 0,void 0,function*(){try{return{data:(yield er(this.fetch,`${this.url}/CreateIndex`,t,{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}getIndex(t,n){return we(this,void 0,void 0,function*(){try{return{data:yield er(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:t,indexName:n},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qn(r))return{data:null,error:r};throw r}})}listIndexes(t){return we(this,void 0,void 0,function*(){try{return{data:yield er(this.fetch,`${this.url}/ListIndexes`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}deleteIndex(t,n){return we(this,void 0,void 0,function*(){try{return{data:(yield er(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:t,indexName:n},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qn(r))return{data:null,error:r};throw r}})}}class I3{constructor(t,n={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Xb),n),this.fetch=Jb(r)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(t){return we(this,void 0,void 0,function*(){try{if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:(yield er(this.fetch,`${this.url}/PutVectors`,t,{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}getVectors(t){return we(this,void 0,void 0,function*(){try{return{data:yield er(this.fetch,`${this.url}/GetVectors`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}listVectors(t){return we(this,void 0,void 0,function*(){try{if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return{data:yield er(this.fetch,`${this.url}/ListVectors`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}queryVectors(t){return we(this,void 0,void 0,function*(){try{return{data:yield er(this.fetch,`${this.url}/QueryVectors`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}deleteVectors(t){return we(this,void 0,void 0,function*(){try{if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:(yield er(this.fetch,`${this.url}/DeleteVectors`,t,{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}}class z3{constructor(t,n={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Xb),n),this.fetch=Jb(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(t){return we(this,void 0,void 0,function*(){try{return{data:(yield er(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}getBucket(t){return we(this,void 0,void 0,function*(){try{return{data:yield er(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:t},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}listBuckets(){return we(this,arguments,void 0,function*(t={}){try{return{data:yield er(this.fetch,`${this.url}/ListVectorBuckets`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}deleteBucket(t){return we(this,void 0,void 0,function*(){try{return{data:(yield er(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qn(n))return{data:null,error:n};throw n}})}}class U3 extends z3{constructor(t,n={}){super(t,n.headers||{},n.fetch)}from(t){return new B3(this.url,this.headers,t,this.fetch)}}class B3 extends L3{constructor(t,n,r,a){super(t,n,a),this.vectorBucketName=r}createIndex(t){const n=Object.create(null,{createIndex:{get:()=>super.createIndex}});return we(this,void 0,void 0,function*(){return n.createIndex.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName}))})}listIndexes(){const t=Object.create(null,{listIndexes:{get:()=>super.listIndexes}});return we(this,arguments,void 0,function*(n={}){return t.listIndexes.call(this,Object.assign(Object.assign({},n),{vectorBucketName:this.vectorBucketName}))})}getIndex(t){const n=Object.create(null,{getIndex:{get:()=>super.getIndex}});return we(this,void 0,void 0,function*(){return n.getIndex.call(this,this.vectorBucketName,t)})}deleteIndex(t){const n=Object.create(null,{deleteIndex:{get:()=>super.deleteIndex}});return we(this,void 0,void 0,function*(){return n.deleteIndex.call(this,this.vectorBucketName,t)})}index(t){return new q3(this.url,this.headers,this.vectorBucketName,t,this.fetch)}}class q3 extends I3{constructor(t,n,r,a,s){super(t,n,s),this.vectorBucketName=r,this.indexName=a}putVectors(t){const n=Object.create(null,{putVectors:{get:()=>super.putVectors}});return we(this,void 0,void 0,function*(){return n.putVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}getVectors(t){const n=Object.create(null,{getVectors:{get:()=>super.getVectors}});return we(this,void 0,void 0,function*(){return n.getVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}listVectors(){const t=Object.create(null,{listVectors:{get:()=>super.listVectors}});return we(this,arguments,void 0,function*(n={}){return t.listVectors.call(this,Object.assign(Object.assign({},n),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}queryVectors(t){const n=Object.create(null,{queryVectors:{get:()=>super.queryVectors}});return we(this,void 0,void 0,function*(){return n.queryVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}deleteVectors(t){const n=Object.create(null,{deleteVectors:{get:()=>super.deleteVectors}});return we(this,void 0,void 0,function*(){return n.deleteVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class H3 extends k3{constructor(t,n={},r,a){super(t,n,r,a)}from(t){return new C3(this.url,this.headers,t,this.fetch)}get vectors(){return new U3(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new N3(this.url+"/iceberg",this.headers,this.fetch)}}const V3="2.76.1";let Eu="";typeof Deno<"u"?Eu="deno":typeof document<"u"?Eu="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Eu="react-native":Eu="node";const F3={"X-Client-Info":`supabase-js-${Eu}/${V3}`},K3={headers:F3},G3={schema:"public"},Z3={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},W3={},Y3=e=>{let t;return e?t=e:typeof fetch>"u"?t=rk:t=fetch,(...n)=>t(...n)},X3=()=>typeof Headers>"u"?ak:Headers,J3=(e,t,n)=>{const r=Y3(n),a=X3();return async(s,l)=>{var c;const f=(c=await t())!==null&&c!==void 0?c:e;let h=new a(l?.headers);return h.has("apikey")||h.set("apikey",e),h.has("Authorization")||h.set("Authorization",`Bearer ${f}`),r(s,Object.assign(Object.assign({},l),{headers:h}))}};function Q3(e){return e.endsWith("/")?e:e+"/"}function eU(e,t){var n,r;const{db:a,auth:s,realtime:l,global:c}=e,{db:f,auth:h,realtime:p,global:m}=t,y={db:Object.assign(Object.assign({},f),a),auth:Object.assign(Object.assign({},h),s),realtime:Object.assign(Object.assign({},p),l),storage:{},global:Object.assign(Object.assign(Object.assign({},m),c),{headers:Object.assign(Object.assign({},(n=m?.headers)!==null&&n!==void 0?n:{}),(r=c?.headers)!==null&&r!==void 0?r:{})}),accessToken:async()=>""};return e.accessToken?y.accessToken=e.accessToken:delete y.accessToken,y}function tU(e){const t=e?.trim();if(!t)throw new Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(Q3(t))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const gk="2.76.1",Mo=30*1e3,Uy=3,Hg=Uy*Mo,nU="http://localhost:9999",rU="supabase.auth.token",aU={"X-Client-Info":`gotrue-js/${gk}`},By="X-Supabase-Api-Version",vk={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},iU=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,sU=600*1e3;class zu extends Error{constructor(t,n,r){super(t),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=r}}function Ae(e){return typeof e=="object"&&e!==null&&"__isAuthError"in e}class oU extends zu{constructor(t,n,r){super(t,n,r),this.name="AuthApiError",this.status=n,this.code=r}}function lU(e){return Ae(e)&&e.name==="AuthApiError"}class ds extends zu{constructor(t,n){super(t),this.name="AuthUnknownError",this.originalError=n}}class Pi extends zu{constructor(t,n,r,a){super(t,r,a),this.name=n,this.status=r}}class _i extends Pi{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function uU(e){return Ae(e)&&e.name==="AuthSessionMissingError"}class Ao extends Pi{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Gf extends Pi{constructor(t){super(t,"AuthInvalidCredentialsError",400,void 0)}}class Zf extends Pi{constructor(t,n=null){super(t,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function cU(e){return Ae(e)&&e.name==="AuthImplicitGrantRedirectError"}class LE extends Pi{constructor(t,n=null){super(t,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class qy extends Pi{constructor(t,n){super(t,"AuthRetryableFetchError",n,void 0)}}function Vg(e){return Ae(e)&&e.name==="AuthRetryableFetchError"}class IE extends Pi{constructor(t,n,r){super(t,"AuthWeakPasswordError",n,"weak_password"),this.reasons=r}}class Hy extends Pi{constructor(t){super(t,"AuthInvalidJwtError",400,"invalid_jwt")}}const jd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),zE=` \r=`.split(""),fU=(()=>{const e=new Array(128);for(let t=0;t=6;){const r=t.queue>>t.queuedBits-6&63;n(jd[r]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){const r=t.queue>>t.queuedBits-6&63;n(jd[r]),t.queuedBits-=6}}function yk(e,t,n){const r=fU[e];if(r>-1)for(t.queue=t.queue<<6|r,t.queuedBits+=6;t.queuedBits>=8;)n(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}}function BE(e){const t=[],n=l=>{t.push(String.fromCodePoint(l))},r={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},s=l=>{pU(l,r,n)};for(let l=0;l>6),t(128|e&63);return}else if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|e&63);return}else if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|e&63);return}throw new Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}function hU(e,t){for(let n=0;n55295&&r<=56319){const a=(r-55296)*1024&65535;r=(e.charCodeAt(n+1)-56320&65535|a)+65536,n+=1}dU(r,t)}}function pU(e,t,n){if(t.utf8seq===0){if(e<=127){n(e);return}for(let r=1;r<6;r+=1)if((e>>7-r&1)===0){t.utf8seq=r;break}if(t.utf8seq===2)t.codepoint=e&31;else if(t.utf8seq===3)t.codepoint=e&15;else if(t.utf8seq===4)t.codepoint=e&7;else throw new Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|e&63,t.utf8seq-=1,t.utf8seq===0&&n(t.codepoint)}}function Bo(e){const t=[],n={queue:0,queuedBits:0},r=a=>{t.push(a)};for(let a=0;at.push(n)),new Uint8Array(t)}function hs(e){const t=[],n={queue:0,queuedBits:0},r=a=>{t.push(a)};return e.forEach(a=>UE(a,n,r)),UE(null,n,r),t.join("")}function gU(e){return Math.round(Date.now()/1e3)+e}function vU(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}const Zn=()=>typeof window<"u"&&typeof document<"u",is={tested:!1,writable:!1},bk=()=>{if(!Zn())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(is.tested)return is.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),is.tested=!0,is.writable=!0}catch{is.tested=!0,is.writable=!1}return is.writable};function yU(e){const t={},n=new URL(e);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((a,s)=>{t[s]=a})}catch{}return n.searchParams.forEach((r,a)=>{t[a]=r}),t}const xk=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...n)=>al(async()=>{const{default:r}=await Promise.resolve().then(()=>Rs);return{default:r}},void 0).then(({default:r})=>r(...n)):t=fetch,(...n)=>t(...n)},bU=e=>typeof e=="object"&&e!==null&&"status"in e&&"ok"in e&&"json"in e&&typeof e.json=="function",$o=async(e,t,n)=>{await e.setItem(t,JSON.stringify(n))},ss=async(e,t)=>{const n=await e.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch{return n}},wi=async(e,t)=>{await e.removeItem(t)};class Eh{constructor(){this.promise=new Eh.promiseConstructor((t,n)=>{this.resolve=t,this.reject=n})}}Eh.promiseConstructor=Promise;function Fg(e){const t=e.split(".");if(t.length!==3)throw new Hy("Invalid JWT structure");for(let r=0;r{setTimeout(()=>t(null),e)})}function wU(e,t){return new Promise((r,a)=>{(async()=>{for(let s=0;s<1/0;s++)try{const l=await e(s);if(!t(s,null,l)){r(l);return}}catch(l){if(!t(s,l)){a(l);return}}})()})}function _U(e){return("0"+e.toString(16)).substr(-2)}function SU(){const t=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=n.length;let a="";for(let s=0;s<56;s++)a+=n.charAt(Math.floor(Math.random()*r));return a}return crypto.getRandomValues(t),Array.from(t,_U).join("")}async function EU(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n),a=new Uint8Array(r);return Array.from(a).map(s=>String.fromCharCode(s)).join("")}async function OU(e){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."),e;const n=await EU(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function jo(e,t,n=!1){const r=SU();let a=r;n&&(a+="/PASSWORD_RECOVERY"),await $o(e,`${t}-code-verifier`,a);const s=await OU(r);return[s,r===s?"plain":"s256"]}const AU=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function jU(e){const t=e.headers.get(By);if(!t||!t.match(AU))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch{return null}}function TU(e){if(!e)throw new Error("Missing exp claim");const t=Math.floor(Date.now()/1e3);if(e<=t)throw new Error("JWT has expired")}function CU(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const kU=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function To(e){if(!kU.test(e))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Kg(){const e={};return new Proxy(e,{get:(t,n)=>{if(n==="__isUserNotAvailableProxy")return!0;if(typeof n=="symbol"){const r=n.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${n}" property of the session object is not supported. Please use getUser() instead.`)},set:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function qE(e){return JSON.parse(JSON.stringify(e))}const os=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),NU=[502,503,504];async function HE(e){var t;if(!bU(e))throw new qy(os(e),0);if(NU.includes(e.status))throw new qy(os(e),e.status);let n;try{n=await e.json()}catch(s){throw new ds(os(s),s)}let r;const a=jU(e);if(a&&a.getTime()>=vk["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?r=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(r=n.error_code),r){if(r==="weak_password")throw new IE(os(n),e.status,((t=n.weak_password)===null||t===void 0?void 0:t.reasons)||[]);if(r==="session_not_found")throw new _i}else if(typeof n=="object"&&n&&typeof n.weak_password=="object"&&n.weak_password&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.reasons.reduce((s,l)=>s&&typeof l=="string",!0))throw new IE(os(n),e.status,n.weak_password.reasons);throw new oU(os(n),e.status||500,r)}const PU=(e,t,n,r)=>{const a={method:e,headers:t?.headers||{}};return e==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},t?.headers),a.body=JSON.stringify(r),Object.assign(Object.assign({},a),n))};async function Re(e,t,n,r){var a;const s=Object.assign({},r?.headers);s[By]||(s[By]=vk["2024-01-01"].name),r?.jwt&&(s.Authorization=`Bearer ${r.jwt}`);const l=(a=r?.query)!==null&&a!==void 0?a:{};r?.redirectTo&&(l.redirect_to=r.redirectTo);const c=Object.keys(l).length?"?"+new URLSearchParams(l).toString():"",f=await RU(e,t,n+c,{headers:s,noResolveJson:r?.noResolveJson},{},r?.body);return r?.xform?r?.xform(f):{data:Object.assign({},f),error:null}}async function RU(e,t,n,r,a,s){const l=PU(t,r,a,s);let c;try{c=await e(n,Object.assign({},l))}catch(f){throw console.error(f),new qy(os(f),0)}if(c.ok||await HE(c),r?.noResolveJson)return c;try{return await c.json()}catch(f){await HE(f)}}function $r(e){var t;let n=null;$U(e)&&(n=Object.assign({},e),e.expires_at||(n.expires_at=gU(e.expires_in)));const r=(t=e.user)!==null&&t!==void 0?t:e;return{data:{session:n,user:r},error:null}}function VE(e){const t=$r(e);return!t.error&&e.weak_password&&typeof e.weak_password=="object"&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&typeof e.weak_password.message=="string"&&e.weak_password.reasons.reduce((n,r)=>n&&typeof r=="string",!0)&&(t.data.weak_password=e.weak_password),t}function Oi(e){var t;return{data:{user:(t=e.user)!==null&&t!==void 0?t:e},error:null}}function DU(e){return{data:e,error:null}}function MU(e){const{action_link:t,email_otp:n,hashed_token:r,redirect_to:a,verification_type:s}=e,l=rl(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),c={action_link:t,email_otp:n,hashed_token:r,redirect_to:a,verification_type:s},f=Object.assign({},l);return{data:{properties:c,user:f},error:null}}function FE(e){return e}function $U(e){return e.access_token&&e.refresh_token&&e.expires_in}const Gg=["global","local","others"];class LU{constructor({url:t="",headers:n={},fetch:r}){this.url=t,this.headers=n,this.fetch=xk(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(t,n=Gg[0]){if(Gg.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Gg.join(", ")}`);try{return await Re(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:t,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Ae(r))return{data:null,error:r};throw r}}async inviteUserByEmail(t,n={}){try{return await Re(this.fetch,"POST",`${this.url}/invite`,{body:{email:t,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:Oi})}catch(r){if(Ae(r))return{data:{user:null},error:r};throw r}}async generateLink(t){try{const{options:n}=t,r=rl(t,["options"]),a=Object.assign(Object.assign({},r),n);return"newEmail"in r&&(a.new_email=r?.newEmail,delete a.newEmail),await Re(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:MU,redirectTo:n?.redirectTo})}catch(n){if(Ae(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(t){try{return await Re(this.fetch,"POST",`${this.url}/admin/users`,{body:t,headers:this.headers,xform:Oi})}catch(n){if(Ae(n))return{data:{user:null},error:n};throw n}}async listUsers(t){var n,r,a,s,l,c,f;try{const h={nextPage:null,lastPage:0,total:0},p=await Re(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=t?.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(s=(a=t?.perPage)===null||a===void 0?void 0:a.toString())!==null&&s!==void 0?s:""},xform:FE});if(p.error)throw p.error;const m=await p.json(),y=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,v=(f=(c=p.headers.get("link"))===null||c===void 0?void 0:c.split(","))!==null&&f!==void 0?f:[];return v.length>0&&(v.forEach(w=>{const E=parseInt(w.split(";")[0].split("=")[1].substring(0,1)),S=JSON.parse(w.split(";")[1].split("=")[1]);h[`${S}Page`]=E}),h.total=parseInt(y)),{data:Object.assign(Object.assign({},m),h),error:null}}catch(h){if(Ae(h))return{data:{users:[]},error:h};throw h}}async getUserById(t){To(t);try{return await Re(this.fetch,"GET",`${this.url}/admin/users/${t}`,{headers:this.headers,xform:Oi})}catch(n){if(Ae(n))return{data:{user:null},error:n};throw n}}async updateUserById(t,n){To(t);try{return await Re(this.fetch,"PUT",`${this.url}/admin/users/${t}`,{body:n,headers:this.headers,xform:Oi})}catch(r){if(Ae(r))return{data:{user:null},error:r};throw r}}async deleteUser(t,n=!1){To(t);try{return await Re(this.fetch,"DELETE",`${this.url}/admin/users/${t}`,{headers:this.headers,body:{should_soft_delete:n},xform:Oi})}catch(r){if(Ae(r))return{data:{user:null},error:r};throw r}}async _listFactors(t){To(t.userId);try{const{data:n,error:r}=await Re(this.fetch,"GET",`${this.url}/admin/users/${t.userId}/factors`,{headers:this.headers,xform:a=>({data:{factors:a},error:null})});return{data:n,error:r}}catch(n){if(Ae(n))return{data:null,error:n};throw n}}async _deleteFactor(t){To(t.userId),To(t.id);try{return{data:await Re(this.fetch,"DELETE",`${this.url}/admin/users/${t.userId}/factors/${t.id}`,{headers:this.headers}),error:null}}catch(n){if(Ae(n))return{data:null,error:n};throw n}}async _listOAuthClients(t){var n,r,a,s,l,c,f;try{const h={nextPage:null,lastPage:0,total:0},p=await Re(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=t?.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(s=(a=t?.perPage)===null||a===void 0?void 0:a.toString())!==null&&s!==void 0?s:""},xform:FE});if(p.error)throw p.error;const m=await p.json(),y=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,v=(f=(c=p.headers.get("link"))===null||c===void 0?void 0:c.split(","))!==null&&f!==void 0?f:[];return v.length>0&&(v.forEach(w=>{const E=parseInt(w.split(";")[0].split("=")[1].substring(0,1)),S=JSON.parse(w.split(";")[1].split("=")[1]);h[`${S}Page`]=E}),h.total=parseInt(y)),{data:Object.assign(Object.assign({},m),h),error:null}}catch(h){if(Ae(h))return{data:{clients:[]},error:h};throw h}}async _createOAuthClient(t){try{return await Re(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:t,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ae(n))return{data:null,error:n};throw n}}async _getOAuthClient(t){try{return await Re(this.fetch,"GET",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ae(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(t){try{return await Re(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ae(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(t){try{return await Re(this.fetch,"POST",`${this.url}/admin/oauth/clients/${t}/regenerate_secret`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ae(n))return{data:null,error:n};throw n}}}function KE(e={}){return{getItem:t=>e[t]||null,setItem:(t,n)=>{e[t]=n},removeItem:t=>{delete e[t]}}}const Co={debug:!!(globalThis&&bk()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class wk extends Error{constructor(t){super(t),this.isAcquireTimeout=!0}}class IU extends wk{}async function zU(e,t,n){Co.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);const r=new globalThis.AbortController;return t>0&&setTimeout(()=>{r.abort(),Co.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,t===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async a=>{if(a){Co.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,a.name);try{return await n()}finally{Co.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,a.name)}}else{if(t===0)throw Co.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new IU(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(Co.debug)try{const s=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(s,null," "))}catch(s){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",s)}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()}}))}function UU(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function _k(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw new Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}function BU(e){return parseInt(e,16)}function qU(e){const t=new TextEncoder().encode(e);return"0x"+Array.from(t,r=>r.toString(16).padStart(2,"0")).join("")}function HU(e){var t;const{chainId:n,domain:r,expirationTime:a,issuedAt:s=new Date,nonce:l,notBefore:c,requestId:f,resources:h,scheme:p,uri:m,version:y}=e;{if(!Number.isInteger(n))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${n}`);if(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(l&&l.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${l}`);if(!m)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(y!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${y}`);if(!((t=e.statement)===null||t===void 0)&&t.includes(` `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`)}const v=_k(e.address),w=p?`${p}://${r}`:r,E=e.statement?`${e.statement} `:"",S=`${w} wants you to sign in with your Ethereum account: ${v} ${E}`;let A=`URI: ${m} Version: ${y} Chain ID: ${n}${l?` Nonce: ${l}`:""} Issued At: ${s.toISOString()}`;if(a&&(A+=` Expiration Time: ${a.toISOString()}`),c&&(A+=` Not Before: ${c.toISOString()}`),f&&(A+=` Request ID: ${f}`),h){let j=` Resources:`;for(const T of h){if(!T||typeof T!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${T}`);j+=` - ${T}`}A+=j}return`${S} ${A}`}class $t extends Error{constructor({message:t,code:n,cause:r,name:a}){var s;super(t,{cause:r}),this.__isWebAuthnError=!0,this.name=(s=a??(r instanceof Error?r.name:void 0))!==null&&s!==void 0?s:"Unknown Error",this.code=n}}class Td extends $t{constructor(t,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:t}),this.name="WebAuthnUnknownError",this.originalError=n}}function VU({error:e,options:t}){var n,r,a;const{publicKey:s}=t;if(!s)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new $t({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if(e.name==="ConstraintError"){if(((n=s.authenticatorSelection)===null||n===void 0?void 0:n.requireResidentKey)===!0)return new $t({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if(t.mediation==="conditional"&&((r=s.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new $t({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if(((a=s.authenticatorSelection)===null||a===void 0?void 0:a.userVerification)==="required")return new $t({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if(e.name==="InvalidStateError")return new $t({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if(e.name==="NotAllowedError")return new $t({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="NotSupportedError")return s.pubKeyCredParams.filter(c=>c.type==="public-key").length===0?new $t({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new $t({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if(e.name==="SecurityError"){const l=window.location.hostname;if(Sk(l)){if(s.rp.id!==l)return new $t({message:`The RP ID "${s.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new $t({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="TypeError"){if(s.user.id.byteLength<1||s.user.id.byteLength>64)return new $t({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if(e.name==="UnknownError")return new $t({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new $t({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}function FU({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new $t({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if(e.name==="NotAllowedError")return new $t({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="SecurityError"){const r=window.location.hostname;if(Sk(r)){if(n.rpId!==r)return new $t({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new $t({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="UnknownError")return new $t({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new $t({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}class KU{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const t=new AbortController;return this.controller=t,t.signal}cancelCeremony(){if(this.controller){const t=new Error("Manually cancelling existing WebAuthn API call");t.name="AbortError",this.controller.abort(t),this.controller=void 0}}}const GU=new KU;function ZU(e){if(!e)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(e);const{challenge:t,user:n,excludeCredentials:r}=e,a=rl(e,["challenge","user","excludeCredentials"]),s=Bo(t).buffer,l=Object.assign(Object.assign({},n),{id:Bo(n.id).buffer}),c=Object.assign(Object.assign({},a),{challenge:s,user:l});if(r&&r.length>0){c.excludeCredentials=new Array(r.length);for(let f=0;f0){s.allowCredentials=new Array(n.length);for(let l=0;la!==null&&typeof a=="object"&&!Array.isArray(a),n=a=>a instanceof ArrayBuffer||ArrayBuffer.isView(a),r={};for(const a of e)if(a)for(const s in a){const l=a[s];if(l!==void 0)if(Array.isArray(l))r[s]=l;else if(n(l))r[s]=l;else if(t(l)){const c=r[s];t(c)?r[s]=Cd(c,l):r[s]=Cd(l)}else r[s]=l}return r}function n4(e,t){return Cd(e4,e,t||{})}function r4(e,t){return Cd(t4,e,t||{})}class a4{constructor(t){this.client=t,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(t){return this.client.mfa.enroll(Object.assign(Object.assign({},t),{factorType:"webauthn"}))}async _challenge({factorId:t,webauthn:n,friendlyName:r,signal:a},s){try{const{data:l,error:c}=await this.client.mfa.challenge({factorId:t,webauthn:n});if(!l)return{data:null,error:c};const f=a??GU.createNewAbortSignal();if(l.webauthn.type==="create"){const{user:h}=l.webauthn.credential_options.publicKey;h.name||(h.name=`${h.id}:${r}`),h.displayName||(h.displayName=h.name)}switch(l.webauthn.type){case"create":{const h=n4(l.webauthn.credential_options.publicKey,s?.create),{data:p,error:m}=await JU({publicKey:h,signal:f});return p?{data:{factorId:t,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:m}}case"request":{const h=r4(l.webauthn.credential_options.publicKey,s?.request),{data:p,error:m}=await QU(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:h,signal:f}));return p?{data:{factorId:t,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:m}}}}catch(l){return Ae(l)?{data:null,error:l}:{data:null,error:new ds("Unexpected error in challenge",l)}}}async _verify({challengeId:t,factorId:n,webauthn:r}){return this.client.mfa.verify({factorId:n,challengeId:t,webauthn:r})}async _authenticate({factorId:t,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:a}},s){if(!n)return{data:null,error:new zu("rpId is required for WebAuthn authentication")};try{if(!GE())return{data:null,error:new ds("Browser does not support WebAuthn",null)};const{data:l,error:c}=await this.challenge({factorId:t,webauthn:{rpId:n,rpOrigins:r},signal:a},{request:s});if(!l)return{data:null,error:c};const{webauthn:f}=l;return this._verify({factorId:t,challengeId:l.challengeId,webauthn:{type:f.type,rpId:n,rpOrigins:r,credential_response:f.credential_response}})}catch(l){return Ae(l)?{data:null,error:l}:{data:null,error:new ds("Unexpected error in authenticate",l)}}}async _register({friendlyName:t,rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:a},s){if(!n)return{data:null,error:new zu("rpId is required for WebAuthn registration")};try{if(!GE())return{data:null,error:new ds("Browser does not support WebAuthn",null)};const{data:l,error:c}=await this._enroll({friendlyName:t});if(!l)return await this.client.mfa.listFactors().then(p=>{var m;return(m=p.data)===null||m===void 0?void 0:m.all.find(y=>y.factor_type==="webauthn"&&y.friendly_name===t&&y.status!=="unverified")}).then(p=>p?this.client.mfa.unenroll({factorId:p?.id}):void 0),{data:null,error:c};const{data:f,error:h}=await this._challenge({factorId:l.id,friendlyName:l.friendly_name,webauthn:{rpId:n,rpOrigins:r},signal:a},{create:s});return f?this._verify({factorId:l.id,challengeId:f.challengeId,webauthn:{rpId:n,rpOrigins:r,type:f.webauthn.type,credential_response:f.webauthn.credential_response}}):{data:null,error:h}}catch(l){return Ae(l)?{data:null,error:l}:{data:null,error:new ds("Unexpected error in register",l)}}}}UU();const i4={url:nU,storageKey:rU,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:aU,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function ZE(e,t,n){return await n()}const ko={};class Uu{get jwks(){var t,n;return(n=(t=ko[this.storageKey])===null||t===void 0?void 0:t.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(t){ko[this.storageKey]=Object.assign(Object.assign({},ko[this.storageKey]),{jwks:t})}get jwks_cached_at(){var t,n;return(n=(t=ko[this.storageKey])===null||t===void 0?void 0:t.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(t){ko[this.storageKey]=Object.assign(Object.assign({},ko[this.storageKey]),{cachedAt:t})}constructor(t){var n,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Uu.nextInstanceID,Uu.nextInstanceID+=1,this.instanceID>0&&Zn()&&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 a=Object.assign(Object.assign({},i4),t);if(this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.persistSession=a.persistSession,this.storageKey=a.storageKey,this.autoRefreshToken=a.autoRefreshToken,this.admin=new LU({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=xk(a.fetch),this.lock=a.lock||ZE,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:Zn()&&(!((n=globalThis?.navigator)===null||n===void 0)&&n.locks)?this.lock=zU:this.lock=ZE,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new a4(this)},this.persistSession?(a.storage?this.storage=a.storage:bk()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=KE(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=KE(this.memoryStorage)),Zn()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(s){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",s)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async s=>{this._debug("received broadcast notification from other tab or client",s),await this._notifyAllSubscribers(s.data.event,s.data.session,!1)})}this.initialize()}_debug(...t){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${gk}) ${new Date().toISOString()}`,...t),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var t;try{const n=yU(window.location.href);let r="none";if(this._isImplicitGrantCallback(n)?r="implicit":await this._isPKCECallback(n)&&(r="pkce"),Zn()&&this.detectSessionInUrl&&r!=="none"){const{data:a,error:s}=await this._getSessionFromURL(n,r);if(s){if(this._debug("#_initialize()","error detecting session from URL",s),cU(s)){const f=(t=s.details)===null||t===void 0?void 0:t.code;if(f==="identity_already_exists"||f==="identity_not_found"||f==="single_identity_not_deletable")return{error:s}}return await this._removeSession(),{error:s}}const{session:l,redirectType:c}=a;return this._debug("#_initialize()","detected session in URL",l,"redirect type",c),await this._saveSession(l),setTimeout(async()=>{c==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",l):await this._notifyAllSubscribers("SIGNED_IN",l)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return Ae(n)?{error:n}:{error:new ds("Unexpected error during initialization",n)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(t){var n,r,a;try{const s=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(n=t?.options)===null||n===void 0?void 0:n.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(a=t?.options)===null||a===void 0?void 0:a.captchaToken}},xform:$r}),{data:l,error:c}=s;if(c||!l)return{data:{user:null,session:null},error:c};const f=l.session,h=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:h,session:f},error:null}}catch(s){if(Ae(s))return{data:{user:null,session:null},error:s};throw s}}async signUp(t){var n,r,a;try{let s;if("email"in t){const{email:p,password:m,options:y}=t;let v=null,w=null;this.flowType==="pkce"&&([v,w]=await jo(this.storage,this.storageKey)),s=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:y?.emailRedirectTo,body:{email:p,password:m,data:(n=y?.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:y?.captchaToken},code_challenge:v,code_challenge_method:w},xform:$r})}else if("phone"in t){const{phone:p,password:m,options:y}=t;s=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:m,data:(r=y?.data)!==null&&r!==void 0?r:{},channel:(a=y?.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:y?.captchaToken}},xform:$r})}else throw new Gf("You must provide either an email or phone number and a password");const{data:l,error:c}=s;if(c||!l)return{data:{user:null,session:null},error:c};const f=l.session,h=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:h,session:f},error:null}}catch(s){if(Ae(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithPassword(t){try{let n;if("email"in t){const{email:s,password:l,options:c}=t;n=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:s,password:l,gotrue_meta_security:{captcha_token:c?.captchaToken}},xform:VE})}else if("phone"in t){const{phone:s,password:l,options:c}=t;n=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:s,password:l,gotrue_meta_security:{captcha_token:c?.captchaToken}},xform:VE})}else throw new Gf("You must provide either an email or phone number and a password");const{data:r,error:a}=n;return a?{data:{user:null,session:null},error:a}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new Ao}:(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:a})}catch(n){if(Ae(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOAuth(t){var n,r,a,s;return await this._handleProviderSignIn(t.provider,{redirectTo:(n=t.options)===null||n===void 0?void 0:n.redirectTo,scopes:(r=t.options)===null||r===void 0?void 0:r.scopes,queryParams:(a=t.options)===null||a===void 0?void 0:a.queryParams,skipBrowserRedirect:(s=t.options)===null||s===void 0?void 0:s.skipBrowserRedirect})}async exchangeCodeForSession(t){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(t))}async signInWithWeb3(t){const{chain:n}=t;switch(n){case"ethereum":return await this.signInWithEthereum(t);case"solana":return await this.signInWithSolana(t);default:throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}}async signInWithEthereum(t){var n,r,a,s,l,c,f,h,p,m,y;let v,w;if("message"in t)v=t.message,w=t.signature;else{const{chain:E,wallet:S,statement:A,options:j}=t;let T;if(Zn())if(typeof S=="object")T=S;else{const J=window;if("ethereum"in J&&typeof J.ethereum=="object"&&"request"in J.ethereum&&typeof J.ethereum.request=="function")T=J.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof S!="object"||!j?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");T=S}const N=new URL((n=j?.url)!==null&&n!==void 0?n:window.location.href),k=await T.request({method:"eth_requestAccounts"}).then(J=>J).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!k||k.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const P=_k(k[0]);let $=(r=j?.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!$){const J=await T.request({method:"eth_chainId"});$=BU(J)}const W={domain:N.host,address:P,statement:A,uri:N.href,version:"1",chainId:$,nonce:(a=j?.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(s=j?.signInWithEthereum)===null||s===void 0?void 0:s.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(c=j?.signInWithEthereum)===null||c===void 0?void 0:c.expirationTime,notBefore:(f=j?.signInWithEthereum)===null||f===void 0?void 0:f.notBefore,requestId:(h=j?.signInWithEthereum)===null||h===void 0?void 0:h.requestId,resources:(p=j?.signInWithEthereum)===null||p===void 0?void 0:p.resources};v=HU(W),w=await T.request({method:"personal_sign",params:[qU(v),P]})}try{const{data:E,error:S}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:v,signature:w},!((m=t.options)===null||m===void 0)&&m.captchaToken?{gotrue_meta_security:{captcha_token:(y=t.options)===null||y===void 0?void 0:y.captchaToken}}:null),xform:$r});if(S)throw S;return!E||!E.session||!E.user?{data:{user:null,session:null},error:new Ao}:(E.session&&(await this._saveSession(E.session),await this._notifyAllSubscribers("SIGNED_IN",E.session)),{data:Object.assign({},E),error:S})}catch(E){if(Ae(E))return{data:{user:null,session:null},error:E};throw E}}async signInWithSolana(t){var n,r,a,s,l,c,f,h,p,m,y,v;let w,E;if("message"in t)w=t.message,E=t.signature;else{const{chain:S,wallet:A,statement:j,options:T}=t;let N;if(Zn())if(typeof A=="object")N=A;else{const P=window;if("solana"in P&&typeof P.solana=="object"&&("signIn"in P.solana&&typeof P.solana.signIn=="function"||"signMessage"in P.solana&&typeof P.solana.signMessage=="function"))N=P.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof A!="object"||!T?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");N=A}const k=new URL((n=T?.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in N&&N.signIn){const P=await N.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},T?.signInWithSolana),{version:"1",domain:k.host,uri:k.href}),j?{statement:j}:null));let $;if(Array.isArray(P)&&P[0]&&typeof P[0]=="object")$=P[0];else if(P&&typeof P=="object"&&"signedMessage"in P&&"signature"in P)$=P;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in $&&"signature"in $&&(typeof $.signedMessage=="string"||$.signedMessage instanceof Uint8Array)&&$.signature instanceof Uint8Array)w=typeof $.signedMessage=="string"?$.signedMessage:new TextDecoder().decode($.signedMessage),E=$.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in N)||typeof N.signMessage!="function"||!("publicKey"in N)||typeof N!="object"||!N.publicKey||!("toBase58"in N.publicKey)||typeof N.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");w=[`${k.host} wants you to sign in with your Solana account:`,N.publicKey.toBase58(),...j?["",j,""]:[""],"Version: 1",`URI: ${k.href}`,`Issued At: ${(a=(r=T?.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((s=T?.signInWithSolana)===null||s===void 0)&&s.notBefore?[`Not Before: ${T.signInWithSolana.notBefore}`]:[],...!((l=T?.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${T.signInWithSolana.expirationTime}`]:[],...!((c=T?.signInWithSolana)===null||c===void 0)&&c.chainId?[`Chain ID: ${T.signInWithSolana.chainId}`]:[],...!((f=T?.signInWithSolana)===null||f===void 0)&&f.nonce?[`Nonce: ${T.signInWithSolana.nonce}`]:[],...!((h=T?.signInWithSolana)===null||h===void 0)&&h.requestId?[`Request ID: ${T.signInWithSolana.requestId}`]:[],...!((m=(p=T?.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||m===void 0)&&m.length?["Resources",...T.signInWithSolana.resources.map($=>`- ${$}`)]:[]].join(` `);const P=await N.signMessage(new TextEncoder().encode(w),"utf8");if(!P||!(P instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");E=P}}try{const{data:S,error:A}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:w,signature:hs(E)},!((y=t.options)===null||y===void 0)&&y.captchaToken?{gotrue_meta_security:{captcha_token:(v=t.options)===null||v===void 0?void 0:v.captchaToken}}:null),xform:$r});if(A)throw A;return!S||!S.session||!S.user?{data:{user:null,session:null},error:new Ao}:(S.session&&(await this._saveSession(S.session),await this._notifyAllSubscribers("SIGNED_IN",S.session)),{data:Object.assign({},S),error:A})}catch(S){if(Ae(S))return{data:{user:null,session:null},error:S};throw S}}async _exchangeCodeForSession(t){const n=await ss(this.storage,`${this.storageKey}-code-verifier`),[r,a]=(n??"").split("/");try{const{data:s,error:l}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:t,code_verifier:r},xform:$r});if(await wi(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!s||!s.session||!s.user?{data:{user:null,session:null,redirectType:null},error:new Ao}:(s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:Object.assign(Object.assign({},s),{redirectType:a??null}),error:l})}catch(s){if(Ae(s))return{data:{user:null,session:null,redirectType:null},error:s};throw s}}async signInWithIdToken(t){try{const{options:n,provider:r,token:a,access_token:s,nonce:l}=t,c=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:a,access_token:s,nonce:l,gotrue_meta_security:{captcha_token:n?.captchaToken}},xform:$r}),{data:f,error:h}=c;return h?{data:{user:null,session:null},error:h}:!f||!f.session||!f.user?{data:{user:null,session:null},error:new Ao}:(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("SIGNED_IN",f.session)),{data:f,error:h})}catch(n){if(Ae(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOtp(t){var n,r,a,s,l;try{if("email"in t){const{email:c,options:f}=t;let h=null,p=null;this.flowType==="pkce"&&([h,p]=await jo(this.storage,this.storageKey));const{error:m}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:c,data:(n=f?.data)!==null&&n!==void 0?n:{},create_user:(r=f?.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:f?.captchaToken},code_challenge:h,code_challenge_method:p},redirectTo:f?.emailRedirectTo});return{data:{user:null,session:null},error:m}}if("phone"in t){const{phone:c,options:f}=t,{data:h,error:p}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:c,data:(a=f?.data)!==null&&a!==void 0?a:{},create_user:(s=f?.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:f?.captchaToken},channel:(l=f?.channel)!==null&&l!==void 0?l:"sms"}});return{data:{user:null,session:null,messageId:h?.message_id},error:p}}throw new Gf("You must provide either an email or phone number.")}catch(c){if(Ae(c))return{data:{user:null,session:null},error:c};throw c}}async verifyOtp(t){var n,r;try{let a,s;"options"in t&&(a=(n=t.options)===null||n===void 0?void 0:n.redirectTo,s=(r=t.options)===null||r===void 0?void 0:r.captchaToken);const{data:l,error:c}=await Re(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},t),{gotrue_meta_security:{captcha_token:s}}),redirectTo:a,xform:$r});if(c)throw c;if(!l)throw new Error("An error occurred on token verification.");const f=l.session,h=l.user;return f?.access_token&&(await this._saveSession(f),await this._notifyAllSubscribers(t.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",f)),{data:{user:h,session:f},error:null}}catch(a){if(Ae(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithSSO(t){var n,r,a;try{let s=null,l=null;return this.flowType==="pkce"&&([s,l]=await jo(this.storage,this.storageKey)),await Re(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in t?{provider_id:t.providerId}:null),"domain"in t?{domain:t.domain}:null),{redirect_to:(r=(n=t.options)===null||n===void 0?void 0:n.redirectTo)!==null&&r!==void 0?r:void 0}),!((a=t?.options)===null||a===void 0)&&a.captchaToken?{gotrue_meta_security:{captcha_token:t.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:s,code_challenge_method:l}),headers:this.headers,xform:DU})}catch(s){if(Ae(s))return{data:null,error:s};throw s}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async t=>{const{data:{session:n},error:r}=t;if(r)throw r;if(!n)throw new _i;const{error:a}=await Re(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return{data:{user:null,session:null},error:a}})}catch(t){if(Ae(t))return{data:{user:null,session:null},error:t};throw t}}async resend(t){try{const n=`${this.url}/resend`;if("email"in t){const{email:r,type:a,options:s}=t,{error:l}=await Re(this.fetch,"POST",n,{headers:this.headers,body:{email:r,type:a,gotrue_meta_security:{captcha_token:s?.captchaToken}},redirectTo:s?.emailRedirectTo});return{data:{user:null,session:null},error:l}}else if("phone"in t){const{phone:r,type:a,options:s}=t,{data:l,error:c}=await Re(this.fetch,"POST",n,{headers:this.headers,body:{phone:r,type:a,gotrue_meta_security:{captcha_token:s?.captchaToken}}});return{data:{user:null,session:null,messageId:l?.message_id},error:c}}throw new Gf("You must provide either an email or phone number and a type")}catch(n){if(Ae(n))return{data:{user:null,session:null},error:n};throw n}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async n=>n))}async _acquireLock(t,n){this._debug("#_acquireLock","begin",t);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),a=(async()=>(await r,await n()))();return this.pendingInLock.push((async()=>{try{await a}catch{}})()),a}return await this.lock(`lock:${this.storageKey}`,t,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 a=[...this.pendingInLock];await Promise.all(a),this.pendingInLock.splice(0,a.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(t){this._debug("#_useSession","begin");try{const n=await this.__loadSession();return await t(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 t=null;const n=await ss(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?t=n:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!t)return{data:{session:null},error:null};const r=t.expires_at?t.expires_at*1e3-Date.now()(!l&&h==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),l=!0,this.suppressGetSessionWarning=!0),Reflect.get(f,h,p))})}return{data:{session:t},error:null}}const{data:a,error:s}=await this._callRefreshToken(t.refresh_token);return s?{data:{session:null},error:s}:{data:{session:a},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(t){return t?await this._getUser(t):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(t){try{return t?await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:t,xform:Oi}):await this._useSession(async n=>{var r,a,s;const{data:l,error:c}=n;if(c)throw c;return!(!((r=l.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new _i}:await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(s=(a=l.session)===null||a===void 0?void 0:a.access_token)!==null&&s!==void 0?s:void 0,xform:Oi})})}catch(n){if(Ae(n))return uU(n)&&(await this._removeSession(),await wi(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:n};throw n}}async updateUser(t,n={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(t,n))}async _updateUser(t,n={}){try{return await this._useSession(async r=>{const{data:a,error:s}=r;if(s)throw s;if(!a.session)throw new _i;const l=a.session;let c=null,f=null;this.flowType==="pkce"&&t.email!=null&&([c,f]=await jo(this.storage,this.storageKey));const{data:h,error:p}=await Re(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n?.emailRedirectTo,body:Object.assign(Object.assign({},t),{code_challenge:c,code_challenge_method:f}),jwt:l.access_token,xform:Oi});if(p)throw p;return l.user=h.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(r){if(Ae(r))return{data:{user:null},error:r};throw r}}async setSession(t){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(t))}async _setSession(t){try{if(!t.access_token||!t.refresh_token)throw new _i;const n=Date.now()/1e3;let r=n,a=!0,s=null;const{payload:l}=Fg(t.access_token);if(l.exp&&(r=l.exp,a=r<=n),a){const{data:c,error:f}=await this._callRefreshToken(t.refresh_token);if(f)return{data:{user:null,session:null},error:f};if(!c)return{data:{user:null,session:null},error:null};s=c}else{const{data:c,error:f}=await this._getUser(t.access_token);if(f)throw f;s={access_token:t.access_token,refresh_token:t.refresh_token,user:c.user,token_type:"bearer",expires_in:r-n,expires_at:r},await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)}return{data:{user:s.user,session:s},error:null}}catch(n){if(Ae(n))return{data:{session:null,user:null},error:n};throw n}}async refreshSession(t){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(t))}async _refreshSession(t){try{return await this._useSession(async n=>{var r;if(!t){const{data:l,error:c}=n;if(c)throw c;t=(r=l.session)!==null&&r!==void 0?r:void 0}if(!t?.refresh_token)throw new _i;const{data:a,error:s}=await this._callRefreshToken(t.refresh_token);return s?{data:{user:null,session:null},error:s}:a?{data:{user:a.user,session:a},error:null}:{data:{user:null,session:null},error:null}})}catch(n){if(Ae(n))return{data:{user:null,session:null},error:n};throw n}}async _getSessionFromURL(t,n){try{if(!Zn())throw new Zf("No browser detected.");if(t.error||t.error_description||t.error_code)throw new Zf(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new LE("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Zf("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!t.code)throw new LE("No code detected.");const{data:j,error:T}=await this._exchangeCodeForSession(t.code);if(T)throw T;const N=new URL(window.location.href);return N.searchParams.delete("code"),window.history.replaceState(window.history.state,"",N.toString()),{data:{session:j.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:a,access_token:s,refresh_token:l,expires_in:c,expires_at:f,token_type:h}=t;if(!s||!c||!l||!h)throw new Zf("No session defined in URL");const p=Math.round(Date.now()/1e3),m=parseInt(c);let y=p+m;f&&(y=parseInt(f));const v=y-p;v*1e3<=Mo&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${v}s, should have been closer to ${m}s`);const w=y-m;p-w>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",w,y,p):p-w<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",w,y,p);const{data:E,error:S}=await this._getUser(s);if(S)throw S;const A={provider_token:r,provider_refresh_token:a,access_token:s,expires_in:m,expires_at:y,refresh_token:l,token_type:h,user:E.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:A,redirectType:t.type},error:null}}catch(r){if(Ae(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantCallback(t){return!!(t.access_token||t.error_description)}async _isPKCECallback(t){const n=await ss(this.storage,`${this.storageKey}-code-verifier`);return!!(t.code&&n)}async signOut(t={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(t))}async _signOut({scope:t}={scope:"global"}){return await this._useSession(async n=>{var r;const{data:a,error:s}=n;if(s)return{error:s};const l=(r=a.session)===null||r===void 0?void 0:r.access_token;if(l){const{error:c}=await this.admin.signOut(l,t);if(c&&!(lU(c)&&(c.status===404||c.status===401||c.status===403)))return{error:c}}return t!=="others"&&(await this._removeSession(),await wi(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(t){const n=vU(),r={id:n,callback:t,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(t){return await this._useSession(async n=>{var r,a;try{const{data:{session:s},error:l}=n;if(l)throw l;await((r=this.stateChangeEmitters.get(t))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",s)),this._debug("INITIAL_SESSION","callback id",t,"session",s)}catch(s){await((a=this.stateChangeEmitters.get(t))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",t,"error",s),console.error(s)}})}async resetPasswordForEmail(t,n={}){let r=null,a=null;this.flowType==="pkce"&&([r,a]=await jo(this.storage,this.storageKey,!0));try{return await Re(this.fetch,"POST",`${this.url}/recover`,{body:{email:t,code_challenge:r,code_challenge_method:a,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(s){if(Ae(s))return{data:null,error:s};throw s}}async getUserIdentities(){var t;try{const{data:n,error:r}=await this.getUser();if(r)throw r;return{data:{identities:(t=n.user.identities)!==null&&t!==void 0?t:[]},error:null}}catch(n){if(Ae(n))return{data:null,error:n};throw n}}async linkIdentity(t){return"token"in t?this.linkIdentityIdToken(t):this.linkIdentityOAuth(t)}async linkIdentityOAuth(t){var n;try{const{data:r,error:a}=await this._useSession(async s=>{var l,c,f,h,p;const{data:m,error:y}=s;if(y)throw y;const v=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,t.provider,{redirectTo:(l=t.options)===null||l===void 0?void 0:l.redirectTo,scopes:(c=t.options)===null||c===void 0?void 0:c.scopes,queryParams:(f=t.options)===null||f===void 0?void 0:f.queryParams,skipBrowserRedirect:!0});return await Re(this.fetch,"GET",v,{headers:this.headers,jwt:(p=(h=m.session)===null||h===void 0?void 0:h.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return Zn()&&!(!((n=t.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(r?.url),{data:{provider:t.provider,url:r?.url},error:null}}catch(r){if(Ae(r))return{data:{provider:t.provider,url:null},error:r};throw r}}async linkIdentityIdToken(t){return await this._useSession(async n=>{var r;try{const{error:a,data:{session:s}}=n;if(a)throw a;const{options:l,provider:c,token:f,access_token:h,nonce:p}=t,m=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=s?.access_token)!==null&&r!==void 0?r:void 0,body:{provider:c,id_token:f,access_token:h,nonce:p,link_identity:!0,gotrue_meta_security:{captcha_token:l?.captchaToken}},xform:$r}),{data:y,error:v}=m;return v?{data:{user:null,session:null},error:v}:!y||!y.session||!y.user?{data:{user:null,session:null},error:new Ao}:(y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("USER_UPDATED",y.session)),{data:y,error:v})}catch(a){if(Ae(a))return{data:{user:null,session:null},error:a};throw a}})}async unlinkIdentity(t){try{return await this._useSession(async n=>{var r,a;const{data:s,error:l}=n;if(l)throw l;return await Re(this.fetch,"DELETE",`${this.url}/user/identities/${t.identity_id}`,{headers:this.headers,jwt:(a=(r=s.session)===null||r===void 0?void 0:r.access_token)!==null&&a!==void 0?a:void 0})})}catch(n){if(Ae(n))return{data:null,error:n};throw n}}async _refreshAccessToken(t){const n=`#_refreshAccessToken(${t.substring(0,5)}...)`;this._debug(n,"begin");try{const r=Date.now();return await wU(async a=>(a>0&&await xU(200*Math.pow(2,a-1)),this._debug(n,"refreshing attempt",a),await Re(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:t},headers:this.headers,xform:$r})),(a,s)=>{const l=200*Math.pow(2,a);return s&&Vg(s)&&Date.now()+l-r{try{await c.callback(t,n)}catch(f){s.push(f)}});if(await Promise.all(l),s.length>0){for(let c=0;cthis._autoRefreshTokenTick(),Mo);this.autoRefreshTicker=t,t&&typeof t=="object"&&typeof t.unref=="function"?t.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(t),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const t=this.autoRefreshTicker;this.autoRefreshTicker=null,t&&clearInterval(t)}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 t=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 a=Math.floor((r.expires_at*1e3-t)/Mo);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${Mo}ms, refresh threshold is ${Uy} ticks`),a<=Uy&&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(t){if(t.isAcquireTimeout||t instanceof wk)this._debug("auto refresh token tick lock not available");else throw t}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Zn()||!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(t){console.error("_handleVisibilityChange",t)}}async _onVisibilityChanged(t){const n=`#_onVisibilityChanged(${t})`;this._debug(n,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),t||(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(t,n,r){const a=[`provider=${encodeURIComponent(n)}`];if(r?.redirectTo&&a.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r?.scopes&&a.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[s,l]=await jo(this.storage,this.storageKey),c=new URLSearchParams({code_challenge:`${encodeURIComponent(s)}`,code_challenge_method:`${encodeURIComponent(l)}`});a.push(c.toString())}if(r?.queryParams){const s=new URLSearchParams(r.queryParams);a.push(s.toString())}return r?.skipBrowserRedirect&&a.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${t}?${a.join("&")}`}async _unenroll(t){try{return await this._useSession(async n=>{var r;const{data:a,error:s}=n;return s?{data:null,error:s}:await Re(this.fetch,"DELETE",`${this.url}/factors/${t.factorId}`,{headers:this.headers,jwt:(r=a?.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if(Ae(n))return{data:null,error:n};throw n}}async _enroll(t){try{return await this._useSession(async n=>{var r,a;const{data:s,error:l}=n;if(l)return{data:null,error:l};const c=Object.assign({friendly_name:t.friendlyName,factor_type:t.factorType},t.factorType==="phone"?{phone:t.phone}:t.factorType==="totp"?{issuer:t.issuer}:{}),{data:f,error:h}=await Re(this.fetch,"POST",`${this.url}/factors`,{body:c,headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token});return h?{data:null,error:h}:(t.factorType==="totp"&&f.type==="totp"&&(!((a=f?.totp)===null||a===void 0)&&a.qr_code)&&(f.totp.qr_code=`data:image/svg+xml;utf-8,${f.totp.qr_code}`),{data:f,error:null})})}catch(n){if(Ae(n))return{data:null,error:n};throw n}}async _verify(t){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:a,error:s}=n;if(s)return{data:null,error:s};const l=Object.assign({challenge_id:t.challengeId},"webauthn"in t?{webauthn:Object.assign(Object.assign({},t.webauthn),{credential_response:t.webauthn.type==="create"?YU(t.webauthn.credential_response):XU(t.webauthn.credential_response)})}:{code:t.code}),{data:c,error:f}=await Re(this.fetch,"POST",`${this.url}/factors/${t.factorId}/verify`,{body:l,headers:this.headers,jwt:(r=a?.session)===null||r===void 0?void 0:r.access_token});return f?{data:null,error:f}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+c.expires_in},c)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",c),{data:c,error:f})})}catch(n){if(Ae(n))return{data:null,error:n};throw n}})}async _challenge(t){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:a,error:s}=n;if(s)return{data:null,error:s};const l=await Re(this.fetch,"POST",`${this.url}/factors/${t.factorId}/challenge`,{body:t,headers:this.headers,jwt:(r=a?.session)===null||r===void 0?void 0:r.access_token});if(l.error)return l;const{data:c}=l;if(c.type!=="webauthn")return{data:c,error:null};switch(c.webauthn.type){case"create":return{data:Object.assign(Object.assign({},c),{webauthn:Object.assign(Object.assign({},c.webauthn),{credential_options:Object.assign(Object.assign({},c.webauthn.credential_options),{publicKey:ZU(c.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},c),{webauthn:Object.assign(Object.assign({},c.webauthn),{credential_options:Object.assign(Object.assign({},c.webauthn.credential_options),{publicKey:WU(c.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(Ae(n))return{data:null,error:n};throw n}})}async _challengeAndVerify(t){const{data:n,error:r}=await this._challenge({factorId:t.factorId});return r?{data:null,error:r}:await this._verify({factorId:t.factorId,challengeId:n.id,code:t.code})}async _listFactors(){var t;const{data:{user:n},error:r}=await this.getUser();if(r)return{data:null,error:r};const a={all:[],phone:[],totp:[],webauthn:[]};for(const s of(t=n?.factors)!==null&&t!==void 0?t:[])a.all.push(s),s.status==="verified"&&a[s.factor_type].push(s);return{data:a,error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async t=>{var n,r;const{data:{session:a},error:s}=t;if(s)return{data:null,error:s};if(!a)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=Fg(a.access_token);let c=null;l.aal&&(c=l.aal);let f=c;((r=(n=a.user.factors)===null||n===void 0?void 0:n.filter(m=>m.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(f="aal2");const p=l.amr||[];return{data:{currentLevel:c,nextLevel:f,currentAuthenticationMethods:p},error:null}}))}async fetchJwk(t,n={keys:[]}){let r=n.keys.find(c=>c.kid===t);if(r)return r;const a=Date.now();if(r=this.jwks.keys.find(c=>c.kid===t),r&&this.jwks_cached_at+sU>a)return r;const{data:s,error:l}=await Re(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(l)throw l;return!s.keys||s.keys.length===0||(this.jwks=s,this.jwks_cached_at=a,r=s.keys.find(c=>c.kid===t),!r)?null:r}async getClaims(t,n={}){try{let r=t;if(!r){const{data:v,error:w}=await this.getSession();if(w||!v.session)return{data:null,error:w};r=v.session.access_token}const{header:a,payload:s,signature:l,raw:{header:c,payload:f}}=Fg(r);n?.allowExpired||TU(s.exp);const h=!a.alg||a.alg.startsWith("HS")||!a.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(a.kid,n?.keys?{keys:n.keys}:n?.jwks);if(!h){const{error:v}=await this.getUser(r);if(v)throw v;return{data:{claims:s,header:a,signature:l},error:null}}const p=CU(a.alg),m=await crypto.subtle.importKey("jwk",h,p,!0,["verify"]);if(!await crypto.subtle.verify(p,m,l,mU(`${c}.${f}`)))throw new Hy("Invalid JWT signature");return{data:{claims:s,header:a,signature:l},error:null}}catch(r){if(Ae(r))return{data:null,error:r};throw r}}}Uu.nextInstanceID=0;const s4=Uu;class o4 extends s4{constructor(t){super(t)}}class l4{constructor(t,n,r){var a,s,l;this.supabaseUrl=t,this.supabaseKey=n;const c=tU(t);if(!n)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",c),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",c),this.storageUrl=new URL("storage/v1",c),this.functionsUrl=new URL("functions/v1",c);const f=`sb-${c.hostname.split(".")[0]}-auth-token`,h={db:G3,realtime:W3,auth:Object.assign(Object.assign({},Z3),{storageKey:f}),global:K3},p=eU(r??{},h);this.storageKey=(a=p.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(s=p.global.headers)!==null&&s!==void 0?s:{},p.accessToken?(this.accessToken=p.accessToken,this.auth=new Proxy({},{get:(m,y)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(y)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=p.auth)!==null&&l!==void 0?l:{},this.headers,p.global.fetch),this.fetch=J3(n,this._getAccessToken.bind(this),p.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},p.realtime)),this.rest=new n3(new URL("rest/v1",c).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new H3(this.storageUrl.href,this.headers,this.fetch,r?.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new Kz(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,n={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,n,r)}channel(t,n={config:{}}){return this.realtime.channel(t,n)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t,n;if(this.accessToken)return await this.accessToken();const{data:r}=await this.auth.getSession();return(n=(t=r.session)===null||t===void 0?void 0:t.access_token)!==null&&n!==void 0?n:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:n,detectSessionInUrl:r,storage:a,userStorage:s,storageKey:l,flowType:c,lock:f,debug:h},p,m){const y={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new o4({url:this.authUrl.href,headers:Object.assign(Object.assign({},y),p),storageKey:l,autoRefreshToken:t,persistSession:n,detectSessionInUrl:r,storage:a,userStorage:s,flowType:c,lock:f,debug:h,fetch:m,hasCustomAuthorizationHeader:Object.keys(this.headers).some(v=>v.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new b3(this.realtimeUrl.href,Object.assign(Object.assign({},t),{params:Object.assign({apikey:this.supabaseKey},t?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((n,r)=>{this._handleTokenChanged(n,"CLIENT",r?.access_token)})}_handleTokenChanged(t,n,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),n=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const Ek=(e,t,n)=>new l4(e,t,n);function u4(){if(typeof window<"u"||typeof process>"u")return!1;const e=process.version;if(e==null)return!1;const t=e.match(/^v(\d+)\./);return t?parseInt(t[1],10)<=18:!1}u4()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const c4={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_NAME:"CareTide",VITE_I18N_DEFAULT_LOCALE:"zh-TW",VITE_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNwem90eWxzaHd4eGJoa2pxc2RyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAyMjkwNzcsImV4cCI6MjA3NTgwNTA3N30.ncrxdo5YiNBU7LACuVRgHedz-rIR-t3XgZt90LzTRss",VITE_SUPABASE_URL:"https://cpzotylshwxxbhkjqsdr.supabase.co",VITE_VERCEL_BRANCH_URL:"care-log-git-main-jimmyshsos-projects.vercel.app",VITE_VERCEL_DEPLOYMENT_ID:"dpl_8Zb2V1cafDST4Mx925fxwvsAeJ36",VITE_VERCEL_ENV:"production",VITE_VERCEL_GIT_COMMIT_AUTHOR_LOGIN:"jim00e-Shao",VITE_VERCEL_GIT_COMMIT_AUTHOR_NAME:"jim00e-Shao",VITE_VERCEL_GIT_COMMIT_MESSAGE:"feat(db): add age snapshot health monitoring views",VITE_VERCEL_GIT_COMMIT_REF:"main",VITE_VERCEL_GIT_COMMIT_SHA:"d2469ced3169ef676295f1b5000c0e989c18eae3",VITE_VERCEL_GIT_PREVIOUS_SHA:"",VITE_VERCEL_GIT_PROVIDER:"github",VITE_VERCEL_GIT_PULL_REQUEST_ID:"",VITE_VERCEL_GIT_REPO_ID:"1074070480",VITE_VERCEL_GIT_REPO_OWNER:"jim00e-Shao",VITE_VERCEL_GIT_REPO_SLUG:"caretide-carelog",VITE_VERCEL_PROJECT_ID:"prj_Xr8rR5pGJ8AJhsmc2OzQ66uEIjbL",VITE_VERCEL_PROJECT_PRODUCTION_URL:"www.caretide.tw",VITE_VERCEL_TARGET_ENV:"production",VITE_VERCEL_URL:"care-cecaivn9v-jimmyshsos-projects.vercel.app"};function Io(e,t=""){return(c4[e]??t).toString().trim()}const f4=Io("VITE_SUPABASE_URL"),d4=Io("VITE_SUPABASE_ANON_KEY"),Ok={SUPABASE_URL:f4,SUPABASE_ANON_KEY:d4,APP_URL:Io("VITE_PUBLIC_APP_URL"),ROUTER_MODE:Io("VITE_PUBLIC_ROUTER_MODE","browser"),APP_NAME:Io("VITE_APP_NAME","CareTide"),I18N_DEFAULT_LOCALE:Io("VITE_I18N_DEFAULT_LOCALE","zh-TW")};let kd=Ok.SUPABASE_URL,Nd=Ok.SUPABASE_ANON_KEY;/^https?:\/\//.test(kd)||(console.warn("[ENV] VITE_SUPABASE_URL invalid, using fallback value"),kd="https://cpzotylshwxxbhkjqsdr.supabase.co");Nd||(console.warn("[ENV] VITE_SUPABASE_ANON_KEY missing, using fallback value (dev only)"),Nd="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNwem90eWxzaHd4eGJoa2pxc2RyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAyMjkwNzcsImV4cCI6MjA3NTgwNTA3N30.ncrxdo5YiNBU7LACuVRgHedz-rIR-t3XgZt90LzTRss");const $e=globalThis.__supabase__??Ek(kd,Nd,{auth:{persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!0}}),h4=!!(kd&&Nd);/** * react-router v7.9.4 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */var WE="popstate";function p4(e={}){function t(r,a){let{pathname:s,search:l,hash:c}=r.location;return Vy("",{pathname:s,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:Bu(a)}return g4(t,n,null,e)}function bt(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Hr(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function m4(){return Math.random().toString(36).substring(2,10)}function YE(e,t){return{usr:e.state,key:e.key,idx:t}}function Vy(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?sl(t):t,state:n,key:t&&t.key||r||m4()}}function Bu({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function sl(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function g4(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:s=!1}=r,l=a.history,c="POP",f=null,h=p();h==null&&(h=0,l.replaceState({...l.state,idx:h},""));function p(){return(l.state||{idx:null}).idx}function m(){c="POP";let S=p(),A=S==null?null:S-h;h=S,f&&f({action:c,location:E.location,delta:A})}function y(S,A){c="PUSH";let j=Vy(E.location,S,A);h=p()+1;let T=YE(j,h),N=E.createHref(j);try{l.pushState(T,"",N)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;a.location.assign(N)}s&&f&&f({action:c,location:E.location,delta:1})}function v(S,A){c="REPLACE";let j=Vy(E.location,S,A);h=p();let T=YE(j,h),N=E.createHref(j);l.replaceState(T,"",N),s&&f&&f({action:c,location:E.location,delta:0})}function w(S){return v4(S)}let E={get action(){return c},get location(){return e(a,l)},listen(S){if(f)throw new Error("A history only accepts one active listener");return a.addEventListener(WE,m),f=S,()=>{a.removeEventListener(WE,m),f=null}},createHref(S){return t(a,S)},createURL:w,encodeLocation(S){let A=w(S);return{pathname:A.pathname,search:A.search,hash:A.hash}},push:y,replace:v,go(S){return l.go(S)}};return E}function v4(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),bt(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Bu(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Ak(e,t,n="/"){return y4(e,t,n,!1)}function y4(e,t,n,r){let a=typeof t=="string"?sl(t):t,s=Ia(a.pathname||"/",n);if(s==null)return null;let l=jk(e);b4(l);let c=null;for(let f=0;c==null&&f{let p={relativePath:h===void 0?l.path||"":h,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(r)&&f)return;bt(p.relativePath.startsWith(r),`Absolute route path "${p.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(r.length)}let m=Ma([r,p.relativePath]),y=n.concat(p);l.children&&l.children.length>0&&(bt(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),jk(l.children,t,y,m,f)),!(l.path==null&&!l.index)&&t.push({path:m,score:A4(m,l.index),routesMeta:y})};return e.forEach((l,c)=>{if(l.path===""||!l.path?.includes("?"))s(l,c);else for(let f of Tk(l.path))s(l,c,!0,f)}),t}function Tk(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return a?[s,""]:[s];let l=Tk(r.join("/")),c=[];return c.push(...l.map(f=>f===""?s:[s,f].join("/"))),a&&c.push(...l),c.map(f=>e.startsWith("/")&&f===""?"/":f)}function b4(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:j4(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var x4=/^:[\w-]+$/,w4=3,_4=2,S4=1,E4=10,O4=-2,XE=e=>e==="*";function A4(e,t){let n=e.split("/"),r=n.length;return n.some(XE)&&(r+=O4),t&&(r+=_4),n.filter(a=>!XE(a)).reduce((a,s)=>a+(x4.test(s)?w4:s===""?S4:E4),r)}function j4(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function T4(e,t,n=!1){let{routesMeta:r}=e,a={},s="/",l=[];for(let c=0;c{if(p==="*"){let w=c[y]||"";l=s.slice(0,s.length-w.length).replace(/(.)\/+$/,"$1")}const v=c[y];return m&&!v?h[p]=void 0:h[p]=(v||"").replace(/%2F/g,"/"),h},{}),pathname:s,pathnameBase:l,pattern:e}}function C4(e,t=!1,n=!0){Hr(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,c,f)=>(r.push({paramName:c,isOptional:f!=null}),f?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function k4(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Hr(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ia(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function N4(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?sl(e):e;return{pathname:n?n.startsWith("/")?n:P4(n,t):t,search:M4(r),hash:$4(a)}}function P4(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Zg(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function R4(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Qb(e){let t=R4(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function e0(e,t,n,r=!1){let a;typeof e=="string"?a=sl(e):(a={...e},bt(!a.pathname||!a.pathname.includes("?"),Zg("?","pathname","search",a)),bt(!a.pathname||!a.pathname.includes("#"),Zg("#","pathname","hash",a)),bt(!a.search||!a.search.includes("#"),Zg("#","search","hash",a)));let s=e===""||a.pathname==="",l=s?"/":a.pathname,c;if(l==null)c=n;else{let m=t.length-1;if(!r&&l.startsWith("..")){let y=l.split("/");for(;y[0]==="..";)y.shift(),m-=1;a.pathname=y.join("/")}c=m>=0?t[m]:"/"}let f=N4(a,c),h=l&&l!=="/"&&l.endsWith("/"),p=(s||l===".")&&n.endsWith("/");return!f.pathname.endsWith("/")&&(h||p)&&(f.pathname+="/"),f}var Ma=e=>e.join("/").replace(/\/\/+/g,"/"),D4=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),M4=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,$4=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function L4(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var Ck=["POST","PUT","PATCH","DELETE"];new Set(Ck);var I4=["GET",...Ck];new Set(I4);var ol=_.createContext(null);ol.displayName="DataRouter";var Oh=_.createContext(null);Oh.displayName="DataRouterState";_.createContext(!1);var kk=_.createContext({isTransitioning:!1});kk.displayName="ViewTransition";var z4=_.createContext(new Map);z4.displayName="Fetchers";var U4=_.createContext(null);U4.displayName="Await";var Fr=_.createContext(null);Fr.displayName="Navigation";var nc=_.createContext(null);nc.displayName="Location";var Tr=_.createContext({outlet:null,matches:[],isDataRoute:!1});Tr.displayName="Route";var t0=_.createContext(null);t0.displayName="RouteError";function B4(e,{relative:t}={}){bt(ll(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=_.useContext(Fr),{hash:a,pathname:s,search:l}=rc(e,{relative:t}),c=s;return n!=="/"&&(c=s==="/"?n:Ma([n,s])),r.createHref({pathname:c,search:l,hash:a})}function ll(){return _.useContext(nc)!=null}function Va(){return bt(ll(),"useLocation() may be used only in the context of a component."),_.useContext(nc).location}var Nk="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Pk(e){_.useContext(Fr).static||_.useLayoutEffect(e)}function Qe(){let{isDataRoute:e}=_.useContext(Tr);return e?n6():q4()}function q4(){bt(ll(),"useNavigate() may be used only in the context of a component.");let e=_.useContext(ol),{basename:t,navigator:n}=_.useContext(Fr),{matches:r}=_.useContext(Tr),{pathname:a}=Va(),s=JSON.stringify(Qb(r)),l=_.useRef(!1);return Pk(()=>{l.current=!0}),_.useCallback((f,h={})=>{if(Hr(l.current,Nk),!l.current)return;if(typeof f=="number"){n.go(f);return}let p=e0(f,JSON.parse(s),a,h.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:Ma([t,p.pathname])),(h.replace?n.replace:n.push)(p,h.state,h)},[t,n,s,a,e])}var H4=_.createContext(null);function V4(e){let t=_.useContext(Tr).outlet;return _.useMemo(()=>t&&_.createElement(H4.Provider,{value:e},t),[t,e])}function Rk(){let{matches:e}=_.useContext(Tr),t=e[e.length-1];return t?t.params:{}}function rc(e,{relative:t}={}){let{matches:n}=_.useContext(Tr),{pathname:r}=Va(),a=JSON.stringify(Qb(n));return _.useMemo(()=>e0(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function F4(e,t){return Dk(e,t)}function Dk(e,t,n,r,a){bt(ll(),"useRoutes() may be used only in the context of a component.");let{navigator:s}=_.useContext(Fr),{matches:l}=_.useContext(Tr),c=l[l.length-1],f=c?c.params:{},h=c?c.pathname:"/",p=c?c.pathnameBase:"/",m=c&&c.route;{let j=m&&m.path||"";Mk(h,!m||j.endsWith("*")||j.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${h}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. Please change the parent to .`)}let y=Va(),v;if(t){let j=typeof t=="string"?sl(t):t;bt(p==="/"||j.pathname?.startsWith(p),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${j.pathname}" was given in the \`location\` prop.`),v=j}else v=y;let w=v.pathname||"/",E=w;if(p!=="/"){let j=p.replace(/^\//,"").split("/");E="/"+w.replace(/^\//,"").split("/").slice(j.length).join("/")}let S=Ak(e,{pathname:E});Hr(m||S!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Hr(S==null||S[S.length-1].route.element!==void 0||S[S.length-1].route.Component!==void 0||S[S.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let A=Y4(S&&S.map(j=>Object.assign({},j,{params:Object.assign({},f,j.params),pathname:Ma([p,s.encodeLocation?s.encodeLocation(j.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?p:Ma([p,s.encodeLocation?s.encodeLocation(j.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:j.pathnameBase])})),l,n,r,a);return t&&A?_.createElement(nc.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...v},navigationType:"POP"}},A):A}function K4(){let e=t6(),t=L4(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=_.createElement(_.Fragment,null,_.createElement("p",null,"💿 Hey developer 👋"),_.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",_.createElement("code",{style:s},"ErrorBoundary")," or"," ",_.createElement("code",{style:s},"errorElement")," prop on your route.")),_.createElement(_.Fragment,null,_.createElement("h2",null,"Unexpected Application Error!"),_.createElement("h3",{style:{fontStyle:"italic"}},t),n?_.createElement("pre",{style:a},n):null,l)}var G4=_.createElement(K4,null),Z4=class extends _.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?_.createElement(Tr.Provider,{value:this.props.routeContext},_.createElement(t0.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function W4({routeContext:e,match:t,children:n}){let r=_.useContext(ol);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),_.createElement(Tr.Provider,{value:e},n)}function Y4(e,t=[],n=null,r=null,a=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let s=e,l=n?.errors;if(l!=null){let h=s.findIndex(p=>p.route.id&&l?.[p.route.id]!==void 0);bt(h>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),s=s.slice(0,Math.min(s.length,h+1))}let c=!1,f=-1;if(n)for(let h=0;h=0?s=s.slice(0,f+1):s=[s[0]];break}}}return s.reduceRight((h,p,m)=>{let y,v=!1,w=null,E=null;n&&(y=l&&p.route.id?l[p.route.id]:void 0,w=p.route.errorElement||G4,c&&(f<0&&m===0?(Mk("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),v=!0,E=null):f===m&&(v=!0,E=p.route.hydrateFallbackElement||null)));let S=t.concat(s.slice(0,m+1)),A=()=>{let j;return y?j=w:v?j=E:p.route.Component?j=_.createElement(p.route.Component,null):p.route.element?j=p.route.element:j=h,_.createElement(W4,{match:p,routeContext:{outlet:h,matches:S,isDataRoute:n!=null},children:j})};return n&&(p.route.ErrorBoundary||p.route.errorElement||m===0)?_.createElement(Z4,{location:n.location,revalidation:n.revalidation,component:w,error:y,children:A(),routeContext:{outlet:null,matches:S,isDataRoute:!0},unstable_onError:r}):A()},null)}function n0(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function X4(e){let t=_.useContext(ol);return bt(t,n0(e)),t}function J4(e){let t=_.useContext(Oh);return bt(t,n0(e)),t}function Q4(e){let t=_.useContext(Tr);return bt(t,n0(e)),t}function r0(e){let t=Q4(e),n=t.matches[t.matches.length-1];return bt(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function e6(){return r0("useRouteId")}function t6(){let e=_.useContext(t0),t=J4("useRouteError"),n=r0("useRouteError");return e!==void 0?e:t.errors?.[n]}function n6(){let{router:e}=X4("useNavigate"),t=r0("useNavigate"),n=_.useRef(!1);return Pk(()=>{n.current=!0}),_.useCallback(async(a,s={})=>{Hr(n.current,Nk),n.current&&(typeof a=="number"?e.navigate(a):await e.navigate(a,{fromRouteId:t,...s}))},[e,t])}var JE={};function Mk(e,t,n){!t&&!JE[e]&&(JE[e]=!0,Hr(!1,n))}_.memo(r6);function r6({routes:e,future:t,state:n,unstable_onError:r}){return Dk(e,void 0,n,r,t)}function a6({to:e,replace:t,state:n,relative:r}){bt(ll()," may be used only in the context of a component.");let{static:a}=_.useContext(Fr);Hr(!a," must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.");let{matches:s}=_.useContext(Tr),{pathname:l}=Va(),c=Qe(),f=e0(e,Qb(s),l,r==="path"),h=JSON.stringify(f);return _.useEffect(()=>{c(JSON.parse(h),{replace:t,state:n,relative:r})},[c,h,r,t,n]),null}function a0(e){return V4(e.context)}function Ie(e){bt(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function i6({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:s=!1}){bt(!ll(),"You cannot render a inside another . You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=_.useMemo(()=>({basename:l,navigator:a,static:s,future:{}}),[l,a,s]);typeof n=="string"&&(n=sl(n));let{pathname:f="/",search:h="",hash:p="",state:m=null,key:y="default"}=n,v=_.useMemo(()=>{let w=Ia(f,l);return w==null?null:{location:{pathname:w,search:h,hash:p,state:m,key:y},navigationType:r}},[l,f,h,p,m,y,r]);return Hr(v!=null,` is not able to match the URL "${f}${h}${p}" because it does not start with the basename, so the won't render anything.`),v==null?null:_.createElement(Fr.Provider,{value:c},_.createElement(nc.Provider,{children:t,value:v}))}function s6({children:e,location:t}){return F4(Fy(e),t)}function Fy(e,t=[]){let n=[];return _.Children.forEach(e,(r,a)=>{if(!_.isValidElement(r))return;let s=[...t,a];if(r.type===_.Fragment){n.push.apply(n,Fy(r.props.children,s));return}bt(r.type===Ie,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),bt(!r.props.index||!r.props.children,"An index route cannot have child routes.");let l={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Fy(r.props.children,s)),n.push(l)}),n}var vd="get",yd="application/x-www-form-urlencoded";function Ah(e){return e!=null&&typeof e.tagName=="string"}function o6(e){return Ah(e)&&e.tagName.toLowerCase()==="button"}function l6(e){return Ah(e)&&e.tagName.toLowerCase()==="form"}function u6(e){return Ah(e)&&e.tagName.toLowerCase()==="input"}function c6(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function f6(e,t){return e.button===0&&(!t||t==="_self")&&!c6(e)}var Wf=null;function d6(){if(Wf===null)try{new FormData(document.createElement("form"),0),Wf=!1}catch{Wf=!0}return Wf}var h6=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Wg(e){return e!=null&&!h6.has(e)?(Hr(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${yd}"`),null):e}function p6(e,t){let n,r,a,s,l;if(l6(e)){let c=e.getAttribute("action");r=c?Ia(c,t):null,n=e.getAttribute("method")||vd,a=Wg(e.getAttribute("enctype"))||yd,s=new FormData(e)}else if(o6(e)||u6(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a