@sawport/peers-caller 1.0.0-alpha.15 → 1.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -2
- package/dist/context/VideoCallContext.d.ts +2 -1
- package/dist/context/VideoCallContext.d.ts.map +1 -1
- package/dist/core/PeersCaller.d.ts +4 -0
- package/dist/core/PeersCaller.d.ts.map +1 -1
- package/dist/peers-caller.es.js +2759 -2979
- package/dist/peers-caller.es.js.map +1 -1
- package/dist/peers-caller.umd.js +8 -13
- package/dist/peers-caller.umd.js.map +1 -1
- package/dist/store/tester.store.d.ts +1 -0
- package/dist/store/tester.store.d.ts.map +1 -1
- package/dist/tester/App.d.ts.map +1 -1
- package/dist/tester/components/ConfigPanel.d.ts +1 -0
- package/dist/tester/components/ConfigPanel.d.ts.map +1 -1
- package/dist/tester/main.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/peers-caller.umd.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
(function(){ne.apply(null,ve)},0)}});typeof global=="undefined"&&(globalThis.global=globalThis);(function(ne,ve){typeof exports=="object"&&typeof module!="undefined"?ve(exports,require("socket.io-client"),require("zustand"),require("react")):typeof define=="function"&&define.amd?define(["exports","socket.io-client","zustand","react"],ve):(ne=typeof globalThis!="undefined"?globalThis:ne||self,ve(ne.PeersCaller={},ne.io,ne.zustand,ne.React))})(this,function(ne,ve,ke,ce){"use strict";var Hl=Object.defineProperty,Yl=Object.defineProperties;var Jl=Object.getOwnPropertyDescriptors;var xt=Object.getOwnPropertySymbols;var ha=Object.prototype.hasOwnProperty,da=Object.prototype.propertyIsEnumerable;var se=Math.pow,Nn=(ne,ve,ke)=>ve in ne?Hl(ne,ve,{enumerable:!0,configurable:!0,writable:!0,value:ke}):ne[ve]=ke,ze=(ne,ve)=>{for(var ke in ve||(ve={}))ha.call(ve,ke)&&Nn(ne,ke,ve[ke]);if(xt)for(var ke of xt(ve))da.call(ve,ke)&&Nn(ne,ke,ve[ke]);return ne},Ln=(ne,ve)=>Yl(ne,Jl(ve));var Dn=(ne,ve)=>{var ke={};for(var ce in ne)ha.call(ne,ce)&&ve.indexOf(ce)<0&&(ke[ce]=ne[ce]);if(ne!=null&&xt)for(var ce of xt(ne))ve.indexOf(ce)<0&&da.call(ne,ce)&&(ke[ce]=ne[ce]);return ke};var He=(ne,ve,ke)=>Nn(ne,typeof ve!="symbol"?ve+"":ve,ke);typeof process=="undefined"&&(globalThis.process={env:{},browser:!0,version:"v18.0.0",platform:"browser",nextTick:function(ne){var ve=Array.prototype.slice.call(arguments,1);if(typeof MessageChannel!="undefined"){var ke=new MessageChannel;ke.port2.onmessage=function(){ne.apply(null,ve)},ke.port1.postMessage(null)}else setTimeoutfunction pa(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Fn={exports:{}},Me=Fn.exports={},Ye,Je;function qt(){throw new Error("setTimeout has not been defined")}function $t(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Ye=setTimeout:Ye=qt}catch(r){Ye=qt}try{typeof clearTimeout=="function"?Je=clearTimeout:Je=$t}catch(r){Je=$t}})();function Un(r){if(Ye===setTimeout)return setTimeout(r,0);if((Ye===qt||!Ye)&&setTimeout)return Ye=setTimeout,setTimeout(r,0);try{return Ye(r,0)}catch(e){try{return Ye.call(null,r,0)}catch(t){return Ye.call(this,r,0)}}}function ga(r){if(Je===clearTimeout)return clearTimeout(r);if((Je===$t||!Je)&&clearTimeout)return Je=clearTimeout,clearTimeout(r);try{return Je(r)}catch(e){try{return Je.call(null,r)}catch(t){return Je.call(this,r)}}}var Qe=[],st=!1,it,Ct=-1;function ya(){!st||!it||(st=!1,it.length?Qe=it.concat(Qe):Ct=-1,Qe.length&&jn())}function jn(){if(!st){var r=Un(ya);st=!0;for(var e=Qe.length;e;){for(it=Qe,Qe=[];++Ct<e;)it&&it[Ct].run();Ct=-1,e=Qe.length}it=null,st=!1,ga(r)}}Me.nextTick=function(r){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];Qe.push(new xn(r,e)),Qe.length===1&&!st&&Un(jn)};function xn(r,e){this.fun=r,this.array=e}xn.prototype.run=function(){this.fun.apply(null,this.array)},Me.title="browser",Me.browser=!0,Me.env={},Me.argv=[],Me.version="",Me.versions={};function et(){}Me.on=et,Me.addListener=et,Me.once=et,Me.off=et,Me.removeListener=et,Me.removeAllListeners=et,Me.emit=et,Me.prependListener=et,Me.prependOnceListener=et,Me.listeners=function(r){return[]},Me.binding=function(r){throw new Error("process.binding is not supported")},Me.cwd=function(){return"/"},Me.chdir=function(r){throw new Error("process.chdir is not supported")},Me.umask=function(){return 0};var ma=Fn.exports;const le=pa(ma);var qn={},Rt={};Rt.byteLength=ba,Rt.toByteArray=_a,Rt.fromByteArray=Ra;for(var Ke=[],$e=[],va=typeof Uint8Array!="undefined"?Uint8Array:Array,Wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lt=0,wa=Wt.length;lt<wa;++lt)Ke[lt]=Wt[lt],$e[Wt.charCodeAt(lt)]=lt;$e[45]=62,$e[95]=63;function $n(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var s=t===e?0:4-t%4;return[t,s]}function ba(r){var e=$n(r),t=e[0],s=e[1];return(t+s)*3/4-s}function Sa(r,e,t){return(e+t)*3/4-t}function _a(r){var e,t=$n(r),s=t[0],c=t[1],l=new va(Sa(r,s,c)),g=0,f=c>0?s-4:s,u;for(u=0;u<f;u+=4)e=$e[r.charCodeAt(u)]<<18|$e[r.charCodeAt(u+1)]<<12|$e[r.charCodeAt(u+2)]<<6|$e[r.charCodeAt(u+3)],l[g++]=e>>16&255,l[g++]=e>>8&255,l[g++]=e&255;return c===2&&(e=$e[r.charCodeAt(u)]<<2|$e[r.charCodeAt(u+1)]>>4,l[g++]=e&255),c===1&&(e=$e[r.charCodeAt(u)]<<10|$e[r.charCodeAt(u+1)]<<4|$e[r.charCodeAt(u+2)]>>2,l[g++]=e>>8&255,l[g++]=e&255),l}function Ea(r){return Ke[r>>18&63]+Ke[r>>12&63]+Ke[r>>6&63]+Ke[r&63]}function Ca(r,e,t){for(var s,c=[],l=e;l<t;l+=3)s=(r[l]<<16&16711680)+(r[l+1]<<8&65280)+(r[l+2]&255),c.push(Ea(s));return c.join("")}function Ra(r){for(var e,t=r.length,s=t%3,c=[],l=16383,g=0,f=t-s;g<f;g+=l)c.push(Ca(r,g,g+l>f?f:g+l));return s===1?(e=r[t-1],c.push(Ke[e>>2]+Ke[e<<4&63]+"==")):s===2&&(e=(r[t-2]<<8)+r[t-1],c.push(Ke[e>>10]+Ke[e>>4&63]+Ke[e<<2&63]+"=")),c.join("")}var Vt={};Vt.read=function(r,e,t,s,c){var l,g,f=c*8-s-1,u=(1<<f)-1,m=u>>1,h=-7,k=t?c-1:0,I=t?-1:1,V=r[e+k];for(k+=I,l=V&(1<<-h)-1,V>>=-h,h+=f;h>0;l=l*256+r[e+k],k+=I,h-=8);for(g=l&(1<<-h)-1,l>>=-h,h+=s;h>0;g=g*256+r[e+k],k+=I,h-=8);if(l===0)l=1-m;else{if(l===u)return g?NaN:(V?-1:1)*(1/0);g=g+Math.pow(2,s),l=l-m}return(V?-1:1)*g*Math.pow(2,l-s)},Vt.write=function(r,e,t,s,c,l){var g,f,u,m=l*8-c-1,h=(1<<m)-1,k=h>>1,I=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,V=s?0:l-1,b=s?1:-1,B=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,g=h):(g=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-g))<1&&(g--,u*=2),g+k>=1?e+=I/u:e+=I*Math.pow(2,1-k),e*u>=2&&(g++,u/=2),g+k>=h?(f=0,g=h):g+k>=1?(f=(e*u-1)*Math.pow(2,c),g=g+k):(f=e*Math.pow(2,k-1)*Math.pow(2,c),g=0));c>=8;r[t+V]=f&255,V+=b,f/=256,c-=8);for(g=g<<c|f,m+=c;m>0;r[t+V]=g&255,V+=b,g/=256,m-=8);r[t+V-b]|=B*128};(function(r){const e=Rt,t=Vt,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=h,r.SlowBuffer=O,r.INSPECT_MAX_BYTES=50;const c=2147483647;r.kMaxLength=c;const{Uint8Array:l,ArrayBuffer:g,SharedArrayBuffer:f}=globalThis;h.TYPED_ARRAY_SUPPORT=u(),!h.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{const d=new l(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,l.prototype),Object.setPrototypeOf(d,n),d.foo()===42}catch(d){return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function m(d){if(d>c)throw new RangeError('The value "'+d+'" is invalid for option "size"');const n=new l(d);return Object.setPrototypeOf(n,h.prototype),n}function h(d,n,o){if(typeof d=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(d)}return k(d,n,o)}h.poolSize=8192;function k(d,n,o){if(typeof d=="string")return B(d,n);if(g.isView(d))return y(d);if(d==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof d);if(De(d,g)||d&&De(d.buffer,g)||typeof f!="undefined"&&(De(d,f)||d&&De(d.buffer,f)))return C(d,n,o);if(typeof d=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const _=d.valueOf&&d.valueOf();if(_!=null&&_!==d)return h.from(_,n,o);const N=A(d);if(N)return N;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof d[Symbol.toPrimitive]=="function")return h.from(d[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof d)}h.from=function(d,n,o){return k(d,n,o)},Object.setPrototypeOf(h.prototype,l.prototype),Object.setPrototypeOf(h,l);function I(d){if(typeof d!="number")throw new TypeError('"size" argument must be of type number');if(d<0)throw new RangeError('The value "'+d+'" is invalid for option "size"')}function V(d,n,o){return I(d),d<=0?m(d):n!==void 0?typeof o=="string"?m(d).fill(n,o):m(d).fill(n):m(d)}h.alloc=function(d,n,o){return V(d,n,o)};function b(d){return I(d),m(d<0?0:T(d)|0)}h.allocUnsafe=function(d){return b(d)},h.allocUnsafeSlow=function(d){return b(d)};function B(d,n){if((typeof n!="string"||n==="")&&(n="utf8"),!h.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const o=S(d,n)|0;let _=m(o);const N=_.write(d,n);return N!==o&&(_=_.slice(0,N)),_}function P(d){const n=d.length<0?0:T(d.length)|0,o=m(n);for(let _=0;_<n;_+=1)o[_]=d[_]&255;return o}function y(d){if(De(d,l)){const n=new l(d);return C(n.buffer,n.byteOffset,n.byteLength)}return P(d)}function C(d,n,o){if(n<0||d.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(d.byteLength<n+(o||0))throw new RangeError('"length" is outside of buffer bounds');let _;return n===void 0&&o===void 0?_=new l(d):o===void 0?_=new l(d,n):_=new l(d,n,o),Object.setPrototypeOf(_,h.prototype),_}function A(d){if(h.isBuffer(d)){const n=T(d.length)|0,o=m(n);return o.length===0||d.copy(o,0,0,n),o}if(d.length!==void 0)return typeof d.length!="number"||We(d.length)?m(0):P(d);if(d.type==="Buffer"&&Array.isArray(d.data))return P(d.data)}function T(d){if(d>=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return d|0}function O(d){return+d!=d&&(d=0),h.alloc(+d)}h.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==h.prototype},h.compare=function(n,o){if(De(n,l)&&(n=h.from(n,n.offset,n.byteLength)),De(o,l)&&(o=h.from(o,o.offset,o.byteLength)),!h.isBuffer(n)||!h.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===o)return 0;let _=n.length,N=o.length;for(let x=0,J=Math.min(_,N);x<J;++x)if(n[x]!==o[x]){_=n[x],N=o[x];break}return _<N?-1:N<_?1:0},h.isEncoding=function(n){switch(String(n).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(n,o){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return h.alloc(0);let _;if(o===void 0)for(o=0,_=0;_<n.length;++_)o+=n[_].length;const N=h.allocUnsafe(o);let x=0;for(_=0;_<n.length;++_){let J=n[_];if(De(J,l))x+J.length>N.length?(h.isBuffer(J)||(J=h.from(J)),J.copy(N,x)):l.prototype.set.call(N,J,x);else if(h.isBuffer(J))J.copy(N,x);else throw new TypeError('"list" argument must be an Array of Buffers');x+=J.length}return N};function S(d,n){if(h.isBuffer(d))return d.length;if(g.isView(d)||De(d,g))return d.byteLength;if(typeof d!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof d);const o=d.length,_=arguments.length>2&&arguments[2]===!0;if(!_&&o===0)return 0;let N=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return Ue(d).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return Ee(d).length;default:if(N)return _?-1:Ue(d).length;n=(""+n).toLowerCase(),N=!0}}h.byteLength=S;function R(d,n,o){let _=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,n>>>=0,o<=n))return"";for(d||(d="utf8");;)switch(d){case"hex":return j(this,n,o);case"utf8":case"utf-8":return Te(this,n,o);case"ascii":return X(this,n,o);case"latin1":case"binary":return ae(this,n,o);case"base64":return Pe(this,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return W(this,n,o);default:if(_)throw new TypeError("Unknown encoding: "+d);d=(d+"").toLowerCase(),_=!0}}h.prototype._isBuffer=!0;function M(d,n,o){const _=d[n];d[n]=d[o],d[o]=_}h.prototype.swap16=function(){const n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<n;o+=2)M(this,o,o+1);return this},h.prototype.swap32=function(){const n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<n;o+=4)M(this,o,o+3),M(this,o+1,o+2);return this},h.prototype.swap64=function(){const n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<n;o+=8)M(this,o,o+7),M(this,o+1,o+6),M(this,o+2,o+5),M(this,o+3,o+4);return this},h.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?Te(this,0,n):R.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(n){if(!h.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:h.compare(this,n)===0},h.prototype.inspect=function(){let n="";const o=r.INSPECT_MAX_BYTES;return n=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(n+=" ... "),"<Buffer "+n+">"},s&&(h.prototype[s]=h.prototype.inspect),h.prototype.compare=function(n,o,_,N,x){if(De(n,l)&&(n=h.from(n,n.offset,n.byteLength)),!h.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(o===void 0&&(o=0),_===void 0&&(_=n?n.length:0),N===void 0&&(N=0),x===void 0&&(x=this.length),o<0||_>n.length||N<0||x>this.length)throw new RangeError("out of range index");if(N>=x&&o>=_)return 0;if(N>=x)return-1;if(o>=_)return 1;if(o>>>=0,_>>>=0,N>>>=0,x>>>=0,this===n)return 0;let J=x-N,he=_-o;const Ce=Math.min(J,he),Re=this.slice(N,x),Ae=n.slice(o,_);for(let me=0;me<Ce;++me)if(Re[me]!==Ae[me]){J=Re[me],he=Ae[me];break}return J<he?-1:he<J?1:0};function G(d,n,o,_,N){if(d.length===0)return-1;if(typeof o=="string"?(_=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,We(o)&&(o=N?0:d.length-1),o<0&&(o=d.length+o),o>=d.length){if(N)return-1;o=d.length-1}else if(o<0)if(N)o=0;else return-1;if(typeof n=="string"&&(n=h.from(n,_)),h.isBuffer(n))return n.length===0?-1:Q(d,n,o,_,N);if(typeof n=="number")return n=n&255,typeof l.prototype.indexOf=="function"?N?l.prototype.indexOf.call(d,n,o):l.prototype.lastIndexOf.call(d,n,o):Q(d,[n],o,_,N);throw new TypeError("val must be string, number or Buffer")}function Q(d,n,o,_,N){let x=1,J=d.length,he=n.length;if(_!==void 0&&(_=String(_).toLowerCase(),_==="ucs2"||_==="ucs-2"||_==="utf16le"||_==="utf-16le")){if(d.length<2||n.length<2)return-1;x=2,J/=2,he/=2,o/=2}function Ce(Ae,me){return x===1?Ae[me]:Ae.readUInt16BE(me*x)}let Re;if(N){let Ae=-1;for(Re=o;Re<J;Re++)if(Ce(d,Re)===Ce(n,Ae===-1?0:Re-Ae)){if(Ae===-1&&(Ae=Re),Re-Ae+1===he)return Ae*x}else Ae!==-1&&(Re-=Re-Ae),Ae=-1}else for(o+he>J&&(o=J-he),Re=o;Re>=0;Re--){let Ae=!0;for(let me=0;me<he;me++)if(Ce(d,Re+me)!==Ce(n,me)){Ae=!1;break}if(Ae)return Re}return-1}h.prototype.includes=function(n,o,_){return this.indexOf(n,o,_)!==-1},h.prototype.indexOf=function(n,o,_){return G(this,n,o,_,!0)},h.prototype.lastIndexOf=function(n,o,_){return G(this,n,o,_,!1)};function ie(d,n,o,_){o=Number(o)||0;const N=d.length-o;_?(_=Number(_),_>N&&(_=N)):_=N;const x=n.length;_>x/2&&(_=x/2);let J;for(J=0;J<_;++J){const he=parseInt(n.substr(J*2,2),16);if(We(he))return J;d[o+J]=he}return J}function U(d,n,o,_){return xe(Ue(n,d.length-o),d,o,_)}function ge(d,n,o,_){return xe(je(n),d,o,_)}function de(d,n,o,_){return xe(Ee(n),d,o,_)}function ye(d,n,o,_){return xe(be(n,d.length-o),d,o,_)}h.prototype.write=function(n,o,_,N){if(o===void 0)N="utf8",_=this.length,o=0;else if(_===void 0&&typeof o=="string")N=o,_=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(_)?(_=_>>>0,N===void 0&&(N="utf8")):(N=_,_=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const x=this.length-o;if((_===void 0||_>x)&&(_=x),n.length>0&&(_<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");N||(N="utf8");let J=!1;for(;;)switch(N){case"hex":return ie(this,n,o,_);case"utf8":case"utf-8":return U(this,n,o,_);case"ascii":case"latin1":case"binary":return ge(this,n,o,_);case"base64":return de(this,n,o,_);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ye(this,n,o,_);default:if(J)throw new TypeError("Unknown encoding: "+N);N=(""+N).toLowerCase(),J=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Pe(d,n,o){return n===0&&o===d.length?e.fromByteArray(d):e.fromByteArray(d.slice(n,o))}function Te(d,n,o){o=Math.min(d.length,o);const _=[];let N=n;for(;N<o;){const x=d[N];let J=null,he=x>239?4:x>223?3:x>191?2:1;if(N+he<=o){let Ce,Re,Ae,me;switch(he){case 1:x<128&&(J=x);break;case 2:Ce=d[N+1],(Ce&192)===128&&(me=(x&31)<<6|Ce&63,me>127&&(J=me));break;case 3:Ce=d[N+1],Re=d[N+2],(Ce&192)===128&&(Re&192)===128&&(me=(x&15)<<12|(Ce&63)<<6|Re&63,me>2047&&(me<55296||me>57343)&&(J=me));break;case 4:Ce=d[N+1],Re=d[N+2],Ae=d[N+3],(Ce&192)===128&&(Re&192)===128&&(Ae&192)===128&&(me=(x&15)<<18|(Ce&63)<<12|(Re&63)<<6|Ae&63,me>65535&&me<1114112&&(J=me))}}J===null?(J=65533,he=1):J>65535&&(J-=65536,_.push(J>>>10&1023|55296),J=56320|J&1023),_.push(J),N+=he}return we(_)}const Se=4096;function we(d){const n=d.length;if(n<=Se)return String.fromCharCode.apply(String,d);let o="",_=0;for(;_<n;)o+=String.fromCharCode.apply(String,d.slice(_,_+=Se));return o}function X(d,n,o){let _="";o=Math.min(d.length,o);for(let N=n;N<o;++N)_+=String.fromCharCode(d[N]&127);return _}function ae(d,n,o){let _="";o=Math.min(d.length,o);for(let N=n;N<o;++N)_+=String.fromCharCode(d[N]);return _}function j(d,n,o){const _=d.length;(!n||n<0)&&(n=0),(!o||o<0||o>_)&&(o=_);let N="";for(let x=n;x<o;++x)N+=Ge[d[x]];return N}function W(d,n,o){const _=d.slice(n,o);let N="";for(let x=0;x<_.length-1;x+=2)N+=String.fromCharCode(_[x]+_[x+1]*256);return N}h.prototype.slice=function(n,o){const _=this.length;n=~~n,o=o===void 0?_:~~o,n<0?(n+=_,n<0&&(n=0)):n>_&&(n=_),o<0?(o+=_,o<0&&(o=0)):o>_&&(o=_),o<n&&(o=n);const N=this.subarray(n,o);return Object.setPrototypeOf(N,h.prototype),N};function z(d,n,o){if(d%1!==0||d<0)throw new RangeError("offset is not uint");if(d+n>o)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(n,o,_){n=n>>>0,o=o>>>0,_||z(n,o,this.length);let N=this[n],x=1,J=0;for(;++J<o&&(x*=256);)N+=this[n+J]*x;return N},h.prototype.readUintBE=h.prototype.readUIntBE=function(n,o,_){n=n>>>0,o=o>>>0,_||z(n,o,this.length);let N=this[n+--o],x=1;for(;o>0&&(x*=256);)N+=this[n+--o]*x;return N},h.prototype.readUint8=h.prototype.readUInt8=function(n,o){return n=n>>>0,o||z(n,1,this.length),this[n]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(n,o){return n=n>>>0,o||z(n,2,this.length),this[n]|this[n+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(n,o){return n=n>>>0,o||z(n,2,this.length),this[n]<<8|this[n+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(n,o){return n=n>>>0,o||z(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(n,o){return n=n>>>0,o||z(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},h.prototype.readBigUInt64LE=Le(function(n){n=n>>>0,oe(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&ue(n,this.length-8);const N=o+this[++n]*se(2,8)+this[++n]*se(2,16)+this[++n]*se(2,24),x=this[++n]+this[++n]*se(2,8)+this[++n]*se(2,16)+_*se(2,24);return BigInt(N)+(BigInt(x)<<BigInt(32))}),h.prototype.readBigUInt64BE=Le(function(n){n=n>>>0,oe(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&ue(n,this.length-8);const N=o*se(2,24)+this[++n]*se(2,16)+this[++n]*se(2,8)+this[++n],x=this[++n]*se(2,24)+this[++n]*se(2,16)+this[++n]*se(2,8)+_;return(BigInt(N)<<BigInt(32))+BigInt(x)}),h.prototype.readIntLE=function(n,o,_){n=n>>>0,o=o>>>0,_||z(n,o,this.length);let N=this[n],x=1,J=0;for(;++J<o&&(x*=256);)N+=this[n+J]*x;return x*=128,N>=x&&(N-=Math.pow(2,8*o)),N},h.prototype.readIntBE=function(n,o,_){n=n>>>0,o=o>>>0,_||z(n,o,this.length);let N=o,x=1,J=this[n+--N];for(;N>0&&(x*=256);)J+=this[n+--N]*x;return x*=128,J>=x&&(J-=Math.pow(2,8*o)),J},h.prototype.readInt8=function(n,o){return n=n>>>0,o||z(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},h.prototype.readInt16LE=function(n,o){n=n>>>0,o||z(n,2,this.length);const _=this[n]|this[n+1]<<8;return _&32768?_|4294901760:_},h.prototype.readInt16BE=function(n,o){n=n>>>0,o||z(n,2,this.length);const _=this[n+1]|this[n]<<8;return _&32768?_|4294901760:_},h.prototype.readInt32LE=function(n,o){return n=n>>>0,o||z(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},h.prototype.readInt32BE=function(n,o){return n=n>>>0,o||z(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},h.prototype.readBigInt64LE=Le(function(n){n=n>>>0,oe(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&ue(n,this.length-8);const N=this[n+4]+this[n+5]*se(2,8)+this[n+6]*se(2,16)+(_<<24);return(BigInt(N)<<BigInt(32))+BigInt(o+this[++n]*se(2,8)+this[++n]*se(2,16)+this[++n]*se(2,24))}),h.prototype.readBigInt64BE=Le(function(n){n=n>>>0,oe(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&ue(n,this.length-8);const N=(o<<24)+this[++n]*se(2,16)+this[++n]*se(2,8)+this[++n];return(BigInt(N)<<BigInt(32))+BigInt(this[++n]*se(2,24)+this[++n]*se(2,16)+this[++n]*se(2,8)+_)}),h.prototype.readFloatLE=function(n,o){return n=n>>>0,o||z(n,4,this.length),t.read(this,n,!0,23,4)},h.prototype.readFloatBE=function(n,o){return n=n>>>0,o||z(n,4,this.length),t.read(this,n,!1,23,4)},h.prototype.readDoubleLE=function(n,o){return n=n>>>0,o||z(n,8,this.length),t.read(this,n,!0,52,8)},h.prototype.readDoubleBE=function(n,o){return n=n>>>0,o||z(n,8,this.length),t.read(this,n,!1,52,8)};function re(d,n,o,_,N,x){if(!h.isBuffer(d))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>N||n<x)throw new RangeError('"value" argument is out of bounds');if(o+_>d.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(n,o,_,N){if(n=+n,o=o>>>0,_=_>>>0,!N){const he=Math.pow(2,8*_)-1;re(this,n,o,_,he,0)}let x=1,J=0;for(this[o]=n&255;++J<_&&(x*=256);)this[o+J]=n/x&255;return o+_},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(n,o,_,N){if(n=+n,o=o>>>0,_=_>>>0,!N){const he=Math.pow(2,8*_)-1;re(this,n,o,_,he,0)}let x=_-1,J=1;for(this[o+x]=n&255;--x>=0&&(J*=256);)this[o+x]=n/J&255;return o+_},h.prototype.writeUint8=h.prototype.writeUInt8=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,1,255,0),this[o]=n&255,o+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,2,65535,0),this[o]=n&255,this[o+1]=n>>>8,o+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,2,65535,0),this[o]=n>>>8,this[o+1]=n&255,o+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,4,4294967295,0),this[o+3]=n>>>24,this[o+2]=n>>>16,this[o+1]=n>>>8,this[o]=n&255,o+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,4,4294967295,0),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4};function L(d,n,o,_,N){fe(n,_,N,d,o,7);let x=Number(n&BigInt(4294967295));d[o++]=x,x=x>>8,d[o++]=x,x=x>>8,d[o++]=x,x=x>>8,d[o++]=x;let J=Number(n>>BigInt(32)&BigInt(4294967295));return d[o++]=J,J=J>>8,d[o++]=J,J=J>>8,d[o++]=J,J=J>>8,d[o++]=J,o}function D(d,n,o,_,N){fe(n,_,N,d,o,7);let x=Number(n&BigInt(4294967295));d[o+7]=x,x=x>>8,d[o+6]=x,x=x>>8,d[o+5]=x,x=x>>8,d[o+4]=x;let J=Number(n>>BigInt(32)&BigInt(4294967295));return d[o+3]=J,J=J>>8,d[o+2]=J,J=J>>8,d[o+1]=J,J=J>>8,d[o]=J,o+8}h.prototype.writeBigUInt64LE=Le(function(n,o=0){return L(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Le(function(n,o=0){return D(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(n,o,_,N){if(n=+n,o=o>>>0,!N){const Ce=Math.pow(2,8*_-1);re(this,n,o,_,Ce-1,-Ce)}let x=0,J=1,he=0;for(this[o]=n&255;++x<_&&(J*=256);)n<0&&he===0&&this[o+x-1]!==0&&(he=1),this[o+x]=(n/J>>0)-he&255;return o+_},h.prototype.writeIntBE=function(n,o,_,N){if(n=+n,o=o>>>0,!N){const Ce=Math.pow(2,8*_-1);re(this,n,o,_,Ce-1,-Ce)}let x=_-1,J=1,he=0;for(this[o+x]=n&255;--x>=0&&(J*=256);)n<0&&he===0&&this[o+x+1]!==0&&(he=1),this[o+x]=(n/J>>0)-he&255;return o+_},h.prototype.writeInt8=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,1,127,-128),n<0&&(n=255+n+1),this[o]=n&255,o+1},h.prototype.writeInt16LE=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,2,32767,-32768),this[o]=n&255,this[o+1]=n>>>8,o+2},h.prototype.writeInt16BE=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,2,32767,-32768),this[o]=n>>>8,this[o+1]=n&255,o+2},h.prototype.writeInt32LE=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,4,2147483647,-2147483648),this[o]=n&255,this[o+1]=n>>>8,this[o+2]=n>>>16,this[o+3]=n>>>24,o+4},h.prototype.writeInt32BE=function(n,o,_){return n=+n,o=o>>>0,_||re(this,n,o,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4},h.prototype.writeBigInt64LE=Le(function(n,o=0){return L(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Le(function(n,o=0){return D(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function q(d,n,o,_,N,x){if(o+_>d.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function Z(d,n,o,_,N){return n=+n,o=o>>>0,N||q(d,n,o,4),t.write(d,n,o,_,23,4),o+4}h.prototype.writeFloatLE=function(n,o,_){return Z(this,n,o,!0,_)},h.prototype.writeFloatBE=function(n,o,_){return Z(this,n,o,!1,_)};function ee(d,n,o,_,N){return n=+n,o=o>>>0,N||q(d,n,o,8),t.write(d,n,o,_,52,8),o+8}h.prototype.writeDoubleLE=function(n,o,_){return ee(this,n,o,!0,_)},h.prototype.writeDoubleBE=function(n,o,_){return ee(this,n,o,!1,_)},h.prototype.copy=function(n,o,_,N){if(!h.isBuffer(n))throw new TypeError("argument should be a Buffer");if(_||(_=0),!N&&N!==0&&(N=this.length),o>=n.length&&(o=n.length),o||(o=0),N>0&&N<_&&(N=_),N===_||n.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(_<0||_>=this.length)throw new RangeError("Index out of range");if(N<0)throw new RangeError("sourceEnd out of bounds");N>this.length&&(N=this.length),n.length-o<N-_&&(N=n.length-o+_);const x=N-_;return this===n&&typeof l.prototype.copyWithin=="function"?this.copyWithin(o,_,N):l.prototype.set.call(n,this.subarray(_,N),o),x},h.prototype.fill=function(n,o,_,N){if(typeof n=="string"){if(typeof o=="string"?(N=o,o=0,_=this.length):typeof _=="string"&&(N=_,_=this.length),N!==void 0&&typeof N!="string")throw new TypeError("encoding must be a string");if(typeof N=="string"&&!h.isEncoding(N))throw new TypeError("Unknown encoding: "+N);if(n.length===1){const J=n.charCodeAt(0);(N==="utf8"&&J<128||N==="latin1")&&(n=J)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(o<0||this.length<o||this.length<_)throw new RangeError("Out of range index");if(_<=o)return this;o=o>>>0,_=_===void 0?this.length:_>>>0,n||(n=0);let x;if(typeof n=="number")for(x=o;x<_;++x)this[x]=n;else{const J=h.isBuffer(n)?n:h.from(n,N),he=J.length;if(he===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(x=0;x<_-o;++x)this[x+o]=J[x%he]}return this};const v={};function w(d,n,o){v[d]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${d}]`,this.stack,delete this.name}get code(){return d}set code(N){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:N,writable:!0})}toString(){return`${this.name} [${d}]: ${this.message}`}}}w("ERR_BUFFER_OUT_OF_BOUNDS",function(d){return d?`${d} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),w("ERR_INVALID_ARG_TYPE",function(d,n){return`The "${d}" argument must be of type number. Received type ${typeof n}`},TypeError),w("ERR_OUT_OF_RANGE",function(d,n,o){let _=`The value of "${d}" is out of range.`,N=o;return Number.isInteger(o)&&Math.abs(o)>se(2,32)?N=H(String(o)):typeof o=="bigint"&&(N=String(o),(o>se(BigInt(2),BigInt(32))||o<-se(BigInt(2),BigInt(32)))&&(N=H(N)),N+="n"),_+=` It must be ${n}. Received ${N}`,_},RangeError);function H(d){let n="",o=d.length;const _=d[0]==="-"?1:0;for(;o>=_+4;o-=3)n=`_${d.slice(o-3,o)}${n}`;return`${d.slice(0,o)}${n}`}function te(d,n,o){oe(n,"offset"),(d[n]===void 0||d[n+o]===void 0)&&ue(n,d.length-(o+1))}function fe(d,n,o,_,N,x){if(d>o||d<n){const J=typeof n=="bigint"?"n":"";let he;throw n===0||n===BigInt(0)?he=`>= 0${J} and < 2${J} ** ${(x+1)*8}${J}`:he=`>= -(2${J} ** ${(x+1)*8-1}${J}) and < 2 ** ${(x+1)*8-1}${J}`,new v.ERR_OUT_OF_RANGE("value",he,d)}te(_,N,x)}function oe(d,n){if(typeof d!="number")throw new v.ERR_INVALID_ARG_TYPE(n,"number",d)}function ue(d,n,o){throw Math.floor(d)!==d?(oe(d,o),new v.ERR_OUT_OF_RANGE("offset","an integer",d)):n<0?new v.ERR_BUFFER_OUT_OF_BOUNDS:new v.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,d)}const Fe=/[^+/0-9A-Za-z-_]/g;function Y(d){if(d=d.split("=")[0],d=d.trim().replace(Fe,""),d.length<2)return"";for(;d.length%4!==0;)d=d+"=";return d}function Ue(d,n){n=n||1/0;let o;const _=d.length;let N=null;const x=[];for(let J=0;J<_;++J){if(o=d.charCodeAt(J),o>55295&&o<57344){if(!N){if(o>56319){(n-=3)>-1&&x.push(239,191,189);continue}else if(J+1===_){(n-=3)>-1&&x.push(239,191,189);continue}N=o;continue}if(o<56320){(n-=3)>-1&&x.push(239,191,189),N=o;continue}o=(N-55296<<10|o-56320)+65536}else N&&(n-=3)>-1&&x.push(239,191,189);if(N=null,o<128){if((n-=1)<0)break;x.push(o)}else if(o<2048){if((n-=2)<0)break;x.push(o>>6|192,o&63|128)}else if(o<65536){if((n-=3)<0)break;x.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((n-=4)<0)break;x.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return x}function je(d){const n=[];for(let o=0;o<d.length;++o)n.push(d.charCodeAt(o)&255);return n}function be(d,n){let o,_,N;const x=[];for(let J=0;J<d.length&&!((n-=2)<0);++J)o=d.charCodeAt(J),_=o>>8,N=o%256,x.push(N),x.push(_);return x}function Ee(d){return e.toByteArray(Y(d))}function xe(d,n,o,_){let N;for(N=0;N<_&&!(N+o>=n.length||N>=d.length);++N)n[N+o]=d[N];return N}function De(d,n){return d instanceof n||d!=null&&d.constructor!=null&&d.constructor.name!=null&&d.constructor.name===n.name}function We(d){return d!==d}const Ge=function(){const d="0123456789abcdef",n=new Array(256);for(let o=0;o<16;++o){const _=o*16;for(let N=0;N<16;++N)n[_+N]=d[o]+d[N]}return n}();function Le(d){return typeof BigInt=="undefined"?rt:d}function rt(){throw new Error("BigInt not supported")}})(qn);const Pa=qn.Buffer;if(typeof le=="undefined"?globalThis.process={env:{},browser:!0,version:"v18.0.0",platform:"browser",arch:"x64",versions:{node:"18.0.0"},nextTick:(r,...e)=>{if(typeof r!="function")throw new TypeError("nextTick callback must be a function");if(typeof MessageChannel!="undefined"){const t=new MessageChannel;t.port2.onmessage=()=>{try{r(...e)}catch(s){setTimeout(()=>{throw s},0)}},t.port1.postMessage(null)}else setTimeout(()=>{try{r(...e)}catch(t){setTimeout(()=>{throw t},0)}},0)},cwd:()=>"/",chdir:()=>{},umask:()=>0}:typeof le.nextTick=="undefined"&&(le.nextTick=(r,...e)=>{if(typeof r!="function")throw new TypeError("nextTick callback must be a function");if(typeof MessageChannel!="undefined"){const t=new MessageChannel;t.port2.onmessage=()=>{try{r(...e)}catch(s){setTimeout(()=>{throw s},0)}},t.port1.postMessage(null)}else setTimeout(()=>{try{r(...e)}catch(t){setTimeout(()=>{throw t},0)}},0)}),typeof globalThis=="undefined"&&(globalThis.global=globalThis),typeof Pa=="undefined"){let r=null;try{typeof require!="undefined"&&(r=require("buffer").Buffer)}catch(e){}r?globalThis.Buffer=r:globalThis.Buffer={isBuffer:e=>!1,from:e=>new Uint8Array(e),alloc:e=>new Uint8Array(e),allocUnsafe:e=>new Uint8Array(e)}}typeof setImmediate=="undefined"&&(globalThis.setImmediate=(r,...e)=>setTimeout(()=>r(...e),0)),typeof clearImmediate=="undefined"&&(globalThis.clearImmediate=r=>{clearTimeout(r)});var Ta=Object.defineProperty,Aa=(r,e,t)=>e in r?Ta(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ot=(r,e,t)=>Aa(r,typeof e!="symbol"?e+"":e,t),tt=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class Wn{constructor(e,t,s="/apis/video-call"){ot(this,"socket",null),ot(this,"serverUrl"),ot(this,"socketPath"),ot(this,"token"),ot(this,"connected",!1),ot(this,"reconnectAttempts",0),ot(this,"maxReconnectAttempts",5),this.serverUrl=e,this.token=t,this.socketPath=s}connect(){return tt(this,null,function*(){return this.socket&&this.socket.connected?Promise.resolve():(this.socket&&(this.socket.removeAllListeners(),this.socket.disconnect(),this.socket=null),new Promise((e,t)=>{try{this.socket=ve.io(this.serverUrl,{path:this.socketPath,transports:["websocket","polling"],timeout:1e4,forceNew:!0,auth:{token:this.token}}),this.socket.on("connect",()=>{this.connected=!0,this.reconnectAttempts=0,console.log("[CallSocket] Connected to signaling server"),e()}),this.socket.on("disconnect",s=>{this.connected=!1,console.log("[CallSocket] Disconnected:",s),this.handleDisconnection(s)}),this.socket.on("connect_error",s=>{console.error("[CallSocket] Connection error:",s),this.reconnectAttempts++,this.reconnectAttempts>=this.maxReconnectAttempts&&t(new Error(`Failed to connect after ${this.maxReconnectAttempts} attempts`))})}catch(s){t(s)}}))})}disconnect(){this.socket&&(this.socket.removeAllListeners(),this.socket.disconnect(),this.socket=null,this.connected=!1)}isConnected(){var e;return this.connected&&((e=this.socket)==null?void 0:e.connected)===!0}emit(e,t){var s;if(!this.isConnected())throw new Error("Socket not connected");console.log(`[CallSocket] Emitting ${e}:`,t),(s=this.socket)==null||s.emit(e,t,c=>{c!=null&&c.error&&console.error(`[CallSocket] Error in ${e}:`,c.error)})}emitWithResponse(e,t,s=1e4){return tt(this,null,function*(){if(!this.isConnected())throw new Error("Socket not connected");return console.log(`[CallSocket] Emitting ${e} with response:`,t),new Promise((c,l)=>{var g;const f=setTimeout(()=>{l(new Error(`Timeout waiting for response to ${e}`))},s);console.log(`[CallSocket] about to emit: ${e}...`),(g=this.socket)==null||g.emit(e,t,u=>{clearTimeout(f),u!=null&&u.error?(console.error(`[CallSocket] Error in ${e}:`,u.error),l(new Error(u.error))):(console.log(`[CallSocket] Response for ${e}:`,u),c(u))})})})}on(e,t){if(!this.socket)throw new Error("Socket not connected");this.socket.on(e,t)}off(e,t){this.socket&&(t?this.socket.off(e,t):this.socket.removeAllListeners(e))}startCall(e){return tt(this,null,function*(){return this.emitWithResponse("call.start",{roomId:e})})}joinRoom(e){return tt(this,null,function*(){return this.emitWithResponse("call.join",{roomId:e})})}leaveCall(e){return tt(this,null,function*(){return this.emitWithResponse("call.leave",{roomId:e})})}sendOffer(e,t,s){this.emit("call.offer",{to:e,offer:t,roomId:s})}sendAnswer(e,t,s){this.emit("call.answer",{to:e,answer:t,roomId:s})}sendCandidate(e,t,s){this.emit("call.candidate",{to:e,candidate:t,roomId:s})}sendStateUpdate(e,t,s){this.emit("call.state",{to:e,state:t,roomId:s})}endCall(e,t,s){this.emit("call.end",{roomId:s,targetUserId:e})}endCallForAll(e){return tt(this,null,function*(){this.emit("call.end",{roomId:e})})}startRecording(e,t){return this.emit("call.recording.start",{roomId:e,recordingId:t})}sendRecordingChunk(e,t,s){this.emit("call.recording.chunk",{roomId:e,recordingId:t,chunk:s})}endRecording(e,t,s){return tt(this,null,function*(){return this.emitWithResponse("call.recording.end",{roomId:e,recordingId:t,transcripts:s})})}sendTranscript(e,t){this.emit("call.transcript",{roomId:e,transcript:t,timestamp:Date.now()})}checkCallStatus(e){return tt(this,null,function*(){return this.emitWithResponse("call.status",{roomId:e})})}getIceServers(e){return tt(this,null,function*(){return this.emitWithResponse("call.ice-servers",{roomId:e})})}handleDisconnection(e){["transport close","transport error","io server disconnect"].includes(e)&&this.reconnectAttempts<this.maxReconnectAttempts&&setTimeout(()=>{this.connected||(console.log(`[CallSocket] Attempting to reconnect... (${this.reconnectAttempts+1}/${this.maxReconnectAttempts})`),this.connect().catch(console.error))},Math.pow(2,this.reconnectAttempts)*1e3)}getConnectionInfo(){var e,t;return{connected:this.connected,socketId:(e=this.socket)==null?void 0:e.id,transport:(t=this.socket)==null?void 0:t.io.engine.transport.name,reconnectAttempts:this.reconnectAttempts}}}var Ia=Object.defineProperty,ka=(r,e,t)=>e in r?Ia(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yt=(r,e,t)=>ka(r,typeof e!="symbol"?e+"":e,t),Pt=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class Vn{constructor(e={video:!0,audio:!0}){yt(this,"cameraStream",null),yt(this,"screenStream",null),yt(this,"videoElement",null),yt(this,"constraints"),yt(this,"isScreenShare",!1),this.constraints=e}initialize(){return Pt(this,null,function*(){try{return console.log("[CallMediaStream] Initializing media stream with constraints:",this.constraints),this.cameraStream=yield navigator.mediaDevices.getUserMedia(this.constraints),console.log("[CallMediaStream] Media stream initialized successfully"),this.cameraStream}catch(e){throw console.error("[CallMediaStream] Failed to initialize media stream:",e),this.handleMediaError(e)}})}startScreenShare(){return Pt(this,arguments,function*(e={video:!0,audio:!1}){try{return console.log("[CallMediaStream] Starting screen share"),this.screenStream=yield navigator.mediaDevices.getDisplayMedia({video:e.video,audio:e.audio}),this.isScreenShare=!0,this.screenStream.getVideoTracks()[0].addEventListener("ended",()=>{console.log("[CallMediaStream] Screen share ended by user"),this.stopScreenShare()}),console.log("[CallMediaStream] Screen share started successfully"),this.screenStream}catch(t){throw console.error("[CallMediaStream] Failed to start screen share:",t),this.handleMediaError(t)}})}stopScreenShare(){return Pt(this,null,function*(){try{if(console.log("[CallMediaStream] Stopping screen share"),this.screenStream&&this.isScreenShare&&(this.screenStream.getTracks().forEach(e=>e.stop()),this.screenStream=null),!this.cameraStream)this.cameraStream=yield this.initialize();else{const e=this.cameraStream.getVideoTracks();(e.length===0||e[0].readyState==="ended")&&(console.log("[CallMediaStream] Camera stream is inactive, reinitializing"),this.cameraStream=yield this.initialize())}return this.isScreenShare=!1,console.log("[CallMediaStream] Reverted to camera stream"),this.cameraStream}catch(e){throw console.error("[CallMediaStream] Failed to stop screen share:",e),this.handleMediaError(e)}})}toggleAudio(e){const t=this.getCurrentStream();if(!t){console.warn("[CallMediaStream] No stream available for audio toggle");return}t.getAudioTracks().forEach(c=>{c.enabled=e}),console.log(`[CallMediaStream] Audio ${e?"enabled":"disabled"}`)}toggleVideo(e){const t=this.getCurrentStream();if(!t){console.warn("[CallMediaStream] No stream available for video toggle");return}t.getVideoTracks().forEach(c=>{c.enabled=e}),console.log(`[CallMediaStream] Video ${e?"enabled":"disabled"}`)}createVideoElement(){const e=document.createElement("video");e.autoplay=!0,e.playsInline=!0,e.muted=!0;const t=this.getCurrentStream();return t&&(e.srcObject=t),this.videoElement=e,e}attachToVideoElement(e){const t=this.getCurrentStream();t&&(e.srcObject=t,this.videoElement=e)}replaceStream(e){const t=this.getCurrentStream();t&&t.getTracks().forEach(s=>s.stop()),this.isScreenShare?this.screenStream=e:this.cameraStream=e,this.videoElement&&(this.videoElement.srcObject=e),console.log("[CallMediaStream] Stream replaced successfully")}getCurrentStream(){return this.isScreenShare?this.screenStream:this.cameraStream}getStream(){return this.getCurrentStream()}getCameraStream(){return this.cameraStream}getScreenStream(){return this.screenStream}getVideoElement(){return this.videoElement}getIsScreenShare(){return this.isScreenShare}isAudioEnabled(){const e=this.getCurrentStream();if(!e)return!1;const t=e.getAudioTracks();return t.length>0&&t[0].enabled}isVideoEnabled(){const e=this.getCurrentStream();if(!e)return!1;const t=e.getVideoTracks();return t.length>0&&t[0].enabled}getStreamInfo(){const e=this.getCurrentStream();if(!e)return null;const t=e.getVideoTracks(),s=e.getAudioTracks();return{id:e.id,videoTracks:t.length,audioTracks:s.length,isScreenShare:this.isScreenShare,videoEnabled:t.length>0?t[0].enabled:!1,audioEnabled:s.length>0?s[0].enabled:!1,videoConstraints:t.length>0?t[0].getSettings():null,audioConstraints:s.length>0?s[0].getSettings():null,hasCameraStream:!!this.cameraStream,hasScreenStream:!!this.screenStream}}getVideoTrack(){const e=this.getCurrentStream();if(!e)return null;const t=e.getVideoTracks();return t.length>0?t[0]:null}getAudioTrack(){const e=this.getCurrentStream();if(!e)return null;const t=e.getAudioTracks();return t.length>0?t[0]:null}getCameraVideoTrack(){if(!this.cameraStream)return null;const e=this.cameraStream.getVideoTracks();return e.length>0?e[0]:null}getScreenVideoTrack(){if(!this.screenStream)return null;const e=this.screenStream.getVideoTracks();return e.length>0?e[0]:null}cleanup(){console.log("[CallMediaStream] Cleaning up media stream"),this.cameraStream&&(this.cameraStream.getTracks().forEach(e=>{e.stop()}),this.cameraStream=null),this.screenStream&&(this.screenStream.getTracks().forEach(e=>{e.stop()}),this.screenStream=null),this.videoElement&&(this.videoElement.srcObject=null,this.videoElement=null),this.isScreenShare=!1}handleMediaError(e){let t="Unknown media error";return e.name==="NotAllowedError"?t="Permission denied. Please allow camera and microphone access.":e.name==="NotFoundError"?t="No camera or microphone found. Please check your devices.":e.name==="NotReadableError"?t="Camera or microphone is already in use by another application.":e.name==="OverconstrainedError"?t="Camera or microphone does not support the requested constraints.":e.name==="SecurityError"?t="Media access blocked due to security restrictions.":e.name==="AbortError"&&(t="Media access was aborted."),new Error(`${t} (${e.name})`)}static getAvailableDevices(){return Pt(this,null,function*(){try{const e=yield navigator.mediaDevices.enumerateDevices();return{videoDevices:e.filter(t=>t.kind==="videoinput"),audioDevices:e.filter(t=>t.kind==="audioinput")}}catch(e){throw console.error("[CallMediaStream] Failed to get available devices:",e),e}})}static checkBrowserSupport(){return{getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),webRTC:!!window.RTCPeerConnection}}}function Gt(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Tt={exports:{}},zt,Gn;function Ba(){if(Gn)return zt;Gn=1;var r=1e3,e=r*60,t=e*60,s=t*24,c=s*7,l=s*365.25;zt=function(h,k){k=k||{};var I=typeof h;if(I==="string"&&h.length>0)return g(h);if(I==="number"&&isFinite(h))return k.long?u(h):f(h);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(h))};function g(h){if(h=String(h),!(h.length>100)){var k=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(k){var I=parseFloat(k[1]),V=(k[2]||"ms").toLowerCase();switch(V){case"years":case"year":case"yrs":case"yr":case"y":return I*l;case"weeks":case"week":case"w":return I*c;case"days":case"day":case"d":return I*s;case"hours":case"hour":case"hrs":case"hr":case"h":return I*t;case"minutes":case"minute":case"mins":case"min":case"m":return I*e;case"seconds":case"second":case"secs":case"sec":case"s":return I*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return I;default:return}}}}function f(h){var k=Math.abs(h);return k>=s?Math.round(h/s)+"d":k>=t?Math.round(h/t)+"h":k>=e?Math.round(h/e)+"m":k>=r?Math.round(h/r)+"s":h+"ms"}function u(h){var k=Math.abs(h);return k>=s?m(h,k,s,"day"):k>=t?m(h,k,t,"hour"):k>=e?m(h,k,e,"minute"):k>=r?m(h,k,r,"second"):h+" ms"}function m(h,k,I,V){var b=k>=I*1.5;return Math.round(h/I)+" "+V+(b?"s":"")}return zt}var Ht,zn;function Oa(){if(zn)return Ht;zn=1;function r(e){s.debug=s,s.default=s,s.coerce=m,s.disable=f,s.enable=l,s.enabled=u,s.humanize=Ba(),s.destroy=h,Object.keys(e).forEach(k=>{s[k]=e[k]}),s.names=[],s.skips=[],s.formatters={};function t(k){let I=0;for(let V=0;V<k.length;V++)I=(I<<5)-I+k.charCodeAt(V),I|=0;return s.colors[Math.abs(I)%s.colors.length]}s.selectColor=t;function s(k){let I,V=null,b,B;function P(...y){if(!P.enabled)return;const C=P,A=Number(new Date),T=A-(I||A);C.diff=T,C.prev=I,C.curr=A,I=A,y[0]=s.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let O=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(R,M)=>{if(R==="%%")return"%";O++;const G=s.formatters[M];if(typeof G=="function"){const Q=y[O];R=G.call(C,Q),y.splice(O,1),O--}return R}),s.formatArgs.call(C,y),(C.log||s.log).apply(C,y)}return P.namespace=k,P.useColors=s.useColors(),P.color=s.selectColor(k),P.extend=c,P.destroy=s.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>V!==null?V:(b!==s.namespaces&&(b=s.namespaces,B=s.enabled(k)),B),set:y=>{V=y}}),typeof s.init=="function"&&s.init(P),P}function c(k,I){const V=s(this.namespace+(typeof I=="undefined"?":":I)+k);return V.log=this.log,V}function l(k){s.save(k),s.namespaces=k,s.names=[],s.skips=[];const I=(typeof k=="string"?k:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const V of I)V[0]==="-"?s.skips.push(V.slice(1)):s.names.push(V)}function g(k,I){let V=0,b=0,B=-1,P=0;for(;V<k.length;)if(b<I.length&&(I[b]===k[V]||I[b]==="*"))I[b]==="*"?(B=b,P=V,b++):(V++,b++);else if(B!==-1)b=B+1,P++,V=P;else return!1;for(;b<I.length&&I[b]==="*";)b++;return b===I.length}function f(){const k=[...s.names,...s.skips.map(I=>"-"+I)].join(",");return s.enable(""),k}function u(k){for(const I of s.skips)if(g(k,I))return!1;for(const I of s.names)if(g(k,I))return!0;return!1}function m(k){return k instanceof Error?k.stack||k.message:k}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return s.enable(s.load()),s}return Ht=r,Ht}var Hn;function Ma(){return Hn||(Hn=1,function(r,e){e.formatArgs=s,e.save=c,e.load=l,e.useColors=t,e.storage=g(),e.destroy=(()=>{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){if(typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let u;return typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&(u=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(u[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function s(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+r.exports.humanize(this.diff),!this.useColors)return;const m="color: "+this.color;u.splice(1,0,m,"color: inherit");let h=0,k=0;u[0].replace(/%[a-zA-Z%]/g,I=>{I!=="%%"&&(h++,I==="%c"&&(k=h))}),u.splice(k,0,m)}e.log=console.debug||console.log||(()=>{});function c(u){try{u?e.storage.setItem("debug",u):e.storage.removeItem("debug")}catch(m){}}function l(){let u;try{u=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch(m){}return!u&&typeof le!="undefined"&&"env"in le&&(u=le.env.DEBUG),u}function g(){try{return localStorage}catch(u){}}r.exports=Oa()(e);const{formatters:f}=r.exports;f.j=function(u){try{return JSON.stringify(u)}catch(m){return"[UnexpectedJSONParseError]: "+m.message}}}(Tt,Tt.exports)),Tt.exports}var Yt,Yn;function Na(){return Yn||(Yn=1,Yt=function(){if(typeof globalThis=="undefined")return null;var e={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}),Yt}var At={exports:{}},It={exports:{}},Jt={},Jn;function mt(){return Jn||(Jn=1,function(r){Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},t={};t.byteLength=h,t.toByteArray=I,t.fromByteArray=B;for(var s=[],c=[],l=typeof Uint8Array!="undefined"?Uint8Array:Array,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,u=g.length;f<u;++f)s[f]=g[f],c[g.charCodeAt(f)]=f;c[45]=62,c[95]=63;function m(C){var A=C.length;if(A%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var T=C.indexOf("=");T===-1&&(T=A);var O=T===A?0:4-T%4;return[T,O]}function h(C){var A=m(C),T=A[0],O=A[1];return(T+O)*3/4-O}function k(C,A,T){return(A+T)*3/4-T}function I(C){var A,T=m(C),O=T[0],S=T[1],R=new l(k(C,O,S)),M=0,G=S>0?O-4:O,Q;for(Q=0;Q<G;Q+=4)A=c[C.charCodeAt(Q)]<<18|c[C.charCodeAt(Q+1)]<<12|c[C.charCodeAt(Q+2)]<<6|c[C.charCodeAt(Q+3)],R[M++]=A>>16&255,R[M++]=A>>8&255,R[M++]=A&255;return S===2&&(A=c[C.charCodeAt(Q)]<<2|c[C.charCodeAt(Q+1)]>>4,R[M++]=A&255),S===1&&(A=c[C.charCodeAt(Q)]<<10|c[C.charCodeAt(Q+1)]<<4|c[C.charCodeAt(Q+2)]>>2,R[M++]=A>>8&255,R[M++]=A&255),R}function V(C){return s[C>>18&63]+s[C>>12&63]+s[C>>6&63]+s[C&63]}function b(C,A,T){for(var O,S=[],R=A;R<T;R+=3)O=(C[R]<<16&16711680)+(C[R+1]<<8&65280)+(C[R+2]&255),S.push(V(O));return S.join("")}function B(C){for(var A,T=C.length,O=T%3,S=[],R=16383,M=0,G=T-O;M<G;M+=R)S.push(b(C,M,M+R>G?G:M+R));return O===1?(A=C[T-1],S.push(s[A>>2]+s[A<<4&63]+"==")):O===2&&(A=(C[T-2]<<8)+C[T-1],S.push(s[A>>10]+s[A>>4&63]+s[A<<2&63]+"=")),S.join("")}var P={};P.read=function(C,A,T,O,S){var R,M,G=S*8-O-1,Q=(1<<G)-1,ie=Q>>1,U=-7,ge=T?S-1:0,de=T?-1:1,ye=C[A+ge];for(ge+=de,R=ye&(1<<-U)-1,ye>>=-U,U+=G;U>0;R=R*256+C[A+ge],ge+=de,U-=8);for(M=R&(1<<-U)-1,R>>=-U,U+=O;U>0;M=M*256+C[A+ge],ge+=de,U-=8);if(R===0)R=1-ie;else{if(R===Q)return M?NaN:(ye?-1:1)*(1/0);M=M+Math.pow(2,O),R=R-ie}return(ye?-1:1)*M*Math.pow(2,R-O)},P.write=function(C,A,T,O,S,R){var M,G,Q,ie=R*8-S-1,U=(1<<ie)-1,ge=U>>1,de=S===23?Math.pow(2,-24)-Math.pow(2,-77):0,ye=O?0:R-1,Pe=O?1:-1,Te=A<0||A===0&&1/A<0?1:0;for(A=Math.abs(A),isNaN(A)||A===1/0?(G=isNaN(A)?1:0,M=U):(M=Math.floor(Math.log(A)/Math.LN2),A*(Q=Math.pow(2,-M))<1&&(M--,Q*=2),M+ge>=1?A+=de/Q:A+=de*Math.pow(2,1-ge),A*Q>=2&&(M++,Q/=2),M+ge>=U?(G=0,M=U):M+ge>=1?(G=(A*Q-1)*Math.pow(2,S),M=M+ge):(G=A*Math.pow(2,ge-1)*Math.pow(2,S),M=0));S>=8;C[T+ye]=G&255,ye+=Pe,G/=256,S-=8);for(M=M<<S|G,ie+=S;ie>0;C[T+ye]=M&255,ye+=Pe,M/=256,ie-=8);C[T+ye-Pe]|=Te*128};(function(C){const A=t,T=P,O=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;C.Buffer=U,C.SlowBuffer=W,C.INSPECT_MAX_BYTES=50;const S=2147483647;C.kMaxLength=S;const{Uint8Array:R,ArrayBuffer:M,SharedArrayBuffer:G}=globalThis;U.TYPED_ARRAY_SUPPORT=Q(),!U.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Q(){try{const p=new R(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,R.prototype),Object.setPrototypeOf(p,i),p.foo()===42}catch(p){return!1}}Object.defineProperty(U.prototype,"parent",{enumerable:!0,get:function(){if(U.isBuffer(this))return this.buffer}}),Object.defineProperty(U.prototype,"offset",{enumerable:!0,get:function(){if(U.isBuffer(this))return this.byteOffset}});function ie(p){if(p>S)throw new RangeError('The value "'+p+'" is invalid for option "size"');const i=new R(p);return Object.setPrototypeOf(i,U.prototype),i}function U(p,i,a){if(typeof p=="number"){if(typeof i=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Pe(p)}return ge(p,i,a)}U.poolSize=8192;function ge(p,i,a){if(typeof p=="string")return Te(p,i);if(M.isView(p))return we(p);if(p==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p);if(Ze(p,M)||p&&Ze(p.buffer,M)||typeof G!="undefined"&&(Ze(p,G)||p&&Ze(p.buffer,G)))return X(p,i,a);if(typeof p=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const E=p.valueOf&&p.valueOf();if(E!=null&&E!==p)return U.from(E,i,a);const F=ae(p);if(F)return F;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof p[Symbol.toPrimitive]=="function")return U.from(p[Symbol.toPrimitive]("string"),i,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p)}U.from=function(p,i,a){return ge(p,i,a)},Object.setPrototypeOf(U.prototype,R.prototype),Object.setPrototypeOf(U,R);function de(p){if(typeof p!="number")throw new TypeError('"size" argument must be of type number');if(p<0)throw new RangeError('The value "'+p+'" is invalid for option "size"')}function ye(p,i,a){return de(p),p<=0?ie(p):i!==void 0?typeof a=="string"?ie(p).fill(i,a):ie(p).fill(i):ie(p)}U.alloc=function(p,i,a){return ye(p,i,a)};function Pe(p){return de(p),ie(p<0?0:j(p)|0)}U.allocUnsafe=function(p){return Pe(p)},U.allocUnsafeSlow=function(p){return Pe(p)};function Te(p,i){if((typeof i!="string"||i==="")&&(i="utf8"),!U.isEncoding(i))throw new TypeError("Unknown encoding: "+i);const a=z(p,i)|0;let E=ie(a);const F=E.write(p,i);return F!==a&&(E=E.slice(0,F)),E}function Se(p){const i=p.length<0?0:j(p.length)|0,a=ie(i);for(let E=0;E<i;E+=1)a[E]=p[E]&255;return a}function we(p){if(Ze(p,R)){const i=new R(p);return X(i.buffer,i.byteOffset,i.byteLength)}return Se(p)}function X(p,i,a){if(i<0||p.byteLength<i)throw new RangeError('"offset" is outside of buffer bounds');if(p.byteLength<i+(a||0))throw new RangeError('"length" is outside of buffer bounds');let E;return i===void 0&&a===void 0?E=new R(p):a===void 0?E=new R(p,i):E=new R(p,i,a),Object.setPrototypeOf(E,U.prototype),E}function ae(p){if(U.isBuffer(p)){const i=j(p.length)|0,a=ie(i);return a.length===0||p.copy(a,0,0,i),a}if(p.length!==void 0)return typeof p.length!="number"||Mn(p.length)?ie(0):Se(p);if(p.type==="Buffer"&&Array.isArray(p.data))return Se(p.data)}function j(p){if(p>=S)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+S.toString(16)+" bytes");return p|0}function W(p){return+p!=p&&(p=0),U.alloc(+p)}U.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==U.prototype},U.compare=function(i,a){if(Ze(i,R)&&(i=U.from(i,i.offset,i.byteLength)),Ze(a,R)&&(a=U.from(a,a.offset,a.byteLength)),!U.isBuffer(i)||!U.isBuffer(a))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===a)return 0;let E=i.length,F=a.length;for(let $=0,K=Math.min(E,F);$<K;++$)if(i[$]!==a[$]){E=i[$],F=a[$];break}return E<F?-1:F<E?1:0},U.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},U.concat=function(i,a){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return U.alloc(0);let E;if(a===void 0)for(a=0,E=0;E<i.length;++E)a+=i[E].length;const F=U.allocUnsafe(a);let $=0;for(E=0;E<i.length;++E){let K=i[E];if(Ze(K,R))$+K.length>F.length?(U.isBuffer(K)||(K=U.from(K)),K.copy(F,$)):R.prototype.set.call(F,K,$);else if(U.isBuffer(K))K.copy(F,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=K.length}return F};function z(p,i){if(U.isBuffer(p))return p.length;if(M.isView(p)||Ze(p,M))return p.byteLength;if(typeof p!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof p);const a=p.length,E=arguments.length>2&&arguments[2]===!0;if(!E&&a===0)return 0;let F=!1;for(;;)switch(i){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return Ce(p).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a*2;case"hex":return a>>>1;case"base64":return me(p).length;default:if(F)return E?-1:Ce(p).length;i=(""+i).toLowerCase(),F=!0}}U.byteLength=z;function re(p,i,a){let E=!1;if((i===void 0||i<0)&&(i=0),i>this.length||((a===void 0||a>this.length)&&(a=this.length),a<=0)||(a>>>=0,i>>>=0,a<=i))return"";for(p||(p="utf8");;)switch(p){case"hex":return Ue(this,i,a);case"utf8":case"utf-8":return fe(this,i,a);case"ascii":return Fe(this,i,a);case"latin1":case"binary":return Y(this,i,a);case"base64":return te(this,i,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return je(this,i,a);default:if(E)throw new TypeError("Unknown encoding: "+p);p=(p+"").toLowerCase(),E=!0}}U.prototype._isBuffer=!0;function L(p,i,a){const E=p[i];p[i]=p[a],p[a]=E}U.prototype.swap16=function(){const i=this.length;if(i%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let a=0;a<i;a+=2)L(this,a,a+1);return this},U.prototype.swap32=function(){const i=this.length;if(i%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let a=0;a<i;a+=4)L(this,a,a+3),L(this,a+1,a+2);return this},U.prototype.swap64=function(){const i=this.length;if(i%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let a=0;a<i;a+=8)L(this,a,a+7),L(this,a+1,a+6),L(this,a+2,a+5),L(this,a+3,a+4);return this},U.prototype.toString=function(){const i=this.length;return i===0?"":arguments.length===0?fe(this,0,i):re.apply(this,arguments)},U.prototype.toLocaleString=U.prototype.toString,U.prototype.equals=function(i){if(!U.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i?!0:U.compare(this,i)===0},U.prototype.inspect=function(){let i="";const a=C.INSPECT_MAX_BYTES;return i=this.toString("hex",0,a).replace(/(.{2})/g,"$1 ").trim(),this.length>a&&(i+=" ... "),"<Buffer "+i+">"},O&&(U.prototype[O]=U.prototype.inspect),U.prototype.compare=function(i,a,E,F,$){if(Ze(i,R)&&(i=U.from(i,i.offset,i.byteLength)),!U.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(a===void 0&&(a=0),E===void 0&&(E=i?i.length:0),F===void 0&&(F=0),$===void 0&&($=this.length),a<0||E>i.length||F<0||$>this.length)throw new RangeError("out of range index");if(F>=$&&a>=E)return 0;if(F>=$)return-1;if(a>=E)return 1;if(a>>>=0,E>>>=0,F>>>=0,$>>>=0,this===i)return 0;let K=$-F,pe=E-a;const Be=Math.min(K,pe),Ie=this.slice(F,$),Oe=i.slice(a,E);for(let _e=0;_e<Be;++_e)if(Ie[_e]!==Oe[_e]){K=Ie[_e],pe=Oe[_e];break}return K<pe?-1:pe<K?1:0};function D(p,i,a,E,F){if(p.length===0)return-1;if(typeof a=="string"?(E=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,Mn(a)&&(a=F?0:p.length-1),a<0&&(a=p.length+a),a>=p.length){if(F)return-1;a=p.length-1}else if(a<0)if(F)a=0;else return-1;if(typeof i=="string"&&(i=U.from(i,E)),U.isBuffer(i))return i.length===0?-1:q(p,i,a,E,F);if(typeof i=="number")return i=i&255,typeof R.prototype.indexOf=="function"?F?R.prototype.indexOf.call(p,i,a):R.prototype.lastIndexOf.call(p,i,a):q(p,[i],a,E,F);throw new TypeError("val must be string, number or Buffer")}function q(p,i,a,E,F){let $=1,K=p.length,pe=i.length;if(E!==void 0&&(E=String(E).toLowerCase(),E==="ucs2"||E==="ucs-2"||E==="utf16le"||E==="utf-16le")){if(p.length<2||i.length<2)return-1;$=2,K/=2,pe/=2,a/=2}function Be(Oe,_e){return $===1?Oe[_e]:Oe.readUInt16BE(_e*$)}let Ie;if(F){let Oe=-1;for(Ie=a;Ie<K;Ie++)if(Be(p,Ie)===Be(i,Oe===-1?0:Ie-Oe)){if(Oe===-1&&(Oe=Ie),Ie-Oe+1===pe)return Oe*$}else Oe!==-1&&(Ie-=Ie-Oe),Oe=-1}else for(a+pe>K&&(a=K-pe),Ie=a;Ie>=0;Ie--){let Oe=!0;for(let _e=0;_e<pe;_e++)if(Be(p,Ie+_e)!==Be(i,_e)){Oe=!1;break}if(Oe)return Ie}return-1}U.prototype.includes=function(i,a,E){return this.indexOf(i,a,E)!==-1},U.prototype.indexOf=function(i,a,E){return D(this,i,a,E,!0)},U.prototype.lastIndexOf=function(i,a,E){return D(this,i,a,E,!1)};function Z(p,i,a,E){a=Number(a)||0;const F=p.length-a;E?(E=Number(E),E>F&&(E=F)):E=F;const $=i.length;E>$/2&&(E=$/2);let K;for(K=0;K<E;++K){const pe=parseInt(i.substr(K*2,2),16);if(Mn(pe))return K;p[a+K]=pe}return K}function ee(p,i,a,E){return jt(Ce(i,p.length-a),p,a,E)}function v(p,i,a,E){return jt(Re(i),p,a,E)}function w(p,i,a,E){return jt(me(i),p,a,E)}function H(p,i,a,E){return jt(Ae(i,p.length-a),p,a,E)}U.prototype.write=function(i,a,E,F){if(a===void 0)F="utf8",E=this.length,a=0;else if(E===void 0&&typeof a=="string")F=a,E=this.length,a=0;else if(isFinite(a))a=a>>>0,isFinite(E)?(E=E>>>0,F===void 0&&(F="utf8")):(F=E,E=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-a;if((E===void 0||E>$)&&(E=$),i.length>0&&(E<0||a<0)||a>this.length)throw new RangeError("Attempt to write outside buffer bounds");F||(F="utf8");let K=!1;for(;;)switch(F){case"hex":return Z(this,i,a,E);case"utf8":case"utf-8":return ee(this,i,a,E);case"ascii":case"latin1":case"binary":return v(this,i,a,E);case"base64":return w(this,i,a,E);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,i,a,E);default:if(K)throw new TypeError("Unknown encoding: "+F);F=(""+F).toLowerCase(),K=!0}},U.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function te(p,i,a){return i===0&&a===p.length?A.fromByteArray(p):A.fromByteArray(p.slice(i,a))}function fe(p,i,a){a=Math.min(p.length,a);const E=[];let F=i;for(;F<a;){const $=p[F];let K=null,pe=$>239?4:$>223?3:$>191?2:1;if(F+pe<=a){let Be,Ie,Oe,_e;switch(pe){case 1:$<128&&(K=$);break;case 2:Be=p[F+1],(Be&192)===128&&(_e=($&31)<<6|Be&63,_e>127&&(K=_e));break;case 3:Be=p[F+1],Ie=p[F+2],(Be&192)===128&&(Ie&192)===128&&(_e=($&15)<<12|(Be&63)<<6|Ie&63,_e>2047&&(_e<55296||_e>57343)&&(K=_e));break;case 4:Be=p[F+1],Ie=p[F+2],Oe=p[F+3],(Be&192)===128&&(Ie&192)===128&&(Oe&192)===128&&(_e=($&15)<<18|(Be&63)<<12|(Ie&63)<<6|Oe&63,_e>65535&&_e<1114112&&(K=_e))}}K===null?(K=65533,pe=1):K>65535&&(K-=65536,E.push(K>>>10&1023|55296),K=56320|K&1023),E.push(K),F+=pe}return ue(E)}const oe=4096;function ue(p){const i=p.length;if(i<=oe)return String.fromCharCode.apply(String,p);let a="",E=0;for(;E<i;)a+=String.fromCharCode.apply(String,p.slice(E,E+=oe));return a}function Fe(p,i,a){let E="";a=Math.min(p.length,a);for(let F=i;F<a;++F)E+=String.fromCharCode(p[F]&127);return E}function Y(p,i,a){let E="";a=Math.min(p.length,a);for(let F=i;F<a;++F)E+=String.fromCharCode(p[F]);return E}function Ue(p,i,a){const E=p.length;(!i||i<0)&&(i=0),(!a||a<0||a>E)&&(a=E);let F="";for(let $=i;$<a;++$)F+=Gl[p[$]];return F}function je(p,i,a){const E=p.slice(i,a);let F="";for(let $=0;$<E.length-1;$+=2)F+=String.fromCharCode(E[$]+E[$+1]*256);return F}U.prototype.slice=function(i,a){const E=this.length;i=~~i,a=a===void 0?E:~~a,i<0?(i+=E,i<0&&(i=0)):i>E&&(i=E),a<0?(a+=E,a<0&&(a=0)):a>E&&(a=E),a<i&&(a=i);const F=this.subarray(i,a);return Object.setPrototypeOf(F,U.prototype),F};function be(p,i,a){if(p%1!==0||p<0)throw new RangeError("offset is not uint");if(p+i>a)throw new RangeError("Trying to access beyond buffer length")}U.prototype.readUintLE=U.prototype.readUIntLE=function(i,a,E){i=i>>>0,a=a>>>0,E||be(i,a,this.length);let F=this[i],$=1,K=0;for(;++K<a&&($*=256);)F+=this[i+K]*$;return F},U.prototype.readUintBE=U.prototype.readUIntBE=function(i,a,E){i=i>>>0,a=a>>>0,E||be(i,a,this.length);let F=this[i+--a],$=1;for(;a>0&&($*=256);)F+=this[i+--a]*$;return F},U.prototype.readUint8=U.prototype.readUInt8=function(i,a){return i=i>>>0,a||be(i,1,this.length),this[i]},U.prototype.readUint16LE=U.prototype.readUInt16LE=function(i,a){return i=i>>>0,a||be(i,2,this.length),this[i]|this[i+1]<<8},U.prototype.readUint16BE=U.prototype.readUInt16BE=function(i,a){return i=i>>>0,a||be(i,2,this.length),this[i]<<8|this[i+1]},U.prototype.readUint32LE=U.prototype.readUInt32LE=function(i,a){return i=i>>>0,a||be(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+this[i+3]*16777216},U.prototype.readUint32BE=U.prototype.readUInt32BE=function(i,a){return i=i>>>0,a||be(i,4,this.length),this[i]*16777216+(this[i+1]<<16|this[i+2]<<8|this[i+3])},U.prototype.readBigUInt64LE=nt(function(i){i=i>>>0,N(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&x(i,this.length-8);const F=a+this[++i]*se(2,8)+this[++i]*se(2,16)+this[++i]*se(2,24),$=this[++i]+this[++i]*se(2,8)+this[++i]*se(2,16)+E*se(2,24);return BigInt(F)+(BigInt($)<<BigInt(32))}),U.prototype.readBigUInt64BE=nt(function(i){i=i>>>0,N(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&x(i,this.length-8);const F=a*se(2,24)+this[++i]*se(2,16)+this[++i]*se(2,8)+this[++i],$=this[++i]*se(2,24)+this[++i]*se(2,16)+this[++i]*se(2,8)+E;return(BigInt(F)<<BigInt(32))+BigInt($)}),U.prototype.readIntLE=function(i,a,E){i=i>>>0,a=a>>>0,E||be(i,a,this.length);let F=this[i],$=1,K=0;for(;++K<a&&($*=256);)F+=this[i+K]*$;return $*=128,F>=$&&(F-=Math.pow(2,8*a)),F},U.prototype.readIntBE=function(i,a,E){i=i>>>0,a=a>>>0,E||be(i,a,this.length);let F=a,$=1,K=this[i+--F];for(;F>0&&($*=256);)K+=this[i+--F]*$;return $*=128,K>=$&&(K-=Math.pow(2,8*a)),K},U.prototype.readInt8=function(i,a){return i=i>>>0,a||be(i,1,this.length),this[i]&128?(255-this[i]+1)*-1:this[i]},U.prototype.readInt16LE=function(i,a){i=i>>>0,a||be(i,2,this.length);const E=this[i]|this[i+1]<<8;return E&32768?E|4294901760:E},U.prototype.readInt16BE=function(i,a){i=i>>>0,a||be(i,2,this.length);const E=this[i+1]|this[i]<<8;return E&32768?E|4294901760:E},U.prototype.readInt32LE=function(i,a){return i=i>>>0,a||be(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},U.prototype.readInt32BE=function(i,a){return i=i>>>0,a||be(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},U.prototype.readBigInt64LE=nt(function(i){i=i>>>0,N(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&x(i,this.length-8);const F=this[i+4]+this[i+5]*se(2,8)+this[i+6]*se(2,16)+(E<<24);return(BigInt(F)<<BigInt(32))+BigInt(a+this[++i]*se(2,8)+this[++i]*se(2,16)+this[++i]*se(2,24))}),U.prototype.readBigInt64BE=nt(function(i){i=i>>>0,N(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&x(i,this.length-8);const F=(a<<24)+this[++i]*se(2,16)+this[++i]*se(2,8)+this[++i];return(BigInt(F)<<BigInt(32))+BigInt(this[++i]*se(2,24)+this[++i]*se(2,16)+this[++i]*se(2,8)+E)}),U.prototype.readFloatLE=function(i,a){return i=i>>>0,a||be(i,4,this.length),T.read(this,i,!0,23,4)},U.prototype.readFloatBE=function(i,a){return i=i>>>0,a||be(i,4,this.length),T.read(this,i,!1,23,4)},U.prototype.readDoubleLE=function(i,a){return i=i>>>0,a||be(i,8,this.length),T.read(this,i,!0,52,8)},U.prototype.readDoubleBE=function(i,a){return i=i>>>0,a||be(i,8,this.length),T.read(this,i,!1,52,8)};function Ee(p,i,a,E,F,$){if(!U.isBuffer(p))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>F||i<$)throw new RangeError('"value" argument is out of bounds');if(a+E>p.length)throw new RangeError("Index out of range")}U.prototype.writeUintLE=U.prototype.writeUIntLE=function(i,a,E,F){if(i=+i,a=a>>>0,E=E>>>0,!F){const pe=Math.pow(2,8*E)-1;Ee(this,i,a,E,pe,0)}let $=1,K=0;for(this[a]=i&255;++K<E&&($*=256);)this[a+K]=i/$&255;return a+E},U.prototype.writeUintBE=U.prototype.writeUIntBE=function(i,a,E,F){if(i=+i,a=a>>>0,E=E>>>0,!F){const pe=Math.pow(2,8*E)-1;Ee(this,i,a,E,pe,0)}let $=E-1,K=1;for(this[a+$]=i&255;--$>=0&&(K*=256);)this[a+$]=i/K&255;return a+E},U.prototype.writeUint8=U.prototype.writeUInt8=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,1,255,0),this[a]=i&255,a+1},U.prototype.writeUint16LE=U.prototype.writeUInt16LE=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,2,65535,0),this[a]=i&255,this[a+1]=i>>>8,a+2},U.prototype.writeUint16BE=U.prototype.writeUInt16BE=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,2,65535,0),this[a]=i>>>8,this[a+1]=i&255,a+2},U.prototype.writeUint32LE=U.prototype.writeUInt32LE=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,4,4294967295,0),this[a+3]=i>>>24,this[a+2]=i>>>16,this[a+1]=i>>>8,this[a]=i&255,a+4},U.prototype.writeUint32BE=U.prototype.writeUInt32BE=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,4,4294967295,0),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4};function xe(p,i,a,E,F){_(i,E,F,p,a,7);let $=Number(i&BigInt(4294967295));p[a++]=$,$=$>>8,p[a++]=$,$=$>>8,p[a++]=$,$=$>>8,p[a++]=$;let K=Number(i>>BigInt(32)&BigInt(4294967295));return p[a++]=K,K=K>>8,p[a++]=K,K=K>>8,p[a++]=K,K=K>>8,p[a++]=K,a}function De(p,i,a,E,F){_(i,E,F,p,a,7);let $=Number(i&BigInt(4294967295));p[a+7]=$,$=$>>8,p[a+6]=$,$=$>>8,p[a+5]=$,$=$>>8,p[a+4]=$;let K=Number(i>>BigInt(32)&BigInt(4294967295));return p[a+3]=K,K=K>>8,p[a+2]=K,K=K>>8,p[a+1]=K,K=K>>8,p[a]=K,a+8}U.prototype.writeBigUInt64LE=nt(function(i,a=0){return xe(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),U.prototype.writeBigUInt64BE=nt(function(i,a=0){return De(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),U.prototype.writeIntLE=function(i,a,E,F){if(i=+i,a=a>>>0,!F){const Be=Math.pow(2,8*E-1);Ee(this,i,a,E,Be-1,-Be)}let $=0,K=1,pe=0;for(this[a]=i&255;++$<E&&(K*=256);)i<0&&pe===0&&this[a+$-1]!==0&&(pe=1),this[a+$]=(i/K>>0)-pe&255;return a+E},U.prototype.writeIntBE=function(i,a,E,F){if(i=+i,a=a>>>0,!F){const Be=Math.pow(2,8*E-1);Ee(this,i,a,E,Be-1,-Be)}let $=E-1,K=1,pe=0;for(this[a+$]=i&255;--$>=0&&(K*=256);)i<0&&pe===0&&this[a+$+1]!==0&&(pe=1),this[a+$]=(i/K>>0)-pe&255;return a+E},U.prototype.writeInt8=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,1,127,-128),i<0&&(i=255+i+1),this[a]=i&255,a+1},U.prototype.writeInt16LE=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,2,32767,-32768),this[a]=i&255,this[a+1]=i>>>8,a+2},U.prototype.writeInt16BE=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,2,32767,-32768),this[a]=i>>>8,this[a+1]=i&255,a+2},U.prototype.writeInt32LE=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,4,2147483647,-2147483648),this[a]=i&255,this[a+1]=i>>>8,this[a+2]=i>>>16,this[a+3]=i>>>24,a+4},U.prototype.writeInt32BE=function(i,a,E){return i=+i,a=a>>>0,E||Ee(this,i,a,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4},U.prototype.writeBigInt64LE=nt(function(i,a=0){return xe(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),U.prototype.writeBigInt64BE=nt(function(i,a=0){return De(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function We(p,i,a,E,F,$){if(a+E>p.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function Ge(p,i,a,E,F){return i=+i,a=a>>>0,F||We(p,i,a,4),T.write(p,i,a,E,23,4),a+4}U.prototype.writeFloatLE=function(i,a,E){return Ge(this,i,a,!0,E)},U.prototype.writeFloatBE=function(i,a,E){return Ge(this,i,a,!1,E)};function Le(p,i,a,E,F){return i=+i,a=a>>>0,F||We(p,i,a,8),T.write(p,i,a,E,52,8),a+8}U.prototype.writeDoubleLE=function(i,a,E){return Le(this,i,a,!0,E)},U.prototype.writeDoubleBE=function(i,a,E){return Le(this,i,a,!1,E)},U.prototype.copy=function(i,a,E,F){if(!U.isBuffer(i))throw new TypeError("argument should be a Buffer");if(E||(E=0),!F&&F!==0&&(F=this.length),a>=i.length&&(a=i.length),a||(a=0),F>0&&F<E&&(F=E),F===E||i.length===0||this.length===0)return 0;if(a<0)throw new RangeError("targetStart out of bounds");if(E<0||E>=this.length)throw new RangeError("Index out of range");if(F<0)throw new RangeError("sourceEnd out of bounds");F>this.length&&(F=this.length),i.length-a<F-E&&(F=i.length-a+E);const $=F-E;return this===i&&typeof R.prototype.copyWithin=="function"?this.copyWithin(a,E,F):R.prototype.set.call(i,this.subarray(E,F),a),$},U.prototype.fill=function(i,a,E,F){if(typeof i=="string"){if(typeof a=="string"?(F=a,a=0,E=this.length):typeof E=="string"&&(F=E,E=this.length),F!==void 0&&typeof F!="string")throw new TypeError("encoding must be a string");if(typeof F=="string"&&!U.isEncoding(F))throw new TypeError("Unknown encoding: "+F);if(i.length===1){const K=i.charCodeAt(0);(F==="utf8"&&K<128||F==="latin1")&&(i=K)}}else typeof i=="number"?i=i&255:typeof i=="boolean"&&(i=Number(i));if(a<0||this.length<a||this.length<E)throw new RangeError("Out of range index");if(E<=a)return this;a=a>>>0,E=E===void 0?this.length:E>>>0,i||(i=0);let $;if(typeof i=="number")for($=a;$<E;++$)this[$]=i;else{const K=U.isBuffer(i)?i:U.from(i,F),pe=K.length;if(pe===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for($=0;$<E-a;++$)this[$+a]=K[$%pe]}return this};const rt={};function d(p,i,a){rt[p]=class extends a{constructor(){super(),Object.defineProperty(this,"message",{value:i.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${p}]`,this.stack,delete this.name}get code(){return p}set code(F){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:F,writable:!0})}toString(){return`${this.name} [${p}]: ${this.message}`}}}d("ERR_BUFFER_OUT_OF_BOUNDS",function(p){return p?`${p} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),d("ERR_INVALID_ARG_TYPE",function(p,i){return`The "${p}" argument must be of type number. Received type ${typeof i}`},TypeError),d("ERR_OUT_OF_RANGE",function(p,i,a){let E=`The value of "${p}" is out of range.`,F=a;return Number.isInteger(a)&&Math.abs(a)>se(2,32)?F=n(String(a)):typeof a=="bigint"&&(F=String(a),(a>se(BigInt(2),BigInt(32))||a<-se(BigInt(2),BigInt(32)))&&(F=n(F)),F+="n"),E+=` It must be ${i}. Received ${F}`,E},RangeError);function n(p){let i="",a=p.length;const E=p[0]==="-"?1:0;for(;a>=E+4;a-=3)i=`_${p.slice(a-3,a)}${i}`;return`${p.slice(0,a)}${i}`}function o(p,i,a){N(i,"offset"),(p[i]===void 0||p[i+a]===void 0)&&x(i,p.length-(a+1))}function _(p,i,a,E,F,$){if(p>a||p<i){const K=typeof i=="bigint"?"n":"";let pe;throw i===0||i===BigInt(0)?pe=`>= 0${K} and < 2${K} ** ${($+1)*8}${K}`:pe=`>= -(2${K} ** ${($+1)*8-1}${K}) and < 2 ** ${($+1)*8-1}${K}`,new rt.ERR_OUT_OF_RANGE("value",pe,p)}o(E,F,$)}function N(p,i){if(typeof p!="number")throw new rt.ERR_INVALID_ARG_TYPE(i,"number",p)}function x(p,i,a){throw Math.floor(p)!==p?(N(p,a),new rt.ERR_OUT_OF_RANGE("offset","an integer",p)):i<0?new rt.ERR_BUFFER_OUT_OF_BOUNDS:new rt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${i}`,p)}const J=/[^+/0-9A-Za-z-_]/g;function he(p){if(p=p.split("=")[0],p=p.trim().replace(J,""),p.length<2)return"";for(;p.length%4!==0;)p=p+"=";return p}function Ce(p,i){i=i||1/0;let a;const E=p.length;let F=null;const $=[];for(let K=0;K<E;++K){if(a=p.charCodeAt(K),a>55295&&a<57344){if(!F){if(a>56319){(i-=3)>-1&&$.push(239,191,189);continue}else if(K+1===E){(i-=3)>-1&&$.push(239,191,189);continue}F=a;continue}if(a<56320){(i-=3)>-1&&$.push(239,191,189),F=a;continue}a=(F-55296<<10|a-56320)+65536}else F&&(i-=3)>-1&&$.push(239,191,189);if(F=null,a<128){if((i-=1)<0)break;$.push(a)}else if(a<2048){if((i-=2)<0)break;$.push(a>>6|192,a&63|128)}else if(a<65536){if((i-=3)<0)break;$.push(a>>12|224,a>>6&63|128,a&63|128)}else if(a<1114112){if((i-=4)<0)break;$.push(a>>18|240,a>>12&63|128,a>>6&63|128,a&63|128)}else throw new Error("Invalid code point")}return $}function Re(p){const i=[];for(let a=0;a<p.length;++a)i.push(p.charCodeAt(a)&255);return i}function Ae(p,i){let a,E,F;const $=[];for(let K=0;K<p.length&&!((i-=2)<0);++K)a=p.charCodeAt(K),E=a>>8,F=a%256,$.push(F),$.push(E);return $}function me(p){return A.toByteArray(he(p))}function jt(p,i,a,E){let F;for(F=0;F<E&&!(F+a>=i.length||F>=p.length);++F)i[F+a]=p[F];return F}function Ze(p,i){return p instanceof i||p!=null&&p.constructor!=null&&p.constructor.name!=null&&p.constructor.name===i.name}function Mn(p){return p!==p}const Gl=function(){const p="0123456789abcdef",i=new Array(256);for(let a=0;a<16;++a){const E=a*16;for(let F=0;F<16;++F)i[E+F]=p[a]+p[F]}return i}();function nt(p){return typeof BigInt=="undefined"?zl:p}function zl(){throw new Error("BigInt not supported")}})(e);const y=e.Buffer;r.Blob=e.Blob,r.BlobOptions=e.BlobOptions,r.Buffer=e.Buffer,r.File=e.File,r.FileOptions=e.FileOptions,r.INSPECT_MAX_BYTES=e.INSPECT_MAX_BYTES,r.SlowBuffer=e.SlowBuffer,r.TranscodeEncoding=e.TranscodeEncoding,r.atob=e.atob,r.btoa=e.btoa,r.constants=e.constants,r.default=y,r.isAscii=e.isAscii,r.isUtf8=e.isUtf8,r.kMaxLength=e.kMaxLength,r.kStringMaxLength=e.kStringMaxLength,r.resolveObjectURL=e.resolveObjectURL,r.transcode=e.transcode}(Jt)),Jt}var Kn;function Xn(){return Kn||(Kn=1,function(r,e){var t=mt(),s=t.Buffer;function c(g,f){for(var u in g)f[u]=g[u]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?r.exports=t:(c(t,e),e.Buffer=l);function l(g,f,u){return s(g,f,u)}l.prototype=Object.create(s.prototype),c(s,l),l.from=function(g,f,u){if(typeof g=="number")throw new TypeError("Argument must not be a number");return s(g,f,u)},l.alloc=function(g,f,u){if(typeof g!="number")throw new TypeError("Argument must be a number");var m=s(g);return f!==void 0?typeof u=="string"?m.fill(f,u):m.fill(f):m.fill(0),m},l.allocUnsafe=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return s(g)},l.allocUnsafeSlow=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(g)}}(It,It.exports)),It.exports}var Zn;function La(){if(Zn)return At.exports;Zn=1;var r=65536,e=4294967295;function t(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
2
|
-
Use Chrome, Firefox or Internet Explorer 11`)}var s=Xn().Buffer,c=globalThis.crypto||globalThis.msCrypto;c&&c.getRandomValues?At.exports=l:At.exports=t;function l(g,f){if(g>e)throw new RangeError("requested too many random bytes");var u=s.allocUnsafe(g);if(g>0)if(g>r)for(var m=0;m<g;m+=r)c.getRandomValues(u.slice(m,m+r));else c.getRandomValues(u);return typeof f=="function"?le.nextTick(function(){f(null,u)}):u}return At.exports}var kt={exports:{}},Bt={exports:{}},Qn;function Kt(){if(Qn)return Bt.exports;Qn=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(O,S,R){return Function.prototype.apply.call(O,S,R)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(O){return Object.getOwnPropertyNames(O).concat(Object.getOwnPropertySymbols(O))}:t=function(O){return Object.getOwnPropertyNames(O)};function s(T){console&&console.warn&&console.warn(T)}var c=Number.isNaN||function(O){return O!==O};function l(){l.init.call(this)}Bt.exports=l,Bt.exports.once=y,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var g=10;function f(T){if(typeof T!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof T)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return g},set:function(T){if(typeof T!="number"||T<0||c(T))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+T+".");g=T}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(O){if(typeof O!="number"||O<0||c(O))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+O+".");return this._maxListeners=O,this};function u(T){return T._maxListeners===void 0?l.defaultMaxListeners:T._maxListeners}l.prototype.getMaxListeners=function(){return u(this)},l.prototype.emit=function(O){for(var S=[],R=1;R<arguments.length;R++)S.push(arguments[R]);var M=O==="error",G=this._events;if(G!==void 0)M=M&&G.error===void 0;else if(!M)return!1;if(M){var Q;if(S.length>0&&(Q=S[0]),Q instanceof Error)throw Q;var ie=new Error("Unhandled error."+(Q?" ("+Q.message+")":""));throw ie.context=Q,ie}var U=G[O];if(U===void 0)return!1;if(typeof U=="function")e(U,this,S);else for(var ge=U.length,de=b(U,ge),R=0;R<ge;++R)e(de[R],this,S);return!0};function m(T,O,S,R){var M,G,Q;if(f(S),G=T._events,G===void 0?(G=T._events=Object.create(null),T._eventsCount=0):(G.newListener!==void 0&&(T.emit("newListener",O,S.listener?S.listener:S),G=T._events),Q=G[O]),Q===void 0)Q=G[O]=S,++T._eventsCount;else if(typeof Q=="function"?Q=G[O]=R?[S,Q]:[Q,S]:R?Q.unshift(S):Q.push(S),M=u(T),M>0&&Q.length>M&&!Q.warned){Q.warned=!0;var ie=new Error("Possible EventEmitter memory leak detected. "+Q.length+" "+String(O)+" listeners added. Use emitter.setMaxListeners() to increase limit");ie.name="MaxListenersExceededWarning",ie.emitter=T,ie.type=O,ie.count=Q.length,s(ie)}return T}l.prototype.addListener=function(O,S){return m(this,O,S,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(O,S){return m(this,O,S,!0)};function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function k(T,O,S){var R={fired:!1,wrapFn:void 0,target:T,type:O,listener:S},M=h.bind(R);return M.listener=S,R.wrapFn=M,M}l.prototype.once=function(O,S){return f(S),this.on(O,k(this,O,S)),this},l.prototype.prependOnceListener=function(O,S){return f(S),this.prependListener(O,k(this,O,S)),this},l.prototype.removeListener=function(O,S){var R,M,G,Q,ie;if(f(S),M=this._events,M===void 0)return this;if(R=M[O],R===void 0)return this;if(R===S||R.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete M[O],M.removeListener&&this.emit("removeListener",O,R.listener||S));else if(typeof R!="function"){for(G=-1,Q=R.length-1;Q>=0;Q--)if(R[Q]===S||R[Q].listener===S){ie=R[Q].listener,G=Q;break}if(G<0)return this;G===0?R.shift():B(R,G),R.length===1&&(M[O]=R[0]),M.removeListener!==void 0&&this.emit("removeListener",O,ie||S)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(O){var S,R,M;if(R=this._events,R===void 0)return this;if(R.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):R[O]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete R[O]),this;if(arguments.length===0){var G=Object.keys(R),Q;for(M=0;M<G.length;++M)Q=G[M],Q!=="removeListener"&&this.removeAllListeners(Q);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=R[O],typeof S=="function")this.removeListener(O,S);else if(S!==void 0)for(M=S.length-1;M>=0;M--)this.removeListener(O,S[M]);return this};function I(T,O,S){var R=T._events;if(R===void 0)return[];var M=R[O];return M===void 0?[]:typeof M=="function"?S?[M.listener||M]:[M]:S?P(M):b(M,M.length)}l.prototype.listeners=function(O){return I(this,O,!0)},l.prototype.rawListeners=function(O){return I(this,O,!1)},l.listenerCount=function(T,O){return typeof T.listenerCount=="function"?T.listenerCount(O):V.call(T,O)},l.prototype.listenerCount=V;function V(T){var O=this._events;if(O!==void 0){var S=O[T];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function b(T,O){for(var S=new Array(O),R=0;R<O;++R)S[R]=T[R];return S}function B(T,O){for(;O+1<T.length;O++)T[O]=T[O+1];T.pop()}function P(T){for(var O=new Array(T.length),S=0;S<O.length;++S)O[S]=T[S].listener||T[S];return O}function y(T,O){return new Promise(function(S,R){function M(Q){T.removeListener(O,G),R(Q)}function G(){typeof T.removeListener=="function"&&T.removeListener("error",M),S([].slice.call(arguments))}A(T,O,G,{once:!0}),O!=="error"&&C(T,M,{once:!0})})}function C(T,O,S){typeof T.on=="function"&&A(T,"error",O,S)}function A(T,O,S,R){if(typeof T.on=="function")R.once?T.once(O,S):T.on(O,S);else if(typeof T.addEventListener=="function")T.addEventListener(O,function M(G){R.once&&T.removeEventListener(O,M),S(G)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof T)}return Bt.exports}var Xt,ei;function ti(){return ei||(ei=1,Xt=Kt().EventEmitter),Xt}var Zt={},Qt={},er,ri;function ni(){return ri||(ri=1,er=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),s=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(s)!=="[object Symbol]")return!1;var c=42;e[t]=c;for(var l in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var g=Object.getOwnPropertySymbols(e);if(g.length!==1||g[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var f=Object.getOwnPropertyDescriptor(e,t);if(f.value!==c||f.enumerable!==!0)return!1}return!0}),er}var tr,ii;function Ot(){if(ii)return tr;ii=1;var r=ni();return tr=function(){return r()&&!!Symbol.toStringTag},tr}var rr,oi;function ai(){return oi||(oi=1,rr=Object),rr}var nr,si;function Da(){return si||(si=1,nr=Error),nr}var ir,li;function Fa(){return li||(li=1,ir=EvalError),ir}var or,ci;function Ua(){return ci||(ci=1,or=RangeError),or}var ar,ui;function ja(){return ui||(ui=1,ar=ReferenceError),ar}var sr,fi;function hi(){return fi||(fi=1,sr=SyntaxError),sr}var lr,di;function vt(){return di||(di=1,lr=TypeError),lr}var cr,pi;function xa(){return pi||(pi=1,cr=URIError),cr}var ur,gi;function qa(){return gi||(gi=1,ur=Math.abs),ur}var fr,yi;function $a(){return yi||(yi=1,fr=Math.floor),fr}var hr,mi;function Wa(){return mi||(mi=1,hr=Math.max),hr}var dr,vi;function Va(){return vi||(vi=1,dr=Math.min),dr}var pr,wi;function Ga(){return wi||(wi=1,pr=Math.pow),pr}var gr,bi;function za(){return bi||(bi=1,gr=Math.round),gr}var yr,Si;function Ha(){return Si||(Si=1,yr=Number.isNaN||function(e){return e!==e}),yr}var mr,_i;function Ya(){if(_i)return mr;_i=1;var r=Ha();return mr=function(t){return r(t)||t===0?t:t<0?-1:1},mr}var vr,Ei;function Ja(){return Ei||(Ei=1,vr=Object.getOwnPropertyDescriptor),vr}var wr,Ci;function ct(){if(Ci)return wr;Ci=1;var r=Ja();if(r)try{r([],"length")}catch(e){r=null}return wr=r,wr}var br,Ri;function Mt(){if(Ri)return br;Ri=1;var r=Object.defineProperty||!1;if(r)try{r({},"a",{value:1})}catch(e){r=!1}return br=r,br}var Sr,Pi;function Ka(){if(Pi)return Sr;Pi=1;var r=typeof Symbol!="undefined"&&Symbol,e=ni();return Sr=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Sr}var _r,Ti;function Ai(){return Ti||(Ti=1,_r=typeof Reflect!="undefined"&&Reflect.getPrototypeOf||null),_r}var Er,Ii;function ki(){if(Ii)return Er;Ii=1;var r=ai();return Er=r.getPrototypeOf||null,Er}var Cr,Bi;function Xa(){if(Bi)return Cr;Bi=1;var r="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,t=Math.max,s="[object Function]",c=function(u,m){for(var h=[],k=0;k<u.length;k+=1)h[k]=u[k];for(var I=0;I<m.length;I+=1)h[I+u.length]=m[I];return h},l=function(u,m){for(var h=[],k=m,I=0;k<u.length;k+=1,I+=1)h[I]=u[k];return h},g=function(f,u){for(var m="",h=0;h<f.length;h+=1)m+=f[h],h+1<f.length&&(m+=u);return m};return Cr=function(u){var m=this;if(typeof m!="function"||e.apply(m)!==s)throw new TypeError(r+m);for(var h=l(arguments,1),k,I=function(){if(this instanceof k){var y=m.apply(this,c(h,arguments));return Object(y)===y?y:this}return m.apply(u,c(h,arguments))},V=t(0,m.length-h.length),b=[],B=0;B<V;B++)b[B]="$"+B;if(k=Function("binder","return function ("+g(b,",")+"){ return binder.apply(this,arguments); }")(I),m.prototype){var P=function(){};P.prototype=m.prototype,k.prototype=new P,P.prototype=null}return k},Cr}var Rr,Oi;function wt(){if(Oi)return Rr;Oi=1;var r=Xa();return Rr=Function.prototype.bind||r,Rr}var Pr,Mi;function Tr(){return Mi||(Mi=1,Pr=Function.prototype.call),Pr}var Ar,Ni;function Ir(){return Ni||(Ni=1,Ar=Function.prototype.apply),Ar}var kr,Li;function Za(){return Li||(Li=1,kr=typeof Reflect!="undefined"&&Reflect&&Reflect.apply),kr}var Br,Di;function Fi(){if(Di)return Br;Di=1;var r=wt(),e=Ir(),t=Tr(),s=Za();return Br=s||r.call(t,e),Br}var Or,Ui;function Mr(){if(Ui)return Or;Ui=1;var r=wt(),e=vt(),t=Tr(),s=Fi();return Or=function(l){if(l.length<1||typeof l[0]!="function")throw new e("a function is required");return s(r,t,l)},Or}var Nr,ji;function Qa(){if(ji)return Nr;ji=1;var r=Mr(),e=ct(),t;try{t=[].__proto__===Array.prototype}catch(g){if(!g||typeof g!="object"||!("code"in g)||g.code!=="ERR_PROTO_ACCESS")throw g}var s=!!t&&e&&e(Object.prototype,"__proto__"),c=Object,l=c.getPrototypeOf;return Nr=s&&typeof s.get=="function"?r([s.get]):typeof l=="function"?function(f){return l(f==null?f:c(f))}:!1,Nr}var Lr,xi;function Dr(){if(xi)return Lr;xi=1;var r=Ai(),e=ki(),t=Qa();return Lr=r?function(c){return r(c)}:e?function(c){if(!c||typeof c!="object"&&typeof c!="function")throw new TypeError("getProto: not an object");return e(c)}:t?function(c){return t(c)}:null,Lr}var Fr,qi;function $i(){if(qi)return Fr;qi=1;var r=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=wt();return Fr=t.call(r,e),Fr}var Ur,Wi;function Vi(){if(Wi)return Ur;Wi=1;var r,e=ai(),t=Da(),s=Fa(),c=Ua(),l=ja(),g=hi(),f=vt(),u=xa(),m=qa(),h=$a(),k=Wa(),I=Va(),V=Ga(),b=za(),B=Ya(),P=Function,y=function(Z){try{return P('"use strict"; return ('+Z+").constructor;")()}catch(ee){}},C=ct(),A=Mt(),T=function(){throw new f},O=C?function(){try{return arguments.callee,T}catch(Z){try{return C(arguments,"callee").get}catch(ee){return T}}}():T,S=Ka()(),R=Dr(),M=ki(),G=Ai(),Q=Ir(),ie=Tr(),U={},ge=typeof Uint8Array=="undefined"||!R?r:R(Uint8Array),de={__proto__:null,"%AggregateError%":typeof AggregateError=="undefined"?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?r:ArrayBuffer,"%ArrayIteratorPrototype%":S&&R?R([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":U,"%AsyncGenerator%":U,"%AsyncGeneratorFunction%":U,"%AsyncIteratorPrototype%":U,"%Atomics%":typeof Atomics=="undefined"?r:Atomics,"%BigInt%":typeof BigInt=="undefined"?r:BigInt,"%BigInt64Array%":typeof BigInt64Array=="undefined"?r:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array=="undefined"?r:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":s,"%Float16Array%":typeof Float16Array=="undefined"?r:Float16Array,"%Float32Array%":typeof Float32Array=="undefined"?r:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?r:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?r:FinalizationRegistry,"%Function%":P,"%GeneratorFunction%":U,"%Int8Array%":typeof Int8Array=="undefined"?r:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?r:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":S&&R?R(R([][Symbol.iterator]())):r,"%JSON%":typeof JSON=="object"?JSON:r,"%Map%":typeof Map=="undefined"?r:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!S||!R?r:R(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":C,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?r:Promise,"%Proxy%":typeof Proxy=="undefined"?r:Proxy,"%RangeError%":c,"%ReferenceError%":l,"%Reflect%":typeof Reflect=="undefined"?r:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?r:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!S||!R?r:R(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":S&&R?R(""[Symbol.iterator]()):r,"%Symbol%":S?Symbol:r,"%SyntaxError%":g,"%ThrowTypeError%":O,"%TypedArray%":ge,"%TypeError%":f,"%Uint8Array%":typeof Uint8Array=="undefined"?r:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?r:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?r:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?r:Uint32Array,"%URIError%":u,"%WeakMap%":typeof WeakMap=="undefined"?r:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?r:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?r:WeakSet,"%Function.prototype.call%":ie,"%Function.prototype.apply%":Q,"%Object.defineProperty%":A,"%Object.getPrototypeOf%":M,"%Math.abs%":m,"%Math.floor%":h,"%Math.max%":k,"%Math.min%":I,"%Math.pow%":V,"%Math.round%":b,"%Math.sign%":B,"%Reflect.getPrototypeOf%":G};if(R)try{null.error}catch(Z){var ye=R(R(Z));de["%Error.prototype%"]=ye}var Pe=function Z(ee){var v;if(ee==="%AsyncFunction%")v=y("async function () {}");else if(ee==="%GeneratorFunction%")v=y("function* () {}");else if(ee==="%AsyncGeneratorFunction%")v=y("async function* () {}");else if(ee==="%AsyncGenerator%"){var w=Z("%AsyncGeneratorFunction%");w&&(v=w.prototype)}else if(ee==="%AsyncIteratorPrototype%"){var H=Z("%AsyncGenerator%");H&&R&&(v=R(H.prototype))}return de[ee]=v,v},Te={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Se=wt(),we=$i(),X=Se.call(ie,Array.prototype.concat),ae=Se.call(Q,Array.prototype.splice),j=Se.call(ie,String.prototype.replace),W=Se.call(ie,String.prototype.slice),z=Se.call(ie,RegExp.prototype.exec),re=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,L=/\\(\\)?/g,D=function(ee){var v=W(ee,0,1),w=W(ee,-1);if(v==="%"&&w!=="%")throw new g("invalid intrinsic syntax, expected closing `%`");if(w==="%"&&v!=="%")throw new g("invalid intrinsic syntax, expected opening `%`");var H=[];return j(ee,re,function(te,fe,oe,ue){H[H.length]=oe?j(ue,L,"$1"):fe||te}),H},q=function(ee,v){var w=ee,H;if(we(Te,w)&&(H=Te[w],w="%"+H[0]+"%"),we(de,w)){var te=de[w];if(te===U&&(te=Pe(w)),typeof te=="undefined"&&!v)throw new f("intrinsic "+ee+" exists, but is not available. Please file an issue!");return{alias:H,name:w,value:te}}throw new g("intrinsic "+ee+" does not exist!")};return Ur=function(ee,v){if(typeof ee!="string"||ee.length===0)throw new f("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof v!="boolean")throw new f('"allowMissing" argument must be a boolean');if(z(/^%?[^%]*%?$/,ee)===null)throw new g("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var w=D(ee),H=w.length>0?w[0]:"",te=q("%"+H+"%",v),fe=te.name,oe=te.value,ue=!1,Fe=te.alias;Fe&&(H=Fe[0],ae(w,X([0,1],Fe)));for(var Y=1,Ue=!0;Y<w.length;Y+=1){var je=w[Y],be=W(je,0,1),Ee=W(je,-1);if((be==='"'||be==="'"||be==="`"||Ee==='"'||Ee==="'"||Ee==="`")&&be!==Ee)throw new g("property names with quotes must have matching quotes");if((je==="constructor"||!Ue)&&(ue=!0),H+="."+je,fe="%"+H+"%",we(de,fe))oe=de[fe];else if(oe!=null){if(!(je in oe)){if(!v)throw new f("base intrinsic for "+ee+" exists, but the property is not available.");return}if(C&&Y+1>=w.length){var xe=C(oe,je);Ue=!!xe,Ue&&"get"in xe&&!("originalValue"in xe.get)?oe=xe.get:oe=oe[je]}else Ue=we(oe,je),oe=oe[je];Ue&&!ue&&(de[fe]=oe)}}return oe},Ur}var jr,Gi;function bt(){if(Gi)return jr;Gi=1;var r=Vi(),e=Mr(),t=e([r("%String.prototype.indexOf%")]);return jr=function(c,l){var g=r(c,!!l);return typeof g=="function"&&t(c,".prototype.")>-1?e([g]):g},jr}var xr,zi;function es(){if(zi)return xr;zi=1;var r=Ot()(),e=bt(),t=e("Object.prototype.toString"),s=function(f){return r&&f&&typeof f=="object"&&Symbol.toStringTag in f?!1:t(f)==="[object Arguments]"},c=function(f){return s(f)?!0:f!==null&&typeof f=="object"&&"length"in f&&typeof f.length=="number"&&f.length>=0&&t(f)!=="[object Array]"&&"callee"in f&&t(f.callee)==="[object Function]"},l=function(){return s(arguments)}();return s.isLegacyArguments=c,xr=l?s:c,xr}var qr,Hi;function ts(){if(Hi)return qr;Hi=1;var r=bt(),e=Ot()(),t=$i(),s=ct(),c;if(e){var l=r("RegExp.prototype.exec"),g={},f=function(){throw g},u={toString:f,valueOf:f};typeof Symbol.toPrimitive=="symbol"&&(u[Symbol.toPrimitive]=f),c=function(I){if(!I||typeof I!="object")return!1;var V=s(I,"lastIndex"),b=V&&t(V,"value");if(!b)return!1;try{l(I,u)}catch(B){return B===g}}}else{var m=r("Object.prototype.toString"),h="[object RegExp]";c=function(I){return!I||typeof I!="object"&&typeof I!="function"?!1:m(I)===h}}return qr=c,qr}var $r,Yi;function rs(){if(Yi)return $r;Yi=1;var r=bt(),e=ts(),t=r("RegExp.prototype.exec"),s=vt();return $r=function(l){if(!e(l))throw new s("`regex` must be a RegExp");return function(f){return t(l,f)!==null}},$r}var Wr,Ji;function ns(){if(Ji)return Wr;Ji=1;var r=bt(),e=rs(),t=e(/^\s*(?:function)?\*/),s=Ot()(),c=Dr(),l=r("Object.prototype.toString"),g=r("Function.prototype.toString"),f=function(){if(!s)return!1;try{return Function("return function*() {}")()}catch(m){}},u;return Wr=function(h){if(typeof h!="function")return!1;if(t(g(h)))return!0;if(!s){var k=l(h);return k==="[object GeneratorFunction]"}if(!c)return!1;if(typeof u=="undefined"){var I=f();u=I?c(I):!1}return c(h)===u},Wr}var Vr,Ki;function is(){if(Ki)return Vr;Ki=1;var r=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,t,s;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{t=Object.defineProperty({},"length",{get:function(){throw s}}),s={},e(function(){throw 42},null,t)}catch(C){C!==s&&(e=null)}else e=null;var c=/^\s*class\b/,l=function(A){try{var T=r.call(A);return c.test(T)}catch(O){return!1}},g=function(A){try{return l(A)?!1:(r.call(A),!0)}catch(T){return!1}},f=Object.prototype.toString,u="[object Object]",m="[object Function]",h="[object GeneratorFunction]",k="[object HTMLAllCollection]",I="[object HTML document.all class]",V="[object HTMLCollection]",b=typeof Symbol=="function"&&!!Symbol.toStringTag,B=!(0 in[,]),P=function(){return!1};if(typeof document=="object"){var y=document.all;f.call(y)===f.call(document.all)&&(P=function(A){if((B||!A)&&(typeof A=="undefined"||typeof A=="object"))try{var T=f.call(A);return(T===k||T===I||T===V||T===u)&&A("")==null}catch(O){}return!1})}return Vr=e?function(A){if(P(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;try{e(A,null,t)}catch(T){if(T!==s)return!1}return!l(A)&&g(A)}:function(A){if(P(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;if(b)return g(A);if(l(A))return!1;var T=f.call(A);return T!==m&&T!==h&&!/^\[object HTML/.test(T)?!1:g(A)},Vr}var Gr,Xi;function os(){if(Xi)return Gr;Xi=1;var r=is(),e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,s=function(u,m,h){for(var k=0,I=u.length;k<I;k++)t.call(u,k)&&(h==null?m(u[k],k,u):m.call(h,u[k],k,u))},c=function(u,m,h){for(var k=0,I=u.length;k<I;k++)h==null?m(u.charAt(k),k,u):m.call(h,u.charAt(k),k,u)},l=function(u,m,h){for(var k in u)t.call(u,k)&&(h==null?m(u[k],k,u):m.call(h,u[k],k,u))};function g(f){return e.call(f)==="[object Array]"}return Gr=function(u,m,h){if(!r(m))throw new TypeError("iterator must be a function");var k;arguments.length>=3&&(k=h),g(u)?s(u,m,k):typeof u=="string"?c(u,m,k):l(u,m,k)},Gr}var zr,Zi;function as(){return Zi||(Zi=1,zr=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),zr}var Hr,Qi;function ss(){if(Qi)return Hr;Qi=1;var r=as(),e=globalThis;return Hr=function(){for(var s=[],c=0;c<r.length;c++)typeof e[r[c]]=="function"&&(s[s.length]=r[c]);return s},Hr}var Yr={exports:{}},Jr,eo;function ls(){if(eo)return Jr;eo=1;var r=Mt(),e=hi(),t=vt(),s=ct();return Jr=function(l,g,f){if(!l||typeof l!="object"&&typeof l!="function")throw new t("`obj` must be an object or a function`");if(typeof g!="string"&&typeof g!="symbol")throw new t("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new t("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new t("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new t("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new t("`loose`, if provided, must be a boolean");var u=arguments.length>3?arguments[3]:null,m=arguments.length>4?arguments[4]:null,h=arguments.length>5?arguments[5]:null,k=arguments.length>6?arguments[6]:!1,I=!!s&&s(l,g);if(r)r(l,g,{configurable:h===null&&I?I.configurable:!h,enumerable:u===null&&I?I.enumerable:!u,value:f,writable:m===null&&I?I.writable:!m});else if(k||!u&&!m&&!h)l[g]=f;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Jr}var Kr,to;function cs(){if(to)return Kr;to=1;var r=Mt(),e=function(){return!!r};return e.hasArrayLengthDefineBug=function(){if(!r)return null;try{return r([],"length",{value:1}).length!==1}catch(s){return!0}},Kr=e,Kr}var Xr,ro;function us(){if(ro)return Xr;ro=1;var r=Vi(),e=ls(),t=cs()(),s=ct(),c=vt(),l=r("%Math.floor%");return Xr=function(f,u){if(typeof f!="function")throw new c("`fn` is not a function");if(typeof u!="number"||u<0||u>4294967295||l(u)!==u)throw new c("`length` must be a positive 32-bit integer");var m=arguments.length>2&&!!arguments[2],h=!0,k=!0;if("length"in f&&s){var I=s(f,"length");I&&!I.configurable&&(h=!1),I&&!I.writable&&(k=!1)}return(h||k||!m)&&(t?e(f,"length",u,!0,!0):e(f,"length",u)),f},Xr}var Zr,no;function fs(){if(no)return Zr;no=1;var r=wt(),e=Ir(),t=Fi();return Zr=function(){return t(r,e,arguments)},Zr}var io;function hs(){return io||(io=1,function(r){var e=us(),t=Mt(),s=Mr(),c=fs();r.exports=function(g){var f=s(arguments),u=g.length-(arguments.length-1);return e(f,1+(u>0?u:0),!0)},t?t(r.exports,"apply",{value:c}):r.exports.apply=c}(Yr)),Yr.exports}var Qr,oo;function ao(){if(oo)return Qr;oo=1;var r=os(),e=ss(),t=hs(),s=bt(),c=ct(),l=Dr(),g=s("Object.prototype.toString"),f=Ot()(),u=globalThis,m=e(),h=s("String.prototype.slice"),k=s("Array.prototype.indexOf",!0)||function(P,y){for(var C=0;C<P.length;C+=1)if(P[C]===y)return C;return-1},I={__proto__:null};f&&c&&l?r(m,function(B){var P=new u[B];if(Symbol.toStringTag in P&&l){var y=l(P),C=c(y,Symbol.toStringTag);if(!C&&y){var A=l(y);C=c(A,Symbol.toStringTag)}I["$"+B]=t(C.get)}}):r(m,function(B){var P=new u[B],y=P.slice||P.set;y&&(I["$"+B]=t(y))});var V=function(P){var y=!1;return r(I,function(C,A){if(!y)try{"$"+C(P)===A&&(y=h(A,1))}catch(T){}}),y},b=function(P){var y=!1;return r(I,function(C,A){if(!y)try{C(P),y=h(A,1)}catch(T){}}),y};return Qr=function(P){if(!P||typeof P!="object")return!1;if(!f){var y=h(g(P),8,-1);return k(m,y)>-1?y:y!=="Object"?!1:b(P)}return c?V(P):null},Qr}var en,so;function ds(){if(so)return en;so=1;var r=ao();return en=function(t){return!!r(t)},en}var lo;function ps(){return lo||(lo=1,function(r){var e=es(),t=ns(),s=ao(),c=ds();function l(Y){return Y.call.bind(Y)}var g=typeof BigInt!="undefined",f=typeof Symbol!="undefined",u=l(Object.prototype.toString),m=l(Number.prototype.valueOf),h=l(String.prototype.valueOf),k=l(Boolean.prototype.valueOf);if(g)var I=l(BigInt.prototype.valueOf);if(f)var V=l(Symbol.prototype.valueOf);function b(Y,Ue){if(typeof Y!="object")return!1;try{return Ue(Y),!0}catch(je){return!1}}r.isArgumentsObject=e,r.isGeneratorFunction=t,r.isTypedArray=c;function B(Y){return typeof Promise!="undefined"&&Y instanceof Promise||Y!==null&&typeof Y=="object"&&typeof Y.then=="function"&&typeof Y.catch=="function"}r.isPromise=B;function P(Y){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?ArrayBuffer.isView(Y):c(Y)||W(Y)}r.isArrayBufferView=P;function y(Y){return s(Y)==="Uint8Array"}r.isUint8Array=y;function C(Y){return s(Y)==="Uint8ClampedArray"}r.isUint8ClampedArray=C;function A(Y){return s(Y)==="Uint16Array"}r.isUint16Array=A;function T(Y){return s(Y)==="Uint32Array"}r.isUint32Array=T;function O(Y){return s(Y)==="Int8Array"}r.isInt8Array=O;function S(Y){return s(Y)==="Int16Array"}r.isInt16Array=S;function R(Y){return s(Y)==="Int32Array"}r.isInt32Array=R;function M(Y){return s(Y)==="Float32Array"}r.isFloat32Array=M;function G(Y){return s(Y)==="Float64Array"}r.isFloat64Array=G;function Q(Y){return s(Y)==="BigInt64Array"}r.isBigInt64Array=Q;function ie(Y){return s(Y)==="BigUint64Array"}r.isBigUint64Array=ie;function U(Y){return u(Y)==="[object Map]"}U.working=typeof Map!="undefined"&&U(new Map);function ge(Y){return typeof Map=="undefined"?!1:U.working?U(Y):Y instanceof Map}r.isMap=ge;function de(Y){return u(Y)==="[object Set]"}de.working=typeof Set!="undefined"&&de(new Set);function ye(Y){return typeof Set=="undefined"?!1:de.working?de(Y):Y instanceof Set}r.isSet=ye;function Pe(Y){return u(Y)==="[object WeakMap]"}Pe.working=typeof WeakMap!="undefined"&&Pe(new WeakMap);function Te(Y){return typeof WeakMap=="undefined"?!1:Pe.working?Pe(Y):Y instanceof WeakMap}r.isWeakMap=Te;function Se(Y){return u(Y)==="[object WeakSet]"}Se.working=typeof WeakSet!="undefined"&&Se(new WeakSet);function we(Y){return Se(Y)}r.isWeakSet=we;function X(Y){return u(Y)==="[object ArrayBuffer]"}X.working=typeof ArrayBuffer!="undefined"&&X(new ArrayBuffer);function ae(Y){return typeof ArrayBuffer=="undefined"?!1:X.working?X(Y):Y instanceof ArrayBuffer}r.isArrayBuffer=ae;function j(Y){return u(Y)==="[object DataView]"}j.working=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined"&&j(new DataView(new ArrayBuffer(1),0,1));function W(Y){return typeof DataView=="undefined"?!1:j.working?j(Y):Y instanceof DataView}r.isDataView=W;var z=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer:void 0;function re(Y){return u(Y)==="[object SharedArrayBuffer]"}function L(Y){return typeof z=="undefined"?!1:(typeof re.working=="undefined"&&(re.working=re(new z)),re.working?re(Y):Y instanceof z)}r.isSharedArrayBuffer=L;function D(Y){return u(Y)==="[object AsyncFunction]"}r.isAsyncFunction=D;function q(Y){return u(Y)==="[object Map Iterator]"}r.isMapIterator=q;function Z(Y){return u(Y)==="[object Set Iterator]"}r.isSetIterator=Z;function ee(Y){return u(Y)==="[object Generator]"}r.isGeneratorObject=ee;function v(Y){return u(Y)==="[object WebAssembly.Module]"}r.isWebAssemblyCompiledModule=v;function w(Y){return b(Y,m)}r.isNumberObject=w;function H(Y){return b(Y,h)}r.isStringObject=H;function te(Y){return b(Y,k)}r.isBooleanObject=te;function fe(Y){return g&&b(Y,I)}r.isBigIntObject=fe;function oe(Y){return f&&b(Y,V)}r.isSymbolObject=oe;function ue(Y){return w(Y)||H(Y)||te(Y)||fe(Y)||oe(Y)}r.isBoxedPrimitive=ue;function Fe(Y){return typeof Uint8Array!="undefined"&&(ae(Y)||L(Y))}r.isAnyArrayBuffer=Fe,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(Y){Object.defineProperty(r,Y,{enumerable:!1,value:function(){throw new Error(Y+" is not supported in userland")}})})}(Qt)),Qt}var tn,co;function gs(){return co||(co=1,tn=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),tn}var Nt={exports:{}},uo;function ut(){return uo||(uo=1,typeof Object.create=="function"?Nt.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Nt.exports=function(e,t){if(t){e.super_=t;var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e}}),Nt.exports}var fo;function ho(){return fo||(fo=1,function(r){var e=Object.getOwnPropertyDescriptors||function(W){for(var z=Object.keys(W),re={},L=0;L<z.length;L++)re[z[L]]=Object.getOwnPropertyDescriptor(W,z[L]);return re},t=/%[sdj%]/g;r.format=function(j){if(!O(j)){for(var W=[],z=0;z<arguments.length;z++)W.push(g(arguments[z]));return W.join(" ")}for(var z=1,re=arguments,L=re.length,D=String(j).replace(t,function(Z){if(Z==="%%")return"%";if(z>=L)return Z;switch(Z){case"%s":return String(re[z++]);case"%d":return Number(re[z++]);case"%j":try{return JSON.stringify(re[z++])}catch(ee){return"[Circular]"}default:return Z}}),q=re[z];z<L;q=re[++z])C(q)||!G(q)?D+=" "+q:D+=" "+g(q);return D},r.deprecate=function(j,W){if(typeof le!="undefined"&&le.noDeprecation===!0)return j;if(typeof le=="undefined")return function(){return r.deprecate(j,W).apply(this,arguments)};var z=!1;function re(){if(!z){if(le.throwDeprecation)throw new Error(W);le.traceDeprecation?console.trace(W):console.error(W),z=!0}return j.apply(this,arguments)}return re};var s={},c=/^$/;if(le.env.NODE_DEBUG){var l=le.env.NODE_DEBUG;l=l.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),c=new RegExp("^"+l+"$","i")}r.debuglog=function(j){if(j=j.toUpperCase(),!s[j])if(c.test(j)){var W=le.pid;s[j]=function(){var z=r.format.apply(r,arguments);console.error("%s %d: %s",j,W,z)}}else s[j]=function(){};return s[j]};function g(j,W){var z={seen:[],stylize:u};return arguments.length>=3&&(z.depth=arguments[2]),arguments.length>=4&&(z.colors=arguments[3]),y(W)?z.showHidden=W:W&&r._extend(z,W),R(z.showHidden)&&(z.showHidden=!1),R(z.depth)&&(z.depth=2),R(z.colors)&&(z.colors=!1),R(z.customInspect)&&(z.customInspect=!0),z.colors&&(z.stylize=f),h(z,j,z.depth)}r.inspect=g,g.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},g.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function f(j,W){var z=g.styles[W];return z?"\x1B["+g.colors[z][0]+"m"+j+"\x1B["+g.colors[z][1]+"m":j}function u(j,W){return j}function m(j){var W={};return j.forEach(function(z,re){W[z]=!0}),W}function h(j,W,z){if(j.customInspect&&W&&U(W.inspect)&&W.inspect!==r.inspect&&!(W.constructor&&W.constructor.prototype===W)){var re=W.inspect(z,j);return O(re)||(re=h(j,re,z)),re}var L=k(j,W);if(L)return L;var D=Object.keys(W),q=m(D);if(j.showHidden&&(D=Object.getOwnPropertyNames(W)),ie(W)&&(D.indexOf("message")>=0||D.indexOf("description")>=0))return I(W);if(D.length===0){if(U(W)){var Z=W.name?": "+W.name:"";return j.stylize("[Function"+Z+"]","special")}if(M(W))return j.stylize(RegExp.prototype.toString.call(W),"regexp");if(Q(W))return j.stylize(Date.prototype.toString.call(W),"date");if(ie(W))return I(W)}var ee="",v=!1,w=["{","}"];if(P(W)&&(v=!0,w=["[","]"]),U(W)){var H=W.name?": "+W.name:"";ee=" [Function"+H+"]"}if(M(W)&&(ee=" "+RegExp.prototype.toString.call(W)),Q(W)&&(ee=" "+Date.prototype.toUTCString.call(W)),ie(W)&&(ee=" "+I(W)),D.length===0&&(!v||W.length==0))return w[0]+ee+w[1];if(z<0)return M(W)?j.stylize(RegExp.prototype.toString.call(W),"regexp"):j.stylize("[Object]","special");j.seen.push(W);var te;return v?te=V(j,W,z,q,D):te=D.map(function(fe){return b(j,W,z,q,fe,v)}),j.seen.pop(),B(te,ee,w)}function k(j,W){if(R(W))return j.stylize("undefined","undefined");if(O(W)){var z="'"+JSON.stringify(W).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return j.stylize(z,"string")}if(T(W))return j.stylize(""+W,"number");if(y(W))return j.stylize(""+W,"boolean");if(C(W))return j.stylize("null","null")}function I(j){return"["+Error.prototype.toString.call(j)+"]"}function V(j,W,z,re,L){for(var D=[],q=0,Z=W.length;q<Z;++q)Se(W,String(q))?D.push(b(j,W,z,re,String(q),!0)):D.push("");return L.forEach(function(ee){ee.match(/^\d+$/)||D.push(b(j,W,z,re,ee,!0))}),D}function b(j,W,z,re,L,D){var q,Z,ee;if(ee=Object.getOwnPropertyDescriptor(W,L)||{value:W[L]},ee.get?ee.set?Z=j.stylize("[Getter/Setter]","special"):Z=j.stylize("[Getter]","special"):ee.set&&(Z=j.stylize("[Setter]","special")),Se(re,L)||(q="["+L+"]"),Z||(j.seen.indexOf(ee.value)<0?(C(z)?Z=h(j,ee.value,null):Z=h(j,ee.value,z-1),Z.indexOf(`
|
|
3
|
-
`)>-1&&(
|
|
1
|
+
(function(){te.apply(null,ge)},0)}});typeof global=="undefined"&&(globalThis.global=globalThis);(function(te,ge){typeof exports=="object"&&typeof module!="undefined"?ge(exports,require("socket.io-client"),require("zustand"),require("react")):typeof define=="function"&&define.amd?define(["exports","socket.io-client","zustand","react"],ge):(te=typeof globalThis!="undefined"?globalThis:te||self,ge(te.PeersCaller={},te.io,te.zustand,te.React))})(this,function(te,ge,Pe,se){"use strict";var jl=Object.defineProperty,ql=Object.defineProperties;var xl=Object.getOwnPropertyDescriptors;var Ft=Object.getOwnPropertySymbols;var aa=Object.prototype.hasOwnProperty,sa=Object.prototype.propertyIsEnumerable;var oe=Math.pow,kn=(te,ge,Pe)=>ge in te?jl(te,ge,{enumerable:!0,configurable:!0,writable:!0,value:Pe}):te[ge]=Pe,ze=(te,ge)=>{for(var Pe in ge||(ge={}))aa.call(ge,Pe)&&kn(te,Pe,ge[Pe]);if(Ft)for(var Pe of Ft(ge))sa.call(ge,Pe)&&kn(te,Pe,ge[Pe]);return te},On=(te,ge)=>ql(te,xl(ge));var Mn=(te,ge)=>{var Pe={};for(var se in te)aa.call(te,se)&&ge.indexOf(se)<0&&(Pe[se]=te[se]);if(te!=null&&Ft)for(var se of Ft(te))ge.indexOf(se)<0&&sa.call(te,se)&&(Pe[se]=te[se]);return Pe};var He=(te,ge,Pe)=>kn(te,typeof ge!="symbol"?ge+"":ge,Pe);typeof process=="undefined"&&(globalThis.process={env:{},browser:!0,version:"v18.0.0",platform:"browser",nextTick:function(te){var ge=Array.prototype.slice.call(arguments,1);if(typeof MessageChannel!="undefined"){var Pe=new MessageChannel;Pe.port2.onmessage=function(){te.apply(null,ge)},Pe.port1.postMessage(null)}else setTimeoutfunction la(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const ca=la(se);function ua(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ln={exports:{}},Be=Ln.exports={},Je,Ye;function Ut(){throw new Error("setTimeout has not been defined")}function jt(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Je=setTimeout:Je=Ut}catch(r){Je=Ut}try{typeof clearTimeout=="function"?Ye=clearTimeout:Ye=jt}catch(r){Ye=jt}})();function Nn(r){if(Je===setTimeout)return setTimeout(r,0);if((Je===Ut||!Je)&&setTimeout)return Je=setTimeout,setTimeout(r,0);try{return Je(r,0)}catch(e){try{return Je.call(null,r,0)}catch(t){return Je.call(this,r,0)}}}function fa(r){if(Ye===clearTimeout)return clearTimeout(r);if((Ye===jt||!Ye)&&clearTimeout)return Ye=clearTimeout,clearTimeout(r);try{return Ye(r)}catch(e){try{return Ye.call(null,r)}catch(t){return Ye.call(this,r)}}}var Qe=[],st=!1,it,_t=-1;function ha(){!st||!it||(st=!1,it.length?Qe=it.concat(Qe):_t=-1,Qe.length&&Dn())}function Dn(){if(!st){var r=Nn(ha);st=!0;for(var e=Qe.length;e;){for(it=Qe,Qe=[];++_t<e;)it&&it[_t].run();_t=-1,e=Qe.length}it=null,st=!1,fa(r)}}Be.nextTick=function(r){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];Qe.push(new Fn(r,e)),Qe.length===1&&!st&&Nn(Dn)};function Fn(r,e){this.fun=r,this.array=e}Fn.prototype.run=function(){this.fun.apply(null,this.array)},Be.title="browser",Be.browser=!0,Be.env={},Be.argv=[],Be.version="",Be.versions={};function et(){}Be.on=et,Be.addListener=et,Be.once=et,Be.off=et,Be.removeListener=et,Be.removeAllListeners=et,Be.emit=et,Be.prependListener=et,Be.prependOnceListener=et,Be.listeners=function(r){return[]},Be.binding=function(r){throw new Error("process.binding is not supported")},Be.cwd=function(){return"/"},Be.chdir=function(r){throw new Error("process.chdir is not supported")},Be.umask=function(){return 0};var da=Ln.exports;const ae=ua(da);var Un={},Et={};Et.byteLength=ya,Et.toByteArray=va,Et.fromByteArray=Sa;for(var Ke=[],$e=[],pa=typeof Uint8Array!="undefined"?Uint8Array:Array,qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lt=0,ga=qt.length;lt<ga;++lt)Ke[lt]=qt[lt],$e[qt.charCodeAt(lt)]=lt;$e[45]=62,$e[95]=63;function jn(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var s=t===e?0:4-t%4;return[t,s]}function ya(r){var e=jn(r),t=e[0],s=e[1];return(t+s)*3/4-s}function ma(r,e,t){return(e+t)*3/4-t}function va(r){var e,t=jn(r),s=t[0],c=t[1],l=new pa(ma(r,s,c)),g=0,f=c>0?s-4:s,u;for(u=0;u<f;u+=4)e=$e[r.charCodeAt(u)]<<18|$e[r.charCodeAt(u+1)]<<12|$e[r.charCodeAt(u+2)]<<6|$e[r.charCodeAt(u+3)],l[g++]=e>>16&255,l[g++]=e>>8&255,l[g++]=e&255;return c===2&&(e=$e[r.charCodeAt(u)]<<2|$e[r.charCodeAt(u+1)]>>4,l[g++]=e&255),c===1&&(e=$e[r.charCodeAt(u)]<<10|$e[r.charCodeAt(u+1)]<<4|$e[r.charCodeAt(u+2)]>>2,l[g++]=e>>8&255,l[g++]=e&255),l}function wa(r){return Ke[r>>18&63]+Ke[r>>12&63]+Ke[r>>6&63]+Ke[r&63]}function ba(r,e,t){for(var s,c=[],l=e;l<t;l+=3)s=(r[l]<<16&16711680)+(r[l+1]<<8&65280)+(r[l+2]&255),c.push(wa(s));return c.join("")}function Sa(r){for(var e,t=r.length,s=t%3,c=[],l=16383,g=0,f=t-s;g<f;g+=l)c.push(ba(r,g,g+l>f?f:g+l));return s===1?(e=r[t-1],c.push(Ke[e>>2]+Ke[e<<4&63]+"==")):s===2&&(e=(r[t-2]<<8)+r[t-1],c.push(Ke[e>>10]+Ke[e>>4&63]+Ke[e<<2&63]+"=")),c.join("")}var xt={};xt.read=function(r,e,t,s,c){var l,g,f=c*8-s-1,u=(1<<f)-1,m=u>>1,h=-7,B=t?c-1:0,I=t?-1:1,$=r[e+B];for(B+=I,l=$&(1<<-h)-1,$>>=-h,h+=f;h>0;l=l*256+r[e+B],B+=I,h-=8);for(g=l&(1<<-h)-1,l>>=-h,h+=s;h>0;g=g*256+r[e+B],B+=I,h-=8);if(l===0)l=1-m;else{if(l===u)return g?NaN:($?-1:1)*(1/0);g=g+Math.pow(2,s),l=l-m}return($?-1:1)*g*Math.pow(2,l-s)},xt.write=function(r,e,t,s,c,l){var g,f,u,m=l*8-c-1,h=(1<<m)-1,B=h>>1,I=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,$=s?0:l-1,b=s?1:-1,k=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,g=h):(g=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-g))<1&&(g--,u*=2),g+B>=1?e+=I/u:e+=I*Math.pow(2,1-B),e*u>=2&&(g++,u/=2),g+B>=h?(f=0,g=h):g+B>=1?(f=(e*u-1)*Math.pow(2,c),g=g+B):(f=e*Math.pow(2,B-1)*Math.pow(2,c),g=0));c>=8;r[t+$]=f&255,$+=b,f/=256,c-=8);for(g=g<<c|f,m+=c;m>0;r[t+$]=g&255,$+=b,g/=256,m-=8);r[t+$-b]|=k*128};(function(r){const e=Et,t=xt,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=h,r.SlowBuffer=O,r.INSPECT_MAX_BYTES=50;const c=2147483647;r.kMaxLength=c;const{Uint8Array:l,ArrayBuffer:g,SharedArrayBuffer:f}=globalThis;h.TYPED_ARRAY_SUPPORT=u(),!h.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{const d=new l(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,l.prototype),Object.setPrototypeOf(d,n),d.foo()===42}catch(d){return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function m(d){if(d>c)throw new RangeError('The value "'+d+'" is invalid for option "size"');const n=new l(d);return Object.setPrototypeOf(n,h.prototype),n}function h(d,n,o){if(typeof d=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(d)}return B(d,n,o)}h.poolSize=8192;function B(d,n,o){if(typeof d=="string")return k(d,n);if(g.isView(d))return y(d);if(d==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof d);if(Ne(d,g)||d&&Ne(d.buffer,g)||typeof f!="undefined"&&(Ne(d,f)||d&&Ne(d.buffer,f)))return C(d,n,o);if(typeof d=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const _=d.valueOf&&d.valueOf();if(_!=null&&_!==d)return h.from(_,n,o);const M=A(d);if(M)return M;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof d[Symbol.toPrimitive]=="function")return h.from(d[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof d)}h.from=function(d,n,o){return B(d,n,o)},Object.setPrototypeOf(h.prototype,l.prototype),Object.setPrototypeOf(h,l);function I(d){if(typeof d!="number")throw new TypeError('"size" argument must be of type number');if(d<0)throw new RangeError('The value "'+d+'" is invalid for option "size"')}function $(d,n,o){return I(d),d<=0?m(d):n!==void 0?typeof o=="string"?m(d).fill(n,o):m(d).fill(n):m(d)}h.alloc=function(d,n,o){return $(d,n,o)};function b(d){return I(d),m(d<0?0:T(d)|0)}h.allocUnsafe=function(d){return b(d)},h.allocUnsafeSlow=function(d){return b(d)};function k(d,n){if((typeof n!="string"||n==="")&&(n="utf8"),!h.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const o=S(d,n)|0;let _=m(o);const M=_.write(d,n);return M!==o&&(_=_.slice(0,M)),_}function P(d){const n=d.length<0?0:T(d.length)|0,o=m(n);for(let _=0;_<n;_+=1)o[_]=d[_]&255;return o}function y(d){if(Ne(d,l)){const n=new l(d);return C(n.buffer,n.byteOffset,n.byteLength)}return P(d)}function C(d,n,o){if(n<0||d.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(d.byteLength<n+(o||0))throw new RangeError('"length" is outside of buffer bounds');let _;return n===void 0&&o===void 0?_=new l(d):o===void 0?_=new l(d,n):_=new l(d,n,o),Object.setPrototypeOf(_,h.prototype),_}function A(d){if(h.isBuffer(d)){const n=T(d.length)|0,o=m(n);return o.length===0||d.copy(o,0,0,n),o}if(d.length!==void 0)return typeof d.length!="number"||We(d.length)?m(0):P(d);if(d.type==="Buffer"&&Array.isArray(d.data))return P(d.data)}function T(d){if(d>=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return d|0}function O(d){return+d!=d&&(d=0),h.alloc(+d)}h.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==h.prototype},h.compare=function(n,o){if(Ne(n,l)&&(n=h.from(n,n.offset,n.byteLength)),Ne(o,l)&&(o=h.from(o,o.offset,o.byteLength)),!h.isBuffer(n)||!h.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===o)return 0;let _=n.length,M=o.length;for(let q=0,Y=Math.min(_,M);q<Y;++q)if(n[q]!==o[q]){_=n[q],M=o[q];break}return _<M?-1:M<_?1:0},h.isEncoding=function(n){switch(String(n).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(n,o){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return h.alloc(0);let _;if(o===void 0)for(o=0,_=0;_<n.length;++_)o+=n[_].length;const M=h.allocUnsafe(o);let q=0;for(_=0;_<n.length;++_){let Y=n[_];if(Ne(Y,l))q+Y.length>M.length?(h.isBuffer(Y)||(Y=h.from(Y)),Y.copy(M,q)):l.prototype.set.call(M,Y,q);else if(h.isBuffer(Y))Y.copy(M,q);else throw new TypeError('"list" argument must be an Array of Buffers');q+=Y.length}return M};function S(d,n){if(h.isBuffer(d))return d.length;if(g.isView(d)||Ne(d,g))return d.byteLength;if(typeof d!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof d);const o=d.length,_=arguments.length>2&&arguments[2]===!0;if(!_&&o===0)return 0;let M=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return Fe(d).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return we(d).length;default:if(M)return _?-1:Fe(d).length;n=(""+n).toLowerCase(),M=!0}}h.byteLength=S;function R(d,n,o){let _=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,n>>>=0,o<=n))return"";for(d||(d="utf8");;)switch(d){case"hex":return j(this,n,o);case"utf8":case"utf-8":return ke(this,n,o);case"ascii":return Me(this,n,o);case"latin1":case"binary":return xe(this,n,o);case"base64":return Te(this,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,n,o);default:if(_)throw new TypeError("Unknown encoding: "+d);d=(d+"").toLowerCase(),_=!0}}h.prototype._isBuffer=!0;function L(d,n,o){const _=d[n];d[n]=d[o],d[o]=_}h.prototype.swap16=function(){const n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<n;o+=2)L(this,o,o+1);return this},h.prototype.swap32=function(){const n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<n;o+=4)L(this,o,o+3),L(this,o+1,o+2);return this},h.prototype.swap64=function(){const n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<n;o+=8)L(this,o,o+7),L(this,o+1,o+6),L(this,o+2,o+5),L(this,o+3,o+4);return this},h.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?ke(this,0,n):R.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(n){if(!h.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:h.compare(this,n)===0},h.prototype.inspect=function(){let n="";const o=r.INSPECT_MAX_BYTES;return n=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(n+=" ... "),"<Buffer "+n+">"},s&&(h.prototype[s]=h.prototype.inspect),h.prototype.compare=function(n,o,_,M,q){if(Ne(n,l)&&(n=h.from(n,n.offset,n.byteLength)),!h.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(o===void 0&&(o=0),_===void 0&&(_=n?n.length:0),M===void 0&&(M=0),q===void 0&&(q=this.length),o<0||_>n.length||M<0||q>this.length)throw new RangeError("out of range index");if(M>=q&&o>=_)return 0;if(M>=q)return-1;if(o>=_)return 1;if(o>>>=0,_>>>=0,M>>>=0,q>>>=0,this===n)return 0;let Y=q-M,ue=_-o;const be=Math.min(Y,ue),Se=this.slice(M,q),Ce=n.slice(o,_);for(let pe=0;pe<be;++pe)if(Se[pe]!==Ce[pe]){Y=Se[pe],ue=Ce[pe];break}return Y<ue?-1:ue<Y?1:0};function W(d,n,o,_,M){if(d.length===0)return-1;if(typeof o=="string"?(_=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,We(o)&&(o=M?0:d.length-1),o<0&&(o=d.length+o),o>=d.length){if(M)return-1;o=d.length-1}else if(o<0)if(M)o=0;else return-1;if(typeof n=="string"&&(n=h.from(n,_)),h.isBuffer(n))return n.length===0?-1:X(d,n,o,_,M);if(typeof n=="number")return n=n&255,typeof l.prototype.indexOf=="function"?M?l.prototype.indexOf.call(d,n,o):l.prototype.lastIndexOf.call(d,n,o):X(d,[n],o,_,M);throw new TypeError("val must be string, number or Buffer")}function X(d,n,o,_,M){let q=1,Y=d.length,ue=n.length;if(_!==void 0&&(_=String(_).toLowerCase(),_==="ucs2"||_==="ucs-2"||_==="utf16le"||_==="utf-16le")){if(d.length<2||n.length<2)return-1;q=2,Y/=2,ue/=2,o/=2}function be(Ce,pe){return q===1?Ce[pe]:Ce.readUInt16BE(pe*q)}let Se;if(M){let Ce=-1;for(Se=o;Se<Y;Se++)if(be(d,Se)===be(n,Ce===-1?0:Se-Ce)){if(Ce===-1&&(Ce=Se),Se-Ce+1===ue)return Ce*q}else Ce!==-1&&(Se-=Se-Ce),Ce=-1}else for(o+ue>Y&&(o=Y-ue),Se=o;Se>=0;Se--){let Ce=!0;for(let pe=0;pe<ue;pe++)if(be(d,Se+pe)!==be(n,pe)){Ce=!1;break}if(Ce)return Se}return-1}h.prototype.includes=function(n,o,_){return this.indexOf(n,o,_)!==-1},h.prototype.indexOf=function(n,o,_){return W(this,n,o,_,!0)},h.prototype.lastIndexOf=function(n,o,_){return W(this,n,o,_,!1)};function re(d,n,o,_){o=Number(o)||0;const M=d.length-o;_?(_=Number(_),_>M&&(_=M)):_=M;const q=n.length;_>q/2&&(_=q/2);let Y;for(Y=0;Y<_;++Y){const ue=parseInt(n.substr(Y*2,2),16);if(We(ue))return Y;d[o+Y]=ue}return Y}function U(d,n,o,_){return je(Fe(n,d.length-o),d,o,_)}function he(d,n,o,_){return je(Ue(n),d,o,_)}function de(d,n,o,_){return je(we(n),d,o,_)}function me(d,n,o,_){return je(ye(n,d.length-o),d,o,_)}h.prototype.write=function(n,o,_,M){if(o===void 0)M="utf8",_=this.length,o=0;else if(_===void 0&&typeof o=="string")M=o,_=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(_)?(_=_>>>0,M===void 0&&(M="utf8")):(M=_,_=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const q=this.length-o;if((_===void 0||_>q)&&(_=q),n.length>0&&(_<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");M||(M="utf8");let Y=!1;for(;;)switch(M){case"hex":return re(this,n,o,_);case"utf8":case"utf-8":return U(this,n,o,_);case"ascii":case"latin1":case"binary":return he(this,n,o,_);case"base64":return de(this,n,o,_);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return me(this,n,o,_);default:if(Y)throw new TypeError("Unknown encoding: "+M);M=(""+M).toLowerCase(),Y=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Te(d,n,o){return n===0&&o===d.length?e.fromByteArray(d):e.fromByteArray(d.slice(n,o))}function ke(d,n,o){o=Math.min(d.length,o);const _=[];let M=n;for(;M<o;){const q=d[M];let Y=null,ue=q>239?4:q>223?3:q>191?2:1;if(M+ue<=o){let be,Se,Ce,pe;switch(ue){case 1:q<128&&(Y=q);break;case 2:be=d[M+1],(be&192)===128&&(pe=(q&31)<<6|be&63,pe>127&&(Y=pe));break;case 3:be=d[M+1],Se=d[M+2],(be&192)===128&&(Se&192)===128&&(pe=(q&15)<<12|(be&63)<<6|Se&63,pe>2047&&(pe<55296||pe>57343)&&(Y=pe));break;case 4:be=d[M+1],Se=d[M+2],Ce=d[M+3],(be&192)===128&&(Se&192)===128&&(Ce&192)===128&&(pe=(q&15)<<18|(be&63)<<12|(Se&63)<<6|Ce&63,pe>65535&&pe<1114112&&(Y=pe))}}Y===null?(Y=65533,ue=1):Y>65535&&(Y-=65536,_.push(Y>>>10&1023|55296),Y=56320|Y&1023),_.push(Y),M+=ue}return _e(_)}const Ee=4096;function _e(d){const n=d.length;if(n<=Ee)return String.fromCharCode.apply(String,d);let o="",_=0;for(;_<n;)o+=String.fromCharCode.apply(String,d.slice(_,_+=Ee));return o}function Me(d,n,o){let _="";o=Math.min(d.length,o);for(let M=n;M<o;++M)_+=String.fromCharCode(d[M]&127);return _}function xe(d,n,o){let _="";o=Math.min(d.length,o);for(let M=n;M<o;++M)_+=String.fromCharCode(d[M]);return _}function j(d,n,o){const _=d.length;(!n||n<0)&&(n=0),(!o||o<0||o>_)&&(o=_);let M="";for(let q=n;q<o;++q)M+=Ge[d[q]];return M}function G(d,n,o){const _=d.slice(n,o);let M="";for(let q=0;q<_.length-1;q+=2)M+=String.fromCharCode(_[q]+_[q+1]*256);return M}h.prototype.slice=function(n,o){const _=this.length;n=~~n,o=o===void 0?_:~~o,n<0?(n+=_,n<0&&(n=0)):n>_&&(n=_),o<0?(o+=_,o<0&&(o=0)):o>_&&(o=_),o<n&&(o=n);const M=this.subarray(n,o);return Object.setPrototypeOf(M,h.prototype),M};function J(d,n,o){if(d%1!==0||d<0)throw new RangeError("offset is not uint");if(d+n>o)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(n,o,_){n=n>>>0,o=o>>>0,_||J(n,o,this.length);let M=this[n],q=1,Y=0;for(;++Y<o&&(q*=256);)M+=this[n+Y]*q;return M},h.prototype.readUintBE=h.prototype.readUIntBE=function(n,o,_){n=n>>>0,o=o>>>0,_||J(n,o,this.length);let M=this[n+--o],q=1;for(;o>0&&(q*=256);)M+=this[n+--o]*q;return M},h.prototype.readUint8=h.prototype.readUInt8=function(n,o){return n=n>>>0,o||J(n,1,this.length),this[n]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(n,o){return n=n>>>0,o||J(n,2,this.length),this[n]|this[n+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(n,o){return n=n>>>0,o||J(n,2,this.length),this[n]<<8|this[n+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(n,o){return n=n>>>0,o||J(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(n,o){return n=n>>>0,o||J(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},h.prototype.readBigUInt64LE=Le(function(n){n=n>>>0,ie(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&le(n,this.length-8);const M=o+this[++n]*oe(2,8)+this[++n]*oe(2,16)+this[++n]*oe(2,24),q=this[++n]+this[++n]*oe(2,8)+this[++n]*oe(2,16)+_*oe(2,24);return BigInt(M)+(BigInt(q)<<BigInt(32))}),h.prototype.readBigUInt64BE=Le(function(n){n=n>>>0,ie(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&le(n,this.length-8);const M=o*oe(2,24)+this[++n]*oe(2,16)+this[++n]*oe(2,8)+this[++n],q=this[++n]*oe(2,24)+this[++n]*oe(2,16)+this[++n]*oe(2,8)+_;return(BigInt(M)<<BigInt(32))+BigInt(q)}),h.prototype.readIntLE=function(n,o,_){n=n>>>0,o=o>>>0,_||J(n,o,this.length);let M=this[n],q=1,Y=0;for(;++Y<o&&(q*=256);)M+=this[n+Y]*q;return q*=128,M>=q&&(M-=Math.pow(2,8*o)),M},h.prototype.readIntBE=function(n,o,_){n=n>>>0,o=o>>>0,_||J(n,o,this.length);let M=o,q=1,Y=this[n+--M];for(;M>0&&(q*=256);)Y+=this[n+--M]*q;return q*=128,Y>=q&&(Y-=Math.pow(2,8*o)),Y},h.prototype.readInt8=function(n,o){return n=n>>>0,o||J(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},h.prototype.readInt16LE=function(n,o){n=n>>>0,o||J(n,2,this.length);const _=this[n]|this[n+1]<<8;return _&32768?_|4294901760:_},h.prototype.readInt16BE=function(n,o){n=n>>>0,o||J(n,2,this.length);const _=this[n+1]|this[n]<<8;return _&32768?_|4294901760:_},h.prototype.readInt32LE=function(n,o){return n=n>>>0,o||J(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},h.prototype.readInt32BE=function(n,o){return n=n>>>0,o||J(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},h.prototype.readBigInt64LE=Le(function(n){n=n>>>0,ie(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&le(n,this.length-8);const M=this[n+4]+this[n+5]*oe(2,8)+this[n+6]*oe(2,16)+(_<<24);return(BigInt(M)<<BigInt(32))+BigInt(o+this[++n]*oe(2,8)+this[++n]*oe(2,16)+this[++n]*oe(2,24))}),h.prototype.readBigInt64BE=Le(function(n){n=n>>>0,ie(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&le(n,this.length-8);const M=(o<<24)+this[++n]*oe(2,16)+this[++n]*oe(2,8)+this[++n];return(BigInt(M)<<BigInt(32))+BigInt(this[++n]*oe(2,24)+this[++n]*oe(2,16)+this[++n]*oe(2,8)+_)}),h.prototype.readFloatLE=function(n,o){return n=n>>>0,o||J(n,4,this.length),t.read(this,n,!0,23,4)},h.prototype.readFloatBE=function(n,o){return n=n>>>0,o||J(n,4,this.length),t.read(this,n,!1,23,4)},h.prototype.readDoubleLE=function(n,o){return n=n>>>0,o||J(n,8,this.length),t.read(this,n,!0,52,8)},h.prototype.readDoubleBE=function(n,o){return n=n>>>0,o||J(n,8,this.length),t.read(this,n,!1,52,8)};function ne(d,n,o,_,M,q){if(!h.isBuffer(d))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>M||n<q)throw new RangeError('"value" argument is out of bounds');if(o+_>d.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(n,o,_,M){if(n=+n,o=o>>>0,_=_>>>0,!M){const ue=Math.pow(2,8*_)-1;ne(this,n,o,_,ue,0)}let q=1,Y=0;for(this[o]=n&255;++Y<_&&(q*=256);)this[o+Y]=n/q&255;return o+_},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(n,o,_,M){if(n=+n,o=o>>>0,_=_>>>0,!M){const ue=Math.pow(2,8*_)-1;ne(this,n,o,_,ue,0)}let q=_-1,Y=1;for(this[o+q]=n&255;--q>=0&&(Y*=256);)this[o+q]=n/Y&255;return o+_},h.prototype.writeUint8=h.prototype.writeUInt8=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,1,255,0),this[o]=n&255,o+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,2,65535,0),this[o]=n&255,this[o+1]=n>>>8,o+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,2,65535,0),this[o]=n>>>8,this[o+1]=n&255,o+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,4,4294967295,0),this[o+3]=n>>>24,this[o+2]=n>>>16,this[o+1]=n>>>8,this[o]=n&255,o+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,4,4294967295,0),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4};function D(d,n,o,_,M){ce(n,_,M,d,o,7);let q=Number(n&BigInt(4294967295));d[o++]=q,q=q>>8,d[o++]=q,q=q>>8,d[o++]=q,q=q>>8,d[o++]=q;let Y=Number(n>>BigInt(32)&BigInt(4294967295));return d[o++]=Y,Y=Y>>8,d[o++]=Y,Y=Y>>8,d[o++]=Y,Y=Y>>8,d[o++]=Y,o}function F(d,n,o,_,M){ce(n,_,M,d,o,7);let q=Number(n&BigInt(4294967295));d[o+7]=q,q=q>>8,d[o+6]=q,q=q>>8,d[o+5]=q,q=q>>8,d[o+4]=q;let Y=Number(n>>BigInt(32)&BigInt(4294967295));return d[o+3]=Y,Y=Y>>8,d[o+2]=Y,Y=Y>>8,d[o+1]=Y,Y=Y>>8,d[o]=Y,o+8}h.prototype.writeBigUInt64LE=Le(function(n,o=0){return D(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Le(function(n,o=0){return F(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(n,o,_,M){if(n=+n,o=o>>>0,!M){const be=Math.pow(2,8*_-1);ne(this,n,o,_,be-1,-be)}let q=0,Y=1,ue=0;for(this[o]=n&255;++q<_&&(Y*=256);)n<0&&ue===0&&this[o+q-1]!==0&&(ue=1),this[o+q]=(n/Y>>0)-ue&255;return o+_},h.prototype.writeIntBE=function(n,o,_,M){if(n=+n,o=o>>>0,!M){const be=Math.pow(2,8*_-1);ne(this,n,o,_,be-1,-be)}let q=_-1,Y=1,ue=0;for(this[o+q]=n&255;--q>=0&&(Y*=256);)n<0&&ue===0&&this[o+q+1]!==0&&(ue=1),this[o+q]=(n/Y>>0)-ue&255;return o+_},h.prototype.writeInt8=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,1,127,-128),n<0&&(n=255+n+1),this[o]=n&255,o+1},h.prototype.writeInt16LE=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,2,32767,-32768),this[o]=n&255,this[o+1]=n>>>8,o+2},h.prototype.writeInt16BE=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,2,32767,-32768),this[o]=n>>>8,this[o+1]=n&255,o+2},h.prototype.writeInt32LE=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,4,2147483647,-2147483648),this[o]=n&255,this[o+1]=n>>>8,this[o+2]=n>>>16,this[o+3]=n>>>24,o+4},h.prototype.writeInt32BE=function(n,o,_){return n=+n,o=o>>>0,_||ne(this,n,o,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4},h.prototype.writeBigInt64LE=Le(function(n,o=0){return D(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Le(function(n,o=0){return F(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function V(d,n,o,_,M,q){if(o+_>d.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function Z(d,n,o,_,M){return n=+n,o=o>>>0,M||V(d,n,o,4),t.write(d,n,o,_,23,4),o+4}h.prototype.writeFloatLE=function(n,o,_){return Z(this,n,o,!0,_)},h.prototype.writeFloatBE=function(n,o,_){return Z(this,n,o,!1,_)};function Q(d,n,o,_,M){return n=+n,o=o>>>0,M||V(d,n,o,8),t.write(d,n,o,_,52,8),o+8}h.prototype.writeDoubleLE=function(n,o,_){return Q(this,n,o,!0,_)},h.prototype.writeDoubleBE=function(n,o,_){return Q(this,n,o,!1,_)},h.prototype.copy=function(n,o,_,M){if(!h.isBuffer(n))throw new TypeError("argument should be a Buffer");if(_||(_=0),!M&&M!==0&&(M=this.length),o>=n.length&&(o=n.length),o||(o=0),M>0&&M<_&&(M=_),M===_||n.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(_<0||_>=this.length)throw new RangeError("Index out of range");if(M<0)throw new RangeError("sourceEnd out of bounds");M>this.length&&(M=this.length),n.length-o<M-_&&(M=n.length-o+_);const q=M-_;return this===n&&typeof l.prototype.copyWithin=="function"?this.copyWithin(o,_,M):l.prototype.set.call(n,this.subarray(_,M),o),q},h.prototype.fill=function(n,o,_,M){if(typeof n=="string"){if(typeof o=="string"?(M=o,o=0,_=this.length):typeof _=="string"&&(M=_,_=this.length),M!==void 0&&typeof M!="string")throw new TypeError("encoding must be a string");if(typeof M=="string"&&!h.isEncoding(M))throw new TypeError("Unknown encoding: "+M);if(n.length===1){const Y=n.charCodeAt(0);(M==="utf8"&&Y<128||M==="latin1")&&(n=Y)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(o<0||this.length<o||this.length<_)throw new RangeError("Out of range index");if(_<=o)return this;o=o>>>0,_=_===void 0?this.length:_>>>0,n||(n=0);let q;if(typeof n=="number")for(q=o;q<_;++q)this[q]=n;else{const Y=h.isBuffer(n)?n:h.from(n,M),ue=Y.length;if(ue===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(q=0;q<_-o;++q)this[q+o]=Y[q%ue]}return this};const v={};function w(d,n,o){v[d]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${d}]`,this.stack,delete this.name}get code(){return d}set code(M){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:M,writable:!0})}toString(){return`${this.name} [${d}]: ${this.message}`}}}w("ERR_BUFFER_OUT_OF_BOUNDS",function(d){return d?`${d} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),w("ERR_INVALID_ARG_TYPE",function(d,n){return`The "${d}" argument must be of type number. Received type ${typeof n}`},TypeError),w("ERR_OUT_OF_RANGE",function(d,n,o){let _=`The value of "${d}" is out of range.`,M=o;return Number.isInteger(o)&&Math.abs(o)>oe(2,32)?M=z(String(o)):typeof o=="bigint"&&(M=String(o),(o>oe(BigInt(2),BigInt(32))||o<-oe(BigInt(2),BigInt(32)))&&(M=z(M)),M+="n"),_+=` It must be ${n}. Received ${M}`,_},RangeError);function z(d){let n="",o=d.length;const _=d[0]==="-"?1:0;for(;o>=_+4;o-=3)n=`_${d.slice(o-3,o)}${n}`;return`${d.slice(0,o)}${n}`}function ee(d,n,o){ie(n,"offset"),(d[n]===void 0||d[n+o]===void 0)&&le(n,d.length-(o+1))}function ce(d,n,o,_,M,q){if(d>o||d<n){const Y=typeof n=="bigint"?"n":"";let ue;throw n===0||n===BigInt(0)?ue=`>= 0${Y} and < 2${Y} ** ${(q+1)*8}${Y}`:ue=`>= -(2${Y} ** ${(q+1)*8-1}${Y}) and < 2 ** ${(q+1)*8-1}${Y}`,new v.ERR_OUT_OF_RANGE("value",ue,d)}ee(_,M,q)}function ie(d,n){if(typeof d!="number")throw new v.ERR_INVALID_ARG_TYPE(n,"number",d)}function le(d,n,o){throw Math.floor(d)!==d?(ie(d,o),new v.ERR_OUT_OF_RANGE("offset","an integer",d)):n<0?new v.ERR_BUFFER_OUT_OF_BOUNDS:new v.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,d)}const De=/[^+/0-9A-Za-z-_]/g;function H(d){if(d=d.split("=")[0],d=d.trim().replace(De,""),d.length<2)return"";for(;d.length%4!==0;)d=d+"=";return d}function Fe(d,n){n=n||1/0;let o;const _=d.length;let M=null;const q=[];for(let Y=0;Y<_;++Y){if(o=d.charCodeAt(Y),o>55295&&o<57344){if(!M){if(o>56319){(n-=3)>-1&&q.push(239,191,189);continue}else if(Y+1===_){(n-=3)>-1&&q.push(239,191,189);continue}M=o;continue}if(o<56320){(n-=3)>-1&&q.push(239,191,189),M=o;continue}o=(M-55296<<10|o-56320)+65536}else M&&(n-=3)>-1&&q.push(239,191,189);if(M=null,o<128){if((n-=1)<0)break;q.push(o)}else if(o<2048){if((n-=2)<0)break;q.push(o>>6|192,o&63|128)}else if(o<65536){if((n-=3)<0)break;q.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((n-=4)<0)break;q.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return q}function Ue(d){const n=[];for(let o=0;o<d.length;++o)n.push(d.charCodeAt(o)&255);return n}function ye(d,n){let o,_,M;const q=[];for(let Y=0;Y<d.length&&!((n-=2)<0);++Y)o=d.charCodeAt(Y),_=o>>8,M=o%256,q.push(M),q.push(_);return q}function we(d){return e.toByteArray(H(d))}function je(d,n,o,_){let M;for(M=0;M<_&&!(M+o>=n.length||M>=d.length);++M)n[M+o]=d[M];return M}function Ne(d,n){return d instanceof n||d!=null&&d.constructor!=null&&d.constructor.name!=null&&d.constructor.name===n.name}function We(d){return d!==d}const Ge=function(){const d="0123456789abcdef",n=new Array(256);for(let o=0;o<16;++o){const _=o*16;for(let M=0;M<16;++M)n[_+M]=d[o]+d[M]}return n}();function Le(d){return typeof BigInt=="undefined"?rt:d}function rt(){throw new Error("BigInt not supported")}})(Un);const _a=Un.Buffer;if(typeof ae=="undefined"?globalThis.process={env:{},browser:!0,version:"v18.0.0",platform:"browser",arch:"x64",versions:{node:"18.0.0"},nextTick:(r,...e)=>{if(typeof r!="function")throw new TypeError("nextTick callback must be a function");if(typeof MessageChannel!="undefined"){const t=new MessageChannel;t.port2.onmessage=()=>{try{r(...e)}catch(s){setTimeout(()=>{throw s},0)}},t.port1.postMessage(null)}else setTimeout(()=>{try{r(...e)}catch(t){setTimeout(()=>{throw t},0)}},0)},cwd:()=>"/",chdir:()=>{},umask:()=>0}:typeof ae.nextTick=="undefined"&&(ae.nextTick=(r,...e)=>{if(typeof r!="function")throw new TypeError("nextTick callback must be a function");if(typeof MessageChannel!="undefined"){const t=new MessageChannel;t.port2.onmessage=()=>{try{r(...e)}catch(s){setTimeout(()=>{throw s},0)}},t.port1.postMessage(null)}else setTimeout(()=>{try{r(...e)}catch(t){setTimeout(()=>{throw t},0)}},0)}),typeof globalThis=="undefined"&&(globalThis.global=globalThis),typeof _a=="undefined"){let r=null;try{typeof require!="undefined"&&(r=require("buffer").Buffer)}catch(e){}r?globalThis.Buffer=r:globalThis.Buffer={isBuffer:e=>!1,from:e=>new Uint8Array(e),alloc:e=>new Uint8Array(e),allocUnsafe:e=>new Uint8Array(e)}}typeof setImmediate=="undefined"&&(globalThis.setImmediate=(r,...e)=>setTimeout(()=>r(...e),0)),typeof clearImmediate=="undefined"&&(globalThis.clearImmediate=r=>{clearTimeout(r)});var Ea=Object.defineProperty,Ca=(r,e,t)=>e in r?Ea(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ot=(r,e,t)=>Ca(r,typeof e!="symbol"?e+"":e,t),tt=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class qn{constructor(e,t,s="/apis/video-call"){ot(this,"socket",null),ot(this,"serverUrl"),ot(this,"socketPath"),ot(this,"token"),ot(this,"connected",!1),ot(this,"reconnectAttempts",0),ot(this,"maxReconnectAttempts",5),this.serverUrl=e,this.token=t,this.socketPath=s}connect(){return tt(this,null,function*(){return this.socket&&this.socket.connected?Promise.resolve():(this.socket&&(this.socket.removeAllListeners(),this.socket.disconnect(),this.socket=null),new Promise((e,t)=>{try{this.socket=ge.io(this.serverUrl,{path:this.socketPath,transports:["websocket","polling"],timeout:1e4,forceNew:!0,auth:{token:this.token}}),this.socket.on("connect",()=>{this.connected=!0,this.reconnectAttempts=0,console.log("[CallSocket] Connected to signaling server"),e()}),this.socket.on("disconnect",s=>{this.connected=!1,console.log("[CallSocket] Disconnected:",s),this.handleDisconnection(s)}),this.socket.on("connect_error",s=>{console.error("[CallSocket] Connection error:",s),this.reconnectAttempts++,this.reconnectAttempts>=this.maxReconnectAttempts&&t(new Error(`Failed to connect after ${this.maxReconnectAttempts} attempts`))})}catch(s){t(s)}}))})}disconnect(){this.socket&&(this.socket.removeAllListeners(),this.socket.disconnect(),this.socket=null,this.connected=!1)}isConnected(){var e;return this.connected&&((e=this.socket)==null?void 0:e.connected)===!0}emit(e,t){var s;if(!this.isConnected())throw new Error("Socket not connected");console.log(`[CallSocket] Emitting ${e}:`,t),(s=this.socket)==null||s.emit(e,t,c=>{c!=null&&c.error&&console.error(`[CallSocket] Error in ${e}:`,c.error)})}emitWithResponse(e,t,s=1e4){return tt(this,null,function*(){if(!this.isConnected())throw new Error("Socket not connected");return console.log(`[CallSocket] Emitting ${e} with response:`,t),new Promise((c,l)=>{var g;const f=setTimeout(()=>{l(new Error(`Timeout waiting for response to ${e}`))},s);console.log(`[CallSocket] about to emit: ${e}...`),(g=this.socket)==null||g.emit(e,t,u=>{clearTimeout(f),u!=null&&u.error?(console.error(`[CallSocket] Error in ${e}:`,u.error),l(new Error(u.error))):(console.log(`[CallSocket] Response for ${e}:`,u),c(u))})})})}on(e,t){if(!this.socket)throw new Error("Socket not connected");this.socket.on(e,t)}off(e,t){this.socket&&(t?this.socket.off(e,t):this.socket.removeAllListeners(e))}startCall(e){return tt(this,null,function*(){return this.emitWithResponse("call.start",{roomId:e})})}joinRoom(e){return tt(this,null,function*(){return this.emitWithResponse("call.join",{roomId:e})})}leaveCall(e){return tt(this,null,function*(){return this.emitWithResponse("call.leave",{roomId:e})})}sendOffer(e,t,s){this.emit("call.offer",{to:e,offer:t,roomId:s})}sendAnswer(e,t,s){this.emit("call.answer",{to:e,answer:t,roomId:s})}sendCandidate(e,t,s){this.emit("call.candidate",{to:e,candidate:t,roomId:s})}sendStateUpdate(e,t,s){this.emit("call.state",{to:e,state:t,roomId:s})}endCall(e,t,s){this.emit("call.end",{roomId:s,targetUserId:e})}endCallForAll(e){return tt(this,null,function*(){this.emit("call.end",{roomId:e})})}startRecording(e,t){return this.emit("call.recording.start",{roomId:e,recordingId:t})}sendRecordingChunk(e,t,s){this.emit("call.recording.chunk",{roomId:e,recordingId:t,chunk:s})}endRecording(e,t,s){return tt(this,null,function*(){return this.emitWithResponse("call.recording.end",{roomId:e,recordingId:t,transcripts:s})})}sendTranscript(e,t){this.emit("call.transcript",{roomId:e,transcript:t,timestamp:Date.now()})}checkCallStatus(e){return tt(this,null,function*(){return this.emitWithResponse("call.status",{roomId:e})})}getIceServers(e){return tt(this,null,function*(){return this.emitWithResponse("call.ice-servers",{roomId:e})})}handleDisconnection(e){["transport close","transport error","io server disconnect"].includes(e)&&this.reconnectAttempts<this.maxReconnectAttempts&&setTimeout(()=>{this.connected||(console.log(`[CallSocket] Attempting to reconnect... (${this.reconnectAttempts+1}/${this.maxReconnectAttempts})`),this.connect().catch(console.error))},Math.pow(2,this.reconnectAttempts)*1e3)}getConnectionInfo(){var e,t;return{connected:this.connected,socketId:(e=this.socket)==null?void 0:e.id,transport:(t=this.socket)==null?void 0:t.io.engine.transport.name,reconnectAttempts:this.reconnectAttempts}}}var Ra=Object.defineProperty,Pa=(r,e,t)=>e in r?Ra(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yt=(r,e,t)=>Pa(r,typeof e!="symbol"?e+"":e,t),Ct=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class xn{constructor(e={video:!0,audio:!0}){yt(this,"cameraStream",null),yt(this,"screenStream",null),yt(this,"videoElement",null),yt(this,"constraints"),yt(this,"isScreenShare",!1),this.constraints=e}initialize(){return Ct(this,null,function*(){try{return console.log("[CallMediaStream] Initializing media stream with constraints:",this.constraints),this.cameraStream=yield navigator.mediaDevices.getUserMedia(this.constraints),console.log("[CallMediaStream] Media stream initialized successfully"),this.cameraStream}catch(e){throw console.error("[CallMediaStream] Failed to initialize media stream:",e),this.handleMediaError(e)}})}startScreenShare(){return Ct(this,arguments,function*(e={video:!0,audio:!1}){try{return console.log("[CallMediaStream] Starting screen share"),this.screenStream=yield navigator.mediaDevices.getDisplayMedia({video:e.video,audio:e.audio}),this.isScreenShare=!0,this.screenStream.getVideoTracks()[0].addEventListener("ended",()=>{console.log("[CallMediaStream] Screen share ended by user"),this.stopScreenShare()}),console.log("[CallMediaStream] Screen share started successfully"),this.screenStream}catch(t){throw console.error("[CallMediaStream] Failed to start screen share:",t),this.handleMediaError(t)}})}stopScreenShare(){return Ct(this,null,function*(){try{if(console.log("[CallMediaStream] Stopping screen share"),this.screenStream&&this.isScreenShare&&(this.screenStream.getTracks().forEach(e=>e.stop()),this.screenStream=null),!this.cameraStream)this.cameraStream=yield this.initialize();else{const e=this.cameraStream.getVideoTracks();(e.length===0||e[0].readyState==="ended")&&(console.log("[CallMediaStream] Camera stream is inactive, reinitializing"),this.cameraStream=yield this.initialize())}return this.isScreenShare=!1,console.log("[CallMediaStream] Reverted to camera stream"),this.cameraStream}catch(e){throw console.error("[CallMediaStream] Failed to stop screen share:",e),this.handleMediaError(e)}})}toggleAudio(e){const t=this.getCurrentStream();if(!t){console.warn("[CallMediaStream] No stream available for audio toggle");return}t.getAudioTracks().forEach(c=>{c.enabled=e}),console.log(`[CallMediaStream] Audio ${e?"enabled":"disabled"}`)}toggleVideo(e){const t=this.getCurrentStream();if(!t){console.warn("[CallMediaStream] No stream available for video toggle");return}t.getVideoTracks().forEach(c=>{c.enabled=e}),console.log(`[CallMediaStream] Video ${e?"enabled":"disabled"}`)}createVideoElement(){const e=document.createElement("video");e.autoplay=!0,e.playsInline=!0,e.muted=!0;const t=this.getCurrentStream();return t&&(e.srcObject=t),this.videoElement=e,e}attachToVideoElement(e){const t=this.getCurrentStream();t&&(e.srcObject=t,this.videoElement=e)}replaceStream(e){const t=this.getCurrentStream();t&&t.getTracks().forEach(s=>s.stop()),this.isScreenShare?this.screenStream=e:this.cameraStream=e,this.videoElement&&(this.videoElement.srcObject=e),console.log("[CallMediaStream] Stream replaced successfully")}getCurrentStream(){return this.isScreenShare?this.screenStream:this.cameraStream}getStream(){return this.getCurrentStream()}getCameraStream(){return this.cameraStream}getScreenStream(){return this.screenStream}getVideoElement(){return this.videoElement}getIsScreenShare(){return this.isScreenShare}isAudioEnabled(){const e=this.getCurrentStream();if(!e)return!1;const t=e.getAudioTracks();return t.length>0&&t[0].enabled}isVideoEnabled(){const e=this.getCurrentStream();if(!e)return!1;const t=e.getVideoTracks();return t.length>0&&t[0].enabled}getStreamInfo(){const e=this.getCurrentStream();if(!e)return null;const t=e.getVideoTracks(),s=e.getAudioTracks();return{id:e.id,videoTracks:t.length,audioTracks:s.length,isScreenShare:this.isScreenShare,videoEnabled:t.length>0?t[0].enabled:!1,audioEnabled:s.length>0?s[0].enabled:!1,videoConstraints:t.length>0?t[0].getSettings():null,audioConstraints:s.length>0?s[0].getSettings():null,hasCameraStream:!!this.cameraStream,hasScreenStream:!!this.screenStream}}getVideoTrack(){const e=this.getCurrentStream();if(!e)return null;const t=e.getVideoTracks();return t.length>0?t[0]:null}getAudioTrack(){const e=this.getCurrentStream();if(!e)return null;const t=e.getAudioTracks();return t.length>0?t[0]:null}getCameraVideoTrack(){if(!this.cameraStream)return null;const e=this.cameraStream.getVideoTracks();return e.length>0?e[0]:null}getScreenVideoTrack(){if(!this.screenStream)return null;const e=this.screenStream.getVideoTracks();return e.length>0?e[0]:null}cleanup(){console.log("[CallMediaStream] Cleaning up media stream"),this.cameraStream&&(this.cameraStream.getTracks().forEach(e=>{e.stop()}),this.cameraStream=null),this.screenStream&&(this.screenStream.getTracks().forEach(e=>{e.stop()}),this.screenStream=null),this.videoElement&&(this.videoElement.srcObject=null,this.videoElement=null),this.isScreenShare=!1}handleMediaError(e){let t="Unknown media error";return e.name==="NotAllowedError"?t="Permission denied. Please allow camera and microphone access.":e.name==="NotFoundError"?t="No camera or microphone found. Please check your devices.":e.name==="NotReadableError"?t="Camera or microphone is already in use by another application.":e.name==="OverconstrainedError"?t="Camera or microphone does not support the requested constraints.":e.name==="SecurityError"?t="Media access blocked due to security restrictions.":e.name==="AbortError"&&(t="Media access was aborted."),new Error(`${t} (${e.name})`)}static getAvailableDevices(){return Ct(this,null,function*(){try{const e=yield navigator.mediaDevices.enumerateDevices();return{videoDevices:e.filter(t=>t.kind==="videoinput"),audioDevices:e.filter(t=>t.kind==="audioinput")}}catch(e){throw console.error("[CallMediaStream] Failed to get available devices:",e),e}})}static checkBrowserSupport(){return{getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),webRTC:!!window.RTCPeerConnection}}}function $t(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Rt={exports:{}},Wt,$n;function Ta(){if($n)return Wt;$n=1;var r=1e3,e=r*60,t=e*60,s=t*24,c=s*7,l=s*365.25;Wt=function(h,B){B=B||{};var I=typeof h;if(I==="string"&&h.length>0)return g(h);if(I==="number"&&isFinite(h))return B.long?u(h):f(h);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(h))};function g(h){if(h=String(h),!(h.length>100)){var B=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(B){var I=parseFloat(B[1]),$=(B[2]||"ms").toLowerCase();switch($){case"years":case"year":case"yrs":case"yr":case"y":return I*l;case"weeks":case"week":case"w":return I*c;case"days":case"day":case"d":return I*s;case"hours":case"hour":case"hrs":case"hr":case"h":return I*t;case"minutes":case"minute":case"mins":case"min":case"m":return I*e;case"seconds":case"second":case"secs":case"sec":case"s":return I*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return I;default:return}}}}function f(h){var B=Math.abs(h);return B>=s?Math.round(h/s)+"d":B>=t?Math.round(h/t)+"h":B>=e?Math.round(h/e)+"m":B>=r?Math.round(h/r)+"s":h+"ms"}function u(h){var B=Math.abs(h);return B>=s?m(h,B,s,"day"):B>=t?m(h,B,t,"hour"):B>=e?m(h,B,e,"minute"):B>=r?m(h,B,r,"second"):h+" ms"}function m(h,B,I,$){var b=B>=I*1.5;return Math.round(h/I)+" "+$+(b?"s":"")}return Wt}var Vt,Wn;function Aa(){if(Wn)return Vt;Wn=1;function r(e){s.debug=s,s.default=s,s.coerce=m,s.disable=f,s.enable=l,s.enabled=u,s.humanize=Ta(),s.destroy=h,Object.keys(e).forEach(B=>{s[B]=e[B]}),s.names=[],s.skips=[],s.formatters={};function t(B){let I=0;for(let $=0;$<B.length;$++)I=(I<<5)-I+B.charCodeAt($),I|=0;return s.colors[Math.abs(I)%s.colors.length]}s.selectColor=t;function s(B){let I,$=null,b,k;function P(...y){if(!P.enabled)return;const C=P,A=Number(new Date),T=A-(I||A);C.diff=T,C.prev=I,C.curr=A,I=A,y[0]=s.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let O=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(R,L)=>{if(R==="%%")return"%";O++;const W=s.formatters[L];if(typeof W=="function"){const X=y[O];R=W.call(C,X),y.splice(O,1),O--}return R}),s.formatArgs.call(C,y),(C.log||s.log).apply(C,y)}return P.namespace=B,P.useColors=s.useColors(),P.color=s.selectColor(B),P.extend=c,P.destroy=s.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>$!==null?$:(b!==s.namespaces&&(b=s.namespaces,k=s.enabled(B)),k),set:y=>{$=y}}),typeof s.init=="function"&&s.init(P),P}function c(B,I){const $=s(this.namespace+(typeof I=="undefined"?":":I)+B);return $.log=this.log,$}function l(B){s.save(B),s.namespaces=B,s.names=[],s.skips=[];const I=(typeof B=="string"?B:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const $ of I)$[0]==="-"?s.skips.push($.slice(1)):s.names.push($)}function g(B,I){let $=0,b=0,k=-1,P=0;for(;$<B.length;)if(b<I.length&&(I[b]===B[$]||I[b]==="*"))I[b]==="*"?(k=b,P=$,b++):($++,b++);else if(k!==-1)b=k+1,P++,$=P;else return!1;for(;b<I.length&&I[b]==="*";)b++;return b===I.length}function f(){const B=[...s.names,...s.skips.map(I=>"-"+I)].join(",");return s.enable(""),B}function u(B){for(const I of s.skips)if(g(B,I))return!1;for(const I of s.names)if(g(B,I))return!0;return!1}function m(B){return B instanceof Error?B.stack||B.message:B}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return s.enable(s.load()),s}return Vt=r,Vt}var Vn;function Ia(){return Vn||(Vn=1,function(r,e){e.formatArgs=s,e.save=c,e.load=l,e.useColors=t,e.storage=g(),e.destroy=(()=>{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){if(typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let u;return typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&(u=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(u[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function s(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+r.exports.humanize(this.diff),!this.useColors)return;const m="color: "+this.color;u.splice(1,0,m,"color: inherit");let h=0,B=0;u[0].replace(/%[a-zA-Z%]/g,I=>{I!=="%%"&&(h++,I==="%c"&&(B=h))}),u.splice(B,0,m)}e.log=console.debug||console.log||(()=>{});function c(u){try{u?e.storage.setItem("debug",u):e.storage.removeItem("debug")}catch(m){}}function l(){let u;try{u=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch(m){}return!u&&typeof ae!="undefined"&&"env"in ae&&(u=ae.env.DEBUG),u}function g(){try{return localStorage}catch(u){}}r.exports=Aa()(e);const{formatters:f}=r.exports;f.j=function(u){try{return JSON.stringify(u)}catch(m){return"[UnexpectedJSONParseError]: "+m.message}}}(Rt,Rt.exports)),Rt.exports}var Gt,Gn;function Ba(){return Gn||(Gn=1,Gt=function(){if(typeof globalThis=="undefined")return null;var e={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}),Gt}var Pt={exports:{}},Tt={exports:{}},zt={},zn;function mt(){return zn||(zn=1,function(r){Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},t={};t.byteLength=h,t.toByteArray=I,t.fromByteArray=k;for(var s=[],c=[],l=typeof Uint8Array!="undefined"?Uint8Array:Array,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,u=g.length;f<u;++f)s[f]=g[f],c[g.charCodeAt(f)]=f;c[45]=62,c[95]=63;function m(C){var A=C.length;if(A%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var T=C.indexOf("=");T===-1&&(T=A);var O=T===A?0:4-T%4;return[T,O]}function h(C){var A=m(C),T=A[0],O=A[1];return(T+O)*3/4-O}function B(C,A,T){return(A+T)*3/4-T}function I(C){var A,T=m(C),O=T[0],S=T[1],R=new l(B(C,O,S)),L=0,W=S>0?O-4:O,X;for(X=0;X<W;X+=4)A=c[C.charCodeAt(X)]<<18|c[C.charCodeAt(X+1)]<<12|c[C.charCodeAt(X+2)]<<6|c[C.charCodeAt(X+3)],R[L++]=A>>16&255,R[L++]=A>>8&255,R[L++]=A&255;return S===2&&(A=c[C.charCodeAt(X)]<<2|c[C.charCodeAt(X+1)]>>4,R[L++]=A&255),S===1&&(A=c[C.charCodeAt(X)]<<10|c[C.charCodeAt(X+1)]<<4|c[C.charCodeAt(X+2)]>>2,R[L++]=A>>8&255,R[L++]=A&255),R}function $(C){return s[C>>18&63]+s[C>>12&63]+s[C>>6&63]+s[C&63]}function b(C,A,T){for(var O,S=[],R=A;R<T;R+=3)O=(C[R]<<16&16711680)+(C[R+1]<<8&65280)+(C[R+2]&255),S.push($(O));return S.join("")}function k(C){for(var A,T=C.length,O=T%3,S=[],R=16383,L=0,W=T-O;L<W;L+=R)S.push(b(C,L,L+R>W?W:L+R));return O===1?(A=C[T-1],S.push(s[A>>2]+s[A<<4&63]+"==")):O===2&&(A=(C[T-2]<<8)+C[T-1],S.push(s[A>>10]+s[A>>4&63]+s[A<<2&63]+"=")),S.join("")}var P={};P.read=function(C,A,T,O,S){var R,L,W=S*8-O-1,X=(1<<W)-1,re=X>>1,U=-7,he=T?S-1:0,de=T?-1:1,me=C[A+he];for(he+=de,R=me&(1<<-U)-1,me>>=-U,U+=W;U>0;R=R*256+C[A+he],he+=de,U-=8);for(L=R&(1<<-U)-1,R>>=-U,U+=O;U>0;L=L*256+C[A+he],he+=de,U-=8);if(R===0)R=1-re;else{if(R===X)return L?NaN:(me?-1:1)*(1/0);L=L+Math.pow(2,O),R=R-re}return(me?-1:1)*L*Math.pow(2,R-O)},P.write=function(C,A,T,O,S,R){var L,W,X,re=R*8-S-1,U=(1<<re)-1,he=U>>1,de=S===23?Math.pow(2,-24)-Math.pow(2,-77):0,me=O?0:R-1,Te=O?1:-1,ke=A<0||A===0&&1/A<0?1:0;for(A=Math.abs(A),isNaN(A)||A===1/0?(W=isNaN(A)?1:0,L=U):(L=Math.floor(Math.log(A)/Math.LN2),A*(X=Math.pow(2,-L))<1&&(L--,X*=2),L+he>=1?A+=de/X:A+=de*Math.pow(2,1-he),A*X>=2&&(L++,X/=2),L+he>=U?(W=0,L=U):L+he>=1?(W=(A*X-1)*Math.pow(2,S),L=L+he):(W=A*Math.pow(2,he-1)*Math.pow(2,S),L=0));S>=8;C[T+me]=W&255,me+=Te,W/=256,S-=8);for(L=L<<S|W,re+=S;re>0;C[T+me]=L&255,me+=Te,L/=256,re-=8);C[T+me-Te]|=ke*128};(function(C){const A=t,T=P,O=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;C.Buffer=U,C.SlowBuffer=G,C.INSPECT_MAX_BYTES=50;const S=2147483647;C.kMaxLength=S;const{Uint8Array:R,ArrayBuffer:L,SharedArrayBuffer:W}=globalThis;U.TYPED_ARRAY_SUPPORT=X(),!U.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function X(){try{const p=new R(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,R.prototype),Object.setPrototypeOf(p,i),p.foo()===42}catch(p){return!1}}Object.defineProperty(U.prototype,"parent",{enumerable:!0,get:function(){if(U.isBuffer(this))return this.buffer}}),Object.defineProperty(U.prototype,"offset",{enumerable:!0,get:function(){if(U.isBuffer(this))return this.byteOffset}});function re(p){if(p>S)throw new RangeError('The value "'+p+'" is invalid for option "size"');const i=new R(p);return Object.setPrototypeOf(i,U.prototype),i}function U(p,i,a){if(typeof p=="number"){if(typeof i=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Te(p)}return he(p,i,a)}U.poolSize=8192;function he(p,i,a){if(typeof p=="string")return ke(p,i);if(L.isView(p))return _e(p);if(p==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p);if(Ze(p,L)||p&&Ze(p.buffer,L)||typeof W!="undefined"&&(Ze(p,W)||p&&Ze(p.buffer,W)))return Me(p,i,a);if(typeof p=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const E=p.valueOf&&p.valueOf();if(E!=null&&E!==p)return U.from(E,i,a);const N=xe(p);if(N)return N;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof p[Symbol.toPrimitive]=="function")return U.from(p[Symbol.toPrimitive]("string"),i,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p)}U.from=function(p,i,a){return he(p,i,a)},Object.setPrototypeOf(U.prototype,R.prototype),Object.setPrototypeOf(U,R);function de(p){if(typeof p!="number")throw new TypeError('"size" argument must be of type number');if(p<0)throw new RangeError('The value "'+p+'" is invalid for option "size"')}function me(p,i,a){return de(p),p<=0?re(p):i!==void 0?typeof a=="string"?re(p).fill(i,a):re(p).fill(i):re(p)}U.alloc=function(p,i,a){return me(p,i,a)};function Te(p){return de(p),re(p<0?0:j(p)|0)}U.allocUnsafe=function(p){return Te(p)},U.allocUnsafeSlow=function(p){return Te(p)};function ke(p,i){if((typeof i!="string"||i==="")&&(i="utf8"),!U.isEncoding(i))throw new TypeError("Unknown encoding: "+i);const a=J(p,i)|0;let E=re(a);const N=E.write(p,i);return N!==a&&(E=E.slice(0,N)),E}function Ee(p){const i=p.length<0?0:j(p.length)|0,a=re(i);for(let E=0;E<i;E+=1)a[E]=p[E]&255;return a}function _e(p){if(Ze(p,R)){const i=new R(p);return Me(i.buffer,i.byteOffset,i.byteLength)}return Ee(p)}function Me(p,i,a){if(i<0||p.byteLength<i)throw new RangeError('"offset" is outside of buffer bounds');if(p.byteLength<i+(a||0))throw new RangeError('"length" is outside of buffer bounds');let E;return i===void 0&&a===void 0?E=new R(p):a===void 0?E=new R(p,i):E=new R(p,i,a),Object.setPrototypeOf(E,U.prototype),E}function xe(p){if(U.isBuffer(p)){const i=j(p.length)|0,a=re(i);return a.length===0||p.copy(a,0,0,i),a}if(p.length!==void 0)return typeof p.length!="number"||Bn(p.length)?re(0):Ee(p);if(p.type==="Buffer"&&Array.isArray(p.data))return Ee(p.data)}function j(p){if(p>=S)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+S.toString(16)+" bytes");return p|0}function G(p){return+p!=p&&(p=0),U.alloc(+p)}U.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==U.prototype},U.compare=function(i,a){if(Ze(i,R)&&(i=U.from(i,i.offset,i.byteLength)),Ze(a,R)&&(a=U.from(a,a.offset,a.byteLength)),!U.isBuffer(i)||!U.isBuffer(a))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===a)return 0;let E=i.length,N=a.length;for(let x=0,K=Math.min(E,N);x<K;++x)if(i[x]!==a[x]){E=i[x],N=a[x];break}return E<N?-1:N<E?1:0},U.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},U.concat=function(i,a){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return U.alloc(0);let E;if(a===void 0)for(a=0,E=0;E<i.length;++E)a+=i[E].length;const N=U.allocUnsafe(a);let x=0;for(E=0;E<i.length;++E){let K=i[E];if(Ze(K,R))x+K.length>N.length?(U.isBuffer(K)||(K=U.from(K)),K.copy(N,x)):R.prototype.set.call(N,K,x);else if(U.isBuffer(K))K.copy(N,x);else throw new TypeError('"list" argument must be an Array of Buffers');x+=K.length}return N};function J(p,i){if(U.isBuffer(p))return p.length;if(L.isView(p)||Ze(p,L))return p.byteLength;if(typeof p!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof p);const a=p.length,E=arguments.length>2&&arguments[2]===!0;if(!E&&a===0)return 0;let N=!1;for(;;)switch(i){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return be(p).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a*2;case"hex":return a>>>1;case"base64":return pe(p).length;default:if(N)return E?-1:be(p).length;i=(""+i).toLowerCase(),N=!0}}U.byteLength=J;function ne(p,i,a){let E=!1;if((i===void 0||i<0)&&(i=0),i>this.length||((a===void 0||a>this.length)&&(a=this.length),a<=0)||(a>>>=0,i>>>=0,a<=i))return"";for(p||(p="utf8");;)switch(p){case"hex":return Fe(this,i,a);case"utf8":case"utf-8":return ce(this,i,a);case"ascii":return De(this,i,a);case"latin1":case"binary":return H(this,i,a);case"base64":return ee(this,i,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ue(this,i,a);default:if(E)throw new TypeError("Unknown encoding: "+p);p=(p+"").toLowerCase(),E=!0}}U.prototype._isBuffer=!0;function D(p,i,a){const E=p[i];p[i]=p[a],p[a]=E}U.prototype.swap16=function(){const i=this.length;if(i%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let a=0;a<i;a+=2)D(this,a,a+1);return this},U.prototype.swap32=function(){const i=this.length;if(i%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let a=0;a<i;a+=4)D(this,a,a+3),D(this,a+1,a+2);return this},U.prototype.swap64=function(){const i=this.length;if(i%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let a=0;a<i;a+=8)D(this,a,a+7),D(this,a+1,a+6),D(this,a+2,a+5),D(this,a+3,a+4);return this},U.prototype.toString=function(){const i=this.length;return i===0?"":arguments.length===0?ce(this,0,i):ne.apply(this,arguments)},U.prototype.toLocaleString=U.prototype.toString,U.prototype.equals=function(i){if(!U.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i?!0:U.compare(this,i)===0},U.prototype.inspect=function(){let i="";const a=C.INSPECT_MAX_BYTES;return i=this.toString("hex",0,a).replace(/(.{2})/g,"$1 ").trim(),this.length>a&&(i+=" ... "),"<Buffer "+i+">"},O&&(U.prototype[O]=U.prototype.inspect),U.prototype.compare=function(i,a,E,N,x){if(Ze(i,R)&&(i=U.from(i,i.offset,i.byteLength)),!U.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(a===void 0&&(a=0),E===void 0&&(E=i?i.length:0),N===void 0&&(N=0),x===void 0&&(x=this.length),a<0||E>i.length||N<0||x>this.length)throw new RangeError("out of range index");if(N>=x&&a>=E)return 0;if(N>=x)return-1;if(a>=E)return 1;if(a>>>=0,E>>>=0,N>>>=0,x>>>=0,this===i)return 0;let K=x-N,fe=E-a;const Ae=Math.min(K,fe),Re=this.slice(N,x),Ie=i.slice(a,E);for(let ve=0;ve<Ae;++ve)if(Re[ve]!==Ie[ve]){K=Re[ve],fe=Ie[ve];break}return K<fe?-1:fe<K?1:0};function F(p,i,a,E,N){if(p.length===0)return-1;if(typeof a=="string"?(E=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,Bn(a)&&(a=N?0:p.length-1),a<0&&(a=p.length+a),a>=p.length){if(N)return-1;a=p.length-1}else if(a<0)if(N)a=0;else return-1;if(typeof i=="string"&&(i=U.from(i,E)),U.isBuffer(i))return i.length===0?-1:V(p,i,a,E,N);if(typeof i=="number")return i=i&255,typeof R.prototype.indexOf=="function"?N?R.prototype.indexOf.call(p,i,a):R.prototype.lastIndexOf.call(p,i,a):V(p,[i],a,E,N);throw new TypeError("val must be string, number or Buffer")}function V(p,i,a,E,N){let x=1,K=p.length,fe=i.length;if(E!==void 0&&(E=String(E).toLowerCase(),E==="ucs2"||E==="ucs-2"||E==="utf16le"||E==="utf-16le")){if(p.length<2||i.length<2)return-1;x=2,K/=2,fe/=2,a/=2}function Ae(Ie,ve){return x===1?Ie[ve]:Ie.readUInt16BE(ve*x)}let Re;if(N){let Ie=-1;for(Re=a;Re<K;Re++)if(Ae(p,Re)===Ae(i,Ie===-1?0:Re-Ie)){if(Ie===-1&&(Ie=Re),Re-Ie+1===fe)return Ie*x}else Ie!==-1&&(Re-=Re-Ie),Ie=-1}else for(a+fe>K&&(a=K-fe),Re=a;Re>=0;Re--){let Ie=!0;for(let ve=0;ve<fe;ve++)if(Ae(p,Re+ve)!==Ae(i,ve)){Ie=!1;break}if(Ie)return Re}return-1}U.prototype.includes=function(i,a,E){return this.indexOf(i,a,E)!==-1},U.prototype.indexOf=function(i,a,E){return F(this,i,a,E,!0)},U.prototype.lastIndexOf=function(i,a,E){return F(this,i,a,E,!1)};function Z(p,i,a,E){a=Number(a)||0;const N=p.length-a;E?(E=Number(E),E>N&&(E=N)):E=N;const x=i.length;E>x/2&&(E=x/2);let K;for(K=0;K<E;++K){const fe=parseInt(i.substr(K*2,2),16);if(Bn(fe))return K;p[a+K]=fe}return K}function Q(p,i,a,E){return Dt(be(i,p.length-a),p,a,E)}function v(p,i,a,E){return Dt(Se(i),p,a,E)}function w(p,i,a,E){return Dt(pe(i),p,a,E)}function z(p,i,a,E){return Dt(Ce(i,p.length-a),p,a,E)}U.prototype.write=function(i,a,E,N){if(a===void 0)N="utf8",E=this.length,a=0;else if(E===void 0&&typeof a=="string")N=a,E=this.length,a=0;else if(isFinite(a))a=a>>>0,isFinite(E)?(E=E>>>0,N===void 0&&(N="utf8")):(N=E,E=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const x=this.length-a;if((E===void 0||E>x)&&(E=x),i.length>0&&(E<0||a<0)||a>this.length)throw new RangeError("Attempt to write outside buffer bounds");N||(N="utf8");let K=!1;for(;;)switch(N){case"hex":return Z(this,i,a,E);case"utf8":case"utf-8":return Q(this,i,a,E);case"ascii":case"latin1":case"binary":return v(this,i,a,E);case"base64":return w(this,i,a,E);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,i,a,E);default:if(K)throw new TypeError("Unknown encoding: "+N);N=(""+N).toLowerCase(),K=!0}},U.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ee(p,i,a){return i===0&&a===p.length?A.fromByteArray(p):A.fromByteArray(p.slice(i,a))}function ce(p,i,a){a=Math.min(p.length,a);const E=[];let N=i;for(;N<a;){const x=p[N];let K=null,fe=x>239?4:x>223?3:x>191?2:1;if(N+fe<=a){let Ae,Re,Ie,ve;switch(fe){case 1:x<128&&(K=x);break;case 2:Ae=p[N+1],(Ae&192)===128&&(ve=(x&31)<<6|Ae&63,ve>127&&(K=ve));break;case 3:Ae=p[N+1],Re=p[N+2],(Ae&192)===128&&(Re&192)===128&&(ve=(x&15)<<12|(Ae&63)<<6|Re&63,ve>2047&&(ve<55296||ve>57343)&&(K=ve));break;case 4:Ae=p[N+1],Re=p[N+2],Ie=p[N+3],(Ae&192)===128&&(Re&192)===128&&(Ie&192)===128&&(ve=(x&15)<<18|(Ae&63)<<12|(Re&63)<<6|Ie&63,ve>65535&&ve<1114112&&(K=ve))}}K===null?(K=65533,fe=1):K>65535&&(K-=65536,E.push(K>>>10&1023|55296),K=56320|K&1023),E.push(K),N+=fe}return le(E)}const ie=4096;function le(p){const i=p.length;if(i<=ie)return String.fromCharCode.apply(String,p);let a="",E=0;for(;E<i;)a+=String.fromCharCode.apply(String,p.slice(E,E+=ie));return a}function De(p,i,a){let E="";a=Math.min(p.length,a);for(let N=i;N<a;++N)E+=String.fromCharCode(p[N]&127);return E}function H(p,i,a){let E="";a=Math.min(p.length,a);for(let N=i;N<a;++N)E+=String.fromCharCode(p[N]);return E}function Fe(p,i,a){const E=p.length;(!i||i<0)&&(i=0),(!a||a<0||a>E)&&(a=E);let N="";for(let x=i;x<a;++x)N+=Fl[p[x]];return N}function Ue(p,i,a){const E=p.slice(i,a);let N="";for(let x=0;x<E.length-1;x+=2)N+=String.fromCharCode(E[x]+E[x+1]*256);return N}U.prototype.slice=function(i,a){const E=this.length;i=~~i,a=a===void 0?E:~~a,i<0?(i+=E,i<0&&(i=0)):i>E&&(i=E),a<0?(a+=E,a<0&&(a=0)):a>E&&(a=E),a<i&&(a=i);const N=this.subarray(i,a);return Object.setPrototypeOf(N,U.prototype),N};function ye(p,i,a){if(p%1!==0||p<0)throw new RangeError("offset is not uint");if(p+i>a)throw new RangeError("Trying to access beyond buffer length")}U.prototype.readUintLE=U.prototype.readUIntLE=function(i,a,E){i=i>>>0,a=a>>>0,E||ye(i,a,this.length);let N=this[i],x=1,K=0;for(;++K<a&&(x*=256);)N+=this[i+K]*x;return N},U.prototype.readUintBE=U.prototype.readUIntBE=function(i,a,E){i=i>>>0,a=a>>>0,E||ye(i,a,this.length);let N=this[i+--a],x=1;for(;a>0&&(x*=256);)N+=this[i+--a]*x;return N},U.prototype.readUint8=U.prototype.readUInt8=function(i,a){return i=i>>>0,a||ye(i,1,this.length),this[i]},U.prototype.readUint16LE=U.prototype.readUInt16LE=function(i,a){return i=i>>>0,a||ye(i,2,this.length),this[i]|this[i+1]<<8},U.prototype.readUint16BE=U.prototype.readUInt16BE=function(i,a){return i=i>>>0,a||ye(i,2,this.length),this[i]<<8|this[i+1]},U.prototype.readUint32LE=U.prototype.readUInt32LE=function(i,a){return i=i>>>0,a||ye(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+this[i+3]*16777216},U.prototype.readUint32BE=U.prototype.readUInt32BE=function(i,a){return i=i>>>0,a||ye(i,4,this.length),this[i]*16777216+(this[i+1]<<16|this[i+2]<<8|this[i+3])},U.prototype.readBigUInt64LE=nt(function(i){i=i>>>0,M(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&q(i,this.length-8);const N=a+this[++i]*oe(2,8)+this[++i]*oe(2,16)+this[++i]*oe(2,24),x=this[++i]+this[++i]*oe(2,8)+this[++i]*oe(2,16)+E*oe(2,24);return BigInt(N)+(BigInt(x)<<BigInt(32))}),U.prototype.readBigUInt64BE=nt(function(i){i=i>>>0,M(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&q(i,this.length-8);const N=a*oe(2,24)+this[++i]*oe(2,16)+this[++i]*oe(2,8)+this[++i],x=this[++i]*oe(2,24)+this[++i]*oe(2,16)+this[++i]*oe(2,8)+E;return(BigInt(N)<<BigInt(32))+BigInt(x)}),U.prototype.readIntLE=function(i,a,E){i=i>>>0,a=a>>>0,E||ye(i,a,this.length);let N=this[i],x=1,K=0;for(;++K<a&&(x*=256);)N+=this[i+K]*x;return x*=128,N>=x&&(N-=Math.pow(2,8*a)),N},U.prototype.readIntBE=function(i,a,E){i=i>>>0,a=a>>>0,E||ye(i,a,this.length);let N=a,x=1,K=this[i+--N];for(;N>0&&(x*=256);)K+=this[i+--N]*x;return x*=128,K>=x&&(K-=Math.pow(2,8*a)),K},U.prototype.readInt8=function(i,a){return i=i>>>0,a||ye(i,1,this.length),this[i]&128?(255-this[i]+1)*-1:this[i]},U.prototype.readInt16LE=function(i,a){i=i>>>0,a||ye(i,2,this.length);const E=this[i]|this[i+1]<<8;return E&32768?E|4294901760:E},U.prototype.readInt16BE=function(i,a){i=i>>>0,a||ye(i,2,this.length);const E=this[i+1]|this[i]<<8;return E&32768?E|4294901760:E},U.prototype.readInt32LE=function(i,a){return i=i>>>0,a||ye(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},U.prototype.readInt32BE=function(i,a){return i=i>>>0,a||ye(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},U.prototype.readBigInt64LE=nt(function(i){i=i>>>0,M(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&q(i,this.length-8);const N=this[i+4]+this[i+5]*oe(2,8)+this[i+6]*oe(2,16)+(E<<24);return(BigInt(N)<<BigInt(32))+BigInt(a+this[++i]*oe(2,8)+this[++i]*oe(2,16)+this[++i]*oe(2,24))}),U.prototype.readBigInt64BE=nt(function(i){i=i>>>0,M(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&q(i,this.length-8);const N=(a<<24)+this[++i]*oe(2,16)+this[++i]*oe(2,8)+this[++i];return(BigInt(N)<<BigInt(32))+BigInt(this[++i]*oe(2,24)+this[++i]*oe(2,16)+this[++i]*oe(2,8)+E)}),U.prototype.readFloatLE=function(i,a){return i=i>>>0,a||ye(i,4,this.length),T.read(this,i,!0,23,4)},U.prototype.readFloatBE=function(i,a){return i=i>>>0,a||ye(i,4,this.length),T.read(this,i,!1,23,4)},U.prototype.readDoubleLE=function(i,a){return i=i>>>0,a||ye(i,8,this.length),T.read(this,i,!0,52,8)},U.prototype.readDoubleBE=function(i,a){return i=i>>>0,a||ye(i,8,this.length),T.read(this,i,!1,52,8)};function we(p,i,a,E,N,x){if(!U.isBuffer(p))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>N||i<x)throw new RangeError('"value" argument is out of bounds');if(a+E>p.length)throw new RangeError("Index out of range")}U.prototype.writeUintLE=U.prototype.writeUIntLE=function(i,a,E,N){if(i=+i,a=a>>>0,E=E>>>0,!N){const fe=Math.pow(2,8*E)-1;we(this,i,a,E,fe,0)}let x=1,K=0;for(this[a]=i&255;++K<E&&(x*=256);)this[a+K]=i/x&255;return a+E},U.prototype.writeUintBE=U.prototype.writeUIntBE=function(i,a,E,N){if(i=+i,a=a>>>0,E=E>>>0,!N){const fe=Math.pow(2,8*E)-1;we(this,i,a,E,fe,0)}let x=E-1,K=1;for(this[a+x]=i&255;--x>=0&&(K*=256);)this[a+x]=i/K&255;return a+E},U.prototype.writeUint8=U.prototype.writeUInt8=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,1,255,0),this[a]=i&255,a+1},U.prototype.writeUint16LE=U.prototype.writeUInt16LE=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,2,65535,0),this[a]=i&255,this[a+1]=i>>>8,a+2},U.prototype.writeUint16BE=U.prototype.writeUInt16BE=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,2,65535,0),this[a]=i>>>8,this[a+1]=i&255,a+2},U.prototype.writeUint32LE=U.prototype.writeUInt32LE=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,4,4294967295,0),this[a+3]=i>>>24,this[a+2]=i>>>16,this[a+1]=i>>>8,this[a]=i&255,a+4},U.prototype.writeUint32BE=U.prototype.writeUInt32BE=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,4,4294967295,0),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4};function je(p,i,a,E,N){_(i,E,N,p,a,7);let x=Number(i&BigInt(4294967295));p[a++]=x,x=x>>8,p[a++]=x,x=x>>8,p[a++]=x,x=x>>8,p[a++]=x;let K=Number(i>>BigInt(32)&BigInt(4294967295));return p[a++]=K,K=K>>8,p[a++]=K,K=K>>8,p[a++]=K,K=K>>8,p[a++]=K,a}function Ne(p,i,a,E,N){_(i,E,N,p,a,7);let x=Number(i&BigInt(4294967295));p[a+7]=x,x=x>>8,p[a+6]=x,x=x>>8,p[a+5]=x,x=x>>8,p[a+4]=x;let K=Number(i>>BigInt(32)&BigInt(4294967295));return p[a+3]=K,K=K>>8,p[a+2]=K,K=K>>8,p[a+1]=K,K=K>>8,p[a]=K,a+8}U.prototype.writeBigUInt64LE=nt(function(i,a=0){return je(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),U.prototype.writeBigUInt64BE=nt(function(i,a=0){return Ne(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),U.prototype.writeIntLE=function(i,a,E,N){if(i=+i,a=a>>>0,!N){const Ae=Math.pow(2,8*E-1);we(this,i,a,E,Ae-1,-Ae)}let x=0,K=1,fe=0;for(this[a]=i&255;++x<E&&(K*=256);)i<0&&fe===0&&this[a+x-1]!==0&&(fe=1),this[a+x]=(i/K>>0)-fe&255;return a+E},U.prototype.writeIntBE=function(i,a,E,N){if(i=+i,a=a>>>0,!N){const Ae=Math.pow(2,8*E-1);we(this,i,a,E,Ae-1,-Ae)}let x=E-1,K=1,fe=0;for(this[a+x]=i&255;--x>=0&&(K*=256);)i<0&&fe===0&&this[a+x+1]!==0&&(fe=1),this[a+x]=(i/K>>0)-fe&255;return a+E},U.prototype.writeInt8=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,1,127,-128),i<0&&(i=255+i+1),this[a]=i&255,a+1},U.prototype.writeInt16LE=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,2,32767,-32768),this[a]=i&255,this[a+1]=i>>>8,a+2},U.prototype.writeInt16BE=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,2,32767,-32768),this[a]=i>>>8,this[a+1]=i&255,a+2},U.prototype.writeInt32LE=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,4,2147483647,-2147483648),this[a]=i&255,this[a+1]=i>>>8,this[a+2]=i>>>16,this[a+3]=i>>>24,a+4},U.prototype.writeInt32BE=function(i,a,E){return i=+i,a=a>>>0,E||we(this,i,a,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4},U.prototype.writeBigInt64LE=nt(function(i,a=0){return je(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),U.prototype.writeBigInt64BE=nt(function(i,a=0){return Ne(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function We(p,i,a,E,N,x){if(a+E>p.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function Ge(p,i,a,E,N){return i=+i,a=a>>>0,N||We(p,i,a,4),T.write(p,i,a,E,23,4),a+4}U.prototype.writeFloatLE=function(i,a,E){return Ge(this,i,a,!0,E)},U.prototype.writeFloatBE=function(i,a,E){return Ge(this,i,a,!1,E)};function Le(p,i,a,E,N){return i=+i,a=a>>>0,N||We(p,i,a,8),T.write(p,i,a,E,52,8),a+8}U.prototype.writeDoubleLE=function(i,a,E){return Le(this,i,a,!0,E)},U.prototype.writeDoubleBE=function(i,a,E){return Le(this,i,a,!1,E)},U.prototype.copy=function(i,a,E,N){if(!U.isBuffer(i))throw new TypeError("argument should be a Buffer");if(E||(E=0),!N&&N!==0&&(N=this.length),a>=i.length&&(a=i.length),a||(a=0),N>0&&N<E&&(N=E),N===E||i.length===0||this.length===0)return 0;if(a<0)throw new RangeError("targetStart out of bounds");if(E<0||E>=this.length)throw new RangeError("Index out of range");if(N<0)throw new RangeError("sourceEnd out of bounds");N>this.length&&(N=this.length),i.length-a<N-E&&(N=i.length-a+E);const x=N-E;return this===i&&typeof R.prototype.copyWithin=="function"?this.copyWithin(a,E,N):R.prototype.set.call(i,this.subarray(E,N),a),x},U.prototype.fill=function(i,a,E,N){if(typeof i=="string"){if(typeof a=="string"?(N=a,a=0,E=this.length):typeof E=="string"&&(N=E,E=this.length),N!==void 0&&typeof N!="string")throw new TypeError("encoding must be a string");if(typeof N=="string"&&!U.isEncoding(N))throw new TypeError("Unknown encoding: "+N);if(i.length===1){const K=i.charCodeAt(0);(N==="utf8"&&K<128||N==="latin1")&&(i=K)}}else typeof i=="number"?i=i&255:typeof i=="boolean"&&(i=Number(i));if(a<0||this.length<a||this.length<E)throw new RangeError("Out of range index");if(E<=a)return this;a=a>>>0,E=E===void 0?this.length:E>>>0,i||(i=0);let x;if(typeof i=="number")for(x=a;x<E;++x)this[x]=i;else{const K=U.isBuffer(i)?i:U.from(i,N),fe=K.length;if(fe===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(x=0;x<E-a;++x)this[x+a]=K[x%fe]}return this};const rt={};function d(p,i,a){rt[p]=class extends a{constructor(){super(),Object.defineProperty(this,"message",{value:i.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${p}]`,this.stack,delete this.name}get code(){return p}set code(N){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:N,writable:!0})}toString(){return`${this.name} [${p}]: ${this.message}`}}}d("ERR_BUFFER_OUT_OF_BOUNDS",function(p){return p?`${p} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),d("ERR_INVALID_ARG_TYPE",function(p,i){return`The "${p}" argument must be of type number. Received type ${typeof i}`},TypeError),d("ERR_OUT_OF_RANGE",function(p,i,a){let E=`The value of "${p}" is out of range.`,N=a;return Number.isInteger(a)&&Math.abs(a)>oe(2,32)?N=n(String(a)):typeof a=="bigint"&&(N=String(a),(a>oe(BigInt(2),BigInt(32))||a<-oe(BigInt(2),BigInt(32)))&&(N=n(N)),N+="n"),E+=` It must be ${i}. Received ${N}`,E},RangeError);function n(p){let i="",a=p.length;const E=p[0]==="-"?1:0;for(;a>=E+4;a-=3)i=`_${p.slice(a-3,a)}${i}`;return`${p.slice(0,a)}${i}`}function o(p,i,a){M(i,"offset"),(p[i]===void 0||p[i+a]===void 0)&&q(i,p.length-(a+1))}function _(p,i,a,E,N,x){if(p>a||p<i){const K=typeof i=="bigint"?"n":"";let fe;throw i===0||i===BigInt(0)?fe=`>= 0${K} and < 2${K} ** ${(x+1)*8}${K}`:fe=`>= -(2${K} ** ${(x+1)*8-1}${K}) and < 2 ** ${(x+1)*8-1}${K}`,new rt.ERR_OUT_OF_RANGE("value",fe,p)}o(E,N,x)}function M(p,i){if(typeof p!="number")throw new rt.ERR_INVALID_ARG_TYPE(i,"number",p)}function q(p,i,a){throw Math.floor(p)!==p?(M(p,a),new rt.ERR_OUT_OF_RANGE("offset","an integer",p)):i<0?new rt.ERR_BUFFER_OUT_OF_BOUNDS:new rt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${i}`,p)}const Y=/[^+/0-9A-Za-z-_]/g;function ue(p){if(p=p.split("=")[0],p=p.trim().replace(Y,""),p.length<2)return"";for(;p.length%4!==0;)p=p+"=";return p}function be(p,i){i=i||1/0;let a;const E=p.length;let N=null;const x=[];for(let K=0;K<E;++K){if(a=p.charCodeAt(K),a>55295&&a<57344){if(!N){if(a>56319){(i-=3)>-1&&x.push(239,191,189);continue}else if(K+1===E){(i-=3)>-1&&x.push(239,191,189);continue}N=a;continue}if(a<56320){(i-=3)>-1&&x.push(239,191,189),N=a;continue}a=(N-55296<<10|a-56320)+65536}else N&&(i-=3)>-1&&x.push(239,191,189);if(N=null,a<128){if((i-=1)<0)break;x.push(a)}else if(a<2048){if((i-=2)<0)break;x.push(a>>6|192,a&63|128)}else if(a<65536){if((i-=3)<0)break;x.push(a>>12|224,a>>6&63|128,a&63|128)}else if(a<1114112){if((i-=4)<0)break;x.push(a>>18|240,a>>12&63|128,a>>6&63|128,a&63|128)}else throw new Error("Invalid code point")}return x}function Se(p){const i=[];for(let a=0;a<p.length;++a)i.push(p.charCodeAt(a)&255);return i}function Ce(p,i){let a,E,N;const x=[];for(let K=0;K<p.length&&!((i-=2)<0);++K)a=p.charCodeAt(K),E=a>>8,N=a%256,x.push(N),x.push(E);return x}function pe(p){return A.toByteArray(ue(p))}function Dt(p,i,a,E){let N;for(N=0;N<E&&!(N+a>=i.length||N>=p.length);++N)i[N+a]=p[N];return N}function Ze(p,i){return p instanceof i||p!=null&&p.constructor!=null&&p.constructor.name!=null&&p.constructor.name===i.name}function Bn(p){return p!==p}const Fl=function(){const p="0123456789abcdef",i=new Array(256);for(let a=0;a<16;++a){const E=a*16;for(let N=0;N<16;++N)i[E+N]=p[a]+p[N]}return i}();function nt(p){return typeof BigInt=="undefined"?Ul:p}function Ul(){throw new Error("BigInt not supported")}})(e);const y=e.Buffer;r.Blob=e.Blob,r.BlobOptions=e.BlobOptions,r.Buffer=e.Buffer,r.File=e.File,r.FileOptions=e.FileOptions,r.INSPECT_MAX_BYTES=e.INSPECT_MAX_BYTES,r.SlowBuffer=e.SlowBuffer,r.TranscodeEncoding=e.TranscodeEncoding,r.atob=e.atob,r.btoa=e.btoa,r.constants=e.constants,r.default=y,r.isAscii=e.isAscii,r.isUtf8=e.isUtf8,r.kMaxLength=e.kMaxLength,r.kStringMaxLength=e.kStringMaxLength,r.resolveObjectURL=e.resolveObjectURL,r.transcode=e.transcode}(zt)),zt}var Hn;function Jn(){return Hn||(Hn=1,function(r,e){var t=mt(),s=t.Buffer;function c(g,f){for(var u in g)f[u]=g[u]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?r.exports=t:(c(t,e),e.Buffer=l);function l(g,f,u){return s(g,f,u)}l.prototype=Object.create(s.prototype),c(s,l),l.from=function(g,f,u){if(typeof g=="number")throw new TypeError("Argument must not be a number");return s(g,f,u)},l.alloc=function(g,f,u){if(typeof g!="number")throw new TypeError("Argument must be a number");var m=s(g);return f!==void 0?typeof u=="string"?m.fill(f,u):m.fill(f):m.fill(0),m},l.allocUnsafe=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return s(g)},l.allocUnsafeSlow=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(g)}}(Tt,Tt.exports)),Tt.exports}var Yn;function ka(){if(Yn)return Pt.exports;Yn=1;var r=65536,e=4294967295;function t(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
2
|
+
Use Chrome, Firefox or Internet Explorer 11`)}var s=Jn().Buffer,c=globalThis.crypto||globalThis.msCrypto;c&&c.getRandomValues?Pt.exports=l:Pt.exports=t;function l(g,f){if(g>e)throw new RangeError("requested too many random bytes");var u=s.allocUnsafe(g);if(g>0)if(g>r)for(var m=0;m<g;m+=r)c.getRandomValues(u.slice(m,m+r));else c.getRandomValues(u);return typeof f=="function"?ae.nextTick(function(){f(null,u)}):u}return Pt.exports}var At={exports:{}},It={exports:{}},Kn;function Ht(){if(Kn)return It.exports;Kn=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(O,S,R){return Function.prototype.apply.call(O,S,R)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(O){return Object.getOwnPropertyNames(O).concat(Object.getOwnPropertySymbols(O))}:t=function(O){return Object.getOwnPropertyNames(O)};function s(T){console&&console.warn&&console.warn(T)}var c=Number.isNaN||function(O){return O!==O};function l(){l.init.call(this)}It.exports=l,It.exports.once=y,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var g=10;function f(T){if(typeof T!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof T)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return g},set:function(T){if(typeof T!="number"||T<0||c(T))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+T+".");g=T}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(O){if(typeof O!="number"||O<0||c(O))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+O+".");return this._maxListeners=O,this};function u(T){return T._maxListeners===void 0?l.defaultMaxListeners:T._maxListeners}l.prototype.getMaxListeners=function(){return u(this)},l.prototype.emit=function(O){for(var S=[],R=1;R<arguments.length;R++)S.push(arguments[R]);var L=O==="error",W=this._events;if(W!==void 0)L=L&&W.error===void 0;else if(!L)return!1;if(L){var X;if(S.length>0&&(X=S[0]),X instanceof Error)throw X;var re=new Error("Unhandled error."+(X?" ("+X.message+")":""));throw re.context=X,re}var U=W[O];if(U===void 0)return!1;if(typeof U=="function")e(U,this,S);else for(var he=U.length,de=b(U,he),R=0;R<he;++R)e(de[R],this,S);return!0};function m(T,O,S,R){var L,W,X;if(f(S),W=T._events,W===void 0?(W=T._events=Object.create(null),T._eventsCount=0):(W.newListener!==void 0&&(T.emit("newListener",O,S.listener?S.listener:S),W=T._events),X=W[O]),X===void 0)X=W[O]=S,++T._eventsCount;else if(typeof X=="function"?X=W[O]=R?[S,X]:[X,S]:R?X.unshift(S):X.push(S),L=u(T),L>0&&X.length>L&&!X.warned){X.warned=!0;var re=new Error("Possible EventEmitter memory leak detected. "+X.length+" "+String(O)+" listeners added. Use emitter.setMaxListeners() to increase limit");re.name="MaxListenersExceededWarning",re.emitter=T,re.type=O,re.count=X.length,s(re)}return T}l.prototype.addListener=function(O,S){return m(this,O,S,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(O,S){return m(this,O,S,!0)};function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function B(T,O,S){var R={fired:!1,wrapFn:void 0,target:T,type:O,listener:S},L=h.bind(R);return L.listener=S,R.wrapFn=L,L}l.prototype.once=function(O,S){return f(S),this.on(O,B(this,O,S)),this},l.prototype.prependOnceListener=function(O,S){return f(S),this.prependListener(O,B(this,O,S)),this},l.prototype.removeListener=function(O,S){var R,L,W,X,re;if(f(S),L=this._events,L===void 0)return this;if(R=L[O],R===void 0)return this;if(R===S||R.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete L[O],L.removeListener&&this.emit("removeListener",O,R.listener||S));else if(typeof R!="function"){for(W=-1,X=R.length-1;X>=0;X--)if(R[X]===S||R[X].listener===S){re=R[X].listener,W=X;break}if(W<0)return this;W===0?R.shift():k(R,W),R.length===1&&(L[O]=R[0]),L.removeListener!==void 0&&this.emit("removeListener",O,re||S)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(O){var S,R,L;if(R=this._events,R===void 0)return this;if(R.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):R[O]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete R[O]),this;if(arguments.length===0){var W=Object.keys(R),X;for(L=0;L<W.length;++L)X=W[L],X!=="removeListener"&&this.removeAllListeners(X);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=R[O],typeof S=="function")this.removeListener(O,S);else if(S!==void 0)for(L=S.length-1;L>=0;L--)this.removeListener(O,S[L]);return this};function I(T,O,S){var R=T._events;if(R===void 0)return[];var L=R[O];return L===void 0?[]:typeof L=="function"?S?[L.listener||L]:[L]:S?P(L):b(L,L.length)}l.prototype.listeners=function(O){return I(this,O,!0)},l.prototype.rawListeners=function(O){return I(this,O,!1)},l.listenerCount=function(T,O){return typeof T.listenerCount=="function"?T.listenerCount(O):$.call(T,O)},l.prototype.listenerCount=$;function $(T){var O=this._events;if(O!==void 0){var S=O[T];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function b(T,O){for(var S=new Array(O),R=0;R<O;++R)S[R]=T[R];return S}function k(T,O){for(;O+1<T.length;O++)T[O]=T[O+1];T.pop()}function P(T){for(var O=new Array(T.length),S=0;S<O.length;++S)O[S]=T[S].listener||T[S];return O}function y(T,O){return new Promise(function(S,R){function L(X){T.removeListener(O,W),R(X)}function W(){typeof T.removeListener=="function"&&T.removeListener("error",L),S([].slice.call(arguments))}A(T,O,W,{once:!0}),O!=="error"&&C(T,L,{once:!0})})}function C(T,O,S){typeof T.on=="function"&&A(T,"error",O,S)}function A(T,O,S,R){if(typeof T.on=="function")R.once?T.once(O,S):T.on(O,S);else if(typeof T.addEventListener=="function")T.addEventListener(O,function L(W){R.once&&T.removeEventListener(O,L),S(W)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof T)}return It.exports}var Jt,Xn;function Zn(){return Xn||(Xn=1,Jt=Ht().EventEmitter),Jt}var Yt={},Kt={},Xt,Qn;function ei(){return Qn||(Qn=1,Xt=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),s=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(s)!=="[object Symbol]")return!1;var c=42;e[t]=c;for(var l in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var g=Object.getOwnPropertySymbols(e);if(g.length!==1||g[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var f=Object.getOwnPropertyDescriptor(e,t);if(f.value!==c||f.enumerable!==!0)return!1}return!0}),Xt}var Zt,ti;function Bt(){if(ti)return Zt;ti=1;var r=ei();return Zt=function(){return r()&&!!Symbol.toStringTag},Zt}var Qt,ri;function ni(){return ri||(ri=1,Qt=Object),Qt}var er,ii;function Oa(){return ii||(ii=1,er=Error),er}var tr,oi;function Ma(){return oi||(oi=1,tr=EvalError),tr}var rr,ai;function La(){return ai||(ai=1,rr=RangeError),rr}var nr,si;function Na(){return si||(si=1,nr=ReferenceError),nr}var ir,li;function ci(){return li||(li=1,ir=SyntaxError),ir}var or,ui;function vt(){return ui||(ui=1,or=TypeError),or}var ar,fi;function Da(){return fi||(fi=1,ar=URIError),ar}var sr,hi;function Fa(){return hi||(hi=1,sr=Math.abs),sr}var lr,di;function Ua(){return di||(di=1,lr=Math.floor),lr}var cr,pi;function ja(){return pi||(pi=1,cr=Math.max),cr}var ur,gi;function qa(){return gi||(gi=1,ur=Math.min),ur}var fr,yi;function xa(){return yi||(yi=1,fr=Math.pow),fr}var hr,mi;function $a(){return mi||(mi=1,hr=Math.round),hr}var dr,vi;function Wa(){return vi||(vi=1,dr=Number.isNaN||function(e){return e!==e}),dr}var pr,wi;function Va(){if(wi)return pr;wi=1;var r=Wa();return pr=function(t){return r(t)||t===0?t:t<0?-1:1},pr}var gr,bi;function Ga(){return bi||(bi=1,gr=Object.getOwnPropertyDescriptor),gr}var yr,Si;function ct(){if(Si)return yr;Si=1;var r=Ga();if(r)try{r([],"length")}catch(e){r=null}return yr=r,yr}var mr,_i;function kt(){if(_i)return mr;_i=1;var r=Object.defineProperty||!1;if(r)try{r({},"a",{value:1})}catch(e){r=!1}return mr=r,mr}var vr,Ei;function za(){if(Ei)return vr;Ei=1;var r=typeof Symbol!="undefined"&&Symbol,e=ei();return vr=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},vr}var wr,Ci;function Ri(){return Ci||(Ci=1,wr=typeof Reflect!="undefined"&&Reflect.getPrototypeOf||null),wr}var br,Pi;function Ti(){if(Pi)return br;Pi=1;var r=ni();return br=r.getPrototypeOf||null,br}var Sr,Ai;function Ha(){if(Ai)return Sr;Ai=1;var r="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,t=Math.max,s="[object Function]",c=function(u,m){for(var h=[],B=0;B<u.length;B+=1)h[B]=u[B];for(var I=0;I<m.length;I+=1)h[I+u.length]=m[I];return h},l=function(u,m){for(var h=[],B=m,I=0;B<u.length;B+=1,I+=1)h[I]=u[B];return h},g=function(f,u){for(var m="",h=0;h<f.length;h+=1)m+=f[h],h+1<f.length&&(m+=u);return m};return Sr=function(u){var m=this;if(typeof m!="function"||e.apply(m)!==s)throw new TypeError(r+m);for(var h=l(arguments,1),B,I=function(){if(this instanceof B){var y=m.apply(this,c(h,arguments));return Object(y)===y?y:this}return m.apply(u,c(h,arguments))},$=t(0,m.length-h.length),b=[],k=0;k<$;k++)b[k]="$"+k;if(B=Function("binder","return function ("+g(b,",")+"){ return binder.apply(this,arguments); }")(I),m.prototype){var P=function(){};P.prototype=m.prototype,B.prototype=new P,P.prototype=null}return B},Sr}var _r,Ii;function wt(){if(Ii)return _r;Ii=1;var r=Ha();return _r=Function.prototype.bind||r,_r}var Er,Bi;function Cr(){return Bi||(Bi=1,Er=Function.prototype.call),Er}var Rr,ki;function Pr(){return ki||(ki=1,Rr=Function.prototype.apply),Rr}var Tr,Oi;function Ja(){return Oi||(Oi=1,Tr=typeof Reflect!="undefined"&&Reflect&&Reflect.apply),Tr}var Ar,Mi;function Li(){if(Mi)return Ar;Mi=1;var r=wt(),e=Pr(),t=Cr(),s=Ja();return Ar=s||r.call(t,e),Ar}var Ir,Ni;function Br(){if(Ni)return Ir;Ni=1;var r=wt(),e=vt(),t=Cr(),s=Li();return Ir=function(l){if(l.length<1||typeof l[0]!="function")throw new e("a function is required");return s(r,t,l)},Ir}var kr,Di;function Ya(){if(Di)return kr;Di=1;var r=Br(),e=ct(),t;try{t=[].__proto__===Array.prototype}catch(g){if(!g||typeof g!="object"||!("code"in g)||g.code!=="ERR_PROTO_ACCESS")throw g}var s=!!t&&e&&e(Object.prototype,"__proto__"),c=Object,l=c.getPrototypeOf;return kr=s&&typeof s.get=="function"?r([s.get]):typeof l=="function"?function(f){return l(f==null?f:c(f))}:!1,kr}var Or,Fi;function Mr(){if(Fi)return Or;Fi=1;var r=Ri(),e=Ti(),t=Ya();return Or=r?function(c){return r(c)}:e?function(c){if(!c||typeof c!="object"&&typeof c!="function")throw new TypeError("getProto: not an object");return e(c)}:t?function(c){return t(c)}:null,Or}var Lr,Ui;function ji(){if(Ui)return Lr;Ui=1;var r=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=wt();return Lr=t.call(r,e),Lr}var Nr,qi;function xi(){if(qi)return Nr;qi=1;var r,e=ni(),t=Oa(),s=Ma(),c=La(),l=Na(),g=ci(),f=vt(),u=Da(),m=Fa(),h=Ua(),B=ja(),I=qa(),$=xa(),b=$a(),k=Va(),P=Function,y=function(Z){try{return P('"use strict"; return ('+Z+").constructor;")()}catch(Q){}},C=ct(),A=kt(),T=function(){throw new f},O=C?function(){try{return arguments.callee,T}catch(Z){try{return C(arguments,"callee").get}catch(Q){return T}}}():T,S=za()(),R=Mr(),L=Ti(),W=Ri(),X=Pr(),re=Cr(),U={},he=typeof Uint8Array=="undefined"||!R?r:R(Uint8Array),de={__proto__:null,"%AggregateError%":typeof AggregateError=="undefined"?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?r:ArrayBuffer,"%ArrayIteratorPrototype%":S&&R?R([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":U,"%AsyncGenerator%":U,"%AsyncGeneratorFunction%":U,"%AsyncIteratorPrototype%":U,"%Atomics%":typeof Atomics=="undefined"?r:Atomics,"%BigInt%":typeof BigInt=="undefined"?r:BigInt,"%BigInt64Array%":typeof BigInt64Array=="undefined"?r:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array=="undefined"?r:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":s,"%Float16Array%":typeof Float16Array=="undefined"?r:Float16Array,"%Float32Array%":typeof Float32Array=="undefined"?r:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?r:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?r:FinalizationRegistry,"%Function%":P,"%GeneratorFunction%":U,"%Int8Array%":typeof Int8Array=="undefined"?r:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?r:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":S&&R?R(R([][Symbol.iterator]())):r,"%JSON%":typeof JSON=="object"?JSON:r,"%Map%":typeof Map=="undefined"?r:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!S||!R?r:R(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":C,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?r:Promise,"%Proxy%":typeof Proxy=="undefined"?r:Proxy,"%RangeError%":c,"%ReferenceError%":l,"%Reflect%":typeof Reflect=="undefined"?r:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?r:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!S||!R?r:R(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":S&&R?R(""[Symbol.iterator]()):r,"%Symbol%":S?Symbol:r,"%SyntaxError%":g,"%ThrowTypeError%":O,"%TypedArray%":he,"%TypeError%":f,"%Uint8Array%":typeof Uint8Array=="undefined"?r:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?r:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?r:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?r:Uint32Array,"%URIError%":u,"%WeakMap%":typeof WeakMap=="undefined"?r:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?r:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?r:WeakSet,"%Function.prototype.call%":re,"%Function.prototype.apply%":X,"%Object.defineProperty%":A,"%Object.getPrototypeOf%":L,"%Math.abs%":m,"%Math.floor%":h,"%Math.max%":B,"%Math.min%":I,"%Math.pow%":$,"%Math.round%":b,"%Math.sign%":k,"%Reflect.getPrototypeOf%":W};if(R)try{null.error}catch(Z){var me=R(R(Z));de["%Error.prototype%"]=me}var Te=function Z(Q){var v;if(Q==="%AsyncFunction%")v=y("async function () {}");else if(Q==="%GeneratorFunction%")v=y("function* () {}");else if(Q==="%AsyncGeneratorFunction%")v=y("async function* () {}");else if(Q==="%AsyncGenerator%"){var w=Z("%AsyncGeneratorFunction%");w&&(v=w.prototype)}else if(Q==="%AsyncIteratorPrototype%"){var z=Z("%AsyncGenerator%");z&&R&&(v=R(z.prototype))}return de[Q]=v,v},ke={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Ee=wt(),_e=ji(),Me=Ee.call(re,Array.prototype.concat),xe=Ee.call(X,Array.prototype.splice),j=Ee.call(re,String.prototype.replace),G=Ee.call(re,String.prototype.slice),J=Ee.call(re,RegExp.prototype.exec),ne=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,D=/\\(\\)?/g,F=function(Q){var v=G(Q,0,1),w=G(Q,-1);if(v==="%"&&w!=="%")throw new g("invalid intrinsic syntax, expected closing `%`");if(w==="%"&&v!=="%")throw new g("invalid intrinsic syntax, expected opening `%`");var z=[];return j(Q,ne,function(ee,ce,ie,le){z[z.length]=ie?j(le,D,"$1"):ce||ee}),z},V=function(Q,v){var w=Q,z;if(_e(ke,w)&&(z=ke[w],w="%"+z[0]+"%"),_e(de,w)){var ee=de[w];if(ee===U&&(ee=Te(w)),typeof ee=="undefined"&&!v)throw new f("intrinsic "+Q+" exists, but is not available. Please file an issue!");return{alias:z,name:w,value:ee}}throw new g("intrinsic "+Q+" does not exist!")};return Nr=function(Q,v){if(typeof Q!="string"||Q.length===0)throw new f("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof v!="boolean")throw new f('"allowMissing" argument must be a boolean');if(J(/^%?[^%]*%?$/,Q)===null)throw new g("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var w=F(Q),z=w.length>0?w[0]:"",ee=V("%"+z+"%",v),ce=ee.name,ie=ee.value,le=!1,De=ee.alias;De&&(z=De[0],xe(w,Me([0,1],De)));for(var H=1,Fe=!0;H<w.length;H+=1){var Ue=w[H],ye=G(Ue,0,1),we=G(Ue,-1);if((ye==='"'||ye==="'"||ye==="`"||we==='"'||we==="'"||we==="`")&&ye!==we)throw new g("property names with quotes must have matching quotes");if((Ue==="constructor"||!Fe)&&(le=!0),z+="."+Ue,ce="%"+z+"%",_e(de,ce))ie=de[ce];else if(ie!=null){if(!(Ue in ie)){if(!v)throw new f("base intrinsic for "+Q+" exists, but the property is not available.");return}if(C&&H+1>=w.length){var je=C(ie,Ue);Fe=!!je,Fe&&"get"in je&&!("originalValue"in je.get)?ie=je.get:ie=ie[Ue]}else Fe=_e(ie,Ue),ie=ie[Ue];Fe&&!le&&(de[ce]=ie)}}return ie},Nr}var Dr,$i;function bt(){if($i)return Dr;$i=1;var r=xi(),e=Br(),t=e([r("%String.prototype.indexOf%")]);return Dr=function(c,l){var g=r(c,!!l);return typeof g=="function"&&t(c,".prototype.")>-1?e([g]):g},Dr}var Fr,Wi;function Ka(){if(Wi)return Fr;Wi=1;var r=Bt()(),e=bt(),t=e("Object.prototype.toString"),s=function(f){return r&&f&&typeof f=="object"&&Symbol.toStringTag in f?!1:t(f)==="[object Arguments]"},c=function(f){return s(f)?!0:f!==null&&typeof f=="object"&&"length"in f&&typeof f.length=="number"&&f.length>=0&&t(f)!=="[object Array]"&&"callee"in f&&t(f.callee)==="[object Function]"},l=function(){return s(arguments)}();return s.isLegacyArguments=c,Fr=l?s:c,Fr}var Ur,Vi;function Xa(){if(Vi)return Ur;Vi=1;var r=bt(),e=Bt()(),t=ji(),s=ct(),c;if(e){var l=r("RegExp.prototype.exec"),g={},f=function(){throw g},u={toString:f,valueOf:f};typeof Symbol.toPrimitive=="symbol"&&(u[Symbol.toPrimitive]=f),c=function(I){if(!I||typeof I!="object")return!1;var $=s(I,"lastIndex"),b=$&&t($,"value");if(!b)return!1;try{l(I,u)}catch(k){return k===g}}}else{var m=r("Object.prototype.toString"),h="[object RegExp]";c=function(I){return!I||typeof I!="object"&&typeof I!="function"?!1:m(I)===h}}return Ur=c,Ur}var jr,Gi;function Za(){if(Gi)return jr;Gi=1;var r=bt(),e=Xa(),t=r("RegExp.prototype.exec"),s=vt();return jr=function(l){if(!e(l))throw new s("`regex` must be a RegExp");return function(f){return t(l,f)!==null}},jr}var qr,zi;function Qa(){if(zi)return qr;zi=1;var r=bt(),e=Za(),t=e(/^\s*(?:function)?\*/),s=Bt()(),c=Mr(),l=r("Object.prototype.toString"),g=r("Function.prototype.toString"),f=function(){if(!s)return!1;try{return Function("return function*() {}")()}catch(m){}},u;return qr=function(h){if(typeof h!="function")return!1;if(t(g(h)))return!0;if(!s){var B=l(h);return B==="[object GeneratorFunction]"}if(!c)return!1;if(typeof u=="undefined"){var I=f();u=I?c(I):!1}return c(h)===u},qr}var xr,Hi;function es(){if(Hi)return xr;Hi=1;var r=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,t,s;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{t=Object.defineProperty({},"length",{get:function(){throw s}}),s={},e(function(){throw 42},null,t)}catch(C){C!==s&&(e=null)}else e=null;var c=/^\s*class\b/,l=function(A){try{var T=r.call(A);return c.test(T)}catch(O){return!1}},g=function(A){try{return l(A)?!1:(r.call(A),!0)}catch(T){return!1}},f=Object.prototype.toString,u="[object Object]",m="[object Function]",h="[object GeneratorFunction]",B="[object HTMLAllCollection]",I="[object HTML document.all class]",$="[object HTMLCollection]",b=typeof Symbol=="function"&&!!Symbol.toStringTag,k=!(0 in[,]),P=function(){return!1};if(typeof document=="object"){var y=document.all;f.call(y)===f.call(document.all)&&(P=function(A){if((k||!A)&&(typeof A=="undefined"||typeof A=="object"))try{var T=f.call(A);return(T===B||T===I||T===$||T===u)&&A("")==null}catch(O){}return!1})}return xr=e?function(A){if(P(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;try{e(A,null,t)}catch(T){if(T!==s)return!1}return!l(A)&&g(A)}:function(A){if(P(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;if(b)return g(A);if(l(A))return!1;var T=f.call(A);return T!==m&&T!==h&&!/^\[object HTML/.test(T)?!1:g(A)},xr}var $r,Ji;function ts(){if(Ji)return $r;Ji=1;var r=es(),e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,s=function(u,m,h){for(var B=0,I=u.length;B<I;B++)t.call(u,B)&&(h==null?m(u[B],B,u):m.call(h,u[B],B,u))},c=function(u,m,h){for(var B=0,I=u.length;B<I;B++)h==null?m(u.charAt(B),B,u):m.call(h,u.charAt(B),B,u)},l=function(u,m,h){for(var B in u)t.call(u,B)&&(h==null?m(u[B],B,u):m.call(h,u[B],B,u))};function g(f){return e.call(f)==="[object Array]"}return $r=function(u,m,h){if(!r(m))throw new TypeError("iterator must be a function");var B;arguments.length>=3&&(B=h),g(u)?s(u,m,B):typeof u=="string"?c(u,m,B):l(u,m,B)},$r}var Wr,Yi;function rs(){return Yi||(Yi=1,Wr=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),Wr}var Vr,Ki;function ns(){if(Ki)return Vr;Ki=1;var r=rs(),e=globalThis;return Vr=function(){for(var s=[],c=0;c<r.length;c++)typeof e[r[c]]=="function"&&(s[s.length]=r[c]);return s},Vr}var Gr={exports:{}},zr,Xi;function is(){if(Xi)return zr;Xi=1;var r=kt(),e=ci(),t=vt(),s=ct();return zr=function(l,g,f){if(!l||typeof l!="object"&&typeof l!="function")throw new t("`obj` must be an object or a function`");if(typeof g!="string"&&typeof g!="symbol")throw new t("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new t("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new t("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new t("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new t("`loose`, if provided, must be a boolean");var u=arguments.length>3?arguments[3]:null,m=arguments.length>4?arguments[4]:null,h=arguments.length>5?arguments[5]:null,B=arguments.length>6?arguments[6]:!1,I=!!s&&s(l,g);if(r)r(l,g,{configurable:h===null&&I?I.configurable:!h,enumerable:u===null&&I?I.enumerable:!u,value:f,writable:m===null&&I?I.writable:!m});else if(B||!u&&!m&&!h)l[g]=f;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},zr}var Hr,Zi;function os(){if(Zi)return Hr;Zi=1;var r=kt(),e=function(){return!!r};return e.hasArrayLengthDefineBug=function(){if(!r)return null;try{return r([],"length",{value:1}).length!==1}catch(s){return!0}},Hr=e,Hr}var Jr,Qi;function as(){if(Qi)return Jr;Qi=1;var r=xi(),e=is(),t=os()(),s=ct(),c=vt(),l=r("%Math.floor%");return Jr=function(f,u){if(typeof f!="function")throw new c("`fn` is not a function");if(typeof u!="number"||u<0||u>4294967295||l(u)!==u)throw new c("`length` must be a positive 32-bit integer");var m=arguments.length>2&&!!arguments[2],h=!0,B=!0;if("length"in f&&s){var I=s(f,"length");I&&!I.configurable&&(h=!1),I&&!I.writable&&(B=!1)}return(h||B||!m)&&(t?e(f,"length",u,!0,!0):e(f,"length",u)),f},Jr}var Yr,eo;function ss(){if(eo)return Yr;eo=1;var r=wt(),e=Pr(),t=Li();return Yr=function(){return t(r,e,arguments)},Yr}var to;function ls(){return to||(to=1,function(r){var e=as(),t=kt(),s=Br(),c=ss();r.exports=function(g){var f=s(arguments),u=g.length-(arguments.length-1);return e(f,1+(u>0?u:0),!0)},t?t(r.exports,"apply",{value:c}):r.exports.apply=c}(Gr)),Gr.exports}var Kr,ro;function no(){if(ro)return Kr;ro=1;var r=ts(),e=ns(),t=ls(),s=bt(),c=ct(),l=Mr(),g=s("Object.prototype.toString"),f=Bt()(),u=globalThis,m=e(),h=s("String.prototype.slice"),B=s("Array.prototype.indexOf",!0)||function(P,y){for(var C=0;C<P.length;C+=1)if(P[C]===y)return C;return-1},I={__proto__:null};f&&c&&l?r(m,function(k){var P=new u[k];if(Symbol.toStringTag in P&&l){var y=l(P),C=c(y,Symbol.toStringTag);if(!C&&y){var A=l(y);C=c(A,Symbol.toStringTag)}I["$"+k]=t(C.get)}}):r(m,function(k){var P=new u[k],y=P.slice||P.set;y&&(I["$"+k]=t(y))});var $=function(P){var y=!1;return r(I,function(C,A){if(!y)try{"$"+C(P)===A&&(y=h(A,1))}catch(T){}}),y},b=function(P){var y=!1;return r(I,function(C,A){if(!y)try{C(P),y=h(A,1)}catch(T){}}),y};return Kr=function(P){if(!P||typeof P!="object")return!1;if(!f){var y=h(g(P),8,-1);return B(m,y)>-1?y:y!=="Object"?!1:b(P)}return c?$(P):null},Kr}var Xr,io;function cs(){if(io)return Xr;io=1;var r=no();return Xr=function(t){return!!r(t)},Xr}var oo;function us(){return oo||(oo=1,function(r){var e=Ka(),t=Qa(),s=no(),c=cs();function l(H){return H.call.bind(H)}var g=typeof BigInt!="undefined",f=typeof Symbol!="undefined",u=l(Object.prototype.toString),m=l(Number.prototype.valueOf),h=l(String.prototype.valueOf),B=l(Boolean.prototype.valueOf);if(g)var I=l(BigInt.prototype.valueOf);if(f)var $=l(Symbol.prototype.valueOf);function b(H,Fe){if(typeof H!="object")return!1;try{return Fe(H),!0}catch(Ue){return!1}}r.isArgumentsObject=e,r.isGeneratorFunction=t,r.isTypedArray=c;function k(H){return typeof Promise!="undefined"&&H instanceof Promise||H!==null&&typeof H=="object"&&typeof H.then=="function"&&typeof H.catch=="function"}r.isPromise=k;function P(H){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?ArrayBuffer.isView(H):c(H)||G(H)}r.isArrayBufferView=P;function y(H){return s(H)==="Uint8Array"}r.isUint8Array=y;function C(H){return s(H)==="Uint8ClampedArray"}r.isUint8ClampedArray=C;function A(H){return s(H)==="Uint16Array"}r.isUint16Array=A;function T(H){return s(H)==="Uint32Array"}r.isUint32Array=T;function O(H){return s(H)==="Int8Array"}r.isInt8Array=O;function S(H){return s(H)==="Int16Array"}r.isInt16Array=S;function R(H){return s(H)==="Int32Array"}r.isInt32Array=R;function L(H){return s(H)==="Float32Array"}r.isFloat32Array=L;function W(H){return s(H)==="Float64Array"}r.isFloat64Array=W;function X(H){return s(H)==="BigInt64Array"}r.isBigInt64Array=X;function re(H){return s(H)==="BigUint64Array"}r.isBigUint64Array=re;function U(H){return u(H)==="[object Map]"}U.working=typeof Map!="undefined"&&U(new Map);function he(H){return typeof Map=="undefined"?!1:U.working?U(H):H instanceof Map}r.isMap=he;function de(H){return u(H)==="[object Set]"}de.working=typeof Set!="undefined"&&de(new Set);function me(H){return typeof Set=="undefined"?!1:de.working?de(H):H instanceof Set}r.isSet=me;function Te(H){return u(H)==="[object WeakMap]"}Te.working=typeof WeakMap!="undefined"&&Te(new WeakMap);function ke(H){return typeof WeakMap=="undefined"?!1:Te.working?Te(H):H instanceof WeakMap}r.isWeakMap=ke;function Ee(H){return u(H)==="[object WeakSet]"}Ee.working=typeof WeakSet!="undefined"&&Ee(new WeakSet);function _e(H){return Ee(H)}r.isWeakSet=_e;function Me(H){return u(H)==="[object ArrayBuffer]"}Me.working=typeof ArrayBuffer!="undefined"&&Me(new ArrayBuffer);function xe(H){return typeof ArrayBuffer=="undefined"?!1:Me.working?Me(H):H instanceof ArrayBuffer}r.isArrayBuffer=xe;function j(H){return u(H)==="[object DataView]"}j.working=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined"&&j(new DataView(new ArrayBuffer(1),0,1));function G(H){return typeof DataView=="undefined"?!1:j.working?j(H):H instanceof DataView}r.isDataView=G;var J=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer:void 0;function ne(H){return u(H)==="[object SharedArrayBuffer]"}function D(H){return typeof J=="undefined"?!1:(typeof ne.working=="undefined"&&(ne.working=ne(new J)),ne.working?ne(H):H instanceof J)}r.isSharedArrayBuffer=D;function F(H){return u(H)==="[object AsyncFunction]"}r.isAsyncFunction=F;function V(H){return u(H)==="[object Map Iterator]"}r.isMapIterator=V;function Z(H){return u(H)==="[object Set Iterator]"}r.isSetIterator=Z;function Q(H){return u(H)==="[object Generator]"}r.isGeneratorObject=Q;function v(H){return u(H)==="[object WebAssembly.Module]"}r.isWebAssemblyCompiledModule=v;function w(H){return b(H,m)}r.isNumberObject=w;function z(H){return b(H,h)}r.isStringObject=z;function ee(H){return b(H,B)}r.isBooleanObject=ee;function ce(H){return g&&b(H,I)}r.isBigIntObject=ce;function ie(H){return f&&b(H,$)}r.isSymbolObject=ie;function le(H){return w(H)||z(H)||ee(H)||ce(H)||ie(H)}r.isBoxedPrimitive=le;function De(H){return typeof Uint8Array!="undefined"&&(xe(H)||D(H))}r.isAnyArrayBuffer=De,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(H){Object.defineProperty(r,H,{enumerable:!1,value:function(){throw new Error(H+" is not supported in userland")}})})}(Kt)),Kt}var Zr,ao;function fs(){return ao||(ao=1,Zr=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),Zr}var Ot={exports:{}},so;function ut(){return so||(so=1,typeof Object.create=="function"?Ot.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Ot.exports=function(e,t){if(t){e.super_=t;var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e}}),Ot.exports}var lo;function co(){return lo||(lo=1,function(r){var e=Object.getOwnPropertyDescriptors||function(G){for(var J=Object.keys(G),ne={},D=0;D<J.length;D++)ne[J[D]]=Object.getOwnPropertyDescriptor(G,J[D]);return ne},t=/%[sdj%]/g;r.format=function(j){if(!O(j)){for(var G=[],J=0;J<arguments.length;J++)G.push(g(arguments[J]));return G.join(" ")}for(var J=1,ne=arguments,D=ne.length,F=String(j).replace(t,function(Z){if(Z==="%%")return"%";if(J>=D)return Z;switch(Z){case"%s":return String(ne[J++]);case"%d":return Number(ne[J++]);case"%j":try{return JSON.stringify(ne[J++])}catch(Q){return"[Circular]"}default:return Z}}),V=ne[J];J<D;V=ne[++J])C(V)||!W(V)?F+=" "+V:F+=" "+g(V);return F},r.deprecate=function(j,G){if(typeof ae!="undefined"&&ae.noDeprecation===!0)return j;if(typeof ae=="undefined")return function(){return r.deprecate(j,G).apply(this,arguments)};var J=!1;function ne(){if(!J){if(ae.throwDeprecation)throw new Error(G);ae.traceDeprecation?console.trace(G):console.error(G),J=!0}return j.apply(this,arguments)}return ne};var s={},c=/^$/;if(ae.env.NODE_DEBUG){var l=ae.env.NODE_DEBUG;l=l.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),c=new RegExp("^"+l+"$","i")}r.debuglog=function(j){if(j=j.toUpperCase(),!s[j])if(c.test(j)){var G=ae.pid;s[j]=function(){var J=r.format.apply(r,arguments);console.error("%s %d: %s",j,G,J)}}else s[j]=function(){};return s[j]};function g(j,G){var J={seen:[],stylize:u};return arguments.length>=3&&(J.depth=arguments[2]),arguments.length>=4&&(J.colors=arguments[3]),y(G)?J.showHidden=G:G&&r._extend(J,G),R(J.showHidden)&&(J.showHidden=!1),R(J.depth)&&(J.depth=2),R(J.colors)&&(J.colors=!1),R(J.customInspect)&&(J.customInspect=!0),J.colors&&(J.stylize=f),h(J,j,J.depth)}r.inspect=g,g.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},g.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function f(j,G){var J=g.styles[G];return J?"\x1B["+g.colors[J][0]+"m"+j+"\x1B["+g.colors[J][1]+"m":j}function u(j,G){return j}function m(j){var G={};return j.forEach(function(J,ne){G[J]=!0}),G}function h(j,G,J){if(j.customInspect&&G&&U(G.inspect)&&G.inspect!==r.inspect&&!(G.constructor&&G.constructor.prototype===G)){var ne=G.inspect(J,j);return O(ne)||(ne=h(j,ne,J)),ne}var D=B(j,G);if(D)return D;var F=Object.keys(G),V=m(F);if(j.showHidden&&(F=Object.getOwnPropertyNames(G)),re(G)&&(F.indexOf("message")>=0||F.indexOf("description")>=0))return I(G);if(F.length===0){if(U(G)){var Z=G.name?": "+G.name:"";return j.stylize("[Function"+Z+"]","special")}if(L(G))return j.stylize(RegExp.prototype.toString.call(G),"regexp");if(X(G))return j.stylize(Date.prototype.toString.call(G),"date");if(re(G))return I(G)}var Q="",v=!1,w=["{","}"];if(P(G)&&(v=!0,w=["[","]"]),U(G)){var z=G.name?": "+G.name:"";Q=" [Function"+z+"]"}if(L(G)&&(Q=" "+RegExp.prototype.toString.call(G)),X(G)&&(Q=" "+Date.prototype.toUTCString.call(G)),re(G)&&(Q=" "+I(G)),F.length===0&&(!v||G.length==0))return w[0]+Q+w[1];if(J<0)return L(G)?j.stylize(RegExp.prototype.toString.call(G),"regexp"):j.stylize("[Object]","special");j.seen.push(G);var ee;return v?ee=$(j,G,J,V,F):ee=F.map(function(ce){return b(j,G,J,V,ce,v)}),j.seen.pop(),k(ee,Q,w)}function B(j,G){if(R(G))return j.stylize("undefined","undefined");if(O(G)){var J="'"+JSON.stringify(G).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return j.stylize(J,"string")}if(T(G))return j.stylize(""+G,"number");if(y(G))return j.stylize(""+G,"boolean");if(C(G))return j.stylize("null","null")}function I(j){return"["+Error.prototype.toString.call(j)+"]"}function $(j,G,J,ne,D){for(var F=[],V=0,Z=G.length;V<Z;++V)Ee(G,String(V))?F.push(b(j,G,J,ne,String(V),!0)):F.push("");return D.forEach(function(Q){Q.match(/^\d+$/)||F.push(b(j,G,J,ne,Q,!0))}),F}function b(j,G,J,ne,D,F){var V,Z,Q;if(Q=Object.getOwnPropertyDescriptor(G,D)||{value:G[D]},Q.get?Q.set?Z=j.stylize("[Getter/Setter]","special"):Z=j.stylize("[Getter]","special"):Q.set&&(Z=j.stylize("[Setter]","special")),Ee(ne,D)||(V="["+D+"]"),Z||(j.seen.indexOf(Q.value)<0?(C(J)?Z=h(j,Q.value,null):Z=h(j,Q.value,J-1),Z.indexOf(`
|
|
3
|
+
`)>-1&&(F?Z=Z.split(`
|
|
4
4
|
`).map(function(v){return" "+v}).join(`
|
|
5
5
|
`).slice(2):Z=`
|
|
6
6
|
`+Z.split(`
|
|
7
7
|
`).map(function(v){return" "+v}).join(`
|
|
8
|
-
`))):Z=j.stylize("[Circular]","special")),R(
|
|
9
|
-
`)>=0,
|
|
8
|
+
`))):Z=j.stylize("[Circular]","special")),R(V)){if(F&&D.match(/^\d+$/))return Z;V=JSON.stringify(""+D),V.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(V=V.slice(1,-1),V=j.stylize(V,"name")):(V=V.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),V=j.stylize(V,"string"))}return V+": "+Z}function k(j,G,J){var ne=j.reduce(function(D,F){return F.indexOf(`
|
|
9
|
+
`)>=0,D+F.replace(/\u001b\[\d\d?m/g,"").length+1},0);return ne>60?J[0]+(G===""?"":G+`
|
|
10
10
|
`)+" "+j.join(`,
|
|
11
|
-
`)+" "+z[1]:z[0]+W+" "+j.join(", ")+" "+z[1]}r.types=ps();function P(j){return Array.isArray(j)}r.isArray=P;function y(j){return typeof j=="boolean"}r.isBoolean=y;function C(j){return j===null}r.isNull=C;function A(j){return j==null}r.isNullOrUndefined=A;function T(j){return typeof j=="number"}r.isNumber=T;function O(j){return typeof j=="string"}r.isString=O;function S(j){return typeof j=="symbol"}r.isSymbol=S;function R(j){return j===void 0}r.isUndefined=R;function M(j){return G(j)&&de(j)==="[object RegExp]"}r.isRegExp=M,r.types.isRegExp=M;function G(j){return typeof j=="object"&&j!==null}r.isObject=G;function Q(j){return G(j)&&de(j)==="[object Date]"}r.isDate=Q,r.types.isDate=Q;function ie(j){return G(j)&&(de(j)==="[object Error]"||j instanceof Error)}r.isError=ie,r.types.isNativeError=ie;function U(j){return typeof j=="function"}r.isFunction=U;function ge(j){return j===null||typeof j=="boolean"||typeof j=="number"||typeof j=="string"||typeof j=="symbol"||typeof j=="undefined"}r.isPrimitive=ge,r.isBuffer=gs();function de(j){return Object.prototype.toString.call(j)}function ye(j){return j<10?"0"+j.toString(10):j.toString(10)}var Pe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Te(){var j=new Date,W=[ye(j.getHours()),ye(j.getMinutes()),ye(j.getSeconds())].join(":");return[j.getDate(),Pe[j.getMonth()],W].join(" ")}r.log=function(){console.log("%s - %s",Te(),r.format.apply(r,arguments))},r.inherits=ut(),r._extend=function(j,W){if(!W||!G(W))return j;for(var z=Object.keys(W),re=z.length;re--;)j[z[re]]=W[z[re]];return j};function Se(j,W){return Object.prototype.hasOwnProperty.call(j,W)}var we=typeof Symbol!="undefined"?Symbol("util.promisify.custom"):void 0;r.promisify=function(W){if(typeof W!="function")throw new TypeError('The "original" argument must be of type Function');if(we&&W[we]){var z=W[we];if(typeof z!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(z,we,{value:z,enumerable:!1,writable:!1,configurable:!0}),z}function z(){for(var re,L,D=new Promise(function(ee,v){re=ee,L=v}),q=[],Z=0;Z<arguments.length;Z++)q.push(arguments[Z]);q.push(function(ee,v){ee?L(ee):re(v)});try{W.apply(this,q)}catch(ee){L(ee)}return D}return Object.setPrototypeOf(z,Object.getPrototypeOf(W)),we&&Object.defineProperty(z,we,{value:z,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(z,e(W))},r.promisify.custom=we;function X(j,W){if(!j){var z=new Error("Promise was rejected with a falsy value");z.reason=j,j=z}return W(j)}function ae(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');function W(){for(var z=[],re=0;re<arguments.length;re++)z.push(arguments[re]);var L=z.pop();if(typeof L!="function")throw new TypeError("The last argument must be of type Function");var D=this,q=function(){return L.apply(D,arguments)};j.apply(this,z).then(function(Z){le.nextTick(q.bind(null,null,Z))},function(Z){le.nextTick(X.bind(null,Z,q))})}return Object.setPrototypeOf(W,Object.getPrototypeOf(j)),Object.defineProperties(W,e(j)),W}r.callbackify=ae}(Zt)),Zt}var rn,po;function ys(){if(po)return rn;po=1;function r(b,B){var P=Object.keys(b);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(b);B&&(y=y.filter(function(C){return Object.getOwnPropertyDescriptor(b,C).enumerable})),P.push.apply(P,y)}return P}function e(b){for(var B=1;B<arguments.length;B++){var P=arguments[B]!=null?arguments[B]:{};B%2?r(Object(P),!0).forEach(function(y){t(b,y,P[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(b,Object.getOwnPropertyDescriptors(P)):r(Object(P)).forEach(function(y){Object.defineProperty(b,y,Object.getOwnPropertyDescriptor(P,y))})}return b}function t(b,B,P){return B=g(B),B in b?Object.defineProperty(b,B,{value:P,enumerable:!0,configurable:!0,writable:!0}):b[B]=P,b}function s(b,B){if(!(b instanceof B))throw new TypeError("Cannot call a class as a function")}function c(b,B){for(var P=0;P<B.length;P++){var y=B[P];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(b,g(y.key),y)}}function l(b,B,P){return B&&c(b.prototype,B),Object.defineProperty(b,"prototype",{writable:!1}),b}function g(b){var B=f(b,"string");return typeof B=="symbol"?B:String(B)}function f(b,B){if(typeof b!="object"||b===null)return b;var P=b[Symbol.toPrimitive];if(P!==void 0){var y=P.call(b,B);if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(b)}var u=mt(),m=u.Buffer,h=ho(),k=h.inspect,I=k&&k.custom||"inspect";function V(b,B,P){m.prototype.copy.call(b,B,P)}return rn=function(){function b(){s(this,b),this.head=null,this.tail=null,this.length=0}return l(b,[{key:"push",value:function(P){var y={data:P,next:null};this.length>0?this.tail.next=y:this.head=y,this.tail=y,++this.length}},{key:"unshift",value:function(P){var y={data:P,next:this.head};this.length===0&&(this.tail=y),this.head=y,++this.length}},{key:"shift",value:function(){if(this.length!==0){var P=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,P}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(P){if(this.length===0)return"";for(var y=this.head,C=""+y.data;y=y.next;)C+=P+y.data;return C}},{key:"concat",value:function(P){if(this.length===0)return m.alloc(0);for(var y=m.allocUnsafe(P>>>0),C=this.head,A=0;C;)V(C.data,y,A),A+=C.data.length,C=C.next;return y}},{key:"consume",value:function(P,y){var C;return P<this.head.data.length?(C=this.head.data.slice(0,P),this.head.data=this.head.data.slice(P)):P===this.head.data.length?C=this.shift():C=y?this._getString(P):this._getBuffer(P),C}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(P){var y=this.head,C=1,A=y.data;for(P-=A.length;y=y.next;){var T=y.data,O=P>T.length?T.length:P;if(O===T.length?A+=T:A+=T.slice(0,P),P-=O,P===0){O===T.length?(++C,y.next?this.head=y.next:this.head=this.tail=null):(this.head=y,y.data=T.slice(O));break}++C}return this.length-=C,A}},{key:"_getBuffer",value:function(P){var y=m.allocUnsafe(P),C=this.head,A=1;for(C.data.copy(y),P-=C.data.length;C=C.next;){var T=C.data,O=P>T.length?T.length:P;if(T.copy(y,y.length-P,0,O),P-=O,P===0){O===T.length?(++A,C.next?this.head=C.next:this.head=this.tail=null):(this.head=C,C.data=T.slice(O));break}++A}return this.length-=A,y}},{key:I,value:function(P,y){return k(this,e(e({},y),{},{depth:0,customInspect:!1}))}}]),b}(),rn}var nn,go;function yo(){if(go)return nn;go=1;function r(g,f){var u=this,m=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return m||h?(f?f(g):g&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,le.nextTick(c,this,g)):le.nextTick(c,this,g)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(g||null,function(k){!f&&k?u._writableState?u._writableState.errorEmitted?le.nextTick(t,u):(u._writableState.errorEmitted=!0,le.nextTick(e,u,k)):le.nextTick(e,u,k):f?(le.nextTick(t,u),f(k)):le.nextTick(t,u)}),this)}function e(g,f){c(g,f),t(g)}function t(g){g._writableState&&!g._writableState.emitClose||g._readableState&&!g._readableState.emitClose||g.emit("close")}function s(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function c(g,f){g.emit("error",f)}function l(g,f){var u=g._readableState,m=g._writableState;u&&u.autoDestroy||m&&m.autoDestroy?g.destroy(f):g.emit("error",f)}return nn={destroy:r,undestroy:s,errorOrDestroy:l},nn}var on={},mo;function ft(){if(mo)return on;mo=1;function r(f,u){f.prototype=Object.create(u.prototype),f.prototype.constructor=f,f.__proto__=u}var e={};function t(f,u,m){m||(m=Error);function h(I,V,b){return typeof u=="string"?u:u(I,V,b)}var k=function(I){r(V,I);function V(b,B,P){return I.call(this,h(b,B,P))||this}return V}(m);k.prototype.name=m.name,k.prototype.code=f,e[f]=k}function s(f,u){if(Array.isArray(f)){var m=f.length;return f=f.map(function(h){return String(h)}),m>2?"one of ".concat(u," ").concat(f.slice(0,m-1).join(", "),", or ")+f[m-1]:m===2?"one of ".concat(u," ").concat(f[0]," or ").concat(f[1]):"of ".concat(u," ").concat(f[0])}else return"of ".concat(u," ").concat(String(f))}function c(f,u,m){return f.substr(0,u.length)===u}function l(f,u,m){return(m===void 0||m>f.length)&&(m=f.length),f.substring(m-u.length,m)===u}function g(f,u,m){return typeof m!="number"&&(m=0),m+u.length>f.length?!1:f.indexOf(u,m)!==-1}return t("ERR_INVALID_OPT_VALUE",function(f,u){return'The value "'+u+'" is invalid for option "'+f+'"'},TypeError),t("ERR_INVALID_ARG_TYPE",function(f,u,m){var h;typeof u=="string"&&c(u,"not ")?(h="must not be",u=u.replace(/^not /,"")):h="must be";var k;if(l(f," argument"))k="The ".concat(f," ").concat(h," ").concat(s(u,"type"));else{var I=g(f,".")?"property":"argument";k='The "'.concat(f,'" ').concat(I," ").concat(h," ").concat(s(u,"type"))}return k+=". Received type ".concat(typeof m),k},TypeError),t("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),t("ERR_METHOD_NOT_IMPLEMENTED",function(f){return"The "+f+" method is not implemented"}),t("ERR_STREAM_PREMATURE_CLOSE","Premature close"),t("ERR_STREAM_DESTROYED",function(f){return"Cannot call "+f+" after a stream was destroyed"}),t("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),t("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),t("ERR_STREAM_WRITE_AFTER_END","write after end"),t("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),t("ERR_UNKNOWN_ENCODING",function(f){return"Unknown encoding: "+f},TypeError),t("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),on.codes=e,on}var an,vo;function wo(){if(vo)return an;vo=1;var r=ft().codes.ERR_INVALID_OPT_VALUE;function e(s,c,l){return s.highWaterMark!=null?s.highWaterMark:c?s[l]:null}function t(s,c,l,g){var f=e(c,g,l);if(f!=null){if(!(isFinite(f)&&Math.floor(f)===f)||f<0){var u=g?l:"highWaterMark";throw new r(u,f)}return Math.floor(f)}return s.objectMode?16:16*1024}return an={getHighWaterMark:t},an}var sn,bo;function ms(){if(bo)return sn;bo=1,sn=r;function r(t,s){if(e("noDeprecation"))return t;var c=!1;function l(){if(!c){if(e("throwDeprecation"))throw new Error(s);e("traceDeprecation")?console.trace(s):console.warn(s),c=!0}return t.apply(this,arguments)}return l}function e(t){try{if(!globalThis.localStorage)return!1}catch(c){return!1}var s=globalThis.localStorage[t];return s==null?!1:String(s).toLowerCase()==="true"}return sn}var ln,So;function _o(){if(So)return ln;So=1,ln=M;function r(L){var D=this;this.next=null,this.entry=null,this.finish=function(){re(D,L)}}var e;M.WritableState=S;var t={deprecate:ms()},s=ti(),c=mt().Buffer,l=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function g(L){return c.from(L)}function f(L){return c.isBuffer(L)||L instanceof l}var u=yo(),m=wo(),h=m.getHighWaterMark,k=ft().codes,I=k.ERR_INVALID_ARG_TYPE,V=k.ERR_METHOD_NOT_IMPLEMENTED,b=k.ERR_MULTIPLE_CALLBACK,B=k.ERR_STREAM_CANNOT_PIPE,P=k.ERR_STREAM_DESTROYED,y=k.ERR_STREAM_NULL_VALUES,C=k.ERR_STREAM_WRITE_AFTER_END,A=k.ERR_UNKNOWN_ENCODING,T=u.errorOrDestroy;ut()(M,s);function O(){}function S(L,D,q){e=e||ht(),L=L||{},typeof q!="boolean"&&(q=D instanceof e),this.objectMode=!!L.objectMode,q&&(this.objectMode=this.objectMode||!!L.writableObjectMode),this.highWaterMark=h(this,L,"writableHighWaterMark",q),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var Z=L.decodeStrings===!1;this.decodeStrings=!Z,this.defaultEncoding=L.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ee){Pe(D,ee)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=L.emitClose!==!1,this.autoDestroy=!!L.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}S.prototype.getBuffer=function(){for(var D=this.bufferedRequest,q=[];D;)q.push(D),D=D.next;return q},function(){try{Object.defineProperty(S.prototype,"buffer",{get:t.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(L){}}();var R;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(R=Function.prototype[Symbol.hasInstance],Object.defineProperty(M,Symbol.hasInstance,{value:function(D){return R.call(this,D)?!0:this!==M?!1:D&&D._writableState instanceof S}})):R=function(D){return D instanceof this};function M(L){e=e||ht();var D=this instanceof e;if(!D&&!R.call(M,this))return new M(L);this._writableState=new S(L,this,D),this.writable=!0,L&&(typeof L.write=="function"&&(this._write=L.write),typeof L.writev=="function"&&(this._writev=L.writev),typeof L.destroy=="function"&&(this._destroy=L.destroy),typeof L.final=="function"&&(this._final=L.final)),s.call(this)}M.prototype.pipe=function(){T(this,new B)};function G(L,D){var q=new C;T(L,q),le.nextTick(D,q)}function Q(L,D,q,Z){var ee;return q===null?ee=new y:typeof q!="string"&&!D.objectMode&&(ee=new I("chunk",["string","Buffer"],q)),ee?(T(L,ee),le.nextTick(Z,ee),!1):!0}M.prototype.write=function(L,D,q){var Z=this._writableState,ee=!1,v=!Z.objectMode&&f(L);return v&&!c.isBuffer(L)&&(L=g(L)),typeof D=="function"&&(q=D,D=null),v?D="buffer":D||(D=Z.defaultEncoding),typeof q!="function"&&(q=O),Z.ending?G(this,q):(v||Q(this,Z,L,q))&&(Z.pendingcb++,ee=U(this,Z,v,L,D,q)),ee},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){var L=this._writableState;L.corked&&(L.corked--,!L.writing&&!L.corked&&!L.bufferProcessing&&L.bufferedRequest&&we(this,L))},M.prototype.setDefaultEncoding=function(D){if(typeof D=="string"&&(D=D.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((D+"").toLowerCase())>-1))throw new A(D);return this._writableState.defaultEncoding=D,this},Object.defineProperty(M.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function ie(L,D,q){return!L.objectMode&&L.decodeStrings!==!1&&typeof D=="string"&&(D=c.from(D,q)),D}Object.defineProperty(M.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function U(L,D,q,Z,ee,v){if(!q){var w=ie(D,Z,ee);Z!==w&&(q=!0,ee="buffer",Z=w)}var H=D.objectMode?1:Z.length;D.length+=H;var te=D.length<D.highWaterMark;if(te||(D.needDrain=!0),D.writing||D.corked){var fe=D.lastBufferedRequest;D.lastBufferedRequest={chunk:Z,encoding:ee,isBuf:q,callback:v,next:null},fe?fe.next=D.lastBufferedRequest:D.bufferedRequest=D.lastBufferedRequest,D.bufferedRequestCount+=1}else ge(L,D,!1,H,Z,ee,v);return te}function ge(L,D,q,Z,ee,v,w){D.writelen=Z,D.writecb=w,D.writing=!0,D.sync=!0,D.destroyed?D.onwrite(new P("write")):q?L._writev(ee,D.onwrite):L._write(ee,v,D.onwrite),D.sync=!1}function de(L,D,q,Z,ee){--D.pendingcb,q?(le.nextTick(ee,Z),le.nextTick(W,L,D),L._writableState.errorEmitted=!0,T(L,Z)):(ee(Z),L._writableState.errorEmitted=!0,T(L,Z),W(L,D))}function ye(L){L.writing=!1,L.writecb=null,L.length-=L.writelen,L.writelen=0}function Pe(L,D){var q=L._writableState,Z=q.sync,ee=q.writecb;if(typeof ee!="function")throw new b;if(ye(q),D)de(L,q,Z,D,ee);else{var v=X(q)||L.destroyed;!v&&!q.corked&&!q.bufferProcessing&&q.bufferedRequest&&we(L,q),Z?le.nextTick(Te,L,q,v,ee):Te(L,q,v,ee)}}function Te(L,D,q,Z){q||Se(L,D),D.pendingcb--,Z(),W(L,D)}function Se(L,D){D.length===0&&D.needDrain&&(D.needDrain=!1,L.emit("drain"))}function we(L,D){D.bufferProcessing=!0;var q=D.bufferedRequest;if(L._writev&&q&&q.next){var Z=D.bufferedRequestCount,ee=new Array(Z),v=D.corkedRequestsFree;v.entry=q;for(var w=0,H=!0;q;)ee[w]=q,q.isBuf||(H=!1),q=q.next,w+=1;ee.allBuffers=H,ge(L,D,!0,D.length,ee,"",v.finish),D.pendingcb++,D.lastBufferedRequest=null,v.next?(D.corkedRequestsFree=v.next,v.next=null):D.corkedRequestsFree=new r(D),D.bufferedRequestCount=0}else{for(;q;){var te=q.chunk,fe=q.encoding,oe=q.callback,ue=D.objectMode?1:te.length;if(ge(L,D,!1,ue,te,fe,oe),q=q.next,D.bufferedRequestCount--,D.writing)break}q===null&&(D.lastBufferedRequest=null)}D.bufferedRequest=q,D.bufferProcessing=!1}M.prototype._write=function(L,D,q){q(new V("_write()"))},M.prototype._writev=null,M.prototype.end=function(L,D,q){var Z=this._writableState;return typeof L=="function"?(q=L,L=null,D=null):typeof D=="function"&&(q=D,D=null),L!=null&&this.write(L,D),Z.corked&&(Z.corked=1,this.uncork()),Z.ending||z(this,Z,q),this},Object.defineProperty(M.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function X(L){return L.ending&&L.length===0&&L.bufferedRequest===null&&!L.finished&&!L.writing}function ae(L,D){L._final(function(q){D.pendingcb--,q&&T(L,q),D.prefinished=!0,L.emit("prefinish"),W(L,D)})}function j(L,D){!D.prefinished&&!D.finalCalled&&(typeof L._final=="function"&&!D.destroyed?(D.pendingcb++,D.finalCalled=!0,le.nextTick(ae,L,D)):(D.prefinished=!0,L.emit("prefinish")))}function W(L,D){var q=X(D);if(q&&(j(L,D),D.pendingcb===0&&(D.finished=!0,L.emit("finish"),D.autoDestroy))){var Z=L._readableState;(!Z||Z.autoDestroy&&Z.endEmitted)&&L.destroy()}return q}function z(L,D,q){D.ending=!0,W(L,D),q&&(D.finished?le.nextTick(q):L.once("finish",q)),D.ended=!0,L.writable=!1}function re(L,D,q){var Z=L.entry;for(L.entry=null;Z;){var ee=Z.callback;D.pendingcb--,ee(q),Z=Z.next}D.corkedRequestsFree.next=L}return Object.defineProperty(M.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(D){this._writableState&&(this._writableState.destroyed=D)}}),M.prototype.destroy=u.destroy,M.prototype._undestroy=u.undestroy,M.prototype._destroy=function(L,D){D(L)},ln}var cn,Eo;function ht(){if(Eo)return cn;Eo=1;var r=Object.keys||function(m){var h=[];for(var k in m)h.push(k);return h};cn=g;var e=ko(),t=_o();ut()(g,e);for(var s=r(t.prototype),c=0;c<s.length;c++){var l=s[c];g.prototype[l]||(g.prototype[l]=t.prototype[l])}function g(m){if(!(this instanceof g))return new g(m);e.call(this,m),t.call(this,m),this.allowHalfOpen=!0,m&&(m.readable===!1&&(this.readable=!1),m.writable===!1&&(this.writable=!1),m.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",f)))}Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(g.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(g.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function f(){this._writableState.ended||le.nextTick(u,this)}function u(m){m.end()}return Object.defineProperty(g.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(h){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=h,this._writableState.destroyed=h)}}),cn}var un={},Co;function Ro(){if(Co)return un;Co=1;var r=Xn().Buffer,e=r.isEncoding||function(y){switch(y=""+y,y&&y.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function t(y){if(!y)return"utf8";for(var C;;)switch(y){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return y;default:if(C)return;y=(""+y).toLowerCase(),C=!0}}function s(y){var C=t(y);if(typeof C!="string"&&(r.isEncoding===e||!e(y)))throw new Error("Unknown encoding: "+y);return C||y}un.StringDecoder=c;function c(y){this.encoding=s(y);var C;switch(this.encoding){case"utf16le":this.text=k,this.end=I,C=4;break;case"utf8":this.fillLast=u,C=4;break;case"base64":this.text=V,this.end=b,C=3;break;default:this.write=B,this.end=P;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(C)}c.prototype.write=function(y){if(y.length===0)return"";var C,A;if(this.lastNeed){if(C=this.fillLast(y),C===void 0)return"";A=this.lastNeed,this.lastNeed=0}else A=0;return A<y.length?C?C+this.text(y,A):this.text(y,A):C||""},c.prototype.end=h,c.prototype.text=m,c.prototype.fillLast=function(y){if(this.lastNeed<=y.length)return y.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);y.copy(this.lastChar,this.lastTotal-this.lastNeed,0,y.length),this.lastNeed-=y.length};function l(y){return y<=127?0:y>>5===6?2:y>>4===14?3:y>>3===30?4:y>>6===2?-1:-2}function g(y,C,A){var T=C.length-1;if(T<A)return 0;var O=l(C[T]);return O>=0?(O>0&&(y.lastNeed=O-1),O):--T<A||O===-2?0:(O=l(C[T]),O>=0?(O>0&&(y.lastNeed=O-2),O):--T<A||O===-2?0:(O=l(C[T]),O>=0?(O>0&&(O===2?O=0:y.lastNeed=O-3),O):0))}function f(y,C,A){if((C[0]&192)!==128)return y.lastNeed=0,"�";if(y.lastNeed>1&&C.length>1){if((C[1]&192)!==128)return y.lastNeed=1,"�";if(y.lastNeed>2&&C.length>2&&(C[2]&192)!==128)return y.lastNeed=2,"�"}}function u(y){var C=this.lastTotal-this.lastNeed,A=f(this,y);if(A!==void 0)return A;if(this.lastNeed<=y.length)return y.copy(this.lastChar,C,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);y.copy(this.lastChar,C,0,y.length),this.lastNeed-=y.length}function m(y,C){var A=g(this,y,C);if(!this.lastNeed)return y.toString("utf8",C);this.lastTotal=A;var T=y.length-(A-this.lastNeed);return y.copy(this.lastChar,0,T),y.toString("utf8",C,T)}function h(y){var C=y&&y.length?this.write(y):"";return this.lastNeed?C+"�":C}function k(y,C){if((y.length-C)%2===0){var A=y.toString("utf16le",C);if(A){var T=A.charCodeAt(A.length-1);if(T>=55296&&T<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=y[y.length-2],this.lastChar[1]=y[y.length-1],A.slice(0,-1)}return A}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=y[y.length-1],y.toString("utf16le",C,y.length-1)}function I(y){var C=y&&y.length?this.write(y):"";if(this.lastNeed){var A=this.lastTotal-this.lastNeed;return C+this.lastChar.toString("utf16le",0,A)}return C}function V(y,C){var A=(y.length-C)%3;return A===0?y.toString("base64",C):(this.lastNeed=3-A,this.lastTotal=3,A===1?this.lastChar[0]=y[y.length-1]:(this.lastChar[0]=y[y.length-2],this.lastChar[1]=y[y.length-1]),y.toString("base64",C,y.length-A))}function b(y){var C=y&&y.length?this.write(y):"";return this.lastNeed?C+this.lastChar.toString("base64",0,3-this.lastNeed):C}function B(y){return y.toString(this.encoding)}function P(y){return y&&y.length?this.write(y):""}return un}var fn,Po;function hn(){if(Po)return fn;Po=1;var r=ft().codes.ERR_STREAM_PREMATURE_CLOSE;function e(l){var g=!1;return function(){if(!g){g=!0;for(var f=arguments.length,u=new Array(f),m=0;m<f;m++)u[m]=arguments[m];l.apply(this,u)}}}function t(){}function s(l){return l.setHeader&&typeof l.abort=="function"}function c(l,g,f){if(typeof g=="function")return c(l,null,g);g||(g={}),f=e(f||t);var u=g.readable||g.readable!==!1&&l.readable,m=g.writable||g.writable!==!1&&l.writable,h=function(){l.writable||I()},k=l._writableState&&l._writableState.finished,I=function(){m=!1,k=!0,u||f.call(l)},V=l._readableState&&l._readableState.endEmitted,b=function(){u=!1,V=!0,m||f.call(l)},B=function(A){f.call(l,A)},P=function(){var A;if(u&&!V)return(!l._readableState||!l._readableState.ended)&&(A=new r),f.call(l,A);if(m&&!k)return(!l._writableState||!l._writableState.ended)&&(A=new r),f.call(l,A)},y=function(){l.req.on("finish",I)};return s(l)?(l.on("complete",I),l.on("abort",P),l.req?y():l.on("request",y)):m&&!l._writableState&&(l.on("end",h),l.on("close",h)),l.on("end",b),l.on("finish",I),g.error!==!1&&l.on("error",B),l.on("close",P),function(){l.removeListener("complete",I),l.removeListener("abort",P),l.removeListener("request",y),l.req&&l.req.removeListener("finish",I),l.removeListener("end",h),l.removeListener("close",h),l.removeListener("finish",I),l.removeListener("end",b),l.removeListener("error",B),l.removeListener("close",P)}}return fn=c,fn}var dn,To;function vs(){if(To)return dn;To=1;var r;function e(A,T,O){return T=t(T),T in A?Object.defineProperty(A,T,{value:O,enumerable:!0,configurable:!0,writable:!0}):A[T]=O,A}function t(A){var T=s(A,"string");return typeof T=="symbol"?T:String(T)}function s(A,T){if(typeof A!="object"||A===null)return A;var O=A[Symbol.toPrimitive];if(O!==void 0){var S=O.call(A,T);if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(T==="string"?String:Number)(A)}var c=hn(),l=Symbol("lastResolve"),g=Symbol("lastReject"),f=Symbol("error"),u=Symbol("ended"),m=Symbol("lastPromise"),h=Symbol("handlePromise"),k=Symbol("stream");function I(A,T){return{value:A,done:T}}function V(A){var T=A[l];if(T!==null){var O=A[k].read();O!==null&&(A[m]=null,A[l]=null,A[g]=null,T(I(O,!1)))}}function b(A){le.nextTick(V,A)}function B(A,T){return function(O,S){A.then(function(){if(T[u]){O(I(void 0,!0));return}T[h](O,S)},S)}}var P=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((r={get stream(){return this[k]},next:function(){var T=this,O=this[f];if(O!==null)return Promise.reject(O);if(this[u])return Promise.resolve(I(void 0,!0));if(this[k].destroyed)return new Promise(function(G,Q){le.nextTick(function(){T[f]?Q(T[f]):G(I(void 0,!0))})});var S=this[m],R;if(S)R=new Promise(B(S,this));else{var M=this[k].read();if(M!==null)return Promise.resolve(I(M,!1));R=new Promise(this[h])}return this[m]=R,R}},e(r,Symbol.asyncIterator,function(){return this}),e(r,"return",function(){var T=this;return new Promise(function(O,S){T[k].destroy(null,function(R){if(R){S(R);return}O(I(void 0,!0))})})}),r),P),C=function(T){var O,S=Object.create(y,(O={},e(O,k,{value:T,writable:!0}),e(O,l,{value:null,writable:!0}),e(O,g,{value:null,writable:!0}),e(O,f,{value:null,writable:!0}),e(O,u,{value:T._readableState.endEmitted,writable:!0}),e(O,h,{value:function(M,G){var Q=S[k].read();Q?(S[m]=null,S[l]=null,S[g]=null,M(I(Q,!1))):(S[l]=M,S[g]=G)},writable:!0}),O));return S[m]=null,c(T,function(R){if(R&&R.code!=="ERR_STREAM_PREMATURE_CLOSE"){var M=S[g];M!==null&&(S[m]=null,S[l]=null,S[g]=null,M(R)),S[f]=R;return}var G=S[l];G!==null&&(S[m]=null,S[l]=null,S[g]=null,G(I(void 0,!0))),S[u]=!0}),T.on("readable",b.bind(null,S)),S};return dn=C,dn}var pn,Ao;function ws(){return Ao||(Ao=1,pn=function(){throw new Error("Readable.from is not available in the browser")}),pn}var gn,Io;function ko(){if(Io)return gn;Io=1,gn=G;var r;G.ReadableState=M,Kt().EventEmitter;var e=function(w,H){return w.listeners(H).length},t=ti(),s=mt().Buffer,c=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function l(v){return s.from(v)}function g(v){return s.isBuffer(v)||v instanceof c}var f=ho(),u;f&&f.debuglog?u=f.debuglog("stream"):u=function(){};var m=ys(),h=yo(),k=wo(),I=k.getHighWaterMark,V=ft().codes,b=V.ERR_INVALID_ARG_TYPE,B=V.ERR_STREAM_PUSH_AFTER_EOF,P=V.ERR_METHOD_NOT_IMPLEMENTED,y=V.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,C,A,T;ut()(G,t);var O=h.errorOrDestroy,S=["error","close","destroy","pause","resume"];function R(v,w,H){if(typeof v.prependListener=="function")return v.prependListener(w,H);!v._events||!v._events[w]?v.on(w,H):Array.isArray(v._events[w])?v._events[w].unshift(H):v._events[w]=[H,v._events[w]]}function M(v,w,H){r=r||ht(),v=v||{},typeof H!="boolean"&&(H=w instanceof r),this.objectMode=!!v.objectMode,H&&(this.objectMode=this.objectMode||!!v.readableObjectMode),this.highWaterMark=I(this,v,"readableHighWaterMark",H),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=v.emitClose!==!1,this.autoDestroy=!!v.autoDestroy,this.destroyed=!1,this.defaultEncoding=v.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,v.encoding&&(C||(C=Ro().StringDecoder),this.decoder=new C(v.encoding),this.encoding=v.encoding)}function G(v){if(r=r||ht(),!(this instanceof G))return new G(v);var w=this instanceof r;this._readableState=new M(v,this,w),this.readable=!0,v&&(typeof v.read=="function"&&(this._read=v.read),typeof v.destroy=="function"&&(this._destroy=v.destroy)),t.call(this)}Object.defineProperty(G.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(w){this._readableState&&(this._readableState.destroyed=w)}}),G.prototype.destroy=h.destroy,G.prototype._undestroy=h.undestroy,G.prototype._destroy=function(v,w){w(v)},G.prototype.push=function(v,w){var H=this._readableState,te;return H.objectMode?te=!0:typeof v=="string"&&(w=w||H.defaultEncoding,w!==H.encoding&&(v=s.from(v,w),w=""),te=!0),Q(this,v,w,!1,te)},G.prototype.unshift=function(v){return Q(this,v,null,!0,!1)};function Q(v,w,H,te,fe){u("readableAddChunk",w);var oe=v._readableState;if(w===null)oe.reading=!1,Pe(v,oe);else{var ue;if(fe||(ue=U(oe,w)),ue)O(v,ue);else if(oe.objectMode||w&&w.length>0)if(typeof w!="string"&&!oe.objectMode&&Object.getPrototypeOf(w)!==s.prototype&&(w=l(w)),te)oe.endEmitted?O(v,new y):ie(v,oe,w,!0);else if(oe.ended)O(v,new B);else{if(oe.destroyed)return!1;oe.reading=!1,oe.decoder&&!H?(w=oe.decoder.write(w),oe.objectMode||w.length!==0?ie(v,oe,w,!1):we(v,oe)):ie(v,oe,w,!1)}else te||(oe.reading=!1,we(v,oe))}return!oe.ended&&(oe.length<oe.highWaterMark||oe.length===0)}function ie(v,w,H,te){w.flowing&&w.length===0&&!w.sync?(w.awaitDrain=0,v.emit("data",H)):(w.length+=w.objectMode?1:H.length,te?w.buffer.unshift(H):w.buffer.push(H),w.needReadable&&Te(v)),we(v,w)}function U(v,w){var H;return!g(w)&&typeof w!="string"&&w!==void 0&&!v.objectMode&&(H=new b("chunk",["string","Buffer","Uint8Array"],w)),H}G.prototype.isPaused=function(){return this._readableState.flowing===!1},G.prototype.setEncoding=function(v){C||(C=Ro().StringDecoder);var w=new C(v);this._readableState.decoder=w,this._readableState.encoding=this._readableState.decoder.encoding;for(var H=this._readableState.buffer.head,te="";H!==null;)te+=w.write(H.data),H=H.next;return this._readableState.buffer.clear(),te!==""&&this._readableState.buffer.push(te),this._readableState.length=te.length,this};var ge=1073741824;function de(v){return v>=ge?v=ge:(v--,v|=v>>>1,v|=v>>>2,v|=v>>>4,v|=v>>>8,v|=v>>>16,v++),v}function ye(v,w){return v<=0||w.length===0&&w.ended?0:w.objectMode?1:v!==v?w.flowing&&w.length?w.buffer.head.data.length:w.length:(v>w.highWaterMark&&(w.highWaterMark=de(v)),v<=w.length?v:w.ended?w.length:(w.needReadable=!0,0))}G.prototype.read=function(v){u("read",v),v=parseInt(v,10);var w=this._readableState,H=v;if(v!==0&&(w.emittedReadable=!1),v===0&&w.needReadable&&((w.highWaterMark!==0?w.length>=w.highWaterMark:w.length>0)||w.ended))return u("read: emitReadable",w.length,w.ended),w.length===0&&w.ended?q(this):Te(this),null;if(v=ye(v,w),v===0&&w.ended)return w.length===0&&q(this),null;var te=w.needReadable;u("need readable",te),(w.length===0||w.length-v<w.highWaterMark)&&(te=!0,u("length less than watermark",te)),w.ended||w.reading?(te=!1,u("reading or ended",te)):te&&(u("do read"),w.reading=!0,w.sync=!0,w.length===0&&(w.needReadable=!0),this._read(w.highWaterMark),w.sync=!1,w.reading||(v=ye(H,w)));var fe;return v>0?fe=D(v,w):fe=null,fe===null?(w.needReadable=w.length<=w.highWaterMark,v=0):(w.length-=v,w.awaitDrain=0),w.length===0&&(w.ended||(w.needReadable=!0),H!==v&&w.ended&&q(this)),fe!==null&&this.emit("data",fe),fe};function Pe(v,w){if(u("onEofChunk"),!w.ended){if(w.decoder){var H=w.decoder.end();H&&H.length&&(w.buffer.push(H),w.length+=w.objectMode?1:H.length)}w.ended=!0,w.sync?Te(v):(w.needReadable=!1,w.emittedReadable||(w.emittedReadable=!0,Se(v)))}}function Te(v){var w=v._readableState;u("emitReadable",w.needReadable,w.emittedReadable),w.needReadable=!1,w.emittedReadable||(u("emitReadable",w.flowing),w.emittedReadable=!0,le.nextTick(Se,v))}function Se(v){var w=v._readableState;u("emitReadable_",w.destroyed,w.length,w.ended),!w.destroyed&&(w.length||w.ended)&&(v.emit("readable"),w.emittedReadable=!1),w.needReadable=!w.flowing&&!w.ended&&w.length<=w.highWaterMark,L(v)}function we(v,w){w.readingMore||(w.readingMore=!0,le.nextTick(X,v,w))}function X(v,w){for(;!w.reading&&!w.ended&&(w.length<w.highWaterMark||w.flowing&&w.length===0);){var H=w.length;if(u("maybeReadMore read 0"),v.read(0),H===w.length)break}w.readingMore=!1}G.prototype._read=function(v){O(this,new P("_read()"))},G.prototype.pipe=function(v,w){var H=this,te=this._readableState;switch(te.pipesCount){case 0:te.pipes=v;break;case 1:te.pipes=[te.pipes,v];break;default:te.pipes.push(v);break}te.pipesCount+=1,u("pipe count=%d opts=%j",te.pipesCount,w);var fe=(!w||w.end!==!1)&&v!==le.stdout&&v!==le.stderr,oe=fe?Fe:We;te.endEmitted?le.nextTick(oe):H.once("end",oe),v.on("unpipe",ue);function ue(Ge,Le){u("onunpipe"),Ge===H&&Le&&Le.hasUnpiped===!1&&(Le.hasUnpiped=!0,je())}function Fe(){u("onend"),v.end()}var Y=ae(H);v.on("drain",Y);var Ue=!1;function je(){u("cleanup"),v.removeListener("close",xe),v.removeListener("finish",De),v.removeListener("drain",Y),v.removeListener("error",Ee),v.removeListener("unpipe",ue),H.removeListener("end",Fe),H.removeListener("end",We),H.removeListener("data",be),Ue=!0,te.awaitDrain&&(!v._writableState||v._writableState.needDrain)&&Y()}H.on("data",be);function be(Ge){u("ondata");var Le=v.write(Ge);u("dest.write",Le),Le===!1&&((te.pipesCount===1&&te.pipes===v||te.pipesCount>1&&ee(te.pipes,v)!==-1)&&!Ue&&(u("false write response, pause",te.awaitDrain),te.awaitDrain++),H.pause())}function Ee(Ge){u("onerror",Ge),We(),v.removeListener("error",Ee),e(v,"error")===0&&O(v,Ge)}R(v,"error",Ee);function xe(){v.removeListener("finish",De),We()}v.once("close",xe);function De(){u("onfinish"),v.removeListener("close",xe),We()}v.once("finish",De);function We(){u("unpipe"),H.unpipe(v)}return v.emit("pipe",H),te.flowing||(u("pipe resume"),H.resume()),v};function ae(v){return function(){var H=v._readableState;u("pipeOnDrain",H.awaitDrain),H.awaitDrain&&H.awaitDrain--,H.awaitDrain===0&&e(v,"data")&&(H.flowing=!0,L(v))}}G.prototype.unpipe=function(v){var w=this._readableState,H={hasUnpiped:!1};if(w.pipesCount===0)return this;if(w.pipesCount===1)return v&&v!==w.pipes?this:(v||(v=w.pipes),w.pipes=null,w.pipesCount=0,w.flowing=!1,v&&v.emit("unpipe",this,H),this);if(!v){var te=w.pipes,fe=w.pipesCount;w.pipes=null,w.pipesCount=0,w.flowing=!1;for(var oe=0;oe<fe;oe++)te[oe].emit("unpipe",this,{hasUnpiped:!1});return this}var ue=ee(w.pipes,v);return ue===-1?this:(w.pipes.splice(ue,1),w.pipesCount-=1,w.pipesCount===1&&(w.pipes=w.pipes[0]),v.emit("unpipe",this,H),this)},G.prototype.on=function(v,w){var H=t.prototype.on.call(this,v,w),te=this._readableState;return v==="data"?(te.readableListening=this.listenerCount("readable")>0,te.flowing!==!1&&this.resume()):v==="readable"&&!te.endEmitted&&!te.readableListening&&(te.readableListening=te.needReadable=!0,te.flowing=!1,te.emittedReadable=!1,u("on readable",te.length,te.reading),te.length?Te(this):te.reading||le.nextTick(W,this)),H},G.prototype.addListener=G.prototype.on,G.prototype.removeListener=function(v,w){var H=t.prototype.removeListener.call(this,v,w);return v==="readable"&&le.nextTick(j,this),H},G.prototype.removeAllListeners=function(v){var w=t.prototype.removeAllListeners.apply(this,arguments);return(v==="readable"||v===void 0)&&le.nextTick(j,this),w};function j(v){var w=v._readableState;w.readableListening=v.listenerCount("readable")>0,w.resumeScheduled&&!w.paused?w.flowing=!0:v.listenerCount("data")>0&&v.resume()}function W(v){u("readable nexttick read 0"),v.read(0)}G.prototype.resume=function(){var v=this._readableState;return v.flowing||(u("resume"),v.flowing=!v.readableListening,z(this,v)),v.paused=!1,this};function z(v,w){w.resumeScheduled||(w.resumeScheduled=!0,le.nextTick(re,v,w))}function re(v,w){u("resume",w.reading),w.reading||v.read(0),w.resumeScheduled=!1,v.emit("resume"),L(v),w.flowing&&!w.reading&&v.read(0)}G.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function L(v){var w=v._readableState;for(u("flow",w.flowing);w.flowing&&v.read()!==null;);}G.prototype.wrap=function(v){var w=this,H=this._readableState,te=!1;v.on("end",function(){if(u("wrapped end"),H.decoder&&!H.ended){var ue=H.decoder.end();ue&&ue.length&&w.push(ue)}w.push(null)}),v.on("data",function(ue){if(u("wrapped data"),H.decoder&&(ue=H.decoder.write(ue)),!(H.objectMode&&ue==null)&&!(!H.objectMode&&(!ue||!ue.length))){var Fe=w.push(ue);Fe||(te=!0,v.pause())}});for(var fe in v)this[fe]===void 0&&typeof v[fe]=="function"&&(this[fe]=function(Fe){return function(){return v[Fe].apply(v,arguments)}}(fe));for(var oe=0;oe<S.length;oe++)v.on(S[oe],this.emit.bind(this,S[oe]));return this._read=function(ue){u("wrapped _read",ue),te&&(te=!1,v.resume())},this},typeof Symbol=="function"&&(G.prototype[Symbol.asyncIterator]=function(){return A===void 0&&(A=vs()),A(this)}),Object.defineProperty(G.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(G.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(G.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(w){this._readableState&&(this._readableState.flowing=w)}}),G._fromList=D,Object.defineProperty(G.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function D(v,w){if(w.length===0)return null;var H;return w.objectMode?H=w.buffer.shift():!v||v>=w.length?(w.decoder?H=w.buffer.join(""):w.buffer.length===1?H=w.buffer.first():H=w.buffer.concat(w.length),w.buffer.clear()):H=w.buffer.consume(v,w.decoder),H}function q(v){var w=v._readableState;u("endReadable",w.endEmitted),w.endEmitted||(w.ended=!0,le.nextTick(Z,w,v))}function Z(v,w){if(u("endReadableNT",v.endEmitted,v.length),!v.endEmitted&&v.length===0&&(v.endEmitted=!0,w.readable=!1,w.emit("end"),v.autoDestroy)){var H=w._writableState;(!H||H.autoDestroy&&H.finished)&&w.destroy()}}typeof Symbol=="function"&&(G.from=function(v,w){return T===void 0&&(T=ws()),T(G,v,w)});function ee(v,w){for(var H=0,te=v.length;H<te;H++)if(v[H]===w)return H;return-1}return gn}var yn,Bo;function Oo(){if(Bo)return yn;Bo=1,yn=f;var r=ft().codes,e=r.ERR_METHOD_NOT_IMPLEMENTED,t=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,c=r.ERR_TRANSFORM_WITH_LENGTH_0,l=ht();ut()(f,l);function g(h,k){var I=this._transformState;I.transforming=!1;var V=I.writecb;if(V===null)return this.emit("error",new t);I.writechunk=null,I.writecb=null,k!=null&&this.push(k),V(h);var b=this._readableState;b.reading=!1,(b.needReadable||b.length<b.highWaterMark)&&this._read(b.highWaterMark)}function f(h){if(!(this instanceof f))return new f(h);l.call(this,h),this._transformState={afterTransform:g.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,h&&(typeof h.transform=="function"&&(this._transform=h.transform),typeof h.flush=="function"&&(this._flush=h.flush)),this.on("prefinish",u)}function u(){var h=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(k,I){m(h,k,I)}):m(this,null,null)}f.prototype.push=function(h,k){return this._transformState.needTransform=!1,l.prototype.push.call(this,h,k)},f.prototype._transform=function(h,k,I){I(new e("_transform()"))},f.prototype._write=function(h,k,I){var V=this._transformState;if(V.writecb=I,V.writechunk=h,V.writeencoding=k,!V.transforming){var b=this._readableState;(V.needTransform||b.needReadable||b.length<b.highWaterMark)&&this._read(b.highWaterMark)}},f.prototype._read=function(h){var k=this._transformState;k.writechunk!==null&&!k.transforming?(k.transforming=!0,this._transform(k.writechunk,k.writeencoding,k.afterTransform)):k.needTransform=!0},f.prototype._destroy=function(h,k){l.prototype._destroy.call(this,h,function(I){k(I)})};function m(h,k,I){if(k)return h.emit("error",k);if(I!=null&&h.push(I),h._writableState.length)throw new c;if(h._transformState.transforming)throw new s;return h.push(null)}return yn}var mn,Mo;function bs(){if(Mo)return mn;Mo=1,mn=e;var r=Oo();ut()(e,r);function e(t){if(!(this instanceof e))return new e(t);r.call(this,t)}return e.prototype._transform=function(t,s,c){c(null,t)},mn}var vn,No;function Ss(){if(No)return vn;No=1;var r;function e(I){var V=!1;return function(){V||(V=!0,I.apply(void 0,arguments))}}var t=ft().codes,s=t.ERR_MISSING_ARGS,c=t.ERR_STREAM_DESTROYED;function l(I){if(I)throw I}function g(I){return I.setHeader&&typeof I.abort=="function"}function f(I,V,b,B){B=e(B);var P=!1;I.on("close",function(){P=!0}),r===void 0&&(r=hn()),r(I,{readable:V,writable:b},function(C){if(C)return B(C);P=!0,B()});var y=!1;return function(C){if(!P&&!y){if(y=!0,g(I))return I.abort();if(typeof I.destroy=="function")return I.destroy();B(C||new c("pipe"))}}}function u(I){I()}function m(I,V){return I.pipe(V)}function h(I){return!I.length||typeof I[I.length-1]!="function"?l:I.pop()}function k(){for(var I=arguments.length,V=new Array(I),b=0;b<I;b++)V[b]=arguments[b];var B=h(V);if(Array.isArray(V[0])&&(V=V[0]),V.length<2)throw new s("streams");var P,y=V.map(function(C,A){var T=A<V.length-1,O=A>0;return f(C,T,O,function(S){P||(P=S),S&&y.forEach(u),!T&&(y.forEach(u),B(P))})});return V.reduce(m)}return vn=k,vn}var Lo;function _s(){return Lo||(Lo=1,function(r,e){e=r.exports=ko(),e.Stream=e,e.Readable=e,e.Writable=_o(),e.Duplex=ht(),e.Transform=Oo(),e.PassThrough=bs(),e.finished=hn(),e.pipeline=Ss()}(kt,kt.exports)),kt.exports}var wn,Do;function Es(){if(Do)return wn;Do=1;let r;return wn=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window!="undefined"?window:globalThis):e=>(r||(r=Promise.resolve())).then(e).catch(t=>setTimeout(()=>{throw t},0)),wn}var bn,Fo;function Cs(){if(Fo)return bn;Fo=1;function r(t,s){for(const c in s)Object.defineProperty(t,c,{value:s[c],enumerable:!0,configurable:!0});return t}function e(t,s,c){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");c||(c={}),typeof s=="object"&&(c=s,s=""),s&&(c.code=s);try{return r(t,c)}catch(l){c.message=t.message,c.stack=t.stack;const g=function(){};return g.prototype=Object.create(Object.getPrototypeOf(t)),r(new g,c)}}return bn=e,bn}var Sn,Uo;function Rs(){if(Uo)return Sn;Uo=1;const r=Ma()("simple-peer"),e=Na(),t=La(),s=_s(),c=Es(),l=Cs(),{Buffer:g}=mt(),f=64*1024,u=5*1e3,m=5*1e3;function h(V){return V.replace(/a=ice-options:trickle\s\n/g,"")}function k(V){console.warn(V)}class I extends s.Duplex{constructor(b){if(b=Object.assign({allowHalfOpen:!1},b),super(b),this._id=t(4).toString("hex").slice(0,7),this._debug("new peer %o",b),this.channelName=b.initiator?b.channelName||t(20).toString("hex"):null,this.initiator=b.initiator||!1,this.channelConfig=b.channelConfig||I.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},I.config,b.config),this.offerOptions=b.offerOptions||{},this.answerOptions=b.answerOptions||{},this.sdpTransform=b.sdpTransform||(B=>B),this.streams=b.streams||(b.stream?[b.stream]:[]),this.trickle=b.trickle!==void 0?b.trickle:!0,this.allowHalfTrickle=b.allowHalfTrickle!==void 0?b.allowHalfTrickle:!1,this.iceCompleteTimeout=b.iceCompleteTimeout||u,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=b.wrtc&&typeof b.wrtc=="object"?b.wrtc:e(),!this._wrtc)throw l(typeof window=="undefined"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(B){this.destroy(l(B,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=B=>{this._onIceCandidate(B)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(B=>{this.destroy(l(B,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=B=>{this._setupData(B)},this.streams&&this.streams.forEach(B=>{this.addStream(B)}),this._pc.ontrack=B=>{this._onTrack(B)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(b){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof b=="string")try{b=JSON.parse(b)}catch(B){b={}}this._debug("signal()"),b.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),b.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(b.transceiverRequest.kind,b.transceiverRequest.init)),b.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(b.candidate):this._pendingCandidates.push(b.candidate)),b.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(b)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(B=>{this._addIceCandidate(B)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(B=>{this.destroy(l(B,"ERR_SET_REMOTE_DESCRIPTION"))}),!b.sdp&&!b.candidate&&!b.renegotiate&&!b.transceiverRequest&&this.destroy(l(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(b){const B=new this._wrtc.RTCIceCandidate(b);this._pc.addIceCandidate(B).catch(P=>{!B.address||B.address.endsWith(".local")?k("Ignoring unsupported ICE candidate."):this.destroy(l(P,"ERR_ADD_ICE_CANDIDATE"))})}send(b){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(b)}}addTransceiver(b,B){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(b,B),this._needsNegotiation()}catch(P){this.destroy(l(P,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:b,init:B}})}}addStream(b){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),b.getTracks().forEach(B=>{this.addTrack(B,b)})}}addTrack(b,B){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const P=this._senderMap.get(b)||new Map;let y=P.get(B);if(!y)y=this._pc.addTrack(b,B),P.set(B,y),this._senderMap.set(b,P),this._needsNegotiation();else throw y.removed?l(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):l(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(b,B,P){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const y=this._senderMap.get(b),C=y?y.get(P):null;if(!C)throw l(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");B&&this._senderMap.set(B,y),C.replaceTrack!=null?C.replaceTrack(B):this.destroy(l(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(b,B){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const P=this._senderMap.get(b),y=P?P.get(B):null;if(!y)throw l(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{y.removed=!0,this._pc.removeTrack(y)}catch(C){C.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(y):this.destroy(l(C,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(b){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),b.getTracks().forEach(B=>{this.removeTrack(B,b)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,c(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(b){this._destroy(b,()=>{})}_destroy(b,B){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",b&&(b.message||b)),c(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",b&&(b.message||b)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(P){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(P){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,b&&this.emit("error",b),this.emit("close"),B()}))}_setupData(b){if(!b.channel)return this.destroy(l(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=b.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=f),this.channelName=this._channel.label,this._channel.onmessage=P=>{this._onChannelMessage(P)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=P=>{const y=P.error instanceof Error?P.error:new Error(`Datachannel error: ${P.message} ${P.filename}:${P.lineno}:${P.colno}`);this.destroy(l(y,"ERR_DATA_CHANNEL"))};let B=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(B&&this._onChannelClose(),B=!0):B=!1},m)}_read(){}_write(b,B,P){if(this.destroyed)return P(l(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(b)}catch(y){return this.destroy(l(y,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>f?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=P):P(null)}else this._debug("write before connect"),this._chunk=b,this._cb=P}_onFinish(){if(this.destroyed)return;const b=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?b():this.once("connect",b)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(b=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(b.sdp=h(b.sdp)),b.sdp=this.sdpTransform(b.sdp);const B=()=>{if(this.destroyed)return;const C=this._pc.localDescription||b;this._debug("signal"),this.emit("signal",{type:C.type,sdp:C.sdp})},P=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?B():this.once("_iceComplete",B))},y=C=>{this.destroy(l(C,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(b).then(P).catch(y)}).catch(b=>{this.destroy(l(b,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(b=>{!b.mid&&b.sender.track&&!b.requested&&(b.requested=!0,this.addTransceiver(b.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(b=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(b.sdp=h(b.sdp)),b.sdp=this.sdpTransform(b.sdp);const B=()=>{if(this.destroyed)return;const C=this._pc.localDescription||b;this._debug("signal"),this.emit("signal",{type:C.type,sdp:C.sdp}),this.initiator||this._requestMissingTransceivers()},P=()=>{this.destroyed||(this.trickle||this._iceComplete?B():this.once("_iceComplete",B))},y=C=>{this.destroy(l(C,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(b).then(P).catch(y)}).catch(b=>{this.destroy(l(b,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(l(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const b=this._pc.iceConnectionState,B=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",b,B),this.emit("iceStateChange",b,B),(b==="connected"||b==="completed")&&(this._pcReady=!0,this._maybeReady()),b==="failed"&&this.destroy(l(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),b==="closed"&&this.destroy(l(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(b){const B=P=>(Object.prototype.toString.call(P.values)==="[object Array]"&&P.values.forEach(y=>{Object.assign(P,y)}),P);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(P=>{const y=[];P.forEach(C=>{y.push(B(C))}),b(null,y)},P=>b(P)):this._pc.getStats.length>0?this._pc.getStats(P=>{if(this.destroyed)return;const y=[];P.result().forEach(C=>{const A={};C.names().forEach(T=>{A[T]=C.stat(T)}),A.id=C.id,A.type=C.type,A.timestamp=C.timestamp,y.push(B(A))}),b(null,y)},P=>b(P)):b(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const b=()=>{this.destroyed||this.getStats((B,P)=>{if(this.destroyed)return;B&&(P=[]);const y={},C={},A={};let T=!1;P.forEach(S=>{(S.type==="remotecandidate"||S.type==="remote-candidate")&&(y[S.id]=S),(S.type==="localcandidate"||S.type==="local-candidate")&&(C[S.id]=S),(S.type==="candidatepair"||S.type==="candidate-pair")&&(A[S.id]=S)});const O=S=>{T=!0;let R=C[S.localCandidateId];R&&(R.ip||R.address)?(this.localAddress=R.ip||R.address,this.localPort=Number(R.port)):R&&R.ipAddress?(this.localAddress=R.ipAddress,this.localPort=Number(R.portNumber)):typeof S.googLocalAddress=="string"&&(R=S.googLocalAddress.split(":"),this.localAddress=R[0],this.localPort=Number(R[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let M=y[S.remoteCandidateId];M&&(M.ip||M.address)?(this.remoteAddress=M.ip||M.address,this.remotePort=Number(M.port)):M&&M.ipAddress?(this.remoteAddress=M.ipAddress,this.remotePort=Number(M.portNumber)):typeof S.googRemoteAddress=="string"&&(M=S.googRemoteAddress.split(":"),this.remoteAddress=M[0],this.remotePort=Number(M[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(P.forEach(S=>{S.type==="transport"&&S.selectedCandidatePairId&&O(A[S.selectedCandidatePairId]),(S.type==="googCandidatePair"&&S.googActiveConnection==="true"||(S.type==="candidatepair"||S.type==="candidate-pair")&&S.selected)&&O(S)}),!T&&(!Object.keys(A).length||Object.keys(C).length)){setTimeout(b,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(R){return this.destroy(l(R,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const S=this._cb;this._cb=null,S(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};b()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>f||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(b=>{this._pc.removeTrack(b),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(b){this.destroyed||(b.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:b.candidate.candidate,sdpMLineIndex:b.candidate.sdpMLineIndex,sdpMid:b.candidate.sdpMid}}):!b.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),b.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(b){if(this.destroyed)return;let B=b.data;B instanceof ArrayBuffer&&(B=g.from(B)),this.push(B)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const b=this._cb;this._cb=null,b(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(b){this.destroyed||b.streams.forEach(B=>{this._debug("on track"),this.emit("track",b.track,B),this._remoteTracks.push({track:b.track,stream:B}),!this._remoteStreams.some(P=>P.id===B.id)&&(this._remoteStreams.push(B),c(()=>{this._debug("on stream"),this.emit("stream",B)}))})}_debug(){const b=[].slice.call(arguments);b[0]="["+this._id+"] "+b[0],r.apply(null,b)}}return I.WEBRTC_SUPPORT=!!e(),I.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},I.channelConfig={},Sn=I,Sn}var Ps=Rs();const Ts=Gt(Ps);var As=Object.defineProperty,Is=(r,e,t)=>e in r?As(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,at=(r,e,t)=>Is(r,typeof e!="symbol"?e+"":e,t),_n=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class jo{constructor(e,t,s={}){at(this,"peer",null),at(this,"config"),at(this,"events"),at(this,"connectionState","new"),at(this,"isInitiator"),at(this,"remoteUserId"),at(this,"localStream",null),this.remoteUserId=e,this.config=t,this.events=s,this.isInitiator=t.initiator||!1}createConnection(e){return _n(this,null,function*(){try{console.log(`[CallPeerConnection] Creating connection to ${this.remoteUserId}, initiator: ${this.isInitiator}`),this.localStream=e||null;const t={initiator:this.isInitiator,trickle:!0,stream:this.localStream||void 0,config:{iceServers:this.config.iceServers}};this.peer=new Ts(t),this.setupPeerEventListeners(),console.log(`[CallPeerConnection] Peer connection created for ${this.remoteUserId}`)}catch(t){throw console.error(`[CallPeerConnection] Failed to create connection to ${this.remoteUserId}:`,t),t}})}signal(e){var t,s;if(!this.peer){console.error(`[CallPeerConnection] Cannot signal to ${this.remoteUserId}: peer not initialized`);return}try{console.log(`[CallPeerConnection] Signaling to ${this.remoteUserId}:`,e.type),this.peer.signal(e)}catch(c){console.error(`[CallPeerConnection] Failed to signal to ${this.remoteUserId}:`,c),(s=(t=this.events).onError)==null||s.call(t,c)}}addStream(e){var t,s;if(!this.peer){console.error(`[CallPeerConnection] Cannot add stream to ${this.remoteUserId}: peer not initialized`);return}try{this.localStream&&this.removeStream(this.localStream),this.localStream=e,this.peer.addStream(e),console.log(`[CallPeerConnection] Stream added to ${this.remoteUserId}`)}catch(c){console.error(`[CallPeerConnection] Failed to add stream to ${this.remoteUserId}:`,c),(s=(t=this.events).onError)==null||s.call(t,c)}}removeStream(e){var t,s;if(!this.peer){console.error(`[CallPeerConnection] Cannot remove stream from ${this.remoteUserId}: peer not initialized`);return}try{this.peer.removeStream(e),this.localStream===e&&(this.localStream=null),console.log(`[CallPeerConnection] Stream removed from ${this.remoteUserId}`)}catch(c){console.error(`[CallPeerConnection] Failed to remove stream from ${this.remoteUserId}:`,c),(s=(t=this.events).onError)==null||s.call(t,c)}}replaceTrack(e,t){var s,c;if(!this.peer){console.error(`[CallPeerConnection] Cannot replace track for ${this.remoteUserId}: peer not initialized`);return}if(!this.localStream){console.error(`[CallPeerConnection] Cannot replace track for ${this.remoteUserId}: no local stream`);return}if(e.kind!==t.kind){console.error(`[CallPeerConnection] Cannot replace track for ${this.remoteUserId}: track kinds don't match (${e.kind} vs ${t.kind})`);return}const g=this.localStream.getTracks().some(f=>f.id===e.id);g||console.warn(`[CallPeerConnection] Old track not found in local stream for ${this.remoteUserId}, attempting replacement anyway`);try{this.peer.replaceTrack(e,t,this.localStream),g&&this.localStream.removeTrack(e),this.localStream.addTrack(t),console.log(`[CallPeerConnection] ${t.kind} track replaced for ${this.remoteUserId} (${e.id} -> ${t.id})`)}catch(f){throw console.error(`[CallPeerConnection] Failed to replace track for ${this.remoteUserId}:`,f),(c=(s=this.events).onError)==null||c.call(s,f),f}}getVideoTrack(){if(!this.localStream)return null;const e=this.localStream.getVideoTracks();return e.length>0?e[0]:null}getAudioTrack(){if(!this.localStream)return null;const e=this.localStream.getAudioTracks();return e.length>0?e[0]:null}sendData(e){var t,s;if(!this.peer){console.error(`[CallPeerConnection] Cannot send data to ${this.remoteUserId}: peer not initialized`);return}if(!this.peer.connected){console.warn(`[CallPeerConnection] Cannot send data to ${this.remoteUserId}: not connected`);return}try{this.peer.send(JSON.stringify(e))}catch(c){console.error(`[CallPeerConnection] Failed to send data to ${this.remoteUserId}:`,c),(s=(t=this.events).onError)==null||s.call(t,c)}}setBandwidthLimit(e){return _n(this,null,function*(){if(!this.peer){console.warn(`[CallPeerConnection] Cannot set bandwidth for ${this.remoteUserId}: peer connection not available`);return}try{const t=this.peer._pc;if(!t)return;const s=t.getSenders();for(const c of s)if(c.track){const l=c.getParameters();l.encodings||(l.encodings=[{}]),l.encodings[0].maxBitrate=e*1e3,yield c.setParameters(l)}console.log(`[CallPeerConnection] Bandwidth limit set to ${e}kbps for ${this.remoteUserId}`)}catch(t){console.error(`[CallPeerConnection] Failed to set bandwidth limit for ${this.remoteUserId}:`,t)}})}getConnectionState(){return this.connectionState}isConnected(){var e;return((e=this.peer)==null?void 0:e.connected)===!0}getStats(){return _n(this,null,function*(){if(!this.peer)return null;try{const e=this.peer._pc;return e?yield e.getStats():null}catch(e){return console.error(`[CallPeerConnection] Failed to get stats for ${this.remoteUserId}:`,e),null}})}getRemoteUserId(){return this.remoteUserId}destroy(){if(console.log(`[CallPeerConnection] Destroying connection to ${this.remoteUserId}`),this.peer){try{this.peer.destroy()}catch(e){console.error(`[CallPeerConnection] Error destroying peer for ${this.remoteUserId}:`,e)}this.peer=null}this.localStream=null,this.connectionState="closed"}isExpectedDisconnectionError(e){const t=e.message||"",s=e.name||"";return["User-Initiated Abort","Close called","Connection closed","Connection failed","Peer connection closed","Peer is destroyed","cannot signal after peer is destroyed","cannot close after peer is destroyed"].some(l=>t.includes(l)||s.includes("OperationError")||s.includes("InvalidStateError"))}setupPeerEventListeners(){if(!this.peer)return;this.peer.on("signal",t=>{var s,c;console.log(`[CallPeerConnection] Signal from ${this.remoteUserId}:`,t.type),(c=(s=this.events).onSignal)==null||c.call(s,t)}),this.peer.on("connect",()=>{var t,s;console.log(`[CallPeerConnection] Connected to ${this.remoteUserId}`),this.connectionState="connected",(s=(t=this.events).onConnect)==null||s.call(t)}),this.peer.on("data",t=>{var s,c;try{const l=JSON.parse(t.toString());(c=(s=this.events).onData)==null||c.call(s,l)}catch(l){console.error(`[CallPeerConnection] Failed to parse data from ${this.remoteUserId}:`,l)}}),this.peer.on("stream",t=>{var s,c;console.log(`[CallPeerConnection] Stream received from ${this.remoteUserId}`),(c=(s=this.events).onStream)==null||c.call(s,t)}),this.peer.on("track",(t,s)=>{var c,l;console.log(`[CallPeerConnection] Track received from ${this.remoteUserId}:`,t.kind),(l=(c=this.events).onTrack)==null||l.call(c,t,s)}),this.peer.on("close",()=>{var t,s;console.log(`[CallPeerConnection] Connection closed with ${this.remoteUserId}`),this.connectionState="closed",(s=(t=this.events).onClose)==null||s.call(t)}),this.peer.on("error",t=>{var s,c,l,g;if(this.isExpectedDisconnectionError(t)){console.log(`[CallPeerConnection] Expected disconnection for ${this.remoteUserId}:`,t.message),this.connectionState="closed",(c=(s=this.events).onClose)==null||c.call(s);return}console.error(`[CallPeerConnection] Unexpected error with ${this.remoteUserId}:`,t),this.connectionState="failed",(g=(l=this.events).onError)==null||g.call(l,t)});const e=this.peer._pc;e&&e.addEventListener("connectionstatechange",()=>{if(this.peer){const t=this.peer._pc;t&&(this.connectionState=t.connectionState,console.log(`[CallPeerConnection] Connection state changed for ${this.remoteUserId}:`,this.connectionState))}})}getConnectionInfo(){return{remoteUserId:this.remoteUserId,isInitiator:this.isInitiator,connectionState:this.connectionState,connected:this.isConnected(),hasLocalStream:!!this.localStream,localStreamTracks:this.localStream?{video:this.localStream.getVideoTracks().length,audio:this.localStream.getAudioTracks().length}:null}}}const xo={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},St=new Map,Lt=r=>{const e=St.get(r);return e?Object.fromEntries(Object.entries(e.stores).map(([t,s])=>[t,s.getState()])):{}},ks=(r,e,t)=>{if(r===void 0)return{type:"untracked",connection:e.connect(t)};const s=St.get(t.name);if(s)return ze({type:"tracked",store:r},s);const c={connection:e.connect(t),stores:{}};return St.set(t.name,c),ze({type:"tracked",store:r},c)},Bs=(r,e)=>{if(e===void 0)return;const t=St.get(r);t&&(delete t.stores[e],Object.keys(t.stores).length===0&&St.delete(r))},Os=r=>{var e,t;if(!r)return;const s=r.split(`
|
|
12
|
-
`),c=s.findIndex(g=>g.includes("api.setState"));if(c<0)return;const l=((e=s[c+1])==null?void 0:e.trim())||"";return(t=/.+ (.+) .+/.exec(l))==null?void 0:t[1]},
|
|
11
|
+
`)+" "+J[1]:J[0]+G+" "+j.join(", ")+" "+J[1]}r.types=us();function P(j){return Array.isArray(j)}r.isArray=P;function y(j){return typeof j=="boolean"}r.isBoolean=y;function C(j){return j===null}r.isNull=C;function A(j){return j==null}r.isNullOrUndefined=A;function T(j){return typeof j=="number"}r.isNumber=T;function O(j){return typeof j=="string"}r.isString=O;function S(j){return typeof j=="symbol"}r.isSymbol=S;function R(j){return j===void 0}r.isUndefined=R;function L(j){return W(j)&&de(j)==="[object RegExp]"}r.isRegExp=L,r.types.isRegExp=L;function W(j){return typeof j=="object"&&j!==null}r.isObject=W;function X(j){return W(j)&&de(j)==="[object Date]"}r.isDate=X,r.types.isDate=X;function re(j){return W(j)&&(de(j)==="[object Error]"||j instanceof Error)}r.isError=re,r.types.isNativeError=re;function U(j){return typeof j=="function"}r.isFunction=U;function he(j){return j===null||typeof j=="boolean"||typeof j=="number"||typeof j=="string"||typeof j=="symbol"||typeof j=="undefined"}r.isPrimitive=he,r.isBuffer=fs();function de(j){return Object.prototype.toString.call(j)}function me(j){return j<10?"0"+j.toString(10):j.toString(10)}var Te=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ke(){var j=new Date,G=[me(j.getHours()),me(j.getMinutes()),me(j.getSeconds())].join(":");return[j.getDate(),Te[j.getMonth()],G].join(" ")}r.log=function(){console.log("%s - %s",ke(),r.format.apply(r,arguments))},r.inherits=ut(),r._extend=function(j,G){if(!G||!W(G))return j;for(var J=Object.keys(G),ne=J.length;ne--;)j[J[ne]]=G[J[ne]];return j};function Ee(j,G){return Object.prototype.hasOwnProperty.call(j,G)}var _e=typeof Symbol!="undefined"?Symbol("util.promisify.custom"):void 0;r.promisify=function(G){if(typeof G!="function")throw new TypeError('The "original" argument must be of type Function');if(_e&&G[_e]){var J=G[_e];if(typeof J!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(J,_e,{value:J,enumerable:!1,writable:!1,configurable:!0}),J}function J(){for(var ne,D,F=new Promise(function(Q,v){ne=Q,D=v}),V=[],Z=0;Z<arguments.length;Z++)V.push(arguments[Z]);V.push(function(Q,v){Q?D(Q):ne(v)});try{G.apply(this,V)}catch(Q){D(Q)}return F}return Object.setPrototypeOf(J,Object.getPrototypeOf(G)),_e&&Object.defineProperty(J,_e,{value:J,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(J,e(G))},r.promisify.custom=_e;function Me(j,G){if(!j){var J=new Error("Promise was rejected with a falsy value");J.reason=j,j=J}return G(j)}function xe(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');function G(){for(var J=[],ne=0;ne<arguments.length;ne++)J.push(arguments[ne]);var D=J.pop();if(typeof D!="function")throw new TypeError("The last argument must be of type Function");var F=this,V=function(){return D.apply(F,arguments)};j.apply(this,J).then(function(Z){ae.nextTick(V.bind(null,null,Z))},function(Z){ae.nextTick(Me.bind(null,Z,V))})}return Object.setPrototypeOf(G,Object.getPrototypeOf(j)),Object.defineProperties(G,e(j)),G}r.callbackify=xe}(Yt)),Yt}var Qr,uo;function hs(){if(uo)return Qr;uo=1;function r(b,k){var P=Object.keys(b);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(b);k&&(y=y.filter(function(C){return Object.getOwnPropertyDescriptor(b,C).enumerable})),P.push.apply(P,y)}return P}function e(b){for(var k=1;k<arguments.length;k++){var P=arguments[k]!=null?arguments[k]:{};k%2?r(Object(P),!0).forEach(function(y){t(b,y,P[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(b,Object.getOwnPropertyDescriptors(P)):r(Object(P)).forEach(function(y){Object.defineProperty(b,y,Object.getOwnPropertyDescriptor(P,y))})}return b}function t(b,k,P){return k=g(k),k in b?Object.defineProperty(b,k,{value:P,enumerable:!0,configurable:!0,writable:!0}):b[k]=P,b}function s(b,k){if(!(b instanceof k))throw new TypeError("Cannot call a class as a function")}function c(b,k){for(var P=0;P<k.length;P++){var y=k[P];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(b,g(y.key),y)}}function l(b,k,P){return k&&c(b.prototype,k),Object.defineProperty(b,"prototype",{writable:!1}),b}function g(b){var k=f(b,"string");return typeof k=="symbol"?k:String(k)}function f(b,k){if(typeof b!="object"||b===null)return b;var P=b[Symbol.toPrimitive];if(P!==void 0){var y=P.call(b,k);if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(b)}var u=mt(),m=u.Buffer,h=co(),B=h.inspect,I=B&&B.custom||"inspect";function $(b,k,P){m.prototype.copy.call(b,k,P)}return Qr=function(){function b(){s(this,b),this.head=null,this.tail=null,this.length=0}return l(b,[{key:"push",value:function(P){var y={data:P,next:null};this.length>0?this.tail.next=y:this.head=y,this.tail=y,++this.length}},{key:"unshift",value:function(P){var y={data:P,next:this.head};this.length===0&&(this.tail=y),this.head=y,++this.length}},{key:"shift",value:function(){if(this.length!==0){var P=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,P}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(P){if(this.length===0)return"";for(var y=this.head,C=""+y.data;y=y.next;)C+=P+y.data;return C}},{key:"concat",value:function(P){if(this.length===0)return m.alloc(0);for(var y=m.allocUnsafe(P>>>0),C=this.head,A=0;C;)$(C.data,y,A),A+=C.data.length,C=C.next;return y}},{key:"consume",value:function(P,y){var C;return P<this.head.data.length?(C=this.head.data.slice(0,P),this.head.data=this.head.data.slice(P)):P===this.head.data.length?C=this.shift():C=y?this._getString(P):this._getBuffer(P),C}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(P){var y=this.head,C=1,A=y.data;for(P-=A.length;y=y.next;){var T=y.data,O=P>T.length?T.length:P;if(O===T.length?A+=T:A+=T.slice(0,P),P-=O,P===0){O===T.length?(++C,y.next?this.head=y.next:this.head=this.tail=null):(this.head=y,y.data=T.slice(O));break}++C}return this.length-=C,A}},{key:"_getBuffer",value:function(P){var y=m.allocUnsafe(P),C=this.head,A=1;for(C.data.copy(y),P-=C.data.length;C=C.next;){var T=C.data,O=P>T.length?T.length:P;if(T.copy(y,y.length-P,0,O),P-=O,P===0){O===T.length?(++A,C.next?this.head=C.next:this.head=this.tail=null):(this.head=C,C.data=T.slice(O));break}++A}return this.length-=A,y}},{key:I,value:function(P,y){return B(this,e(e({},y),{},{depth:0,customInspect:!1}))}}]),b}(),Qr}var en,fo;function ho(){if(fo)return en;fo=1;function r(g,f){var u=this,m=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return m||h?(f?f(g):g&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,ae.nextTick(c,this,g)):ae.nextTick(c,this,g)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(g||null,function(B){!f&&B?u._writableState?u._writableState.errorEmitted?ae.nextTick(t,u):(u._writableState.errorEmitted=!0,ae.nextTick(e,u,B)):ae.nextTick(e,u,B):f?(ae.nextTick(t,u),f(B)):ae.nextTick(t,u)}),this)}function e(g,f){c(g,f),t(g)}function t(g){g._writableState&&!g._writableState.emitClose||g._readableState&&!g._readableState.emitClose||g.emit("close")}function s(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function c(g,f){g.emit("error",f)}function l(g,f){var u=g._readableState,m=g._writableState;u&&u.autoDestroy||m&&m.autoDestroy?g.destroy(f):g.emit("error",f)}return en={destroy:r,undestroy:s,errorOrDestroy:l},en}var tn={},po;function ft(){if(po)return tn;po=1;function r(f,u){f.prototype=Object.create(u.prototype),f.prototype.constructor=f,f.__proto__=u}var e={};function t(f,u,m){m||(m=Error);function h(I,$,b){return typeof u=="string"?u:u(I,$,b)}var B=function(I){r($,I);function $(b,k,P){return I.call(this,h(b,k,P))||this}return $}(m);B.prototype.name=m.name,B.prototype.code=f,e[f]=B}function s(f,u){if(Array.isArray(f)){var m=f.length;return f=f.map(function(h){return String(h)}),m>2?"one of ".concat(u," ").concat(f.slice(0,m-1).join(", "),", or ")+f[m-1]:m===2?"one of ".concat(u," ").concat(f[0]," or ").concat(f[1]):"of ".concat(u," ").concat(f[0])}else return"of ".concat(u," ").concat(String(f))}function c(f,u,m){return f.substr(0,u.length)===u}function l(f,u,m){return(m===void 0||m>f.length)&&(m=f.length),f.substring(m-u.length,m)===u}function g(f,u,m){return typeof m!="number"&&(m=0),m+u.length>f.length?!1:f.indexOf(u,m)!==-1}return t("ERR_INVALID_OPT_VALUE",function(f,u){return'The value "'+u+'" is invalid for option "'+f+'"'},TypeError),t("ERR_INVALID_ARG_TYPE",function(f,u,m){var h;typeof u=="string"&&c(u,"not ")?(h="must not be",u=u.replace(/^not /,"")):h="must be";var B;if(l(f," argument"))B="The ".concat(f," ").concat(h," ").concat(s(u,"type"));else{var I=g(f,".")?"property":"argument";B='The "'.concat(f,'" ').concat(I," ").concat(h," ").concat(s(u,"type"))}return B+=". Received type ".concat(typeof m),B},TypeError),t("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),t("ERR_METHOD_NOT_IMPLEMENTED",function(f){return"The "+f+" method is not implemented"}),t("ERR_STREAM_PREMATURE_CLOSE","Premature close"),t("ERR_STREAM_DESTROYED",function(f){return"Cannot call "+f+" after a stream was destroyed"}),t("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),t("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),t("ERR_STREAM_WRITE_AFTER_END","write after end"),t("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),t("ERR_UNKNOWN_ENCODING",function(f){return"Unknown encoding: "+f},TypeError),t("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),tn.codes=e,tn}var rn,go;function yo(){if(go)return rn;go=1;var r=ft().codes.ERR_INVALID_OPT_VALUE;function e(s,c,l){return s.highWaterMark!=null?s.highWaterMark:c?s[l]:null}function t(s,c,l,g){var f=e(c,g,l);if(f!=null){if(!(isFinite(f)&&Math.floor(f)===f)||f<0){var u=g?l:"highWaterMark";throw new r(u,f)}return Math.floor(f)}return s.objectMode?16:16*1024}return rn={getHighWaterMark:t},rn}var nn,mo;function ds(){if(mo)return nn;mo=1,nn=r;function r(t,s){if(e("noDeprecation"))return t;var c=!1;function l(){if(!c){if(e("throwDeprecation"))throw new Error(s);e("traceDeprecation")?console.trace(s):console.warn(s),c=!0}return t.apply(this,arguments)}return l}function e(t){try{if(!globalThis.localStorage)return!1}catch(c){return!1}var s=globalThis.localStorage[t];return s==null?!1:String(s).toLowerCase()==="true"}return nn}var on,vo;function wo(){if(vo)return on;vo=1,on=L;function r(D){var F=this;this.next=null,this.entry=null,this.finish=function(){ne(F,D)}}var e;L.WritableState=S;var t={deprecate:ds()},s=Zn(),c=mt().Buffer,l=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function g(D){return c.from(D)}function f(D){return c.isBuffer(D)||D instanceof l}var u=ho(),m=yo(),h=m.getHighWaterMark,B=ft().codes,I=B.ERR_INVALID_ARG_TYPE,$=B.ERR_METHOD_NOT_IMPLEMENTED,b=B.ERR_MULTIPLE_CALLBACK,k=B.ERR_STREAM_CANNOT_PIPE,P=B.ERR_STREAM_DESTROYED,y=B.ERR_STREAM_NULL_VALUES,C=B.ERR_STREAM_WRITE_AFTER_END,A=B.ERR_UNKNOWN_ENCODING,T=u.errorOrDestroy;ut()(L,s);function O(){}function S(D,F,V){e=e||ht(),D=D||{},typeof V!="boolean"&&(V=F instanceof e),this.objectMode=!!D.objectMode,V&&(this.objectMode=this.objectMode||!!D.writableObjectMode),this.highWaterMark=h(this,D,"writableHighWaterMark",V),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var Z=D.decodeStrings===!1;this.decodeStrings=!Z,this.defaultEncoding=D.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(Q){Te(F,Q)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=D.emitClose!==!1,this.autoDestroy=!!D.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}S.prototype.getBuffer=function(){for(var F=this.bufferedRequest,V=[];F;)V.push(F),F=F.next;return V},function(){try{Object.defineProperty(S.prototype,"buffer",{get:t.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(D){}}();var R;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(R=Function.prototype[Symbol.hasInstance],Object.defineProperty(L,Symbol.hasInstance,{value:function(F){return R.call(this,F)?!0:this!==L?!1:F&&F._writableState instanceof S}})):R=function(F){return F instanceof this};function L(D){e=e||ht();var F=this instanceof e;if(!F&&!R.call(L,this))return new L(D);this._writableState=new S(D,this,F),this.writable=!0,D&&(typeof D.write=="function"&&(this._write=D.write),typeof D.writev=="function"&&(this._writev=D.writev),typeof D.destroy=="function"&&(this._destroy=D.destroy),typeof D.final=="function"&&(this._final=D.final)),s.call(this)}L.prototype.pipe=function(){T(this,new k)};function W(D,F){var V=new C;T(D,V),ae.nextTick(F,V)}function X(D,F,V,Z){var Q;return V===null?Q=new y:typeof V!="string"&&!F.objectMode&&(Q=new I("chunk",["string","Buffer"],V)),Q?(T(D,Q),ae.nextTick(Z,Q),!1):!0}L.prototype.write=function(D,F,V){var Z=this._writableState,Q=!1,v=!Z.objectMode&&f(D);return v&&!c.isBuffer(D)&&(D=g(D)),typeof F=="function"&&(V=F,F=null),v?F="buffer":F||(F=Z.defaultEncoding),typeof V!="function"&&(V=O),Z.ending?W(this,V):(v||X(this,Z,D,V))&&(Z.pendingcb++,Q=U(this,Z,v,D,F,V)),Q},L.prototype.cork=function(){this._writableState.corked++},L.prototype.uncork=function(){var D=this._writableState;D.corked&&(D.corked--,!D.writing&&!D.corked&&!D.bufferProcessing&&D.bufferedRequest&&_e(this,D))},L.prototype.setDefaultEncoding=function(F){if(typeof F=="string"&&(F=F.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((F+"").toLowerCase())>-1))throw new A(F);return this._writableState.defaultEncoding=F,this},Object.defineProperty(L.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function re(D,F,V){return!D.objectMode&&D.decodeStrings!==!1&&typeof F=="string"&&(F=c.from(F,V)),F}Object.defineProperty(L.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function U(D,F,V,Z,Q,v){if(!V){var w=re(F,Z,Q);Z!==w&&(V=!0,Q="buffer",Z=w)}var z=F.objectMode?1:Z.length;F.length+=z;var ee=F.length<F.highWaterMark;if(ee||(F.needDrain=!0),F.writing||F.corked){var ce=F.lastBufferedRequest;F.lastBufferedRequest={chunk:Z,encoding:Q,isBuf:V,callback:v,next:null},ce?ce.next=F.lastBufferedRequest:F.bufferedRequest=F.lastBufferedRequest,F.bufferedRequestCount+=1}else he(D,F,!1,z,Z,Q,v);return ee}function he(D,F,V,Z,Q,v,w){F.writelen=Z,F.writecb=w,F.writing=!0,F.sync=!0,F.destroyed?F.onwrite(new P("write")):V?D._writev(Q,F.onwrite):D._write(Q,v,F.onwrite),F.sync=!1}function de(D,F,V,Z,Q){--F.pendingcb,V?(ae.nextTick(Q,Z),ae.nextTick(G,D,F),D._writableState.errorEmitted=!0,T(D,Z)):(Q(Z),D._writableState.errorEmitted=!0,T(D,Z),G(D,F))}function me(D){D.writing=!1,D.writecb=null,D.length-=D.writelen,D.writelen=0}function Te(D,F){var V=D._writableState,Z=V.sync,Q=V.writecb;if(typeof Q!="function")throw new b;if(me(V),F)de(D,V,Z,F,Q);else{var v=Me(V)||D.destroyed;!v&&!V.corked&&!V.bufferProcessing&&V.bufferedRequest&&_e(D,V),Z?ae.nextTick(ke,D,V,v,Q):ke(D,V,v,Q)}}function ke(D,F,V,Z){V||Ee(D,F),F.pendingcb--,Z(),G(D,F)}function Ee(D,F){F.length===0&&F.needDrain&&(F.needDrain=!1,D.emit("drain"))}function _e(D,F){F.bufferProcessing=!0;var V=F.bufferedRequest;if(D._writev&&V&&V.next){var Z=F.bufferedRequestCount,Q=new Array(Z),v=F.corkedRequestsFree;v.entry=V;for(var w=0,z=!0;V;)Q[w]=V,V.isBuf||(z=!1),V=V.next,w+=1;Q.allBuffers=z,he(D,F,!0,F.length,Q,"",v.finish),F.pendingcb++,F.lastBufferedRequest=null,v.next?(F.corkedRequestsFree=v.next,v.next=null):F.corkedRequestsFree=new r(F),F.bufferedRequestCount=0}else{for(;V;){var ee=V.chunk,ce=V.encoding,ie=V.callback,le=F.objectMode?1:ee.length;if(he(D,F,!1,le,ee,ce,ie),V=V.next,F.bufferedRequestCount--,F.writing)break}V===null&&(F.lastBufferedRequest=null)}F.bufferedRequest=V,F.bufferProcessing=!1}L.prototype._write=function(D,F,V){V(new $("_write()"))},L.prototype._writev=null,L.prototype.end=function(D,F,V){var Z=this._writableState;return typeof D=="function"?(V=D,D=null,F=null):typeof F=="function"&&(V=F,F=null),D!=null&&this.write(D,F),Z.corked&&(Z.corked=1,this.uncork()),Z.ending||J(this,Z,V),this},Object.defineProperty(L.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Me(D){return D.ending&&D.length===0&&D.bufferedRequest===null&&!D.finished&&!D.writing}function xe(D,F){D._final(function(V){F.pendingcb--,V&&T(D,V),F.prefinished=!0,D.emit("prefinish"),G(D,F)})}function j(D,F){!F.prefinished&&!F.finalCalled&&(typeof D._final=="function"&&!F.destroyed?(F.pendingcb++,F.finalCalled=!0,ae.nextTick(xe,D,F)):(F.prefinished=!0,D.emit("prefinish")))}function G(D,F){var V=Me(F);if(V&&(j(D,F),F.pendingcb===0&&(F.finished=!0,D.emit("finish"),F.autoDestroy))){var Z=D._readableState;(!Z||Z.autoDestroy&&Z.endEmitted)&&D.destroy()}return V}function J(D,F,V){F.ending=!0,G(D,F),V&&(F.finished?ae.nextTick(V):D.once("finish",V)),F.ended=!0,D.writable=!1}function ne(D,F,V){var Z=D.entry;for(D.entry=null;Z;){var Q=Z.callback;F.pendingcb--,Q(V),Z=Z.next}F.corkedRequestsFree.next=D}return Object.defineProperty(L.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(F){this._writableState&&(this._writableState.destroyed=F)}}),L.prototype.destroy=u.destroy,L.prototype._undestroy=u.undestroy,L.prototype._destroy=function(D,F){F(D)},on}var an,bo;function ht(){if(bo)return an;bo=1;var r=Object.keys||function(m){var h=[];for(var B in m)h.push(B);return h};an=g;var e=To(),t=wo();ut()(g,e);for(var s=r(t.prototype),c=0;c<s.length;c++){var l=s[c];g.prototype[l]||(g.prototype[l]=t.prototype[l])}function g(m){if(!(this instanceof g))return new g(m);e.call(this,m),t.call(this,m),this.allowHalfOpen=!0,m&&(m.readable===!1&&(this.readable=!1),m.writable===!1&&(this.writable=!1),m.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",f)))}Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(g.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(g.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function f(){this._writableState.ended||ae.nextTick(u,this)}function u(m){m.end()}return Object.defineProperty(g.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(h){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=h,this._writableState.destroyed=h)}}),an}var sn={},So;function _o(){if(So)return sn;So=1;var r=Jn().Buffer,e=r.isEncoding||function(y){switch(y=""+y,y&&y.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function t(y){if(!y)return"utf8";for(var C;;)switch(y){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return y;default:if(C)return;y=(""+y).toLowerCase(),C=!0}}function s(y){var C=t(y);if(typeof C!="string"&&(r.isEncoding===e||!e(y)))throw new Error("Unknown encoding: "+y);return C||y}sn.StringDecoder=c;function c(y){this.encoding=s(y);var C;switch(this.encoding){case"utf16le":this.text=B,this.end=I,C=4;break;case"utf8":this.fillLast=u,C=4;break;case"base64":this.text=$,this.end=b,C=3;break;default:this.write=k,this.end=P;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(C)}c.prototype.write=function(y){if(y.length===0)return"";var C,A;if(this.lastNeed){if(C=this.fillLast(y),C===void 0)return"";A=this.lastNeed,this.lastNeed=0}else A=0;return A<y.length?C?C+this.text(y,A):this.text(y,A):C||""},c.prototype.end=h,c.prototype.text=m,c.prototype.fillLast=function(y){if(this.lastNeed<=y.length)return y.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);y.copy(this.lastChar,this.lastTotal-this.lastNeed,0,y.length),this.lastNeed-=y.length};function l(y){return y<=127?0:y>>5===6?2:y>>4===14?3:y>>3===30?4:y>>6===2?-1:-2}function g(y,C,A){var T=C.length-1;if(T<A)return 0;var O=l(C[T]);return O>=0?(O>0&&(y.lastNeed=O-1),O):--T<A||O===-2?0:(O=l(C[T]),O>=0?(O>0&&(y.lastNeed=O-2),O):--T<A||O===-2?0:(O=l(C[T]),O>=0?(O>0&&(O===2?O=0:y.lastNeed=O-3),O):0))}function f(y,C,A){if((C[0]&192)!==128)return y.lastNeed=0,"�";if(y.lastNeed>1&&C.length>1){if((C[1]&192)!==128)return y.lastNeed=1,"�";if(y.lastNeed>2&&C.length>2&&(C[2]&192)!==128)return y.lastNeed=2,"�"}}function u(y){var C=this.lastTotal-this.lastNeed,A=f(this,y);if(A!==void 0)return A;if(this.lastNeed<=y.length)return y.copy(this.lastChar,C,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);y.copy(this.lastChar,C,0,y.length),this.lastNeed-=y.length}function m(y,C){var A=g(this,y,C);if(!this.lastNeed)return y.toString("utf8",C);this.lastTotal=A;var T=y.length-(A-this.lastNeed);return y.copy(this.lastChar,0,T),y.toString("utf8",C,T)}function h(y){var C=y&&y.length?this.write(y):"";return this.lastNeed?C+"�":C}function B(y,C){if((y.length-C)%2===0){var A=y.toString("utf16le",C);if(A){var T=A.charCodeAt(A.length-1);if(T>=55296&&T<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=y[y.length-2],this.lastChar[1]=y[y.length-1],A.slice(0,-1)}return A}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=y[y.length-1],y.toString("utf16le",C,y.length-1)}function I(y){var C=y&&y.length?this.write(y):"";if(this.lastNeed){var A=this.lastTotal-this.lastNeed;return C+this.lastChar.toString("utf16le",0,A)}return C}function $(y,C){var A=(y.length-C)%3;return A===0?y.toString("base64",C):(this.lastNeed=3-A,this.lastTotal=3,A===1?this.lastChar[0]=y[y.length-1]:(this.lastChar[0]=y[y.length-2],this.lastChar[1]=y[y.length-1]),y.toString("base64",C,y.length-A))}function b(y){var C=y&&y.length?this.write(y):"";return this.lastNeed?C+this.lastChar.toString("base64",0,3-this.lastNeed):C}function k(y){return y.toString(this.encoding)}function P(y){return y&&y.length?this.write(y):""}return sn}var ln,Eo;function cn(){if(Eo)return ln;Eo=1;var r=ft().codes.ERR_STREAM_PREMATURE_CLOSE;function e(l){var g=!1;return function(){if(!g){g=!0;for(var f=arguments.length,u=new Array(f),m=0;m<f;m++)u[m]=arguments[m];l.apply(this,u)}}}function t(){}function s(l){return l.setHeader&&typeof l.abort=="function"}function c(l,g,f){if(typeof g=="function")return c(l,null,g);g||(g={}),f=e(f||t);var u=g.readable||g.readable!==!1&&l.readable,m=g.writable||g.writable!==!1&&l.writable,h=function(){l.writable||I()},B=l._writableState&&l._writableState.finished,I=function(){m=!1,B=!0,u||f.call(l)},$=l._readableState&&l._readableState.endEmitted,b=function(){u=!1,$=!0,m||f.call(l)},k=function(A){f.call(l,A)},P=function(){var A;if(u&&!$)return(!l._readableState||!l._readableState.ended)&&(A=new r),f.call(l,A);if(m&&!B)return(!l._writableState||!l._writableState.ended)&&(A=new r),f.call(l,A)},y=function(){l.req.on("finish",I)};return s(l)?(l.on("complete",I),l.on("abort",P),l.req?y():l.on("request",y)):m&&!l._writableState&&(l.on("end",h),l.on("close",h)),l.on("end",b),l.on("finish",I),g.error!==!1&&l.on("error",k),l.on("close",P),function(){l.removeListener("complete",I),l.removeListener("abort",P),l.removeListener("request",y),l.req&&l.req.removeListener("finish",I),l.removeListener("end",h),l.removeListener("close",h),l.removeListener("finish",I),l.removeListener("end",b),l.removeListener("error",k),l.removeListener("close",P)}}return ln=c,ln}var un,Co;function ps(){if(Co)return un;Co=1;var r;function e(A,T,O){return T=t(T),T in A?Object.defineProperty(A,T,{value:O,enumerable:!0,configurable:!0,writable:!0}):A[T]=O,A}function t(A){var T=s(A,"string");return typeof T=="symbol"?T:String(T)}function s(A,T){if(typeof A!="object"||A===null)return A;var O=A[Symbol.toPrimitive];if(O!==void 0){var S=O.call(A,T);if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(T==="string"?String:Number)(A)}var c=cn(),l=Symbol("lastResolve"),g=Symbol("lastReject"),f=Symbol("error"),u=Symbol("ended"),m=Symbol("lastPromise"),h=Symbol("handlePromise"),B=Symbol("stream");function I(A,T){return{value:A,done:T}}function $(A){var T=A[l];if(T!==null){var O=A[B].read();O!==null&&(A[m]=null,A[l]=null,A[g]=null,T(I(O,!1)))}}function b(A){ae.nextTick($,A)}function k(A,T){return function(O,S){A.then(function(){if(T[u]){O(I(void 0,!0));return}T[h](O,S)},S)}}var P=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((r={get stream(){return this[B]},next:function(){var T=this,O=this[f];if(O!==null)return Promise.reject(O);if(this[u])return Promise.resolve(I(void 0,!0));if(this[B].destroyed)return new Promise(function(W,X){ae.nextTick(function(){T[f]?X(T[f]):W(I(void 0,!0))})});var S=this[m],R;if(S)R=new Promise(k(S,this));else{var L=this[B].read();if(L!==null)return Promise.resolve(I(L,!1));R=new Promise(this[h])}return this[m]=R,R}},e(r,Symbol.asyncIterator,function(){return this}),e(r,"return",function(){var T=this;return new Promise(function(O,S){T[B].destroy(null,function(R){if(R){S(R);return}O(I(void 0,!0))})})}),r),P),C=function(T){var O,S=Object.create(y,(O={},e(O,B,{value:T,writable:!0}),e(O,l,{value:null,writable:!0}),e(O,g,{value:null,writable:!0}),e(O,f,{value:null,writable:!0}),e(O,u,{value:T._readableState.endEmitted,writable:!0}),e(O,h,{value:function(L,W){var X=S[B].read();X?(S[m]=null,S[l]=null,S[g]=null,L(I(X,!1))):(S[l]=L,S[g]=W)},writable:!0}),O));return S[m]=null,c(T,function(R){if(R&&R.code!=="ERR_STREAM_PREMATURE_CLOSE"){var L=S[g];L!==null&&(S[m]=null,S[l]=null,S[g]=null,L(R)),S[f]=R;return}var W=S[l];W!==null&&(S[m]=null,S[l]=null,S[g]=null,W(I(void 0,!0))),S[u]=!0}),T.on("readable",b.bind(null,S)),S};return un=C,un}var fn,Ro;function gs(){return Ro||(Ro=1,fn=function(){throw new Error("Readable.from is not available in the browser")}),fn}var hn,Po;function To(){if(Po)return hn;Po=1,hn=W;var r;W.ReadableState=L,Ht().EventEmitter;var e=function(w,z){return w.listeners(z).length},t=Zn(),s=mt().Buffer,c=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function l(v){return s.from(v)}function g(v){return s.isBuffer(v)||v instanceof c}var f=co(),u;f&&f.debuglog?u=f.debuglog("stream"):u=function(){};var m=hs(),h=ho(),B=yo(),I=B.getHighWaterMark,$=ft().codes,b=$.ERR_INVALID_ARG_TYPE,k=$.ERR_STREAM_PUSH_AFTER_EOF,P=$.ERR_METHOD_NOT_IMPLEMENTED,y=$.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,C,A,T;ut()(W,t);var O=h.errorOrDestroy,S=["error","close","destroy","pause","resume"];function R(v,w,z){if(typeof v.prependListener=="function")return v.prependListener(w,z);!v._events||!v._events[w]?v.on(w,z):Array.isArray(v._events[w])?v._events[w].unshift(z):v._events[w]=[z,v._events[w]]}function L(v,w,z){r=r||ht(),v=v||{},typeof z!="boolean"&&(z=w instanceof r),this.objectMode=!!v.objectMode,z&&(this.objectMode=this.objectMode||!!v.readableObjectMode),this.highWaterMark=I(this,v,"readableHighWaterMark",z),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=v.emitClose!==!1,this.autoDestroy=!!v.autoDestroy,this.destroyed=!1,this.defaultEncoding=v.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,v.encoding&&(C||(C=_o().StringDecoder),this.decoder=new C(v.encoding),this.encoding=v.encoding)}function W(v){if(r=r||ht(),!(this instanceof W))return new W(v);var w=this instanceof r;this._readableState=new L(v,this,w),this.readable=!0,v&&(typeof v.read=="function"&&(this._read=v.read),typeof v.destroy=="function"&&(this._destroy=v.destroy)),t.call(this)}Object.defineProperty(W.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(w){this._readableState&&(this._readableState.destroyed=w)}}),W.prototype.destroy=h.destroy,W.prototype._undestroy=h.undestroy,W.prototype._destroy=function(v,w){w(v)},W.prototype.push=function(v,w){var z=this._readableState,ee;return z.objectMode?ee=!0:typeof v=="string"&&(w=w||z.defaultEncoding,w!==z.encoding&&(v=s.from(v,w),w=""),ee=!0),X(this,v,w,!1,ee)},W.prototype.unshift=function(v){return X(this,v,null,!0,!1)};function X(v,w,z,ee,ce){u("readableAddChunk",w);var ie=v._readableState;if(w===null)ie.reading=!1,Te(v,ie);else{var le;if(ce||(le=U(ie,w)),le)O(v,le);else if(ie.objectMode||w&&w.length>0)if(typeof w!="string"&&!ie.objectMode&&Object.getPrototypeOf(w)!==s.prototype&&(w=l(w)),ee)ie.endEmitted?O(v,new y):re(v,ie,w,!0);else if(ie.ended)O(v,new k);else{if(ie.destroyed)return!1;ie.reading=!1,ie.decoder&&!z?(w=ie.decoder.write(w),ie.objectMode||w.length!==0?re(v,ie,w,!1):_e(v,ie)):re(v,ie,w,!1)}else ee||(ie.reading=!1,_e(v,ie))}return!ie.ended&&(ie.length<ie.highWaterMark||ie.length===0)}function re(v,w,z,ee){w.flowing&&w.length===0&&!w.sync?(w.awaitDrain=0,v.emit("data",z)):(w.length+=w.objectMode?1:z.length,ee?w.buffer.unshift(z):w.buffer.push(z),w.needReadable&&ke(v)),_e(v,w)}function U(v,w){var z;return!g(w)&&typeof w!="string"&&w!==void 0&&!v.objectMode&&(z=new b("chunk",["string","Buffer","Uint8Array"],w)),z}W.prototype.isPaused=function(){return this._readableState.flowing===!1},W.prototype.setEncoding=function(v){C||(C=_o().StringDecoder);var w=new C(v);this._readableState.decoder=w,this._readableState.encoding=this._readableState.decoder.encoding;for(var z=this._readableState.buffer.head,ee="";z!==null;)ee+=w.write(z.data),z=z.next;return this._readableState.buffer.clear(),ee!==""&&this._readableState.buffer.push(ee),this._readableState.length=ee.length,this};var he=1073741824;function de(v){return v>=he?v=he:(v--,v|=v>>>1,v|=v>>>2,v|=v>>>4,v|=v>>>8,v|=v>>>16,v++),v}function me(v,w){return v<=0||w.length===0&&w.ended?0:w.objectMode?1:v!==v?w.flowing&&w.length?w.buffer.head.data.length:w.length:(v>w.highWaterMark&&(w.highWaterMark=de(v)),v<=w.length?v:w.ended?w.length:(w.needReadable=!0,0))}W.prototype.read=function(v){u("read",v),v=parseInt(v,10);var w=this._readableState,z=v;if(v!==0&&(w.emittedReadable=!1),v===0&&w.needReadable&&((w.highWaterMark!==0?w.length>=w.highWaterMark:w.length>0)||w.ended))return u("read: emitReadable",w.length,w.ended),w.length===0&&w.ended?V(this):ke(this),null;if(v=me(v,w),v===0&&w.ended)return w.length===0&&V(this),null;var ee=w.needReadable;u("need readable",ee),(w.length===0||w.length-v<w.highWaterMark)&&(ee=!0,u("length less than watermark",ee)),w.ended||w.reading?(ee=!1,u("reading or ended",ee)):ee&&(u("do read"),w.reading=!0,w.sync=!0,w.length===0&&(w.needReadable=!0),this._read(w.highWaterMark),w.sync=!1,w.reading||(v=me(z,w)));var ce;return v>0?ce=F(v,w):ce=null,ce===null?(w.needReadable=w.length<=w.highWaterMark,v=0):(w.length-=v,w.awaitDrain=0),w.length===0&&(w.ended||(w.needReadable=!0),z!==v&&w.ended&&V(this)),ce!==null&&this.emit("data",ce),ce};function Te(v,w){if(u("onEofChunk"),!w.ended){if(w.decoder){var z=w.decoder.end();z&&z.length&&(w.buffer.push(z),w.length+=w.objectMode?1:z.length)}w.ended=!0,w.sync?ke(v):(w.needReadable=!1,w.emittedReadable||(w.emittedReadable=!0,Ee(v)))}}function ke(v){var w=v._readableState;u("emitReadable",w.needReadable,w.emittedReadable),w.needReadable=!1,w.emittedReadable||(u("emitReadable",w.flowing),w.emittedReadable=!0,ae.nextTick(Ee,v))}function Ee(v){var w=v._readableState;u("emitReadable_",w.destroyed,w.length,w.ended),!w.destroyed&&(w.length||w.ended)&&(v.emit("readable"),w.emittedReadable=!1),w.needReadable=!w.flowing&&!w.ended&&w.length<=w.highWaterMark,D(v)}function _e(v,w){w.readingMore||(w.readingMore=!0,ae.nextTick(Me,v,w))}function Me(v,w){for(;!w.reading&&!w.ended&&(w.length<w.highWaterMark||w.flowing&&w.length===0);){var z=w.length;if(u("maybeReadMore read 0"),v.read(0),z===w.length)break}w.readingMore=!1}W.prototype._read=function(v){O(this,new P("_read()"))},W.prototype.pipe=function(v,w){var z=this,ee=this._readableState;switch(ee.pipesCount){case 0:ee.pipes=v;break;case 1:ee.pipes=[ee.pipes,v];break;default:ee.pipes.push(v);break}ee.pipesCount+=1,u("pipe count=%d opts=%j",ee.pipesCount,w);var ce=(!w||w.end!==!1)&&v!==ae.stdout&&v!==ae.stderr,ie=ce?De:We;ee.endEmitted?ae.nextTick(ie):z.once("end",ie),v.on("unpipe",le);function le(Ge,Le){u("onunpipe"),Ge===z&&Le&&Le.hasUnpiped===!1&&(Le.hasUnpiped=!0,Ue())}function De(){u("onend"),v.end()}var H=xe(z);v.on("drain",H);var Fe=!1;function Ue(){u("cleanup"),v.removeListener("close",je),v.removeListener("finish",Ne),v.removeListener("drain",H),v.removeListener("error",we),v.removeListener("unpipe",le),z.removeListener("end",De),z.removeListener("end",We),z.removeListener("data",ye),Fe=!0,ee.awaitDrain&&(!v._writableState||v._writableState.needDrain)&&H()}z.on("data",ye);function ye(Ge){u("ondata");var Le=v.write(Ge);u("dest.write",Le),Le===!1&&((ee.pipesCount===1&&ee.pipes===v||ee.pipesCount>1&&Q(ee.pipes,v)!==-1)&&!Fe&&(u("false write response, pause",ee.awaitDrain),ee.awaitDrain++),z.pause())}function we(Ge){u("onerror",Ge),We(),v.removeListener("error",we),e(v,"error")===0&&O(v,Ge)}R(v,"error",we);function je(){v.removeListener("finish",Ne),We()}v.once("close",je);function Ne(){u("onfinish"),v.removeListener("close",je),We()}v.once("finish",Ne);function We(){u("unpipe"),z.unpipe(v)}return v.emit("pipe",z),ee.flowing||(u("pipe resume"),z.resume()),v};function xe(v){return function(){var z=v._readableState;u("pipeOnDrain",z.awaitDrain),z.awaitDrain&&z.awaitDrain--,z.awaitDrain===0&&e(v,"data")&&(z.flowing=!0,D(v))}}W.prototype.unpipe=function(v){var w=this._readableState,z={hasUnpiped:!1};if(w.pipesCount===0)return this;if(w.pipesCount===1)return v&&v!==w.pipes?this:(v||(v=w.pipes),w.pipes=null,w.pipesCount=0,w.flowing=!1,v&&v.emit("unpipe",this,z),this);if(!v){var ee=w.pipes,ce=w.pipesCount;w.pipes=null,w.pipesCount=0,w.flowing=!1;for(var ie=0;ie<ce;ie++)ee[ie].emit("unpipe",this,{hasUnpiped:!1});return this}var le=Q(w.pipes,v);return le===-1?this:(w.pipes.splice(le,1),w.pipesCount-=1,w.pipesCount===1&&(w.pipes=w.pipes[0]),v.emit("unpipe",this,z),this)},W.prototype.on=function(v,w){var z=t.prototype.on.call(this,v,w),ee=this._readableState;return v==="data"?(ee.readableListening=this.listenerCount("readable")>0,ee.flowing!==!1&&this.resume()):v==="readable"&&!ee.endEmitted&&!ee.readableListening&&(ee.readableListening=ee.needReadable=!0,ee.flowing=!1,ee.emittedReadable=!1,u("on readable",ee.length,ee.reading),ee.length?ke(this):ee.reading||ae.nextTick(G,this)),z},W.prototype.addListener=W.prototype.on,W.prototype.removeListener=function(v,w){var z=t.prototype.removeListener.call(this,v,w);return v==="readable"&&ae.nextTick(j,this),z},W.prototype.removeAllListeners=function(v){var w=t.prototype.removeAllListeners.apply(this,arguments);return(v==="readable"||v===void 0)&&ae.nextTick(j,this),w};function j(v){var w=v._readableState;w.readableListening=v.listenerCount("readable")>0,w.resumeScheduled&&!w.paused?w.flowing=!0:v.listenerCount("data")>0&&v.resume()}function G(v){u("readable nexttick read 0"),v.read(0)}W.prototype.resume=function(){var v=this._readableState;return v.flowing||(u("resume"),v.flowing=!v.readableListening,J(this,v)),v.paused=!1,this};function J(v,w){w.resumeScheduled||(w.resumeScheduled=!0,ae.nextTick(ne,v,w))}function ne(v,w){u("resume",w.reading),w.reading||v.read(0),w.resumeScheduled=!1,v.emit("resume"),D(v),w.flowing&&!w.reading&&v.read(0)}W.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function D(v){var w=v._readableState;for(u("flow",w.flowing);w.flowing&&v.read()!==null;);}W.prototype.wrap=function(v){var w=this,z=this._readableState,ee=!1;v.on("end",function(){if(u("wrapped end"),z.decoder&&!z.ended){var le=z.decoder.end();le&&le.length&&w.push(le)}w.push(null)}),v.on("data",function(le){if(u("wrapped data"),z.decoder&&(le=z.decoder.write(le)),!(z.objectMode&&le==null)&&!(!z.objectMode&&(!le||!le.length))){var De=w.push(le);De||(ee=!0,v.pause())}});for(var ce in v)this[ce]===void 0&&typeof v[ce]=="function"&&(this[ce]=function(De){return function(){return v[De].apply(v,arguments)}}(ce));for(var ie=0;ie<S.length;ie++)v.on(S[ie],this.emit.bind(this,S[ie]));return this._read=function(le){u("wrapped _read",le),ee&&(ee=!1,v.resume())},this},typeof Symbol=="function"&&(W.prototype[Symbol.asyncIterator]=function(){return A===void 0&&(A=ps()),A(this)}),Object.defineProperty(W.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(W.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(W.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(w){this._readableState&&(this._readableState.flowing=w)}}),W._fromList=F,Object.defineProperty(W.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function F(v,w){if(w.length===0)return null;var z;return w.objectMode?z=w.buffer.shift():!v||v>=w.length?(w.decoder?z=w.buffer.join(""):w.buffer.length===1?z=w.buffer.first():z=w.buffer.concat(w.length),w.buffer.clear()):z=w.buffer.consume(v,w.decoder),z}function V(v){var w=v._readableState;u("endReadable",w.endEmitted),w.endEmitted||(w.ended=!0,ae.nextTick(Z,w,v))}function Z(v,w){if(u("endReadableNT",v.endEmitted,v.length),!v.endEmitted&&v.length===0&&(v.endEmitted=!0,w.readable=!1,w.emit("end"),v.autoDestroy)){var z=w._writableState;(!z||z.autoDestroy&&z.finished)&&w.destroy()}}typeof Symbol=="function"&&(W.from=function(v,w){return T===void 0&&(T=gs()),T(W,v,w)});function Q(v,w){for(var z=0,ee=v.length;z<ee;z++)if(v[z]===w)return z;return-1}return hn}var dn,Ao;function Io(){if(Ao)return dn;Ao=1,dn=f;var r=ft().codes,e=r.ERR_METHOD_NOT_IMPLEMENTED,t=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,c=r.ERR_TRANSFORM_WITH_LENGTH_0,l=ht();ut()(f,l);function g(h,B){var I=this._transformState;I.transforming=!1;var $=I.writecb;if($===null)return this.emit("error",new t);I.writechunk=null,I.writecb=null,B!=null&&this.push(B),$(h);var b=this._readableState;b.reading=!1,(b.needReadable||b.length<b.highWaterMark)&&this._read(b.highWaterMark)}function f(h){if(!(this instanceof f))return new f(h);l.call(this,h),this._transformState={afterTransform:g.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,h&&(typeof h.transform=="function"&&(this._transform=h.transform),typeof h.flush=="function"&&(this._flush=h.flush)),this.on("prefinish",u)}function u(){var h=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(B,I){m(h,B,I)}):m(this,null,null)}f.prototype.push=function(h,B){return this._transformState.needTransform=!1,l.prototype.push.call(this,h,B)},f.prototype._transform=function(h,B,I){I(new e("_transform()"))},f.prototype._write=function(h,B,I){var $=this._transformState;if($.writecb=I,$.writechunk=h,$.writeencoding=B,!$.transforming){var b=this._readableState;($.needTransform||b.needReadable||b.length<b.highWaterMark)&&this._read(b.highWaterMark)}},f.prototype._read=function(h){var B=this._transformState;B.writechunk!==null&&!B.transforming?(B.transforming=!0,this._transform(B.writechunk,B.writeencoding,B.afterTransform)):B.needTransform=!0},f.prototype._destroy=function(h,B){l.prototype._destroy.call(this,h,function(I){B(I)})};function m(h,B,I){if(B)return h.emit("error",B);if(I!=null&&h.push(I),h._writableState.length)throw new c;if(h._transformState.transforming)throw new s;return h.push(null)}return dn}var pn,Bo;function ys(){if(Bo)return pn;Bo=1,pn=e;var r=Io();ut()(e,r);function e(t){if(!(this instanceof e))return new e(t);r.call(this,t)}return e.prototype._transform=function(t,s,c){c(null,t)},pn}var gn,ko;function ms(){if(ko)return gn;ko=1;var r;function e(I){var $=!1;return function(){$||($=!0,I.apply(void 0,arguments))}}var t=ft().codes,s=t.ERR_MISSING_ARGS,c=t.ERR_STREAM_DESTROYED;function l(I){if(I)throw I}function g(I){return I.setHeader&&typeof I.abort=="function"}function f(I,$,b,k){k=e(k);var P=!1;I.on("close",function(){P=!0}),r===void 0&&(r=cn()),r(I,{readable:$,writable:b},function(C){if(C)return k(C);P=!0,k()});var y=!1;return function(C){if(!P&&!y){if(y=!0,g(I))return I.abort();if(typeof I.destroy=="function")return I.destroy();k(C||new c("pipe"))}}}function u(I){I()}function m(I,$){return I.pipe($)}function h(I){return!I.length||typeof I[I.length-1]!="function"?l:I.pop()}function B(){for(var I=arguments.length,$=new Array(I),b=0;b<I;b++)$[b]=arguments[b];var k=h($);if(Array.isArray($[0])&&($=$[0]),$.length<2)throw new s("streams");var P,y=$.map(function(C,A){var T=A<$.length-1,O=A>0;return f(C,T,O,function(S){P||(P=S),S&&y.forEach(u),!T&&(y.forEach(u),k(P))})});return $.reduce(m)}return gn=B,gn}var Oo;function vs(){return Oo||(Oo=1,function(r,e){e=r.exports=To(),e.Stream=e,e.Readable=e,e.Writable=wo(),e.Duplex=ht(),e.Transform=Io(),e.PassThrough=ys(),e.finished=cn(),e.pipeline=ms()}(At,At.exports)),At.exports}var yn,Mo;function ws(){if(Mo)return yn;Mo=1;let r;return yn=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window!="undefined"?window:globalThis):e=>(r||(r=Promise.resolve())).then(e).catch(t=>setTimeout(()=>{throw t},0)),yn}var mn,Lo;function bs(){if(Lo)return mn;Lo=1;function r(t,s){for(const c in s)Object.defineProperty(t,c,{value:s[c],enumerable:!0,configurable:!0});return t}function e(t,s,c){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");c||(c={}),typeof s=="object"&&(c=s,s=""),s&&(c.code=s);try{return r(t,c)}catch(l){c.message=t.message,c.stack=t.stack;const g=function(){};return g.prototype=Object.create(Object.getPrototypeOf(t)),r(new g,c)}}return mn=e,mn}var vn,No;function Ss(){if(No)return vn;No=1;const r=Ia()("simple-peer"),e=Ba(),t=ka(),s=vs(),c=ws(),l=bs(),{Buffer:g}=mt(),f=64*1024,u=5*1e3,m=5*1e3;function h($){return $.replace(/a=ice-options:trickle\s\n/g,"")}function B($){console.warn($)}class I extends s.Duplex{constructor(b){if(b=Object.assign({allowHalfOpen:!1},b),super(b),this._id=t(4).toString("hex").slice(0,7),this._debug("new peer %o",b),this.channelName=b.initiator?b.channelName||t(20).toString("hex"):null,this.initiator=b.initiator||!1,this.channelConfig=b.channelConfig||I.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},I.config,b.config),this.offerOptions=b.offerOptions||{},this.answerOptions=b.answerOptions||{},this.sdpTransform=b.sdpTransform||(k=>k),this.streams=b.streams||(b.stream?[b.stream]:[]),this.trickle=b.trickle!==void 0?b.trickle:!0,this.allowHalfTrickle=b.allowHalfTrickle!==void 0?b.allowHalfTrickle:!1,this.iceCompleteTimeout=b.iceCompleteTimeout||u,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=b.wrtc&&typeof b.wrtc=="object"?b.wrtc:e(),!this._wrtc)throw l(typeof window=="undefined"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(k){this.destroy(l(k,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=k=>{this._onIceCandidate(k)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(k=>{this.destroy(l(k,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=k=>{this._setupData(k)},this.streams&&this.streams.forEach(k=>{this.addStream(k)}),this._pc.ontrack=k=>{this._onTrack(k)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(b){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof b=="string")try{b=JSON.parse(b)}catch(k){b={}}this._debug("signal()"),b.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),b.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(b.transceiverRequest.kind,b.transceiverRequest.init)),b.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(b.candidate):this._pendingCandidates.push(b.candidate)),b.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(b)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(k=>{this._addIceCandidate(k)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(k=>{this.destroy(l(k,"ERR_SET_REMOTE_DESCRIPTION"))}),!b.sdp&&!b.candidate&&!b.renegotiate&&!b.transceiverRequest&&this.destroy(l(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(b){const k=new this._wrtc.RTCIceCandidate(b);this._pc.addIceCandidate(k).catch(P=>{!k.address||k.address.endsWith(".local")?B("Ignoring unsupported ICE candidate."):this.destroy(l(P,"ERR_ADD_ICE_CANDIDATE"))})}send(b){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(b)}}addTransceiver(b,k){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(b,k),this._needsNegotiation()}catch(P){this.destroy(l(P,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:b,init:k}})}}addStream(b){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),b.getTracks().forEach(k=>{this.addTrack(k,b)})}}addTrack(b,k){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const P=this._senderMap.get(b)||new Map;let y=P.get(k);if(!y)y=this._pc.addTrack(b,k),P.set(k,y),this._senderMap.set(b,P),this._needsNegotiation();else throw y.removed?l(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):l(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(b,k,P){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const y=this._senderMap.get(b),C=y?y.get(P):null;if(!C)throw l(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");k&&this._senderMap.set(k,y),C.replaceTrack!=null?C.replaceTrack(k):this.destroy(l(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(b,k){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const P=this._senderMap.get(b),y=P?P.get(k):null;if(!y)throw l(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{y.removed=!0,this._pc.removeTrack(y)}catch(C){C.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(y):this.destroy(l(C,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(b){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),b.getTracks().forEach(k=>{this.removeTrack(k,b)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,c(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(b){this._destroy(b,()=>{})}_destroy(b,k){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",b&&(b.message||b)),c(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",b&&(b.message||b)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(P){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(P){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,b&&this.emit("error",b),this.emit("close"),k()}))}_setupData(b){if(!b.channel)return this.destroy(l(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=b.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=f),this.channelName=this._channel.label,this._channel.onmessage=P=>{this._onChannelMessage(P)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=P=>{const y=P.error instanceof Error?P.error:new Error(`Datachannel error: ${P.message} ${P.filename}:${P.lineno}:${P.colno}`);this.destroy(l(y,"ERR_DATA_CHANNEL"))};let k=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(k&&this._onChannelClose(),k=!0):k=!1},m)}_read(){}_write(b,k,P){if(this.destroyed)return P(l(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(b)}catch(y){return this.destroy(l(y,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>f?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=P):P(null)}else this._debug("write before connect"),this._chunk=b,this._cb=P}_onFinish(){if(this.destroyed)return;const b=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?b():this.once("connect",b)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(b=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(b.sdp=h(b.sdp)),b.sdp=this.sdpTransform(b.sdp);const k=()=>{if(this.destroyed)return;const C=this._pc.localDescription||b;this._debug("signal"),this.emit("signal",{type:C.type,sdp:C.sdp})},P=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?k():this.once("_iceComplete",k))},y=C=>{this.destroy(l(C,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(b).then(P).catch(y)}).catch(b=>{this.destroy(l(b,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(b=>{!b.mid&&b.sender.track&&!b.requested&&(b.requested=!0,this.addTransceiver(b.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(b=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(b.sdp=h(b.sdp)),b.sdp=this.sdpTransform(b.sdp);const k=()=>{if(this.destroyed)return;const C=this._pc.localDescription||b;this._debug("signal"),this.emit("signal",{type:C.type,sdp:C.sdp}),this.initiator||this._requestMissingTransceivers()},P=()=>{this.destroyed||(this.trickle||this._iceComplete?k():this.once("_iceComplete",k))},y=C=>{this.destroy(l(C,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(b).then(P).catch(y)}).catch(b=>{this.destroy(l(b,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(l(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const b=this._pc.iceConnectionState,k=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",b,k),this.emit("iceStateChange",b,k),(b==="connected"||b==="completed")&&(this._pcReady=!0,this._maybeReady()),b==="failed"&&this.destroy(l(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),b==="closed"&&this.destroy(l(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(b){const k=P=>(Object.prototype.toString.call(P.values)==="[object Array]"&&P.values.forEach(y=>{Object.assign(P,y)}),P);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(P=>{const y=[];P.forEach(C=>{y.push(k(C))}),b(null,y)},P=>b(P)):this._pc.getStats.length>0?this._pc.getStats(P=>{if(this.destroyed)return;const y=[];P.result().forEach(C=>{const A={};C.names().forEach(T=>{A[T]=C.stat(T)}),A.id=C.id,A.type=C.type,A.timestamp=C.timestamp,y.push(k(A))}),b(null,y)},P=>b(P)):b(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const b=()=>{this.destroyed||this.getStats((k,P)=>{if(this.destroyed)return;k&&(P=[]);const y={},C={},A={};let T=!1;P.forEach(S=>{(S.type==="remotecandidate"||S.type==="remote-candidate")&&(y[S.id]=S),(S.type==="localcandidate"||S.type==="local-candidate")&&(C[S.id]=S),(S.type==="candidatepair"||S.type==="candidate-pair")&&(A[S.id]=S)});const O=S=>{T=!0;let R=C[S.localCandidateId];R&&(R.ip||R.address)?(this.localAddress=R.ip||R.address,this.localPort=Number(R.port)):R&&R.ipAddress?(this.localAddress=R.ipAddress,this.localPort=Number(R.portNumber)):typeof S.googLocalAddress=="string"&&(R=S.googLocalAddress.split(":"),this.localAddress=R[0],this.localPort=Number(R[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let L=y[S.remoteCandidateId];L&&(L.ip||L.address)?(this.remoteAddress=L.ip||L.address,this.remotePort=Number(L.port)):L&&L.ipAddress?(this.remoteAddress=L.ipAddress,this.remotePort=Number(L.portNumber)):typeof S.googRemoteAddress=="string"&&(L=S.googRemoteAddress.split(":"),this.remoteAddress=L[0],this.remotePort=Number(L[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(P.forEach(S=>{S.type==="transport"&&S.selectedCandidatePairId&&O(A[S.selectedCandidatePairId]),(S.type==="googCandidatePair"&&S.googActiveConnection==="true"||(S.type==="candidatepair"||S.type==="candidate-pair")&&S.selected)&&O(S)}),!T&&(!Object.keys(A).length||Object.keys(C).length)){setTimeout(b,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(R){return this.destroy(l(R,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const S=this._cb;this._cb=null,S(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};b()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>f||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(b=>{this._pc.removeTrack(b),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(b){this.destroyed||(b.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:b.candidate.candidate,sdpMLineIndex:b.candidate.sdpMLineIndex,sdpMid:b.candidate.sdpMid}}):!b.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),b.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(b){if(this.destroyed)return;let k=b.data;k instanceof ArrayBuffer&&(k=g.from(k)),this.push(k)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const b=this._cb;this._cb=null,b(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(b){this.destroyed||b.streams.forEach(k=>{this._debug("on track"),this.emit("track",b.track,k),this._remoteTracks.push({track:b.track,stream:k}),!this._remoteStreams.some(P=>P.id===k.id)&&(this._remoteStreams.push(k),c(()=>{this._debug("on stream"),this.emit("stream",k)}))})}_debug(){const b=[].slice.call(arguments);b[0]="["+this._id+"] "+b[0],r.apply(null,b)}}return I.WEBRTC_SUPPORT=!!e(),I.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},I.channelConfig={},vn=I,vn}var _s=Ss();const Es=$t(_s);var Cs=Object.defineProperty,Rs=(r,e,t)=>e in r?Cs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,at=(r,e,t)=>Rs(r,typeof e!="symbol"?e+"":e,t),wn=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class Do{constructor(e,t,s={}){at(this,"peer",null),at(this,"config"),at(this,"events"),at(this,"connectionState","new"),at(this,"isInitiator"),at(this,"remoteUserId"),at(this,"localStream",null),this.remoteUserId=e,this.config=t,this.events=s,this.isInitiator=t.initiator||!1}createConnection(e){return wn(this,null,function*(){try{console.log(`[CallPeerConnection] Creating connection to ${this.remoteUserId}, initiator: ${this.isInitiator}`),this.localStream=e||null;const t={initiator:this.isInitiator,trickle:!0,stream:this.localStream||void 0,config:{iceServers:this.config.iceServers}};this.peer=new Es(t),this.setupPeerEventListeners(),console.log(`[CallPeerConnection] Peer connection created for ${this.remoteUserId}`)}catch(t){throw console.error(`[CallPeerConnection] Failed to create connection to ${this.remoteUserId}:`,t),t}})}signal(e){var t,s;if(!this.peer){console.error(`[CallPeerConnection] Cannot signal to ${this.remoteUserId}: peer not initialized`);return}try{console.log(`[CallPeerConnection] Signaling to ${this.remoteUserId}:`,e.type),this.peer.signal(e)}catch(c){console.error(`[CallPeerConnection] Failed to signal to ${this.remoteUserId}:`,c),(s=(t=this.events).onError)==null||s.call(t,c)}}addStream(e){var t,s;if(!this.peer){console.error(`[CallPeerConnection] Cannot add stream to ${this.remoteUserId}: peer not initialized`);return}try{this.localStream&&this.removeStream(this.localStream),this.localStream=e,this.peer.addStream(e),console.log(`[CallPeerConnection] Stream added to ${this.remoteUserId}`)}catch(c){console.error(`[CallPeerConnection] Failed to add stream to ${this.remoteUserId}:`,c),(s=(t=this.events).onError)==null||s.call(t,c)}}removeStream(e){var t,s;if(!this.peer){console.error(`[CallPeerConnection] Cannot remove stream from ${this.remoteUserId}: peer not initialized`);return}try{this.peer.removeStream(e),this.localStream===e&&(this.localStream=null),console.log(`[CallPeerConnection] Stream removed from ${this.remoteUserId}`)}catch(c){console.error(`[CallPeerConnection] Failed to remove stream from ${this.remoteUserId}:`,c),(s=(t=this.events).onError)==null||s.call(t,c)}}replaceTrack(e,t){var s,c;if(!this.peer){console.error(`[CallPeerConnection] Cannot replace track for ${this.remoteUserId}: peer not initialized`);return}if(!this.localStream){console.error(`[CallPeerConnection] Cannot replace track for ${this.remoteUserId}: no local stream`);return}if(e.kind!==t.kind){console.error(`[CallPeerConnection] Cannot replace track for ${this.remoteUserId}: track kinds don't match (${e.kind} vs ${t.kind})`);return}const g=this.localStream.getTracks().some(f=>f.id===e.id);g||console.warn(`[CallPeerConnection] Old track not found in local stream for ${this.remoteUserId}, attempting replacement anyway`);try{this.peer.replaceTrack(e,t,this.localStream),g&&this.localStream.removeTrack(e),this.localStream.addTrack(t),console.log(`[CallPeerConnection] ${t.kind} track replaced for ${this.remoteUserId} (${e.id} -> ${t.id})`)}catch(f){throw console.error(`[CallPeerConnection] Failed to replace track for ${this.remoteUserId}:`,f),(c=(s=this.events).onError)==null||c.call(s,f),f}}getVideoTrack(){if(!this.localStream)return null;const e=this.localStream.getVideoTracks();return e.length>0?e[0]:null}getAudioTrack(){if(!this.localStream)return null;const e=this.localStream.getAudioTracks();return e.length>0?e[0]:null}sendData(e){var t,s;if(!this.peer){console.error(`[CallPeerConnection] Cannot send data to ${this.remoteUserId}: peer not initialized`);return}if(!this.peer.connected){console.warn(`[CallPeerConnection] Cannot send data to ${this.remoteUserId}: not connected`);return}try{this.peer.send(JSON.stringify(e))}catch(c){console.error(`[CallPeerConnection] Failed to send data to ${this.remoteUserId}:`,c),(s=(t=this.events).onError)==null||s.call(t,c)}}setBandwidthLimit(e){return wn(this,null,function*(){if(!this.peer){console.warn(`[CallPeerConnection] Cannot set bandwidth for ${this.remoteUserId}: peer connection not available`);return}try{const t=this.peer._pc;if(!t)return;const s=t.getSenders();for(const c of s)if(c.track){const l=c.getParameters();l.encodings||(l.encodings=[{}]),l.encodings[0].maxBitrate=e*1e3,yield c.setParameters(l)}console.log(`[CallPeerConnection] Bandwidth limit set to ${e}kbps for ${this.remoteUserId}`)}catch(t){console.error(`[CallPeerConnection] Failed to set bandwidth limit for ${this.remoteUserId}:`,t)}})}getConnectionState(){return this.connectionState}isConnected(){var e;return((e=this.peer)==null?void 0:e.connected)===!0}getStats(){return wn(this,null,function*(){if(!this.peer)return null;try{const e=this.peer._pc;return e?yield e.getStats():null}catch(e){return console.error(`[CallPeerConnection] Failed to get stats for ${this.remoteUserId}:`,e),null}})}getRemoteUserId(){return this.remoteUserId}destroy(){if(console.log(`[CallPeerConnection] Destroying connection to ${this.remoteUserId}`),this.peer){try{this.peer.destroy()}catch(e){console.error(`[CallPeerConnection] Error destroying peer for ${this.remoteUserId}:`,e)}this.peer=null}this.localStream=null,this.connectionState="closed"}isExpectedDisconnectionError(e){const t=e.message||"",s=e.name||"";return["User-Initiated Abort","Close called","Connection closed","Connection failed","Peer connection closed","Peer is destroyed","cannot signal after peer is destroyed","cannot close after peer is destroyed"].some(l=>t.includes(l)||s.includes("OperationError")||s.includes("InvalidStateError"))}setupPeerEventListeners(){if(!this.peer)return;this.peer.on("signal",t=>{var s,c;console.log(`[CallPeerConnection] Signal from ${this.remoteUserId}:`,t.type),(c=(s=this.events).onSignal)==null||c.call(s,t)}),this.peer.on("connect",()=>{var t,s;console.log(`[CallPeerConnection] Connected to ${this.remoteUserId}`),this.connectionState="connected",(s=(t=this.events).onConnect)==null||s.call(t)}),this.peer.on("data",t=>{var s,c;try{const l=JSON.parse(t.toString());(c=(s=this.events).onData)==null||c.call(s,l)}catch(l){console.error(`[CallPeerConnection] Failed to parse data from ${this.remoteUserId}:`,l)}}),this.peer.on("stream",t=>{var s,c;console.log(`[CallPeerConnection] Stream received from ${this.remoteUserId}`),(c=(s=this.events).onStream)==null||c.call(s,t)}),this.peer.on("track",(t,s)=>{var c,l;console.log(`[CallPeerConnection] Track received from ${this.remoteUserId}:`,t.kind),(l=(c=this.events).onTrack)==null||l.call(c,t,s)}),this.peer.on("close",()=>{var t,s;console.log(`[CallPeerConnection] Connection closed with ${this.remoteUserId}`),this.connectionState="closed",(s=(t=this.events).onClose)==null||s.call(t)}),this.peer.on("error",t=>{var s,c,l,g;if(this.isExpectedDisconnectionError(t)){console.log(`[CallPeerConnection] Expected disconnection for ${this.remoteUserId}:`,t.message),this.connectionState="closed",(c=(s=this.events).onClose)==null||c.call(s);return}console.error(`[CallPeerConnection] Unexpected error with ${this.remoteUserId}:`,t),this.connectionState="failed",(g=(l=this.events).onError)==null||g.call(l,t)});const e=this.peer._pc;e&&e.addEventListener("connectionstatechange",()=>{if(this.peer){const t=this.peer._pc;t&&(this.connectionState=t.connectionState,console.log(`[CallPeerConnection] Connection state changed for ${this.remoteUserId}:`,this.connectionState))}})}getConnectionInfo(){return{remoteUserId:this.remoteUserId,isInitiator:this.isInitiator,connectionState:this.connectionState,connected:this.isConnected(),hasLocalStream:!!this.localStream,localStreamTracks:this.localStream?{video:this.localStream.getVideoTracks().length,audio:this.localStream.getAudioTracks().length}:null}}}const Fo={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},St=new Map,Mt=r=>{const e=St.get(r);return e?Object.fromEntries(Object.entries(e.stores).map(([t,s])=>[t,s.getState()])):{}},Ps=(r,e,t)=>{if(r===void 0)return{type:"untracked",connection:e.connect(t)};const s=St.get(t.name);if(s)return ze({type:"tracked",store:r},s);const c={connection:e.connect(t),stores:{}};return St.set(t.name,c),ze({type:"tracked",store:r},c)},Ts=(r,e)=>{if(e===void 0)return;const t=St.get(r);t&&(delete t.stores[e],Object.keys(t.stores).length===0&&St.delete(r))},As=r=>{var e,t;if(!r)return;const s=r.split(`
|
|
12
|
+
`),c=s.findIndex(g=>g.includes("api.setState"));if(c<0)return;const l=((e=s[c+1])==null?void 0:e.trim())||"";return(t=/.+ (.+) .+/.exec(l))==null?void 0:t[1]},Uo=(r,e={})=>(t,s,c)=>{const k=e,{enabled:l,anonymousActionType:g,store:f}=k,u=Mn(k,["enabled","anonymousActionType","store"]);let m;try{m=(l!=null?l:(Fo?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(y){}if(!m)return r(t,s,c);const P=Ps(f,m,u),{connection:h}=P,B=Mn(P,["connection"]);let I=!0;c.setState=(y,C,A)=>{const T=t(y,C);if(!I)return T;const O=A===void 0?{type:g||As(new Error().stack)||"anonymous"}:typeof A=="string"?{type:A}:A;return f===void 0?(h==null||h.send(O,s()),T):(h==null||h.send(On(ze({},O),{type:`${f}/${O.type}`}),On(ze({},Mt(u.name)),{[f]:c.getState()})),T)},c.devtools={cleanup:()=>{h&&typeof h.unsubscribe=="function"&&h.unsubscribe(),Ts(u.name,f)}};const $=(...y)=>{const C=I;I=!1,t(...y),I=C},b=r(c.setState,s,c);if(B.type==="untracked"?h==null||h.init(b):(B.stores[B.store]=c,h==null||h.init(Object.fromEntries(Object.entries(B.stores).map(([y,C])=>[y,y===B.store?b:C.getState()])))),c.dispatchFromDevtools&&typeof c.dispatch=="function"){let y=!1;const C=c.dispatch;c.dispatch=(...A)=>{(Fo?"production":void 0)!=="production"&&A[0].type==="__setState"&&!y&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),y=!0),C(...A)}}return h.subscribe(y=>{var C;switch(y.type){case"ACTION":if(typeof y.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return bn(y.payload,A=>{if(A.type==="__setState"){if(f===void 0){$(A.state);return}Object.keys(A.state).length!==1&&console.error(`
|
|
13
13
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
14
14
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
15
15
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
16
|
-
`);const T=A.state[f];if(T==null)return;JSON.stringify(c.getState())!==JSON.stringify(T)&&V(T);return}c.dispatchFromDevtools&&typeof c.dispatch=="function"&&c.dispatch(A)});case"DISPATCH":switch(y.payload.type){case"RESET":return V(b),f===void 0?h==null?void 0:h.init(c.getState()):h==null?void 0:h.init(Lt(u.name));case"COMMIT":if(f===void 0){h==null||h.init(c.getState());return}return h==null?void 0:h.init(Lt(u.name));case"ROLLBACK":return En(y.state,A=>{if(f===void 0){V(A),h==null||h.init(c.getState());return}V(A[f]),h==null||h.init(Lt(u.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return En(y.state,A=>{if(f===void 0){V(A);return}JSON.stringify(c.getState())!==JSON.stringify(A[f])&&V(A[f])});case"IMPORT_STATE":{const{nextLiftedState:A}=y.payload,T=(C=A.computedStates.slice(-1)[0])==null?void 0:C.state;if(!T)return;V(f===void 0?T:T[f]),h==null||h.send(null,A);return}case"PAUSE_RECORDING":return I=!I}return}}),b},En=(r,e)=>{let t;try{t=JSON.parse(r)}catch(s){console.error("[zustand devtools middleware] Could not parse the received json",s)}t!==void 0&&e(t)};function Ms(r,e){let t;try{t=r()}catch(c){return}return{getItem:c=>{var l;const g=u=>u===null?null:JSON.parse(u,void 0),f=(l=t.getItem(c))!=null?l:null;return f instanceof Promise?f.then(g):g(f)},setItem:(c,l)=>t.setItem(c,JSON.stringify(l,void 0)),removeItem:c=>t.removeItem(c)}}const Cn=r=>e=>{try{const t=r(e);return t instanceof Promise?t:{then(s){return Cn(s)(t)},catch(s){return this}}}catch(t){return{then(s){return this},catch(s){return Cn(s)(t)}}}},Ns=(r,e)=>(t,s,c)=>{let l=ze({storage:Ms(()=>localStorage),partialize:B=>B,version:0,merge:(B,P)=>ze(ze({},P),B)},e),g=!1;const f=new Set,u=new Set;let m=l.storage;if(!m)return r((...B)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),t(...B)},s,c);const h=()=>{const B=l.partialize(ze({},s()));return m.setItem(l.name,{state:B,version:l.version})},k=c.setState;c.setState=(B,P)=>{k(B,P),h()};const I=r((...B)=>{t(...B),h()},s,c);c.getInitialState=()=>I;let V;const b=()=>{var B,P;if(!m)return;g=!1,f.forEach(C=>{var A;return C((A=s())!=null?A:I)});const y=((P=l.onRehydrateStorage)==null?void 0:P.call(l,(B=s())!=null?B:I))||void 0;return Cn(m.getItem.bind(m))(l.name).then(C=>{if(C)if(typeof C.version=="number"&&C.version!==l.version){if(l.migrate){const A=l.migrate(C.state,C.version);return A instanceof Promise?A.then(T=>[!0,T]):[!0,A]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,C.state];return[!1,void 0]}).then(C=>{var A;const[T,O]=C;if(V=l.merge(O,(A=s())!=null?A:I),t(V,!0),T)return h()}).then(()=>{y==null||y(V,void 0),V=s(),g=!0,u.forEach(C=>C(V))}).catch(C=>{y==null||y(void 0,C)})};return c.persist={setOptions:B=>{l=ze(ze({},l),B),B.storage&&(m=B.storage)},clearStorage:()=>{m==null||m.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>b(),hasHydrated:()=>g,onHydrate:B=>(f.add(B),()=>{f.delete(B)}),onFinishHydration:B=>(u.add(B),()=>{u.delete(B)})},l.skipHydration||b(),V||I};var Ls=Object.defineProperty,$o=Object.getOwnPropertySymbols,Ds=Object.prototype.hasOwnProperty,Fs=Object.prototype.propertyIsEnumerable,Wo=(r,e,t)=>e in r?Ls(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Vo=(r,e)=>{for(var t in e||(e={}))Ds.call(e,t)&&Wo(r,t,e[t]);if($o)for(var t of $o(e))Fs.call(e,t)&&Wo(r,t,e[t]);return r};const Go={socketUrl:"ws://localhost:5000",roomId:"",userId:"",token:"",apiUrl:"http://127.0.0.1:5000",iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]},Us=ke.create()(qo(Ns(r=>({config:Go,setConfig:e=>r(t=>({config:Vo(Vo({},t.config),e)}),!1,"setConfig"),resetConfig:()=>r({config:Go},!1,"resetConfig")}),{name:"peers-caller-tester-store"}),{name:"peers-caller-tester",enabled:le.env.NODE_ENV==="development"}));var js=Object.defineProperty,xs=Object.defineProperties,qs=Object.getOwnPropertyDescriptors,Dt=Object.getOwnPropertySymbols,zo=Object.prototype.hasOwnProperty,Ho=Object.prototype.propertyIsEnumerable,Yo=(r,e,t)=>e in r?js(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,dt=(r,e)=>{for(var t in e||(e={}))zo.call(e,t)&&Yo(r,t,e[t]);if(Dt)for(var t of Dt(e))Ho.call(e,t)&&Yo(r,t,e[t]);return r},Rn=(r,e)=>xs(r,qs(e)),$s=r=>typeof r=="symbol"?r:r+"",Ws=(r,e)=>{var t={};for(var s in r)zo.call(r,s)&&e.indexOf(s)<0&&(t[s]=r[s]);if(r!=null&&Dt)for(var s of Dt(r))e.indexOf(s)<0&&Ho.call(r,s)&&(t[s]=r[s]);return t};const Jo={roomId:"",participants:{},localParticipant:null,isCalling:!1,isRecording:!1,recordLoading:!1,callStatus:"idle",error:null,callStatusInfo:null,callStatusLoading:!1,callStatusError:null},qe=ke.create()(qo(r=>Rn(dt({},Jo),{setRoomId:e=>r({roomId:e},!1,"setRoomId"),setLocalParticipant:e=>r({localParticipant:e},!1,"setLocalParticipant"),addParticipant:e=>r(t=>({participants:Rn(dt({},t.participants),{[e.user.id]:e})}),!1,"addParticipant"),removeParticipant:e=>r(t=>{const s=t.participants,{[e]:c}=s;return{participants:Ws(s,[$s(e)])}},!1,"removeParticipant"),updateParticipant:(e,t)=>r(s=>s.participants[e]?{participants:Rn(dt({},s.participants),{[e]:dt(dt({},s.participants[e]),t)})}:s,!1,"updateParticipant"),clearParticipants:()=>r({participants:{}},!1,"clearParticipants"),setCallStatus:e=>r({callStatus:e},!1,"setCallStatus"),setIsCalling:e=>r({isCalling:e},!1,"setIsCalling"),setIsRecording:e=>r({isRecording:e},!1,"setIsRecording"),setRecordLoading:e=>r({recordLoading:e},!1,"setRecordLoading"),setError:(e,t)=>r({error:t||e},!1,"setError"),clearError:()=>r({error:null},!1,"clearError"),setCallStatusInfo:e=>r({callStatusInfo:e},!1,"setCallStatusInfo"),setCallStatusLoading:e=>r({callStatusLoading:e},!1,"setCallStatusLoading"),setCallStatusError:e=>r({callStatusError:e},!1,"setCallStatusError"),resetCall:()=>r(dt({},Jo),!1,"resetCall")}),{name:"peers-caller-store",enabled:le.env.NODE_ENV==="development"})),Vs=r=>r.participants,Ko=r=>Object.keys(r.participants).length,Gs=r=>r.localParticipant,zs=r=>r.callStatus,Hs=r=>r.callStatus==="connected",Ys=r=>r.error,Js=r=>r.callStatusInfo,Ks=r=>r.callStatusLoading,Xs=r=>r.callStatusError,Zs=r=>{var e;return((e=r.callStatusInfo)==null?void 0:e.canJoin)||!1},Qs=r=>{var e;return((e=r.callStatusInfo)==null?void 0:e.hasActiveCall)||!1},Xo=r=>qe.getState().participants[r],el=r=>{const e=Xo(r);return!!(e!=null&&e.stream)},tl=()=>{const r=qe.getState();return Object.values(r.participants)},rl=(r=4)=>Ko(qe.getState())<r;var nl=Object.defineProperty,il=(r,e,t)=>e in r?nl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ol=(r,e,t)=>il(r,e+"",t);class Zo{constructor(e){if(ol(this,"store"),e&&typeof e.getState=="function")this.store=e;else{const t=e;this.store={getState:()=>t}}}get state(){return this.store.getState()}}var al=Object.defineProperty,sl=Object.defineProperties,ll=Object.getOwnPropertyDescriptors,Qo=Object.getOwnPropertySymbols,cl=Object.prototype.hasOwnProperty,ul=Object.prototype.propertyIsEnumerable,Pn=(r,e,t)=>e in r?al(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Tn=(r,e)=>{for(var t in e||(e={}))cl.call(e,t)&&Pn(r,t,e[t]);if(Qo)for(var t of Qo(e))ul.call(e,t)&&Pn(r,t,e[t]);return r},fl=(r,e)=>sl(r,ll(e)),pt=(r,e,t)=>Pn(r,typeof e!="symbol"?e+"":e,t),Ft=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class An extends Zo{constructor(e,t={},s=!1){super(qe),pt(this,"user"),pt(this,"mediaStream",null),pt(this,"peerConnections",new Map),pt(this,"remoteStreams",new Map),pt(this,"isLocalParticipant",!1),pt(this,"callbacks"),this.user=e,this.callbacks=t,this.isLocalParticipant=s;const c={user:e,videoOn:!0,audioOn:!0,screenSharing:!1};this.isLocalParticipant&&this.state.setLocalParticipant(c),this.state.addParticipant(c)}initialize(e){return Ft(this,null,function*(){var t,s;try{console.log(`[CallParticipant] Initializing participant ${this.user.id}`),this.mediaStream=new Vn(e);const l={stream:yield this.mediaStream.initialize(),videoElement:this.mediaStream.createVideoElement()};this.updateState(l),console.log(`[CallParticipant] Participant ${this.user.id} initialized successfully`)}catch(c){throw console.error(`[CallParticipant] Failed to initialize participant ${this.user.id}:`,c),(s=(t=this.callbacks).onError)==null||s.call(t,c),c}})}createPeerConnection(e,t,s){return Ft(this,null,function*(){var c,l;try{console.log(`[CallParticipant] Creating peer connection from ${this.user.id} to ${e}`),this.peerConnections.has(e)&&(console.warn(`[CallParticipant] Peer connection to ${e} already exists, destroying before recreating`),this.destroyPeerConnection(e));const g={onSignal:u=>{var m,h;console.log(`[CallParticipant] Signal from ${this.user.id} to ${e}:`,u.type),(h=(m=this.callbacks).onSignal)==null||h.call(m,this.user.id,e,u)},onConnect:()=>{var u,m;console.log(`[CallParticipant] ${this.user.id} connected to ${e}`),(m=(u=this.callbacks).onPeerConnected)==null||m.call(u,e)},onStream:u=>{var m,h;console.log(`[CallParticipant] Stream received from ${e} by ${this.user.id}`),this.remoteStreams.set(e,u),this.state.updateParticipant(e,{stream:u}),(h=(m=this.callbacks).onStreamReceived)==null||h.call(m,e,u)},onClose:()=>{var u,m;console.log(`[CallParticipant] Connection closed between ${this.user.id} and ${e}`),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),(m=(u=this.callbacks).onPeerDisconnected)==null||m.call(u,e)},onError:u=>{var m,h;console.error(`[CallParticipant] Peer connection error between ${this.user.id} and ${e}:`,u),(h=(m=this.callbacks).onError)==null||h.call(m,u)}},f=new jo(e,fl(Tn({},t),{initiator:s}),g);yield f.createConnection(this.getCurrentStream()),this.peerConnections.set(e,f)}catch(g){throw console.error(`[CallParticipant] Failed to create peer connection from ${this.user.id} to ${e}:`,g),(l=(c=this.callbacks).onError)==null||l.call(c,g),g}})}getPeerConnection(e){return this.peerConnections.get(e)}signalToPeer(e,t){const s=this.peerConnections.get(e);s?s.signal(t):console.warn(`[CallParticipant] No peer connection found for ${e}`)}toggleAudio(e){this.mediaStream&&(this.mediaStream.toggleAudio(e),this.updateState({audioOn:e}))}toggleVideo(e){this.mediaStream&&(this.mediaStream.toggleVideo(e),this.updateState({videoOn:e}))}startScreenShare(){return Ft(this,null,function*(){var e,t;try{if(!this.mediaStream)throw new Error("Media stream not initialized");console.log(`[CallParticipant] Starting screen share for ${this.user.id}`);const s=yield this.mediaStream.startScreenShare(),c=this.mediaStream.getScreenVideoTrack(),l=this.mediaStream.getCameraVideoTrack();if(!c)throw new Error("Failed to get screen video track");for(const[g,f]of this.peerConnections)l?(f.replaceTrack(l,c),console.log(`[CallParticipant] Screen video track replaced for connection with ${g}`)):console.warn(`[CallParticipant] No camera video track to replace for ${g}`);this.updateState({screenSharing:!0,stream:s}),console.log(`[CallParticipant] Screen sharing started for ${this.user.id}`)}catch(s){throw console.error(`[CallParticipant] Failed to start screen share for ${this.user.id}:`,s),(t=(e=this.callbacks).onError)==null||t.call(e,s),s}})}stopScreenShare(){return Ft(this,null,function*(){var e,t;try{if(!this.mediaStream)throw new Error("Media stream not initialized");console.log(`[CallParticipant] Stopping screen share for ${this.user.id}`);const s=this.mediaStream.getScreenVideoTrack();console.log("[CallParticipant] Screen video track found:",!!s);const c=yield this.mediaStream.stopScreenShare(),l=this.mediaStream.getCameraVideoTrack();if(console.log("[CallParticipant] Camera stream:",!!c),console.log("[CallParticipant] Camera video track:",!!l),!l)throw new Error("Failed to get camera video track");for(const[g,f]of this.peerConnections)try{s&&l?(f.replaceTrack(s,l),console.log(`[CallParticipant] Camera video track restored for connection with ${g}`)):(console.log(`[CallParticipant] Updating entire stream for connection with ${g}`),f.addStream(c))}catch(u){console.warn(`[CallParticipant] Failed to replace track for ${g}, trying stream replacement:`,u)}if(this.updateState({screenSharing:!1,stream:c}),this.isLocalParticipant&&this.mediaStream){const g=this.mediaStream.getVideoElement();g&&(g.srcObject=c,console.log(`[CallParticipant] Updated local video element for ${this.user.id}`))}console.log(`[CallParticipant] Screen sharing stopped for ${this.user.id}`)}catch(s){throw console.error(`[CallParticipant] Failed to stop screen share for ${this.user.id}:`,s),(t=(e=this.callbacks).onError)==null||t.call(e,s),s}})}getState(){const e=this.state;return this.isLocalParticipant?e.localParticipant||{user:this.user,videoOn:!0,audioOn:!0,screenSharing:!1}:e.participants[this.user.id]||{user:this.user,videoOn:!0,audioOn:!0,screenSharing:!1}}getUserId(){return this.user.id}getUser(){return this.user}setUser(e){this.user=e,this.updateState({user:e}),console.log(`[CallParticipant] Updated user for participant ${e.id}:`,e)}getMediaStream(){return this.mediaStream}getCurrentStream(){return this.getState().stream}getVideoElement(){return this.getState().videoElement}getRemoteStream(e){return this.remoteStreams.get(e)}getAllRemoteStreams(){return new Map(this.remoteStreams)}getAllPeerConnections(){return new Map(this.peerConnections)}getConnectionStatus(){const e={};for(const[t,s]of this.peerConnections)e[t]=s.isConnected();return e}removePeerConnection(e){const t=this.peerConnections.get(e);t&&(t.destroy(),this.peerConnections.delete(e),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),console.log(`[CallParticipant] Removed peer connection from ${this.user.id} to ${e}`))}destroyPeerConnection(e){const t=this.peerConnections.get(e);t&&(console.log(`[CallParticipant] Destroying peer connection from ${this.user.id} to ${e}`),t.destroy(),this.peerConnections.delete(e),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}))}updateState(e){var t,s;const c=this.getState();if(Object.keys(e).some(g=>c[g]!==e[g])){const g=Tn(Tn({},c),e);this.isLocalParticipant&&this.state.setLocalParticipant(g),this.state.updateParticipant(this.user.id,e),(s=(t=this.callbacks).onStateChanged)==null||s.call(t,this.user,e)}}getDebugInfo(){var e;return{user:this.user,state:this.getState(),peerConnections:Array.from(this.peerConnections.keys()),remoteStreams:Array.from(this.remoteStreams.keys()),connectionStatus:this.getConnectionStatus(),mediaStreamInfo:(e=this.mediaStream)==null?void 0:e.getStreamInfo()}}cleanup(){console.log(`[CallParticipant] Cleaning up participant ${this.user.id}`),this.state.removeParticipant(this.user.id);for(const e of this.peerConnections.values())e.destroy();this.peerConnections.clear(),this.remoteStreams.clear(),this.mediaStream&&(this.mediaStream.cleanup(),this.mediaStream=null),console.log(`[CallParticipant] Participant ${this.user.id} cleanup completed`)}}var In={exports:{}},ea;function hl(){return ea||(ea=1,function(r){function e(t,s){var c="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";(function(S){typeof RecordRTC=="undefined"&&S&&typeof window=="undefined"&&typeof globalThis!="undefined"&&(globalThis.navigator={userAgent:c,getUserMedia:function(){}},globalThis.console||(globalThis.console={}),(typeof globalThis.console.log=="undefined"||typeof globalThis.console.error=="undefined")&&(globalThis.console.error=globalThis.console.log=globalThis.console.log||function(){console.log(arguments)}),typeof document=="undefined"&&(S.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var R={getContext:function(){return R},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return R},S.HTMLVideoElement=function(){}),typeof location=="undefined"&&(S.location={protocol:"file:",href:"",hash:""}),typeof screen=="undefined"&&(S.screen={width:0,height:0}),typeof k=="undefined"&&(S.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),S.window=globalThis)})(typeof globalThis!="undefined"?globalThis:null),s=s||"multi-streams-mixer";var l=[],g=!1,f=document.createElement("canvas"),u=f.getContext("2d");f.style.opacity=0,f.style.position="absolute",f.style.zIndex=-1,f.style.top="-1000em",f.style.left="-1000em",f.className=s,(document.body||document.documentElement).appendChild(f),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var m=this,h=window.AudioContext;typeof h=="undefined"&&(typeof webkitAudioContext!="undefined"&&(h=webkitAudioContext),typeof mozAudioContext!="undefined"&&(h=mozAudioContext));var k=window.URL;typeof k=="undefined"&&typeof webkitURL!="undefined"&&(k=webkitURL),typeof navigator!="undefined"&&typeof navigator.getUserMedia=="undefined"&&(typeof navigator.webkitGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.webkitGetUserMedia),typeof navigator.mozGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.mozGetUserMedia));var I=window.MediaStream;typeof I=="undefined"&&typeof webkitMediaStream!="undefined"&&(I=webkitMediaStream),typeof I!="undefined"&&typeof I.prototype.stop=="undefined"&&(I.prototype.stop=function(){this.getTracks().forEach(function(S){S.stop()})});var V={};typeof h!="undefined"?V.AudioContext=h:typeof webkitAudioContext!="undefined"&&(V.AudioContext=webkitAudioContext);function b(S,R){"srcObject"in R?R.srcObject=S:"mozSrcObject"in R?R.mozSrcObject=S:R.srcObject=S}this.startDrawingFrames=function(){B()};function B(){if(!g){var S=l.length,R=!1,M=[];if(l.forEach(function(Q){Q.stream||(Q.stream={}),Q.stream.fullcanvas?R=Q:M.push(Q)}),R)f.width=R.stream.width,f.height=R.stream.height;else if(M.length){f.width=S>1?M[0].width*2:M[0].width;var G=1;(S===3||S===4)&&(G=2),(S===5||S===6)&&(G=3),(S===7||S===8)&&(G=4),(S===9||S===10)&&(G=5),f.height=M[0].height*G}else f.width=m.width||360,f.height=m.height||240;R&&R instanceof HTMLVideoElement&&P(R),M.forEach(function(Q,ie){P(Q,ie)}),setTimeout(B,m.frameInterval)}}function P(S,R){if(!g){var M=0,G=0,Q=S.width,ie=S.height;R===1&&(M=S.width),R===2&&(G=S.height),R===3&&(M=S.width,G=S.height),R===4&&(G=S.height*2),R===5&&(M=S.width,G=S.height*2),R===6&&(G=S.height*3),R===7&&(M=S.width,G=S.height*3),typeof S.stream.left!="undefined"&&(M=S.stream.left),typeof S.stream.top!="undefined"&&(G=S.stream.top),typeof S.stream.width!="undefined"&&(Q=S.stream.width),typeof S.stream.height!="undefined"&&(ie=S.stream.height),u.drawImage(S,M,G,Q,ie),typeof S.stream.onRender=="function"&&S.stream.onRender(u,M,G,Q,ie,R)}}function y(){g=!1;var S=C(),R=A();return R&&R.getTracks().filter(function(M){return M.kind==="audio"}).forEach(function(M){S.addTrack(M)}),t.forEach(function(M){M.fullcanvas}),S}function C(){O();var S;"captureStream"in f?S=f.captureStream():"mozCaptureStream"in f?S=f.mozCaptureStream():m.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var R=new I;return S.getTracks().filter(function(M){return M.kind==="video"}).forEach(function(M){R.addTrack(M)}),f.stream=R,R}function A(){V.AudioContextConstructor||(V.AudioContextConstructor=new V.AudioContext),m.audioContext=V.AudioContextConstructor,m.audioSources=[],m.useGainNode===!0&&(m.gainNode=m.audioContext.createGain(),m.gainNode.connect(m.audioContext.destination),m.gainNode.gain.value=0);var S=0;if(t.forEach(function(R){if(R.getTracks().filter(function(G){return G.kind==="audio"}).length){S++;var M=m.audioContext.createMediaStreamSource(R);m.useGainNode===!0&&M.connect(m.gainNode),m.audioSources.push(M)}}),!!S)return m.audioDestination=m.audioContext.createMediaStreamDestination(),m.audioSources.forEach(function(R){R.connect(m.audioDestination)}),m.audioDestination.stream}function T(S){var R=document.createElement("video");return b(S,R),R.className=s,R.muted=!0,R.volume=0,R.width=S.width||m.width||360,R.height=S.height||m.height||240,R.play(),R}this.appendStreams=function(S){if(!S)throw"First parameter is required.";S instanceof Array||(S=[S]),S.forEach(function(R){var M=new I;if(R.getTracks().filter(function(ie){return ie.kind==="video"}).length){var G=T(R);G.stream=R,l.push(G),M.addTrack(R.getTracks().filter(function(ie){return ie.kind==="video"})[0])}if(R.getTracks().filter(function(ie){return ie.kind==="audio"}).length){var Q=m.audioContext.createMediaStreamSource(R);m.audioDestination=m.audioContext.createMediaStreamDestination(),Q.connect(m.audioDestination),M.addTrack(m.audioDestination.stream.getTracks().filter(function(ie){return ie.kind==="audio"})[0])}t.push(M)})},this.releaseStreams=function(){l=[],g=!0,m.gainNode&&(m.gainNode.disconnect(),m.gainNode=null),m.audioSources.length&&(m.audioSources.forEach(function(S){S.disconnect()}),m.audioSources=[]),m.audioDestination&&(m.audioDestination.disconnect(),m.audioDestination=null),m.audioContext&&m.audioContext.close(),m.audioContext=null,u.clearRect(0,0,f.width,f.height),f.stream&&(f.stream.stop(),f.stream=null)},this.resetVideoStreams=function(S){S&&!(S instanceof Array)&&(S=[S]),O(S)};function O(S){l=[],S=S||t,S.forEach(function(R){if(R.getTracks().filter(function(G){return G.kind==="video"}).length){var M=T(R);M.stream=R,l.push(M)}})}this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=y}typeof RecordRTC=="undefined"&&(r.exports=e)}(In)),In.exports}var dl=hl();const pl=Gt(dl);var gl=Kt();const yl=Gt(gl);class ml extends yl{constructor(t,s=navigator.language){super();He(this,"track",null);He(this,"trackId",null);He(this,"recognition",null);He(this,"recognizing",!1);He(this,"transcripts",[]);He(this,"startTime",0);He(this,"endTime",0);He(this,"currentStamp",0);He(this,"start",()=>(this.recognition.start(),this.recognition.stream=this.track,this.recognizing=!0,this.startTime=performance.now(),this));He(this,"stop",()=>(this.recognition.stop(),this.recognizing=!1,this.endTime=performance.now(),this));("webkitSpeechRecognition"in window||"SpeechRecognition"in window)&&(this.recognition=new(window.SpeechRecognition||window.webkitSpeechRecognition),this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.lang=s,this.track=t,this.recognition.onstart=this.emit("start"),this.recognition.onend=()=>this.emit("end"),this.recognition.onresult=c=>{const{results:l,resultIndex:g}=c;let f="";if(l[g].isFinal&&l[g][0].transcript){const u={sentence:l[g][0].transcript,confidence:l[g][0].confidence,timeStamp:this.currentStamp,endTimeStamp:new Date().getTime()};this.transcripts.push(u),this.emit("sentence",u)}else this.currentStamp=new Date().getTime(),f+=l[g][0].transcript,this.emit("interim",{sentence:f,timeStamp:this.currentStamp});this.emit("result",c)})}}var vl=Object.defineProperty,ta=Object.getOwnPropertySymbols,wl=Object.prototype.hasOwnProperty,bl=Object.prototype.propertyIsEnumerable,kn=(r,e,t)=>e in r?vl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Sl=(r,e)=>{for(var t in e||(e={}))wl.call(e,t)&&kn(r,t,e[t]);if(ta)for(var t of ta(e))bl.call(e,t)&&kn(r,t,e[t]);return r},gt=(r,e,t)=>kn(r,typeof e!="symbol"?e+"":e,t),Bn=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class ra{constructor(e={},t={}){gt(this,"mixer",null),gt(this,"recorder",null),gt(this,"localTranscriber",null),gt(this,"isRecording",!1),gt(this,"config"),gt(this,"callbacks"),this.config=Sl({mimeType:"video/webm;codecs=vp8,opus",videoBitsPerSecond:1e6,audioBitsPerSecond:128e3,interval:1e3},e),this.callbacks=t}startRecording(e,t){return Bn(this,null,function*(){var s,c,l,g;try{if(console.log("[CallRecorder] Starting recording with",e.length,"streams"),this.isRecording)throw new Error("Recording already in progress");if(!t)throw new Error("Recording data is required");this.mixer=new pl(e),this.mixer.frameInterval=1,this.mixer.startDrawingFrames();const f=e[0];f&&f.getAudioTracks().length>0&&(this.localTranscriber=new ml(f)),MediaRecorder.isTypeSupported(this.config.mimeType)||(console.warn("[CallRecorder] Preferred mime type not supported, falling back to default"),this.config.mimeType="video/webm");const u=this.mixer.getMixedStream();this.recorder=new MediaRecorder(u,{mimeType:this.config.mimeType,videoBitsPerSecond:this.config.videoBitsPerSecond,audioBitsPerSecond:this.config.audioBitsPerSecond}),this.setupRecorderEventHandlers(t),this.recorder.start(this.config.interval),this.isRecording=!0,this.localTranscriber&&this.localTranscriber.start(),(c=(s=this.callbacks).onRecordingStarted)==null||c.call(s,t),console.log("[CallRecorder] Recording started successfully")}catch(f){throw console.error("[CallRecorder] Failed to start recording:",f),(g=(l=this.callbacks).onError)==null||g.call(l,f),f}})}stopRecording(){return Bn(this,null,function*(){var e,t;try{if(console.log("[CallRecorder] Stopping recording"),!this.isRecording||!this.recorder){console.warn("[CallRecorder] No active recording to stop");return}this.recorder.stop(),this.isRecording=!1,this.localTranscriber&&this.localTranscriber.stop(),this.mixer&&this.mixer.releaseStreams(),console.log("[CallRecorder] Recording stopped successfully")}catch(s){console.error("[CallRecorder] Failed to stop recording:",s),(t=(e=this.callbacks).onError)==null||t.call(e,s)}})}resetVideoStreams(e){this.mixer&&(this.mixer.resetVideoStreams(e),console.log("[CallRecorder] Video streams reset"))}setupRecorderEventHandlers(e){this.recorder&&(this.recorder.ondataavailable=t=>{var s,c;t.data&&t.data.size>0&&((c=(s=this.callbacks).onRecordingChunk)==null||c.call(s,t.data,e))},this.recorder.onstart=()=>{console.log("[CallRecorder] MediaRecorder started")},this.recorder.onstop=()=>{var t,s;console.log("[CallRecorder] MediaRecorder stopped"),(s=(t=this.callbacks).onRecordingStopped)==null||s.call(t,e,this.getTranscripts())},this.recorder.onerror=t=>{var s,c;console.error("[CallRecorder] MediaRecorder error:",t),(c=(s=this.callbacks).onError)==null||c.call(s,new Error(`Recording error: ${t}`))})}getRecordingState(){var e,t;return{isRecording:this.isRecording,isTranscribing:this.localTranscriber!==null,transcriptCount:((t=(e=this.localTranscriber)==null?void 0:e.transcripts)==null?void 0:t.length)||0}}getTranscripts(){var e;return((e=this.localTranscriber)==null?void 0:e.transcripts)||[]}static isRecordingSupported(){return typeof MediaRecorder!="undefined"&&typeof MediaRecorder.isTypeSupported=="function"}static isTranscriptionSupported(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}static getSupportedMimeTypes(){return["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=h264,opus","video/webm","video/mp4;codecs=h264,aac","video/mp4"].filter(t=>MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported(t))}cleanup(){return Bn(this,null,function*(){console.log("[CallRecorder] Cleaning up recorder"),this.isRecording&&(yield this.stopRecording()),this.localTranscriber&&(this.localTranscriber.stop(),this.localTranscriber=null),this.mixer&&(this.mixer.releaseStreams(),this.mixer=null),this.recorder=null})}}var _l=Object.defineProperty,El=Object.defineProperties,Cl=Object.getOwnPropertyDescriptors,na=Object.getOwnPropertySymbols,Rl=Object.prototype.hasOwnProperty,Pl=Object.prototype.propertyIsEnumerable,On=(r,e,t)=>e in r?_l(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ia=(r,e)=>{for(var t in e||(e={}))Rl.call(e,t)&&On(r,t,e[t]);if(na)for(var t of na(e))Pl.call(e,t)&&On(r,t,e[t]);return r},oa=(r,e)=>El(r,Cl(e)),Ve=(r,e,t)=>On(r,typeof e!="symbol"?e+"":e,t),Ne=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class aa extends Zo{constructor(e,t={}){if(super(qe),Ve(this,"config"),Ve(this,"callbacks"),Ve(this,"socket"),Ve(this,"localParticipant",null),Ve(this,"participants",new Map),Ve(this,"recorder",null),Ve(this,"iceServers",[]),Ve(this,"isInitialized",!1),Ve(this,"listenersSetup",!1),Ve(this,"roomId"),Ve(this,"eventListeners",new Map),!e.user||!e.user.id)throw new Error("config.user with id must be provided");if(this.roomId=e.roomId,!this.roomId)throw new Error("roomId must be provided in config");this.config=oa(ia({maxParticipants:4,debug:!1,socketPath:"/apis/video-call",mediaConfig:{video:!0,audio:!0}},e),{roomId:this.roomId}),this.callbacks=t,this.socket=new Wn(this.config.socketUrl,this.config.token,this.config.socketPath),this.iceServers=this.config.iceServers||[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}],this.state.setRoomId(this.roomId),console.log("[PeersCaller] Initialized with config:",{roomId:this.roomId,user:this.config.user,tokenLength:this.config.token.length,maxParticipants:this.config.maxParticipants})}initialize(){return Ne(this,null,function*(){try{if(console.log("[PeersCaller] Initializing..."),this.isInitialized){console.warn("[PeersCaller] Already initialized");return}yield this.socket.connect(),yield this.fetchIceServers(),this.setupSocketListeners(),yield this.initializeLocalParticipant(),this.isInitialized=!0,this.state.setCallStatus("idle"),console.log("[PeersCaller] Initialization completed successfully (ready to start/join call)")}catch(e){throw console.error("[PeersCaller] Initialization failed:",e),this.handleError("NETWORK_ERROR",`Failed to initialize: ${e}`),e}})}startCall(){return Ne(this,arguments,function*(e=this.config.mediaConfig){var t,s;try{if(console.log("[PeersCaller] Starting call..."),this.isInitialized||(yield this.initialize()),yield this.initializeLocalParticipant(),this.localParticipant&&!this.localParticipant.getCurrentStream()){const l={video:e!=null&&e.video&&typeof e.video=="boolean"?e.video:!0,audio:e!=null&&e.audio&&typeof e.audio=="boolean"?e.audio:!0};yield this.localParticipant.initialize(l)}this.state.setIsCalling(!0),this.state.setCallStatus("connecting"),console.log("[PeersCaller] Starting call for room:",this.config.roomId);const c=yield this.socket.startCall(this.config.roomId);if(console.log("[PeersCaller] Received call.start response:",c),c.success){this.state.setCallStatus("connected"),c.user&&this.localParticipant&&this.localParticipant.setUser(c.user),c.participants.forEach(g=>{const f=typeof g=="string"?{id:g}:g;f.id!==this.config.user.id&&this.handleParticipantJoined(f)}),console.log("[PeersCaller] Call started successfully");const l=c.participants.map(g=>typeof g=="string"?{id:g}:g);(s=(t=this.callbacks).onCallStarted)==null||s.call(t,oa(ia({},c),{participants:l}))}else{this.state.setIsCalling(!1),this.state.setCallStatus("idle");const l="Failed to start call on server";throw this.handleError("SIGNALING_ERROR",l),console.error("[PeersCaller] Call start failed:",l),new Error(l)}}catch(c){throw console.error("[PeersCaller] Failed to start call:",c),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start call: ${c}`),c}})}joinCall(){return Ne(this,arguments,function*(e=this.config.mediaConfig){try{console.log("[PeersCaller] Joining call..."),this.isInitialized||(yield this.initialize()),yield this.initializeLocalParticipant();const t=yield this.checkCallStatus();if(!t.hasActiveCall)throw new Error("No active call found");if(!t.canJoin)throw new Error(`Cannot join call: ${t.status==="full"?"Call is full":"Unable to join"}`);if(this.state.setCallStatus("connecting"),this.localParticipant&&!this.localParticipant.getCurrentStream()){const c={video:typeof(e==null?void 0:e.video)=="boolean"?e.video:!0,audio:typeof(e==null?void 0:e.audio)=="boolean"?e.audio:!0};console.log("[PeersCaller] Initializing local media with config:",c),yield this.localParticipant.initialize(c)}console.log("[PeersCaller] Joining call for room:",this.config.roomId);const s=yield this.socket.joinRoom(this.config.roomId);console.log("[PeersCaller] Received call.join response:",s),this.state.setCallStatus("connected"),this.state.setIsCalling(!0),s.user&&this.localParticipant&&(this.localParticipant.setUser(s.user),console.log("[PeersCaller] Updated local participant user:",s.user)),s.participants.forEach(c=>{const l=typeof c=="string"?{id:c}:c;l.id!==this.config.user.id&&this.handleParticipantJoined(l)}),console.log("[PeersCaller] Joined call successfully")}catch(t){throw console.error("[PeersCaller] Failed to join call:",t),this.state.setCallStatus("idle"),this.handleError("INVALID_ROOM_ID",`Failed to join call: ${t}`),t}})}endCall(){return Ne(this,null,function*(){try{console.log("[PeersCaller] Ending call..."),this.recorder&&this.state.isRecording&&(yield this.stopRecording());try{yield this.socket.endCallForAll(this.config.roomId),console.log("[PeersCaller] End call request sent to server")}catch(e){console.warn("[PeersCaller] Failed to notify server of call end:",e)}this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),console.log("[PeersCaller] Call ended successfully")}catch(e){console.error("[PeersCaller] Error ending call:",e)}})}leaveCall(){return Ne(this,null,function*(){try{console.log("[PeersCaller] Leaving call..."),console.log("[PeersCaller] Leaving call for room:",this.config.roomId);const e=yield this.socket.leaveCall(this.config.roomId);if(console.log("[PeersCaller] Received call.leave response:",e),e.success)this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),console.log("[PeersCaller] Left call successfully");else{const t="Failed to leave call on server";throw this.handleError("SIGNALING_ERROR",t),console.error("[PeersCaller] Call leave failed:",t),new Error(t)}}catch(e){throw console.error("[PeersCaller] Failed to leave call:",e),this.handleError("SIGNALING_ERROR",`Failed to leave call: ${e}`),e}})}toggleAudio(e){this.localParticipant&&(this.localParticipant.toggleAudio(e),this.broadcastStateUpdate({audioOn:e}),console.log(`[PeersCaller] Audio ${e?"enabled":"disabled"}`))}toggleVideo(e){this.localParticipant&&(this.localParticipant.toggleVideo(e),this.broadcastStateUpdate({videoOn:e}),console.log(`[PeersCaller] Video ${e?"enabled":"disabled"}`))}startScreenShare(){return Ne(this,null,function*(){try{if(!this.localParticipant)throw new Error("Local participant not initialized");yield this.localParticipant.startScreenShare(),this.broadcastStateUpdate({screenSharing:!0}),console.log("[PeersCaller] Screen sharing started")}catch(e){throw console.error("[PeersCaller] Failed to start screen share:",e),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start screen share: ${e}`),e}})}stopScreenShare(){return Ne(this,null,function*(){try{if(!this.localParticipant)throw new Error("Local participant not initialized");yield this.localParticipant.stopScreenShare(),this.broadcastStateUpdate({screenSharing:!1}),console.log("[PeersCaller] Screen sharing stopped")}catch(e){throw console.error("[PeersCaller] Failed to stop screen share:",e),e}})}startRecording(e,t){return Ne(this,null,function*(){var s;try{if(console.log("[PeersCaller] Starting recording..."),this.state.isRecording){console.warn("[PeersCaller] Recording already in progress");return}const c=[],l=(s=this.localParticipant)==null?void 0:s.getCurrentStream();l&&c.push(l);for(const g of this.participants.values()){const f=g.getCurrentStream();f&&c.push(f)}if(c.length===0)throw new Error("No streams available for recording");this.recorder=new ra(t,{onRecordingStarted:g=>{this.socket.startRecording(this.config.roomId,g.id)},onRecordingChunk:(g,f)=>{this.socket.sendRecordingChunk(this.config.roomId,f.id,g)},onRecordingStopped:(g,f)=>{this.socket.endRecording(this.config.roomId,g.id,f)},onTranscriptReceived:g=>{this.socket.sendTranscript(this.config.roomId,g.text)},onError:g=>{this.handleError("RECORDING_FAILED",g.message)}}),yield this.recorder.startRecording(c,e),this.state.setIsRecording(!0),console.log("[PeersCaller] Recording started successfully")}catch(c){throw console.error("[PeersCaller] Failed to start recording:",c),this.handleError("RECORDING_FAILED",`Failed to start recording: ${c}`),c}})}stopRecording(){return Ne(this,null,function*(){try{if(console.log("[PeersCaller] Stopping recording..."),!this.recorder||!this.state.isRecording){console.warn("[PeersCaller] No active recording to stop");return}yield this.recorder.stopRecording(),this.state.setIsRecording(!1),console.log("[PeersCaller] Recording stopped successfully")}catch(e){throw console.error("[PeersCaller] Failed to stop recording:",e),e}})}getCallState(){return this.state}getLocalParticipant(){return this.localParticipant}getParticipants(){return new Map(this.participants)}getParticipant(e){return this.participants.get(e)}getDebugInfo(){return{isInitialized:this.isInitialized,localParticipant:this.localParticipant?{userId:this.localParticipant.getUserId(),hasStream:!!this.localParticipant.getCurrentStream(),streamTracks:this.localParticipant.getCurrentStream()?{video:this.localParticipant.getCurrentStream().getVideoTracks().length,audio:this.localParticipant.getCurrentStream().getAudioTracks().length}:null,peerConnections:Array.from(this.localParticipant.getAllPeerConnections().keys()),connectionStatus:this.localParticipant.getConnectionStatus()}:null,remoteParticipants:Array.from(this.participants.keys()),storeState:this.state,socketConnected:this.socket.isConnected()}}cleanup(){return Ne(this,null,function*(){console.log("[PeersCaller] Cleaning up..."),this.state.isCalling&&(yield this.endCall()),this.cleanupSocketListeners(),this.cleanupAllParticipants(),this.recorder&&(this.recorder.cleanup(),this.recorder=null),this.socket.disconnect(),this.state.resetCall(),this.isInitialized=!1,console.log("[PeersCaller] Cleanup completed")})}initializeLocalParticipant(){return Ne(this,null,function*(){this.localParticipant||(this.localParticipant=new An(this.config.user,{onSignal:(e,t,s)=>{this.forwardSignalToServer(e,t,s)},onError:e=>this.handleError("UNKNOWN_ERROR",e.message)},!0)),console.log("[PeersCaller] Local participant created (media not initialized yet)")})}setupSocketListeners(){if(this.listenersSetup){console.log("[PeersCaller] Socket listeners already set up, skipping...");return}this.cleanupSocketListeners(),console.log("[PeersCaller] Setting up socket listeners...");const e=P=>{const y=typeof P.user=="string"?{id:P.user}:P.user||{id:P.userId};this.handleParticipantJoined(y)};this.socket.on("call.participant.joined",e),this.eventListeners.set("call.participant.joined",e);const t=P=>{const y=typeof P.user=="string"?{id:P.user}:P.user||{id:P.userId};this.handleParticipantLeft(y)};this.socket.on("call.participant.left",t),this.eventListeners.set("call.participant.left",t);const s=P=>{P.participants.forEach(y=>{const C=typeof y=="string"?{id:y}:y;C.id!==this.config.user.id&&this.handleParticipantJoined(C)})};this.socket.on("call.participants",s),this.eventListeners.set("call.participants",s);const c=()=>{this.state.setIsCalling(!1)};this.socket.on("call.left",c),this.eventListeners.set("call.left",c);const l=P=>{var y,C;console.error("[PeersCaller] Server error:",P),(C=(y=this.callbacks).onError)==null||C.call(y,P.error,P.message)};this.socket.on("call.error",l),this.eventListeners.set("call.error",l);const g=P=>{this.handleOffer(P.from,P.offer)};this.socket.on("call.offer",g),this.eventListeners.set("call.offer",g);const f=P=>{this.handleAnswer(P.from,P.answer)};this.socket.on("call.answer",f),this.eventListeners.set("call.answer",f);const u=P=>{this.handleCandidate(P.from,P.candidate)};this.socket.on("call.candidate",u),this.eventListeners.set("call.candidate",u);const m=P=>{this.handleParticipantStateUpdate(P.from,P.state)};this.socket.on("call.state",m),this.eventListeners.set("call.state",m);const h=P=>{this.handleCallEnded(P)};this.socket.on("call.ended",h),this.eventListeners.set("call.ended",h);const k=P=>{this.handleCallStatusChanged(P)};this.socket.on("call.status.changed",k),this.eventListeners.set("call.status.changed",k);const I=P=>{console.log("[PeersCaller] Recording started:",P.recordingId),this.state.setIsRecording(!0)};this.socket.on("call.recording.start",I),this.eventListeners.set("call.recording.start",I);const V=P=>{console.log("[PeersCaller] Recording chunk received:",P)};this.socket.on("call.recording.chunk.received",V),this.eventListeners.set("call.recording.chunk.received",V);const b=P=>{console.log("[PeersCaller] Recording ended:",P.recordingId),this.state.setIsRecording(!1)};this.socket.on("call.recording.end",b),this.eventListeners.set("call.recording.end",b);const B=P=>{console.log("[PeersCaller] Transcript received:",P)};this.socket.on("call.transcript",B),this.eventListeners.set("call.transcript",B),this.listenersSetup=!0,console.log("[PeersCaller] Socket listeners set up successfully")}cleanupSocketListeners(){if(!(!this.listenersSetup&&this.eventListeners.size===0)){console.log("[PeersCaller] Cleaning up socket listeners...");for(const[e,t]of this.eventListeners)this.socket.off(e,t);this.eventListeners.clear(),this.listenersSetup=!1,console.log("[PeersCaller] Socket listeners cleaned up successfully")}}handleParticipantJoined(e){return Ne(this,null,function*(){var t,s;try{if(e.id===this.config.user.id||this.participants.has(e.id))return;if(this.participants.size>=this.config.maxParticipants-1){console.warn("[PeersCaller] Maximum participants reached");return}console.log(`[PeersCaller] Participant ${e.id} (${e.name||"Unknown"}) joined`);const c=new An(e,{onStreamReceived:(f,u)=>{var m,h;const k=this.participants.get(f),I=(k==null?void 0:k.getUser())||{id:f};(h=(m=this.callbacks).onStreamReceived)==null||h.call(m,I,u)},onPeerConnected:f=>{console.log(`[PeersCaller] Peer connection established with ${f}`)},onPeerDisconnected:f=>{const u=this.participants.get(f),m=(u==null?void 0:u.getUser())||{id:f};this.handleParticipantLeft(m)},onSignal:(f,u,m)=>{this.forwardSignalToServer(f,u,m)},onError:f=>{this.handleError("PEER_CONNECTION_FAILED",f.message)}},!1);if(this.participants.set(e.id,c),!this.localParticipant){console.error("[PeersCaller] Cannot create peer connection - local participant not initialized");return}const l=this.config.user.id<e.id,g={iceServers:this.iceServers,initiator:l};yield this.localParticipant.createPeerConnection(e.id,g,l),(s=(t=this.callbacks).onParticipantJoined)==null||s.call(t,{user:e,videoOn:!0,audioOn:!0,screenSharing:!1})}catch(c){console.error(`[PeersCaller] Failed to handle participant ${e.id} joining:`,c)}})}checkCallStatus(){return Ne(this,null,function*(){try{if(console.log("[PeersCaller] Checking call status..."),!this.socket.isConnected())throw new Error("Socket not connected");this.state.setCallStatusLoading(!0),this.state.setCallStatusError(null);const e=yield this.socket.checkCallStatus(this.config.roomId);return this.state.setCallStatusInfo(e),this.state.setCallStatusLoading(!1),console.log("[PeersCaller] Call status received:",e),e}catch(e){console.error("[PeersCaller] Failed to check call status:",e);const t=e instanceof Error?e.message:String(e);throw this.state.setCallStatusLoading(!1),this.state.setCallStatusError(t),this.handleError("NETWORK_ERROR",`Failed to check call status: ${t}`),e}})}handleOffer(e,t){return Ne(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received offer from ${e} but local participant not initialized`);return}const s=this.localParticipant.getPeerConnection(e);s?(console.log(`[PeersCaller] Processing offer from ${e}`),s.signal({type:"offer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for offer from ${e}`)}catch(s){console.error(`[PeersCaller] Failed to handle offer from ${e}:`,s)}})}handleAnswer(e,t){return Ne(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received answer from ${e} but local participant not initialized`);return}const s=this.localParticipant.getPeerConnection(e);s?(console.log(`[PeersCaller] Processing answer from ${e}`),s.signal({type:"answer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for answer from ${e}`)}catch(s){console.error(`[PeersCaller] Failed to handle answer from ${e}:`,s)}})}handleCandidate(e,t){return Ne(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received candidate from ${e} but local participant not initialized`);return}const s=this.localParticipant.getPeerConnection(e);s?(console.log(`[PeersCaller] Processing candidate from ${e}`),s.signal({type:"candidate",candidate:t})):console.warn(`[PeersCaller] No peer connection found for candidate from ${e}`)}catch(s){console.error(`[PeersCaller] Failed to handle candidate from ${e}:`,s)}})}handleParticipantStateUpdate(e,t){var s,c;this.state.updateParticipant(e,t);const l=this.participants.get(e),g=(l==null?void 0:l.getUser())||{id:e};(c=(s=this.callbacks).onParticipantStateChanged)==null||c.call(s,g,t)}handleParticipantLeft(e){var t,s;console.log(`[PeersCaller] Participant ${e.id} (${e.name||"Unknown"}) left`);const c=this.participants.get(e.id);c&&(c.cleanup(),this.participants.delete(e.id)),this.localParticipant&&this.localParticipant.destroyPeerConnection(e.id),this.state.removeParticipant(e.id),(s=(t=this.callbacks).onParticipantLeft)==null||s.call(t,e)}handleCallEnded(e){return Ne(this,null,function*(){var t,s;const c=typeof e.endedBy=="string"?{id:e.endedBy}:e.endedBy;console.log(`[PeersCaller] Call ended by ${c.id} (${c.name||"Unknown"}), reason: ${e.reason}`);try{this.recorder&&this.state.isRecording&&(yield this.stopRecording()),this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),(s=(t=this.callbacks).onCallEnded)==null||s.call(t,{roomId:e.roomId,endedBy:c,reason:e.reason}),console.log("[PeersCaller] Call ended cleanup completed")}catch(l){console.error("[PeersCaller] Error handling call ended:",l)}})}broadcastStateUpdate(e){for(const t of this.participants.keys())this.socket.sendStateUpdate(t,e,this.config.roomId)}handleCallStatusChanged(e){var t,s;console.log("[PeersCaller] Call status changed:",e),this.state.setCallStatusInfo(e),(s=(t=this.callbacks).onCallStatusChanged)==null||s.call(t,e)}cleanupAllParticipants(){for(const e of this.participants.values())e.cleanup();this.participants.clear(),this.localParticipant&&(this.localParticipant.cleanup(),this.localParticipant=null)}handleError(e,t){var s,c;console.error(`[PeersCaller] ${e}: ${t}`),this.state.setError(e,t),(c=(s=this.callbacks).onError)==null||c.call(s,e,t)}fetchIceServers(){return Ne(this,null,function*(){try{console.log("[PeersCaller] Fetching ICE servers from backend...");const e=yield this.socket.getIceServers(this.roomId);if(e.error){console.warn("[PeersCaller] Failed to fetch ICE servers from backend:",e.error),console.log("[PeersCaller] Using default ICE servers");return}e.iceServers&&e.iceServers.length>0?this.iceServers=e.iceServers:console.log("[PeersCaller] No ICE servers received from backend, using defaults")}catch(e){console.warn("[PeersCaller] Error fetching ICE servers:",e)}})}forwardSignalToServer(e,t,s){try{switch(console.log(`[PeersCaller] Forwarding signal from ${e} to ${t}:`,s.type),s.type){case"offer":this.socket.sendOffer(t,s,this.config.roomId);break;case"answer":this.socket.sendAnswer(t,s,this.config.roomId);break;case"candidate":this.socket.sendCandidate(t,s.candidate,this.config.roomId);break;case"renegotiate":console.log(`[PeersCaller] Renegotiation signal from ${e} to ${t} - handled locally`);break;default:console.warn(`[PeersCaller] Unknown signal type: ${s.type} - this may indicate a new signal type that needs handling`),this.config.debug&&console.log("[PeersCaller] Unknown signal data:",s);break}}catch(c){console.error(`[PeersCaller] Failed to forward signal from ${e} to ${t}:`,c),this.handleError("SIGNALING_ERROR",`Failed to forward signal: ${c}`)}}}var Ut={exports:{}},_t={};var sa;function Tl(){if(sa)return _t;sa=1;var r=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(s,c,l){var g=null;if(l!==void 0&&(g=""+l),c.key!==void 0&&(g=""+c.key),"key"in c){l={};for(var f in c)f!=="key"&&(l[f]=c[f])}else l=c;return c=l.ref,{$$typeof:r,type:s,key:g,ref:c!==void 0?c:null,props:l}}return _t.Fragment=e,_t.jsx=t,_t.jsxs=t,_t}var Et={},la;function Al(){return la||(la=1,le.env.NODE_ENV!=="production"&&function(){function r(X){if(X==null)return null;if(typeof X=="function")return X.$$typeof===Q?null:X.displayName||X.name||null;if(typeof X=="string")return X;switch(X){case B:return"Fragment";case y:return"Profiler";case P:return"StrictMode";case O:return"Suspense";case S:return"SuspenseList";case G:return"Activity"}if(typeof X=="object")switch(typeof X.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),X.$$typeof){case b:return"Portal";case A:return(X.displayName||"Context")+".Provider";case C:return(X._context.displayName||"Context")+".Consumer";case T:var ae=X.render;return X=X.displayName,X||(X=ae.displayName||ae.name||"",X=X!==""?"ForwardRef("+X+")":"ForwardRef"),X;case R:return ae=X.displayName||null,ae!==null?ae:r(X.type)||"Memo";case M:ae=X._payload,X=X._init;try{return r(X(ae))}catch(j){}}return null}function e(X){return""+X}function t(X){try{e(X);var ae=!1}catch(z){ae=!0}if(ae){ae=console;var j=ae.error,W=typeof Symbol=="function"&&Symbol.toStringTag&&X[Symbol.toStringTag]||X.constructor.name||"Object";return j.call(ae,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",W),e(X)}}function s(X){if(X===B)return"<>";if(typeof X=="object"&&X!==null&&X.$$typeof===M)return"<...>";try{var ae=r(X);return ae?"<"+ae+">":"<...>"}catch(j){return"<...>"}}function c(){var X=ie.A;return X===null?null:X.getOwner()}function l(){return Error("react-stack-top-frame")}function g(X){if(U.call(X,"key")){var ae=Object.getOwnPropertyDescriptor(X,"key").get;if(ae&&ae.isReactWarning)return!1}return X.key!==void 0}function f(X,ae){function j(){ye||(ye=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",ae))}j.isReactWarning=!0,Object.defineProperty(X,"key",{get:j,configurable:!0})}function u(){var X=r(this.type);return Pe[X]||(Pe[X]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),X=this.props.ref,X!==void 0?X:null}function m(X,ae,j,W,z,re,L,D){return j=re.ref,X={$$typeof:V,type:X,key:ae,props:re,_owner:z},(j!==void 0?j:null)!==null?Object.defineProperty(X,"ref",{enumerable:!1,get:u}):Object.defineProperty(X,"ref",{enumerable:!1,value:null}),X._store={},Object.defineProperty(X._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(X,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(X,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:L}),Object.defineProperty(X,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.freeze&&(Object.freeze(X.props),Object.freeze(X)),X}function h(X,ae,j,W,z,re,L,D){var q=ae.children;if(q!==void 0)if(W)if(ge(q)){for(W=0;W<q.length;W++)k(q[W]);Object.freeze&&Object.freeze(q)}else console.error("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 k(q);if(U.call(ae,"key")){q=r(X);var Z=Object.keys(ae).filter(function(v){return v!=="key"});W=0<Z.length?"{key: someKey, "+Z.join(": ..., ")+": ...}":"{key: someKey}",we[q+W]||(Z=0<Z.length?"{"+Z.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
17
|
-
let props = %s;
|
|
18
|
-
<%s {...props} />
|
|
19
|
-
React keys must be passed directly to JSX without using spread:
|
|
20
|
-
let props = %s;
|
|
21
|
-
<%s key={someKey} {...props} />`,W,q,Z,q),we[q+W]=!0)}if(q=null,j!==void 0&&(t(j),q=""+j),g(ae)&&(t(ae.key),q=""+ae.key),"key"in ae){j={};for(var ee in ae)ee!=="key"&&(j[ee]=ae[ee])}else j=ae;return q&&f(j,typeof X=="function"?X.displayName||X.name||"Unknown":X),m(X,q,re,z,c(),j,L,D)}function k(X){typeof X=="object"&&X!==null&&X.$$typeof===V&&X._store&&(X._store.validated=1)}var I=ce,V=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),A=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),ie=I.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,ge=Array.isArray,de=console.createTask?console.createTask:function(){return null};I={react_stack_bottom_frame:function(X){return X()}};var ye,Pe={},Te=I.react_stack_bottom_frame.bind(I,l)(),Se=de(s(l)),we={};Et.Fragment=B,Et.jsx=function(X,ae,j,W,z){var re=1e4>ie.recentlyCreatedOwnerStacks++;return h(X,ae,j,!1,W,z,re?Error("react-stack-top-frame"):Te,re?de(s(X)):Se)},Et.jsxs=function(X,ae,j,W,z){var re=1e4>ie.recentlyCreatedOwnerStacks++;return h(X,ae,j,!0,W,z,re?Error("react-stack-top-frame"):Te,re?de(s(X)):Se)}}()),Et}var ca;function Il(){return ca||(ca=1,le.env.NODE_ENV==="production"?Ut.exports=Tl():Ut.exports=Al()),Ut.exports}var kl=Il();const ua=ce.createContext(null);function Bl({options:r,children:e}){const t=fa(r);return kl.jsx(ua.Provider,{value:t,children:e})}function Ol(){const r=ce.useContext(ua);if(!r)throw new Error("useVideoCallContext must be used within a VideoCallProvider. Wrap your component tree with <VideoCallProvider> to use this hook.");return r}var Xe=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});function fa(r){const[e,t]=ce.useState(null),[s,c]=ce.useState(!1),l=ce.useRef(!1),g=qe(R=>R),f=Object.values(qe(R=>R.participants)),u=qe(R=>R.localParticipant),m=qe(R=>R.callStatus==="connected"),h=qe(R=>R.isRecording),k=qe(R=>R.error),I=ce.useCallback(()=>Xe(null,null,function*(){if(!(l.current||e))try{l.current=!0;const R=new aa(r,r.callbacks);yield R.initialize(),t(R),c(!0)}catch(R){throw console.error("[useVideoCall] Failed to initialize:",R),l.current=!1,R}}),[r,e]),V=ce.useCallback(R=>Xe(null,null,function*(){if(!e){yield I();return}return e.startCall(R)}),[e,I]),b=ce.useCallback(R=>Xe(null,null,function*(){if(!e){yield I();return}return e.joinCall(R)}),[e,I]),B=ce.useCallback(()=>{e==null||e.endCall()},[e]),P=ce.useCallback(R=>{e==null||e.toggleAudio(R)},[e]),y=ce.useCallback(R=>{e==null||e.toggleVideo(R)},[e]),C=ce.useCallback(()=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startScreenShare()}),[e]),A=ce.useCallback(()=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopScreenShare()}),[e]),T=ce.useCallback(R=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startRecording(R)}),[e]),O=ce.useCallback(()=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopRecording()}),[e]),S=ce.useCallback(()=>{e&&(e.cleanup(),t(null),c(!1),l.current=!1)},[e]);return ce.useEffect(()=>{r.autoInitialize&&!s&&!l.current&&I().catch(console.error)},[r.autoInitialize,s,I]),ce.useEffect(()=>()=>{S()},[S]),{initialize:I,startCall:V,joinCall:b,endCall:B,toggleAudio:P,toggleVideo:y,startScreenShare:C,stopScreenShare:A,startRecording:T,stopRecording:O,callState:g,participants:f,localParticipant:u,isConnected:m,isRecording:h,error:k,cleanup:S,peersCaller:e}}function Ml(r){const[e,t]=ce.useState(null),[s,c]=ce.useState(null),l=qe(g=>g.participants[r]);return ce.useEffect(()=>{var g;if(l!=null&&l.stream){if(c(l.stream),!e){const f=document.createElement("video");f.autoplay=!0,f.playsInline=!0,f.muted=r===((g=qe.getState().localParticipant)==null?void 0:g.user.id),t(f)}e&&(e.srcObject=l.stream)}},[l==null?void 0:l.stream,r,e]),ce.useEffect(()=>()=>{e&&(e.srcObject=null)},[e]),{videoElement:e,stream:s,participant:l}}function Nl(){const r=qe();return{roomId:r.roomId,participants:r.participants,localParticipant:r.localParticipant,isCalling:r.isCalling,isRecording:r.isRecording,recordLoading:r.recordLoading,callStatus:r.callStatus,error:r.error,participantCount:Object.keys(r.participants).length,isConnected:r.callStatus==="connected",hasError:!!r.error}}function Ll(){const[r,e]=ce.useState({videoDevices:[],audioDevices:[]}),[t,s]=ce.useState({camera:null,microphone:null}),c=ce.useCallback(()=>Xe(null,null,function*(){try{const f=yield navigator.mediaDevices.enumerateDevices();e({videoDevices:f.filter(u=>u.kind==="videoinput"),audioDevices:f.filter(u=>u.kind==="audioinput")})}catch(f){console.error("[useMediaDevices] Failed to get devices:",f)}}),[]),l=ce.useCallback(()=>Xe(null,null,function*(){try{if("permissions"in navigator){const f=yield navigator.permissions.query({name:"camera"}),u=yield navigator.permissions.query({name:"microphone"});s({camera:f.state,microphone:u.state})}}catch(f){console.error("[useMediaDevices] Failed to check permissions:",f)}}),[]),g=ce.useCallback(()=>Xe(null,null,function*(){try{return(yield navigator.mediaDevices.getUserMedia({video:!0,audio:!0})).getTracks().forEach(u=>u.stop()),yield l(),yield c(),!0}catch(f){return console.error("[useMediaDevices] Failed to request permissions:",f),!1}}),[l,c]);return ce.useEffect(()=>{var f;c(),l();const u=()=>{c()};return(f=navigator.mediaDevices)==null||f.addEventListener("devicechange",u),()=>{var m;(m=navigator.mediaDevices)==null||m.removeEventListener("devicechange",u)}},[c,l]),{devices:r,permissions:t,getDevices:c,checkPermissions:l,requestPermissions:g}}function Dl(){const[r,e]=ce.useState({webRTC:!1,getUserMedia:!1,getDisplayMedia:!1,mediaRecorder:!1,speechRecognition:!1});return ce.useEffect(()=>{e({webRTC:!!window.RTCPeerConnection,getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),mediaRecorder:typeof MediaRecorder!="undefined",speechRecognition:!!(window.SpeechRecognition||window.webkitSpeechRecognition)})},[]),{support:r,isSupported:Object.values(r).every(Boolean),unsupportedFeatures:Object.entries(r).filter(([,t])=>!t).map(([t])=>t)}}function Fl(r=""){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return r?`${r}_${e}_${t}`:`${e}_${t}`}const Ul=()=>`peer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,jl=r=>!r||typeof r!="string"?!1:/^peer_\d+_[a-z0-9]{1,9}$/.test(r),xl=r=>{var e,t;return{video:(e=r.video)!=null?e:!0,audio:(t=r.audio)!=null?t:!0}};function ql(r,e,t){const s=`[${r}] ${e}`,c=new Error(s);return t&&(c.details=t),c}function $l(){const r={getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),RTCPeerConnection:!!window.RTCPeerConnection,MediaRecorder:typeof MediaRecorder!="undefined",WebSocket:typeof WebSocket!="undefined"},e=Object.entries(r).filter(([,t])=>!t).map(([t])=>t);return{supported:e.length===0,features:r,missingFeatures:e}}const Wl=()=>{try{return typeof window!="undefined"&&typeof window.RTCPeerConnection!="undefined"&&typeof navigator!="undefined"&&typeof navigator.mediaDevices!="undefined"&&typeof navigator.mediaDevices.getUserMedia!="undefined"}catch(r){return!1}};function Vl(){return[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun3.l.google.com:19302"}]}ne.CallMediaStream=Vn,ne.CallParticipant=An,ne.CallPeerConnection=jo,ne.CallRecorder=ra,ne.CallSocket=Wn,ne.PeersCaller=aa,ne.VideoCallProvider=Bl,ne.canAcceptMoreParticipants=rl,ne.checkWebRTCSupport=$l,ne.formatError=ql,ne.formatMediaConstraints=xl,ne.generateId=Fl,ne.generatePeerId=Ul,ne.getDefaultIceServers=Vl,ne.getParticipant=Xo,ne.getParticipantList=tl,ne.isParticipantConnected=el,ne.isValidPeerId=jl,ne.isWebRTCSupported=Wl,ne.selectCallStatus=zs,ne.selectCallStatusError=Xs,ne.selectCallStatusInfo=Js,ne.selectCallStatusLoading=Ks,ne.selectCanJoinCall=Zs,ne.selectError=Ys,ne.selectIsCallActive=Qs,ne.selectIsConnected=Hs,ne.selectLocalParticipant=Gs,ne.selectParticipantCount=Ko,ne.selectParticipants=Vs,ne.useBrowserSupport=Dl,ne.useCallState=Nl,ne.useCallStore=qe,ne.useMediaDevices=Ll,ne.useParticipantVideo=Ml,ne.useTesterStore=Us,ne.useVideoCall=fa,ne.useVideoCallContext=Ol,Object.defineProperty(ne,Symbol.toStringTag,{value:"Module"})});
|
|
16
|
+
`);const T=A.state[f];if(T==null)return;JSON.stringify(c.getState())!==JSON.stringify(T)&&$(T);return}c.dispatchFromDevtools&&typeof c.dispatch=="function"&&c.dispatch(A)});case"DISPATCH":switch(y.payload.type){case"RESET":return $(b),f===void 0?h==null?void 0:h.init(c.getState()):h==null?void 0:h.init(Mt(u.name));case"COMMIT":if(f===void 0){h==null||h.init(c.getState());return}return h==null?void 0:h.init(Mt(u.name));case"ROLLBACK":return bn(y.state,A=>{if(f===void 0){$(A),h==null||h.init(c.getState());return}$(A[f]),h==null||h.init(Mt(u.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return bn(y.state,A=>{if(f===void 0){$(A);return}JSON.stringify(c.getState())!==JSON.stringify(A[f])&&$(A[f])});case"IMPORT_STATE":{const{nextLiftedState:A}=y.payload,T=(C=A.computedStates.slice(-1)[0])==null?void 0:C.state;if(!T)return;$(f===void 0?T:T[f]),h==null||h.send(null,A);return}case"PAUSE_RECORDING":return I=!I}return}}),b},bn=(r,e)=>{let t;try{t=JSON.parse(r)}catch(s){console.error("[zustand devtools middleware] Could not parse the received json",s)}t!==void 0&&e(t)};function Is(r,e){let t;try{t=r()}catch(c){return}return{getItem:c=>{var l;const g=u=>u===null?null:JSON.parse(u,void 0),f=(l=t.getItem(c))!=null?l:null;return f instanceof Promise?f.then(g):g(f)},setItem:(c,l)=>t.setItem(c,JSON.stringify(l,void 0)),removeItem:c=>t.removeItem(c)}}const Sn=r=>e=>{try{const t=r(e);return t instanceof Promise?t:{then(s){return Sn(s)(t)},catch(s){return this}}}catch(t){return{then(s){return this},catch(s){return Sn(s)(t)}}}},Bs=(r,e)=>(t,s,c)=>{let l=ze({storage:Is(()=>localStorage),partialize:k=>k,version:0,merge:(k,P)=>ze(ze({},P),k)},e),g=!1;const f=new Set,u=new Set;let m=l.storage;if(!m)return r((...k)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),t(...k)},s,c);const h=()=>{const k=l.partialize(ze({},s()));return m.setItem(l.name,{state:k,version:l.version})},B=c.setState;c.setState=(k,P)=>{B(k,P),h()};const I=r((...k)=>{t(...k),h()},s,c);c.getInitialState=()=>I;let $;const b=()=>{var k,P;if(!m)return;g=!1,f.forEach(C=>{var A;return C((A=s())!=null?A:I)});const y=((P=l.onRehydrateStorage)==null?void 0:P.call(l,(k=s())!=null?k:I))||void 0;return Sn(m.getItem.bind(m))(l.name).then(C=>{if(C)if(typeof C.version=="number"&&C.version!==l.version){if(l.migrate){const A=l.migrate(C.state,C.version);return A instanceof Promise?A.then(T=>[!0,T]):[!0,A]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,C.state];return[!1,void 0]}).then(C=>{var A;const[T,O]=C;if($=l.merge(O,(A=s())!=null?A:I),t($,!0),T)return h()}).then(()=>{y==null||y($,void 0),$=s(),g=!0,u.forEach(C=>C($))}).catch(C=>{y==null||y(void 0,C)})};return c.persist={setOptions:k=>{l=ze(ze({},l),k),k.storage&&(m=k.storage)},clearStorage:()=>{m==null||m.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>b(),hasHydrated:()=>g,onHydrate:k=>(f.add(k),()=>{f.delete(k)}),onFinishHydration:k=>(u.add(k),()=>{u.delete(k)})},l.skipHydration||b(),$||I};var ks=Object.defineProperty,jo=Object.getOwnPropertySymbols,Os=Object.prototype.hasOwnProperty,Ms=Object.prototype.propertyIsEnumerable,qo=(r,e,t)=>e in r?ks(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,xo=(r,e)=>{for(var t in e||(e={}))Os.call(e,t)&&qo(r,t,e[t]);if(jo)for(var t of jo(e))Ms.call(e,t)&&qo(r,t,e[t]);return r};const $o={socketUrl:"ws://localhost:5000",roomId:"",userId:"",token:"",apiUrl:"http://127.0.0.1:5000",autoRecording:!1,iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]},Ls=Pe.create()(Uo(Bs(r=>({config:$o,setConfig:e=>r(t=>({config:xo(xo({},t.config),e)}),!1,"setConfig"),resetConfig:()=>r({config:$o},!1,"resetConfig")}),{name:"peers-caller-tester-store"}),{name:"peers-caller-tester",enabled:ae.env.NODE_ENV==="development"}));var Ns=Object.defineProperty,Ds=Object.defineProperties,Fs=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,Wo=Object.prototype.hasOwnProperty,Vo=Object.prototype.propertyIsEnumerable,Go=(r,e,t)=>e in r?Ns(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,dt=(r,e)=>{for(var t in e||(e={}))Wo.call(e,t)&&Go(r,t,e[t]);if(Lt)for(var t of Lt(e))Vo.call(e,t)&&Go(r,t,e[t]);return r},_n=(r,e)=>Ds(r,Fs(e)),Us=r=>typeof r=="symbol"?r:r+"",js=(r,e)=>{var t={};for(var s in r)Wo.call(r,s)&&e.indexOf(s)<0&&(t[s]=r[s]);if(r!=null&&Lt)for(var s of Lt(r))e.indexOf(s)<0&&Vo.call(r,s)&&(t[s]=r[s]);return t};const zo={roomId:"",participants:{},localParticipant:null,isCalling:!1,isRecording:!1,recordLoading:!1,callStatus:"idle",error:null,callStatusInfo:null,callStatusLoading:!1,callStatusError:null},qe=Pe.create()(Uo(r=>_n(dt({},zo),{setRoomId:e=>r({roomId:e},!1,"setRoomId"),setLocalParticipant:e=>r({localParticipant:e},!1,"setLocalParticipant"),addParticipant:e=>r(t=>({participants:_n(dt({},t.participants),{[e.user.id]:e})}),!1,"addParticipant"),removeParticipant:e=>r(t=>{const s=t.participants,{[e]:c}=s;return{participants:js(s,[Us(e)])}},!1,"removeParticipant"),updateParticipant:(e,t)=>r(s=>s.participants[e]?{participants:_n(dt({},s.participants),{[e]:dt(dt({},s.participants[e]),t)})}:s,!1,"updateParticipant"),clearParticipants:()=>r({participants:{}},!1,"clearParticipants"),setCallStatus:e=>r({callStatus:e},!1,"setCallStatus"),setIsCalling:e=>r({isCalling:e},!1,"setIsCalling"),setIsRecording:e=>r({isRecording:e},!1,"setIsRecording"),setRecordLoading:e=>r({recordLoading:e},!1,"setRecordLoading"),setError:(e,t)=>r({error:t||e},!1,"setError"),clearError:()=>r({error:null},!1,"clearError"),setCallStatusInfo:e=>r({callStatusInfo:e},!1,"setCallStatusInfo"),setCallStatusLoading:e=>r({callStatusLoading:e},!1,"setCallStatusLoading"),setCallStatusError:e=>r({callStatusError:e},!1,"setCallStatusError"),resetCall:()=>r(dt({},zo),!1,"resetCall")}),{name:"peers-caller-store",enabled:ae.env.NODE_ENV==="development"})),qs=r=>r.participants,Ho=r=>Object.keys(r.participants).length,xs=r=>r.localParticipant,$s=r=>r.callStatus,Ws=r=>r.callStatus==="connected",Vs=r=>r.error,Gs=r=>r.callStatusInfo,zs=r=>r.callStatusLoading,Hs=r=>r.callStatusError,Js=r=>{var e;return((e=r.callStatusInfo)==null?void 0:e.canJoin)||!1},Ys=r=>{var e;return((e=r.callStatusInfo)==null?void 0:e.hasActiveCall)||!1},Jo=r=>qe.getState().participants[r],Ks=r=>{const e=Jo(r);return!!(e!=null&&e.stream)},Xs=()=>{const r=qe.getState();return Object.values(r.participants)},Zs=(r=4)=>Ho(qe.getState())<r;var Qs=Object.defineProperty,el=(r,e,t)=>e in r?Qs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tl=(r,e,t)=>el(r,e+"",t);class Yo{constructor(e){if(tl(this,"store"),e&&typeof e.getState=="function")this.store=e;else{const t=e;this.store={getState:()=>t}}}get state(){return this.store.getState()}}var rl=Object.defineProperty,nl=Object.defineProperties,il=Object.getOwnPropertyDescriptors,Ko=Object.getOwnPropertySymbols,ol=Object.prototype.hasOwnProperty,al=Object.prototype.propertyIsEnumerable,En=(r,e,t)=>e in r?rl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cn=(r,e)=>{for(var t in e||(e={}))ol.call(e,t)&&En(r,t,e[t]);if(Ko)for(var t of Ko(e))al.call(e,t)&&En(r,t,e[t]);return r},sl=(r,e)=>nl(r,il(e)),pt=(r,e,t)=>En(r,typeof e!="symbol"?e+"":e,t),Nt=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class Rn extends Yo{constructor(e,t={},s=!1){super(qe),pt(this,"user"),pt(this,"mediaStream",null),pt(this,"peerConnections",new Map),pt(this,"remoteStreams",new Map),pt(this,"isLocalParticipant",!1),pt(this,"callbacks"),this.user=e,this.callbacks=t,this.isLocalParticipant=s;const c={user:e,videoOn:!0,audioOn:!0,screenSharing:!1};this.isLocalParticipant&&this.state.setLocalParticipant(c),this.state.addParticipant(c)}initialize(e){return Nt(this,null,function*(){var t,s;try{console.log(`[CallParticipant] Initializing participant ${this.user.id}`),this.mediaStream=new xn(e);const l={stream:yield this.mediaStream.initialize(),videoElement:this.mediaStream.createVideoElement()};this.updateState(l),console.log(`[CallParticipant] Participant ${this.user.id} initialized successfully`)}catch(c){throw console.error(`[CallParticipant] Failed to initialize participant ${this.user.id}:`,c),(s=(t=this.callbacks).onError)==null||s.call(t,c),c}})}createPeerConnection(e,t,s){return Nt(this,null,function*(){var c,l;try{console.log(`[CallParticipant] Creating peer connection from ${this.user.id} to ${e}`),this.peerConnections.has(e)&&(console.warn(`[CallParticipant] Peer connection to ${e} already exists, destroying before recreating`),this.destroyPeerConnection(e));const g={onSignal:u=>{var m,h;console.log(`[CallParticipant] Signal from ${this.user.id} to ${e}:`,u.type),(h=(m=this.callbacks).onSignal)==null||h.call(m,this.user.id,e,u)},onConnect:()=>{var u,m;console.log(`[CallParticipant] ${this.user.id} connected to ${e}`),(m=(u=this.callbacks).onPeerConnected)==null||m.call(u,e)},onStream:u=>{var m,h;console.log(`[CallParticipant] Stream received from ${e} by ${this.user.id}`),this.remoteStreams.set(e,u),this.state.updateParticipant(e,{stream:u}),(h=(m=this.callbacks).onStreamReceived)==null||h.call(m,e,u)},onClose:()=>{var u,m;console.log(`[CallParticipant] Connection closed between ${this.user.id} and ${e}`),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),(m=(u=this.callbacks).onPeerDisconnected)==null||m.call(u,e)},onError:u=>{var m,h;console.error(`[CallParticipant] Peer connection error between ${this.user.id} and ${e}:`,u),(h=(m=this.callbacks).onError)==null||h.call(m,u)}},f=new Do(e,sl(Cn({},t),{initiator:s}),g);yield f.createConnection(this.getCurrentStream()),this.peerConnections.set(e,f)}catch(g){throw console.error(`[CallParticipant] Failed to create peer connection from ${this.user.id} to ${e}:`,g),(l=(c=this.callbacks).onError)==null||l.call(c,g),g}})}getPeerConnection(e){return this.peerConnections.get(e)}signalToPeer(e,t){const s=this.peerConnections.get(e);s?s.signal(t):console.warn(`[CallParticipant] No peer connection found for ${e}`)}toggleAudio(e){this.mediaStream&&(this.mediaStream.toggleAudio(e),this.updateState({audioOn:e}))}toggleVideo(e){this.mediaStream&&(this.mediaStream.toggleVideo(e),this.updateState({videoOn:e}))}startScreenShare(){return Nt(this,null,function*(){var e,t;try{if(!this.mediaStream)throw new Error("Media stream not initialized");console.log(`[CallParticipant] Starting screen share for ${this.user.id}`);const s=yield this.mediaStream.startScreenShare(),c=this.mediaStream.getScreenVideoTrack(),l=this.mediaStream.getCameraVideoTrack();if(!c)throw new Error("Failed to get screen video track");for(const[g,f]of this.peerConnections)l?(f.replaceTrack(l,c),console.log(`[CallParticipant] Screen video track replaced for connection with ${g}`)):console.warn(`[CallParticipant] No camera video track to replace for ${g}`);this.updateState({screenSharing:!0,stream:s}),console.log(`[CallParticipant] Screen sharing started for ${this.user.id}`)}catch(s){throw console.error(`[CallParticipant] Failed to start screen share for ${this.user.id}:`,s),(t=(e=this.callbacks).onError)==null||t.call(e,s),s}})}stopScreenShare(){return Nt(this,null,function*(){var e,t;try{if(!this.mediaStream)throw new Error("Media stream not initialized");console.log(`[CallParticipant] Stopping screen share for ${this.user.id}`);const s=this.mediaStream.getScreenVideoTrack();console.log("[CallParticipant] Screen video track found:",!!s);const c=yield this.mediaStream.stopScreenShare(),l=this.mediaStream.getCameraVideoTrack();if(console.log("[CallParticipant] Camera stream:",!!c),console.log("[CallParticipant] Camera video track:",!!l),!l)throw new Error("Failed to get camera video track");for(const[g,f]of this.peerConnections)try{s&&l?(f.replaceTrack(s,l),console.log(`[CallParticipant] Camera video track restored for connection with ${g}`)):(console.log(`[CallParticipant] Updating entire stream for connection with ${g}`),f.addStream(c))}catch(u){console.warn(`[CallParticipant] Failed to replace track for ${g}, trying stream replacement:`,u)}if(this.updateState({screenSharing:!1,stream:c}),this.isLocalParticipant&&this.mediaStream){const g=this.mediaStream.getVideoElement();g&&(g.srcObject=c,console.log(`[CallParticipant] Updated local video element for ${this.user.id}`))}console.log(`[CallParticipant] Screen sharing stopped for ${this.user.id}`)}catch(s){throw console.error(`[CallParticipant] Failed to stop screen share for ${this.user.id}:`,s),(t=(e=this.callbacks).onError)==null||t.call(e,s),s}})}getState(){const e=this.state;return this.isLocalParticipant?e.localParticipant||{user:this.user,videoOn:!0,audioOn:!0,screenSharing:!1}:e.participants[this.user.id]||{user:this.user,videoOn:!0,audioOn:!0,screenSharing:!1}}getUserId(){return this.user.id}getUser(){return this.user}setUser(e){this.user=e,this.updateState({user:e}),console.log(`[CallParticipant] Updated user for participant ${e.id}:`,e)}getMediaStream(){return this.mediaStream}getCurrentStream(){return this.getState().stream}getVideoElement(){return this.getState().videoElement}getRemoteStream(e){return this.remoteStreams.get(e)}getAllRemoteStreams(){return new Map(this.remoteStreams)}getAllPeerConnections(){return new Map(this.peerConnections)}getConnectionStatus(){const e={};for(const[t,s]of this.peerConnections)e[t]=s.isConnected();return e}removePeerConnection(e){const t=this.peerConnections.get(e);t&&(t.destroy(),this.peerConnections.delete(e),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),console.log(`[CallParticipant] Removed peer connection from ${this.user.id} to ${e}`))}destroyPeerConnection(e){const t=this.peerConnections.get(e);t&&(console.log(`[CallParticipant] Destroying peer connection from ${this.user.id} to ${e}`),t.destroy(),this.peerConnections.delete(e),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}))}updateState(e){var t,s;const c=this.getState();if(Object.keys(e).some(g=>c[g]!==e[g])){const g=Cn(Cn({},c),e);this.isLocalParticipant&&this.state.setLocalParticipant(g),this.state.updateParticipant(this.user.id,e),(s=(t=this.callbacks).onStateChanged)==null||s.call(t,this.user,e)}}getDebugInfo(){var e;return{user:this.user,state:this.getState(),peerConnections:Array.from(this.peerConnections.keys()),remoteStreams:Array.from(this.remoteStreams.keys()),connectionStatus:this.getConnectionStatus(),mediaStreamInfo:(e=this.mediaStream)==null?void 0:e.getStreamInfo()}}cleanup(){console.log(`[CallParticipant] Cleaning up participant ${this.user.id}`),this.state.removeParticipant(this.user.id);for(const e of this.peerConnections.values())e.destroy();this.peerConnections.clear(),this.remoteStreams.clear(),this.mediaStream&&(this.mediaStream.cleanup(),this.mediaStream=null),console.log(`[CallParticipant] Participant ${this.user.id} cleanup completed`)}}var Pn={exports:{}},Xo;function ll(){return Xo||(Xo=1,function(r){function e(t,s){var c="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";(function(S){typeof RecordRTC=="undefined"&&S&&typeof window=="undefined"&&typeof globalThis!="undefined"&&(globalThis.navigator={userAgent:c,getUserMedia:function(){}},globalThis.console||(globalThis.console={}),(typeof globalThis.console.log=="undefined"||typeof globalThis.console.error=="undefined")&&(globalThis.console.error=globalThis.console.log=globalThis.console.log||function(){console.log(arguments)}),typeof document=="undefined"&&(S.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var R={getContext:function(){return R},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return R},S.HTMLVideoElement=function(){}),typeof location=="undefined"&&(S.location={protocol:"file:",href:"",hash:""}),typeof screen=="undefined"&&(S.screen={width:0,height:0}),typeof B=="undefined"&&(S.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),S.window=globalThis)})(typeof globalThis!="undefined"?globalThis:null),s=s||"multi-streams-mixer";var l=[],g=!1,f=document.createElement("canvas"),u=f.getContext("2d");f.style.opacity=0,f.style.position="absolute",f.style.zIndex=-1,f.style.top="-1000em",f.style.left="-1000em",f.className=s,(document.body||document.documentElement).appendChild(f),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var m=this,h=window.AudioContext;typeof h=="undefined"&&(typeof webkitAudioContext!="undefined"&&(h=webkitAudioContext),typeof mozAudioContext!="undefined"&&(h=mozAudioContext));var B=window.URL;typeof B=="undefined"&&typeof webkitURL!="undefined"&&(B=webkitURL),typeof navigator!="undefined"&&typeof navigator.getUserMedia=="undefined"&&(typeof navigator.webkitGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.webkitGetUserMedia),typeof navigator.mozGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.mozGetUserMedia));var I=window.MediaStream;typeof I=="undefined"&&typeof webkitMediaStream!="undefined"&&(I=webkitMediaStream),typeof I!="undefined"&&typeof I.prototype.stop=="undefined"&&(I.prototype.stop=function(){this.getTracks().forEach(function(S){S.stop()})});var $={};typeof h!="undefined"?$.AudioContext=h:typeof webkitAudioContext!="undefined"&&($.AudioContext=webkitAudioContext);function b(S,R){"srcObject"in R?R.srcObject=S:"mozSrcObject"in R?R.mozSrcObject=S:R.srcObject=S}this.startDrawingFrames=function(){k()};function k(){if(!g){var S=l.length,R=!1,L=[];if(l.forEach(function(X){X.stream||(X.stream={}),X.stream.fullcanvas?R=X:L.push(X)}),R)f.width=R.stream.width,f.height=R.stream.height;else if(L.length){f.width=S>1?L[0].width*2:L[0].width;var W=1;(S===3||S===4)&&(W=2),(S===5||S===6)&&(W=3),(S===7||S===8)&&(W=4),(S===9||S===10)&&(W=5),f.height=L[0].height*W}else f.width=m.width||360,f.height=m.height||240;R&&R instanceof HTMLVideoElement&&P(R),L.forEach(function(X,re){P(X,re)}),setTimeout(k,m.frameInterval)}}function P(S,R){if(!g){var L=0,W=0,X=S.width,re=S.height;R===1&&(L=S.width),R===2&&(W=S.height),R===3&&(L=S.width,W=S.height),R===4&&(W=S.height*2),R===5&&(L=S.width,W=S.height*2),R===6&&(W=S.height*3),R===7&&(L=S.width,W=S.height*3),typeof S.stream.left!="undefined"&&(L=S.stream.left),typeof S.stream.top!="undefined"&&(W=S.stream.top),typeof S.stream.width!="undefined"&&(X=S.stream.width),typeof S.stream.height!="undefined"&&(re=S.stream.height),u.drawImage(S,L,W,X,re),typeof S.stream.onRender=="function"&&S.stream.onRender(u,L,W,X,re,R)}}function y(){g=!1;var S=C(),R=A();return R&&R.getTracks().filter(function(L){return L.kind==="audio"}).forEach(function(L){S.addTrack(L)}),t.forEach(function(L){L.fullcanvas}),S}function C(){O();var S;"captureStream"in f?S=f.captureStream():"mozCaptureStream"in f?S=f.mozCaptureStream():m.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var R=new I;return S.getTracks().filter(function(L){return L.kind==="video"}).forEach(function(L){R.addTrack(L)}),f.stream=R,R}function A(){$.AudioContextConstructor||($.AudioContextConstructor=new $.AudioContext),m.audioContext=$.AudioContextConstructor,m.audioSources=[],m.useGainNode===!0&&(m.gainNode=m.audioContext.createGain(),m.gainNode.connect(m.audioContext.destination),m.gainNode.gain.value=0);var S=0;if(t.forEach(function(R){if(R.getTracks().filter(function(W){return W.kind==="audio"}).length){S++;var L=m.audioContext.createMediaStreamSource(R);m.useGainNode===!0&&L.connect(m.gainNode),m.audioSources.push(L)}}),!!S)return m.audioDestination=m.audioContext.createMediaStreamDestination(),m.audioSources.forEach(function(R){R.connect(m.audioDestination)}),m.audioDestination.stream}function T(S){var R=document.createElement("video");return b(S,R),R.className=s,R.muted=!0,R.volume=0,R.width=S.width||m.width||360,R.height=S.height||m.height||240,R.play(),R}this.appendStreams=function(S){if(!S)throw"First parameter is required.";S instanceof Array||(S=[S]),S.forEach(function(R){var L=new I;if(R.getTracks().filter(function(re){return re.kind==="video"}).length){var W=T(R);W.stream=R,l.push(W),L.addTrack(R.getTracks().filter(function(re){return re.kind==="video"})[0])}if(R.getTracks().filter(function(re){return re.kind==="audio"}).length){var X=m.audioContext.createMediaStreamSource(R);m.audioDestination=m.audioContext.createMediaStreamDestination(),X.connect(m.audioDestination),L.addTrack(m.audioDestination.stream.getTracks().filter(function(re){return re.kind==="audio"})[0])}t.push(L)})},this.releaseStreams=function(){l=[],g=!0,m.gainNode&&(m.gainNode.disconnect(),m.gainNode=null),m.audioSources.length&&(m.audioSources.forEach(function(S){S.disconnect()}),m.audioSources=[]),m.audioDestination&&(m.audioDestination.disconnect(),m.audioDestination=null),m.audioContext&&m.audioContext.close(),m.audioContext=null,u.clearRect(0,0,f.width,f.height),f.stream&&(f.stream.stop(),f.stream=null)},this.resetVideoStreams=function(S){S&&!(S instanceof Array)&&(S=[S]),O(S)};function O(S){l=[],S=S||t,S.forEach(function(R){if(R.getTracks().filter(function(W){return W.kind==="video"}).length){var L=T(R);L.stream=R,l.push(L)}})}this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=y}typeof RecordRTC=="undefined"&&(r.exports=e)}(Pn)),Pn.exports}var cl=ll();const ul=$t(cl);var fl=Ht();const hl=$t(fl);class dl extends hl{constructor(t,s=navigator.language){super();He(this,"track",null);He(this,"trackId",null);He(this,"recognition",null);He(this,"recognizing",!1);He(this,"transcripts",[]);He(this,"startTime",0);He(this,"endTime",0);He(this,"currentStamp",0);He(this,"start",()=>(this.recognition.start(),this.recognition.stream=this.track,this.recognizing=!0,this.startTime=performance.now(),this));He(this,"stop",()=>(this.recognition.stop(),this.recognizing=!1,this.endTime=performance.now(),this));("webkitSpeechRecognition"in window||"SpeechRecognition"in window)&&(this.recognition=new(window.SpeechRecognition||window.webkitSpeechRecognition),this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.lang=s,this.track=t,this.recognition.onstart=this.emit("start"),this.recognition.onend=()=>this.emit("end"),this.recognition.onresult=c=>{const{results:l,resultIndex:g}=c;let f="";if(l[g].isFinal&&l[g][0].transcript){const u={sentence:l[g][0].transcript,confidence:l[g][0].confidence,timeStamp:this.currentStamp,endTimeStamp:new Date().getTime()};this.transcripts.push(u),this.emit("sentence",u)}else this.currentStamp=new Date().getTime(),f+=l[g][0].transcript,this.emit("interim",{sentence:f,timeStamp:this.currentStamp});this.emit("result",c)})}}var pl=Object.defineProperty,Zo=Object.getOwnPropertySymbols,gl=Object.prototype.hasOwnProperty,yl=Object.prototype.propertyIsEnumerable,Tn=(r,e,t)=>e in r?pl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ml=(r,e)=>{for(var t in e||(e={}))gl.call(e,t)&&Tn(r,t,e[t]);if(Zo)for(var t of Zo(e))yl.call(e,t)&&Tn(r,t,e[t]);return r},gt=(r,e,t)=>Tn(r,typeof e!="symbol"?e+"":e,t),An=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class Qo{constructor(e={},t={}){gt(this,"mixer",null),gt(this,"recorder",null),gt(this,"localTranscriber",null),gt(this,"isRecording",!1),gt(this,"config"),gt(this,"callbacks"),this.config=ml({mimeType:"video/webm;codecs=vp8,opus",videoBitsPerSecond:1e6,audioBitsPerSecond:128e3,interval:1e3},e),this.callbacks=t}startRecording(e,t){return An(this,null,function*(){var s,c,l,g;try{if(console.log("[CallRecorder] Starting recording with",e.length,"streams"),this.isRecording)throw new Error("Recording already in progress");if(!t)throw new Error("Recording data is required");this.mixer=new ul(e),this.mixer.frameInterval=1,this.mixer.startDrawingFrames();const f=e[0];f&&f.getAudioTracks().length>0&&(this.localTranscriber=new dl(f)),MediaRecorder.isTypeSupported(this.config.mimeType)||(console.warn("[CallRecorder] Preferred mime type not supported, falling back to default"),this.config.mimeType="video/webm");const u=this.mixer.getMixedStream();this.recorder=new MediaRecorder(u,{mimeType:this.config.mimeType,videoBitsPerSecond:this.config.videoBitsPerSecond,audioBitsPerSecond:this.config.audioBitsPerSecond}),this.setupRecorderEventHandlers(t),this.recorder.start(this.config.interval),this.isRecording=!0,this.localTranscriber&&this.localTranscriber.start(),(c=(s=this.callbacks).onRecordingStarted)==null||c.call(s,t),console.log("[CallRecorder] Recording started successfully")}catch(f){throw console.error("[CallRecorder] Failed to start recording:",f),(g=(l=this.callbacks).onError)==null||g.call(l,f),f}})}stopRecording(){return An(this,null,function*(){var e,t;try{if(console.log("[CallRecorder] Stopping recording"),!this.isRecording||!this.recorder){console.warn("[CallRecorder] No active recording to stop");return}this.recorder.stop(),this.isRecording=!1,this.localTranscriber&&this.localTranscriber.stop(),this.mixer&&this.mixer.releaseStreams(),console.log("[CallRecorder] Recording stopped successfully")}catch(s){console.error("[CallRecorder] Failed to stop recording:",s),(t=(e=this.callbacks).onError)==null||t.call(e,s)}})}resetVideoStreams(e){this.mixer&&(this.mixer.resetVideoStreams(e),console.log("[CallRecorder] Video streams reset"))}setupRecorderEventHandlers(e){this.recorder&&(this.recorder.ondataavailable=t=>{var s,c;t.data&&t.data.size>0&&((c=(s=this.callbacks).onRecordingChunk)==null||c.call(s,t.data,e))},this.recorder.onstart=()=>{console.log("[CallRecorder] MediaRecorder started")},this.recorder.onstop=()=>{var t,s;console.log("[CallRecorder] MediaRecorder stopped"),(s=(t=this.callbacks).onRecordingStopped)==null||s.call(t,e,this.getTranscripts())},this.recorder.onerror=t=>{var s,c;console.error("[CallRecorder] MediaRecorder error:",t),(c=(s=this.callbacks).onError)==null||c.call(s,new Error(`Recording error: ${t}`))})}getRecordingState(){var e,t;return{isRecording:this.isRecording,isTranscribing:this.localTranscriber!==null,transcriptCount:((t=(e=this.localTranscriber)==null?void 0:e.transcripts)==null?void 0:t.length)||0}}getTranscripts(){var e;return((e=this.localTranscriber)==null?void 0:e.transcripts)||[]}static isRecordingSupported(){return typeof MediaRecorder!="undefined"&&typeof MediaRecorder.isTypeSupported=="function"}static isTranscriptionSupported(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}static getSupportedMimeTypes(){return["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=h264,opus","video/webm","video/mp4;codecs=h264,aac","video/mp4"].filter(t=>MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported(t))}cleanup(){return An(this,null,function*(){console.log("[CallRecorder] Cleaning up recorder"),this.isRecording&&(yield this.stopRecording()),this.localTranscriber&&(this.localTranscriber.stop(),this.localTranscriber=null),this.mixer&&(this.mixer.releaseStreams(),this.mixer=null),this.recorder=null})}}var vl=Object.defineProperty,wl=Object.defineProperties,bl=Object.getOwnPropertyDescriptors,ea=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,_l=Object.prototype.propertyIsEnumerable,In=(r,e,t)=>e in r?vl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ta=(r,e)=>{for(var t in e||(e={}))Sl.call(e,t)&&In(r,t,e[t]);if(ea)for(var t of ea(e))_l.call(e,t)&&In(r,t,e[t]);return r},ra=(r,e)=>wl(r,bl(e)),Ve=(r,e,t)=>In(r,typeof e!="symbol"?e+"":e,t),Oe=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});class na extends Yo{constructor(e,t={}){if(super(qe),Ve(this,"config"),Ve(this,"callbacks"),Ve(this,"socket"),Ve(this,"localParticipant",null),Ve(this,"participants",new Map),Ve(this,"recorder",null),Ve(this,"iceServers",[]),Ve(this,"isInitialized",!1),Ve(this,"listenersSetup",!1),Ve(this,"roomId"),Ve(this,"eventListeners",new Map),!e.user||!e.user.id)throw new Error("config.user with id must be provided");if(this.roomId=e.roomId,!this.roomId)throw new Error("roomId must be provided in config");this.config=ra(ta({maxParticipants:4,debug:!1,socketPath:"/apis/video-call",mediaConfig:{video:!0,audio:!0}},e),{roomId:this.roomId}),this.callbacks=t,this.socket=new qn(this.config.socketUrl,this.config.token,this.config.socketPath),this.iceServers=this.config.iceServers||[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}],this.state.setRoomId(this.roomId),console.log("[PeersCaller] Initialized with config:",{roomId:this.roomId,user:this.config.user,tokenLength:this.config.token.length,maxParticipants:this.config.maxParticipants})}initialize(){return Oe(this,null,function*(){try{if(console.log("[PeersCaller] Initializing..."),this.isInitialized){console.warn("[PeersCaller] Already initialized");return}yield this.socket.connect(),yield this.fetchIceServers(),this.setupSocketListeners(),yield this.initializeLocalParticipant(),this.isInitialized=!0,this.state.setCallStatus("idle"),console.log("[PeersCaller] Initialization completed successfully (ready to start/join call)")}catch(e){throw console.error("[PeersCaller] Initialization failed:",e),this.handleError("NETWORK_ERROR",`Failed to initialize: ${e}`),e}})}startCall(){return Oe(this,arguments,function*(e=this.config.mediaConfig){var t,s;try{if(console.log("[PeersCaller] Starting call..."),this.isInitialized||(yield this.initialize()),yield this.initializeLocalParticipant(),this.localParticipant&&!this.localParticipant.getCurrentStream()){const l={video:e!=null&&e.video&&typeof e.video=="boolean"?e.video:!0,audio:e!=null&&e.audio&&typeof e.audio=="boolean"?e.audio:!0};yield this.localParticipant.initialize(l)}this.state.setIsCalling(!0),this.state.setCallStatus("connecting"),console.log("[PeersCaller] Starting call for room:",this.config.roomId);const c=yield this.socket.startCall(this.config.roomId);if(console.log("[PeersCaller] Received call.start response:",c),c.success){this.state.setCallStatus("connected"),c.user&&this.localParticipant&&this.localParticipant.setUser(c.user),c.participants.forEach(g=>{const f=typeof g=="string"?{id:g}:g;f.id!==this.config.user.id&&this.handleParticipantJoined(f)}),console.log("[PeersCaller] Call started successfully");const l=c.participants.map(g=>typeof g=="string"?{id:g}:g);(s=(t=this.callbacks).onCallStarted)==null||s.call(t,ra(ta({},c),{participants:l})),yield this.handleAutoRecording()}else{this.state.setIsCalling(!1),this.state.setCallStatus("idle");const l="Failed to start call on server";throw this.handleError("SIGNALING_ERROR",l),console.error("[PeersCaller] Call start failed:",l),new Error(l)}}catch(c){throw console.error("[PeersCaller] Failed to start call:",c),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start call: ${c}`),c}})}joinCall(){return Oe(this,arguments,function*(e=this.config.mediaConfig){try{console.log("[PeersCaller] Joining call..."),this.isInitialized||(yield this.initialize()),yield this.initializeLocalParticipant();const t=yield this.checkCallStatus();if(!t.hasActiveCall)throw new Error("No active call found");if(!t.canJoin)throw new Error(`Cannot join call: ${t.status==="full"?"Call is full":"Unable to join"}`);if(this.state.setCallStatus("connecting"),this.localParticipant&&!this.localParticipant.getCurrentStream()){const c={video:typeof(e==null?void 0:e.video)=="boolean"?e.video:!0,audio:typeof(e==null?void 0:e.audio)=="boolean"?e.audio:!0};console.log("[PeersCaller] Initializing local media with config:",c),yield this.localParticipant.initialize(c)}console.log("[PeersCaller] Joining call for room:",this.config.roomId);const s=yield this.socket.joinRoom(this.config.roomId);console.log("[PeersCaller] Received call.join response:",s),this.state.setCallStatus("connected"),this.state.setIsCalling(!0),s.user&&this.localParticipant&&(this.localParticipant.setUser(s.user),console.log("[PeersCaller] Updated local participant user:",s.user)),s.participants.forEach(c=>{const l=typeof c=="string"?{id:c}:c;l.id!==this.config.user.id&&this.handleParticipantJoined(l)}),console.log("[PeersCaller] Joined call successfully"),yield this.handleAutoRecording()}catch(t){throw console.error("[PeersCaller] Failed to join call:",t),this.state.setCallStatus("idle"),this.handleError("INVALID_ROOM_ID",`Failed to join call: ${t}`),t}})}endCall(){return Oe(this,null,function*(){try{console.log("[PeersCaller] Ending call..."),this.recorder&&this.state.isRecording&&(yield this.stopRecording());try{yield this.socket.endCallForAll(this.config.roomId),console.log("[PeersCaller] End call request sent to server")}catch(e){console.warn("[PeersCaller] Failed to notify server of call end:",e)}this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),console.log("[PeersCaller] Call ended successfully")}catch(e){console.error("[PeersCaller] Error ending call:",e)}})}leaveCall(){return Oe(this,null,function*(){try{console.log("[PeersCaller] Leaving call..."),console.log("[PeersCaller] Leaving call for room:",this.config.roomId);const e=yield this.socket.leaveCall(this.config.roomId);if(console.log("[PeersCaller] Received call.leave response:",e),e.success)this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),console.log("[PeersCaller] Left call successfully");else{const t="Failed to leave call on server";throw this.handleError("SIGNALING_ERROR",t),console.error("[PeersCaller] Call leave failed:",t),new Error(t)}}catch(e){throw console.error("[PeersCaller] Failed to leave call:",e),this.handleError("SIGNALING_ERROR",`Failed to leave call: ${e}`),e}})}toggleAudio(e){this.localParticipant&&(this.localParticipant.toggleAudio(e),this.broadcastStateUpdate({audioOn:e}),console.log(`[PeersCaller] Audio ${e?"enabled":"disabled"}`))}toggleVideo(e){this.localParticipant&&(this.localParticipant.toggleVideo(e),this.broadcastStateUpdate({videoOn:e}),console.log(`[PeersCaller] Video ${e?"enabled":"disabled"}`))}startScreenShare(){return Oe(this,null,function*(){try{if(!this.localParticipant)throw new Error("Local participant not initialized");yield this.localParticipant.startScreenShare(),this.broadcastStateUpdate({screenSharing:!0}),console.log("[PeersCaller] Screen sharing started")}catch(e){throw console.error("[PeersCaller] Failed to start screen share:",e),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start screen share: ${e}`),e}})}stopScreenShare(){return Oe(this,null,function*(){try{if(!this.localParticipant)throw new Error("Local participant not initialized");yield this.localParticipant.stopScreenShare(),this.broadcastStateUpdate({screenSharing:!1}),console.log("[PeersCaller] Screen sharing stopped")}catch(e){throw console.error("[PeersCaller] Failed to stop screen share:",e),e}})}startRecording(e,t){return Oe(this,null,function*(){var s;try{if(console.log("[PeersCaller] Starting recording..."),this.state.isRecording){console.warn("[PeersCaller] Recording already in progress");return}const c=[],l=(s=this.localParticipant)==null?void 0:s.getCurrentStream();l&&c.push(l);for(const g of this.participants.values()){const f=g.getCurrentStream();f&&c.push(f)}if(c.length===0)throw new Error("No streams available for recording");this.recorder=new Qo(t,{onRecordingStarted:g=>{this.socket.startRecording(this.config.roomId,g.id)},onRecordingChunk:(g,f)=>{this.socket.sendRecordingChunk(this.config.roomId,f.id,g)},onRecordingStopped:(g,f)=>{this.socket.endRecording(this.config.roomId,g.id,f)},onTranscriptReceived:g=>{this.socket.sendTranscript(this.config.roomId,g.text)},onError:g=>{this.handleError("RECORDING_FAILED",g.message)}}),yield this.recorder.startRecording(c,e),this.state.setIsRecording(!0),console.log("[PeersCaller] Recording started successfully")}catch(c){throw console.error("[PeersCaller] Failed to start recording:",c),this.handleError("RECORDING_FAILED",`Failed to start recording: ${c}`),c}})}stopRecording(){return Oe(this,null,function*(){try{if(console.log("[PeersCaller] Stopping recording..."),!this.recorder||!this.state.isRecording){console.warn("[PeersCaller] No active recording to stop");return}yield this.recorder.stopRecording(),this.state.setIsRecording(!1),console.log("[PeersCaller] Recording stopped successfully")}catch(e){throw console.error("[PeersCaller] Failed to stop recording:",e),e}})}handleAutoRecording(){return Oe(this,null,function*(){if(this.config.autoRecording){if(this.state.isRecording){console.log("[PeersCaller] Recording already in progress, skipping auto recording");return}if(!this.config.getRecordingOptions){console.warn("[PeersCaller] Auto recording enabled but getRecordingOptions callback not provided");return}try{console.log("[PeersCaller] Auto recording enabled, fetching recording options...");const e=yield this.config.getRecordingOptions();if(!e||!e.recordingData){console.warn("[PeersCaller] getRecordingOptions did not return valid recording data");return}console.log("[PeersCaller] Starting auto recording with options:",e.recordingData),yield this.startRecording(e.recordingData,e.config)}catch(e){console.error("[PeersCaller] Failed to start auto recording:",e),this.handleError("RECORDING_FAILED",`Auto recording failed: ${e}`)}}})}getCallState(){return this.state}getLocalParticipant(){return this.localParticipant}getParticipants(){return new Map(this.participants)}getParticipant(e){return this.participants.get(e)}getDebugInfo(){return{isInitialized:this.isInitialized,localParticipant:this.localParticipant?{userId:this.localParticipant.getUserId(),hasStream:!!this.localParticipant.getCurrentStream(),streamTracks:this.localParticipant.getCurrentStream()?{video:this.localParticipant.getCurrentStream().getVideoTracks().length,audio:this.localParticipant.getCurrentStream().getAudioTracks().length}:null,peerConnections:Array.from(this.localParticipant.getAllPeerConnections().keys()),connectionStatus:this.localParticipant.getConnectionStatus()}:null,remoteParticipants:Array.from(this.participants.keys()),storeState:this.state,socketConnected:this.socket.isConnected()}}cleanup(){return Oe(this,null,function*(){console.log("[PeersCaller] Cleaning up..."),this.state.isCalling&&(yield this.endCall()),this.cleanupSocketListeners(),this.cleanupAllParticipants(),this.recorder&&(this.recorder.cleanup(),this.recorder=null),this.socket.disconnect(),this.state.resetCall(),this.isInitialized=!1,console.log("[PeersCaller] Cleanup completed")})}initializeLocalParticipant(){return Oe(this,null,function*(){this.localParticipant||(this.localParticipant=new Rn(this.config.user,{onSignal:(e,t,s)=>{this.forwardSignalToServer(e,t,s)},onError:e=>this.handleError("UNKNOWN_ERROR",e.message)},!0)),console.log("[PeersCaller] Local participant created (media not initialized yet)")})}setupSocketListeners(){if(this.listenersSetup){console.log("[PeersCaller] Socket listeners already set up, skipping...");return}this.cleanupSocketListeners(),console.log("[PeersCaller] Setting up socket listeners...");const e=P=>{const y=typeof P.user=="string"?{id:P.user}:P.user||{id:P.userId};this.handleParticipantJoined(y)};this.socket.on("call.participant.joined",e),this.eventListeners.set("call.participant.joined",e);const t=P=>{const y=typeof P.user=="string"?{id:P.user}:P.user||{id:P.userId};this.handleParticipantLeft(y)};this.socket.on("call.participant.left",t),this.eventListeners.set("call.participant.left",t);const s=P=>{P.participants.forEach(y=>{const C=typeof y=="string"?{id:y}:y;C.id!==this.config.user.id&&this.handleParticipantJoined(C)})};this.socket.on("call.participants",s),this.eventListeners.set("call.participants",s);const c=()=>{this.state.setIsCalling(!1)};this.socket.on("call.left",c),this.eventListeners.set("call.left",c);const l=P=>{var y,C;console.error("[PeersCaller] Server error:",P),(C=(y=this.callbacks).onError)==null||C.call(y,P.error,P.message)};this.socket.on("call.error",l),this.eventListeners.set("call.error",l);const g=P=>{this.handleOffer(P.from,P.offer)};this.socket.on("call.offer",g),this.eventListeners.set("call.offer",g);const f=P=>{this.handleAnswer(P.from,P.answer)};this.socket.on("call.answer",f),this.eventListeners.set("call.answer",f);const u=P=>{this.handleCandidate(P.from,P.candidate)};this.socket.on("call.candidate",u),this.eventListeners.set("call.candidate",u);const m=P=>{this.handleParticipantStateUpdate(P.from,P.state)};this.socket.on("call.state",m),this.eventListeners.set("call.state",m);const h=P=>{this.handleCallEnded(P)};this.socket.on("call.ended",h),this.eventListeners.set("call.ended",h);const B=P=>{this.handleCallStatusChanged(P)};this.socket.on("call.status.changed",B),this.eventListeners.set("call.status.changed",B);const I=P=>{console.log("[PeersCaller] Recording started:",P.recordingId),this.state.setIsRecording(!0)};this.socket.on("call.recording.start",I),this.eventListeners.set("call.recording.start",I);const $=P=>{console.log("[PeersCaller] Recording chunk received:",P)};this.socket.on("call.recording.chunk.received",$),this.eventListeners.set("call.recording.chunk.received",$);const b=P=>{console.log("[PeersCaller] Recording ended:",P.recordingId),this.state.setIsRecording(!1)};this.socket.on("call.recording.end",b),this.eventListeners.set("call.recording.end",b);const k=P=>{console.log("[PeersCaller] Transcript received:",P)};this.socket.on("call.transcript",k),this.eventListeners.set("call.transcript",k),this.listenersSetup=!0,console.log("[PeersCaller] Socket listeners set up successfully")}cleanupSocketListeners(){if(!(!this.listenersSetup&&this.eventListeners.size===0)){console.log("[PeersCaller] Cleaning up socket listeners...");for(const[e,t]of this.eventListeners)this.socket.off(e,t);this.eventListeners.clear(),this.listenersSetup=!1,console.log("[PeersCaller] Socket listeners cleaned up successfully")}}handleParticipantJoined(e){return Oe(this,null,function*(){var t,s;try{if(e.id===this.config.user.id||this.participants.has(e.id))return;if(this.participants.size>=this.config.maxParticipants-1){console.warn("[PeersCaller] Maximum participants reached");return}console.log(`[PeersCaller] Participant ${e.id} (${e.name||"Unknown"}) joined`);const c=new Rn(e,{onStreamReceived:(f,u)=>{var m,h;const B=this.participants.get(f),I=(B==null?void 0:B.getUser())||{id:f};(h=(m=this.callbacks).onStreamReceived)==null||h.call(m,I,u)},onPeerConnected:f=>{console.log(`[PeersCaller] Peer connection established with ${f}`)},onPeerDisconnected:f=>{const u=this.participants.get(f),m=(u==null?void 0:u.getUser())||{id:f};this.handleParticipantLeft(m)},onSignal:(f,u,m)=>{this.forwardSignalToServer(f,u,m)},onError:f=>{this.handleError("PEER_CONNECTION_FAILED",f.message)}},!1);if(this.participants.set(e.id,c),!this.localParticipant){console.error("[PeersCaller] Cannot create peer connection - local participant not initialized");return}const l=this.config.user.id<e.id,g={iceServers:this.iceServers,initiator:l};yield this.localParticipant.createPeerConnection(e.id,g,l),(s=(t=this.callbacks).onParticipantJoined)==null||s.call(t,{user:e,videoOn:!0,audioOn:!0,screenSharing:!1})}catch(c){console.error(`[PeersCaller] Failed to handle participant ${e.id} joining:`,c)}})}checkCallStatus(){return Oe(this,null,function*(){try{if(console.log("[PeersCaller] Checking call status..."),!this.socket.isConnected())throw new Error("Socket not connected");this.state.setCallStatusLoading(!0),this.state.setCallStatusError(null);const e=yield this.socket.checkCallStatus(this.config.roomId);return this.state.setCallStatusInfo(e),this.state.setCallStatusLoading(!1),console.log("[PeersCaller] Call status received:",e),e}catch(e){console.error("[PeersCaller] Failed to check call status:",e);const t=e instanceof Error?e.message:String(e);throw this.state.setCallStatusLoading(!1),this.state.setCallStatusError(t),this.handleError("NETWORK_ERROR",`Failed to check call status: ${t}`),e}})}handleOffer(e,t){return Oe(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received offer from ${e} but local participant not initialized`);return}const s=this.localParticipant.getPeerConnection(e);s?(console.log(`[PeersCaller] Processing offer from ${e}`),s.signal({type:"offer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for offer from ${e}`)}catch(s){console.error(`[PeersCaller] Failed to handle offer from ${e}:`,s)}})}handleAnswer(e,t){return Oe(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received answer from ${e} but local participant not initialized`);return}const s=this.localParticipant.getPeerConnection(e);s?(console.log(`[PeersCaller] Processing answer from ${e}`),s.signal({type:"answer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for answer from ${e}`)}catch(s){console.error(`[PeersCaller] Failed to handle answer from ${e}:`,s)}})}handleCandidate(e,t){return Oe(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received candidate from ${e} but local participant not initialized`);return}const s=this.localParticipant.getPeerConnection(e);s?(console.log(`[PeersCaller] Processing candidate from ${e}`),s.signal({type:"candidate",candidate:t})):console.warn(`[PeersCaller] No peer connection found for candidate from ${e}`)}catch(s){console.error(`[PeersCaller] Failed to handle candidate from ${e}:`,s)}})}handleParticipantStateUpdate(e,t){var s,c;this.state.updateParticipant(e,t);const l=this.participants.get(e),g=(l==null?void 0:l.getUser())||{id:e};(c=(s=this.callbacks).onParticipantStateChanged)==null||c.call(s,g,t)}handleParticipantLeft(e){var t,s;console.log(`[PeersCaller] Participant ${e.id} (${e.name||"Unknown"}) left`);const c=this.participants.get(e.id);c&&(c.cleanup(),this.participants.delete(e.id)),this.localParticipant&&this.localParticipant.destroyPeerConnection(e.id),this.state.removeParticipant(e.id),(s=(t=this.callbacks).onParticipantLeft)==null||s.call(t,e)}handleCallEnded(e){return Oe(this,null,function*(){var t,s;const c=typeof e.endedBy=="string"?{id:e.endedBy}:e.endedBy;console.log(`[PeersCaller] Call ended by ${c.id} (${c.name||"Unknown"}), reason: ${e.reason}`);try{this.recorder&&this.state.isRecording&&(yield this.stopRecording()),this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),(s=(t=this.callbacks).onCallEnded)==null||s.call(t,{roomId:e.roomId,endedBy:c,reason:e.reason}),console.log("[PeersCaller] Call ended cleanup completed")}catch(l){console.error("[PeersCaller] Error handling call ended:",l)}})}broadcastStateUpdate(e){for(const t of this.participants.keys())this.socket.sendStateUpdate(t,e,this.config.roomId)}handleCallStatusChanged(e){var t,s;console.log("[PeersCaller] Call status changed:",e),this.state.setCallStatusInfo(e),(s=(t=this.callbacks).onCallStatusChanged)==null||s.call(t,e)}cleanupAllParticipants(){for(const e of this.participants.values())e.cleanup();this.participants.clear(),this.localParticipant&&(this.localParticipant.cleanup(),this.localParticipant=null)}handleError(e,t){var s,c;console.error(`[PeersCaller] ${e}: ${t}`),this.state.setError(e,t),(c=(s=this.callbacks).onError)==null||c.call(s,e,t)}fetchIceServers(){return Oe(this,null,function*(){try{console.log("[PeersCaller] Fetching ICE servers from backend...");const e=yield this.socket.getIceServers(this.roomId);if(e.error){console.warn("[PeersCaller] Failed to fetch ICE servers from backend:",e.error),console.log("[PeersCaller] Using default ICE servers");return}e.iceServers&&e.iceServers.length>0?this.iceServers=e.iceServers:console.log("[PeersCaller] No ICE servers received from backend, using defaults")}catch(e){console.warn("[PeersCaller] Error fetching ICE servers:",e)}})}forwardSignalToServer(e,t,s){try{switch(console.log(`[PeersCaller] Forwarding signal from ${e} to ${t}:`,s.type),s.type){case"offer":this.socket.sendOffer(t,s,this.config.roomId);break;case"answer":this.socket.sendAnswer(t,s,this.config.roomId);break;case"candidate":this.socket.sendCandidate(t,s.candidate,this.config.roomId);break;case"renegotiate":console.log(`[PeersCaller] Renegotiation signal from ${e} to ${t} - handled locally`);break;default:console.warn(`[PeersCaller] Unknown signal type: ${s.type} - this may indicate a new signal type that needs handling`),this.config.debug&&console.log("[PeersCaller] Unknown signal data:",s);break}}catch(c){console.error(`[PeersCaller] Failed to forward signal from ${e} to ${t}:`,c),this.handleError("SIGNALING_ERROR",`Failed to forward signal: ${c}`)}}}const ia=se.createContext(null);function El({options:r,children:e}){const t=oa(r);return ca.createElement(ia.Provider,{value:t},e)}function Cl(){const r=se.useContext(ia);if(!r)throw new Error("useVideoCallContext must be used within a VideoCallProvider. Wrap your component tree with <VideoCallProvider> to use this hook.");return r}var Xe=(r,e,t)=>new Promise((s,c)=>{var l=u=>{try{f(t.next(u))}catch(m){c(m)}},g=u=>{try{f(t.throw(u))}catch(m){c(m)}},f=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,g);f((t=t.apply(r,e)).next())});function oa(r){const[e,t]=se.useState(null),[s,c]=se.useState(!1),l=se.useRef(!1),g=qe(R=>R),f=Object.values(qe(R=>R.participants)),u=qe(R=>R.localParticipant),m=qe(R=>R.callStatus==="connected"),h=qe(R=>R.isRecording),B=qe(R=>R.error),I=se.useCallback(()=>Xe(null,null,function*(){if(!(l.current||e))try{l.current=!0;const R=new na(r,r.callbacks);yield R.initialize(),t(R),c(!0)}catch(R){throw console.error("[useVideoCall] Failed to initialize:",R),l.current=!1,R}}),[r,e]),$=se.useCallback(R=>Xe(null,null,function*(){if(!e){yield I();return}return e.startCall(R)}),[e,I]),b=se.useCallback(R=>Xe(null,null,function*(){if(!e){yield I();return}return e.joinCall(R)}),[e,I]),k=se.useCallback(()=>{e==null||e.endCall()},[e]),P=se.useCallback(R=>{e==null||e.toggleAudio(R)},[e]),y=se.useCallback(R=>{e==null||e.toggleVideo(R)},[e]),C=se.useCallback(()=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startScreenShare()}),[e]),A=se.useCallback(()=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopScreenShare()}),[e]),T=se.useCallback(R=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startRecording(R)}),[e]),O=se.useCallback(()=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopRecording()}),[e]),S=se.useCallback(()=>{e&&(e.cleanup(),t(null),c(!1),l.current=!1)},[e]);return se.useEffect(()=>{r.autoInitialize&&!s&&!l.current&&I().catch(console.error)},[r.autoInitialize,s,I]),se.useEffect(()=>()=>{S()},[S]),{initialize:I,startCall:$,joinCall:b,endCall:k,toggleAudio:P,toggleVideo:y,startScreenShare:C,stopScreenShare:A,startRecording:T,stopRecording:O,callState:g,participants:f,localParticipant:u,isConnected:m,isRecording:h,error:B,cleanup:S,peersCaller:e}}function Rl(r){const[e,t]=se.useState(null),[s,c]=se.useState(null),l=qe(g=>g.participants[r]);return se.useEffect(()=>{var g;if(l!=null&&l.stream){if(c(l.stream),!e){const f=document.createElement("video");f.autoplay=!0,f.playsInline=!0,f.muted=r===((g=qe.getState().localParticipant)==null?void 0:g.user.id),t(f)}e&&(e.srcObject=l.stream)}},[l==null?void 0:l.stream,r,e]),se.useEffect(()=>()=>{e&&(e.srcObject=null)},[e]),{videoElement:e,stream:s,participant:l}}function Pl(){const r=qe();return{roomId:r.roomId,participants:r.participants,localParticipant:r.localParticipant,isCalling:r.isCalling,isRecording:r.isRecording,recordLoading:r.recordLoading,callStatus:r.callStatus,error:r.error,participantCount:Object.keys(r.participants).length,isConnected:r.callStatus==="connected",hasError:!!r.error}}function Tl(){const[r,e]=se.useState({videoDevices:[],audioDevices:[]}),[t,s]=se.useState({camera:null,microphone:null}),c=se.useCallback(()=>Xe(null,null,function*(){try{const f=yield navigator.mediaDevices.enumerateDevices();e({videoDevices:f.filter(u=>u.kind==="videoinput"),audioDevices:f.filter(u=>u.kind==="audioinput")})}catch(f){console.error("[useMediaDevices] Failed to get devices:",f)}}),[]),l=se.useCallback(()=>Xe(null,null,function*(){try{if("permissions"in navigator){const f=yield navigator.permissions.query({name:"camera"}),u=yield navigator.permissions.query({name:"microphone"});s({camera:f.state,microphone:u.state})}}catch(f){console.error("[useMediaDevices] Failed to check permissions:",f)}}),[]),g=se.useCallback(()=>Xe(null,null,function*(){try{return(yield navigator.mediaDevices.getUserMedia({video:!0,audio:!0})).getTracks().forEach(u=>u.stop()),yield l(),yield c(),!0}catch(f){return console.error("[useMediaDevices] Failed to request permissions:",f),!1}}),[l,c]);return se.useEffect(()=>{var f;c(),l();const u=()=>{c()};return(f=navigator.mediaDevices)==null||f.addEventListener("devicechange",u),()=>{var m;(m=navigator.mediaDevices)==null||m.removeEventListener("devicechange",u)}},[c,l]),{devices:r,permissions:t,getDevices:c,checkPermissions:l,requestPermissions:g}}function Al(){const[r,e]=se.useState({webRTC:!1,getUserMedia:!1,getDisplayMedia:!1,mediaRecorder:!1,speechRecognition:!1});return se.useEffect(()=>{e({webRTC:!!window.RTCPeerConnection,getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),mediaRecorder:typeof MediaRecorder!="undefined",speechRecognition:!!(window.SpeechRecognition||window.webkitSpeechRecognition)})},[]),{support:r,isSupported:Object.values(r).every(Boolean),unsupportedFeatures:Object.entries(r).filter(([,t])=>!t).map(([t])=>t)}}function Il(r=""){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return r?`${r}_${e}_${t}`:`${e}_${t}`}const Bl=()=>`peer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,kl=r=>!r||typeof r!="string"?!1:/^peer_\d+_[a-z0-9]{1,9}$/.test(r),Ol=r=>{var e,t;return{video:(e=r.video)!=null?e:!0,audio:(t=r.audio)!=null?t:!0}};function Ml(r,e,t){const s=`[${r}] ${e}`,c=new Error(s);return t&&(c.details=t),c}function Ll(){const r={getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),RTCPeerConnection:!!window.RTCPeerConnection,MediaRecorder:typeof MediaRecorder!="undefined",WebSocket:typeof WebSocket!="undefined"},e=Object.entries(r).filter(([,t])=>!t).map(([t])=>t);return{supported:e.length===0,features:r,missingFeatures:e}}const Nl=()=>{try{return typeof window!="undefined"&&typeof window.RTCPeerConnection!="undefined"&&typeof navigator!="undefined"&&typeof navigator.mediaDevices!="undefined"&&typeof navigator.mediaDevices.getUserMedia!="undefined"}catch(r){return!1}};function Dl(){return[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun3.l.google.com:19302"}]}te.CallMediaStream=xn,te.CallParticipant=Rn,te.CallPeerConnection=Do,te.CallRecorder=Qo,te.CallSocket=qn,te.PeersCaller=na,te.VideoCallProvider=El,te.canAcceptMoreParticipants=Zs,te.checkWebRTCSupport=Ll,te.formatError=Ml,te.formatMediaConstraints=Ol,te.generateId=Il,te.generatePeerId=Bl,te.getDefaultIceServers=Dl,te.getParticipant=Jo,te.getParticipantList=Xs,te.isParticipantConnected=Ks,te.isValidPeerId=kl,te.isWebRTCSupported=Nl,te.selectCallStatus=$s,te.selectCallStatusError=Hs,te.selectCallStatusInfo=Gs,te.selectCallStatusLoading=zs,te.selectCanJoinCall=Js,te.selectError=Vs,te.selectIsCallActive=Ys,te.selectIsConnected=Ws,te.selectLocalParticipant=xs,te.selectParticipantCount=Ho,te.selectParticipants=qs,te.useBrowserSupport=Al,te.useCallState=Pl,te.useCallStore=qe,te.useMediaDevices=Tl,te.useParticipantVideo=Rl,te.useTesterStore=Ls,te.useVideoCall=oa,te.useVideoCallContext=Cl,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});
|
|
22
17
|
//# sourceMappingURL=peers-caller.umd.js.map
|