@sawport/peers-caller 1.0.0-alpha.4 → 1.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,27 @@
1
- (function(Y,ae){typeof exports=="object"&&typeof module!="undefined"?ae(exports,require("socket.io-client"),require("zustand"),require("react")):typeof define=="function"&&define.amd?define(["exports","socket.io-client","zustand","react"],ae):(Y=typeof globalThis!="undefined"?globalThis:Y||self,ae(Y.PeersCaller={},Y.io,Y.zustand,Y.React))})(this,function(Y,ae,ye,Q){"use strict";var Ws=Object.defineProperty,Vs=Object.defineProperties;var zs=Object.getOwnPropertyDescriptors;var pt=Object.getOwnPropertySymbols;var Co=Object.prototype.hasOwnProperty,Eo=Object.prototype.propertyIsEnumerable;var oe=Math.pow,an=(Y,ae,ye)=>ae in Y?Ws(Y,ae,{enumerable:!0,configurable:!0,writable:!0,value:ye}):Y[ae]=ye,et=(Y,ae)=>{for(var ye in ae||(ae={}))Co.call(ae,ye)&&an(Y,ye,ae[ye]);if(pt)for(var ye of pt(ae))Eo.call(ae,ye)&&an(Y,ye,ae[ye]);return Y},sn=(Y,ae)=>Vs(Y,zs(ae));var ln=(Y,ae)=>{var ye={};for(var Q in Y)Co.call(Y,Q)&&ae.indexOf(Q)<0&&(ye[Q]=Y[Q]);if(Y!=null&&pt)for(var Q of pt(Y))ae.indexOf(Q)<0&&Eo.call(Y,Q)&&(ye[Q]=Y[Q]);return ye};var Te=(Y,ae,ye)=>an(Y,typeof ae!="symbol"?ae+"":ae,ye);var gt={};typeof gt=="undefined"?globalThis.process={env:{},browser:!0,version:"v18.0.0",nextTick:(n,...e)=>{setTimeout(()=>n(...e),0)}}:typeof gt.nextTick=="undefined"&&(gt.nextTick=(n,...e)=>{setTimeout(()=>n(...e),0)}),typeof globalThis=="undefined"&&(globalThis.global=globalThis);var Ro=Object.defineProperty,Po=(n,e,t)=>e in n?Ro(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ne=(n,e,t)=>Po(n,typeof e!="symbol"?e+"":e,t),Ie=(n,e,t)=>new Promise((o,l)=>{var c=f=>{try{a(t.next(f))}catch(u){l(u)}},E=f=>{try{a(t.throw(f))}catch(u){l(u)}},a=f=>f.done?o(f.value):Promise.resolve(f.value).then(c,E);a((t=t.apply(n,e)).next())});class cn{constructor(e,t,o="/apis/video-call"){Ne(this,"socket",null),Ne(this,"serverUrl"),Ne(this,"socketPath"),Ne(this,"token"),Ne(this,"connected",!1),Ne(this,"reconnectAttempts",0),Ne(this,"maxReconnectAttempts",5),this.serverUrl=e,this.token=t,this.socketPath=o}connect(){return Ie(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=ae.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",o=>{this.connected=!1,console.log("[CallSocket] Disconnected:",o),this.handleDisconnection(o)}),this.socket.on("connect_error",o=>{console.error("[CallSocket] Connection error:",o),this.reconnectAttempts++,this.reconnectAttempts>=this.maxReconnectAttempts&&t(new Error(`Failed to connect after ${this.maxReconnectAttempts} attempts`))})}catch(o){t(o)}}))})}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 o;if(!this.isConnected())throw new Error("Socket not connected");console.log(`[CallSocket] Emitting ${e}:`,t),(o=this.socket)==null||o.emit(e,t,l=>{l!=null&&l.error&&console.error(`[CallSocket] Error in ${e}:`,l.error)})}emitWithResponse(e,t,o=1e4){return Ie(this,null,function*(){if(!this.isConnected())throw new Error("Socket not connected");return console.log(`[CallSocket] Emitting ${e} with response:`,t),new Promise((l,c)=>{var E;const a=setTimeout(()=>{c(new Error(`Timeout waiting for response to ${e}`))},o);console.log(`[CallSocket] about to emit: ${e}...`),(E=this.socket)==null||E.emit(e,t,f=>{clearTimeout(a),f!=null&&f.error?(console.error(`[CallSocket] Error in ${e}:`,f.error),c(new Error(f.error))):(console.log(`[CallSocket] Response for ${e}:`,f),l(f))})})})}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 Ie(this,null,function*(){return this.emitWithResponse("call.start",{roomId:e})})}joinRoom(e){return Ie(this,null,function*(){return this.emitWithResponse("call.join",{roomId:e})})}leaveCall(e){return Ie(this,null,function*(){return this.emitWithResponse("call.leave",{roomId:e})})}sendOffer(e,t,o){this.emit("call.offer",{to:e,offer:t,roomId:o})}sendAnswer(e,t,o){this.emit("call.answer",{to:e,answer:t,roomId:o})}sendCandidate(e,t,o){this.emit("call.candidate",{to:e,candidate:t,roomId:o})}sendStateUpdate(e,t,o){this.emit("call.state",{to:e,state:t,roomId:o})}endCall(e,t,o){this.emit("call.end",{roomId:o,targetUserId:e})}endCallForAll(e){return Ie(this,null,function*(){this.emit("call.end",{roomId:e})})}startRecording(e,t){return Ie(this,null,function*(){return this.emitWithResponse("call.recording.start",{roomId:e,recordingId:t})})}sendRecordingChunk(e,t,o){this.emit("call.recording.chunk",{roomId:e,recordingId:t,chunk:o})}endRecording(e,t){return Ie(this,null,function*(){return this.emitWithResponse("call.recording.end",{roomId:e,recordingId:t})})}sendTranscript(e,t){this.emit("call.transcript",{roomId:e,transcript:t,timestamp:Date.now()})}checkCallStatus(e){return Ie(this,null,function*(){return this.emitWithResponse("call.status",{roomId:e})})}getIceServers(e){return Ie(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 Ao=Object.defineProperty,To=(n,e,t)=>e in n?Ao(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,He=(n,e,t)=>To(n,typeof e!="symbol"?e+"":e,t),tt=(n,e,t)=>new Promise((o,l)=>{var c=f=>{try{a(t.next(f))}catch(u){l(u)}},E=f=>{try{a(t.throw(f))}catch(u){l(u)}},a=f=>f.done?o(f.value):Promise.resolve(f.value).then(c,E);a((t=t.apply(n,e)).next())});class un{constructor(e={video:!0,audio:!0}){He(this,"cameraStream",null),He(this,"screenStream",null),He(this,"videoElement",null),He(this,"constraints"),He(this,"isScreenShare",!1),this.constraints=e}initialize(){return tt(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 tt(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 tt(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(l=>{l.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(l=>{l.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(o=>o.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(),o=e.getAudioTracks();return{id:e.id,videoTracks:t.length,audioTracks:o.length,isScreenShare:this.isScreenShare,videoEnabled:t.length>0?t[0].enabled:!1,audioEnabled:o.length>0?o[0].enabled:!1,videoConstraints:t.length>0?t[0].getSettings():null,audioConstraints:o.length>0?o[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 tt(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 yt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var rt={exports:{}},mt,fn;function Io(){if(fn)return mt;fn=1;var n=1e3,e=n*60,t=e*60,o=t*24,l=o*7,c=o*365.25;mt=function(w,A){A=A||{};var C=typeof w;if(C==="string"&&w.length>0)return E(w);if(C==="number"&&isFinite(w))return A.long?f(w):a(w);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(w))};function E(w){if(w=String(w),!(w.length>100)){var A=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(w);if(A){var C=parseFloat(A[1]),j=(A[2]||"ms").toLowerCase();switch(j){case"years":case"year":case"yrs":case"yr":case"y":return C*c;case"weeks":case"week":case"w":return C*l;case"days":case"day":case"d":return C*o;case"hours":case"hour":case"hrs":case"hr":case"h":return C*t;case"minutes":case"minute":case"mins":case"min":case"m":return C*e;case"seconds":case"second":case"secs":case"sec":case"s":return C*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return C;default:return}}}}function a(w){var A=Math.abs(w);return A>=o?Math.round(w/o)+"d":A>=t?Math.round(w/t)+"h":A>=e?Math.round(w/e)+"m":A>=n?Math.round(w/n)+"s":w+"ms"}function f(w){var A=Math.abs(w);return A>=o?u(w,A,o,"day"):A>=t?u(w,A,t,"hour"):A>=e?u(w,A,e,"minute"):A>=n?u(w,A,n,"second"):w+" ms"}function u(w,A,C,j){var y=A>=C*1.5;return Math.round(w/C)+" "+j+(y?"s":"")}return mt}var vt,dn;function ko(){if(dn)return vt;dn=1;function n(e){o.debug=o,o.default=o,o.coerce=u,o.disable=a,o.enable=c,o.enabled=f,o.humanize=Io(),o.destroy=w,Object.keys(e).forEach(A=>{o[A]=e[A]}),o.names=[],o.skips=[],o.formatters={};function t(A){let C=0;for(let j=0;j<A.length;j++)C=(C<<5)-C+A.charCodeAt(j),C|=0;return o.colors[Math.abs(C)%o.colors.length]}o.selectColor=t;function o(A){let C,j=null,y,I;function _(...h){if(!_.enabled)return;const b=_,P=Number(new Date),S=P-(C||P);b.diff=S,b.prev=C,b.curr=P,C=P,h[0]=o.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let R=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(p,B)=>{if(p==="%%")return"%";R++;const U=o.formatters[B];if(typeof U=="function"){const F=h[R];p=U.call(b,F),h.splice(R,1),R--}return p}),o.formatArgs.call(b,h),(b.log||o.log).apply(b,h)}return _.namespace=A,_.useColors=o.useColors(),_.color=o.selectColor(A),_.extend=l,_.destroy=o.destroy,Object.defineProperty(_,"enabled",{enumerable:!0,configurable:!1,get:()=>j!==null?j:(y!==o.namespaces&&(y=o.namespaces,I=o.enabled(A)),I),set:h=>{j=h}}),typeof o.init=="function"&&o.init(_),_}function l(A,C){const j=o(this.namespace+(typeof C=="undefined"?":":C)+A);return j.log=this.log,j}function c(A){o.save(A),o.namespaces=A,o.names=[],o.skips=[];const C=(typeof A=="string"?A:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const j of C)j[0]==="-"?o.skips.push(j.slice(1)):o.names.push(j)}function E(A,C){let j=0,y=0,I=-1,_=0;for(;j<A.length;)if(y<C.length&&(C[y]===A[j]||C[y]==="*"))C[y]==="*"?(I=y,_=j,y++):(j++,y++);else if(I!==-1)y=I+1,_++,j=_;else return!1;for(;y<C.length&&C[y]==="*";)y++;return y===C.length}function a(){const A=[...o.names,...o.skips.map(C=>"-"+C)].join(",");return o.enable(""),A}function f(A){for(const C of o.skips)if(E(A,C))return!1;for(const C of o.names)if(E(A,C))return!0;return!1}function u(A){return A instanceof Error?A.stack||A.message:A}function w(){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 o.enable(o.load()),o}return vt=n,vt}var hn;function Oo(){return hn||(hn=1,function(n,e){var t={env:{}};e.formatArgs=l,e.save=c,e.load=E,e.useColors=o,e.storage=a(),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 o(){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 l(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+n.exports.humanize(this.diff),!this.useColors)return;const w="color: "+this.color;u.splice(1,0,w,"color: inherit");let A=0,C=0;u[0].replace(/%[a-zA-Z%]/g,j=>{j!=="%%"&&(A++,j==="%c"&&(C=A))}),u.splice(C,0,w)}e.log=console.debug||console.log||(()=>{});function c(u){try{u?e.storage.setItem("debug",u):e.storage.removeItem("debug")}catch(w){}}function E(){let u;try{u=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch(w){}return!u&&typeof t!="undefined"&&"env"in t&&(u=t.env.DEBUG),u}function a(){try{return localStorage}catch(u){}}n.exports=ko()(e);const{formatters:f}=n.exports;f.j=function(u){try{return JSON.stringify(u)}catch(w){return"[UnexpectedJSONParseError]: "+w.message}}}(rt,rt.exports)),rt.exports}var bt,pn;function Mo(){return pn||(pn=1,bt=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}),bt}var nt={exports:{}},it={exports:{}},wt={},gn;function Je(){return gn||(gn=1,function(n){Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},t={};t.byteLength=w,t.toByteArray=C,t.fromByteArray=I;for(var o=[],l=[],c=typeof Uint8Array!="undefined"?Uint8Array:Array,E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,f=E.length;a<f;++a)o[a]=E[a],l[E.charCodeAt(a)]=a;l[45]=62,l[95]=63;function u(b){var P=b.length;if(P%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var S=b.indexOf("=");S===-1&&(S=P);var R=S===P?0:4-S%4;return[S,R]}function w(b){var P=u(b),S=P[0],R=P[1];return(S+R)*3/4-R}function A(b,P,S){return(P+S)*3/4-S}function C(b){var P,S=u(b),R=S[0],v=S[1],p=new c(A(b,R,v)),B=0,U=v>0?R-4:R,F;for(F=0;F<U;F+=4)P=l[b.charCodeAt(F)]<<18|l[b.charCodeAt(F+1)]<<12|l[b.charCodeAt(F+2)]<<6|l[b.charCodeAt(F+3)],p[B++]=P>>16&255,p[B++]=P>>8&255,p[B++]=P&255;return v===2&&(P=l[b.charCodeAt(F)]<<2|l[b.charCodeAt(F+1)]>>4,p[B++]=P&255),v===1&&(P=l[b.charCodeAt(F)]<<10|l[b.charCodeAt(F+1)]<<4|l[b.charCodeAt(F+2)]>>2,p[B++]=P>>8&255,p[B++]=P&255),p}function j(b){return o[b>>18&63]+o[b>>12&63]+o[b>>6&63]+o[b&63]}function y(b,P,S){for(var R,v=[],p=P;p<S;p+=3)R=(b[p]<<16&16711680)+(b[p+1]<<8&65280)+(b[p+2]&255),v.push(j(R));return v.join("")}function I(b){for(var P,S=b.length,R=S%3,v=[],p=16383,B=0,U=S-R;B<U;B+=p)v.push(y(b,B,B+p>U?U:B+p));return R===1?(P=b[S-1],v.push(o[P>>2]+o[P<<4&63]+"==")):R===2&&(P=(b[S-2]<<8)+b[S-1],v.push(o[P>>10]+o[P>>4&63]+o[P<<2&63]+"=")),v.join("")}var _={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */_.read=function(b,P,S,R,v){var p,B,U=v*8-R-1,F=(1<<U)-1,J=F>>1,O=-7,ne=S?v-1:0,re=S?-1:1,ce=b[P+ne];for(ne+=re,p=ce&(1<<-O)-1,ce>>=-O,O+=U;O>0;p=p*256+b[P+ne],ne+=re,O-=8);for(B=p&(1<<-O)-1,p>>=-O,O+=R;O>0;B=B*256+b[P+ne],ne+=re,O-=8);if(p===0)p=1-J;else{if(p===F)return B?NaN:(ce?-1:1)*(1/0);B=B+Math.pow(2,R),p=p-J}return(ce?-1:1)*B*Math.pow(2,p-R)},_.write=function(b,P,S,R,v,p){var B,U,F,J=p*8-v-1,O=(1<<J)-1,ne=O>>1,re=v===23?Math.pow(2,-24)-Math.pow(2,-77):0,ce=R?0:p-1,fe=R?1:-1,_e=P<0||P===0&&1/P<0?1:0;for(P=Math.abs(P),isNaN(P)||P===1/0?(U=isNaN(P)?1:0,B=O):(B=Math.floor(Math.log(P)/Math.LN2),P*(F=Math.pow(2,-B))<1&&(B--,F*=2),B+ne>=1?P+=re/F:P+=re*Math.pow(2,1-ne),P*F>=2&&(B++,F/=2),B+ne>=O?(U=0,B=O):B+ne>=1?(U=(P*F-1)*Math.pow(2,v),B=B+ne):(U=P*Math.pow(2,ne-1)*Math.pow(2,v),B=0));v>=8;b[S+ce]=U&255,ce+=fe,U/=256,v-=8);for(B=B<<v|U,J+=v;J>0;b[S+ce]=B&255,ce+=fe,B/=256,J-=8);b[S+ce-fe]|=_e*128};/*!
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,Ie,ue){"use strict";var El=Object.defineProperty,Cl=Object.defineProperties;var Rl=Object.getOwnPropertyDescriptors;var Ft=Object.getOwnPropertySymbols;var Ko=Object.prototype.hasOwnProperty,Xo=Object.prototype.propertyIsEnumerable;var oe=Math.pow,Bn=(te,ge,Ie)=>ge in te?El(te,ge,{enumerable:!0,configurable:!0,writable:!0,value:Ie}):te[ge]=Ie,St=(te,ge)=>{for(var Ie in ge||(ge={}))Ko.call(ge,Ie)&&Bn(te,Ie,ge[Ie]);if(Ft)for(var Ie of Ft(ge))Xo.call(ge,Ie)&&Bn(te,Ie,ge[Ie]);return te},kn=(te,ge)=>Cl(te,Rl(ge));var On=(te,ge)=>{var Ie={};for(var ue in te)Ko.call(te,ue)&&ge.indexOf(ue)<0&&(Ie[ue]=te[ue]);if(te!=null&&Ft)for(var ue of Ft(te))ge.indexOf(ue)<0&&Xo.call(te,ue)&&(Ie[ue]=te[ue]);return Ie};var ze=(te,ge,Ie)=>Bn(te,typeof ge!="symbol"?ge+"":ge,Ie);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 Ie=new MessageChannel;Ie.port2.onmessage=function(){te.apply(null,ge)},Ie.port1.postMessage(null)}else setTimeoutfunction Zo(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Mn={exports:{}},Be=Mn.exports={},He,Je;function Ut(){throw new Error("setTimeout has not been defined")}function $t(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?He=setTimeout:He=Ut}catch(r){He=Ut}try{typeof clearTimeout=="function"?Je=clearTimeout:Je=$t}catch(r){Je=$t}})();function Ln(r){if(He===setTimeout)return setTimeout(r,0);if((He===Ut||!He)&&setTimeout)return He=setTimeout,setTimeout(r,0);try{return He(r,0)}catch(e){try{return He.call(null,r,0)}catch(t){return He.call(this,r,0)}}}function Qo(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,nt,_t=-1;function ea(){!st||!nt||(st=!1,nt.length?Qe=nt.concat(Qe):_t=-1,Qe.length&&Nn())}function Nn(){if(!st){var r=Ln(ea);st=!0;for(var e=Qe.length;e;){for(nt=Qe,Qe=[];++_t<e;)nt&&nt[_t].run();_t=-1,e=Qe.length}nt=null,st=!1,Qo(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 Dn(r,e)),Qe.length===1&&!st&&Ln(Nn)};function Dn(r,e){this.fun=r,this.array=e}Dn.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 ta=Mn.exports;const ae=Zo(ta);var Fn={},Et={};Et.byteLength=ia,Et.toByteArray=aa,Et.fromByteArray=ca;for(var Ye=[],xe=[],ra=typeof Uint8Array!="undefined"?Uint8Array:Array,jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lt=0,na=jt.length;lt<na;++lt)Ye[lt]=jt[lt],xe[jt.charCodeAt(lt)]=lt;xe[45]=62,xe[95]=63;function Un(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 ia(r){var e=Un(r),t=e[0],s=e[1];return(t+s)*3/4-s}function oa(r,e,t){return(e+t)*3/4-t}function aa(r){var e,t=Un(r),s=t[0],u=t[1],l=new ra(oa(r,s,u)),g=0,f=u>0?s-4:s,c;for(c=0;c<f;c+=4)e=xe[r.charCodeAt(c)]<<18|xe[r.charCodeAt(c+1)]<<12|xe[r.charCodeAt(c+2)]<<6|xe[r.charCodeAt(c+3)],l[g++]=e>>16&255,l[g++]=e>>8&255,l[g++]=e&255;return u===2&&(e=xe[r.charCodeAt(c)]<<2|xe[r.charCodeAt(c+1)]>>4,l[g++]=e&255),u===1&&(e=xe[r.charCodeAt(c)]<<10|xe[r.charCodeAt(c+1)]<<4|xe[r.charCodeAt(c+2)]>>2,l[g++]=e>>8&255,l[g++]=e&255),l}function sa(r){return Ye[r>>18&63]+Ye[r>>12&63]+Ye[r>>6&63]+Ye[r&63]}function la(r,e,t){for(var s,u=[],l=e;l<t;l+=3)s=(r[l]<<16&16711680)+(r[l+1]<<8&65280)+(r[l+2]&255),u.push(sa(s));return u.join("")}function ca(r){for(var e,t=r.length,s=t%3,u=[],l=16383,g=0,f=t-s;g<f;g+=l)u.push(la(r,g,g+l>f?f:g+l));return s===1?(e=r[t-1],u.push(Ye[e>>2]+Ye[e<<4&63]+"==")):s===2&&(e=(r[t-2]<<8)+r[t-1],u.push(Ye[e>>10]+Ye[e>>4&63]+Ye[e<<2&63]+"=")),u.join("")}var qt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */qt.read=function(r,e,t,s,u){var l,g,f=u*8-s-1,c=(1<<f)-1,v=c>>1,h=-7,I=t?u-1:0,B=t?-1:1,x=r[e+I];for(I+=B,l=x&(1<<-h)-1,x>>=-h,h+=f;h>0;l=l*256+r[e+I],I+=B,h-=8);for(g=l&(1<<-h)-1,l>>=-h,h+=s;h>0;g=g*256+r[e+I],I+=B,h-=8);if(l===0)l=1-v;else{if(l===c)return g?NaN:(x?-1:1)*(1/0);g=g+Math.pow(2,s),l=l-v}return(x?-1:1)*g*Math.pow(2,l-s)},qt.write=function(r,e,t,s,u,l){var g,f,c,v=l*8-u-1,h=(1<<v)-1,I=h>>1,B=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=s?0:l-1,b=s?1:-1,N=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*(c=Math.pow(2,-g))<1&&(g--,c*=2),g+I>=1?e+=B/c:e+=B*Math.pow(2,1-I),e*c>=2&&(g++,c/=2),g+I>=h?(f=0,g=h):g+I>=1?(f=(e*c-1)*Math.pow(2,u),g=g+I):(f=e*Math.pow(2,I-1)*Math.pow(2,u),g=0));u>=8;r[t+x]=f&255,x+=b,f/=256,u-=8);for(g=g<<u|f,v+=u;v>0;r[t+x]=g&255,x+=b,g/=256,v-=8);r[t+x-b]|=N*128};/*!
2
2
  * The buffer module from node.js, for the browser.
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */(function(b){const P=t,S=_,R=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;b.Buffer=O,b.SlowBuffer=L,b.INSPECT_MAX_BYTES=50;const v=2147483647;b.kMaxLength=v;const{Uint8Array:p,ArrayBuffer:B,SharedArrayBuffer:U}=globalThis;O.TYPED_ARRAY_SUPPORT=F(),!O.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 F(){try{const s=new p(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,p.prototype),Object.setPrototypeOf(s,r),s.foo()===42}catch(s){return!1}}Object.defineProperty(O.prototype,"parent",{enumerable:!0,get:function(){if(O.isBuffer(this))return this.buffer}}),Object.defineProperty(O.prototype,"offset",{enumerable:!0,get:function(){if(O.isBuffer(this))return this.byteOffset}});function J(s){if(s>v)throw new RangeError('The value "'+s+'" is invalid for option "size"');const r=new p(s);return Object.setPrototypeOf(r,O.prototype),r}function O(s,r,i){if(typeof s=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return fe(s)}return ne(s,r,i)}O.poolSize=8192;function ne(s,r,i){if(typeof s=="string")return _e(s,r);if(B.isView(s))return be(s);if(s==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s);if(Oe(s,B)||s&&Oe(s.buffer,B)||typeof U!="undefined"&&(Oe(s,U)||s&&Oe(s.buffer,U)))return se(s,r,i);if(typeof s=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=s.valueOf&&s.valueOf();if(m!=null&&m!==s)return O.from(m,r,i);const T=Ee(s);if(T)return T;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof s[Symbol.toPrimitive]=="function")return O.from(s[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s)}O.from=function(s,r,i){return ne(s,r,i)},Object.setPrototypeOf(O.prototype,p.prototype),Object.setPrototypeOf(O,p);function re(s){if(typeof s!="number")throw new TypeError('"size" argument must be of type number');if(s<0)throw new RangeError('The value "'+s+'" is invalid for option "size"')}function ce(s,r,i){return re(s),s<=0?J(s):r!==void 0?typeof i=="string"?J(s).fill(r,i):J(s).fill(r):J(s)}O.alloc=function(s,r,i){return ce(s,r,i)};function fe(s){return re(s),J(s<0?0:ve(s)|0)}O.allocUnsafe=function(s){return fe(s)},O.allocUnsafeSlow=function(s){return fe(s)};function _e(s,r){if((typeof r!="string"||r==="")&&(r="utf8"),!O.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=$(s,r)|0;let m=J(i);const T=m.write(s,r);return T!==i&&(m=m.slice(0,T)),m}function de(s){const r=s.length<0?0:ve(s.length)|0,i=J(r);for(let m=0;m<r;m+=1)i[m]=s[m]&255;return i}function be(s){if(Oe(s,p)){const r=new p(s);return se(r.buffer,r.byteOffset,r.byteLength)}return de(s)}function se(s,r,i){if(r<0||s.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(s.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let m;return r===void 0&&i===void 0?m=new p(s):i===void 0?m=new p(s,r):m=new p(s,r,i),Object.setPrototypeOf(m,O.prototype),m}function Ee(s){if(O.isBuffer(s)){const r=ve(s.length)|0,i=J(r);return i.length===0||s.copy(i,0,0,r),i}if(s.length!==void 0)return typeof s.length!="number"||on(s.length)?J(0):de(s);if(s.type==="Buffer"&&Array.isArray(s.data))return de(s.data)}function ve(s){if(s>=v)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+v.toString(16)+" bytes");return s|0}function L(s){return+s!=s&&(s=0),O.alloc(+s)}O.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==O.prototype},O.compare=function(r,i){if(Oe(r,p)&&(r=O.from(r,r.offset,r.byteLength)),Oe(i,p)&&(i=O.from(i,i.offset,i.byteLength)),!O.isBuffer(r)||!O.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let m=r.length,T=i.length;for(let N=0,W=Math.min(m,T);N<W;++N)if(r[N]!==i[N]){m=r[N],T=i[N];break}return m<T?-1:T<m?1:0},O.isEncoding=function(r){switch(String(r).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}},O.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return O.alloc(0);let m;if(i===void 0)for(i=0,m=0;m<r.length;++m)i+=r[m].length;const T=O.allocUnsafe(i);let N=0;for(m=0;m<r.length;++m){let W=r[m];if(Oe(W,p))N+W.length>T.length?(O.isBuffer(W)||(W=O.from(W)),W.copy(T,N)):p.prototype.set.call(T,W,N);else if(O.isBuffer(W))W.copy(T,N);else throw new TypeError('"list" argument must be an Array of Buffers');N+=W.length}return T};function $(s,r){if(O.isBuffer(s))return s.length;if(B.isView(s)||Oe(s,B))return s.byteLength;if(typeof s!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof s);const i=s.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&i===0)return 0;let T=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return nn(s).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return _o(s).length;default:if(T)return m?-1:nn(s).length;r=(""+r).toLowerCase(),T=!0}}O.byteLength=$;function z(s,r,i){let m=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(s||(s="utf8");;)switch(s){case"hex":return Ce(this,r,i);case"utf8":case"utf-8":return H(this,r,i);case"ascii":return te(this,r,i);case"latin1":case"binary":return q(this,r,i);case"base64":return x(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Se(this,r,i);default:if(m)throw new TypeError("Unknown encoding: "+s);s=(s+"").toLowerCase(),m=!0}}O.prototype._isBuffer=!0;function K(s,r,i){const m=s[r];s[r]=s[i],s[i]=m}O.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)K(this,i,i+1);return this},O.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)K(this,i,i+3),K(this,i+1,i+2);return this},O.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)K(this,i,i+7),K(this,i+1,i+6),K(this,i+2,i+5),K(this,i+3,i+4);return this},O.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?H(this,0,r):z.apply(this,arguments)},O.prototype.toLocaleString=O.prototype.toString,O.prototype.equals=function(r){if(!O.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:O.compare(this,r)===0},O.prototype.inspect=function(){let r="";const i=b.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},R&&(O.prototype[R]=O.prototype.inspect),O.prototype.compare=function(r,i,m,T,N){if(Oe(r,p)&&(r=O.from(r,r.offset,r.byteLength)),!O.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),m===void 0&&(m=r?r.length:0),T===void 0&&(T=0),N===void 0&&(N=this.length),i<0||m>r.length||T<0||N>this.length)throw new RangeError("out of range index");if(T>=N&&i>=m)return 0;if(T>=N)return-1;if(i>=m)return 1;if(i>>>=0,m>>>=0,T>>>=0,N>>>=0,this===r)return 0;let W=N-T,ee=m-i;const pe=Math.min(W,ee),ue=this.slice(T,N),ge=r.slice(i,m);for(let ie=0;ie<pe;++ie)if(ue[ie]!==ge[ie]){W=ue[ie],ee=ge[ie];break}return W<ee?-1:ee<W?1:0};function M(s,r,i,m,T){if(s.length===0)return-1;if(typeof i=="string"?(m=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,on(i)&&(i=T?0:s.length-1),i<0&&(i=s.length+i),i>=s.length){if(T)return-1;i=s.length-1}else if(i<0)if(T)i=0;else return-1;if(typeof r=="string"&&(r=O.from(r,m)),O.isBuffer(r))return r.length===0?-1:k(s,r,i,m,T);if(typeof r=="number")return r=r&255,typeof p.prototype.indexOf=="function"?T?p.prototype.indexOf.call(s,r,i):p.prototype.lastIndexOf.call(s,r,i):k(s,[r],i,m,T);throw new TypeError("val must be string, number or Buffer")}function k(s,r,i,m,T){let N=1,W=s.length,ee=r.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(s.length<2||r.length<2)return-1;N=2,W/=2,ee/=2,i/=2}function pe(ge,ie){return N===1?ge[ie]:ge.readUInt16BE(ie*N)}let ue;if(T){let ge=-1;for(ue=i;ue<W;ue++)if(pe(s,ue)===pe(r,ge===-1?0:ue-ge)){if(ge===-1&&(ge=ue),ue-ge+1===ee)return ge*N}else ge!==-1&&(ue-=ue-ge),ge=-1}else for(i+ee>W&&(i=W-ee),ue=i;ue>=0;ue--){let ge=!0;for(let ie=0;ie<ee;ie++)if(pe(s,ue+ie)!==pe(r,ie)){ge=!1;break}if(ge)return ue}return-1}O.prototype.includes=function(r,i,m){return this.indexOf(r,i,m)!==-1},O.prototype.indexOf=function(r,i,m){return M(this,r,i,m,!0)},O.prototype.lastIndexOf=function(r,i,m){return M(this,r,i,m,!1)};function D(s,r,i,m){i=Number(i)||0;const T=s.length-i;m?(m=Number(m),m>T&&(m=T)):m=T;const N=r.length;m>N/2&&(m=N/2);let W;for(W=0;W<m;++W){const ee=parseInt(r.substr(W*2,2),16);if(on(ee))return W;s[i+W]=ee}return W}function V(s,r,i,m){return ht(nn(r,s.length-i),s,i,m)}function G(s,r,i,m){return ht($s(r),s,i,m)}function d(s,r,i,m){return ht(_o(r),s,i,m)}function g(s,r,i,m){return ht(Us(r,s.length-i),s,i,m)}O.prototype.write=function(r,i,m,T){if(i===void 0)T="utf8",m=this.length,i=0;else if(m===void 0&&typeof i=="string")T=i,m=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(m)?(m=m>>>0,T===void 0&&(T="utf8")):(T=m,m=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const N=this.length-i;if((m===void 0||m>N)&&(m=N),r.length>0&&(m<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");T||(T="utf8");let W=!1;for(;;)switch(T){case"hex":return D(this,r,i,m);case"utf8":case"utf-8":return V(this,r,i,m);case"ascii":case"latin1":case"binary":return G(this,r,i,m);case"base64":return d(this,r,i,m);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return g(this,r,i,m);default:if(W)throw new TypeError("Unknown encoding: "+T);T=(""+T).toLowerCase(),W=!0}},O.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(s,r,i){return r===0&&i===s.length?P.fromByteArray(s):P.fromByteArray(s.slice(r,i))}function H(s,r,i){i=Math.min(s.length,i);const m=[];let T=r;for(;T<i;){const N=s[T];let W=null,ee=N>239?4:N>223?3:N>191?2:1;if(T+ee<=i){let pe,ue,ge,ie;switch(ee){case 1:N<128&&(W=N);break;case 2:pe=s[T+1],(pe&192)===128&&(ie=(N&31)<<6|pe&63,ie>127&&(W=ie));break;case 3:pe=s[T+1],ue=s[T+2],(pe&192)===128&&(ue&192)===128&&(ie=(N&15)<<12|(pe&63)<<6|ue&63,ie>2047&&(ie<55296||ie>57343)&&(W=ie));break;case 4:pe=s[T+1],ue=s[T+2],ge=s[T+3],(pe&192)===128&&(ue&192)===128&&(ge&192)===128&&(ie=(N&15)<<18|(pe&63)<<12|(ue&63)<<6|ge&63,ie>65535&&ie<1114112&&(W=ie))}}W===null?(W=65533,ee=1):W>65535&&(W-=65536,m.push(W>>>10&1023|55296),W=56320|W&1023),m.push(W),T+=ee}return Z(m)}const X=4096;function Z(s){const r=s.length;if(r<=X)return String.fromCharCode.apply(String,s);let i="",m=0;for(;m<r;)i+=String.fromCharCode.apply(String,s.slice(m,m+=X));return i}function te(s,r,i){let m="";i=Math.min(s.length,i);for(let T=r;T<i;++T)m+=String.fromCharCode(s[T]&127);return m}function q(s,r,i){let m="";i=Math.min(s.length,i);for(let T=r;T<i;++T)m+=String.fromCharCode(s[T]);return m}function Ce(s,r,i){const m=s.length;(!r||r<0)&&(r=0),(!i||i<0||i>m)&&(i=m);let T="";for(let N=r;N<i;++N)T+=qs[s[N]];return T}function Se(s,r,i){const m=s.slice(r,i);let T="";for(let N=0;N<m.length-1;N+=2)T+=String.fromCharCode(m[N]+m[N+1]*256);return T}O.prototype.slice=function(r,i){const m=this.length;r=~~r,i=i===void 0?m:~~i,r<0?(r+=m,r<0&&(r=0)):r>m&&(r=m),i<0?(i+=m,i<0&&(i=0)):i>m&&(i=m),i<r&&(i=r);const T=this.subarray(r,i);return Object.setPrototypeOf(T,O.prototype),T};function le(s,r,i){if(s%1!==0||s<0)throw new RangeError("offset is not uint");if(s+r>i)throw new RangeError("Trying to access beyond buffer length")}O.prototype.readUintLE=O.prototype.readUIntLE=function(r,i,m){r=r>>>0,i=i>>>0,m||le(r,i,this.length);let T=this[r],N=1,W=0;for(;++W<i&&(N*=256);)T+=this[r+W]*N;return T},O.prototype.readUintBE=O.prototype.readUIntBE=function(r,i,m){r=r>>>0,i=i>>>0,m||le(r,i,this.length);let T=this[r+--i],N=1;for(;i>0&&(N*=256);)T+=this[r+--i]*N;return T},O.prototype.readUint8=O.prototype.readUInt8=function(r,i){return r=r>>>0,i||le(r,1,this.length),this[r]},O.prototype.readUint16LE=O.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||le(r,2,this.length),this[r]|this[r+1]<<8},O.prototype.readUint16BE=O.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||le(r,2,this.length),this[r]<<8|this[r+1]},O.prototype.readUint32LE=O.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||le(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},O.prototype.readUint32BE=O.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||le(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},O.prototype.readBigUInt64LE=Le(function(r){r=r>>>0,Ge(r,"offset");const i=this[r],m=this[r+7];(i===void 0||m===void 0)&&Qe(r,this.length-8);const T=i+this[++r]*oe(2,8)+this[++r]*oe(2,16)+this[++r]*oe(2,24),N=this[++r]+this[++r]*oe(2,8)+this[++r]*oe(2,16)+m*oe(2,24);return BigInt(T)+(BigInt(N)<<BigInt(32))}),O.prototype.readBigUInt64BE=Le(function(r){r=r>>>0,Ge(r,"offset");const i=this[r],m=this[r+7];(i===void 0||m===void 0)&&Qe(r,this.length-8);const T=i*oe(2,24)+this[++r]*oe(2,16)+this[++r]*oe(2,8)+this[++r],N=this[++r]*oe(2,24)+this[++r]*oe(2,16)+this[++r]*oe(2,8)+m;return(BigInt(T)<<BigInt(32))+BigInt(N)}),O.prototype.readIntLE=function(r,i,m){r=r>>>0,i=i>>>0,m||le(r,i,this.length);let T=this[r],N=1,W=0;for(;++W<i&&(N*=256);)T+=this[r+W]*N;return N*=128,T>=N&&(T-=Math.pow(2,8*i)),T},O.prototype.readIntBE=function(r,i,m){r=r>>>0,i=i>>>0,m||le(r,i,this.length);let T=i,N=1,W=this[r+--T];for(;T>0&&(N*=256);)W+=this[r+--T]*N;return N*=128,W>=N&&(W-=Math.pow(2,8*i)),W},O.prototype.readInt8=function(r,i){return r=r>>>0,i||le(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},O.prototype.readInt16LE=function(r,i){r=r>>>0,i||le(r,2,this.length);const m=this[r]|this[r+1]<<8;return m&32768?m|4294901760:m},O.prototype.readInt16BE=function(r,i){r=r>>>0,i||le(r,2,this.length);const m=this[r+1]|this[r]<<8;return m&32768?m|4294901760:m},O.prototype.readInt32LE=function(r,i){return r=r>>>0,i||le(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},O.prototype.readInt32BE=function(r,i){return r=r>>>0,i||le(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},O.prototype.readBigInt64LE=Le(function(r){r=r>>>0,Ge(r,"offset");const i=this[r],m=this[r+7];(i===void 0||m===void 0)&&Qe(r,this.length-8);const T=this[r+4]+this[r+5]*oe(2,8)+this[r+6]*oe(2,16)+(m<<24);return(BigInt(T)<<BigInt(32))+BigInt(i+this[++r]*oe(2,8)+this[++r]*oe(2,16)+this[++r]*oe(2,24))}),O.prototype.readBigInt64BE=Le(function(r){r=r>>>0,Ge(r,"offset");const i=this[r],m=this[r+7];(i===void 0||m===void 0)&&Qe(r,this.length-8);const T=(i<<24)+this[++r]*oe(2,16)+this[++r]*oe(2,8)+this[++r];return(BigInt(T)<<BigInt(32))+BigInt(this[++r]*oe(2,24)+this[++r]*oe(2,16)+this[++r]*oe(2,8)+m)}),O.prototype.readFloatLE=function(r,i){return r=r>>>0,i||le(r,4,this.length),S.read(this,r,!0,23,4)},O.prototype.readFloatBE=function(r,i){return r=r>>>0,i||le(r,4,this.length),S.read(this,r,!1,23,4)},O.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||le(r,8,this.length),S.read(this,r,!0,52,8)},O.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||le(r,8,this.length),S.read(this,r,!1,52,8)};function he(s,r,i,m,T,N){if(!O.isBuffer(s))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>T||r<N)throw new RangeError('"value" argument is out of bounds');if(i+m>s.length)throw new RangeError("Index out of range")}O.prototype.writeUintLE=O.prototype.writeUIntLE=function(r,i,m,T){if(r=+r,i=i>>>0,m=m>>>0,!T){const ee=Math.pow(2,8*m)-1;he(this,r,i,m,ee,0)}let N=1,W=0;for(this[i]=r&255;++W<m&&(N*=256);)this[i+W]=r/N&255;return i+m},O.prototype.writeUintBE=O.prototype.writeUIntBE=function(r,i,m,T){if(r=+r,i=i>>>0,m=m>>>0,!T){const ee=Math.pow(2,8*m)-1;he(this,r,i,m,ee,0)}let N=m-1,W=1;for(this[i+N]=r&255;--N>=0&&(W*=256);)this[i+N]=r/W&255;return i+m},O.prototype.writeUint8=O.prototype.writeUInt8=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,1,255,0),this[i]=r&255,i+1},O.prototype.writeUint16LE=O.prototype.writeUInt16LE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},O.prototype.writeUint16BE=O.prototype.writeUInt16BE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},O.prototype.writeUint32LE=O.prototype.writeUInt32LE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},O.prototype.writeUint32BE=O.prototype.writeUInt32BE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function Ae(s,r,i,m,T){So(r,m,T,s,i,7);let N=Number(r&BigInt(4294967295));s[i++]=N,N=N>>8,s[i++]=N,N=N>>8,s[i++]=N,N=N>>8,s[i++]=N;let W=Number(r>>BigInt(32)&BigInt(4294967295));return s[i++]=W,W=W>>8,s[i++]=W,W=W>>8,s[i++]=W,W=W>>8,s[i++]=W,i}function Ve(s,r,i,m,T){So(r,m,T,s,i,7);let N=Number(r&BigInt(4294967295));s[i+7]=N,N=N>>8,s[i+6]=N,N=N>>8,s[i+5]=N,N=N>>8,s[i+4]=N;let W=Number(r>>BigInt(32)&BigInt(4294967295));return s[i+3]=W,W=W>>8,s[i+2]=W,W=W>>8,s[i+1]=W,W=W>>8,s[i]=W,i+8}O.prototype.writeBigUInt64LE=Le(function(r,i=0){return Ae(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),O.prototype.writeBigUInt64BE=Le(function(r,i=0){return Ve(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),O.prototype.writeIntLE=function(r,i,m,T){if(r=+r,i=i>>>0,!T){const pe=Math.pow(2,8*m-1);he(this,r,i,m,pe-1,-pe)}let N=0,W=1,ee=0;for(this[i]=r&255;++N<m&&(W*=256);)r<0&&ee===0&&this[i+N-1]!==0&&(ee=1),this[i+N]=(r/W>>0)-ee&255;return i+m},O.prototype.writeIntBE=function(r,i,m,T){if(r=+r,i=i>>>0,!T){const pe=Math.pow(2,8*m-1);he(this,r,i,m,pe-1,-pe)}let N=m-1,W=1,ee=0;for(this[i+N]=r&255;--N>=0&&(W*=256);)r<0&&ee===0&&this[i+N+1]!==0&&(ee=1),this[i+N]=(r/W>>0)-ee&255;return i+m},O.prototype.writeInt8=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},O.prototype.writeInt16LE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},O.prototype.writeInt16BE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},O.prototype.writeInt32LE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},O.prototype.writeInt32BE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},O.prototype.writeBigInt64LE=Le(function(r,i=0){return Ae(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),O.prototype.writeBigInt64BE=Le(function(r,i=0){return Ve(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ze(s,r,i,m,T,N){if(i+m>s.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function Be(s,r,i,m,T){return r=+r,i=i>>>0,T||ze(s,r,i,4),S.write(s,r,i,m,23,4),i+4}O.prototype.writeFloatLE=function(r,i,m){return Be(this,r,i,!0,m)},O.prototype.writeFloatBE=function(r,i,m){return Be(this,r,i,!1,m)};function Me(s,r,i,m,T){return r=+r,i=i>>>0,T||ze(s,r,i,8),S.write(s,r,i,m,52,8),i+8}O.prototype.writeDoubleLE=function(r,i,m){return Me(this,r,i,!0,m)},O.prototype.writeDoubleBE=function(r,i,m){return Me(this,r,i,!1,m)},O.prototype.copy=function(r,i,m,T){if(!O.isBuffer(r))throw new TypeError("argument should be a Buffer");if(m||(m=0),!T&&T!==0&&(T=this.length),i>=r.length&&(i=r.length),i||(i=0),T>0&&T<m&&(T=m),T===m||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(m<0||m>=this.length)throw new RangeError("Index out of range");if(T<0)throw new RangeError("sourceEnd out of bounds");T>this.length&&(T=this.length),r.length-i<T-m&&(T=r.length-i+m);const N=T-m;return this===r&&typeof p.prototype.copyWithin=="function"?this.copyWithin(i,m,T):p.prototype.set.call(r,this.subarray(m,T),i),N},O.prototype.fill=function(r,i,m,T){if(typeof r=="string"){if(typeof i=="string"?(T=i,i=0,m=this.length):typeof m=="string"&&(T=m,m=this.length),T!==void 0&&typeof T!="string")throw new TypeError("encoding must be a string");if(typeof T=="string"&&!O.isEncoding(T))throw new TypeError("Unknown encoding: "+T);if(r.length===1){const W=r.charCodeAt(0);(T==="utf8"&&W<128||T==="latin1")&&(r=W)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<m)throw new RangeError("Out of range index");if(m<=i)return this;i=i>>>0,m=m===void 0?this.length:m>>>0,r||(r=0);let N;if(typeof r=="number")for(N=i;N<m;++N)this[N]=r;else{const W=O.isBuffer(r)?r:O.from(r,T),ee=W.length;if(ee===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(N=0;N<m-i;++N)this[N+i]=W[N%ee]}return this};const Re={};function rn(s,r,i){Re[s]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${s}]`,this.stack,delete this.name}get code(){return s}set code(T){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:T,writable:!0})}toString(){return`${this.name} [${s}]: ${this.message}`}}}rn("ERR_BUFFER_OUT_OF_BOUNDS",function(s){return s?`${s} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),rn("ERR_INVALID_ARG_TYPE",function(s,r){return`The "${s}" argument must be of type number. Received type ${typeof r}`},TypeError),rn("ERR_OUT_OF_RANGE",function(s,r,i){let m=`The value of "${s}" is out of range.`,T=i;return Number.isInteger(i)&&Math.abs(i)>oe(2,32)?T=wo(String(i)):typeof i=="bigint"&&(T=String(i),(i>oe(BigInt(2),BigInt(32))||i<-oe(BigInt(2),BigInt(32)))&&(T=wo(T)),T+="n"),m+=` It must be ${r}. Received ${T}`,m},RangeError);function wo(s){let r="",i=s.length;const m=s[0]==="-"?1:0;for(;i>=m+4;i-=3)r=`_${s.slice(i-3,i)}${r}`;return`${s.slice(0,i)}${r}`}function Ds(s,r,i){Ge(r,"offset"),(s[r]===void 0||s[r+i]===void 0)&&Qe(r,s.length-(i+1))}function So(s,r,i,m,T,N){if(s>i||s<r){const W=typeof r=="bigint"?"n":"";let ee;throw r===0||r===BigInt(0)?ee=`>= 0${W} and < 2${W} ** ${(N+1)*8}${W}`:ee=`>= -(2${W} ** ${(N+1)*8-1}${W}) and < 2 ** ${(N+1)*8-1}${W}`,new Re.ERR_OUT_OF_RANGE("value",ee,s)}Ds(m,T,N)}function Ge(s,r){if(typeof s!="number")throw new Re.ERR_INVALID_ARG_TYPE(r,"number",s)}function Qe(s,r,i){throw Math.floor(s)!==s?(Ge(s,i),new Re.ERR_OUT_OF_RANGE("offset","an integer",s)):r<0?new Re.ERR_BUFFER_OUT_OF_BOUNDS:new Re.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,s)}const Fs=/[^+/0-9A-Za-z-_]/g;function js(s){if(s=s.split("=")[0],s=s.trim().replace(Fs,""),s.length<2)return"";for(;s.length%4!==0;)s=s+"=";return s}function nn(s,r){r=r||1/0;let i;const m=s.length;let T=null;const N=[];for(let W=0;W<m;++W){if(i=s.charCodeAt(W),i>55295&&i<57344){if(!T){if(i>56319){(r-=3)>-1&&N.push(239,191,189);continue}else if(W+1===m){(r-=3)>-1&&N.push(239,191,189);continue}T=i;continue}if(i<56320){(r-=3)>-1&&N.push(239,191,189),T=i;continue}i=(T-55296<<10|i-56320)+65536}else T&&(r-=3)>-1&&N.push(239,191,189);if(T=null,i<128){if((r-=1)<0)break;N.push(i)}else if(i<2048){if((r-=2)<0)break;N.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;N.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;N.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return N}function $s(s){const r=[];for(let i=0;i<s.length;++i)r.push(s.charCodeAt(i)&255);return r}function Us(s,r){let i,m,T;const N=[];for(let W=0;W<s.length&&!((r-=2)<0);++W)i=s.charCodeAt(W),m=i>>8,T=i%256,N.push(T),N.push(m);return N}function _o(s){return P.toByteArray(js(s))}function ht(s,r,i,m){let T;for(T=0;T<m&&!(T+i>=r.length||T>=s.length);++T)r[T+i]=s[T];return T}function Oe(s,r){return s instanceof r||s!=null&&s.constructor!=null&&s.constructor.name!=null&&s.constructor.name===r.name}function on(s){return s!==s}const qs=function(){const s="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const m=i*16;for(let T=0;T<16;++T)r[m+T]=s[i]+s[T]}return r}();function Le(s){return typeof BigInt=="undefined"?xs:s}function xs(){throw new Error("BigInt not supported")}})(e);const h=e.Buffer;n.Blob=e.Blob,n.BlobOptions=e.BlobOptions,n.Buffer=e.Buffer,n.File=e.File,n.FileOptions=e.FileOptions,n.INSPECT_MAX_BYTES=e.INSPECT_MAX_BYTES,n.SlowBuffer=e.SlowBuffer,n.TranscodeEncoding=e.TranscodeEncoding,n.atob=e.atob,n.btoa=e.btoa,n.constants=e.constants,n.default=h,n.isAscii=e.isAscii,n.isUtf8=e.isUtf8,n.kMaxLength=e.kMaxLength,n.kStringMaxLength=e.kStringMaxLength,n.resolveObjectURL=e.resolveObjectURL,n.transcode=e.transcode}(wt)),wt}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var yn;function mn(){return yn||(yn=1,function(n,e){var t=Je(),o=t.Buffer;function l(E,a){for(var f in E)a[f]=E[f]}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?n.exports=t:(l(t,e),e.Buffer=c);function c(E,a,f){return o(E,a,f)}c.prototype=Object.create(o.prototype),l(o,c),c.from=function(E,a,f){if(typeof E=="number")throw new TypeError("Argument must not be a number");return o(E,a,f)},c.alloc=function(E,a,f){if(typeof E!="number")throw new TypeError("Argument must be a number");var u=o(E);return a!==void 0?typeof f=="string"?u.fill(a,f):u.fill(a):u.fill(0),u},c.allocUnsafe=function(E){if(typeof E!="number")throw new TypeError("Argument must be a number");return o(E)},c.allocUnsafeSlow=function(E){if(typeof E!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(E)}}(it,it.exports)),it.exports}var vn;function Bo(){if(vn)return nt.exports;vn=1;var n={env:{}},e=65536,t=4294967295;function o(){throw new Error(`Secure random number generation is not supported by this browser.
7
- Use Chrome, Firefox or Internet Explorer 11`)}var l=mn().Buffer,c=globalThis.crypto||globalThis.msCrypto;c&&c.getRandomValues?nt.exports=E:nt.exports=o;function E(a,f){if(a>t)throw new RangeError("requested too many random bytes");var u=l.allocUnsafe(a);if(a>0)if(a>e)for(var w=0;w<a;w+=e)c.getRandomValues(u.slice(w,w+e));else c.getRandomValues(u);return typeof f=="function"?n.nextTick(function(){f(null,u)}):u}return nt.exports}var ot={exports:{}},at={exports:{}},bn;function St(){if(bn)return at.exports;bn=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(R,v,p){return Function.prototype.apply.call(R,v,p)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(R){return Object.getOwnPropertyNames(R).concat(Object.getOwnPropertySymbols(R))}:t=function(R){return Object.getOwnPropertyNames(R)};function o(S){console&&console.warn&&console.warn(S)}var l=Number.isNaN||function(R){return R!==R};function c(){c.init.call(this)}at.exports=c,at.exports.once=h,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var E=10;function a(S){if(typeof S!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof S)}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return E},set:function(S){if(typeof S!="number"||S<0||l(S))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+S+".");E=S}}),c.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},c.prototype.setMaxListeners=function(R){if(typeof R!="number"||R<0||l(R))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+R+".");return this._maxListeners=R,this};function f(S){return S._maxListeners===void 0?c.defaultMaxListeners:S._maxListeners}c.prototype.getMaxListeners=function(){return f(this)},c.prototype.emit=function(R){for(var v=[],p=1;p<arguments.length;p++)v.push(arguments[p]);var B=R==="error",U=this._events;if(U!==void 0)B=B&&U.error===void 0;else if(!B)return!1;if(B){var F;if(v.length>0&&(F=v[0]),F instanceof Error)throw F;var J=new Error("Unhandled error."+(F?" ("+F.message+")":""));throw J.context=F,J}var O=U[R];if(O===void 0)return!1;if(typeof O=="function")e(O,this,v);else for(var ne=O.length,re=y(O,ne),p=0;p<ne;++p)e(re[p],this,v);return!0};function u(S,R,v,p){var B,U,F;if(a(v),U=S._events,U===void 0?(U=S._events=Object.create(null),S._eventsCount=0):(U.newListener!==void 0&&(S.emit("newListener",R,v.listener?v.listener:v),U=S._events),F=U[R]),F===void 0)F=U[R]=v,++S._eventsCount;else if(typeof F=="function"?F=U[R]=p?[v,F]:[F,v]:p?F.unshift(v):F.push(v),B=f(S),B>0&&F.length>B&&!F.warned){F.warned=!0;var J=new Error("Possible EventEmitter memory leak detected. "+F.length+" "+String(R)+" listeners added. Use emitter.setMaxListeners() to increase limit");J.name="MaxListenersExceededWarning",J.emitter=S,J.type=R,J.count=F.length,o(J)}return S}c.prototype.addListener=function(R,v){return u(this,R,v,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(R,v){return u(this,R,v,!0)};function w(){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 A(S,R,v){var p={fired:!1,wrapFn:void 0,target:S,type:R,listener:v},B=w.bind(p);return B.listener=v,p.wrapFn=B,B}c.prototype.once=function(R,v){return a(v),this.on(R,A(this,R,v)),this},c.prototype.prependOnceListener=function(R,v){return a(v),this.prependListener(R,A(this,R,v)),this},c.prototype.removeListener=function(R,v){var p,B,U,F,J;if(a(v),B=this._events,B===void 0)return this;if(p=B[R],p===void 0)return this;if(p===v||p.listener===v)--this._eventsCount===0?this._events=Object.create(null):(delete B[R],B.removeListener&&this.emit("removeListener",R,p.listener||v));else if(typeof p!="function"){for(U=-1,F=p.length-1;F>=0;F--)if(p[F]===v||p[F].listener===v){J=p[F].listener,U=F;break}if(U<0)return this;U===0?p.shift():I(p,U),p.length===1&&(B[R]=p[0]),B.removeListener!==void 0&&this.emit("removeListener",R,J||v)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(R){var v,p,B;if(p=this._events,p===void 0)return this;if(p.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):p[R]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete p[R]),this;if(arguments.length===0){var U=Object.keys(p),F;for(B=0;B<U.length;++B)F=U[B],F!=="removeListener"&&this.removeAllListeners(F);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(v=p[R],typeof v=="function")this.removeListener(R,v);else if(v!==void 0)for(B=v.length-1;B>=0;B--)this.removeListener(R,v[B]);return this};function C(S,R,v){var p=S._events;if(p===void 0)return[];var B=p[R];return B===void 0?[]:typeof B=="function"?v?[B.listener||B]:[B]:v?_(B):y(B,B.length)}c.prototype.listeners=function(R){return C(this,R,!0)},c.prototype.rawListeners=function(R){return C(this,R,!1)},c.listenerCount=function(S,R){return typeof S.listenerCount=="function"?S.listenerCount(R):j.call(S,R)},c.prototype.listenerCount=j;function j(S){var R=this._events;if(R!==void 0){var v=R[S];if(typeof v=="function")return 1;if(v!==void 0)return v.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function y(S,R){for(var v=new Array(R),p=0;p<R;++p)v[p]=S[p];return v}function I(S,R){for(;R+1<S.length;R++)S[R]=S[R+1];S.pop()}function _(S){for(var R=new Array(S.length),v=0;v<R.length;++v)R[v]=S[v].listener||S[v];return R}function h(S,R){return new Promise(function(v,p){function B(F){S.removeListener(R,U),p(F)}function U(){typeof S.removeListener=="function"&&S.removeListener("error",B),v([].slice.call(arguments))}P(S,R,U,{once:!0}),R!=="error"&&b(S,B,{once:!0})})}function b(S,R,v){typeof S.on=="function"&&P(S,"error",R,v)}function P(S,R,v,p){if(typeof S.on=="function")p.once?S.once(R,v):S.on(R,v);else if(typeof S.addEventListener=="function")S.addEventListener(R,function B(U){p.once&&S.removeEventListener(R,B),v(U)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof S)}return at.exports}var _t,wn;function Sn(){return wn||(wn=1,_t=St().EventEmitter),_t}var Ct={},Et={},Rt,_n;function Cn(){return _n||(_n=1,Rt=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),o=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(o)!=="[object Symbol]")return!1;var l=42;e[t]=l;for(var c 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 E=Object.getOwnPropertySymbols(e);if(E.length!==1||E[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==l||a.enumerable!==!0)return!1}return!0}),Rt}var Pt,En;function st(){if(En)return Pt;En=1;var n=Cn();return Pt=function(){return n()&&!!Symbol.toStringTag},Pt}var At,Rn;function Pn(){return Rn||(Rn=1,At=Object),At}var Tt,An;function Lo(){return An||(An=1,Tt=Error),Tt}var It,Tn;function No(){return Tn||(Tn=1,It=EvalError),It}var kt,In;function Do(){return In||(In=1,kt=RangeError),kt}var Ot,kn;function Fo(){return kn||(kn=1,Ot=ReferenceError),Ot}var Mt,On;function Mn(){return On||(On=1,Mt=SyntaxError),Mt}var Bt,Bn;function Ye(){return Bn||(Bn=1,Bt=TypeError),Bt}var Lt,Ln;function jo(){return Ln||(Ln=1,Lt=URIError),Lt}var Nt,Nn;function $o(){return Nn||(Nn=1,Nt=Math.abs),Nt}var Dt,Dn;function Uo(){return Dn||(Dn=1,Dt=Math.floor),Dt}var Ft,Fn;function qo(){return Fn||(Fn=1,Ft=Math.max),Ft}var jt,jn;function xo(){return jn||(jn=1,jt=Math.min),jt}var $t,$n;function Wo(){return $n||($n=1,$t=Math.pow),$t}var Ut,Un;function Vo(){return Un||(Un=1,Ut=Math.round),Ut}var qt,qn;function zo(){return qn||(qn=1,qt=Number.isNaN||function(e){return e!==e}),qt}var xt,xn;function Go(){if(xn)return xt;xn=1;var n=zo();return xt=function(t){return n(t)||t===0?t:t<0?-1:1},xt}var Wt,Wn;function Ho(){return Wn||(Wn=1,Wt=Object.getOwnPropertyDescriptor),Wt}var Vt,Vn;function je(){if(Vn)return Vt;Vn=1;var n=Ho();if(n)try{n([],"length")}catch(e){n=null}return Vt=n,Vt}var zt,zn;function lt(){if(zn)return zt;zn=1;var n=Object.defineProperty||!1;if(n)try{n({},"a",{value:1})}catch(e){n=!1}return zt=n,zt}var Gt,Gn;function Jo(){if(Gn)return Gt;Gn=1;var n=typeof Symbol!="undefined"&&Symbol,e=Cn();return Gt=function(){return typeof n!="function"||typeof Symbol!="function"||typeof n("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Gt}var Ht,Hn;function Jn(){return Hn||(Hn=1,Ht=typeof Reflect!="undefined"&&Reflect.getPrototypeOf||null),Ht}var Jt,Yn;function Kn(){if(Yn)return Jt;Yn=1;var n=Pn();return Jt=n.getPrototypeOf||null,Jt}var Yt,Xn;function Yo(){if(Xn)return Yt;Xn=1;var n="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,t=Math.max,o="[object Function]",l=function(f,u){for(var w=[],A=0;A<f.length;A+=1)w[A]=f[A];for(var C=0;C<u.length;C+=1)w[C+f.length]=u[C];return w},c=function(f,u){for(var w=[],A=u,C=0;A<f.length;A+=1,C+=1)w[C]=f[A];return w},E=function(a,f){for(var u="",w=0;w<a.length;w+=1)u+=a[w],w+1<a.length&&(u+=f);return u};return Yt=function(f){var u=this;if(typeof u!="function"||e.apply(u)!==o)throw new TypeError(n+u);for(var w=c(arguments,1),A,C=function(){if(this instanceof A){var h=u.apply(this,l(w,arguments));return Object(h)===h?h:this}return u.apply(f,l(w,arguments))},j=t(0,u.length-w.length),y=[],I=0;I<j;I++)y[I]="$"+I;if(A=Function("binder","return function ("+E(y,",")+"){ return binder.apply(this,arguments); }")(C),u.prototype){var _=function(){};_.prototype=u.prototype,A.prototype=new _,_.prototype=null}return A},Yt}var Kt,Zn;function Ke(){if(Zn)return Kt;Zn=1;var n=Yo();return Kt=Function.prototype.bind||n,Kt}var Xt,Qn;function Zt(){return Qn||(Qn=1,Xt=Function.prototype.call),Xt}var Qt,ei;function er(){return ei||(ei=1,Qt=Function.prototype.apply),Qt}var tr,ti;function Ko(){return ti||(ti=1,tr=typeof Reflect!="undefined"&&Reflect&&Reflect.apply),tr}var rr,ri;function ni(){if(ri)return rr;ri=1;var n=Ke(),e=er(),t=Zt(),o=Ko();return rr=o||n.call(t,e),rr}var nr,ii;function ir(){if(ii)return nr;ii=1;var n=Ke(),e=Ye(),t=Zt(),o=ni();return nr=function(c){if(c.length<1||typeof c[0]!="function")throw new e("a function is required");return o(n,t,c)},nr}var or,oi;function Xo(){if(oi)return or;oi=1;var n=ir(),e=je(),t;try{t=[].__proto__===Array.prototype}catch(E){if(!E||typeof E!="object"||!("code"in E)||E.code!=="ERR_PROTO_ACCESS")throw E}var o=!!t&&e&&e(Object.prototype,"__proto__"),l=Object,c=l.getPrototypeOf;return or=o&&typeof o.get=="function"?n([o.get]):typeof c=="function"?function(a){return c(a==null?a:l(a))}:!1,or}var ar,ai;function sr(){if(ai)return ar;ai=1;var n=Jn(),e=Kn(),t=Xo();return ar=n?function(l){return n(l)}:e?function(l){if(!l||typeof l!="object"&&typeof l!="function")throw new TypeError("getProto: not an object");return e(l)}:t?function(l){return t(l)}:null,ar}var lr,si;function li(){if(si)return lr;si=1;var n=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=Ke();return lr=t.call(n,e),lr}var cr,ci;function ui(){if(ci)return cr;ci=1;var n,e=Pn(),t=Lo(),o=No(),l=Do(),c=Fo(),E=Mn(),a=Ye(),f=jo(),u=$o(),w=Uo(),A=qo(),C=xo(),j=Wo(),y=Vo(),I=Go(),_=Function,h=function(D){try{return _('"use strict"; return ('+D+").constructor;")()}catch(V){}},b=je(),P=lt(),S=function(){throw new a},R=b?function(){try{return arguments.callee,S}catch(D){try{return b(arguments,"callee").get}catch(V){return S}}}():S,v=Jo()(),p=sr(),B=Kn(),U=Jn(),F=er(),J=Zt(),O={},ne=typeof Uint8Array=="undefined"||!p?n:p(Uint8Array),re={__proto__:null,"%AggregateError%":typeof AggregateError=="undefined"?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?n:ArrayBuffer,"%ArrayIteratorPrototype%":v&&p?p([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":O,"%AsyncGenerator%":O,"%AsyncGeneratorFunction%":O,"%AsyncIteratorPrototype%":O,"%Atomics%":typeof Atomics=="undefined"?n:Atomics,"%BigInt%":typeof BigInt=="undefined"?n:BigInt,"%BigInt64Array%":typeof BigInt64Array=="undefined"?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array=="undefined"?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":o,"%Float16Array%":typeof Float16Array=="undefined"?n:Float16Array,"%Float32Array%":typeof Float32Array=="undefined"?n:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?n:FinalizationRegistry,"%Function%":_,"%GeneratorFunction%":O,"%Int8Array%":typeof Int8Array=="undefined"?n:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?n:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":v&&p?p(p([][Symbol.iterator]())):n,"%JSON%":typeof JSON=="object"?JSON:n,"%Map%":typeof Map=="undefined"?n:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!v||!p?n:p(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?n:Promise,"%Proxy%":typeof Proxy=="undefined"?n:Proxy,"%RangeError%":l,"%ReferenceError%":c,"%Reflect%":typeof Reflect=="undefined"?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?n:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!v||!p?n:p(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":v&&p?p(""[Symbol.iterator]()):n,"%Symbol%":v?Symbol:n,"%SyntaxError%":E,"%ThrowTypeError%":R,"%TypedArray%":ne,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array=="undefined"?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?n:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?n:Uint32Array,"%URIError%":f,"%WeakMap%":typeof WeakMap=="undefined"?n:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?n:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?n:WeakSet,"%Function.prototype.call%":J,"%Function.prototype.apply%":F,"%Object.defineProperty%":P,"%Object.getPrototypeOf%":B,"%Math.abs%":u,"%Math.floor%":w,"%Math.max%":A,"%Math.min%":C,"%Math.pow%":j,"%Math.round%":y,"%Math.sign%":I,"%Reflect.getPrototypeOf%":U};if(p)try{null.error}catch(D){var ce=p(p(D));re["%Error.prototype%"]=ce}var fe=function D(V){var G;if(V==="%AsyncFunction%")G=h("async function () {}");else if(V==="%GeneratorFunction%")G=h("function* () {}");else if(V==="%AsyncGeneratorFunction%")G=h("async function* () {}");else if(V==="%AsyncGenerator%"){var d=D("%AsyncGeneratorFunction%");d&&(G=d.prototype)}else if(V==="%AsyncIteratorPrototype%"){var g=D("%AsyncGenerator%");g&&p&&(G=p(g.prototype))}return re[V]=G,G},_e={__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"]},de=Ke(),be=li(),se=de.call(J,Array.prototype.concat),Ee=de.call(F,Array.prototype.splice),ve=de.call(J,String.prototype.replace),L=de.call(J,String.prototype.slice),$=de.call(J,RegExp.prototype.exec),z=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,K=/\\(\\)?/g,M=function(V){var G=L(V,0,1),d=L(V,-1);if(G==="%"&&d!=="%")throw new E("invalid intrinsic syntax, expected closing `%`");if(d==="%"&&G!=="%")throw new E("invalid intrinsic syntax, expected opening `%`");var g=[];return ve(V,z,function(x,H,X,Z){g[g.length]=X?ve(Z,K,"$1"):H||x}),g},k=function(V,G){var d=V,g;if(be(_e,d)&&(g=_e[d],d="%"+g[0]+"%"),be(re,d)){var x=re[d];if(x===O&&(x=fe(d)),typeof x=="undefined"&&!G)throw new a("intrinsic "+V+" exists, but is not available. Please file an issue!");return{alias:g,name:d,value:x}}throw new E("intrinsic "+V+" does not exist!")};return cr=function(V,G){if(typeof V!="string"||V.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof G!="boolean")throw new a('"allowMissing" argument must be a boolean');if($(/^%?[^%]*%?$/,V)===null)throw new E("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var d=M(V),g=d.length>0?d[0]:"",x=k("%"+g+"%",G),H=x.name,X=x.value,Z=!1,te=x.alias;te&&(g=te[0],Ee(d,se([0,1],te)));for(var q=1,Ce=!0;q<d.length;q+=1){var Se=d[q],le=L(Se,0,1),he=L(Se,-1);if((le==='"'||le==="'"||le==="`"||he==='"'||he==="'"||he==="`")&&le!==he)throw new E("property names with quotes must have matching quotes");if((Se==="constructor"||!Ce)&&(Z=!0),g+="."+Se,H="%"+g+"%",be(re,H))X=re[H];else if(X!=null){if(!(Se in X)){if(!G)throw new a("base intrinsic for "+V+" exists, but the property is not available.");return}if(b&&q+1>=d.length){var Ae=b(X,Se);Ce=!!Ae,Ce&&"get"in Ae&&!("originalValue"in Ae.get)?X=Ae.get:X=X[Se]}else Ce=be(X,Se),X=X[Se];Ce&&!Z&&(re[H]=X)}}return X},cr}var ur,fi;function Xe(){if(fi)return ur;fi=1;var n=ui(),e=ir(),t=e([n("%String.prototype.indexOf%")]);return ur=function(l,c){var E=n(l,!!c);return typeof E=="function"&&t(l,".prototype.")>-1?e([E]):E},ur}var fr,di;function Zo(){if(di)return fr;di=1;var n=st()(),e=Xe(),t=e("Object.prototype.toString"),o=function(a){return n&&a&&typeof a=="object"&&Symbol.toStringTag in a?!1:t(a)==="[object Arguments]"},l=function(a){return o(a)?!0:a!==null&&typeof a=="object"&&"length"in a&&typeof a.length=="number"&&a.length>=0&&t(a)!=="[object Array]"&&"callee"in a&&t(a.callee)==="[object Function]"},c=function(){return o(arguments)}();return o.isLegacyArguments=l,fr=c?o:l,fr}var dr,hi;function Qo(){if(hi)return dr;hi=1;var n=Xe(),e=st()(),t=li(),o=je(),l;if(e){var c=n("RegExp.prototype.exec"),E={},a=function(){throw E},f={toString:a,valueOf:a};typeof Symbol.toPrimitive=="symbol"&&(f[Symbol.toPrimitive]=a),l=function(C){if(!C||typeof C!="object")return!1;var j=o(C,"lastIndex"),y=j&&t(j,"value");if(!y)return!1;try{c(C,f)}catch(I){return I===E}}}else{var u=n("Object.prototype.toString"),w="[object RegExp]";l=function(C){return!C||typeof C!="object"&&typeof C!="function"?!1:u(C)===w}}return dr=l,dr}var hr,pi;function ea(){if(pi)return hr;pi=1;var n=Xe(),e=Qo(),t=n("RegExp.prototype.exec"),o=Ye();return hr=function(c){if(!e(c))throw new o("`regex` must be a RegExp");return function(a){return t(c,a)!==null}},hr}var pr,gi;function ta(){if(gi)return pr;gi=1;var n=Xe(),e=ea(),t=e(/^\s*(?:function)?\*/),o=st()(),l=sr(),c=n("Object.prototype.toString"),E=n("Function.prototype.toString"),a=function(){if(!o)return!1;try{return Function("return function*() {}")()}catch(u){}},f;return pr=function(w){if(typeof w!="function")return!1;if(t(E(w)))return!0;if(!o){var A=c(w);return A==="[object GeneratorFunction]"}if(!l)return!1;if(typeof f=="undefined"){var C=a();f=C?l(C):!1}return l(w)===f},pr}var gr,yi;function ra(){if(yi)return gr;yi=1;var n=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,t,o;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{t=Object.defineProperty({},"length",{get:function(){throw o}}),o={},e(function(){throw 42},null,t)}catch(b){b!==o&&(e=null)}else e=null;var l=/^\s*class\b/,c=function(P){try{var S=n.call(P);return l.test(S)}catch(R){return!1}},E=function(P){try{return c(P)?!1:(n.call(P),!0)}catch(S){return!1}},a=Object.prototype.toString,f="[object Object]",u="[object Function]",w="[object GeneratorFunction]",A="[object HTMLAllCollection]",C="[object HTML document.all class]",j="[object HTMLCollection]",y=typeof Symbol=="function"&&!!Symbol.toStringTag,I=!(0 in[,]),_=function(){return!1};if(typeof document=="object"){var h=document.all;a.call(h)===a.call(document.all)&&(_=function(P){if((I||!P)&&(typeof P=="undefined"||typeof P=="object"))try{var S=a.call(P);return(S===A||S===C||S===j||S===f)&&P("")==null}catch(R){}return!1})}return gr=e?function(P){if(_(P))return!0;if(!P||typeof P!="function"&&typeof P!="object")return!1;try{e(P,null,t)}catch(S){if(S!==o)return!1}return!c(P)&&E(P)}:function(P){if(_(P))return!0;if(!P||typeof P!="function"&&typeof P!="object")return!1;if(y)return E(P);if(c(P))return!1;var S=a.call(P);return S!==u&&S!==w&&!/^\[object HTML/.test(S)?!1:E(P)},gr}var yr,mi;function na(){if(mi)return yr;mi=1;var n=ra(),e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,o=function(f,u,w){for(var A=0,C=f.length;A<C;A++)t.call(f,A)&&(w==null?u(f[A],A,f):u.call(w,f[A],A,f))},l=function(f,u,w){for(var A=0,C=f.length;A<C;A++)w==null?u(f.charAt(A),A,f):u.call(w,f.charAt(A),A,f)},c=function(f,u,w){for(var A in f)t.call(f,A)&&(w==null?u(f[A],A,f):u.call(w,f[A],A,f))};function E(a){return e.call(a)==="[object Array]"}return yr=function(f,u,w){if(!n(u))throw new TypeError("iterator must be a function");var A;arguments.length>=3&&(A=w),E(f)?o(f,u,A):typeof f=="string"?l(f,u,A):c(f,u,A)},yr}var mr,vi;function ia(){return vi||(vi=1,mr=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),mr}var vr,bi;function oa(){if(bi)return vr;bi=1;var n=ia(),e=globalThis;return vr=function(){for(var o=[],l=0;l<n.length;l++)typeof e[n[l]]=="function"&&(o[o.length]=n[l]);return o},vr}var br={exports:{}},wr,wi;function aa(){if(wi)return wr;wi=1;var n=lt(),e=Mn(),t=Ye(),o=je();return wr=function(c,E,a){if(!c||typeof c!="object"&&typeof c!="function")throw new t("`obj` must be an object or a function`");if(typeof E!="string"&&typeof E!="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 f=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,w=arguments.length>5?arguments[5]:null,A=arguments.length>6?arguments[6]:!1,C=!!o&&o(c,E);if(n)n(c,E,{configurable:w===null&&C?C.configurable:!w,enumerable:f===null&&C?C.enumerable:!f,value:a,writable:u===null&&C?C.writable:!u});else if(A||!f&&!u&&!w)c[E]=a;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},wr}var Sr,Si;function sa(){if(Si)return Sr;Si=1;var n=lt(),e=function(){return!!n};return e.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],"length",{value:1}).length!==1}catch(o){return!0}},Sr=e,Sr}var _r,_i;function la(){if(_i)return _r;_i=1;var n=ui(),e=aa(),t=sa()(),o=je(),l=Ye(),c=n("%Math.floor%");return _r=function(a,f){if(typeof a!="function")throw new l("`fn` is not a function");if(typeof f!="number"||f<0||f>4294967295||c(f)!==f)throw new l("`length` must be a positive 32-bit integer");var u=arguments.length>2&&!!arguments[2],w=!0,A=!0;if("length"in a&&o){var C=o(a,"length");C&&!C.configurable&&(w=!1),C&&!C.writable&&(A=!1)}return(w||A||!u)&&(t?e(a,"length",f,!0,!0):e(a,"length",f)),a},_r}var Cr,Ci;function ca(){if(Ci)return Cr;Ci=1;var n=Ke(),e=er(),t=ni();return Cr=function(){return t(n,e,arguments)},Cr}var Ei;function ua(){return Ei||(Ei=1,function(n){var e=la(),t=lt(),o=ir(),l=ca();n.exports=function(E){var a=o(arguments),f=E.length-(arguments.length-1);return e(a,1+(f>0?f:0),!0)},t?t(n.exports,"apply",{value:l}):n.exports.apply=l}(br)),br.exports}var Er,Ri;function Pi(){if(Ri)return Er;Ri=1;var n=na(),e=oa(),t=ua(),o=Xe(),l=je(),c=sr(),E=o("Object.prototype.toString"),a=st()(),f=globalThis,u=e(),w=o("String.prototype.slice"),A=o("Array.prototype.indexOf",!0)||function(_,h){for(var b=0;b<_.length;b+=1)if(_[b]===h)return b;return-1},C={__proto__:null};a&&l&&c?n(u,function(I){var _=new f[I];if(Symbol.toStringTag in _&&c){var h=c(_),b=l(h,Symbol.toStringTag);if(!b&&h){var P=c(h);b=l(P,Symbol.toStringTag)}C["$"+I]=t(b.get)}}):n(u,function(I){var _=new f[I],h=_.slice||_.set;h&&(C["$"+I]=t(h))});var j=function(_){var h=!1;return n(C,function(b,P){if(!h)try{"$"+b(_)===P&&(h=w(P,1))}catch(S){}}),h},y=function(_){var h=!1;return n(C,function(b,P){if(!h)try{b(_),h=w(P,1)}catch(S){}}),h};return Er=function(_){if(!_||typeof _!="object")return!1;if(!a){var h=w(E(_),8,-1);return A(u,h)>-1?h:h!=="Object"?!1:y(_)}return l?j(_):null},Er}var Rr,Ai;function fa(){if(Ai)return Rr;Ai=1;var n=Pi();return Rr=function(t){return!!n(t)},Rr}var Ti;function da(){return Ti||(Ti=1,function(n){var e=Zo(),t=ta(),o=Pi(),l=fa();function c(q){return q.call.bind(q)}var E=typeof BigInt!="undefined",a=typeof Symbol!="undefined",f=c(Object.prototype.toString),u=c(Number.prototype.valueOf),w=c(String.prototype.valueOf),A=c(Boolean.prototype.valueOf);if(E)var C=c(BigInt.prototype.valueOf);if(a)var j=c(Symbol.prototype.valueOf);function y(q,Ce){if(typeof q!="object")return!1;try{return Ce(q),!0}catch(Se){return!1}}n.isArgumentsObject=e,n.isGeneratorFunction=t,n.isTypedArray=l;function I(q){return typeof Promise!="undefined"&&q instanceof Promise||q!==null&&typeof q=="object"&&typeof q.then=="function"&&typeof q.catch=="function"}n.isPromise=I;function _(q){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?ArrayBuffer.isView(q):l(q)||L(q)}n.isArrayBufferView=_;function h(q){return o(q)==="Uint8Array"}n.isUint8Array=h;function b(q){return o(q)==="Uint8ClampedArray"}n.isUint8ClampedArray=b;function P(q){return o(q)==="Uint16Array"}n.isUint16Array=P;function S(q){return o(q)==="Uint32Array"}n.isUint32Array=S;function R(q){return o(q)==="Int8Array"}n.isInt8Array=R;function v(q){return o(q)==="Int16Array"}n.isInt16Array=v;function p(q){return o(q)==="Int32Array"}n.isInt32Array=p;function B(q){return o(q)==="Float32Array"}n.isFloat32Array=B;function U(q){return o(q)==="Float64Array"}n.isFloat64Array=U;function F(q){return o(q)==="BigInt64Array"}n.isBigInt64Array=F;function J(q){return o(q)==="BigUint64Array"}n.isBigUint64Array=J;function O(q){return f(q)==="[object Map]"}O.working=typeof Map!="undefined"&&O(new Map);function ne(q){return typeof Map=="undefined"?!1:O.working?O(q):q instanceof Map}n.isMap=ne;function re(q){return f(q)==="[object Set]"}re.working=typeof Set!="undefined"&&re(new Set);function ce(q){return typeof Set=="undefined"?!1:re.working?re(q):q instanceof Set}n.isSet=ce;function fe(q){return f(q)==="[object WeakMap]"}fe.working=typeof WeakMap!="undefined"&&fe(new WeakMap);function _e(q){return typeof WeakMap=="undefined"?!1:fe.working?fe(q):q instanceof WeakMap}n.isWeakMap=_e;function de(q){return f(q)==="[object WeakSet]"}de.working=typeof WeakSet!="undefined"&&de(new WeakSet);function be(q){return de(q)}n.isWeakSet=be;function se(q){return f(q)==="[object ArrayBuffer]"}se.working=typeof ArrayBuffer!="undefined"&&se(new ArrayBuffer);function Ee(q){return typeof ArrayBuffer=="undefined"?!1:se.working?se(q):q instanceof ArrayBuffer}n.isArrayBuffer=Ee;function ve(q){return f(q)==="[object DataView]"}ve.working=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined"&&ve(new DataView(new ArrayBuffer(1),0,1));function L(q){return typeof DataView=="undefined"?!1:ve.working?ve(q):q instanceof DataView}n.isDataView=L;var $=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer:void 0;function z(q){return f(q)==="[object SharedArrayBuffer]"}function K(q){return typeof $=="undefined"?!1:(typeof z.working=="undefined"&&(z.working=z(new $)),z.working?z(q):q instanceof $)}n.isSharedArrayBuffer=K;function M(q){return f(q)==="[object AsyncFunction]"}n.isAsyncFunction=M;function k(q){return f(q)==="[object Map Iterator]"}n.isMapIterator=k;function D(q){return f(q)==="[object Set Iterator]"}n.isSetIterator=D;function V(q){return f(q)==="[object Generator]"}n.isGeneratorObject=V;function G(q){return f(q)==="[object WebAssembly.Module]"}n.isWebAssemblyCompiledModule=G;function d(q){return y(q,u)}n.isNumberObject=d;function g(q){return y(q,w)}n.isStringObject=g;function x(q){return y(q,A)}n.isBooleanObject=x;function H(q){return E&&y(q,C)}n.isBigIntObject=H;function X(q){return a&&y(q,j)}n.isSymbolObject=X;function Z(q){return d(q)||g(q)||x(q)||H(q)||X(q)}n.isBoxedPrimitive=Z;function te(q){return typeof Uint8Array!="undefined"&&(Ee(q)||K(q))}n.isAnyArrayBuffer=te,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(q){Object.defineProperty(n,q,{enumerable:!1,value:function(){throw new Error(q+" is not supported in userland")}})})}(Et)),Et}var Pr,Ii;function ha(){return Ii||(Ii=1,Pr=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),Pr}var ct={exports:{}},ki;function $e(){return ki||(ki=1,typeof Object.create=="function"?ct.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ct.exports=function(e,t){if(t){e.super_=t;var o=function(){};o.prototype=t.prototype,e.prototype=new o,e.prototype.constructor=e}}),ct.exports}var Oi;function Mi(){return Oi||(Oi=1,function(n){var e={env:{}},t=Object.getOwnPropertyDescriptors||function($){for(var z=Object.keys($),K={},M=0;M<z.length;M++)K[z[M]]=Object.getOwnPropertyDescriptor($,z[M]);return K},o=/%[sdj%]/g;n.format=function(L){if(!v(L)){for(var $=[],z=0;z<arguments.length;z++)$.push(a(arguments[z]));return $.join(" ")}for(var z=1,K=arguments,M=K.length,k=String(L).replace(o,function(V){if(V==="%%")return"%";if(z>=M)return V;switch(V){case"%s":return String(K[z++]);case"%d":return Number(K[z++]);case"%j":try{return JSON.stringify(K[z++])}catch(G){return"[Circular]"}default:return V}}),D=K[z];z<M;D=K[++z])P(D)||!F(D)?k+=" "+D:k+=" "+a(D);return k},n.deprecate=function(L,$){if(typeof e!="undefined"&&e.noDeprecation===!0)return L;if(typeof e=="undefined")return function(){return n.deprecate(L,$).apply(this,arguments)};var z=!1;function K(){if(!z){if(e.throwDeprecation)throw new Error($);e.traceDeprecation?console.trace($):console.error($),z=!0}return L.apply(this,arguments)}return K};var l={},c=/^$/;if(e.env.NODE_DEBUG){var E=e.env.NODE_DEBUG;E=E.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),c=new RegExp("^"+E+"$","i")}n.debuglog=function(L){if(L=L.toUpperCase(),!l[L])if(c.test(L)){var $=e.pid;l[L]=function(){var z=n.format.apply(n,arguments);console.error("%s %d: %s",L,$,z)}}else l[L]=function(){};return l[L]};function a(L,$){var z={seen:[],stylize:u};return arguments.length>=3&&(z.depth=arguments[2]),arguments.length>=4&&(z.colors=arguments[3]),b($)?z.showHidden=$:$&&n._extend(z,$),B(z.showHidden)&&(z.showHidden=!1),B(z.depth)&&(z.depth=2),B(z.colors)&&(z.colors=!1),B(z.customInspect)&&(z.customInspect=!0),z.colors&&(z.stylize=f),A(z,L,z.depth)}n.inspect=a,a.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]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function f(L,$){var z=a.styles[$];return z?"\x1B["+a.colors[z][0]+"m"+L+"\x1B["+a.colors[z][1]+"m":L}function u(L,$){return L}function w(L){var $={};return L.forEach(function(z,K){$[z]=!0}),$}function A(L,$,z){if(L.customInspect&&$&&ne($.inspect)&&$.inspect!==n.inspect&&!($.constructor&&$.constructor.prototype===$)){var K=$.inspect(z,L);return v(K)||(K=A(L,K,z)),K}var M=C(L,$);if(M)return M;var k=Object.keys($),D=w(k);if(L.showHidden&&(k=Object.getOwnPropertyNames($)),O($)&&(k.indexOf("message")>=0||k.indexOf("description")>=0))return j($);if(k.length===0){if(ne($)){var V=$.name?": "+$.name:"";return L.stylize("[Function"+V+"]","special")}if(U($))return L.stylize(RegExp.prototype.toString.call($),"regexp");if(J($))return L.stylize(Date.prototype.toString.call($),"date");if(O($))return j($)}var G="",d=!1,g=["{","}"];if(h($)&&(d=!0,g=["[","]"]),ne($)){var x=$.name?": "+$.name:"";G=" [Function"+x+"]"}if(U($)&&(G=" "+RegExp.prototype.toString.call($)),J($)&&(G=" "+Date.prototype.toUTCString.call($)),O($)&&(G=" "+j($)),k.length===0&&(!d||$.length==0))return g[0]+G+g[1];if(z<0)return U($)?L.stylize(RegExp.prototype.toString.call($),"regexp"):L.stylize("[Object]","special");L.seen.push($);var H;return d?H=y(L,$,z,D,k):H=k.map(function(X){return I(L,$,z,D,X,d)}),L.seen.pop(),_(H,G,g)}function C(L,$){if(B($))return L.stylize("undefined","undefined");if(v($)){var z="'"+JSON.stringify($).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return L.stylize(z,"string")}if(R($))return L.stylize(""+$,"number");if(b($))return L.stylize(""+$,"boolean");if(P($))return L.stylize("null","null")}function j(L){return"["+Error.prototype.toString.call(L)+"]"}function y(L,$,z,K,M){for(var k=[],D=0,V=$.length;D<V;++D)be($,String(D))?k.push(I(L,$,z,K,String(D),!0)):k.push("");return M.forEach(function(G){G.match(/^\d+$/)||k.push(I(L,$,z,K,G,!0))}),k}function I(L,$,z,K,M,k){var D,V,G;if(G=Object.getOwnPropertyDescriptor($,M)||{value:$[M]},G.get?G.set?V=L.stylize("[Getter/Setter]","special"):V=L.stylize("[Getter]","special"):G.set&&(V=L.stylize("[Setter]","special")),be(K,M)||(D="["+M+"]"),V||(L.seen.indexOf(G.value)<0?(P(z)?V=A(L,G.value,null):V=A(L,G.value,z-1),V.indexOf(`
8
- `)>-1&&(k?V=V.split(`
9
- `).map(function(d){return" "+d}).join(`
10
- `).slice(2):V=`
11
- `+V.split(`
12
- `).map(function(d){return" "+d}).join(`
13
- `))):V=L.stylize("[Circular]","special")),B(D)){if(k&&M.match(/^\d+$/))return V;D=JSON.stringify(""+M),D.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(D=D.slice(1,-1),D=L.stylize(D,"name")):(D=D.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),D=L.stylize(D,"string"))}return D+": "+V}function _(L,$,z){var K=L.reduce(function(M,k){return k.indexOf(`
14
- `)>=0,M+k.replace(/\u001b\[\d\d?m/g,"").length+1},0);return K>60?z[0]+($===""?"":$+`
15
- `)+" "+L.join(`,
16
- `)+" "+z[1]:z[0]+$+" "+L.join(", ")+" "+z[1]}n.types=da();function h(L){return Array.isArray(L)}n.isArray=h;function b(L){return typeof L=="boolean"}n.isBoolean=b;function P(L){return L===null}n.isNull=P;function S(L){return L==null}n.isNullOrUndefined=S;function R(L){return typeof L=="number"}n.isNumber=R;function v(L){return typeof L=="string"}n.isString=v;function p(L){return typeof L=="symbol"}n.isSymbol=p;function B(L){return L===void 0}n.isUndefined=B;function U(L){return F(L)&&ce(L)==="[object RegExp]"}n.isRegExp=U,n.types.isRegExp=U;function F(L){return typeof L=="object"&&L!==null}n.isObject=F;function J(L){return F(L)&&ce(L)==="[object Date]"}n.isDate=J,n.types.isDate=J;function O(L){return F(L)&&(ce(L)==="[object Error]"||L instanceof Error)}n.isError=O,n.types.isNativeError=O;function ne(L){return typeof L=="function"}n.isFunction=ne;function re(L){return L===null||typeof L=="boolean"||typeof L=="number"||typeof L=="string"||typeof L=="symbol"||typeof L=="undefined"}n.isPrimitive=re,n.isBuffer=ha();function ce(L){return Object.prototype.toString.call(L)}function fe(L){return L<10?"0"+L.toString(10):L.toString(10)}var _e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function de(){var L=new Date,$=[fe(L.getHours()),fe(L.getMinutes()),fe(L.getSeconds())].join(":");return[L.getDate(),_e[L.getMonth()],$].join(" ")}n.log=function(){console.log("%s - %s",de(),n.format.apply(n,arguments))},n.inherits=$e(),n._extend=function(L,$){if(!$||!F($))return L;for(var z=Object.keys($),K=z.length;K--;)L[z[K]]=$[z[K]];return L};function be(L,$){return Object.prototype.hasOwnProperty.call(L,$)}var se=typeof Symbol!="undefined"?Symbol("util.promisify.custom"):void 0;n.promisify=function($){if(typeof $!="function")throw new TypeError('The "original" argument must be of type Function');if(se&&$[se]){var z=$[se];if(typeof z!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(z,se,{value:z,enumerable:!1,writable:!1,configurable:!0}),z}function z(){for(var K,M,k=new Promise(function(G,d){K=G,M=d}),D=[],V=0;V<arguments.length;V++)D.push(arguments[V]);D.push(function(G,d){G?M(G):K(d)});try{$.apply(this,D)}catch(G){M(G)}return k}return Object.setPrototypeOf(z,Object.getPrototypeOf($)),se&&Object.defineProperty(z,se,{value:z,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(z,t($))},n.promisify.custom=se;function Ee(L,$){if(!L){var z=new Error("Promise was rejected with a falsy value");z.reason=L,L=z}return $(L)}function ve(L){if(typeof L!="function")throw new TypeError('The "original" argument must be of type Function');function $(){for(var z=[],K=0;K<arguments.length;K++)z.push(arguments[K]);var M=z.pop();if(typeof M!="function")throw new TypeError("The last argument must be of type Function");var k=this,D=function(){return M.apply(k,arguments)};L.apply(this,z).then(function(V){e.nextTick(D.bind(null,null,V))},function(V){e.nextTick(Ee.bind(null,V,D))})}return Object.setPrototypeOf($,Object.getPrototypeOf(L)),Object.defineProperties($,t(L)),$}n.callbackify=ve}(Ct)),Ct}var Ar,Bi;function pa(){if(Bi)return Ar;Bi=1;function n(y,I){var _=Object.keys(y);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(y);I&&(h=h.filter(function(b){return Object.getOwnPropertyDescriptor(y,b).enumerable})),_.push.apply(_,h)}return _}function e(y){for(var I=1;I<arguments.length;I++){var _=arguments[I]!=null?arguments[I]:{};I%2?n(Object(_),!0).forEach(function(h){t(y,h,_[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(_)):n(Object(_)).forEach(function(h){Object.defineProperty(y,h,Object.getOwnPropertyDescriptor(_,h))})}return y}function t(y,I,_){return I=E(I),I in y?Object.defineProperty(y,I,{value:_,enumerable:!0,configurable:!0,writable:!0}):y[I]=_,y}function o(y,I){if(!(y instanceof I))throw new TypeError("Cannot call a class as a function")}function l(y,I){for(var _=0;_<I.length;_++){var h=I[_];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(y,E(h.key),h)}}function c(y,I,_){return I&&l(y.prototype,I),Object.defineProperty(y,"prototype",{writable:!1}),y}function E(y){var I=a(y,"string");return typeof I=="symbol"?I:String(I)}function a(y,I){if(typeof y!="object"||y===null)return y;var _=y[Symbol.toPrimitive];if(_!==void 0){var h=_.call(y,I);if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}var f=Je(),u=f.Buffer,w=Mi(),A=w.inspect,C=A&&A.custom||"inspect";function j(y,I,_){u.prototype.copy.call(y,I,_)}return Ar=function(){function y(){o(this,y),this.head=null,this.tail=null,this.length=0}return c(y,[{key:"push",value:function(_){var h={data:_,next:null};this.length>0?this.tail.next=h:this.head=h,this.tail=h,++this.length}},{key:"unshift",value:function(_){var h={data:_,next:this.head};this.length===0&&(this.tail=h),this.head=h,++this.length}},{key:"shift",value:function(){if(this.length!==0){var _=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,_}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(_){if(this.length===0)return"";for(var h=this.head,b=""+h.data;h=h.next;)b+=_+h.data;return b}},{key:"concat",value:function(_){if(this.length===0)return u.alloc(0);for(var h=u.allocUnsafe(_>>>0),b=this.head,P=0;b;)j(b.data,h,P),P+=b.data.length,b=b.next;return h}},{key:"consume",value:function(_,h){var b;return _<this.head.data.length?(b=this.head.data.slice(0,_),this.head.data=this.head.data.slice(_)):_===this.head.data.length?b=this.shift():b=h?this._getString(_):this._getBuffer(_),b}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(_){var h=this.head,b=1,P=h.data;for(_-=P.length;h=h.next;){var S=h.data,R=_>S.length?S.length:_;if(R===S.length?P+=S:P+=S.slice(0,_),_-=R,_===0){R===S.length?(++b,h.next?this.head=h.next:this.head=this.tail=null):(this.head=h,h.data=S.slice(R));break}++b}return this.length-=b,P}},{key:"_getBuffer",value:function(_){var h=u.allocUnsafe(_),b=this.head,P=1;for(b.data.copy(h),_-=b.data.length;b=b.next;){var S=b.data,R=_>S.length?S.length:_;if(S.copy(h,h.length-_,0,R),_-=R,_===0){R===S.length?(++P,b.next?this.head=b.next:this.head=this.tail=null):(this.head=b,b.data=S.slice(R));break}++P}return this.length-=P,h}},{key:C,value:function(_,h){return A(this,e(e({},h),{},{depth:0,customInspect:!1}))}}]),y}(),Ar}var Tr,Li;function Ni(){if(Li)return Tr;Li=1;var n={env:{}};function e(a,f){var u=this,w=this._readableState&&this._readableState.destroyed,A=this._writableState&&this._writableState.destroyed;return w||A?(f?f(a):a&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(c,this,a)):n.nextTick(c,this,a)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(a||null,function(C){!f&&C?u._writableState?u._writableState.errorEmitted?n.nextTick(o,u):(u._writableState.errorEmitted=!0,n.nextTick(t,u,C)):n.nextTick(t,u,C):f?(n.nextTick(o,u),f(C)):n.nextTick(o,u)}),this)}function t(a,f){c(a,f),o(a)}function o(a){a._writableState&&!a._writableState.emitClose||a._readableState&&!a._readableState.emitClose||a.emit("close")}function l(){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(a,f){a.emit("error",f)}function E(a,f){var u=a._readableState,w=a._writableState;u&&u.autoDestroy||w&&w.autoDestroy?a.destroy(f):a.emit("error",f)}return Tr={destroy:e,undestroy:l,errorOrDestroy:E},Tr}var Ir={},Di;function Ue(){if(Di)return Ir;Di=1;function n(a,f){a.prototype=Object.create(f.prototype),a.prototype.constructor=a,a.__proto__=f}var e={};function t(a,f,u){u||(u=Error);function w(C,j,y){return typeof f=="string"?f:f(C,j,y)}var A=function(C){n(j,C);function j(y,I,_){return C.call(this,w(y,I,_))||this}return j}(u);A.prototype.name=u.name,A.prototype.code=a,e[a]=A}function o(a,f){if(Array.isArray(a)){var u=a.length;return a=a.map(function(w){return String(w)}),u>2?"one of ".concat(f," ").concat(a.slice(0,u-1).join(", "),", or ")+a[u-1]:u===2?"one of ".concat(f," ").concat(a[0]," or ").concat(a[1]):"of ".concat(f," ").concat(a[0])}else return"of ".concat(f," ").concat(String(a))}function l(a,f,u){return a.substr(0,f.length)===f}function c(a,f,u){return(u===void 0||u>a.length)&&(u=a.length),a.substring(u-f.length,u)===f}function E(a,f,u){return typeof u!="number"&&(u=0),u+f.length>a.length?!1:a.indexOf(f,u)!==-1}return t("ERR_INVALID_OPT_VALUE",function(a,f){return'The value "'+f+'" is invalid for option "'+a+'"'},TypeError),t("ERR_INVALID_ARG_TYPE",function(a,f,u){var w;typeof f=="string"&&l(f,"not ")?(w="must not be",f=f.replace(/^not /,"")):w="must be";var A;if(c(a," argument"))A="The ".concat(a," ").concat(w," ").concat(o(f,"type"));else{var C=E(a,".")?"property":"argument";A='The "'.concat(a,'" ').concat(C," ").concat(w," ").concat(o(f,"type"))}return A+=". Received type ".concat(typeof u),A},TypeError),t("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),t("ERR_METHOD_NOT_IMPLEMENTED",function(a){return"The "+a+" method is not implemented"}),t("ERR_STREAM_PREMATURE_CLOSE","Premature close"),t("ERR_STREAM_DESTROYED",function(a){return"Cannot call "+a+" 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(a){return"Unknown encoding: "+a},TypeError),t("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Ir.codes=e,Ir}var kr,Fi;function ji(){if(Fi)return kr;Fi=1;var n=Ue().codes.ERR_INVALID_OPT_VALUE;function e(o,l,c){return o.highWaterMark!=null?o.highWaterMark:l?o[c]:null}function t(o,l,c,E){var a=e(l,E,c);if(a!=null){if(!(isFinite(a)&&Math.floor(a)===a)||a<0){var f=E?c:"highWaterMark";throw new n(f,a)}return Math.floor(a)}return o.objectMode?16:16*1024}return kr={getHighWaterMark:t},kr}var Or,$i;function ga(){if($i)return Or;$i=1,Or=n;function n(t,o){if(e("noDeprecation"))return t;var l=!1;function c(){if(!l){if(e("throwDeprecation"))throw new Error(o);e("traceDeprecation")?console.trace(o):console.warn(o),l=!0}return t.apply(this,arguments)}return c}function e(t){try{if(!globalThis.localStorage)return!1}catch(l){return!1}var o=globalThis.localStorage[t];return o==null?!1:String(o).toLowerCase()==="true"}return Or}var Mr,Ui;function qi(){if(Ui)return Mr;Ui=1;var n={env:{}};Mr=U;function e(M){var k=this;this.next=null,this.entry=null,this.finish=function(){K(k,M)}}var t;U.WritableState=p;var o={deprecate:ga()},l=Sn(),c=Je().Buffer,E=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function a(M){return c.from(M)}function f(M){return c.isBuffer(M)||M instanceof E}var u=Ni(),w=ji(),A=w.getHighWaterMark,C=Ue().codes,j=C.ERR_INVALID_ARG_TYPE,y=C.ERR_METHOD_NOT_IMPLEMENTED,I=C.ERR_MULTIPLE_CALLBACK,_=C.ERR_STREAM_CANNOT_PIPE,h=C.ERR_STREAM_DESTROYED,b=C.ERR_STREAM_NULL_VALUES,P=C.ERR_STREAM_WRITE_AFTER_END,S=C.ERR_UNKNOWN_ENCODING,R=u.errorOrDestroy;$e()(U,l);function v(){}function p(M,k,D){t=t||qe(),M=M||{},typeof D!="boolean"&&(D=k instanceof t),this.objectMode=!!M.objectMode,D&&(this.objectMode=this.objectMode||!!M.writableObjectMode),this.highWaterMark=A(this,M,"writableHighWaterMark",D),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var V=M.decodeStrings===!1;this.decodeStrings=!V,this.defaultEncoding=M.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(G){_e(k,G)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=M.emitClose!==!1,this.autoDestroy=!!M.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}p.prototype.getBuffer=function(){for(var k=this.bufferedRequest,D=[];k;)D.push(k),k=k.next;return D},function(){try{Object.defineProperty(p.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(M){}}();var B;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(B=Function.prototype[Symbol.hasInstance],Object.defineProperty(U,Symbol.hasInstance,{value:function(k){return B.call(this,k)?!0:this!==U?!1:k&&k._writableState instanceof p}})):B=function(k){return k instanceof this};function U(M){t=t||qe();var k=this instanceof t;if(!k&&!B.call(U,this))return new U(M);this._writableState=new p(M,this,k),this.writable=!0,M&&(typeof M.write=="function"&&(this._write=M.write),typeof M.writev=="function"&&(this._writev=M.writev),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.final=="function"&&(this._final=M.final)),l.call(this)}U.prototype.pipe=function(){R(this,new _)};function F(M,k){var D=new P;R(M,D),n.nextTick(k,D)}function J(M,k,D,V){var G;return D===null?G=new b:typeof D!="string"&&!k.objectMode&&(G=new j("chunk",["string","Buffer"],D)),G?(R(M,G),n.nextTick(V,G),!1):!0}U.prototype.write=function(M,k,D){var V=this._writableState,G=!1,d=!V.objectMode&&f(M);return d&&!c.isBuffer(M)&&(M=a(M)),typeof k=="function"&&(D=k,k=null),d?k="buffer":k||(k=V.defaultEncoding),typeof D!="function"&&(D=v),V.ending?F(this,D):(d||J(this,V,M,D))&&(V.pendingcb++,G=ne(this,V,d,M,k,D)),G},U.prototype.cork=function(){this._writableState.corked++},U.prototype.uncork=function(){var M=this._writableState;M.corked&&(M.corked--,!M.writing&&!M.corked&&!M.bufferProcessing&&M.bufferedRequest&&se(this,M))},U.prototype.setDefaultEncoding=function(k){if(typeof k=="string"&&(k=k.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((k+"").toLowerCase())>-1))throw new S(k);return this._writableState.defaultEncoding=k,this},Object.defineProperty(U.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function O(M,k,D){return!M.objectMode&&M.decodeStrings!==!1&&typeof k=="string"&&(k=c.from(k,D)),k}Object.defineProperty(U.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function ne(M,k,D,V,G,d){if(!D){var g=O(k,V,G);V!==g&&(D=!0,G="buffer",V=g)}var x=k.objectMode?1:V.length;k.length+=x;var H=k.length<k.highWaterMark;if(H||(k.needDrain=!0),k.writing||k.corked){var X=k.lastBufferedRequest;k.lastBufferedRequest={chunk:V,encoding:G,isBuf:D,callback:d,next:null},X?X.next=k.lastBufferedRequest:k.bufferedRequest=k.lastBufferedRequest,k.bufferedRequestCount+=1}else re(M,k,!1,x,V,G,d);return H}function re(M,k,D,V,G,d,g){k.writelen=V,k.writecb=g,k.writing=!0,k.sync=!0,k.destroyed?k.onwrite(new h("write")):D?M._writev(G,k.onwrite):M._write(G,d,k.onwrite),k.sync=!1}function ce(M,k,D,V,G){--k.pendingcb,D?(n.nextTick(G,V),n.nextTick($,M,k),M._writableState.errorEmitted=!0,R(M,V)):(G(V),M._writableState.errorEmitted=!0,R(M,V),$(M,k))}function fe(M){M.writing=!1,M.writecb=null,M.length-=M.writelen,M.writelen=0}function _e(M,k){var D=M._writableState,V=D.sync,G=D.writecb;if(typeof G!="function")throw new I;if(fe(D),k)ce(M,D,V,k,G);else{var d=Ee(D)||M.destroyed;!d&&!D.corked&&!D.bufferProcessing&&D.bufferedRequest&&se(M,D),V?n.nextTick(de,M,D,d,G):de(M,D,d,G)}}function de(M,k,D,V){D||be(M,k),k.pendingcb--,V(),$(M,k)}function be(M,k){k.length===0&&k.needDrain&&(k.needDrain=!1,M.emit("drain"))}function se(M,k){k.bufferProcessing=!0;var D=k.bufferedRequest;if(M._writev&&D&&D.next){var V=k.bufferedRequestCount,G=new Array(V),d=k.corkedRequestsFree;d.entry=D;for(var g=0,x=!0;D;)G[g]=D,D.isBuf||(x=!1),D=D.next,g+=1;G.allBuffers=x,re(M,k,!0,k.length,G,"",d.finish),k.pendingcb++,k.lastBufferedRequest=null,d.next?(k.corkedRequestsFree=d.next,d.next=null):k.corkedRequestsFree=new e(k),k.bufferedRequestCount=0}else{for(;D;){var H=D.chunk,X=D.encoding,Z=D.callback,te=k.objectMode?1:H.length;if(re(M,k,!1,te,H,X,Z),D=D.next,k.bufferedRequestCount--,k.writing)break}D===null&&(k.lastBufferedRequest=null)}k.bufferedRequest=D,k.bufferProcessing=!1}U.prototype._write=function(M,k,D){D(new y("_write()"))},U.prototype._writev=null,U.prototype.end=function(M,k,D){var V=this._writableState;return typeof M=="function"?(D=M,M=null,k=null):typeof k=="function"&&(D=k,k=null),M!=null&&this.write(M,k),V.corked&&(V.corked=1,this.uncork()),V.ending||z(this,V,D),this},Object.defineProperty(U.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Ee(M){return M.ending&&M.length===0&&M.bufferedRequest===null&&!M.finished&&!M.writing}function ve(M,k){M._final(function(D){k.pendingcb--,D&&R(M,D),k.prefinished=!0,M.emit("prefinish"),$(M,k)})}function L(M,k){!k.prefinished&&!k.finalCalled&&(typeof M._final=="function"&&!k.destroyed?(k.pendingcb++,k.finalCalled=!0,n.nextTick(ve,M,k)):(k.prefinished=!0,M.emit("prefinish")))}function $(M,k){var D=Ee(k);if(D&&(L(M,k),k.pendingcb===0&&(k.finished=!0,M.emit("finish"),k.autoDestroy))){var V=M._readableState;(!V||V.autoDestroy&&V.endEmitted)&&M.destroy()}return D}function z(M,k,D){k.ending=!0,$(M,k),D&&(k.finished?n.nextTick(D):M.once("finish",D)),k.ended=!0,M.writable=!1}function K(M,k,D){var V=M.entry;for(M.entry=null;V;){var G=V.callback;k.pendingcb--,G(D),V=V.next}k.corkedRequestsFree.next=M}return Object.defineProperty(U.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(k){this._writableState&&(this._writableState.destroyed=k)}}),U.prototype.destroy=u.destroy,U.prototype._undestroy=u.undestroy,U.prototype._destroy=function(M,k){k(M)},Mr}var Br,xi;function qe(){if(xi)return Br;xi=1;var n={env:{}},e=Object.keys||function(w){var A=[];for(var C in w)A.push(C);return A};Br=a;var t=Yi(),o=qi();$e()(a,t);for(var l=e(o.prototype),c=0;c<l.length;c++){var E=l[c];a.prototype[E]||(a.prototype[E]=o.prototype[E])}function a(w){if(!(this instanceof a))return new a(w);t.call(this,w),o.call(this,w),this.allowHalfOpen=!0,w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",f)))}Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(a.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(a.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function f(){this._writableState.ended||n.nextTick(u,this)}function u(w){w.end()}return Object.defineProperty(a.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(A){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=A,this._writableState.destroyed=A)}}),Br}var Lr={},Wi;function Vi(){if(Wi)return Lr;Wi=1;var n=mn().Buffer,e=n.isEncoding||function(h){switch(h=""+h,h&&h.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(h){if(!h)return"utf8";for(var b;;)switch(h){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 h;default:if(b)return;h=(""+h).toLowerCase(),b=!0}}function o(h){var b=t(h);if(typeof b!="string"&&(n.isEncoding===e||!e(h)))throw new Error("Unknown encoding: "+h);return b||h}Lr.StringDecoder=l;function l(h){this.encoding=o(h);var b;switch(this.encoding){case"utf16le":this.text=A,this.end=C,b=4;break;case"utf8":this.fillLast=f,b=4;break;case"base64":this.text=j,this.end=y,b=3;break;default:this.write=I,this.end=_;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(b)}l.prototype.write=function(h){if(h.length===0)return"";var b,P;if(this.lastNeed){if(b=this.fillLast(h),b===void 0)return"";P=this.lastNeed,this.lastNeed=0}else P=0;return P<h.length?b?b+this.text(h,P):this.text(h,P):b||""},l.prototype.end=w,l.prototype.text=u,l.prototype.fillLast=function(h){if(this.lastNeed<=h.length)return h.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);h.copy(this.lastChar,this.lastTotal-this.lastNeed,0,h.length),this.lastNeed-=h.length};function c(h){return h<=127?0:h>>5===6?2:h>>4===14?3:h>>3===30?4:h>>6===2?-1:-2}function E(h,b,P){var S=b.length-1;if(S<P)return 0;var R=c(b[S]);return R>=0?(R>0&&(h.lastNeed=R-1),R):--S<P||R===-2?0:(R=c(b[S]),R>=0?(R>0&&(h.lastNeed=R-2),R):--S<P||R===-2?0:(R=c(b[S]),R>=0?(R>0&&(R===2?R=0:h.lastNeed=R-3),R):0))}function a(h,b,P){if((b[0]&192)!==128)return h.lastNeed=0,"�";if(h.lastNeed>1&&b.length>1){if((b[1]&192)!==128)return h.lastNeed=1,"�";if(h.lastNeed>2&&b.length>2&&(b[2]&192)!==128)return h.lastNeed=2,"�"}}function f(h){var b=this.lastTotal-this.lastNeed,P=a(this,h);if(P!==void 0)return P;if(this.lastNeed<=h.length)return h.copy(this.lastChar,b,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);h.copy(this.lastChar,b,0,h.length),this.lastNeed-=h.length}function u(h,b){var P=E(this,h,b);if(!this.lastNeed)return h.toString("utf8",b);this.lastTotal=P;var S=h.length-(P-this.lastNeed);return h.copy(this.lastChar,0,S),h.toString("utf8",b,S)}function w(h){var b=h&&h.length?this.write(h):"";return this.lastNeed?b+"�":b}function A(h,b){if((h.length-b)%2===0){var P=h.toString("utf16le",b);if(P){var S=P.charCodeAt(P.length-1);if(S>=55296&&S<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=h[h.length-2],this.lastChar[1]=h[h.length-1],P.slice(0,-1)}return P}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=h[h.length-1],h.toString("utf16le",b,h.length-1)}function C(h){var b=h&&h.length?this.write(h):"";if(this.lastNeed){var P=this.lastTotal-this.lastNeed;return b+this.lastChar.toString("utf16le",0,P)}return b}function j(h,b){var P=(h.length-b)%3;return P===0?h.toString("base64",b):(this.lastNeed=3-P,this.lastTotal=3,P===1?this.lastChar[0]=h[h.length-1]:(this.lastChar[0]=h[h.length-2],this.lastChar[1]=h[h.length-1]),h.toString("base64",b,h.length-P))}function y(h){var b=h&&h.length?this.write(h):"";return this.lastNeed?b+this.lastChar.toString("base64",0,3-this.lastNeed):b}function I(h){return h.toString(this.encoding)}function _(h){return h&&h.length?this.write(h):""}return Lr}var Nr,zi;function Dr(){if(zi)return Nr;zi=1;var n=Ue().codes.ERR_STREAM_PREMATURE_CLOSE;function e(c){var E=!1;return function(){if(!E){E=!0;for(var a=arguments.length,f=new Array(a),u=0;u<a;u++)f[u]=arguments[u];c.apply(this,f)}}}function t(){}function o(c){return c.setHeader&&typeof c.abort=="function"}function l(c,E,a){if(typeof E=="function")return l(c,null,E);E||(E={}),a=e(a||t);var f=E.readable||E.readable!==!1&&c.readable,u=E.writable||E.writable!==!1&&c.writable,w=function(){c.writable||C()},A=c._writableState&&c._writableState.finished,C=function(){u=!1,A=!0,f||a.call(c)},j=c._readableState&&c._readableState.endEmitted,y=function(){f=!1,j=!0,u||a.call(c)},I=function(P){a.call(c,P)},_=function(){var P;if(f&&!j)return(!c._readableState||!c._readableState.ended)&&(P=new n),a.call(c,P);if(u&&!A)return(!c._writableState||!c._writableState.ended)&&(P=new n),a.call(c,P)},h=function(){c.req.on("finish",C)};return o(c)?(c.on("complete",C),c.on("abort",_),c.req?h():c.on("request",h)):u&&!c._writableState&&(c.on("end",w),c.on("close",w)),c.on("end",y),c.on("finish",C),E.error!==!1&&c.on("error",I),c.on("close",_),function(){c.removeListener("complete",C),c.removeListener("abort",_),c.removeListener("request",h),c.req&&c.req.removeListener("finish",C),c.removeListener("end",w),c.removeListener("close",w),c.removeListener("finish",C),c.removeListener("end",y),c.removeListener("error",I),c.removeListener("close",_)}}return Nr=l,Nr}var Fr,Gi;function ya(){if(Gi)return Fr;Gi=1;var n={env:{}},e;function t(S,R,v){return R=o(R),R in S?Object.defineProperty(S,R,{value:v,enumerable:!0,configurable:!0,writable:!0}):S[R]=v,S}function o(S){var R=l(S,"string");return typeof R=="symbol"?R:String(R)}function l(S,R){if(typeof S!="object"||S===null)return S;var v=S[Symbol.toPrimitive];if(v!==void 0){var p=v.call(S,R);if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(R==="string"?String:Number)(S)}var c=Dr(),E=Symbol("lastResolve"),a=Symbol("lastReject"),f=Symbol("error"),u=Symbol("ended"),w=Symbol("lastPromise"),A=Symbol("handlePromise"),C=Symbol("stream");function j(S,R){return{value:S,done:R}}function y(S){var R=S[E];if(R!==null){var v=S[C].read();v!==null&&(S[w]=null,S[E]=null,S[a]=null,R(j(v,!1)))}}function I(S){n.nextTick(y,S)}function _(S,R){return function(v,p){S.then(function(){if(R[u]){v(j(void 0,!0));return}R[A](v,p)},p)}}var h=Object.getPrototypeOf(function(){}),b=Object.setPrototypeOf((e={get stream(){return this[C]},next:function(){var R=this,v=this[f];if(v!==null)return Promise.reject(v);if(this[u])return Promise.resolve(j(void 0,!0));if(this[C].destroyed)return new Promise(function(F,J){n.nextTick(function(){R[f]?J(R[f]):F(j(void 0,!0))})});var p=this[w],B;if(p)B=new Promise(_(p,this));else{var U=this[C].read();if(U!==null)return Promise.resolve(j(U,!1));B=new Promise(this[A])}return this[w]=B,B}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var R=this;return new Promise(function(v,p){R[C].destroy(null,function(B){if(B){p(B);return}v(j(void 0,!0))})})}),e),h),P=function(R){var v,p=Object.create(b,(v={},t(v,C,{value:R,writable:!0}),t(v,E,{value:null,writable:!0}),t(v,a,{value:null,writable:!0}),t(v,f,{value:null,writable:!0}),t(v,u,{value:R._readableState.endEmitted,writable:!0}),t(v,A,{value:function(U,F){var J=p[C].read();J?(p[w]=null,p[E]=null,p[a]=null,U(j(J,!1))):(p[E]=U,p[a]=F)},writable:!0}),v));return p[w]=null,c(R,function(B){if(B&&B.code!=="ERR_STREAM_PREMATURE_CLOSE"){var U=p[a];U!==null&&(p[w]=null,p[E]=null,p[a]=null,U(B)),p[f]=B;return}var F=p[E];F!==null&&(p[w]=null,p[E]=null,p[a]=null,F(j(void 0,!0))),p[u]=!0}),R.on("readable",I.bind(null,p)),p};return Fr=P,Fr}var jr,Hi;function ma(){return Hi||(Hi=1,jr=function(){throw new Error("Readable.from is not available in the browser")}),jr}var $r,Ji;function Yi(){if(Ji)return $r;Ji=1;var n={env:{}};$r=F;var e;F.ReadableState=U,St().EventEmitter;var t=function(g,x){return g.listeners(x).length},o=Sn(),l=Je().Buffer,c=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function E(d){return l.from(d)}function a(d){return l.isBuffer(d)||d instanceof c}var f=Mi(),u;f&&f.debuglog?u=f.debuglog("stream"):u=function(){};var w=pa(),A=Ni(),C=ji(),j=C.getHighWaterMark,y=Ue().codes,I=y.ERR_INVALID_ARG_TYPE,_=y.ERR_STREAM_PUSH_AFTER_EOF,h=y.ERR_METHOD_NOT_IMPLEMENTED,b=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,P,S,R;$e()(F,o);var v=A.errorOrDestroy,p=["error","close","destroy","pause","resume"];function B(d,g,x){if(typeof d.prependListener=="function")return d.prependListener(g,x);!d._events||!d._events[g]?d.on(g,x):Array.isArray(d._events[g])?d._events[g].unshift(x):d._events[g]=[x,d._events[g]]}function U(d,g,x){e=e||qe(),d=d||{},typeof x!="boolean"&&(x=g instanceof e),this.objectMode=!!d.objectMode,x&&(this.objectMode=this.objectMode||!!d.readableObjectMode),this.highWaterMark=j(this,d,"readableHighWaterMark",x),this.buffer=new w,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=d.emitClose!==!1,this.autoDestroy=!!d.autoDestroy,this.destroyed=!1,this.defaultEncoding=d.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,d.encoding&&(P||(P=Vi().StringDecoder),this.decoder=new P(d.encoding),this.encoding=d.encoding)}function F(d){if(e=e||qe(),!(this instanceof F))return new F(d);var g=this instanceof e;this._readableState=new U(d,this,g),this.readable=!0,d&&(typeof d.read=="function"&&(this._read=d.read),typeof d.destroy=="function"&&(this._destroy=d.destroy)),o.call(this)}Object.defineProperty(F.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(g){this._readableState&&(this._readableState.destroyed=g)}}),F.prototype.destroy=A.destroy,F.prototype._undestroy=A.undestroy,F.prototype._destroy=function(d,g){g(d)},F.prototype.push=function(d,g){var x=this._readableState,H;return x.objectMode?H=!0:typeof d=="string"&&(g=g||x.defaultEncoding,g!==x.encoding&&(d=l.from(d,g),g=""),H=!0),J(this,d,g,!1,H)},F.prototype.unshift=function(d){return J(this,d,null,!0,!1)};function J(d,g,x,H,X){u("readableAddChunk",g);var Z=d._readableState;if(g===null)Z.reading=!1,_e(d,Z);else{var te;if(X||(te=ne(Z,g)),te)v(d,te);else if(Z.objectMode||g&&g.length>0)if(typeof g!="string"&&!Z.objectMode&&Object.getPrototypeOf(g)!==l.prototype&&(g=E(g)),H)Z.endEmitted?v(d,new b):O(d,Z,g,!0);else if(Z.ended)v(d,new _);else{if(Z.destroyed)return!1;Z.reading=!1,Z.decoder&&!x?(g=Z.decoder.write(g),Z.objectMode||g.length!==0?O(d,Z,g,!1):se(d,Z)):O(d,Z,g,!1)}else H||(Z.reading=!1,se(d,Z))}return!Z.ended&&(Z.length<Z.highWaterMark||Z.length===0)}function O(d,g,x,H){g.flowing&&g.length===0&&!g.sync?(g.awaitDrain=0,d.emit("data",x)):(g.length+=g.objectMode?1:x.length,H?g.buffer.unshift(x):g.buffer.push(x),g.needReadable&&de(d)),se(d,g)}function ne(d,g){var x;return!a(g)&&typeof g!="string"&&g!==void 0&&!d.objectMode&&(x=new I("chunk",["string","Buffer","Uint8Array"],g)),x}F.prototype.isPaused=function(){return this._readableState.flowing===!1},F.prototype.setEncoding=function(d){P||(P=Vi().StringDecoder);var g=new P(d);this._readableState.decoder=g,this._readableState.encoding=this._readableState.decoder.encoding;for(var x=this._readableState.buffer.head,H="";x!==null;)H+=g.write(x.data),x=x.next;return this._readableState.buffer.clear(),H!==""&&this._readableState.buffer.push(H),this._readableState.length=H.length,this};var re=1073741824;function ce(d){return d>=re?d=re:(d--,d|=d>>>1,d|=d>>>2,d|=d>>>4,d|=d>>>8,d|=d>>>16,d++),d}function fe(d,g){return d<=0||g.length===0&&g.ended?0:g.objectMode?1:d!==d?g.flowing&&g.length?g.buffer.head.data.length:g.length:(d>g.highWaterMark&&(g.highWaterMark=ce(d)),d<=g.length?d:g.ended?g.length:(g.needReadable=!0,0))}F.prototype.read=function(d){u("read",d),d=parseInt(d,10);var g=this._readableState,x=d;if(d!==0&&(g.emittedReadable=!1),d===0&&g.needReadable&&((g.highWaterMark!==0?g.length>=g.highWaterMark:g.length>0)||g.ended))return u("read: emitReadable",g.length,g.ended),g.length===0&&g.ended?D(this):de(this),null;if(d=fe(d,g),d===0&&g.ended)return g.length===0&&D(this),null;var H=g.needReadable;u("need readable",H),(g.length===0||g.length-d<g.highWaterMark)&&(H=!0,u("length less than watermark",H)),g.ended||g.reading?(H=!1,u("reading or ended",H)):H&&(u("do read"),g.reading=!0,g.sync=!0,g.length===0&&(g.needReadable=!0),this._read(g.highWaterMark),g.sync=!1,g.reading||(d=fe(x,g)));var X;return d>0?X=k(d,g):X=null,X===null?(g.needReadable=g.length<=g.highWaterMark,d=0):(g.length-=d,g.awaitDrain=0),g.length===0&&(g.ended||(g.needReadable=!0),x!==d&&g.ended&&D(this)),X!==null&&this.emit("data",X),X};function _e(d,g){if(u("onEofChunk"),!g.ended){if(g.decoder){var x=g.decoder.end();x&&x.length&&(g.buffer.push(x),g.length+=g.objectMode?1:x.length)}g.ended=!0,g.sync?de(d):(g.needReadable=!1,g.emittedReadable||(g.emittedReadable=!0,be(d)))}}function de(d){var g=d._readableState;u("emitReadable",g.needReadable,g.emittedReadable),g.needReadable=!1,g.emittedReadable||(u("emitReadable",g.flowing),g.emittedReadable=!0,n.nextTick(be,d))}function be(d){var g=d._readableState;u("emitReadable_",g.destroyed,g.length,g.ended),!g.destroyed&&(g.length||g.ended)&&(d.emit("readable"),g.emittedReadable=!1),g.needReadable=!g.flowing&&!g.ended&&g.length<=g.highWaterMark,M(d)}function se(d,g){g.readingMore||(g.readingMore=!0,n.nextTick(Ee,d,g))}function Ee(d,g){for(;!g.reading&&!g.ended&&(g.length<g.highWaterMark||g.flowing&&g.length===0);){var x=g.length;if(u("maybeReadMore read 0"),d.read(0),x===g.length)break}g.readingMore=!1}F.prototype._read=function(d){v(this,new h("_read()"))},F.prototype.pipe=function(d,g){var x=this,H=this._readableState;switch(H.pipesCount){case 0:H.pipes=d;break;case 1:H.pipes=[H.pipes,d];break;default:H.pipes.push(d);break}H.pipesCount+=1,u("pipe count=%d opts=%j",H.pipesCount,g);var X=(!g||g.end!==!1)&&d!==n.stdout&&d!==n.stderr,Z=X?q:Be;H.endEmitted?n.nextTick(Z):x.once("end",Z),d.on("unpipe",te);function te(Me,Re){u("onunpipe"),Me===x&&Re&&Re.hasUnpiped===!1&&(Re.hasUnpiped=!0,le())}function q(){u("onend"),d.end()}var Ce=ve(x);d.on("drain",Ce);var Se=!1;function le(){u("cleanup"),d.removeListener("close",Ve),d.removeListener("finish",ze),d.removeListener("drain",Ce),d.removeListener("error",Ae),d.removeListener("unpipe",te),x.removeListener("end",q),x.removeListener("end",Be),x.removeListener("data",he),Se=!0,H.awaitDrain&&(!d._writableState||d._writableState.needDrain)&&Ce()}x.on("data",he);function he(Me){u("ondata");var Re=d.write(Me);u("dest.write",Re),Re===!1&&((H.pipesCount===1&&H.pipes===d||H.pipesCount>1&&G(H.pipes,d)!==-1)&&!Se&&(u("false write response, pause",H.awaitDrain),H.awaitDrain++),x.pause())}function Ae(Me){u("onerror",Me),Be(),d.removeListener("error",Ae),t(d,"error")===0&&v(d,Me)}B(d,"error",Ae);function Ve(){d.removeListener("finish",ze),Be()}d.once("close",Ve);function ze(){u("onfinish"),d.removeListener("close",Ve),Be()}d.once("finish",ze);function Be(){u("unpipe"),x.unpipe(d)}return d.emit("pipe",x),H.flowing||(u("pipe resume"),x.resume()),d};function ve(d){return function(){var x=d._readableState;u("pipeOnDrain",x.awaitDrain),x.awaitDrain&&x.awaitDrain--,x.awaitDrain===0&&t(d,"data")&&(x.flowing=!0,M(d))}}F.prototype.unpipe=function(d){var g=this._readableState,x={hasUnpiped:!1};if(g.pipesCount===0)return this;if(g.pipesCount===1)return d&&d!==g.pipes?this:(d||(d=g.pipes),g.pipes=null,g.pipesCount=0,g.flowing=!1,d&&d.emit("unpipe",this,x),this);if(!d){var H=g.pipes,X=g.pipesCount;g.pipes=null,g.pipesCount=0,g.flowing=!1;for(var Z=0;Z<X;Z++)H[Z].emit("unpipe",this,{hasUnpiped:!1});return this}var te=G(g.pipes,d);return te===-1?this:(g.pipes.splice(te,1),g.pipesCount-=1,g.pipesCount===1&&(g.pipes=g.pipes[0]),d.emit("unpipe",this,x),this)},F.prototype.on=function(d,g){var x=o.prototype.on.call(this,d,g),H=this._readableState;return d==="data"?(H.readableListening=this.listenerCount("readable")>0,H.flowing!==!1&&this.resume()):d==="readable"&&!H.endEmitted&&!H.readableListening&&(H.readableListening=H.needReadable=!0,H.flowing=!1,H.emittedReadable=!1,u("on readable",H.length,H.reading),H.length?de(this):H.reading||n.nextTick($,this)),x},F.prototype.addListener=F.prototype.on,F.prototype.removeListener=function(d,g){var x=o.prototype.removeListener.call(this,d,g);return d==="readable"&&n.nextTick(L,this),x},F.prototype.removeAllListeners=function(d){var g=o.prototype.removeAllListeners.apply(this,arguments);return(d==="readable"||d===void 0)&&n.nextTick(L,this),g};function L(d){var g=d._readableState;g.readableListening=d.listenerCount("readable")>0,g.resumeScheduled&&!g.paused?g.flowing=!0:d.listenerCount("data")>0&&d.resume()}function $(d){u("readable nexttick read 0"),d.read(0)}F.prototype.resume=function(){var d=this._readableState;return d.flowing||(u("resume"),d.flowing=!d.readableListening,z(this,d)),d.paused=!1,this};function z(d,g){g.resumeScheduled||(g.resumeScheduled=!0,n.nextTick(K,d,g))}function K(d,g){u("resume",g.reading),g.reading||d.read(0),g.resumeScheduled=!1,d.emit("resume"),M(d),g.flowing&&!g.reading&&d.read(0)}F.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 M(d){var g=d._readableState;for(u("flow",g.flowing);g.flowing&&d.read()!==null;);}F.prototype.wrap=function(d){var g=this,x=this._readableState,H=!1;d.on("end",function(){if(u("wrapped end"),x.decoder&&!x.ended){var te=x.decoder.end();te&&te.length&&g.push(te)}g.push(null)}),d.on("data",function(te){if(u("wrapped data"),x.decoder&&(te=x.decoder.write(te)),!(x.objectMode&&te==null)&&!(!x.objectMode&&(!te||!te.length))){var q=g.push(te);q||(H=!0,d.pause())}});for(var X in d)this[X]===void 0&&typeof d[X]=="function"&&(this[X]=function(q){return function(){return d[q].apply(d,arguments)}}(X));for(var Z=0;Z<p.length;Z++)d.on(p[Z],this.emit.bind(this,p[Z]));return this._read=function(te){u("wrapped _read",te),H&&(H=!1,d.resume())},this},typeof Symbol=="function"&&(F.prototype[Symbol.asyncIterator]=function(){return S===void 0&&(S=ya()),S(this)}),Object.defineProperty(F.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(F.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(F.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(g){this._readableState&&(this._readableState.flowing=g)}}),F._fromList=k,Object.defineProperty(F.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function k(d,g){if(g.length===0)return null;var x;return g.objectMode?x=g.buffer.shift():!d||d>=g.length?(g.decoder?x=g.buffer.join(""):g.buffer.length===1?x=g.buffer.first():x=g.buffer.concat(g.length),g.buffer.clear()):x=g.buffer.consume(d,g.decoder),x}function D(d){var g=d._readableState;u("endReadable",g.endEmitted),g.endEmitted||(g.ended=!0,n.nextTick(V,g,d))}function V(d,g){if(u("endReadableNT",d.endEmitted,d.length),!d.endEmitted&&d.length===0&&(d.endEmitted=!0,g.readable=!1,g.emit("end"),d.autoDestroy)){var x=g._writableState;(!x||x.autoDestroy&&x.finished)&&g.destroy()}}typeof Symbol=="function"&&(F.from=function(d,g){return R===void 0&&(R=ma()),R(F,d,g)});function G(d,g){for(var x=0,H=d.length;x<H;x++)if(d[x]===g)return x;return-1}return $r}var Ur,Ki;function Xi(){if(Ki)return Ur;Ki=1,Ur=a;var n=Ue().codes,e=n.ERR_METHOD_NOT_IMPLEMENTED,t=n.ERR_MULTIPLE_CALLBACK,o=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,l=n.ERR_TRANSFORM_WITH_LENGTH_0,c=qe();$e()(a,c);function E(w,A){var C=this._transformState;C.transforming=!1;var j=C.writecb;if(j===null)return this.emit("error",new t);C.writechunk=null,C.writecb=null,A!=null&&this.push(A),j(w);var y=this._readableState;y.reading=!1,(y.needReadable||y.length<y.highWaterMark)&&this._read(y.highWaterMark)}function a(w){if(!(this instanceof a))return new a(w);c.call(this,w),this._transformState={afterTransform:E.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,w&&(typeof w.transform=="function"&&(this._transform=w.transform),typeof w.flush=="function"&&(this._flush=w.flush)),this.on("prefinish",f)}function f(){var w=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(A,C){u(w,A,C)}):u(this,null,null)}a.prototype.push=function(w,A){return this._transformState.needTransform=!1,c.prototype.push.call(this,w,A)},a.prototype._transform=function(w,A,C){C(new e("_transform()"))},a.prototype._write=function(w,A,C){var j=this._transformState;if(j.writecb=C,j.writechunk=w,j.writeencoding=A,!j.transforming){var y=this._readableState;(j.needTransform||y.needReadable||y.length<y.highWaterMark)&&this._read(y.highWaterMark)}},a.prototype._read=function(w){var A=this._transformState;A.writechunk!==null&&!A.transforming?(A.transforming=!0,this._transform(A.writechunk,A.writeencoding,A.afterTransform)):A.needTransform=!0},a.prototype._destroy=function(w,A){c.prototype._destroy.call(this,w,function(C){A(C)})};function u(w,A,C){if(A)return w.emit("error",A);if(C!=null&&w.push(C),w._writableState.length)throw new l;if(w._transformState.transforming)throw new o;return w.push(null)}return Ur}var qr,Zi;function va(){if(Zi)return qr;Zi=1,qr=e;var n=Xi();$e()(e,n);function e(t){if(!(this instanceof e))return new e(t);n.call(this,t)}return e.prototype._transform=function(t,o,l){l(null,t)},qr}var xr,Qi;function ba(){if(Qi)return xr;Qi=1;var n;function e(C){var j=!1;return function(){j||(j=!0,C.apply(void 0,arguments))}}var t=Ue().codes,o=t.ERR_MISSING_ARGS,l=t.ERR_STREAM_DESTROYED;function c(C){if(C)throw C}function E(C){return C.setHeader&&typeof C.abort=="function"}function a(C,j,y,I){I=e(I);var _=!1;C.on("close",function(){_=!0}),n===void 0&&(n=Dr()),n(C,{readable:j,writable:y},function(b){if(b)return I(b);_=!0,I()});var h=!1;return function(b){if(!_&&!h){if(h=!0,E(C))return C.abort();if(typeof C.destroy=="function")return C.destroy();I(b||new l("pipe"))}}}function f(C){C()}function u(C,j){return C.pipe(j)}function w(C){return!C.length||typeof C[C.length-1]!="function"?c:C.pop()}function A(){for(var C=arguments.length,j=new Array(C),y=0;y<C;y++)j[y]=arguments[y];var I=w(j);if(Array.isArray(j[0])&&(j=j[0]),j.length<2)throw new o("streams");var _,h=j.map(function(b,P){var S=P<j.length-1,R=P>0;return a(b,S,R,function(v){_||(_=v),v&&h.forEach(f),!S&&(h.forEach(f),I(_))})});return j.reduce(u)}return xr=A,xr}var eo;function wa(){return eo||(eo=1,function(n,e){e=n.exports=Yi(),e.Stream=e,e.Readable=e,e.Writable=qi(),e.Duplex=qe(),e.Transform=Xi(),e.PassThrough=va(),e.finished=Dr(),e.pipeline=ba()}(ot,ot.exports)),ot.exports}/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Wr,to;function Sa(){if(to)return Wr;to=1;let n;return Wr=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window!="undefined"?window:globalThis):e=>(n||(n=Promise.resolve())).then(e).catch(t=>setTimeout(()=>{throw t},0)),Wr}var Vr,ro;function _a(){if(ro)return Vr;ro=1;function n(t,o){for(const l in o)Object.defineProperty(t,l,{value:o[l],enumerable:!0,configurable:!0});return t}function e(t,o,l){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");l||(l={}),typeof o=="object"&&(l=o,o=""),o&&(l.code=o);try{return n(t,l)}catch(c){l.message=t.message,l.stack=t.stack;const E=function(){};return E.prototype=Object.create(Object.getPrototypeOf(t)),n(new E,l)}}return Vr=e,Vr}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var zr,no;function Ca(){if(no)return zr;no=1;const n=Oo()("simple-peer"),e=Mo(),t=Bo(),o=wa(),l=Sa(),c=_a(),{Buffer:E}=Je(),a=64*1024,f=5*1e3,u=5*1e3;function w(j){return j.replace(/a=ice-options:trickle\s\n/g,"")}function A(j){console.warn(j)}class C extends o.Duplex{constructor(y){if(y=Object.assign({allowHalfOpen:!1},y),super(y),this._id=t(4).toString("hex").slice(0,7),this._debug("new peer %o",y),this.channelName=y.initiator?y.channelName||t(20).toString("hex"):null,this.initiator=y.initiator||!1,this.channelConfig=y.channelConfig||C.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},C.config,y.config),this.offerOptions=y.offerOptions||{},this.answerOptions=y.answerOptions||{},this.sdpTransform=y.sdpTransform||(I=>I),this.streams=y.streams||(y.stream?[y.stream]:[]),this.trickle=y.trickle!==void 0?y.trickle:!0,this.allowHalfTrickle=y.allowHalfTrickle!==void 0?y.allowHalfTrickle:!1,this.iceCompleteTimeout=y.iceCompleteTimeout||f,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=y.wrtc&&typeof y.wrtc=="object"?y.wrtc:e(),!this._wrtc)throw c(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(I){this.destroy(c(I,"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=I=>{this._onIceCandidate(I)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(I=>{this.destroy(c(I,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=I=>{this._setupData(I)},this.streams&&this.streams.forEach(I=>{this.addStream(I)}),this._pc.ontrack=I=>{this._onTrack(I)},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(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof y=="string")try{y=JSON.parse(y)}catch(I){y={}}this._debug("signal()"),y.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),y.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(y.transceiverRequest.kind,y.transceiverRequest.init)),y.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(y.candidate):this._pendingCandidates.push(y.candidate)),y.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(y)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(I=>{this._addIceCandidate(I)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(I=>{this.destroy(c(I,"ERR_SET_REMOTE_DESCRIPTION"))}),!y.sdp&&!y.candidate&&!y.renegotiate&&!y.transceiverRequest&&this.destroy(c(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(y){const I=new this._wrtc.RTCIceCandidate(y);this._pc.addIceCandidate(I).catch(_=>{!I.address||I.address.endsWith(".local")?A("Ignoring unsupported ICE candidate."):this.destroy(c(_,"ERR_ADD_ICE_CANDIDATE"))})}send(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(y)}}addTransceiver(y,I){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(y,I),this._needsNegotiation()}catch(_){this.destroy(c(_,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:y,init:I}})}}addStream(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),y.getTracks().forEach(I=>{this.addTrack(I,y)})}}addTrack(y,I){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const _=this._senderMap.get(y)||new Map;let h=_.get(I);if(!h)h=this._pc.addTrack(y,I),_.set(I,h),this._senderMap.set(y,_),this._needsNegotiation();else throw h.removed?c(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):c(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(y,I,_){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const h=this._senderMap.get(y),b=h?h.get(_):null;if(!b)throw c(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");I&&this._senderMap.set(I,h),b.replaceTrack!=null?b.replaceTrack(I):this.destroy(c(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(y,I){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const _=this._senderMap.get(y),h=_?_.get(I):null;if(!h)throw c(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{h.removed=!0,this._pc.removeTrack(h)}catch(b){b.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(h):this.destroy(c(b,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),y.getTracks().forEach(I=>{this.removeTrack(I,y)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,l(()=>{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 c(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(y){this._destroy(y,()=>{})}_destroy(y,I){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",y&&(y.message||y)),l(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",y&&(y.message||y)),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(_){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(_){}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,y&&this.emit("error",y),this.emit("close"),I()}))}_setupData(y){if(!y.channel)return this.destroy(c(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=y.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=a),this.channelName=this._channel.label,this._channel.onmessage=_=>{this._onChannelMessage(_)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=_=>{const h=_.error instanceof Error?_.error:new Error(`Datachannel error: ${_.message} ${_.filename}:${_.lineno}:${_.colno}`);this.destroy(c(h,"ERR_DATA_CHANNEL"))};let I=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(I&&this._onChannelClose(),I=!0):I=!1},u)}_read(){}_write(y,I,_){if(this.destroyed)return _(c(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(y)}catch(h){return this.destroy(c(h,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>a?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=_):_(null)}else this._debug("write before connect"),this._chunk=y,this._cb=_}_onFinish(){if(this.destroyed)return;const y=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?y():this.once("connect",y)}_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(y=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(y.sdp=w(y.sdp)),y.sdp=this.sdpTransform(y.sdp);const I=()=>{if(this.destroyed)return;const b=this._pc.localDescription||y;this._debug("signal"),this.emit("signal",{type:b.type,sdp:b.sdp})},_=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?I():this.once("_iceComplete",I))},h=b=>{this.destroy(c(b,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(y).then(_).catch(h)}).catch(y=>{this.destroy(c(y,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(y=>{!y.mid&&y.sender.track&&!y.requested&&(y.requested=!0,this.addTransceiver(y.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(y=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(y.sdp=w(y.sdp)),y.sdp=this.sdpTransform(y.sdp);const I=()=>{if(this.destroyed)return;const b=this._pc.localDescription||y;this._debug("signal"),this.emit("signal",{type:b.type,sdp:b.sdp}),this.initiator||this._requestMissingTransceivers()},_=()=>{this.destroyed||(this.trickle||this._iceComplete?I():this.once("_iceComplete",I))},h=b=>{this.destroy(c(b,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(y).then(_).catch(h)}).catch(y=>{this.destroy(c(y,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(c(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const y=this._pc.iceConnectionState,I=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",y,I),this.emit("iceStateChange",y,I),(y==="connected"||y==="completed")&&(this._pcReady=!0,this._maybeReady()),y==="failed"&&this.destroy(c(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),y==="closed"&&this.destroy(c(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(y){const I=_=>(Object.prototype.toString.call(_.values)==="[object Array]"&&_.values.forEach(h=>{Object.assign(_,h)}),_);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(_=>{const h=[];_.forEach(b=>{h.push(I(b))}),y(null,h)},_=>y(_)):this._pc.getStats.length>0?this._pc.getStats(_=>{if(this.destroyed)return;const h=[];_.result().forEach(b=>{const P={};b.names().forEach(S=>{P[S]=b.stat(S)}),P.id=b.id,P.type=b.type,P.timestamp=b.timestamp,h.push(I(P))}),y(null,h)},_=>y(_)):y(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 y=()=>{this.destroyed||this.getStats((I,_)=>{if(this.destroyed)return;I&&(_=[]);const h={},b={},P={};let S=!1;_.forEach(v=>{(v.type==="remotecandidate"||v.type==="remote-candidate")&&(h[v.id]=v),(v.type==="localcandidate"||v.type==="local-candidate")&&(b[v.id]=v),(v.type==="candidatepair"||v.type==="candidate-pair")&&(P[v.id]=v)});const R=v=>{S=!0;let p=b[v.localCandidateId];p&&(p.ip||p.address)?(this.localAddress=p.ip||p.address,this.localPort=Number(p.port)):p&&p.ipAddress?(this.localAddress=p.ipAddress,this.localPort=Number(p.portNumber)):typeof v.googLocalAddress=="string"&&(p=v.googLocalAddress.split(":"),this.localAddress=p[0],this.localPort=Number(p[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let B=h[v.remoteCandidateId];B&&(B.ip||B.address)?(this.remoteAddress=B.ip||B.address,this.remotePort=Number(B.port)):B&&B.ipAddress?(this.remoteAddress=B.ipAddress,this.remotePort=Number(B.portNumber)):typeof v.googRemoteAddress=="string"&&(B=v.googRemoteAddress.split(":"),this.remoteAddress=B[0],this.remotePort=Number(B[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(_.forEach(v=>{v.type==="transport"&&v.selectedCandidatePairId&&R(P[v.selectedCandidatePairId]),(v.type==="googCandidatePair"&&v.googActiveConnection==="true"||(v.type==="candidatepair"||v.type==="candidate-pair")&&v.selected)&&R(v)}),!S&&(!Object.keys(P).length||Object.keys(b).length)){setTimeout(y,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(p){return this.destroy(c(p,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const v=this._cb;this._cb=null,v(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};y()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>a||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(y=>{this._pc.removeTrack(y),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(y){this.destroyed||(y.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:y.candidate.candidate,sdpMLineIndex:y.candidate.sdpMLineIndex,sdpMid:y.candidate.sdpMid}}):!y.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),y.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(y){if(this.destroyed)return;let I=y.data;I instanceof ArrayBuffer&&(I=E.from(I)),this.push(I)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const y=this._cb;this._cb=null,y(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(y){this.destroyed||y.streams.forEach(I=>{this._debug("on track"),this.emit("track",y.track,I),this._remoteTracks.push({track:y.track,stream:I}),!this._remoteStreams.some(_=>_.id===I.id)&&(this._remoteStreams.push(I),l(()=>{this._debug("on stream"),this.emit("stream",I)}))})}_debug(){const y=[].slice.call(arguments);y[0]="["+this._id+"] "+y[0],n.apply(null,y)}}return C.WEBRTC_SUPPORT=!!e(),C.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},C.channelConfig={},zr=C,zr}var Ea=Ca();const Ra=yt(Ea);var Pa=Object.defineProperty,Aa=(n,e,t)=>e in n?Pa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t)=>Aa(n,typeof e!="symbol"?e+"":e,t),Gr=(n,e,t)=>new Promise((o,l)=>{var c=f=>{try{a(t.next(f))}catch(u){l(u)}},E=f=>{try{a(t.throw(f))}catch(u){l(u)}},a=f=>f.done?o(f.value):Promise.resolve(f.value).then(c,E);a((t=t.apply(n,e)).next())});class io{constructor(e,t,o={}){De(this,"peer",null),De(this,"config"),De(this,"events"),De(this,"connectionState","new"),De(this,"isInitiator"),De(this,"remoteUserId"),De(this,"localStream",null),this.remoteUserId=e,this.config=t,this.events=o,this.isInitiator=t.initiator||!1}createConnection(e){return Gr(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 Ra(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,o;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(l){console.error(`[CallPeerConnection] Failed to signal to ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}addStream(e){var t,o;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(l){console.error(`[CallPeerConnection] Failed to add stream to ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}removeStream(e){var t,o;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(l){console.error(`[CallPeerConnection] Failed to remove stream from ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}replaceTrack(e,t){var o,l;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 E=this.localStream.getTracks().some(a=>a.id===e.id);E||console.warn(`[CallPeerConnection] Old track not found in local stream for ${this.remoteUserId}, attempting replacement anyway`);try{this.peer.replaceTrack(e,t,this.localStream),E&&this.localStream.removeTrack(e),this.localStream.addTrack(t),console.log(`[CallPeerConnection] ${t.kind} track replaced for ${this.remoteUserId} (${e.id} -> ${t.id})`)}catch(a){throw console.error(`[CallPeerConnection] Failed to replace track for ${this.remoteUserId}:`,a),(l=(o=this.events).onError)==null||l.call(o,a),a}}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,o;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(l){console.error(`[CallPeerConnection] Failed to send data to ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}setBandwidthLimit(e){return Gr(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 o=t.getSenders();for(const l of o)if(l.track){const c=l.getParameters();c.encodings||(c.encodings=[{}]),c.encodings[0].maxBitrate=e*1e3,yield l.setParameters(c)}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 Gr(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"}setupPeerEventListeners(){if(!this.peer)return;this.peer.on("signal",t=>{var o,l;console.log(`[CallPeerConnection] Signal from ${this.remoteUserId}:`,t.type),(l=(o=this.events).onSignal)==null||l.call(o,t)}),this.peer.on("connect",()=>{var t,o;console.log(`[CallPeerConnection] Connected to ${this.remoteUserId}`),this.connectionState="connected",(o=(t=this.events).onConnect)==null||o.call(t)}),this.peer.on("data",t=>{var o,l;try{const c=JSON.parse(t.toString());(l=(o=this.events).onData)==null||l.call(o,c)}catch(c){console.error(`[CallPeerConnection] Failed to parse data from ${this.remoteUserId}:`,c)}}),this.peer.on("stream",t=>{var o,l;console.log(`[CallPeerConnection] Stream received from ${this.remoteUserId}`),(l=(o=this.events).onStream)==null||l.call(o,t)}),this.peer.on("track",(t,o)=>{var l,c;console.log(`[CallPeerConnection] Track received from ${this.remoteUserId}:`,t.kind),(c=(l=this.events).onTrack)==null||c.call(l,t,o)}),this.peer.on("close",()=>{var t,o;console.log(`[CallPeerConnection] Connection closed with ${this.remoteUserId}`),this.connectionState="closed",(o=(t=this.events).onClose)==null||o.call(t)}),this.peer.on("error",t=>{var o,l;console.error(`[CallPeerConnection] Error with ${this.remoteUserId}:`,t),this.connectionState="failed",(l=(o=this.events).onError)==null||l.call(o,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 oo={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Ze=new Map,ut=n=>{const e=Ze.get(n);return e?Object.fromEntries(Object.entries(e.stores).map(([t,o])=>[t,o.getState()])):{}},Ta=(n,e,t)=>{if(n===void 0)return{type:"untracked",connection:e.connect(t)};const o=Ze.get(t.name);if(o)return et({type:"tracked",store:n},o);const l={connection:e.connect(t),stores:{}};return Ze.set(t.name,l),et({type:"tracked",store:n},l)},Ia=(n,e)=>{if(e===void 0)return;const t=Ze.get(n);t&&(delete t.stores[e],Object.keys(t.stores).length===0&&Ze.delete(n))},ka=n=>{var e,t;if(!n)return;const o=n.split(`
17
- `),l=o.findIndex(E=>E.includes("api.setState"));if(l<0)return;const c=((e=o[l+1])==null?void 0:e.trim())||"";return(t=/.+ (.+) .+/.exec(c))==null?void 0:t[1]},Oa=(n,e={})=>(t,o,l)=>{const I=e,{enabled:c,anonymousActionType:E,store:a}=I,f=ln(I,["enabled","anonymousActionType","store"]);let u;try{u=(c!=null?c:(oo?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(h){}if(!u)return n(t,o,l);const _=Ta(a,u,f),{connection:w}=_,A=ln(_,["connection"]);let C=!0;l.setState=(h,b,P)=>{const S=t(h,b);if(!C)return S;const R=P===void 0?{type:E||ka(new Error().stack)||"anonymous"}:typeof P=="string"?{type:P}:P;return a===void 0?(w==null||w.send(R,o()),S):(w==null||w.send(sn(et({},R),{type:`${a}/${R.type}`}),sn(et({},ut(f.name)),{[a]:l.getState()})),S)},l.devtools={cleanup:()=>{w&&typeof w.unsubscribe=="function"&&w.unsubscribe(),Ia(f.name,a)}};const j=(...h)=>{const b=C;C=!1,t(...h),C=b},y=n(l.setState,o,l);if(A.type==="untracked"?w==null||w.init(y):(A.stores[A.store]=l,w==null||w.init(Object.fromEntries(Object.entries(A.stores).map(([h,b])=>[h,h===A.store?y:b.getState()])))),l.dispatchFromDevtools&&typeof l.dispatch=="function"){let h=!1;const b=l.dispatch;l.dispatch=(...P)=>{(oo?"production":void 0)!=="production"&&P[0].type==="__setState"&&!h&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),h=!0),b(...P)}}return w.subscribe(h=>{var b;switch(h.type){case"ACTION":if(typeof h.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Hr(h.payload,P=>{if(P.type==="__setState"){if(a===void 0){j(P.state);return}Object.keys(P.state).length!==1&&console.error(`
6
+ */(function(r){const e=Et,t=qt,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=h,r.SlowBuffer=k,r.INSPECT_MAX_BYTES=50;const u=2147483647;r.kMaxLength=u;const{Uint8Array:l,ArrayBuffer:g,SharedArrayBuffer:f}=globalThis;h.TYPED_ARRAY_SUPPORT=c(),!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 c(){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 v(d){if(d>u)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 I(d,n,o)}h.poolSize=8192;function I(d,n,o){if(typeof d=="string")return N(d,n);if(g.isView(d))return m(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 R(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 O=A(d);if(O)return O;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 I(d,n,o)},Object.setPrototypeOf(h.prototype,l.prototype),Object.setPrototypeOf(h,l);function B(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 x(d,n,o){return B(d),d<=0?v(d):n!==void 0?typeof o=="string"?v(d).fill(n,o):v(d).fill(n):v(d)}h.alloc=function(d,n,o){return x(d,n,o)};function b(d){return B(d),v(d<0?0:P(d)|0)}h.allocUnsafe=function(d){return b(d)},h.allocUnsafeSlow=function(d){return b(d)};function N(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 _=v(o);const O=_.write(d,n);return O!==o&&(_=_.slice(0,O)),_}function T(d){const n=d.length<0?0:P(d.length)|0,o=v(n);for(let _=0;_<n;_+=1)o[_]=d[_]&255;return o}function m(d){if(Ne(d,l)){const n=new l(d);return R(n.buffer,n.byteOffset,n.byteLength)}return T(d)}function R(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=P(d.length)|0,o=v(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)?v(0):T(d);if(d.type==="Buffer"&&Array.isArray(d.data))return T(d.data)}function P(d){if(d>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return d|0}function k(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,O=o.length;for(let j=0,Y=Math.min(_,O);j<Y;++j)if(n[j]!==o[j]){_=n[j],O=o[j];break}return _<O?-1:O<_?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 O=h.allocUnsafe(o);let j=0;for(_=0;_<n.length;++_){let Y=n[_];if(Ne(Y,l))j+Y.length>O.length?(h.isBuffer(Y)||(Y=h.from(Y)),Y.copy(O,j)):l.prototype.set.call(O,Y,j);else if(h.isBuffer(Y))Y.copy(O,j);else throw new TypeError('"list" argument must be an Array of Buffers');j+=Y.length}return O};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 O=!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(O)return _?-1:Fe(d).length;n=(""+n).toLowerCase(),O=!0}}h.byteLength=S;function C(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 $(this,n,o);case"utf8":case"utf-8":return ke(this,n,o);case"ascii":return Oe(this,n,o);case"latin1":case"binary":return qe(this,n,o);case"base64":return Pe(this,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(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?ke(this,0,n):C.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,_,O,j){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),O===void 0&&(O=0),j===void 0&&(j=this.length),o<0||_>n.length||O<0||j>this.length)throw new RangeError("out of range index");if(O>=j&&o>=_)return 0;if(O>=j)return-1;if(o>=_)return 1;if(o>>>=0,_>>>=0,O>>>=0,j>>>=0,this===n)return 0;let Y=j-O,ce=_-o;const be=Math.min(Y,ce),Se=this.slice(O,j),Ce=n.slice(o,_);for(let pe=0;pe<be;++pe)if(Se[pe]!==Ce[pe]){Y=Se[pe],ce=Ce[pe];break}return Y<ce?-1:ce<Y?1:0};function W(d,n,o,_,O){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=O?0:d.length-1),o<0&&(o=d.length+o),o>=d.length){if(O)return-1;o=d.length-1}else if(o<0)if(O)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,_,O);if(typeof n=="number")return n=n&255,typeof l.prototype.indexOf=="function"?O?l.prototype.indexOf.call(d,n,o):l.prototype.lastIndexOf.call(d,n,o):X(d,[n],o,_,O);throw new TypeError("val must be string, number or Buffer")}function X(d,n,o,_,O){let j=1,Y=d.length,ce=n.length;if(_!==void 0&&(_=String(_).toLowerCase(),_==="ucs2"||_==="ucs-2"||_==="utf16le"||_==="utf-16le")){if(d.length<2||n.length<2)return-1;j=2,Y/=2,ce/=2,o/=2}function be(Ce,pe){return j===1?Ce[pe]:Ce.readUInt16BE(pe*j)}let Se;if(O){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===ce)return Ce*j}else Ce!==-1&&(Se-=Se-Ce),Ce=-1}else for(o+ce>Y&&(o=Y-ce),Se=o;Se>=0;Se--){let Ce=!0;for(let pe=0;pe<ce;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 O=d.length-o;_?(_=Number(_),_>O&&(_=O)):_=O;const j=n.length;_>j/2&&(_=j/2);let Y;for(Y=0;Y<_;++Y){const ce=parseInt(n.substr(Y*2,2),16);if(We(ce))return Y;d[o+Y]=ce}return Y}function U(d,n,o,_){return $e(Fe(n,d.length-o),d,o,_)}function he(d,n,o,_){return $e(Ue(n),d,o,_)}function de(d,n,o,_){return $e(we(n),d,o,_)}function me(d,n,o,_){return $e(ye(n,d.length-o),d,o,_)}h.prototype.write=function(n,o,_,O){if(o===void 0)O="utf8",_=this.length,o=0;else if(_===void 0&&typeof o=="string")O=o,_=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(_)?(_=_>>>0,O===void 0&&(O="utf8")):(O=_,_=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const j=this.length-o;if((_===void 0||_>j)&&(_=j),n.length>0&&(_<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");O||(O="utf8");let Y=!1;for(;;)switch(O){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: "+O);O=(""+O).toLowerCase(),Y=!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 ke(d,n,o){o=Math.min(d.length,o);const _=[];let O=n;for(;O<o;){const j=d[O];let Y=null,ce=j>239?4:j>223?3:j>191?2:1;if(O+ce<=o){let be,Se,Ce,pe;switch(ce){case 1:j<128&&(Y=j);break;case 2:be=d[O+1],(be&192)===128&&(pe=(j&31)<<6|be&63,pe>127&&(Y=pe));break;case 3:be=d[O+1],Se=d[O+2],(be&192)===128&&(Se&192)===128&&(pe=(j&15)<<12|(be&63)<<6|Se&63,pe>2047&&(pe<55296||pe>57343)&&(Y=pe));break;case 4:be=d[O+1],Se=d[O+2],Ce=d[O+3],(be&192)===128&&(Se&192)===128&&(Ce&192)===128&&(pe=(j&15)<<18|(be&63)<<12|(Se&63)<<6|Ce&63,pe>65535&&pe<1114112&&(Y=pe))}}Y===null?(Y=65533,ce=1):Y>65535&&(Y-=65536,_.push(Y>>>10&1023|55296),Y=56320|Y&1023),_.push(Y),O+=ce}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 Oe(d,n,o){let _="";o=Math.min(d.length,o);for(let O=n;O<o;++O)_+=String.fromCharCode(d[O]&127);return _}function qe(d,n,o){let _="";o=Math.min(d.length,o);for(let O=n;O<o;++O)_+=String.fromCharCode(d[O]);return _}function $(d,n,o){const _=d.length;(!n||n<0)&&(n=0),(!o||o<0||o>_)&&(o=_);let O="";for(let j=n;j<o;++j)O+=Ve[d[j]];return O}function V(d,n,o){const _=d.slice(n,o);let O="";for(let j=0;j<_.length-1;j+=2)O+=String.fromCharCode(_[j]+_[j+1]*256);return O}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 O=this.subarray(n,o);return Object.setPrototypeOf(O,h.prototype),O};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 O=this[n],j=1,Y=0;for(;++Y<o&&(j*=256);)O+=this[n+Y]*j;return O},h.prototype.readUintBE=h.prototype.readUIntBE=function(n,o,_){n=n>>>0,o=o>>>0,_||J(n,o,this.length);let O=this[n+--o],j=1;for(;o>0&&(j*=256);)O+=this[n+--o]*j;return O},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=Me(function(n){n=n>>>0,ie(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&se(n,this.length-8);const O=o+this[++n]*oe(2,8)+this[++n]*oe(2,16)+this[++n]*oe(2,24),j=this[++n]+this[++n]*oe(2,8)+this[++n]*oe(2,16)+_*oe(2,24);return BigInt(O)+(BigInt(j)<<BigInt(32))}),h.prototype.readBigUInt64BE=Me(function(n){n=n>>>0,ie(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&se(n,this.length-8);const O=o*oe(2,24)+this[++n]*oe(2,16)+this[++n]*oe(2,8)+this[++n],j=this[++n]*oe(2,24)+this[++n]*oe(2,16)+this[++n]*oe(2,8)+_;return(BigInt(O)<<BigInt(32))+BigInt(j)}),h.prototype.readIntLE=function(n,o,_){n=n>>>0,o=o>>>0,_||J(n,o,this.length);let O=this[n],j=1,Y=0;for(;++Y<o&&(j*=256);)O+=this[n+Y]*j;return j*=128,O>=j&&(O-=Math.pow(2,8*o)),O},h.prototype.readIntBE=function(n,o,_){n=n>>>0,o=o>>>0,_||J(n,o,this.length);let O=o,j=1,Y=this[n+--O];for(;O>0&&(j*=256);)Y+=this[n+--O]*j;return j*=128,Y>=j&&(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=Me(function(n){n=n>>>0,ie(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&se(n,this.length-8);const O=this[n+4]+this[n+5]*oe(2,8)+this[n+6]*oe(2,16)+(_<<24);return(BigInt(O)<<BigInt(32))+BigInt(o+this[++n]*oe(2,8)+this[++n]*oe(2,16)+this[++n]*oe(2,24))}),h.prototype.readBigInt64BE=Me(function(n){n=n>>>0,ie(n,"offset");const o=this[n],_=this[n+7];(o===void 0||_===void 0)&&se(n,this.length-8);const O=(o<<24)+this[++n]*oe(2,16)+this[++n]*oe(2,8)+this[++n];return(BigInt(O)<<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,_,O,j){if(!h.isBuffer(d))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>O||n<j)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,_,O){if(n=+n,o=o>>>0,_=_>>>0,!O){const ce=Math.pow(2,8*_)-1;ne(this,n,o,_,ce,0)}let j=1,Y=0;for(this[o]=n&255;++Y<_&&(j*=256);)this[o+Y]=n/j&255;return o+_},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(n,o,_,O){if(n=+n,o=o>>>0,_=_>>>0,!O){const ce=Math.pow(2,8*_)-1;ne(this,n,o,_,ce,0)}let j=_-1,Y=1;for(this[o+j]=n&255;--j>=0&&(Y*=256);)this[o+j]=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,_,O){le(n,_,O,d,o,7);let j=Number(n&BigInt(4294967295));d[o++]=j,j=j>>8,d[o++]=j,j=j>>8,d[o++]=j,j=j>>8,d[o++]=j;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,_,O){le(n,_,O,d,o,7);let j=Number(n&BigInt(4294967295));d[o+7]=j,j=j>>8,d[o+6]=j,j=j>>8,d[o+5]=j,j=j>>8,d[o+4]=j;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=Me(function(n,o=0){return D(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Me(function(n,o=0){return F(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(n,o,_,O){if(n=+n,o=o>>>0,!O){const be=Math.pow(2,8*_-1);ne(this,n,o,_,be-1,-be)}let j=0,Y=1,ce=0;for(this[o]=n&255;++j<_&&(Y*=256);)n<0&&ce===0&&this[o+j-1]!==0&&(ce=1),this[o+j]=(n/Y>>0)-ce&255;return o+_},h.prototype.writeIntBE=function(n,o,_,O){if(n=+n,o=o>>>0,!O){const be=Math.pow(2,8*_-1);ne(this,n,o,_,be-1,-be)}let j=_-1,Y=1,ce=0;for(this[o+j]=n&255;--j>=0&&(Y*=256);)n<0&&ce===0&&this[o+j+1]!==0&&(ce=1),this[o+j]=(n/Y>>0)-ce&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=Me(function(n,o=0){return D(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Me(function(n,o=0){return F(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function G(d,n,o,_,O,j){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,_,O){return n=+n,o=o>>>0,O||G(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,_,O){return n=+n,o=o>>>0,O||G(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,_,O){if(!h.isBuffer(n))throw new TypeError("argument should be a Buffer");if(_||(_=0),!O&&O!==0&&(O=this.length),o>=n.length&&(o=n.length),o||(o=0),O>0&&O<_&&(O=_),O===_||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(O<0)throw new RangeError("sourceEnd out of bounds");O>this.length&&(O=this.length),n.length-o<O-_&&(O=n.length-o+_);const j=O-_;return this===n&&typeof l.prototype.copyWithin=="function"?this.copyWithin(o,_,O):l.prototype.set.call(n,this.subarray(_,O),o),j},h.prototype.fill=function(n,o,_,O){if(typeof n=="string"){if(typeof o=="string"?(O=o,o=0,_=this.length):typeof _=="string"&&(O=_,_=this.length),O!==void 0&&typeof O!="string")throw new TypeError("encoding must be a string");if(typeof O=="string"&&!h.isEncoding(O))throw new TypeError("Unknown encoding: "+O);if(n.length===1){const Y=n.charCodeAt(0);(O==="utf8"&&Y<128||O==="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 j;if(typeof n=="number")for(j=o;j<_;++j)this[j]=n;else{const Y=h.isBuffer(n)?n:h.from(n,O),ce=Y.length;if(ce===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(j=0;j<_-o;++j)this[j+o]=Y[j%ce]}return this};const y={};function w(d,n,o){y[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(O){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:O,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.`,O=o;return Number.isInteger(o)&&Math.abs(o)>oe(2,32)?O=z(String(o)):typeof o=="bigint"&&(O=String(o),(o>oe(BigInt(2),BigInt(32))||o<-oe(BigInt(2),BigInt(32)))&&(O=z(O)),O+="n"),_+=` It must be ${n}. Received ${O}`,_},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)&&se(n,d.length-(o+1))}function le(d,n,o,_,O,j){if(d>o||d<n){const Y=typeof n=="bigint"?"n":"";let ce;throw n===0||n===BigInt(0)?ce=`>= 0${Y} and < 2${Y} ** ${(j+1)*8}${Y}`:ce=`>= -(2${Y} ** ${(j+1)*8-1}${Y}) and < 2 ** ${(j+1)*8-1}${Y}`,new y.ERR_OUT_OF_RANGE("value",ce,d)}ee(_,O,j)}function ie(d,n){if(typeof d!="number")throw new y.ERR_INVALID_ARG_TYPE(n,"number",d)}function se(d,n,o){throw Math.floor(d)!==d?(ie(d,o),new y.ERR_OUT_OF_RANGE("offset","an integer",d)):n<0?new y.ERR_BUFFER_OUT_OF_BOUNDS:new y.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 O=null;const j=[];for(let Y=0;Y<_;++Y){if(o=d.charCodeAt(Y),o>55295&&o<57344){if(!O){if(o>56319){(n-=3)>-1&&j.push(239,191,189);continue}else if(Y+1===_){(n-=3)>-1&&j.push(239,191,189);continue}O=o;continue}if(o<56320){(n-=3)>-1&&j.push(239,191,189),O=o;continue}o=(O-55296<<10|o-56320)+65536}else O&&(n-=3)>-1&&j.push(239,191,189);if(O=null,o<128){if((n-=1)<0)break;j.push(o)}else if(o<2048){if((n-=2)<0)break;j.push(o>>6|192,o&63|128)}else if(o<65536){if((n-=3)<0)break;j.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((n-=4)<0)break;j.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return j}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,_,O;const j=[];for(let Y=0;Y<d.length&&!((n-=2)<0);++Y)o=d.charCodeAt(Y),_=o>>8,O=o%256,j.push(O),j.push(_);return j}function we(d){return e.toByteArray(H(d))}function $e(d,n,o,_){let O;for(O=0;O<_&&!(O+o>=n.length||O>=d.length);++O)n[O+o]=d[O];return O}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 Ve=function(){const d="0123456789abcdef",n=new Array(256);for(let o=0;o<16;++o){const _=o*16;for(let O=0;O<16;++O)n[_+O]=d[o]+d[O]}return n}();function Me(d){return typeof BigInt=="undefined"?tt:d}function tt(){throw new Error("BigInt not supported")}})(Fn);const ua=Fn.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 ua=="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 fa=Object.defineProperty,ha=(r,e,t)=>e in r?fa(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,it=(r,e,t)=>ha(r,typeof e!="symbol"?e+"":e,t),Ke=(r,e,t)=>new Promise((s,u)=>{var l=c=>{try{f(t.next(c))}catch(v){u(v)}},g=c=>{try{f(t.throw(c))}catch(v){u(v)}},f=c=>c.done?s(c.value):Promise.resolve(c.value).then(l,g);f((t=t.apply(r,e)).next())});class $n{constructor(e,t,s="/apis/video-call"){it(this,"socket",null),it(this,"serverUrl"),it(this,"socketPath"),it(this,"token"),it(this,"connected",!1),it(this,"reconnectAttempts",0),it(this,"maxReconnectAttempts",5),this.serverUrl=e,this.token=t,this.socketPath=s}connect(){return Ke(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,u=>{u!=null&&u.error&&console.error(`[CallSocket] Error in ${e}:`,u.error)})}emitWithResponse(e,t,s=1e4){return Ke(this,null,function*(){if(!this.isConnected())throw new Error("Socket not connected");return console.log(`[CallSocket] Emitting ${e} with response:`,t),new Promise((u,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,c=>{clearTimeout(f),c!=null&&c.error?(console.error(`[CallSocket] Error in ${e}:`,c.error),l(new Error(c.error))):(console.log(`[CallSocket] Response for ${e}:`,c),u(c))})})})}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 Ke(this,null,function*(){return this.emitWithResponse("call.start",{roomId:e})})}joinRoom(e){return Ke(this,null,function*(){return this.emitWithResponse("call.join",{roomId:e})})}leaveCall(e){return Ke(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 Ke(this,null,function*(){this.emit("call.end",{roomId:e})})}startRecording(e,t){return Ke(this,null,function*(){return this.emitWithResponse("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){return Ke(this,null,function*(){return this.emitWithResponse("call.recording.end",{roomId:e,recordingId:t})})}sendTranscript(e,t){this.emit("call.transcript",{roomId:e,transcript:t,timestamp:Date.now()})}checkCallStatus(e){return Ke(this,null,function*(){return this.emitWithResponse("call.status",{roomId:e})})}getIceServers(e){return Ke(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 da=Object.defineProperty,pa=(r,e,t)=>e in r?da(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,gt=(r,e,t)=>pa(r,typeof e!="symbol"?e+"":e,t),Ct=(r,e,t)=>new Promise((s,u)=>{var l=c=>{try{f(t.next(c))}catch(v){u(v)}},g=c=>{try{f(t.throw(c))}catch(v){u(v)}},f=c=>c.done?s(c.value):Promise.resolve(c.value).then(l,g);f((t=t.apply(r,e)).next())});class jn{constructor(e={video:!0,audio:!0}){gt(this,"cameraStream",null),gt(this,"screenStream",null),gt(this,"videoElement",null),gt(this,"constraints"),gt(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(u=>{u.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(u=>{u.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 xt(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Rt={exports:{}},Wt,qn;function ga(){if(qn)return Wt;qn=1;var r=1e3,e=r*60,t=e*60,s=t*24,u=s*7,l=s*365.25;Wt=function(h,I){I=I||{};var B=typeof h;if(B==="string"&&h.length>0)return g(h);if(B==="number"&&isFinite(h))return I.long?c(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 I=/^(-?(?:\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(I){var B=parseFloat(I[1]),x=(I[2]||"ms").toLowerCase();switch(x){case"years":case"year":case"yrs":case"yr":case"y":return B*l;case"weeks":case"week":case"w":return B*u;case"days":case"day":case"d":return B*s;case"hours":case"hour":case"hrs":case"hr":case"h":return B*t;case"minutes":case"minute":case"mins":case"min":case"m":return B*e;case"seconds":case"second":case"secs":case"sec":case"s":return B*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return B;default:return}}}}function f(h){var I=Math.abs(h);return I>=s?Math.round(h/s)+"d":I>=t?Math.round(h/t)+"h":I>=e?Math.round(h/e)+"m":I>=r?Math.round(h/r)+"s":h+"ms"}function c(h){var I=Math.abs(h);return I>=s?v(h,I,s,"day"):I>=t?v(h,I,t,"hour"):I>=e?v(h,I,e,"minute"):I>=r?v(h,I,r,"second"):h+" ms"}function v(h,I,B,x){var b=I>=B*1.5;return Math.round(h/B)+" "+x+(b?"s":"")}return Wt}var Gt,xn;function ya(){if(xn)return Gt;xn=1;function r(e){s.debug=s,s.default=s,s.coerce=v,s.disable=f,s.enable=l,s.enabled=c,s.humanize=ga(),s.destroy=h,Object.keys(e).forEach(I=>{s[I]=e[I]}),s.names=[],s.skips=[],s.formatters={};function t(I){let B=0;for(let x=0;x<I.length;x++)B=(B<<5)-B+I.charCodeAt(x),B|=0;return s.colors[Math.abs(B)%s.colors.length]}s.selectColor=t;function s(I){let B,x=null,b,N;function T(...m){if(!T.enabled)return;const R=T,A=Number(new Date),P=A-(B||A);R.diff=P,R.prev=B,R.curr=A,B=A,m[0]=s.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let k=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(C,M)=>{if(C==="%%")return"%";k++;const W=s.formatters[M];if(typeof W=="function"){const X=m[k];C=W.call(R,X),m.splice(k,1),k--}return C}),s.formatArgs.call(R,m),(R.log||s.log).apply(R,m)}return T.namespace=I,T.useColors=s.useColors(),T.color=s.selectColor(I),T.extend=u,T.destroy=s.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>x!==null?x:(b!==s.namespaces&&(b=s.namespaces,N=s.enabled(I)),N),set:m=>{x=m}}),typeof s.init=="function"&&s.init(T),T}function u(I,B){const x=s(this.namespace+(typeof B=="undefined"?":":B)+I);return x.log=this.log,x}function l(I){s.save(I),s.namespaces=I,s.names=[],s.skips=[];const B=(typeof I=="string"?I:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const x of B)x[0]==="-"?s.skips.push(x.slice(1)):s.names.push(x)}function g(I,B){let x=0,b=0,N=-1,T=0;for(;x<I.length;)if(b<B.length&&(B[b]===I[x]||B[b]==="*"))B[b]==="*"?(N=b,T=x,b++):(x++,b++);else if(N!==-1)b=N+1,T++,x=T;else return!1;for(;b<B.length&&B[b]==="*";)b++;return b===B.length}function f(){const I=[...s.names,...s.skips.map(B=>"-"+B)].join(",");return s.enable(""),I}function c(I){for(const B of s.skips)if(g(I,B))return!1;for(const B of s.names)if(g(I,B))return!0;return!1}function v(I){return I instanceof Error?I.stack||I.message:I}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 Gt=r,Gt}var Wn;function ma(){return Wn||(Wn=1,function(r,e){e.formatArgs=s,e.save=u,e.load=l,e.useColors=t,e.storage=g(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!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 c;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&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function s(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+r.exports.humanize(this.diff),!this.useColors)return;const v="color: "+this.color;c.splice(1,0,v,"color: inherit");let h=0,I=0;c[0].replace(/%[a-zA-Z%]/g,B=>{B!=="%%"&&(h++,B==="%c"&&(I=h))}),c.splice(I,0,v)}e.log=console.debug||console.log||(()=>{});function u(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch(v){}}function l(){let c;try{c=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch(v){}return!c&&typeof ae!="undefined"&&"env"in ae&&(c=ae.env.DEBUG),c}function g(){try{return localStorage}catch(c){}}r.exports=ya()(e);const{formatters:f}=r.exports;f.j=function(c){try{return JSON.stringify(c)}catch(v){return"[UnexpectedJSONParseError]: "+v.message}}}(Rt,Rt.exports)),Rt.exports}var Vt,Gn;function va(){return Gn||(Gn=1,Vt=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}),Vt}var Pt={exports:{}},Tt={exports:{}},zt={},Vn;function yt(){return Vn||(Vn=1,function(r){Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},t={};t.byteLength=h,t.toByteArray=B,t.fromByteArray=N;for(var s=[],u=[],l=typeof Uint8Array!="undefined"?Uint8Array:Array,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,c=g.length;f<c;++f)s[f]=g[f],u[g.charCodeAt(f)]=f;u[45]=62,u[95]=63;function v(R){var A=R.length;if(A%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var P=R.indexOf("=");P===-1&&(P=A);var k=P===A?0:4-P%4;return[P,k]}function h(R){var A=v(R),P=A[0],k=A[1];return(P+k)*3/4-k}function I(R,A,P){return(A+P)*3/4-P}function B(R){var A,P=v(R),k=P[0],S=P[1],C=new l(I(R,k,S)),M=0,W=S>0?k-4:k,X;for(X=0;X<W;X+=4)A=u[R.charCodeAt(X)]<<18|u[R.charCodeAt(X+1)]<<12|u[R.charCodeAt(X+2)]<<6|u[R.charCodeAt(X+3)],C[M++]=A>>16&255,C[M++]=A>>8&255,C[M++]=A&255;return S===2&&(A=u[R.charCodeAt(X)]<<2|u[R.charCodeAt(X+1)]>>4,C[M++]=A&255),S===1&&(A=u[R.charCodeAt(X)]<<10|u[R.charCodeAt(X+1)]<<4|u[R.charCodeAt(X+2)]>>2,C[M++]=A>>8&255,C[M++]=A&255),C}function x(R){return s[R>>18&63]+s[R>>12&63]+s[R>>6&63]+s[R&63]}function b(R,A,P){for(var k,S=[],C=A;C<P;C+=3)k=(R[C]<<16&16711680)+(R[C+1]<<8&65280)+(R[C+2]&255),S.push(x(k));return S.join("")}function N(R){for(var A,P=R.length,k=P%3,S=[],C=16383,M=0,W=P-k;M<W;M+=C)S.push(b(R,M,M+C>W?W:M+C));return k===1?(A=R[P-1],S.push(s[A>>2]+s[A<<4&63]+"==")):k===2&&(A=(R[P-2]<<8)+R[P-1],S.push(s[A>>10]+s[A>>4&63]+s[A<<2&63]+"=")),S.join("")}var T={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */T.read=function(R,A,P,k,S){var C,M,W=S*8-k-1,X=(1<<W)-1,re=X>>1,U=-7,he=P?S-1:0,de=P?-1:1,me=R[A+he];for(he+=de,C=me&(1<<-U)-1,me>>=-U,U+=W;U>0;C=C*256+R[A+he],he+=de,U-=8);for(M=C&(1<<-U)-1,C>>=-U,U+=k;U>0;M=M*256+R[A+he],he+=de,U-=8);if(C===0)C=1-re;else{if(C===X)return M?NaN:(me?-1:1)*(1/0);M=M+Math.pow(2,k),C=C-re}return(me?-1:1)*M*Math.pow(2,C-k)},T.write=function(R,A,P,k,S,C){var M,W,X,re=C*8-S-1,U=(1<<re)-1,he=U>>1,de=S===23?Math.pow(2,-24)-Math.pow(2,-77):0,me=k?0:C-1,Pe=k?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,M=U):(M=Math.floor(Math.log(A)/Math.LN2),A*(X=Math.pow(2,-M))<1&&(M--,X*=2),M+he>=1?A+=de/X:A+=de*Math.pow(2,1-he),A*X>=2&&(M++,X/=2),M+he>=U?(W=0,M=U):M+he>=1?(W=(A*X-1)*Math.pow(2,S),M=M+he):(W=A*Math.pow(2,he-1)*Math.pow(2,S),M=0));S>=8;R[P+me]=W&255,me+=Pe,W/=256,S-=8);for(M=M<<S|W,re+=S;re>0;R[P+me]=M&255,me+=Pe,M/=256,re-=8);R[P+me-Pe]|=ke*128};/*!
7
+ * The buffer module from node.js, for the browser.
8
+ *
9
+ * @author Feross Aboukhadijeh <https://feross.org>
10
+ * @license MIT
11
+ */(function(R){const A=t,P=T,k=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;R.Buffer=U,R.SlowBuffer=V,R.INSPECT_MAX_BYTES=50;const S=2147483647;R.kMaxLength=S;const{Uint8Array:C,ArrayBuffer:M,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 C(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,C.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 C(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 he(p,i,a)}U.poolSize=8192;function he(p,i,a){if(typeof p=="string")return ke(p,i);if(M.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,M)||p&&Ze(p.buffer,M)||typeof W!="undefined"&&(Ze(p,W)||p&&Ze(p.buffer,W)))return Oe(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 L=qe(p);if(L)return L;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,C.prototype),Object.setPrototypeOf(U,C);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 Pe(p){return de(p),re(p<0?0:$(p)|0)}U.allocUnsafe=function(p){return Pe(p)},U.allocUnsafeSlow=function(p){return Pe(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 L=E.write(p,i);return L!==a&&(E=E.slice(0,L)),E}function Ee(p){const i=p.length<0?0:$(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,C)){const i=new C(p);return Oe(i.buffer,i.byteOffset,i.byteLength)}return Ee(p)}function Oe(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 C(p):a===void 0?E=new C(p,i):E=new C(p,i,a),Object.setPrototypeOf(E,U.prototype),E}function qe(p){if(U.isBuffer(p)){const i=$(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"||In(p.length)?re(0):Ee(p);if(p.type==="Buffer"&&Array.isArray(p.data))return Ee(p.data)}function $(p){if(p>=S)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+S.toString(16)+" bytes");return p|0}function V(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,C)&&(i=U.from(i,i.offset,i.byteLength)),Ze(a,C)&&(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,L=a.length;for(let q=0,K=Math.min(E,L);q<K;++q)if(i[q]!==a[q]){E=i[q],L=a[q];break}return E<L?-1:L<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 L=U.allocUnsafe(a);let q=0;for(E=0;E<i.length;++E){let K=i[E];if(Ze(K,C))q+K.length>L.length?(U.isBuffer(K)||(K=U.from(K)),K.copy(L,q)):C.prototype.set.call(L,K,q);else if(U.isBuffer(K))K.copy(L,q);else throw new TypeError('"list" argument must be an Array of Buffers');q+=K.length}return L};function J(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 L=!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(L)return E?-1:be(p).length;i=(""+i).toLowerCase(),L=!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 le(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?le(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=R.INSPECT_MAX_BYTES;return i=this.toString("hex",0,a).replace(/(.{2})/g,"$1 ").trim(),this.length>a&&(i+=" ... "),"<Buffer "+i+">"},k&&(U.prototype[k]=U.prototype.inspect),U.prototype.compare=function(i,a,E,L,q){if(Ze(i,C)&&(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),L===void 0&&(L=0),q===void 0&&(q=this.length),a<0||E>i.length||L<0||q>this.length)throw new RangeError("out of range index");if(L>=q&&a>=E)return 0;if(L>=q)return-1;if(a>=E)return 1;if(a>>>=0,E>>>=0,L>>>=0,q>>>=0,this===i)return 0;let K=q-L,fe=E-a;const Te=Math.min(K,fe),Re=this.slice(L,q),Ae=i.slice(a,E);for(let ve=0;ve<Te;++ve)if(Re[ve]!==Ae[ve]){K=Re[ve],fe=Ae[ve];break}return K<fe?-1:fe<K?1:0};function F(p,i,a,E,L){if(p.length===0)return-1;if(typeof a=="string"?(E=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,In(a)&&(a=L?0:p.length-1),a<0&&(a=p.length+a),a>=p.length){if(L)return-1;a=p.length-1}else if(a<0)if(L)a=0;else return-1;if(typeof i=="string"&&(i=U.from(i,E)),U.isBuffer(i))return i.length===0?-1:G(p,i,a,E,L);if(typeof i=="number")return i=i&255,typeof C.prototype.indexOf=="function"?L?C.prototype.indexOf.call(p,i,a):C.prototype.lastIndexOf.call(p,i,a):G(p,[i],a,E,L);throw new TypeError("val must be string, number or Buffer")}function G(p,i,a,E,L){let q=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;q=2,K/=2,fe/=2,a/=2}function Te(Ae,ve){return q===1?Ae[ve]:Ae.readUInt16BE(ve*q)}let Re;if(L){let Ae=-1;for(Re=a;Re<K;Re++)if(Te(p,Re)===Te(i,Ae===-1?0:Re-Ae)){if(Ae===-1&&(Ae=Re),Re-Ae+1===fe)return Ae*q}else Ae!==-1&&(Re-=Re-Ae),Ae=-1}else for(a+fe>K&&(a=K-fe),Re=a;Re>=0;Re--){let Ae=!0;for(let ve=0;ve<fe;ve++)if(Te(p,Re+ve)!==Te(i,ve)){Ae=!1;break}if(Ae)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 L=p.length-a;E?(E=Number(E),E>L&&(E=L)):E=L;const q=i.length;E>q/2&&(E=q/2);let K;for(K=0;K<E;++K){const fe=parseInt(i.substr(K*2,2),16);if(In(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 y(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,L){if(a===void 0)L="utf8",E=this.length,a=0;else if(E===void 0&&typeof a=="string")L=a,E=this.length,a=0;else if(isFinite(a))a=a>>>0,isFinite(E)?(E=E>>>0,L===void 0&&(L="utf8")):(L=E,E=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const q=this.length-a;if((E===void 0||E>q)&&(E=q),i.length>0&&(E<0||a<0)||a>this.length)throw new RangeError("Attempt to write outside buffer bounds");L||(L="utf8");let K=!1;for(;;)switch(L){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 y(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: "+L);L=(""+L).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 le(p,i,a){a=Math.min(p.length,a);const E=[];let L=i;for(;L<a;){const q=p[L];let K=null,fe=q>239?4:q>223?3:q>191?2:1;if(L+fe<=a){let Te,Re,Ae,ve;switch(fe){case 1:q<128&&(K=q);break;case 2:Te=p[L+1],(Te&192)===128&&(ve=(q&31)<<6|Te&63,ve>127&&(K=ve));break;case 3:Te=p[L+1],Re=p[L+2],(Te&192)===128&&(Re&192)===128&&(ve=(q&15)<<12|(Te&63)<<6|Re&63,ve>2047&&(ve<55296||ve>57343)&&(K=ve));break;case 4:Te=p[L+1],Re=p[L+2],Ae=p[L+3],(Te&192)===128&&(Re&192)===128&&(Ae&192)===128&&(ve=(q&15)<<18|(Te&63)<<12|(Re&63)<<6|Ae&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),L+=fe}return se(E)}const ie=4096;function se(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 L=i;L<a;++L)E+=String.fromCharCode(p[L]&127);return E}function H(p,i,a){let E="";a=Math.min(p.length,a);for(let L=i;L<a;++L)E+=String.fromCharCode(p[L]);return E}function Fe(p,i,a){const E=p.length;(!i||i<0)&&(i=0),(!a||a<0||a>E)&&(a=E);let L="";for(let q=i;q<a;++q)L+=Sl[p[q]];return L}function Ue(p,i,a){const E=p.slice(i,a);let L="";for(let q=0;q<E.length-1;q+=2)L+=String.fromCharCode(E[q]+E[q+1]*256);return L}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 L=this.subarray(i,a);return Object.setPrototypeOf(L,U.prototype),L};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 L=this[i],q=1,K=0;for(;++K<a&&(q*=256);)L+=this[i+K]*q;return L},U.prototype.readUintBE=U.prototype.readUIntBE=function(i,a,E){i=i>>>0,a=a>>>0,E||ye(i,a,this.length);let L=this[i+--a],q=1;for(;a>0&&(q*=256);)L+=this[i+--a]*q;return L},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=rt(function(i){i=i>>>0,O(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&j(i,this.length-8);const L=a+this[++i]*oe(2,8)+this[++i]*oe(2,16)+this[++i]*oe(2,24),q=this[++i]+this[++i]*oe(2,8)+this[++i]*oe(2,16)+E*oe(2,24);return BigInt(L)+(BigInt(q)<<BigInt(32))}),U.prototype.readBigUInt64BE=rt(function(i){i=i>>>0,O(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&j(i,this.length-8);const L=a*oe(2,24)+this[++i]*oe(2,16)+this[++i]*oe(2,8)+this[++i],q=this[++i]*oe(2,24)+this[++i]*oe(2,16)+this[++i]*oe(2,8)+E;return(BigInt(L)<<BigInt(32))+BigInt(q)}),U.prototype.readIntLE=function(i,a,E){i=i>>>0,a=a>>>0,E||ye(i,a,this.length);let L=this[i],q=1,K=0;for(;++K<a&&(q*=256);)L+=this[i+K]*q;return q*=128,L>=q&&(L-=Math.pow(2,8*a)),L},U.prototype.readIntBE=function(i,a,E){i=i>>>0,a=a>>>0,E||ye(i,a,this.length);let L=a,q=1,K=this[i+--L];for(;L>0&&(q*=256);)K+=this[i+--L]*q;return q*=128,K>=q&&(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=rt(function(i){i=i>>>0,O(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&j(i,this.length-8);const L=this[i+4]+this[i+5]*oe(2,8)+this[i+6]*oe(2,16)+(E<<24);return(BigInt(L)<<BigInt(32))+BigInt(a+this[++i]*oe(2,8)+this[++i]*oe(2,16)+this[++i]*oe(2,24))}),U.prototype.readBigInt64BE=rt(function(i){i=i>>>0,O(i,"offset");const a=this[i],E=this[i+7];(a===void 0||E===void 0)&&j(i,this.length-8);const L=(a<<24)+this[++i]*oe(2,16)+this[++i]*oe(2,8)+this[++i];return(BigInt(L)<<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),P.read(this,i,!0,23,4)},U.prototype.readFloatBE=function(i,a){return i=i>>>0,a||ye(i,4,this.length),P.read(this,i,!1,23,4)},U.prototype.readDoubleLE=function(i,a){return i=i>>>0,a||ye(i,8,this.length),P.read(this,i,!0,52,8)},U.prototype.readDoubleBE=function(i,a){return i=i>>>0,a||ye(i,8,this.length),P.read(this,i,!1,52,8)};function we(p,i,a,E,L,q){if(!U.isBuffer(p))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>L||i<q)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,L){if(i=+i,a=a>>>0,E=E>>>0,!L){const fe=Math.pow(2,8*E)-1;we(this,i,a,E,fe,0)}let q=1,K=0;for(this[a]=i&255;++K<E&&(q*=256);)this[a+K]=i/q&255;return a+E},U.prototype.writeUintBE=U.prototype.writeUIntBE=function(i,a,E,L){if(i=+i,a=a>>>0,E=E>>>0,!L){const fe=Math.pow(2,8*E)-1;we(this,i,a,E,fe,0)}let q=E-1,K=1;for(this[a+q]=i&255;--q>=0&&(K*=256);)this[a+q]=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 $e(p,i,a,E,L){_(i,E,L,p,a,7);let q=Number(i&BigInt(4294967295));p[a++]=q,q=q>>8,p[a++]=q,q=q>>8,p[a++]=q,q=q>>8,p[a++]=q;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,L){_(i,E,L,p,a,7);let q=Number(i&BigInt(4294967295));p[a+7]=q,q=q>>8,p[a+6]=q,q=q>>8,p[a+5]=q,q=q>>8,p[a+4]=q;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=rt(function(i,a=0){return $e(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),U.prototype.writeBigUInt64BE=rt(function(i,a=0){return Ne(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),U.prototype.writeIntLE=function(i,a,E,L){if(i=+i,a=a>>>0,!L){const Te=Math.pow(2,8*E-1);we(this,i,a,E,Te-1,-Te)}let q=0,K=1,fe=0;for(this[a]=i&255;++q<E&&(K*=256);)i<0&&fe===0&&this[a+q-1]!==0&&(fe=1),this[a+q]=(i/K>>0)-fe&255;return a+E},U.prototype.writeIntBE=function(i,a,E,L){if(i=+i,a=a>>>0,!L){const Te=Math.pow(2,8*E-1);we(this,i,a,E,Te-1,-Te)}let q=E-1,K=1,fe=0;for(this[a+q]=i&255;--q>=0&&(K*=256);)i<0&&fe===0&&this[a+q+1]!==0&&(fe=1),this[a+q]=(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=rt(function(i,a=0){return $e(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),U.prototype.writeBigInt64BE=rt(function(i,a=0){return Ne(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function We(p,i,a,E,L,q){if(a+E>p.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function Ve(p,i,a,E,L){return i=+i,a=a>>>0,L||We(p,i,a,4),P.write(p,i,a,E,23,4),a+4}U.prototype.writeFloatLE=function(i,a,E){return Ve(this,i,a,!0,E)},U.prototype.writeFloatBE=function(i,a,E){return Ve(this,i,a,!1,E)};function Me(p,i,a,E,L){return i=+i,a=a>>>0,L||We(p,i,a,8),P.write(p,i,a,E,52,8),a+8}U.prototype.writeDoubleLE=function(i,a,E){return Me(this,i,a,!0,E)},U.prototype.writeDoubleBE=function(i,a,E){return Me(this,i,a,!1,E)},U.prototype.copy=function(i,a,E,L){if(!U.isBuffer(i))throw new TypeError("argument should be a Buffer");if(E||(E=0),!L&&L!==0&&(L=this.length),a>=i.length&&(a=i.length),a||(a=0),L>0&&L<E&&(L=E),L===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(L<0)throw new RangeError("sourceEnd out of bounds");L>this.length&&(L=this.length),i.length-a<L-E&&(L=i.length-a+E);const q=L-E;return this===i&&typeof C.prototype.copyWithin=="function"?this.copyWithin(a,E,L):C.prototype.set.call(i,this.subarray(E,L),a),q},U.prototype.fill=function(i,a,E,L){if(typeof i=="string"){if(typeof a=="string"?(L=a,a=0,E=this.length):typeof E=="string"&&(L=E,E=this.length),L!==void 0&&typeof L!="string")throw new TypeError("encoding must be a string");if(typeof L=="string"&&!U.isEncoding(L))throw new TypeError("Unknown encoding: "+L);if(i.length===1){const K=i.charCodeAt(0);(L==="utf8"&&K<128||L==="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 q;if(typeof i=="number")for(q=a;q<E;++q)this[q]=i;else{const K=U.isBuffer(i)?i:U.from(i,L),fe=K.length;if(fe===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(q=0;q<E-a;++q)this[q+a]=K[q%fe]}return this};const tt={};function d(p,i,a){tt[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(L){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:L,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.`,L=a;return Number.isInteger(a)&&Math.abs(a)>oe(2,32)?L=n(String(a)):typeof a=="bigint"&&(L=String(a),(a>oe(BigInt(2),BigInt(32))||a<-oe(BigInt(2),BigInt(32)))&&(L=n(L)),L+="n"),E+=` It must be ${i}. Received ${L}`,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){O(i,"offset"),(p[i]===void 0||p[i+a]===void 0)&&j(i,p.length-(a+1))}function _(p,i,a,E,L,q){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} ** ${(q+1)*8}${K}`:fe=`>= -(2${K} ** ${(q+1)*8-1}${K}) and < 2 ** ${(q+1)*8-1}${K}`,new tt.ERR_OUT_OF_RANGE("value",fe,p)}o(E,L,q)}function O(p,i){if(typeof p!="number")throw new tt.ERR_INVALID_ARG_TYPE(i,"number",p)}function j(p,i,a){throw Math.floor(p)!==p?(O(p,a),new tt.ERR_OUT_OF_RANGE("offset","an integer",p)):i<0?new tt.ERR_BUFFER_OUT_OF_BOUNDS:new tt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${i}`,p)}const Y=/[^+/0-9A-Za-z-_]/g;function ce(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 L=null;const q=[];for(let K=0;K<E;++K){if(a=p.charCodeAt(K),a>55295&&a<57344){if(!L){if(a>56319){(i-=3)>-1&&q.push(239,191,189);continue}else if(K+1===E){(i-=3)>-1&&q.push(239,191,189);continue}L=a;continue}if(a<56320){(i-=3)>-1&&q.push(239,191,189),L=a;continue}a=(L-55296<<10|a-56320)+65536}else L&&(i-=3)>-1&&q.push(239,191,189);if(L=null,a<128){if((i-=1)<0)break;q.push(a)}else if(a<2048){if((i-=2)<0)break;q.push(a>>6|192,a&63|128)}else if(a<65536){if((i-=3)<0)break;q.push(a>>12|224,a>>6&63|128,a&63|128)}else if(a<1114112){if((i-=4)<0)break;q.push(a>>18|240,a>>12&63|128,a>>6&63|128,a&63|128)}else throw new Error("Invalid code point")}return q}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,L;const q=[];for(let K=0;K<p.length&&!((i-=2)<0);++K)a=p.charCodeAt(K),E=a>>8,L=a%256,q.push(L),q.push(E);return q}function pe(p){return A.toByteArray(ce(p))}function Dt(p,i,a,E){let L;for(L=0;L<E&&!(L+a>=i.length||L>=p.length);++L)i[L+a]=p[L];return L}function Ze(p,i){return p instanceof i||p!=null&&p.constructor!=null&&p.constructor.name!=null&&p.constructor.name===i.name}function In(p){return p!==p}const Sl=function(){const p="0123456789abcdef",i=new Array(256);for(let a=0;a<16;++a){const E=a*16;for(let L=0;L<16;++L)i[E+L]=p[a]+p[L]}return i}();function rt(p){return typeof BigInt=="undefined"?_l:p}function _l(){throw new Error("BigInt not supported")}})(e);const m=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=m,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}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var zn;function Hn(){return zn||(zn=1,function(r,e){var t=yt(),s=t.Buffer;function u(g,f){for(var c in g)f[c]=g[c]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?r.exports=t:(u(t,e),e.Buffer=l);function l(g,f,c){return s(g,f,c)}l.prototype=Object.create(s.prototype),u(s,l),l.from=function(g,f,c){if(typeof g=="number")throw new TypeError("Argument must not be a number");return s(g,f,c)},l.alloc=function(g,f,c){if(typeof g!="number")throw new TypeError("Argument must be a number");var v=s(g);return f!==void 0?typeof c=="string"?v.fill(f,c):v.fill(f):v.fill(0),v},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 Jn;function wa(){if(Jn)return Pt.exports;Jn=1;var r=65536,e=4294967295;function t(){throw new Error(`Secure random number generation is not supported by this browser.
12
+ Use Chrome, Firefox or Internet Explorer 11`)}var s=Hn().Buffer,u=globalThis.crypto||globalThis.msCrypto;u&&u.getRandomValues?Pt.exports=l:Pt.exports=t;function l(g,f){if(g>e)throw new RangeError("requested too many random bytes");var c=s.allocUnsafe(g);if(g>0)if(g>r)for(var v=0;v<g;v+=r)u.getRandomValues(c.slice(v,v+r));else u.getRandomValues(c);return typeof f=="function"?ae.nextTick(function(){f(null,c)}):c}return Pt.exports}var At={exports:{}},It={exports:{}},Yn;function Ht(){if(Yn)return It.exports;Yn=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(k,S,C){return Function.prototype.apply.call(k,S,C)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(k){return Object.getOwnPropertyNames(k).concat(Object.getOwnPropertySymbols(k))}:t=function(k){return Object.getOwnPropertyNames(k)};function s(P){console&&console.warn&&console.warn(P)}var u=Number.isNaN||function(k){return k!==k};function l(){l.init.call(this)}It.exports=l,It.exports.once=m,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var g=10;function f(P){if(typeof P!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof P)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return g},set:function(P){if(typeof P!="number"||P<0||u(P))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+P+".");g=P}}),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(k){if(typeof k!="number"||k<0||u(k))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+k+".");return this._maxListeners=k,this};function c(P){return P._maxListeners===void 0?l.defaultMaxListeners:P._maxListeners}l.prototype.getMaxListeners=function(){return c(this)},l.prototype.emit=function(k){for(var S=[],C=1;C<arguments.length;C++)S.push(arguments[C]);var M=k==="error",W=this._events;if(W!==void 0)M=M&&W.error===void 0;else if(!M)return!1;if(M){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[k];if(U===void 0)return!1;if(typeof U=="function")e(U,this,S);else for(var he=U.length,de=b(U,he),C=0;C<he;++C)e(de[C],this,S);return!0};function v(P,k,S,C){var M,W,X;if(f(S),W=P._events,W===void 0?(W=P._events=Object.create(null),P._eventsCount=0):(W.newListener!==void 0&&(P.emit("newListener",k,S.listener?S.listener:S),W=P._events),X=W[k]),X===void 0)X=W[k]=S,++P._eventsCount;else if(typeof X=="function"?X=W[k]=C?[S,X]:[X,S]:C?X.unshift(S):X.push(S),M=c(P),M>0&&X.length>M&&!X.warned){X.warned=!0;var re=new Error("Possible EventEmitter memory leak detected. "+X.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");re.name="MaxListenersExceededWarning",re.emitter=P,re.type=k,re.count=X.length,s(re)}return P}l.prototype.addListener=function(k,S){return v(this,k,S,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(k,S){return v(this,k,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 I(P,k,S){var C={fired:!1,wrapFn:void 0,target:P,type:k,listener:S},M=h.bind(C);return M.listener=S,C.wrapFn=M,M}l.prototype.once=function(k,S){return f(S),this.on(k,I(this,k,S)),this},l.prototype.prependOnceListener=function(k,S){return f(S),this.prependListener(k,I(this,k,S)),this},l.prototype.removeListener=function(k,S){var C,M,W,X,re;if(f(S),M=this._events,M===void 0)return this;if(C=M[k],C===void 0)return this;if(C===S||C.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete M[k],M.removeListener&&this.emit("removeListener",k,C.listener||S));else if(typeof C!="function"){for(W=-1,X=C.length-1;X>=0;X--)if(C[X]===S||C[X].listener===S){re=C[X].listener,W=X;break}if(W<0)return this;W===0?C.shift():N(C,W),C.length===1&&(M[k]=C[0]),M.removeListener!==void 0&&this.emit("removeListener",k,re||S)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(k){var S,C,M;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[k]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[k]),this;if(arguments.length===0){var W=Object.keys(C),X;for(M=0;M<W.length;++M)X=W[M],X!=="removeListener"&&this.removeAllListeners(X);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=C[k],typeof S=="function")this.removeListener(k,S);else if(S!==void 0)for(M=S.length-1;M>=0;M--)this.removeListener(k,S[M]);return this};function B(P,k,S){var C=P._events;if(C===void 0)return[];var M=C[k];return M===void 0?[]:typeof M=="function"?S?[M.listener||M]:[M]:S?T(M):b(M,M.length)}l.prototype.listeners=function(k){return B(this,k,!0)},l.prototype.rawListeners=function(k){return B(this,k,!1)},l.listenerCount=function(P,k){return typeof P.listenerCount=="function"?P.listenerCount(k):x.call(P,k)},l.prototype.listenerCount=x;function x(P){var k=this._events;if(k!==void 0){var S=k[P];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(P,k){for(var S=new Array(k),C=0;C<k;++C)S[C]=P[C];return S}function N(P,k){for(;k+1<P.length;k++)P[k]=P[k+1];P.pop()}function T(P){for(var k=new Array(P.length),S=0;S<k.length;++S)k[S]=P[S].listener||P[S];return k}function m(P,k){return new Promise(function(S,C){function M(X){P.removeListener(k,W),C(X)}function W(){typeof P.removeListener=="function"&&P.removeListener("error",M),S([].slice.call(arguments))}A(P,k,W,{once:!0}),k!=="error"&&R(P,M,{once:!0})})}function R(P,k,S){typeof P.on=="function"&&A(P,"error",k,S)}function A(P,k,S,C){if(typeof P.on=="function")C.once?P.once(k,S):P.on(k,S);else if(typeof P.addEventListener=="function")P.addEventListener(k,function M(W){C.once&&P.removeEventListener(k,M),S(W)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof P)}return It.exports}var Jt,Kn;function Xn(){return Kn||(Kn=1,Jt=Ht().EventEmitter),Jt}var Yt={},Kt={},Xt,Zn;function Qn(){return Zn||(Zn=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 u=42;e[t]=u;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!==u||f.enumerable!==!0)return!1}return!0}),Xt}var Zt,ei;function Bt(){if(ei)return Zt;ei=1;var r=Qn();return Zt=function(){return r()&&!!Symbol.toStringTag},Zt}var Qt,ti;function ri(){return ti||(ti=1,Qt=Object),Qt}var er,ni;function ba(){return ni||(ni=1,er=Error),er}var tr,ii;function Sa(){return ii||(ii=1,tr=EvalError),tr}var rr,oi;function _a(){return oi||(oi=1,rr=RangeError),rr}var nr,ai;function Ea(){return ai||(ai=1,nr=ReferenceError),nr}var ir,si;function li(){return si||(si=1,ir=SyntaxError),ir}var or,ci;function mt(){return ci||(ci=1,or=TypeError),or}var ar,ui;function Ca(){return ui||(ui=1,ar=URIError),ar}var sr,fi;function Ra(){return fi||(fi=1,sr=Math.abs),sr}var lr,hi;function Pa(){return hi||(hi=1,lr=Math.floor),lr}var cr,di;function Ta(){return di||(di=1,cr=Math.max),cr}var ur,pi;function Aa(){return pi||(pi=1,ur=Math.min),ur}var fr,gi;function Ia(){return gi||(gi=1,fr=Math.pow),fr}var hr,yi;function Ba(){return yi||(yi=1,hr=Math.round),hr}var dr,mi;function ka(){return mi||(mi=1,dr=Number.isNaN||function(e){return e!==e}),dr}var pr,vi;function Oa(){if(vi)return pr;vi=1;var r=ka();return pr=function(t){return r(t)||t===0?t:t<0?-1:1},pr}var gr,wi;function Ma(){return wi||(wi=1,gr=Object.getOwnPropertyDescriptor),gr}var yr,bi;function ct(){if(bi)return yr;bi=1;var r=Ma();if(r)try{r([],"length")}catch(e){r=null}return yr=r,yr}var mr,Si;function kt(){if(Si)return mr;Si=1;var r=Object.defineProperty||!1;if(r)try{r({},"a",{value:1})}catch(e){r=!1}return mr=r,mr}var vr,_i;function La(){if(_i)return vr;_i=1;var r=typeof Symbol!="undefined"&&Symbol,e=Qn();return vr=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},vr}var wr,Ei;function Ci(){return Ei||(Ei=1,wr=typeof Reflect!="undefined"&&Reflect.getPrototypeOf||null),wr}var br,Ri;function Pi(){if(Ri)return br;Ri=1;var r=ri();return br=r.getPrototypeOf||null,br}var Sr,Ti;function Na(){if(Ti)return Sr;Ti=1;var r="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,t=Math.max,s="[object Function]",u=function(c,v){for(var h=[],I=0;I<c.length;I+=1)h[I]=c[I];for(var B=0;B<v.length;B+=1)h[B+c.length]=v[B];return h},l=function(c,v){for(var h=[],I=v,B=0;I<c.length;I+=1,B+=1)h[B]=c[I];return h},g=function(f,c){for(var v="",h=0;h<f.length;h+=1)v+=f[h],h+1<f.length&&(v+=c);return v};return Sr=function(c){var v=this;if(typeof v!="function"||e.apply(v)!==s)throw new TypeError(r+v);for(var h=l(arguments,1),I,B=function(){if(this instanceof I){var m=v.apply(this,u(h,arguments));return Object(m)===m?m:this}return v.apply(c,u(h,arguments))},x=t(0,v.length-h.length),b=[],N=0;N<x;N++)b[N]="$"+N;if(I=Function("binder","return function ("+g(b,",")+"){ return binder.apply(this,arguments); }")(B),v.prototype){var T=function(){};T.prototype=v.prototype,I.prototype=new T,T.prototype=null}return I},Sr}var _r,Ai;function vt(){if(Ai)return _r;Ai=1;var r=Na();return _r=Function.prototype.bind||r,_r}var Er,Ii;function Cr(){return Ii||(Ii=1,Er=Function.prototype.call),Er}var Rr,Bi;function Pr(){return Bi||(Bi=1,Rr=Function.prototype.apply),Rr}var Tr,ki;function Da(){return ki||(ki=1,Tr=typeof Reflect!="undefined"&&Reflect&&Reflect.apply),Tr}var Ar,Oi;function Mi(){if(Oi)return Ar;Oi=1;var r=vt(),e=Pr(),t=Cr(),s=Da();return Ar=s||r.call(t,e),Ar}var Ir,Li;function Br(){if(Li)return Ir;Li=1;var r=vt(),e=mt(),t=Cr(),s=Mi();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,Ni;function Fa(){if(Ni)return kr;Ni=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__"),u=Object,l=u.getPrototypeOf;return kr=s&&typeof s.get=="function"?r([s.get]):typeof l=="function"?function(f){return l(f==null?f:u(f))}:!1,kr}var Or,Di;function Mr(){if(Di)return Or;Di=1;var r=Ci(),e=Pi(),t=Fa();return Or=r?function(u){return r(u)}:e?function(u){if(!u||typeof u!="object"&&typeof u!="function")throw new TypeError("getProto: not an object");return e(u)}:t?function(u){return t(u)}:null,Or}var Lr,Fi;function Ui(){if(Fi)return Lr;Fi=1;var r=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=vt();return Lr=t.call(r,e),Lr}var Nr,$i;function ji(){if($i)return Nr;$i=1;var r,e=ri(),t=ba(),s=Sa(),u=_a(),l=Ea(),g=li(),f=mt(),c=Ca(),v=Ra(),h=Pa(),I=Ta(),B=Aa(),x=Ia(),b=Ba(),N=Oa(),T=Function,m=function(Z){try{return T('"use strict"; return ('+Z+").constructor;")()}catch(Q){}},R=ct(),A=kt(),P=function(){throw new f},k=R?function(){try{return arguments.callee,P}catch(Z){try{return R(arguments,"callee").get}catch(Q){return P}}}():P,S=La()(),C=Mr(),M=Pi(),W=Ci(),X=Pr(),re=Cr(),U={},he=typeof Uint8Array=="undefined"||!C?r:C(Uint8Array),de={__proto__:null,"%AggregateError%":typeof AggregateError=="undefined"?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?r:ArrayBuffer,"%ArrayIteratorPrototype%":S&&C?C([][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%":T,"%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&&C?C(C([][Symbol.iterator]())):r,"%JSON%":typeof JSON=="object"?JSON:r,"%Map%":typeof Map=="undefined"?r:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!S||!C?r:C(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":R,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?r:Promise,"%Proxy%":typeof Proxy=="undefined"?r:Proxy,"%RangeError%":u,"%ReferenceError%":l,"%Reflect%":typeof Reflect=="undefined"?r:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?r:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!S||!C?r:C(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":S&&C?C(""[Symbol.iterator]()):r,"%Symbol%":S?Symbol:r,"%SyntaxError%":g,"%ThrowTypeError%":k,"%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%":c,"%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%":M,"%Math.abs%":v,"%Math.floor%":h,"%Math.max%":I,"%Math.min%":B,"%Math.pow%":x,"%Math.round%":b,"%Math.sign%":N,"%Reflect.getPrototypeOf%":W};if(C)try{null.error}catch(Z){var me=C(C(Z));de["%Error.prototype%"]=me}var Pe=function Z(Q){var y;if(Q==="%AsyncFunction%")y=m("async function () {}");else if(Q==="%GeneratorFunction%")y=m("function* () {}");else if(Q==="%AsyncGeneratorFunction%")y=m("async function* () {}");else if(Q==="%AsyncGenerator%"){var w=Z("%AsyncGeneratorFunction%");w&&(y=w.prototype)}else if(Q==="%AsyncIteratorPrototype%"){var z=Z("%AsyncGenerator%");z&&C&&(y=C(z.prototype))}return de[Q]=y,y},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=vt(),_e=Ui(),Oe=Ee.call(re,Array.prototype.concat),qe=Ee.call(X,Array.prototype.splice),$=Ee.call(re,String.prototype.replace),V=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 y=V(Q,0,1),w=V(Q,-1);if(y==="%"&&w!=="%")throw new g("invalid intrinsic syntax, expected closing `%`");if(w==="%"&&y!=="%")throw new g("invalid intrinsic syntax, expected opening `%`");var z=[];return $(Q,ne,function(ee,le,ie,se){z[z.length]=ie?$(se,D,"$1"):le||ee}),z},G=function(Q,y){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=Pe(w)),typeof ee=="undefined"&&!y)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,y){if(typeof Q!="string"||Q.length===0)throw new f("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof y!="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=G("%"+z+"%",y),le=ee.name,ie=ee.value,se=!1,De=ee.alias;De&&(z=De[0],qe(w,Oe([0,1],De)));for(var H=1,Fe=!0;H<w.length;H+=1){var Ue=w[H],ye=V(Ue,0,1),we=V(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)&&(se=!0),z+="."+Ue,le="%"+z+"%",_e(de,le))ie=de[le];else if(ie!=null){if(!(Ue in ie)){if(!y)throw new f("base intrinsic for "+Q+" exists, but the property is not available.");return}if(R&&H+1>=w.length){var $e=R(ie,Ue);Fe=!!$e,Fe&&"get"in $e&&!("originalValue"in $e.get)?ie=$e.get:ie=ie[Ue]}else Fe=_e(ie,Ue),ie=ie[Ue];Fe&&!se&&(de[le]=ie)}}return ie},Nr}var Dr,qi;function wt(){if(qi)return Dr;qi=1;var r=ji(),e=Br(),t=e([r("%String.prototype.indexOf%")]);return Dr=function(u,l){var g=r(u,!!l);return typeof g=="function"&&t(u,".prototype.")>-1?e([g]):g},Dr}var Fr,xi;function Ua(){if(xi)return Fr;xi=1;var r=Bt()(),e=wt(),t=e("Object.prototype.toString"),s=function(f){return r&&f&&typeof f=="object"&&Symbol.toStringTag in f?!1:t(f)==="[object Arguments]"},u=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=u,Fr=l?s:u,Fr}var Ur,Wi;function $a(){if(Wi)return Ur;Wi=1;var r=wt(),e=Bt()(),t=Ui(),s=ct(),u;if(e){var l=r("RegExp.prototype.exec"),g={},f=function(){throw g},c={toString:f,valueOf:f};typeof Symbol.toPrimitive=="symbol"&&(c[Symbol.toPrimitive]=f),u=function(B){if(!B||typeof B!="object")return!1;var x=s(B,"lastIndex"),b=x&&t(x,"value");if(!b)return!1;try{l(B,c)}catch(N){return N===g}}}else{var v=r("Object.prototype.toString"),h="[object RegExp]";u=function(B){return!B||typeof B!="object"&&typeof B!="function"?!1:v(B)===h}}return Ur=u,Ur}var $r,Gi;function ja(){if(Gi)return $r;Gi=1;var r=wt(),e=$a(),t=r("RegExp.prototype.exec"),s=mt();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 jr,Vi;function qa(){if(Vi)return jr;Vi=1;var r=wt(),e=ja(),t=e(/^\s*(?:function)?\*/),s=Bt()(),u=Mr(),l=r("Object.prototype.toString"),g=r("Function.prototype.toString"),f=function(){if(!s)return!1;try{return Function("return function*() {}")()}catch(v){}},c;return jr=function(h){if(typeof h!="function")return!1;if(t(g(h)))return!0;if(!s){var I=l(h);return I==="[object GeneratorFunction]"}if(!u)return!1;if(typeof c=="undefined"){var B=f();c=B?u(B):!1}return u(h)===c},jr}var qr,zi;function xa(){if(zi)return qr;zi=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(R){R!==s&&(e=null)}else e=null;var u=/^\s*class\b/,l=function(A){try{var P=r.call(A);return u.test(P)}catch(k){return!1}},g=function(A){try{return l(A)?!1:(r.call(A),!0)}catch(P){return!1}},f=Object.prototype.toString,c="[object Object]",v="[object Function]",h="[object GeneratorFunction]",I="[object HTMLAllCollection]",B="[object HTML document.all class]",x="[object HTMLCollection]",b=typeof Symbol=="function"&&!!Symbol.toStringTag,N=!(0 in[,]),T=function(){return!1};if(typeof document=="object"){var m=document.all;f.call(m)===f.call(document.all)&&(T=function(A){if((N||!A)&&(typeof A=="undefined"||typeof A=="object"))try{var P=f.call(A);return(P===I||P===B||P===x||P===c)&&A("")==null}catch(k){}return!1})}return qr=e?function(A){if(T(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;try{e(A,null,t)}catch(P){if(P!==s)return!1}return!l(A)&&g(A)}:function(A){if(T(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;if(b)return g(A);if(l(A))return!1;var P=f.call(A);return P!==v&&P!==h&&!/^\[object HTML/.test(P)?!1:g(A)},qr}var xr,Hi;function Wa(){if(Hi)return xr;Hi=1;var r=xa(),e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,s=function(c,v,h){for(var I=0,B=c.length;I<B;I++)t.call(c,I)&&(h==null?v(c[I],I,c):v.call(h,c[I],I,c))},u=function(c,v,h){for(var I=0,B=c.length;I<B;I++)h==null?v(c.charAt(I),I,c):v.call(h,c.charAt(I),I,c)},l=function(c,v,h){for(var I in c)t.call(c,I)&&(h==null?v(c[I],I,c):v.call(h,c[I],I,c))};function g(f){return e.call(f)==="[object Array]"}return xr=function(c,v,h){if(!r(v))throw new TypeError("iterator must be a function");var I;arguments.length>=3&&(I=h),g(c)?s(c,v,I):typeof c=="string"?u(c,v,I):l(c,v,I)},xr}var Wr,Ji;function Ga(){return Ji||(Ji=1,Wr=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),Wr}var Gr,Yi;function Va(){if(Yi)return Gr;Yi=1;var r=Ga(),e=globalThis;return Gr=function(){for(var s=[],u=0;u<r.length;u++)typeof e[r[u]]=="function"&&(s[s.length]=r[u]);return s},Gr}var Vr={exports:{}},zr,Ki;function za(){if(Ki)return zr;Ki=1;var r=kt(),e=li(),t=mt(),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 c=arguments.length>3?arguments[3]:null,v=arguments.length>4?arguments[4]:null,h=arguments.length>5?arguments[5]:null,I=arguments.length>6?arguments[6]:!1,B=!!s&&s(l,g);if(r)r(l,g,{configurable:h===null&&B?B.configurable:!h,enumerable:c===null&&B?B.enumerable:!c,value:f,writable:v===null&&B?B.writable:!v});else if(I||!c&&!v&&!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,Xi;function Ha(){if(Xi)return Hr;Xi=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,Zi;function Ja(){if(Zi)return Jr;Zi=1;var r=ji(),e=za(),t=Ha()(),s=ct(),u=mt(),l=r("%Math.floor%");return Jr=function(f,c){if(typeof f!="function")throw new u("`fn` is not a function");if(typeof c!="number"||c<0||c>4294967295||l(c)!==c)throw new u("`length` must be a positive 32-bit integer");var v=arguments.length>2&&!!arguments[2],h=!0,I=!0;if("length"in f&&s){var B=s(f,"length");B&&!B.configurable&&(h=!1),B&&!B.writable&&(I=!1)}return(h||I||!v)&&(t?e(f,"length",c,!0,!0):e(f,"length",c)),f},Jr}var Yr,Qi;function Ya(){if(Qi)return Yr;Qi=1;var r=vt(),e=Pr(),t=Mi();return Yr=function(){return t(r,e,arguments)},Yr}var eo;function Ka(){return eo||(eo=1,function(r){var e=Ja(),t=kt(),s=Br(),u=Ya();r.exports=function(g){var f=s(arguments),c=g.length-(arguments.length-1);return e(f,1+(c>0?c:0),!0)},t?t(r.exports,"apply",{value:u}):r.exports.apply=u}(Vr)),Vr.exports}var Kr,to;function ro(){if(to)return Kr;to=1;var r=Wa(),e=Va(),t=Ka(),s=wt(),u=ct(),l=Mr(),g=s("Object.prototype.toString"),f=Bt()(),c=globalThis,v=e(),h=s("String.prototype.slice"),I=s("Array.prototype.indexOf",!0)||function(T,m){for(var R=0;R<T.length;R+=1)if(T[R]===m)return R;return-1},B={__proto__:null};f&&u&&l?r(v,function(N){var T=new c[N];if(Symbol.toStringTag in T&&l){var m=l(T),R=u(m,Symbol.toStringTag);if(!R&&m){var A=l(m);R=u(A,Symbol.toStringTag)}B["$"+N]=t(R.get)}}):r(v,function(N){var T=new c[N],m=T.slice||T.set;m&&(B["$"+N]=t(m))});var x=function(T){var m=!1;return r(B,function(R,A){if(!m)try{"$"+R(T)===A&&(m=h(A,1))}catch(P){}}),m},b=function(T){var m=!1;return r(B,function(R,A){if(!m)try{R(T),m=h(A,1)}catch(P){}}),m};return Kr=function(T){if(!T||typeof T!="object")return!1;if(!f){var m=h(g(T),8,-1);return I(v,m)>-1?m:m!=="Object"?!1:b(T)}return u?x(T):null},Kr}var Xr,no;function Xa(){if(no)return Xr;no=1;var r=ro();return Xr=function(t){return!!r(t)},Xr}var io;function Za(){return io||(io=1,function(r){var e=Ua(),t=qa(),s=ro(),u=Xa();function l(H){return H.call.bind(H)}var g=typeof BigInt!="undefined",f=typeof Symbol!="undefined",c=l(Object.prototype.toString),v=l(Number.prototype.valueOf),h=l(String.prototype.valueOf),I=l(Boolean.prototype.valueOf);if(g)var B=l(BigInt.prototype.valueOf);if(f)var x=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=u;function N(H){return typeof Promise!="undefined"&&H instanceof Promise||H!==null&&typeof H=="object"&&typeof H.then=="function"&&typeof H.catch=="function"}r.isPromise=N;function T(H){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?ArrayBuffer.isView(H):u(H)||V(H)}r.isArrayBufferView=T;function m(H){return s(H)==="Uint8Array"}r.isUint8Array=m;function R(H){return s(H)==="Uint8ClampedArray"}r.isUint8ClampedArray=R;function A(H){return s(H)==="Uint16Array"}r.isUint16Array=A;function P(H){return s(H)==="Uint32Array"}r.isUint32Array=P;function k(H){return s(H)==="Int8Array"}r.isInt8Array=k;function S(H){return s(H)==="Int16Array"}r.isInt16Array=S;function C(H){return s(H)==="Int32Array"}r.isInt32Array=C;function M(H){return s(H)==="Float32Array"}r.isFloat32Array=M;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 c(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 c(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 Pe(H){return c(H)==="[object WeakMap]"}Pe.working=typeof WeakMap!="undefined"&&Pe(new WeakMap);function ke(H){return typeof WeakMap=="undefined"?!1:Pe.working?Pe(H):H instanceof WeakMap}r.isWeakMap=ke;function Ee(H){return c(H)==="[object WeakSet]"}Ee.working=typeof WeakSet!="undefined"&&Ee(new WeakSet);function _e(H){return Ee(H)}r.isWeakSet=_e;function Oe(H){return c(H)==="[object ArrayBuffer]"}Oe.working=typeof ArrayBuffer!="undefined"&&Oe(new ArrayBuffer);function qe(H){return typeof ArrayBuffer=="undefined"?!1:Oe.working?Oe(H):H instanceof ArrayBuffer}r.isArrayBuffer=qe;function $(H){return c(H)==="[object DataView]"}$.working=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined"&&$(new DataView(new ArrayBuffer(1),0,1));function V(H){return typeof DataView=="undefined"?!1:$.working?$(H):H instanceof DataView}r.isDataView=V;var J=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer:void 0;function ne(H){return c(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 c(H)==="[object AsyncFunction]"}r.isAsyncFunction=F;function G(H){return c(H)==="[object Map Iterator]"}r.isMapIterator=G;function Z(H){return c(H)==="[object Set Iterator]"}r.isSetIterator=Z;function Q(H){return c(H)==="[object Generator]"}r.isGeneratorObject=Q;function y(H){return c(H)==="[object WebAssembly.Module]"}r.isWebAssemblyCompiledModule=y;function w(H){return b(H,v)}r.isNumberObject=w;function z(H){return b(H,h)}r.isStringObject=z;function ee(H){return b(H,I)}r.isBooleanObject=ee;function le(H){return g&&b(H,B)}r.isBigIntObject=le;function ie(H){return f&&b(H,x)}r.isSymbolObject=ie;function se(H){return w(H)||z(H)||ee(H)||le(H)||ie(H)}r.isBoxedPrimitive=se;function De(H){return typeof Uint8Array!="undefined"&&(qe(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,oo;function Qa(){return oo||(oo=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:{}},ao;function ut(){return ao||(ao=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 so;function lo(){return so||(so=1,function(r){var e=Object.getOwnPropertyDescriptors||function(V){for(var J=Object.keys(V),ne={},D=0;D<J.length;D++)ne[J[D]]=Object.getOwnPropertyDescriptor(V,J[D]);return ne},t=/%[sdj%]/g;r.format=function($){if(!k($)){for(var V=[],J=0;J<arguments.length;J++)V.push(g(arguments[J]));return V.join(" ")}for(var J=1,ne=arguments,D=ne.length,F=String($).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}}),G=ne[J];J<D;G=ne[++J])R(G)||!W(G)?F+=" "+G:F+=" "+g(G);return F},r.deprecate=function($,V){if(typeof ae!="undefined"&&ae.noDeprecation===!0)return $;if(typeof ae=="undefined")return function(){return r.deprecate($,V).apply(this,arguments)};var J=!1;function ne(){if(!J){if(ae.throwDeprecation)throw new Error(V);ae.traceDeprecation?console.trace(V):console.error(V),J=!0}return $.apply(this,arguments)}return ne};var s={},u=/^$/;if(ae.env.NODE_DEBUG){var l=ae.env.NODE_DEBUG;l=l.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),u=new RegExp("^"+l+"$","i")}r.debuglog=function($){if($=$.toUpperCase(),!s[$])if(u.test($)){var V=ae.pid;s[$]=function(){var J=r.format.apply(r,arguments);console.error("%s %d: %s",$,V,J)}}else s[$]=function(){};return s[$]};function g($,V){var J={seen:[],stylize:c};return arguments.length>=3&&(J.depth=arguments[2]),arguments.length>=4&&(J.colors=arguments[3]),m(V)?J.showHidden=V:V&&r._extend(J,V),C(J.showHidden)&&(J.showHidden=!1),C(J.depth)&&(J.depth=2),C(J.colors)&&(J.colors=!1),C(J.customInspect)&&(J.customInspect=!0),J.colors&&(J.stylize=f),h(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($,V){var J=g.styles[V];return J?"\x1B["+g.colors[J][0]+"m"+$+"\x1B["+g.colors[J][1]+"m":$}function c($,V){return $}function v($){var V={};return $.forEach(function(J,ne){V[J]=!0}),V}function h($,V,J){if($.customInspect&&V&&U(V.inspect)&&V.inspect!==r.inspect&&!(V.constructor&&V.constructor.prototype===V)){var ne=V.inspect(J,$);return k(ne)||(ne=h($,ne,J)),ne}var D=I($,V);if(D)return D;var F=Object.keys(V),G=v(F);if($.showHidden&&(F=Object.getOwnPropertyNames(V)),re(V)&&(F.indexOf("message")>=0||F.indexOf("description")>=0))return B(V);if(F.length===0){if(U(V)){var Z=V.name?": "+V.name:"";return $.stylize("[Function"+Z+"]","special")}if(M(V))return $.stylize(RegExp.prototype.toString.call(V),"regexp");if(X(V))return $.stylize(Date.prototype.toString.call(V),"date");if(re(V))return B(V)}var Q="",y=!1,w=["{","}"];if(T(V)&&(y=!0,w=["[","]"]),U(V)){var z=V.name?": "+V.name:"";Q=" [Function"+z+"]"}if(M(V)&&(Q=" "+RegExp.prototype.toString.call(V)),X(V)&&(Q=" "+Date.prototype.toUTCString.call(V)),re(V)&&(Q=" "+B(V)),F.length===0&&(!y||V.length==0))return w[0]+Q+w[1];if(J<0)return M(V)?$.stylize(RegExp.prototype.toString.call(V),"regexp"):$.stylize("[Object]","special");$.seen.push(V);var ee;return y?ee=x($,V,J,G,F):ee=F.map(function(le){return b($,V,J,G,le,y)}),$.seen.pop(),N(ee,Q,w)}function I($,V){if(C(V))return $.stylize("undefined","undefined");if(k(V)){var J="'"+JSON.stringify(V).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return $.stylize(J,"string")}if(P(V))return $.stylize(""+V,"number");if(m(V))return $.stylize(""+V,"boolean");if(R(V))return $.stylize("null","null")}function B($){return"["+Error.prototype.toString.call($)+"]"}function x($,V,J,ne,D){for(var F=[],G=0,Z=V.length;G<Z;++G)Ee(V,String(G))?F.push(b($,V,J,ne,String(G),!0)):F.push("");return D.forEach(function(Q){Q.match(/^\d+$/)||F.push(b($,V,J,ne,Q,!0))}),F}function b($,V,J,ne,D,F){var G,Z,Q;if(Q=Object.getOwnPropertyDescriptor(V,D)||{value:V[D]},Q.get?Q.set?Z=$.stylize("[Getter/Setter]","special"):Z=$.stylize("[Getter]","special"):Q.set&&(Z=$.stylize("[Setter]","special")),Ee(ne,D)||(G="["+D+"]"),Z||($.seen.indexOf(Q.value)<0?(R(J)?Z=h($,Q.value,null):Z=h($,Q.value,J-1),Z.indexOf(`
13
+ `)>-1&&(F?Z=Z.split(`
14
+ `).map(function(y){return" "+y}).join(`
15
+ `).slice(2):Z=`
16
+ `+Z.split(`
17
+ `).map(function(y){return" "+y}).join(`
18
+ `))):Z=$.stylize("[Circular]","special")),C(G)){if(F&&D.match(/^\d+$/))return Z;G=JSON.stringify(""+D),G.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(G=G.slice(1,-1),G=$.stylize(G,"name")):(G=G.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),G=$.stylize(G,"string"))}return G+": "+Z}function N($,V,J){var ne=$.reduce(function(D,F){return F.indexOf(`
19
+ `)>=0,D+F.replace(/\u001b\[\d\d?m/g,"").length+1},0);return ne>60?J[0]+(V===""?"":V+`
20
+ `)+" "+$.join(`,
21
+ `)+" "+J[1]:J[0]+V+" "+$.join(", ")+" "+J[1]}r.types=Za();function T($){return Array.isArray($)}r.isArray=T;function m($){return typeof $=="boolean"}r.isBoolean=m;function R($){return $===null}r.isNull=R;function A($){return $==null}r.isNullOrUndefined=A;function P($){return typeof $=="number"}r.isNumber=P;function k($){return typeof $=="string"}r.isString=k;function S($){return typeof $=="symbol"}r.isSymbol=S;function C($){return $===void 0}r.isUndefined=C;function M($){return W($)&&de($)==="[object RegExp]"}r.isRegExp=M,r.types.isRegExp=M;function W($){return typeof $=="object"&&$!==null}r.isObject=W;function X($){return W($)&&de($)==="[object Date]"}r.isDate=X,r.types.isDate=X;function re($){return W($)&&(de($)==="[object Error]"||$ instanceof Error)}r.isError=re,r.types.isNativeError=re;function U($){return typeof $=="function"}r.isFunction=U;function he($){return $===null||typeof $=="boolean"||typeof $=="number"||typeof $=="string"||typeof $=="symbol"||typeof $=="undefined"}r.isPrimitive=he,r.isBuffer=Qa();function de($){return Object.prototype.toString.call($)}function me($){return $<10?"0"+$.toString(10):$.toString(10)}var Pe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ke(){var $=new Date,V=[me($.getHours()),me($.getMinutes()),me($.getSeconds())].join(":");return[$.getDate(),Pe[$.getMonth()],V].join(" ")}r.log=function(){console.log("%s - %s",ke(),r.format.apply(r,arguments))},r.inherits=ut(),r._extend=function($,V){if(!V||!W(V))return $;for(var J=Object.keys(V),ne=J.length;ne--;)$[J[ne]]=V[J[ne]];return $};function Ee($,V){return Object.prototype.hasOwnProperty.call($,V)}var _e=typeof Symbol!="undefined"?Symbol("util.promisify.custom"):void 0;r.promisify=function(V){if(typeof V!="function")throw new TypeError('The "original" argument must be of type Function');if(_e&&V[_e]){var J=V[_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,y){ne=Q,D=y}),G=[],Z=0;Z<arguments.length;Z++)G.push(arguments[Z]);G.push(function(Q,y){Q?D(Q):ne(y)});try{V.apply(this,G)}catch(Q){D(Q)}return F}return Object.setPrototypeOf(J,Object.getPrototypeOf(V)),_e&&Object.defineProperty(J,_e,{value:J,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(J,e(V))},r.promisify.custom=_e;function Oe($,V){if(!$){var J=new Error("Promise was rejected with a falsy value");J.reason=$,$=J}return V($)}function qe($){if(typeof $!="function")throw new TypeError('The "original" argument must be of type Function');function V(){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,G=function(){return D.apply(F,arguments)};$.apply(this,J).then(function(Z){ae.nextTick(G.bind(null,null,Z))},function(Z){ae.nextTick(Oe.bind(null,Z,G))})}return Object.setPrototypeOf(V,Object.getPrototypeOf($)),Object.defineProperties(V,e($)),V}r.callbackify=qe}(Yt)),Yt}var Qr,co;function es(){if(co)return Qr;co=1;function r(b,N){var T=Object.keys(b);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(b);N&&(m=m.filter(function(R){return Object.getOwnPropertyDescriptor(b,R).enumerable})),T.push.apply(T,m)}return T}function e(b){for(var N=1;N<arguments.length;N++){var T=arguments[N]!=null?arguments[N]:{};N%2?r(Object(T),!0).forEach(function(m){t(b,m,T[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(b,Object.getOwnPropertyDescriptors(T)):r(Object(T)).forEach(function(m){Object.defineProperty(b,m,Object.getOwnPropertyDescriptor(T,m))})}return b}function t(b,N,T){return N=g(N),N in b?Object.defineProperty(b,N,{value:T,enumerable:!0,configurable:!0,writable:!0}):b[N]=T,b}function s(b,N){if(!(b instanceof N))throw new TypeError("Cannot call a class as a function")}function u(b,N){for(var T=0;T<N.length;T++){var m=N[T];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(b,g(m.key),m)}}function l(b,N,T){return N&&u(b.prototype,N),Object.defineProperty(b,"prototype",{writable:!1}),b}function g(b){var N=f(b,"string");return typeof N=="symbol"?N:String(N)}function f(b,N){if(typeof b!="object"||b===null)return b;var T=b[Symbol.toPrimitive];if(T!==void 0){var m=T.call(b,N);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(b)}var c=yt(),v=c.Buffer,h=lo(),I=h.inspect,B=I&&I.custom||"inspect";function x(b,N,T){v.prototype.copy.call(b,N,T)}return Qr=function(){function b(){s(this,b),this.head=null,this.tail=null,this.length=0}return l(b,[{key:"push",value:function(T){var m={data:T,next:null};this.length>0?this.tail.next=m:this.head=m,this.tail=m,++this.length}},{key:"unshift",value:function(T){var m={data:T,next:this.head};this.length===0&&(this.tail=m),this.head=m,++this.length}},{key:"shift",value:function(){if(this.length!==0){var T=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,T}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(T){if(this.length===0)return"";for(var m=this.head,R=""+m.data;m=m.next;)R+=T+m.data;return R}},{key:"concat",value:function(T){if(this.length===0)return v.alloc(0);for(var m=v.allocUnsafe(T>>>0),R=this.head,A=0;R;)x(R.data,m,A),A+=R.data.length,R=R.next;return m}},{key:"consume",value:function(T,m){var R;return T<this.head.data.length?(R=this.head.data.slice(0,T),this.head.data=this.head.data.slice(T)):T===this.head.data.length?R=this.shift():R=m?this._getString(T):this._getBuffer(T),R}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(T){var m=this.head,R=1,A=m.data;for(T-=A.length;m=m.next;){var P=m.data,k=T>P.length?P.length:T;if(k===P.length?A+=P:A+=P.slice(0,T),T-=k,T===0){k===P.length?(++R,m.next?this.head=m.next:this.head=this.tail=null):(this.head=m,m.data=P.slice(k));break}++R}return this.length-=R,A}},{key:"_getBuffer",value:function(T){var m=v.allocUnsafe(T),R=this.head,A=1;for(R.data.copy(m),T-=R.data.length;R=R.next;){var P=R.data,k=T>P.length?P.length:T;if(P.copy(m,m.length-T,0,k),T-=k,T===0){k===P.length?(++A,R.next?this.head=R.next:this.head=this.tail=null):(this.head=R,R.data=P.slice(k));break}++A}return this.length-=A,m}},{key:B,value:function(T,m){return I(this,e(e({},m),{},{depth:0,customInspect:!1}))}}]),b}(),Qr}var en,uo;function fo(){if(uo)return en;uo=1;function r(g,f){var c=this,v=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return v||h?(f?f(g):g&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,ae.nextTick(u,this,g)):ae.nextTick(u,this,g)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(g||null,function(I){!f&&I?c._writableState?c._writableState.errorEmitted?ae.nextTick(t,c):(c._writableState.errorEmitted=!0,ae.nextTick(e,c,I)):ae.nextTick(e,c,I):f?(ae.nextTick(t,c),f(I)):ae.nextTick(t,c)}),this)}function e(g,f){u(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 u(g,f){g.emit("error",f)}function l(g,f){var c=g._readableState,v=g._writableState;c&&c.autoDestroy||v&&v.autoDestroy?g.destroy(f):g.emit("error",f)}return en={destroy:r,undestroy:s,errorOrDestroy:l},en}var tn={},ho;function ft(){if(ho)return tn;ho=1;function r(f,c){f.prototype=Object.create(c.prototype),f.prototype.constructor=f,f.__proto__=c}var e={};function t(f,c,v){v||(v=Error);function h(B,x,b){return typeof c=="string"?c:c(B,x,b)}var I=function(B){r(x,B);function x(b,N,T){return B.call(this,h(b,N,T))||this}return x}(v);I.prototype.name=v.name,I.prototype.code=f,e[f]=I}function s(f,c){if(Array.isArray(f)){var v=f.length;return f=f.map(function(h){return String(h)}),v>2?"one of ".concat(c," ").concat(f.slice(0,v-1).join(", "),", or ")+f[v-1]:v===2?"one of ".concat(c," ").concat(f[0]," or ").concat(f[1]):"of ".concat(c," ").concat(f[0])}else return"of ".concat(c," ").concat(String(f))}function u(f,c,v){return f.substr(0,c.length)===c}function l(f,c,v){return(v===void 0||v>f.length)&&(v=f.length),f.substring(v-c.length,v)===c}function g(f,c,v){return typeof v!="number"&&(v=0),v+c.length>f.length?!1:f.indexOf(c,v)!==-1}return t("ERR_INVALID_OPT_VALUE",function(f,c){return'The value "'+c+'" is invalid for option "'+f+'"'},TypeError),t("ERR_INVALID_ARG_TYPE",function(f,c,v){var h;typeof c=="string"&&u(c,"not ")?(h="must not be",c=c.replace(/^not /,"")):h="must be";var I;if(l(f," argument"))I="The ".concat(f," ").concat(h," ").concat(s(c,"type"));else{var B=g(f,".")?"property":"argument";I='The "'.concat(f,'" ').concat(B," ").concat(h," ").concat(s(c,"type"))}return I+=". Received type ".concat(typeof v),I},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,po;function go(){if(po)return rn;po=1;var r=ft().codes.ERR_INVALID_OPT_VALUE;function e(s,u,l){return s.highWaterMark!=null?s.highWaterMark:u?s[l]:null}function t(s,u,l,g){var f=e(u,g,l);if(f!=null){if(!(isFinite(f)&&Math.floor(f)===f)||f<0){var c=g?l:"highWaterMark";throw new r(c,f)}return Math.floor(f)}return s.objectMode?16:16*1024}return rn={getHighWaterMark:t},rn}var nn,yo;function ts(){if(yo)return nn;yo=1,nn=r;function r(t,s){if(e("noDeprecation"))return t;var u=!1;function l(){if(!u){if(e("throwDeprecation"))throw new Error(s);e("traceDeprecation")?console.trace(s):console.warn(s),u=!0}return t.apply(this,arguments)}return l}function e(t){try{if(!globalThis.localStorage)return!1}catch(u){return!1}var s=globalThis.localStorage[t];return s==null?!1:String(s).toLowerCase()==="true"}return nn}var on,mo;function vo(){if(mo)return on;mo=1,on=M;function r(D){var F=this;this.next=null,this.entry=null,this.finish=function(){ne(F,D)}}var e;M.WritableState=S;var t={deprecate:ts()},s=Xn(),u=yt().Buffer,l=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function g(D){return u.from(D)}function f(D){return u.isBuffer(D)||D instanceof l}var c=fo(),v=go(),h=v.getHighWaterMark,I=ft().codes,B=I.ERR_INVALID_ARG_TYPE,x=I.ERR_METHOD_NOT_IMPLEMENTED,b=I.ERR_MULTIPLE_CALLBACK,N=I.ERR_STREAM_CANNOT_PIPE,T=I.ERR_STREAM_DESTROYED,m=I.ERR_STREAM_NULL_VALUES,R=I.ERR_STREAM_WRITE_AFTER_END,A=I.ERR_UNKNOWN_ENCODING,P=c.errorOrDestroy;ut()(M,s);function k(){}function S(D,F,G){e=e||ht(),D=D||{},typeof G!="boolean"&&(G=F instanceof e),this.objectMode=!!D.objectMode,G&&(this.objectMode=this.objectMode||!!D.writableObjectMode),this.highWaterMark=h(this,D,"writableHighWaterMark",G),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){Pe(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,G=[];F;)G.push(F),F=F.next;return G},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 C;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(C=Function.prototype[Symbol.hasInstance],Object.defineProperty(M,Symbol.hasInstance,{value:function(F){return C.call(this,F)?!0:this!==M?!1:F&&F._writableState instanceof S}})):C=function(F){return F instanceof this};function M(D){e=e||ht();var F=this instanceof e;if(!F&&!C.call(M,this))return new M(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)}M.prototype.pipe=function(){P(this,new N)};function W(D,F){var G=new R;P(D,G),ae.nextTick(F,G)}function X(D,F,G,Z){var Q;return G===null?Q=new m:typeof G!="string"&&!F.objectMode&&(Q=new B("chunk",["string","Buffer"],G)),Q?(P(D,Q),ae.nextTick(Z,Q),!1):!0}M.prototype.write=function(D,F,G){var Z=this._writableState,Q=!1,y=!Z.objectMode&&f(D);return y&&!u.isBuffer(D)&&(D=g(D)),typeof F=="function"&&(G=F,F=null),y?F="buffer":F||(F=Z.defaultEncoding),typeof G!="function"&&(G=k),Z.ending?W(this,G):(y||X(this,Z,D,G))&&(Z.pendingcb++,Q=U(this,Z,y,D,F,G)),Q},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){var D=this._writableState;D.corked&&(D.corked--,!D.writing&&!D.corked&&!D.bufferProcessing&&D.bufferedRequest&&_e(this,D))},M.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(M.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function re(D,F,G){return!D.objectMode&&D.decodeStrings!==!1&&typeof F=="string"&&(F=u.from(F,G)),F}Object.defineProperty(M.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function U(D,F,G,Z,Q,y){if(!G){var w=re(F,Z,Q);Z!==w&&(G=!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 le=F.lastBufferedRequest;F.lastBufferedRequest={chunk:Z,encoding:Q,isBuf:G,callback:y,next:null},le?le.next=F.lastBufferedRequest:F.bufferedRequest=F.lastBufferedRequest,F.bufferedRequestCount+=1}else he(D,F,!1,z,Z,Q,y);return ee}function he(D,F,G,Z,Q,y,w){F.writelen=Z,F.writecb=w,F.writing=!0,F.sync=!0,F.destroyed?F.onwrite(new T("write")):G?D._writev(Q,F.onwrite):D._write(Q,y,F.onwrite),F.sync=!1}function de(D,F,G,Z,Q){--F.pendingcb,G?(ae.nextTick(Q,Z),ae.nextTick(V,D,F),D._writableState.errorEmitted=!0,P(D,Z)):(Q(Z),D._writableState.errorEmitted=!0,P(D,Z),V(D,F))}function me(D){D.writing=!1,D.writecb=null,D.length-=D.writelen,D.writelen=0}function Pe(D,F){var G=D._writableState,Z=G.sync,Q=G.writecb;if(typeof Q!="function")throw new b;if(me(G),F)de(D,G,Z,F,Q);else{var y=Oe(G)||D.destroyed;!y&&!G.corked&&!G.bufferProcessing&&G.bufferedRequest&&_e(D,G),Z?ae.nextTick(ke,D,G,y,Q):ke(D,G,y,Q)}}function ke(D,F,G,Z){G||Ee(D,F),F.pendingcb--,Z(),V(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 G=F.bufferedRequest;if(D._writev&&G&&G.next){var Z=F.bufferedRequestCount,Q=new Array(Z),y=F.corkedRequestsFree;y.entry=G;for(var w=0,z=!0;G;)Q[w]=G,G.isBuf||(z=!1),G=G.next,w+=1;Q.allBuffers=z,he(D,F,!0,F.length,Q,"",y.finish),F.pendingcb++,F.lastBufferedRequest=null,y.next?(F.corkedRequestsFree=y.next,y.next=null):F.corkedRequestsFree=new r(F),F.bufferedRequestCount=0}else{for(;G;){var ee=G.chunk,le=G.encoding,ie=G.callback,se=F.objectMode?1:ee.length;if(he(D,F,!1,se,ee,le,ie),G=G.next,F.bufferedRequestCount--,F.writing)break}G===null&&(F.lastBufferedRequest=null)}F.bufferedRequest=G,F.bufferProcessing=!1}M.prototype._write=function(D,F,G){G(new x("_write()"))},M.prototype._writev=null,M.prototype.end=function(D,F,G){var Z=this._writableState;return typeof D=="function"?(G=D,D=null,F=null):typeof F=="function"&&(G=F,F=null),D!=null&&this.write(D,F),Z.corked&&(Z.corked=1,this.uncork()),Z.ending||J(this,Z,G),this},Object.defineProperty(M.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Oe(D){return D.ending&&D.length===0&&D.bufferedRequest===null&&!D.finished&&!D.writing}function qe(D,F){D._final(function(G){F.pendingcb--,G&&P(D,G),F.prefinished=!0,D.emit("prefinish"),V(D,F)})}function $(D,F){!F.prefinished&&!F.finalCalled&&(typeof D._final=="function"&&!F.destroyed?(F.pendingcb++,F.finalCalled=!0,ae.nextTick(qe,D,F)):(F.prefinished=!0,D.emit("prefinish")))}function V(D,F){var G=Oe(F);if(G&&($(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 G}function J(D,F,G){F.ending=!0,V(D,F),G&&(F.finished?ae.nextTick(G):D.once("finish",G)),F.ended=!0,D.writable=!1}function ne(D,F,G){var Z=D.entry;for(D.entry=null;Z;){var Q=Z.callback;F.pendingcb--,Q(G),Z=Z.next}F.corkedRequestsFree.next=D}return Object.defineProperty(M.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(F){this._writableState&&(this._writableState.destroyed=F)}}),M.prototype.destroy=c.destroy,M.prototype._undestroy=c.undestroy,M.prototype._destroy=function(D,F){F(D)},on}var an,wo;function ht(){if(wo)return an;wo=1;var r=Object.keys||function(v){var h=[];for(var I in v)h.push(I);return h};an=g;var e=Po(),t=vo();ut()(g,e);for(var s=r(t.prototype),u=0;u<s.length;u++){var l=s[u];g.prototype[l]||(g.prototype[l]=t.prototype[l])}function g(v){if(!(this instanceof g))return new g(v);e.call(this,v),t.call(this,v),this.allowHalfOpen=!0,v&&(v.readable===!1&&(this.readable=!1),v.writable===!1&&(this.writable=!1),v.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(c,this)}function c(v){v.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={},bo;function So(){if(bo)return sn;bo=1;var r=Hn().Buffer,e=r.isEncoding||function(m){switch(m=""+m,m&&m.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(m){if(!m)return"utf8";for(var R;;)switch(m){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 m;default:if(R)return;m=(""+m).toLowerCase(),R=!0}}function s(m){var R=t(m);if(typeof R!="string"&&(r.isEncoding===e||!e(m)))throw new Error("Unknown encoding: "+m);return R||m}sn.StringDecoder=u;function u(m){this.encoding=s(m);var R;switch(this.encoding){case"utf16le":this.text=I,this.end=B,R=4;break;case"utf8":this.fillLast=c,R=4;break;case"base64":this.text=x,this.end=b,R=3;break;default:this.write=N,this.end=T;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(R)}u.prototype.write=function(m){if(m.length===0)return"";var R,A;if(this.lastNeed){if(R=this.fillLast(m),R===void 0)return"";A=this.lastNeed,this.lastNeed=0}else A=0;return A<m.length?R?R+this.text(m,A):this.text(m,A):R||""},u.prototype.end=h,u.prototype.text=v,u.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length};function l(m){return m<=127?0:m>>5===6?2:m>>4===14?3:m>>3===30?4:m>>6===2?-1:-2}function g(m,R,A){var P=R.length-1;if(P<A)return 0;var k=l(R[P]);return k>=0?(k>0&&(m.lastNeed=k-1),k):--P<A||k===-2?0:(k=l(R[P]),k>=0?(k>0&&(m.lastNeed=k-2),k):--P<A||k===-2?0:(k=l(R[P]),k>=0?(k>0&&(k===2?k=0:m.lastNeed=k-3),k):0))}function f(m,R,A){if((R[0]&192)!==128)return m.lastNeed=0,"�";if(m.lastNeed>1&&R.length>1){if((R[1]&192)!==128)return m.lastNeed=1,"�";if(m.lastNeed>2&&R.length>2&&(R[2]&192)!==128)return m.lastNeed=2,"�"}}function c(m){var R=this.lastTotal-this.lastNeed,A=f(this,m);if(A!==void 0)return A;if(this.lastNeed<=m.length)return m.copy(this.lastChar,R,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,R,0,m.length),this.lastNeed-=m.length}function v(m,R){var A=g(this,m,R);if(!this.lastNeed)return m.toString("utf8",R);this.lastTotal=A;var P=m.length-(A-this.lastNeed);return m.copy(this.lastChar,0,P),m.toString("utf8",R,P)}function h(m){var R=m&&m.length?this.write(m):"";return this.lastNeed?R+"�":R}function I(m,R){if((m.length-R)%2===0){var A=m.toString("utf16le",R);if(A){var P=A.charCodeAt(A.length-1);if(P>=55296&&P<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],A.slice(0,-1)}return A}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",R,m.length-1)}function B(m){var R=m&&m.length?this.write(m):"";if(this.lastNeed){var A=this.lastTotal-this.lastNeed;return R+this.lastChar.toString("utf16le",0,A)}return R}function x(m,R){var A=(m.length-R)%3;return A===0?m.toString("base64",R):(this.lastNeed=3-A,this.lastTotal=3,A===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",R,m.length-A))}function b(m){var R=m&&m.length?this.write(m):"";return this.lastNeed?R+this.lastChar.toString("base64",0,3-this.lastNeed):R}function N(m){return m.toString(this.encoding)}function T(m){return m&&m.length?this.write(m):""}return sn}var ln,_o;function cn(){if(_o)return ln;_o=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,c=new Array(f),v=0;v<f;v++)c[v]=arguments[v];l.apply(this,c)}}}function t(){}function s(l){return l.setHeader&&typeof l.abort=="function"}function u(l,g,f){if(typeof g=="function")return u(l,null,g);g||(g={}),f=e(f||t);var c=g.readable||g.readable!==!1&&l.readable,v=g.writable||g.writable!==!1&&l.writable,h=function(){l.writable||B()},I=l._writableState&&l._writableState.finished,B=function(){v=!1,I=!0,c||f.call(l)},x=l._readableState&&l._readableState.endEmitted,b=function(){c=!1,x=!0,v||f.call(l)},N=function(A){f.call(l,A)},T=function(){var A;if(c&&!x)return(!l._readableState||!l._readableState.ended)&&(A=new r),f.call(l,A);if(v&&!I)return(!l._writableState||!l._writableState.ended)&&(A=new r),f.call(l,A)},m=function(){l.req.on("finish",B)};return s(l)?(l.on("complete",B),l.on("abort",T),l.req?m():l.on("request",m)):v&&!l._writableState&&(l.on("end",h),l.on("close",h)),l.on("end",b),l.on("finish",B),g.error!==!1&&l.on("error",N),l.on("close",T),function(){l.removeListener("complete",B),l.removeListener("abort",T),l.removeListener("request",m),l.req&&l.req.removeListener("finish",B),l.removeListener("end",h),l.removeListener("close",h),l.removeListener("finish",B),l.removeListener("end",b),l.removeListener("error",N),l.removeListener("close",T)}}return ln=u,ln}var un,Eo;function rs(){if(Eo)return un;Eo=1;var r;function e(A,P,k){return P=t(P),P in A?Object.defineProperty(A,P,{value:k,enumerable:!0,configurable:!0,writable:!0}):A[P]=k,A}function t(A){var P=s(A,"string");return typeof P=="symbol"?P:String(P)}function s(A,P){if(typeof A!="object"||A===null)return A;var k=A[Symbol.toPrimitive];if(k!==void 0){var S=k.call(A,P);if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(P==="string"?String:Number)(A)}var u=cn(),l=Symbol("lastResolve"),g=Symbol("lastReject"),f=Symbol("error"),c=Symbol("ended"),v=Symbol("lastPromise"),h=Symbol("handlePromise"),I=Symbol("stream");function B(A,P){return{value:A,done:P}}function x(A){var P=A[l];if(P!==null){var k=A[I].read();k!==null&&(A[v]=null,A[l]=null,A[g]=null,P(B(k,!1)))}}function b(A){ae.nextTick(x,A)}function N(A,P){return function(k,S){A.then(function(){if(P[c]){k(B(void 0,!0));return}P[h](k,S)},S)}}var T=Object.getPrototypeOf(function(){}),m=Object.setPrototypeOf((r={get stream(){return this[I]},next:function(){var P=this,k=this[f];if(k!==null)return Promise.reject(k);if(this[c])return Promise.resolve(B(void 0,!0));if(this[I].destroyed)return new Promise(function(W,X){ae.nextTick(function(){P[f]?X(P[f]):W(B(void 0,!0))})});var S=this[v],C;if(S)C=new Promise(N(S,this));else{var M=this[I].read();if(M!==null)return Promise.resolve(B(M,!1));C=new Promise(this[h])}return this[v]=C,C}},e(r,Symbol.asyncIterator,function(){return this}),e(r,"return",function(){var P=this;return new Promise(function(k,S){P[I].destroy(null,function(C){if(C){S(C);return}k(B(void 0,!0))})})}),r),T),R=function(P){var k,S=Object.create(m,(k={},e(k,I,{value:P,writable:!0}),e(k,l,{value:null,writable:!0}),e(k,g,{value:null,writable:!0}),e(k,f,{value:null,writable:!0}),e(k,c,{value:P._readableState.endEmitted,writable:!0}),e(k,h,{value:function(M,W){var X=S[I].read();X?(S[v]=null,S[l]=null,S[g]=null,M(B(X,!1))):(S[l]=M,S[g]=W)},writable:!0}),k));return S[v]=null,u(P,function(C){if(C&&C.code!=="ERR_STREAM_PREMATURE_CLOSE"){var M=S[g];M!==null&&(S[v]=null,S[l]=null,S[g]=null,M(C)),S[f]=C;return}var W=S[l];W!==null&&(S[v]=null,S[l]=null,S[g]=null,W(B(void 0,!0))),S[c]=!0}),P.on("readable",b.bind(null,S)),S};return un=R,un}var fn,Co;function ns(){return Co||(Co=1,fn=function(){throw new Error("Readable.from is not available in the browser")}),fn}var hn,Ro;function Po(){if(Ro)return hn;Ro=1,hn=W;var r;W.ReadableState=M,Ht().EventEmitter;var e=function(w,z){return w.listeners(z).length},t=Xn(),s=yt().Buffer,u=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function l(y){return s.from(y)}function g(y){return s.isBuffer(y)||y instanceof u}var f=lo(),c;f&&f.debuglog?c=f.debuglog("stream"):c=function(){};var v=es(),h=fo(),I=go(),B=I.getHighWaterMark,x=ft().codes,b=x.ERR_INVALID_ARG_TYPE,N=x.ERR_STREAM_PUSH_AFTER_EOF,T=x.ERR_METHOD_NOT_IMPLEMENTED,m=x.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,R,A,P;ut()(W,t);var k=h.errorOrDestroy,S=["error","close","destroy","pause","resume"];function C(y,w,z){if(typeof y.prependListener=="function")return y.prependListener(w,z);!y._events||!y._events[w]?y.on(w,z):Array.isArray(y._events[w])?y._events[w].unshift(z):y._events[w]=[z,y._events[w]]}function M(y,w,z){r=r||ht(),y=y||{},typeof z!="boolean"&&(z=w instanceof r),this.objectMode=!!y.objectMode,z&&(this.objectMode=this.objectMode||!!y.readableObjectMode),this.highWaterMark=B(this,y,"readableHighWaterMark",z),this.buffer=new v,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=y.emitClose!==!1,this.autoDestroy=!!y.autoDestroy,this.destroyed=!1,this.defaultEncoding=y.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,y.encoding&&(R||(R=So().StringDecoder),this.decoder=new R(y.encoding),this.encoding=y.encoding)}function W(y){if(r=r||ht(),!(this instanceof W))return new W(y);var w=this instanceof r;this._readableState=new M(y,this,w),this.readable=!0,y&&(typeof y.read=="function"&&(this._read=y.read),typeof y.destroy=="function"&&(this._destroy=y.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(y,w){w(y)},W.prototype.push=function(y,w){var z=this._readableState,ee;return z.objectMode?ee=!0:typeof y=="string"&&(w=w||z.defaultEncoding,w!==z.encoding&&(y=s.from(y,w),w=""),ee=!0),X(this,y,w,!1,ee)},W.prototype.unshift=function(y){return X(this,y,null,!0,!1)};function X(y,w,z,ee,le){c("readableAddChunk",w);var ie=y._readableState;if(w===null)ie.reading=!1,Pe(y,ie);else{var se;if(le||(se=U(ie,w)),se)k(y,se);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?k(y,new m):re(y,ie,w,!0);else if(ie.ended)k(y,new N);else{if(ie.destroyed)return!1;ie.reading=!1,ie.decoder&&!z?(w=ie.decoder.write(w),ie.objectMode||w.length!==0?re(y,ie,w,!1):_e(y,ie)):re(y,ie,w,!1)}else ee||(ie.reading=!1,_e(y,ie))}return!ie.ended&&(ie.length<ie.highWaterMark||ie.length===0)}function re(y,w,z,ee){w.flowing&&w.length===0&&!w.sync?(w.awaitDrain=0,y.emit("data",z)):(w.length+=w.objectMode?1:z.length,ee?w.buffer.unshift(z):w.buffer.push(z),w.needReadable&&ke(y)),_e(y,w)}function U(y,w){var z;return!g(w)&&typeof w!="string"&&w!==void 0&&!y.objectMode&&(z=new b("chunk",["string","Buffer","Uint8Array"],w)),z}W.prototype.isPaused=function(){return this._readableState.flowing===!1},W.prototype.setEncoding=function(y){R||(R=So().StringDecoder);var w=new R(y);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(y){return y>=he?y=he:(y--,y|=y>>>1,y|=y>>>2,y|=y>>>4,y|=y>>>8,y|=y>>>16,y++),y}function me(y,w){return y<=0||w.length===0&&w.ended?0:w.objectMode?1:y!==y?w.flowing&&w.length?w.buffer.head.data.length:w.length:(y>w.highWaterMark&&(w.highWaterMark=de(y)),y<=w.length?y:w.ended?w.length:(w.needReadable=!0,0))}W.prototype.read=function(y){c("read",y),y=parseInt(y,10);var w=this._readableState,z=y;if(y!==0&&(w.emittedReadable=!1),y===0&&w.needReadable&&((w.highWaterMark!==0?w.length>=w.highWaterMark:w.length>0)||w.ended))return c("read: emitReadable",w.length,w.ended),w.length===0&&w.ended?G(this):ke(this),null;if(y=me(y,w),y===0&&w.ended)return w.length===0&&G(this),null;var ee=w.needReadable;c("need readable",ee),(w.length===0||w.length-y<w.highWaterMark)&&(ee=!0,c("length less than watermark",ee)),w.ended||w.reading?(ee=!1,c("reading or ended",ee)):ee&&(c("do read"),w.reading=!0,w.sync=!0,w.length===0&&(w.needReadable=!0),this._read(w.highWaterMark),w.sync=!1,w.reading||(y=me(z,w)));var le;return y>0?le=F(y,w):le=null,le===null?(w.needReadable=w.length<=w.highWaterMark,y=0):(w.length-=y,w.awaitDrain=0),w.length===0&&(w.ended||(w.needReadable=!0),z!==y&&w.ended&&G(this)),le!==null&&this.emit("data",le),le};function Pe(y,w){if(c("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(y):(w.needReadable=!1,w.emittedReadable||(w.emittedReadable=!0,Ee(y)))}}function ke(y){var w=y._readableState;c("emitReadable",w.needReadable,w.emittedReadable),w.needReadable=!1,w.emittedReadable||(c("emitReadable",w.flowing),w.emittedReadable=!0,ae.nextTick(Ee,y))}function Ee(y){var w=y._readableState;c("emitReadable_",w.destroyed,w.length,w.ended),!w.destroyed&&(w.length||w.ended)&&(y.emit("readable"),w.emittedReadable=!1),w.needReadable=!w.flowing&&!w.ended&&w.length<=w.highWaterMark,D(y)}function _e(y,w){w.readingMore||(w.readingMore=!0,ae.nextTick(Oe,y,w))}function Oe(y,w){for(;!w.reading&&!w.ended&&(w.length<w.highWaterMark||w.flowing&&w.length===0);){var z=w.length;if(c("maybeReadMore read 0"),y.read(0),z===w.length)break}w.readingMore=!1}W.prototype._read=function(y){k(this,new T("_read()"))},W.prototype.pipe=function(y,w){var z=this,ee=this._readableState;switch(ee.pipesCount){case 0:ee.pipes=y;break;case 1:ee.pipes=[ee.pipes,y];break;default:ee.pipes.push(y);break}ee.pipesCount+=1,c("pipe count=%d opts=%j",ee.pipesCount,w);var le=(!w||w.end!==!1)&&y!==ae.stdout&&y!==ae.stderr,ie=le?De:We;ee.endEmitted?ae.nextTick(ie):z.once("end",ie),y.on("unpipe",se);function se(Ve,Me){c("onunpipe"),Ve===z&&Me&&Me.hasUnpiped===!1&&(Me.hasUnpiped=!0,Ue())}function De(){c("onend"),y.end()}var H=qe(z);y.on("drain",H);var Fe=!1;function Ue(){c("cleanup"),y.removeListener("close",$e),y.removeListener("finish",Ne),y.removeListener("drain",H),y.removeListener("error",we),y.removeListener("unpipe",se),z.removeListener("end",De),z.removeListener("end",We),z.removeListener("data",ye),Fe=!0,ee.awaitDrain&&(!y._writableState||y._writableState.needDrain)&&H()}z.on("data",ye);function ye(Ve){c("ondata");var Me=y.write(Ve);c("dest.write",Me),Me===!1&&((ee.pipesCount===1&&ee.pipes===y||ee.pipesCount>1&&Q(ee.pipes,y)!==-1)&&!Fe&&(c("false write response, pause",ee.awaitDrain),ee.awaitDrain++),z.pause())}function we(Ve){c("onerror",Ve),We(),y.removeListener("error",we),e(y,"error")===0&&k(y,Ve)}C(y,"error",we);function $e(){y.removeListener("finish",Ne),We()}y.once("close",$e);function Ne(){c("onfinish"),y.removeListener("close",$e),We()}y.once("finish",Ne);function We(){c("unpipe"),z.unpipe(y)}return y.emit("pipe",z),ee.flowing||(c("pipe resume"),z.resume()),y};function qe(y){return function(){var z=y._readableState;c("pipeOnDrain",z.awaitDrain),z.awaitDrain&&z.awaitDrain--,z.awaitDrain===0&&e(y,"data")&&(z.flowing=!0,D(y))}}W.prototype.unpipe=function(y){var w=this._readableState,z={hasUnpiped:!1};if(w.pipesCount===0)return this;if(w.pipesCount===1)return y&&y!==w.pipes?this:(y||(y=w.pipes),w.pipes=null,w.pipesCount=0,w.flowing=!1,y&&y.emit("unpipe",this,z),this);if(!y){var ee=w.pipes,le=w.pipesCount;w.pipes=null,w.pipesCount=0,w.flowing=!1;for(var ie=0;ie<le;ie++)ee[ie].emit("unpipe",this,{hasUnpiped:!1});return this}var se=Q(w.pipes,y);return se===-1?this:(w.pipes.splice(se,1),w.pipesCount-=1,w.pipesCount===1&&(w.pipes=w.pipes[0]),y.emit("unpipe",this,z),this)},W.prototype.on=function(y,w){var z=t.prototype.on.call(this,y,w),ee=this._readableState;return y==="data"?(ee.readableListening=this.listenerCount("readable")>0,ee.flowing!==!1&&this.resume()):y==="readable"&&!ee.endEmitted&&!ee.readableListening&&(ee.readableListening=ee.needReadable=!0,ee.flowing=!1,ee.emittedReadable=!1,c("on readable",ee.length,ee.reading),ee.length?ke(this):ee.reading||ae.nextTick(V,this)),z},W.prototype.addListener=W.prototype.on,W.prototype.removeListener=function(y,w){var z=t.prototype.removeListener.call(this,y,w);return y==="readable"&&ae.nextTick($,this),z},W.prototype.removeAllListeners=function(y){var w=t.prototype.removeAllListeners.apply(this,arguments);return(y==="readable"||y===void 0)&&ae.nextTick($,this),w};function $(y){var w=y._readableState;w.readableListening=y.listenerCount("readable")>0,w.resumeScheduled&&!w.paused?w.flowing=!0:y.listenerCount("data")>0&&y.resume()}function V(y){c("readable nexttick read 0"),y.read(0)}W.prototype.resume=function(){var y=this._readableState;return y.flowing||(c("resume"),y.flowing=!y.readableListening,J(this,y)),y.paused=!1,this};function J(y,w){w.resumeScheduled||(w.resumeScheduled=!0,ae.nextTick(ne,y,w))}function ne(y,w){c("resume",w.reading),w.reading||y.read(0),w.resumeScheduled=!1,y.emit("resume"),D(y),w.flowing&&!w.reading&&y.read(0)}W.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function D(y){var w=y._readableState;for(c("flow",w.flowing);w.flowing&&y.read()!==null;);}W.prototype.wrap=function(y){var w=this,z=this._readableState,ee=!1;y.on("end",function(){if(c("wrapped end"),z.decoder&&!z.ended){var se=z.decoder.end();se&&se.length&&w.push(se)}w.push(null)}),y.on("data",function(se){if(c("wrapped data"),z.decoder&&(se=z.decoder.write(se)),!(z.objectMode&&se==null)&&!(!z.objectMode&&(!se||!se.length))){var De=w.push(se);De||(ee=!0,y.pause())}});for(var le in y)this[le]===void 0&&typeof y[le]=="function"&&(this[le]=function(De){return function(){return y[De].apply(y,arguments)}}(le));for(var ie=0;ie<S.length;ie++)y.on(S[ie],this.emit.bind(this,S[ie]));return this._read=function(se){c("wrapped _read",se),ee&&(ee=!1,y.resume())},this},typeof Symbol=="function"&&(W.prototype[Symbol.asyncIterator]=function(){return A===void 0&&(A=rs()),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(y,w){if(w.length===0)return null;var z;return w.objectMode?z=w.buffer.shift():!y||y>=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(y,w.decoder),z}function G(y){var w=y._readableState;c("endReadable",w.endEmitted),w.endEmitted||(w.ended=!0,ae.nextTick(Z,w,y))}function Z(y,w){if(c("endReadableNT",y.endEmitted,y.length),!y.endEmitted&&y.length===0&&(y.endEmitted=!0,w.readable=!1,w.emit("end"),y.autoDestroy)){var z=w._writableState;(!z||z.autoDestroy&&z.finished)&&w.destroy()}}typeof Symbol=="function"&&(W.from=function(y,w){return P===void 0&&(P=ns()),P(W,y,w)});function Q(y,w){for(var z=0,ee=y.length;z<ee;z++)if(y[z]===w)return z;return-1}return hn}var dn,To;function Ao(){if(To)return dn;To=1,dn=f;var r=ft().codes,e=r.ERR_METHOD_NOT_IMPLEMENTED,t=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,u=r.ERR_TRANSFORM_WITH_LENGTH_0,l=ht();ut()(f,l);function g(h,I){var B=this._transformState;B.transforming=!1;var x=B.writecb;if(x===null)return this.emit("error",new t);B.writechunk=null,B.writecb=null,I!=null&&this.push(I),x(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",c)}function c(){var h=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(I,B){v(h,I,B)}):v(this,null,null)}f.prototype.push=function(h,I){return this._transformState.needTransform=!1,l.prototype.push.call(this,h,I)},f.prototype._transform=function(h,I,B){B(new e("_transform()"))},f.prototype._write=function(h,I,B){var x=this._transformState;if(x.writecb=B,x.writechunk=h,x.writeencoding=I,!x.transforming){var b=this._readableState;(x.needTransform||b.needReadable||b.length<b.highWaterMark)&&this._read(b.highWaterMark)}},f.prototype._read=function(h){var I=this._transformState;I.writechunk!==null&&!I.transforming?(I.transforming=!0,this._transform(I.writechunk,I.writeencoding,I.afterTransform)):I.needTransform=!0},f.prototype._destroy=function(h,I){l.prototype._destroy.call(this,h,function(B){I(B)})};function v(h,I,B){if(I)return h.emit("error",I);if(B!=null&&h.push(B),h._writableState.length)throw new u;if(h._transformState.transforming)throw new s;return h.push(null)}return dn}var pn,Io;function is(){if(Io)return pn;Io=1,pn=e;var r=Ao();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,u){u(null,t)},pn}var gn,Bo;function os(){if(Bo)return gn;Bo=1;var r;function e(B){var x=!1;return function(){x||(x=!0,B.apply(void 0,arguments))}}var t=ft().codes,s=t.ERR_MISSING_ARGS,u=t.ERR_STREAM_DESTROYED;function l(B){if(B)throw B}function g(B){return B.setHeader&&typeof B.abort=="function"}function f(B,x,b,N){N=e(N);var T=!1;B.on("close",function(){T=!0}),r===void 0&&(r=cn()),r(B,{readable:x,writable:b},function(R){if(R)return N(R);T=!0,N()});var m=!1;return function(R){if(!T&&!m){if(m=!0,g(B))return B.abort();if(typeof B.destroy=="function")return B.destroy();N(R||new u("pipe"))}}}function c(B){B()}function v(B,x){return B.pipe(x)}function h(B){return!B.length||typeof B[B.length-1]!="function"?l:B.pop()}function I(){for(var B=arguments.length,x=new Array(B),b=0;b<B;b++)x[b]=arguments[b];var N=h(x);if(Array.isArray(x[0])&&(x=x[0]),x.length<2)throw new s("streams");var T,m=x.map(function(R,A){var P=A<x.length-1,k=A>0;return f(R,P,k,function(S){T||(T=S),S&&m.forEach(c),!P&&(m.forEach(c),N(T))})});return x.reduce(v)}return gn=I,gn}var ko;function as(){return ko||(ko=1,function(r,e){e=r.exports=Po(),e.Stream=e,e.Readable=e,e.Writable=vo(),e.Duplex=ht(),e.Transform=Ao(),e.PassThrough=is(),e.finished=cn(),e.pipeline=os()}(At,At.exports)),At.exports}/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var yn,Oo;function ss(){if(Oo)return yn;Oo=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,Mo;function ls(){if(Mo)return mn;Mo=1;function r(t,s){for(const u in s)Object.defineProperty(t,u,{value:s[u],enumerable:!0,configurable:!0});return t}function e(t,s,u){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");u||(u={}),typeof s=="object"&&(u=s,s=""),s&&(u.code=s);try{return r(t,u)}catch(l){u.message=t.message,u.stack=t.stack;const g=function(){};return g.prototype=Object.create(Object.getPrototypeOf(t)),r(new g,u)}}return mn=e,mn}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var vn,Lo;function cs(){if(Lo)return vn;Lo=1;const r=ma()("simple-peer"),e=va(),t=wa(),s=as(),u=ss(),l=ls(),{Buffer:g}=yt(),f=64*1024,c=5*1e3,v=5*1e3;function h(x){return x.replace(/a=ice-options:trickle\s\n/g,"")}function I(x){console.warn(x)}class B 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||B.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},B.config,b.config),this.offerOptions=b.offerOptions||{},this.answerOptions=b.answerOptions||{},this.sdpTransform=b.sdpTransform||(N=>N),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||c,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(N){this.destroy(l(N,"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=N=>{this._onIceCandidate(N)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(N=>{this.destroy(l(N,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=N=>{this._setupData(N)},this.streams&&this.streams.forEach(N=>{this.addStream(N)}),this._pc.ontrack=N=>{this._onTrack(N)},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(N){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(N=>{this._addIceCandidate(N)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(N=>{this.destroy(l(N,"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 N=new this._wrtc.RTCIceCandidate(b);this._pc.addIceCandidate(N).catch(T=>{!N.address||N.address.endsWith(".local")?I("Ignoring unsupported ICE candidate."):this.destroy(l(T,"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,N){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,N),this._needsNegotiation()}catch(T){this.destroy(l(T,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:b,init:N}})}}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(N=>{this.addTrack(N,b)})}}addTrack(b,N){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const T=this._senderMap.get(b)||new Map;let m=T.get(N);if(!m)m=this._pc.addTrack(b,N),T.set(N,m),this._senderMap.set(b,T),this._needsNegotiation();else throw m.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,N,T){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const m=this._senderMap.get(b),R=m?m.get(T):null;if(!R)throw l(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");N&&this._senderMap.set(N,m),R.replaceTrack!=null?R.replaceTrack(N):this.destroy(l(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(b,N){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const T=this._senderMap.get(b),m=T?T.get(N):null;if(!m)throw l(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{m.removed=!0,this._pc.removeTrack(m)}catch(R){R.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(m):this.destroy(l(R,"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(N=>{this.removeTrack(N,b)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,u(()=>{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,N){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",b&&(b.message||b)),u(()=>{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(T){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(T){}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"),N()}))}_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=T=>{this._onChannelMessage(T)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=T=>{const m=T.error instanceof Error?T.error:new Error(`Datachannel error: ${T.message} ${T.filename}:${T.lineno}:${T.colno}`);this.destroy(l(m,"ERR_DATA_CHANNEL"))};let N=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(N&&this._onChannelClose(),N=!0):N=!1},v)}_read(){}_write(b,N,T){if(this.destroyed)return T(l(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(b)}catch(m){return this.destroy(l(m,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>f?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=T):T(null)}else this._debug("write before connect"),this._chunk=b,this._cb=T}_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 N=()=>{if(this.destroyed)return;const R=this._pc.localDescription||b;this._debug("signal"),this.emit("signal",{type:R.type,sdp:R.sdp})},T=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?N():this.once("_iceComplete",N))},m=R=>{this.destroy(l(R,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(b).then(T).catch(m)}).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 N=()=>{if(this.destroyed)return;const R=this._pc.localDescription||b;this._debug("signal"),this.emit("signal",{type:R.type,sdp:R.sdp}),this.initiator||this._requestMissingTransceivers()},T=()=>{this.destroyed||(this.trickle||this._iceComplete?N():this.once("_iceComplete",N))},m=R=>{this.destroy(l(R,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(b).then(T).catch(m)}).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,N=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",b,N),this.emit("iceStateChange",b,N),(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 N=T=>(Object.prototype.toString.call(T.values)==="[object Array]"&&T.values.forEach(m=>{Object.assign(T,m)}),T);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(T=>{const m=[];T.forEach(R=>{m.push(N(R))}),b(null,m)},T=>b(T)):this._pc.getStats.length>0?this._pc.getStats(T=>{if(this.destroyed)return;const m=[];T.result().forEach(R=>{const A={};R.names().forEach(P=>{A[P]=R.stat(P)}),A.id=R.id,A.type=R.type,A.timestamp=R.timestamp,m.push(N(A))}),b(null,m)},T=>b(T)):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((N,T)=>{if(this.destroyed)return;N&&(T=[]);const m={},R={},A={};let P=!1;T.forEach(S=>{(S.type==="remotecandidate"||S.type==="remote-candidate")&&(m[S.id]=S),(S.type==="localcandidate"||S.type==="local-candidate")&&(R[S.id]=S),(S.type==="candidatepair"||S.type==="candidate-pair")&&(A[S.id]=S)});const k=S=>{P=!0;let C=R[S.localCandidateId];C&&(C.ip||C.address)?(this.localAddress=C.ip||C.address,this.localPort=Number(C.port)):C&&C.ipAddress?(this.localAddress=C.ipAddress,this.localPort=Number(C.portNumber)):typeof S.googLocalAddress=="string"&&(C=S.googLocalAddress.split(":"),this.localAddress=C[0],this.localPort=Number(C[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let M=m[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(T.forEach(S=>{S.type==="transport"&&S.selectedCandidatePairId&&k(A[S.selectedCandidatePairId]),(S.type==="googCandidatePair"&&S.googActiveConnection==="true"||(S.type==="candidatepair"||S.type==="candidate-pair")&&S.selected)&&k(S)}),!P&&(!Object.keys(A).length||Object.keys(R).length)){setTimeout(b,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(C){return this.destroy(l(C,"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 N=b.data;N instanceof ArrayBuffer&&(N=g.from(N)),this.push(N)}_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(N=>{this._debug("on track"),this.emit("track",b.track,N),this._remoteTracks.push({track:b.track,stream:N}),!this._remoteStreams.some(T=>T.id===N.id)&&(this._remoteStreams.push(N),u(()=>{this._debug("on stream"),this.emit("stream",N)}))})}_debug(){const b=[].slice.call(arguments);b[0]="["+this._id+"] "+b[0],r.apply(null,b)}}return B.WEBRTC_SUPPORT=!!e(),B.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},B.channelConfig={},vn=B,vn}var us=cs();const fs=xt(us);var hs=Object.defineProperty,ds=(r,e,t)=>e in r?hs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ot=(r,e,t)=>ds(r,typeof e!="symbol"?e+"":e,t),wn=(r,e,t)=>new Promise((s,u)=>{var l=c=>{try{f(t.next(c))}catch(v){u(v)}},g=c=>{try{f(t.throw(c))}catch(v){u(v)}},f=c=>c.done?s(c.value):Promise.resolve(c.value).then(l,g);f((t=t.apply(r,e)).next())});class No{constructor(e,t,s={}){ot(this,"peer",null),ot(this,"config"),ot(this,"events"),ot(this,"connectionState","new"),ot(this,"isInitiator"),ot(this,"remoteUserId"),ot(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 fs(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(u){console.error(`[CallPeerConnection] Failed to signal to ${this.remoteUserId}:`,u),(s=(t=this.events).onError)==null||s.call(t,u)}}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(u){console.error(`[CallPeerConnection] Failed to add stream to ${this.remoteUserId}:`,u),(s=(t=this.events).onError)==null||s.call(t,u)}}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(u){console.error(`[CallPeerConnection] Failed to remove stream from ${this.remoteUserId}:`,u),(s=(t=this.events).onError)==null||s.call(t,u)}}replaceTrack(e,t){var s,u;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),(u=(s=this.events).onError)==null||u.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(u){console.error(`[CallPeerConnection] Failed to send data to ${this.remoteUserId}:`,u),(s=(t=this.events).onError)==null||s.call(t,u)}}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 u of s)if(u.track){const l=u.getParameters();l.encodings||(l.encodings=[{}]),l.encodings[0].maxBitrate=e*1e3,yield u.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"}setupPeerEventListeners(){if(!this.peer)return;this.peer.on("signal",t=>{var s,u;console.log(`[CallPeerConnection] Signal from ${this.remoteUserId}:`,t.type),(u=(s=this.events).onSignal)==null||u.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,u;try{const l=JSON.parse(t.toString());(u=(s=this.events).onData)==null||u.call(s,l)}catch(l){console.error(`[CallPeerConnection] Failed to parse data from ${this.remoteUserId}:`,l)}}),this.peer.on("stream",t=>{var s,u;console.log(`[CallPeerConnection] Stream received from ${this.remoteUserId}`),(u=(s=this.events).onStream)==null||u.call(s,t)}),this.peer.on("track",(t,s)=>{var u,l;console.log(`[CallPeerConnection] Track received from ${this.remoteUserId}:`,t.kind),(l=(u=this.events).onTrack)==null||l.call(u,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,u;console.error(`[CallPeerConnection] Error with ${this.remoteUserId}:`,t),this.connectionState="failed",(u=(s=this.events).onError)==null||u.call(s,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 Do={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},bt=new Map,Mt=r=>{const e=bt.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=bt.get(t.name);if(s)return St({type:"tracked",store:r},s);const u={connection:e.connect(t),stores:{}};return bt.set(t.name,u),St({type:"tracked",store:r},u)},gs=(r,e)=>{if(e===void 0)return;const t=bt.get(r);t&&(delete t.stores[e],Object.keys(t.stores).length===0&&bt.delete(r))},ys=r=>{var e,t;if(!r)return;const s=r.split(`
22
+ `),u=s.findIndex(g=>g.includes("api.setState"));if(u<0)return;const l=((e=s[u+1])==null?void 0:e.trim())||"";return(t=/.+ (.+) .+/.exec(l))==null?void 0:t[1]},ms=(r,e={})=>(t,s,u)=>{const N=e,{enabled:l,anonymousActionType:g,store:f}=N,c=On(N,["enabled","anonymousActionType","store"]);let v;try{v=(l!=null?l:(Do?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(m){}if(!v)return r(t,s,u);const T=ps(f,v,c),{connection:h}=T,I=On(T,["connection"]);let B=!0;u.setState=(m,R,A)=>{const P=t(m,R);if(!B)return P;const k=A===void 0?{type:g||ys(new Error().stack)||"anonymous"}:typeof A=="string"?{type:A}:A;return f===void 0?(h==null||h.send(k,s()),P):(h==null||h.send(kn(St({},k),{type:`${f}/${k.type}`}),kn(St({},Mt(c.name)),{[f]:u.getState()})),P)},u.devtools={cleanup:()=>{h&&typeof h.unsubscribe=="function"&&h.unsubscribe(),gs(c.name,f)}};const x=(...m)=>{const R=B;B=!1,t(...m),B=R},b=r(u.setState,s,u);if(I.type==="untracked"?h==null||h.init(b):(I.stores[I.store]=u,h==null||h.init(Object.fromEntries(Object.entries(I.stores).map(([m,R])=>[m,m===I.store?b:R.getState()])))),u.dispatchFromDevtools&&typeof u.dispatch=="function"){let m=!1;const R=u.dispatch;u.dispatch=(...A)=>{(Do?"production":void 0)!=="production"&&A[0].type==="__setState"&&!m&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),m=!0),R(...A)}}return h.subscribe(m=>{var R;switch(m.type){case"ACTION":if(typeof m.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return bn(m.payload,A=>{if(A.type==="__setState"){if(f===void 0){x(A.state);return}Object.keys(A.state).length!==1&&console.error(`
18
23
  [zustand devtools middleware] Unsupported __setState action format.
19
24
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
20
25
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
21
- `);const S=P.state[a];if(S==null)return;JSON.stringify(l.getState())!==JSON.stringify(S)&&j(S);return}l.dispatchFromDevtools&&typeof l.dispatch=="function"&&l.dispatch(P)});case"DISPATCH":switch(h.payload.type){case"RESET":return j(y),a===void 0?w==null?void 0:w.init(l.getState()):w==null?void 0:w.init(ut(f.name));case"COMMIT":if(a===void 0){w==null||w.init(l.getState());return}return w==null?void 0:w.init(ut(f.name));case"ROLLBACK":return Hr(h.state,P=>{if(a===void 0){j(P),w==null||w.init(l.getState());return}j(P[a]),w==null||w.init(ut(f.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return Hr(h.state,P=>{if(a===void 0){j(P);return}JSON.stringify(l.getState())!==JSON.stringify(P[a])&&j(P[a])});case"IMPORT_STATE":{const{nextLiftedState:P}=h.payload,S=(b=P.computedStates.slice(-1)[0])==null?void 0:b.state;if(!S)return;j(a===void 0?S:S[a]),w==null||w.send(null,P);return}case"PAUSE_RECORDING":return C=!C}return}}),y},Hr=(n,e)=>{let t;try{t=JSON.parse(n)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}t!==void 0&&e(t)};var Ma={env:{}},Ba=Object.defineProperty,La=Object.defineProperties,Na=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,so=Object.prototype.propertyIsEnumerable,lo=(n,e,t)=>e in n?Ba(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Fe=(n,e)=>{for(var t in e||(e={}))ao.call(e,t)&&lo(n,t,e[t]);if(ft)for(var t of ft(e))so.call(e,t)&&lo(n,t,e[t]);return n},Jr=(n,e)=>La(n,Na(e)),Da=n=>typeof n=="symbol"?n:n+"",Fa=(n,e)=>{var t={};for(var o in n)ao.call(n,o)&&e.indexOf(o)<0&&(t[o]=n[o]);if(n!=null&&ft)for(var o of ft(n))e.indexOf(o)<0&&so.call(n,o)&&(t[o]=n[o]);return t};const co={roomId:"",participants:{},localParticipant:null,isCalling:!1,isRecording:!1,recordLoading:!1,callStatus:"idle",error:null,callStatusInfo:null,callStatusLoading:!1,callStatusError:null},we=ye.create()(Oa(n=>Jr(Fe({},co),{setRoomId:e=>n({roomId:e},!1,"setRoomId"),setLocalParticipant:e=>n({localParticipant:e},!1,"setLocalParticipant"),addParticipant:e=>n(t=>({participants:Jr(Fe({},t.participants),{[e.userId]:e})}),!1,"addParticipant"),removeParticipant:e=>n(t=>{const o=t.participants,{[e]:l}=o;return{participants:Fa(o,[Da(e)])}},!1,"removeParticipant"),updateParticipant:(e,t)=>n(o=>({participants:Jr(Fe({},o.participants),{[e]:o.participants[e]?Fe(Fe({},o.participants[e]),t):Fe({userId:e,videoOn:!0,audioOn:!0,screenSharing:!1},t)})}),!1,"updateParticipant"),clearParticipants:()=>n({participants:{}},!1,"clearParticipants"),setCallStatus:e=>n({callStatus:e},!1,"setCallStatus"),setIsCalling:e=>n({isCalling:e},!1,"setIsCalling"),setIsRecording:e=>n({isRecording:e},!1,"setIsRecording"),setRecordLoading:e=>n({recordLoading:e},!1,"setRecordLoading"),setError:(e,t)=>n({error:t||e},!1,"setError"),clearError:()=>n({error:null},!1,"clearError"),setCallStatusInfo:e=>n({callStatusInfo:e},!1,"setCallStatusInfo"),setCallStatusLoading:e=>n({callStatusLoading:e},!1,"setCallStatusLoading"),setCallStatusError:e=>n({callStatusError:e},!1,"setCallStatusError"),resetCall:()=>n(Fe({},co),!1,"resetCall")}),{name:"peers-caller-store",enabled:Ma.env.NODE_ENV==="development"})),ja=n=>n.participants,uo=n=>Object.keys(n.participants).length,$a=n=>n.localParticipant,Ua=n=>n.callStatus,qa=n=>n.callStatus==="connected",xa=n=>n.error,Wa=n=>n.callStatusInfo,Va=n=>n.callStatusLoading,za=n=>n.callStatusError,Ga=n=>{var e;return((e=n.callStatusInfo)==null?void 0:e.canJoin)||!1},Ha=n=>{var e;return((e=n.callStatusInfo)==null?void 0:e.hasActiveCall)||!1},fo=n=>we.getState().participants[n],Ja=n=>{const e=fo(n);return!!(e!=null&&e.stream)},Ya=()=>{const n=we.getState();return Object.values(n.participants)},Ka=(n=4)=>uo(we.getState())<n;var Xa=Object.defineProperty,Za=(n,e,t)=>e in n?Xa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Qa=(n,e,t)=>Za(n,e+"",t);class ho{constructor(e){if(Qa(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 es=Object.defineProperty,ts=Object.defineProperties,rs=Object.getOwnPropertyDescriptors,po=Object.getOwnPropertySymbols,ns=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,Yr=(n,e,t)=>e in n?es(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Kr=(n,e)=>{for(var t in e||(e={}))ns.call(e,t)&&Yr(n,t,e[t]);if(po)for(var t of po(e))is.call(e,t)&&Yr(n,t,e[t]);return n},os=(n,e)=>ts(n,rs(e)),xe=(n,e,t)=>Yr(n,typeof e!="symbol"?e+"":e,t),dt=(n,e,t)=>new Promise((o,l)=>{var c=f=>{try{a(t.next(f))}catch(u){l(u)}},E=f=>{try{a(t.throw(f))}catch(u){l(u)}},a=f=>f.done?o(f.value):Promise.resolve(f.value).then(c,E);a((t=t.apply(n,e)).next())});class Xr extends ho{constructor(e,t={},o=!1){super(we),xe(this,"userId"),xe(this,"mediaStream",null),xe(this,"peerConnections",new Map),xe(this,"remoteStreams",new Map),xe(this,"isLocalParticipant",!1),xe(this,"callbacks"),this.userId=e,this.callbacks=t,this.isLocalParticipant=o;const l={userId:e,videoOn:!0,audioOn:!0,screenSharing:!1};this.isLocalParticipant&&this.state.setLocalParticipant(l),this.state.addParticipant(l)}initialize(e){return dt(this,null,function*(){var t,o;try{console.log(`[CallParticipant] Initializing participant ${this.userId}`),this.mediaStream=new un(e);const c={stream:yield this.mediaStream.initialize(),videoElement:this.mediaStream.createVideoElement()};this.updateState(c),console.log(`[CallParticipant] Participant ${this.userId} initialized successfully`)}catch(l){throw console.error(`[CallParticipant] Failed to initialize participant ${this.userId}:`,l),(o=(t=this.callbacks).onError)==null||o.call(t,l),l}})}createPeerConnection(e,t,o){return dt(this,null,function*(){var l,c;try{if(console.log(`[CallParticipant] Creating peer connection from ${this.userId} to ${e}`),this.peerConnections.has(e)){console.warn(`[CallParticipant] Peer connection to ${e} already exists`);return}const E={onSignal:f=>{var u,w;console.log(`[CallParticipant] Signal from ${this.userId} to ${e}:`,f.type),(w=(u=this.callbacks).onSignal)==null||w.call(u,this.userId,e,f)},onConnect:()=>{var f,u;console.log(`[CallParticipant] ${this.userId} connected to ${e}`),(u=(f=this.callbacks).onPeerConnected)==null||u.call(f,e)},onStream:f=>{var u,w;console.log(`[CallParticipant] Stream received from ${e} by ${this.userId}`),this.remoteStreams.set(e,f),this.state.updateParticipant(e,{stream:f}),(w=(u=this.callbacks).onStreamReceived)==null||w.call(u,e,f)},onClose:()=>{var f,u;console.log(`[CallParticipant] Connection closed between ${this.userId} and ${e}`),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),(u=(f=this.callbacks).onPeerDisconnected)==null||u.call(f,e)},onError:f=>{var u,w;console.error(`[CallParticipant] Peer connection error between ${this.userId} and ${e}:`,f),(w=(u=this.callbacks).onError)==null||w.call(u,f)}},a=new io(e,os(Kr({},t),{initiator:o}),E);yield a.createConnection(this.getCurrentStream()),this.peerConnections.set(e,a)}catch(E){throw console.error(`[CallParticipant] Failed to create peer connection from ${this.userId} to ${e}:`,E),(c=(l=this.callbacks).onError)==null||c.call(l,E),E}})}getPeerConnection(e){return this.peerConnections.get(e)}signalToPeer(e,t){const o=this.peerConnections.get(e);o?o.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 dt(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.userId}`);const o=yield this.mediaStream.startScreenShare(),l=this.mediaStream.getScreenVideoTrack(),c=this.mediaStream.getCameraVideoTrack();if(!l)throw new Error("Failed to get screen video track");for(const[E,a]of this.peerConnections)c?(a.replaceTrack(c,l),console.log(`[CallParticipant] Screen video track replaced for connection with ${E}`)):console.warn(`[CallParticipant] No camera video track to replace for ${E}`);this.updateState({screenSharing:!0,stream:o}),console.log(`[CallParticipant] Screen sharing started for ${this.userId}`)}catch(o){throw console.error(`[CallParticipant] Failed to start screen share for ${this.userId}:`,o),(t=(e=this.callbacks).onError)==null||t.call(e,o),o}})}stopScreenShare(){return dt(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.userId}`);const o=this.mediaStream.getScreenVideoTrack();console.log("[CallParticipant] Screen video track found:",!!o);const l=yield this.mediaStream.stopScreenShare(),c=this.mediaStream.getCameraVideoTrack();if(console.log("[CallParticipant] Camera stream:",!!l),console.log("[CallParticipant] Camera video track:",!!c),!c)throw new Error("Failed to get camera video track");for(const[E,a]of this.peerConnections)try{o&&c?(a.replaceTrack(o,c),console.log(`[CallParticipant] Camera video track restored for connection with ${E}`)):(console.log(`[CallParticipant] Updating entire stream for connection with ${E}`),a.addStream(l))}catch(f){console.warn(`[CallParticipant] Failed to replace track for ${E}, trying stream replacement:`,f)}if(this.updateState({screenSharing:!1,stream:l}),this.isLocalParticipant&&this.mediaStream){const E=this.mediaStream.getVideoElement();E&&(E.srcObject=l,console.log(`[CallParticipant] Updated local video element for ${this.userId}`))}console.log(`[CallParticipant] Screen sharing stopped for ${this.userId}`)}catch(o){throw console.error(`[CallParticipant] Failed to stop screen share for ${this.userId}:`,o),(t=(e=this.callbacks).onError)==null||t.call(e,o),o}})}getState(){const e=this.state;return this.isLocalParticipant?e.localParticipant||{userId:this.userId,videoOn:!0,audioOn:!0,screenSharing:!1}:e.participants[this.userId]||{userId:this.userId,videoOn:!0,audioOn:!0,screenSharing:!1}}getUserId(){return this.userId}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,o]of this.peerConnections)e[t]=o.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.userId} to ${e}`))}updateState(e){var t,o;const l=this.getState();if(Object.keys(e).some(E=>l[E]!==e[E])){const E=Kr(Kr({},l),e);this.isLocalParticipant&&this.state.setLocalParticipant(E),this.state.updateParticipant(this.userId,e),(o=(t=this.callbacks).onStateChanged)==null||o.call(t,this.userId,e)}}getDebugInfo(){var e;return{userId:this.userId,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.userId}`),this.state.removeParticipant(this.userId);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.userId} cleanup completed`)}}var Zr={exports:{}},go;function as(){return go||(go=1,function(n){function e(t,o){var l="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";(function(v){typeof RecordRTC=="undefined"&&v&&typeof window=="undefined"&&typeof globalThis!="undefined"&&(globalThis.navigator={userAgent:l,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"&&(v.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var p={getContext:function(){return p},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return p},v.HTMLVideoElement=function(){}),typeof location=="undefined"&&(v.location={protocol:"file:",href:"",hash:""}),typeof screen=="undefined"&&(v.screen={width:0,height:0}),typeof A=="undefined"&&(v.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),v.window=globalThis)})(typeof globalThis!="undefined"?globalThis:null),o=o||"multi-streams-mixer";var c=[],E=!1,a=document.createElement("canvas"),f=a.getContext("2d");a.style.opacity=0,a.style.position="absolute",a.style.zIndex=-1,a.style.top="-1000em",a.style.left="-1000em",a.className=o,(document.body||document.documentElement).appendChild(a),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var u=this,w=window.AudioContext;typeof w=="undefined"&&(typeof webkitAudioContext!="undefined"&&(w=webkitAudioContext),typeof mozAudioContext!="undefined"&&(w=mozAudioContext));var A=window.URL;typeof A=="undefined"&&typeof webkitURL!="undefined"&&(A=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 C=window.MediaStream;typeof C=="undefined"&&typeof webkitMediaStream!="undefined"&&(C=webkitMediaStream),typeof C!="undefined"&&typeof C.prototype.stop=="undefined"&&(C.prototype.stop=function(){this.getTracks().forEach(function(v){v.stop()})});var j={};typeof w!="undefined"?j.AudioContext=w:typeof webkitAudioContext!="undefined"&&(j.AudioContext=webkitAudioContext);function y(v,p){"srcObject"in p?p.srcObject=v:"mozSrcObject"in p?p.mozSrcObject=v:p.srcObject=v}this.startDrawingFrames=function(){I()};function I(){if(!E){var v=c.length,p=!1,B=[];if(c.forEach(function(F){F.stream||(F.stream={}),F.stream.fullcanvas?p=F:B.push(F)}),p)a.width=p.stream.width,a.height=p.stream.height;else if(B.length){a.width=v>1?B[0].width*2:B[0].width;var U=1;(v===3||v===4)&&(U=2),(v===5||v===6)&&(U=3),(v===7||v===8)&&(U=4),(v===9||v===10)&&(U=5),a.height=B[0].height*U}else a.width=u.width||360,a.height=u.height||240;p&&p instanceof HTMLVideoElement&&_(p),B.forEach(function(F,J){_(F,J)}),setTimeout(I,u.frameInterval)}}function _(v,p){if(!E){var B=0,U=0,F=v.width,J=v.height;p===1&&(B=v.width),p===2&&(U=v.height),p===3&&(B=v.width,U=v.height),p===4&&(U=v.height*2),p===5&&(B=v.width,U=v.height*2),p===6&&(U=v.height*3),p===7&&(B=v.width,U=v.height*3),typeof v.stream.left!="undefined"&&(B=v.stream.left),typeof v.stream.top!="undefined"&&(U=v.stream.top),typeof v.stream.width!="undefined"&&(F=v.stream.width),typeof v.stream.height!="undefined"&&(J=v.stream.height),f.drawImage(v,B,U,F,J),typeof v.stream.onRender=="function"&&v.stream.onRender(f,B,U,F,J,p)}}function h(){E=!1;var v=b(),p=P();return p&&p.getTracks().filter(function(B){return B.kind==="audio"}).forEach(function(B){v.addTrack(B)}),t.forEach(function(B){B.fullcanvas}),v}function b(){R();var v;"captureStream"in a?v=a.captureStream():"mozCaptureStream"in a?v=a.mozCaptureStream():u.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var p=new C;return v.getTracks().filter(function(B){return B.kind==="video"}).forEach(function(B){p.addTrack(B)}),a.stream=p,p}function P(){j.AudioContextConstructor||(j.AudioContextConstructor=new j.AudioContext),u.audioContext=j.AudioContextConstructor,u.audioSources=[],u.useGainNode===!0&&(u.gainNode=u.audioContext.createGain(),u.gainNode.connect(u.audioContext.destination),u.gainNode.gain.value=0);var v=0;if(t.forEach(function(p){if(p.getTracks().filter(function(U){return U.kind==="audio"}).length){v++;var B=u.audioContext.createMediaStreamSource(p);u.useGainNode===!0&&B.connect(u.gainNode),u.audioSources.push(B)}}),!!v)return u.audioDestination=u.audioContext.createMediaStreamDestination(),u.audioSources.forEach(function(p){p.connect(u.audioDestination)}),u.audioDestination.stream}function S(v){var p=document.createElement("video");return y(v,p),p.className=o,p.muted=!0,p.volume=0,p.width=v.width||u.width||360,p.height=v.height||u.height||240,p.play(),p}this.appendStreams=function(v){if(!v)throw"First parameter is required.";v instanceof Array||(v=[v]),v.forEach(function(p){var B=new C;if(p.getTracks().filter(function(J){return J.kind==="video"}).length){var U=S(p);U.stream=p,c.push(U),B.addTrack(p.getTracks().filter(function(J){return J.kind==="video"})[0])}if(p.getTracks().filter(function(J){return J.kind==="audio"}).length){var F=u.audioContext.createMediaStreamSource(p);u.audioDestination=u.audioContext.createMediaStreamDestination(),F.connect(u.audioDestination),B.addTrack(u.audioDestination.stream.getTracks().filter(function(J){return J.kind==="audio"})[0])}t.push(B)})},this.releaseStreams=function(){c=[],E=!0,u.gainNode&&(u.gainNode.disconnect(),u.gainNode=null),u.audioSources.length&&(u.audioSources.forEach(function(v){v.disconnect()}),u.audioSources=[]),u.audioDestination&&(u.audioDestination.disconnect(),u.audioDestination=null),u.audioContext&&u.audioContext.close(),u.audioContext=null,f.clearRect(0,0,a.width,a.height),a.stream&&(a.stream.stop(),a.stream=null)},this.resetVideoStreams=function(v){v&&!(v instanceof Array)&&(v=[v]),R(v)};function R(v){c=[],v=v||t,v.forEach(function(p){if(p.getTracks().filter(function(U){return U.kind==="video"}).length){var B=S(p);B.stream=p,c.push(B)}})}this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=h}typeof RecordRTC=="undefined"&&(n.exports=e)}(Zr)),Zr.exports}var ss=as();const ls=yt(ss);var cs=St();const us=yt(cs);class fs extends us{constructor(t,o=navigator.language){super();Te(this,"track",null);Te(this,"trackId",null);Te(this,"recognition",null);Te(this,"recognizing",!1);Te(this,"transcripts",[]);Te(this,"startTime",0);Te(this,"endTime",0);Te(this,"currentStamp",0);Te(this,"start",()=>(this.recognition.start(),this.recognition.stream=this.track,this.recognizing=!0,this.startTime=performance.now(),this));Te(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=o,this.track=t,this.recognition.onstart=this.emit("start"),this.recognition.onend=()=>this.emit("end"),this.recognition.onresult=l=>{const{results:c,resultIndex:E}=l;let a="";if(c[E].isFinal&&c[E][0].transcript){const f={sentence:c[E][0].transcript,confidence:c[E][0].confidence,timeStamp:this.currentStamp,endTimeStamp:new Date().getTime()};this.transcripts.push(f),this.emit("sentence",f)}else this.currentStamp=new Date().getTime(),a+=c[E][0].transcript,this.emit("interim",{sentence:a,timeStamp:this.currentStamp});this.emit("result",l)})}}var ds=Object.defineProperty,yo=Object.getOwnPropertySymbols,hs=Object.prototype.hasOwnProperty,ps=Object.prototype.propertyIsEnumerable,Qr=(n,e,t)=>e in n?ds(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,gs=(n,e)=>{for(var t in e||(e={}))hs.call(e,t)&&Qr(n,t,e[t]);if(yo)for(var t of yo(e))ps.call(e,t)&&Qr(n,t,e[t]);return n},We=(n,e,t)=>Qr(n,typeof e!="symbol"?e+"":e,t),en=(n,e,t)=>new Promise((o,l)=>{var c=f=>{try{a(t.next(f))}catch(u){l(u)}},E=f=>{try{a(t.throw(f))}catch(u){l(u)}},a=f=>f.done?o(f.value):Promise.resolve(f.value).then(c,E);a((t=t.apply(n,e)).next())});class mo{constructor(e={},t={}){We(this,"mixer",null),We(this,"recorder",null),We(this,"localTranscriber",null),We(this,"isRecording",!1),We(this,"config"),We(this,"callbacks"),this.config=gs({mimeType:"video/webm;codecs=vp8,opus",videoBitsPerSecond:1e6,audioBitsPerSecond:128e3,interval:1e3},e),this.callbacks=t}startRecording(e,t){return en(this,null,function*(){var o,l,c,E;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 ls(e),this.mixer.frameInterval=1,this.mixer.startDrawingFrames();const a=e[0];a&&a.getAudioTracks().length>0&&(this.localTranscriber=new fs(a)),MediaRecorder.isTypeSupported(this.config.mimeType)||(console.warn("[CallRecorder] Preferred mime type not supported, falling back to default"),this.config.mimeType="video/webm");const f=this.mixer.getMixedStream();this.recorder=new MediaRecorder(f,{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(),(l=(o=this.callbacks).onRecordingStarted)==null||l.call(o,t),console.log("[CallRecorder] Recording started successfully")}catch(a){throw console.error("[CallRecorder] Failed to start recording:",a),(E=(c=this.callbacks).onError)==null||E.call(c,a),a}})}stopRecording(){return en(this,null,function*(){var e,t;try{if(console.log("[CallRecorder] Stopping recording"),!this.isRecording||!this.recorder)return console.warn("[CallRecorder] No active recording to stop"),[];this.recorder.stop(),this.isRecording=!1;let o=[];return this.localTranscriber&&(this.localTranscriber.stop(),o=this.localTranscriber.transcripts||[]),this.mixer&&this.mixer.releaseStreams(),console.log("[CallRecorder] Recording stopped successfully"),o}catch(o){return console.error("[CallRecorder] Failed to stop recording:",o),(t=(e=this.callbacks).onError)==null||t.call(e,o),[]}})}resetVideoStreams(e){this.mixer&&(this.mixer.resetVideoStreams(e),console.log("[CallRecorder] Video streams reset"))}setupRecorderEventHandlers(e){this.recorder&&(this.recorder.ondataavailable=t=>{var o,l;t.data&&t.data.size>0&&((l=(o=this.callbacks).onRecordingChunk)==null||l.call(o,t.data,e))},this.recorder.onstart=()=>{console.log("[CallRecorder] MediaRecorder started")},this.recorder.onstop=()=>{var t,o;console.log("[CallRecorder] MediaRecorder stopped"),(o=(t=this.callbacks).onRecordingStopped)==null||o.call(t,e)},this.recorder.onerror=t=>{var o,l;console.error("[CallRecorder] MediaRecorder error:",t),(l=(o=this.callbacks).onError)==null||l.call(o,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 en(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 ys=Object.defineProperty,ms=Object.defineProperties,vs=Object.getOwnPropertyDescriptors,vo=Object.getOwnPropertySymbols,bs=Object.prototype.hasOwnProperty,ws=Object.prototype.propertyIsEnumerable,tn=(n,e,t)=>e in n?ys(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ss=(n,e)=>{for(var t in e||(e={}))bs.call(e,t)&&tn(n,t,e[t]);if(vo)for(var t of vo(e))ws.call(e,t)&&tn(n,t,e[t]);return n},_s=(n,e)=>ms(n,vs(e)),Pe=(n,e,t)=>tn(n,typeof e!="symbol"?e+"":e,t),me=(n,e,t)=>new Promise((o,l)=>{var c=f=>{try{a(t.next(f))}catch(u){l(u)}},E=f=>{try{a(t.throw(f))}catch(u){l(u)}},a=f=>f.done?o(f.value):Promise.resolve(f.value).then(c,E);a((t=t.apply(n,e)).next())});class bo extends ho{constructor(e,t={}){if(super(we),Pe(this,"config"),Pe(this,"callbacks"),Pe(this,"socket"),Pe(this,"localParticipant",null),Pe(this,"participants",new Map),Pe(this,"recorder",null),Pe(this,"iceServers",[]),Pe(this,"isInitialized",!1),Pe(this,"listenersSetup",!1),Pe(this,"roomId"),Pe(this,"eventListeners",new Map),this.roomId=e.roomId,!this.roomId)throw new Error("roomId must be provided in config");this.config=_s(Ss({maxParticipants:4,debug:!1,socketPath:"/apis/video-call",mediaConfig:{video:!0,audio:!0}},e),{roomId:this.roomId}),this.callbacks=t,this.socket=new cn(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,tokenLength:this.config.token.length,maxParticipants:this.config.maxParticipants})}initialize(){return me(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 me(this,arguments,function*(e=this.config.mediaConfig){var t,o;try{if(console.log("[PeersCaller] Starting call..."),this.isInitialized||(yield this.initialize()),this.localParticipant&&!this.localParticipant.getCurrentStream()){const c={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(c)}this.state.setIsCalling(!0),this.state.setCallStatus("connecting"),console.log("[PeersCaller] Starting call for room:",this.config.roomId);const l=yield this.socket.startCall(this.config.roomId);if(console.log("[PeersCaller] Received call.start response:",l),l.success)this.state.setCallStatus("connected"),l.participants.forEach(c=>{c!==this.config.userId&&this.handleParticipantJoined(c)}),console.log("[PeersCaller] Call started successfully"),(o=(t=this.callbacks).onCallStarted)==null||o.call(t,l);else{this.state.setIsCalling(!1),this.state.setCallStatus("idle");const c="Failed to start call on server";throw this.handleError("SIGNALING_ERROR",c),console.error("[PeersCaller] Call start failed:",c),new Error(c)}}catch(l){throw console.error("[PeersCaller] Failed to start call:",l),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start call: ${l}`),l}})}joinCall(){return me(this,arguments,function*(e=this.config.mediaConfig){try{console.log("[PeersCaller] Joining call..."),this.isInitialized||(yield this.initialize());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 l={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:",l),yield this.localParticipant.initialize(l)}console.log("[PeersCaller] Joining call for room:",this.config.roomId);const o=yield this.socket.joinRoom(this.config.roomId);console.log("[PeersCaller] Received call.join response:",o),this.state.setCallStatus("connected"),this.state.setIsCalling(!0),o.participants.forEach(l=>{l!==this.config.userId&&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 me(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 me(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 me(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 me(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 me(this,null,function*(){var o;try{if(console.log("[PeersCaller] Starting recording..."),this.state.isRecording){console.warn("[PeersCaller] Recording already in progress");return}const l=[],c=(o=this.localParticipant)==null?void 0:o.getCurrentStream();c&&l.push(c);for(const E of this.participants.values()){const a=E.getAllRemoteStreams();l.push(...a.values())}if(l.length===0)throw new Error("No streams available for recording");this.recorder=new mo(t,{onRecordingStarted:E=>{this.socket.startRecording(this.config.roomId,E.id)},onRecordingChunk:(E,a)=>{this.socket.sendRecordingChunk(this.config.roomId,a.id,E)},onRecordingStopped:E=>{this.socket.endRecording(this.config.roomId,E.id)},onTranscriptReceived:E=>{this.socket.sendTranscript(this.config.roomId,E.text)},onError:E=>{this.handleError("RECORDING_FAILED",E.message)}}),yield this.recorder.startRecording(l,e),this.state.setIsRecording(!0),console.log("[PeersCaller] Recording started successfully")}catch(l){throw console.error("[PeersCaller] Failed to start recording:",l),this.handleError("RECORDING_FAILED",`Failed to start recording: ${l}`),l}})}stopRecording(){return me(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(){console.log("[PeersCaller] Cleaning up..."),this.state.isCalling&&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 me(this,null,function*(){this.localParticipant=new Xr(this.config.userId,{onSignal:(e,t,o)=>{this.forwardSignalToServer(e,t,o)},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=_=>{this.handleParticipantJoined(_.userId)};this.socket.on("call.participant.joined",e),this.eventListeners.set("call.participant.joined",e);const t=_=>{this.handleParticipantLeft(_.userId)};this.socket.on("call.participant.left",t),this.eventListeners.set("call.participant.left",t);const o=_=>{_.participants.forEach(h=>{h!==this.config.userId&&this.handleParticipantJoined(h)})};this.socket.on("call.participants",o),this.eventListeners.set("call.participants",o);const l=()=>{this.state.setIsCalling(!1)};this.socket.on("call.left",l),this.eventListeners.set("call.left",l);const c=_=>{var h,b;console.error("[PeersCaller] Server error:",_),(b=(h=this.callbacks).onError)==null||b.call(h,_.error,_.message)};this.socket.on("call.error",c),this.eventListeners.set("call.error",c);const E=_=>{this.handleOffer(_.from,_.offer)};this.socket.on("call.offer",E),this.eventListeners.set("call.offer",E);const a=_=>{this.handleAnswer(_.from,_.answer)};this.socket.on("call.answer",a),this.eventListeners.set("call.answer",a);const f=_=>{this.handleCandidate(_.from,_.candidate)};this.socket.on("call.candidate",f),this.eventListeners.set("call.candidate",f);const u=_=>{this.handleParticipantStateUpdate(_.from,_.state)};this.socket.on("call.state",u),this.eventListeners.set("call.state",u);const w=_=>{this.handleCallEnded(_)};this.socket.on("call.ended",w),this.eventListeners.set("call.ended",w);const A=_=>{this.handleCallStatusChanged(_)};this.socket.on("call.status.changed",A),this.eventListeners.set("call.status.changed",A);const C=_=>{console.log("[PeersCaller] Recording started:",_.recordingId),this.state.setIsRecording(!0)};this.socket.on("call.recording.start",C),this.eventListeners.set("call.recording.start",C);const j=_=>{console.log("[PeersCaller] Recording chunk received:",_)};this.socket.on("call.recording.chunk.received",j),this.eventListeners.set("call.recording.chunk.received",j);const y=_=>{console.log("[PeersCaller] Recording ended:",_.recordingId),this.state.setIsRecording(!1)};this.socket.on("call.recording.end",y),this.eventListeners.set("call.recording.end",y);const I=_=>{console.log("[PeersCaller] Transcript received:",_)};this.socket.on("call.transcript",I),this.eventListeners.set("call.transcript",I),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 me(this,null,function*(){var t,o;try{if(e===this.config.userId||this.participants.has(e))return;if(this.participants.size>=this.config.maxParticipants-1){console.warn("[PeersCaller] Maximum participants reached");return}console.log(`[PeersCaller] Participant ${e} joined`);const l=new Xr(e,{onStreamReceived:(a,f)=>{var u,w;(w=(u=this.callbacks).onStreamReceived)==null||w.call(u,a,f)},onPeerConnected:a=>{console.log(`[PeersCaller] Peer connection established with ${a}`)},onPeerDisconnected:a=>{this.handleParticipantLeft(a)},onSignal:(a,f,u)=>{this.forwardSignalToServer(a,f,u)},onError:a=>{this.handleError("PEER_CONNECTION_FAILED",a.message)}},!1);if(this.participants.set(e,l),!this.localParticipant){console.error("[PeersCaller] Cannot create peer connection - local participant not initialized");return}const c=this.config.userId<e,E={iceServers:this.iceServers,initiator:c};yield this.localParticipant.createPeerConnection(e,E,c),(o=(t=this.callbacks).onParticipantJoined)==null||o.call(t,{userId:e,videoOn:!0,audioOn:!0,screenSharing:!1})}catch(l){console.error(`[PeersCaller] Failed to handle participant ${e} joining:`,l)}})}checkCallStatus(){return me(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 me(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received offer from ${e} but local participant not initialized`);return}const o=this.localParticipant.getPeerConnection(e);o?(console.log(`[PeersCaller] Processing offer from ${e}`),o.signal({type:"offer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for offer from ${e}`)}catch(o){console.error(`[PeersCaller] Failed to handle offer from ${e}:`,o)}})}handleAnswer(e,t){return me(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received answer from ${e} but local participant not initialized`);return}const o=this.localParticipant.getPeerConnection(e);o?(console.log(`[PeersCaller] Processing answer from ${e}`),o.signal({type:"answer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for answer from ${e}`)}catch(o){console.error(`[PeersCaller] Failed to handle answer from ${e}:`,o)}})}handleCandidate(e,t){return me(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received candidate from ${e} but local participant not initialized`);return}const o=this.localParticipant.getPeerConnection(e);o?(console.log(`[PeersCaller] Processing candidate from ${e}`),o.signal({type:"candidate",candidate:t})):console.warn(`[PeersCaller] No peer connection found for candidate from ${e}`)}catch(o){console.error(`[PeersCaller] Failed to handle candidate from ${e}:`,o)}})}handleParticipantStateUpdate(e,t){var o,l;this.state.updateParticipant(e,t),(l=(o=this.callbacks).onParticipantStateChanged)==null||l.call(o,e,t)}handleParticipantLeft(e){var t,o;console.log(`[PeersCaller] Participant ${e} left`);const l=this.participants.get(e);l&&(l.cleanup(),this.participants.delete(e)),this.state.removeParticipant(e),(o=(t=this.callbacks).onParticipantLeft)==null||o.call(t,e)}handleCallEnded(e){return me(this,null,function*(){var t,o;console.log(`[PeersCaller] Call ended by ${e.endedBy}, 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(),(o=(t=this.callbacks).onCallEnded)==null||o.call(t,e),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,o;console.log("[PeersCaller] Call status changed:",e),this.state.setCallStatusInfo(e),(o=(t=this.callbacks).onCallStatusChanged)==null||o.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 o,l;console.error(`[PeersCaller] ${e}: ${t}`),this.state.setError(e,t),(l=(o=this.callbacks).onError)==null||l.call(o,e,t)}fetchIceServers(){return me(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,o){try{switch(console.log(`[PeersCaller] Forwarding signal from ${e} to ${t}:`,o.type),o.type){case"offer":this.socket.sendOffer(t,o,this.config.roomId);break;case"answer":this.socket.sendAnswer(t,o,this.config.roomId);break;case"candidate":this.socket.sendCandidate(t,o.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: ${o.type} - this may indicate a new signal type that needs handling`),this.config.debug&&console.log("[PeersCaller] Unknown signal data:",o);break}}catch(l){console.error(`[PeersCaller] Failed to forward signal from ${e} to ${t}:`,l),this.handleError("SIGNALING_ERROR",`Failed to forward signal: ${l}`)}}}var ke=(n,e,t)=>new Promise((o,l)=>{var c=f=>{try{a(t.next(f))}catch(u){l(u)}},E=f=>{try{a(t.throw(f))}catch(u){l(u)}},a=f=>f.done?o(f.value):Promise.resolve(f.value).then(c,E);a((t=t.apply(n,e)).next())});function Cs(n){const[e,t]=Q.useState(null),[o,l]=Q.useState(!1),c=Q.useRef(!1),E=we(p=>p),a=Object.values(we(p=>p.participants)),f=we(p=>p.localParticipant),u=we(p=>p.callStatus==="connected"),w=we(p=>p.isRecording),A=we(p=>p.error),C=Q.useCallback(()=>ke(null,null,function*(){if(!(c.current||e))try{c.current=!0;const p=new bo(n,n.callbacks);yield p.initialize(),t(p),l(!0)}catch(p){throw console.error("[useVideoCall] Failed to initialize:",p),c.current=!1,p}}),[n,e]),j=Q.useCallback(p=>ke(null,null,function*(){if(!e){yield C();return}return e.startCall(p)}),[e,C]),y=Q.useCallback(p=>ke(null,null,function*(){if(!e){yield C();return}return e.joinCall(p)}),[e,C]),I=Q.useCallback(()=>{e==null||e.endCall()},[e]),_=Q.useCallback(p=>{e==null||e.toggleAudio(p)},[e]),h=Q.useCallback(p=>{e==null||e.toggleVideo(p)},[e]),b=Q.useCallback(()=>ke(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startScreenShare()}),[e]),P=Q.useCallback(()=>ke(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopScreenShare()}),[e]),S=Q.useCallback(p=>ke(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startRecording(p)}),[e]),R=Q.useCallback(()=>ke(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopRecording()}),[e]),v=Q.useCallback(()=>{e&&(e.cleanup(),t(null),l(!1),c.current=!1)},[e]);return Q.useEffect(()=>{n.autoInitialize&&!o&&!c.current&&C().catch(console.error)},[n.autoInitialize,o,C]),Q.useEffect(()=>()=>{v()},[v]),{initialize:C,startCall:j,joinCall:y,endCall:I,toggleAudio:_,toggleVideo:h,startScreenShare:b,stopScreenShare:P,startRecording:S,stopRecording:R,callState:E,participants:a,localParticipant:f,isConnected:u,isRecording:w,error:A,cleanup:v,peersCaller:e}}function Es(n){const[e,t]=Q.useState(null),[o,l]=Q.useState(null),c=we(E=>E.participants[n]);return Q.useEffect(()=>{var E;if(c!=null&&c.stream){if(l(c.stream),!e){const a=document.createElement("video");a.autoplay=!0,a.playsInline=!0,a.muted=n===((E=we.getState().localParticipant)==null?void 0:E.userId),t(a)}e&&(e.srcObject=c.stream)}},[c==null?void 0:c.stream,n,e]),Q.useEffect(()=>()=>{e&&(e.srcObject=null)},[e]),{videoElement:e,stream:o,participant:c}}function Rs(){const n=we();return{roomId:n.roomId,participants:n.participants,localParticipant:n.localParticipant,isCalling:n.isCalling,isRecording:n.isRecording,recordLoading:n.recordLoading,callStatus:n.callStatus,error:n.error,participantCount:Object.keys(n.participants).length,isConnected:n.callStatus==="connected",hasError:!!n.error}}function Ps(){const[n,e]=Q.useState({videoDevices:[],audioDevices:[]}),[t,o]=Q.useState({camera:null,microphone:null}),l=Q.useCallback(()=>ke(null,null,function*(){try{const a=yield navigator.mediaDevices.enumerateDevices();e({videoDevices:a.filter(f=>f.kind==="videoinput"),audioDevices:a.filter(f=>f.kind==="audioinput")})}catch(a){console.error("[useMediaDevices] Failed to get devices:",a)}}),[]),c=Q.useCallback(()=>ke(null,null,function*(){try{if("permissions"in navigator){const a=yield navigator.permissions.query({name:"camera"}),f=yield navigator.permissions.query({name:"microphone"});o({camera:a.state,microphone:f.state})}}catch(a){console.error("[useMediaDevices] Failed to check permissions:",a)}}),[]),E=Q.useCallback(()=>ke(null,null,function*(){try{return(yield navigator.mediaDevices.getUserMedia({video:!0,audio:!0})).getTracks().forEach(f=>f.stop()),yield c(),yield l(),!0}catch(a){return console.error("[useMediaDevices] Failed to request permissions:",a),!1}}),[c,l]);return Q.useEffect(()=>{var a;l(),c();const f=()=>{l()};return(a=navigator.mediaDevices)==null||a.addEventListener("devicechange",f),()=>{var u;(u=navigator.mediaDevices)==null||u.removeEventListener("devicechange",f)}},[l,c]),{devices:n,permissions:t,getDevices:l,checkPermissions:c,requestPermissions:E}}function As(){const[n,e]=Q.useState({webRTC:!1,getUserMedia:!1,getDisplayMedia:!1,mediaRecorder:!1,speechRecognition:!1});return Q.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:n,isSupported:Object.values(n).every(Boolean),unsupportedFeatures:Object.entries(n).filter(([,t])=>!t).map(([t])=>t)}}function Ts(n=""){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return n?`${n}_${e}_${t}`:`${e}_${t}`}const Is=()=>`peer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,ks=n=>!n||typeof n!="string"?!1:/^peer_\d+_[a-z0-9]{1,9}$/.test(n),Os=n=>{var e,t;return{video:(e=n.video)!=null?e:!0,audio:(t=n.audio)!=null?t:!0}};function Ms(n,e,t){const o=`[${n}] ${e}`,l=new Error(o);return t&&(l.details=t),l}function Bs(){const n={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(n).filter(([,t])=>!t).map(([t])=>t);return{supported:e.length===0,features:n,missingFeatures:e}}const Ls=()=>{try{return typeof window!="undefined"&&typeof window.RTCPeerConnection!="undefined"&&typeof navigator!="undefined"&&typeof navigator.mediaDevices!="undefined"&&typeof navigator.mediaDevices.getUserMedia!="undefined"}catch(n){return!1}};function Ns(){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"}]}Y.CallMediaStream=un,Y.CallParticipant=Xr,Y.CallPeerConnection=io,Y.CallRecorder=mo,Y.CallSocket=cn,Y.PeersCaller=bo,Y.canAcceptMoreParticipants=Ka,Y.checkWebRTCSupport=Bs,Y.formatError=Ms,Y.formatMediaConstraints=Os,Y.generateId=Ts,Y.generatePeerId=Is,Y.getDefaultIceServers=Ns,Y.getParticipant=fo,Y.getParticipantList=Ya,Y.isParticipantConnected=Ja,Y.isValidPeerId=ks,Y.isWebRTCSupported=Ls,Y.selectCallStatus=Ua,Y.selectCallStatusError=za,Y.selectCallStatusInfo=Wa,Y.selectCallStatusLoading=Va,Y.selectCanJoinCall=Ga,Y.selectError=xa,Y.selectIsCallActive=Ha,Y.selectIsConnected=qa,Y.selectLocalParticipant=$a,Y.selectParticipantCount=uo,Y.selectParticipants=ja,Y.useBrowserSupport=As,Y.useCallState=Rs,Y.useCallStore=we,Y.useMediaDevices=Ps,Y.useParticipantVideo=Es,Y.useVideoCall=Cs,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
26
+ `);const P=A.state[f];if(P==null)return;JSON.stringify(u.getState())!==JSON.stringify(P)&&x(P);return}u.dispatchFromDevtools&&typeof u.dispatch=="function"&&u.dispatch(A)});case"DISPATCH":switch(m.payload.type){case"RESET":return x(b),f===void 0?h==null?void 0:h.init(u.getState()):h==null?void 0:h.init(Mt(c.name));case"COMMIT":if(f===void 0){h==null||h.init(u.getState());return}return h==null?void 0:h.init(Mt(c.name));case"ROLLBACK":return bn(m.state,A=>{if(f===void 0){x(A),h==null||h.init(u.getState());return}x(A[f]),h==null||h.init(Mt(c.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return bn(m.state,A=>{if(f===void 0){x(A);return}JSON.stringify(u.getState())!==JSON.stringify(A[f])&&x(A[f])});case"IMPORT_STATE":{const{nextLiftedState:A}=m.payload,P=(R=A.computedStates.slice(-1)[0])==null?void 0:R.state;if(!P)return;x(f===void 0?P:P[f]),h==null||h.send(null,A);return}case"PAUSE_RECORDING":return B=!B}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)};var vs=Object.defineProperty,ws=Object.defineProperties,bs=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,Fo=Object.prototype.hasOwnProperty,Uo=Object.prototype.propertyIsEnumerable,$o=(r,e,t)=>e in r?vs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,at=(r,e)=>{for(var t in e||(e={}))Fo.call(e,t)&&$o(r,t,e[t]);if(Lt)for(var t of Lt(e))Uo.call(e,t)&&$o(r,t,e[t]);return r},Sn=(r,e)=>ws(r,bs(e)),Ss=r=>typeof r=="symbol"?r:r+"",_s=(r,e)=>{var t={};for(var s in r)Fo.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&&Uo.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},je=Ie.create()(ms(r=>Sn(at({},jo),{setRoomId:e=>r({roomId:e},!1,"setRoomId"),setLocalParticipant:e=>r({localParticipant:e},!1,"setLocalParticipant"),addParticipant:e=>r(t=>({participants:Sn(at({},t.participants),{[e.userId]:e})}),!1,"addParticipant"),removeParticipant:e=>r(t=>{const s=t.participants,{[e]:u}=s;return{participants:_s(s,[Ss(e)])}},!1,"removeParticipant"),updateParticipant:(e,t)=>r(s=>({participants:Sn(at({},s.participants),{[e]:s.participants[e]?at(at({},s.participants[e]),t):at({userId:e,videoOn:!0,audioOn:!0,screenSharing:!1},t)})}),!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(at({},jo),!1,"resetCall")}),{name:"peers-caller-store",enabled:ae.env.NODE_ENV==="development"})),Es=r=>r.participants,qo=r=>Object.keys(r.participants).length,Cs=r=>r.localParticipant,Rs=r=>r.callStatus,Ps=r=>r.callStatus==="connected",Ts=r=>r.error,As=r=>r.callStatusInfo,Is=r=>r.callStatusLoading,Bs=r=>r.callStatusError,ks=r=>{var e;return((e=r.callStatusInfo)==null?void 0:e.canJoin)||!1},Os=r=>{var e;return((e=r.callStatusInfo)==null?void 0:e.hasActiveCall)||!1},xo=r=>je.getState().participants[r],Ms=r=>{const e=xo(r);return!!(e!=null&&e.stream)},Ls=()=>{const r=je.getState();return Object.values(r.participants)},Ns=(r=4)=>qo(je.getState())<r;var Ds=Object.defineProperty,Fs=(r,e,t)=>e in r?Ds(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Us=(r,e,t)=>Fs(r,e+"",t);class Wo{constructor(e){if(Us(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 $s=Object.defineProperty,js=Object.defineProperties,qs=Object.getOwnPropertyDescriptors,Go=Object.getOwnPropertySymbols,xs=Object.prototype.hasOwnProperty,Ws=Object.prototype.propertyIsEnumerable,_n=(r,e,t)=>e in r?$s(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,En=(r,e)=>{for(var t in e||(e={}))xs.call(e,t)&&_n(r,t,e[t]);if(Go)for(var t of Go(e))Ws.call(e,t)&&_n(r,t,e[t]);return r},Gs=(r,e)=>js(r,qs(e)),dt=(r,e,t)=>_n(r,typeof e!="symbol"?e+"":e,t),Nt=(r,e,t)=>new Promise((s,u)=>{var l=c=>{try{f(t.next(c))}catch(v){u(v)}},g=c=>{try{f(t.throw(c))}catch(v){u(v)}},f=c=>c.done?s(c.value):Promise.resolve(c.value).then(l,g);f((t=t.apply(r,e)).next())});class Cn extends Wo{constructor(e,t={},s=!1){super(je),dt(this,"userId"),dt(this,"mediaStream",null),dt(this,"peerConnections",new Map),dt(this,"remoteStreams",new Map),dt(this,"isLocalParticipant",!1),dt(this,"callbacks"),this.userId=e,this.callbacks=t,this.isLocalParticipant=s;const u={userId:e,videoOn:!0,audioOn:!0,screenSharing:!1};this.isLocalParticipant&&this.state.setLocalParticipant(u),this.state.addParticipant(u)}initialize(e){return Nt(this,null,function*(){var t,s;try{console.log(`[CallParticipant] Initializing participant ${this.userId}`),this.mediaStream=new jn(e);const l={stream:yield this.mediaStream.initialize(),videoElement:this.mediaStream.createVideoElement()};this.updateState(l),console.log(`[CallParticipant] Participant ${this.userId} initialized successfully`)}catch(u){throw console.error(`[CallParticipant] Failed to initialize participant ${this.userId}:`,u),(s=(t=this.callbacks).onError)==null||s.call(t,u),u}})}createPeerConnection(e,t,s){return Nt(this,null,function*(){var u,l;try{if(console.log(`[CallParticipant] Creating peer connection from ${this.userId} to ${e}`),this.peerConnections.has(e)){console.warn(`[CallParticipant] Peer connection to ${e} already exists`);return}const g={onSignal:c=>{var v,h;console.log(`[CallParticipant] Signal from ${this.userId} to ${e}:`,c.type),(h=(v=this.callbacks).onSignal)==null||h.call(v,this.userId,e,c)},onConnect:()=>{var c,v;console.log(`[CallParticipant] ${this.userId} connected to ${e}`),(v=(c=this.callbacks).onPeerConnected)==null||v.call(c,e)},onStream:c=>{var v,h;console.log(`[CallParticipant] Stream received from ${e} by ${this.userId}`),this.remoteStreams.set(e,c),this.state.updateParticipant(e,{stream:c}),(h=(v=this.callbacks).onStreamReceived)==null||h.call(v,e,c)},onClose:()=>{var c,v;console.log(`[CallParticipant] Connection closed between ${this.userId} and ${e}`),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),(v=(c=this.callbacks).onPeerDisconnected)==null||v.call(c,e)},onError:c=>{var v,h;console.error(`[CallParticipant] Peer connection error between ${this.userId} and ${e}:`,c),(h=(v=this.callbacks).onError)==null||h.call(v,c)}},f=new No(e,Gs(En({},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.userId} to ${e}:`,g),(l=(u=this.callbacks).onError)==null||l.call(u,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.userId}`);const s=yield this.mediaStream.startScreenShare(),u=this.mediaStream.getScreenVideoTrack(),l=this.mediaStream.getCameraVideoTrack();if(!u)throw new Error("Failed to get screen video track");for(const[g,f]of this.peerConnections)l?(f.replaceTrack(l,u),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.userId}`)}catch(s){throw console.error(`[CallParticipant] Failed to start screen share for ${this.userId}:`,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.userId}`);const s=this.mediaStream.getScreenVideoTrack();console.log("[CallParticipant] Screen video track found:",!!s);const u=yield this.mediaStream.stopScreenShare(),l=this.mediaStream.getCameraVideoTrack();if(console.log("[CallParticipant] Camera stream:",!!u),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(u))}catch(c){console.warn(`[CallParticipant] Failed to replace track for ${g}, trying stream replacement:`,c)}if(this.updateState({screenSharing:!1,stream:u}),this.isLocalParticipant&&this.mediaStream){const g=this.mediaStream.getVideoElement();g&&(g.srcObject=u,console.log(`[CallParticipant] Updated local video element for ${this.userId}`))}console.log(`[CallParticipant] Screen sharing stopped for ${this.userId}`)}catch(s){throw console.error(`[CallParticipant] Failed to stop screen share for ${this.userId}:`,s),(t=(e=this.callbacks).onError)==null||t.call(e,s),s}})}getState(){const e=this.state;return this.isLocalParticipant?e.localParticipant||{userId:this.userId,videoOn:!0,audioOn:!0,screenSharing:!1}:e.participants[this.userId]||{userId:this.userId,videoOn:!0,audioOn:!0,screenSharing:!1}}getUserId(){return this.userId}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.userId} to ${e}`))}updateState(e){var t,s;const u=this.getState();if(Object.keys(e).some(g=>u[g]!==e[g])){const g=En(En({},u),e);this.isLocalParticipant&&this.state.setLocalParticipant(g),this.state.updateParticipant(this.userId,e),(s=(t=this.callbacks).onStateChanged)==null||s.call(t,this.userId,e)}}getDebugInfo(){var e;return{userId:this.userId,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.userId}`),this.state.removeParticipant(this.userId);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.userId} cleanup completed`)}}var Rn={exports:{}},Vo;function Vs(){return Vo||(Vo=1,function(r){function e(t,s){var u="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:u,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 C={getContext:function(){return C},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return C},S.HTMLVideoElement=function(){}),typeof location=="undefined"&&(S.location={protocol:"file:",href:"",hash:""}),typeof screen=="undefined"&&(S.screen={width:0,height:0}),typeof I=="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"),c=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 v=this,h=window.AudioContext;typeof h=="undefined"&&(typeof webkitAudioContext!="undefined"&&(h=webkitAudioContext),typeof mozAudioContext!="undefined"&&(h=mozAudioContext));var I=window.URL;typeof I=="undefined"&&typeof webkitURL!="undefined"&&(I=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 B=window.MediaStream;typeof B=="undefined"&&typeof webkitMediaStream!="undefined"&&(B=webkitMediaStream),typeof B!="undefined"&&typeof B.prototype.stop=="undefined"&&(B.prototype.stop=function(){this.getTracks().forEach(function(S){S.stop()})});var x={};typeof h!="undefined"?x.AudioContext=h:typeof webkitAudioContext!="undefined"&&(x.AudioContext=webkitAudioContext);function b(S,C){"srcObject"in C?C.srcObject=S:"mozSrcObject"in C?C.mozSrcObject=S:C.srcObject=S}this.startDrawingFrames=function(){N()};function N(){if(!g){var S=l.length,C=!1,M=[];if(l.forEach(function(X){X.stream||(X.stream={}),X.stream.fullcanvas?C=X:M.push(X)}),C)f.width=C.stream.width,f.height=C.stream.height;else if(M.length){f.width=S>1?M[0].width*2:M[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=M[0].height*W}else f.width=v.width||360,f.height=v.height||240;C&&C instanceof HTMLVideoElement&&T(C),M.forEach(function(X,re){T(X,re)}),setTimeout(N,v.frameInterval)}}function T(S,C){if(!g){var M=0,W=0,X=S.width,re=S.height;C===1&&(M=S.width),C===2&&(W=S.height),C===3&&(M=S.width,W=S.height),C===4&&(W=S.height*2),C===5&&(M=S.width,W=S.height*2),C===6&&(W=S.height*3),C===7&&(M=S.width,W=S.height*3),typeof S.stream.left!="undefined"&&(M=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),c.drawImage(S,M,W,X,re),typeof S.stream.onRender=="function"&&S.stream.onRender(c,M,W,X,re,C)}}function m(){g=!1;var S=R(),C=A();return C&&C.getTracks().filter(function(M){return M.kind==="audio"}).forEach(function(M){S.addTrack(M)}),t.forEach(function(M){M.fullcanvas}),S}function R(){k();var S;"captureStream"in f?S=f.captureStream():"mozCaptureStream"in f?S=f.mozCaptureStream():v.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var C=new B;return S.getTracks().filter(function(M){return M.kind==="video"}).forEach(function(M){C.addTrack(M)}),f.stream=C,C}function A(){x.AudioContextConstructor||(x.AudioContextConstructor=new x.AudioContext),v.audioContext=x.AudioContextConstructor,v.audioSources=[],v.useGainNode===!0&&(v.gainNode=v.audioContext.createGain(),v.gainNode.connect(v.audioContext.destination),v.gainNode.gain.value=0);var S=0;if(t.forEach(function(C){if(C.getTracks().filter(function(W){return W.kind==="audio"}).length){S++;var M=v.audioContext.createMediaStreamSource(C);v.useGainNode===!0&&M.connect(v.gainNode),v.audioSources.push(M)}}),!!S)return v.audioDestination=v.audioContext.createMediaStreamDestination(),v.audioSources.forEach(function(C){C.connect(v.audioDestination)}),v.audioDestination.stream}function P(S){var C=document.createElement("video");return b(S,C),C.className=s,C.muted=!0,C.volume=0,C.width=S.width||v.width||360,C.height=S.height||v.height||240,C.play(),C}this.appendStreams=function(S){if(!S)throw"First parameter is required.";S instanceof Array||(S=[S]),S.forEach(function(C){var M=new B;if(C.getTracks().filter(function(re){return re.kind==="video"}).length){var W=P(C);W.stream=C,l.push(W),M.addTrack(C.getTracks().filter(function(re){return re.kind==="video"})[0])}if(C.getTracks().filter(function(re){return re.kind==="audio"}).length){var X=v.audioContext.createMediaStreamSource(C);v.audioDestination=v.audioContext.createMediaStreamDestination(),X.connect(v.audioDestination),M.addTrack(v.audioDestination.stream.getTracks().filter(function(re){return re.kind==="audio"})[0])}t.push(M)})},this.releaseStreams=function(){l=[],g=!0,v.gainNode&&(v.gainNode.disconnect(),v.gainNode=null),v.audioSources.length&&(v.audioSources.forEach(function(S){S.disconnect()}),v.audioSources=[]),v.audioDestination&&(v.audioDestination.disconnect(),v.audioDestination=null),v.audioContext&&v.audioContext.close(),v.audioContext=null,c.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]),k(S)};function k(S){l=[],S=S||t,S.forEach(function(C){if(C.getTracks().filter(function(W){return W.kind==="video"}).length){var M=P(C);M.stream=C,l.push(M)}})}this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=m}typeof RecordRTC=="undefined"&&(r.exports=e)}(Rn)),Rn.exports}var zs=Vs();const Hs=xt(zs);var Js=Ht();const Ys=xt(Js);class Ks extends Ys{constructor(t,s=navigator.language){super();ze(this,"track",null);ze(this,"trackId",null);ze(this,"recognition",null);ze(this,"recognizing",!1);ze(this,"transcripts",[]);ze(this,"startTime",0);ze(this,"endTime",0);ze(this,"currentStamp",0);ze(this,"start",()=>(this.recognition.start(),this.recognition.stream=this.track,this.recognizing=!0,this.startTime=performance.now(),this));ze(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=u=>{const{results:l,resultIndex:g}=u;let f="";if(l[g].isFinal&&l[g][0].transcript){const c={sentence:l[g][0].transcript,confidence:l[g][0].confidence,timeStamp:this.currentStamp,endTimeStamp:new Date().getTime()};this.transcripts.push(c),this.emit("sentence",c)}else this.currentStamp=new Date().getTime(),f+=l[g][0].transcript,this.emit("interim",{sentence:f,timeStamp:this.currentStamp});this.emit("result",u)})}}var Xs=Object.defineProperty,zo=Object.getOwnPropertySymbols,Zs=Object.prototype.hasOwnProperty,Qs=Object.prototype.propertyIsEnumerable,Pn=(r,e,t)=>e in r?Xs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,el=(r,e)=>{for(var t in e||(e={}))Zs.call(e,t)&&Pn(r,t,e[t]);if(zo)for(var t of zo(e))Qs.call(e,t)&&Pn(r,t,e[t]);return r},pt=(r,e,t)=>Pn(r,typeof e!="symbol"?e+"":e,t),Tn=(r,e,t)=>new Promise((s,u)=>{var l=c=>{try{f(t.next(c))}catch(v){u(v)}},g=c=>{try{f(t.throw(c))}catch(v){u(v)}},f=c=>c.done?s(c.value):Promise.resolve(c.value).then(l,g);f((t=t.apply(r,e)).next())});class Ho{constructor(e={},t={}){pt(this,"mixer",null),pt(this,"recorder",null),pt(this,"localTranscriber",null),pt(this,"isRecording",!1),pt(this,"config"),pt(this,"callbacks"),this.config=el({mimeType:"video/webm;codecs=vp8,opus",videoBitsPerSecond:1e6,audioBitsPerSecond:128e3,interval:1e3},e),this.callbacks=t}startRecording(e,t){return Tn(this,null,function*(){var s,u,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 Hs(e),this.mixer.frameInterval=1,this.mixer.startDrawingFrames();const f=e[0];f&&f.getAudioTracks().length>0&&(this.localTranscriber=new Ks(f)),MediaRecorder.isTypeSupported(this.config.mimeType)||(console.warn("[CallRecorder] Preferred mime type not supported, falling back to default"),this.config.mimeType="video/webm");const c=this.mixer.getMixedStream();this.recorder=new MediaRecorder(c,{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(),(u=(s=this.callbacks).onRecordingStarted)==null||u.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 Tn(this,null,function*(){var e,t;try{if(console.log("[CallRecorder] Stopping recording"),!this.isRecording||!this.recorder)return console.warn("[CallRecorder] No active recording to stop"),[];this.recorder.stop(),this.isRecording=!1;let s=[];return this.localTranscriber&&(this.localTranscriber.stop(),s=this.localTranscriber.transcripts||[]),this.mixer&&this.mixer.releaseStreams(),console.log("[CallRecorder] Recording stopped successfully"),s}catch(s){return 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,u;t.data&&t.data.size>0&&((u=(s=this.callbacks).onRecordingChunk)==null||u.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.recorder.onerror=t=>{var s,u;console.error("[CallRecorder] MediaRecorder error:",t),(u=(s=this.callbacks).onError)==null||u.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 Tn(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 tl=Object.defineProperty,rl=Object.defineProperties,nl=Object.getOwnPropertyDescriptors,Jo=Object.getOwnPropertySymbols,il=Object.prototype.hasOwnProperty,ol=Object.prototype.propertyIsEnumerable,An=(r,e,t)=>e in r?tl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,al=(r,e)=>{for(var t in e||(e={}))il.call(e,t)&&An(r,t,e[t]);if(Jo)for(var t of Jo(e))ol.call(e,t)&&An(r,t,e[t]);return r},sl=(r,e)=>rl(r,nl(e)),Ge=(r,e,t)=>An(r,typeof e!="symbol"?e+"":e,t),Le=(r,e,t)=>new Promise((s,u)=>{var l=c=>{try{f(t.next(c))}catch(v){u(v)}},g=c=>{try{f(t.throw(c))}catch(v){u(v)}},f=c=>c.done?s(c.value):Promise.resolve(c.value).then(l,g);f((t=t.apply(r,e)).next())});class Yo extends Wo{constructor(e,t={}){if(super(je),Ge(this,"config"),Ge(this,"callbacks"),Ge(this,"socket"),Ge(this,"localParticipant",null),Ge(this,"participants",new Map),Ge(this,"recorder",null),Ge(this,"iceServers",[]),Ge(this,"isInitialized",!1),Ge(this,"listenersSetup",!1),Ge(this,"roomId"),Ge(this,"eventListeners",new Map),this.roomId=e.roomId,!this.roomId)throw new Error("roomId must be provided in config");this.config=sl(al({maxParticipants:4,debug:!1,socketPath:"/apis/video-call",mediaConfig:{video:!0,audio:!0}},e),{roomId:this.roomId}),this.callbacks=t,this.socket=new $n(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,tokenLength:this.config.token.length,maxParticipants:this.config.maxParticipants})}initialize(){return Le(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 Le(this,arguments,function*(e=this.config.mediaConfig){var t,s;try{if(console.log("[PeersCaller] Starting call..."),this.isInitialized||(yield this.initialize()),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 u=yield this.socket.startCall(this.config.roomId);if(console.log("[PeersCaller] Received call.start response:",u),u.success)this.state.setCallStatus("connected"),u.participants.forEach(l=>{l!==this.config.userId&&this.handleParticipantJoined(l)}),console.log("[PeersCaller] Call started successfully"),(s=(t=this.callbacks).onCallStarted)==null||s.call(t,u);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(u){throw console.error("[PeersCaller] Failed to start call:",u),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start call: ${u}`),u}})}joinCall(){return Le(this,arguments,function*(e=this.config.mediaConfig){try{console.log("[PeersCaller] Joining call..."),this.isInitialized||(yield this.initialize());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 u={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:",u),yield this.localParticipant.initialize(u)}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.participants.forEach(u=>{u!==this.config.userId&&this.handleParticipantJoined(u)}),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 Le(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 Le(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 Le(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 Le(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 Le(this,null,function*(){var s;try{if(console.log("[PeersCaller] Starting recording..."),this.state.isRecording){console.warn("[PeersCaller] Recording already in progress");return}const u=[],l=(s=this.localParticipant)==null?void 0:s.getCurrentStream();l&&u.push(l);for(const g of this.participants.values()){const f=g.getAllRemoteStreams();u.push(...f.values())}if(u.length===0)throw new Error("No streams available for recording");this.recorder=new Ho(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=>{this.socket.endRecording(this.config.roomId,g.id)},onTranscriptReceived:g=>{this.socket.sendTranscript(this.config.roomId,g.text)},onError:g=>{this.handleError("RECORDING_FAILED",g.message)}}),yield this.recorder.startRecording(u,e),this.state.setIsRecording(!0),console.log("[PeersCaller] Recording started successfully")}catch(u){throw console.error("[PeersCaller] Failed to start recording:",u),this.handleError("RECORDING_FAILED",`Failed to start recording: ${u}`),u}})}stopRecording(){return Le(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(){console.log("[PeersCaller] Cleaning up..."),this.state.isCalling&&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 Le(this,null,function*(){this.localParticipant=new Cn(this.config.userId,{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=T=>{this.handleParticipantJoined(T.userId)};this.socket.on("call.participant.joined",e),this.eventListeners.set("call.participant.joined",e);const t=T=>{this.handleParticipantLeft(T.userId)};this.socket.on("call.participant.left",t),this.eventListeners.set("call.participant.left",t);const s=T=>{T.participants.forEach(m=>{m!==this.config.userId&&this.handleParticipantJoined(m)})};this.socket.on("call.participants",s),this.eventListeners.set("call.participants",s);const u=()=>{this.state.setIsCalling(!1)};this.socket.on("call.left",u),this.eventListeners.set("call.left",u);const l=T=>{var m,R;console.error("[PeersCaller] Server error:",T),(R=(m=this.callbacks).onError)==null||R.call(m,T.error,T.message)};this.socket.on("call.error",l),this.eventListeners.set("call.error",l);const g=T=>{this.handleOffer(T.from,T.offer)};this.socket.on("call.offer",g),this.eventListeners.set("call.offer",g);const f=T=>{this.handleAnswer(T.from,T.answer)};this.socket.on("call.answer",f),this.eventListeners.set("call.answer",f);const c=T=>{this.handleCandidate(T.from,T.candidate)};this.socket.on("call.candidate",c),this.eventListeners.set("call.candidate",c);const v=T=>{this.handleParticipantStateUpdate(T.from,T.state)};this.socket.on("call.state",v),this.eventListeners.set("call.state",v);const h=T=>{this.handleCallEnded(T)};this.socket.on("call.ended",h),this.eventListeners.set("call.ended",h);const I=T=>{this.handleCallStatusChanged(T)};this.socket.on("call.status.changed",I),this.eventListeners.set("call.status.changed",I);const B=T=>{console.log("[PeersCaller] Recording started:",T.recordingId),this.state.setIsRecording(!0)};this.socket.on("call.recording.start",B),this.eventListeners.set("call.recording.start",B);const x=T=>{console.log("[PeersCaller] Recording chunk received:",T)};this.socket.on("call.recording.chunk.received",x),this.eventListeners.set("call.recording.chunk.received",x);const b=T=>{console.log("[PeersCaller] Recording ended:",T.recordingId),this.state.setIsRecording(!1)};this.socket.on("call.recording.end",b),this.eventListeners.set("call.recording.end",b);const N=T=>{console.log("[PeersCaller] Transcript received:",T)};this.socket.on("call.transcript",N),this.eventListeners.set("call.transcript",N),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 Le(this,null,function*(){var t,s;try{if(e===this.config.userId||this.participants.has(e))return;if(this.participants.size>=this.config.maxParticipants-1){console.warn("[PeersCaller] Maximum participants reached");return}console.log(`[PeersCaller] Participant ${e} joined`);const u=new Cn(e,{onStreamReceived:(f,c)=>{var v,h;(h=(v=this.callbacks).onStreamReceived)==null||h.call(v,f,c)},onPeerConnected:f=>{console.log(`[PeersCaller] Peer connection established with ${f}`)},onPeerDisconnected:f=>{this.handleParticipantLeft(f)},onSignal:(f,c,v)=>{this.forwardSignalToServer(f,c,v)},onError:f=>{this.handleError("PEER_CONNECTION_FAILED",f.message)}},!1);if(this.participants.set(e,u),!this.localParticipant){console.error("[PeersCaller] Cannot create peer connection - local participant not initialized");return}const l=this.config.userId<e,g={iceServers:this.iceServers,initiator:l};yield this.localParticipant.createPeerConnection(e,g,l),(s=(t=this.callbacks).onParticipantJoined)==null||s.call(t,{userId:e,videoOn:!0,audioOn:!0,screenSharing:!1})}catch(u){console.error(`[PeersCaller] Failed to handle participant ${e} joining:`,u)}})}checkCallStatus(){return Le(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 Le(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 Le(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 Le(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,u;this.state.updateParticipant(e,t),(u=(s=this.callbacks).onParticipantStateChanged)==null||u.call(s,e,t)}handleParticipantLeft(e){var t,s;console.log(`[PeersCaller] Participant ${e} left`);const u=this.participants.get(e);u&&(u.cleanup(),this.participants.delete(e)),this.state.removeParticipant(e),(s=(t=this.callbacks).onParticipantLeft)==null||s.call(t,e)}handleCallEnded(e){return Le(this,null,function*(){var t,s;console.log(`[PeersCaller] Call ended by ${e.endedBy}, 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,e),console.log("[PeersCaller] Call ended cleanup completed")}catch(u){console.error("[PeersCaller] Error handling call ended:",u)}})}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,u;console.error(`[PeersCaller] ${e}: ${t}`),this.state.setError(e,t),(u=(s=this.callbacks).onError)==null||u.call(s,e,t)}fetchIceServers(){return Le(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(u){console.error(`[PeersCaller] Failed to forward signal from ${e} to ${t}:`,u),this.handleError("SIGNALING_ERROR",`Failed to forward signal: ${u}`)}}}var Xe=(r,e,t)=>new Promise((s,u)=>{var l=c=>{try{f(t.next(c))}catch(v){u(v)}},g=c=>{try{f(t.throw(c))}catch(v){u(v)}},f=c=>c.done?s(c.value):Promise.resolve(c.value).then(l,g);f((t=t.apply(r,e)).next())});function ll(r){const[e,t]=ue.useState(null),[s,u]=ue.useState(!1),l=ue.useRef(!1),g=je(C=>C),f=Object.values(je(C=>C.participants)),c=je(C=>C.localParticipant),v=je(C=>C.callStatus==="connected"),h=je(C=>C.isRecording),I=je(C=>C.error),B=ue.useCallback(()=>Xe(null,null,function*(){if(!(l.current||e))try{l.current=!0;const C=new Yo(r,r.callbacks);yield C.initialize(),t(C),u(!0)}catch(C){throw console.error("[useVideoCall] Failed to initialize:",C),l.current=!1,C}}),[r,e]),x=ue.useCallback(C=>Xe(null,null,function*(){if(!e){yield B();return}return e.startCall(C)}),[e,B]),b=ue.useCallback(C=>Xe(null,null,function*(){if(!e){yield B();return}return e.joinCall(C)}),[e,B]),N=ue.useCallback(()=>{e==null||e.endCall()},[e]),T=ue.useCallback(C=>{e==null||e.toggleAudio(C)},[e]),m=ue.useCallback(C=>{e==null||e.toggleVideo(C)},[e]),R=ue.useCallback(()=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startScreenShare()}),[e]),A=ue.useCallback(()=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopScreenShare()}),[e]),P=ue.useCallback(C=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startRecording(C)}),[e]),k=ue.useCallback(()=>Xe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopRecording()}),[e]),S=ue.useCallback(()=>{e&&(e.cleanup(),t(null),u(!1),l.current=!1)},[e]);return ue.useEffect(()=>{r.autoInitialize&&!s&&!l.current&&B().catch(console.error)},[r.autoInitialize,s,B]),ue.useEffect(()=>()=>{S()},[S]),{initialize:B,startCall:x,joinCall:b,endCall:N,toggleAudio:T,toggleVideo:m,startScreenShare:R,stopScreenShare:A,startRecording:P,stopRecording:k,callState:g,participants:f,localParticipant:c,isConnected:v,isRecording:h,error:I,cleanup:S,peersCaller:e}}function cl(r){const[e,t]=ue.useState(null),[s,u]=ue.useState(null),l=je(g=>g.participants[r]);return ue.useEffect(()=>{var g;if(l!=null&&l.stream){if(u(l.stream),!e){const f=document.createElement("video");f.autoplay=!0,f.playsInline=!0,f.muted=r===((g=je.getState().localParticipant)==null?void 0:g.userId),t(f)}e&&(e.srcObject=l.stream)}},[l==null?void 0:l.stream,r,e]),ue.useEffect(()=>()=>{e&&(e.srcObject=null)},[e]),{videoElement:e,stream:s,participant:l}}function ul(){const r=je();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 fl(){const[r,e]=ue.useState({videoDevices:[],audioDevices:[]}),[t,s]=ue.useState({camera:null,microphone:null}),u=ue.useCallback(()=>Xe(null,null,function*(){try{const f=yield navigator.mediaDevices.enumerateDevices();e({videoDevices:f.filter(c=>c.kind==="videoinput"),audioDevices:f.filter(c=>c.kind==="audioinput")})}catch(f){console.error("[useMediaDevices] Failed to get devices:",f)}}),[]),l=ue.useCallback(()=>Xe(null,null,function*(){try{if("permissions"in navigator){const f=yield navigator.permissions.query({name:"camera"}),c=yield navigator.permissions.query({name:"microphone"});s({camera:f.state,microphone:c.state})}}catch(f){console.error("[useMediaDevices] Failed to check permissions:",f)}}),[]),g=ue.useCallback(()=>Xe(null,null,function*(){try{return(yield navigator.mediaDevices.getUserMedia({video:!0,audio:!0})).getTracks().forEach(c=>c.stop()),yield l(),yield u(),!0}catch(f){return console.error("[useMediaDevices] Failed to request permissions:",f),!1}}),[l,u]);return ue.useEffect(()=>{var f;u(),l();const c=()=>{u()};return(f=navigator.mediaDevices)==null||f.addEventListener("devicechange",c),()=>{var v;(v=navigator.mediaDevices)==null||v.removeEventListener("devicechange",c)}},[u,l]),{devices:r,permissions:t,getDevices:u,checkPermissions:l,requestPermissions:g}}function hl(){const[r,e]=ue.useState({webRTC:!1,getUserMedia:!1,getDisplayMedia:!1,mediaRecorder:!1,speechRecognition:!1});return ue.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 dl(r=""){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return r?`${r}_${e}_${t}`:`${e}_${t}`}const pl=()=>`peer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,gl=r=>!r||typeof r!="string"?!1:/^peer_\d+_[a-z0-9]{1,9}$/.test(r),yl=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}`,u=new Error(s);return t&&(u.details=t),u}function vl(){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 bl(){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=jn,te.CallParticipant=Cn,te.CallPeerConnection=No,te.CallRecorder=Ho,te.CallSocket=$n,te.PeersCaller=Yo,te.canAcceptMoreParticipants=Ns,te.checkWebRTCSupport=vl,te.formatError=ml,te.formatMediaConstraints=yl,te.generateId=dl,te.generatePeerId=pl,te.getDefaultIceServers=bl,te.getParticipant=xo,te.getParticipantList=Ls,te.isParticipantConnected=Ms,te.isValidPeerId=gl,te.isWebRTCSupported=wl,te.selectCallStatus=Rs,te.selectCallStatusError=Bs,te.selectCallStatusInfo=As,te.selectCallStatusLoading=Is,te.selectCanJoinCall=ks,te.selectError=Ts,te.selectIsCallActive=Os,te.selectIsConnected=Ps,te.selectLocalParticipant=Cs,te.selectParticipantCount=qo,te.selectParticipants=Es,te.useBrowserSupport=hl,te.useCallState=ul,te.useCallStore=je,te.useMediaDevices=fl,te.useParticipantVideo=cl,te.useVideoCall=ll,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});
22
27
  //# sourceMappingURL=peers-caller.umd.js.map