frappe-react-sdk 1.1.5 → 1.1.6
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.
|
@@ -3427,7 +3427,7 @@ class fa {
|
|
|
3427
3427
|
Le(this, "protocol");
|
|
3428
3428
|
Le(this, "url");
|
|
3429
3429
|
Le(this, "socket");
|
|
3430
|
-
this.socket_port = t != null ? t : "9000", this.host = window.location.hostname, this.port = window.location.port ? `:${this.socket_port}` : "", this.protocol = this.port ? "http" : "https", this.url = e
|
|
3430
|
+
this.socket_port = t != null ? t : "9000", this.host = window.location.hostname, this.port = window.location.port ? `:${this.socket_port}` : "", this.protocol = this.port ? "http" : "https", this.url = e || `${this.protocol}://${this.host}${this.port}`, this.socket = kt(this.url, { withCredentials: !0 });
|
|
3431
3431
|
}
|
|
3432
3432
|
}
|
|
3433
3433
|
var ws = { exports: {} }, rt = {};
|
|
@@ -4055,23 +4055,21 @@ const pa = ws.exports.jsx, Q = Nr(null), ba = ({
|
|
|
4055
4055
|
socketPort: t,
|
|
4056
4056
|
children: r
|
|
4057
4057
|
}) => {
|
|
4058
|
-
const s =
|
|
4059
|
-
const
|
|
4058
|
+
const s = Pr(() => {
|
|
4059
|
+
const i = new Ji.FrappeApp(n, e);
|
|
4060
4060
|
return {
|
|
4061
4061
|
url: n,
|
|
4062
4062
|
tokenParams: e,
|
|
4063
|
-
app:
|
|
4064
|
-
auth:
|
|
4065
|
-
db:
|
|
4066
|
-
call:
|
|
4067
|
-
file:
|
|
4063
|
+
app: i,
|
|
4064
|
+
auth: i.auth(),
|
|
4065
|
+
db: i.db(),
|
|
4066
|
+
call: i.call(),
|
|
4067
|
+
file: i.file(),
|
|
4068
|
+
socket: new fa(n, t).socket
|
|
4068
4069
|
};
|
|
4069
4070
|
}, [n, e, t]);
|
|
4070
4071
|
return /* @__PURE__ */ pa(Q.Provider, {
|
|
4071
|
-
value:
|
|
4072
|
-
...i,
|
|
4073
|
-
socket: s.socket
|
|
4074
|
-
},
|
|
4072
|
+
value: s,
|
|
4075
4073
|
children: r
|
|
4076
4074
|
});
|
|
4077
4075
|
}, wa = (n) => {
|
|
@@ -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 Tr;function Oi(){return Tr||(Tr=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=Pe.default,e=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(D){{for(var y=arguments.length,W=new Array(y>1?y-1:0),S=1;S<y;S++)W[S-1]=arguments[S];r("error",D,W)}}function r(D,y,W){{var S=e.ReactDebugCurrentFrame,C=S.getStackAddendum();C!==""&&(y+="%s",W=W.concat([C]));var Q=W.map(function(F){return String(F)});Q.unshift("Warning: "+y),Function.prototype.apply.call(console[D],console,Q)}}function s(D,y){return D===y&&(D!==0||1/D===1/y)||D!==D&&y!==y}var i=typeof Object.is=="function"?Object.is:s,o=n.useState,c=n.useEffect,f=n.useLayoutEffect,a=n.useDebugValue,h=!1,l=!1;function m(D,y,W){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 S=y();if(!l){var C=y();i(S,C)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}var Q=o({inst:{value:S,getSnapshot:y}}),F=Q[0].inst,I=Q[1];return f(function(){F.value=S,F.getSnapshot=y,v(F)&&I({inst:F})},[D,S,y]),c(function(){v(F)&&I({inst:F});var re=function(){v(F)&&I({inst:F})};return D(re)},[D]),a(S),S}function v(D){var y=D.getSnapshot,W=D.value;try{var S=y();return!i(W,S)}catch{return!0}}function w(D,y,W){return y()}var E=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",_=!E,N=_?w:m,R=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:N;fn.useSyncExternalStore=R,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),fn}(function(n){process.env.NODE_ENV==="production"?n.exports=Ti():n.exports=Oi()})(Rr);const ye=new WeakMap,hn={},St={},Oe=()=>{},le=Oe(),dn=Object,L=n=>n===le,ge=n=>typeof n=="function",xe=(n,e)=>({...n,...e}),pn="undefined",Rt=typeof window!=pn,vn=typeof document!=pn,xi=()=>Rt&&typeof window.requestAnimationFrame!=pn,Or=(n,e)=>{const t=ye.get(n);return[()=>!L(e)&&n.get(e)||hn,r=>{if(!L(e)){const s=n.get(e);e in St||(St[e]=s),t[5](e,xe(s,r),s||hn)}},t[6],()=>!L(e)&&e in St?St[e]:!L(e)&&n.get(e)||hn]},Ct=new WeakMap;let Ai=0;const Ze=n=>{const e=typeof n,t=n&&n.constructor,r=t==Date;let s,i;if(dn(n)===n&&!r&&t!=RegExp){if(s=Ct.get(n),s)return s;if(s=++Ai+"~",Ct.set(n,s),t==Array){for(s="@",i=0;i<n.length;i++)s+=Ze(n[i])+",";Ct.set(n,s)}if(t==dn){s="#";const o=dn.keys(n).sort();for(;!L(i=o.pop());)L(n[i])||(s+=i+":"+Ze(n[i])+",");Ct.set(n,s)}}else s=r?n.toJSON():e=="symbol"?n.toString():e=="string"?JSON.stringify(n):""+n;return s};let mn=!0;const ki=()=>mn,[yn,gn]=Rt&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Oe,Oe],Di=()=>{const n=vn&&document.visibilityState;return L(n)||n!=="hidden"},Li=n=>(vn&&document.addEventListener("visibilitychange",n),yn("focus",n),()=>{vn&&document.removeEventListener("visibilitychange",n),gn("focus",n)}),Ni=n=>{const e=()=>{mn=!0,n()},t=()=>{mn=!1};return yn("online",e),yn("offline",t),()=>{gn("online",e),gn("offline",t)}},Fi={isOnline:ki,isVisible:Di},Pi={initFocus:Li,initReconnect:Ni},xr=!Pe.default.useId,$e=!Rt||"Deno"in window,Bi=n=>xi()?window.requestAnimationFrame(n):setTimeout(n,1),_n=$e?d.useEffect:d.useLayoutEffect,bn=typeof navigator<"u"&&navigator.connection,Ar=!$e&&bn&&(["slow-2g","2g"].includes(bn.effectiveType)||bn.saveData),wn=n=>{if(ge(n))try{n=n()}catch{n=""}const e=n;return n=typeof n=="string"?n:(Array.isArray(n)?n.length:n)?Ze(n):"",[n,e]};let Ii=0;const En=()=>++Ii,kr=0,Dr=1,Lr=2;var et={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:kr,MUTATE_EVENT:Lr,RECONNECT_EVENT:Dr};async function Nr(...n){const[e,t,r,s]=n,i=xe({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let o=i.populateCache;const c=i.rollbackOnError;let f=i.optimisticData;const a=i.revalidate!==!1,h=v=>typeof c=="function"?c(v):c!==!1,l=i.throwOnError;if(ge(t)){const v=t,w=[],E=e.keys();for(let _=E.next();!_.done;_=E.next()){const N=_.value;!/^\$(inf|sub)\$/.test(N)&&v(e.get(N)._k)&&w.push(N)}return Promise.all(w.map(m))}return m(t);async function m(v){const[w]=wn(v);if(!w)return;const[E,_]=Or(e,w),[N,R,D]=ye.get(e),y=N[w],W=()=>a&&(delete D[w],y&&y[0])?y[0](Lr).then(()=>E().data):E().data;if(n.length<3)return W();let S=r,C;const Q=En();R[w]=[Q,0];const F=!L(f),I=E(),re=I.data,Z=I._c,V=L(Z)?re:Z;if(F&&(f=ge(f)?f(V):f,_({data:f,_c:V})),ge(S))try{S=S(V)}catch(ue){C=ue}if(S&&ge(S.then))if(S=await S.catch(ue=>{C=ue}),Q!==R[w][0]){if(C)throw C;return S}else C&&F&&h(C)&&(o=!0,S=V,_({data:S,_c:le}));o&&(C||(ge(o)&&(S=o(S,V)),_({data:S,_c:le}))),R[w][1]=En();const $=await W();if(_({_c:le}),C){if(l)throw C;return}return o?$:S}}const Fr=(n,e)=>{for(const t in n)n[t][0]&&n[t][0](e)},Ui=(n,e)=>{if(!ye.has(n)){const t=xe(Pi,e),r={},s=Nr.bind(le,n);let i=Oe;const o={},c=(h,l)=>{const m=o[h]||[];return o[h]=m,m.push(l),()=>m.splice(m.indexOf(l),1)},f=(h,l,m)=>{n.set(h,l);const v=o[h];if(v)for(const w of v)w(l,m)},a=()=>{if(!ye.has(n)&&(ye.set(n,[r,{},{},{},s,f,c]),!$e)){const h=t.initFocus(setTimeout.bind(le,Fr.bind(le,r,kr))),l=t.initReconnect(setTimeout.bind(le,Fr.bind(le,r,Dr)));i=()=>{h&&h(),l&&l(),ye.delete(n)}}};return a(),[n,s,a,i]}return[n,ye.get(n)[4]]},Vi=(n,e,t,r,s)=>{const i=t.errorRetryCount,o=s.retryCount,c=~~((Math.random()+.5)*(1<<(o<8?o:8)))*t.errorRetryInterval;!L(i)&&o>i||setTimeout(r,c,s)},ji=(n,e)=>Ze(n)==Ze(e),[Pr,Mi]=Ui(new Map),Wi=xe({onLoadingSlow:Oe,onSuccess:Oe,onError:Oe,onErrorRetry:Vi,onDiscarded:Oe,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ar?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ar?5e3:3e3,compare:ji,isPaused:()=>!1,cache:Pr,mutate:Mi,fallback:{}},Fi),qi=(n,e)=>{const t=xe(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=xe(s,o))}return t},Hi=d.createContext({}),Br=Rt&&window.__SWR_DEVTOOLS_USE__,Yi=Br?window.__SWR_DEVTOOLS_USE__:[],Ji=()=>{Br&&(window.__SWR_DEVTOOLS_REACT__=Pe.default)},zi=n=>ge(n[1])?[n[0],n[1],n[2]||{}]:[n[0],null,(n[1]===null?n[2]:n[1])||{}],Ki=()=>xe(Wi,d.useContext(Hi)),Gi=n=>(e,t,r)=>n(e,t&&((...i)=>{const[o]=wn(e),[,,,c]=ye.get(Pr),f=c[o];return f?(delete c[o],f):t(...i)}),r),Xi=Yi.concat(Gi),Qi=n=>function(...t){const r=Ki(),[s,i,o]=zi(t),c=qi(r,o);let f=n;const{use:a}=c,h=(a||[]).concat(Xi);for(let l=h.length;l--;)f=h[l](f);return f(s,i||c.fetcher||null,c)},Zi=(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())}};Ji();const Sn={dedupe:!0},tt=Qi((n,e,t)=>{const{cache:r,compare:s,suspense:i,fallbackData:o,revalidateOnMount:c,revalidateIfStale:f,refreshInterval:a,refreshWhenHidden:h,refreshWhenOffline:l,keepPreviousData:m}=t,[v,w,E]=ye.get(r),[_,N]=wn(n),R=d.useRef(!1),D=d.useRef(!1),y=d.useRef(_),W=d.useRef(e),S=d.useRef(t),C=()=>S.current,Q=()=>C().isVisible()&&C().isOnline(),[F,I,re,Z]=Or(r,_),V=d.useRef({}).current,$=L(o)?t.fallback[_]:o,ue=(U,M)=>{for(const z in V){const j=z;if(j==="data"){if(!s(U[j],M[j])&&(!L(U[j])||!s(ct,M[j])))return!1}else if(M[j]!==U[j])return!1}return!0},ot=d.useMemo(()=>{const U=(()=>!_||!e?!1:L(c)?C().isPaused()||i?!1:L(f)?!0:f:c)(),M=K=>{const se=xe(K);return delete se._k,U?{isValidating:!0,isLoading:!0,...se}:se},z=F(),j=Z(),ee=M(z),he=z===j?ee:M(j);let Y=ee;return[()=>{const K=M(F());return ue(K,Y)?(Y.data=K.data,Y.isLoading=K.isLoading,Y.isValidating=K.isValidating,Y.error=K.error,Y):(Y=K,K)},()=>he]},[r,_]),_e=Rr.exports.useSyncExternalStore(d.useCallback(U=>re(_,(M,z)=>{ue(z,M)||U()}),[r,_]),ot[0],ot[1]),at=!R.current,Nt=v[_]&&v[_].length>0,be=_e.data,we=L(be)?$:be,Le=_e.error,ut=d.useRef(we),ct=m?L(be)?ut.current:be:we,Ft=(()=>Nt&&!L(Le)?!1:at&&!L(c)?c:C().isPaused()?!1:i?L(we)?!1:f:L(we)||f)(),je=!!(_&&e&&at&&Ft),lt=L(_e.isValidating)?je:_e.isValidating,Me=L(_e.isLoading)?je:_e.isLoading,Ee=d.useCallback(async U=>{const M=W.current;if(!_||!M||D.current||C().isPaused())return!1;let z,j,ee=!0;const he=U||{},Y=!E[_]||!he.dedupe,K=()=>xr?!D.current&&_===y.current&&R.current:_===y.current,se={isValidating:!1,isLoading:!1},Pt=()=>{I(se)},Bt=()=>{const ie=E[_];ie&&ie[1]===j&&delete E[_]},qe={isValidating:!0};L(F().data)&&(qe.isLoading=!0);try{if(Y&&(I(qe),t.loadingTimeout&&L(F().data)&&setTimeout(()=>{ee&&K()&&C().onLoadingSlow(_,t)},t.loadingTimeout),E[_]=[M(N),En()]),[z,j]=E[_],z=await z,Y&&setTimeout(Bt,t.dedupingInterval),!E[_]||E[_][1]!==j)return Y&&K()&&C().onDiscarded(_),!1;se.error=le;const ie=w[_];if(!L(ie)&&(j<=ie[0]||j<=ie[1]||ie[1]===0))return Pt(),Y&&K()&&C().onDiscarded(_),!1;const de=F().data;se.data=s(de,z)?de:z,Y&&K()&&C().onSuccess(z,_,t)}catch(ie){Bt();const de=C(),{shouldRetryOnError:He}=de;de.isPaused()||(se.error=ie,Y&&K()&&(de.onError(ie,_,de),(He===!0||ge(He)&&He(ie))&&Q()&&de.onErrorRetry(ie,_,de,It=>{const Se=v[_];Se&&Se[0]&&Se[0](et.ERROR_REVALIDATE_EVENT,It)},{retryCount:(he.retryCount||0)+1,dedupe:!0})))}return ee=!1,Pt(),!0},[_,r]),We=d.useCallback((...U)=>Nr(r,y.current,...U),[]);if(_n(()=>{W.current=e,S.current=t,L(be)||(ut.current=be)}),_n(()=>{if(!_)return;const U=Ee.bind(le,Sn);let M=0;const j=Zi(_,v,(ee,he={})=>{if(ee==et.FOCUS_EVENT){const Y=Date.now();C().revalidateOnFocus&&Y>M&&Q()&&(M=Y+C().focusThrottleInterval,U())}else if(ee==et.RECONNECT_EVENT)C().revalidateOnReconnect&&Q()&&U();else{if(ee==et.MUTATE_EVENT)return Ee();if(ee==et.ERROR_REVALIDATE_EVENT)return Ee(he)}});return D.current=!1,y.current=_,R.current=!0,I({_k:N}),Ft&&(L(we)||$e?U():Bi(U)),()=>{D.current=!0,j()}},[_]),_n(()=>{let U;function M(){const j=ge(a)?a(F().data):a;j&&U!==-1&&(U=setTimeout(z,j))}function z(){!F().error&&(h||C().isVisible())&&(l||C().isOnline())?Ee(Sn).then(M):M()}return M(),()=>{U&&(clearTimeout(U),U=-1)}},[a,h,l,_]),d.useDebugValue(ct),i&&L(we)&&_)throw!xr&&$e?new Error("Fallback data is required when using suspense in SSR."):(W.current=e,S.current=t,D.current=!1,L(Le)?Ee(Sn):Le);return{mutate:We,get data(){return V.data=!0,ct},get error(){return V.error=!0,Le},get isValidating(){return V.isValidating=!0,lt},get isLoading(){return V.isLoading=!0,Me}}}),ve=Object.create(null);ve.open="0",ve.close="1",ve.ping="2",ve.pong="3",ve.message="4",ve.upgrade="5",ve.noop="6";const Tt=Object.create(null);Object.keys(ve).forEach(n=>{Tt[ve[n]]=n});const $i={type:"error",data:"parser error"},eo=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",to=typeof ArrayBuffer=="function",no=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Ir=({type:n,data:e},t,r)=>eo&&e instanceof Blob?t?r(e):Ur(e,r):to&&(e instanceof ArrayBuffer||no(e))?t?r(e):Ur(new Blob([e]),r):r(ve[n]+(e||"")),Ur=(n,e)=>{const t=new FileReader;return t.onload=function(){const r=t.result.split(",")[1];e("b"+(r||""))},t.readAsDataURL(n)},Vr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",nt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Vr.length;n++)nt[Vr.charCodeAt(n)]=n;const ro=n=>{let e=n.length*.75,t=n.length,r,s=0,i,o,c,f;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=nt[n.charCodeAt(r)],o=nt[n.charCodeAt(r+1)],c=nt[n.charCodeAt(r+2)],f=nt[n.charCodeAt(r+3)],h[s++]=i<<2|o>>4,h[s++]=(o&15)<<4|c>>2,h[s++]=(c&3)<<6|f&63;return a},so=typeof ArrayBuffer=="function",jr=(n,e)=>{if(typeof n!="string")return{type:"message",data:Mr(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:io(n.substring(1),e)}:Tt[t]?n.length>1?{type:Tt[t],data:n.substring(1)}:{type:Tt[t]}:$i},io=(n,e)=>{if(so){const t=ro(n);return Mr(t,e)}else return{base64:!0,data:n}},Mr=(n,e)=>{switch(e){case"blob":return n instanceof ArrayBuffer?new Blob([n]):n;case"arraybuffer":default:return n}},Wr=String.fromCharCode(30),oo=(n,e)=>{const t=n.length,r=new Array(t);let s=0;n.forEach((i,o)=>{Ir(i,!1,c=>{r[o]=c,++s===t&&e(r.join(Wr))})})},ao=(n,e)=>{const t=n.split(Wr),r=[];for(let s=0;s<t.length;s++){const i=jr(t[s],e);if(r.push(i),i.type==="error")break}return r},qr=4;function H(n){if(n)return uo(n)}function uo(n){for(var e in H.prototype)n[e]=H.prototype[e];return n}H.prototype.on=H.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this},H.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this},H.prototype.off=H.prototype.removeListener=H.prototype.removeAllListeners=H.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},H.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},H.prototype.emitReserved=H.prototype.emit,H.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]},H.prototype.hasListeners=function(n){return!!this.listeners(n).length};const ae=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function Hr(n,...e){return e.reduce((t,r)=>(n.hasOwnProperty(r)&&(t[r]=n[r]),t),{})}const co=ae.setTimeout,lo=ae.clearTimeout;function Ot(n,e){e.useNativeTimers?(n.setTimeoutFn=co.bind(ae),n.clearTimeoutFn=lo.bind(ae)):(n.setTimeoutFn=ae.setTimeout.bind(ae),n.clearTimeoutFn=ae.clearTimeout.bind(ae))}const fo=1.33;function ho(n){return typeof n=="string"?po(n):Math.ceil((n.byteLength||n.size)*fo)}function po(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}class vo extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class Yr extends H{constructor(e){super(),this.writable=!1,Ot(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new vo(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=jr(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}}const Jr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Rn=64,mo={};let zr=0,xt=0,Kr;function Gr(n){let e="";do e=Jr[n%Rn]+e,n=Math.floor(n/Rn);while(n>0);return e}function Xr(){const n=Gr(+new Date);return n!==Kr?(zr=0,Kr=n):n+"."+Gr(zr++)}for(;xt<Rn;xt++)mo[Jr[xt]]=xt;function Qr(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function yo(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}let Zr=!1;try{Zr=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const go=Zr;function $r(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||go))return new XMLHttpRequest}catch{}if(!e)try{return new ae[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function _o(){}const bo=function(){return new $r({xdomain:!1}).responseType!=null}();class wo extends Yr{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,this.xs=e.secure!==r}const t=e&&e.forceBase64;this.supportsBinary=bo&&!t}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)};ao(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,oo(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.query||{};const t=this.opts.secure?"https":"http";let r="";this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=Xr()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.opts.port&&(t==="https"&&Number(this.opts.port)!==443||t==="http"&&Number(this.opts.port)!==80)&&(r=":"+this.opts.port);const s=Qr(e),i=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(i?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+(s.length?"?"+s:"")}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},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 H{constructor(e,t){super(),Ot(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.async=t.async!==!1,this.data=t.data!==void 0?t.data:null,this.create()}create(){const e=Hr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const t=this.xhr=new $r(e);try{t.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(let r in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&t.setRequestHeader(r,this.opts.extraHeaders[r])}}catch{}if(this.method==="POST")try{t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{t.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in t&&(t.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t.timeout=this.opts.requestTimeout),t.onreadystatechange=()=>{t.readyState===4&&(t.status===200||t.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof t.status=="number"?t.status:0)},0))},t.send(this.data)}catch(r){this.setTimeoutFn(()=>{this.onError(r)},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=_o,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",es);else if(typeof addEventListener=="function"){const n="onpagehide"in ae?"pagehide":"unload";addEventListener(n,es,!1)}}function es(){for(let n in me.requests)me.requests.hasOwnProperty(n)&&me.requests[n].abort()}const ts=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0))(),At=ae.WebSocket||ae.MozWebSocket,ns=!0,Eo="arraybuffer",rs=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class So extends Yr{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=rs?{}:Hr(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=ns&&!rs?t?new At(e,t):new At(e):new At(e,t,r)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType||Eo,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;Ir(r,this.supportsBinary,i=>{const o={};try{ns&&this.ws.send(i)}catch{}s&&ts(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?"wss":"ws";let r="";this.opts.port&&(t==="wss"&&Number(this.opts.port)!==443||t==="ws"&&Number(this.opts.port)!==80)&&(r=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=Xr()),this.supportsBinary||(e.b64=1);const s=Qr(e),i=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(i?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+(s.length?"?"+s:"")}check(){return!!At}}const Ro={websocket:So,polling:wo},Co=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,To=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Cn(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=Co.exec(n||""),i={},o=14;for(;o--;)i[To[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=Oo(i,i.path),i.queryKey=xo(i,i.query),i}function Oo(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 xo(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,s,i){s&&(t[s]=i)}),t}class Ae extends H{constructor(e,t={}){super(),this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Cn(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=Cn(t.host).host),Ot(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"],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:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=yo(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=qr,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new Ro[e](r)}open(){let e;if(this.opts.rememberUpgrade&&Ae.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;Ae.priorWebsocketSuccess=!1;const s=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",l=>{if(!r)if(l.type==="pong"&&l.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Ae.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 m=new Error("probe error");m.transport=t.name,this.emitReserved("upgradeError",m)}}))};function i(){r||(r=!0,h(),t.close(),t=null)}const o=l=>{const m=new Error("probe error: "+l);m.transport=t.name,i(),this.emitReserved("upgradeError",m)};function c(){o("transport closed")}function f(){o("socket closed")}function a(l){t&&l.name!==t.name&&i()}const h=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",c),this.off("close",f),this.off("upgrading",a)};t.once("open",s),t.once("error",o),t.once("close",c),this.once("close",f),this.once("upgrading",a),t.open()}onOpen(){if(this.readyState="open",Ae.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"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),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+=ho(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){Ae.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}}Ae.protocol=qr;function Ao(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=Cn(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 ko=typeof ArrayBuffer=="function",Do=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ss=Object.prototype.toString,Lo=typeof Blob=="function"||typeof Blob<"u"&&ss.call(Blob)==="[object BlobConstructor]",No=typeof File=="function"||typeof File<"u"&&ss.call(File)==="[object FileConstructor]";function Tn(n){return ko&&(n instanceof ArrayBuffer||Do(n))||Lo&&n instanceof Blob||No&&n instanceof File}function kt(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,r=n.length;t<r;t++)if(kt(n[t]))return!0;return!1}if(Tn(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return kt(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&kt(n[t]))return!0;return!1}function Fo(n){const e=[],t=n.data,r=n;return r.data=On(t,e),r.attachments=e.length,{packet:r,buffers:e}}function On(n,e){if(!n)return n;if(Tn(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]=On(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]=On(n[r],e));return t}return n}function Po(n,e){return n.data=xn(n.data,e),delete n.attachments,n}function xn(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]=xn(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=xn(n[t],e));return n}const Bo=5;var O;(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"})(O||(O={}));class Io{constructor(e){this.replacer=e}encode(e){return(e.type===O.EVENT||e.type===O.ACK)&&kt(e)?this.encodeAsBinary({type:e.type===O.EVENT?O.BINARY_EVENT:O.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===O.BINARY_EVENT||e.type===O.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=Fo(e),r=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(r),s}}class An extends H{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===O.BINARY_EVENT;r||t.type===O.BINARY_ACK?(t.type=r?O.EVENT:O.ACK,this.reconstructor=new Uo(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Tn(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(O[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===O.BINARY_EVENT||r.type===O.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(An.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 O.CONNECT:return typeof t=="object";case O.DISCONNECT:return t===void 0;case O.CONNECT_ERROR:return typeof t=="string"||typeof t=="object";case O.EVENT:case O.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="string"||typeof t[0]=="number");case O.ACK:case O.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Uo{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=Po(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Vo=Object.freeze(Object.defineProperty({__proto__:null,protocol:Bo,get PacketType(){return O},Encoder:Io,Decoder:An},Symbol.toStringTag,{value:"Module"}));function fe(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const jo=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class is extends H{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=[fe(e,"open",this.onopen.bind(this)),fe(e,"packet",this.onpacket.bind(this)),fe(e,"error",this.onerror.bind(this)),fe(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(jo.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:O.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:O.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 O.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 O.EVENT:case O.BINARY_EVENT:this.onevent(e);break;case O.ACK:case O.BINARY_ACK:this.onack(e);break;case O.DISCONNECT:this.ondisconnect();break;case O.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:O.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:O.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 Ve(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}Ve.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},Ve.prototype.reset=function(){this.attempts=0},Ve.prototype.setMin=function(n){this.ms=n},Ve.prototype.setMax=function(n){this.max=n},Ve.prototype.setJitter=function(n){this.jitter=n};class kn extends H{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,Ot(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 Ve({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||Vo;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 Ae(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const s=fe(t,"open",function(){r.onopen(),e&&e()}),i=fe(t,"error",o=>{r.cleanup(),r._readyState="closed",this.emitReserved("error",o),e?e(o):r.maybeReconnectOnOpen()});if(this._timeout!==!1){const o=this._timeout;o===0&&s();const c=this.setTimeoutFn(()=>{s(),t.close(),t.emit("error",new Error("timeout"))},o);this.opts.autoUnref&&c.unref(),this.subs.push(function(){clearTimeout(c)})}return this.subs.push(s),this.subs.push(i),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(fe(e,"ping",this.onping.bind(this)),fe(e,"data",this.ondata.bind(this)),fe(e,"error",this.onerror.bind(this)),fe(e,"close",this.onclose.bind(this)),fe(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){ts(()=>{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 is(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(function(){clearTimeout(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const rt={};function Dt(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=Ao(n,e.path||"/socket.io"),r=t.source,s=t.id,i=t.path,o=rt[s]&&i in rt[s].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let f;return c?f=new kn(r,e):(rt[s]||(rt[s]=new kn(r,e)),f=rt[s]),t.query&&!e.query&&(e.query=t.queryKey),f.socket(t.path,e)}Object.assign(Dt,{Manager:kn,Socket:is,io:Dt,connect:Dt});class Mo{constructor(e,t){Ne(this,"socket_port");Ne(this,"host");Ne(this,"port");Ne(this,"protocol");Ne(this,"url");Ne(this,"socket");this.socket_port=t!=null?t:"9000",this.host=window.location.hostname,this.port=window.location.port?`:${this.socket_port}`:"",this.protocol=this.port?"http":"https",this.url=e!=null?e:`${this.protocol}://${this.host}${this.port}`,this.socket=Dt(this.url,{withCredentials:!0})}}var os={exports:{}},st={};/**
|
|
18
|
+
*/var Tr;function Oi(){return Tr||(Tr=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=Pe.default,e=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(D){{for(var y=arguments.length,W=new Array(y>1?y-1:0),S=1;S<y;S++)W[S-1]=arguments[S];r("error",D,W)}}function r(D,y,W){{var S=e.ReactDebugCurrentFrame,C=S.getStackAddendum();C!==""&&(y+="%s",W=W.concat([C]));var Q=W.map(function(F){return String(F)});Q.unshift("Warning: "+y),Function.prototype.apply.call(console[D],console,Q)}}function s(D,y){return D===y&&(D!==0||1/D===1/y)||D!==D&&y!==y}var i=typeof Object.is=="function"?Object.is:s,o=n.useState,c=n.useEffect,f=n.useLayoutEffect,a=n.useDebugValue,h=!1,l=!1;function m(D,y,W){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 S=y();if(!l){var C=y();i(S,C)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}var Q=o({inst:{value:S,getSnapshot:y}}),F=Q[0].inst,I=Q[1];return f(function(){F.value=S,F.getSnapshot=y,v(F)&&I({inst:F})},[D,S,y]),c(function(){v(F)&&I({inst:F});var re=function(){v(F)&&I({inst:F})};return D(re)},[D]),a(S),S}function v(D){var y=D.getSnapshot,W=D.value;try{var S=y();return!i(W,S)}catch{return!0}}function w(D,y,W){return y()}var E=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",_=!E,N=_?w:m,R=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:N;fn.useSyncExternalStore=R,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),fn}(function(n){process.env.NODE_ENV==="production"?n.exports=Ti():n.exports=Oi()})(Rr);const ye=new WeakMap,hn={},St={},Oe=()=>{},le=Oe(),dn=Object,L=n=>n===le,ge=n=>typeof n=="function",xe=(n,e)=>({...n,...e}),pn="undefined",Rt=typeof window!=pn,vn=typeof document!=pn,xi=()=>Rt&&typeof window.requestAnimationFrame!=pn,Or=(n,e)=>{const t=ye.get(n);return[()=>!L(e)&&n.get(e)||hn,r=>{if(!L(e)){const s=n.get(e);e in St||(St[e]=s),t[5](e,xe(s,r),s||hn)}},t[6],()=>!L(e)&&e in St?St[e]:!L(e)&&n.get(e)||hn]},Ct=new WeakMap;let Ai=0;const Ze=n=>{const e=typeof n,t=n&&n.constructor,r=t==Date;let s,i;if(dn(n)===n&&!r&&t!=RegExp){if(s=Ct.get(n),s)return s;if(s=++Ai+"~",Ct.set(n,s),t==Array){for(s="@",i=0;i<n.length;i++)s+=Ze(n[i])+",";Ct.set(n,s)}if(t==dn){s="#";const o=dn.keys(n).sort();for(;!L(i=o.pop());)L(n[i])||(s+=i+":"+Ze(n[i])+",");Ct.set(n,s)}}else s=r?n.toJSON():e=="symbol"?n.toString():e=="string"?JSON.stringify(n):""+n;return s};let mn=!0;const ki=()=>mn,[yn,gn]=Rt&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Oe,Oe],Di=()=>{const n=vn&&document.visibilityState;return L(n)||n!=="hidden"},Li=n=>(vn&&document.addEventListener("visibilitychange",n),yn("focus",n),()=>{vn&&document.removeEventListener("visibilitychange",n),gn("focus",n)}),Ni=n=>{const e=()=>{mn=!0,n()},t=()=>{mn=!1};return yn("online",e),yn("offline",t),()=>{gn("online",e),gn("offline",t)}},Fi={isOnline:ki,isVisible:Di},Pi={initFocus:Li,initReconnect:Ni},xr=!Pe.default.useId,$e=!Rt||"Deno"in window,Bi=n=>xi()?window.requestAnimationFrame(n):setTimeout(n,1),_n=$e?d.useEffect:d.useLayoutEffect,bn=typeof navigator<"u"&&navigator.connection,Ar=!$e&&bn&&(["slow-2g","2g"].includes(bn.effectiveType)||bn.saveData),wn=n=>{if(ge(n))try{n=n()}catch{n=""}const e=n;return n=typeof n=="string"?n:(Array.isArray(n)?n.length:n)?Ze(n):"",[n,e]};let Ii=0;const En=()=>++Ii,kr=0,Dr=1,Lr=2;var et={__proto__:null,ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:kr,MUTATE_EVENT:Lr,RECONNECT_EVENT:Dr};async function Nr(...n){const[e,t,r,s]=n,i=xe({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let o=i.populateCache;const c=i.rollbackOnError;let f=i.optimisticData;const a=i.revalidate!==!1,h=v=>typeof c=="function"?c(v):c!==!1,l=i.throwOnError;if(ge(t)){const v=t,w=[],E=e.keys();for(let _=E.next();!_.done;_=E.next()){const N=_.value;!/^\$(inf|sub)\$/.test(N)&&v(e.get(N)._k)&&w.push(N)}return Promise.all(w.map(m))}return m(t);async function m(v){const[w]=wn(v);if(!w)return;const[E,_]=Or(e,w),[N,R,D]=ye.get(e),y=N[w],W=()=>a&&(delete D[w],y&&y[0])?y[0](Lr).then(()=>E().data):E().data;if(n.length<3)return W();let S=r,C;const Q=En();R[w]=[Q,0];const F=!L(f),I=E(),re=I.data,Z=I._c,V=L(Z)?re:Z;if(F&&(f=ge(f)?f(V):f,_({data:f,_c:V})),ge(S))try{S=S(V)}catch(ue){C=ue}if(S&&ge(S.then))if(S=await S.catch(ue=>{C=ue}),Q!==R[w][0]){if(C)throw C;return S}else C&&F&&h(C)&&(o=!0,S=V,_({data:S,_c:le}));o&&(C||(ge(o)&&(S=o(S,V)),_({data:S,_c:le}))),R[w][1]=En();const $=await W();if(_({_c:le}),C){if(l)throw C;return}return o?$:S}}const Fr=(n,e)=>{for(const t in n)n[t][0]&&n[t][0](e)},Ui=(n,e)=>{if(!ye.has(n)){const t=xe(Pi,e),r={},s=Nr.bind(le,n);let i=Oe;const o={},c=(h,l)=>{const m=o[h]||[];return o[h]=m,m.push(l),()=>m.splice(m.indexOf(l),1)},f=(h,l,m)=>{n.set(h,l);const v=o[h];if(v)for(const w of v)w(l,m)},a=()=>{if(!ye.has(n)&&(ye.set(n,[r,{},{},{},s,f,c]),!$e)){const h=t.initFocus(setTimeout.bind(le,Fr.bind(le,r,kr))),l=t.initReconnect(setTimeout.bind(le,Fr.bind(le,r,Dr)));i=()=>{h&&h(),l&&l(),ye.delete(n)}}};return a(),[n,s,a,i]}return[n,ye.get(n)[4]]},Vi=(n,e,t,r,s)=>{const i=t.errorRetryCount,o=s.retryCount,c=~~((Math.random()+.5)*(1<<(o<8?o:8)))*t.errorRetryInterval;!L(i)&&o>i||setTimeout(r,c,s)},ji=(n,e)=>Ze(n)==Ze(e),[Pr,Mi]=Ui(new Map),Wi=xe({onLoadingSlow:Oe,onSuccess:Oe,onError:Oe,onErrorRetry:Vi,onDiscarded:Oe,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ar?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ar?5e3:3e3,compare:ji,isPaused:()=>!1,cache:Pr,mutate:Mi,fallback:{}},Fi),qi=(n,e)=>{const t=xe(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=xe(s,o))}return t},Hi=d.createContext({}),Br=Rt&&window.__SWR_DEVTOOLS_USE__,Yi=Br?window.__SWR_DEVTOOLS_USE__:[],Ji=()=>{Br&&(window.__SWR_DEVTOOLS_REACT__=Pe.default)},zi=n=>ge(n[1])?[n[0],n[1],n[2]||{}]:[n[0],null,(n[1]===null?n[2]:n[1])||{}],Ki=()=>xe(Wi,d.useContext(Hi)),Gi=n=>(e,t,r)=>n(e,t&&((...i)=>{const[o]=wn(e),[,,,c]=ye.get(Pr),f=c[o];return f?(delete c[o],f):t(...i)}),r),Xi=Yi.concat(Gi),Qi=n=>function(...t){const r=Ki(),[s,i,o]=zi(t),c=qi(r,o);let f=n;const{use:a}=c,h=(a||[]).concat(Xi);for(let l=h.length;l--;)f=h[l](f);return f(s,i||c.fetcher||null,c)},Zi=(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())}};Ji();const Sn={dedupe:!0},tt=Qi((n,e,t)=>{const{cache:r,compare:s,suspense:i,fallbackData:o,revalidateOnMount:c,revalidateIfStale:f,refreshInterval:a,refreshWhenHidden:h,refreshWhenOffline:l,keepPreviousData:m}=t,[v,w,E]=ye.get(r),[_,N]=wn(n),R=d.useRef(!1),D=d.useRef(!1),y=d.useRef(_),W=d.useRef(e),S=d.useRef(t),C=()=>S.current,Q=()=>C().isVisible()&&C().isOnline(),[F,I,re,Z]=Or(r,_),V=d.useRef({}).current,$=L(o)?t.fallback[_]:o,ue=(U,M)=>{for(const z in V){const j=z;if(j==="data"){if(!s(U[j],M[j])&&(!L(U[j])||!s(ct,M[j])))return!1}else if(M[j]!==U[j])return!1}return!0},ot=d.useMemo(()=>{const U=(()=>!_||!e?!1:L(c)?C().isPaused()||i?!1:L(f)?!0:f:c)(),M=K=>{const se=xe(K);return delete se._k,U?{isValidating:!0,isLoading:!0,...se}:se},z=F(),j=Z(),ee=M(z),he=z===j?ee:M(j);let Y=ee;return[()=>{const K=M(F());return ue(K,Y)?(Y.data=K.data,Y.isLoading=K.isLoading,Y.isValidating=K.isValidating,Y.error=K.error,Y):(Y=K,K)},()=>he]},[r,_]),_e=Rr.exports.useSyncExternalStore(d.useCallback(U=>re(_,(M,z)=>{ue(z,M)||U()}),[r,_]),ot[0],ot[1]),at=!R.current,Nt=v[_]&&v[_].length>0,be=_e.data,we=L(be)?$:be,Le=_e.error,ut=d.useRef(we),ct=m?L(be)?ut.current:be:we,Ft=(()=>Nt&&!L(Le)?!1:at&&!L(c)?c:C().isPaused()?!1:i?L(we)?!1:f:L(we)||f)(),je=!!(_&&e&&at&&Ft),lt=L(_e.isValidating)?je:_e.isValidating,Me=L(_e.isLoading)?je:_e.isLoading,Ee=d.useCallback(async U=>{const M=W.current;if(!_||!M||D.current||C().isPaused())return!1;let z,j,ee=!0;const he=U||{},Y=!E[_]||!he.dedupe,K=()=>xr?!D.current&&_===y.current&&R.current:_===y.current,se={isValidating:!1,isLoading:!1},Pt=()=>{I(se)},Bt=()=>{const ie=E[_];ie&&ie[1]===j&&delete E[_]},qe={isValidating:!0};L(F().data)&&(qe.isLoading=!0);try{if(Y&&(I(qe),t.loadingTimeout&&L(F().data)&&setTimeout(()=>{ee&&K()&&C().onLoadingSlow(_,t)},t.loadingTimeout),E[_]=[M(N),En()]),[z,j]=E[_],z=await z,Y&&setTimeout(Bt,t.dedupingInterval),!E[_]||E[_][1]!==j)return Y&&K()&&C().onDiscarded(_),!1;se.error=le;const ie=w[_];if(!L(ie)&&(j<=ie[0]||j<=ie[1]||ie[1]===0))return Pt(),Y&&K()&&C().onDiscarded(_),!1;const de=F().data;se.data=s(de,z)?de:z,Y&&K()&&C().onSuccess(z,_,t)}catch(ie){Bt();const de=C(),{shouldRetryOnError:He}=de;de.isPaused()||(se.error=ie,Y&&K()&&(de.onError(ie,_,de),(He===!0||ge(He)&&He(ie))&&Q()&&de.onErrorRetry(ie,_,de,It=>{const Se=v[_];Se&&Se[0]&&Se[0](et.ERROR_REVALIDATE_EVENT,It)},{retryCount:(he.retryCount||0)+1,dedupe:!0})))}return ee=!1,Pt(),!0},[_,r]),We=d.useCallback((...U)=>Nr(r,y.current,...U),[]);if(_n(()=>{W.current=e,S.current=t,L(be)||(ut.current=be)}),_n(()=>{if(!_)return;const U=Ee.bind(le,Sn);let M=0;const j=Zi(_,v,(ee,he={})=>{if(ee==et.FOCUS_EVENT){const Y=Date.now();C().revalidateOnFocus&&Y>M&&Q()&&(M=Y+C().focusThrottleInterval,U())}else if(ee==et.RECONNECT_EVENT)C().revalidateOnReconnect&&Q()&&U();else{if(ee==et.MUTATE_EVENT)return Ee();if(ee==et.ERROR_REVALIDATE_EVENT)return Ee(he)}});return D.current=!1,y.current=_,R.current=!0,I({_k:N}),Ft&&(L(we)||$e?U():Bi(U)),()=>{D.current=!0,j()}},[_]),_n(()=>{let U;function M(){const j=ge(a)?a(F().data):a;j&&U!==-1&&(U=setTimeout(z,j))}function z(){!F().error&&(h||C().isVisible())&&(l||C().isOnline())?Ee(Sn).then(M):M()}return M(),()=>{U&&(clearTimeout(U),U=-1)}},[a,h,l,_]),d.useDebugValue(ct),i&&L(we)&&_)throw!xr&&$e?new Error("Fallback data is required when using suspense in SSR."):(W.current=e,S.current=t,D.current=!1,L(Le)?Ee(Sn):Le);return{mutate:We,get data(){return V.data=!0,ct},get error(){return V.error=!0,Le},get isValidating(){return V.isValidating=!0,lt},get isLoading(){return V.isLoading=!0,Me}}}),ve=Object.create(null);ve.open="0",ve.close="1",ve.ping="2",ve.pong="3",ve.message="4",ve.upgrade="5",ve.noop="6";const Tt=Object.create(null);Object.keys(ve).forEach(n=>{Tt[ve[n]]=n});const $i={type:"error",data:"parser error"},eo=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",to=typeof ArrayBuffer=="function",no=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Ir=({type:n,data:e},t,r)=>eo&&e instanceof Blob?t?r(e):Ur(e,r):to&&(e instanceof ArrayBuffer||no(e))?t?r(e):Ur(new Blob([e]),r):r(ve[n]+(e||"")),Ur=(n,e)=>{const t=new FileReader;return t.onload=function(){const r=t.result.split(",")[1];e("b"+(r||""))},t.readAsDataURL(n)},Vr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",nt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Vr.length;n++)nt[Vr.charCodeAt(n)]=n;const ro=n=>{let e=n.length*.75,t=n.length,r,s=0,i,o,c,f;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=nt[n.charCodeAt(r)],o=nt[n.charCodeAt(r+1)],c=nt[n.charCodeAt(r+2)],f=nt[n.charCodeAt(r+3)],h[s++]=i<<2|o>>4,h[s++]=(o&15)<<4|c>>2,h[s++]=(c&3)<<6|f&63;return a},so=typeof ArrayBuffer=="function",jr=(n,e)=>{if(typeof n!="string")return{type:"message",data:Mr(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:io(n.substring(1),e)}:Tt[t]?n.length>1?{type:Tt[t],data:n.substring(1)}:{type:Tt[t]}:$i},io=(n,e)=>{if(so){const t=ro(n);return Mr(t,e)}else return{base64:!0,data:n}},Mr=(n,e)=>{switch(e){case"blob":return n instanceof ArrayBuffer?new Blob([n]):n;case"arraybuffer":default:return n}},Wr=String.fromCharCode(30),oo=(n,e)=>{const t=n.length,r=new Array(t);let s=0;n.forEach((i,o)=>{Ir(i,!1,c=>{r[o]=c,++s===t&&e(r.join(Wr))})})},ao=(n,e)=>{const t=n.split(Wr),r=[];for(let s=0;s<t.length;s++){const i=jr(t[s],e);if(r.push(i),i.type==="error")break}return r},qr=4;function H(n){if(n)return uo(n)}function uo(n){for(var e in H.prototype)n[e]=H.prototype[e];return n}H.prototype.on=H.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this},H.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this},H.prototype.off=H.prototype.removeListener=H.prototype.removeAllListeners=H.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},H.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},H.prototype.emitReserved=H.prototype.emit,H.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]},H.prototype.hasListeners=function(n){return!!this.listeners(n).length};const ae=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function Hr(n,...e){return e.reduce((t,r)=>(n.hasOwnProperty(r)&&(t[r]=n[r]),t),{})}const co=ae.setTimeout,lo=ae.clearTimeout;function Ot(n,e){e.useNativeTimers?(n.setTimeoutFn=co.bind(ae),n.clearTimeoutFn=lo.bind(ae)):(n.setTimeoutFn=ae.setTimeout.bind(ae),n.clearTimeoutFn=ae.clearTimeout.bind(ae))}const fo=1.33;function ho(n){return typeof n=="string"?po(n):Math.ceil((n.byteLength||n.size)*fo)}function po(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}class vo extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class Yr extends H{constructor(e){super(),this.writable=!1,Ot(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new vo(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=jr(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}}const Jr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Rn=64,mo={};let zr=0,xt=0,Kr;function Gr(n){let e="";do e=Jr[n%Rn]+e,n=Math.floor(n/Rn);while(n>0);return e}function Xr(){const n=Gr(+new Date);return n!==Kr?(zr=0,Kr=n):n+"."+Gr(zr++)}for(;xt<Rn;xt++)mo[Jr[xt]]=xt;function Qr(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function yo(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}let Zr=!1;try{Zr=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const go=Zr;function $r(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||go))return new XMLHttpRequest}catch{}if(!e)try{return new ae[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function _o(){}const bo=function(){return new $r({xdomain:!1}).responseType!=null}();class wo extends Yr{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,this.xs=e.secure!==r}const t=e&&e.forceBase64;this.supportsBinary=bo&&!t}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)};ao(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,oo(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.query||{};const t=this.opts.secure?"https":"http";let r="";this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=Xr()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.opts.port&&(t==="https"&&Number(this.opts.port)!==443||t==="http"&&Number(this.opts.port)!==80)&&(r=":"+this.opts.port);const s=Qr(e),i=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(i?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+(s.length?"?"+s:"")}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},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 H{constructor(e,t){super(),Ot(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.async=t.async!==!1,this.data=t.data!==void 0?t.data:null,this.create()}create(){const e=Hr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const t=this.xhr=new $r(e);try{t.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(let r in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&t.setRequestHeader(r,this.opts.extraHeaders[r])}}catch{}if(this.method==="POST")try{t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{t.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in t&&(t.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t.timeout=this.opts.requestTimeout),t.onreadystatechange=()=>{t.readyState===4&&(t.status===200||t.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof t.status=="number"?t.status:0)},0))},t.send(this.data)}catch(r){this.setTimeoutFn(()=>{this.onError(r)},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=_o,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",es);else if(typeof addEventListener=="function"){const n="onpagehide"in ae?"pagehide":"unload";addEventListener(n,es,!1)}}function es(){for(let n in me.requests)me.requests.hasOwnProperty(n)&&me.requests[n].abort()}const ts=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0))(),At=ae.WebSocket||ae.MozWebSocket,ns=!0,Eo="arraybuffer",rs=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class So extends Yr{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=rs?{}:Hr(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=ns&&!rs?t?new At(e,t):new At(e):new At(e,t,r)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType||Eo,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;Ir(r,this.supportsBinary,i=>{const o={};try{ns&&this.ws.send(i)}catch{}s&&ts(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?"wss":"ws";let r="";this.opts.port&&(t==="wss"&&Number(this.opts.port)!==443||t==="ws"&&Number(this.opts.port)!==80)&&(r=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=Xr()),this.supportsBinary||(e.b64=1);const s=Qr(e),i=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(i?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+(s.length?"?"+s:"")}check(){return!!At}}const Ro={websocket:So,polling:wo},Co=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,To=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Cn(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=Co.exec(n||""),i={},o=14;for(;o--;)i[To[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=Oo(i,i.path),i.queryKey=xo(i,i.query),i}function Oo(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 xo(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,s,i){s&&(t[s]=i)}),t}class Ae extends H{constructor(e,t={}){super(),this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Cn(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=Cn(t.host).host),Ot(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"],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:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=yo(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=qr,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new Ro[e](r)}open(){let e;if(this.opts.rememberUpgrade&&Ae.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;Ae.priorWebsocketSuccess=!1;const s=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",l=>{if(!r)if(l.type==="pong"&&l.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Ae.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 m=new Error("probe error");m.transport=t.name,this.emitReserved("upgradeError",m)}}))};function i(){r||(r=!0,h(),t.close(),t=null)}const o=l=>{const m=new Error("probe error: "+l);m.transport=t.name,i(),this.emitReserved("upgradeError",m)};function c(){o("transport closed")}function f(){o("socket closed")}function a(l){t&&l.name!==t.name&&i()}const h=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",c),this.off("close",f),this.off("upgrading",a)};t.once("open",s),t.once("error",o),t.once("close",c),this.once("close",f),this.once("upgrading",a),t.open()}onOpen(){if(this.readyState="open",Ae.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"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),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+=ho(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){Ae.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}}Ae.protocol=qr;function Ao(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=Cn(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 ko=typeof ArrayBuffer=="function",Do=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ss=Object.prototype.toString,Lo=typeof Blob=="function"||typeof Blob<"u"&&ss.call(Blob)==="[object BlobConstructor]",No=typeof File=="function"||typeof File<"u"&&ss.call(File)==="[object FileConstructor]";function Tn(n){return ko&&(n instanceof ArrayBuffer||Do(n))||Lo&&n instanceof Blob||No&&n instanceof File}function kt(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,r=n.length;t<r;t++)if(kt(n[t]))return!0;return!1}if(Tn(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return kt(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&kt(n[t]))return!0;return!1}function Fo(n){const e=[],t=n.data,r=n;return r.data=On(t,e),r.attachments=e.length,{packet:r,buffers:e}}function On(n,e){if(!n)return n;if(Tn(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]=On(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]=On(n[r],e));return t}return n}function Po(n,e){return n.data=xn(n.data,e),delete n.attachments,n}function xn(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]=xn(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=xn(n[t],e));return n}const Bo=5;var O;(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"})(O||(O={}));class Io{constructor(e){this.replacer=e}encode(e){return(e.type===O.EVENT||e.type===O.ACK)&&kt(e)?this.encodeAsBinary({type:e.type===O.EVENT?O.BINARY_EVENT:O.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===O.BINARY_EVENT||e.type===O.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=Fo(e),r=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(r),s}}class An extends H{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===O.BINARY_EVENT;r||t.type===O.BINARY_ACK?(t.type=r?O.EVENT:O.ACK,this.reconstructor=new Uo(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Tn(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(O[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===O.BINARY_EVENT||r.type===O.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(An.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 O.CONNECT:return typeof t=="object";case O.DISCONNECT:return t===void 0;case O.CONNECT_ERROR:return typeof t=="string"||typeof t=="object";case O.EVENT:case O.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="string"||typeof t[0]=="number");case O.ACK:case O.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Uo{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=Po(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Vo=Object.freeze(Object.defineProperty({__proto__:null,protocol:Bo,get PacketType(){return O},Encoder:Io,Decoder:An},Symbol.toStringTag,{value:"Module"}));function fe(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const jo=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class is extends H{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=[fe(e,"open",this.onopen.bind(this)),fe(e,"packet",this.onpacket.bind(this)),fe(e,"error",this.onerror.bind(this)),fe(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(jo.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:O.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:O.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 O.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 O.EVENT:case O.BINARY_EVENT:this.onevent(e);break;case O.ACK:case O.BINARY_ACK:this.onack(e);break;case O.DISCONNECT:this.ondisconnect();break;case O.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:O.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:O.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 Ve(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}Ve.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},Ve.prototype.reset=function(){this.attempts=0},Ve.prototype.setMin=function(n){this.ms=n},Ve.prototype.setMax=function(n){this.max=n},Ve.prototype.setJitter=function(n){this.jitter=n};class kn extends H{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,Ot(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 Ve({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||Vo;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 Ae(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const s=fe(t,"open",function(){r.onopen(),e&&e()}),i=fe(t,"error",o=>{r.cleanup(),r._readyState="closed",this.emitReserved("error",o),e?e(o):r.maybeReconnectOnOpen()});if(this._timeout!==!1){const o=this._timeout;o===0&&s();const c=this.setTimeoutFn(()=>{s(),t.close(),t.emit("error",new Error("timeout"))},o);this.opts.autoUnref&&c.unref(),this.subs.push(function(){clearTimeout(c)})}return this.subs.push(s),this.subs.push(i),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(fe(e,"ping",this.onping.bind(this)),fe(e,"data",this.ondata.bind(this)),fe(e,"error",this.onerror.bind(this)),fe(e,"close",this.onclose.bind(this)),fe(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){ts(()=>{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 is(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(function(){clearTimeout(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const rt={};function Dt(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=Ao(n,e.path||"/socket.io"),r=t.source,s=t.id,i=t.path,o=rt[s]&&i in rt[s].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let f;return c?f=new kn(r,e):(rt[s]||(rt[s]=new kn(r,e)),f=rt[s]),t.query&&!e.query&&(e.query=t.queryKey),f.socket(t.path,e)}Object.assign(Dt,{Manager:kn,Socket:is,io:Dt,connect:Dt});class Mo{constructor(e,t){Ne(this,"socket_port");Ne(this,"host");Ne(this,"port");Ne(this,"protocol");Ne(this,"url");Ne(this,"socket");this.socket_port=t!=null?t:"9000",this.host=window.location.hostname,this.port=window.location.port?`:${this.socket_port}`:"",this.protocol=this.port?"http":"https",this.url=e||`${this.protocol}://${this.host}${this.port}`,this.socket=Dt(this.url,{withCredentials:!0})}}var os={exports:{}},st={};/**
|
|
19
19
|
* @license React
|
|
20
20
|
* react-jsx-runtime.production.min.js
|
|
21
21
|
*
|
|
@@ -41,4 +41,4 @@ Check the render method of \``+u+"`."}return""}}function va(u){{if(u!==void 0){v
|
|
|
41
41
|
|
|
42
42
|
Check your code at `+p+":"+g+"."}return""}}var ms={};function ma(u){{var p=vs();if(!p){var g=typeof u=="string"?u:u.displayName||u.name;g&&(p=`
|
|
43
43
|
|
|
44
|
-
Check the top-level render call using <`+g+">.")}return p}}function ys(u,p){{if(!u._store||u._store.validated||u.key!=null)return;u._store.validated=!0;var g=ma(p);if(ms[g])return;ms[g]=!0;var b="";u&&u._owner&&u._owner!==Ln.current&&(b=" It was passed a child from "+V(u._owner.type)+"."),Ye(u),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,b),Ye(null)}}function gs(u,p){{if(typeof u!="object")return;if(qe(u))for(var g=0;g<u.length;g++){var b=u[g];Fn(b)&&ys(b,p)}else if(Fn(u))u._store&&(u._store.validated=!0);else if(u){var k=_(u);if(typeof k=="function"&&k!==u.entries)for(var P=k.call(u),x;!(x=P.next()).done;)Fn(x.value)&&ys(x.value,p)}}}function ya(u){{var p=u.type;if(p==null||typeof p=="string")return;var g;if(typeof p=="function")g=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===f||p.$$typeof===l))g=p.propTypes;else return;if(g){var b=V(p);Pt(g,u.props,"prop",b,u)}else if(p.PropTypes!==void 0&&!Nn){Nn=!0;var k=V(p);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ga(u){{for(var p=Object.keys(u.props),g=0;g<p.length;g++){var b=p[g];if(b!=="children"&&b!=="key"){Ye(u),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),Ye(null);break}}u.ref!==null&&(Ye(u),R("Invalid attribute `ref` supplied to `React.Fragment`."),Ye(null))}}function _s(u,p,g,b,k,P){{var x=I(u);if(!x){var T="";(u===void 0||typeof u=="object"&&u!==null&&Object.keys(u).length===0)&&(T+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var te=va(k);te?T+=te:T+=vs();var q;u===null?q="null":qe(u)?q="array":u!==void 0&&u.$$typeof===e?(q="<"+(V(u.type)||"Unknown")+" />",T=" Did you accidentally export a JSX literal instead of a component?"):q=typeof u,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",q,T)}var J=pa(u,p,g,k,P);if(J==null)return J;if(x){var ce=p.children;if(ce!==void 0)if(b)if(qe(ce)){for(var Je=0;Je<ce.length;Je++)gs(ce[Je],u);Object.freeze&&Object.freeze(ce)}else R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else gs(ce,u)}return u===r?ga(J):ya(J),J}}function _a(u,p,g){return _s(u,p,g,!0)}function ba(u,p,g){return _s(u,p,g,!1)}var wa=ba,Ea=_a;it.Fragment=r,it.jsx=wa,it.jsxs=Ea}()),it}(function(n){process.env.NODE_ENV==="production"?n.exports=Wo():n.exports=qo()})(os);const Ho=os.exports.jsx,X=d.createContext(null),Yo=({url:n="",tokenParams:e,socketPort:t,children:r})=>{const s=
|
|
44
|
+
Check the top-level render call using <`+g+">.")}return p}}function ys(u,p){{if(!u._store||u._store.validated||u.key!=null)return;u._store.validated=!0;var g=ma(p);if(ms[g])return;ms[g]=!0;var b="";u&&u._owner&&u._owner!==Ln.current&&(b=" It was passed a child from "+V(u._owner.type)+"."),Ye(u),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,b),Ye(null)}}function gs(u,p){{if(typeof u!="object")return;if(qe(u))for(var g=0;g<u.length;g++){var b=u[g];Fn(b)&&ys(b,p)}else if(Fn(u))u._store&&(u._store.validated=!0);else if(u){var k=_(u);if(typeof k=="function"&&k!==u.entries)for(var P=k.call(u),x;!(x=P.next()).done;)Fn(x.value)&&ys(x.value,p)}}}function ya(u){{var p=u.type;if(p==null||typeof p=="string")return;var g;if(typeof p=="function")g=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===f||p.$$typeof===l))g=p.propTypes;else return;if(g){var b=V(p);Pt(g,u.props,"prop",b,u)}else if(p.PropTypes!==void 0&&!Nn){Nn=!0;var k=V(p);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ga(u){{for(var p=Object.keys(u.props),g=0;g<p.length;g++){var b=p[g];if(b!=="children"&&b!=="key"){Ye(u),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),Ye(null);break}}u.ref!==null&&(Ye(u),R("Invalid attribute `ref` supplied to `React.Fragment`."),Ye(null))}}function _s(u,p,g,b,k,P){{var x=I(u);if(!x){var T="";(u===void 0||typeof u=="object"&&u!==null&&Object.keys(u).length===0)&&(T+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var te=va(k);te?T+=te:T+=vs();var q;u===null?q="null":qe(u)?q="array":u!==void 0&&u.$$typeof===e?(q="<"+(V(u.type)||"Unknown")+" />",T=" Did you accidentally export a JSX literal instead of a component?"):q=typeof u,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",q,T)}var J=pa(u,p,g,k,P);if(J==null)return J;if(x){var ce=p.children;if(ce!==void 0)if(b)if(qe(ce)){for(var Je=0;Je<ce.length;Je++)gs(ce[Je],u);Object.freeze&&Object.freeze(ce)}else R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else gs(ce,u)}return u===r?ga(J):ya(J),J}}function _a(u,p,g){return _s(u,p,g,!0)}function ba(u,p,g){return _s(u,p,g,!1)}var wa=ba,Ea=_a;it.Fragment=r,it.jsx=wa,it.jsxs=Ea}()),it}(function(n){process.env.NODE_ENV==="production"?n.exports=Wo():n.exports=qo()})(os);const Ho=os.exports.jsx,X=d.createContext(null),Yo=({url:n="",tokenParams:e,socketPort:t,children:r})=>{const s=d.useMemo(()=>{const i=new Ci.FrappeApp(n,e);return{url:n,tokenParams:e,app:i,auth:i.auth(),db:i.db(),call:i.call(),file:i.file(),socket:new Mo(n,t).socket}},[n,e,t]);return Ho(X.Provider,{value:s,children:r})},Jo=n=>{const{url:e,auth:t,tokenParams:r}=d.useContext(X),[s,i]=d.useState(),o=d.useCallback(()=>{const w=document.cookie.split(";").find(E=>E.trim().startsWith("user_id="));if(w){const E=w.split("=")[1];i(E&&E!=="Guest"?E:null)}else i(null)},[]);d.useEffect(()=>{r&&r.useToken?i(null):o()},[]);const{data:c,error:f,isLoading:a,isValidating:h,mutate:l}=tt(()=>r&&r.useToken||s?`${e}/api/method/frappe.auth.get_logged_user`:null,()=>t.getLoggedInUser(),{onError:()=>{i(null)},shouldRetryOnError:!1,revalidateOnFocus:!1,...n}),m=d.useCallback(async(w,E)=>t.loginWithUsernamePassword({username:w,password:E}).then(_=>{o()}),[]),v=d.useCallback(async()=>t.logout().then(()=>l(null)).then(()=>i(null)),[]);return{isLoading:s===void 0||a,currentUser:c,isValidating:h,error:f,login:m,logout:v,updateCurrentUser:l,getUserCookie:o}},zo=(n,e,t,r)=>{const{url:s,db:i}=d.useContext(X);return{...tt(t===void 0?`${s}/api/resource/${n}/${e}`:t,()=>i.getDoc(n,e),r)}},cs=n=>{var t,r,s;let e="";if(n!=null&&n.fields&&(e+="fields="+JSON.stringify(n==null?void 0:n.fields)+"&"),n!=null&&n.filters&&(e+="filters="+JSON.stringify(n==null?void 0:n.filters)+"&"),n!=null&&n.orFilters&&(e+="or_filters="+JSON.stringify(n==null?void 0:n.orFilters)+"&"),n!=null&&n.limit_start&&(e+="limit_start="+JSON.stringify(n==null?void 0:n.limit_start)+"&"),n!=null&&n.limit&&(e+="limit="+JSON.stringify(n==null?void 0:n.limit)+"&"),n!=null&&n.groupBy&&(e+="group_by="+n.groupBy+"&"),n!=null&&n.orderBy){const i=`${(t=n.orderBy)==null?void 0:t.field} ${(s=(r=n.orderBy)==null?void 0:r.order)!=null?s:"asc"}`;e+="order_by="+i+"&"}return n!=null&&n.asDict&&(e+="as_dict="+n.asDict),e},Ko=(n,e,t,r)=>{const{url:s,db:i}=d.useContext(X);return{...tt(t===void 0?`${s}/api/resource/${n}?${cs(e)}`:t,()=>i.getDocList(n,e),r)}},Go=()=>{const{db:n}=d.useContext(X),[e,t]=d.useState(!1),[r,s]=d.useState(null),[i,o]=d.useState(!1),c=d.useCallback(()=>{t(!1),s(null),o(!1)},[]);return{createDoc:d.useCallback(async(a,h)=>(s(null),o(!1),t(!0),n.createDoc(a,h).then(l=>(t(!1),o(!0),l)).catch(l=>{throw t(!1),o(!1),s(l),l})),[]),loading:e,error:r,isCompleted:i,reset:c}},Xo=()=>{const{db:n}=d.useContext(X),[e,t]=d.useState(!1),[r,s]=d.useState(null),[i,o]=d.useState(!1),c=d.useCallback(()=>{t(!1),s(null),o(!1)},[]);return{updateDoc:d.useCallback(async(a,h,l)=>(s(null),o(!1),t(!0),n.updateDoc(a,h,l).then(m=>(t(!1),o(!0),m)).catch(m=>{throw t(!1),o(!1),s(m),m})),[]),loading:e,error:r,reset:c,isCompleted:i}},Qo=()=>{const{db:n}=d.useContext(X),[e,t]=d.useState(!1),[r,s]=d.useState(null),[i,o]=d.useState(!1),c=d.useCallback(()=>{t(!1),s(null),o(!1)},[]);return{deleteDoc:d.useCallback(async(a,h)=>(s(null),o(!1),t(!0),n.deleteDoc(a,h).then(l=>(t(!1),o(!0),l)).catch(l=>{throw t(!1),o(!1),s(l),l})),[]),loading:e,error:r,reset:c,isCompleted:i}};function ls(n){const e=[];for(let t in n)e.push(encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e.join("&")}const Zo=(n,e,t=!1,r=!1,s,i)=>{const{url:o,db:c}=d.useContext(X);return{...tt(s===void 0?(()=>{const h=ls(t?{doctype:n,filters:e!=null?e:[],cache:t,debug:r}:{doctype:n,filters:e!=null?e:[],debug:r});return`${o}/api/method/frappe.client.get_count?${h}`})():s,()=>c.getCount(n,e,t,r),i)}},fs=(n,e,t,r)=>{const{call:s}=d.useContext(X),i=ls(e!=null?e:{}),o=`${n}?${i}`;return{...tt(t===void 0?o:t,()=>s.get(n,e),r)}},$o=n=>{const{call:e}=d.useContext(X),[t,r]=d.useState(null),[s,i]=d.useState(!1),[o,c]=d.useState(null),[f,a]=d.useState(!1),h=d.useCallback(()=>{r(null),i(!1),c(null),a(!1)},[]);return{call:d.useCallback(async m=>(c(null),a(!1),i(!0),r(null),e.post(n,m).then(v=>(r(v),i(!1),a(!0),v)).catch(v=>{throw i(!1),a(!1),c(v),v})),[]),result:t,loading:s,error:o,reset:h,isCompleted:f}},ea=n=>{const{call:e}=d.useContext(X),[t,r]=d.useState(null),[s,i]=d.useState(!1),[o,c]=d.useState(null),[f,a]=d.useState(!1),h=d.useCallback(()=>{r(null),i(!1),c(null),a(!1)},[]);return{call:d.useCallback(async m=>(c(null),a(!1),i(!0),r(null),e.put(n,m).then(v=>(r(v),i(!1),a(!0),v)).catch(v=>{throw i(!1),a(!1),c(v),v})),[]),result:t,loading:s,error:o,reset:h,isCompleted:f}},ta=n=>{const{call:e}=d.useContext(X),[t,r]=d.useState(null),[s,i]=d.useState(!1),[o,c]=d.useState(null),[f,a]=d.useState(!1),h=d.useCallback(()=>{r(null),i(!1),c(null),a(!1)},[]);return{call:d.useCallback(async m=>(c(null),a(!1),i(!0),r(null),e.delete(n,m).then(v=>(r(v),i(!1),a(!0),v)).catch(v=>{throw i(!1),a(!1),c(v),v})),[]),result:t,loading:s,error:o,reset:h,isCompleted:f}},na=()=>{const{file:n}=d.useContext(X),[e,t]=d.useState(0),[r,s]=d.useState(!1),[i,o]=d.useState(null),[c,f]=d.useState(!1),a=d.useCallback(async(l,m)=>(h(),s(!0),n.uploadFile(l,m,(v,w)=>t(Math.round(v/w*100))).then(v=>(f(!0),t(100),s(!1),v.data.message)).catch(v=>{throw console.error(v),o(v),s(!1),v})),[]),h=d.useCallback(()=>{t(0),s(!1),o(null),f(!1)},[]);return{upload:a,progress:e,loading:r,isCompleted:c,error:i,reset:h}},ra=(n,e,t=[],r=20,s=250)=>{const i=sa(e,s);return fs("frappe.desk.search.search_link",{doctype:n,page_length:r,txt:i,filters:JSON.stringify(t!=null?t:[])})},sa=(n,e)=>{const[t,r]=d.useState(n);return d.useEffect(()=>{const s=setTimeout(()=>{r(n)},e);return()=>{clearTimeout(s)}},[n,e]),t},Lt=(n,e)=>{const{socket:t}=d.useContext(X);d.useEffect(()=>{let r=t.on(n,e);return()=>{r.off(n)}},[n,e])},ia=(n,e,t=!0,r)=>{const{socket:s}=d.useContext(X),[i,o]=d.useState([]);d.useEffect(()=>(s.emit("doc_subscribe",n,e),t&&s.emit("doc_open",n,e),()=>{s.emit("doc_unsubscribe",n,e),t&&s.emit("doc_close",n,e)}),[n,e,t]),Lt("doc_update",r);const c=d.useCallback(()=>{s.emit("doc_open",n,e)},[n,e]),f=d.useCallback(()=>{s.emit("doc_close",n,e)},[n,e]),a=d.useCallback(h=>{h.doctype===n&&h.docname===e&&o(h.users)},[n,e]);return Lt("doc_viewers",a),{viewers:i,emitDocOpen:c,emitDocClose:f}},oa=(n,e)=>{const{socket:t}=d.useContext(X);d.useEffect(()=>(t.emit("doctype_subscribe",n),()=>{t.emit("doctype_unsubscribe",n)}),[n]),Lt("list_update",e)};A.FrappeContext=X,A.FrappeProvider=Yo,A.getDocListQueryString=cs,A.useFrappeAuth=Jo,A.useFrappeCreateDoc=Go,A.useFrappeDeleteCall=ta,A.useFrappeDeleteDoc=Qo,A.useFrappeDocTypeEventListener=oa,A.useFrappeDocumentEventListener=ia,A.useFrappeEventListener=Lt,A.useFrappeFileUpload=na,A.useFrappeGetCall=fs,A.useFrappeGetDoc=zo,A.useFrappeGetDocCount=Zo,A.useFrappeGetDocList=Ko,A.useFrappePostCall=$o,A.useFrappePutCall=ea,A.useFrappeUpdateDoc=Xo,A.useSearch=ra,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|