@sleep2agi/agent-network 2.3.0-preview.155 → 2.3.0-preview.157

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.
@@ -69,7 +69,7 @@ ${X}
69
69
  `).length,B=D.stack.split(`
70
70
  `).splice(0,O),A=[];if(q.stackTrace){for(let L of q.stackTrace.callFrames)if(A.push(` at ${L.functionName||"<anonymous>"} (${L.url}:${L.lineNumber+1}:${L.columnNumber+1})`),A.length>=Error.stackTraceLimit)break}D.stack=[...B,...A].join(`
71
71
  `),this.page().trustedEmitter.emit("pageerror",D)}else $0(`Unhandled LogEntry with type "${q.type}", text "${q.text}" and level "${q.level}"`)}),this.browsingContext.on("worker",({realm:q})=>{let D=jK.from(this,q);q.on("destroyed",()=>{this.page().trustedEmitter.emit("workerdestroyed",D)}),this.page().trustedEmitter.emit("workercreated",D)})}#X(q){let D=F.from(this,q);return this.#Z.set(q,D),this.page().trustedEmitter.emit("frameattached",D),q.on("closed",()=>{this.#Z.delete(q)}),D}get timeoutSettings(){return this.page()._timeoutSettings}mainRealm(){return this.realms.default}isolatedRealm(){return this.realms.internal}realm(q){for(let D of Object.values(this.realms))if(D.realm.id===q)return D;return}page(){let q=this.#$;while(q instanceof F)q=q.#$;return q}url(){return this.browsingContext.url}parentFrame(){if(this.#$ instanceof F)return this.#$;return null}childFrames(){return[...this.browsingContext.children].map((q)=>{return this.#Z.get(q)})}#Q(){return Y4(()=>{if(this.detached)return l8(this);return W1(this.page().trustedEmitter,"framedetached").pipe(B6((q)=>{return q===this}))})}async goto(q,D={}){let[O]=await Promise.all([this.waitForNavigation(D),this.browsingContext.navigate(q,"interactive").catch((B)=>{if(x1(B)&&B.message.includes("net::ERR_HTTP_RESPONSE_CODE_FAILURE"))return;if(B.message.includes("navigation canceled"))return;if(B.message.includes("Navigation was aborted by another navigation"))return;throw B})]).catch(MK(q,D.timeout??this.timeoutSettings.navigationTimeout()));return O}async setContent(q,D={}){await Promise.all([this.setFrameContent(q),C1(dJ([this.#G(D),this.#W(D)]))])}async waitForNavigation(q={}){let{timeout:D=this.timeoutSettings.navigationTimeout(),signal:O}=q,B=this.childFrames().map((A)=>{return A.#Q()});return await C1(dJ([HZ(W1(this.browsingContext,"navigation"),W1(this.browsingContext,"historyUpdated").pipe(R1(()=>{return{navigation:null}}))).pipe(G4()).pipe(qZ(({navigation:A})=>{if(A===null)return l8(null);return this.#G(q).pipe(PH(()=>{if(B.length===0)return l8(void 0);return dJ(B)}),f1(W1(A,"fragment"),W1(A,"failed"),W1(A,"aborted")),qZ(()=>{if(A.request){let L=function(M){if(A===null)return l8(null);if(M.response||M.error)return l8(A);if(M.redirect)return L(M.redirect);return W1(M,"success").pipe(f1(W1(M,"error")),f1(W1(M,"redirect"))).pipe(qZ(()=>{return L(M)}))};return L(A.request)}return l8(A)}))})),this.#W(q)]).pipe(R1(([A])=>{if(!A)return null;let L=A.request;if(!L)return null;let M=L.lastRedirect??L;return NK.get(M).response()}),f1(t1(D),u6(O),this.#Q().pipe(R1(()=>{throw new Y8("Frame detached.")})))))}waitForDevicePrompt(q={}){let{timeout:D=this.timeoutSettings.timeout(),signal:O}=q;return this.browsingContext.waitForDevicePrompt(D,O)}get detached(){return this.browsingContext.closed}#Y=new Map;async exposeFunction(q,D){if(this.#Y.has(q))throw Error(`Failed to add page binding with name ${q}: globalThis['${q}'] already exists!`);let O=await B7.from(this,q,D);this.#Y.set(q,O)}async removeExposedFunction(q){let D=this.#Y.get(q);if(!D)throw Error(`Failed to remove page binding with name ${q}: window['${q}'] does not exists!`);this.#Y.delete(q),await D[Symbol.asyncDispose]()}async createCDPSession(){if(!this.page().browser().cdpSupported)throw new L0;return await this.page().browser().cdpConnection._createSession({targetId:this._id})}get#G(){return K.value}get#W(){return H.value}async setFiles(q,D){await this.browsingContext.setFiles(q.remoteValue(),D)}async frameElement(){let q=this.parentFrame();if(!q)return null;let[D]=await q.browsingContext.locateNodes({type:"context",value:{context:this._id}});if(!D)return null;return D9.from(D,q.mainRealm())}async locateNodes(q,D){return await this.browsingContext.locateNodes(D,[q.remoteValue()])}extensionRealms(){throw new L0}}})()});class DP{#$=!1;#Z;#J;#X;#Q;#Y;#G;constructor($,Z,J,X,Y,Q){this.#Q=$,this.#Y=Z,this.#Z=Math.round(X),this.#J=Math.round(Y),this.#G=Q,this.#X=`__puppeteer_finger_${J}`}async start($={}){if(this.#$)throw new K4("Touch has already started");await this.#Q.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:this.#X,parameters:{pointerType:"touch"},actions:[{type:m1.PointerMove,x:this.#Z,y:this.#J,origin:$.origin},{...this.#G,type:m1.PointerDown,button:0}]}]),this.#$=!0}move($,Z){let J=Math.round($),X=Math.round(Z);return this.#Q.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:this.#X,parameters:{pointerType:"touch"},actions:[{...this.#G,type:m1.PointerMove,x:J,y:X}]}])}async end(){await this.#Q.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:this.#X,parameters:{pointerType:"touch"},actions:[{type:m1.PointerUp,button:0}]}]),this.#Y.removeHandle(this)}}var F6,m1,sX=($)=>{switch($){case"\r":case`
72
- `:$="Enter";break}if([...$].length===1)return $;switch($){case"Cancel":return"";case"Help":return"";case"Backspace":return"";case"Tab":return"";case"Clear":return"";case"Enter":return"";case"Shift":case"ShiftLeft":return"";case"Control":case"ControlLeft":return"";case"Alt":case"AltLeft":return"";case"Pause":return"";case"Escape":return"";case"PageUp":return"";case"PageDown":return"";case"End":return"";case"Home":return"";case"ArrowLeft":return"";case"ArrowUp":return"";case"ArrowRight":return"";case"ArrowDown":return"";case"Insert":return"";case"Delete":return"";case"NumpadEqual":return"";case"Numpad0":return"";case"Numpad1":return"";case"Numpad2":return"";case"Numpad3":return"";case"Numpad4":return"";case"Numpad5":return"";case"Numpad6":return"";case"Numpad7":return"";case"Numpad8":return"";case"Numpad9":return"";case"NumpadMultiply":return"";case"NumpadAdd":return"";case"NumpadSubtract":return"";case"NumpadDecimal":return"";case"NumpadDivide":return"";case"F1":return"";case"F2":return"";case"F3":return"";case"F4":return"";case"F5":return"";case"F6":return"";case"F7":return"";case"F8":return"";case"F9":return"";case"F10":return"";case"F11":return"";case"F12":return"";case"Meta":case"MetaLeft":return"";case"ShiftRight":return"";case"ControlRight":return"";case"AltRight":return"";case"MetaRight":return"";case"Digit0":return"0";case"Digit1":return"1";case"Digit2":return"2";case"Digit3":return"3";case"Digit4":return"4";case"Digit5":return"5";case"Digit6":return"6";case"Digit7":return"7";case"Digit8":return"8";case"Digit9":return"9";case"KeyA":return"a";case"KeyB":return"b";case"KeyC":return"c";case"KeyD":return"d";case"KeyE":return"e";case"KeyF":return"f";case"KeyG":return"g";case"KeyH":return"h";case"KeyI":return"i";case"KeyJ":return"j";case"KeyK":return"k";case"KeyL":return"l";case"KeyM":return"m";case"KeyN":return"n";case"KeyO":return"o";case"KeyP":return"p";case"KeyQ":return"q";case"KeyR":return"r";case"KeyS":return"s";case"KeyT":return"t";case"KeyU":return"u";case"KeyV":return"v";case"KeyW":return"w";case"KeyX":return"x";case"KeyY":return"y";case"KeyZ":return"z";case"Semicolon":return";";case"Equal":return"=";case"Comma":return",";case"Minus":return"-";case"Period":return".";case"Slash":return"/";case"Backquote":return"`";case"BracketLeft":return"[";case"Backslash":return"\\";case"BracketRight":return"]";case"Quote":return'"';default:throw Error(`Unknown key: "${$}"`)}},PK,Vq=($)=>{switch($){case w1.Left:return 0;case w1.Middle:return 1;case w1.Right:return 2;case w1.Back:return 3;case w1.Forward:return 4}},IK,CK;var Hq=c(()=>{KG();K1();K1();(function($){$.None="none",$.Key="key",$.Pointer="pointer",$.Wheel="wheel"})(F6||(F6={}));(function($){$.Pause="pause",$.KeyDown="keyDown",$.KeyUp="keyUp",$.PointerUp="pointerUp",$.PointerDown="pointerDown",$.PointerMove="pointerMove",$.Scroll="scroll"})(m1||(m1={}));PK=class PK extends yZ{#$;constructor($){super();this.#$=$}async down($,Z){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Key,id:"__puppeteer_keyboard",actions:[{type:m1.KeyDown,value:sX($)}]}])}async up($){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Key,id:"__puppeteer_keyboard",actions:[{type:m1.KeyUp,value:sX($)}]}])}async press($,Z={}){let{delay:J=0}=Z,X=[{type:m1.KeyDown,value:sX($)}];if(J>0)X.push({type:m1.Pause,duration:J});X.push({type:m1.KeyUp,value:sX($)}),await this.#$.mainFrame().browsingContext.performActions([{type:F6.Key,id:"__puppeteer_keyboard",actions:X}])}async type($,Z={}){let{delay:J=0}=Z,X=[...$].map(sX),Y=[];if(J<=0)for(let Q of X)Y.push({type:m1.KeyDown,value:Q},{type:m1.KeyUp,value:Q});else for(let Q of X)Y.push({type:m1.KeyDown,value:Q},{type:m1.Pause,duration:J},{type:m1.KeyUp,value:Q});await this.#$.mainFrame().browsingContext.performActions([{type:F6.Key,id:"__puppeteer_keyboard",actions:Y}])}async sendCharacter($){if([...$].length>1)throw Error("Cannot send more than 1 character.");await(await this.#$.focusedFrame()).isolatedRealm().evaluate(async(J)=>{document.execCommand("insertText",!1,J)},$)}};IK=class IK extends xZ{#$;#Z={x:0,y:0};constructor($){super();this.#$=$}async reset(){this.#Z={x:0,y:0},await this.#$.mainFrame().browsingContext.releaseActions()}async move($,Z,J={}){let X=this.#Z,Y={x:Math.round($),y:Math.round(Z)},Q=[],G=J.steps??0;for(let K=0;K<G;++K)Q.push({type:m1.PointerMove,x:X.x+(Y.x-X.x)*(K/G),y:X.y+(Y.y-X.y)*(K/G),origin:J.origin});Q.push({type:m1.PointerMove,...Y,origin:J.origin}),this.#Z=Y,await this.#$.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:"__puppeteer_mouse",actions:Q}])}async down($={}){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:"__puppeteer_mouse",actions:[{type:m1.PointerDown,button:Vq($.button??w1.Left)}]}])}async up($={}){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:"__puppeteer_mouse",actions:[{type:m1.PointerUp,button:Vq($.button??w1.Left)}]}])}async click($,Z,J={}){let X=[{type:m1.PointerMove,x:Math.round($),y:Math.round(Z),origin:J.origin}],Y={type:m1.PointerDown,button:Vq(J.button??w1.Left)},Q={type:m1.PointerUp,button:Y.button};for(let G=1;G<(J.count??1);++G)X.push(Y,Q);if(X.push(Y),J.delay)X.push({type:m1.Pause,duration:J.delay});X.push(Q),await this.#$.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:"__puppeteer_mouse",actions:X}])}async wheel($={}){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Wheel,id:"__puppeteer_wheel",actions:[{type:m1.Scroll,...this.#Z??{x:0,y:0},deltaX:$.deltaX??0,deltaY:$.deltaY??0}]}])}drag(){throw new L0}dragOver(){throw new L0}dragEnter(){throw new L0}drop(){throw new L0}dragAndDrop(){throw new L0}};CK=class CK extends kZ{#$;constructor($){super();this.#$=$}async touchStart($,Z,J={}){let X=this.idGenerator(),Y={width:1,height:1,pressure:0.5},Q=new DP(this.#$,this,X,$,Z,Y);return await Q.start(J),this.touches.push(Q),Q}}});function Xr($,...Z){return`() => {${$7($,...Z)}}`}function Yr($,Z){let J=$.domain.toLowerCase(),X=Z.hostname.toLowerCase();if(J===X)return!0;return J.startsWith(".")&&X.endsWith(J)}function Qr($,Z){let J=Z.pathname,X=$.path;if(J===X)return!0;if(J.startsWith(X)){if(X.endsWith("/"))return!0;if(J[X.length]==="/")return!0}return!1}function Gr($,Z){let J=new URL(Z);if(J0($!==void 0),!Yr($,J))return!1;return Qr($,J)}function SK($,Z=!1){let J=$[wK+"partitionKey"];function X(){if(typeof J==="string")return{partitionKey:J};if(typeof J==="object"&&J!==null){if(Z)return{partitionKey:{sourceOrigin:J.topLevelSite,hasCrossSiteAncestor:J.hasCrossSiteAncestor??!1}};return{partitionKey:J.topLevelSite}}return{}}return{name:$.name,value:$.value.value,domain:$.domain,path:$.path,size:$.size,httpOnly:$.httpOnly,secure:$.secure,sameSite:Wr($.sameSite),expires:$.expiry??-1,session:$.expiry===void 0||$.expiry<=0,...Kr($,"sameParty","sourceScheme","partitionKeyOpaque","priority"),...X()}}function Kr($,...Z){let J={};for(let X of Z)if($[wK+X]!==void 0)J[X]=$[wK+X];if(!J.sameParty)J.sameParty=!1;return J}function _K($,...Z){let J={};for(let X of Z)if($[X]!==void 0)J[wK+X]=$[X];return J}function Wr($){switch($){case"strict":return"Strict";case"lax":return"Lax";case"none":return"None";default:return"Default"}}function yK($){switch($){case"Strict":return"strict";case"Lax":return"lax";case"None":return"none";default:return"default"}}function xK($){return[void 0,-1].includes($)?void 0:$}function zq($){if($===void 0||typeof $==="string")return $;if($.hasCrossSiteAncestor)throw new L0("WebDriver BiDi does not support `hasCrossSiteAncestor` yet.");return $.sourceOrigin}var Jr=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},UP=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},OP=function($,Z,J){if(Z!==null&&Z!==void 0){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError("Object expected.");var X,Y;if(J){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");X=Z[Symbol.asyncDispose]}if(X===void 0){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");if(X=Z[Symbol.dispose],J)Y=X}if(typeof X!=="function")throw TypeError("Object not disposable.");if(Y)X=function(){try{Y.call(this)}catch(Q){return Promise.reject(Q)}};$.stack.push({value:Z,dispose:X,async:J})}else if(J)$.stack.push({async:!0});return Z},BP,rX,wK="goog:";var kK=c(()=>{b6();WG();OG();NG();fG();K1();D1();UG();g0();G8();S8();F5();Wq();Hq();RK();BP=function($){return function(Z){function J(G){Z.error=Z.hasError?new $(G,Z.error,"An error was suppressed during disposal."):G,Z.hasError=!0}var X,Y=0;function Q(){while(X=Z.stack.pop())try{if(!X.async&&Y===1)return Y=0,Z.stack.push(X),Promise.resolve().then(Q);if(X.dispose){var G=X.dispose.call(X.value);if(X.async)return Y|=2,Promise.resolve(G).then(Q,function(K){return J(K),Q()})}else Y|=1}catch(K){J(K)}if(Y===1)return Z.hasError?Promise.reject(Z.error):Promise.resolve();if(Z.hasError)throw Z.error}return Q()}}(typeof SuppressedError==="function"?SuppressedError:function($,Z,J){var X=Error(J);return X.name="SuppressedError",X.error=$,X.suppressed=Z,X}),rX=(()=>{let $=BX,Z,J=[],X=[];return class Y extends ${static{let Q=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(Z=[f4()],Jr(this,null,Z,{kind:"accessor",name:"trustedEmitter",static:!1,private:!1,access:{has:(G)=>("trustedEmitter"in G),get:(G)=>G.trustedEmitter,set:(G,K)=>{G.trustedEmitter=K}},metadata:Q},J,X),Q)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:Q})}static from(Q,G){let K=new Y(Q,G);return K.#K(),K}#$=UP(this,J,new q0);get trustedEmitter(){return this.#$}set trustedEmitter(Q){this.#$=Q}#Z=UP(this,X);#J;#X=null;#Q=new Set;keyboard;mouse;touchscreen;tracing;get webmcp(){throw new L0}coverage;#Y;#G;#W=new Set;_client(){return this.#J.client}constructor(Q,G){super();this.#Z=Q,this.#J=Kq.from(this,G),this.#Y=new RX(this.#J.client),this.tracing=new pZ(this.#J.client),this.coverage=new gZ(this.#J.client),this.keyboard=new PK(this),this.mouse=new IK(this),this.touchscreen=new CK(this)}#K(){this.#J.browsingContext.on("closed",()=>{this.trustedEmitter.emit("close",void 0),this.trustedEmitter.removeAllListeners()}),this.trustedEmitter.on("workercreated",(Q)=>{this.#Q.add(Q)}),this.trustedEmitter.on("workerdestroyed",(Q)=>{this.#Q.delete(Q)})}async setUserAgent(Q,G){let K,W,H;if(typeof Q==="string")K=Q,W=G;else K=Q.userAgent??null,W=Q.userAgentMetadata,H=Q.platform===""?void 0:Q.platform;if(K==="")K=null;if(await this.#J.browsingContext.setUserAgent(K),H&&H!=="")W=W??{},W.platform=H;await this.#J.browsingContext.setClientHintsOverride(W??null)}async setBypassCSP(Q){await this._client().send("Page.setBypassCSP",{enabled:Q})}async queryObjects(Q){J0(!Q.disposed,"Prototype JSHandle is disposed!"),J0(Q.id,"Prototype JSHandle must not be referencing primitive value");let G=await this.#J.client.send("Runtime.queryObjects",{prototypeObjectId:Q.id});return this.#J.mainRealm().createHandle({type:"array",handle:G.objects.objectId})}browser(){return this.browserContext().browser()}browserContext(){return this.#Z}mainFrame(){return this.#J}async triggerExtensionAction(Q){throw new L0}async emulateFocusedPage(Q){return await this.#Y.emulateFocus(Q)}resize(Q){throw new L0}async windowId(){return this.#J.browsingContext.windowId}openDevTools(){throw new L0}hasDevTools(){throw new L0}async focusedFrame(){let Q={stack:[],error:void 0,hasError:!1};try{let K=OP(Q,await this.mainFrame().isolatedRealm().evaluateHandle(()=>{let H=window;while(H.document.activeElement instanceof H.HTMLIFrameElement||H.document.activeElement instanceof H.HTMLFrameElement){if(H.document.activeElement.contentWindow===null)break;H=H.document.activeElement.contentWindow}return H}),!1).remoteValue();J0(K.type==="window");let W=this.frames().find((H)=>{return H._id===K.value.context});return J0(W),W}catch(G){Q.error=G,Q.hasError=!0}finally{BP(Q)}}frames(){let Q=[this.#J];for(let G of Q)Q.push(...G.childFrames());return Q}isClosed(){return this.#J.detached}async close(Q){let G={stack:[],error:void 0,hasError:!1};try{let K=OP(G,await this.#Z.waitForScreenshotOperations(),!1);try{await this.#J.browsingContext.close(Q?.runBeforeUnload)}catch{return}}catch(K){G.error=K,G.hasError=!0}finally{BP(G)}}async reload(Q={}){let[G]=await Promise.all([this.#J.waitForNavigation(Q),this.#J.browsingContext.reload({ignoreCache:Q.ignoreCache?!0:void 0})]).catch(MK(this.url(),Q.timeout??this._timeoutSettings.navigationTimeout()));return G}setDefaultNavigationTimeout(Q){this._timeoutSettings.setDefaultNavigationTimeout(Q)}setDefaultTimeout(Q){this._timeoutSettings.setDefaultTimeout(Q)}getDefaultTimeout(){return this._timeoutSettings.timeout()}getDefaultNavigationTimeout(){return this._timeoutSettings.navigationTimeout()}isJavaScriptEnabled(){return this.#J.browsingContext.isJavaScriptEnabled()}async setGeolocation(Q){let{longitude:G,latitude:K,accuracy:W=0}=Q;if(G<-180||G>180)throw Error(`Invalid longitude "${G}": precondition -180 <= LONGITUDE <= 180 failed.`);if(K<-90||K>90)throw Error(`Invalid latitude "${K}": precondition -90 <= LATITUDE <= 90 failed.`);if(W<0)throw Error(`Invalid accuracy "${W}": precondition 0 <= ACCURACY failed.`);return await this.#J.browsingContext.setGeolocationOverride({coordinates:{latitude:Q.latitude,longitude:Q.longitude,accuracy:Q.accuracy}})}async setJavaScriptEnabled(Q){return await this.#J.browsingContext.setJavaScriptEnabled(Q)}async emulateMediaType(Q){return await this.#Y.emulateMediaType(Q)}async emulateCPUThrottling(Q){return await this.#Y.emulateCPUThrottling(Q)}async emulateMediaFeatures(Q){return await this.#Y.emulateMediaFeatures(Q)}async emulateTimezone(Q){return await this.#J.browsingContext.setTimezoneOverride(Q)}async emulateIdleState(Q){return await this.#Y.emulateIdleState(Q)}async emulateVisionDeficiency(Q){return await this.#Y.emulateVisionDeficiency(Q)}async setViewport(Q){let G=!1;if(!this.browser().cdpSupported){let K=Q?.width&&Q?.height?{width:Q.width,height:Q.height}:null,W=Q?.deviceScaleFactor?Q.deviceScaleFactor:null,H=Q?Q.isLandscape?{natural:"landscape",type:"landscape-primary"}:{natural:"portrait",type:"portrait-primary"}:null,z=[this.#J.browsingContext.setViewport({viewport:K,devicePixelRatio:W}),this.#J.browsingContext.setScreenOrientationOverride(H)];if((this.#X?.hasTouch??!1)!==(Q?.hasTouch??!1)){G=!0;let V=Q?.hasTouch?1:null;z.push(this.#J.browsingContext.setTouchOverride(V).catch((U)=>{if(U instanceof X8&&(U.message.includes("unknown command")||U.message.includes("unsupported operation")))return;throw U}))}await Promise.all(z)}else G=await this.#Y.emulateViewport(Q);if(this.#X=Q,G)await this.reload()}viewport(){return this.#X}async pdf(Q={}){let{timeout:G=this._timeoutSettings.timeout(),path:K=void 0}=Q,{printBackground:W,margin:H,landscape:z,width:V,height:U,pageRanges:F,scale:q,preferCSSPageSize:D}=eJ(Q,"cm"),O=F?F.split(", "):[];await C1(l0(this.mainFrame().isolatedRealm().evaluate(()=>{return document.fonts.ready})).pipe(f1(t1(G))));let B=await C1(l0(this.#J.browsingContext.print({background:W,margin:H,orientation:z?"landscape":"portrait",page:{width:V,height:U},pageRanges:O,scale:q,shrinkToFit:!D})).pipe(f1(t1(G)))),A=f6(B,!0);return await this._maybeWriteTypedArrayToFile(K,A),A}async createPDFStream(Q){let G=await this.pdf(Q);return new ReadableStream({start(K){K.enqueue(G),K.close()}})}async _screenshot(Q){let{clip:G,type:K,captureBeyondViewport:W,quality:H}=Q;if(Q.omitBackground!==void 0&&Q.omitBackground)throw new L0("BiDi does not support 'omitBackground'.");if(Q.optimizeForSpeed!==void 0&&Q.optimizeForSpeed)throw new L0("BiDi does not support 'optimizeForSpeed'.");if(Q.fromSurface!==void 0&&!Q.fromSurface)throw new L0("BiDi does not support 'fromSurface'.");if(G!==void 0&&G.scale!==void 0&&G.scale!==1)throw new L0("BiDi does not support 'scale' in 'clip'.");let z;if(G)if(W)z=G;else{let[U,F]=await this.evaluate(()=>{if(!window.visualViewport)throw Error("window.visualViewport is not supported.");return[window.visualViewport.pageLeft,window.visualViewport.pageTop]});z={...G,x:G.x-U,y:G.y-F}}return await this.#J.browsingContext.captureScreenshot({origin:W?"document":"viewport",format:{type:`image/${K}`,...H!==void 0?{quality:H/100}:{}},...z?{clip:{type:"box",...z}}:{}})}async createCDPSession(){return await this.#J.createCDPSession()}async bringToFront(){await this.#J.browsingContext.activate()}async evaluateOnNewDocument(Q,...G){let K=Xr(Q,...G);return{identifier:await this.#J.browsingContext.addPreloadScript(K)}}async removeScriptToEvaluateOnNewDocument(Q){await this.#J.browsingContext.removePreloadScript(Q)}async exposeFunction(Q,G){return await this.mainFrame().exposeFunction(Q,"default"in G?G.default:G)}isDragInterceptionEnabled(){return!1}async setCacheEnabled(Q){if(!this.#Z.browser().cdpSupported){await this.#J.browsingContext.setCacheBehavior(Q?"default":"bypass");return}await this._client().send("Network.setCacheDisabled",{cacheDisabled:!Q})}async cookies(...Q){let G=(Q.length?Q:[this.url()]).map((W)=>{return new URL(W)});return(await this.#J.browsingContext.getCookies()).map((W)=>{return SK(W)}).filter((W)=>{return G.some((H)=>{return Gr(W,H)})})}isServiceWorkerBypassed(){throw new L0}target(){let Q=this.browserContext().getTargetForPage(this);if(!Q)throw Error("Target not found for page");return Q}async waitForFileChooser(Q={}){let{timeout:G=this._timeoutSettings.timeout()}=Q,K=d0.create({message:`Waiting for \`FileChooser\` failed: ${G}ms exceeded`,timeout:G});if(this.#W.add(K),Q.signal)Q.signal.addEventListener("abort",()=>{K.reject(Q.signal?.reason)},{once:!0});this.#J.browsingContext.once("filedialogopened",(W)=>{if(!W.element)return;let H=new fZ(D9.from({sharedId:W.element.sharedId,handle:W.element.handle,type:"node"},this.#J.mainRealm()),W.multiple);for(let z of this.#W)z.resolve(H),this.#W.delete(z)});try{return await K.valueOrThrow()}catch(W){throw this.#W.delete(K),W}}workers(){return[...this.#Q]}get isNetworkInterceptionEnabled(){return Boolean(this.#H)||Boolean(this.#z)}#H;async setRequestInterception(Q){this.#H=await this.#F(["beforeRequestSent"],this.#H,Q)}async setExtraHTTPHeaders(Q){await this.#J.browsingContext.setExtraHTTPHeaders(Q)}_credentials=null;#z;async authenticate(Q){this.#z=await this.#F(["authRequired"],this.#z,Boolean(Q)),this._credentials=Q}async#F(Q,G,K){if(K&&!G)return await this.#J.browsingContext.addIntercept({phases:Q});else if(!K&&G){await this.#J.browsingContext.userContext.browser.removeIntercept(G);return}return G}setDragInterception(){throw new L0}setBypassServiceWorker(){throw new L0}async setOfflineMode(Q){if(!this.#Z.browser().cdpSupported)return await this.#J.browsingContext.setOfflineMode(Q);if(!this.#G)this.#G={offline:!1,upload:-1,download:-1,latency:0};return this.#G.offline=Q,await this.#q()}async emulateNetworkConditions(Q){if(!this.#Z.browser().cdpSupported){if(!Q?.offline&&((Q?.upload??-1)>=0||(Q?.download??-1)>=0||(Q?.latency??0)>0))throw new L0;return await this.#J.browsingContext.setOfflineMode(Q?.offline??!1)}if(!this.#G)this.#G={offline:Q?.offline??!1,upload:-1,download:-1,latency:0};return this.#G.upload=Q?Q.upload:-1,this.#G.download=Q?Q.download:-1,this.#G.latency=Q?Q.latency:0,this.#G.offline=Q?.offline??!1,await this.#q()}async#q(){if(!this.#G)return;await this._client().send("Network.emulateNetworkConditions",{offline:this.#G.offline,latency:this.#G.latency,uploadThroughput:this.#G.upload,downloadThroughput:this.#G.download})}async setCookie(...Q){let G=this.url(),K=G.startsWith("http");for(let W of Q){let H=W.url||"";if(!H&&K)H=G;J0(H!=="about:blank",`Blank page can not have cookie "${W.name}"`),J0(!String.prototype.startsWith.call(H||"","data:"),`Data URL page can not have cookie "${W.name}"`),J0(W.partitionKey===void 0||typeof W.partitionKey==="string","BiDi only allows domain partition keys");let z=URL.canParse(H)?new URL(H):void 0,V=W.domain??z?.hostname;J0(V!==void 0,"At least one of the url and domain needs to be specified");let U={domain:V,name:W.name,value:{type:"string",value:W.value},...W.path!==void 0?{path:W.path}:{},...W.httpOnly!==void 0?{httpOnly:W.httpOnly}:{},...W.secure!==void 0?{secure:W.secure}:{},...W.sameSite!==void 0?{sameSite:yK(W.sameSite)}:{},...{expiry:xK(W.expires)},..._K(W,"sameParty","sourceScheme","priority","url")};if(W.partitionKey!==void 0)await this.browserContext().userContext.setCookie(U,W.partitionKey);else await this.#J.browsingContext.setCookie(U)}}async deleteCookie(...Q){await Promise.all(Q.map(async(G)=>{let K=G.url??this.url(),W=URL.canParse(K)?new URL(K):void 0,H=G.domain??W?.hostname;J0(H!==void 0,"At least one of the url and domain needs to be specified");let z={domain:H,name:G.name,...G.path!==void 0?{path:G.path}:{}};await this.#J.browsingContext.deleteCookie(z)}))}async removeExposedFunction(Q){await this.#J.removeExposedFunction(Q)}metrics(){throw new L0}async captureHeapSnapshot(Q){throw new L0}async goBack(Q={}){return await this.#V(-1,Q)}async goForward(Q={}){return await this.#V(1,Q)}async#V(Q,G){let K=new AbortController;try{let[W]=await Promise.all([this.waitForNavigation({...G,signal:K.signal}),this.#J.browsingContext.traverseHistory(Q)]);return W}catch(W){throw K.abort(),W}}async waitForDevicePrompt(Q={}){return await this.mainFrame().waitForDevicePrompt(Q)}get bluetooth(){return this.mainFrame().browsingContext.bluetooth}extensionRealms(){throw new L0}}})()});var Fq,qq,Dq,Uq;var hK=c(()=>{NX();K1();kK();Fq=class Fq extends q4{#$;constructor($){super();this.#$=$}asPage(){throw new L0}url(){return""}createCDPSession(){throw new L0}type(){return W8.BROWSER}browser(){return this.#$}browserContext(){return this.#$.defaultBrowserContext()}opener(){throw new L0}};qq=class qq extends q4{#$;constructor($){super();this.#$=$}async page(){return this.#$}async asPage(){return await this.page()}url(){return this.#$.url()}createCDPSession(){return this.#$.createCDPSession()}type(){return W8.PAGE}browser(){return this.browserContext().browser()}browserContext(){return this.#$.browserContext()}opener(){throw new L0}};Dq=class Dq extends q4{#$;#Z;constructor($){super();this.#$=$}async page(){if(this.#Z===void 0)this.#Z=rX.from(this.browserContext(),this.#$.browsingContext);return this.#Z}async asPage(){return await this.page()}url(){return this.#$.url()}createCDPSession(){return this.#$.createCDPSession()}type(){return W8.PAGE}browser(){return this.browserContext().browser()}browserContext(){return this.#$.page().browserContext()}opener(){throw new L0}};Uq=class Uq extends q4{#$;constructor($){super();this.#$=$}async page(){throw new L0}async asPage(){throw new L0}url(){return this.#$.url()}createCDPSession(){throw new L0}type(){return W8.OTHER}browser(){return this.browserContext().browser()}browserContext(){return this.#$.frame.page().browserContext()}opener(){throw new L0}}});var Vr=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},NP=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},Hr=function($,Z,J){if(Z!==null&&Z!==void 0){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError("Object expected.");var X,Y;if(J){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");X=Z[Symbol.asyncDispose]}if(X===void 0){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");if(X=Z[Symbol.dispose],J)Y=X}if(typeof X!=="function")throw TypeError("Object not disposable.");if(Y)X=function(){try{Y.call(this)}catch(Q){return Promise.reject(Q)}};$.stack.push({value:Z,dispose:X,async:J})}else if(J)$.stack.push({async:!0});return Z},zr,Oq;var Bq=c(()=>{RZ();mQ();K1();D1();g0();G8();tF();kK();hK();hK();zr=function($){return function(Z){function J(G){Z.error=Z.hasError?new $(G,Z.error,"An error was suppressed during disposal."):G,Z.hasError=!0}var X,Y=0;function Q(){while(X=Z.stack.pop())try{if(!X.async&&Y===1)return Y=0,Z.stack.push(X),Promise.resolve().then(Q);if(X.dispose){var G=X.dispose.call(X.value);if(X.async)return Y|=2,Promise.resolve(G).then(Q,function(K){return J(K),Q()})}else Y|=1}catch(K){J(K)}if(Y===1)return Z.hasError?Promise.reject(Z.error):Promise.resolve();if(Z.hasError)throw Z.error}return Q()}}(typeof SuppressedError==="function"?SuppressedError:function($,Z,J){var X=Error(J);return X.name="SuppressedError",X.error=$,X.suppressed=Z,X}),Oq=(()=>{let $=EZ,Z,J=[],X=[];return class Y extends ${static{let Q=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(Z=[f4()],Vr(this,null,Z,{kind:"accessor",name:"trustedEmitter",static:!1,private:!1,access:{has:(G)=>("trustedEmitter"in G),get:(G)=>G.trustedEmitter,set:(G,K)=>{G.trustedEmitter=K}},metadata:Q},J,X),Q)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:Q})}static from(Q,G,K){let W=new Y(Q,G,K);return W.#G(),W}#$=NP(this,J,new q0);get trustedEmitter(){return this.#$}set trustedEmitter(Q){this.#$=Q}#Z=NP(this,X);#J;userContext;#X=new WeakMap;#Q=new Map;#Y=[];constructor(Q,G,K){super();this.#Z=Q,this.userContext=G,this.#J=K.defaultViewport}#G(){for(let Q of this.userContext.browsingContexts)this.#W(Q);this.userContext.on("browsingcontext",({browsingContext:Q})=>{let G=this.#W(Q);if(Q.originalOpener){for(let K of this.userContext.browsingContexts)if(K.id===Q.originalOpener)this.#X.get(K).trustedEmitter.emit("popup",G)}}),this.userContext.on("closed",()=>{this.trustedEmitter.removeAllListeners()})}#W(Q){let G=rX.from(this,Q);this.#X.set(Q,G),G.trustedEmitter.on("close",()=>{this.#X.delete(Q)});let K=new qq(G),W=new Map;return this.#Q.set(G,[K,W]),G.trustedEmitter.on("frameattached",(H)=>{let z=H,V=new Dq(z);W.set(z,V),this.trustedEmitter.emit("targetcreated",V)}),G.trustedEmitter.on("framenavigated",(H)=>{let z=H,V=W.get(z);if(V===void 0)this.trustedEmitter.emit("targetchanged",K);else this.trustedEmitter.emit("targetchanged",V)}),G.trustedEmitter.on("framedetached",(H)=>{let z=H,V=W.get(z);if(V===void 0)return;W.delete(z),this.trustedEmitter.emit("targetdestroyed",V)}),G.trustedEmitter.on("workercreated",(H)=>{let z=H,V=new Uq(z);W.set(z,V),this.trustedEmitter.emit("targetcreated",V)}),G.trustedEmitter.on("workerdestroyed",(H)=>{let z=H,V=W.get(z);if(V===void 0)return;W.delete(H),this.trustedEmitter.emit("targetdestroyed",V)}),G.trustedEmitter.on("close",()=>{this.#Q.delete(G),this.trustedEmitter.emit("targetdestroyed",K)}),this.trustedEmitter.emit("targetcreated",K),G}targets(){return[...this.#Q.values()].flatMap(([Q,G])=>{return[Q,...G.values()]})}getTargetForPage(Q){return this.#Q.get(Q)?.[0]}async newPage(Q){let G={stack:[],error:void 0,hasError:!1};try{let K=Hr(G,await this.waitForScreenshotOperations(),!1),W=Q?.type==="window"?"window":"tab",H=await this.userContext.createBrowsingContext(W,{background:Q?.background}),z=this.#X.get(H);if(!z)throw Error("Page is not found");if(this.#J)try{await z.setViewport(this.#J)}catch(V){$0(V)}if(Q?.type==="window"&&Q?.windowBounds!==void 0)try{await this.browser().setWindowBounds(H.windowId,Q.windowBounds)}catch(V){$0(V)}return z}catch(K){G.error=K,G.hasError=!0}finally{zr(G)}}async close(){J0(this.userContext.id!==H5.DEFAULT,"Default BrowserContext cannot be closed!");try{await this.userContext.remove()}catch(Q){$0(Q)}this.#Q.clear()}browser(){return this.#Z}async pages(Q=!1){return[...this.userContext.browsingContexts].map((G)=>{return this.#X.get(G)})}async overridePermissions(Q,G){let K=new Set(G.map((W)=>{if(!J7.get(W))throw Error("Unknown permission: "+W);return W}));await Promise.all(Array.from(J7.keys()).map((W)=>{let H=this.userContext.setPermissions(Q,{name:W},K.has(W)?"granted":"denied");if(this.#Y.push({origin:Q,permission:W}),!K.has(W))return H.catch($0);return H}))}async setPermission(Q,...G){if(Q==="*")throw new L0("Origin (*) is not supported by WebDriver BiDi");await Promise.all(G.map((K)=>{if(K.permission.allowWithoutSanitization)throw new L0("allowWithoutSanitization is not supported by WebDriver BiDi");if(K.permission.panTiltZoom)throw new L0("panTiltZoom is not supported by WebDriver BiDi");if(K.permission.userVisibleOnly)throw new L0("userVisibleOnly is not supported by WebDriver BiDi");return this.userContext.setPermissions(Q,{name:K.permission.name},K.state)}))}async clearPermissionOverrides(){let Q=this.#Y.map(({permission:G,origin:K})=>{return this.userContext.setPermissions(K,{name:G},"prompt").catch($0)});this.#Y=[],await Promise.all(Q)}get id(){if(this.userContext.id===H5.DEFAULT)return;return this.userContext.id}async cookies(){return(await this.userContext.getCookies()).map((G)=>{return SK(G,!0)})}async setCookie(...Q){await Promise.all(Q.map(async(G)=>{let K={domain:G.domain,name:G.name,value:{type:"string",value:G.value},...G.path!==void 0?{path:G.path}:{},...G.httpOnly!==void 0?{httpOnly:G.httpOnly}:{},...G.secure!==void 0?{secure:G.secure}:{},...G.sameSite!==void 0?{sameSite:yK(G.sameSite)}:{},...{expiry:xK(G.expires)},..._K(G,"sameParty","sourceScheme","priority","url")};return await this.userContext.setCookie(K,zq(G.partitionKey))}))}}})()});var Fr=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},b9=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},qr=function($,Z,J){if(Z!==null&&Z!==void 0){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError("Object expected.");var X,Y;if(J){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");X=Z[Symbol.asyncDispose]}if(X===void 0){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");if(X=Z[Symbol.dispose],J)Y=X}if(typeof X!=="function")throw TypeError("Object not disposable.");if(Y)X=function(){try{Y.call(this)}catch(Q){return Promise.reject(Q)}};$.stack.push({value:Z,dispose:X,async:J})}else if(J)$.stack.push({async:!0});return Z},Dr,AP;var LP=c(()=>{K1();D1();G8();E1();rF();tF();Dr=function($){return function(Z){function J(G){Z.error=Z.hasError?new $(G,Z.error,"An error was suppressed during disposal."):G,Z.hasError=!0}var X,Y=0;function Q(){while(X=Z.stack.pop())try{if(!X.async&&Y===1)return Y=0,Z.stack.push(X),Promise.resolve().then(Q);if(X.dispose){var G=X.dispose.call(X.value);if(X.async)return Y|=2,Promise.resolve(G).then(Q,function(K){return J(K),Q()})}else Y|=1}catch(K){J(K)}if(Y===1)return Z.hasError?Promise.reject(Z.error):Promise.resolve();if(Z.hasError)throw Z.error}return Q()}}(typeof SuppressedError==="function"?SuppressedError:function($,Z,J){var X=Error(J);return X.name="SuppressedError",X.error=$,X.suppressed=Z,X}),AP=(()=>{let $=q0,Z=[],J,X,Y,Q,G,K,W,H,z,V;return class U extends ${static{let F=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(b9(this,null,J,{kind:"method",name:"dispose",static:!1,private:!1,access:{has:(q)=>("dispose"in q),get:(q)=>q.dispose},metadata:F},null,Z),b9(this,null,X,{kind:"method",name:"close",static:!1,private:!1,access:{has:(q)=>("close"in q),get:(q)=>q.close},metadata:F},null,Z),b9(this,null,Y,{kind:"method",name:"addPreloadScript",static:!1,private:!1,access:{has:(q)=>("addPreloadScript"in q),get:(q)=>q.addPreloadScript},metadata:F},null,Z),b9(this,null,Q,{kind:"method",name:"removeIntercept",static:!1,private:!1,access:{has:(q)=>("removeIntercept"in q),get:(q)=>q.removeIntercept},metadata:F},null,Z),b9(this,null,G,{kind:"method",name:"removePreloadScript",static:!1,private:!1,access:{has:(q)=>("removePreloadScript"in q),get:(q)=>q.removePreloadScript},metadata:F},null,Z),b9(this,null,K,{kind:"method",name:"createUserContext",static:!1,private:!1,access:{has:(q)=>("createUserContext"in q),get:(q)=>q.createUserContext},metadata:F},null,Z),b9(this,null,W,{kind:"method",name:"installExtension",static:!1,private:!1,access:{has:(q)=>("installExtension"in q),get:(q)=>q.installExtension},metadata:F},null,Z),b9(this,null,H,{kind:"method",name:"uninstallExtension",static:!1,private:!1,access:{has:(q)=>("uninstallExtension"in q),get:(q)=>q.uninstallExtension},metadata:F},null,Z),b9(this,null,z,{kind:"method",name:"setClientWindowState",static:!1,private:!1,access:{has:(q)=>("setClientWindowState"in q),get:(q)=>q.setClientWindowState},metadata:F},null,Z),b9(this,null,V,{kind:"method",name:"getClientWindowInfo",static:!1,private:!1,access:{has:(q)=>("getClientWindowInfo"in q),get:(q)=>q.getClientWindowInfo},metadata:F},null,Z),F)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:F})}static async from(F){let q=new U(F);return await q.#Y(),q}#$=(Fr(this,Z),!1);#Z;#J=new G1;#X=new Map;session;#Q=new Map;constructor(F){super();this.session=F}async#Y(){let F=this.#J.use(new q0(this.session));F.once("ended",({reason:q})=>{this.dispose(q)}),F.on("script.realmCreated",(q)=>{if(q.type!=="shared-worker")return;this.#Q.set(q.realm,DK.from(this,q.realm,q.origin))}),await this.#G(),await this.#W()}async#G(){let{result:{userContexts:F}}=await this.session.send("browser.getUserContexts",{});for(let q of F)this.#K(q.userContext)}async#W(){let F=new Set,q;{let D={stack:[],error:void 0,hasError:!1};try{qr(D,new q0(this.session),!1).on("browsingContext.contextCreated",(A)=>{F.add(A.context)});let{result:B}=await this.session.send("browsingContext.getTree",{});q=B.contexts}catch(O){D.error=O,D.hasError=!0}finally{Dr(D)}}for(let D of q){if(!F.has(D.context))this.session.emit("browsingContext.contextCreated",D);if(D.children)q.push(...D.children)}}#K(F){let q=H5.create(this,F);this.#X.set(q.id,q);let D=this.#J.use(new q0(q));return D.once("closed",()=>{D.removeAllListeners(),this.#X.delete(q.id)}),q}get closed(){return this.#$}get defaultUserContext(){return this.#X.get(H5.DEFAULT)}get disconnected(){return this.#Z!==void 0}get disposed(){return this.disconnected}get userContexts(){return this.#X.values()}dispose(F,q=!1){this.#$=q,this.#Z=F,this[A0]()}async close(){try{await this.session.send("browser.close",{})}finally{this.dispose("Browser already closed.",!0)}}async addPreloadScript(F,q={}){let{result:{script:D}}=await this.session.send("script.addPreloadScript",{functionDeclaration:F,...q,contexts:q.contexts?.map((O)=>{return O.id})});return D}async removeIntercept(F){await this.session.send("network.removeIntercept",{intercept:F})}async removePreloadScript(F){await this.session.send("script.removePreloadScript",{script:F})}async createUserContext(F){let q=F.proxyServer===void 0?void 0:{proxyType:"manual",httpProxy:F.proxyServer,sslProxy:F.proxyServer,noProxy:F.proxyBypassList},{result:{userContext:D}}=await this.session.send("browser.createUserContext",{proxy:q});if(F.downloadBehavior?.policy==="allowAndName")throw new L0("`allowAndName` is not supported in WebDriver BiDi");if(F.downloadBehavior?.policy==="allow"){if(F.downloadBehavior.downloadPath===void 0)throw new L0("`downloadPath` is required in `allow` download behavior");await this.session.send("browser.setDownloadBehavior",{downloadBehavior:{type:"allowed",destinationFolder:F.downloadBehavior.downloadPath},userContexts:[D]})}if(F.downloadBehavior?.policy==="deny")await this.session.send("browser.setDownloadBehavior",{downloadBehavior:{type:"denied"},userContexts:[D]});return this.#K(D)}async installExtension(F){let{result:{extension:q}}=await this.session.send("webExtension.install",{extensionData:{type:"path",path:F}});return q}async uninstallExtension(F){await this.session.send("webExtension.uninstall",{extension:F})}async setClientWindowState(F){await this.session.send("browser.setClientWindowState",F)}async getClientWindowInfo(F){let{result:{clientWindows:q}}=await this.session.send("browser.getClientWindows",{}),D=q.find((O)=>{return O.clientWindow===F});if(!D)throw Error("Window not found");return D}[(J=[o8],X=[F0((F)=>{return F.#Z})],Y=[F0((F)=>{return F.#Z})],Q=[F0((F)=>{return F.#Z})],G=[F0((F)=>{return F.#Z})],K=[F0((F)=>{return F.#Z})],W=[F0((F)=>{return F.#Z})],H=[F0((F)=>{return F.#Z})],z=[F0((F)=>{return F.#Z})],V=[F0((F)=>{return F.#Z})],A0)](){if(this.#Z??="Browser was disconnected, probably because the session ended.",this.closed)this.emit("closed",{reason:this.#Z});this.emit("disconnected",{reason:this.#Z}),this.#J.dispose(),super[A0]()}}})()});var Nq=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},q5=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},MP;var RP=c(()=>{D1();G8();E1();LP();MP=(()=>{let $=q0,Z=[],J,X=[],Y=[],Q,G,K,W,H;return class z extends ${static{let V=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(q5(this,null,J,{kind:"accessor",name:"connection",static:!1,private:!1,access:{has:(U)=>("connection"in U),get:(U)=>U.connection,set:(U,F)=>{U.connection=F}},metadata:V},X,Y),q5(this,null,Q,{kind:"method",name:"dispose",static:!1,private:!1,access:{has:(U)=>("dispose"in U),get:(U)=>U.dispose},metadata:V},null,Z),q5(this,null,G,{kind:"method",name:"send",static:!1,private:!1,access:{has:(U)=>("send"in U),get:(U)=>U.send},metadata:V},null,Z),q5(this,null,K,{kind:"method",name:"subscribe",static:!1,private:!1,access:{has:(U)=>("subscribe"in U),get:(U)=>U.subscribe},metadata:V},null,Z),q5(this,null,W,{kind:"method",name:"addIntercepts",static:!1,private:!1,access:{has:(U)=>("addIntercepts"in U),get:(U)=>U.addIntercepts},metadata:V},null,Z),q5(this,null,H,{kind:"method",name:"end",static:!1,private:!1,access:{has:(U)=>("end"in U),get:(U)=>U.end},metadata:V},null,Z),V)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:V})}static async from(V,U){let{result:F}=await V.send("session.new",{capabilities:U}),q=new z(V,F);return await q.#Q(),q}#$=Nq(this,Z);#Z=new G1;#J;browser;#X=Nq(this,X,void 0);get connection(){return this.#X}set connection(V){this.#X=V}constructor(V,U){super();Nq(this,Y),this.#J=U,this.connection=V}async#Q(){this.browser=await AP.from(this),this.#Z.use(this.browser).once("closed",({reason:F})=>{this.dispose(F)});let U=new WeakSet;this.on("browsingContext.fragmentNavigated",(F)=>{if(U.has(F))return;U.add(F),this.emit("browsingContext.navigationStarted",F),this.emit("browsingContext.fragmentNavigated",F)})}get capabilities(){return this.#J.capabilities}get disposed(){return this.ended}get ended(){return this.#$!==void 0}get id(){return this.#J.sessionId}dispose(V){this.#$=V,this[A0]()}async send(V,U){return await this.connection.send(V,U)}async subscribe(V,U){await this.send("session.subscribe",{events:V,contexts:U})}async addIntercepts(V,U){await this.send("session.subscribe",{events:V,contexts:U})}async end(){try{await this.send("session.end",{})}finally{this.dispose("Session already ended.")}}[(J=[f4()],Q=[o8],G=[F0((V)=>{return V.#$})],K=[F0((V)=>{return V.#$})],W=[F0((V)=>{return V.#$})],H=[F0((V)=>{return V.#$})],A0)](){this.#$??="Session already destroyed, probably because the connection broke.",this.emit("ended",{reason:this.#$}),this.#Z.dispose(),super[A0]()}}})()});var Ur=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},EP=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},TP=function($,Z,J){if(typeof Z==="symbol")Z=Z.description?"[".concat(Z.description,"]"):"";return Object.defineProperty($,"name",{configurable:!0,value:J?"".concat(J," ",Z):Z})},Or;var jP=c(()=>{RZ();K1();D1();g0();G8();Bq();RP();hK();Or=(()=>{let $=MZ,Z,J=[],X=[],Y;return class Q extends ${static{let G=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(Z=[f4()],Ur(this,Y={get:TP(function(){return this.#$},"#trustedEmitter","get"),set:TP(function(K){this.#$=K},"#trustedEmitter","set")},Z,{kind:"accessor",name:"#trustedEmitter",static:!1,private:!0,access:{has:(K)=>(#Z in K),get:(K)=>K.#Z,set:(K,W)=>{K.#Z=W}},metadata:G},J,X),G)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:G})}protocol="webDriverBiDi";static subscribeModules=["browsingContext","network","log","script","input"];static subscribeCdpEvents=["goog:cdp.Debugger.scriptParsed","goog:cdp.CSS.styleSheetAdded","goog:cdp.Runtime.executionContextsCleared","goog:cdp.Tracing.tracingComplete","goog:cdp.Network.requestWillBeSent","goog:cdp.Debugger.scriptParsed","goog:cdp.Page.screencastFrame"];static async create(G){let K=await MP.from(G.connection,{firstMatch:G.capabilities?.firstMatch,alwaysMatch:{...G.capabilities?.alwaysMatch,acceptInsecureCerts:G.acceptInsecureCerts,unhandledPromptBehavior:{default:"ignore"},webSocketUrl:!0,"goog:prerenderingDisabled":!0,"goog:disableNetworkDurableMessages":!0}});await K.subscribe((G.cdpConnection?[...Q.subscribeModules,...Q.subscribeCdpEvents]:Q.subscribeModules).filter((H)=>{if(!G.networkEnabled)return H!=="network"&&H!=="goog:cdp.Network.requestWillBeSent";return!0})),await Promise.all(["request","response"].map(async(H)=>{try{await K.send("network.addDataCollector",{dataTypes:[H],maxEncodedDataSize:20000000})}catch(z){if(z instanceof X8)$0(z);else throw z}}));let W=new Q(K.browser,G);return W.#F(),W}#$=EP(this,J,new q0);get#Z(){return Y.get.call(this)}set#Z(G){return Y.set.call(this,G)}#J=EP(this,X);#X;#Q;#Y;#G=new WeakMap;#W=new Fq(this);#K;#H;#z;constructor(G,K){super();this.#J=K.process,this.#X=K.closeCallback,this.#Q=G,this.#Y=K.defaultViewport,this.#K=K.cdpConnection,this.#H=K.networkEnabled,this.#z=K.issuesEnabled}#F(){for(let G of this.#Q.userContexts)this.#D(G);this.#Q.once("disconnected",()=>{this.#Z.emit("disconnected",void 0),this.#Z.removeAllListeners()}),this.#J?.once("close",()=>{this.#Q.dispose("Browser process exited.",!0),this.connection.dispose()})}get#q(){return this.#Q.session.capabilities.browserName}get#V(){return this.#Q.session.capabilities.browserVersion}get cdpSupported(){return this.#K!==void 0}get cdpConnection(){return this.#K}async userAgent(){return this.#Q.session.capabilities.userAgent}#D(G){let K=Oq.from(this,G,{defaultViewport:this.#Y});return this.#G.set(G,K),K.trustedEmitter.on("targetcreated",(W)=>{this.#Z.emit("targetcreated",W)}),K.trustedEmitter.on("targetchanged",(W)=>{this.#Z.emit("targetchanged",W)}),K.trustedEmitter.on("targetdestroyed",(W)=>{this.#Z.emit("targetdestroyed",W)}),K}get connection(){return this.#Q.session.connection}wsEndpoint(){return this.connection.url}async close(){if(this.connection.closed)return;try{await this.#Q.close(),await this.#X?.call(null)}catch(G){$0(G)}finally{this.connection.dispose()}}get connected(){return!this.#Q.disconnected}process(){return this.#J??null}async createBrowserContext(G={}){let K=await this.#Q.createUserContext(G);return this.#D(K)}async version(){return`${this.#q}/${this.#V}`}browserContexts(){return[...this.#Q.userContexts].map((G)=>{return this.#G.get(G)})}defaultBrowserContext(){return this.#G.get(this.#Q.defaultUserContext)}newPage(G){return this.defaultBrowserContext().newPage(G)}installExtension(G){return this.#Q.installExtension(G)}async uninstallExtension(G){await this.#Q.uninstallExtension(G)}screens(){throw new L0}addScreen(G){throw new L0}removeScreen(G){throw new L0}async getWindowBounds(G){let K=await this.#Q.getClientWindowInfo(G);return{left:K.x,top:K.y,width:K.width,height:K.height,windowState:K.state}}async setWindowBounds(G,K){let W,H=K.windowState??"normal";if(H==="normal")W={clientWindow:G,state:"normal",x:K.left,y:K.top,width:K.width,height:K.height};else W={clientWindow:G,state:H};await this.#Q.setClientWindowState(W)}targets(){return[this.#W,...this.browserContexts().flatMap((G)=>{return G.targets()})]}target(){return this.#W}async disconnect(){try{await this.#Q.session.end()}catch(G){$0(G)}finally{this.connection.dispose()}}get debugInfo(){return{pendingProtocolErrors:this.connection.getPendingProtocolErrors()}}isNetworkEnabled(){return this.#H}extensions(){throw new L0}isIssuesEnabled(){return this.#z}}})()});var tX={};k6(tX,{requests:()=>NK,convertCookiesSameSiteCdpToBiDi:()=>yK,convertCookiesPartitionKeyFromPuppeteerToBiDi:()=>zq,convertCookiesExpiryCdpToBiDi:()=>xK,connectBidiOverCdp:()=>bs,cdpSpecificCookiePropertiesFromPuppeteerToBidi:()=>_K,bidiToPuppeteerCookie:()=>SK,BidiWorkerRealm:()=>aX,BidiTouchscreen:()=>CK,BidiRealm:()=>EK,BidiPage:()=>rX,BidiMouse:()=>IK,BidiKeyboard:()=>PK,BidiJSHandle:()=>c6,BidiHTTPResponse:()=>BK,BidiHTTPRequest:()=>oX,BidiFrameRealm:()=>A4,BidiFrame:()=>Kq,BidiElementHandle:()=>D9,BidiConnection:()=>zK,BidiBrowserContext:()=>Oq,BidiBrowser:()=>Or});var eX=c(()=>{ij();jP();Bq();lF();F5();Wq();Xq();Zq();Hq();z5();kK();TK()});async function PP($,Z,J){let{acceptInsecureCerts:X=!1,networkEnabled:Y=!0,issuesEnabled:Q=!0,defaultViewport:G=e$}=J,{bidiConnection:K,cdpConnection:W,closeCallback:H}=await Br($,Z,J);return await(await Promise.resolve().then(() => (eX(),tX))).BidiBrowser.create({connection:K,cdpConnection:W,closeCallback:H,process:void 0,defaultViewport:G,acceptInsecureCerts:X,networkEnabled:Y,issuesEnabled:Q,capabilities:J.capabilities})}async function Br($,Z,J){let X=await Promise.resolve().then(() => (eX(),tX)),{slowMo:Y=0,protocolTimeout:Q,idGenerator:G=H9()}=J,K=new X.BidiConnection(Z,$,G,Y,Q);try{let V=await K.send("session.status",{});if("type"in V&&V.type==="success")return{bidiConnection:K,closeCallback:async()=>{await K.send("browser.close",{}).catch($0)}}}catch(V){if(!(V instanceof X8))throw V}K.unbind();let W=new D4(Z,$,Y,Q,!0,G);if((await W.send("Browser.getVersion")).product.toLowerCase().includes("firefox"))throw new L0("Firefox is not supported in BiDi over CDP mode.");let z=await X.connectBidiOverCdp(W);return{cdpConnection:W,bidiConnection:z,closeCallback:async()=>{await W.send("Browser.close").catch($0)}}}var IP=c(()=>{U4();K1();g0()});var L4=S((tI0,SP)=>{var CP=["nodebuffer","arraybuffer","fragments"],wP=typeof Blob<"u";if(wP)CP.push("blob");SP.exports={BINARY_TYPES:CP,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:wP,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var $Y=S((eI0,vK)=>{var{EMPTY_BUFFER:Nr}=L4(),Aq=Buffer[Symbol.species];function Ar($,Z){if($.length===0)return Nr;if($.length===1)return $[0];let J=Buffer.allocUnsafe(Z),X=0;for(let Y=0;Y<$.length;Y++){let Q=$[Y];J.set(Q,X),X+=Q.length}if(X<Z)return new Aq(J.buffer,J.byteOffset,X);return J}function _P($,Z,J,X,Y){for(let Q=0;Q<Y;Q++)J[X+Q]=$[Q]^Z[Q&3]}function yP($,Z){for(let J=0;J<$.length;J++)$[J]^=Z[J&3]}function Lr($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function Lq($){if(Lq.readOnly=!0,Buffer.isBuffer($))return $;let Z;if($ instanceof ArrayBuffer)Z=new Aq($);else if(ArrayBuffer.isView($))Z=new Aq($.buffer,$.byteOffset,$.byteLength);else Z=Buffer.from($),Lq.readOnly=!1;return Z}vK.exports={concat:Ar,mask:_P,toArrayBuffer:Lr,toBuffer:Lq,unmask:yP};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();vK.exports.mask=function(Z,J,X,Y,Q){if(Q<48)_P(Z,J,X,Y,Q);else $.mask(Z,J,X,Y,Q)},vK.exports.unmask=function(Z,J){if(Z.length<32)yP(Z,J);else $.unmask(Z,J)}}catch($){}});var vP=S(($C0,hP)=>{var xP=Symbol("kDone"),Mq=Symbol("kRun");class kP{constructor($){this[xP]=()=>{this.pending--,this[Mq]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[Mq]()}[Mq](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[xP])}}}hP.exports=kP});var O5=S((ZC0,mP)=>{var ZY=Y0("zlib"),bP=$Y(),Mr=vP(),{kStatusCode:fP}=L4(),Rr=Buffer[Symbol.species],Er=Buffer.from([0,0,255,255]),fK=Symbol("permessage-deflate"),M4=Symbol("total-length"),D5=Symbol("callback"),G$=Symbol("buffers"),U5=Symbol("error"),bK;class gP{constructor($){if(this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!bK){let Z=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;bK=new Mr(Z)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[D5];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let Z=this._options,J=$.find((X)=>{if(Z.serverNoContextTakeover===!1&&X.server_no_context_takeover||X.server_max_window_bits&&(Z.serverMaxWindowBits===!1||typeof Z.serverMaxWindowBits==="number"&&Z.serverMaxWindowBits>X.server_max_window_bits)||typeof Z.clientMaxWindowBits==="number"&&!X.client_max_window_bits)return!1;return!0});if(!J)throw Error("None of the extension offers can be accepted");if(Z.serverNoContextTakeover)J.server_no_context_takeover=!0;if(Z.clientNoContextTakeover)J.client_no_context_takeover=!0;if(typeof Z.serverMaxWindowBits==="number")J.server_max_window_bits=Z.serverMaxWindowBits;if(typeof Z.clientMaxWindowBits==="number")J.client_max_window_bits=Z.clientMaxWindowBits;else if(J.client_max_window_bits===!0||Z.clientMaxWindowBits===!1)delete J.client_max_window_bits;return J}acceptAsClient($){let Z=$[0];if(this._options.clientNoContextTakeover===!1&&Z.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!Z.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")Z.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&Z.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return Z}normalizeParams($){return $.forEach((Z)=>{Object.keys(Z).forEach((J)=>{let X=Z[J];if(X.length>1)throw Error(`Parameter "${J}" must have only a single value`);if(X=X[0],J==="client_max_window_bits"){if(X!==!0){let Y=+X;if(!Number.isInteger(Y)||Y<8||Y>15)throw TypeError(`Invalid value for parameter "${J}": ${X}`);X=Y}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${J}": ${X}`)}else if(J==="server_max_window_bits"){let Y=+X;if(!Number.isInteger(Y)||Y<8||Y>15)throw TypeError(`Invalid value for parameter "${J}": ${X}`);X=Y}else if(J==="client_no_context_takeover"||J==="server_no_context_takeover"){if(X!==!0)throw TypeError(`Invalid value for parameter "${J}": ${X}`)}else throw Error(`Unknown parameter "${J}"`);Z[J]=X})}),$}decompress($,Z,J){bK.add((X)=>{this._decompress($,Z,(Y,Q)=>{X(),J(Y,Q)})})}compress($,Z,J){bK.add((X)=>{this._compress($,Z,(Y,Q)=>{X(),J(Y,Q)})})}_decompress($,Z,J){let X=this._isServer?"client":"server";if(!this._inflate){let Y=`${X}_max_window_bits`,Q=typeof this.params[Y]!=="number"?ZY.Z_DEFAULT_WINDOWBITS:this.params[Y];this._inflate=ZY.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Q}),this._inflate[fK]=this,this._inflate[M4]=0,this._inflate[G$]=[],this._inflate.on("error",jr),this._inflate.on("data",uP)}if(this._inflate[D5]=J,this._inflate.write($),Z)this._inflate.write(Er);this._inflate.flush(()=>{let Y=this._inflate[U5];if(Y){this._inflate.close(),this._inflate=null,J(Y);return}let Q=bP.concat(this._inflate[G$],this._inflate[M4]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[M4]=0,this._inflate[G$]=[],Z&&this.params[`${X}_no_context_takeover`])this._inflate.reset();J(null,Q)})}_compress($,Z,J){let X=this._isServer?"server":"client";if(!this._deflate){let Y=`${X}_max_window_bits`,Q=typeof this.params[Y]!=="number"?ZY.Z_DEFAULT_WINDOWBITS:this.params[Y];this._deflate=ZY.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Q}),this._deflate[M4]=0,this._deflate[G$]=[],this._deflate.on("data",Tr)}this._deflate[D5]=J,this._deflate.write($),this._deflate.flush(ZY.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let Y=bP.concat(this._deflate[G$],this._deflate[M4]);if(Z)Y=new Rr(Y.buffer,Y.byteOffset,Y.length-4);if(this._deflate[D5]=null,this._deflate[M4]=0,this._deflate[G$]=[],Z&&this.params[`${X}_no_context_takeover`])this._deflate.reset();J(null,Y)})}}mP.exports=gP;function Tr($){this[G$].push($),this[M4]+=$.length}function uP($){if(this[M4]+=$.length,this[fK]._maxPayload<1||this[M4]<=this[fK]._maxPayload){this[G$].push($);return}this[U5]=RangeError("Max payload size exceeded"),this[U5].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[U5][fP]=1009,this.removeListener("data",uP),this.reset()}function jr($){if(this[fK]._inflate=null,this[U5]){this[D5](this[U5]);return}$[fP]=1007,this[D5]($)}});var B5=S((JC0,gK)=>{var{isUtf8:cP}=Y0("buffer"),{hasBlob:Pr}=L4(),Ir=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Cr($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function Rq($){let Z=$.length,J=0;while(J<Z)if(($[J]&128)===0)J++;else if(($[J]&224)===192){if(J+1===Z||($[J+1]&192)!==128||($[J]&254)===192)return!1;J+=2}else if(($[J]&240)===224){if(J+2>=Z||($[J+1]&192)!==128||($[J+2]&192)!==128||$[J]===224&&($[J+1]&224)===128||$[J]===237&&($[J+1]&224)===160)return!1;J+=3}else if(($[J]&248)===240){if(J+3>=Z||($[J+1]&192)!==128||($[J+2]&192)!==128||($[J+3]&192)!==128||$[J]===240&&($[J+1]&240)===128||$[J]===244&&$[J+1]>143||$[J]>244)return!1;J+=4}else return!1;return!0}function wr($){return Pr&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}gK.exports={isBlob:wr,isValidStatusCode:Cr,isValidUTF8:Rq,tokenChars:Ir};if(cP)gK.exports.isValidUTF8=function($){return $.length<24?Rq($):cP($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();gK.exports.isValidUTF8=function(Z){return Z.length<32?Rq(Z):$(Z)}}catch($){}});var Tq=S((XC0,nP)=>{var{Writable:Sr}=Y0("stream"),dP=O5(),{BINARY_TYPES:_r,EMPTY_BUFFER:pP,kStatusCode:yr,kWebSocket:xr}=L4(),{concat:Eq,toArrayBuffer:kr,unmask:hr}=$Y(),{isValidStatusCode:vr,isValidUTF8:lP}=B5(),uK=Buffer[Symbol.species];class iP extends Sr{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||_r[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxBufferedChunks=$.maxBufferedChunks|0,this._maxFragments=$.maxFragments|0,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[xr]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,Z,J){if(this._opcode===8&&this._state==0)return J();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){J(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(J)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let J=this._buffers[0];return this._buffers[0]=new uK(J.buffer,J.byteOffset+$,J.length-$),new uK(J.buffer,J.byteOffset,$)}let Z=Buffer.allocUnsafe($);do{let J=this._buffers[0],X=Z.length-$;if($>=J.length)Z.set(this._buffers.shift(),X);else Z.set(new Uint8Array(J.buffer,J.byteOffset,$),X),this._buffers[0]=new uK(J.buffer,J.byteOffset+$,J.length-$);$-=J.length}while($>0);return Z}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let Z=this.consume(2);if((Z[0]&48)!==0){let X=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(X);return}let J=(Z[0]&64)===64;if(J&&!this._extensions[dP.extensionName]){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(this._fin=(Z[0]&128)===128,this._opcode=Z[0]&15,this._payloadLength=Z[1]&127,this._opcode===0){if(J){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(!this._fragmented){let X=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let X=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}this._compressed=J}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let X=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(X);return}if(J){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let X=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(X);return}}else{let X=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(Z[1]&128)===128,this._isServer){if(!this._masked){let X=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(X);return}}else if(this._masked){let X=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(X);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let Z=this.consume(8),J=Z.readUInt32BE(0);if(J>Math.pow(2,21)-1){let X=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(X);return}this._payloadLength=J*Math.pow(2,32)+Z.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let Z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(Z);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let Z=pP;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(Z=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)hr(Z,this._mask)}if(this._opcode>7){this.controlMessage(Z,$);return}if(this._compressed){this._state=5,this.decompress(Z,$);return}if(Z.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let J=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");$(J);return}this._messageLength=this._totalPayloadLength,this._fragments.push(Z)}this.dataMessage($)}decompress($,Z){this._extensions[dP.extensionName].decompress($,this._fin,(X,Y)=>{if(X)return Z(X);if(Y.length){if(this._messageLength+=Y.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Q=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");Z(Q);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let Q=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");Z(Q);return}this._fragments.push(Y)}if(this.dataMessage(Z),this._state===0)this.startLoop(Z)})}dataMessage($){if(!this._fin){this._state=0;return}let Z=this._messageLength,J=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let X;if(this._binaryType==="nodebuffer")X=Eq(J,Z);else if(this._binaryType==="arraybuffer")X=kr(Eq(J,Z));else if(this._binaryType==="blob")X=new Blob(J);else X=J;if(this._allowSynchronousEvents)this.emit("message",X,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",X,!0),this._state=0,this.startLoop($)})}else{let X=Eq(J,Z);if(!this._skipUTF8Validation&&!lP(X)){let Y=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(Y);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",X,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",X,!1),this._state=0,this.startLoop($)})}}controlMessage($,Z){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,pP),this.end();else{let J=$.readUInt16BE(0);if(!vr(J)){let Y=this.createError(RangeError,`invalid status code ${J}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");Z(Y);return}let X=new uK($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!lP(X)){let Y=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");Z(Y);return}this._loop=!1,this.emit("conclude",J,X),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(Z)})}createError($,Z,J,X,Y){this._loop=!1,this._errored=!0;let Q=new $(J?`Invalid WebSocket frame: ${Z}`:Z);return Error.captureStackTrace(Q,this.createError),Q.code=Y,Q[yr]=X,Q}}nP.exports=iP});var Pq=S((QC0,sP)=>{var{Duplex:YC0}=Y0("stream"),{randomFillSync:br}=Y0("crypto"),{types:{isUint8Array:fr}}=Y0("util"),oP=O5(),{EMPTY_BUFFER:gr,kWebSocket:ur,NOOP:mr}=L4(),{isBlob:N5,isValidStatusCode:cr}=B5(),{mask:aP,toBuffer:N7}=$Y(),d6=Symbol("kByteLength"),dr=Buffer.alloc(4),A7,A5=8192,U9=0,pr=1,lr=2;class K${constructor($,Z,J){if(this._extensions=Z||{},J)this._generateMask=J,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=U9,this.onerror=mr,this[ur]=void 0}static frame($,Z){let J,X=!1,Y=2,Q=!1;if(Z.mask){if(J=Z.maskBuffer||dr,Z.generateMask)Z.generateMask(J);else{if(A5===8192){if(A7===void 0)A7=Buffer.alloc(8192);br(A7,0,8192),A5=0}J[0]=A7[A5++],J[1]=A7[A5++],J[2]=A7[A5++],J[3]=A7[A5++]}Q=(J[0]|J[1]|J[2]|J[3])===0,Y=6}let G;if(typeof $==="string")if((!Z.mask||Q)&&Z[d6]!==void 0)G=Z[d6];else $=Buffer.from($),G=$.length;else G=$.length,X=Z.mask&&Z.readOnly&&!Q;let K=G;if(G>=65536)Y+=8,K=127;else if(G>125)Y+=2,K=126;let W=Buffer.allocUnsafe(X?G+Y:Y);if(W[0]=Z.fin?Z.opcode|128:Z.opcode,Z.rsv1)W[0]|=64;if(W[1]=K,K===126)W.writeUInt16BE(G,2);else if(K===127)W[2]=W[3]=0,W.writeUIntBE(G,4,6);if(!Z.mask)return[W,$];if(W[1]|=128,W[Y-4]=J[0],W[Y-3]=J[1],W[Y-2]=J[2],W[Y-1]=J[3],Q)return[W,$];if(X)return aP($,J,W,Y,G),[W];return aP($,J,$,0,G),[W,$]}close($,Z,J,X){let Y;if($===void 0)Y=gr;else if(typeof $!=="number"||!cr($))throw TypeError("First argument must be a valid error code number");else if(Z===void 0||!Z.length)Y=Buffer.allocUnsafe(2),Y.writeUInt16BE($,0);else{let G=Buffer.byteLength(Z);if(G>123)throw RangeError("The message must not be greater than 123 bytes");if(Y=Buffer.allocUnsafe(2+G),Y.writeUInt16BE($,0),typeof Z==="string")Y.write(Z,2);else if(fr(Z))Y.set(Z,2);else throw TypeError("Second argument must be a string or a Uint8Array")}let Q={[d6]:Y.length,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==U9)this.enqueue([this.dispatch,Y,!1,Q,X]);else this.sendFrame(K$.frame(Y,Q),X)}ping($,Z,J){let X,Y;if(typeof $==="string")X=Buffer.byteLength($),Y=!1;else if(N5($))X=$.size,Y=!1;else $=N7($),X=$.length,Y=N7.readOnly;if(X>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[d6]:X,fin:!0,generateMask:this._generateMask,mask:Z,maskBuffer:this._maskBuffer,opcode:9,readOnly:Y,rsv1:!1};if(N5($))if(this._state!==U9)this.enqueue([this.getBlobData,$,!1,Q,J]);else this.getBlobData($,!1,Q,J);else if(this._state!==U9)this.enqueue([this.dispatch,$,!1,Q,J]);else this.sendFrame(K$.frame($,Q),J)}pong($,Z,J){let X,Y;if(typeof $==="string")X=Buffer.byteLength($),Y=!1;else if(N5($))X=$.size,Y=!1;else $=N7($),X=$.length,Y=N7.readOnly;if(X>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[d6]:X,fin:!0,generateMask:this._generateMask,mask:Z,maskBuffer:this._maskBuffer,opcode:10,readOnly:Y,rsv1:!1};if(N5($))if(this._state!==U9)this.enqueue([this.getBlobData,$,!1,Q,J]);else this.getBlobData($,!1,Q,J);else if(this._state!==U9)this.enqueue([this.dispatch,$,!1,Q,J]);else this.sendFrame(K$.frame($,Q),J)}send($,Z,J){let X=this._extensions[oP.extensionName],Y=Z.binary?2:1,Q=Z.compress,G,K;if(typeof $==="string")G=Buffer.byteLength($),K=!1;else if(N5($))G=$.size,K=!1;else $=N7($),G=$.length,K=N7.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Q&&X&&X.params[X._isServer?"server_no_context_takeover":"client_no_context_takeover"])Q=G>=X._threshold;this._compress=Q}else Q=!1,Y=0;if(Z.fin)this._firstFragment=!0;let W={[d6]:G,fin:Z.fin,generateMask:this._generateMask,mask:Z.mask,maskBuffer:this._maskBuffer,opcode:Y,readOnly:K,rsv1:Q};if(N5($))if(this._state!==U9)this.enqueue([this.getBlobData,$,this._compress,W,J]);else this.getBlobData($,this._compress,W,J);else if(this._state!==U9)this.enqueue([this.dispatch,$,this._compress,W,J]);else this.dispatch($,this._compress,W,J)}getBlobData($,Z,J,X){this._bufferedBytes+=J[d6],this._state=lr,$.arrayBuffer().then((Y)=>{if(this._socket.destroyed){let G=Error("The socket was closed while the blob was being read");process.nextTick(jq,this,G,X);return}this._bufferedBytes-=J[d6];let Q=N7(Y);if(!Z)this._state=U9,this.sendFrame(K$.frame(Q,J),X),this.dequeue();else this.dispatch(Q,Z,J,X)}).catch((Y)=>{process.nextTick(ir,this,Y,X)})}dispatch($,Z,J,X){if(!Z){this.sendFrame(K$.frame($,J),X);return}let Y=this._extensions[oP.extensionName];this._bufferedBytes+=J[d6],this._state=pr,Y.compress($,J.fin,(Q,G)=>{if(this._socket.destroyed){let K=Error("The socket was closed while data was being compressed");jq(this,K,X);return}this._bufferedBytes-=J[d6],this._state=U9,J.readOnly=!1,this.sendFrame(K$.frame(G,J),X),this.dequeue()})}dequeue(){while(this._state===U9&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][d6],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][d6],this._queue.push($)}sendFrame($,Z){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],Z),this._socket.uncork();else this._socket.write($[0],Z)}}sP.exports=K$;function jq($,Z,J){if(typeof J==="function")J(Z);for(let X=0;X<$._queue.length;X++){let Y=$._queue[X],Q=Y[Y.length-1];if(typeof Q==="function")Q(Z)}}function ir($,Z,J){jq($,Z,J),$.onerror(Z)}});var QI=S((GC0,YI)=>{var{kForOnEventAttribute:JY,kListener:Iq}=L4(),rP=Symbol("kCode"),tP=Symbol("kData"),eP=Symbol("kError"),$I=Symbol("kMessage"),ZI=Symbol("kReason"),L5=Symbol("kTarget"),JI=Symbol("kType"),XI=Symbol("kWasClean");class W${constructor($){this[L5]=null,this[JI]=$}get target(){return this[L5]}get type(){return this[JI]}}Object.defineProperty(W$.prototype,"target",{enumerable:!0});Object.defineProperty(W$.prototype,"type",{enumerable:!0});class M5 extends W${constructor($,Z={}){super($);this[rP]=Z.code===void 0?0:Z.code,this[ZI]=Z.reason===void 0?"":Z.reason,this[XI]=Z.wasClean===void 0?!1:Z.wasClean}get code(){return this[rP]}get reason(){return this[ZI]}get wasClean(){return this[XI]}}Object.defineProperty(M5.prototype,"code",{enumerable:!0});Object.defineProperty(M5.prototype,"reason",{enumerable:!0});Object.defineProperty(M5.prototype,"wasClean",{enumerable:!0});class XY extends W${constructor($,Z={}){super($);this[eP]=Z.error===void 0?null:Z.error,this[$I]=Z.message===void 0?"":Z.message}get error(){return this[eP]}get message(){return this[$I]}}Object.defineProperty(XY.prototype,"error",{enumerable:!0});Object.defineProperty(XY.prototype,"message",{enumerable:!0});class cK extends W${constructor($,Z={}){super($);this[tP]=Z.data===void 0?null:Z.data}get data(){return this[tP]}}Object.defineProperty(cK.prototype,"data",{enumerable:!0});var nr={addEventListener($,Z,J={}){for(let Y of this.listeners($))if(!J[JY]&&Y[Iq]===Z&&!Y[JY])return;let X;if($==="message")X=function(Q,G){let K=new cK("message",{data:G?Q:Q.toString()});K[L5]=this,mK(Z,this,K)};else if($==="close")X=function(Q,G){let K=new M5("close",{code:Q,reason:G.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});K[L5]=this,mK(Z,this,K)};else if($==="error")X=function(Q){let G=new XY("error",{error:Q,message:Q.message});G[L5]=this,mK(Z,this,G)};else if($==="open")X=function(){let Q=new W$("open");Q[L5]=this,mK(Z,this,Q)};else return;if(X[JY]=!!J[JY],X[Iq]=Z,J.once)this.once($,X);else this.on($,X)},removeEventListener($,Z){for(let J of this.listeners($))if(J[Iq]===Z&&!J[JY]){this.removeListener($,J);break}}};YI.exports={CloseEvent:M5,ErrorEvent:XY,Event:W$,EventTarget:nr,MessageEvent:cK};function mK($,Z,J){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,J);else $.call(Z,J)}});var dK=S((KC0,GI)=>{var{tokenChars:YY}=B5();function f9($,Z,J){if($[Z]===void 0)$[Z]=[J];else $[Z].push(J)}function or($){let Z=Object.create(null),J=Object.create(null),X=!1,Y=!1,Q=!1,G,K,W=-1,H=-1,z=-1,V=0;for(;V<$.length;V++)if(H=$.charCodeAt(V),G===void 0)if(z===-1&&YY[H]===1){if(W===-1)W=V}else if(V!==0&&(H===32||H===9)){if(z===-1&&W!==-1)z=V}else if(H===59||H===44){if(W===-1)throw SyntaxError(`Unexpected character at index ${V}`);if(z===-1)z=V;let F=$.slice(W,z);if(H===44)f9(Z,F,J),J=Object.create(null);else G=F;W=z=-1}else throw SyntaxError(`Unexpected character at index ${V}`);else if(K===void 0)if(z===-1&&YY[H]===1){if(W===-1)W=V}else if(H===32||H===9){if(z===-1&&W!==-1)z=V}else if(H===59||H===44){if(W===-1)throw SyntaxError(`Unexpected character at index ${V}`);if(z===-1)z=V;if(f9(J,$.slice(W,z),!0),H===44)f9(Z,G,J),J=Object.create(null),G=void 0;W=z=-1}else if(H===61&&W!==-1&&z===-1)K=$.slice(W,V),W=z=-1;else throw SyntaxError(`Unexpected character at index ${V}`);else if(Y){if(YY[H]!==1)throw SyntaxError(`Unexpected character at index ${V}`);if(W===-1)W=V;else if(!X)X=!0;Y=!1}else if(Q)if(YY[H]===1){if(W===-1)W=V}else if(H===34&&W!==-1)Q=!1,z=V;else if(H===92)Y=!0;else throw SyntaxError(`Unexpected character at index ${V}`);else if(H===34&&$.charCodeAt(V-1)===61)Q=!0;else if(z===-1&&YY[H]===1){if(W===-1)W=V}else if(W!==-1&&(H===32||H===9)){if(z===-1)z=V}else if(H===59||H===44){if(W===-1)throw SyntaxError(`Unexpected character at index ${V}`);if(z===-1)z=V;let F=$.slice(W,z);if(X)F=F.replace(/\\/g,""),X=!1;if(f9(J,K,F),H===44)f9(Z,G,J),J=Object.create(null),G=void 0;K=void 0,W=z=-1}else throw SyntaxError(`Unexpected character at index ${V}`);if(W===-1||Q||H===32||H===9)throw SyntaxError("Unexpected end of input");if(z===-1)z=V;let U=$.slice(W,z);if(G===void 0)f9(Z,U,J);else{if(K===void 0)f9(J,U,!0);else if(X)f9(J,K,U.replace(/\\/g,""));else f9(J,K,U);f9(Z,G,J)}return Z}function ar($){return Object.keys($).map((Z)=>{let J=$[Z];if(!Array.isArray(J))J=[J];return J.map((X)=>{return[Z].concat(Object.keys(X).map((Y)=>{let Q=X[Y];if(!Array.isArray(Q))Q=[Q];return Q.map((G)=>G===!0?Y:`${Y}=${G}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}GI.exports={format:ar,parse:or}});var nK=S((HC0,NI)=>{var sr=Y0("events"),rr=Y0("https"),tr=Y0("http"),VI=Y0("net"),er=Y0("tls"),{randomBytes:$t,createHash:Zt}=Y0("crypto"),{Duplex:WC0,Readable:VC0}=Y0("stream"),{URL:Cq}=Y0("url"),V$=O5(),Jt=Tq(),Xt=Pq(),{isBlob:Yt}=B5(),{BINARY_TYPES:KI,CLOSE_TIMEOUT:Qt,EMPTY_BUFFER:pK,GUID:Gt,kForOnEventAttribute:wq,kListener:Kt,kStatusCode:Wt,kWebSocket:x8,NOOP:HI}=L4(),{EventTarget:{addEventListener:Vt,removeEventListener:Ht}}=QI(),{format:zt,parse:Ft}=dK(),{toBuffer:qt}=$Y(),zI=Symbol("kAborted"),Sq=[8,13],R4=["CONNECTING","OPEN","CLOSING","CLOSED"],Dt=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class a0 extends sr{constructor($,Z,J){super();if(this._binaryType=KI[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=pK,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=a0.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Z===void 0)Z=[];else if(!Array.isArray(Z))if(typeof Z==="object"&&Z!==null)J=Z,Z=[];else Z=[Z];FI(this,$,Z,J)}else this._autoPong=J.autoPong,this._closeTimeout=J.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!KI.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,Z,J){let X=new Jt({allowSynchronousEvents:J.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:J.maxBufferedChunks,maxFragments:J.maxFragments,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation}),Y=new Xt($,this._extensions,J.generateMask);if(this._receiver=X,this._sender=Y,this._socket=$,X[x8]=this,Y[x8]=this,$[x8]=this,X.on("conclude",Bt),X.on("drain",Nt),X.on("error",At),X.on("message",Lt),X.on("ping",Mt),X.on("pong",Rt),Y.onerror=Et,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(Z.length>0)$.unshift(Z);$.on("close",UI),$.on("data",iK),$.on("end",OI),$.on("error",BI),this._readyState=a0.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[V$.extensionName])this._extensions[V$.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,Z){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){j6(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===a0.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=a0.CLOSING,this._sender.close($,Z,!this._isServer,(J)=>{if(J)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),DI(this)}pause(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,Z,J){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=Z=void 0;else if(typeof Z==="function")J=Z,Z=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==a0.OPEN){_q(this,$,J);return}if(Z===void 0)Z=!this._isServer;this._sender.ping($||pK,Z,J)}pong($,Z,J){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=Z=void 0;else if(typeof Z==="function")J=Z,Z=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==a0.OPEN){_q(this,$,J);return}if(Z===void 0)Z=!this._isServer;this._sender.pong($||pK,Z,J)}resume(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,Z,J){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof Z==="function")J=Z,Z={};if(typeof $==="number")$=$.toString();if(this.readyState!==a0.OPEN){_q(this,$,J);return}let X={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...Z};if(!this._extensions[V$.extensionName])X.compress=!1;this._sender.send($||pK,X,J)}terminate(){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){j6(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=a0.CLOSING,this._socket.destroy()}}Object.defineProperty(a0,"CONNECTING",{enumerable:!0,value:R4.indexOf("CONNECTING")});Object.defineProperty(a0.prototype,"CONNECTING",{enumerable:!0,value:R4.indexOf("CONNECTING")});Object.defineProperty(a0,"OPEN",{enumerable:!0,value:R4.indexOf("OPEN")});Object.defineProperty(a0.prototype,"OPEN",{enumerable:!0,value:R4.indexOf("OPEN")});Object.defineProperty(a0,"CLOSING",{enumerable:!0,value:R4.indexOf("CLOSING")});Object.defineProperty(a0.prototype,"CLOSING",{enumerable:!0,value:R4.indexOf("CLOSING")});Object.defineProperty(a0,"CLOSED",{enumerable:!0,value:R4.indexOf("CLOSED")});Object.defineProperty(a0.prototype,"CLOSED",{enumerable:!0,value:R4.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(a0.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(a0.prototype,`on${$}`,{enumerable:!0,get(){for(let Z of this.listeners($))if(Z[wq])return Z[Kt];return null},set(Z){for(let J of this.listeners($))if(J[wq]){this.removeListener($,J);break}if(typeof Z!=="function")return;this.addEventListener($,Z,{[wq]:!0})}})});a0.prototype.addEventListener=Vt;a0.prototype.removeEventListener=Ht;NI.exports=a0;function FI($,Z,J,X){let Y={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Qt,protocolVersion:Sq[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...X,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=Y.autoPong,$._closeTimeout=Y.closeTimeout,!Sq.includes(Y.protocolVersion))throw RangeError(`Unsupported protocol version: ${Y.protocolVersion} (supported versions: ${Sq.join(", ")})`);let Q;if(Z instanceof Cq)Q=Z;else try{Q=new Cq(Z)}catch{throw SyntaxError(`Invalid URL: ${Z}`)}if(Q.protocol==="http:")Q.protocol="ws:";else if(Q.protocol==="https:")Q.protocol="wss:";$._url=Q.href;let G=Q.protocol==="wss:",K=Q.protocol==="ws+unix:",W;if(Q.protocol!=="ws:"&&!G&&!K)W=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(K&&!Q.pathname)W="The URL's pathname is empty";else if(Q.hash)W="The URL contains a fragment identifier";if(W){let D=SyntaxError(W);if($._redirects===0)throw D;else{lK($,D);return}}let H=G?443:80,z=$t(16).toString("base64"),V=G?rr.request:tr.request,U=new Set,F;if(Y.createConnection=Y.createConnection||(G?Ot:Ut),Y.defaultPort=Y.defaultPort||H,Y.port=Q.port||H,Y.host=Q.hostname.startsWith("[")?Q.hostname.slice(1,-1):Q.hostname,Y.headers={...Y.headers,"Sec-WebSocket-Version":Y.protocolVersion,"Sec-WebSocket-Key":z,Connection:"Upgrade",Upgrade:"websocket"},Y.path=Q.pathname+Q.search,Y.timeout=Y.handshakeTimeout,Y.perMessageDeflate)F=new V$({...Y.perMessageDeflate,isServer:!1,maxPayload:Y.maxPayload}),Y.headers["Sec-WebSocket-Extensions"]=zt({[V$.extensionName]:F.offer()});if(J.length){for(let D of J){if(typeof D!=="string"||!Dt.test(D)||U.has(D))throw SyntaxError("An invalid or duplicated subprotocol was specified");U.add(D)}Y.headers["Sec-WebSocket-Protocol"]=J.join(",")}if(Y.origin)if(Y.protocolVersion<13)Y.headers["Sec-WebSocket-Origin"]=Y.origin;else Y.headers.Origin=Y.origin;if(Q.username||Q.password)Y.auth=`${Q.username}:${Q.password}`;if(K){let D=Y.path.split(":");Y.socketPath=D[0],Y.path=D[1]}let q;if(Y.followRedirects){if($._redirects===0){$._originalIpc=K,$._originalSecure=G,$._originalHostOrSocketPath=K?Y.socketPath:Q.host;let D=X&&X.headers;if(X={...X,headers:{}},D)for(let[O,B]of Object.entries(D))X.headers[O.toLowerCase()]=B}else if($.listenerCount("redirect")===0){let D=K?$._originalIpc?Y.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:Q.host===$._originalHostOrSocketPath;if(!D||$._originalSecure&&!G){if(delete Y.headers.authorization,delete Y.headers.cookie,!D)delete Y.headers.host;Y.auth=void 0}}if(Y.auth&&!X.headers.authorization)X.headers.authorization="Basic "+Buffer.from(Y.auth).toString("base64");if(q=$._req=V(Y),$._redirects)$.emit("redirect",$.url,q)}else q=$._req=V(Y);if(Y.timeout)q.on("timeout",()=>{j6($,q,"Opening handshake has timed out")});if(q.on("error",(D)=>{if(q===null||q[zI])return;q=$._req=null,lK($,D)}),q.on("response",(D)=>{let O=D.headers.location,B=D.statusCode;if(O&&Y.followRedirects&&B>=300&&B<400){if(++$._redirects>Y.maxRedirects){j6($,q,"Maximum redirects exceeded");return}q.abort();let A;try{A=new Cq(O,Z)}catch(L){let M=SyntaxError(`Invalid URL: ${O}`);lK($,M);return}FI($,A,J,X)}else if(!$.emit("unexpected-response",q,D))j6($,q,`Unexpected server response: ${D.statusCode}`)}),q.on("upgrade",(D,O,B)=>{if($.emit("upgrade",D),$.readyState!==a0.CONNECTING)return;q=$._req=null;let A=D.headers.upgrade;if(A===void 0||A.toLowerCase()!=="websocket"){j6($,O,"Invalid Upgrade header");return}let L=Zt("sha1").update(z+Gt).digest("base64");if(D.headers["sec-websocket-accept"]!==L){j6($,O,"Invalid Sec-WebSocket-Accept header");return}let M=D.headers["sec-websocket-protocol"],E;if(M!==void 0){if(!U.size)E="Server sent a subprotocol but none was requested";else if(!U.has(M))E="Server sent an invalid subprotocol"}else if(U.size)E="Server sent no subprotocol";if(E){j6($,O,E);return}if(M)$._protocol=M;let y=D.headers["sec-websocket-extensions"];if(y!==void 0){if(!F){j6($,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=Ft(y)}catch(w){j6($,O,"Invalid Sec-WebSocket-Extensions header");return}let T=Object.keys(C);if(T.length!==1||T[0]!==V$.extensionName){j6($,O,"Server indicated an extension that was not requested");return}try{F.accept(C[V$.extensionName])}catch(w){j6($,O,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[V$.extensionName]=F}$.setSocket(O,B,{allowSynchronousEvents:Y.allowSynchronousEvents,generateMask:Y.generateMask,maxBufferedChunks:Y.maxBufferedChunks,maxFragments:Y.maxFragments,maxPayload:Y.maxPayload,skipUTF8Validation:Y.skipUTF8Validation})}),Y.finishRequest)Y.finishRequest(q,$);else q.end()}function lK($,Z){$._readyState=a0.CLOSING,$._errorEmitted=!0,$.emit("error",Z),$.emitClose()}function Ut($){return $.path=$.socketPath,VI.connect($)}function Ot($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=VI.isIP($.host)?"":$.host;return er.connect($)}function j6($,Z,J){$._readyState=a0.CLOSING;let X=Error(J);if(Error.captureStackTrace(X,j6),Z.setHeader){if(Z[zI]=!0,Z.abort(),Z.socket&&!Z.socket.destroyed)Z.socket.destroy();process.nextTick(lK,$,X)}else Z.destroy(X),Z.once("error",$.emit.bind($,"error")),Z.once("close",$.emitClose.bind($))}function _q($,Z,J){if(Z){let X=Yt(Z)?Z.size:qt(Z).length;if($._socket)$._sender._bufferedBytes+=X;else $._bufferedAmount+=X}if(J){let X=Error(`WebSocket is not open: readyState ${$.readyState} (${R4[$.readyState]})`);process.nextTick(J,X)}}function Bt($,Z){let J=this[x8];if(J._closeFrameReceived=!0,J._closeMessage=Z,J._closeCode=$,J._socket[x8]===void 0)return;if(J._socket.removeListener("data",iK),process.nextTick(qI,J._socket),$===1005)J.close();else J.close($,Z)}function Nt(){let $=this[x8];if(!$.isPaused)$._socket.resume()}function At($){let Z=this[x8];if(Z._socket[x8]!==void 0)Z._socket.removeListener("data",iK),process.nextTick(qI,Z._socket),Z.close($[Wt]);if(!Z._errorEmitted)Z._errorEmitted=!0,Z.emit("error",$)}function WI(){this[x8].emitClose()}function Lt($,Z){this[x8].emit("message",$,Z)}function Mt($){let Z=this[x8];if(Z._autoPong)Z.pong($,!this._isServer,HI);Z.emit("ping",$)}function Rt($){this[x8].emit("pong",$)}function qI($){$.resume()}function Et($){let Z=this[x8];if(Z.readyState===a0.CLOSED)return;if(Z.readyState===a0.OPEN)Z._readyState=a0.CLOSING,DI(Z);if(this._socket.end(),!Z._errorEmitted)Z._errorEmitted=!0,Z.emit("error",$)}function DI($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function UI(){let $=this[x8];if(this.removeListener("close",UI),this.removeListener("data",iK),this.removeListener("end",OI),$._readyState=a0.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let Z=this.read(this._readableState.length);$._receiver.write(Z)}if($._receiver.end(),this[x8]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",WI),$._receiver.on("finish",WI)}function iK($){if(!this[x8]._receiver.write($))this.pause()}function OI(){let $=this[x8];$._readyState=a0.CLOSING,$._receiver.end(),this.end()}function BI(){let $=this[x8];if(this.removeListener("error",BI),this.on("error",HI),$)$._readyState=a0.CLOSING,this.destroy()}});var RI=S((FC0,MI)=>{var zC0=nK(),{Duplex:Tt}=Y0("stream");function AI($){$.emit("close")}function jt(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function LI($){if(this.removeListener("error",LI),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function Pt($,Z){let J=!0,X=new Tt({...Z,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(Q,G){let K=!G&&X._readableState.objectMode?Q.toString():Q;if(!X.push(K))$.pause()}),$.once("error",function(Q){if(X.destroyed)return;J=!1,X.destroy(Q)}),$.once("close",function(){if(X.destroyed)return;X.push(null)}),X._destroy=function(Y,Q){if($.readyState===$.CLOSED){Q(Y),process.nextTick(AI,X);return}let G=!1;if($.once("error",function(W){G=!0,Q(W)}),$.once("close",function(){if(!G)Q(Y);process.nextTick(AI,X)}),J)$.terminate()},X._final=function(Y){if($.readyState===$.CONNECTING){$.once("open",function(){X._final(Y)});return}if($._socket===null)return;if($._socket._writableState.finished){if(Y(),X._readableState.endEmitted)X.destroy()}else $._socket.once("finish",function(){Y()}),$.close()},X._read=function(){if($.isPaused)$.resume()},X._write=function(Y,Q,G){if($.readyState===$.CONNECTING){$.once("open",function(){X._write(Y,Q,G)});return}$.send(Y,G)},X.on("end",jt),X.on("error",LI),X}MI.exports=Pt});var yq=S((qC0,EI)=>{var{tokenChars:It}=B5();function Ct($){let Z=new Set,J=-1,X=-1,Y=0;for(Y;Y<$.length;Y++){let G=$.charCodeAt(Y);if(X===-1&&It[G]===1){if(J===-1)J=Y}else if(Y!==0&&(G===32||G===9)){if(X===-1&&J!==-1)X=Y}else if(G===44){if(J===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(X===-1)X=Y;let K=$.slice(J,X);if(Z.has(K))throw SyntaxError(`The "${K}" subprotocol is duplicated`);Z.add(K),J=X=-1}else throw SyntaxError(`Unexpected character at index ${Y}`)}if(J===-1||X!==-1)throw SyntaxError("Unexpected end of input");let Q=$.slice(J,Y);if(Z.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);return Z.add(Q),Z}EI.exports={parse:Ct}});var CI=S((UC0,II)=>{var wt=Y0("events"),oK=Y0("http"),{Duplex:DC0}=Y0("stream"),{createHash:St}=Y0("crypto"),TI=dK(),L7=O5(),_t=yq(),yt=nK(),{CLOSE_TIMEOUT:xt,GUID:kt,kWebSocket:ht}=L4(),vt=/^[+/0-9A-Za-z]{22}==$/;class PI extends wt{constructor($,Z){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:xt,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:yt,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=oK.createServer((J,X)=>{let Y=oK.STATUS_CODES[426];X.writeHead(426,{"Content-Length":Y.length,"Content-Type":"text/plain"}),X.end(Y)}),this._server.listen($.port,$.host,$.backlog,Z);else if($.server)this._server=$.server;if(this._server){let J=this.emit.bind(this,"connection");this._removeListeners=bt(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(X,Y,Q)=>{this.handleUpgrade(X,Y,Q,J)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(QY,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(QY,this);else this._shouldEmitClose=!0;else process.nextTick(QY,this)}else{let Z=this._server;this._removeListeners(),this._removeListeners=this._server=null,Z.close(()=>{QY(this)})}}shouldHandle($){if(this.options.path){let Z=$.url.indexOf("?");if((Z!==-1?$.url.slice(0,Z):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,Z,J,X){Z.on("error",jI);let Y=$.headers["sec-websocket-key"],Q=$.headers.upgrade,G=+$.headers["sec-websocket-version"];if($.method!=="GET"){M7(this,$,Z,405,"Invalid HTTP method");return}if(Q===void 0||Q.toLowerCase()!=="websocket"){M7(this,$,Z,400,"Invalid Upgrade header");return}if(Y===void 0||!vt.test(Y)){M7(this,$,Z,400,"Missing or invalid Sec-WebSocket-Key header");return}if(G!==13&&G!==8){M7(this,$,Z,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){GY(Z,400);return}let K=$.headers["sec-websocket-protocol"],W=new Set;if(K!==void 0)try{W=_t.parse(K)}catch(V){M7(this,$,Z,400,"Invalid Sec-WebSocket-Protocol header");return}let H=$.headers["sec-websocket-extensions"],z={};if(this.options.perMessageDeflate&&H!==void 0){let V=new L7({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let U=TI.parse(H);if(U[L7.extensionName])V.accept(U[L7.extensionName]),z[L7.extensionName]=V}catch(U){M7(this,$,Z,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let V={origin:$.headers[`${G===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(V,(U,F,q,D)=>{if(!U)return GY(Z,F||401,q,D);this.completeUpgrade(z,Y,W,$,Z,J,X)});return}if(!this.options.verifyClient(V))return GY(Z,401)}this.completeUpgrade(z,Y,W,$,Z,J,X)}completeUpgrade($,Z,J,X,Y,Q,G){if(!Y.readable||!Y.writable)return Y.destroy();if(Y[ht])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return GY(Y,503);let W=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${St("sha1").update(Z+kt).digest("base64")}`],H=new this.options.WebSocket(null,void 0,this.options);if(J.size){let z=this.options.handleProtocols?this.options.handleProtocols(J,X):J.values().next().value;if(z)W.push(`Sec-WebSocket-Protocol: ${z}`),H._protocol=z}if($[L7.extensionName]){let z=$[L7.extensionName].params,V=TI.format({[L7.extensionName]:[z]});W.push(`Sec-WebSocket-Extensions: ${V}`),H._extensions=$}if(this.emit("headers",W,X),Y.write(W.concat(`\r
72
+ `:$="Enter";break}if([...$].length===1)return $;switch($){case"Cancel":return"";case"Help":return"";case"Backspace":return"";case"Tab":return"";case"Clear":return"";case"Enter":return"";case"Shift":case"ShiftLeft":return"";case"Control":case"ControlLeft":return"";case"Alt":case"AltLeft":return"";case"Pause":return"";case"Escape":return"";case"PageUp":return"";case"PageDown":return"";case"End":return"";case"Home":return"";case"ArrowLeft":return"";case"ArrowUp":return"";case"ArrowRight":return"";case"ArrowDown":return"";case"Insert":return"";case"Delete":return"";case"NumpadEqual":return"";case"Numpad0":return"";case"Numpad1":return"";case"Numpad2":return"";case"Numpad3":return"";case"Numpad4":return"";case"Numpad5":return"";case"Numpad6":return"";case"Numpad7":return"";case"Numpad8":return"";case"Numpad9":return"";case"NumpadMultiply":return"";case"NumpadAdd":return"";case"NumpadSubtract":return"";case"NumpadDecimal":return"";case"NumpadDivide":return"";case"F1":return"";case"F2":return"";case"F3":return"";case"F4":return"";case"F5":return"";case"F6":return"";case"F7":return"";case"F8":return"";case"F9":return"";case"F10":return"";case"F11":return"";case"F12":return"";case"Meta":case"MetaLeft":return"";case"ShiftRight":return"";case"ControlRight":return"";case"AltRight":return"";case"MetaRight":return"";case"Digit0":return"0";case"Digit1":return"1";case"Digit2":return"2";case"Digit3":return"3";case"Digit4":return"4";case"Digit5":return"5";case"Digit6":return"6";case"Digit7":return"7";case"Digit8":return"8";case"Digit9":return"9";case"KeyA":return"a";case"KeyB":return"b";case"KeyC":return"c";case"KeyD":return"d";case"KeyE":return"e";case"KeyF":return"f";case"KeyG":return"g";case"KeyH":return"h";case"KeyI":return"i";case"KeyJ":return"j";case"KeyK":return"k";case"KeyL":return"l";case"KeyM":return"m";case"KeyN":return"n";case"KeyO":return"o";case"KeyP":return"p";case"KeyQ":return"q";case"KeyR":return"r";case"KeyS":return"s";case"KeyT":return"t";case"KeyU":return"u";case"KeyV":return"v";case"KeyW":return"w";case"KeyX":return"x";case"KeyY":return"y";case"KeyZ":return"z";case"Semicolon":return";";case"Equal":return"=";case"Comma":return",";case"Minus":return"-";case"Period":return".";case"Slash":return"/";case"Backquote":return"`";case"BracketLeft":return"[";case"Backslash":return"\\";case"BracketRight":return"]";case"Quote":return'"';default:throw Error(`Unknown key: "${$}"`)}},PK,Vq=($)=>{switch($){case w1.Left:return 0;case w1.Middle:return 1;case w1.Right:return 2;case w1.Back:return 3;case w1.Forward:return 4}},IK,CK;var Hq=c(()=>{KG();K1();K1();(function($){$.None="none",$.Key="key",$.Pointer="pointer",$.Wheel="wheel"})(F6||(F6={}));(function($){$.Pause="pause",$.KeyDown="keyDown",$.KeyUp="keyUp",$.PointerUp="pointerUp",$.PointerDown="pointerDown",$.PointerMove="pointerMove",$.Scroll="scroll"})(m1||(m1={}));PK=class PK extends yZ{#$;constructor($){super();this.#$=$}async down($,Z){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Key,id:"__puppeteer_keyboard",actions:[{type:m1.KeyDown,value:sX($)}]}])}async up($){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Key,id:"__puppeteer_keyboard",actions:[{type:m1.KeyUp,value:sX($)}]}])}async press($,Z={}){let{delay:J=0}=Z,X=[{type:m1.KeyDown,value:sX($)}];if(J>0)X.push({type:m1.Pause,duration:J});X.push({type:m1.KeyUp,value:sX($)}),await this.#$.mainFrame().browsingContext.performActions([{type:F6.Key,id:"__puppeteer_keyboard",actions:X}])}async type($,Z={}){let{delay:J=0}=Z,X=[...$].map(sX),Y=[];if(J<=0)for(let Q of X)Y.push({type:m1.KeyDown,value:Q},{type:m1.KeyUp,value:Q});else for(let Q of X)Y.push({type:m1.KeyDown,value:Q},{type:m1.Pause,duration:J},{type:m1.KeyUp,value:Q});await this.#$.mainFrame().browsingContext.performActions([{type:F6.Key,id:"__puppeteer_keyboard",actions:Y}])}async sendCharacter($){if([...$].length>1)throw Error("Cannot send more than 1 character.");await(await this.#$.focusedFrame()).isolatedRealm().evaluate(async(J)=>{document.execCommand("insertText",!1,J)},$)}};IK=class IK extends xZ{#$;#Z={x:0,y:0};constructor($){super();this.#$=$}async reset(){this.#Z={x:0,y:0},await this.#$.mainFrame().browsingContext.releaseActions()}async move($,Z,J={}){let X=this.#Z,Y={x:Math.round($),y:Math.round(Z)},Q=[],G=J.steps??0;for(let K=0;K<G;++K)Q.push({type:m1.PointerMove,x:X.x+(Y.x-X.x)*(K/G),y:X.y+(Y.y-X.y)*(K/G),origin:J.origin});Q.push({type:m1.PointerMove,...Y,origin:J.origin}),this.#Z=Y,await this.#$.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:"__puppeteer_mouse",actions:Q}])}async down($={}){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:"__puppeteer_mouse",actions:[{type:m1.PointerDown,button:Vq($.button??w1.Left)}]}])}async up($={}){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:"__puppeteer_mouse",actions:[{type:m1.PointerUp,button:Vq($.button??w1.Left)}]}])}async click($,Z,J={}){let X=[{type:m1.PointerMove,x:Math.round($),y:Math.round(Z),origin:J.origin}],Y={type:m1.PointerDown,button:Vq(J.button??w1.Left)},Q={type:m1.PointerUp,button:Y.button};for(let G=1;G<(J.count??1);++G)X.push(Y,Q);if(X.push(Y),J.delay)X.push({type:m1.Pause,duration:J.delay});X.push(Q),await this.#$.mainFrame().browsingContext.performActions([{type:F6.Pointer,id:"__puppeteer_mouse",actions:X}])}async wheel($={}){await this.#$.mainFrame().browsingContext.performActions([{type:F6.Wheel,id:"__puppeteer_wheel",actions:[{type:m1.Scroll,...this.#Z??{x:0,y:0},deltaX:$.deltaX??0,deltaY:$.deltaY??0}]}])}drag(){throw new L0}dragOver(){throw new L0}dragEnter(){throw new L0}drop(){throw new L0}dragAndDrop(){throw new L0}};CK=class CK extends kZ{#$;constructor($){super();this.#$=$}async touchStart($,Z,J={}){let X=this.idGenerator(),Y={width:1,height:1,pressure:0.5},Q=new DP(this.#$,this,X,$,Z,Y);return await Q.start(J),this.touches.push(Q),Q}}});function Xr($,...Z){return`() => {${$7($,...Z)}}`}function Yr($,Z){let J=$.domain.toLowerCase(),X=Z.hostname.toLowerCase();if(J===X)return!0;return J.startsWith(".")&&X.endsWith(J)}function Qr($,Z){let J=Z.pathname,X=$.path;if(J===X)return!0;if(J.startsWith(X)){if(X.endsWith("/"))return!0;if(J[X.length]==="/")return!0}return!1}function Gr($,Z){let J=new URL(Z);if(J0($!==void 0),!Yr($,J))return!1;return Qr($,J)}function SK($,Z=!1){let J=$[wK+"partitionKey"];function X(){if(typeof J==="string")return{partitionKey:J};if(typeof J==="object"&&J!==null){if(Z)return{partitionKey:{sourceOrigin:J.topLevelSite,hasCrossSiteAncestor:J.hasCrossSiteAncestor??!1}};return{partitionKey:J.topLevelSite}}return{}}return{name:$.name,value:$.value.value,domain:$.domain,path:$.path,size:$.size,httpOnly:$.httpOnly,secure:$.secure,sameSite:Wr($.sameSite),expires:$.expiry??-1,session:$.expiry===void 0||$.expiry<=0,...Kr($,"sameParty","sourceScheme","partitionKeyOpaque","priority"),...X()}}function Kr($,...Z){let J={};for(let X of Z)if($[wK+X]!==void 0)J[X]=$[wK+X];if(!J.sameParty)J.sameParty=!1;return J}function _K($,...Z){let J={};for(let X of Z)if($[X]!==void 0)J[wK+X]=$[X];return J}function Wr($){switch($){case"strict":return"Strict";case"lax":return"Lax";case"none":return"None";default:return"Default"}}function yK($){switch($){case"Strict":return"strict";case"Lax":return"lax";case"None":return"none";default:return"default"}}function xK($){return[void 0,-1].includes($)?void 0:$}function zq($){if($===void 0||typeof $==="string")return $;if($.hasCrossSiteAncestor)throw new L0("WebDriver BiDi does not support `hasCrossSiteAncestor` yet.");return $.sourceOrigin}var Jr=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},UP=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},OP=function($,Z,J){if(Z!==null&&Z!==void 0){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError("Object expected.");var X,Y;if(J){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");X=Z[Symbol.asyncDispose]}if(X===void 0){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");if(X=Z[Symbol.dispose],J)Y=X}if(typeof X!=="function")throw TypeError("Object not disposable.");if(Y)X=function(){try{Y.call(this)}catch(Q){return Promise.reject(Q)}};$.stack.push({value:Z,dispose:X,async:J})}else if(J)$.stack.push({async:!0});return Z},BP,rX,wK="goog:";var kK=c(()=>{b6();WG();OG();NG();fG();K1();D1();UG();g0();G8();S8();F5();Wq();Hq();RK();BP=function($){return function(Z){function J(G){Z.error=Z.hasError?new $(G,Z.error,"An error was suppressed during disposal."):G,Z.hasError=!0}var X,Y=0;function Q(){while(X=Z.stack.pop())try{if(!X.async&&Y===1)return Y=0,Z.stack.push(X),Promise.resolve().then(Q);if(X.dispose){var G=X.dispose.call(X.value);if(X.async)return Y|=2,Promise.resolve(G).then(Q,function(K){return J(K),Q()})}else Y|=1}catch(K){J(K)}if(Y===1)return Z.hasError?Promise.reject(Z.error):Promise.resolve();if(Z.hasError)throw Z.error}return Q()}}(typeof SuppressedError==="function"?SuppressedError:function($,Z,J){var X=Error(J);return X.name="SuppressedError",X.error=$,X.suppressed=Z,X}),rX=(()=>{let $=BX,Z,J=[],X=[];return class Y extends ${static{let Q=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(Z=[f4()],Jr(this,null,Z,{kind:"accessor",name:"trustedEmitter",static:!1,private:!1,access:{has:(G)=>("trustedEmitter"in G),get:(G)=>G.trustedEmitter,set:(G,K)=>{G.trustedEmitter=K}},metadata:Q},J,X),Q)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:Q})}static from(Q,G){let K=new Y(Q,G);return K.#K(),K}#$=UP(this,J,new q0);get trustedEmitter(){return this.#$}set trustedEmitter(Q){this.#$=Q}#Z=UP(this,X);#J;#X=null;#Q=new Set;keyboard;mouse;touchscreen;tracing;get webmcp(){throw new L0}coverage;#Y;#G;#W=new Set;_client(){return this.#J.client}constructor(Q,G){super();this.#Z=Q,this.#J=Kq.from(this,G),this.#Y=new RX(this.#J.client),this.tracing=new pZ(this.#J.client),this.coverage=new gZ(this.#J.client),this.keyboard=new PK(this),this.mouse=new IK(this),this.touchscreen=new CK(this)}#K(){this.#J.browsingContext.on("closed",()=>{this.trustedEmitter.emit("close",void 0),this.trustedEmitter.removeAllListeners()}),this.trustedEmitter.on("workercreated",(Q)=>{this.#Q.add(Q)}),this.trustedEmitter.on("workerdestroyed",(Q)=>{this.#Q.delete(Q)})}async setUserAgent(Q,G){let K,W,H;if(typeof Q==="string")K=Q,W=G;else K=Q.userAgent??null,W=Q.userAgentMetadata,H=Q.platform===""?void 0:Q.platform;if(K==="")K=null;if(await this.#J.browsingContext.setUserAgent(K),H&&H!=="")W=W??{},W.platform=H;await this.#J.browsingContext.setClientHintsOverride(W??null)}async setBypassCSP(Q){await this._client().send("Page.setBypassCSP",{enabled:Q})}async queryObjects(Q){J0(!Q.disposed,"Prototype JSHandle is disposed!"),J0(Q.id,"Prototype JSHandle must not be referencing primitive value");let G=await this.#J.client.send("Runtime.queryObjects",{prototypeObjectId:Q.id});return this.#J.mainRealm().createHandle({type:"array",handle:G.objects.objectId})}browser(){return this.browserContext().browser()}browserContext(){return this.#Z}mainFrame(){return this.#J}async triggerExtensionAction(Q){throw new L0}async emulateFocusedPage(Q){return await this.#Y.emulateFocus(Q)}resize(Q){throw new L0}async windowId(){return this.#J.browsingContext.windowId}openDevTools(){throw new L0}hasDevTools(){throw new L0}async focusedFrame(){let Q={stack:[],error:void 0,hasError:!1};try{let K=OP(Q,await this.mainFrame().isolatedRealm().evaluateHandle(()=>{let H=window;while(H.document.activeElement instanceof H.HTMLIFrameElement||H.document.activeElement instanceof H.HTMLFrameElement){if(H.document.activeElement.contentWindow===null)break;H=H.document.activeElement.contentWindow}return H}),!1).remoteValue();J0(K.type==="window");let W=this.frames().find((H)=>{return H._id===K.value.context});return J0(W),W}catch(G){Q.error=G,Q.hasError=!0}finally{BP(Q)}}frames(){let Q=[this.#J];for(let G of Q)Q.push(...G.childFrames());return Q}isClosed(){return this.#J.detached}async close(Q){let G={stack:[],error:void 0,hasError:!1};try{let K=OP(G,await this.#Z.waitForScreenshotOperations(),!1);try{await this.#J.browsingContext.close(Q?.runBeforeUnload)}catch{return}}catch(K){G.error=K,G.hasError=!0}finally{BP(G)}}async reload(Q={}){let[G]=await Promise.all([this.#J.waitForNavigation(Q),this.#J.browsingContext.reload({ignoreCache:Q.ignoreCache?!0:void 0})]).catch(MK(this.url(),Q.timeout??this._timeoutSettings.navigationTimeout()));return G}setDefaultNavigationTimeout(Q){this._timeoutSettings.setDefaultNavigationTimeout(Q)}setDefaultTimeout(Q){this._timeoutSettings.setDefaultTimeout(Q)}getDefaultTimeout(){return this._timeoutSettings.timeout()}getDefaultNavigationTimeout(){return this._timeoutSettings.navigationTimeout()}isJavaScriptEnabled(){return this.#J.browsingContext.isJavaScriptEnabled()}async setGeolocation(Q){let{longitude:G,latitude:K,accuracy:W=0}=Q;if(G<-180||G>180)throw Error(`Invalid longitude "${G}": precondition -180 <= LONGITUDE <= 180 failed.`);if(K<-90||K>90)throw Error(`Invalid latitude "${K}": precondition -90 <= LATITUDE <= 90 failed.`);if(W<0)throw Error(`Invalid accuracy "${W}": precondition 0 <= ACCURACY failed.`);return await this.#J.browsingContext.setGeolocationOverride({coordinates:{latitude:Q.latitude,longitude:Q.longitude,accuracy:Q.accuracy}})}async setJavaScriptEnabled(Q){return await this.#J.browsingContext.setJavaScriptEnabled(Q)}async emulateMediaType(Q){return await this.#Y.emulateMediaType(Q)}async emulateCPUThrottling(Q){return await this.#Y.emulateCPUThrottling(Q)}async emulateMediaFeatures(Q){return await this.#Y.emulateMediaFeatures(Q)}async emulateTimezone(Q){return await this.#J.browsingContext.setTimezoneOverride(Q)}async emulateIdleState(Q){return await this.#Y.emulateIdleState(Q)}async emulateVisionDeficiency(Q){return await this.#Y.emulateVisionDeficiency(Q)}async setViewport(Q){let G=!1;if(!this.browser().cdpSupported){let K=Q?.width&&Q?.height?{width:Q.width,height:Q.height}:null,W=Q?.deviceScaleFactor?Q.deviceScaleFactor:null,H=Q?Q.isLandscape?{natural:"landscape",type:"landscape-primary"}:{natural:"portrait",type:"portrait-primary"}:null,z=[this.#J.browsingContext.setViewport({viewport:K,devicePixelRatio:W}),this.#J.browsingContext.setScreenOrientationOverride(H)];if((this.#X?.hasTouch??!1)!==(Q?.hasTouch??!1)){G=!0;let V=Q?.hasTouch?1:null;z.push(this.#J.browsingContext.setTouchOverride(V).catch((U)=>{if(U instanceof X8&&(U.message.includes("unknown command")||U.message.includes("unsupported operation")))return;throw U}))}await Promise.all(z)}else G=await this.#Y.emulateViewport(Q);if(this.#X=Q,G)await this.reload()}viewport(){return this.#X}async pdf(Q={}){let{timeout:G=this._timeoutSettings.timeout(),path:K=void 0}=Q,{printBackground:W,margin:H,landscape:z,width:V,height:U,pageRanges:F,scale:q,preferCSSPageSize:D}=eJ(Q,"cm"),O=F?F.split(", "):[];await C1(l0(this.mainFrame().isolatedRealm().evaluate(()=>{return document.fonts.ready})).pipe(f1(t1(G))));let B=await C1(l0(this.#J.browsingContext.print({background:W,margin:H,orientation:z?"landscape":"portrait",page:{width:V,height:U},pageRanges:O,scale:q,shrinkToFit:!D})).pipe(f1(t1(G)))),A=f6(B,!0);return await this._maybeWriteTypedArrayToFile(K,A),A}async createPDFStream(Q){let G=await this.pdf(Q);return new ReadableStream({start(K){K.enqueue(G),K.close()}})}async _screenshot(Q){let{clip:G,type:K,captureBeyondViewport:W,quality:H}=Q;if(Q.omitBackground!==void 0&&Q.omitBackground)throw new L0("BiDi does not support 'omitBackground'.");if(Q.optimizeForSpeed!==void 0&&Q.optimizeForSpeed)throw new L0("BiDi does not support 'optimizeForSpeed'.");if(Q.fromSurface!==void 0&&!Q.fromSurface)throw new L0("BiDi does not support 'fromSurface'.");if(G!==void 0&&G.scale!==void 0&&G.scale!==1)throw new L0("BiDi does not support 'scale' in 'clip'.");let z;if(G)if(W)z=G;else{let[U,F]=await this.evaluate(()=>{if(!window.visualViewport)throw Error("window.visualViewport is not supported.");return[window.visualViewport.pageLeft,window.visualViewport.pageTop]});z={...G,x:G.x-U,y:G.y-F}}return await this.#J.browsingContext.captureScreenshot({origin:W?"document":"viewport",format:{type:`image/${K}`,...H!==void 0?{quality:H/100}:{}},...z?{clip:{type:"box",...z}}:{}})}async createCDPSession(){return await this.#J.createCDPSession()}async bringToFront(){await this.#J.browsingContext.activate()}async evaluateOnNewDocument(Q,...G){let K=Xr(Q,...G);return{identifier:await this.#J.browsingContext.addPreloadScript(K)}}async removeScriptToEvaluateOnNewDocument(Q){await this.#J.browsingContext.removePreloadScript(Q)}async exposeFunction(Q,G){return await this.mainFrame().exposeFunction(Q,"default"in G?G.default:G)}isDragInterceptionEnabled(){return!1}async setCacheEnabled(Q){if(!this.#Z.browser().cdpSupported){await this.#J.browsingContext.setCacheBehavior(Q?"default":"bypass");return}await this._client().send("Network.setCacheDisabled",{cacheDisabled:!Q})}async cookies(...Q){let G=(Q.length?Q:[this.url()]).map((W)=>{return new URL(W)});return(await this.#J.browsingContext.getCookies()).map((W)=>{return SK(W)}).filter((W)=>{return G.some((H)=>{return Gr(W,H)})})}isServiceWorkerBypassed(){throw new L0}target(){let Q=this.browserContext().getTargetForPage(this);if(!Q)throw Error("Target not found for page");return Q}async waitForFileChooser(Q={}){let{timeout:G=this._timeoutSettings.timeout()}=Q,K=d0.create({message:`Waiting for \`FileChooser\` failed: ${G}ms exceeded`,timeout:G});if(this.#W.add(K),Q.signal)Q.signal.addEventListener("abort",()=>{K.reject(Q.signal?.reason)},{once:!0});this.#J.browsingContext.once("filedialogopened",(W)=>{if(!W.element)return;let H=new fZ(D9.from({sharedId:W.element.sharedId,handle:W.element.handle,type:"node"},this.#J.mainRealm()),W.multiple);for(let z of this.#W)z.resolve(H),this.#W.delete(z)});try{return await K.valueOrThrow()}catch(W){throw this.#W.delete(K),W}}workers(){return[...this.#Q]}get isNetworkInterceptionEnabled(){return Boolean(this.#H)||Boolean(this.#z)}#H;async setRequestInterception(Q){this.#H=await this.#F(["beforeRequestSent"],this.#H,Q)}async setExtraHTTPHeaders(Q){await this.#J.browsingContext.setExtraHTTPHeaders(Q)}_credentials=null;#z;async authenticate(Q){this.#z=await this.#F(["authRequired"],this.#z,Boolean(Q)),this._credentials=Q}async#F(Q,G,K){if(K&&!G)return await this.#J.browsingContext.addIntercept({phases:Q});else if(!K&&G){await this.#J.browsingContext.userContext.browser.removeIntercept(G);return}return G}setDragInterception(){throw new L0}setBypassServiceWorker(){throw new L0}async setOfflineMode(Q){if(!this.#Z.browser().cdpSupported)return await this.#J.browsingContext.setOfflineMode(Q);if(!this.#G)this.#G={offline:!1,upload:-1,download:-1,latency:0};return this.#G.offline=Q,await this.#q()}async emulateNetworkConditions(Q){if(!this.#Z.browser().cdpSupported){if(!Q?.offline&&((Q?.upload??-1)>=0||(Q?.download??-1)>=0||(Q?.latency??0)>0))throw new L0;return await this.#J.browsingContext.setOfflineMode(Q?.offline??!1)}if(!this.#G)this.#G={offline:Q?.offline??!1,upload:-1,download:-1,latency:0};return this.#G.upload=Q?Q.upload:-1,this.#G.download=Q?Q.download:-1,this.#G.latency=Q?Q.latency:0,this.#G.offline=Q?.offline??!1,await this.#q()}async#q(){if(!this.#G)return;await this._client().send("Network.emulateNetworkConditions",{offline:this.#G.offline,latency:this.#G.latency,uploadThroughput:this.#G.upload,downloadThroughput:this.#G.download})}async setCookie(...Q){let G=this.url(),K=G.startsWith("http");for(let W of Q){let H=W.url||"";if(!H&&K)H=G;J0(H!=="about:blank",`Blank page can not have cookie "${W.name}"`),J0(!String.prototype.startsWith.call(H||"","data:"),`Data URL page can not have cookie "${W.name}"`),J0(W.partitionKey===void 0||typeof W.partitionKey==="string","BiDi only allows domain partition keys");let z=URL.canParse(H)?new URL(H):void 0,V=W.domain??z?.hostname;J0(V!==void 0,"At least one of the url and domain needs to be specified");let U={domain:V,name:W.name,value:{type:"string",value:W.value},...W.path!==void 0?{path:W.path}:{},...W.httpOnly!==void 0?{httpOnly:W.httpOnly}:{},...W.secure!==void 0?{secure:W.secure}:{},...W.sameSite!==void 0?{sameSite:yK(W.sameSite)}:{},...{expiry:xK(W.expires)},..._K(W,"sameParty","sourceScheme","priority","url")};if(W.partitionKey!==void 0)await this.browserContext().userContext.setCookie(U,W.partitionKey);else await this.#J.browsingContext.setCookie(U)}}async deleteCookie(...Q){await Promise.all(Q.map(async(G)=>{let K=G.url??this.url(),W=URL.canParse(K)?new URL(K):void 0,H=G.domain??W?.hostname;J0(H!==void 0,"At least one of the url and domain needs to be specified");let z={domain:H,name:G.name,...G.path!==void 0?{path:G.path}:{}};await this.#J.browsingContext.deleteCookie(z)}))}async removeExposedFunction(Q){await this.#J.removeExposedFunction(Q)}metrics(){throw new L0}async captureHeapSnapshot(Q){throw new L0}async goBack(Q={}){return await this.#V(-1,Q)}async goForward(Q={}){return await this.#V(1,Q)}async#V(Q,G){let K=new AbortController;try{let[W]=await Promise.all([this.waitForNavigation({...G,signal:K.signal}),this.#J.browsingContext.traverseHistory(Q)]);return W}catch(W){throw K.abort(),W}}async waitForDevicePrompt(Q={}){return await this.mainFrame().waitForDevicePrompt(Q)}get bluetooth(){return this.mainFrame().browsingContext.bluetooth}extensionRealms(){throw new L0}}})()});var Fq,qq,Dq,Uq;var hK=c(()=>{NX();K1();kK();Fq=class Fq extends q4{#$;constructor($){super();this.#$=$}asPage(){throw new L0}url(){return""}createCDPSession(){throw new L0}type(){return W8.BROWSER}browser(){return this.#$}browserContext(){return this.#$.defaultBrowserContext()}opener(){throw new L0}};qq=class qq extends q4{#$;constructor($){super();this.#$=$}async page(){return this.#$}async asPage(){return await this.page()}url(){return this.#$.url()}createCDPSession(){return this.#$.createCDPSession()}type(){return W8.PAGE}browser(){return this.browserContext().browser()}browserContext(){return this.#$.browserContext()}opener(){throw new L0}};Dq=class Dq extends q4{#$;#Z;constructor($){super();this.#$=$}async page(){if(this.#Z===void 0)this.#Z=rX.from(this.browserContext(),this.#$.browsingContext);return this.#Z}async asPage(){return await this.page()}url(){return this.#$.url()}createCDPSession(){return this.#$.createCDPSession()}type(){return W8.PAGE}browser(){return this.browserContext().browser()}browserContext(){return this.#$.page().browserContext()}opener(){throw new L0}};Uq=class Uq extends q4{#$;constructor($){super();this.#$=$}async page(){throw new L0}async asPage(){throw new L0}url(){return this.#$.url()}createCDPSession(){throw new L0}type(){return W8.OTHER}browser(){return this.browserContext().browser()}browserContext(){return this.#$.frame.page().browserContext()}opener(){throw new L0}}});var Vr=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},NP=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},Hr=function($,Z,J){if(Z!==null&&Z!==void 0){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError("Object expected.");var X,Y;if(J){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");X=Z[Symbol.asyncDispose]}if(X===void 0){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");if(X=Z[Symbol.dispose],J)Y=X}if(typeof X!=="function")throw TypeError("Object not disposable.");if(Y)X=function(){try{Y.call(this)}catch(Q){return Promise.reject(Q)}};$.stack.push({value:Z,dispose:X,async:J})}else if(J)$.stack.push({async:!0});return Z},zr,Oq;var Bq=c(()=>{RZ();mQ();K1();D1();g0();G8();tF();kK();hK();hK();zr=function($){return function(Z){function J(G){Z.error=Z.hasError?new $(G,Z.error,"An error was suppressed during disposal."):G,Z.hasError=!0}var X,Y=0;function Q(){while(X=Z.stack.pop())try{if(!X.async&&Y===1)return Y=0,Z.stack.push(X),Promise.resolve().then(Q);if(X.dispose){var G=X.dispose.call(X.value);if(X.async)return Y|=2,Promise.resolve(G).then(Q,function(K){return J(K),Q()})}else Y|=1}catch(K){J(K)}if(Y===1)return Z.hasError?Promise.reject(Z.error):Promise.resolve();if(Z.hasError)throw Z.error}return Q()}}(typeof SuppressedError==="function"?SuppressedError:function($,Z,J){var X=Error(J);return X.name="SuppressedError",X.error=$,X.suppressed=Z,X}),Oq=(()=>{let $=EZ,Z,J=[],X=[];return class Y extends ${static{let Q=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(Z=[f4()],Vr(this,null,Z,{kind:"accessor",name:"trustedEmitter",static:!1,private:!1,access:{has:(G)=>("trustedEmitter"in G),get:(G)=>G.trustedEmitter,set:(G,K)=>{G.trustedEmitter=K}},metadata:Q},J,X),Q)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:Q})}static from(Q,G,K){let W=new Y(Q,G,K);return W.#G(),W}#$=NP(this,J,new q0);get trustedEmitter(){return this.#$}set trustedEmitter(Q){this.#$=Q}#Z=NP(this,X);#J;userContext;#X=new WeakMap;#Q=new Map;#Y=[];constructor(Q,G,K){super();this.#Z=Q,this.userContext=G,this.#J=K.defaultViewport}#G(){for(let Q of this.userContext.browsingContexts)this.#W(Q);this.userContext.on("browsingcontext",({browsingContext:Q})=>{let G=this.#W(Q);if(Q.originalOpener){for(let K of this.userContext.browsingContexts)if(K.id===Q.originalOpener)this.#X.get(K).trustedEmitter.emit("popup",G)}}),this.userContext.on("closed",()=>{this.trustedEmitter.removeAllListeners()})}#W(Q){let G=rX.from(this,Q);this.#X.set(Q,G),G.trustedEmitter.on("close",()=>{this.#X.delete(Q)});let K=new qq(G),W=new Map;return this.#Q.set(G,[K,W]),G.trustedEmitter.on("frameattached",(H)=>{let z=H,V=new Dq(z);W.set(z,V),this.trustedEmitter.emit("targetcreated",V)}),G.trustedEmitter.on("framenavigated",(H)=>{let z=H,V=W.get(z);if(V===void 0)this.trustedEmitter.emit("targetchanged",K);else this.trustedEmitter.emit("targetchanged",V)}),G.trustedEmitter.on("framedetached",(H)=>{let z=H,V=W.get(z);if(V===void 0)return;W.delete(z),this.trustedEmitter.emit("targetdestroyed",V)}),G.trustedEmitter.on("workercreated",(H)=>{let z=H,V=new Uq(z);W.set(z,V),this.trustedEmitter.emit("targetcreated",V)}),G.trustedEmitter.on("workerdestroyed",(H)=>{let z=H,V=W.get(z);if(V===void 0)return;W.delete(H),this.trustedEmitter.emit("targetdestroyed",V)}),G.trustedEmitter.on("close",()=>{this.#Q.delete(G),this.trustedEmitter.emit("targetdestroyed",K)}),this.trustedEmitter.emit("targetcreated",K),G}targets(){return[...this.#Q.values()].flatMap(([Q,G])=>{return[Q,...G.values()]})}getTargetForPage(Q){return this.#Q.get(Q)?.[0]}async newPage(Q){let G={stack:[],error:void 0,hasError:!1};try{let K=Hr(G,await this.waitForScreenshotOperations(),!1),W=Q?.type==="window"?"window":"tab",H=await this.userContext.createBrowsingContext(W,{background:Q?.background}),z=this.#X.get(H);if(!z)throw Error("Page is not found");if(this.#J)try{await z.setViewport(this.#J)}catch(V){$0(V)}if(Q?.type==="window"&&Q?.windowBounds!==void 0)try{await this.browser().setWindowBounds(H.windowId,Q.windowBounds)}catch(V){$0(V)}return z}catch(K){G.error=K,G.hasError=!0}finally{zr(G)}}async close(){J0(this.userContext.id!==H5.DEFAULT,"Default BrowserContext cannot be closed!");try{await this.userContext.remove()}catch(Q){$0(Q)}this.#Q.clear()}browser(){return this.#Z}async pages(Q=!1){return[...this.userContext.browsingContexts].map((G)=>{return this.#X.get(G)})}async overridePermissions(Q,G){let K=new Set(G.map((W)=>{if(!J7.get(W))throw Error("Unknown permission: "+W);return W}));await Promise.all(Array.from(J7.keys()).map((W)=>{let H=this.userContext.setPermissions(Q,{name:W},K.has(W)?"granted":"denied");if(this.#Y.push({origin:Q,permission:W}),!K.has(W))return H.catch($0);return H}))}async setPermission(Q,...G){if(Q==="*")throw new L0("Origin (*) is not supported by WebDriver BiDi");await Promise.all(G.map((K)=>{if(K.permission.allowWithoutSanitization)throw new L0("allowWithoutSanitization is not supported by WebDriver BiDi");if(K.permission.panTiltZoom)throw new L0("panTiltZoom is not supported by WebDriver BiDi");if(K.permission.userVisibleOnly)throw new L0("userVisibleOnly is not supported by WebDriver BiDi");return this.userContext.setPermissions(Q,{name:K.permission.name},K.state)}))}async clearPermissionOverrides(){let Q=this.#Y.map(({permission:G,origin:K})=>{return this.userContext.setPermissions(K,{name:G},"prompt").catch($0)});this.#Y=[],await Promise.all(Q)}get id(){if(this.userContext.id===H5.DEFAULT)return;return this.userContext.id}async cookies(){return(await this.userContext.getCookies()).map((G)=>{return SK(G,!0)})}async setCookie(...Q){await Promise.all(Q.map(async(G)=>{let K={domain:G.domain,name:G.name,value:{type:"string",value:G.value},...G.path!==void 0?{path:G.path}:{},...G.httpOnly!==void 0?{httpOnly:G.httpOnly}:{},...G.secure!==void 0?{secure:G.secure}:{},...G.sameSite!==void 0?{sameSite:yK(G.sameSite)}:{},...{expiry:xK(G.expires)},..._K(G,"sameParty","sourceScheme","priority","url")};return await this.userContext.setCookie(K,zq(G.partitionKey))}))}}})()});var Fr=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},b9=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},qr=function($,Z,J){if(Z!==null&&Z!==void 0){if(typeof Z!=="object"&&typeof Z!=="function")throw TypeError("Object expected.");var X,Y;if(J){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");X=Z[Symbol.asyncDispose]}if(X===void 0){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");if(X=Z[Symbol.dispose],J)Y=X}if(typeof X!=="function")throw TypeError("Object not disposable.");if(Y)X=function(){try{Y.call(this)}catch(Q){return Promise.reject(Q)}};$.stack.push({value:Z,dispose:X,async:J})}else if(J)$.stack.push({async:!0});return Z},Dr,AP;var LP=c(()=>{K1();D1();G8();E1();rF();tF();Dr=function($){return function(Z){function J(G){Z.error=Z.hasError?new $(G,Z.error,"An error was suppressed during disposal."):G,Z.hasError=!0}var X,Y=0;function Q(){while(X=Z.stack.pop())try{if(!X.async&&Y===1)return Y=0,Z.stack.push(X),Promise.resolve().then(Q);if(X.dispose){var G=X.dispose.call(X.value);if(X.async)return Y|=2,Promise.resolve(G).then(Q,function(K){return J(K),Q()})}else Y|=1}catch(K){J(K)}if(Y===1)return Z.hasError?Promise.reject(Z.error):Promise.resolve();if(Z.hasError)throw Z.error}return Q()}}(typeof SuppressedError==="function"?SuppressedError:function($,Z,J){var X=Error(J);return X.name="SuppressedError",X.error=$,X.suppressed=Z,X}),AP=(()=>{let $=q0,Z=[],J,X,Y,Q,G,K,W,H,z,V;return class U extends ${static{let F=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(b9(this,null,J,{kind:"method",name:"dispose",static:!1,private:!1,access:{has:(q)=>("dispose"in q),get:(q)=>q.dispose},metadata:F},null,Z),b9(this,null,X,{kind:"method",name:"close",static:!1,private:!1,access:{has:(q)=>("close"in q),get:(q)=>q.close},metadata:F},null,Z),b9(this,null,Y,{kind:"method",name:"addPreloadScript",static:!1,private:!1,access:{has:(q)=>("addPreloadScript"in q),get:(q)=>q.addPreloadScript},metadata:F},null,Z),b9(this,null,Q,{kind:"method",name:"removeIntercept",static:!1,private:!1,access:{has:(q)=>("removeIntercept"in q),get:(q)=>q.removeIntercept},metadata:F},null,Z),b9(this,null,G,{kind:"method",name:"removePreloadScript",static:!1,private:!1,access:{has:(q)=>("removePreloadScript"in q),get:(q)=>q.removePreloadScript},metadata:F},null,Z),b9(this,null,K,{kind:"method",name:"createUserContext",static:!1,private:!1,access:{has:(q)=>("createUserContext"in q),get:(q)=>q.createUserContext},metadata:F},null,Z),b9(this,null,W,{kind:"method",name:"installExtension",static:!1,private:!1,access:{has:(q)=>("installExtension"in q),get:(q)=>q.installExtension},metadata:F},null,Z),b9(this,null,H,{kind:"method",name:"uninstallExtension",static:!1,private:!1,access:{has:(q)=>("uninstallExtension"in q),get:(q)=>q.uninstallExtension},metadata:F},null,Z),b9(this,null,z,{kind:"method",name:"setClientWindowState",static:!1,private:!1,access:{has:(q)=>("setClientWindowState"in q),get:(q)=>q.setClientWindowState},metadata:F},null,Z),b9(this,null,V,{kind:"method",name:"getClientWindowInfo",static:!1,private:!1,access:{has:(q)=>("getClientWindowInfo"in q),get:(q)=>q.getClientWindowInfo},metadata:F},null,Z),F)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:F})}static async from(F){let q=new U(F);return await q.#Y(),q}#$=(Fr(this,Z),!1);#Z;#J=new G1;#X=new Map;session;#Q=new Map;constructor(F){super();this.session=F}async#Y(){let F=this.#J.use(new q0(this.session));F.once("ended",({reason:q})=>{this.dispose(q)}),F.on("script.realmCreated",(q)=>{if(q.type!=="shared-worker")return;this.#Q.set(q.realm,DK.from(this,q.realm,q.origin))}),await this.#G(),await this.#W()}async#G(){let{result:{userContexts:F}}=await this.session.send("browser.getUserContexts",{});for(let q of F)this.#K(q.userContext)}async#W(){let F=new Set,q;{let D={stack:[],error:void 0,hasError:!1};try{qr(D,new q0(this.session),!1).on("browsingContext.contextCreated",(A)=>{F.add(A.context)});let{result:B}=await this.session.send("browsingContext.getTree",{});q=B.contexts}catch(O){D.error=O,D.hasError=!0}finally{Dr(D)}}for(let D of q){if(!F.has(D.context))this.session.emit("browsingContext.contextCreated",D);if(D.children)q.push(...D.children)}}#K(F){let q=H5.create(this,F);this.#X.set(q.id,q);let D=this.#J.use(new q0(q));return D.once("closed",()=>{D.removeAllListeners(),this.#X.delete(q.id)}),q}get closed(){return this.#$}get defaultUserContext(){return this.#X.get(H5.DEFAULT)}get disconnected(){return this.#Z!==void 0}get disposed(){return this.disconnected}get userContexts(){return this.#X.values()}dispose(F,q=!1){this.#$=q,this.#Z=F,this[A0]()}async close(){try{await this.session.send("browser.close",{})}finally{this.dispose("Browser already closed.",!0)}}async addPreloadScript(F,q={}){let{result:{script:D}}=await this.session.send("script.addPreloadScript",{functionDeclaration:F,...q,contexts:q.contexts?.map((O)=>{return O.id})});return D}async removeIntercept(F){await this.session.send("network.removeIntercept",{intercept:F})}async removePreloadScript(F){await this.session.send("script.removePreloadScript",{script:F})}async createUserContext(F){let q=F.proxyServer===void 0?void 0:{proxyType:"manual",httpProxy:F.proxyServer,sslProxy:F.proxyServer,noProxy:F.proxyBypassList},{result:{userContext:D}}=await this.session.send("browser.createUserContext",{proxy:q});if(F.downloadBehavior?.policy==="allowAndName")throw new L0("`allowAndName` is not supported in WebDriver BiDi");if(F.downloadBehavior?.policy==="allow"){if(F.downloadBehavior.downloadPath===void 0)throw new L0("`downloadPath` is required in `allow` download behavior");await this.session.send("browser.setDownloadBehavior",{downloadBehavior:{type:"allowed",destinationFolder:F.downloadBehavior.downloadPath},userContexts:[D]})}if(F.downloadBehavior?.policy==="deny")await this.session.send("browser.setDownloadBehavior",{downloadBehavior:{type:"denied"},userContexts:[D]});return this.#K(D)}async installExtension(F){let{result:{extension:q}}=await this.session.send("webExtension.install",{extensionData:{type:"path",path:F}});return q}async uninstallExtension(F){await this.session.send("webExtension.uninstall",{extension:F})}async setClientWindowState(F){await this.session.send("browser.setClientWindowState",F)}async getClientWindowInfo(F){let{result:{clientWindows:q}}=await this.session.send("browser.getClientWindows",{}),D=q.find((O)=>{return O.clientWindow===F});if(!D)throw Error("Window not found");return D}[(J=[o8],X=[F0((F)=>{return F.#Z})],Y=[F0((F)=>{return F.#Z})],Q=[F0((F)=>{return F.#Z})],G=[F0((F)=>{return F.#Z})],K=[F0((F)=>{return F.#Z})],W=[F0((F)=>{return F.#Z})],H=[F0((F)=>{return F.#Z})],z=[F0((F)=>{return F.#Z})],V=[F0((F)=>{return F.#Z})],A0)](){if(this.#Z??="Browser was disconnected, probably because the session ended.",this.closed)this.emit("closed",{reason:this.#Z});this.emit("disconnected",{reason:this.#Z}),this.#J.dispose(),super[A0]()}}})()});var Nq=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},q5=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},MP;var RP=c(()=>{D1();G8();E1();LP();MP=(()=>{let $=q0,Z=[],J,X=[],Y=[],Q,G,K,W,H;return class z extends ${static{let V=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(q5(this,null,J,{kind:"accessor",name:"connection",static:!1,private:!1,access:{has:(U)=>("connection"in U),get:(U)=>U.connection,set:(U,F)=>{U.connection=F}},metadata:V},X,Y),q5(this,null,Q,{kind:"method",name:"dispose",static:!1,private:!1,access:{has:(U)=>("dispose"in U),get:(U)=>U.dispose},metadata:V},null,Z),q5(this,null,G,{kind:"method",name:"send",static:!1,private:!1,access:{has:(U)=>("send"in U),get:(U)=>U.send},metadata:V},null,Z),q5(this,null,K,{kind:"method",name:"subscribe",static:!1,private:!1,access:{has:(U)=>("subscribe"in U),get:(U)=>U.subscribe},metadata:V},null,Z),q5(this,null,W,{kind:"method",name:"addIntercepts",static:!1,private:!1,access:{has:(U)=>("addIntercepts"in U),get:(U)=>U.addIntercepts},metadata:V},null,Z),q5(this,null,H,{kind:"method",name:"end",static:!1,private:!1,access:{has:(U)=>("end"in U),get:(U)=>U.end},metadata:V},null,Z),V)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:V})}static async from(V,U){let{result:F}=await V.send("session.new",{capabilities:U}),q=new z(V,F);return await q.#Q(),q}#$=Nq(this,Z);#Z=new G1;#J;browser;#X=Nq(this,X,void 0);get connection(){return this.#X}set connection(V){this.#X=V}constructor(V,U){super();Nq(this,Y),this.#J=U,this.connection=V}async#Q(){this.browser=await AP.from(this),this.#Z.use(this.browser).once("closed",({reason:F})=>{this.dispose(F)});let U=new WeakSet;this.on("browsingContext.fragmentNavigated",(F)=>{if(U.has(F))return;U.add(F),this.emit("browsingContext.navigationStarted",F),this.emit("browsingContext.fragmentNavigated",F)})}get capabilities(){return this.#J.capabilities}get disposed(){return this.ended}get ended(){return this.#$!==void 0}get id(){return this.#J.sessionId}dispose(V){this.#$=V,this[A0]()}async send(V,U){return await this.connection.send(V,U)}async subscribe(V,U){await this.send("session.subscribe",{events:V,contexts:U})}async addIntercepts(V,U){await this.send("session.subscribe",{events:V,contexts:U})}async end(){try{await this.send("session.end",{})}finally{this.dispose("Session already ended.")}}[(J=[f4()],Q=[o8],G=[F0((V)=>{return V.#$})],K=[F0((V)=>{return V.#$})],W=[F0((V)=>{return V.#$})],H=[F0((V)=>{return V.#$})],A0)](){this.#$??="Session already destroyed, probably because the connection broke.",this.emit("ended",{reason:this.#$}),this.#Z.dispose(),super[A0]()}}})()});var Ur=function($,Z,J,X,Y,Q){function G(B){if(B!==void 0&&typeof B!=="function")throw TypeError("Function expected");return B}var K=X.kind,W=K==="getter"?"get":K==="setter"?"set":"value",H=!Z&&$?X.static?$:$.prototype:null,z=Z||(H?Object.getOwnPropertyDescriptor(H,X.name):{}),V,U=!1;for(var F=J.length-1;F>=0;F--){var q={};for(var D in X)q[D]=D==="access"?{}:X[D];for(var D in X.access)q.access[D]=X.access[D];q.addInitializer=function(B){if(U)throw TypeError("Cannot add initializers after decoration has completed");Q.push(G(B||null))};var O=(0,J[F])(K==="accessor"?{get:z.get,set:z.set}:z[W],q);if(K==="accessor"){if(O===void 0)continue;if(O===null||typeof O!=="object")throw TypeError("Object expected");if(V=G(O.get))z.get=V;if(V=G(O.set))z.set=V;if(V=G(O.init))Y.unshift(V)}else if(V=G(O))if(K==="field")Y.unshift(V);else z[W]=V}if(H)Object.defineProperty(H,X.name,z);U=!0},EP=function($,Z,J){var X=arguments.length>2;for(var Y=0;Y<Z.length;Y++)J=X?Z[Y].call($,J):Z[Y].call($);return X?J:void 0},TP=function($,Z,J){if(typeof Z==="symbol")Z=Z.description?"[".concat(Z.description,"]"):"";return Object.defineProperty($,"name",{configurable:!0,value:J?"".concat(J," ",Z):Z})},Or;var jP=c(()=>{RZ();K1();D1();g0();G8();Bq();RP();hK();Or=(()=>{let $=MZ,Z,J=[],X=[],Y;return class Q extends ${static{let G=typeof Symbol==="function"&&Symbol.metadata?Object.create($[Symbol.metadata]??null):void 0;if(Z=[f4()],Ur(this,Y={get:TP(function(){return this.#$},"#trustedEmitter","get"),set:TP(function(K){this.#$=K},"#trustedEmitter","set")},Z,{kind:"accessor",name:"#trustedEmitter",static:!1,private:!0,access:{has:(K)=>(#Z in K),get:(K)=>K.#Z,set:(K,W)=>{K.#Z=W}},metadata:G},J,X),G)Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:G})}protocol="webDriverBiDi";static subscribeModules=["browsingContext","network","log","script","input"];static subscribeCdpEvents=["goog:cdp.Debugger.scriptParsed","goog:cdp.CSS.styleSheetAdded","goog:cdp.Runtime.executionContextsCleared","goog:cdp.Tracing.tracingComplete","goog:cdp.Network.requestWillBeSent","goog:cdp.Debugger.scriptParsed","goog:cdp.Page.screencastFrame"];static async create(G){let K=await MP.from(G.connection,{firstMatch:G.capabilities?.firstMatch,alwaysMatch:{...G.capabilities?.alwaysMatch,acceptInsecureCerts:G.acceptInsecureCerts,unhandledPromptBehavior:{default:"ignore"},webSocketUrl:!0,"goog:prerenderingDisabled":!0,"goog:disableNetworkDurableMessages":!0}});await K.subscribe((G.cdpConnection?[...Q.subscribeModules,...Q.subscribeCdpEvents]:Q.subscribeModules).filter((H)=>{if(!G.networkEnabled)return H!=="network"&&H!=="goog:cdp.Network.requestWillBeSent";return!0})),await Promise.all(["request","response"].map(async(H)=>{try{await K.send("network.addDataCollector",{dataTypes:[H],maxEncodedDataSize:20000000})}catch(z){if(z instanceof X8)$0(z);else throw z}}));let W=new Q(K.browser,G);return W.#F(),W}#$=EP(this,J,new q0);get#Z(){return Y.get.call(this)}set#Z(G){return Y.set.call(this,G)}#J=EP(this,X);#X;#Q;#Y;#G=new WeakMap;#W=new Fq(this);#K;#H;#z;constructor(G,K){super();this.#J=K.process,this.#X=K.closeCallback,this.#Q=G,this.#Y=K.defaultViewport,this.#K=K.cdpConnection,this.#H=K.networkEnabled,this.#z=K.issuesEnabled}#F(){for(let G of this.#Q.userContexts)this.#D(G);this.#Q.once("disconnected",()=>{this.#Z.emit("disconnected",void 0),this.#Z.removeAllListeners()}),this.#J?.once("close",()=>{this.#Q.dispose("Browser process exited.",!0),this.connection.dispose()})}get#q(){return this.#Q.session.capabilities.browserName}get#V(){return this.#Q.session.capabilities.browserVersion}get cdpSupported(){return this.#K!==void 0}get cdpConnection(){return this.#K}async userAgent(){return this.#Q.session.capabilities.userAgent}#D(G){let K=Oq.from(this,G,{defaultViewport:this.#Y});return this.#G.set(G,K),K.trustedEmitter.on("targetcreated",(W)=>{this.#Z.emit("targetcreated",W)}),K.trustedEmitter.on("targetchanged",(W)=>{this.#Z.emit("targetchanged",W)}),K.trustedEmitter.on("targetdestroyed",(W)=>{this.#Z.emit("targetdestroyed",W)}),K}get connection(){return this.#Q.session.connection}wsEndpoint(){return this.connection.url}async close(){if(this.connection.closed)return;try{await this.#Q.close(),await this.#X?.call(null)}catch(G){$0(G)}finally{this.connection.dispose()}}get connected(){return!this.#Q.disconnected}process(){return this.#J??null}async createBrowserContext(G={}){let K=await this.#Q.createUserContext(G);return this.#D(K)}async version(){return`${this.#q}/${this.#V}`}browserContexts(){return[...this.#Q.userContexts].map((G)=>{return this.#G.get(G)})}defaultBrowserContext(){return this.#G.get(this.#Q.defaultUserContext)}newPage(G){return this.defaultBrowserContext().newPage(G)}installExtension(G){return this.#Q.installExtension(G)}async uninstallExtension(G){await this.#Q.uninstallExtension(G)}screens(){throw new L0}addScreen(G){throw new L0}removeScreen(G){throw new L0}async getWindowBounds(G){let K=await this.#Q.getClientWindowInfo(G);return{left:K.x,top:K.y,width:K.width,height:K.height,windowState:K.state}}async setWindowBounds(G,K){let W,H=K.windowState??"normal";if(H==="normal")W={clientWindow:G,state:"normal",x:K.left,y:K.top,width:K.width,height:K.height};else W={clientWindow:G,state:H};await this.#Q.setClientWindowState(W)}targets(){return[this.#W,...this.browserContexts().flatMap((G)=>{return G.targets()})]}target(){return this.#W}async disconnect(){try{await this.#Q.session.end()}catch(G){$0(G)}finally{this.connection.dispose()}}get debugInfo(){return{pendingProtocolErrors:this.connection.getPendingProtocolErrors()}}isNetworkEnabled(){return this.#H}extensions(){throw new L0}isIssuesEnabled(){return this.#z}}})()});var tX={};k6(tX,{requests:()=>NK,convertCookiesSameSiteCdpToBiDi:()=>yK,convertCookiesPartitionKeyFromPuppeteerToBiDi:()=>zq,convertCookiesExpiryCdpToBiDi:()=>xK,connectBidiOverCdp:()=>bs,cdpSpecificCookiePropertiesFromPuppeteerToBidi:()=>_K,bidiToPuppeteerCookie:()=>SK,BidiWorkerRealm:()=>aX,BidiTouchscreen:()=>CK,BidiRealm:()=>EK,BidiPage:()=>rX,BidiMouse:()=>IK,BidiKeyboard:()=>PK,BidiJSHandle:()=>c6,BidiHTTPResponse:()=>BK,BidiHTTPRequest:()=>oX,BidiFrameRealm:()=>A4,BidiFrame:()=>Kq,BidiElementHandle:()=>D9,BidiConnection:()=>zK,BidiBrowserContext:()=>Oq,BidiBrowser:()=>Or});var eX=c(()=>{ij();jP();Bq();lF();F5();Wq();Xq();Zq();Hq();z5();kK();TK()});async function PP($,Z,J){let{acceptInsecureCerts:X=!1,networkEnabled:Y=!0,issuesEnabled:Q=!0,defaultViewport:G=e$}=J,{bidiConnection:K,cdpConnection:W,closeCallback:H}=await Br($,Z,J);return await(await Promise.resolve().then(() => (eX(),tX))).BidiBrowser.create({connection:K,cdpConnection:W,closeCallback:H,process:void 0,defaultViewport:G,acceptInsecureCerts:X,networkEnabled:Y,issuesEnabled:Q,capabilities:J.capabilities})}async function Br($,Z,J){let X=await Promise.resolve().then(() => (eX(),tX)),{slowMo:Y=0,protocolTimeout:Q,idGenerator:G=H9()}=J,K=new X.BidiConnection(Z,$,G,Y,Q);try{let V=await K.send("session.status",{});if("type"in V&&V.type==="success")return{bidiConnection:K,closeCallback:async()=>{await K.send("browser.close",{}).catch($0)}}}catch(V){if(!(V instanceof X8))throw V}K.unbind();let W=new D4(Z,$,Y,Q,!0,G);if((await W.send("Browser.getVersion")).product.toLowerCase().includes("firefox"))throw new L0("Firefox is not supported in BiDi over CDP mode.");let z=await X.connectBidiOverCdp(W);return{cdpConnection:W,bidiConnection:z,closeCallback:async()=>{await W.send("Browser.close").catch($0)}}}var IP=c(()=>{U4();K1();g0()});var L4=S((tI0,SP)=>{var CP=["nodebuffer","arraybuffer","fragments"],wP=typeof Blob<"u";if(wP)CP.push("blob");SP.exports={BINARY_TYPES:CP,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:wP,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var $Y=S((eI0,vK)=>{var{EMPTY_BUFFER:Nr}=L4(),Aq=Buffer[Symbol.species];function Ar($,Z){if($.length===0)return Nr;if($.length===1)return $[0];let J=Buffer.allocUnsafe(Z),X=0;for(let Y=0;Y<$.length;Y++){let Q=$[Y];J.set(Q,X),X+=Q.length}if(X<Z)return new Aq(J.buffer,J.byteOffset,X);return J}function _P($,Z,J,X,Y){for(let Q=0;Q<Y;Q++)J[X+Q]=$[Q]^Z[Q&3]}function yP($,Z){for(let J=0;J<$.length;J++)$[J]^=Z[J&3]}function Lr($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function Lq($){if(Lq.readOnly=!0,Buffer.isBuffer($))return $;let Z;if($ instanceof ArrayBuffer)Z=new Aq($);else if(ArrayBuffer.isView($))Z=new Aq($.buffer,$.byteOffset,$.byteLength);else Z=Buffer.from($),Lq.readOnly=!1;return Z}vK.exports={concat:Ar,mask:_P,toArrayBuffer:Lr,toBuffer:Lq,unmask:yP};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();vK.exports.mask=function(Z,J,X,Y,Q){if(Q<48)_P(Z,J,X,Y,Q);else $.mask(Z,J,X,Y,Q)},vK.exports.unmask=function(Z,J){if(Z.length<32)yP(Z,J);else $.unmask(Z,J)}}catch($){}});var vP=S(($C0,hP)=>{var xP=Symbol("kDone"),Mq=Symbol("kRun");class kP{constructor($){this[xP]=()=>{this.pending--,this[Mq]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[Mq]()}[Mq](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[xP])}}}hP.exports=kP});var O5=S((ZC0,mP)=>{var ZY=Y0("zlib"),bP=$Y(),Mr=vP(),{kStatusCode:fP}=L4(),Rr=Buffer[Symbol.species],Er=Buffer.from([0,0,255,255]),fK=Symbol("permessage-deflate"),M4=Symbol("total-length"),D5=Symbol("callback"),G$=Symbol("buffers"),U5=Symbol("error"),bK;class gP{constructor($){if(this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!bK){let Z=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;bK=new Mr(Z)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[D5];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let Z=this._options,J=$.find((X)=>{if(Z.serverNoContextTakeover===!1&&X.server_no_context_takeover||X.server_max_window_bits&&(Z.serverMaxWindowBits===!1||typeof Z.serverMaxWindowBits==="number"&&Z.serverMaxWindowBits>X.server_max_window_bits)||typeof Z.clientMaxWindowBits==="number"&&(typeof X.client_max_window_bits==="number"?Z.clientMaxWindowBits>X.client_max_window_bits:!X.client_max_window_bits))return!1;return!0});if(!J)throw Error("None of the extension offers can be accepted");if(Z.serverNoContextTakeover)J.server_no_context_takeover=!0;if(Z.clientNoContextTakeover)J.client_no_context_takeover=!0;if(typeof Z.serverMaxWindowBits==="number")J.server_max_window_bits=Z.serverMaxWindowBits;if(typeof Z.clientMaxWindowBits==="number")J.client_max_window_bits=Z.clientMaxWindowBits;else if(J.client_max_window_bits===!0||Z.clientMaxWindowBits===!1)delete J.client_max_window_bits;return J}acceptAsClient($){let Z=$[0];if(this._options.clientNoContextTakeover===!1&&Z.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!Z.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")Z.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&Z.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return Z}normalizeParams($){return $.forEach((Z)=>{Object.keys(Z).forEach((J)=>{let X=Z[J];if(X.length>1)throw Error(`Parameter "${J}" must have only a single value`);if(X=X[0],J==="client_max_window_bits"){if(X!==!0){let Y=+X;if(!Number.isInteger(Y)||Y<8||Y>15)throw TypeError(`Invalid value for parameter "${J}": ${X}`);X=Y}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${J}": ${X}`)}else if(J==="server_max_window_bits"){let Y=+X;if(!Number.isInteger(Y)||Y<8||Y>15)throw TypeError(`Invalid value for parameter "${J}": ${X}`);X=Y}else if(J==="client_no_context_takeover"||J==="server_no_context_takeover"){if(X!==!0)throw TypeError(`Invalid value for parameter "${J}": ${X}`)}else throw Error(`Unknown parameter "${J}"`);Z[J]=X})}),$}decompress($,Z,J){bK.add((X)=>{this._decompress($,Z,(Y,Q)=>{X(),J(Y,Q)})})}compress($,Z,J){bK.add((X)=>{this._compress($,Z,(Y,Q)=>{X(),J(Y,Q)})})}_decompress($,Z,J){let X=this._isServer?"client":"server";if(!this._inflate){let Y=`${X}_max_window_bits`,Q=typeof this.params[Y]!=="number"?ZY.Z_DEFAULT_WINDOWBITS:this.params[Y];this._inflate=ZY.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Q}),this._inflate[fK]=this,this._inflate[M4]=0,this._inflate[G$]=[],this._inflate.on("error",jr),this._inflate.on("data",uP)}if(this._inflate[D5]=J,this._inflate.write($),Z)this._inflate.write(Er);this._inflate.flush(()=>{let Y=this._inflate[U5];if(Y){this._inflate.close(),this._inflate=null,J(Y);return}let Q=bP.concat(this._inflate[G$],this._inflate[M4]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[M4]=0,this._inflate[G$]=[],Z&&this.params[`${X}_no_context_takeover`])this._inflate.reset();J(null,Q)})}_compress($,Z,J){let X=this._isServer?"server":"client";if(!this._deflate){let Y=`${X}_max_window_bits`,Q=typeof this.params[Y]!=="number"?ZY.Z_DEFAULT_WINDOWBITS:this.params[Y];this._deflate=ZY.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Q}),this._deflate[M4]=0,this._deflate[G$]=[],this._deflate.on("data",Tr)}this._deflate[D5]=J,this._deflate.write($),this._deflate.flush(ZY.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let Y=bP.concat(this._deflate[G$],this._deflate[M4]);if(Z)Y=new Rr(Y.buffer,Y.byteOffset,Y.length-4);if(this._deflate[D5]=null,this._deflate[M4]=0,this._deflate[G$]=[],Z&&this.params[`${X}_no_context_takeover`])this._deflate.reset();J(null,Y)})}}mP.exports=gP;function Tr($){this[G$].push($),this[M4]+=$.length}function uP($){if(this[M4]+=$.length,this[fK]._maxPayload<1||this[M4]<=this[fK]._maxPayload){this[G$].push($);return}this[U5]=RangeError("Max payload size exceeded"),this[U5].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[U5][fP]=1009,this.removeListener("data",uP),this.reset()}function jr($){if(this[fK]._inflate=null,this[U5]){this[D5](this[U5]);return}$[fP]=1007,this[D5]($)}});var B5=S((JC0,gK)=>{var{isUtf8:cP}=Y0("buffer"),{hasBlob:Pr}=L4(),Ir=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Cr($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function Rq($){let Z=$.length,J=0;while(J<Z)if(($[J]&128)===0)J++;else if(($[J]&224)===192){if(J+1===Z||($[J+1]&192)!==128||($[J]&254)===192)return!1;J+=2}else if(($[J]&240)===224){if(J+2>=Z||($[J+1]&192)!==128||($[J+2]&192)!==128||$[J]===224&&($[J+1]&224)===128||$[J]===237&&($[J+1]&224)===160)return!1;J+=3}else if(($[J]&248)===240){if(J+3>=Z||($[J+1]&192)!==128||($[J+2]&192)!==128||($[J+3]&192)!==128||$[J]===240&&($[J+1]&240)===128||$[J]===244&&$[J+1]>143||$[J]>244)return!1;J+=4}else return!1;return!0}function wr($){return Pr&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}gK.exports={isBlob:wr,isValidStatusCode:Cr,isValidUTF8:Rq,tokenChars:Ir};if(cP)gK.exports.isValidUTF8=function($){return $.length<24?Rq($):cP($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();gK.exports.isValidUTF8=function(Z){return Z.length<32?Rq(Z):$(Z)}}catch($){}});var Tq=S((XC0,nP)=>{var{Writable:Sr}=Y0("stream"),dP=O5(),{BINARY_TYPES:_r,EMPTY_BUFFER:pP,kStatusCode:yr,kWebSocket:xr}=L4(),{concat:Eq,toArrayBuffer:kr,unmask:hr}=$Y(),{isValidStatusCode:vr,isValidUTF8:lP}=B5(),uK=Buffer[Symbol.species];class iP extends Sr{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||_r[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxBufferedChunks=$.maxBufferedChunks|0,this._maxFragments=$.maxFragments|0,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[xr]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,Z,J){if(this._opcode===8&&this._state==0)return J();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){J(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(J)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let J=this._buffers[0];return this._buffers[0]=new uK(J.buffer,J.byteOffset+$,J.length-$),new uK(J.buffer,J.byteOffset,$)}let Z=Buffer.allocUnsafe($);do{let J=this._buffers[0],X=Z.length-$;if($>=J.length)Z.set(this._buffers.shift(),X);else Z.set(new Uint8Array(J.buffer,J.byteOffset,$),X),this._buffers[0]=new uK(J.buffer,J.byteOffset+$,J.length-$);$-=J.length}while($>0);return Z}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let Z=this.consume(2);if((Z[0]&48)!==0){let X=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(X);return}let J=(Z[0]&64)===64;if(J&&!this._extensions[dP.extensionName]){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(this._fin=(Z[0]&128)===128,this._opcode=Z[0]&15,this._payloadLength=Z[1]&127,this._opcode===0){if(J){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(!this._fragmented){let X=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let X=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}this._compressed=J}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let X=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(X);return}if(J){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let X=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(X);return}}else{let X=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(Z[1]&128)===128,this._isServer){if(!this._masked){let X=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(X);return}}else if(this._masked){let X=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(X);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let Z=this.consume(8),J=Z.readUInt32BE(0);if(J>Math.pow(2,21)-1){let X=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(X);return}this._payloadLength=J*Math.pow(2,32)+Z.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let Z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(Z);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let Z=pP;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(Z=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)hr(Z,this._mask)}if(this._opcode>7){this.controlMessage(Z,$);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let J=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");$(J);return}if(this._compressed){this._state=5,this.decompress(Z,$);return}if(Z.length)this._messageLength=this._totalPayloadLength,this._fragments.push(Z);this.dataMessage($)}decompress($,Z){this._extensions[dP.extensionName].decompress($,this._fin,(X,Y)=>{if(X)return Z(X);if(Y.length){if(this._messageLength+=Y.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Q=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");Z(Q);return}this._fragments.push(Y)}if(this.dataMessage(Z),this._state===0)this.startLoop(Z)})}dataMessage($){if(!this._fin){this._state=0;return}let Z=this._messageLength,J=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let X;if(this._binaryType==="nodebuffer")X=Eq(J,Z);else if(this._binaryType==="arraybuffer")X=kr(Eq(J,Z));else if(this._binaryType==="blob")X=new Blob(J);else X=J;if(this._allowSynchronousEvents)this.emit("message",X,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",X,!0),this._state=0,this.startLoop($)})}else{let X=Eq(J,Z);if(!this._skipUTF8Validation&&!lP(X)){let Y=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(Y);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",X,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",X,!1),this._state=0,this.startLoop($)})}}controlMessage($,Z){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,pP),this.end();else{let J=$.readUInt16BE(0);if(!vr(J)){let Y=this.createError(RangeError,`invalid status code ${J}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");Z(Y);return}let X=new uK($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!lP(X)){let Y=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");Z(Y);return}this._loop=!1,this.emit("conclude",J,X),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(Z)})}createError($,Z,J,X,Y){this._loop=!1,this._errored=!0;let Q=new $(J?`Invalid WebSocket frame: ${Z}`:Z);return Error.captureStackTrace(Q,this.createError),Q.code=Y,Q[yr]=X,Q}}nP.exports=iP});var Pq=S((QC0,sP)=>{var{Duplex:YC0}=Y0("stream"),{randomFillSync:br}=Y0("crypto"),{types:{isUint8Array:fr}}=Y0("util"),oP=O5(),{EMPTY_BUFFER:gr,kWebSocket:ur,NOOP:mr}=L4(),{isBlob:N5,isValidStatusCode:cr}=B5(),{mask:aP,toBuffer:N7}=$Y(),d6=Symbol("kByteLength"),dr=Buffer.alloc(4),A7,A5=8192,U9=0,pr=1,lr=2;class K${constructor($,Z,J){if(this._extensions=Z||{},J)this._generateMask=J,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=U9,this.onerror=mr,this[ur]=void 0}static frame($,Z){let J,X=!1,Y=2,Q=!1;if(Z.mask){if(J=Z.maskBuffer||dr,Z.generateMask)Z.generateMask(J);else{if(A5===8192){if(A7===void 0)A7=Buffer.alloc(8192);br(A7,0,8192),A5=0}J[0]=A7[A5++],J[1]=A7[A5++],J[2]=A7[A5++],J[3]=A7[A5++]}Q=(J[0]|J[1]|J[2]|J[3])===0,Y=6}let G;if(typeof $==="string")if((!Z.mask||Q)&&Z[d6]!==void 0)G=Z[d6];else $=Buffer.from($),G=$.length;else G=$.length,X=Z.mask&&Z.readOnly&&!Q;let K=G;if(G>=65536)Y+=8,K=127;else if(G>125)Y+=2,K=126;let W=Buffer.allocUnsafe(X?G+Y:Y);if(W[0]=Z.fin?Z.opcode|128:Z.opcode,Z.rsv1)W[0]|=64;if(W[1]=K,K===126)W.writeUInt16BE(G,2);else if(K===127)W[2]=W[3]=0,W.writeUIntBE(G,4,6);if(!Z.mask)return[W,$];if(W[1]|=128,W[Y-4]=J[0],W[Y-3]=J[1],W[Y-2]=J[2],W[Y-1]=J[3],Q)return[W,$];if(X)return aP($,J,W,Y,G),[W];return aP($,J,$,0,G),[W,$]}close($,Z,J,X){let Y;if($===void 0)Y=gr;else if(typeof $!=="number"||!cr($))throw TypeError("First argument must be a valid error code number");else if(Z===void 0||!Z.length)Y=Buffer.allocUnsafe(2),Y.writeUInt16BE($,0);else{let G=Buffer.byteLength(Z);if(G>123)throw RangeError("The message must not be greater than 123 bytes");if(Y=Buffer.allocUnsafe(2+G),Y.writeUInt16BE($,0),typeof Z==="string")Y.write(Z,2);else if(fr(Z))Y.set(Z,2);else throw TypeError("Second argument must be a string or a Uint8Array")}let Q={[d6]:Y.length,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==U9)this.enqueue([this.dispatch,Y,!1,Q,X]);else this.sendFrame(K$.frame(Y,Q),X)}ping($,Z,J){let X,Y;if(typeof $==="string")X=Buffer.byteLength($),Y=!1;else if(N5($))X=$.size,Y=!1;else $=N7($),X=$.length,Y=N7.readOnly;if(X>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[d6]:X,fin:!0,generateMask:this._generateMask,mask:Z,maskBuffer:this._maskBuffer,opcode:9,readOnly:Y,rsv1:!1};if(N5($))if(this._state!==U9)this.enqueue([this.getBlobData,$,!1,Q,J]);else this.getBlobData($,!1,Q,J);else if(this._state!==U9)this.enqueue([this.dispatch,$,!1,Q,J]);else this.sendFrame(K$.frame($,Q),J)}pong($,Z,J){let X,Y;if(typeof $==="string")X=Buffer.byteLength($),Y=!1;else if(N5($))X=$.size,Y=!1;else $=N7($),X=$.length,Y=N7.readOnly;if(X>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[d6]:X,fin:!0,generateMask:this._generateMask,mask:Z,maskBuffer:this._maskBuffer,opcode:10,readOnly:Y,rsv1:!1};if(N5($))if(this._state!==U9)this.enqueue([this.getBlobData,$,!1,Q,J]);else this.getBlobData($,!1,Q,J);else if(this._state!==U9)this.enqueue([this.dispatch,$,!1,Q,J]);else this.sendFrame(K$.frame($,Q),J)}send($,Z,J){let X=this._extensions[oP.extensionName],Y=Z.binary?2:1,Q=Z.compress,G,K;if(typeof $==="string")G=Buffer.byteLength($),K=!1;else if(N5($))G=$.size,K=!1;else $=N7($),G=$.length,K=N7.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Q&&X&&X.params[X._isServer?"server_no_context_takeover":"client_no_context_takeover"])Q=G>=X._threshold;this._compress=Q}else Q=!1,Y=0;if(Z.fin)this._firstFragment=!0;let W={[d6]:G,fin:Z.fin,generateMask:this._generateMask,mask:Z.mask,maskBuffer:this._maskBuffer,opcode:Y,readOnly:K,rsv1:Q};if(N5($))if(this._state!==U9)this.enqueue([this.getBlobData,$,this._compress,W,J]);else this.getBlobData($,this._compress,W,J);else if(this._state!==U9)this.enqueue([this.dispatch,$,this._compress,W,J]);else this.dispatch($,this._compress,W,J)}getBlobData($,Z,J,X){this._bufferedBytes+=J[d6],this._state=lr,$.arrayBuffer().then((Y)=>{if(this._socket.destroyed){let G=Error("The socket was closed while the blob was being read");process.nextTick(jq,this,G,X);return}this._bufferedBytes-=J[d6];let Q=N7(Y);if(!Z)this._state=U9,this.sendFrame(K$.frame(Q,J),X),this.dequeue();else this.dispatch(Q,Z,J,X)}).catch((Y)=>{process.nextTick(ir,this,Y,X)})}dispatch($,Z,J,X){if(!Z){this.sendFrame(K$.frame($,J),X);return}let Y=this._extensions[oP.extensionName];this._bufferedBytes+=J[d6],this._state=pr,Y.compress($,J.fin,(Q,G)=>{if(this._socket.destroyed){let K=Error("The socket was closed while data was being compressed");jq(this,K,X);return}this._bufferedBytes-=J[d6],this._state=U9,J.readOnly=!1,this.sendFrame(K$.frame(G,J),X),this.dequeue()})}dequeue(){while(this._state===U9&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][d6],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][d6],this._queue.push($)}sendFrame($,Z){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],Z),this._socket.uncork();else this._socket.write($[0],Z)}}sP.exports=K$;function jq($,Z,J){if(typeof J==="function")J(Z);for(let X=0;X<$._queue.length;X++){let Y=$._queue[X],Q=Y[Y.length-1];if(typeof Q==="function")Q(Z)}}function ir($,Z,J){jq($,Z,J),$.onerror(Z)}});var QI=S((GC0,YI)=>{var{kForOnEventAttribute:JY,kListener:Iq}=L4(),rP=Symbol("kCode"),tP=Symbol("kData"),eP=Symbol("kError"),$I=Symbol("kMessage"),ZI=Symbol("kReason"),L5=Symbol("kTarget"),JI=Symbol("kType"),XI=Symbol("kWasClean");class W${constructor($){this[L5]=null,this[JI]=$}get target(){return this[L5]}get type(){return this[JI]}}Object.defineProperty(W$.prototype,"target",{enumerable:!0});Object.defineProperty(W$.prototype,"type",{enumerable:!0});class M5 extends W${constructor($,Z={}){super($);this[rP]=Z.code===void 0?0:Z.code,this[ZI]=Z.reason===void 0?"":Z.reason,this[XI]=Z.wasClean===void 0?!1:Z.wasClean}get code(){return this[rP]}get reason(){return this[ZI]}get wasClean(){return this[XI]}}Object.defineProperty(M5.prototype,"code",{enumerable:!0});Object.defineProperty(M5.prototype,"reason",{enumerable:!0});Object.defineProperty(M5.prototype,"wasClean",{enumerable:!0});class XY extends W${constructor($,Z={}){super($);this[eP]=Z.error===void 0?null:Z.error,this[$I]=Z.message===void 0?"":Z.message}get error(){return this[eP]}get message(){return this[$I]}}Object.defineProperty(XY.prototype,"error",{enumerable:!0});Object.defineProperty(XY.prototype,"message",{enumerable:!0});class cK extends W${constructor($,Z={}){super($);this[tP]=Z.data===void 0?null:Z.data}get data(){return this[tP]}}Object.defineProperty(cK.prototype,"data",{enumerable:!0});var nr={addEventListener($,Z,J={}){for(let Y of this.listeners($))if(!J[JY]&&Y[Iq]===Z&&!Y[JY])return;let X;if($==="message")X=function(Q,G){let K=new cK("message",{data:G?Q:Q.toString()});K[L5]=this,mK(Z,this,K)};else if($==="close")X=function(Q,G){let K=new M5("close",{code:Q,reason:G.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});K[L5]=this,mK(Z,this,K)};else if($==="error")X=function(Q){let G=new XY("error",{error:Q,message:Q.message});G[L5]=this,mK(Z,this,G)};else if($==="open")X=function(){let Q=new W$("open");Q[L5]=this,mK(Z,this,Q)};else return;if(X[JY]=!!J[JY],X[Iq]=Z,J.once)this.once($,X);else this.on($,X)},removeEventListener($,Z){for(let J of this.listeners($))if(J[Iq]===Z&&!J[JY]){this.removeListener($,J);break}}};YI.exports={CloseEvent:M5,ErrorEvent:XY,Event:W$,EventTarget:nr,MessageEvent:cK};function mK($,Z,J){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,J);else $.call(Z,J)}});var dK=S((KC0,GI)=>{var{tokenChars:YY}=B5();function f9($,Z,J){if($[Z]===void 0)$[Z]=[J];else $[Z].push(J)}function or($){let Z=Object.create(null),J=Object.create(null),X=!1,Y=!1,Q=!1,G,K,W=-1,H=-1,z=-1,V=0;for(;V<$.length;V++)if(H=$.charCodeAt(V),G===void 0)if(z===-1&&YY[H]===1){if(W===-1)W=V}else if(V!==0&&(H===32||H===9)){if(z===-1&&W!==-1)z=V}else if(H===59||H===44){if(W===-1)throw SyntaxError(`Unexpected character at index ${V}`);if(z===-1)z=V;let F=$.slice(W,z);if(H===44)f9(Z,F,J),J=Object.create(null);else G=F;W=z=-1}else throw SyntaxError(`Unexpected character at index ${V}`);else if(K===void 0)if(z===-1&&YY[H]===1){if(W===-1)W=V}else if(H===32||H===9){if(z===-1&&W!==-1)z=V}else if(H===59||H===44){if(W===-1)throw SyntaxError(`Unexpected character at index ${V}`);if(z===-1)z=V;if(f9(J,$.slice(W,z),!0),H===44)f9(Z,G,J),J=Object.create(null),G=void 0;W=z=-1}else if(H===61&&W!==-1&&z===-1)K=$.slice(W,V),W=z=-1;else throw SyntaxError(`Unexpected character at index ${V}`);else if(Y){if(YY[H]!==1)throw SyntaxError(`Unexpected character at index ${V}`);if(W===-1)W=V;else if(!X)X=!0;Y=!1}else if(Q)if(YY[H]===1){if(W===-1)W=V}else if(H===34&&W!==-1)Q=!1,z=V;else if(H===92)Y=!0;else throw SyntaxError(`Unexpected character at index ${V}`);else if(H===34&&$.charCodeAt(V-1)===61)Q=!0;else if(z===-1&&YY[H]===1){if(W===-1)W=V}else if(W!==-1&&(H===32||H===9)){if(z===-1)z=V}else if(H===59||H===44){if(W===-1)throw SyntaxError(`Unexpected character at index ${V}`);if(z===-1)z=V;let F=$.slice(W,z);if(X)F=F.replace(/\\/g,""),X=!1;if(f9(J,K,F),H===44)f9(Z,G,J),J=Object.create(null),G=void 0;K=void 0,W=z=-1}else throw SyntaxError(`Unexpected character at index ${V}`);if(W===-1||Q||H===32||H===9)throw SyntaxError("Unexpected end of input");if(z===-1)z=V;let U=$.slice(W,z);if(G===void 0)f9(Z,U,J);else{if(K===void 0)f9(J,U,!0);else if(X)f9(J,K,U.replace(/\\/g,""));else f9(J,K,U);f9(Z,G,J)}return Z}function ar($){return Object.keys($).map((Z)=>{let J=$[Z];if(!Array.isArray(J))J=[J];return J.map((X)=>{return[Z].concat(Object.keys(X).map((Y)=>{let Q=X[Y];if(!Array.isArray(Q))Q=[Q];return Q.map((G)=>G===!0?Y:`${Y}=${G}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}GI.exports={format:ar,parse:or}});var nK=S((HC0,NI)=>{var sr=Y0("events"),rr=Y0("https"),tr=Y0("http"),VI=Y0("net"),er=Y0("tls"),{randomBytes:$t,createHash:Zt}=Y0("crypto"),{Duplex:WC0,Readable:VC0}=Y0("stream"),{URL:Cq}=Y0("url"),V$=O5(),Jt=Tq(),Xt=Pq(),{isBlob:Yt}=B5(),{BINARY_TYPES:KI,CLOSE_TIMEOUT:Qt,EMPTY_BUFFER:pK,GUID:Gt,kForOnEventAttribute:wq,kListener:Kt,kStatusCode:Wt,kWebSocket:x8,NOOP:HI}=L4(),{EventTarget:{addEventListener:Vt,removeEventListener:Ht}}=QI(),{format:zt,parse:Ft}=dK(),{toBuffer:qt}=$Y(),zI=Symbol("kAborted"),Sq=[8,13],R4=["CONNECTING","OPEN","CLOSING","CLOSED"],Dt=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class a0 extends sr{constructor($,Z,J){super();if(this._binaryType=KI[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=pK,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=a0.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Z===void 0)if(!J||J.protocols===void 0)Z=[];else if(Array.isArray(J.protocols))Z=J.protocols;else Z=[J.protocols];else if(!Array.isArray(Z))if(typeof Z==="object"&&Z!==null)if(J=Z,J.protocols===void 0)Z=[];else if(Array.isArray(J.protocols))Z=J.protocols;else Z=[J.protocols];else Z=[Z];FI(this,$,Z,J)}else this._autoPong=J.autoPong,this._closeTimeout=J.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!KI.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,Z,J){let X=new Jt({allowSynchronousEvents:J.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:J.maxBufferedChunks,maxFragments:J.maxFragments,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation}),Y=new Xt($,this._extensions,J.generateMask);if(this._receiver=X,this._sender=Y,this._socket=$,X[x8]=this,Y[x8]=this,$[x8]=this,X.on("conclude",Bt),X.on("drain",Nt),X.on("error",At),X.on("message",Lt),X.on("ping",Mt),X.on("pong",Rt),Y.onerror=Et,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(Z.length>0)$.unshift(Z);$.on("close",UI),$.on("data",iK),$.on("end",OI),$.on("error",BI),this._readyState=a0.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[V$.extensionName])this._extensions[V$.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,Z){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){j6(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===a0.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._sender.close($,Z,!this._isServer,(J)=>{if(J)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),this._readyState=a0.CLOSING,DI(this)}pause(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,Z,J){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=Z=void 0;else if(typeof Z==="function")J=Z,Z=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==a0.OPEN){_q(this,$,J);return}if(Z===void 0)Z=!this._isServer;this._sender.ping($||pK,Z,J)}pong($,Z,J){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=Z=void 0;else if(typeof Z==="function")J=Z,Z=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==a0.OPEN){_q(this,$,J);return}if(Z===void 0)Z=!this._isServer;this._sender.pong($||pK,Z,J)}resume(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,Z,J){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof Z==="function")J=Z,Z={};if(typeof $==="number")$=$.toString();if(this.readyState!==a0.OPEN){_q(this,$,J);return}let X={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...Z};if(!this._extensions[V$.extensionName])X.compress=!1;this._sender.send($||pK,X,J)}terminate(){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){j6(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=a0.CLOSING,this._socket.destroy()}}Object.defineProperty(a0,"CONNECTING",{enumerable:!0,value:R4.indexOf("CONNECTING")});Object.defineProperty(a0.prototype,"CONNECTING",{enumerable:!0,value:R4.indexOf("CONNECTING")});Object.defineProperty(a0,"OPEN",{enumerable:!0,value:R4.indexOf("OPEN")});Object.defineProperty(a0.prototype,"OPEN",{enumerable:!0,value:R4.indexOf("OPEN")});Object.defineProperty(a0,"CLOSING",{enumerable:!0,value:R4.indexOf("CLOSING")});Object.defineProperty(a0.prototype,"CLOSING",{enumerable:!0,value:R4.indexOf("CLOSING")});Object.defineProperty(a0,"CLOSED",{enumerable:!0,value:R4.indexOf("CLOSED")});Object.defineProperty(a0.prototype,"CLOSED",{enumerable:!0,value:R4.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(a0.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(a0.prototype,`on${$}`,{enumerable:!0,get(){for(let Z of this.listeners($))if(Z[wq])return Z[Kt];return null},set(Z){for(let J of this.listeners($))if(J[wq]){this.removeListener($,J);break}if(typeof Z!=="function")return;this.addEventListener($,Z,{[wq]:!0})}})});a0.prototype.addEventListener=Vt;a0.prototype.removeEventListener=Ht;NI.exports=a0;function FI($,Z,J,X){let Y={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Qt,protocolVersion:Sq[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...X,socketPath:void 0,hostname:void 0,protocol:void 0,protocols:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=Y.autoPong,$._closeTimeout=Y.closeTimeout,!Sq.includes(Y.protocolVersion))throw RangeError(`Unsupported protocol version: ${Y.protocolVersion} (supported versions: ${Sq.join(", ")})`);let Q;if(Z instanceof Cq)Q=Z;else try{Q=new Cq(Z)}catch{throw SyntaxError(`Invalid URL: ${Z}`)}if(Q.protocol==="http:")Q.protocol="ws:";else if(Q.protocol==="https:")Q.protocol="wss:";$._url=Q.href;let G=Q.protocol==="wss:",K=Q.protocol==="ws+unix:",W;if(Q.protocol!=="ws:"&&!G&&!K)W=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(K&&!Q.pathname)W="The URL's pathname is empty";else if(Q.hash)W="The URL contains a fragment identifier";if(W){let D=SyntaxError(W);if($._redirects===0)throw D;else{lK($,D);return}}let H=G?443:80,z=$t(16).toString("base64"),V=G?rr.request:tr.request,U=new Set,F;if(Y.createConnection=Y.createConnection||(G?Ot:Ut),Y.defaultPort=Y.defaultPort||H,Y.port=Q.port||H,Y.host=Q.hostname.startsWith("[")?Q.hostname.slice(1,-1):Q.hostname,Y.headers={...Y.headers,"Sec-WebSocket-Version":Y.protocolVersion,"Sec-WebSocket-Key":z,Connection:"Upgrade",Upgrade:"websocket"},Y.path=Q.pathname+Q.search,Y.timeout=Y.handshakeTimeout,Y.perMessageDeflate)F=new V$({...Y.perMessageDeflate,isServer:!1,maxPayload:Y.maxPayload}),Y.headers["Sec-WebSocket-Extensions"]=zt({[V$.extensionName]:F.offer()});if(J.length){for(let D of J){if(typeof D!=="string"||!Dt.test(D)||U.has(D))throw SyntaxError("An invalid or duplicated subprotocol was specified");U.add(D)}Y.headers["Sec-WebSocket-Protocol"]=J.join(",")}if(Y.origin)if(Y.protocolVersion<13)Y.headers["Sec-WebSocket-Origin"]=Y.origin;else Y.headers.Origin=Y.origin;if(Q.username||Q.password)Y.auth=`${Q.username}:${Q.password}`;if(K){let D=Y.path.split(":");Y.socketPath=D[0],Y.path=D[1]}let q;if(Y.followRedirects){if($._redirects===0){$._originalIpc=K,$._originalSecure=G,$._originalHostOrSocketPath=K?Y.socketPath:Q.host;let D=X&&X.headers;if(X={...X,headers:{}},D)for(let[O,B]of Object.entries(D))X.headers[O.toLowerCase()]=B}else if($.listenerCount("redirect")===0){let D=K?$._originalIpc?Y.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:Q.host===$._originalHostOrSocketPath;if(!D||$._originalSecure&&!G){if(delete Y.headers.authorization,delete Y.headers.cookie,!D)delete Y.headers.host;Y.auth=void 0}}if(Y.auth&&!X.headers.authorization)X.headers.authorization="Basic "+Buffer.from(Y.auth).toString("base64");if(q=$._req=V(Y),$._redirects)$.emit("redirect",$.url,q)}else q=$._req=V(Y);if(Y.timeout)q.on("timeout",()=>{j6($,q,"Opening handshake has timed out")});if(q.on("error",(D)=>{if(q===null||q[zI])return;q=$._req=null,lK($,D)}),q.on("response",(D)=>{let O=D.headers.location,B=D.statusCode;if(O&&Y.followRedirects&&B>=300&&B<400){if(++$._redirects>Y.maxRedirects){j6($,q,"Maximum redirects exceeded");return}q.abort();let A;try{A=new Cq(O,Z)}catch(L){let M=SyntaxError(`Invalid URL: ${O}`);lK($,M);return}FI($,A,J,X)}else if(!$.emit("unexpected-response",q,D))j6($,q,`Unexpected server response: ${D.statusCode}`)}),q.on("upgrade",(D,O,B)=>{if($.emit("upgrade",D),$.readyState!==a0.CONNECTING)return;q=$._req=null;let A=D.headers.upgrade;if(A===void 0||A.toLowerCase()!=="websocket"){j6($,O,"Invalid Upgrade header");return}let L=Zt("sha1").update(z+Gt).digest("base64");if(D.headers["sec-websocket-accept"]!==L){j6($,O,"Invalid Sec-WebSocket-Accept header");return}let M=D.headers["sec-websocket-protocol"],E;if(M!==void 0){if(!U.size)E="Server sent a subprotocol but none was requested";else if(!U.has(M))E="Server sent an invalid subprotocol"}else if(U.size)E="Server sent no subprotocol";if(E){j6($,O,E);return}if(M)$._protocol=M;let y=D.headers["sec-websocket-extensions"];if(y!==void 0){if(!F){j6($,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=Ft(y)}catch(w){j6($,O,"Invalid Sec-WebSocket-Extensions header");return}let T=Object.keys(C);if(T.length!==1||T[0]!==V$.extensionName){j6($,O,"Server indicated an extension that was not requested");return}try{F.accept(C[V$.extensionName])}catch(w){j6($,O,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[V$.extensionName]=F}$.setSocket(O,B,{allowSynchronousEvents:Y.allowSynchronousEvents,generateMask:Y.generateMask,maxBufferedChunks:Y.maxBufferedChunks,maxFragments:Y.maxFragments,maxPayload:Y.maxPayload,skipUTF8Validation:Y.skipUTF8Validation})}),Y.finishRequest)Y.finishRequest(q,$);else q.end()}function lK($,Z){$._readyState=a0.CLOSING,$._errorEmitted=!0,$.emit("error",Z),$.emitClose()}function Ut($){return $.path=$.socketPath,VI.connect($)}function Ot($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=VI.isIP($.host)?"":$.host;return er.connect($)}function j6($,Z,J){$._readyState=a0.CLOSING;let X=Error(J);if(Error.captureStackTrace(X,j6),Z.setHeader){if(Z[zI]=!0,Z.abort(),Z.socket&&!Z.socket.destroyed)Z.socket.destroy();process.nextTick(lK,$,X)}else Z.destroy(X),Z.once("error",$.emit.bind($,"error")),Z.once("close",$.emitClose.bind($))}function _q($,Z,J){if(Z){let X=Yt(Z)?Z.size:qt(Z).length;if($._socket)$._sender._bufferedBytes+=X;else $._bufferedAmount+=X}if(J){let X=Error(`WebSocket is not open: readyState ${$.readyState} (${R4[$.readyState]})`);process.nextTick(J,X)}}function Bt($,Z){let J=this[x8];if(J._closeFrameReceived=!0,J._closeMessage=Z,J._closeCode=$,J._socket[x8]===void 0)return;if(J._socket.removeListener("data",iK),process.nextTick(qI,J._socket),$===1005)J.close();else J.close($,Z)}function Nt(){let $=this[x8];if(!$.isPaused)$._socket.resume()}function At($){let Z=this[x8];if(Z._socket[x8]!==void 0)Z._socket.removeListener("data",iK),process.nextTick(qI,Z._socket),Z.close($[Wt]);if(!Z._errorEmitted)Z._errorEmitted=!0,Z.emit("error",$)}function WI(){this[x8].emitClose()}function Lt($,Z){this[x8].emit("message",$,Z)}function Mt($){let Z=this[x8];if(Z._autoPong)Z.pong($,!this._isServer,HI);Z.emit("ping",$)}function Rt($){this[x8].emit("pong",$)}function qI($){$.resume()}function Et($){let Z=this[x8];if(Z.readyState===a0.CLOSED)return;if(Z.readyState===a0.OPEN)Z._readyState=a0.CLOSING,DI(Z);if(this._socket.end(),!Z._errorEmitted)Z._errorEmitted=!0,Z.emit("error",$)}function DI($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function UI(){let $=this[x8];if(this.removeListener("close",UI),this.removeListener("data",iK),this.removeListener("end",OI),$._readyState=a0.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let Z=this.read(this._readableState.length);$._receiver.write(Z)}if($._receiver.end(),this[x8]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",WI),$._receiver.on("finish",WI)}function iK($){if(!this[x8]._receiver.write($))this.pause()}function OI(){let $=this[x8];$._readyState=a0.CLOSING,$._receiver.end(),this.end()}function BI(){let $=this[x8];if(this.removeListener("error",BI),this.on("error",HI),$)$._readyState=a0.CLOSING,this.destroy()}});var RI=S((FC0,MI)=>{var zC0=nK(),{Duplex:Tt}=Y0("stream");function AI($){$.emit("close")}function jt(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function LI($){if(this.removeListener("error",LI),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function Pt($,Z){let J=!0,X=new Tt({...Z,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(Q,G){let K=!G&&X._readableState.objectMode?Q.toString():Q;if(!X.push(K))$.pause()}),$.once("error",function(Q){if(X.destroyed)return;J=!1,X.destroy(Q)}),$.once("close",function(){if(X.destroyed)return;X.push(null)}),X._destroy=function(Y,Q){if($.readyState===$.CLOSED){Q(Y),process.nextTick(AI,X);return}let G=!1;if($.once("error",function(W){G=!0,Q(W)}),$.once("close",function(){if(!G)Q(Y);process.nextTick(AI,X)}),J)$.terminate()},X._final=function(Y){if($.readyState===$.CONNECTING){$.once("open",function(){X._final(Y)});return}if($._socket===null)return;if($._socket._writableState.finished){if(Y(),X._readableState.endEmitted)X.destroy()}else $._socket.once("finish",function(){Y()}),$.close()},X._read=function(){if($.isPaused)$.resume()},X._write=function(Y,Q,G){if($.readyState===$.CONNECTING){$.once("open",function(){X._write(Y,Q,G)});return}$.send(Y,G)},X.on("end",jt),X.on("error",LI),X}MI.exports=Pt});var yq=S((qC0,EI)=>{var{tokenChars:It}=B5();function Ct($){let Z=new Set,J=-1,X=-1,Y=0;for(Y;Y<$.length;Y++){let G=$.charCodeAt(Y);if(X===-1&&It[G]===1){if(J===-1)J=Y}else if(Y!==0&&(G===32||G===9)){if(X===-1&&J!==-1)X=Y}else if(G===44){if(J===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(X===-1)X=Y;let K=$.slice(J,X);if(Z.has(K))throw SyntaxError(`The "${K}" subprotocol is duplicated`);Z.add(K),J=X=-1}else throw SyntaxError(`Unexpected character at index ${Y}`)}if(J===-1||X!==-1)throw SyntaxError("Unexpected end of input");let Q=$.slice(J,Y);if(Z.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);return Z.add(Q),Z}EI.exports={parse:Ct}});var CI=S((UC0,II)=>{var wt=Y0("events"),oK=Y0("http"),{Duplex:DC0}=Y0("stream"),{createHash:St}=Y0("crypto"),TI=dK(),L7=O5(),_t=yq(),yt=nK(),{CLOSE_TIMEOUT:xt,GUID:kt,kWebSocket:ht}=L4(),vt=/^[+/0-9A-Za-z]{22}==$/;class PI extends wt{constructor($,Z){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:xt,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:yt,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=oK.createServer((J,X)=>{let Y=oK.STATUS_CODES[426];X.writeHead(426,{"Content-Length":Y.length,"Content-Type":"text/plain"}),X.end(Y)}),this._server.listen($.port,$.host,$.backlog,Z);else if($.server)this._server=$.server;if(this._server){let J=this.emit.bind(this,"connection");this._removeListeners=bt(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(X,Y,Q)=>{this.handleUpgrade(X,Y,Q,J)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(QY,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(QY,this);else this._shouldEmitClose=!0;else process.nextTick(QY,this)}else{let Z=this._server;this._removeListeners(),this._removeListeners=this._server=null,Z.close(()=>{QY(this)})}}shouldHandle($){if(this.options.path){let Z=$.url.indexOf("?");if((Z!==-1?$.url.slice(0,Z):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,Z,J,X){Z.on("error",jI);let Y=$.headers["sec-websocket-key"],Q=$.headers.upgrade,G=+$.headers["sec-websocket-version"];if($.method!=="GET"){M7(this,$,Z,405,"Invalid HTTP method");return}if(Q===void 0||Q.toLowerCase()!=="websocket"){M7(this,$,Z,400,"Invalid Upgrade header");return}if(Y===void 0||!vt.test(Y)){M7(this,$,Z,400,"Missing or invalid Sec-WebSocket-Key header");return}if(G!==13&&G!==8){M7(this,$,Z,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){GY(Z,400);return}let K=$.headers["sec-websocket-protocol"],W=new Set;if(K!==void 0)try{W=_t.parse(K)}catch(V){M7(this,$,Z,400,"Invalid Sec-WebSocket-Protocol header");return}let H=$.headers["sec-websocket-extensions"],z={};if(this.options.perMessageDeflate&&H!==void 0){let V=new L7({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let U=TI.parse(H);if(U[L7.extensionName])V.accept(U[L7.extensionName]),z[L7.extensionName]=V}catch(U){M7(this,$,Z,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let V={origin:$.headers[`${G===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(V,(U,F,q,D)=>{if(!U)return GY(Z,F||401,q,D);this.completeUpgrade(z,Y,W,$,Z,J,X)});return}if(!this.options.verifyClient(V))return GY(Z,401)}this.completeUpgrade(z,Y,W,$,Z,J,X)}completeUpgrade($,Z,J,X,Y,Q,G){if(!Y.readable||!Y.writable)return Y.destroy();if(Y[ht])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return GY(Y,503);let W=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${St("sha1").update(Z+kt).digest("base64")}`],H=new this.options.WebSocket(null,void 0,this.options);if(J.size){let z=this.options.handleProtocols?this.options.handleProtocols(J,X):J.values().next().value;if(z)W.push(`Sec-WebSocket-Protocol: ${z}`),H._protocol=z}if($[L7.extensionName]){let z=$[L7.extensionName].params,V=TI.format({[L7.extensionName]:[z]});W.push(`Sec-WebSocket-Extensions: ${V}`),H._extensions=$}if(this.emit("headers",W,X),Y.write(W.concat(`\r
73
73
  `).join(`\r
74
74
  `)),Y.removeListener("error",jI),H.setSocket(Y,Q,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(H),H.on("close",()=>{if(this.clients.delete(H),this._shouldEmitClose&&!this.clients.size)process.nextTick(QY,this)});G(H,X)}}II.exports=PI;function bt($,Z){for(let J of Object.keys(Z))$.on(J,Z[J]);return function(){for(let X of Object.keys(Z))$.removeListener(X,Z[X])}}function QY($){$._state=2,$.emit("close")}function jI(){this.destroy()}function GY($,Z,J,X){J=J||oK.STATUS_CODES[Z],X={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(J),...X},$.once("finish",$.destroy),$.end(`HTTP/1.1 ${Z} ${oK.STATUS_CODES[Z]}\r
75
75
  `+Object.keys(X).map((Y)=>`${Y}: ${X[Y]}`).join(`\r