frappe-react-sdk 1.3.2 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3548,7 +3548,7 @@ class xa {
3548
3548
  Ae(this, "site_name");
3549
3549
  Ae(this, "socket");
3550
3550
  var i, o;
3551
- this.socket_port = r != null ? r : "9000", this.host = (i = window.location) == null ? void 0 : i.hostname, this.port = (o = window.location) != null && o.port ? `:${this.socket_port}` : "", this.protocol = this.port ? "http" : "https", this.url = e || `${this.protocol}://${this.host}${this.port}`, this.site_name = t != null ? t : frappe == null ? void 0 : frappe.boot.sitename, this.socket = Bt(`${this.url}/${this.site_name}`, {
3551
+ this.socket_port = r != null ? r : "9000", this.host = (i = window.location) == null ? void 0 : i.hostname, this.port = (o = window.location) != null && o.port ? `:${this.socket_port}` : "", this.protocol = this.port ? "http" : "https", this.url = e || `${this.protocol}://${this.host}${this.port}`, this.site_name = t, this.socket = Bt(`${this.url}/${this.site_name}`, {
3552
3552
  withCredentials: !0,
3553
3553
  secure: this.protocol === "https",
3554
3554
  extraHeaders: s && s.useToken === !0 ? {
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var Vr;function Mi(){return Vr||(Vr=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=Ne.default,e=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(F){{for(var g=arguments.length,M=new Array(g>1?g-1:0),V=1;V<g;V++)M[V-1]=arguments[V];r("error",F,M)}}function r(F,g,M){{var V=e.ReactDebugCurrentFrame,L=V.getStackAddendum();L!==""&&(g+="%s",M=M.concat([L]));var S=M.map(function(q){return String(q)});S.unshift("Warning: "+g),Function.prototype.apply.call(console[F],console,S)}}function s(F,g){return F===g&&(F!==0||1/F===1/g)||F!==F&&g!==g}var i=typeof Object.is=="function"?Object.is:s,o=n.useState,c=n.useEffect,l=n.useLayoutEffect,a=n.useDebugValue,h=!1,f=!1;function v(F,g,M){h||n.startTransition!==void 0&&(h=!0,t("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var V=g();if(!f){var L=g();i(V,L)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}var S=o({inst:{value:V,getSnapshot:g}}),q=S[0].inst,P=S[1];return l(function(){q.value=V,q.getSnapshot=g,y(q)&&P({inst:q})},[F,V,g]),c(function(){y(q)&&P({inst:q});var $=function(){y(q)&&P({inst:q})};return F($)},[F]),a(V),V}function y(F){var g=F.getSnapshot,M=F.value;try{var V=g();return!i(M,V)}catch{return!0}}function w(F,g,M){return g()}var E=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",x=!E,b=x?w:v,C=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:b;yn.useSyncExternalStore=C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),yn}(function(n){process.env.NODE_ENV==="production"?n.exports=ji():n.exports=Mi()})(Ur);const Ae=()=>{},ue=Ae(),mn=Object,k=n=>n===ue,be=n=>typeof n=="function",ke=(n,e)=>({...n,...e}),qi=n=>be(n.then),Ct=new WeakMap;let Wi=0;const nt=n=>{const e=typeof n,t=n&&n.constructor,r=t==Date;let s,i;if(mn(n)===n&&!r&&t!=RegExp){if(s=Ct.get(n),s)return s;if(s=++Wi+"~",Ct.set(n,s),t==Array){for(s="@",i=0;i<n.length;i++)s+=nt(n[i])+",";Ct.set(n,s)}if(t==mn){s="#";const o=mn.keys(n).sort();for(;!k(i=o.pop());)k(n[i])||(s+=i+":"+nt(n[i])+",");Ct.set(n,s)}}else s=r?n.toJSON():e=="symbol"?n.toString():e=="string"?JSON.stringify(n):""+n;return s},_e=new WeakMap,gn={},Ot={},bn="undefined",xt=typeof window!=bn,_n=typeof document!=bn,Hi=()=>xt&&typeof window.requestAnimationFrame!=bn,jr=(n,e)=>{const t=_e.get(n);return[()=>!k(e)&&n.get(e)||gn,r=>{if(!k(e)){const s=n.get(e);e in Ot||(Ot[e]=s),t[5](e,ke(s,r),s||gn)}},t[6],()=>!k(e)&&e in Ot?Ot[e]:!k(e)&&n.get(e)||gn]};let wn=!0;const Ji=()=>wn,[En,Sn]=xt&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Ae,Ae],Yi=()=>{const n=_n&&document.visibilityState;return k(n)||n!=="hidden"},zi=n=>(_n&&document.addEventListener("visibilitychange",n),En("focus",n),()=>{_n&&document.removeEventListener("visibilitychange",n),Sn("focus",n)}),Ki=n=>{const e=()=>{wn=!0,n()},t=()=>{wn=!1};return En("online",e),En("offline",t),()=>{Sn("online",e),Sn("offline",t)}},Gi={isOnline:Ji,isVisible:Yi},Xi={initFocus:zi,initReconnect:Ki},Mr=!Ne.default.useId,rt=!xt||"Deno"in window,Qi=n=>Hi()?window.requestAnimationFrame(n):setTimeout(n,1),Rn=rt?d.useEffect:d.useLayoutEffect,Tn=typeof navigator<"u"&&navigator.connection,qr=!rt&&Tn&&(["slow-2g","2g"].includes(Tn.effectiveType)||Tn.saveData),Cn=n=>{if(be(n))try{n=n()}catch{n=""}const e=n;return n=typeof n=="string"?n:(Array.isArray(n)?n.length:n)?nt(n):"",[n,e]};let Zi=0;const On=()=>++Zi,Wr=0,Hr=1,Jr=2;var st={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:Wr,MUTATE_EVENT:Jr,RECONNECT_EVENT:Hr};async function Yr(...n){const[e,t,r,s]=n,i=ke({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let o=i.populateCache;const c=i.rollbackOnError;let l=i.optimisticData;const a=i.revalidate!==!1,h=y=>typeof c=="function"?c(y):c!==!1,f=i.throwOnError;if(be(t)){const y=t,w=[],E=e.keys();for(const x of E)!/^\$(inf|sub)\$/.test(x)&&y(e.get(x)._k)&&w.push(x);return Promise.all(w.map(v))}return v(t);async function v(y){const[w]=Cn(y);if(!w)return;const[E,x]=jr(e,w),[b,C,F,g]=_e.get(e),M=b[w],V=()=>a&&(delete F[w],delete g[w],M&&M[0])?M[0](Jr).then(()=>E().data):E().data;if(n.length<3)return V();let L=r,S;const q=On();C[w]=[q,0];const P=!k(l),$=E(),te=$.data,ee=$._c,W=k(ee)?te:ee;if(P&&(l=be(l)?l(W,te):l,x({data:l,_c:W})),be(L))try{L=L(W)}catch(Ee){S=Ee}if(L&&qi(L))if(L=await L.catch(Ee=>{S=Ee}),q!==C[w][0]){if(S)throw S;return L}else S&&P&&h(S)&&(o=!0,L=W,x({data:L,_c:ue}));o&&(S||(be(o)&&(L=o(L,W)),x({data:L,error:ue,_c:ue}))),C[w][1]=On();const we=await V();if(x({_c:ue}),S){if(f)throw S;return}return o?we:L}}const zr=(n,e)=>{for(const t in n)n[t][0]&&n[t][0](e)},$i=(n,e)=>{if(!_e.has(n)){const t=ke(Xi,e),r={},s=Yr.bind(ue,n);let i=Ae;const o={},c=(h,f)=>{const v=o[h]||[];return o[h]=v,v.push(f),()=>v.splice(v.indexOf(f),1)},l=(h,f,v)=>{n.set(h,f);const y=o[h];if(y)for(const w of y)w(f,v)},a=()=>{if(!_e.has(n)&&(_e.set(n,[r,{},{},{},s,l,c]),!rt)){const h=t.initFocus(setTimeout.bind(ue,zr.bind(ue,r,Wr))),f=t.initReconnect(setTimeout.bind(ue,zr.bind(ue,r,Hr)));i=()=>{h&&h(),f&&f(),_e.delete(n)}}};return a(),[n,s,a,i]}return[n,_e.get(n)[4]]},eo=(n,e,t,r,s)=>{const i=t.errorRetryCount,o=s.retryCount,c=~~((Math.random()+.5)*(1<<(o<8?o:8)))*t.errorRetryInterval;!k(i)&&o>i||setTimeout(r,c,s)},to=(n,e)=>nt(n)==nt(e),[Kr,no]=$i(new Map),ro=ke({onLoadingSlow:Ae,onSuccess:Ae,onError:Ae,onErrorRetry:eo,onDiscarded:Ae,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:qr?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:qr?5e3:3e3,compare:to,isPaused:()=>!1,cache:Kr,mutate:no,fallback:{}},Gi),so=(n,e)=>{const t=ke(n,e);if(e){const{use:r,fallback:s}=n,{use:i,fallback:o}=e;r&&i&&(t.use=r.concat(i)),s&&o&&(t.fallback=ke(s,o))}return t},io=d.createContext({}),Gr=xt&&window.__SWR_DEVTOOLS_USE__,oo=Gr?window.__SWR_DEVTOOLS_USE__:[],ao=()=>{Gr&&(window.__SWR_DEVTOOLS_REACT__=Ne.default)},uo=n=>be(n[1])?[n[0],n[1],n[2]||{}]:[n[0],null,(n[1]===null?n[2]:n[1])||{}],co=()=>ke(ro,d.useContext(io)),lo=n=>(e,t,r)=>n(e,t&&((...i)=>{const[o]=Cn(e),[,,,c]=_e.get(Kr),l=c[o];return k(l)?t(...i):(delete c[o],l)}),r),fo=oo.concat(lo),ho=n=>function(...t){const r=co(),[s,i,o]=uo(t),c=so(r,o);let l=n;const{use:a}=c,h=(a||[]).concat(fo);for(let f=h.length;f--;)l=h[f](l);return l(s,i||c.fetcher||null,c)},po=(n,e,t)=>{const r=e[n]||(e[n]=[]);return r.push(t),()=>{const s=r.indexOf(t);s>=0&&(r[s]=r[r.length-1],r.pop())}};ao();const Xr=Ne.default.use||(n=>{if(n.status==="pending")throw n;if(n.status==="fulfilled")return n.value;throw n.status==="rejected"?n.reason:(n.status="pending",n.then(e=>{n.status="fulfilled",n.value=e},e=>{n.status="rejected",n.reason=e}),n)}),xn={dedupe:!0},it=ho((n,e,t)=>{const{cache:r,compare:s,suspense:i,fallbackData:o,revalidateOnMount:c,revalidateIfStale:l,refreshInterval:a,refreshWhenHidden:h,refreshWhenOffline:f,keepPreviousData:v}=t,[y,w,E,x]=_e.get(r),[b,C]=Cn(n),F=d.useRef(!1),g=d.useRef(!1),M=d.useRef(b),V=d.useRef(e),L=d.useRef(t),S=()=>L.current,q=()=>S().isVisible()&&S().isOnline(),[P,$,te,ee]=jr(r,b),W=d.useRef({}).current,we=k(o)?t.fallback[b]:o,Ee=(B,U)=>{for(const X in W){const j=X;if(j==="data"){if(!s(B[j],U[j])&&(!k(B[j])||!s(We,U[j])))return!1}else if(U[j]!==B[j])return!1}return!0},lt=d.useMemo(()=>{const B=(()=>!b||!e?!1:k(c)?S().isPaused()||i?!1:k(l)?!0:l:c)(),U=K=>{const de=ke(K);return delete de._k,B?{isValidating:!0,isLoading:!0,...de}:de},X=P(),j=ee(),ne=U(X),Ce=X===j?ne:U(j);let z=ne;return[()=>{const K=U(P());return Ee(K,z)?(z.data=K.data,z.isLoading=K.isLoading,z.isValidating=K.isValidating,z.error=K.error,z):(z=K,K)},()=>Ce]},[r,b]),Se=Ur.exports.useSyncExternalStore(d.useCallback(B=>te(b,(U,X)=>{Ee(X,U)||B()}),[r,b]),lt[0],lt[1]),ft=!F.current,It=y[b]&&y[b].length>0,Re=Se.data,Te=k(Re)?we:Re,Be=Se.error,Vt=d.useRef(Te),We=v?k(Re)?Vt.current:Re:Te,He=(()=>It&&!k(Be)?!1:ft&&!k(c)?c:S().isPaused()?!1:i?k(Te)?!1:l:k(Te)||l)(),Je=!!(b&&e&&ft&&He),Ye=k(Se.isValidating)?Je:Se.isValidating,ht=k(Se.isLoading)?Je:Se.isLoading,ge=d.useCallback(async B=>{const U=V.current;if(!b||!U||g.current||S().isPaused())return!1;let X,j,ne=!0;const Ce=B||{},z=!E[b]||!Ce.dedupe,K=()=>Mr?!g.current&&b===M.current&&F.current:b===M.current,de={isValidating:!1,isLoading:!1},Mt=()=>{$(de)},ze=()=>{const ie=E[b];ie&&ie[1]===j&&delete E[b]},qt={isValidating:!0};k(P().data)&&(qt.isLoading=!0);try{if(z&&($(qt),t.loadingTimeout&&k(P().data)&&setTimeout(()=>{ne&&K()&&S().onLoadingSlow(b,t)},t.loadingTimeout),E[b]=[U(C),On()]),[X,j]=E[b],X=await X,z&&setTimeout(ze,t.dedupingInterval),!E[b]||E[b][1]!==j)return z&&K()&&S().onDiscarded(b),!1;de.error=ue;const ie=w[b];if(!k(ie)&&(j<=ie[0]||j<=ie[1]||ie[1]===0))return Mt(),z&&K()&&S().onDiscarded(b),!1;const le=P().data;de.data=s(le,X)?le:X,z&&K()&&S().onSuccess(X,b,t)}catch(ie){ze();const le=S(),{shouldRetryOnError:Ke}=le;le.isPaused()||(de.error=ie,z&&K()&&(le.onError(ie,b,le),(Ke===!0||be(Ke)&&Ke(ie))&&q()&&le.onErrorRetry(ie,b,le,Ue=>{const dt=y[b];dt&&dt[0]&&dt[0](st.ERROR_REVALIDATE_EVENT,Ue)},{retryCount:(Ce.retryCount||0)+1,dedupe:!0})))}return ne=!1,Mt(),!0},[b,r]),jt=d.useCallback((...B)=>Yr(r,M.current,...B),[]);if(Rn(()=>{V.current=e,L.current=t,k(Re)||(Vt.current=Re)}),Rn(()=>{if(!b)return;const B=ge.bind(ue,xn);let U=0;const j=po(b,y,(ne,Ce={})=>{if(ne==st.FOCUS_EVENT){const z=Date.now();S().revalidateOnFocus&&z>U&&q()&&(U=z+S().focusThrottleInterval,B())}else if(ne==st.RECONNECT_EVENT)S().revalidateOnReconnect&&q()&&B();else{if(ne==st.MUTATE_EVENT)return ge();if(ne==st.ERROR_REVALIDATE_EVENT)return ge(Ce)}});return g.current=!1,M.current=b,F.current=!0,$({_k:C}),He&&(k(Te)||rt?B():Qi(B)),()=>{g.current=!0,j()}},[b]),Rn(()=>{let B;function U(){const j=be(a)?a(P().data):a;j&&B!==-1&&(B=setTimeout(X,j))}function X(){!P().error&&(h||S().isVisible())&&(f||S().isOnline())?ge(xn).then(U):U()}return U(),()=>{B&&(clearTimeout(B),B=-1)}},[a,h,f,b]),d.useDebugValue(We),i&&k(Te)&&b){if(!Mr&&rt)throw new Error("Fallback data is required when using suspense in SSR.");V.current=e,L.current=t,g.current=!1;const B=x[b];if(!k(B)){const U=jt(B);Xr(U)}if(k(Be)){const U=ge(xn);k(We)||(U.status="fulfilled",U.value=!0),Xr(U)}else throw Be}return{mutate:jt,get data(){return W.data=!0,We},get error(){return W.error=!0,Be},get isValidating(){return W.isValidating=!0,Ye},get isLoading(){return W.isLoading=!0,ht}}}),ye=Object.create(null);ye.open="0",ye.close="1",ye.ping="2",ye.pong="3",ye.message="4",ye.upgrade="5",ye.noop="6";const At=Object.create(null);Object.keys(ye).forEach(n=>{At[ye[n]]=n});const An={type:"error",data:"parser error"},Qr=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Zr=typeof ArrayBuffer=="function",$r=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,kn=({type:n,data:e},t,r)=>Qr&&e instanceof Blob?t?r(e):es(e,r):Zr&&(e instanceof ArrayBuffer||$r(e))?t?r(e):es(new Blob([e]),r):r(ye[n]+(e||"")),es=(n,e)=>{const t=new FileReader;return t.onload=function(){const r=t.result.split(",")[1];e("b"+(r||""))},t.readAsDataURL(n)};function ts(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Dn;function vo(n,e){if(Qr&&n.data instanceof Blob)return n.data.arrayBuffer().then(ts).then(e);if(Zr&&(n.data instanceof ArrayBuffer||$r(n.data)))return e(ts(n.data));kn(n,!1,t=>{Dn||(Dn=new TextEncoder),e(Dn.encode(t))})}const ns="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ot=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<ns.length;n++)ot[ns.charCodeAt(n)]=n;const yo=n=>{let e=n.length*.75,t=n.length,r,s=0,i,o,c,l;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const a=new ArrayBuffer(e),h=new Uint8Array(a);for(r=0;r<t;r+=4)i=ot[n.charCodeAt(r)],o=ot[n.charCodeAt(r+1)],c=ot[n.charCodeAt(r+2)],l=ot[n.charCodeAt(r+3)],h[s++]=i<<2|o>>4,h[s++]=(o&15)<<4|c>>2,h[s++]=(c&3)<<6|l&63;return a},mo=typeof ArrayBuffer=="function",Ln=(n,e)=>{if(typeof n!="string")return{type:"message",data:rs(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:go(n.substring(1),e)}:At[t]?n.length>1?{type:At[t],data:n.substring(1)}:{type:At[t]}:An},go=(n,e)=>{if(mo){const t=yo(n);return rs(t,e)}else return{base64:!0,data:n}},rs=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},ss=String.fromCharCode(30),bo=(n,e)=>{const t=n.length,r=new Array(t);let s=0;n.forEach((i,o)=>{kn(i,!1,c=>{r[o]=c,++s===t&&e(r.join(ss))})})},_o=(n,e)=>{const t=n.split(ss),r=[];for(let s=0;s<t.length;s++){const i=Ln(t[s],e);if(r.push(i),i.type==="error")break}return r};function wo(){return new TransformStream({transform(n,e){vo(n,t=>{const r=t.length;let s;if(r<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,r);else if(r<65536){s=new Uint8Array(3);const i=new DataView(s.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{s=new Uint8Array(9);const i=new DataView(s.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}n.data&&typeof n.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}let Nn;function kt(n){return n.reduce((e,t)=>e+t.length,0)}function Dt(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let r=0;for(let s=0;s<e;s++)t[s]=n[0][r++],r===n[0].length&&(n.shift(),r=0);return n.length&&r<n[0].length&&(n[0]=n[0].slice(r)),t}function Eo(n,e){Nn||(Nn=new TextDecoder);const t=[];let r=0,s=-1,i=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(kt(t)<1)break;const l=Dt(t,1);i=(l[0]&128)===128,s=l[0]&127,s<126?r=3:s===126?r=1:r=2}else if(r===1){if(kt(t)<2)break;const l=Dt(t,2);s=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(kt(t)<8)break;const l=Dt(t,8),a=new DataView(l.buffer,l.byteOffset,l.length),h=a.getUint32(0);if(h>Math.pow(2,53-32)-1){c.enqueue(An);break}s=h*Math.pow(2,32)+a.getUint32(4),r=3}else{if(kt(t)<s)break;const l=Dt(t,s);c.enqueue(Ln(i?l:Nn.decode(l),e)),r=0}if(s===0||s>n){c.enqueue(An);break}}}})}const is=4;function Y(n){if(n)return So(n)}function So(n){for(var e in Y.prototype)n[e]=Y.prototype[e];return n}Y.prototype.on=Y.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this},Y.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this},Y.prototype.off=Y.prototype.removeListener=Y.prototype.removeAllListeners=Y.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var r,s=0;s<t.length;s++)if(r=t[s],r===e||r.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+n],this},Y.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(t){t=t.slice(0);for(var r=0,s=t.length;r<s;++r)t[r].apply(this,e)}return this},Y.prototype.emitReserved=Y.prototype.emit,Y.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]},Y.prototype.hasListeners=function(n){return!!this.listeners(n).length};const ce=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function os(n,...e){return e.reduce((t,r)=>(n.hasOwnProperty(r)&&(t[r]=n[r]),t),{})}const Ro=ce.setTimeout,To=ce.clearTimeout;function Lt(n,e){e.useNativeTimers?(n.setTimeoutFn=Ro.bind(ce),n.clearTimeoutFn=To.bind(ce)):(n.setTimeoutFn=ce.setTimeout.bind(ce),n.clearTimeoutFn=ce.clearTimeout.bind(ce))}const Co=1.33;function Oo(n){return typeof n=="string"?xo(n):Math.ceil((n.byteLength||n.size)*Co)}function xo(n){let e=0,t=0;for(let r=0,s=n.length;r<s;r++)e=n.charCodeAt(r),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(r++,t+=4);return t}function Ao(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function ko(n){let e={},t=n.split("&");for(let r=0,s=t.length;r<s;r++){let i=t[r].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}class Do extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class Fn extends Y{constructor(e){super(),this.writable=!1,Lt(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Do(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=Ln(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=Ao(e);return t.length?"?"+t:""}}const as="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Pn=64,Lo={};let us=0,Nt=0,cs;function ls(n){let e="";do e=as[n%Pn]+e,n=Math.floor(n/Pn);while(n>0);return e}function fs(){const n=ls(+new Date);return n!==cs?(us=0,cs=n):n+"."+ls(us++)}for(;Nt<Pn;Nt++)Lo[as[Nt]]=Nt;let hs=!1;try{hs=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const No=hs;function ds(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||No))return new XMLHttpRequest}catch{}if(!e)try{return new ce[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function Wa(){}function Fo(){}const Po=function(){return new ds({xdomain:!1}).responseType!=null}();class Bo extends Fn{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){const r=location.protocol==="https:";let s=location.port;s||(s=r?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}const t=e&&e.forceBase64;this.supportsBinary=Po&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(r++,this.once("pollComplete",function(){--r||t()})),this.writable||(r++,this.once("drain",function(){--r||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};_o(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,bo(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=fs()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new me(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(s,i)=>{this.onError("xhr post error",s,i)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}}class me extends Y{constructor(e,t){super(),Lt(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=t.data!==void 0?t.data:null,this.create()}create(){var e;const t=os(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const r=this.xhr=new ds(t);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let s in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(s)&&r.setRequestHeader(s,this.opts.extraHeaders[s])}}catch{}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var s;r.readyState===3&&((s=this.opts.cookieJar)===null||s===void 0||s.parseCookies(r)),r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},r.send(this.data)}catch(s){this.setTimeoutFn(()=>{this.onError(s)},0);return}typeof document<"u"&&(this.index=me.requestsCount++,me.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=Fo,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete me.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(me.requestsCount=0,me.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",ps);else if(typeof addEventListener=="function"){const n="onpagehide"in ce?"pagehide":"unload";addEventListener(n,ps,!1)}}function ps(){for(let n in me.requests)me.requests.hasOwnProperty(n)&&me.requests[n].abort()}const Bn=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0))(),Ft=ce.WebSocket||ce.MozWebSocket,vs=!0,Uo="arraybuffer",ys=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Io extends Fn{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=ys?{}:os(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=vs&&!ys?t?new Ft(e,t):new Ft(e):new Ft(e,t,r)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],s=t===e.length-1;kn(r,this.supportsBinary,i=>{const o={};try{vs&&this.ws.send(i)}catch{}s&&Bn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=fs()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Ft}}class Vo extends Fn{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{const t=Eo(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),s=wo();s.readable.pipeTo(e.writable),this.writer=s.writable.getWriter();const i=()=>{r.read().then(({done:c,value:l})=>{c||(this.onPacket(l),i())}).catch(c=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],s=t===e.length-1;this.writer.write(r).then(()=>{s&&Bn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}}const jo={websocket:Io,webtransport:Vo,polling:Bo},Mo=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,qo=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Un(n){const e=n,t=n.indexOf("["),r=n.indexOf("]");t!=-1&&r!=-1&&(n=n.substring(0,t)+n.substring(t,r).replace(/:/g,";")+n.substring(r,n.length));let s=Mo.exec(n||""),i={},o=14;for(;o--;)i[qo[o]]=s[o]||"";return t!=-1&&r!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Wo(i,i.path),i.queryKey=Ho(i,i.query),i}function Wo(n,e){const t=/\/{2,9}/g,r=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Ho(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,s,i){s&&(t[s]=i)}),t}class De extends Y{constructor(e,t={}){super(),this.binaryType=Uo,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Un(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=Un(t.host).host),Lt(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=ko(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=is,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new jo[e](r)}open(){let e;if(this.opts.rememberUpgrade&&De.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){let t=this.createTransport(e),r=!1;De.priorWebsocketSuccess=!1;const s=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;De.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(h(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=t.name,this.emitReserved("upgradeError",v)}}))};function i(){r||(r=!0,h(),t.close(),t=null)}const o=f=>{const v=new Error("probe error: "+f);v.transport=t.name,i(),this.emitReserved("upgradeError",v)};function c(){o("transport closed")}function l(){o("socket closed")}function a(f){t&&f.name!==t.name&&i()}const h=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",c),this.off("close",l),this.off("upgrading",a)};t.once("open",s),t.once("error",o),t.once("close",c),this.once("close",l),this.once("upgrading",a),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(this.readyState="open",De.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){const s=this.writeBuffer[r].data;if(s&&(t+=Oo(s)),r>0&&t>this.maxPayload)return this.writeBuffer.slice(0,r);t+=2}return this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,s){if(typeof t=="function"&&(s=t,t=void 0),typeof r=="function"&&(s=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:e,data:t,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),s&&this.once("flush",s),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){De.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const s=e.length;for(;r<s;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}}De.protocol=is;function Jo(n,e="",t){let r=n;t=t||typeof location<"u"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(typeof t<"u"?n=t.protocol+"//"+n:n="https://"+n),r=Un(n)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+e,r.href=r.protocol+"://"+i+(t&&t.port===r.port?"":":"+r.port),r}const Yo=typeof ArrayBuffer=="function",zo=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ms=Object.prototype.toString,Ko=typeof Blob=="function"||typeof Blob<"u"&&ms.call(Blob)==="[object BlobConstructor]",Go=typeof File=="function"||typeof File<"u"&&ms.call(File)==="[object FileConstructor]";function In(n){return Yo&&(n instanceof ArrayBuffer||zo(n))||Ko&&n instanceof Blob||Go&&n instanceof File}function Pt(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,r=n.length;t<r;t++)if(Pt(n[t]))return!0;return!1}if(In(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Pt(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&Pt(n[t]))return!0;return!1}function Xo(n){const e=[],t=n.data,r=n;return r.data=Vn(t,e),r.attachments=e.length,{packet:r,buffers:e}}function Vn(n,e){if(!n)return n;if(In(n)){const t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){const t=new Array(n.length);for(let r=0;r<n.length;r++)t[r]=Vn(n[r],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){const t={};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=Vn(n[r],e));return t}return n}function Qo(n,e){return n.data=jn(n.data,e),delete n.attachments,n}function jn(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=jn(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=jn(n[t],e));return n}const Zo=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],$o=5;var T;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(T||(T={}));class ea{constructor(e){this.replacer=e}encode(e){return(e.type===T.EVENT||e.type===T.ACK)&&Pt(e)?this.encodeAsBinary({type:e.type===T.EVENT?T.BINARY_EVENT:T.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===T.BINARY_EVENT||e.type===T.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Xo(e),r=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(r),s}}function gs(n){return Object.prototype.toString.call(n)==="[object Object]"}class Mn extends Y{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===T.BINARY_EVENT;r||t.type===T.BINARY_ACK?(t.type=r?T.EVENT:T.ACK,this.reconstructor=new ta(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(In(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(T[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===T.BINARY_EVENT||r.type===T.BINARY_ACK){const i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(i,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){const i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(i,t)}else r.nsp="/";const s=e.charAt(t+1);if(s!==""&&Number(s)==s){const i=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}r.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(Mn.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case T.CONNECT:return gs(t);case T.DISCONNECT:return t===void 0;case T.CONNECT_ERROR:return typeof t=="string"||gs(t);case T.EVENT:case T.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Zo.indexOf(t[0])===-1);case T.ACK:case T.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ta{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Qo(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const na=Object.freeze(Object.defineProperty({__proto__:null,protocol:$o,get PacketType(){return T},Encoder:ea,Decoder:Mn},Symbol.toStringTag,{value:"Module"}));function he(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const ra=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class bs extends Y{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[he(e,"open",this.onopen.bind(this)),he(e,"packet",this.onpacket.bind(this)),he(e,"error",this.onerror.bind(this)),he(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(ra.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:T.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const o=this.ids++,c=t.pop();this._registerAckCallback(o,c),r.id=o}const s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var r;const s=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&this.sendBuffer.splice(o,1);t.call(this,new Error("operation has timed out"))},s);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...o])}}emitWithAck(e,...t){const r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((s,i)=>{t.push((o,c)=>r?o?i(o):s(c):s(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...i)=>r!==this._queue[0]?void 0:(s!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(s)):(this._queue.shift(),t&&t(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:T.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case T.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case T.EVENT:case T.BINARY_EVENT:this.onevent(e);break;case T.ACK:case T.BINARY_ACK:this.onack(e);break;case T.DISCONNECT:this.ondisconnect();break;case T.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...s){r||(r=!0,t.packet({type:T.ACK,id:e,data:s}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:T.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}function qe(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}qe.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-t:n+t}return Math.min(n,this.max)|0},qe.prototype.reset=function(){this.attempts=0},qe.prototype.setMin=function(n){this.ms=n},qe.prototype.setMax=function(n){this.max=n},qe.prototype.setJitter=function(n){this.jitter=n};class qn extends Y{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Lt(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new qe({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const s=t.parser||na;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new De(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const s=he(t,"open",function(){r.onopen(),e&&e()}),i=c=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=he(t,"error",i);if(this._timeout!==!1){const c=this._timeout,l=this.setTimeoutFn(()=>{s(),i(new Error("timeout")),t.close()},c);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(s),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(he(e,"ping",this.onping.bind(this)),he(e,"data",this.ondata.bind(this)),he(e,"error",this.onerror.bind(this)),he(e,"close",this.onclose.bind(this)),he(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){Bn(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new bs(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const r of t)if(this.nsps[r].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):e.onreconnect()}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const at={};function Bt(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=Jo(n,e.path||"/socket.io"),r=t.source,s=t.id,i=t.path,o=at[s]&&i in at[s].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let l;return c?l=new qn(r,e):(at[s]||(at[s]=new qn(r,e)),l=at[s]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(Bt,{Manager:qn,Socket:bs,io:Bt,connect:Bt});class sa{constructor(e,t,r,s){Le(this,"socket_port");Le(this,"host");Le(this,"port");Le(this,"protocol");Le(this,"url");Le(this,"site_name");Le(this,"socket");var i,o;this.socket_port=r!=null?r:"9000",this.host=(i=window.location)==null?void 0:i.hostname,this.port=(o=window.location)!=null&&o.port?`:${this.socket_port}`:"",this.protocol=this.port?"http":"https",this.url=e||`${this.protocol}://${this.host}${this.port}`,this.site_name=t!=null?t:frappe==null?void 0:frappe.boot.sitename,this.socket=Bt(`${this.url}/${this.site_name}`,{withCredentials:!0,secure:this.protocol==="https",extraHeaders:s&&s.useToken===!0?{Authorization:`${s.type} ${s.token}`}:{}})}}var _s={exports:{}},ut={};/**
18
+ */var Vr;function Mi(){return Vr||(Vr=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=Ne.default,e=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(F){{for(var g=arguments.length,M=new Array(g>1?g-1:0),V=1;V<g;V++)M[V-1]=arguments[V];r("error",F,M)}}function r(F,g,M){{var V=e.ReactDebugCurrentFrame,L=V.getStackAddendum();L!==""&&(g+="%s",M=M.concat([L]));var S=M.map(function(q){return String(q)});S.unshift("Warning: "+g),Function.prototype.apply.call(console[F],console,S)}}function s(F,g){return F===g&&(F!==0||1/F===1/g)||F!==F&&g!==g}var i=typeof Object.is=="function"?Object.is:s,o=n.useState,c=n.useEffect,l=n.useLayoutEffect,a=n.useDebugValue,h=!1,f=!1;function v(F,g,M){h||n.startTransition!==void 0&&(h=!0,t("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var V=g();if(!f){var L=g();i(V,L)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}var S=o({inst:{value:V,getSnapshot:g}}),q=S[0].inst,P=S[1];return l(function(){q.value=V,q.getSnapshot=g,y(q)&&P({inst:q})},[F,V,g]),c(function(){y(q)&&P({inst:q});var $=function(){y(q)&&P({inst:q})};return F($)},[F]),a(V),V}function y(F){var g=F.getSnapshot,M=F.value;try{var V=g();return!i(M,V)}catch{return!0}}function w(F,g,M){return g()}var E=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",x=!E,b=x?w:v,C=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:b;yn.useSyncExternalStore=C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),yn}(function(n){process.env.NODE_ENV==="production"?n.exports=ji():n.exports=Mi()})(Ur);const Ae=()=>{},ue=Ae(),mn=Object,k=n=>n===ue,be=n=>typeof n=="function",ke=(n,e)=>({...n,...e}),qi=n=>be(n.then),Ct=new WeakMap;let Wi=0;const nt=n=>{const e=typeof n,t=n&&n.constructor,r=t==Date;let s,i;if(mn(n)===n&&!r&&t!=RegExp){if(s=Ct.get(n),s)return s;if(s=++Wi+"~",Ct.set(n,s),t==Array){for(s="@",i=0;i<n.length;i++)s+=nt(n[i])+",";Ct.set(n,s)}if(t==mn){s="#";const o=mn.keys(n).sort();for(;!k(i=o.pop());)k(n[i])||(s+=i+":"+nt(n[i])+",");Ct.set(n,s)}}else s=r?n.toJSON():e=="symbol"?n.toString():e=="string"?JSON.stringify(n):""+n;return s},_e=new WeakMap,gn={},Ot={},bn="undefined",xt=typeof window!=bn,_n=typeof document!=bn,Hi=()=>xt&&typeof window.requestAnimationFrame!=bn,jr=(n,e)=>{const t=_e.get(n);return[()=>!k(e)&&n.get(e)||gn,r=>{if(!k(e)){const s=n.get(e);e in Ot||(Ot[e]=s),t[5](e,ke(s,r),s||gn)}},t[6],()=>!k(e)&&e in Ot?Ot[e]:!k(e)&&n.get(e)||gn]};let wn=!0;const Ji=()=>wn,[En,Sn]=xt&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Ae,Ae],Yi=()=>{const n=_n&&document.visibilityState;return k(n)||n!=="hidden"},zi=n=>(_n&&document.addEventListener("visibilitychange",n),En("focus",n),()=>{_n&&document.removeEventListener("visibilitychange",n),Sn("focus",n)}),Ki=n=>{const e=()=>{wn=!0,n()},t=()=>{wn=!1};return En("online",e),En("offline",t),()=>{Sn("online",e),Sn("offline",t)}},Gi={isOnline:Ji,isVisible:Yi},Xi={initFocus:zi,initReconnect:Ki},Mr=!Ne.default.useId,rt=!xt||"Deno"in window,Qi=n=>Hi()?window.requestAnimationFrame(n):setTimeout(n,1),Rn=rt?d.useEffect:d.useLayoutEffect,Tn=typeof navigator<"u"&&navigator.connection,qr=!rt&&Tn&&(["slow-2g","2g"].includes(Tn.effectiveType)||Tn.saveData),Cn=n=>{if(be(n))try{n=n()}catch{n=""}const e=n;return n=typeof n=="string"?n:(Array.isArray(n)?n.length:n)?nt(n):"",[n,e]};let Zi=0;const On=()=>++Zi,Wr=0,Hr=1,Jr=2;var st={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:Wr,MUTATE_EVENT:Jr,RECONNECT_EVENT:Hr};async function Yr(...n){const[e,t,r,s]=n,i=ke({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let o=i.populateCache;const c=i.rollbackOnError;let l=i.optimisticData;const a=i.revalidate!==!1,h=y=>typeof c=="function"?c(y):c!==!1,f=i.throwOnError;if(be(t)){const y=t,w=[],E=e.keys();for(const x of E)!/^\$(inf|sub)\$/.test(x)&&y(e.get(x)._k)&&w.push(x);return Promise.all(w.map(v))}return v(t);async function v(y){const[w]=Cn(y);if(!w)return;const[E,x]=jr(e,w),[b,C,F,g]=_e.get(e),M=b[w],V=()=>a&&(delete F[w],delete g[w],M&&M[0])?M[0](Jr).then(()=>E().data):E().data;if(n.length<3)return V();let L=r,S;const q=On();C[w]=[q,0];const P=!k(l),$=E(),te=$.data,ee=$._c,W=k(ee)?te:ee;if(P&&(l=be(l)?l(W,te):l,x({data:l,_c:W})),be(L))try{L=L(W)}catch(Ee){S=Ee}if(L&&qi(L))if(L=await L.catch(Ee=>{S=Ee}),q!==C[w][0]){if(S)throw S;return L}else S&&P&&h(S)&&(o=!0,L=W,x({data:L,_c:ue}));o&&(S||(be(o)&&(L=o(L,W)),x({data:L,error:ue,_c:ue}))),C[w][1]=On();const we=await V();if(x({_c:ue}),S){if(f)throw S;return}return o?we:L}}const zr=(n,e)=>{for(const t in n)n[t][0]&&n[t][0](e)},$i=(n,e)=>{if(!_e.has(n)){const t=ke(Xi,e),r={},s=Yr.bind(ue,n);let i=Ae;const o={},c=(h,f)=>{const v=o[h]||[];return o[h]=v,v.push(f),()=>v.splice(v.indexOf(f),1)},l=(h,f,v)=>{n.set(h,f);const y=o[h];if(y)for(const w of y)w(f,v)},a=()=>{if(!_e.has(n)&&(_e.set(n,[r,{},{},{},s,l,c]),!rt)){const h=t.initFocus(setTimeout.bind(ue,zr.bind(ue,r,Wr))),f=t.initReconnect(setTimeout.bind(ue,zr.bind(ue,r,Hr)));i=()=>{h&&h(),f&&f(),_e.delete(n)}}};return a(),[n,s,a,i]}return[n,_e.get(n)[4]]},eo=(n,e,t,r,s)=>{const i=t.errorRetryCount,o=s.retryCount,c=~~((Math.random()+.5)*(1<<(o<8?o:8)))*t.errorRetryInterval;!k(i)&&o>i||setTimeout(r,c,s)},to=(n,e)=>nt(n)==nt(e),[Kr,no]=$i(new Map),ro=ke({onLoadingSlow:Ae,onSuccess:Ae,onError:Ae,onErrorRetry:eo,onDiscarded:Ae,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:qr?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:qr?5e3:3e3,compare:to,isPaused:()=>!1,cache:Kr,mutate:no,fallback:{}},Gi),so=(n,e)=>{const t=ke(n,e);if(e){const{use:r,fallback:s}=n,{use:i,fallback:o}=e;r&&i&&(t.use=r.concat(i)),s&&o&&(t.fallback=ke(s,o))}return t},io=d.createContext({}),Gr=xt&&window.__SWR_DEVTOOLS_USE__,oo=Gr?window.__SWR_DEVTOOLS_USE__:[],ao=()=>{Gr&&(window.__SWR_DEVTOOLS_REACT__=Ne.default)},uo=n=>be(n[1])?[n[0],n[1],n[2]||{}]:[n[0],null,(n[1]===null?n[2]:n[1])||{}],co=()=>ke(ro,d.useContext(io)),lo=n=>(e,t,r)=>n(e,t&&((...i)=>{const[o]=Cn(e),[,,,c]=_e.get(Kr),l=c[o];return k(l)?t(...i):(delete c[o],l)}),r),fo=oo.concat(lo),ho=n=>function(...t){const r=co(),[s,i,o]=uo(t),c=so(r,o);let l=n;const{use:a}=c,h=(a||[]).concat(fo);for(let f=h.length;f--;)l=h[f](l);return l(s,i||c.fetcher||null,c)},po=(n,e,t)=>{const r=e[n]||(e[n]=[]);return r.push(t),()=>{const s=r.indexOf(t);s>=0&&(r[s]=r[r.length-1],r.pop())}};ao();const Xr=Ne.default.use||(n=>{if(n.status==="pending")throw n;if(n.status==="fulfilled")return n.value;throw n.status==="rejected"?n.reason:(n.status="pending",n.then(e=>{n.status="fulfilled",n.value=e},e=>{n.status="rejected",n.reason=e}),n)}),xn={dedupe:!0},it=ho((n,e,t)=>{const{cache:r,compare:s,suspense:i,fallbackData:o,revalidateOnMount:c,revalidateIfStale:l,refreshInterval:a,refreshWhenHidden:h,refreshWhenOffline:f,keepPreviousData:v}=t,[y,w,E,x]=_e.get(r),[b,C]=Cn(n),F=d.useRef(!1),g=d.useRef(!1),M=d.useRef(b),V=d.useRef(e),L=d.useRef(t),S=()=>L.current,q=()=>S().isVisible()&&S().isOnline(),[P,$,te,ee]=jr(r,b),W=d.useRef({}).current,we=k(o)?t.fallback[b]:o,Ee=(B,U)=>{for(const X in W){const j=X;if(j==="data"){if(!s(B[j],U[j])&&(!k(B[j])||!s(We,U[j])))return!1}else if(U[j]!==B[j])return!1}return!0},lt=d.useMemo(()=>{const B=(()=>!b||!e?!1:k(c)?S().isPaused()||i?!1:k(l)?!0:l:c)(),U=K=>{const de=ke(K);return delete de._k,B?{isValidating:!0,isLoading:!0,...de}:de},X=P(),j=ee(),ne=U(X),Ce=X===j?ne:U(j);let z=ne;return[()=>{const K=U(P());return Ee(K,z)?(z.data=K.data,z.isLoading=K.isLoading,z.isValidating=K.isValidating,z.error=K.error,z):(z=K,K)},()=>Ce]},[r,b]),Se=Ur.exports.useSyncExternalStore(d.useCallback(B=>te(b,(U,X)=>{Ee(X,U)||B()}),[r,b]),lt[0],lt[1]),ft=!F.current,It=y[b]&&y[b].length>0,Re=Se.data,Te=k(Re)?we:Re,Be=Se.error,Vt=d.useRef(Te),We=v?k(Re)?Vt.current:Re:Te,He=(()=>It&&!k(Be)?!1:ft&&!k(c)?c:S().isPaused()?!1:i?k(Te)?!1:l:k(Te)||l)(),Je=!!(b&&e&&ft&&He),Ye=k(Se.isValidating)?Je:Se.isValidating,ht=k(Se.isLoading)?Je:Se.isLoading,ge=d.useCallback(async B=>{const U=V.current;if(!b||!U||g.current||S().isPaused())return!1;let X,j,ne=!0;const Ce=B||{},z=!E[b]||!Ce.dedupe,K=()=>Mr?!g.current&&b===M.current&&F.current:b===M.current,de={isValidating:!1,isLoading:!1},Mt=()=>{$(de)},ze=()=>{const ie=E[b];ie&&ie[1]===j&&delete E[b]},qt={isValidating:!0};k(P().data)&&(qt.isLoading=!0);try{if(z&&($(qt),t.loadingTimeout&&k(P().data)&&setTimeout(()=>{ne&&K()&&S().onLoadingSlow(b,t)},t.loadingTimeout),E[b]=[U(C),On()]),[X,j]=E[b],X=await X,z&&setTimeout(ze,t.dedupingInterval),!E[b]||E[b][1]!==j)return z&&K()&&S().onDiscarded(b),!1;de.error=ue;const ie=w[b];if(!k(ie)&&(j<=ie[0]||j<=ie[1]||ie[1]===0))return Mt(),z&&K()&&S().onDiscarded(b),!1;const le=P().data;de.data=s(le,X)?le:X,z&&K()&&S().onSuccess(X,b,t)}catch(ie){ze();const le=S(),{shouldRetryOnError:Ke}=le;le.isPaused()||(de.error=ie,z&&K()&&(le.onError(ie,b,le),(Ke===!0||be(Ke)&&Ke(ie))&&q()&&le.onErrorRetry(ie,b,le,Ue=>{const dt=y[b];dt&&dt[0]&&dt[0](st.ERROR_REVALIDATE_EVENT,Ue)},{retryCount:(Ce.retryCount||0)+1,dedupe:!0})))}return ne=!1,Mt(),!0},[b,r]),jt=d.useCallback((...B)=>Yr(r,M.current,...B),[]);if(Rn(()=>{V.current=e,L.current=t,k(Re)||(Vt.current=Re)}),Rn(()=>{if(!b)return;const B=ge.bind(ue,xn);let U=0;const j=po(b,y,(ne,Ce={})=>{if(ne==st.FOCUS_EVENT){const z=Date.now();S().revalidateOnFocus&&z>U&&q()&&(U=z+S().focusThrottleInterval,B())}else if(ne==st.RECONNECT_EVENT)S().revalidateOnReconnect&&q()&&B();else{if(ne==st.MUTATE_EVENT)return ge();if(ne==st.ERROR_REVALIDATE_EVENT)return ge(Ce)}});return g.current=!1,M.current=b,F.current=!0,$({_k:C}),He&&(k(Te)||rt?B():Qi(B)),()=>{g.current=!0,j()}},[b]),Rn(()=>{let B;function U(){const j=be(a)?a(P().data):a;j&&B!==-1&&(B=setTimeout(X,j))}function X(){!P().error&&(h||S().isVisible())&&(f||S().isOnline())?ge(xn).then(U):U()}return U(),()=>{B&&(clearTimeout(B),B=-1)}},[a,h,f,b]),d.useDebugValue(We),i&&k(Te)&&b){if(!Mr&&rt)throw new Error("Fallback data is required when using suspense in SSR.");V.current=e,L.current=t,g.current=!1;const B=x[b];if(!k(B)){const U=jt(B);Xr(U)}if(k(Be)){const U=ge(xn);k(We)||(U.status="fulfilled",U.value=!0),Xr(U)}else throw Be}return{mutate:jt,get data(){return W.data=!0,We},get error(){return W.error=!0,Be},get isValidating(){return W.isValidating=!0,Ye},get isLoading(){return W.isLoading=!0,ht}}}),ye=Object.create(null);ye.open="0",ye.close="1",ye.ping="2",ye.pong="3",ye.message="4",ye.upgrade="5",ye.noop="6";const At=Object.create(null);Object.keys(ye).forEach(n=>{At[ye[n]]=n});const An={type:"error",data:"parser error"},Qr=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Zr=typeof ArrayBuffer=="function",$r=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,kn=({type:n,data:e},t,r)=>Qr&&e instanceof Blob?t?r(e):es(e,r):Zr&&(e instanceof ArrayBuffer||$r(e))?t?r(e):es(new Blob([e]),r):r(ye[n]+(e||"")),es=(n,e)=>{const t=new FileReader;return t.onload=function(){const r=t.result.split(",")[1];e("b"+(r||""))},t.readAsDataURL(n)};function ts(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Dn;function vo(n,e){if(Qr&&n.data instanceof Blob)return n.data.arrayBuffer().then(ts).then(e);if(Zr&&(n.data instanceof ArrayBuffer||$r(n.data)))return e(ts(n.data));kn(n,!1,t=>{Dn||(Dn=new TextEncoder),e(Dn.encode(t))})}const ns="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ot=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<ns.length;n++)ot[ns.charCodeAt(n)]=n;const yo=n=>{let e=n.length*.75,t=n.length,r,s=0,i,o,c,l;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const a=new ArrayBuffer(e),h=new Uint8Array(a);for(r=0;r<t;r+=4)i=ot[n.charCodeAt(r)],o=ot[n.charCodeAt(r+1)],c=ot[n.charCodeAt(r+2)],l=ot[n.charCodeAt(r+3)],h[s++]=i<<2|o>>4,h[s++]=(o&15)<<4|c>>2,h[s++]=(c&3)<<6|l&63;return a},mo=typeof ArrayBuffer=="function",Ln=(n,e)=>{if(typeof n!="string")return{type:"message",data:rs(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:go(n.substring(1),e)}:At[t]?n.length>1?{type:At[t],data:n.substring(1)}:{type:At[t]}:An},go=(n,e)=>{if(mo){const t=yo(n);return rs(t,e)}else return{base64:!0,data:n}},rs=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},ss=String.fromCharCode(30),bo=(n,e)=>{const t=n.length,r=new Array(t);let s=0;n.forEach((i,o)=>{kn(i,!1,c=>{r[o]=c,++s===t&&e(r.join(ss))})})},_o=(n,e)=>{const t=n.split(ss),r=[];for(let s=0;s<t.length;s++){const i=Ln(t[s],e);if(r.push(i),i.type==="error")break}return r};function wo(){return new TransformStream({transform(n,e){vo(n,t=>{const r=t.length;let s;if(r<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,r);else if(r<65536){s=new Uint8Array(3);const i=new DataView(s.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{s=new Uint8Array(9);const i=new DataView(s.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}n.data&&typeof n.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}let Nn;function kt(n){return n.reduce((e,t)=>e+t.length,0)}function Dt(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let r=0;for(let s=0;s<e;s++)t[s]=n[0][r++],r===n[0].length&&(n.shift(),r=0);return n.length&&r<n[0].length&&(n[0]=n[0].slice(r)),t}function Eo(n,e){Nn||(Nn=new TextDecoder);const t=[];let r=0,s=-1,i=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(kt(t)<1)break;const l=Dt(t,1);i=(l[0]&128)===128,s=l[0]&127,s<126?r=3:s===126?r=1:r=2}else if(r===1){if(kt(t)<2)break;const l=Dt(t,2);s=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(kt(t)<8)break;const l=Dt(t,8),a=new DataView(l.buffer,l.byteOffset,l.length),h=a.getUint32(0);if(h>Math.pow(2,53-32)-1){c.enqueue(An);break}s=h*Math.pow(2,32)+a.getUint32(4),r=3}else{if(kt(t)<s)break;const l=Dt(t,s);c.enqueue(Ln(i?l:Nn.decode(l),e)),r=0}if(s===0||s>n){c.enqueue(An);break}}}})}const is=4;function Y(n){if(n)return So(n)}function So(n){for(var e in Y.prototype)n[e]=Y.prototype[e];return n}Y.prototype.on=Y.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this},Y.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this},Y.prototype.off=Y.prototype.removeListener=Y.prototype.removeAllListeners=Y.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var r,s=0;s<t.length;s++)if(r=t[s],r===e||r.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+n],this},Y.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(t){t=t.slice(0);for(var r=0,s=t.length;r<s;++r)t[r].apply(this,e)}return this},Y.prototype.emitReserved=Y.prototype.emit,Y.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]},Y.prototype.hasListeners=function(n){return!!this.listeners(n).length};const ce=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function os(n,...e){return e.reduce((t,r)=>(n.hasOwnProperty(r)&&(t[r]=n[r]),t),{})}const Ro=ce.setTimeout,To=ce.clearTimeout;function Lt(n,e){e.useNativeTimers?(n.setTimeoutFn=Ro.bind(ce),n.clearTimeoutFn=To.bind(ce)):(n.setTimeoutFn=ce.setTimeout.bind(ce),n.clearTimeoutFn=ce.clearTimeout.bind(ce))}const Co=1.33;function Oo(n){return typeof n=="string"?xo(n):Math.ceil((n.byteLength||n.size)*Co)}function xo(n){let e=0,t=0;for(let r=0,s=n.length;r<s;r++)e=n.charCodeAt(r),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(r++,t+=4);return t}function Ao(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function ko(n){let e={},t=n.split("&");for(let r=0,s=t.length;r<s;r++){let i=t[r].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}class Do extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class Fn extends Y{constructor(e){super(),this.writable=!1,Lt(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Do(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=Ln(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=Ao(e);return t.length?"?"+t:""}}const as="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Pn=64,Lo={};let us=0,Nt=0,cs;function ls(n){let e="";do e=as[n%Pn]+e,n=Math.floor(n/Pn);while(n>0);return e}function fs(){const n=ls(+new Date);return n!==cs?(us=0,cs=n):n+"."+ls(us++)}for(;Nt<Pn;Nt++)Lo[as[Nt]]=Nt;let hs=!1;try{hs=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const No=hs;function ds(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||No))return new XMLHttpRequest}catch{}if(!e)try{return new ce[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function Wa(){}function Fo(){}const Po=function(){return new ds({xdomain:!1}).responseType!=null}();class Bo extends Fn{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){const r=location.protocol==="https:";let s=location.port;s||(s=r?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}const t=e&&e.forceBase64;this.supportsBinary=Po&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(r++,this.once("pollComplete",function(){--r||t()})),this.writable||(r++,this.once("drain",function(){--r||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};_o(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,bo(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=fs()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new me(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(s,i)=>{this.onError("xhr post error",s,i)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}}class me extends Y{constructor(e,t){super(),Lt(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=t.data!==void 0?t.data:null,this.create()}create(){var e;const t=os(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const r=this.xhr=new ds(t);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let s in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(s)&&r.setRequestHeader(s,this.opts.extraHeaders[s])}}catch{}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var s;r.readyState===3&&((s=this.opts.cookieJar)===null||s===void 0||s.parseCookies(r)),r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},r.send(this.data)}catch(s){this.setTimeoutFn(()=>{this.onError(s)},0);return}typeof document<"u"&&(this.index=me.requestsCount++,me.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=Fo,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete me.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(me.requestsCount=0,me.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",ps);else if(typeof addEventListener=="function"){const n="onpagehide"in ce?"pagehide":"unload";addEventListener(n,ps,!1)}}function ps(){for(let n in me.requests)me.requests.hasOwnProperty(n)&&me.requests[n].abort()}const Bn=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0))(),Ft=ce.WebSocket||ce.MozWebSocket,vs=!0,Uo="arraybuffer",ys=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Io extends Fn{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=ys?{}:os(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=vs&&!ys?t?new Ft(e,t):new Ft(e):new Ft(e,t,r)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],s=t===e.length-1;kn(r,this.supportsBinary,i=>{const o={};try{vs&&this.ws.send(i)}catch{}s&&Bn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=fs()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Ft}}class Vo extends Fn{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{const t=Eo(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),s=wo();s.readable.pipeTo(e.writable),this.writer=s.writable.getWriter();const i=()=>{r.read().then(({done:c,value:l})=>{c||(this.onPacket(l),i())}).catch(c=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],s=t===e.length-1;this.writer.write(r).then(()=>{s&&Bn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}}const jo={websocket:Io,webtransport:Vo,polling:Bo},Mo=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,qo=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Un(n){const e=n,t=n.indexOf("["),r=n.indexOf("]");t!=-1&&r!=-1&&(n=n.substring(0,t)+n.substring(t,r).replace(/:/g,";")+n.substring(r,n.length));let s=Mo.exec(n||""),i={},o=14;for(;o--;)i[qo[o]]=s[o]||"";return t!=-1&&r!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Wo(i,i.path),i.queryKey=Ho(i,i.query),i}function Wo(n,e){const t=/\/{2,9}/g,r=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Ho(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,s,i){s&&(t[s]=i)}),t}class De extends Y{constructor(e,t={}){super(),this.binaryType=Uo,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Un(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=Un(t.host).host),Lt(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=ko(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=is,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new jo[e](r)}open(){let e;if(this.opts.rememberUpgrade&&De.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){let t=this.createTransport(e),r=!1;De.priorWebsocketSuccess=!1;const s=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;De.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(h(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=t.name,this.emitReserved("upgradeError",v)}}))};function i(){r||(r=!0,h(),t.close(),t=null)}const o=f=>{const v=new Error("probe error: "+f);v.transport=t.name,i(),this.emitReserved("upgradeError",v)};function c(){o("transport closed")}function l(){o("socket closed")}function a(f){t&&f.name!==t.name&&i()}const h=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",c),this.off("close",l),this.off("upgrading",a)};t.once("open",s),t.once("error",o),t.once("close",c),this.once("close",l),this.once("upgrading",a),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(this.readyState="open",De.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){const s=this.writeBuffer[r].data;if(s&&(t+=Oo(s)),r>0&&t>this.maxPayload)return this.writeBuffer.slice(0,r);t+=2}return this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,s){if(typeof t=="function"&&(s=t,t=void 0),typeof r=="function"&&(s=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:e,data:t,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),s&&this.once("flush",s),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){De.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const s=e.length;for(;r<s;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}}De.protocol=is;function Jo(n,e="",t){let r=n;t=t||typeof location<"u"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(typeof t<"u"?n=t.protocol+"//"+n:n="https://"+n),r=Un(n)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+e,r.href=r.protocol+"://"+i+(t&&t.port===r.port?"":":"+r.port),r}const Yo=typeof ArrayBuffer=="function",zo=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ms=Object.prototype.toString,Ko=typeof Blob=="function"||typeof Blob<"u"&&ms.call(Blob)==="[object BlobConstructor]",Go=typeof File=="function"||typeof File<"u"&&ms.call(File)==="[object FileConstructor]";function In(n){return Yo&&(n instanceof ArrayBuffer||zo(n))||Ko&&n instanceof Blob||Go&&n instanceof File}function Pt(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,r=n.length;t<r;t++)if(Pt(n[t]))return!0;return!1}if(In(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Pt(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&Pt(n[t]))return!0;return!1}function Xo(n){const e=[],t=n.data,r=n;return r.data=Vn(t,e),r.attachments=e.length,{packet:r,buffers:e}}function Vn(n,e){if(!n)return n;if(In(n)){const t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){const t=new Array(n.length);for(let r=0;r<n.length;r++)t[r]=Vn(n[r],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){const t={};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=Vn(n[r],e));return t}return n}function Qo(n,e){return n.data=jn(n.data,e),delete n.attachments,n}function jn(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=jn(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=jn(n[t],e));return n}const Zo=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],$o=5;var T;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(T||(T={}));class ea{constructor(e){this.replacer=e}encode(e){return(e.type===T.EVENT||e.type===T.ACK)&&Pt(e)?this.encodeAsBinary({type:e.type===T.EVENT?T.BINARY_EVENT:T.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===T.BINARY_EVENT||e.type===T.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Xo(e),r=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(r),s}}function gs(n){return Object.prototype.toString.call(n)==="[object Object]"}class Mn extends Y{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===T.BINARY_EVENT;r||t.type===T.BINARY_ACK?(t.type=r?T.EVENT:T.ACK,this.reconstructor=new ta(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(In(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(T[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===T.BINARY_EVENT||r.type===T.BINARY_ACK){const i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(i,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){const i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(i,t)}else r.nsp="/";const s=e.charAt(t+1);if(s!==""&&Number(s)==s){const i=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}r.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(Mn.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case T.CONNECT:return gs(t);case T.DISCONNECT:return t===void 0;case T.CONNECT_ERROR:return typeof t=="string"||gs(t);case T.EVENT:case T.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Zo.indexOf(t[0])===-1);case T.ACK:case T.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ta{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Qo(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const na=Object.freeze(Object.defineProperty({__proto__:null,protocol:$o,get PacketType(){return T},Encoder:ea,Decoder:Mn},Symbol.toStringTag,{value:"Module"}));function he(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const ra=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class bs extends Y{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[he(e,"open",this.onopen.bind(this)),he(e,"packet",this.onpacket.bind(this)),he(e,"error",this.onerror.bind(this)),he(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(ra.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:T.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const o=this.ids++,c=t.pop();this._registerAckCallback(o,c),r.id=o}const s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var r;const s=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&this.sendBuffer.splice(o,1);t.call(this,new Error("operation has timed out"))},s);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...o])}}emitWithAck(e,...t){const r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((s,i)=>{t.push((o,c)=>r?o?i(o):s(c):s(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...i)=>r!==this._queue[0]?void 0:(s!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(s)):(this._queue.shift(),t&&t(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:T.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case T.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case T.EVENT:case T.BINARY_EVENT:this.onevent(e);break;case T.ACK:case T.BINARY_ACK:this.onack(e);break;case T.DISCONNECT:this.ondisconnect();break;case T.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...s){r||(r=!0,t.packet({type:T.ACK,id:e,data:s}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:T.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}function qe(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}qe.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-t:n+t}return Math.min(n,this.max)|0},qe.prototype.reset=function(){this.attempts=0},qe.prototype.setMin=function(n){this.ms=n},qe.prototype.setMax=function(n){this.max=n},qe.prototype.setJitter=function(n){this.jitter=n};class qn extends Y{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Lt(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new qe({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const s=t.parser||na;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new De(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const s=he(t,"open",function(){r.onopen(),e&&e()}),i=c=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=he(t,"error",i);if(this._timeout!==!1){const c=this._timeout,l=this.setTimeoutFn(()=>{s(),i(new Error("timeout")),t.close()},c);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(s),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(he(e,"ping",this.onping.bind(this)),he(e,"data",this.ondata.bind(this)),he(e,"error",this.onerror.bind(this)),he(e,"close",this.onclose.bind(this)),he(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){Bn(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new bs(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const r of t)if(this.nsps[r].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):e.onreconnect()}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const at={};function Bt(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=Jo(n,e.path||"/socket.io"),r=t.source,s=t.id,i=t.path,o=at[s]&&i in at[s].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let l;return c?l=new qn(r,e):(at[s]||(at[s]=new qn(r,e)),l=at[s]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(Bt,{Manager:qn,Socket:bs,io:Bt,connect:Bt});class sa{constructor(e,t,r,s){Le(this,"socket_port");Le(this,"host");Le(this,"port");Le(this,"protocol");Le(this,"url");Le(this,"site_name");Le(this,"socket");var i,o;this.socket_port=r!=null?r:"9000",this.host=(i=window.location)==null?void 0:i.hostname,this.port=(o=window.location)!=null&&o.port?`:${this.socket_port}`:"",this.protocol=this.port?"http":"https",this.url=e||`${this.protocol}://${this.host}${this.port}`,this.site_name=t,this.socket=Bt(`${this.url}/${this.site_name}`,{withCredentials:!0,secure:this.protocol==="https",extraHeaders:s&&s.useToken===!0?{Authorization:`${s.type} ${s.token}`}:{}})}}var _s={exports:{}},ut={};/**
19
19
  * @license React
20
20
  * react-jsx-runtime.production.min.js
21
21
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "frappe-react-sdk",
3
3
  "description": "React hooks for Frappe Framework",
4
- "version": "1.3.2",
4
+ "version": "1.3.4",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "The Commit Company",