@aikaara/chat-sdk 0.3.0 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/aikaara-chat.iife.js +233 -69
- package/dist/headless.cjs +1 -1
- package/dist/headless.d.ts +598 -1
- package/dist/headless.mjs +239 -69
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +209 -1
- package/dist/index.mjs +35 -33
- package/dist/ui-B0-Np9Dn.cjs +792 -0
- package/dist/ui-BMGa0gZH.mjs +13265 -0
- package/dist/ui.cjs +1 -621
- package/dist/ui.d.ts +300 -7
- package/dist/ui.mjs +16 -1232
- package/package.json +1 -1
- package/dist/AikaaraChatClient-Cqbcd1jb.mjs +0 -11538
- package/dist/AikaaraChatClient-kAu65hX-.cjs +0 -8
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";class as{identifier;callbacks={};sendFn;constructor(i,s){this.identifier=i,this.sendFn=s}onReceived(i){return this.callbacks.received=i,this}onConnected(i){return this.callbacks.connected=i,this}onDisconnected(i){return this.callbacks.disconnected=i,this}onRejected(i){return this.callbacks.rejected=i,this}perform(i,s={}){this.sendFn({action:i,...s})}_notifyReceived(i){this.callbacks.received?.(i)}_notifyConnected(){this.callbacks.connected?.()}_notifyDisconnected(){this.callbacks.disconnected?.()}_notifyRejected(){this.callbacks.rejected?.()}}class Ur{ws=null;url;subscriptions=new Map;welcomePromise=null;pendingSubscriptions=new Map;constructor(i){this.url=i}connect(){return new Promise((i,s)=>{this.welcomePromise={resolve:i,reject:s},this.ws=new WebSocket(this.url),this.ws.onopen=()=>{},this.ws.onmessage=a=>{this.handleMessage(a)},this.ws.onerror=()=>{const a=new Error("WebSocket connection error");this.welcomePromise?.reject(a),this.welcomePromise=null},this.ws.onclose=()=>{this.subscriptions.forEach(a=>a._notifyDisconnected())}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null),this.subscriptions.forEach(i=>i._notifyDisconnected()),this.subscriptions.clear()}subscribe(i){const s=JSON.stringify(i),a=new as(s,l=>{this.send({command:"message",identifier:s,data:JSON.stringify(l)})});return this.subscriptions.set(s,a),this.send({command:"subscribe",identifier:s}),a}subscribeAsync(i){const s=this.subscribe(i),a=s.identifier;return new Promise((l,t)=>{this.pendingSubscriptions.set(a,{resolve:()=>l(s),reject:t}),setTimeout(()=>{this.pendingSubscriptions.has(a)&&(this.pendingSubscriptions.delete(a),t(new Error(`Subscription timeout for ${a}`)))},1e4)})}unsubscribe(i){this.send({command:"unsubscribe",identifier:i}),this.subscriptions.delete(i)}perform(i,s,a={}){this.send({command:"message",identifier:i,data:JSON.stringify({action:s,...a})})}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}send(i){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(i))}handleMessage(i){let s;try{s=JSON.parse(i.data)}catch{return}switch(s.type){case"welcome":this.welcomePromise?.resolve(),this.welcomePromise=null;break;case"ping":break;case"confirm_subscription":{const a=s.identifier;this.subscriptions.get(a)?._notifyConnected();const t=this.pendingSubscriptions.get(a);t&&(t.resolve(),this.pendingSubscriptions.delete(a));break}case"reject_subscription":{const a=s.identifier;this.subscriptions.get(a)?._notifyRejected(),this.subscriptions.delete(a);const t=this.pendingSubscriptions.get(a);t&&(t.reject(new Error(`Subscription rejected: ${a}`)),this.pendingSubscriptions.delete(a));break}case"disconnect":this.subscriptions.forEach(a=>a._notifyDisconnected());break;default:{s.identifier&&s.message!==void 0&&this.subscriptions.get(s.identifier)?._notifyReceived(s.message);break}}}}class Ni{handlers=new Map;on(i,s){return this.handlers.has(i)||this.handlers.set(i,new Set),this.handlers.get(i).add(s),()=>this.off(i,s)}off(i,s){this.handlers.get(i)?.delete(s)}emit(i,s){this.handlers.get(i)?.forEach(a=>{try{a(s)}catch(l){console.error(`Error in event handler for "${i}":`,l)}})}removeAllListeners(){this.handlers.clear()}}const Va=1e3,Ga=10,Qa=400,Ya=600,Ja="#6366f1",Xa=12,Za="system-ui, -apple-system, sans-serif",el="Type a message...",tl="bottom-right",rl="light",nl={x:20,y:20},Cr="aikaara_conversation_id";class ls extends Ni{client;config;state="disconnected";reconnectAttempt=0;reconnectTimer=null;constructor(i){super(),this.config=i;const s=this.buildWsUrl(i.baseUrl,i.userToken);this.client=new Ur(s)}async connect(){this.setState("connecting");try{await this.client.connect(),this.setState("connected"),this.reconnectAttempt=0}catch(i){if(this.setState("disconnected"),this.config.reconnect!==!1)this.scheduleReconnect();else throw i}}async disconnect(){this.clearReconnectTimer(),this.client.disconnect(),this.setState("disconnected")}subscribeToConversation(i){return this.client.subscribeAsync({channel:"ConversationChannel",conversation_id:i})}sendMessage(i,s){const a=JSON.stringify({channel:"ConversationChannel",conversation_id:i});this.client.perform(a,"send_message",{content:s})}sendUserEvent(i,s,a,l){const t=JSON.stringify({channel:"ConversationChannel",conversation_id:i});this.client.perform(t,"send_user_event",{event_key:s,...a&&{value:a},...l&&{source:l}})}get connectionState(){return this.state}setState(i){this.state!==i&&(this.state=i,this.emit("connection:state",i))}scheduleReconnect(){const i=this.config.maxReconnectAttempts??Ga;if(this.reconnectAttempt>=i){this.emit("error",new Error("Max reconnection attempts reached"));return}this.setState("reconnecting");const a=(this.config.reconnectInterval??Va)*Math.pow(2,this.reconnectAttempt);this.reconnectAttempt++,this.reconnectTimer=setTimeout(async()=>{try{const l=this.buildWsUrl(this.config.baseUrl,this.config.userToken);this.client=new Ur(l),await this.connect()}catch{}},a)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}buildWsUrl(i,s){if(this.config.wsUrl){const l=this.config.wsUrl.includes("?")?"&":"?";return`${this.config.wsUrl}${l}token=${s}`}return`${i.replace(/^http/,"ws")}/cable?token=${s}`}}class us{baseUrl;apiKey;authToken;userToken;constructor(i,s,a,l){this.baseUrl=i,this.userToken=s,this.apiKey=a,this.authToken=l}async createConversation(i){const s={conversation:{...i.extUid&&{ext_uid:i.extUid},...i.systemPromptId&&{system_prompt_id:i.systemPromptId},...i.channel&&{channel:i.channel},...i.title&&{title:i.title}}};return this.request("POST","/api/v1/conversations",s)}async updateContext(i,s){const a=this.authToken?`/dashboard/sidekick_conversations/${i}`:`/api/v1/conversations/${i}`;await this.request("PATCH",a,s)}async getMessages(i){return(await this.request("GET",`/api/v1/conversations/${i}/messages`)).map(this.mapMessage)}mapMessage(i){return{id:String(i.id),conversationId:String(i.conversation_id),role:i.role,content:i.content||"",toolCalls:i.tool_calls?.map(s=>({id:s.id,type:s.type,function:s.function})),toolCallResults:i.tool_call_results,tokensInput:i.tokens_input,tokensOutput:i.tokens_output,metadata:i.metadata,createdAt:i.created_at,status:"complete"}}async request(i,s,a){const l={"Content-Type":"application/json",Accept:"application/json"};this.apiKey&&(l["X-Api-Key"]=this.apiKey),this.authToken&&(l.Authorization=`Bearer ${this.authToken}`);const t=`${this.baseUrl}${s}`,r={method:i,headers:l};a&&(r.body=JSON.stringify(a));const n=await fetch(t,r);if(!n.ok){const o=await n.text();let u;try{const p=JSON.parse(o);u=p.error||p.message||o}catch{u=o}throw new Error(`API error ${n.status}: ${u}`)}const e=await n.json();if(e&&typeof e=="object"&&"success"in e){if(!e.success)throw new Error(`API error: ${e.message||"Request failed"}`);return e.data}return e}}class cs{_messages=[];optimisticCounter=0;get messages(){return[...this._messages]}addOptimistic(i,s,a){const l={id:`optimistic_${++this.optimisticCounter}`,conversationId:a,role:i,content:s,createdAt:new Date().toISOString(),status:"sending"};return this._messages.push(l),l}reconcileOptimistic(i,s=3e4){const a=this._messages.findLast(l=>l.status==="sending"&&l.role===i.role&&l.content===i.content&&l.conversationId===i.conversationId&&Date.now()-new Date(l.createdAt).getTime()<s);return a?(a.status=i.status??"sent",a.externalId=i.externalId??i.id,i.template&&(a.template=i.template),i.attachments&&(a.attachments=i.attachments),i.metadata&&(a.metadata={...a.metadata??{},...i.metadata}),a):null}upsertRemoteMessage(i){const s=this.reconcileOptimistic(i);if(s)return{message:s,deduped:!0};const a=i.externalId?this._messages.find(l=>l.externalId&&l.externalId===i.externalId):void 0;return a?(Object.assign(a,i,{id:a.id}),{message:a,deduped:!0}):(this._messages.push(i),{message:i,deduped:!1})}updateMessageStatus(i,s){const a=this._messages.find(l=>l.externalId===i||l.id===i);return a&&(a.status=s),a}confirmOptimistic(i){const s=this._messages.find(a=>a.id===i);s&&(s.status="sent")}addStreamingMessage(i){const s={id:`streaming_${Date.now()}`,conversationId:i,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming"};return this._messages.push(s),s}updateStreaming(i){const s=this._messages.findLast(a=>a.status==="streaming");s&&(s.content=i)}appendToStreaming(i){const s=this._messages.findLast(a=>a.status==="streaming");s&&(s.content+=i)}get streamingContent(){return this._messages.findLast(s=>s.status==="streaming")?.content||""}finalizeStreaming(i){const s=this._messages.findLast(a=>a.status==="streaming");return s&&(s.status="complete",i&&(s.tokensInput=i.tokensInput,s.tokensOutput=i.tokensOutput)),s}addMessage(i){this._messages.push(i)}setMessages(i){this._messages=[...i]}clear(){this._messages=[]}}class hs{_conversationId;persist;constructor(i,s=!0){this.persist=s,this._conversationId=i||this.loadFromStorage()}get conversationId(){return this._conversationId}set conversationId(i){this._conversationId=i,this.persist&&i&&this.saveToStorage(i)}clear(){if(this._conversationId=null,this.persist)try{localStorage.removeItem(Cr)}catch{}}loadFromStorage(){if(!this.persist)return null;try{return localStorage.getItem(Cr)}catch{return null}}saveToStorage(i){try{localStorage.setItem(Cr,i)}catch{}}}var Ui=Object.defineProperty,il=Object.getOwnPropertyDescriptor,ol=Object.getOwnPropertyNames,sl=Object.prototype.hasOwnProperty,He=(f,i)=>()=>(f&&(i=f(f=0)),i),de=(f,i)=>()=>(i||f((i={exports:{}}).exports,i),i.exports),Ct=(f,i)=>{for(var s in i)Ui(f,s,{get:i[s],enumerable:!0})},al=(f,i,s,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let l of ol(i))!sl.call(f,l)&&l!==s&&Ui(f,l,{get:()=>i[l],enumerable:!(a=il(i,l))||a.enumerable});return f},Pe=f=>al(Ui({},"__esModule",{value:!0}),f),le=He(()=>{}),Re={};Ct(Re,{_debugEnd:()=>mn,_debugProcess:()=>yn,_events:()=>Cn,_eventsCount:()=>Mn,_exiting:()=>tn,_fatalExceptions:()=>pn,_getActiveHandles:()=>bs,_getActiveRequests:()=>ms,_kill:()=>on,_linkedBinding:()=>gs,_maxListeners:()=>Rn,_preload_modules:()=>On,_rawDebug:()=>Xr,_startProfilerIdleNotifier:()=>bn,_stopProfilerIdleNotifier:()=>vn,_tickCallback:()=>gn,abort:()=>En,addListener:()=>jn,allowedNodeEnvironmentFlags:()=>hn,arch:()=>Lr,argv:()=>Wr,argv0:()=>xn,assert:()=>vs,binding:()=>Kr,browser:()=>Jr,chdir:()=>Qr,config:()=>rn,cpuUsage:()=>Ft,cwd:()=>Gr,debugPort:()=>kn,default:()=>Li,dlopen:()=>ys,domain:()=>en,emit:()=>Dn,emitWarning:()=>zr,env:()=>Fr,execArgv:()=>qr,execPath:()=>Tn,exit:()=>un,features:()=>fn,hasUncaughtExceptionCaptureCallback:()=>ws,hrtime:()=>Zt,kill:()=>ln,listeners:()=>Ss,memoryUsage:()=>an,moduleLoadList:()=>Zr,nextTick:()=>ps,off:()=>Un,on:()=>rt,once:()=>Nn,openStdin:()=>cn,pid:()=>An,platform:()=>Dr,ppid:()=>In,prependListener:()=>Fn,prependOnceListener:()=>Wn,reallyExit:()=>nn,release:()=>Yr,removeAllListeners:()=>Ln,removeListener:()=>Bn,resourceUsage:()=>sn,setSourceMapsEnabled:()=>Pn,setUncaughtExceptionCaptureCallback:()=>dn,stderr:()=>_n,stdin:()=>Sn,stdout:()=>wn,title:()=>Br,umask:()=>Vr,uptime:()=>_s,version:()=>$r,versions:()=>Hr});function Bi(f){throw new Error("Node.js process "+f+" is not supported by JSPM core outside of Node.js")}function ll(){!St||!wt||(St=!1,wt.length?Ze=wt.concat(Ze):Ht=-1,Ze.length&&fs())}function fs(){if(!St){var f=setTimeout(ll,0);St=!0;for(var i=Ze.length;i;){for(wt=Ze,Ze=[];++Ht<i;)wt&&wt[Ht].run();Ht=-1,i=Ze.length}wt=null,St=!1,clearTimeout(f)}}function ps(f){var i=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)i[s-1]=arguments[s];Ze.push(new ds(f,i)),Ze.length===1&&!St&&setTimeout(fs,0)}function ds(f,i){this.fun=f,this.array=i}function Le(){}function gs(f){Bi("_linkedBinding")}function ys(f){Bi("dlopen")}function ms(){return[]}function bs(){return[]}function vs(f,i){if(!f)throw new Error(i||"assertion error")}function ws(){return!1}function _s(){return it.now()/1e3}function Zt(f){var i=Math.floor((Date.now()-it.now())*.001),s=it.now()*.001,a=Math.floor(s)+i,l=Math.floor(s%1*1e9);return f&&(a=a-f[0],l=l-f[1],l<0&&(a--,l+=er)),[a,l]}function rt(){return Li}function Ss(f){return[]}var Ze,St,wt,Ht,Br,Lr,Dr,Fr,Wr,qr,$r,Hr,zr,Kr,Vr,Gr,Qr,Yr,Jr,Xr,Zr,en,tn,rn,nn,on,Ft,sn,an,ln,un,cn,hn,fn,pn,dn,gn,yn,mn,bn,vn,wn,_n,Sn,En,An,In,Tn,kn,xn,On,Pn,it,Mr,er,Rn,Cn,Mn,jn,Nn,Un,Bn,Ln,Dn,Fn,Wn,Li,ul=He(()=>{le(),ce(),ue(),Ze=[],St=!1,Ht=-1,ds.prototype.run=function(){this.fun.apply(null,this.array)},Br="browser",Lr="x64",Dr="browser",Fr={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},Wr=["/usr/bin/node"],qr=[],$r="v16.8.0",Hr={},zr=function(f,i){console.warn((i?i+": ":"")+f)},Kr=function(f){Bi("binding")},Vr=function(f){return 0},Gr=function(){return"/"},Qr=function(f){},Yr={name:"node",sourceUrl:"",headersUrl:"",libUrl:""},Jr=!0,Xr=Le,Zr=[],en={},tn=!1,rn={},nn=Le,on=Le,Ft=function(){return{}},sn=Ft,an=Ft,ln=Le,un=Le,cn=Le,hn={},fn={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},pn=Le,dn=Le,gn=Le,yn=Le,mn=Le,bn=Le,vn=Le,wn=void 0,_n=void 0,Sn=void 0,En=Le,An=2,In=1,Tn="/bin/usr/node",kn=9229,xn="node",On=[],Pn=Le,it={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0},it.now===void 0&&(Mr=Date.now(),it.timing&&it.timing.navigationStart&&(Mr=it.timing.navigationStart),it.now=()=>Date.now()-Mr),er=1e9,Zt.bigint=function(f){var i=Zt(f);return typeof BigInt>"u"?i[0]*er+i[1]:BigInt(i[0]*er)+BigInt(i[1])},Rn=10,Cn={},Mn=0,jn=rt,Nn=rt,Un=rt,Bn=rt,Ln=rt,Dn=Le,Fn=rt,Wn=rt,Li={version:$r,versions:Hr,arch:Lr,platform:Dr,browser:Jr,release:Yr,_rawDebug:Xr,moduleLoadList:Zr,binding:Kr,_linkedBinding:gs,_events:Cn,_eventsCount:Mn,_maxListeners:Rn,on:rt,addListener:jn,once:Nn,off:Un,removeListener:Bn,removeAllListeners:Ln,emit:Dn,prependListener:Fn,prependOnceListener:Wn,listeners:Ss,domain:en,_exiting:tn,config:rn,dlopen:ys,uptime:_s,_getActiveRequests:ms,_getActiveHandles:bs,reallyExit:nn,_kill:on,cpuUsage:Ft,resourceUsage:sn,memoryUsage:an,kill:ln,exit:un,openStdin:cn,allowedNodeEnvironmentFlags:hn,assert:vs,features:fn,_fatalExceptions:pn,setUncaughtExceptionCaptureCallback:dn,hasUncaughtExceptionCaptureCallback:ws,emitWarning:zr,nextTick:ps,_tickCallback:gn,_debugProcess:yn,_debugEnd:mn,_startProfilerIdleNotifier:bn,_stopProfilerIdleNotifier:vn,stdout:wn,stdin:Sn,stderr:_n,abort:En,umask:Vr,chdir:Qr,cwd:Gr,env:Fr,title:Br,argv:Wr,execArgv:qr,pid:An,ppid:In,execPath:Tn,debugPort:kn,hrtime:Zt,argv0:xn,_preload_modules:On,setSourceMapsEnabled:Pn}}),ue=He(()=>{ul()});function cl(){if(qn)return Ot;qn=!0,Ot.byteLength=n,Ot.toByteArray=o,Ot.fromByteArray=d;for(var f=[],i=[],s=typeof Uint8Array<"u"?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,t=a.length;l<t;++l)f[l]=a[l],i[a.charCodeAt(l)]=l;i[45]=62,i[95]=63;function r(b){var h=b.length;if(h%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var y=b.indexOf("=");y===-1&&(y=h);var m=y===h?0:4-y%4;return[y,m]}function n(b){var h=r(b),y=h[0],m=h[1];return(y+m)*3/4-m}function e(b,h,y){return(h+y)*3/4-y}function o(b){var h,y=r(b),m=y[0],S=y[1],g=new s(e(b,m,S)),_=0,I=S>0?m-4:m,v;for(v=0;v<I;v+=4)h=i[b.charCodeAt(v)]<<18|i[b.charCodeAt(v+1)]<<12|i[b.charCodeAt(v+2)]<<6|i[b.charCodeAt(v+3)],g[_++]=h>>16&255,g[_++]=h>>8&255,g[_++]=h&255;return S===2&&(h=i[b.charCodeAt(v)]<<2|i[b.charCodeAt(v+1)]>>4,g[_++]=h&255),S===1&&(h=i[b.charCodeAt(v)]<<10|i[b.charCodeAt(v+1)]<<4|i[b.charCodeAt(v+2)]>>2,g[_++]=h>>8&255,g[_++]=h&255),g}function u(b){return f[b>>18&63]+f[b>>12&63]+f[b>>6&63]+f[b&63]}function p(b,h,y){for(var m,S=[],g=h;g<y;g+=3)m=(b[g]<<16&16711680)+(b[g+1]<<8&65280)+(b[g+2]&255),S.push(u(m));return S.join("")}function d(b){for(var h,y=b.length,m=y%3,S=[],g=16383,_=0,I=y-m;_<I;_+=g)S.push(p(b,_,_+g>I?I:_+g));return m===1?(h=b[y-1],S.push(f[h>>2]+f[h<<4&63]+"==")):m===2&&(h=(b[y-2]<<8)+b[y-1],S.push(f[h>>10]+f[h>>4&63]+f[h<<2&63]+"=")),S.join("")}return Ot}function hl(){return $n?Wt:($n=!0,Wt.read=function(f,i,s,a,l){var t,r,n=l*8-a-1,e=(1<<n)-1,o=e>>1,u=-7,p=s?l-1:0,d=s?-1:1,b=f[i+p];for(p+=d,t=b&(1<<-u)-1,b>>=-u,u+=n;u>0;t=t*256+f[i+p],p+=d,u-=8);for(r=t&(1<<-u)-1,t>>=-u,u+=a;u>0;r=r*256+f[i+p],p+=d,u-=8);if(t===0)t=1-o;else{if(t===e)return r?NaN:(b?-1:1)*(1/0);r=r+Math.pow(2,a),t=t-o}return(b?-1:1)*r*Math.pow(2,t-a)},Wt.write=function(f,i,s,a,l,t){var r,n,e,o=t*8-l-1,u=(1<<o)-1,p=u>>1,d=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=a?0:t-1,h=a?1:-1,y=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(n=isNaN(i)?1:0,r=u):(r=Math.floor(Math.log(i)/Math.LN2),i*(e=Math.pow(2,-r))<1&&(r--,e*=2),r+p>=1?i+=d/e:i+=d*Math.pow(2,1-p),i*e>=2&&(r++,e/=2),r+p>=u?(n=0,r=u):r+p>=1?(n=(i*e-1)*Math.pow(2,l),r=r+p):(n=i*Math.pow(2,p-1)*Math.pow(2,l),r=0));l>=8;f[s+b]=n&255,b+=h,n/=256,l-=8);for(r=r<<l|n,o+=l;o>0;f[s+b]=r&255,b+=h,r/=256,o-=8);f[s+b-h]|=y*128},Wt)}function fl(){if(Hn)return pt;Hn=!0;let f=cl(),i=hl(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;pt.Buffer=r,pt.SlowBuffer=S,pt.INSPECT_MAX_BYTES=50;let a=2147483647;pt.kMaxLength=a,r.TYPED_ARRAY_SUPPORT=l(),!r.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{let c=new Uint8Array(1),w={foo:function(){return 42}};return Object.setPrototypeOf(w,Uint8Array.prototype),Object.setPrototypeOf(c,w),c.foo()===42}catch{return!1}}Object.defineProperty(r.prototype,"parent",{enumerable:!0,get:function(){if(r.isBuffer(this))return this.buffer}}),Object.defineProperty(r.prototype,"offset",{enumerable:!0,get:function(){if(r.isBuffer(this))return this.byteOffset}});function t(c){if(c>a)throw new RangeError('The value "'+c+'" is invalid for option "size"');let w=new Uint8Array(c);return Object.setPrototypeOf(w,r.prototype),w}function r(c,w,T){if(typeof c=="number"){if(typeof w=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return u(c)}return n(c,w,T)}r.poolSize=8192;function n(c,w,T){if(typeof c=="string")return p(c,w);if(ArrayBuffer.isView(c))return b(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if($(c,ArrayBuffer)||c&&$(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&($(c,SharedArrayBuffer)||c&&$(c.buffer,SharedArrayBuffer)))return h(c,w,T);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let B=c.valueOf&&c.valueOf();if(B!=null&&B!==c)return r.from(B,w,T);let X=y(c);if(X)return X;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return r.from(c[Symbol.toPrimitive]("string"),w,T);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}r.from=function(c,w,T){return n(c,w,T)},Object.setPrototypeOf(r.prototype,Uint8Array.prototype),Object.setPrototypeOf(r,Uint8Array);function e(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function o(c,w,T){return e(c),c<=0?t(c):w!==void 0?typeof T=="string"?t(c).fill(w,T):t(c).fill(w):t(c)}r.alloc=function(c,w,T){return o(c,w,T)};function u(c){return e(c),t(c<0?0:m(c)|0)}r.allocUnsafe=function(c){return u(c)},r.allocUnsafeSlow=function(c){return u(c)};function p(c,w){if((typeof w!="string"||w==="")&&(w="utf8"),!r.isEncoding(w))throw new TypeError("Unknown encoding: "+w);let T=g(c,w)|0,B=t(T),X=B.write(c,w);return X!==T&&(B=B.slice(0,X)),B}function d(c){let w=c.length<0?0:m(c.length)|0,T=t(w);for(let B=0;B<w;B+=1)T[B]=c[B]&255;return T}function b(c){if($(c,Uint8Array)){let w=new Uint8Array(c);return h(w.buffer,w.byteOffset,w.byteLength)}return d(c)}function h(c,w,T){if(w<0||c.byteLength<w)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<w+(T||0))throw new RangeError('"length" is outside of buffer bounds');let B;return w===void 0&&T===void 0?B=new Uint8Array(c):T===void 0?B=new Uint8Array(c,w):B=new Uint8Array(c,w,T),Object.setPrototypeOf(B,r.prototype),B}function y(c){if(r.isBuffer(c)){let w=m(c.length)|0,T=t(w);return T.length===0||c.copy(T,0,0,w),T}if(c.length!==void 0)return typeof c.length!="number"||ge(c.length)?t(0):d(c);if(c.type==="Buffer"&&Array.isArray(c.data))return d(c.data)}function m(c){if(c>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return c|0}function S(c){return+c!=c&&(c=0),r.alloc(+c)}r.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==r.prototype},r.compare=function(c,w){if($(c,Uint8Array)&&(c=r.from(c,c.offset,c.byteLength)),$(w,Uint8Array)&&(w=r.from(w,w.offset,w.byteLength)),!r.isBuffer(c)||!r.isBuffer(w))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===w)return 0;let T=c.length,B=w.length;for(let X=0,he=Math.min(T,B);X<he;++X)if(c[X]!==w[X]){T=c[X],B=w[X];break}return T<B?-1:B<T?1:0},r.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.concat=function(c,w){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return r.alloc(0);let T;if(w===void 0)for(w=0,T=0;T<c.length;++T)w+=c[T].length;let B=r.allocUnsafe(w),X=0;for(T=0;T<c.length;++T){let he=c[T];if($(he,Uint8Array))X+he.length>B.length?(r.isBuffer(he)||(he=r.from(he)),he.copy(B,X)):Uint8Array.prototype.set.call(B,he,X);else if(r.isBuffer(he))he.copy(B,X);else throw new TypeError('"list" argument must be an Array of Buffers');X+=he.length}return B};function g(c,w){if(r.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||$(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);let T=c.length,B=arguments.length>2&&arguments[2]===!0;if(!B&&T===0)return 0;let X=!1;for(;;)switch(w){case"ascii":case"latin1":case"binary":return T;case"utf8":case"utf-8":return W(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T*2;case"hex":return T>>>1;case"base64":return pe(c).length;default:if(X)return B?-1:W(c).length;w=(""+w).toLowerCase(),X=!0}}r.byteLength=g;function _(c,w,T){let B=!1;if((w===void 0||w<0)&&(w=0),w>this.length||((T===void 0||T>this.length)&&(T=this.length),T<=0)||(T>>>=0,w>>>=0,T<=w))return"";for(c||(c="utf8");;)switch(c){case"hex":return K(this,w,T);case"utf8":case"utf-8":return q(this,w,T);case"ascii":return ae(this,w,T);case"latin1":case"binary":return Q(this,w,T);case"base64":return x(this,w,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,w,T);default:if(B)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),B=!0}}r.prototype._isBuffer=!0;function I(c,w,T){let B=c[w];c[w]=c[T],c[T]=B}r.prototype.swap16=function(){let c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let w=0;w<c;w+=2)I(this,w,w+1);return this},r.prototype.swap32=function(){let c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let w=0;w<c;w+=4)I(this,w,w+3),I(this,w+1,w+2);return this},r.prototype.swap64=function(){let c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let w=0;w<c;w+=8)I(this,w,w+7),I(this,w+1,w+6),I(this,w+2,w+5),I(this,w+3,w+4);return this},r.prototype.toString=function(){let c=this.length;return c===0?"":arguments.length===0?q(this,0,c):_.apply(this,arguments)},r.prototype.toLocaleString=r.prototype.toString,r.prototype.equals=function(c){if(!r.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:r.compare(this,c)===0},r.prototype.inspect=function(){let c="",w=pt.INSPECT_MAX_BYTES;return c=this.toString("hex",0,w).replace(/(.{2})/g,"$1 ").trim(),this.length>w&&(c+=" ... "),"<Buffer "+c+">"},s&&(r.prototype[s]=r.prototype.inspect),r.prototype.compare=function(c,w,T,B,X){if($(c,Uint8Array)&&(c=r.from(c,c.offset,c.byteLength)),!r.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(w===void 0&&(w=0),T===void 0&&(T=c?c.length:0),B===void 0&&(B=0),X===void 0&&(X=this.length),w<0||T>c.length||B<0||X>this.length)throw new RangeError("out of range index");if(B>=X&&w>=T)return 0;if(B>=X)return-1;if(w>=T)return 1;if(w>>>=0,T>>>=0,B>>>=0,X>>>=0,this===c)return 0;let he=X-B,Se=T-w,z=Math.min(he,Se),ie=this.slice(B,X),Ie=c.slice(w,T);for(let Te=0;Te<z;++Te)if(ie[Te]!==Ie[Te]){he=ie[Te],Se=Ie[Te];break}return he<Se?-1:Se<he?1:0};function v(c,w,T,B,X){if(c.length===0)return-1;if(typeof T=="string"?(B=T,T=0):T>2147483647?T=2147483647:T<-2147483648&&(T=-2147483648),T=+T,ge(T)&&(T=X?0:c.length-1),T<0&&(T=c.length+T),T>=c.length){if(X)return-1;T=c.length-1}else if(T<0)if(X)T=0;else return-1;if(typeof w=="string"&&(w=r.from(w,B)),r.isBuffer(w))return w.length===0?-1:A(c,w,T,B,X);if(typeof w=="number")return w=w&255,typeof Uint8Array.prototype.indexOf=="function"?X?Uint8Array.prototype.indexOf.call(c,w,T):Uint8Array.prototype.lastIndexOf.call(c,w,T):A(c,[w],T,B,X);throw new TypeError("val must be string, number or Buffer")}function A(c,w,T,B,X){let he=1,Se=c.length,z=w.length;if(B!==void 0&&(B=String(B).toLowerCase(),B==="ucs2"||B==="ucs-2"||B==="utf16le"||B==="utf-16le")){if(c.length<2||w.length<2)return-1;he=2,Se/=2,z/=2,T/=2}function ie(Te,ke){return he===1?Te[ke]:Te.readUInt16BE(ke*he)}let Ie;if(X){let Te=-1;for(Ie=T;Ie<Se;Ie++)if(ie(c,Ie)===ie(w,Te===-1?0:Ie-Te)){if(Te===-1&&(Te=Ie),Ie-Te+1===z)return Te*he}else Te!==-1&&(Ie-=Ie-Te),Te=-1}else for(T+z>Se&&(T=Se-z),Ie=T;Ie>=0;Ie--){let Te=!0;for(let ke=0;ke<z;ke++)if(ie(c,Ie+ke)!==ie(w,ke)){Te=!1;break}if(Te)return Ie}return-1}r.prototype.includes=function(c,w,T){return this.indexOf(c,w,T)!==-1},r.prototype.indexOf=function(c,w,T){return v(this,c,w,T,!0)},r.prototype.lastIndexOf=function(c,w,T){return v(this,c,w,T,!1)};function E(c,w,T,B){T=Number(T)||0;let X=c.length-T;B?(B=Number(B),B>X&&(B=X)):B=X;let he=w.length;B>he/2&&(B=he/2);let Se;for(Se=0;Se<B;++Se){let z=parseInt(w.substr(Se*2,2),16);if(ge(z))return Se;c[T+Se]=z}return Se}function k(c,w,T,B){return be(W(w,c.length-T),c,T,B)}function C(c,w,T,B){return be(ee(w),c,T,B)}function P(c,w,T,B){return be(pe(w),c,T,B)}function L(c,w,T,B){return be(fe(w,c.length-T),c,T,B)}r.prototype.write=function(c,w,T,B){if(w===void 0)B="utf8",T=this.length,w=0;else if(T===void 0&&typeof w=="string")B=w,T=this.length,w=0;else if(isFinite(w))w=w>>>0,isFinite(T)?(T=T>>>0,B===void 0&&(B="utf8")):(B=T,T=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let X=this.length-w;if((T===void 0||T>X)&&(T=X),c.length>0&&(T<0||w<0)||w>this.length)throw new RangeError("Attempt to write outside buffer bounds");B||(B="utf8");let he=!1;for(;;)switch(B){case"hex":return E(this,c,w,T);case"utf8":case"utf-8":return k(this,c,w,T);case"ascii":case"latin1":case"binary":return C(this,c,w,T);case"base64":return P(this,c,w,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,c,w,T);default:if(he)throw new TypeError("Unknown encoding: "+B);B=(""+B).toLowerCase(),he=!0}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(c,w,T){return w===0&&T===c.length?f.fromByteArray(c):f.fromByteArray(c.slice(w,T))}function q(c,w,T){T=Math.min(c.length,T);let B=[],X=w;for(;X<T;){let he=c[X],Se=null,z=he>239?4:he>223?3:he>191?2:1;if(X+z<=T){let ie,Ie,Te,ke;switch(z){case 1:he<128&&(Se=he);break;case 2:ie=c[X+1],(ie&192)===128&&(ke=(he&31)<<6|ie&63,ke>127&&(Se=ke));break;case 3:ie=c[X+1],Ie=c[X+2],(ie&192)===128&&(Ie&192)===128&&(ke=(he&15)<<12|(ie&63)<<6|Ie&63,ke>2047&&(ke<55296||ke>57343)&&(Se=ke));break;case 4:ie=c[X+1],Ie=c[X+2],Te=c[X+3],(ie&192)===128&&(Ie&192)===128&&(Te&192)===128&&(ke=(he&15)<<18|(ie&63)<<12|(Ie&63)<<6|Te&63,ke>65535&&ke<1114112&&(Se=ke))}}Se===null?(Se=65533,z=1):Se>65535&&(Se-=65536,B.push(Se>>>10&1023|55296),Se=56320|Se&1023),B.push(Se),X+=z}return U(B)}let D=4096;function U(c){let w=c.length;if(w<=D)return String.fromCharCode.apply(String,c);let T="",B=0;for(;B<w;)T+=String.fromCharCode.apply(String,c.slice(B,B+=D));return T}function ae(c,w,T){let B="";T=Math.min(c.length,T);for(let X=w;X<T;++X)B+=String.fromCharCode(c[X]&127);return B}function Q(c,w,T){let B="";T=Math.min(c.length,T);for(let X=w;X<T;++X)B+=String.fromCharCode(c[X]);return B}function K(c,w,T){let B=c.length;(!w||w<0)&&(w=0),(!T||T<0||T>B)&&(T=B);let X="";for(let he=w;he<T;++he)X+=ve[c[he]];return X}function re(c,w,T){let B=c.slice(w,T),X="";for(let he=0;he<B.length-1;he+=2)X+=String.fromCharCode(B[he]+B[he+1]*256);return X}r.prototype.slice=function(c,w){let T=this.length;c=~~c,w=w===void 0?T:~~w,c<0?(c+=T,c<0&&(c=0)):c>T&&(c=T),w<0?(w+=T,w<0&&(w=0)):w>T&&(w=T),w<c&&(w=c);let B=this.subarray(c,w);return Object.setPrototypeOf(B,r.prototype),B};function F(c,w,T){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+w>T)throw new RangeError("Trying to access beyond buffer length")}r.prototype.readUintLE=r.prototype.readUIntLE=function(c,w,T){c=c>>>0,w=w>>>0,T||F(c,w,this.length);let B=this[c],X=1,he=0;for(;++he<w&&(X*=256);)B+=this[c+he]*X;return B},r.prototype.readUintBE=r.prototype.readUIntBE=function(c,w,T){c=c>>>0,w=w>>>0,T||F(c,w,this.length);let B=this[c+--w],X=1;for(;w>0&&(X*=256);)B+=this[c+--w]*X;return B},r.prototype.readUint8=r.prototype.readUInt8=function(c,w){return c=c>>>0,w||F(c,1,this.length),this[c]},r.prototype.readUint16LE=r.prototype.readUInt16LE=function(c,w){return c=c>>>0,w||F(c,2,this.length),this[c]|this[c+1]<<8},r.prototype.readUint16BE=r.prototype.readUInt16BE=function(c,w){return c=c>>>0,w||F(c,2,this.length),this[c]<<8|this[c+1]},r.prototype.readUint32LE=r.prototype.readUInt32LE=function(c,w){return c=c>>>0,w||F(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},r.prototype.readUint32BE=r.prototype.readUInt32BE=function(c,w){return c=c>>>0,w||F(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},r.prototype.readBigUInt64LE=se(function(c){c=c>>>0,Y(c,"offset");let w=this[c],T=this[c+7];(w===void 0||T===void 0)&&ye(c,this.length-8);let B=w+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,X=this[++c]+this[++c]*2**8+this[++c]*2**16+T*2**24;return BigInt(B)+(BigInt(X)<<BigInt(32))}),r.prototype.readBigUInt64BE=se(function(c){c=c>>>0,Y(c,"offset");let w=this[c],T=this[c+7];(w===void 0||T===void 0)&&ye(c,this.length-8);let B=w*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],X=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+T;return(BigInt(B)<<BigInt(32))+BigInt(X)}),r.prototype.readIntLE=function(c,w,T){c=c>>>0,w=w>>>0,T||F(c,w,this.length);let B=this[c],X=1,he=0;for(;++he<w&&(X*=256);)B+=this[c+he]*X;return X*=128,B>=X&&(B-=Math.pow(2,8*w)),B},r.prototype.readIntBE=function(c,w,T){c=c>>>0,w=w>>>0,T||F(c,w,this.length);let B=w,X=1,he=this[c+--B];for(;B>0&&(X*=256);)he+=this[c+--B]*X;return X*=128,he>=X&&(he-=Math.pow(2,8*w)),he},r.prototype.readInt8=function(c,w){return c=c>>>0,w||F(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},r.prototype.readInt16LE=function(c,w){c=c>>>0,w||F(c,2,this.length);let T=this[c]|this[c+1]<<8;return T&32768?T|4294901760:T},r.prototype.readInt16BE=function(c,w){c=c>>>0,w||F(c,2,this.length);let T=this[c+1]|this[c]<<8;return T&32768?T|4294901760:T},r.prototype.readInt32LE=function(c,w){return c=c>>>0,w||F(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},r.prototype.readInt32BE=function(c,w){return c=c>>>0,w||F(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},r.prototype.readBigInt64LE=se(function(c){c=c>>>0,Y(c,"offset");let w=this[c],T=this[c+7];(w===void 0||T===void 0)&&ye(c,this.length-8);let B=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(T<<24);return(BigInt(B)<<BigInt(32))+BigInt(w+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),r.prototype.readBigInt64BE=se(function(c){c=c>>>0,Y(c,"offset");let w=this[c],T=this[c+7];(w===void 0||T===void 0)&&ye(c,this.length-8);let B=(w<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(B)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+T)}),r.prototype.readFloatLE=function(c,w){return c=c>>>0,w||F(c,4,this.length),i.read(this,c,!0,23,4)},r.prototype.readFloatBE=function(c,w){return c=c>>>0,w||F(c,4,this.length),i.read(this,c,!1,23,4)},r.prototype.readDoubleLE=function(c,w){return c=c>>>0,w||F(c,8,this.length),i.read(this,c,!0,52,8)},r.prototype.readDoubleBE=function(c,w){return c=c>>>0,w||F(c,8,this.length),i.read(this,c,!1,52,8)};function Z(c,w,T,B,X,he){if(!r.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(w>X||w<he)throw new RangeError('"value" argument is out of bounds');if(T+B>c.length)throw new RangeError("Index out of range")}r.prototype.writeUintLE=r.prototype.writeUIntLE=function(c,w,T,B){if(c=+c,w=w>>>0,T=T>>>0,!B){let Se=Math.pow(2,8*T)-1;Z(this,c,w,T,Se,0)}let X=1,he=0;for(this[w]=c&255;++he<T&&(X*=256);)this[w+he]=c/X&255;return w+T},r.prototype.writeUintBE=r.prototype.writeUIntBE=function(c,w,T,B){if(c=+c,w=w>>>0,T=T>>>0,!B){let Se=Math.pow(2,8*T)-1;Z(this,c,w,T,Se,0)}let X=T-1,he=1;for(this[w+X]=c&255;--X>=0&&(he*=256);)this[w+X]=c/he&255;return w+T},r.prototype.writeUint8=r.prototype.writeUInt8=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,1,255,0),this[w]=c&255,w+1},r.prototype.writeUint16LE=r.prototype.writeUInt16LE=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,2,65535,0),this[w]=c&255,this[w+1]=c>>>8,w+2},r.prototype.writeUint16BE=r.prototype.writeUInt16BE=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,2,65535,0),this[w]=c>>>8,this[w+1]=c&255,w+2},r.prototype.writeUint32LE=r.prototype.writeUInt32LE=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,4,4294967295,0),this[w+3]=c>>>24,this[w+2]=c>>>16,this[w+1]=c>>>8,this[w]=c&255,w+4},r.prototype.writeUint32BE=r.prototype.writeUInt32BE=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,4,4294967295,0),this[w]=c>>>24,this[w+1]=c>>>16,this[w+2]=c>>>8,this[w+3]=c&255,w+4};function R(c,w,T,B,X){G(w,B,X,c,T,7);let he=Number(w&BigInt(4294967295));c[T++]=he,he=he>>8,c[T++]=he,he=he>>8,c[T++]=he,he=he>>8,c[T++]=he;let Se=Number(w>>BigInt(32)&BigInt(4294967295));return c[T++]=Se,Se=Se>>8,c[T++]=Se,Se=Se>>8,c[T++]=Se,Se=Se>>8,c[T++]=Se,T}function J(c,w,T,B,X){G(w,B,X,c,T,7);let he=Number(w&BigInt(4294967295));c[T+7]=he,he=he>>8,c[T+6]=he,he=he>>8,c[T+5]=he,he=he>>8,c[T+4]=he;let Se=Number(w>>BigInt(32)&BigInt(4294967295));return c[T+3]=Se,Se=Se>>8,c[T+2]=Se,Se=Se>>8,c[T+1]=Se,Se=Se>>8,c[T]=Se,T+8}r.prototype.writeBigUInt64LE=se(function(c,w=0){return R(this,c,w,BigInt(0),BigInt("0xffffffffffffffff"))}),r.prototype.writeBigUInt64BE=se(function(c,w=0){return J(this,c,w,BigInt(0),BigInt("0xffffffffffffffff"))}),r.prototype.writeIntLE=function(c,w,T,B){if(c=+c,w=w>>>0,!B){let z=Math.pow(2,8*T-1);Z(this,c,w,T,z-1,-z)}let X=0,he=1,Se=0;for(this[w]=c&255;++X<T&&(he*=256);)c<0&&Se===0&&this[w+X-1]!==0&&(Se=1),this[w+X]=(c/he>>0)-Se&255;return w+T},r.prototype.writeIntBE=function(c,w,T,B){if(c=+c,w=w>>>0,!B){let z=Math.pow(2,8*T-1);Z(this,c,w,T,z-1,-z)}let X=T-1,he=1,Se=0;for(this[w+X]=c&255;--X>=0&&(he*=256);)c<0&&Se===0&&this[w+X+1]!==0&&(Se=1),this[w+X]=(c/he>>0)-Se&255;return w+T},r.prototype.writeInt8=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,1,127,-128),c<0&&(c=255+c+1),this[w]=c&255,w+1},r.prototype.writeInt16LE=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,2,32767,-32768),this[w]=c&255,this[w+1]=c>>>8,w+2},r.prototype.writeInt16BE=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,2,32767,-32768),this[w]=c>>>8,this[w+1]=c&255,w+2},r.prototype.writeInt32LE=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,4,2147483647,-2147483648),this[w]=c&255,this[w+1]=c>>>8,this[w+2]=c>>>16,this[w+3]=c>>>24,w+4},r.prototype.writeInt32BE=function(c,w,T){return c=+c,w=w>>>0,T||Z(this,c,w,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[w]=c>>>24,this[w+1]=c>>>16,this[w+2]=c>>>8,this[w+3]=c&255,w+4},r.prototype.writeBigInt64LE=se(function(c,w=0){return R(this,c,w,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),r.prototype.writeBigInt64BE=se(function(c,w=0){return J(this,c,w,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function me(c,w,T,B,X,he){if(T+B>c.length)throw new RangeError("Index out of range");if(T<0)throw new RangeError("Index out of range")}function te(c,w,T,B,X){return w=+w,T=T>>>0,X||me(c,w,T,4),i.write(c,w,T,B,23,4),T+4}r.prototype.writeFloatLE=function(c,w,T){return te(this,c,w,!0,T)},r.prototype.writeFloatBE=function(c,w,T){return te(this,c,w,!1,T)};function we(c,w,T,B,X){return w=+w,T=T>>>0,X||me(c,w,T,8),i.write(c,w,T,B,52,8),T+8}r.prototype.writeDoubleLE=function(c,w,T){return we(this,c,w,!0,T)},r.prototype.writeDoubleBE=function(c,w,T){return we(this,c,w,!1,T)},r.prototype.copy=function(c,w,T,B){if(!r.isBuffer(c))throw new TypeError("argument should be a Buffer");if(T||(T=0),!B&&B!==0&&(B=this.length),w>=c.length&&(w=c.length),w||(w=0),B>0&&B<T&&(B=T),B===T||c.length===0||this.length===0)return 0;if(w<0)throw new RangeError("targetStart out of bounds");if(T<0||T>=this.length)throw new RangeError("Index out of range");if(B<0)throw new RangeError("sourceEnd out of bounds");B>this.length&&(B=this.length),c.length-w<B-T&&(B=c.length-w+T);let X=B-T;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(w,T,B):Uint8Array.prototype.set.call(c,this.subarray(T,B),w),X},r.prototype.fill=function(c,w,T,B){if(typeof c=="string"){if(typeof w=="string"?(B=w,w=0,T=this.length):typeof T=="string"&&(B=T,T=this.length),B!==void 0&&typeof B!="string")throw new TypeError("encoding must be a string");if(typeof B=="string"&&!r.isEncoding(B))throw new TypeError("Unknown encoding: "+B);if(c.length===1){let he=c.charCodeAt(0);(B==="utf8"&&he<128||B==="latin1")&&(c=he)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(w<0||this.length<w||this.length<T)throw new RangeError("Out of range index");if(T<=w)return this;w=w>>>0,T=T===void 0?this.length:T>>>0,c||(c=0);let X;if(typeof c=="number")for(X=w;X<T;++X)this[X]=c;else{let he=r.isBuffer(c)?c:r.from(c,B),Se=he.length;if(Se===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(X=0;X<T-w;++X)this[X+w]=he[X%Se]}return this};let V={};function N(c,w,T){V[c]=class extends T{constructor(){super(),Object.defineProperty(this,"message",{value:w.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(B){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:B,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}N("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),N("ERR_INVALID_ARG_TYPE",function(c,w){return`The "${c}" argument must be of type number. Received type ${typeof w}`},TypeError),N("ERR_OUT_OF_RANGE",function(c,w,T){let B=`The value of "${c}" is out of range.`,X=T;return Number.isInteger(T)&&Math.abs(T)>2**32?X=ne(String(T)):typeof T=="bigint"&&(X=String(T),(T>BigInt(2)**BigInt(32)||T<-(BigInt(2)**BigInt(32)))&&(X=ne(X)),X+="n"),B+=` It must be ${w}. Received ${X}`,B},RangeError);function ne(c){let w="",T=c.length,B=c[0]==="-"?1:0;for(;T>=B+4;T-=3)w=`_${c.slice(T-3,T)}${w}`;return`${c.slice(0,T)}${w}`}function H(c,w,T){Y(w,"offset"),(c[w]===void 0||c[w+T]===void 0)&&ye(w,c.length-(T+1))}function G(c,w,T,B,X,he){if(c>T||c<w){let Se=typeof w=="bigint"?"n":"",z;throw w===0||w===BigInt(0)?z=`>= 0${Se} and < 2${Se} ** ${(he+1)*8}${Se}`:z=`>= -(2${Se} ** ${(he+1)*8-1}${Se}) and < 2 ** ${(he+1)*8-1}${Se}`,new V.ERR_OUT_OF_RANGE("value",z,c)}H(B,X,he)}function Y(c,w){if(typeof c!="number")throw new V.ERR_INVALID_ARG_TYPE(w,"number",c)}function ye(c,w,T){throw Math.floor(c)!==c?(Y(c,T),new V.ERR_OUT_OF_RANGE("offset","an integer",c)):w<0?new V.ERR_BUFFER_OUT_OF_BOUNDS:new V.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${w}`,c)}let oe=/[^+/0-9A-Za-z-_]/g;function M(c){if(c=c.split("=")[0],c=c.trim().replace(oe,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function W(c,w){w=w||1/0;let T,B=c.length,X=null,he=[];for(let Se=0;Se<B;++Se){if(T=c.charCodeAt(Se),T>55295&&T<57344){if(!X){if(T>56319){(w-=3)>-1&&he.push(239,191,189);continue}else if(Se+1===B){(w-=3)>-1&&he.push(239,191,189);continue}X=T;continue}if(T<56320){(w-=3)>-1&&he.push(239,191,189),X=T;continue}T=(X-55296<<10|T-56320)+65536}else X&&(w-=3)>-1&&he.push(239,191,189);if(X=null,T<128){if((w-=1)<0)break;he.push(T)}else if(T<2048){if((w-=2)<0)break;he.push(T>>6|192,T&63|128)}else if(T<65536){if((w-=3)<0)break;he.push(T>>12|224,T>>6&63|128,T&63|128)}else if(T<1114112){if((w-=4)<0)break;he.push(T>>18|240,T>>12&63|128,T>>6&63|128,T&63|128)}else throw new Error("Invalid code point")}return he}function ee(c){let w=[];for(let T=0;T<c.length;++T)w.push(c.charCodeAt(T)&255);return w}function fe(c,w){let T,B,X,he=[];for(let Se=0;Se<c.length&&!((w-=2)<0);++Se)T=c.charCodeAt(Se),B=T>>8,X=T%256,he.push(X),he.push(B);return he}function pe(c){return f.toByteArray(M(c))}function be(c,w,T,B){let X;for(X=0;X<B&&!(X+T>=w.length||X>=c.length);++X)w[X+T]=c[X];return X}function $(c,w){return c instanceof w||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===w.name}function ge(c){return c!==c}let ve=(function(){let c="0123456789abcdef",w=new Array(256);for(let T=0;T<16;++T){let B=T*16;for(let X=0;X<16;++X)w[B+X]=c[T]+c[X]}return w})();function se(c){return typeof BigInt>"u"?xe:c}function xe(){throw new Error("BigInt not supported")}return pt}var Ot,qn,Wt,$n,pt,Hn,pl=He(()=>{le(),ce(),ue(),Ot={},qn=!1,Wt={},$n=!1,pt={},Hn=!1}),Ne={};Ct(Ne,{Buffer:()=>Ar,INSPECT_MAX_BYTES:()=>Es,default:()=>nt,kMaxLength:()=>As});var nt,Ar,Es,As,Ue=He(()=>{le(),ce(),ue(),pl(),nt=fl(),nt.Buffer,nt.SlowBuffer,nt.INSPECT_MAX_BYTES,nt.kMaxLength,Ar=nt.Buffer,Es=nt.INSPECT_MAX_BYTES,As=nt.kMaxLength}),ce=He(()=>{Ue()}),Me=de((f,i)=>{le(),ce(),ue();var s=class extends Error{constructor(a){if(!Array.isArray(a))throw new TypeError(`Expected input to be an Array, got ${typeof a}`);let l="";for(let t=0;t<a.length;t++)l+=` ${a[t].stack}
|
|
2
|
-
`;super(l),this.name="AggregateError",this.errors=a}};i.exports={AggregateError:s,ArrayIsArray(a){return Array.isArray(a)},ArrayPrototypeIncludes(a,l){return a.includes(l)},ArrayPrototypeIndexOf(a,l){return a.indexOf(l)},ArrayPrototypeJoin(a,l){return a.join(l)},ArrayPrototypeMap(a,l){return a.map(l)},ArrayPrototypePop(a,l){return a.pop(l)},ArrayPrototypePush(a,l){return a.push(l)},ArrayPrototypeSlice(a,l,t){return a.slice(l,t)},Error,FunctionPrototypeCall(a,l,...t){return a.call(l,...t)},FunctionPrototypeSymbolHasInstance(a,l){return Function.prototype[Symbol.hasInstance].call(a,l)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(a,l){return Object.defineProperties(a,l)},ObjectDefineProperty(a,l,t){return Object.defineProperty(a,l,t)},ObjectGetOwnPropertyDescriptor(a,l){return Object.getOwnPropertyDescriptor(a,l)},ObjectKeys(a){return Object.keys(a)},ObjectSetPrototypeOf(a,l){return Object.setPrototypeOf(a,l)},Promise,PromisePrototypeCatch(a,l){return a.catch(l)},PromisePrototypeThen(a,l,t){return a.then(l,t)},PromiseReject(a){return Promise.reject(a)},PromiseResolve(a){return Promise.resolve(a)},ReflectApply:Reflect.apply,RegExpPrototypeTest(a,l){return a.test(l)},SafeSet:Set,String,StringPrototypeSlice(a,l,t){return a.slice(l,t)},StringPrototypeToLowerCase(a){return a.toLowerCase()},StringPrototypeToUpperCase(a){return a.toUpperCase()},StringPrototypeTrim(a){return a.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(a,l,t){return a.set(l,t)},Boolean,Uint8Array}}),Is=de((f,i)=>{le(),ce(),ue(),i.exports={format(s,...a){return s.replace(/%([sdifj])/g,function(...[l,t]){let r=a.shift();return t==="f"?r.toFixed(6):t==="j"?JSON.stringify(r):t==="s"&&typeof r=="object"?`${r.constructor!==Object?r.constructor.name:""} {}`.trim():r.toString()})},inspect(s){switch(typeof s){case"string":if(s.includes("'"))if(s.includes('"')){if(!s.includes("`")&&!s.includes("${"))return`\`${s}\``}else return`"${s}"`;return`'${s}'`;case"number":return isNaN(s)?"NaN":Object.is(s,-0)?String(s):s;case"bigint":return`${String(s)}n`;case"boolean":case"undefined":return String(s);case"object":return"{}"}}}}),qe=de((f,i)=>{le(),ce(),ue();var{format:s,inspect:a}=Is(),{AggregateError:l}=Me(),t=globalThis.AggregateError||l,r=Symbol("kIsNodeError"),n=["string","function","number","object","Function","Object","boolean","bigint","symbol"],e=/^([A-Z][a-z0-9]*)+$/,o="__node_internal_",u={};function p(g,_){if(!g)throw new u.ERR_INTERNAL_ASSERTION(_)}function d(g){let _="",I=g.length,v=g[0]==="-"?1:0;for(;I>=v+4;I-=3)_=`_${g.slice(I-3,I)}${_}`;return`${g.slice(0,I)}${_}`}function b(g,_,I){if(typeof _=="function")return p(_.length<=I.length,`Code: ${g}; The provided arguments length (${I.length}) does not match the required ones (${_.length}).`),_(...I);let v=(_.match(/%[dfijoOs]/g)||[]).length;return p(v===I.length,`Code: ${g}; The provided arguments length (${I.length}) does not match the required ones (${v}).`),I.length===0?_:s(_,...I)}function h(g,_,I){I||(I=Error);class v extends I{constructor(...E){super(b(g,_,E))}toString(){return`${this.name} [${g}]: ${this.message}`}}Object.defineProperties(v.prototype,{name:{value:I.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${g}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),v.prototype.code=g,v.prototype[r]=!0,u[g]=v}function y(g){let _=o+g.name;return Object.defineProperty(g,"name",{value:_}),g}function m(g,_){if(g&&_&&g!==_){if(Array.isArray(_.errors))return _.errors.push(g),_;let I=new t([_,g],_.message);return I.code=_.code,I}return g||_}var S=class extends Error{constructor(g="The operation was aborted",_=void 0){if(_!==void 0&&typeof _!="object")throw new u.ERR_INVALID_ARG_TYPE("options","Object",_);super(g,_),this.code="ABORT_ERR",this.name="AbortError"}};h("ERR_ASSERTION","%s",Error),h("ERR_INVALID_ARG_TYPE",(g,_,I)=>{p(typeof g=="string","'name' must be a string"),Array.isArray(_)||(_=[_]);let v="The ";g.endsWith(" argument")?v+=`${g} `:v+=`"${g}" ${g.includes(".")?"property":"argument"} `,v+="must be ";let A=[],E=[],k=[];for(let P of _)p(typeof P=="string","All expected entries have to be of type string"),n.includes(P)?A.push(P.toLowerCase()):e.test(P)?E.push(P):(p(P!=="object",'The value "object" should be written as "Object"'),k.push(P));if(E.length>0){let P=A.indexOf("object");P!==-1&&(A.splice(A,P,1),E.push("Object"))}if(A.length>0){switch(A.length){case 1:v+=`of type ${A[0]}`;break;case 2:v+=`one of type ${A[0]} or ${A[1]}`;break;default:{let P=A.pop();v+=`one of type ${A.join(", ")}, or ${P}`}}(E.length>0||k.length>0)&&(v+=" or ")}if(E.length>0){switch(E.length){case 1:v+=`an instance of ${E[0]}`;break;case 2:v+=`an instance of ${E[0]} or ${E[1]}`;break;default:{let P=E.pop();v+=`an instance of ${E.join(", ")}, or ${P}`}}k.length>0&&(v+=" or ")}switch(k.length){case 0:break;case 1:k[0].toLowerCase()!==k[0]&&(v+="an "),v+=`${k[0]}`;break;case 2:v+=`one of ${k[0]} or ${k[1]}`;break;default:{let P=k.pop();v+=`one of ${k.join(", ")}, or ${P}`}}if(I==null)v+=`. Received ${I}`;else if(typeof I=="function"&&I.name)v+=`. Received function ${I.name}`;else if(typeof I=="object"){var C;if((C=I.constructor)!==null&&C!==void 0&&C.name)v+=`. Received an instance of ${I.constructor.name}`;else{let P=a(I,{depth:-1});v+=`. Received ${P}`}}else{let P=a(I,{colors:!1});P.length>25&&(P=`${P.slice(0,25)}...`),v+=`. Received type ${typeof I} (${P})`}return v},TypeError),h("ERR_INVALID_ARG_VALUE",(g,_,I="is invalid")=>{let v=a(_);return v.length>128&&(v=v.slice(0,128)+"..."),`The ${g.includes(".")?"property":"argument"} '${g}' ${I}. Received ${v}`},TypeError),h("ERR_INVALID_RETURN_VALUE",(g,_,I)=>{var v;let A=I!=null&&(v=I.constructor)!==null&&v!==void 0&&v.name?`instance of ${I.constructor.name}`:`type ${typeof I}`;return`Expected ${g} to be returned from the "${_}" function but got ${A}.`},TypeError),h("ERR_MISSING_ARGS",(...g)=>{p(g.length>0,"At least one arg needs to be specified");let _,I=g.length;switch(g=(Array.isArray(g)?g:[g]).map(v=>`"${v}"`).join(" or "),I){case 1:_+=`The ${g[0]} argument`;break;case 2:_+=`The ${g[0]} and ${g[1]} arguments`;break;default:{let v=g.pop();_+=`The ${g.join(", ")}, and ${v} arguments`}break}return`${_} must be specified`},TypeError),h("ERR_OUT_OF_RANGE",(g,_,I)=>{p(_,'Missing "range" argument');let v;if(Number.isInteger(I)&&Math.abs(I)>2**32)v=d(String(I));else if(typeof I=="bigint"){v=String(I);let A=BigInt(2)**BigInt(32);(I>A||I<-A)&&(v=d(v)),v+="n"}else v=a(I);return`The value of "${g}" is out of range. It must be ${_}. Received ${v}`},RangeError),h("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),h("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),h("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),h("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),h("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),h("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),h("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),h("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),h("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),h("ERR_STREAM_WRITE_AFTER_END","write after end",Error),h("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),i.exports={AbortError:S,aggregateTwoErrors:y(m),hideStackFrames:y,codes:u}}),Kt=de((f,i)=>{le(),ce(),ue();var{AbortController:s,AbortSignal:a}=typeof self<"u"?self:typeof window<"u"?window:void 0;i.exports=s,i.exports.AbortSignal=a,i.exports.default=s}),yt={};Ct(yt,{EventEmitter:()=>Ts,default:()=>Pt,defaultMaxListeners:()=>ks,init:()=>xs,listenerCount:()=>Os,on:()=>Ps,once:()=>Rs});function dl(){if(zn)return qt;zn=!0;var f=typeof Reflect=="object"?Reflect:null,i=f&&typeof f.apply=="function"?f.apply:function(I,v,A){return Function.prototype.apply.call(I,v,A)},s;f&&typeof f.ownKeys=="function"?s=f.ownKeys:Object.getOwnPropertySymbols?s=function(I){return Object.getOwnPropertyNames(I).concat(Object.getOwnPropertySymbols(I))}:s=function(I){return Object.getOwnPropertyNames(I)};function a(I){console&&console.warn&&console.warn(I)}var l=Number.isNaN||function(I){return I!==I};function t(){t.init.call(this)}qt=t,qt.once=S,t.EventEmitter=t,t.prototype._events=void 0,t.prototype._eventsCount=0,t.prototype._maxListeners=void 0;var r=10;function n(I){if(typeof I!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof I)}Object.defineProperty(t,"defaultMaxListeners",{enumerable:!0,get:function(){return r},set:function(I){if(typeof I!="number"||I<0||l(I))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+I+".");r=I}}),t.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},t.prototype.setMaxListeners=function(I){if(typeof I!="number"||I<0||l(I))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+I+".");return this._maxListeners=I,this};function e(I){return I._maxListeners===void 0?t.defaultMaxListeners:I._maxListeners}t.prototype.getMaxListeners=function(){return e(this)},t.prototype.emit=function(I){for(var v=[],A=1;A<arguments.length;A++)v.push(arguments[A]);var E=I==="error",k=this._events;if(k!==void 0)E=E&&k.error===void 0;else if(!E)return!1;if(E){var C;if(v.length>0&&(C=v[0]),C instanceof Error)throw C;var P=new Error("Unhandled error."+(C?" ("+C.message+")":""));throw P.context=C,P}var L=k[I];if(L===void 0)return!1;if(typeof L=="function")i(L,this,v);else for(var x=L.length,q=h(L,x),A=0;A<x;++A)i(q[A],this,v);return!0};function o(I,v,A,E){var k,C,P;if(n(A),C=I._events,C===void 0?(C=I._events=Object.create(null),I._eventsCount=0):(C.newListener!==void 0&&(I.emit("newListener",v,A.listener?A.listener:A),C=I._events),P=C[v]),P===void 0)P=C[v]=A,++I._eventsCount;else if(typeof P=="function"?P=C[v]=E?[A,P]:[P,A]:E?P.unshift(A):P.push(A),k=e(I),k>0&&P.length>k&&!P.warned){P.warned=!0;var L=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");L.name="MaxListenersExceededWarning",L.emitter=I,L.type=v,L.count=P.length,a(L)}return I}t.prototype.addListener=function(I,v){return o(this,I,v,!1)},t.prototype.on=t.prototype.addListener,t.prototype.prependListener=function(I,v){return o(this,I,v,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(I,v,A){var E={fired:!1,wrapFn:void 0,target:I,type:v,listener:A},k=u.bind(E);return k.listener=A,E.wrapFn=k,k}t.prototype.once=function(I,v){return n(v),this.on(I,p(this,I,v)),this},t.prototype.prependOnceListener=function(I,v){return n(v),this.prependListener(I,p(this,I,v)),this},t.prototype.removeListener=function(I,v){var A,E,k,C,P;if(n(v),E=this._events,E===void 0)return this;if(A=E[I],A===void 0)return this;if(A===v||A.listener===v)--this._eventsCount===0?this._events=Object.create(null):(delete E[I],E.removeListener&&this.emit("removeListener",I,A.listener||v));else if(typeof A!="function"){for(k=-1,C=A.length-1;C>=0;C--)if(A[C]===v||A[C].listener===v){P=A[C].listener,k=C;break}if(k<0)return this;k===0?A.shift():y(A,k),A.length===1&&(E[I]=A[0]),E.removeListener!==void 0&&this.emit("removeListener",I,P||v)}return this},t.prototype.off=t.prototype.removeListener,t.prototype.removeAllListeners=function(I){var v,A,E;if(A=this._events,A===void 0)return this;if(A.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):A[I]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete A[I]),this;if(arguments.length===0){var k=Object.keys(A),C;for(E=0;E<k.length;++E)C=k[E],C!=="removeListener"&&this.removeAllListeners(C);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(v=A[I],typeof v=="function")this.removeListener(I,v);else if(v!==void 0)for(E=v.length-1;E>=0;E--)this.removeListener(I,v[E]);return this};function d(I,v,A){var E=I._events;if(E===void 0)return[];var k=E[v];return k===void 0?[]:typeof k=="function"?A?[k.listener||k]:[k]:A?m(k):h(k,k.length)}t.prototype.listeners=function(I){return d(this,I,!0)},t.prototype.rawListeners=function(I){return d(this,I,!1)},t.listenerCount=function(I,v){return typeof I.listenerCount=="function"?I.listenerCount(v):b.call(I,v)},t.prototype.listenerCount=b;function b(I){var v=this._events;if(v!==void 0){var A=v[I];if(typeof A=="function")return 1;if(A!==void 0)return A.length}return 0}t.prototype.eventNames=function(){return this._eventsCount>0?s(this._events):[]};function h(I,v){for(var A=new Array(v),E=0;E<v;++E)A[E]=I[E];return A}function y(I,v){for(;v+1<I.length;v++)I[v]=I[v+1];I.pop()}function m(I){for(var v=new Array(I.length),A=0;A<v.length;++A)v[A]=I[A].listener||I[A];return v}function S(I,v){return new Promise(function(A,E){function k(P){I.removeListener(v,C),E(P)}function C(){typeof I.removeListener=="function"&&I.removeListener("error",k),A([].slice.call(arguments))}_(I,v,C,{once:!0}),v!=="error"&&g(I,k,{once:!0})})}function g(I,v,A){typeof I.on=="function"&&_(I,"error",v,A)}function _(I,v,A,E){if(typeof I.on=="function")E.once?I.once(v,A):I.on(v,A);else if(typeof I.addEventListener=="function")I.addEventListener(v,function k(C){E.once&&I.removeEventListener(v,k),A(C)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof I)}return qt}var qt,zn,Pt,Ts,ks,xs,Os,Ps,Rs,At=He(()=>{le(),ce(),ue(),qt={},zn=!1,Pt=dl(),Pt.once,Pt.once=function(f,i){return new Promise((s,a)=>{function l(...r){t!==void 0&&f.removeListener("error",t),s(r)}let t;i!=="error"&&(t=r=>{f.removeListener(name,l),a(r)},f.once("error",t)),f.once(i,l)})},Pt.on=function(f,i){let s=[],a=[],l=null,t=!1,r={async next(){let o=s.shift();if(o)return createIterResult(o,!1);if(l){let u=Promise.reject(l);return l=null,u}return t?createIterResult(void 0,!0):new Promise((u,p)=>a.push({resolve:u,reject:p}))},async return(){f.removeListener(i,n),f.removeListener("error",e),t=!0;for(let o of a)o.resolve(createIterResult(void 0,!0));return createIterResult(void 0,!0)},throw(o){l=o,f.removeListener(i,n),f.removeListener("error",e)},[Symbol.asyncIterator](){return this}};return f.on(i,n),f.on("error",e),r;function n(...o){let u=a.shift();u?u.resolve(createIterResult(o,!1)):s.push(o)}function e(o){t=!0;let u=a.shift();u?u.reject(o):l=o,r.return()}},{EventEmitter:Ts,defaultMaxListeners:ks,init:xs,listenerCount:Os,on:Ps,once:Rs}=Pt}),$e=de((f,i)=>{le(),ce(),ue();var s=(Ue(),Pe(Ne)),{format:a,inspect:l}=Is(),{codes:{ERR_INVALID_ARG_TYPE:t}}=qe(),{kResistStopPropagation:r,AggregateError:n,SymbolDispose:e}=Me(),o=globalThis.AbortSignal||Kt().AbortSignal,u=globalThis.AbortController||Kt().AbortController,p=Object.getPrototypeOf(async function(){}).constructor,d=globalThis.Blob||s.Blob,b=typeof d<"u"?function(m){return m instanceof d}:function(m){return!1},h=(m,S)=>{if(m!==void 0&&(m===null||typeof m!="object"||!("aborted"in m)))throw new t(S,"AbortSignal",m)},y=(m,S)=>{if(typeof m!="function")throw new t(S,"Function",m)};i.exports={AggregateError:n,kEmptyObject:Object.freeze({}),once(m){let S=!1;return function(...g){S||(S=!0,m.apply(this,g))}},createDeferredPromise:function(){let m,S;return{promise:new Promise((g,_)=>{m=g,S=_}),resolve:m,reject:S}},promisify(m){return new Promise((S,g)=>{m((_,...I)=>_?g(_):S(...I))})},debuglog(){return function(){}},format:a,inspect:l,types:{isAsyncFunction(m){return m instanceof p},isArrayBufferView(m){return ArrayBuffer.isView(m)}},isBlob:b,deprecate(m,S){return m},addAbortListener:(At(),Pe(yt)).addAbortListener||function(m,S){if(m===void 0)throw new t("signal","AbortSignal",m);h(m,"signal"),y(S,"listener");let g;return m.aborted?queueMicrotask(()=>S()):(m.addEventListener("abort",S,{__proto__:null,once:!0,[r]:!0}),g=()=>{m.removeEventListener("abort",S)}),{__proto__:null,[e](){var _;(_=g)===null||_===void 0||_()}}},AbortSignalAny:o.any||function(m){if(m.length===1)return m[0];let S=new u,g=()=>S.abort();return m.forEach(_=>{h(_,"signals"),_.addEventListener("abort",g,{once:!0})}),S.signal.addEventListener("abort",()=>{m.forEach(_=>_.removeEventListener("abort",g))},{once:!0}),S.signal}},i.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}),Vt=de((f,i)=>{le(),ce(),ue();var{ArrayIsArray:s,ArrayPrototypeIncludes:a,ArrayPrototypeJoin:l,ArrayPrototypeMap:t,NumberIsInteger:r,NumberIsNaN:n,NumberMAX_SAFE_INTEGER:e,NumberMIN_SAFE_INTEGER:o,NumberParseInt:u,ObjectPrototypeHasOwnProperty:p,RegExpPrototypeExec:d,String:b,StringPrototypeToUpperCase:h,StringPrototypeTrim:y}=Me(),{hideStackFrames:m,codes:{ERR_SOCKET_BAD_PORT:S,ERR_INVALID_ARG_TYPE:g,ERR_INVALID_ARG_VALUE:_,ERR_OUT_OF_RANGE:I,ERR_UNKNOWN_SIGNAL:v}}=qe(),{normalizeEncoding:A}=$e(),{isAsyncFunction:E,isArrayBufferView:k}=$e().types,C={};function P($){return $===($|0)}function L($){return $===$>>>0}var x=/^[0-7]+$/,q="must be a 32-bit unsigned integer or an octal string";function D($,ge,ve){if(typeof $>"u"&&($=ve),typeof $=="string"){if(d(x,$)===null)throw new _(ge,$,q);$=u($,8)}return Q($,ge),$}var U=m(($,ge,ve=o,se=e)=>{if(typeof $!="number")throw new g(ge,"number",$);if(!r($))throw new I(ge,"an integer",$);if($<ve||$>se)throw new I(ge,`>= ${ve} && <= ${se}`,$)}),ae=m(($,ge,ve=-2147483648,se=2147483647)=>{if(typeof $!="number")throw new g(ge,"number",$);if(!r($))throw new I(ge,"an integer",$);if($<ve||$>se)throw new I(ge,`>= ${ve} && <= ${se}`,$)}),Q=m(($,ge,ve=!1)=>{if(typeof $!="number")throw new g(ge,"number",$);if(!r($))throw new I(ge,"an integer",$);let se=ve?1:0,xe=4294967295;if($<se||$>xe)throw new I(ge,`>= ${se} && <= ${xe}`,$)});function K($,ge){if(typeof $!="string")throw new g(ge,"string",$)}function re($,ge,ve=void 0,se){if(typeof $!="number")throw new g(ge,"number",$);if(ve!=null&&$<ve||se!=null&&$>se||(ve!=null||se!=null)&&n($))throw new I(ge,`${ve!=null?`>= ${ve}`:""}${ve!=null&&se!=null?" && ":""}${se!=null?`<= ${se}`:""}`,$)}var F=m(($,ge,ve)=>{if(!a(ve,$)){let se="must be one of: "+l(t(ve,xe=>typeof xe=="string"?`'${xe}'`:b(xe)),", ");throw new _(ge,$,se)}});function Z($,ge){if(typeof $!="boolean")throw new g(ge,"boolean",$)}function R($,ge,ve){return $==null||!p($,ge)?ve:$[ge]}var J=m(($,ge,ve=null)=>{let se=R(ve,"allowArray",!1),xe=R(ve,"allowFunction",!1);if(!R(ve,"nullable",!1)&&$===null||!se&&s($)||typeof $!="object"&&(!xe||typeof $!="function"))throw new g(ge,"Object",$)}),me=m(($,ge)=>{if($!=null&&typeof $!="object"&&typeof $!="function")throw new g(ge,"a dictionary",$)}),te=m(($,ge,ve=0)=>{if(!s($))throw new g(ge,"Array",$);if($.length<ve){let se=`must be longer than ${ve}`;throw new _(ge,$,se)}});function we($,ge){te($,ge);for(let ve=0;ve<$.length;ve++)K($[ve],`${ge}[${ve}]`)}function V($,ge){te($,ge);for(let ve=0;ve<$.length;ve++)Z($[ve],`${ge}[${ve}]`)}function N($,ge){te($,ge);for(let ve=0;ve<$.length;ve++){let se=$[ve],xe=`${ge}[${ve}]`;if(se==null)throw new g(xe,"AbortSignal",se);ye(se,xe)}}function ne($,ge="signal"){if(K($,ge),C[$]===void 0)throw C[h($)]!==void 0?new v($+" (signals must use all capital letters)"):new v($)}var H=m(($,ge="buffer")=>{if(!k($))throw new g(ge,["Buffer","TypedArray","DataView"],$)});function G($,ge){let ve=A(ge),se=$.length;if(ve==="hex"&&se%2!==0)throw new _("encoding",ge,`is invalid for data of length ${se}`)}function Y($,ge="Port",ve=!0){if(typeof $!="number"&&typeof $!="string"||typeof $=="string"&&y($).length===0||+$!==+$>>>0||$>65535||$===0&&!ve)throw new S(ge,$,ve);return $|0}var ye=m(($,ge)=>{if($!==void 0&&($===null||typeof $!="object"||!("aborted"in $)))throw new g(ge,"AbortSignal",$)}),oe=m(($,ge)=>{if(typeof $!="function")throw new g(ge,"Function",$)}),M=m(($,ge)=>{if(typeof $!="function"||E($))throw new g(ge,"Function",$)}),W=m(($,ge)=>{if($!==void 0)throw new g(ge,"undefined",$)});function ee($,ge,ve){if(!a(ve,$))throw new g(ge,`('${l(ve,"|")}')`,$)}var fe=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function pe($,ge){if(typeof $>"u"||!d(fe,$))throw new _(ge,$,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function be($){if(typeof $=="string")return pe($,"hints"),$;if(s($)){let ge=$.length,ve="";if(ge===0)return ve;for(let se=0;se<ge;se++){let xe=$[se];pe(xe,"hints"),ve+=xe,se!==ge-1&&(ve+=", ")}return ve}throw new _("hints",$,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}i.exports={isInt32:P,isUint32:L,parseFileMode:D,validateArray:te,validateStringArray:we,validateBooleanArray:V,validateAbortSignalArray:N,validateBoolean:Z,validateBuffer:H,validateDictionary:me,validateEncoding:G,validateFunction:oe,validateInt32:ae,validateInteger:U,validateNumber:re,validateObject:J,validateOneOf:F,validatePlainFunction:M,validatePort:Y,validateSignalName:ne,validateString:K,validateUint32:Q,validateUndefined:W,validateUnion:ee,validateAbortSignal:ye,validateLinkHeaderValue:be}}),It=de((f,i)=>{le(),ce(),ue();var s=i.exports={},a,l;function t(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?a=setTimeout:a=t}catch{a=t}try{typeof clearTimeout=="function"?l=clearTimeout:l=r}catch{l=r}})();function n(S){if(a===setTimeout)return setTimeout(S,0);if((a===t||!a)&&setTimeout)return a=setTimeout,setTimeout(S,0);try{return a(S,0)}catch{try{return a.call(null,S,0)}catch{return a.call(this,S,0)}}}function e(S){if(l===clearTimeout)return clearTimeout(S);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(S);try{return l(S)}catch{try{return l.call(null,S)}catch{return l.call(this,S)}}}var o=[],u=!1,p,d=-1;function b(){!u||!p||(u=!1,p.length?o=p.concat(o):d=-1,o.length&&h())}function h(){if(!u){var S=n(b);u=!0;for(var g=o.length;g;){for(p=o,o=[];++d<g;)p&&p[d].run();d=-1,g=o.length}p=null,u=!1,e(S)}}s.nextTick=function(S){var g=new Array(arguments.length-1);if(arguments.length>1)for(var _=1;_<arguments.length;_++)g[_-1]=arguments[_];o.push(new y(S,g)),o.length===1&&!u&&n(h)};function y(S,g){this.fun=S,this.array=g}y.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={};function m(){}s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(S){return[]},s.binding=function(S){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(S){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}}),lt=de((f,i)=>{le(),ce(),ue();var{SymbolAsyncIterator:s,SymbolIterator:a,SymbolFor:l}=Me(),t=l("nodejs.stream.destroyed"),r=l("nodejs.stream.errored"),n=l("nodejs.stream.readable"),e=l("nodejs.stream.writable"),o=l("nodejs.stream.disturbed"),u=l("nodejs.webstream.isClosedPromise"),p=l("nodejs.webstream.controllerErrorFunction");function d(R,J=!1){var me;return!!(R&&typeof R.pipe=="function"&&typeof R.on=="function"&&(!J||typeof R.pause=="function"&&typeof R.resume=="function")&&(!R._writableState||((me=R._readableState)===null||me===void 0?void 0:me.readable)!==!1)&&(!R._writableState||R._readableState))}function b(R){var J;return!!(R&&typeof R.write=="function"&&typeof R.on=="function"&&(!R._readableState||((J=R._writableState)===null||J===void 0?void 0:J.writable)!==!1))}function h(R){return!!(R&&typeof R.pipe=="function"&&R._readableState&&typeof R.on=="function"&&typeof R.write=="function")}function y(R){return R&&(R._readableState||R._writableState||typeof R.write=="function"&&typeof R.on=="function"||typeof R.pipe=="function"&&typeof R.on=="function")}function m(R){return!!(R&&!y(R)&&typeof R.pipeThrough=="function"&&typeof R.getReader=="function"&&typeof R.cancel=="function")}function S(R){return!!(R&&!y(R)&&typeof R.getWriter=="function"&&typeof R.abort=="function")}function g(R){return!!(R&&!y(R)&&typeof R.readable=="object"&&typeof R.writable=="object")}function _(R){return m(R)||S(R)||g(R)}function I(R,J){return R==null?!1:J===!0?typeof R[s]=="function":J===!1?typeof R[a]=="function":typeof R[s]=="function"||typeof R[a]=="function"}function v(R){if(!y(R))return null;let J=R._writableState,me=R._readableState,te=J||me;return!!(R.destroyed||R[t]||te!=null&&te.destroyed)}function A(R){if(!b(R))return null;if(R.writableEnded===!0)return!0;let J=R._writableState;return J!=null&&J.errored?!1:typeof J?.ended!="boolean"?null:J.ended}function E(R,J){if(!b(R))return null;if(R.writableFinished===!0)return!0;let me=R._writableState;return me!=null&&me.errored?!1:typeof me?.finished!="boolean"?null:!!(me.finished||J===!1&&me.ended===!0&&me.length===0)}function k(R){if(!d(R))return null;if(R.readableEnded===!0)return!0;let J=R._readableState;return!J||J.errored?!1:typeof J?.ended!="boolean"?null:J.ended}function C(R,J){if(!d(R))return null;let me=R._readableState;return me!=null&&me.errored?!1:typeof me?.endEmitted!="boolean"?null:!!(me.endEmitted||J===!1&&me.ended===!0&&me.length===0)}function P(R){return R&&R[n]!=null?R[n]:typeof R?.readable!="boolean"?null:v(R)?!1:d(R)&&R.readable&&!C(R)}function L(R){return R&&R[e]!=null?R[e]:typeof R?.writable!="boolean"?null:v(R)?!1:b(R)&&R.writable&&!A(R)}function x(R,J){return y(R)?v(R)?!0:!(J?.readable!==!1&&P(R)||J?.writable!==!1&&L(R)):null}function q(R){var J,me;return y(R)?R.writableErrored?R.writableErrored:(J=(me=R._writableState)===null||me===void 0?void 0:me.errored)!==null&&J!==void 0?J:null:null}function D(R){var J,me;return y(R)?R.readableErrored?R.readableErrored:(J=(me=R._readableState)===null||me===void 0?void 0:me.errored)!==null&&J!==void 0?J:null:null}function U(R){if(!y(R))return null;if(typeof R.closed=="boolean")return R.closed;let J=R._writableState,me=R._readableState;return typeof J?.closed=="boolean"||typeof me?.closed=="boolean"?J?.closed||me?.closed:typeof R._closed=="boolean"&&ae(R)?R._closed:null}function ae(R){return typeof R._closed=="boolean"&&typeof R._defaultKeepAlive=="boolean"&&typeof R._removedConnection=="boolean"&&typeof R._removedContLen=="boolean"}function Q(R){return typeof R._sent100=="boolean"&&ae(R)}function K(R){var J;return typeof R._consuming=="boolean"&&typeof R._dumped=="boolean"&&((J=R.req)===null||J===void 0?void 0:J.upgradeOrConnect)===void 0}function re(R){if(!y(R))return null;let J=R._writableState,me=R._readableState,te=J||me;return!te&&Q(R)||!!(te&&te.autoDestroy&&te.emitClose&&te.closed===!1)}function F(R){var J;return!!(R&&((J=R[o])!==null&&J!==void 0?J:R.readableDidRead||R.readableAborted))}function Z(R){var J,me,te,we,V,N,ne,H,G,Y;return!!(R&&((J=(me=(te=(we=(V=(N=R[r])!==null&&N!==void 0?N:R.readableErrored)!==null&&V!==void 0?V:R.writableErrored)!==null&&we!==void 0?we:(ne=R._readableState)===null||ne===void 0?void 0:ne.errorEmitted)!==null&&te!==void 0?te:(H=R._writableState)===null||H===void 0?void 0:H.errorEmitted)!==null&&me!==void 0?me:(G=R._readableState)===null||G===void 0?void 0:G.errored)!==null&&J!==void 0?J:!((Y=R._writableState)===null||Y===void 0)&&Y.errored))}i.exports={isDestroyed:v,kIsDestroyed:t,isDisturbed:F,kIsDisturbed:o,isErrored:Z,kIsErrored:r,isReadable:P,kIsReadable:n,kIsClosedPromise:u,kControllerErrorFunction:p,kIsWritable:e,isClosed:U,isDuplexNodeStream:h,isFinished:x,isIterable:I,isReadableNodeStream:d,isReadableStream:m,isReadableEnded:k,isReadableFinished:C,isReadableErrored:D,isNodeStream:y,isWebStream:_,isWritable:L,isWritableNodeStream:b,isWritableStream:S,isWritableEnded:A,isWritableFinished:E,isWritableErrored:q,isServerRequest:K,isServerResponse:Q,willEmitClose:re,isTransformStream:g}}),mt=de((f,i)=>{le(),ce(),ue();var s=It(),{AbortError:a,codes:l}=qe(),{ERR_INVALID_ARG_TYPE:t,ERR_STREAM_PREMATURE_CLOSE:r}=l,{kEmptyObject:n,once:e}=$e(),{validateAbortSignal:o,validateFunction:u,validateObject:p,validateBoolean:d}=Vt(),{Promise:b,PromisePrototypeThen:h,SymbolDispose:y}=Me(),{isClosed:m,isReadable:S,isReadableNodeStream:g,isReadableStream:_,isReadableFinished:I,isReadableErrored:v,isWritable:A,isWritableNodeStream:E,isWritableStream:k,isWritableFinished:C,isWritableErrored:P,isNodeStream:L,willEmitClose:x,kIsClosedPromise:q}=lt(),D;function U(F){return F.setHeader&&typeof F.abort=="function"}var ae=()=>{};function Q(F,Z,R){var J,me;if(arguments.length===2?(R=Z,Z=n):Z==null?Z=n:p(Z,"options"),u(R,"callback"),o(Z.signal,"options.signal"),R=e(R),_(F)||k(F))return K(F,Z,R);if(!L(F))throw new t("stream",["ReadableStream","WritableStream","Stream"],F);let te=(J=Z.readable)!==null&&J!==void 0?J:g(F),we=(me=Z.writable)!==null&&me!==void 0?me:E(F),V=F._writableState,N=F._readableState,ne=()=>{F.writable||Y()},H=x(F)&&g(F)===te&&E(F)===we,G=C(F,!1),Y=()=>{G=!0,F.destroyed&&(H=!1),!(H&&(!F.readable||te))&&(!te||ye)&&R.call(F)},ye=I(F,!1),oe=()=>{ye=!0,F.destroyed&&(H=!1),!(H&&(!F.writable||we))&&(!we||G)&&R.call(F)},M=$=>{R.call(F,$)},W=m(F),ee=()=>{W=!0;let $=P(F)||v(F);if($&&typeof $!="boolean")return R.call(F,$);if(te&&!ye&&g(F,!0)&&!I(F,!1))return R.call(F,new r);if(we&&!G&&!C(F,!1))return R.call(F,new r);R.call(F)},fe=()=>{W=!0;let $=P(F)||v(F);if($&&typeof $!="boolean")return R.call(F,$);R.call(F)},pe=()=>{F.req.on("finish",Y)};U(F)?(F.on("complete",Y),H||F.on("abort",ee),F.req?pe():F.on("request",pe)):we&&!V&&(F.on("end",ne),F.on("close",ne)),!H&&typeof F.aborted=="boolean"&&F.on("aborted",ee),F.on("end",oe),F.on("finish",Y),Z.error!==!1&&F.on("error",M),F.on("close",ee),W?s.nextTick(ee):V!=null&&V.errorEmitted||N!=null&&N.errorEmitted?H||s.nextTick(fe):(!te&&(!H||S(F))&&(G||A(F)===!1)||!we&&(!H||A(F))&&(ye||S(F)===!1)||N&&F.req&&F.aborted)&&s.nextTick(fe);let be=()=>{R=ae,F.removeListener("aborted",ee),F.removeListener("complete",Y),F.removeListener("abort",ee),F.removeListener("request",pe),F.req&&F.req.removeListener("finish",Y),F.removeListener("end",ne),F.removeListener("close",ne),F.removeListener("finish",Y),F.removeListener("end",oe),F.removeListener("error",M),F.removeListener("close",ee)};if(Z.signal&&!W){let $=()=>{let ge=R;be(),ge.call(F,new a(void 0,{cause:Z.signal.reason}))};if(Z.signal.aborted)s.nextTick($);else{D=D||$e().addAbortListener;let ge=D(Z.signal,$),ve=R;R=e((...se)=>{ge[y](),ve.apply(F,se)})}}return be}function K(F,Z,R){let J=!1,me=ae;if(Z.signal)if(me=()=>{J=!0,R.call(F,new a(void 0,{cause:Z.signal.reason}))},Z.signal.aborted)s.nextTick(me);else{D=D||$e().addAbortListener;let we=D(Z.signal,me),V=R;R=e((...N)=>{we[y](),V.apply(F,N)})}let te=(...we)=>{J||s.nextTick(()=>R.apply(F,we))};return h(F[q].promise,te,te),ae}function re(F,Z){var R;let J=!1;return Z===null&&(Z=n),(R=Z)!==null&&R!==void 0&&R.cleanup&&(d(Z.cleanup,"cleanup"),J=Z.cleanup),new b((me,te)=>{let we=Q(F,Z,V=>{J&&we(),V?te(V):me()})})}i.exports=Q,i.exports.finished=re}),Mt=de((f,i)=>{le(),ce(),ue();var s=It(),{aggregateTwoErrors:a,codes:{ERR_MULTIPLE_CALLBACK:l},AbortError:t}=qe(),{Symbol:r}=Me(),{kIsDestroyed:n,isDestroyed:e,isFinished:o,isServerRequest:u}=lt(),p=r("kDestroy"),d=r("kConstruct");function b(x,q,D){x&&(x.stack,q&&!q.errored&&(q.errored=x),D&&!D.errored&&(D.errored=x))}function h(x,q){let D=this._readableState,U=this._writableState,ae=U||D;return U!=null&&U.destroyed||D!=null&&D.destroyed?(typeof q=="function"&&q(),this):(b(x,U,D),U&&(U.destroyed=!0),D&&(D.destroyed=!0),ae.constructed?y(this,x,q):this.once(p,function(Q){y(this,a(Q,x),q)}),this)}function y(x,q,D){let U=!1;function ae(Q){if(U)return;U=!0;let K=x._readableState,re=x._writableState;b(Q,re,K),re&&(re.closed=!0),K&&(K.closed=!0),typeof D=="function"&&D(Q),Q?s.nextTick(m,x,Q):s.nextTick(S,x)}try{x._destroy(q||null,ae)}catch(Q){ae(Q)}}function m(x,q){g(x,q),S(x)}function S(x){let q=x._readableState,D=x._writableState;D&&(D.closeEmitted=!0),q&&(q.closeEmitted=!0),(D!=null&&D.emitClose||q!=null&&q.emitClose)&&x.emit("close")}function g(x,q){let D=x._readableState,U=x._writableState;U!=null&&U.errorEmitted||D!=null&&D.errorEmitted||(U&&(U.errorEmitted=!0),D&&(D.errorEmitted=!0),x.emit("error",q))}function _(){let x=this._readableState,q=this._writableState;x&&(x.constructed=!0,x.closed=!1,x.closeEmitted=!1,x.destroyed=!1,x.errored=null,x.errorEmitted=!1,x.reading=!1,x.ended=x.readable===!1,x.endEmitted=x.readable===!1),q&&(q.constructed=!0,q.destroyed=!1,q.closed=!1,q.closeEmitted=!1,q.errored=null,q.errorEmitted=!1,q.finalCalled=!1,q.prefinished=!1,q.ended=q.writable===!1,q.ending=q.writable===!1,q.finished=q.writable===!1)}function I(x,q,D){let U=x._readableState,ae=x._writableState;if(ae!=null&&ae.destroyed||U!=null&&U.destroyed)return this;U!=null&&U.autoDestroy||ae!=null&&ae.autoDestroy?x.destroy(q):q&&(q.stack,ae&&!ae.errored&&(ae.errored=q),U&&!U.errored&&(U.errored=q),D?s.nextTick(g,x,q):g(x,q))}function v(x,q){if(typeof x._construct!="function")return;let D=x._readableState,U=x._writableState;D&&(D.constructed=!1),U&&(U.constructed=!1),x.once(d,q),!(x.listenerCount(d)>1)&&s.nextTick(A,x)}function A(x){let q=!1;function D(U){if(q){I(x,U??new l);return}q=!0;let ae=x._readableState,Q=x._writableState,K=Q||ae;ae&&(ae.constructed=!0),Q&&(Q.constructed=!0),K.destroyed?x.emit(p,U):U?I(x,U,!0):s.nextTick(E,x)}try{x._construct(U=>{s.nextTick(D,U)})}catch(U){s.nextTick(D,U)}}function E(x){x.emit(d)}function k(x){return x?.setHeader&&typeof x.abort=="function"}function C(x){x.emit("close")}function P(x,q){x.emit("error",q),s.nextTick(C,x)}function L(x,q){!x||e(x)||(!q&&!o(x)&&(q=new t),u(x)?(x.socket=null,x.destroy(q)):k(x)?x.abort():k(x.req)?x.req.abort():typeof x.destroy=="function"?x.destroy(q):typeof x.close=="function"?x.close():q?s.nextTick(P,x,q):s.nextTick(C,x),x.destroyed||(x[n]=!0))}i.exports={construct:v,destroyer:L,destroy:h,undestroy:_,errorOrDestroy:I}}),Di=de((f,i)=>{le(),ce(),ue();var{ArrayIsArray:s,ObjectSetPrototypeOf:a}=Me(),{EventEmitter:l}=(At(),Pe(yt));function t(n){l.call(this,n)}a(t.prototype,l.prototype),a(t,l),t.prototype.pipe=function(n,e){let o=this;function u(S){n.writable&&n.write(S)===!1&&o.pause&&o.pause()}o.on("data",u);function p(){o.readable&&o.resume&&o.resume()}n.on("drain",p),!n._isStdio&&(!e||e.end!==!1)&&(o.on("end",b),o.on("close",h));let d=!1;function b(){d||(d=!0,n.end())}function h(){d||(d=!0,typeof n.destroy=="function"&&n.destroy())}function y(S){m(),l.listenerCount(this,"error")===0&&this.emit("error",S)}r(o,"error",y),r(n,"error",y);function m(){o.removeListener("data",u),n.removeListener("drain",p),o.removeListener("end",b),o.removeListener("close",h),o.removeListener("error",y),n.removeListener("error",y),o.removeListener("end",m),o.removeListener("close",m),n.removeListener("close",m)}return o.on("end",m),o.on("close",m),n.on("close",m),n.emit("pipe",o),n};function r(n,e,o){if(typeof n.prependListener=="function")return n.prependListener(e,o);!n._events||!n._events[e]?n.on(e,o):s(n._events[e])?n._events[e].unshift(o):n._events[e]=[o,n._events[e]]}i.exports={Stream:t,prependListener:r}}),Tr=de((f,i)=>{le(),ce(),ue();var{SymbolDispose:s}=Me(),{AbortError:a,codes:l}=qe(),{isNodeStream:t,isWebStream:r,kControllerErrorFunction:n}=lt(),e=mt(),{ERR_INVALID_ARG_TYPE:o}=l,u,p=(d,b)=>{if(typeof d!="object"||!("aborted"in d))throw new o(b,"AbortSignal",d)};i.exports.addAbortSignal=function(d,b){if(p(d,"signal"),!t(b)&&!r(b))throw new o("stream",["ReadableStream","WritableStream","Stream"],b);return i.exports.addAbortSignalNoValidate(d,b)},i.exports.addAbortSignalNoValidate=function(d,b){if(typeof d!="object"||!("aborted"in d))return b;let h=t(b)?()=>{b.destroy(new a(void 0,{cause:d.reason}))}:()=>{b[n](new a(void 0,{cause:d.reason}))};if(d.aborted)h();else{u=u||$e().addAbortListener;let y=u(d,h);e(b,y[s])}return b}}),gl=de((f,i)=>{le(),ce(),ue();var{StringPrototypeSlice:s,SymbolIterator:a,TypedArrayPrototypeSet:l,Uint8Array:t}=Me(),{Buffer:r}=(Ue(),Pe(Ne)),{inspect:n}=$e();i.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){let o={data:e,next:null};this.length>0?this.tail.next=o:this.head=o,this.tail=o,++this.length}unshift(e){let o={data:e,next:this.head};this.length===0&&(this.tail=o),this.head=o,++this.length}shift(){if(this.length===0)return;let e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(this.length===0)return"";let o=this.head,u=""+o.data;for(;(o=o.next)!==null;)u+=e+o.data;return u}concat(e){if(this.length===0)return r.alloc(0);let o=r.allocUnsafe(e>>>0),u=this.head,p=0;for(;u;)l(o,u.data,p),p+=u.data.length,u=u.next;return o}consume(e,o){let u=this.head.data;if(e<u.length){let p=u.slice(0,e);return this.head.data=u.slice(e),p}return e===u.length?this.shift():o?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[a](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let o="",u=this.head,p=0;do{let d=u.data;if(e>d.length)o+=d,e-=d.length;else{e===d.length?(o+=d,++p,u.next?this.head=u.next:this.head=this.tail=null):(o+=s(d,0,e),this.head=u,u.data=s(d,e));break}++p}while((u=u.next)!==null);return this.length-=p,o}_getBuffer(e){let o=r.allocUnsafe(e),u=e,p=this.head,d=0;do{let b=p.data;if(e>b.length)l(o,b,u-e),e-=b.length;else{e===b.length?(l(o,b,u-e),++d,p.next?this.head=p.next:this.head=this.tail=null):(l(o,new t(b.buffer,b.byteOffset,e),u-e),this.head=p,p.data=b.slice(e));break}++d}while((p=p.next)!==null);return this.length-=d,o}[Symbol.for("nodejs.util.inspect.custom")](e,o){return n(this,{...o,depth:0,customInspect:!1})}}}),kr=de((f,i)=>{le(),ce(),ue();var{MathFloor:s,NumberIsInteger:a}=Me(),{validateInteger:l}=Vt(),{ERR_INVALID_ARG_VALUE:t}=qe().codes,r=16*1024,n=16;function e(d,b,h){return d.highWaterMark!=null?d.highWaterMark:b?d[h]:null}function o(d){return d?n:r}function u(d,b){l(b,"value",0),d?n=b:r=b}function p(d,b,h,y){let m=e(b,y,h);if(m!=null){if(!a(m)||m<0){let S=y?`options.${h}`:"options.highWaterMark";throw new t(S,m)}return s(m)}return o(d.objectMode)}i.exports={getHighWaterMark:p,getDefaultHighWaterMark:o,setDefaultHighWaterMark:u}}),yl=de((f,i)=>{le(),ce(),ue();var s=(Ue(),Pe(Ne)),a=s.Buffer;function l(r,n){for(var e in r)n[e]=r[e]}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?i.exports=s:(l(s,f),f.Buffer=t);function t(r,n,e){return a(r,n,e)}t.prototype=Object.create(a.prototype),l(a,t),t.from=function(r,n,e){if(typeof r=="number")throw new TypeError("Argument must not be a number");return a(r,n,e)},t.alloc=function(r,n,e){if(typeof r!="number")throw new TypeError("Argument must be a number");var o=a(r);return n!==void 0?typeof e=="string"?o.fill(n,e):o.fill(n):o.fill(0),o},t.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return a(r)},t.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return s.SlowBuffer(r)}}),ml=de(f=>{le(),ce(),ue();var i=yl().Buffer,s=i.isEncoding||function(g){switch(g=""+g,g&&g.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(g){if(!g)return"utf8";for(var _;;)switch(g){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return g;default:if(_)return;g=(""+g).toLowerCase(),_=!0}}function l(g){var _=a(g);if(typeof _!="string"&&(i.isEncoding===s||!s(g)))throw new Error("Unknown encoding: "+g);return _||g}f.StringDecoder=t;function t(g){this.encoding=l(g);var _;switch(this.encoding){case"utf16le":this.text=d,this.end=b,_=4;break;case"utf8":this.fillLast=o,_=4;break;case"base64":this.text=h,this.end=y,_=3;break;default:this.write=m,this.end=S;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(_)}t.prototype.write=function(g){if(g.length===0)return"";var _,I;if(this.lastNeed){if(_=this.fillLast(g),_===void 0)return"";I=this.lastNeed,this.lastNeed=0}else I=0;return I<g.length?_?_+this.text(g,I):this.text(g,I):_||""},t.prototype.end=p,t.prototype.text=u,t.prototype.fillLast=function(g){if(this.lastNeed<=g.length)return g.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);g.copy(this.lastChar,this.lastTotal-this.lastNeed,0,g.length),this.lastNeed-=g.length};function r(g){return g<=127?0:g>>5===6?2:g>>4===14?3:g>>3===30?4:g>>6===2?-1:-2}function n(g,_,I){var v=_.length-1;if(v<I)return 0;var A=r(_[v]);return A>=0?(A>0&&(g.lastNeed=A-1),A):--v<I||A===-2?0:(A=r(_[v]),A>=0?(A>0&&(g.lastNeed=A-2),A):--v<I||A===-2?0:(A=r(_[v]),A>=0?(A>0&&(A===2?A=0:g.lastNeed=A-3),A):0))}function e(g,_,I){if((_[0]&192)!==128)return g.lastNeed=0,"�";if(g.lastNeed>1&&_.length>1){if((_[1]&192)!==128)return g.lastNeed=1,"�";if(g.lastNeed>2&&_.length>2&&(_[2]&192)!==128)return g.lastNeed=2,"�"}}function o(g){var _=this.lastTotal-this.lastNeed,I=e(this,g);if(I!==void 0)return I;if(this.lastNeed<=g.length)return g.copy(this.lastChar,_,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);g.copy(this.lastChar,_,0,g.length),this.lastNeed-=g.length}function u(g,_){var I=n(this,g,_);if(!this.lastNeed)return g.toString("utf8",_);this.lastTotal=I;var v=g.length-(I-this.lastNeed);return g.copy(this.lastChar,0,v),g.toString("utf8",_,v)}function p(g){var _=g&&g.length?this.write(g):"";return this.lastNeed?_+"�":_}function d(g,_){if((g.length-_)%2===0){var I=g.toString("utf16le",_);if(I){var v=I.charCodeAt(I.length-1);if(v>=55296&&v<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=g[g.length-2],this.lastChar[1]=g[g.length-1],I.slice(0,-1)}return I}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=g[g.length-1],g.toString("utf16le",_,g.length-1)}function b(g){var _=g&&g.length?this.write(g):"";if(this.lastNeed){var I=this.lastTotal-this.lastNeed;return _+this.lastChar.toString("utf16le",0,I)}return _}function h(g,_){var I=(g.length-_)%3;return I===0?g.toString("base64",_):(this.lastNeed=3-I,this.lastTotal=3,I===1?this.lastChar[0]=g[g.length-1]:(this.lastChar[0]=g[g.length-2],this.lastChar[1]=g[g.length-1]),g.toString("base64",_,g.length-I))}function y(g){var _=g&&g.length?this.write(g):"";return this.lastNeed?_+this.lastChar.toString("base64",0,3-this.lastNeed):_}function m(g){return g.toString(this.encoding)}function S(g){return g&&g.length?this.write(g):""}}),Cs=de((f,i)=>{le(),ce(),ue();var s=It(),{PromisePrototypeThen:a,SymbolAsyncIterator:l,SymbolIterator:t}=Me(),{Buffer:r}=(Ue(),Pe(Ne)),{ERR_INVALID_ARG_TYPE:n,ERR_STREAM_NULL_VALUES:e}=qe().codes;function o(u,p,d){let b;if(typeof p=="string"||p instanceof r)return new u({objectMode:!0,...d,read(){this.push(p),this.push(null)}});let h;if(p&&p[l])h=!0,b=p[l]();else if(p&&p[t])h=!1,b=p[t]();else throw new n("iterable",["Iterable"],p);let y=new u({objectMode:!0,highWaterMark:1,...d}),m=!1;y._read=function(){m||(m=!0,g())},y._destroy=function(_,I){a(S(_),()=>s.nextTick(I,_),v=>s.nextTick(I,v||_))};async function S(_){let I=_!=null,v=typeof b.throw=="function";if(I&&v){let{value:A,done:E}=await b.throw(_);if(await A,E)return}if(typeof b.return=="function"){let{value:A}=await b.return();await A}}async function g(){for(;;){try{let{value:_,done:I}=h?await b.next():b.next();if(I)y.push(null);else{let v=_&&typeof _.then=="function"?await _:_;if(v===null)throw m=!1,new e;if(y.push(v))continue;m=!1}}catch(_){y.destroy(_)}break}}return y}i.exports=o}),xr=de((f,i)=>{le(),ce(),ue();var s=It(),{ArrayPrototypeIndexOf:a,NumberIsInteger:l,NumberIsNaN:t,NumberParseInt:r,ObjectDefineProperties:n,ObjectKeys:e,ObjectSetPrototypeOf:o,Promise:u,SafeSet:p,SymbolAsyncDispose:d,SymbolAsyncIterator:b,Symbol:h}=Me();i.exports=se,se.ReadableState=ve;var{EventEmitter:y}=(At(),Pe(yt)),{Stream:m,prependListener:S}=Di(),{Buffer:g}=(Ue(),Pe(Ne)),{addAbortSignal:_}=Tr(),I=mt(),v=$e().debuglog("stream",O=>{v=O}),A=gl(),E=Mt(),{getHighWaterMark:k,getDefaultHighWaterMark:C}=kr(),{aggregateTwoErrors:P,codes:{ERR_INVALID_ARG_TYPE:L,ERR_METHOD_NOT_IMPLEMENTED:x,ERR_OUT_OF_RANGE:q,ERR_STREAM_PUSH_AFTER_EOF:D,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:U},AbortError:ae}=qe(),{validateObject:Q}=Vt(),K=h("kPaused"),{StringDecoder:re}=ml(),F=Cs();o(se.prototype,m.prototype),o(se,m);var Z=()=>{},{errorOrDestroy:R}=E,J=1,me=2,te=4,we=8,V=16,N=32,ne=64,H=128,G=256,Y=512,ye=1024,oe=2048,M=4096,W=8192,ee=16384,fe=32768,pe=65536,be=1<<17,$=1<<18;function ge(O){return{enumerable:!1,get(){return(this.state&O)!==0},set(j){j?this.state|=O:this.state&=~O}}}n(ve.prototype,{objectMode:ge(J),ended:ge(me),endEmitted:ge(te),reading:ge(we),constructed:ge(V),sync:ge(N),needReadable:ge(ne),emittedReadable:ge(H),readableListening:ge(G),resumeScheduled:ge(Y),errorEmitted:ge(ye),emitClose:ge(oe),autoDestroy:ge(M),destroyed:ge(W),closed:ge(ee),closeEmitted:ge(fe),multiAwaitDrain:ge(pe),readingMore:ge(be),dataEmitted:ge($)});function ve(O,j,_e){typeof _e!="boolean"&&(_e=j instanceof st()),this.state=oe|M|V|N,O&&O.objectMode&&(this.state|=J),_e&&O&&O.readableObjectMode&&(this.state|=J),this.highWaterMark=O?k(this,O,"readableHighWaterMark",_e):C(!1),this.buffer=new A,this.length=0,this.pipes=[],this.flowing=null,this[K]=null,O&&O.emitClose===!1&&(this.state&=~oe),O&&O.autoDestroy===!1&&(this.state&=~M),this.errored=null,this.defaultEncoding=O&&O.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,O&&O.encoding&&(this.decoder=new re(O.encoding),this.encoding=O.encoding)}function se(O){if(!(this instanceof se))return new se(O);let j=this instanceof st();this._readableState=new ve(O,this,j),O&&(typeof O.read=="function"&&(this._read=O.read),typeof O.destroy=="function"&&(this._destroy=O.destroy),typeof O.construct=="function"&&(this._construct=O.construct),O.signal&&!j&&_(O.signal,this)),m.call(this,O),E.construct(this,()=>{this._readableState.needReadable&&z(this,this._readableState)})}se.prototype.destroy=E.destroy,se.prototype._undestroy=E.undestroy,se.prototype._destroy=function(O,j){j(O)},se.prototype[y.captureRejectionSymbol]=function(O){this.destroy(O)},se.prototype[d]=function(){let O;return this.destroyed||(O=this.readableEnded?null:new ae,this.destroy(O)),new u((j,_e)=>I(this,Ee=>Ee&&Ee!==O?_e(Ee):j(null)))},se.prototype.push=function(O,j){return xe(this,O,j,!1)},se.prototype.unshift=function(O,j){return xe(this,O,j,!0)};function xe(O,j,_e,Ee){v("readableAddChunk",j);let Ae=O._readableState,je;if((Ae.state&J)===0&&(typeof j=="string"?(_e=_e||Ae.defaultEncoding,Ae.encoding!==_e&&(Ee&&Ae.encoding?j=g.from(j,_e).toString(Ae.encoding):(j=g.from(j,_e),_e=""))):j instanceof g?_e="":m._isUint8Array(j)?(j=m._uint8ArrayToBuffer(j),_e=""):j!=null&&(je=new L("chunk",["string","Buffer","Uint8Array"],j))),je)R(O,je);else if(j===null)Ae.state&=~we,X(O,Ae);else if((Ae.state&J)!==0||j&&j.length>0)if(Ee)if((Ae.state&te)!==0)R(O,new U);else{if(Ae.destroyed||Ae.errored)return!1;c(O,Ae,j,!0)}else if(Ae.ended)R(O,new D);else{if(Ae.destroyed||Ae.errored)return!1;Ae.state&=~we,Ae.decoder&&!_e?(j=Ae.decoder.write(j),Ae.objectMode||j.length!==0?c(O,Ae,j,!1):z(O,Ae)):c(O,Ae,j,!1)}else Ee||(Ae.state&=~we,z(O,Ae));return!Ae.ended&&(Ae.length<Ae.highWaterMark||Ae.length===0)}function c(O,j,_e,Ee){j.flowing&&j.length===0&&!j.sync&&O.listenerCount("data")>0?((j.state&pe)!==0?j.awaitDrainWriters.clear():j.awaitDrainWriters=null,j.dataEmitted=!0,O.emit("data",_e)):(j.length+=j.objectMode?1:_e.length,Ee?j.buffer.unshift(_e):j.buffer.push(_e),(j.state&ne)!==0&&he(O)),z(O,j)}se.prototype.isPaused=function(){let O=this._readableState;return O[K]===!0||O.flowing===!1},se.prototype.setEncoding=function(O){let j=new re(O);this._readableState.decoder=j,this._readableState.encoding=this._readableState.decoder.encoding;let _e=this._readableState.buffer,Ee="";for(let Ae of _e)Ee+=j.write(Ae);return _e.clear(),Ee!==""&&_e.push(Ee),this._readableState.length=Ee.length,this};var w=1073741824;function T(O){if(O>w)throw new q("size","<= 1GiB",O);return O--,O|=O>>>1,O|=O>>>2,O|=O>>>4,O|=O>>>8,O|=O>>>16,O++,O}function B(O,j){return O<=0||j.length===0&&j.ended?0:(j.state&J)!==0?1:t(O)?j.flowing&&j.length?j.buffer.first().length:j.length:O<=j.length?O:j.ended?j.length:0}se.prototype.read=function(O){v("read",O),O===void 0?O=NaN:l(O)||(O=r(O,10));let j=this._readableState,_e=O;if(O>j.highWaterMark&&(j.highWaterMark=T(O)),O!==0&&(j.state&=~H),O===0&&j.needReadable&&((j.highWaterMark!==0?j.length>=j.highWaterMark:j.length>0)||j.ended))return v("read: emitReadable",j.length,j.ended),j.length===0&&j.ended?Ye(this):he(this),null;if(O=B(O,j),O===0&&j.ended)return j.length===0&&Ye(this),null;let Ee=(j.state&ne)!==0;if(v("need readable",Ee),(j.length===0||j.length-O<j.highWaterMark)&&(Ee=!0,v("length less than watermark",Ee)),j.ended||j.reading||j.destroyed||j.errored||!j.constructed)Ee=!1,v("reading, ended or constructing",Ee);else if(Ee){v("do read"),j.state|=we|N,j.length===0&&(j.state|=ne);try{this._read(j.highWaterMark)}catch(je){R(this,je)}j.state&=~N,j.reading||(O=B(_e,j))}let Ae;return O>0?Ae=kt(O,j):Ae=null,Ae===null?(j.needReadable=j.length<=j.highWaterMark,O=0):(j.length-=O,j.multiAwaitDrain?j.awaitDrainWriters.clear():j.awaitDrainWriters=null),j.length===0&&(j.ended||(j.needReadable=!0),_e!==O&&j.ended&&Ye(this)),Ae!==null&&!j.errorEmitted&&!j.closeEmitted&&(j.dataEmitted=!0,this.emit("data",Ae)),Ae};function X(O,j){if(v("onEofChunk"),!j.ended){if(j.decoder){let _e=j.decoder.end();_e&&_e.length&&(j.buffer.push(_e),j.length+=j.objectMode?1:_e.length)}j.ended=!0,j.sync?he(O):(j.needReadable=!1,j.emittedReadable=!0,Se(O))}}function he(O){let j=O._readableState;v("emitReadable",j.needReadable,j.emittedReadable),j.needReadable=!1,j.emittedReadable||(v("emitReadable",j.flowing),j.emittedReadable=!0,s.nextTick(Se,O))}function Se(O){let j=O._readableState;v("emitReadable_",j.destroyed,j.length,j.ended),!j.destroyed&&!j.errored&&(j.length||j.ended)&&(O.emit("readable"),j.emittedReadable=!1),j.needReadable=!j.flowing&&!j.ended&&j.length<=j.highWaterMark,Ge(O)}function z(O,j){!j.readingMore&&j.constructed&&(j.readingMore=!0,s.nextTick(ie,O,j))}function ie(O,j){for(;!j.reading&&!j.ended&&(j.length<j.highWaterMark||j.flowing&&j.length===0);){let _e=j.length;if(v("maybeReadMore read 0"),O.read(0),_e===j.length)break}j.readingMore=!1}se.prototype._read=function(O){throw new x("_read()")},se.prototype.pipe=function(O,j){let _e=this,Ee=this._readableState;Ee.pipes.length===1&&(Ee.multiAwaitDrain||(Ee.multiAwaitDrain=!0,Ee.awaitDrainWriters=new p(Ee.awaitDrainWriters?[Ee.awaitDrainWriters]:[]))),Ee.pipes.push(O),v("pipe count=%d opts=%j",Ee.pipes.length,j);let Ae=(!j||j.end!==!1)&&O!==s.stdout&&O!==s.stderr?We:vt;Ee.endEmitted?s.nextTick(Ae):_e.once("end",Ae),O.on("unpipe",je);function je(Xe,tt){v("onunpipe"),Xe===_e&&tt&&tt.hasUnpiped===!1&&(tt.hasUnpiped=!0,Lt())}function We(){v("onend"),O.end()}let Ke,Bt=!1;function Lt(){v("cleanup"),O.removeListener("close",Je),O.removeListener("finish",ht),Ke&&O.removeListener("drain",Ke),O.removeListener("error",bt),O.removeListener("unpipe",je),_e.removeListener("end",We),_e.removeListener("end",vt),_e.removeListener("data",Yt),Bt=!0,Ke&&Ee.awaitDrainWriters&&(!O._writableState||O._writableState.needDrain)&&Ke()}function Dt(){Bt||(Ee.pipes.length===1&&Ee.pipes[0]===O?(v("false write response, pause",0),Ee.awaitDrainWriters=O,Ee.multiAwaitDrain=!1):Ee.pipes.length>1&&Ee.pipes.includes(O)&&(v("false write response, pause",Ee.awaitDrainWriters.size),Ee.awaitDrainWriters.add(O)),_e.pause()),Ke||(Ke=Ie(_e,O),O.on("drain",Ke))}_e.on("data",Yt);function Yt(Xe){v("ondata");let tt=O.write(Xe);v("dest.write",tt),tt===!1&&Dt()}function bt(Xe){if(v("onerror",Xe),vt(),O.removeListener("error",bt),O.listenerCount("error")===0){let tt=O._writableState||O._readableState;tt&&!tt.errorEmitted?R(O,Xe):O.emit("error",Xe)}}S(O,"error",bt);function Je(){O.removeListener("finish",ht),vt()}O.once("close",Je);function ht(){v("onfinish"),O.removeListener("close",Je),vt()}O.once("finish",ht);function vt(){v("unpipe"),_e.unpipe(O)}return O.emit("pipe",_e),O.writableNeedDrain===!0?Dt():Ee.flowing||(v("pipe resume"),_e.resume()),O};function Ie(O,j){return function(){let _e=O._readableState;_e.awaitDrainWriters===j?(v("pipeOnDrain",1),_e.awaitDrainWriters=null):_e.multiAwaitDrain&&(v("pipeOnDrain",_e.awaitDrainWriters.size),_e.awaitDrainWriters.delete(j)),(!_e.awaitDrainWriters||_e.awaitDrainWriters.size===0)&&O.listenerCount("data")&&O.resume()}}se.prototype.unpipe=function(O){let j=this._readableState,_e={hasUnpiped:!1};if(j.pipes.length===0)return this;if(!O){let Ae=j.pipes;j.pipes=[],this.pause();for(let je=0;je<Ae.length;je++)Ae[je].emit("unpipe",this,{hasUnpiped:!1});return this}let Ee=a(j.pipes,O);return Ee===-1?this:(j.pipes.splice(Ee,1),j.pipes.length===0&&this.pause(),O.emit("unpipe",this,_e),this)},se.prototype.on=function(O,j){let _e=m.prototype.on.call(this,O,j),Ee=this._readableState;return O==="data"?(Ee.readableListening=this.listenerCount("readable")>0,Ee.flowing!==!1&&this.resume()):O==="readable"&&!Ee.endEmitted&&!Ee.readableListening&&(Ee.readableListening=Ee.needReadable=!0,Ee.flowing=!1,Ee.emittedReadable=!1,v("on readable",Ee.length,Ee.reading),Ee.length?he(this):Ee.reading||s.nextTick(ke,this)),_e},se.prototype.addListener=se.prototype.on,se.prototype.removeListener=function(O,j){let _e=m.prototype.removeListener.call(this,O,j);return O==="readable"&&s.nextTick(Te,this),_e},se.prototype.off=se.prototype.removeListener,se.prototype.removeAllListeners=function(O){let j=m.prototype.removeAllListeners.apply(this,arguments);return(O==="readable"||O===void 0)&&s.nextTick(Te,this),j};function Te(O){let j=O._readableState;j.readableListening=O.listenerCount("readable")>0,j.resumeScheduled&&j[K]===!1?j.flowing=!0:O.listenerCount("data")>0?O.resume():j.readableListening||(j.flowing=null)}function ke(O){v("readable nexttick read 0"),O.read(0)}se.prototype.resume=function(){let O=this._readableState;return O.flowing||(v("resume"),O.flowing=!O.readableListening,Oe(this,O)),O[K]=!1,this};function Oe(O,j){j.resumeScheduled||(j.resumeScheduled=!0,s.nextTick(Ve,O,j))}function Ve(O,j){v("resume",j.reading),j.reading||O.read(0),j.resumeScheduled=!1,O.emit("resume"),Ge(O),j.flowing&&!j.reading&&O.read(0)}se.prototype.pause=function(){return v("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(v("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[K]=!0,this};function Ge(O){let j=O._readableState;for(v("flow",j.flowing);j.flowing&&O.read()!==null;);}se.prototype.wrap=function(O){let j=!1;O.on("data",Ee=>{!this.push(Ee)&&O.pause&&(j=!0,O.pause())}),O.on("end",()=>{this.push(null)}),O.on("error",Ee=>{R(this,Ee)}),O.on("close",()=>{this.destroy()}),O.on("destroy",()=>{this.destroy()}),this._read=()=>{j&&O.resume&&(j=!1,O.resume())};let _e=e(O);for(let Ee=1;Ee<_e.length;Ee++){let Ae=_e[Ee];this[Ae]===void 0&&typeof O[Ae]=="function"&&(this[Ae]=O[Ae].bind(O))}return this},se.prototype[b]=function(){return Be(this)},se.prototype.iterator=function(O){return O!==void 0&&Q(O,"options"),Be(this,O)};function Be(O,j){typeof O.read!="function"&&(O=se.wrap(O,{objectMode:!0}));let _e=Qe(O,j);return _e.stream=O,_e}async function*Qe(O,j){let _e=Z;function Ee(We){this===O?(_e(),_e=Z):_e=We}O.on("readable",Ee);let Ae,je=I(O,{writable:!1},We=>{Ae=We?P(Ae,We):null,_e(),_e=Z});try{for(;;){let We=O.destroyed?null:O.read();if(We!==null)yield We;else{if(Ae)throw Ae;if(Ae===null)return;await new u(Ee)}}}catch(We){throw Ae=P(Ae,We),Ae}finally{(Ae||j?.destroyOnReturn!==!1)&&(Ae===void 0||O._readableState.autoDestroy)?E.destroyer(O,null):(O.off("readable",Ee),je())}}n(se.prototype,{readable:{__proto__:null,get(){let O=this._readableState;return!!O&&O.readable!==!1&&!O.destroyed&&!O.errorEmitted&&!O.endEmitted},set(O){this._readableState&&(this._readableState.readable=!!O)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(O){this._readableState&&(this._readableState.flowing=O)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(O){this._readableState&&(this._readableState.destroyed=O)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),n(ve.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[K]!==!1},set(O){this[K]=!!O}}}),se._fromList=kt;function kt(O,j){if(j.length===0)return null;let _e;return j.objectMode?_e=j.buffer.shift():!O||O>=j.length?(j.decoder?_e=j.buffer.join(""):j.buffer.length===1?_e=j.buffer.first():_e=j.buffer.concat(j.length),j.buffer.clear()):_e=j.buffer.consume(O,j.decoder),_e}function Ye(O){let j=O._readableState;v("endReadable",j.endEmitted),j.endEmitted||(j.ended=!0,s.nextTick(ze,j,O))}function ze(O,j){if(v("endReadableNT",O.endEmitted,O.length),!O.errored&&!O.closeEmitted&&!O.endEmitted&&O.length===0){if(O.endEmitted=!0,j.emit("end"),j.writable&&j.allowHalfOpen===!1)s.nextTick(Qt,j);else if(O.autoDestroy){let _e=j._writableState;(!_e||_e.autoDestroy&&(_e.finished||_e.writable===!1))&&j.destroy()}}}function Qt(O){O.writable&&!O.writableEnded&&!O.destroyed&&O.end()}se.from=function(O,j){return F(se,O,j)};var xt;function Ut(){return xt===void 0&&(xt={}),xt}se.fromWeb=function(O,j){return Ut().newStreamReadableFromReadableStream(O,j)},se.toWeb=function(O,j){return Ut().newReadableStreamFromStreamReadable(O,j)},se.wrap=function(O,j){var _e,Ee;return new se({objectMode:(_e=(Ee=O.readableObjectMode)!==null&&Ee!==void 0?Ee:O.objectMode)!==null&&_e!==void 0?_e:!0,...j,destroy(Ae,je){E.destroyer(O,Ae),je(Ae)}}).wrap(O)}}),Fi=de((f,i)=>{le(),ce(),ue();var s=It(),{ArrayPrototypeSlice:a,Error:l,FunctionPrototypeSymbolHasInstance:t,ObjectDefineProperty:r,ObjectDefineProperties:n,ObjectSetPrototypeOf:e,StringPrototypeToLowerCase:o,Symbol:u,SymbolHasInstance:p}=Me();i.exports=Q,Q.WritableState=U;var{EventEmitter:d}=(At(),Pe(yt)),b=Di().Stream,{Buffer:h}=(Ue(),Pe(Ne)),y=Mt(),{addAbortSignal:m}=Tr(),{getHighWaterMark:S,getDefaultHighWaterMark:g}=kr(),{ERR_INVALID_ARG_TYPE:_,ERR_METHOD_NOT_IMPLEMENTED:I,ERR_MULTIPLE_CALLBACK:v,ERR_STREAM_CANNOT_PIPE:A,ERR_STREAM_DESTROYED:E,ERR_STREAM_ALREADY_FINISHED:k,ERR_STREAM_NULL_VALUES:C,ERR_STREAM_WRITE_AFTER_END:P,ERR_UNKNOWN_ENCODING:L}=qe().codes,{errorOrDestroy:x}=y;e(Q.prototype,b.prototype),e(Q,b);function q(){}var D=u("kOnFinished");function U(M,W,ee){typeof ee!="boolean"&&(ee=W instanceof st()),this.objectMode=!!(M&&M.objectMode),ee&&(this.objectMode=this.objectMode||!!(M&&M.writableObjectMode)),this.highWaterMark=M?S(this,M,"writableHighWaterMark",ee):g(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let fe=!!(M&&M.decodeStrings===!1);this.decodeStrings=!fe,this.defaultEncoding=M&&M.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=R.bind(void 0,W),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,ae(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!M||M.emitClose!==!1,this.autoDestroy=!M||M.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[D]=[]}function ae(M){M.buffered=[],M.bufferedIndex=0,M.allBuffers=!0,M.allNoop=!0}U.prototype.getBuffer=function(){return a(this.buffered,this.bufferedIndex)},r(U.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function Q(M){let W=this instanceof st();if(!W&&!t(Q,this))return new Q(M);this._writableState=new U(M,this,W),M&&(typeof M.write=="function"&&(this._write=M.write),typeof M.writev=="function"&&(this._writev=M.writev),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.final=="function"&&(this._final=M.final),typeof M.construct=="function"&&(this._construct=M.construct),M.signal&&m(M.signal,this)),b.call(this,M),y.construct(this,()=>{let ee=this._writableState;ee.writing||we(this,ee),H(this,ee)})}r(Q,p,{__proto__:null,value:function(M){return t(this,M)?!0:this!==Q?!1:M&&M._writableState instanceof U}}),Q.prototype.pipe=function(){x(this,new A)};function K(M,W,ee,fe){let pe=M._writableState;if(typeof ee=="function")fe=ee,ee=pe.defaultEncoding;else{if(!ee)ee=pe.defaultEncoding;else if(ee!=="buffer"&&!h.isEncoding(ee))throw new L(ee);typeof fe!="function"&&(fe=q)}if(W===null)throw new C;if(!pe.objectMode)if(typeof W=="string")pe.decodeStrings!==!1&&(W=h.from(W,ee),ee="buffer");else if(W instanceof h)ee="buffer";else if(b._isUint8Array(W))W=b._uint8ArrayToBuffer(W),ee="buffer";else throw new _("chunk",["string","Buffer","Uint8Array"],W);let be;return pe.ending?be=new P:pe.destroyed&&(be=new E("write")),be?(s.nextTick(fe,be),x(M,be,!0),be):(pe.pendingcb++,re(M,pe,W,ee,fe))}Q.prototype.write=function(M,W,ee){return K(this,M,W,ee)===!0},Q.prototype.cork=function(){this._writableState.corked++},Q.prototype.uncork=function(){let M=this._writableState;M.corked&&(M.corked--,M.writing||we(this,M))},Q.prototype.setDefaultEncoding=function(M){if(typeof M=="string"&&(M=o(M)),!h.isEncoding(M))throw new L(M);return this._writableState.defaultEncoding=M,this};function re(M,W,ee,fe,pe){let be=W.objectMode?1:ee.length;W.length+=be;let $=W.length<W.highWaterMark;return $||(W.needDrain=!0),W.writing||W.corked||W.errored||!W.constructed?(W.buffered.push({chunk:ee,encoding:fe,callback:pe}),W.allBuffers&&fe!=="buffer"&&(W.allBuffers=!1),W.allNoop&&pe!==q&&(W.allNoop=!1)):(W.writelen=be,W.writecb=pe,W.writing=!0,W.sync=!0,M._write(ee,fe,W.onwrite),W.sync=!1),$&&!W.errored&&!W.destroyed}function F(M,W,ee,fe,pe,be,$){W.writelen=fe,W.writecb=$,W.writing=!0,W.sync=!0,W.destroyed?W.onwrite(new E("write")):ee?M._writev(pe,W.onwrite):M._write(pe,be,W.onwrite),W.sync=!1}function Z(M,W,ee,fe){--W.pendingcb,fe(ee),te(W),x(M,ee)}function R(M,W){let ee=M._writableState,fe=ee.sync,pe=ee.writecb;if(typeof pe!="function"){x(M,new v);return}ee.writing=!1,ee.writecb=null,ee.length-=ee.writelen,ee.writelen=0,W?(W.stack,ee.errored||(ee.errored=W),M._readableState&&!M._readableState.errored&&(M._readableState.errored=W),fe?s.nextTick(Z,M,ee,W,pe):Z(M,ee,W,pe)):(ee.buffered.length>ee.bufferedIndex&&we(M,ee),fe?ee.afterWriteTickInfo!==null&&ee.afterWriteTickInfo.cb===pe?ee.afterWriteTickInfo.count++:(ee.afterWriteTickInfo={count:1,cb:pe,stream:M,state:ee},s.nextTick(J,ee.afterWriteTickInfo)):me(M,ee,1,pe))}function J({stream:M,state:W,count:ee,cb:fe}){return W.afterWriteTickInfo=null,me(M,W,ee,fe)}function me(M,W,ee,fe){for(!W.ending&&!M.destroyed&&W.length===0&&W.needDrain&&(W.needDrain=!1,M.emit("drain"));ee-- >0;)W.pendingcb--,fe();W.destroyed&&te(W),H(M,W)}function te(M){if(M.writing)return;for(let pe=M.bufferedIndex;pe<M.buffered.length;++pe){var W;let{chunk:be,callback:$}=M.buffered[pe],ge=M.objectMode?1:be.length;M.length-=ge,$((W=M.errored)!==null&&W!==void 0?W:new E("write"))}let ee=M[D].splice(0);for(let pe=0;pe<ee.length;pe++){var fe;ee[pe]((fe=M.errored)!==null&&fe!==void 0?fe:new E("end"))}ae(M)}function we(M,W){if(W.corked||W.bufferProcessing||W.destroyed||!W.constructed)return;let{buffered:ee,bufferedIndex:fe,objectMode:pe}=W,be=ee.length-fe;if(!be)return;let $=fe;if(W.bufferProcessing=!0,be>1&&M._writev){W.pendingcb-=be-1;let ge=W.allNoop?q:se=>{for(let xe=$;xe<ee.length;++xe)ee[xe].callback(se)},ve=W.allNoop&&$===0?ee:a(ee,$);ve.allBuffers=W.allBuffers,F(M,W,!0,W.length,ve,"",ge),ae(W)}else{do{let{chunk:ge,encoding:ve,callback:se}=ee[$];ee[$++]=null;let xe=pe?1:ge.length;F(M,W,!1,xe,ge,ve,se)}while($<ee.length&&!W.writing);$===ee.length?ae(W):$>256?(ee.splice(0,$),W.bufferedIndex=0):W.bufferedIndex=$}W.bufferProcessing=!1}Q.prototype._write=function(M,W,ee){if(this._writev)this._writev([{chunk:M,encoding:W}],ee);else throw new I("_write()")},Q.prototype._writev=null,Q.prototype.end=function(M,W,ee){let fe=this._writableState;typeof M=="function"?(ee=M,M=null,W=null):typeof W=="function"&&(ee=W,W=null);let pe;if(M!=null){let be=K(this,M,W);be instanceof l&&(pe=be)}return fe.corked&&(fe.corked=1,this.uncork()),pe||(!fe.errored&&!fe.ending?(fe.ending=!0,H(this,fe,!0),fe.ended=!0):fe.finished?pe=new k("end"):fe.destroyed&&(pe=new E("end"))),typeof ee=="function"&&(pe||fe.finished?s.nextTick(ee,pe):fe[D].push(ee)),this};function V(M){return M.ending&&!M.destroyed&&M.constructed&&M.length===0&&!M.errored&&M.buffered.length===0&&!M.finished&&!M.writing&&!M.errorEmitted&&!M.closeEmitted}function N(M,W){let ee=!1;function fe(pe){if(ee){x(M,pe??v());return}if(ee=!0,W.pendingcb--,pe){let be=W[D].splice(0);for(let $=0;$<be.length;$++)be[$](pe);x(M,pe,W.sync)}else V(W)&&(W.prefinished=!0,M.emit("prefinish"),W.pendingcb++,s.nextTick(G,M,W))}W.sync=!0,W.pendingcb++;try{M._final(fe)}catch(pe){fe(pe)}W.sync=!1}function ne(M,W){!W.prefinished&&!W.finalCalled&&(typeof M._final=="function"&&!W.destroyed?(W.finalCalled=!0,N(M,W)):(W.prefinished=!0,M.emit("prefinish")))}function H(M,W,ee){V(W)&&(ne(M,W),W.pendingcb===0&&(ee?(W.pendingcb++,s.nextTick((fe,pe)=>{V(pe)?G(fe,pe):pe.pendingcb--},M,W)):V(W)&&(W.pendingcb++,G(M,W))))}function G(M,W){W.pendingcb--,W.finished=!0;let ee=W[D].splice(0);for(let fe=0;fe<ee.length;fe++)ee[fe]();if(M.emit("finish"),W.autoDestroy){let fe=M._readableState;(!fe||fe.autoDestroy&&(fe.endEmitted||fe.readable===!1))&&M.destroy()}}n(Q.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(M){this._writableState&&(this._writableState.destroyed=M)}},writable:{__proto__:null,get(){let M=this._writableState;return!!M&&M.writable!==!1&&!M.destroyed&&!M.errored&&!M.ending&&!M.ended},set(M){this._writableState&&(this._writableState.writable=!!M)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let M=this._writableState;return M?!M.destroyed&&!M.ending&&M.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var Y=y.destroy;Q.prototype.destroy=function(M,W){let ee=this._writableState;return!ee.destroyed&&(ee.bufferedIndex<ee.buffered.length||ee[D].length)&&s.nextTick(te,ee),Y.call(this,M,W),this},Q.prototype._undestroy=y.undestroy,Q.prototype._destroy=function(M,W){W(M)},Q.prototype[d.captureRejectionSymbol]=function(M){this.destroy(M)};var ye;function oe(){return ye===void 0&&(ye={}),ye}Q.fromWeb=function(M,W){return oe().newStreamWritableFromWritableStream(M,W)},Q.toWeb=function(M){return oe().newWritableStreamFromStreamWritable(M)}}),bl=de((f,i)=>{le(),ce(),ue();var s=It(),a=(Ue(),Pe(Ne)),{isReadable:l,isWritable:t,isIterable:r,isNodeStream:n,isReadableNodeStream:e,isWritableNodeStream:o,isDuplexNodeStream:u,isReadableStream:p,isWritableStream:d}=lt(),b=mt(),{AbortError:h,codes:{ERR_INVALID_ARG_TYPE:y,ERR_INVALID_RETURN_VALUE:m}}=qe(),{destroyer:S}=Mt(),g=st(),_=xr(),I=Fi(),{createDeferredPromise:v}=$e(),A=Cs(),E=globalThis.Blob||a.Blob,k=typeof E<"u"?function(D){return D instanceof E}:function(D){return!1},C=globalThis.AbortController||Kt().AbortController,{FunctionPrototypeCall:P}=Me(),L=class extends g{constructor(D){super(D),D?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),D?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};i.exports=function D(U,ae){if(u(U))return U;if(e(U))return q({readable:U});if(o(U))return q({writable:U});if(n(U))return q({writable:!1,readable:!1});if(p(U))return q({readable:_.fromWeb(U)});if(d(U))return q({writable:I.fromWeb(U)});if(typeof U=="function"){let{value:K,write:re,final:F,destroy:Z}=x(U);if(r(K))return A(L,K,{objectMode:!0,write:re,final:F,destroy:Z});let R=K?.then;if(typeof R=="function"){let J,me=P(R,K,te=>{if(te!=null)throw new m("nully","body",te)},te=>{S(J,te)});return J=new L({objectMode:!0,readable:!1,write:re,final(te){F(async()=>{try{await me,s.nextTick(te,null)}catch(we){s.nextTick(te,we)}})},destroy:Z})}throw new m("Iterable, AsyncIterable or AsyncFunction",ae,K)}if(k(U))return D(U.arrayBuffer());if(r(U))return A(L,U,{objectMode:!0,writable:!1});if(p(U?.readable)&&d(U?.writable))return L.fromWeb(U);if(typeof U?.writable=="object"||typeof U?.readable=="object"){let K=U!=null&&U.readable?e(U?.readable)?U?.readable:D(U.readable):void 0,re=U!=null&&U.writable?o(U?.writable)?U?.writable:D(U.writable):void 0;return q({readable:K,writable:re})}let Q=U?.then;if(typeof Q=="function"){let K;return P(Q,U,re=>{re!=null&&K.push(re),K.push(null)},re=>{S(K,re)}),K=new L({objectMode:!0,writable:!1,read(){}})}throw new y(ae,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],U)};function x(D){let{promise:U,resolve:ae}=v(),Q=new C,K=Q.signal;return{value:D((async function*(){for(;;){let re=U;U=null;let{chunk:F,done:Z,cb:R}=await re;if(s.nextTick(R),Z)return;if(K.aborted)throw new h(void 0,{cause:K.reason});({promise:U,resolve:ae}=v()),yield F}})(),{signal:K}),write(re,F,Z){let R=ae;ae=null,R({chunk:re,done:!1,cb:Z})},final(re){let F=ae;ae=null,F({done:!0,cb:re})},destroy(re,F){Q.abort(),F(re)}}}function q(D){let U=D.readable&&typeof D.readable.read!="function"?_.wrap(D.readable):D.readable,ae=D.writable,Q=!!l(U),K=!!t(ae),re,F,Z,R,J;function me(te){let we=R;R=null,we?we(te):te&&J.destroy(te)}return J=new L({readableObjectMode:!!(U!=null&&U.readableObjectMode),writableObjectMode:!!(ae!=null&&ae.writableObjectMode),readable:Q,writable:K}),K&&(b(ae,te=>{K=!1,te&&S(U,te),me(te)}),J._write=function(te,we,V){ae.write(te,we)?V():re=V},J._final=function(te){ae.end(),F=te},ae.on("drain",function(){if(re){let te=re;re=null,te()}}),ae.on("finish",function(){if(F){let te=F;F=null,te()}})),Q&&(b(U,te=>{Q=!1,te&&S(U,te),me(te)}),U.on("readable",function(){if(Z){let te=Z;Z=null,te()}}),U.on("end",function(){J.push(null)}),J._read=function(){for(;;){let te=U.read();if(te===null){Z=J._read;return}if(!J.push(te))return}}),J._destroy=function(te,we){!te&&R!==null&&(te=new h),Z=null,re=null,F=null,R===null?we(te):(R=we,S(ae,te),S(U,te))},J}}),st=de((f,i)=>{le(),ce(),ue();var{ObjectDefineProperties:s,ObjectGetOwnPropertyDescriptor:a,ObjectKeys:l,ObjectSetPrototypeOf:t}=Me();i.exports=e;var r=xr(),n=Fi();t(e.prototype,r.prototype),t(e,r);{let d=l(n.prototype);for(let b=0;b<d.length;b++){let h=d[b];e.prototype[h]||(e.prototype[h]=n.prototype[h])}}function e(d){if(!(this instanceof e))return new e(d);r.call(this,d),n.call(this,d),d?(this.allowHalfOpen=d.allowHalfOpen!==!1,d.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),d.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}s(e.prototype,{writable:{__proto__:null,...a(n.prototype,"writable")},writableHighWaterMark:{__proto__:null,...a(n.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...a(n.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...a(n.prototype,"writableBuffer")},writableLength:{__proto__:null,...a(n.prototype,"writableLength")},writableFinished:{__proto__:null,...a(n.prototype,"writableFinished")},writableCorked:{__proto__:null,...a(n.prototype,"writableCorked")},writableEnded:{__proto__:null,...a(n.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...a(n.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(d){this._readableState&&this._writableState&&(this._readableState.destroyed=d,this._writableState.destroyed=d)}}});var o;function u(){return o===void 0&&(o={}),o}e.fromWeb=function(d,b){return u().newStreamDuplexFromReadableWritablePair(d,b)},e.toWeb=function(d){return u().newReadableWritablePairFromDuplex(d)};var p;e.from=function(d){return p||(p=bl()),p(d,"body")}}),Ms=de((f,i)=>{le(),ce(),ue();var{ObjectSetPrototypeOf:s,Symbol:a}=Me();i.exports=e;var{ERR_METHOD_NOT_IMPLEMENTED:l}=qe().codes,t=st(),{getHighWaterMark:r}=kr();s(e.prototype,t.prototype),s(e,t);var n=a("kCallback");function e(p){if(!(this instanceof e))return new e(p);let d=p?r(this,p,"readableHighWaterMark",!0):null;d===0&&(p={...p,highWaterMark:null,readableHighWaterMark:d,writableHighWaterMark:p.writableHighWaterMark||0}),t.call(this,p),this._readableState.sync=!1,this[n]=null,p&&(typeof p.transform=="function"&&(this._transform=p.transform),typeof p.flush=="function"&&(this._flush=p.flush)),this.on("prefinish",u)}function o(p){typeof this._flush=="function"&&!this.destroyed?this._flush((d,b)=>{if(d){p?p(d):this.destroy(d);return}b!=null&&this.push(b),this.push(null),p&&p()}):(this.push(null),p&&p())}function u(){this._final!==o&&o.call(this)}e.prototype._final=o,e.prototype._transform=function(p,d,b){throw new l("_transform()")},e.prototype._write=function(p,d,b){let h=this._readableState,y=this._writableState,m=h.length;this._transform(p,d,(S,g)=>{if(S){b(S);return}g!=null&&this.push(g),y.ended||m===h.length||h.length<h.highWaterMark?b():this[n]=b})},e.prototype._read=function(){if(this[n]){let p=this[n];this[n]=null,p()}}}),js=de((f,i)=>{le(),ce(),ue();var{ObjectSetPrototypeOf:s}=Me();i.exports=l;var a=Ms();s(l.prototype,a.prototype),s(l,a);function l(t){if(!(this instanceof l))return new l(t);a.call(this,t)}l.prototype._transform=function(t,r,n){n(null,t)}}),Wi=de((f,i)=>{le(),ce(),ue();var s=It(),{ArrayIsArray:a,Promise:l,SymbolAsyncIterator:t,SymbolDispose:r}=Me(),n=mt(),{once:e}=$e(),o=Mt(),u=st(),{aggregateTwoErrors:p,codes:{ERR_INVALID_ARG_TYPE:d,ERR_INVALID_RETURN_VALUE:b,ERR_MISSING_ARGS:h,ERR_STREAM_DESTROYED:y,ERR_STREAM_PREMATURE_CLOSE:m},AbortError:S}=qe(),{validateFunction:g,validateAbortSignal:_}=Vt(),{isIterable:I,isReadable:v,isReadableNodeStream:A,isNodeStream:E,isTransformStream:k,isWebStream:C,isReadableStream:P,isReadableFinished:L}=lt(),x=globalThis.AbortController||Kt().AbortController,q,D,U;function ae(te,we,V){let N=!1;te.on("close",()=>{N=!0});let ne=n(te,{readable:we,writable:V},H=>{N=!H});return{destroy:H=>{N||(N=!0,o.destroyer(te,H||new y("pipe")))},cleanup:ne}}function Q(te){return g(te[te.length-1],"streams[stream.length - 1]"),te.pop()}function K(te){if(I(te))return te;if(A(te))return re(te);throw new d("val",["Readable","Iterable","AsyncIterable"],te)}async function*re(te){D||(D=xr()),yield*D.prototype[t].call(te)}async function F(te,we,V,{end:N}){let ne,H=null,G=oe=>{if(oe&&(ne=oe),H){let M=H;H=null,M()}},Y=()=>new l((oe,M)=>{ne?M(ne):H=()=>{ne?M(ne):oe()}});we.on("drain",G);let ye=n(we,{readable:!1},G);try{we.writableNeedDrain&&await Y();for await(let oe of te)we.write(oe)||await Y();N&&(we.end(),await Y()),V()}catch(oe){V(ne!==oe?p(ne,oe):oe)}finally{ye(),we.off("drain",G)}}async function Z(te,we,V,{end:N}){k(we)&&(we=we.writable);let ne=we.getWriter();try{for await(let H of te)await ne.ready,ne.write(H).catch(()=>{});await ne.ready,N&&await ne.close(),V()}catch(H){try{await ne.abort(H),V(H)}catch(G){V(G)}}}function R(...te){return J(te,e(Q(te)))}function J(te,we,V){if(te.length===1&&a(te[0])&&(te=te[0]),te.length<2)throw new h("streams");let N=new x,ne=N.signal,H=V?.signal,G=[];_(H,"options.signal");function Y(){pe(new S)}U=U||$e().addAbortListener;let ye;H&&(ye=U(H,Y));let oe,M,W=[],ee=0;function fe(ve){pe(ve,--ee===0)}function pe(ve,se){var xe;if(ve&&(!oe||oe.code==="ERR_STREAM_PREMATURE_CLOSE")&&(oe=ve),!(!oe&&!se)){for(;W.length;)W.shift()(oe);(xe=ye)===null||xe===void 0||xe[r](),N.abort(),se&&(oe||G.forEach(c=>c()),s.nextTick(we,oe,M))}}let be;for(let ve=0;ve<te.length;ve++){let se=te[ve],xe=ve<te.length-1,c=ve>0,w=xe||V?.end!==!1,T=ve===te.length-1;if(E(se)){let B=function(X){X&&X.name!=="AbortError"&&X.code!=="ERR_STREAM_PREMATURE_CLOSE"&&fe(X)};if(w){let{destroy:X,cleanup:he}=ae(se,xe,c);W.push(X),v(se)&&T&&G.push(he)}se.on("error",B),v(se)&&T&&G.push(()=>{se.removeListener("error",B)})}if(ve===0)if(typeof se=="function"){if(be=se({signal:ne}),!I(be))throw new b("Iterable, AsyncIterable or Stream","source",be)}else I(se)||A(se)||k(se)?be=se:be=u.from(se);else if(typeof se=="function"){if(k(be)){var $;be=K(($=be)===null||$===void 0?void 0:$.readable)}else be=K(be);if(be=se(be,{signal:ne}),xe){if(!I(be,!0))throw new b("AsyncIterable",`transform[${ve-1}]`,be)}else{var ge;q||(q=js());let B=new q({objectMode:!0}),X=(ge=be)===null||ge===void 0?void 0:ge.then;if(typeof X=="function")ee++,X.call(be,z=>{M=z,z!=null&&B.write(z),w&&B.end(),s.nextTick(fe)},z=>{B.destroy(z),s.nextTick(fe,z)});else if(I(be,!0))ee++,F(be,B,fe,{end:w});else if(P(be)||k(be)){let z=be.readable||be;ee++,F(z,B,fe,{end:w})}else throw new b("AsyncIterable or Promise","destination",be);be=B;let{destroy:he,cleanup:Se}=ae(be,!1,!0);W.push(he),T&&G.push(Se)}}else if(E(se)){if(A(be)){ee+=2;let B=me(be,se,fe,{end:w});v(se)&&T&&G.push(B)}else if(k(be)||P(be)){let B=be.readable||be;ee++,F(B,se,fe,{end:w})}else if(I(be))ee++,F(be,se,fe,{end:w});else throw new d("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],be);be=se}else if(C(se)){if(A(be))ee++,Z(K(be),se,fe,{end:w});else if(P(be)||I(be))ee++,Z(be,se,fe,{end:w});else if(k(be))ee++,Z(be.readable,se,fe,{end:w});else throw new d("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],be);be=se}else be=u.from(se)}return(ne!=null&&ne.aborted||H!=null&&H.aborted)&&s.nextTick(Y),be}function me(te,we,V,{end:N}){let ne=!1;if(we.on("close",()=>{ne||V(new m)}),te.pipe(we,{end:!1}),N){let H=function(){ne=!0,we.end()};L(te)?s.nextTick(H):te.once("end",H)}else V();return n(te,{readable:!0,writable:!1},H=>{let G=te._readableState;H&&H.code==="ERR_STREAM_PREMATURE_CLOSE"&&G&&G.ended&&!G.errored&&!G.errorEmitted?te.once("end",V).once("error",V):V(H)}),n(we,{readable:!1,writable:!0},V)}i.exports={pipelineImpl:J,pipeline:R}}),Ns=de((f,i)=>{le(),ce(),ue();var{pipeline:s}=Wi(),a=st(),{destroyer:l}=Mt(),{isNodeStream:t,isReadable:r,isWritable:n,isWebStream:e,isTransformStream:o,isWritableStream:u,isReadableStream:p}=lt(),{AbortError:d,codes:{ERR_INVALID_ARG_VALUE:b,ERR_MISSING_ARGS:h}}=qe(),y=mt();i.exports=function(...m){if(m.length===0)throw new h("streams");if(m.length===1)return a.from(m[0]);let S=[...m];if(typeof m[0]=="function"&&(m[0]=a.from(m[0])),typeof m[m.length-1]=="function"){let x=m.length-1;m[x]=a.from(m[x])}for(let x=0;x<m.length;++x)if(!(!t(m[x])&&!e(m[x]))){if(x<m.length-1&&!(r(m[x])||p(m[x])||o(m[x])))throw new b(`streams[${x}]`,S[x],"must be readable");if(x>0&&!(n(m[x])||u(m[x])||o(m[x])))throw new b(`streams[${x}]`,S[x],"must be writable")}let g,_,I,v,A;function E(x){let q=v;v=null,q?q(x):x?A.destroy(x):!L&&!P&&A.destroy()}let k=m[0],C=s(m,E),P=!!(n(k)||u(k)||o(k)),L=!!(r(C)||p(C)||o(C));if(A=new a({writableObjectMode:!!(k!=null&&k.writableObjectMode),readableObjectMode:!!(C!=null&&C.readableObjectMode),writable:P,readable:L}),P){if(t(k))A._write=function(q,D,U){k.write(q,D)?U():g=U},A._final=function(q){k.end(),_=q},k.on("drain",function(){if(g){let q=g;g=null,q()}});else if(e(k)){let q=(o(k)?k.writable:k).getWriter();A._write=async function(D,U,ae){try{await q.ready,q.write(D).catch(()=>{}),ae()}catch(Q){ae(Q)}},A._final=async function(D){try{await q.ready,q.close().catch(()=>{}),_=D}catch(U){D(U)}}}let x=o(C)?C.readable:C;y(x,()=>{if(_){let q=_;_=null,q()}})}if(L){if(t(C))C.on("readable",function(){if(I){let x=I;I=null,x()}}),C.on("end",function(){A.push(null)}),A._read=function(){for(;;){let x=C.read();if(x===null){I=A._read;return}if(!A.push(x))return}};else if(e(C)){let x=(o(C)?C.readable:C).getReader();A._read=async function(){for(;;)try{let{value:q,done:D}=await x.read();if(!A.push(q))return;if(D){A.push(null);return}}catch{return}}}}return A._destroy=function(x,q){!x&&v!==null&&(x=new d),I=null,g=null,_=null,v===null?q(x):(v=q,t(C)&&l(C,x))},A}}),vl=de((f,i)=>{le(),ce(),ue();var s=globalThis.AbortController||Kt().AbortController,{codes:{ERR_INVALID_ARG_VALUE:a,ERR_INVALID_ARG_TYPE:l,ERR_MISSING_ARGS:t,ERR_OUT_OF_RANGE:r},AbortError:n}=qe(),{validateAbortSignal:e,validateInteger:o,validateObject:u}=Vt(),p=Me().Symbol("kWeak"),d=Me().Symbol("kResistStopPropagation"),{finished:b}=mt(),h=Ns(),{addAbortSignalNoValidate:y}=Tr(),{isWritable:m,isNodeStream:S}=lt(),{deprecate:g}=$e(),{ArrayPrototypePush:_,Boolean:I,MathFloor:v,Number:A,NumberIsNaN:E,Promise:k,PromiseReject:C,PromiseResolve:P,PromisePrototypeThen:L,Symbol:x}=Me(),q=x("kEmpty"),D=x("kEof");function U(H,G){if(G!=null&&u(G,"options"),G?.signal!=null&&e(G.signal,"options.signal"),S(H)&&!m(H))throw new a("stream",H,"must be writable");let Y=h(this,H);return G!=null&&G.signal&&y(G.signal,Y),Y}function ae(H,G){if(typeof H!="function")throw new l("fn",["Function","AsyncFunction"],H);G!=null&&u(G,"options"),G?.signal!=null&&e(G.signal,"options.signal");let Y=1;G?.concurrency!=null&&(Y=v(G.concurrency));let ye=Y-1;return G?.highWaterMark!=null&&(ye=v(G.highWaterMark)),o(Y,"options.concurrency",1),o(ye,"options.highWaterMark",0),ye+=Y,(async function*(){let oe=$e().AbortSignalAny([G?.signal].filter(I)),M=this,W=[],ee={signal:oe},fe,pe,be=!1,$=0;function ge(){be=!0,ve()}function ve(){$-=1,se()}function se(){pe&&!be&&$<Y&&W.length<ye&&(pe(),pe=null)}async function xe(){try{for await(let c of M){if(be)return;if(oe.aborted)throw new n;try{if(c=H(c,ee),c===q)continue;c=P(c)}catch(w){c=C(w)}$+=1,L(c,ve,ge),W.push(c),fe&&(fe(),fe=null),!be&&(W.length>=ye||$>=Y)&&await new k(w=>{pe=w})}W.push(D)}catch(c){let w=C(c);L(w,ve,ge),W.push(w)}finally{be=!0,fe&&(fe(),fe=null)}}xe();try{for(;;){for(;W.length>0;){let c=await W[0];if(c===D)return;if(oe.aborted)throw new n;c!==q&&(yield c),W.shift(),se()}await new k(c=>{fe=c})}}finally{be=!0,pe&&(pe(),pe=null)}}).call(this)}function Q(H=void 0){return H!=null&&u(H,"options"),H?.signal!=null&&e(H.signal,"options.signal"),(async function*(){let G=0;for await(let ye of this){var Y;if(H!=null&&(Y=H.signal)!==null&&Y!==void 0&&Y.aborted)throw new n({cause:H.signal.reason});yield[G++,ye]}}).call(this)}async function K(H,G=void 0){for await(let Y of R.call(this,H,G))return!0;return!1}async function re(H,G=void 0){if(typeof H!="function")throw new l("fn",["Function","AsyncFunction"],H);return!await K.call(this,async(...Y)=>!await H(...Y),G)}async function F(H,G){for await(let Y of R.call(this,H,G))return Y}async function Z(H,G){if(typeof H!="function")throw new l("fn",["Function","AsyncFunction"],H);async function Y(ye,oe){return await H(ye,oe),q}for await(let ye of ae.call(this,Y,G));}function R(H,G){if(typeof H!="function")throw new l("fn",["Function","AsyncFunction"],H);async function Y(ye,oe){return await H(ye,oe)?ye:q}return ae.call(this,Y,G)}var J=class extends t{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function me(H,G,Y){var ye;if(typeof H!="function")throw new l("reducer",["Function","AsyncFunction"],H);Y!=null&&u(Y,"options"),Y?.signal!=null&&e(Y.signal,"options.signal");let oe=arguments.length>1;if(Y!=null&&(ye=Y.signal)!==null&&ye!==void 0&&ye.aborted){let pe=new n(void 0,{cause:Y.signal.reason});throw this.once("error",()=>{}),await b(this.destroy(pe)),pe}let M=new s,W=M.signal;if(Y!=null&&Y.signal){let pe={once:!0,[p]:this,[d]:!0};Y.signal.addEventListener("abort",()=>M.abort(),pe)}let ee=!1;try{for await(let pe of this){var fe;if(ee=!0,Y!=null&&(fe=Y.signal)!==null&&fe!==void 0&&fe.aborted)throw new n;oe?G=await H(G,pe,{signal:W}):(G=pe,oe=!0)}if(!ee&&!oe)throw new J}finally{M.abort()}return G}async function te(H){H!=null&&u(H,"options"),H?.signal!=null&&e(H.signal,"options.signal");let G=[];for await(let ye of this){var Y;if(H!=null&&(Y=H.signal)!==null&&Y!==void 0&&Y.aborted)throw new n(void 0,{cause:H.signal.reason});_(G,ye)}return G}function we(H,G){let Y=ae.call(this,H,G);return(async function*(){for await(let ye of Y)yield*ye}).call(this)}function V(H){if(H=A(H),E(H))return 0;if(H<0)throw new r("number",">= 0",H);return H}function N(H,G=void 0){return G!=null&&u(G,"options"),G?.signal!=null&&e(G.signal,"options.signal"),H=V(H),(async function*(){var Y;if(G!=null&&(Y=G.signal)!==null&&Y!==void 0&&Y.aborted)throw new n;for await(let oe of this){var ye;if(G!=null&&(ye=G.signal)!==null&&ye!==void 0&&ye.aborted)throw new n;H--<=0&&(yield oe)}}).call(this)}function ne(H,G=void 0){return G!=null&&u(G,"options"),G?.signal!=null&&e(G.signal,"options.signal"),H=V(H),(async function*(){var Y;if(G!=null&&(Y=G.signal)!==null&&Y!==void 0&&Y.aborted)throw new n;for await(let oe of this){var ye;if(G!=null&&(ye=G.signal)!==null&&ye!==void 0&&ye.aborted)throw new n;if(H-- >0&&(yield oe),H<=0)return}}).call(this)}i.exports.streamReturningOperators={asIndexedPairs:g(Q,"readable.asIndexedPairs will be removed in a future version."),drop:N,filter:R,flatMap:we,map:ae,take:ne,compose:U},i.exports.promiseReturningOperators={every:re,forEach:Z,reduce:me,toArray:te,some:K,find:F}}),Us=de((f,i)=>{le(),ce(),ue();var{ArrayPrototypePop:s,Promise:a}=Me(),{isIterable:l,isNodeStream:t,isWebStream:r}=lt(),{pipelineImpl:n}=Wi(),{finished:e}=mt();Bs();function o(...u){return new a((p,d)=>{let b,h,y=u[u.length-1];if(y&&typeof y=="object"&&!t(y)&&!l(y)&&!r(y)){let m=s(u);b=m.signal,h=m.end}n(u,(m,S)=>{m?d(m):p(S)},{signal:b,end:h})})}i.exports={finished:e,pipeline:o}}),Bs=de((f,i)=>{le(),ce(),ue();var{Buffer:s}=(Ue(),Pe(Ne)),{ObjectDefineProperty:a,ObjectKeys:l,ReflectApply:t}=Me(),{promisify:{custom:r}}=$e(),{streamReturningOperators:n,promiseReturningOperators:e}=vl(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:o}}=qe(),u=Ns(),{setDefaultHighWaterMark:p,getDefaultHighWaterMark:d}=kr(),{pipeline:b}=Wi(),{destroyer:h}=Mt(),y=mt(),m=Us(),S=lt(),g=i.exports=Di().Stream;g.isDestroyed=S.isDestroyed,g.isDisturbed=S.isDisturbed,g.isErrored=S.isErrored,g.isReadable=S.isReadable,g.isWritable=S.isWritable,g.Readable=xr();for(let I of l(n)){let v=function(...E){if(new.target)throw o();return g.Readable.from(t(A,this,E))},A=n[I];a(v,"name",{__proto__:null,value:A.name}),a(v,"length",{__proto__:null,value:A.length}),a(g.Readable.prototype,I,{__proto__:null,value:v,enumerable:!1,configurable:!0,writable:!0})}for(let I of l(e)){let v=function(...E){if(new.target)throw o();return t(A,this,E)},A=e[I];a(v,"name",{__proto__:null,value:A.name}),a(v,"length",{__proto__:null,value:A.length}),a(g.Readable.prototype,I,{__proto__:null,value:v,enumerable:!1,configurable:!0,writable:!0})}g.Writable=Fi(),g.Duplex=st(),g.Transform=Ms(),g.PassThrough=js(),g.pipeline=b;var{addAbortSignal:_}=Tr();g.addAbortSignal=_,g.finished=y,g.destroy=h,g.compose=u,g.setDefaultHighWaterMark=p,g.getDefaultHighWaterMark=d,a(g,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return m}}),a(b,r,{__proto__:null,enumerable:!0,get(){return m.pipeline}}),a(y,r,{__proto__:null,enumerable:!0,get(){return m.finished}}),g.Stream=g,g._isUint8Array=function(I){return I instanceof Uint8Array},g._uint8ArrayToBuffer=function(I){return s.from(I.buffer,I.byteOffset,I.byteLength)}}),Tt=de((f,i)=>{le(),ce(),ue();var s=Bs(),a=Us(),l=s.Readable.destroy;i.exports=s.Readable,i.exports._uint8ArrayToBuffer=s._uint8ArrayToBuffer,i.exports._isUint8Array=s._isUint8Array,i.exports.isDisturbed=s.isDisturbed,i.exports.isErrored=s.isErrored,i.exports.isReadable=s.isReadable,i.exports.Readable=s.Readable,i.exports.Writable=s.Writable,i.exports.Duplex=s.Duplex,i.exports.Transform=s.Transform,i.exports.PassThrough=s.PassThrough,i.exports.addAbortSignal=s.addAbortSignal,i.exports.finished=s.finished,i.exports.destroy=s.destroy,i.exports.destroy=l,i.exports.pipeline=s.pipeline,i.exports.compose=s.compose,Object.defineProperty(s,"promises",{configurable:!0,enumerable:!0,get(){return a}}),i.exports.Stream=s.Stream,i.exports.default=i.exports}),wl=de((f,i)=>{le(),ce(),ue(),typeof Object.create=="function"?i.exports=function(s,a){a&&(s.super_=a,s.prototype=Object.create(a.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}))}:i.exports=function(s,a){if(a){s.super_=a;var l=function(){};l.prototype=a.prototype,s.prototype=new l,s.prototype.constructor=s}}}),_l=de((f,i)=>{le(),ce(),ue();var{Buffer:s}=(Ue(),Pe(Ne)),a=Symbol.for("BufferList");function l(t){if(!(this instanceof l))return new l(t);l._init.call(this,t)}l._init=function(t){Object.defineProperty(this,a,{value:!0}),this._bufs=[],this.length=0,t&&this.append(t)},l.prototype._new=function(t){return new l(t)},l.prototype._offset=function(t){if(t===0)return[0,0];let r=0;for(let n=0;n<this._bufs.length;n++){let e=r+this._bufs[n].length;if(t<e||n===this._bufs.length-1)return[n,t-r];r=e}},l.prototype._reverseOffset=function(t){let r=t[0],n=t[1];for(let e=0;e<r;e++)n+=this._bufs[e].length;return n},l.prototype.getBuffers=function(){return this._bufs},l.prototype.get=function(t){if(t>this.length||t<0)return;let r=this._offset(t);return this._bufs[r[0]][r[1]]},l.prototype.slice=function(t,r){return typeof t=="number"&&t<0&&(t+=this.length),typeof r=="number"&&r<0&&(r+=this.length),this.copy(null,0,t,r)},l.prototype.copy=function(t,r,n,e){if((typeof n!="number"||n<0)&&(n=0),(typeof e!="number"||e>this.length)&&(e=this.length),n>=this.length||e<=0)return t||s.alloc(0);let o=!!t,u=this._offset(n),p=e-n,d=p,b=o&&r||0,h=u[1];if(n===0&&e===this.length){if(!o)return this._bufs.length===1?this._bufs[0]:s.concat(this._bufs,this.length);for(let y=0;y<this._bufs.length;y++)this._bufs[y].copy(t,b),b+=this._bufs[y].length;return t}if(d<=this._bufs[u[0]].length-h)return o?this._bufs[u[0]].copy(t,r,h,h+d):this._bufs[u[0]].slice(h,h+d);o||(t=s.allocUnsafe(p));for(let y=u[0];y<this._bufs.length;y++){let m=this._bufs[y].length-h;if(d>m)this._bufs[y].copy(t,b,h),b+=m;else{this._bufs[y].copy(t,b,h,h+d),b+=m;break}d-=m,h&&(h=0)}return t.length>b?t.slice(0,b):t},l.prototype.shallowSlice=function(t,r){if(t=t||0,r=typeof r!="number"?this.length:r,t<0&&(t+=this.length),r<0&&(r+=this.length),t===r)return this._new();let n=this._offset(t),e=this._offset(r),o=this._bufs.slice(n[0],e[0]+1);return e[1]===0?o.pop():o[o.length-1]=o[o.length-1].slice(0,e[1]),n[1]!==0&&(o[0]=o[0].slice(n[1])),this._new(o)},l.prototype.toString=function(t,r,n){return this.slice(r,n).toString(t)},l.prototype.consume=function(t){if(t=Math.trunc(t),Number.isNaN(t)||t<=0)return this;for(;this._bufs.length;)if(t>=this._bufs[0].length)t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}return this},l.prototype.duplicate=function(){let t=this._new();for(let r=0;r<this._bufs.length;r++)t.append(this._bufs[r]);return t},l.prototype.append=function(t){return this._attach(t,l.prototype._appendBuffer)},l.prototype.prepend=function(t){return this._attach(t,l.prototype._prependBuffer,!0)},l.prototype._attach=function(t,r,n){if(t==null)return this;if(t.buffer)r.call(this,s.from(t.buffer,t.byteOffset,t.byteLength));else if(Array.isArray(t)){let[e,o]=n?[t.length-1,-1]:[0,1];for(let u=e;u>=0&&u<t.length;u+=o)this._attach(t[u],r,n)}else if(this._isBufferList(t)){let[e,o]=n?[t._bufs.length-1,-1]:[0,1];for(let u=e;u>=0&&u<t._bufs.length;u+=o)this._attach(t._bufs[u],r,n)}else typeof t=="number"&&(t=t.toString()),r.call(this,s.from(t));return this},l.prototype._appendBuffer=function(t){this._bufs.push(t),this.length+=t.length},l.prototype._prependBuffer=function(t){this._bufs.unshift(t),this.length+=t.length},l.prototype.indexOf=function(t,r,n){if(n===void 0&&typeof r=="string"&&(n=r,r=void 0),typeof t=="function"||Array.isArray(t))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof t=="number"?t=s.from([t]):typeof t=="string"?t=s.from(t,n):this._isBufferList(t)?t=t.slice():Array.isArray(t.buffer)?t=s.from(t.buffer,t.byteOffset,t.byteLength):s.isBuffer(t)||(t=s.from(t)),r=Number(r||0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let e=this._offset(r),o=e[0],u=e[1];for(;o<this._bufs.length;o++){let p=this._bufs[o];for(;u<p.length;)if(p.length-u>=t.length){let d=p.indexOf(t,u);if(d!==-1)return this._reverseOffset([o,d]);u=p.length-t.length+1}else{let d=this._reverseOffset([o,u]);if(this._match(d,t))return d;u++}u=0}return-1},l.prototype._match=function(t,r){if(this.length-t<r.length)return!1;for(let n=0;n<r.length;n++)if(this.get(t+n)!==r[n])return!1;return!0},(function(){let t={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readBigInt64BE:8,readBigInt64LE:8,readBigUInt64BE:8,readBigUInt64LE:8,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(let r in t)(function(n){t[n]===null?l.prototype[n]=function(e,o){return this.slice(e,e+o)[n](0,o)}:l.prototype[n]=function(e=0){return this.slice(e,e+t[n])[n](0)}})(r)})(),l.prototype._isBufferList=function(t){return t instanceof l||l.isBufferList(t)},l.isBufferList=function(t){return t!=null&&t[a]},i.exports=l}),Sl=de((f,i)=>{le(),ce(),ue();var s=Tt().Duplex,a=wl(),l=_l();function t(r){if(!(this instanceof t))return new t(r);if(typeof r=="function"){this._callback=r;let n=(function(e){this._callback&&(this._callback(e),this._callback=null)}).bind(this);this.on("pipe",function(e){e.on("error",n)}),this.on("unpipe",function(e){e.removeListener("error",n)}),r=null}l._init.call(this,r),s.call(this)}a(t,s),Object.assign(t.prototype,l.prototype),t.prototype._new=function(r){return new t(r)},t.prototype._write=function(r,n,e){this._appendBuffer(r),typeof e=="function"&&e()},t.prototype._read=function(r){if(!this.length)return this.push(null);r=Math.min(r,this.length),this.push(this.slice(0,r)),this.consume(r)},t.prototype.end=function(r){s.prototype.end.call(this,r),this._callback&&(this._callback(null,this.slice()),this._callback=null)},t.prototype._destroy=function(r,n){this._bufs.length=0,this.length=0,n(r)},t.prototype._isBufferList=function(r){return r instanceof t||r instanceof l||t.isBufferList(r)},t.isBufferList=l.isBufferList,i.exports=t,i.exports.BufferListStream=t,i.exports.BufferList=l}),El=de((f,i)=>{le(),ce(),ue();var s=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}};i.exports=s}),Ls=de((f,i)=>{le(),ce(),ue();var s=i.exports,{Buffer:a}=(Ue(),Pe(Ne));s.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},s.requiredHeaderFlags={1:0,2:0,4:0,5:0,6:2,7:0,8:2,9:0,10:2,11:0,12:0,13:0,14:0,15:0},s.requiredHeaderFlagsErrors={};for(let t in s.requiredHeaderFlags){let r=s.requiredHeaderFlags[t];s.requiredHeaderFlagsErrors[t]="Invalid header flag bits, must be 0x"+r.toString(16)+" for "+s.types[t]+" packet"}s.codes={};for(let t in s.types){let r=s.types[t];s.codes[r]=t}s.CMD_SHIFT=4,s.CMD_MASK=240,s.DUP_MASK=8,s.QOS_MASK=3,s.QOS_SHIFT=1,s.RETAIN_MASK=1,s.VARBYTEINT_MASK=127,s.VARBYTEINT_FIN_MASK=128,s.VARBYTEINT_MAX=268435455,s.SESSIONPRESENT_MASK=1,s.SESSIONPRESENT_HEADER=a.from([s.SESSIONPRESENT_MASK]),s.CONNACK_HEADER=a.from([s.codes.connack<<s.CMD_SHIFT]),s.USERNAME_MASK=128,s.PASSWORD_MASK=64,s.WILL_RETAIN_MASK=32,s.WILL_QOS_MASK=24,s.WILL_QOS_SHIFT=3,s.WILL_FLAG_MASK=4,s.CLEAN_SESSION_MASK=2,s.CONNECT_HEADER=a.from([s.codes.connect<<s.CMD_SHIFT]),s.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},s.propertiesCodes={};for(let t in s.properties){let r=s.properties[t];s.propertiesCodes[r]=t}s.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"};function l(t){return[0,1,2].map(r=>[0,1].map(n=>[0,1].map(e=>{let o=a.alloc(1);return o.writeUInt8(s.codes[t]<<s.CMD_SHIFT|(n?s.DUP_MASK:0)|r<<s.QOS_SHIFT|e,0,!0),o})))}s.PUBLISH_HEADER=l("publish"),s.SUBSCRIBE_HEADER=l("subscribe"),s.SUBSCRIBE_OPTIONS_QOS_MASK=3,s.SUBSCRIBE_OPTIONS_NL_MASK=1,s.SUBSCRIBE_OPTIONS_NL_SHIFT=2,s.SUBSCRIBE_OPTIONS_RAP_MASK=1,s.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,s.SUBSCRIBE_OPTIONS_RH_MASK=3,s.SUBSCRIBE_OPTIONS_RH_SHIFT=4,s.SUBSCRIBE_OPTIONS_RH=[0,16,32],s.SUBSCRIBE_OPTIONS_NL=4,s.SUBSCRIBE_OPTIONS_RAP=8,s.SUBSCRIBE_OPTIONS_QOS=[0,1,2],s.UNSUBSCRIBE_HEADER=l("unsubscribe"),s.ACKS={unsuback:l("unsuback"),puback:l("puback"),pubcomp:l("pubcomp"),pubrel:l("pubrel"),pubrec:l("pubrec")},s.SUBACK_HEADER=a.from([s.codes.suback<<s.CMD_SHIFT]),s.VERSION3=a.from([3]),s.VERSION4=a.from([4]),s.VERSION5=a.from([5]),s.VERSION131=a.from([131]),s.VERSION132=a.from([132]),s.QOS=[0,1,2].map(t=>a.from([t])),s.EMPTY={pingreq:a.from([s.codes.pingreq<<4,0]),pingresp:a.from([s.codes.pingresp<<4,0]),disconnect:a.from([s.codes.disconnect<<4,0])},s.MQTT5_PUBACK_PUBREC_CODES={0:"Success",16:"No matching subscribers",128:"Unspecified error",131:"Implementation specific error",135:"Not authorized",144:"Topic Name invalid",145:"Packet identifier in use",151:"Quota exceeded",153:"Payload format invalid"},s.MQTT5_PUBREL_PUBCOMP_CODES={0:"Success",146:"Packet Identifier not found"},s.MQTT5_SUBACK_CODES={0:"Granted QoS 0",1:"Granted QoS 1",2:"Granted QoS 2",128:"Unspecified error",131:"Implementation specific error",135:"Not authorized",143:"Topic Filter invalid",145:"Packet Identifier in use",151:"Quota exceeded",158:"Shared Subscriptions not supported",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"},s.MQTT5_UNSUBACK_CODES={0:"Success",17:"No subscription existed",128:"Unspecified error",131:"Implementation specific error",135:"Not authorized",143:"Topic Filter invalid",145:"Packet Identifier in use"},s.MQTT5_DISCONNECT_CODES={0:"Normal disconnection",4:"Disconnect with Will Message",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",135:"Not authorized",137:"Server busy",139:"Server shutting down",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"},s.MQTT5_AUTH_CODES={0:"Success",24:"Continue authentication",25:"Re-authenticate"}}),Al=de((f,i)=>{le(),ce(),ue();var s=1e3,a=s*60,l=a*60,t=l*24,r=t*7,n=t*365.25;i.exports=function(d,b){b=b||{};var h=typeof d;if(h==="string"&&d.length>0)return e(d);if(h==="number"&&isFinite(d))return b.long?u(d):o(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))};function e(d){if(d=String(d),!(d.length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var h=parseFloat(b[1]),y=(b[2]||"ms").toLowerCase();switch(y){case"years":case"year":case"yrs":case"yr":case"y":return h*n;case"weeks":case"week":case"w":return h*r;case"days":case"day":case"d":return h*t;case"hours":case"hour":case"hrs":case"hr":case"h":return h*l;case"minutes":case"minute":case"mins":case"min":case"m":return h*a;case"seconds":case"second":case"secs":case"sec":case"s":return h*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}function o(d){var b=Math.abs(d);return b>=t?Math.round(d/t)+"d":b>=l?Math.round(d/l)+"h":b>=a?Math.round(d/a)+"m":b>=s?Math.round(d/s)+"s":d+"ms"}function u(d){var b=Math.abs(d);return b>=t?p(d,b,t,"day"):b>=l?p(d,b,l,"hour"):b>=a?p(d,b,a,"minute"):b>=s?p(d,b,s,"second"):d+" ms"}function p(d,b,h,y){var m=b>=h*1.5;return Math.round(d/h)+" "+y+(m?"s":"")}}),Il=de((f,i)=>{le(),ce(),ue();function s(a){t.debug=t,t.default=t,t.coerce=p,t.disable=o,t.enable=n,t.enabled=u,t.humanize=Al(),t.destroy=d,Object.keys(a).forEach(b=>{t[b]=a[b]}),t.names=[],t.skips=[],t.formatters={};function l(b){let h=0;for(let y=0;y<b.length;y++)h=(h<<5)-h+b.charCodeAt(y),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=l;function t(b){let h,y=null,m,S;function g(..._){if(!g.enabled)return;let I=g,v=Number(new Date),A=v-(h||v);I.diff=A,I.prev=h,I.curr=v,h=v,_[0]=t.coerce(_[0]),typeof _[0]!="string"&&_.unshift("%O");let E=0;_[0]=_[0].replace(/%([a-zA-Z%])/g,(k,C)=>{if(k==="%%")return"%";E++;let P=t.formatters[C];if(typeof P=="function"){let L=_[E];k=P.call(I,L),_.splice(E,1),E--}return k}),t.formatArgs.call(I,_),(I.log||t.log).apply(I,_)}return g.namespace=b,g.useColors=t.useColors(),g.color=t.selectColor(b),g.extend=r,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(m!==t.namespaces&&(m=t.namespaces,S=t.enabled(b)),S),set:_=>{y=_}}),typeof t.init=="function"&&t.init(g),g}function r(b,h){let y=t(this.namespace+(typeof h>"u"?":":h)+b);return y.log=this.log,y}function n(b){t.save(b),t.namespaces=b,t.names=[],t.skips=[];let h=(typeof b=="string"?b:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let y of h)y[0]==="-"?t.skips.push(y.slice(1)):t.names.push(y)}function e(b,h){let y=0,m=0,S=-1,g=0;for(;y<b.length;)if(m<h.length&&(h[m]===b[y]||h[m]==="*"))h[m]==="*"?(S=m,g=y,m++):(y++,m++);else if(S!==-1)m=S+1,g++,y=g;else return!1;for(;m<h.length&&h[m]==="*";)m++;return m===h.length}function o(){let b=[...t.names,...t.skips.map(h=>"-"+h)].join(",");return t.enable(""),b}function u(b){for(let h of t.skips)if(e(b,h))return!1;for(let h of t.names)if(e(b,h))return!0;return!1}function p(b){return b instanceof Error?b.stack||b.message:b}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}i.exports=s}),at=de((f,i)=>{le(),ce(),ue(),f.formatArgs=a,f.save=l,f.load=t,f.useColors=s,f.storage=r(),f.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),f.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function s(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function a(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+i.exports.humanize(this.diff),!this.useColors)return;let o="color: "+this.color;e.splice(1,0,o,"color: inherit");let u=0,p=0;e[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&(u++,d==="%c"&&(p=u))}),e.splice(p,0,o)}f.log=console.debug||console.log||(()=>{});function l(e){try{e?f.storage.setItem("debug",e):f.storage.removeItem("debug")}catch{}}function t(){let e;try{e=f.storage.getItem("debug")||f.storage.getItem("DEBUG")}catch{}return!e&&typeof Re<"u"&&"env"in Re&&(e=Re.env.DEBUG),e}function r(){try{return localStorage}catch{}}i.exports=Il()(f);var{formatters:n}=i.exports;n.j=function(e){try{return JSON.stringify(e)}catch(o){return"[UnexpectedJSONParseError]: "+o.message}}}),Tl=de((f,i)=>{le(),ce(),ue();var s=Sl(),{EventEmitter:a}=(At(),Pe(yt)),l=El(),t=Ls(),r=at()("mqtt-packet:parser"),n=class Kn extends a{constructor(){super(),this.parser=this.constructor.parser}static parser(o){return this instanceof Kn?(this.settings=o||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new Kn().parser(o)}_resetState(){r("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new l,this.error=null,this._list=s(),this._stateCounter=0}parse(o){for(this.error&&this._resetState(),this._list.append(o),r("parse: current state: %s",this._states[this._stateCounter]);(this.packet.length!==-1||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,r("parse: state complete. _stateCounter is now: %d",this._stateCounter),r("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return r("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){let o=this._list.readUInt8(0),u=o>>t.CMD_SHIFT;this.packet.cmd=t.types[u];let p=o&15,d=t.requiredHeaderFlags[u];return d!=null&&p!==d?this._emitError(new Error(t.requiredHeaderFlagsErrors[u])):(this.packet.retain=(o&t.RETAIN_MASK)!==0,this.packet.qos=o>>t.QOS_SHIFT&t.QOS_MASK,this.packet.qos>2?this._emitError(new Error("Packet must not have both QoS bits set to 1")):(this.packet.dup=(o&t.DUP_MASK)!==0,r("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0))}_parseLength(){let o=this._parseVarByteNum(!0);return o&&(this.packet.length=o.value,this._list.consume(o.bytes)),r("_parseLength %d",o.value),!!o}_parsePayload(){r("_parsePayload: payload %O",this._list);let o=!1;if(this.packet.length===0||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}o=!0}return r("_parsePayload complete result: %s",o),o}_parseConnect(){r("_parseConnect");let o,u,p,d,b={},h=this.packet,y=this._parseString();if(y===null)return this._emitError(new Error("Cannot parse protocolId"));if(y!=="MQTT"&&y!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(h.protocolId=y,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(h.protocolVersion=this._list.readUInt8(this._pos),h.protocolVersion>=128&&(h.bridgeMode=!0,h.protocolVersion=h.protocolVersion-128),h.protocolVersion!==3&&h.protocolVersion!==4&&h.protocolVersion!==5)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(this._list.readUInt8(this._pos)&1)return this._emitError(new Error("Connect flag bit 0 must be 0, but got 1"));b.username=this._list.readUInt8(this._pos)&t.USERNAME_MASK,b.password=this._list.readUInt8(this._pos)&t.PASSWORD_MASK,b.will=this._list.readUInt8(this._pos)&t.WILL_FLAG_MASK;let m=!!(this._list.readUInt8(this._pos)&t.WILL_RETAIN_MASK),S=(this._list.readUInt8(this._pos)&t.WILL_QOS_MASK)>>t.WILL_QOS_SHIFT;if(b.will)h.will={},h.will.retain=m,h.will.qos=S;else{if(m)return this._emitError(new Error("Will Retain Flag must be set to zero when Will Flag is set to 0"));if(S)return this._emitError(new Error("Will QoS must be set to zero when Will Flag is set to 0"))}if(h.clean=(this._list.readUInt8(this._pos)&t.CLEAN_SESSION_MASK)!==0,this._pos++,h.keepalive=this._parseNum(),h.keepalive===-1)return this._emitError(new Error("Packet too short"));if(h.protocolVersion===5){let _=this._parseProperties();Object.getOwnPropertyNames(_).length&&(h.properties=_)}let g=this._parseString();if(g===null)return this._emitError(new Error("Packet too short"));if(h.clientId=g,r("_parseConnect: packet.clientId: %s",h.clientId),b.will){if(h.protocolVersion===5){let _=this._parseProperties();Object.getOwnPropertyNames(_).length&&(h.will.properties=_)}if(o=this._parseString(),o===null)return this._emitError(new Error("Cannot parse will topic"));if(h.will.topic=o,r("_parseConnect: packet.will.topic: %s",h.will.topic),u=this._parseBuffer(),u===null)return this._emitError(new Error("Cannot parse will payload"));h.will.payload=u,r("_parseConnect: packet.will.paylaod: %s",h.will.payload)}if(b.username){if(d=this._parseString(),d===null)return this._emitError(new Error("Cannot parse username"));h.username=d,r("_parseConnect: packet.username: %s",h.username)}if(b.password){if(p=this._parseBuffer(),p===null)return this._emitError(new Error("Cannot parse password"));h.password=p}return this.settings=h,r("_parseConnect: complete"),h}_parseConnack(){r("_parseConnack");let o=this.packet;if(this._list.length<1)return null;let u=this._list.readUInt8(this._pos++);if(u>1)return this._emitError(new Error("Invalid connack flags, bits 7-1 must be set to 0"));if(o.sessionPresent=!!(u&t.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)this._list.length>=2?o.reasonCode=this._list.readUInt8(this._pos++):o.reasonCode=0;else{if(this._list.length<2)return null;o.returnCode=this._list.readUInt8(this._pos++)}if(o.returnCode===-1||o.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){let p=this._parseProperties();Object.getOwnPropertyNames(p).length&&(o.properties=p)}r("_parseConnack: complete")}_parsePublish(){r("_parsePublish");let o=this.packet;if(o.topic=this._parseString(),o.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(o.qos>0&&!this._parseMessageId())){if(this.settings.protocolVersion===5){let u=this._parseProperties();Object.getOwnPropertyNames(u).length&&(o.properties=u)}o.payload=this._list.slice(this._pos,o.length),r("_parsePublish: payload from buffer list: %o",o.payload)}}_parseSubscribe(){r("_parseSubscribe");let o=this.packet,u,p,d,b,h,y,m;if(o.subscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let S=this._parseProperties();Object.getOwnPropertyNames(S).length&&(o.properties=S)}if(o.length<=0)return this._emitError(new Error("Malformed subscribe, no payload specified"));for(;this._pos<o.length;){if(u=this._parseString(),u===null)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=o.length)return this._emitError(new Error("Malformed Subscribe Payload"));if(p=this._parseByte(),this.settings.protocolVersion===5){if(p&192)return this._emitError(new Error("Invalid subscribe topic flag bits, bits 7-6 must be 0"))}else if(p&252)return this._emitError(new Error("Invalid subscribe topic flag bits, bits 7-2 must be 0"));if(d=p&t.SUBSCRIBE_OPTIONS_QOS_MASK,d>2)return this._emitError(new Error("Invalid subscribe QoS, must be <= 2"));if(y=(p>>t.SUBSCRIBE_OPTIONS_NL_SHIFT&t.SUBSCRIBE_OPTIONS_NL_MASK)!==0,h=(p>>t.SUBSCRIBE_OPTIONS_RAP_SHIFT&t.SUBSCRIBE_OPTIONS_RAP_MASK)!==0,b=p>>t.SUBSCRIBE_OPTIONS_RH_SHIFT&t.SUBSCRIBE_OPTIONS_RH_MASK,b>2)return this._emitError(new Error("Invalid retain handling, must be <= 2"));m={topic:u,qos:d},this.settings.protocolVersion===5?(m.nl=y,m.rap=h,m.rh=b):this.settings.bridgeMode&&(m.rh=0,m.rap=!0,m.nl=!0),r("_parseSubscribe: push subscription `%s` to subscription",m),o.subscriptions.push(m)}}}_parseSuback(){r("_parseSuback");let o=this.packet;if(this.packet.granted=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let u=this._parseProperties();Object.getOwnPropertyNames(u).length&&(o.properties=u)}if(o.length<=0)return this._emitError(new Error("Malformed suback, no payload specified"));for(;this._pos<this.packet.length;){let u=this._list.readUInt8(this._pos++);if(this.settings.protocolVersion===5){if(!t.MQTT5_SUBACK_CODES[u])return this._emitError(new Error("Invalid suback code"))}else if(u>2&&u!==128)return this._emitError(new Error("Invalid suback QoS, must be 0, 1, 2 or 128"));this.packet.granted.push(u)}}}_parseUnsubscribe(){r("_parseUnsubscribe");let o=this.packet;if(o.unsubscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let u=this._parseProperties();Object.getOwnPropertyNames(u).length&&(o.properties=u)}if(o.length<=0)return this._emitError(new Error("Malformed unsubscribe, no payload specified"));for(;this._pos<o.length;){let u=this._parseString();if(u===null)return this._emitError(new Error("Cannot parse topic"));r("_parseUnsubscribe: push topic `%s` to unsubscriptions",u),o.unsubscriptions.push(u)}}}_parseUnsuback(){r("_parseUnsuback");let o=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if((this.settings.protocolVersion===3||this.settings.protocolVersion===4)&&o.length!==2)return this._emitError(new Error("Malformed unsuback, payload length must be 2"));if(o.length<=0)return this._emitError(new Error("Malformed unsuback, no payload specified"));if(this.settings.protocolVersion===5){let u=this._parseProperties();for(Object.getOwnPropertyNames(u).length&&(o.properties=u),o.granted=[];this._pos<this.packet.length;){let p=this._list.readUInt8(this._pos++);if(!t.MQTT5_UNSUBACK_CODES[p])return this._emitError(new Error("Invalid unsuback code"));this.packet.granted.push(p)}}}_parseConfirmation(){r("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);let o=this.packet;if(this._parseMessageId(),this.settings.protocolVersion===5){if(o.length>2){switch(o.reasonCode=this._parseByte(),this.packet.cmd){case"puback":case"pubrec":if(!t.MQTT5_PUBACK_PUBREC_CODES[o.reasonCode])return this._emitError(new Error("Invalid "+this.packet.cmd+" reason code"));break;case"pubrel":case"pubcomp":if(!t.MQTT5_PUBREL_PUBCOMP_CODES[o.reasonCode])return this._emitError(new Error("Invalid "+this.packet.cmd+" reason code"));break}r("_parseConfirmation: packet.reasonCode `%d`",o.reasonCode)}else o.reasonCode=0;if(o.length>3){let u=this._parseProperties();Object.getOwnPropertyNames(u).length&&(o.properties=u)}}return!0}_parseDisconnect(){let o=this.packet;if(r("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?(o.reasonCode=this._parseByte(),t.MQTT5_DISCONNECT_CODES[o.reasonCode]||this._emitError(new Error("Invalid disconnect reason code"))):o.reasonCode=0;let u=this._parseProperties();Object.getOwnPropertyNames(u).length&&(o.properties=u)}return r("_parseDisconnect result: true"),!0}_parseAuth(){r("_parseAuth");let o=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));if(o.reasonCode=this._parseByte(),!t.MQTT5_AUTH_CODES[o.reasonCode])return this._emitError(new Error("Invalid auth reason code"));let u=this._parseProperties();return Object.getOwnPropertyNames(u).length&&(o.properties=u),r("_parseAuth: result: true"),!0}_parseMessageId(){let o=this.packet;return o.messageId=this._parseNum(),o.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(r("_parseMessageId: packet.messageId %d",o.messageId),!0)}_parseString(o){let u=this._parseNum(),p=u+this._pos;if(u===-1||p>this._list.length||p>this.packet.length)return null;let d=this._list.toString("utf8",this._pos,p);return this._pos+=u,r("_parseString: result: %s",d),d}_parseStringPair(){return r("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){let o=this._parseNum(),u=o+this._pos;if(o===-1||u>this._list.length||u>this.packet.length)return null;let p=this._list.slice(this._pos,u);return this._pos+=o,r("_parseBuffer: result: %o",p),p}_parseNum(){if(this._list.length-this._pos<2)return-1;let o=this._list.readUInt16BE(this._pos);return this._pos+=2,r("_parseNum: result: %s",o),o}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;let o=this._list.readUInt32BE(this._pos);return this._pos+=4,r("_parse4ByteNum: result: %s",o),o}_parseVarByteNum(o){r("_parseVarByteNum");let u=4,p=0,d=1,b=0,h=!1,y,m=this._pos?this._pos:0;for(;p<u&&m+p<this._list.length;){if(y=this._list.readUInt8(m+p++),b+=d*(y&t.VARBYTEINT_MASK),d*=128,(y&t.VARBYTEINT_FIN_MASK)===0){h=!0;break}if(this._list.length<=p)break}return!h&&p===u&&this._list.length>=p&&this._emitError(new Error("Invalid variable byte integer")),m&&(this._pos+=p),h?o?h={bytes:p,value:b}:h=b:h=!1,r("_parseVarByteNum: result: %o",h),h}_parseByte(){let o;return this._pos<this._list.length&&(o=this._list.readUInt8(this._pos),this._pos++),r("_parseByte: result: %o",o),o}_parseByType(o){switch(r("_parseByType: type: %s",o),o){case"byte":return this._parseByte()!==0;case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){r("_parseProperties");let o=this._parseVarByteNum(),u=this._pos+o,p={};for(;this._pos<u;){let d=this._parseByte();if(!d)return this._emitError(new Error("Cannot parse property code type")),!1;let b=t.propertiesCodes[d];if(!b)return this._emitError(new Error("Unknown property")),!1;if(b==="userProperties"){p[b]||(p[b]=Object.create(null));let h=this._parseByType(t.propertiesTypes[b]);if(p[b][h.name])if(Array.isArray(p[b][h.name]))p[b][h.name].push(h.value);else{let y=p[b][h.name];p[b][h.name]=[y],p[b][h.name].push(h.value)}else p[b][h.name]=h.value;continue}p[b]?Array.isArray(p[b])?p[b].push(this._parseByType(t.propertiesTypes[b])):(p[b]=[p[b]],p[b].push(this._parseByType(t.propertiesTypes[b]))):p[b]=this._parseByType(t.propertiesTypes[b])}return p}_newPacket(){return r("_newPacket"),this.packet&&(this._list.consume(this.packet.length),r("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),r("_newPacket: new packet"),this.packet=new l,this._pos=0,!0}_emitError(o){r("_emitError",o),this.error=o,this.emit("error",o)}};i.exports=n}),kl=de((f,i)=>{le(),ce(),ue();var{Buffer:s}=(Ue(),Pe(Ne)),a=65536,l={},t=s.isBuffer(s.from([1,2]).subarray(0,1));function r(u){let p=s.allocUnsafe(2);return p.writeUInt8(u>>8,0),p.writeUInt8(u&255,1),p}function n(){for(let u=0;u<a;u++)l[u]=r(u)}function e(u){let p=0,d=0,b=s.allocUnsafe(4);do p=u%128|0,u=u/128|0,u>0&&(p=p|128),b.writeUInt8(p,d++);while(u>0&&d<4);return u>0&&(d=0),t?b.subarray(0,d):b.slice(0,d)}function o(u){let p=s.allocUnsafe(4);return p.writeUInt32BE(u,0),p}i.exports={cache:l,generateCache:n,generateNumber:r,genBufVariableByteInt:e,generate4ByteBuffer:o}}),xl=de((f,i)=>{le(),ce(),ue(),typeof Re>"u"||!Re.version||Re.version.indexOf("v0.")===0||Re.version.indexOf("v1.")===0&&Re.version.indexOf("v1.8.")!==0?i.exports={nextTick:s}:i.exports=Re;function s(a,l,t,r){if(typeof a!="function")throw new TypeError('"callback" argument must be a function');var n=arguments.length,e,o;switch(n){case 0:case 1:return Re.nextTick(a);case 2:return Re.nextTick(function(){a.call(null,l)});case 3:return Re.nextTick(function(){a.call(null,l,t)});case 4:return Re.nextTick(function(){a.call(null,l,t,r)});default:for(e=new Array(n-1),o=0;o<e.length;)e[o++]=arguments[o];return Re.nextTick(function(){a.apply(null,e)})}}}),Ds=de((f,i)=>{le(),ce(),ue();var s=Ls(),{Buffer:a}=(Ue(),Pe(Ne)),l=a.allocUnsafe(0),t=a.from([0]),r=kl(),n=xl().nextTick,e=at()("mqtt-packet:writeToStream"),o=r.cache,u=r.generateNumber,p=r.generateCache,d=r.genBufVariableByteInt,b=r.generate4ByteBuffer,h=Q,y=!0;function m(V,N,ne){switch(e("generate called"),N.cork&&(N.cork(),n(S,N)),y&&(y=!1,p()),e("generate: packet.cmd: %s",V.cmd),V.cmd){case"connect":return g(V,N);case"connack":return _(V,N,ne);case"publish":return I(V,N,ne);case"puback":case"pubrec":case"pubrel":case"pubcomp":return v(V,N,ne);case"subscribe":return A(V,N,ne);case"suback":return E(V,N,ne);case"unsubscribe":return k(V,N,ne);case"unsuback":return C(V,N,ne);case"pingreq":case"pingresp":return P(V,N);case"disconnect":return L(V,N,ne);case"auth":return x(V,N,ne);default:return N.destroy(new Error("Unknown command")),!1}}Object.defineProperty(m,"cacheNumbers",{get(){return h===Q},set(V){V?((!o||Object.keys(o).length===0)&&(y=!0),h=Q):(y=!1,h=K)}});function S(V){V.uncork()}function g(V,N,ne){let H=V||{},G=H.protocolId||"MQTT",Y=H.protocolVersion||4,ye=H.will,oe=H.clean,M=H.keepalive||0,W=H.clientId||"",ee=H.username,fe=H.password,pe=H.properties;oe===void 0&&(oe=!0);let be=0;if(typeof G!="string"&&!a.isBuffer(G))return N.destroy(new Error("Invalid protocolId")),!1;if(be+=G.length+2,Y!==3&&Y!==4&&Y!==5)return N.destroy(new Error("Invalid protocol version")),!1;if(be+=1,(typeof W=="string"||a.isBuffer(W))&&(W||Y>=4)&&(W||oe))be+=a.byteLength(W)+2;else{if(Y<4)return N.destroy(new Error("clientId must be supplied before 3.1.1")),!1;if(oe*1===0)return N.destroy(new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof M!="number"||M<0||M>65535||M%1!==0)return N.destroy(new Error("Invalid keepalive")),!1;be+=2,be+=1;let $,ge;if(Y===5){if($=Z(N,pe),!$)return!1;be+=$.length}if(ye){if(typeof ye!="object")return N.destroy(new Error("Invalid will")),!1;if(!ye.topic||typeof ye.topic!="string")return N.destroy(new Error("Invalid will topic")),!1;if(be+=a.byteLength(ye.topic)+2,be+=2,ye.payload)if(ye.payload.length>=0)typeof ye.payload=="string"?be+=a.byteLength(ye.payload):be+=ye.payload.length;else return N.destroy(new Error("Invalid will payload")),!1;if(ge={},Y===5){if(ge=Z(N,ye.properties),!ge)return!1;be+=ge.length}}let ve=!1;if(ee!=null)if(we(ee))ve=!0,be+=a.byteLength(ee)+2;else return N.destroy(new Error("Invalid username")),!1;if(fe!=null){if(!ve)return N.destroy(new Error("Username is required to use password")),!1;if(we(fe))be+=te(fe)+2;else return N.destroy(new Error("Invalid password")),!1}N.write(s.CONNECT_HEADER),D(N,be),F(N,G),H.bridgeMode&&(Y+=128),N.write(Y===131?s.VERSION131:Y===132?s.VERSION132:Y===4?s.VERSION4:Y===5?s.VERSION5:s.VERSION3);let se=0;return se|=ee!=null?s.USERNAME_MASK:0,se|=fe!=null?s.PASSWORD_MASK:0,se|=ye&&ye.retain?s.WILL_RETAIN_MASK:0,se|=ye&&ye.qos?ye.qos<<s.WILL_QOS_SHIFT:0,se|=ye?s.WILL_FLAG_MASK:0,se|=oe?s.CLEAN_SESSION_MASK:0,N.write(a.from([se])),h(N,M),Y===5&&$.write(),F(N,W),ye&&(Y===5&&ge.write(),U(N,ye.topic),F(N,ye.payload)),ee!=null&&F(N,ee),fe!=null&&F(N,fe),!0}function _(V,N,ne){let H=ne?ne.protocolVersion:4,G=V||{},Y=H===5?G.reasonCode:G.returnCode,ye=G.properties,oe=2;if(typeof Y!="number")return N.destroy(new Error("Invalid return code")),!1;let M=null;if(H===5){if(M=Z(N,ye),!M)return!1;oe+=M.length}return N.write(s.CONNACK_HEADER),D(N,oe),N.write(G.sessionPresent?s.SESSIONPRESENT_HEADER:t),N.write(a.from([Y])),M?.write(),!0}function I(V,N,ne){e("publish: packet: %o",V);let H=ne?ne.protocolVersion:4,G=V||{},Y=G.qos||0,ye=G.retain?s.RETAIN_MASK:0,oe=G.topic,M=G.payload||l,W=G.messageId,ee=G.properties,fe=0;if(typeof oe=="string")fe+=a.byteLength(oe)+2;else if(a.isBuffer(oe))fe+=oe.length+2;else return N.destroy(new Error("Invalid topic")),!1;if(a.isBuffer(M)?fe+=M.length:fe+=a.byteLength(M),Y&&typeof W!="number")return N.destroy(new Error("Invalid messageId")),!1;Y&&(fe+=2);let pe=null;if(H===5){if(pe=Z(N,ee),!pe)return!1;fe+=pe.length}return N.write(s.PUBLISH_HEADER[Y][G.dup?1:0][ye?1:0]),D(N,fe),h(N,te(oe)),N.write(oe),Y>0&&h(N,W),pe?.write(),e("publish: payload: %o",M),N.write(M)}function v(V,N,ne){let H=ne?ne.protocolVersion:4,G=V||{},Y=G.cmd||"puback",ye=G.messageId,oe=G.dup&&Y==="pubrel"?s.DUP_MASK:0,M=0,W=G.reasonCode,ee=G.properties,fe=H===5?3:2;if(Y==="pubrel"&&(M=1),typeof ye!="number")return N.destroy(new Error("Invalid messageId")),!1;let pe=null;if(H===5&&typeof ee=="object"){if(pe=R(N,ee,ne,fe),!pe)return!1;fe+=pe.length}return N.write(s.ACKS[Y][M][oe][0]),fe===3&&(fe+=W!==0?1:-1),D(N,fe),h(N,ye),H===5&&fe!==2&&N.write(a.from([W])),pe!==null?pe.write():fe===4&&N.write(a.from([0])),!0}function A(V,N,ne){e("subscribe: packet: ");let H=ne?ne.protocolVersion:4,G=V||{},Y=G.dup?s.DUP_MASK:0,ye=G.messageId,oe=G.subscriptions,M=G.properties,W=0;if(typeof ye!="number")return N.destroy(new Error("Invalid messageId")),!1;W+=2;let ee=null;if(H===5){if(ee=Z(N,M),!ee)return!1;W+=ee.length}if(typeof oe=="object"&&oe.length)for(let pe=0;pe<oe.length;pe+=1){let be=oe[pe].topic,$=oe[pe].qos;if(typeof be!="string")return N.destroy(new Error("Invalid subscriptions - invalid topic")),!1;if(typeof $!="number")return N.destroy(new Error("Invalid subscriptions - invalid qos")),!1;if(H===5){if(typeof(oe[pe].nl||!1)!="boolean")return N.destroy(new Error("Invalid subscriptions - invalid No Local")),!1;if(typeof(oe[pe].rap||!1)!="boolean")return N.destroy(new Error("Invalid subscriptions - invalid Retain as Published")),!1;let ge=oe[pe].rh||0;if(typeof ge!="number"||ge>2)return N.destroy(new Error("Invalid subscriptions - invalid Retain Handling")),!1}W+=a.byteLength(be)+2+1}else return N.destroy(new Error("Invalid subscriptions")),!1;e("subscribe: writing to stream: %o",s.SUBSCRIBE_HEADER),N.write(s.SUBSCRIBE_HEADER[1][Y?1:0][0]),D(N,W),h(N,ye),ee!==null&&ee.write();let fe=!0;for(let pe of oe){let be=pe.topic,$=pe.qos,ge=+pe.nl,ve=+pe.rap,se=pe.rh,xe;U(N,be),xe=s.SUBSCRIBE_OPTIONS_QOS[$],H===5&&(xe|=ge?s.SUBSCRIBE_OPTIONS_NL:0,xe|=ve?s.SUBSCRIBE_OPTIONS_RAP:0,xe|=se?s.SUBSCRIBE_OPTIONS_RH[se]:0),fe=N.write(a.from([xe]))}return fe}function E(V,N,ne){let H=ne?ne.protocolVersion:4,G=V||{},Y=G.messageId,ye=G.granted,oe=G.properties,M=0;if(typeof Y!="number")return N.destroy(new Error("Invalid messageId")),!1;if(M+=2,typeof ye=="object"&&ye.length)for(let ee=0;ee<ye.length;ee+=1){if(typeof ye[ee]!="number")return N.destroy(new Error("Invalid qos vector")),!1;M+=1}else return N.destroy(new Error("Invalid qos vector")),!1;let W=null;if(H===5){if(W=R(N,oe,ne,M),!W)return!1;M+=W.length}return N.write(s.SUBACK_HEADER),D(N,M),h(N,Y),W!==null&&W.write(),N.write(a.from(ye))}function k(V,N,ne){let H=ne?ne.protocolVersion:4,G=V||{},Y=G.messageId,ye=G.dup?s.DUP_MASK:0,oe=G.unsubscriptions,M=G.properties,W=0;if(typeof Y!="number")return N.destroy(new Error("Invalid messageId")),!1;if(W+=2,typeof oe=="object"&&oe.length)for(let pe=0;pe<oe.length;pe+=1){if(typeof oe[pe]!="string")return N.destroy(new Error("Invalid unsubscriptions")),!1;W+=a.byteLength(oe[pe])+2}else return N.destroy(new Error("Invalid unsubscriptions")),!1;let ee=null;if(H===5){if(ee=Z(N,M),!ee)return!1;W+=ee.length}N.write(s.UNSUBSCRIBE_HEADER[1][ye?1:0][0]),D(N,W),h(N,Y),ee!==null&&ee.write();let fe=!0;for(let pe=0;pe<oe.length;pe++)fe=U(N,oe[pe]);return fe}function C(V,N,ne){let H=ne?ne.protocolVersion:4,G=V||{},Y=G.messageId,ye=G.dup?s.DUP_MASK:0,oe=G.granted,M=G.properties,W=G.cmd,ee=0,fe=2;if(typeof Y!="number")return N.destroy(new Error("Invalid messageId")),!1;if(H===5)if(typeof oe=="object"&&oe.length)for(let be=0;be<oe.length;be+=1){if(typeof oe[be]!="number")return N.destroy(new Error("Invalid qos vector")),!1;fe+=1}else return N.destroy(new Error("Invalid qos vector")),!1;let pe=null;if(H===5){if(pe=R(N,M,ne,fe),!pe)return!1;fe+=pe.length}return N.write(s.ACKS[W][ee][ye][0]),D(N,fe),h(N,Y),pe!==null&&pe.write(),H===5&&N.write(a.from(oe)),!0}function P(V,N,ne){return N.write(s.EMPTY[V.cmd])}function L(V,N,ne){let H=ne?ne.protocolVersion:4,G=V||{},Y=G.reasonCode,ye=G.properties,oe=H===5?1:0,M=null;if(H===5){if(M=R(N,ye,ne,oe),!M)return!1;oe+=M.length}return N.write(a.from([s.codes.disconnect<<4])),D(N,oe),H===5&&N.write(a.from([Y])),M!==null&&M.write(),!0}function x(V,N,ne){let H=ne?ne.protocolVersion:4,G=V||{},Y=G.reasonCode,ye=G.properties,oe=H===5?1:0;H!==5&&N.destroy(new Error("Invalid mqtt version for auth packet"));let M=R(N,ye,ne,oe);return M?(oe+=M.length,N.write(a.from([s.codes.auth<<4])),D(N,oe),N.write(a.from([Y])),M!==null&&M.write(),!0):!1}var q={};function D(V,N){if(N>s.VARBYTEINT_MAX)return V.destroy(new Error(`Invalid variable byte integer: ${N}`)),!1;let ne=q[N];return ne||(ne=d(N),N<16384&&(q[N]=ne)),e("writeVarByteInt: writing to stream: %o",ne),V.write(ne)}function U(V,N){let ne=a.byteLength(N);return h(V,ne),e("writeString: %s",N),V.write(N,"utf8")}function ae(V,N,ne){U(V,N),U(V,ne)}function Q(V,N){return e("writeNumberCached: number: %d",N),e("writeNumberCached: %o",o[N]),V.write(o[N])}function K(V,N){let ne=u(N);return e("writeNumberGenerated: %o",ne),V.write(ne)}function re(V,N){let ne=b(N);return e("write4ByteNumber: %o",ne),V.write(ne)}function F(V,N){typeof N=="string"?U(V,N):N?(h(V,N.length),V.write(N)):h(V,0)}function Z(V,N){if(typeof N!="object"||N.length!=null)return{length:1,write(){me(V,{},0)}};let ne=0;function H(G,Y){let ye=s.propertiesTypes[G],oe=0;switch(ye){case"byte":{if(typeof Y!="boolean")return V.destroy(new Error(`Invalid ${G}: ${Y}`)),!1;oe+=2;break}case"int8":{if(typeof Y!="number"||Y<0||Y>255)return V.destroy(new Error(`Invalid ${G}: ${Y}`)),!1;oe+=2;break}case"binary":{if(Y&&Y===null)return V.destroy(new Error(`Invalid ${G}: ${Y}`)),!1;oe+=1+a.byteLength(Y)+2;break}case"int16":{if(typeof Y!="number"||Y<0||Y>65535)return V.destroy(new Error(`Invalid ${G}: ${Y}`)),!1;oe+=3;break}case"int32":{if(typeof Y!="number"||Y<0||Y>4294967295)return V.destroy(new Error(`Invalid ${G}: ${Y}`)),!1;oe+=5;break}case"var":{if(typeof Y!="number"||Y<0||Y>268435455)return V.destroy(new Error(`Invalid ${G}: ${Y}`)),!1;oe+=1+a.byteLength(d(Y));break}case"string":{if(typeof Y!="string")return V.destroy(new Error(`Invalid ${G}: ${Y}`)),!1;oe+=3+a.byteLength(Y.toString());break}case"pair":{if(typeof Y!="object")return V.destroy(new Error(`Invalid ${G}: ${Y}`)),!1;oe+=Object.getOwnPropertyNames(Y).reduce((M,W)=>{let ee=Y[W];return Array.isArray(ee)?M+=ee.reduce((fe,pe)=>(fe+=3+a.byteLength(W.toString())+2+a.byteLength(pe.toString()),fe),0):M+=3+a.byteLength(W.toString())+2+a.byteLength(Y[W].toString()),M},0);break}default:return V.destroy(new Error(`Invalid property ${G}: ${Y}`)),!1}return oe}if(N)for(let G in N){let Y=0,ye=0,oe=N[G];if(oe!==void 0){if(Array.isArray(oe))for(let M=0;M<oe.length;M++){if(ye=H(G,oe[M]),!ye)return!1;Y+=ye}else{if(ye=H(G,oe),!ye)return!1;Y=ye}if(!Y)return!1;ne+=Y}}return{length:a.byteLength(d(ne))+ne,write(){me(V,N,ne)}}}function R(V,N,ne,H){let G=["reasonString","userProperties"],Y=ne&&ne.properties&&ne.properties.maximumPacketSize?ne.properties.maximumPacketSize:0,ye=Z(V,N);if(Y)for(;H+ye.length>Y;){let oe=G.shift();if(oe&&N[oe])delete N[oe],ye=Z(V,N);else return!1}return ye}function J(V,N,ne){switch(s.propertiesTypes[N]){case"byte":{V.write(a.from([s.properties[N]])),V.write(a.from([+ne]));break}case"int8":{V.write(a.from([s.properties[N]])),V.write(a.from([ne]));break}case"binary":{V.write(a.from([s.properties[N]])),F(V,ne);break}case"int16":{V.write(a.from([s.properties[N]])),h(V,ne);break}case"int32":{V.write(a.from([s.properties[N]])),re(V,ne);break}case"var":{V.write(a.from([s.properties[N]])),D(V,ne);break}case"string":{V.write(a.from([s.properties[N]])),U(V,ne);break}case"pair":{Object.getOwnPropertyNames(ne).forEach(H=>{let G=ne[H];Array.isArray(G)?G.forEach(Y=>{V.write(a.from([s.properties[N]])),ae(V,H.toString(),Y.toString())}):(V.write(a.from([s.properties[N]])),ae(V,H.toString(),G.toString()))});break}default:return V.destroy(new Error(`Invalid property ${N} value: ${ne}`)),!1}}function me(V,N,ne){D(V,ne);for(let H in N)if(Object.prototype.hasOwnProperty.call(N,H)&&N[H]!=null){let G=N[H];if(Array.isArray(G))for(let Y=0;Y<G.length;Y++)J(V,H,G[Y]);else J(V,H,G)}}function te(V){return V?V instanceof a?V.length:a.byteLength(V):0}function we(V){return typeof V=="string"||V instanceof a}i.exports=m}),Ol=de((f,i)=>{le(),ce(),ue();var s=Ds(),{EventEmitter:a}=(At(),Pe(yt)),{Buffer:l}=(Ue(),Pe(Ne));function t(n,e){let o=new r;return s(n,o,e),o.concat()}var r=class extends a{constructor(){super(),this._array=new Array(20),this._i=0}write(n){return this._array[this._i++]=n,!0}concat(){let n=0,e=new Array(this._array.length),o=this._array,u=0,p;for(p=0;p<o.length&&o[p]!==void 0;p++)typeof o[p]!="string"?e[p]=o[p].length:e[p]=l.byteLength(o[p]),n+=e[p];let d=l.allocUnsafe(n);for(p=0;p<o.length&&o[p]!==void 0;p++)typeof o[p]!="string"?(o[p].copy(d,u),u+=e[p]):(d.write(o[p],u),u+=e[p]);return d}destroy(n){n&&this.emit("error",n)}};i.exports=t}),Pl=de(f=>{le(),ce(),ue(),f.parser=Tl().parser,f.generate=Ol(),f.writeToStream=Ds()}),Rl=de((f,i)=>{le(),ce(),ue(),i.exports=a;function s(t){return t instanceof Ar?Ar.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function a(t){if(t=t||{},t.circles)return l(t);let r=new Map;if(r.set(Date,p=>new Date(p)),r.set(Map,(p,d)=>new Map(e(Array.from(p),d))),r.set(Set,(p,d)=>new Set(e(Array.from(p),d))),t.constructorHandlers)for(let p of t.constructorHandlers)r.set(p[0],p[1]);let n=null;return t.proto?u:o;function e(p,d){let b=Object.keys(p),h=new Array(b.length);for(let y=0;y<b.length;y++){let m=b[y],S=p[m];typeof S!="object"||S===null?h[m]=S:S.constructor!==Object&&(n=r.get(S.constructor))?h[m]=n(S,d):ArrayBuffer.isView(S)?h[m]=s(S):h[m]=d(S)}return h}function o(p){if(typeof p!="object"||p===null)return p;if(Array.isArray(p))return e(p,o);if(p.constructor!==Object&&(n=r.get(p.constructor)))return n(p,o);let d={};for(let b in p){if(Object.hasOwnProperty.call(p,b)===!1)continue;let h=p[b];typeof h!="object"||h===null?d[b]=h:h.constructor!==Object&&(n=r.get(h.constructor))?d[b]=n(h,o):ArrayBuffer.isView(h)?d[b]=s(h):d[b]=o(h)}return d}function u(p){if(typeof p!="object"||p===null)return p;if(Array.isArray(p))return e(p,u);if(p.constructor!==Object&&(n=r.get(p.constructor)))return n(p,u);let d={};for(let b in p){let h=p[b];typeof h!="object"||h===null?d[b]=h:h.constructor!==Object&&(n=r.get(h.constructor))?d[b]=n(h,u):ArrayBuffer.isView(h)?d[b]=s(h):d[b]=u(h)}return d}}function l(t){let r=[],n=[],e=new Map;if(e.set(Date,b=>new Date(b)),e.set(Map,(b,h)=>new Map(u(Array.from(b),h))),e.set(Set,(b,h)=>new Set(u(Array.from(b),h))),t.constructorHandlers)for(let b of t.constructorHandlers)e.set(b[0],b[1]);let o=null;return t.proto?d:p;function u(b,h){let y=Object.keys(b),m=new Array(y.length);for(let S=0;S<y.length;S++){let g=y[S],_=b[g];if(typeof _!="object"||_===null)m[g]=_;else if(_.constructor!==Object&&(o=e.get(_.constructor)))m[g]=o(_,h);else if(ArrayBuffer.isView(_))m[g]=s(_);else{let I=r.indexOf(_);I!==-1?m[g]=n[I]:m[g]=h(_)}}return m}function p(b){if(typeof b!="object"||b===null)return b;if(Array.isArray(b))return u(b,p);if(b.constructor!==Object&&(o=e.get(b.constructor)))return o(b,p);let h={};r.push(b),n.push(h);for(let y in b){if(Object.hasOwnProperty.call(b,y)===!1)continue;let m=b[y];if(typeof m!="object"||m===null)h[y]=m;else if(m.constructor!==Object&&(o=e.get(m.constructor)))h[y]=o(m,p);else if(ArrayBuffer.isView(m))h[y]=s(m);else{let S=r.indexOf(m);S!==-1?h[y]=n[S]:h[y]=p(m)}}return r.pop(),n.pop(),h}function d(b){if(typeof b!="object"||b===null)return b;if(Array.isArray(b))return u(b,d);if(b.constructor!==Object&&(o=e.get(b.constructor)))return o(b,d);let h={};r.push(b),n.push(h);for(let y in b){let m=b[y];if(typeof m!="object"||m===null)h[y]=m;else if(m.constructor!==Object&&(o=e.get(m.constructor)))h[y]=o(m,d);else if(ArrayBuffer.isView(m))h[y]=s(m);else{let S=r.indexOf(m);S!==-1?h[y]=n[S]:h[y]=d(m)}}return r.pop(),n.pop(),h}}}),Cl=de((f,i)=>{le(),ce(),ue(),i.exports=Rl()()}),Fs=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0}),f.validateTopic=i,f.validateTopics=s;function i(a){let l=a.split("/");for(let t=0;t<l.length;t++)if(l[t]!=="+"){if(l[t]==="#")return t===l.length-1;if(l[t].indexOf("+")!==-1||l[t].indexOf("#")!==-1)return!1}return!0}function s(a){if(a.length===0)return"empty_topic_list";for(let l=0;l<a.length;l++)if(!i(a[l]))return a[l];return null}}),Ws=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=Tt(),s={objectMode:!0},a={clean:!0},l=class{options;_inflights;constructor(t){this.options=t||{},this.options={...a,...t},this._inflights=new Map}put(t,r){return this._inflights.set(t.messageId,t),r&&r(),this}createStream(){let t=new i.Readable(s),r=[],n=!1,e=0;return this._inflights.forEach((o,u)=>{r.push(o)}),t._read=()=>{!n&&e<r.length?t.push(r[e++]):t.push(null)},t.destroy=o=>{if(!n)return n=!0,setTimeout(()=>{t.emit("close")},0),t},t}del(t,r){let n=this._inflights.get(t.messageId);return n?(this._inflights.delete(t.messageId),r(null,n)):r&&r(new Error("missing packet")),this}get(t,r){let n=this._inflights.get(t.messageId);return n?r(null,n):r&&r(new Error("missing packet")),this}close(t){this.options.clean&&(this._inflights=null),t&&t()}};f.default=l}),Ml=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=[0,16,128,131,135,144,145,151,153],s=(a,l,t)=>{a.log("handlePublish: packet %o",l),t=typeof t<"u"?t:a.noop;let r=l.topic.toString(),n=l.payload,{qos:e}=l,{messageId:o}=l,{options:u}=a;if(a.options.protocolVersion===5){let p;if(l.properties&&(p=l.properties.topicAlias),typeof p<"u")if(r.length===0)if(p>0&&p<=65535){let d=a.topicAliasRecv.getTopicByAlias(p);if(d)r=d,a.log("handlePublish :: topic complemented by alias. topic: %s - alias: %d",r,p);else{a.log("handlePublish :: unregistered topic alias. alias: %d",p),a.emit("error",new Error("Received unregistered Topic Alias"));return}}else{a.log("handlePublish :: topic alias out of range. alias: %d",p),a.emit("error",new Error("Received Topic Alias is out of range"));return}else if(a.topicAliasRecv.put(r,p))a.log("handlePublish :: registered topic: %s - alias: %d",r,p);else{a.log("handlePublish :: topic alias out of range. alias: %d",p),a.emit("error",new Error("Received Topic Alias is out of range"));return}}switch(a.log("handlePublish: qos %d",e),e){case 2:{u.customHandleAcks(r,n,l,(p,d)=>{if(typeof p=="number"&&(d=p,p=null),p)return a.emit("error",p);if(i.indexOf(d)===-1)return a.emit("error",new Error("Wrong reason code for pubrec"));d?a._sendPacket({cmd:"pubrec",messageId:o,reasonCode:d},t):a.incomingStore.put(l,()=>{a._sendPacket({cmd:"pubrec",messageId:o},t)})});break}case 1:{u.customHandleAcks(r,n,l,(p,d)=>{if(typeof p=="number"&&(d=p,p=null),p)return a.emit("error",p);if(i.indexOf(d)===-1)return a.emit("error",new Error("Wrong reason code for puback"));d||a.emit("message",r,n,l),a.handleMessage(l,b=>{if(b)return t&&t(b);a._sendPacket({cmd:"puback",messageId:o,reasonCode:d},t)})});break}case 0:a.emit("message",r,n,l),a.handleMessage(l,t);break;default:a.log("handlePublish: unknown QoS. Doing nothing.");break}};f.default=s}),jl=de((f,i)=>{i.exports={version:"5.15.0"}}),jt=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0}),f.MQTTJS_VERSION=f.nextTick=f.ErrorWithSubackPacket=f.ErrorWithReasonCode=void 0,f.applyMixin=a;var i=class qs extends Error{code;constructor(t,r){super(t),this.code=r,Object.setPrototypeOf(this,qs.prototype),Object.getPrototypeOf(this).name="ErrorWithReasonCode"}};f.ErrorWithReasonCode=i;var s=class $s extends Error{packet;constructor(t,r){super(t),this.packet=r,Object.setPrototypeOf(this,$s.prototype),Object.getPrototypeOf(this).name="ErrorWithSubackPacket"}};f.ErrorWithSubackPacket=s;function a(l,t,r=!1){let n=[t];for(;;){let e=n[0],o=Object.getPrototypeOf(e);if(o?.prototype)n.unshift(o);else break}for(let e of n)for(let o of Object.getOwnPropertyNames(e.prototype))(r||o!=="constructor")&&Object.defineProperty(l.prototype,o,Object.getOwnPropertyDescriptor(e.prototype,o)??Object.create(null))}f.nextTick=typeof Re?.nextTick=="function"?Re.nextTick:l=>{setTimeout(l,0)},f.MQTTJS_VERSION=jl().version}),Or=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0}),f.ReasonCodes=void 0;var i=jt();f.ReasonCodes={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};var s=(a,l)=>{let{messageId:t}=l,r=l.cmd,n=null,e=a.outgoing[t]?a.outgoing[t].cb:null,o=null;if(!e){a.log("_handleAck :: Server sent an ack in error. Ignoring.");return}switch(a.log("_handleAck :: packet type",r),r){case"pubcomp":case"puback":{let u=l.reasonCode;u&&u>0&&u!==16?(o=new i.ErrorWithReasonCode(`Publish error: ${f.ReasonCodes[u]}`,u),a._removeOutgoingAndStoreMessage(t,()=>{e(o,l)})):a._removeOutgoingAndStoreMessage(t,e);break}case"pubrec":{n={cmd:"pubrel",qos:2,messageId:t};let u=l.reasonCode;u&&u>0&&u!==16?(o=new i.ErrorWithReasonCode(`Publish error: ${f.ReasonCodes[u]}`,u),a._removeOutgoingAndStoreMessage(t,()=>{e(o,l)})):a._sendPacket(n);break}case"suback":{delete a.outgoing[t],a.messageIdProvider.deallocate(t);let u=l.granted;for(let p=0;p<u.length;p++){let d=u[p];if((d&128)!==0){o=new Error(`Subscribe error: ${f.ReasonCodes[d]}`),o.code=d;let b=a.messageIdToTopic[t];b&&b.forEach(h=>{delete a._resubscribeTopics[h]})}}delete a.messageIdToTopic[t],a._invokeStoreProcessingQueue(),e(o,l);break}case"unsuback":{delete a.outgoing[t],a.messageIdProvider.deallocate(t),a._invokeStoreProcessingQueue(),e(null,l);break}default:a.emit("error",new Error("unrecognized packet type"))}a.disconnecting&&Object.keys(a.outgoing).length===0&&a.emit("outgoingEmpty")};f.default=s}),Nl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=jt(),s=Or(),a=(l,t)=>{let{options:r}=l,n=r.protocolVersion,e=n===5?t.reasonCode:t.returnCode;if(n!==5){let o=new i.ErrorWithReasonCode(`Protocol error: Auth packets are only supported in MQTT 5. Your version:${n}`,e);l.emit("error",o);return}l.handleAuth(t,(o,u)=>{if(o){l.emit("error",o);return}if(e===24)l.reconnecting=!1,l._sendPacket(u);else{let p=new i.ErrorWithReasonCode(`Connection refused: ${s.ReasonCodes[e]}`,e);l.emit("error",p)}})};f.default=a}),Ul=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0}),f.LRUCache=void 0;var i=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,s=new Set,a=typeof Re=="object"&&Re?Re:{},l=(b,h,y,m)=>{typeof a.emitWarning=="function"?a.emitWarning(b,h,y,m):console.error(`[${y}] ${h}: ${b}`)},t=globalThis.AbortController,r=globalThis.AbortSignal;if(typeof t>"u"){r=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(y,m){this._onabort.push(m)}},t=class{constructor(){h()}signal=new r;abort(y){if(!this.signal.aborted){this.signal.reason=y,this.signal.aborted=!0;for(let m of this.signal._onabort)m(y);this.signal.onabort?.(y)}}};let b=a.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",h=()=>{b&&(b=!1,l("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",h))}}var n=b=>!s.has(b),e=b=>b&&b===Math.floor(b)&&b>0&&isFinite(b),o=b=>e(b)?b<=Math.pow(2,8)?Uint8Array:b<=Math.pow(2,16)?Uint16Array:b<=Math.pow(2,32)?Uint32Array:b<=Number.MAX_SAFE_INTEGER?u:null:null,u=class extends Array{constructor(b){super(b),this.fill(0)}},p=class $t{heap;length;static#l=!1;static create(h){let y=o(h);if(!y)return[];$t.#l=!0;let m=new $t(h,y);return $t.#l=!1,m}constructor(h,y){if(!$t.#l)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new y(h),this.length=0}push(h){this.heap[this.length++]=h}pop(){return this.heap[--this.length]}},d=class Hs{#l;#h;#g;#y;#P;#R;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#i;#m;#n;#r;#e;#u;#f;#a;#o;#b;#s;#v;#w;#p;#_;#T;#c;static unsafeExposeInternals(h){return{starts:h.#w,ttls:h.#p,sizes:h.#v,keyMap:h.#n,keyList:h.#r,valList:h.#e,next:h.#u,prev:h.#f,get head(){return h.#a},get tail(){return h.#o},free:h.#b,isBackgroundFetch:y=>h.#t(y),backgroundFetch:(y,m,S,g)=>h.#j(y,m,S,g),moveToTail:y=>h.#O(y),indexes:y=>h.#S(y),rindexes:y=>h.#E(y),isStale:y=>h.#d(y)}}get max(){return this.#l}get maxSize(){return this.#h}get calculatedSize(){return this.#m}get size(){return this.#i}get fetchMethod(){return this.#P}get memoMethod(){return this.#R}get dispose(){return this.#g}get disposeAfter(){return this.#y}constructor(h){let{max:y=0,ttl:m,ttlResolution:S=1,ttlAutopurge:g,updateAgeOnGet:_,updateAgeOnHas:I,allowStale:v,dispose:A,disposeAfter:E,noDisposeOnSet:k,noUpdateTTL:C,maxSize:P=0,maxEntrySize:L=0,sizeCalculation:x,fetchMethod:q,memoMethod:D,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:ae,allowStaleOnFetchRejection:Q,allowStaleOnFetchAbort:K,ignoreFetchAbort:re}=h;if(y!==0&&!e(y))throw new TypeError("max option must be a nonnegative integer");let F=y?o(y):Array;if(!F)throw new Error("invalid max value: "+y);if(this.#l=y,this.#h=P,this.maxEntrySize=L||this.#h,this.sizeCalculation=x,this.sizeCalculation){if(!this.#h&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(D!==void 0&&typeof D!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#R=D,q!==void 0&&typeof q!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#P=q,this.#T=!!q,this.#n=new Map,this.#r=new Array(y).fill(void 0),this.#e=new Array(y).fill(void 0),this.#u=new F(y),this.#f=new F(y),this.#a=0,this.#o=0,this.#b=p.create(y),this.#i=0,this.#m=0,typeof A=="function"&&(this.#g=A),typeof E=="function"?(this.#y=E,this.#s=[]):(this.#y=void 0,this.#s=void 0),this.#_=!!this.#g,this.#c=!!this.#y,this.noDisposeOnSet=!!k,this.noUpdateTTL=!!C,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!Q,this.allowStaleOnFetchAbort=!!K,this.ignoreFetchAbort=!!re,this.maxEntrySize!==0){if(this.#h!==0&&!e(this.#h))throw new TypeError("maxSize must be a positive integer if specified");if(!e(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#W()}if(this.allowStale=!!v,this.noDeleteOnStaleGet=!!ae,this.updateAgeOnGet=!!_,this.updateAgeOnHas=!!I,this.ttlResolution=e(S)||S===0?S:1,this.ttlAutopurge=!!g,this.ttl=m||0,this.ttl){if(!e(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#N()}if(this.#l===0&&this.ttl===0&&this.#h===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#l&&!this.#h){let Z="LRU_CACHE_UNBOUNDED";n(Z)&&(s.add(Z),l("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Z,Hs))}}getRemainingTTL(h){return this.#n.has(h)?1/0:0}#N(){let h=new u(this.#l),y=new u(this.#l);this.#p=h,this.#w=y,this.#U=(g,_,I=i.now())=>{if(y[g]=_!==0?I:0,h[g]=_,_!==0&&this.ttlAutopurge){let v=setTimeout(()=>{this.#d(g)&&this.#A(this.#r[g],"expire")},_+1);v.unref&&v.unref()}},this.#k=g=>{y[g]=h[g]!==0?i.now():0},this.#I=(g,_)=>{if(h[_]){let I=h[_],v=y[_];if(!I||!v)return;g.ttl=I,g.start=v,g.now=m||S();let A=g.now-v;g.remainingTTL=I-A}};let m=0,S=()=>{let g=i.now();if(this.ttlResolution>0){m=g;let _=setTimeout(()=>m=0,this.ttlResolution);_.unref&&_.unref()}return g};this.getRemainingTTL=g=>{let _=this.#n.get(g);if(_===void 0)return 0;let I=h[_],v=y[_];if(!I||!v)return 1/0;let A=(m||S())-v;return I-A},this.#d=g=>{let _=y[g],I=h[g];return!!I&&!!_&&(m||S())-_>I}}#k=()=>{};#I=()=>{};#U=()=>{};#d=()=>!1;#W(){let h=new u(this.#l);this.#m=0,this.#v=h,this.#x=y=>{this.#m-=h[y],h[y]=0},this.#B=(y,m,S,g)=>{if(this.#t(m))return 0;if(!e(S))if(g){if(typeof g!="function")throw new TypeError("sizeCalculation must be a function");if(S=g(m,y),!e(S))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return S},this.#C=(y,m,S)=>{if(h[y]=m,this.#h){let g=this.#h-h[y];for(;this.#m>g;)this.#M(!0)}this.#m+=h[y],S&&(S.entrySize=m,S.totalCalculatedSize=this.#m)}}#x=h=>{};#C=(h,y,m)=>{};#B=(h,y,m,S)=>{if(m||S)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#S({allowStale:h=this.allowStale}={}){if(this.#i)for(let y=this.#o;!(!this.#L(y)||((h||!this.#d(y))&&(yield y),y===this.#a));)y=this.#f[y]}*#E({allowStale:h=this.allowStale}={}){if(this.#i)for(let y=this.#a;!(!this.#L(y)||((h||!this.#d(y))&&(yield y),y===this.#o));)y=this.#u[y]}#L(h){return h!==void 0&&this.#n.get(this.#r[h])===h}*entries(){for(let h of this.#S())this.#e[h]!==void 0&&this.#r[h]!==void 0&&!this.#t(this.#e[h])&&(yield[this.#r[h],this.#e[h]])}*rentries(){for(let h of this.#E())this.#e[h]!==void 0&&this.#r[h]!==void 0&&!this.#t(this.#e[h])&&(yield[this.#r[h],this.#e[h]])}*keys(){for(let h of this.#S()){let y=this.#r[h];y!==void 0&&!this.#t(this.#e[h])&&(yield y)}}*rkeys(){for(let h of this.#E()){let y=this.#r[h];y!==void 0&&!this.#t(this.#e[h])&&(yield y)}}*values(){for(let h of this.#S())this.#e[h]!==void 0&&!this.#t(this.#e[h])&&(yield this.#e[h])}*rvalues(){for(let h of this.#E())this.#e[h]!==void 0&&!this.#t(this.#e[h])&&(yield this.#e[h])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(h,y={}){for(let m of this.#S()){let S=this.#e[m],g=this.#t(S)?S.__staleWhileFetching:S;if(g!==void 0&&h(g,this.#r[m],this))return this.get(this.#r[m],y)}}forEach(h,y=this){for(let m of this.#S()){let S=this.#e[m],g=this.#t(S)?S.__staleWhileFetching:S;g!==void 0&&h.call(y,g,this.#r[m],this)}}rforEach(h,y=this){for(let m of this.#E()){let S=this.#e[m],g=this.#t(S)?S.__staleWhileFetching:S;g!==void 0&&h.call(y,g,this.#r[m],this)}}purgeStale(){let h=!1;for(let y of this.#E({allowStale:!0}))this.#d(y)&&(this.#A(this.#r[y],"expire"),h=!0);return h}info(h){let y=this.#n.get(h);if(y===void 0)return;let m=this.#e[y],S=this.#t(m)?m.__staleWhileFetching:m;if(S===void 0)return;let g={value:S};if(this.#p&&this.#w){let _=this.#p[y],I=this.#w[y];if(_&&I){let v=_-(i.now()-I);g.ttl=v,g.start=Date.now()}}return this.#v&&(g.size=this.#v[y]),g}dump(){let h=[];for(let y of this.#S({allowStale:!0})){let m=this.#r[y],S=this.#e[y],g=this.#t(S)?S.__staleWhileFetching:S;if(g===void 0||m===void 0)continue;let _={value:g};if(this.#p&&this.#w){_.ttl=this.#p[y];let I=i.now()-this.#w[y];_.start=Math.floor(Date.now()-I)}this.#v&&(_.size=this.#v[y]),h.unshift([m,_])}return h}load(h){this.clear();for(let[y,m]of h){if(m.start){let S=Date.now()-m.start;m.start=i.now()-S}this.set(y,m.value,m)}}set(h,y,m={}){if(y===void 0)return this.delete(h),this;let{ttl:S=this.ttl,start:g,noDisposeOnSet:_=this.noDisposeOnSet,sizeCalculation:I=this.sizeCalculation,status:v}=m,{noUpdateTTL:A=this.noUpdateTTL}=m,E=this.#B(h,y,m.size||0,I);if(this.maxEntrySize&&E>this.maxEntrySize)return v&&(v.set="miss",v.maxEntrySizeExceeded=!0),this.#A(h,"set"),this;let k=this.#i===0?void 0:this.#n.get(h);if(k===void 0)k=this.#i===0?this.#o:this.#b.length!==0?this.#b.pop():this.#i===this.#l?this.#M(!1):this.#i,this.#r[k]=h,this.#e[k]=y,this.#n.set(h,k),this.#u[this.#o]=k,this.#f[k]=this.#o,this.#o=k,this.#i++,this.#C(k,E,v),v&&(v.set="add"),A=!1;else{this.#O(k);let C=this.#e[k];if(y!==C){if(this.#T&&this.#t(C)){C.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:P}=C;P!==void 0&&!_&&(this.#_&&this.#g?.(P,h,"set"),this.#c&&this.#s?.push([P,h,"set"]))}else _||(this.#_&&this.#g?.(C,h,"set"),this.#c&&this.#s?.push([C,h,"set"]));if(this.#x(k),this.#C(k,E,v),this.#e[k]=y,v){v.set="replace";let P=C&&this.#t(C)?C.__staleWhileFetching:C;P!==void 0&&(v.oldValue=P)}}else v&&(v.set="update")}if(S!==0&&!this.#p&&this.#N(),this.#p&&(A||this.#U(k,S,g),v&&this.#I(v,k)),!_&&this.#c&&this.#s){let C=this.#s,P;for(;P=C?.shift();)this.#y?.(...P)}return this}pop(){try{for(;this.#i;){let h=this.#e[this.#a];if(this.#M(!0),this.#t(h)){if(h.__staleWhileFetching)return h.__staleWhileFetching}else if(h!==void 0)return h}}finally{if(this.#c&&this.#s){let h=this.#s,y;for(;y=h?.shift();)this.#y?.(...y)}}}#M(h){let y=this.#a,m=this.#r[y],S=this.#e[y];return this.#T&&this.#t(S)?S.__abortController.abort(new Error("evicted")):(this.#_||this.#c)&&(this.#_&&this.#g?.(S,m,"evict"),this.#c&&this.#s?.push([S,m,"evict"])),this.#x(y),h&&(this.#r[y]=void 0,this.#e[y]=void 0,this.#b.push(y)),this.#i===1?(this.#a=this.#o=0,this.#b.length=0):this.#a=this.#u[y],this.#n.delete(m),this.#i--,y}has(h,y={}){let{updateAgeOnHas:m=this.updateAgeOnHas,status:S}=y,g=this.#n.get(h);if(g!==void 0){let _=this.#e[g];if(this.#t(_)&&_.__staleWhileFetching===void 0)return!1;if(this.#d(g))S&&(S.has="stale",this.#I(S,g));else return m&&this.#k(g),S&&(S.has="hit",this.#I(S,g)),!0}else S&&(S.has="miss");return!1}peek(h,y={}){let{allowStale:m=this.allowStale}=y,S=this.#n.get(h);if(S===void 0||!m&&this.#d(S))return;let g=this.#e[S];return this.#t(g)?g.__staleWhileFetching:g}#j(h,y,m,S){let g=y===void 0?void 0:this.#e[y];if(this.#t(g))return g;let _=new t,{signal:I}=m;I?.addEventListener("abort",()=>_.abort(I.reason),{signal:_.signal});let v={signal:_.signal,options:m,context:S},A=(x,q=!1)=>{let{aborted:D}=_.signal,U=m.ignoreFetchAbort&&x!==void 0;if(m.status&&(D&&!q?(m.status.fetchAborted=!0,m.status.fetchError=_.signal.reason,U&&(m.status.fetchAbortIgnored=!0)):m.status.fetchResolved=!0),D&&!U&&!q)return k(_.signal.reason);let ae=P;return this.#e[y]===P&&(x===void 0?ae.__staleWhileFetching?this.#e[y]=ae.__staleWhileFetching:this.#A(h,"fetch"):(m.status&&(m.status.fetchUpdated=!0),this.set(h,x,v.options))),x},E=x=>(m.status&&(m.status.fetchRejected=!0,m.status.fetchError=x),k(x)),k=x=>{let{aborted:q}=_.signal,D=q&&m.allowStaleOnFetchAbort,U=D||m.allowStaleOnFetchRejection,ae=U||m.noDeleteOnFetchRejection,Q=P;if(this.#e[y]===P&&(!ae||Q.__staleWhileFetching===void 0?this.#A(h,"fetch"):D||(this.#e[y]=Q.__staleWhileFetching)),U)return m.status&&Q.__staleWhileFetching!==void 0&&(m.status.returnedStale=!0),Q.__staleWhileFetching;if(Q.__returned===Q)throw x},C=(x,q)=>{let D=this.#P?.(h,g,v);D&&D instanceof Promise&&D.then(U=>x(U===void 0?void 0:U),q),_.signal.addEventListener("abort",()=>{(!m.ignoreFetchAbort||m.allowStaleOnFetchAbort)&&(x(void 0),m.allowStaleOnFetchAbort&&(x=U=>A(U,!0)))})};m.status&&(m.status.fetchDispatched=!0);let P=new Promise(C).then(A,E),L=Object.assign(P,{__abortController:_,__staleWhileFetching:g,__returned:void 0});return y===void 0?(this.set(h,L,{...v.options,status:void 0}),y=this.#n.get(h)):this.#e[y]=L,L}#t(h){if(!this.#T)return!1;let y=h;return!!y&&y instanceof Promise&&y.hasOwnProperty("__staleWhileFetching")&&y.__abortController instanceof t}async fetch(h,y={}){let{allowStale:m=this.allowStale,updateAgeOnGet:S=this.updateAgeOnGet,noDeleteOnStaleGet:g=this.noDeleteOnStaleGet,ttl:_=this.ttl,noDisposeOnSet:I=this.noDisposeOnSet,size:v=0,sizeCalculation:A=this.sizeCalculation,noUpdateTTL:E=this.noUpdateTTL,noDeleteOnFetchRejection:k=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:C=this.allowStaleOnFetchRejection,ignoreFetchAbort:P=this.ignoreFetchAbort,allowStaleOnFetchAbort:L=this.allowStaleOnFetchAbort,context:x,forceRefresh:q=!1,status:D,signal:U}=y;if(!this.#T)return D&&(D.fetch="get"),this.get(h,{allowStale:m,updateAgeOnGet:S,noDeleteOnStaleGet:g,status:D});let ae={allowStale:m,updateAgeOnGet:S,noDeleteOnStaleGet:g,ttl:_,noDisposeOnSet:I,size:v,sizeCalculation:A,noUpdateTTL:E,noDeleteOnFetchRejection:k,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:L,ignoreFetchAbort:P,status:D,signal:U},Q=this.#n.get(h);if(Q===void 0){D&&(D.fetch="miss");let K=this.#j(h,Q,ae,x);return K.__returned=K}else{let K=this.#e[Q];if(this.#t(K)){let R=m&&K.__staleWhileFetching!==void 0;return D&&(D.fetch="inflight",R&&(D.returnedStale=!0)),R?K.__staleWhileFetching:K.__returned=K}let re=this.#d(Q);if(!q&&!re)return D&&(D.fetch="hit"),this.#O(Q),S&&this.#k(Q),D&&this.#I(D,Q),K;let F=this.#j(h,Q,ae,x),Z=F.__staleWhileFetching!==void 0&&m;return D&&(D.fetch=re?"stale":"refresh",Z&&re&&(D.returnedStale=!0)),Z?F.__staleWhileFetching:F.__returned=F}}async forceFetch(h,y={}){let m=await this.fetch(h,y);if(m===void 0)throw new Error("fetch() returned undefined");return m}memo(h,y={}){let m=this.#R;if(!m)throw new Error("no memoMethod provided to constructor");let{context:S,forceRefresh:g,..._}=y,I=this.get(h,_);if(!g&&I!==void 0)return I;let v=m(h,I,{options:_,context:S});return this.set(h,v,_),v}get(h,y={}){let{allowStale:m=this.allowStale,updateAgeOnGet:S=this.updateAgeOnGet,noDeleteOnStaleGet:g=this.noDeleteOnStaleGet,status:_}=y,I=this.#n.get(h);if(I!==void 0){let v=this.#e[I],A=this.#t(v);return _&&this.#I(_,I),this.#d(I)?(_&&(_.get="stale"),A?(_&&m&&v.__staleWhileFetching!==void 0&&(_.returnedStale=!0),m?v.__staleWhileFetching:void 0):(g||this.#A(h,"expire"),_&&m&&(_.returnedStale=!0),m?v:void 0)):(_&&(_.get="hit"),A?v.__staleWhileFetching:(this.#O(I),S&&this.#k(I),v))}else _&&(_.get="miss")}#D(h,y){this.#f[y]=h,this.#u[h]=y}#O(h){h!==this.#o&&(h===this.#a?this.#a=this.#u[h]:this.#D(this.#f[h],this.#u[h]),this.#D(this.#o,h),this.#o=h)}delete(h){return this.#A(h,"delete")}#A(h,y){let m=!1;if(this.#i!==0){let S=this.#n.get(h);if(S!==void 0)if(m=!0,this.#i===1)this.#F(y);else{this.#x(S);let g=this.#e[S];if(this.#t(g)?g.__abortController.abort(new Error("deleted")):(this.#_||this.#c)&&(this.#_&&this.#g?.(g,h,y),this.#c&&this.#s?.push([g,h,y])),this.#n.delete(h),this.#r[S]=void 0,this.#e[S]=void 0,S===this.#o)this.#o=this.#f[S];else if(S===this.#a)this.#a=this.#u[S];else{let _=this.#f[S];this.#u[_]=this.#u[S];let I=this.#u[S];this.#f[I]=this.#f[S]}this.#i--,this.#b.push(S)}}if(this.#c&&this.#s?.length){let S=this.#s,g;for(;g=S?.shift();)this.#y?.(...g)}return m}clear(){return this.#F("delete")}#F(h){for(let y of this.#E({allowStale:!0})){let m=this.#e[y];if(this.#t(m))m.__abortController.abort(new Error("deleted"));else{let S=this.#r[y];this.#_&&this.#g?.(m,S,h),this.#c&&this.#s?.push([m,S,h])}}if(this.#n.clear(),this.#e.fill(void 0),this.#r.fill(void 0),this.#p&&this.#w&&(this.#p.fill(0),this.#w.fill(0)),this.#v&&this.#v.fill(0),this.#a=0,this.#o=0,this.#b.length=0,this.#m=0,this.#i=0,this.#c&&this.#s){let y=this.#s,m;for(;m=y?.shift();)this.#y?.(...m)}}};f.LRUCache=d}),ut=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.ContainerIterator=f.Container=f.Base=void 0;var i=class{constructor(l=0){this.iteratorType=l}equals(l){return this.o===l.o}};f.ContainerIterator=i;var s=class{constructor(){this.i=0}get length(){return this.i}size(){return this.i}empty(){return this.i===0}};f.Base=s;var a=class extends s{};f.Container=a}),Bl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=ut(),s=class extends i.Base{constructor(l=[]){super(),this.S=[];let t=this;l.forEach(function(r){t.push(r)})}clear(){this.i=0,this.S=[]}push(l){return this.S.push(l),this.i+=1,this.i}pop(){if(this.i!==0)return this.i-=1,this.S.pop()}top(){return this.S[this.i-1]}},a=s;f.default=a}),Ll=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=ut(),s=class extends i.Base{constructor(l=[]){super(),this.j=0,this.q=[];let t=this;l.forEach(function(r){t.push(r)})}clear(){this.q=[],this.i=this.j=0}push(l){let t=this.q.length;if(this.j/t>.5&&this.j+this.i>=t&&t>4096){let r=this.i;for(let n=0;n<r;++n)this.q[n]=this.q[this.j+n];this.j=0,this.q[this.i]=l}else this.q[this.j+this.i]=l;return++this.i}pop(){if(this.i===0)return;let l=this.q[this.j++];return this.i-=1,l}front(){if(this.i!==0)return this.q[this.j]}},a=s;f.default=a}),Dl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=ut(),s=class extends i.Base{constructor(l=[],t=function(n,e){return n>e?-1:n<e?1:0},r=!0){if(super(),this.v=t,Array.isArray(l))this.C=r?[...l]:l;else{this.C=[];let e=this;l.forEach(function(o){e.C.push(o)})}this.i=this.C.length;let n=this.i>>1;for(let e=this.i-1>>1;e>=0;--e)this.k(e,n)}m(l){let t=this.C[l];for(;l>0;){let r=l-1>>1,n=this.C[r];if(this.v(n,t)<=0)break;this.C[l]=n,l=r}this.C[l]=t}k(l,t){let r=this.C[l];for(;l<t;){let n=l<<1|1,e=n+1,o=this.C[n];if(e<this.i&&this.v(o,this.C[e])>0&&(n=e,o=this.C[e]),this.v(o,r)>=0)break;this.C[l]=o,l=n}this.C[l]=r}clear(){this.i=0,this.C.length=0}push(l){this.C.push(l),this.m(this.i),this.i+=1}pop(){if(this.i===0)return;let l=this.C[0],t=this.C.pop();return this.i-=1,this.i&&(this.C[0]=t,this.k(0,this.i>>1)),l}top(){return this.C[0]}find(l){return this.C.indexOf(l)>=0}remove(l){let t=this.C.indexOf(l);return t<0?!1:(t===0?this.pop():t===this.i-1?(this.C.pop(),this.i-=1):(this.C.splice(t,1,this.C.pop()),this.i-=1,this.m(t),this.k(t,this.i>>1)),!0)}updateItem(l){let t=this.C.indexOf(l);return t<0?!1:(this.m(t),this.k(t,this.i>>1),!0)}toArray(){return[...this.C]}},a=s;f.default=a}),qi=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=ut(),s=class extends i.Container{},a=s;f.default=a}),ct=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.throwIteratorAccessError=i;function i(){throw new RangeError("Iterator access denied!")}}),zs=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.RandomIterator=void 0;var i=ut(),s=ct(),a=class extends i.ContainerIterator{constructor(l,t){super(t),this.o=l,this.iteratorType===0?(this.pre=function(){return this.o===0&&(0,s.throwIteratorAccessError)(),this.o-=1,this},this.next=function(){return this.o===this.container.size()&&(0,s.throwIteratorAccessError)(),this.o+=1,this}):(this.pre=function(){return this.o===this.container.size()-1&&(0,s.throwIteratorAccessError)(),this.o+=1,this},this.next=function(){return this.o===-1&&(0,s.throwIteratorAccessError)(),this.o-=1,this})}get pointer(){return this.container.getElementByPos(this.o)}set pointer(l){this.container.setElementByPos(this.o,l)}};f.RandomIterator=a}),Fl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=a(qi()),s=zs();function a(n){return n&&n.t?n:{default:n}}var l=class Ks extends s.RandomIterator{constructor(e,o,u){super(e,u),this.container=o}copy(){return new Ks(this.o,this.container,this.iteratorType)}},t=class extends i.default{constructor(n=[],e=!0){if(super(),Array.isArray(n))this.J=e?[...n]:n,this.i=n.length;else{this.J=[];let o=this;n.forEach(function(u){o.pushBack(u)})}}clear(){this.i=0,this.J.length=0}begin(){return new l(0,this)}end(){return new l(this.i,this)}rBegin(){return new l(this.i-1,this,1)}rEnd(){return new l(-1,this,1)}front(){return this.J[0]}back(){return this.J[this.i-1]}getElementByPos(n){if(n<0||n>this.i-1)throw new RangeError;return this.J[n]}eraseElementByPos(n){if(n<0||n>this.i-1)throw new RangeError;return this.J.splice(n,1),this.i-=1,this.i}eraseElementByValue(n){let e=0;for(let o=0;o<this.i;++o)this.J[o]!==n&&(this.J[e++]=this.J[o]);return this.i=this.J.length=e,this.i}eraseElementByIterator(n){let e=n.o;return n=n.next(),this.eraseElementByPos(e),n}pushBack(n){return this.J.push(n),this.i+=1,this.i}popBack(){if(this.i!==0)return this.i-=1,this.J.pop()}setElementByPos(n,e){if(n<0||n>this.i-1)throw new RangeError;this.J[n]=e}insert(n,e,o=1){if(n<0||n>this.i)throw new RangeError;return this.J.splice(n,0,...new Array(o).fill(e)),this.i+=o,this.i}find(n){for(let e=0;e<this.i;++e)if(this.J[e]===n)return new l(e,this);return this.end()}reverse(){this.J.reverse()}unique(){let n=1;for(let e=1;e<this.i;++e)this.J[e]!==this.J[e-1]&&(this.J[n++]=this.J[e]);return this.i=this.J.length=n,this.i}sort(n){this.J.sort(n)}forEach(n){for(let e=0;e<this.i;++e)n(this.J[e],e,this)}[Symbol.iterator](){return(function*(){yield*this.J}).bind(this)()}},r=t;f.default=r}),Wl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=l(qi()),s=ut(),a=ct();function l(e){return e&&e.t?e:{default:e}}var t=class Vs extends s.ContainerIterator{constructor(o,u,p,d){super(d),this.o=o,this.h=u,this.container=p,this.iteratorType===0?(this.pre=function(){return this.o.L===this.h&&(0,a.throwIteratorAccessError)(),this.o=this.o.L,this},this.next=function(){return this.o===this.h&&(0,a.throwIteratorAccessError)(),this.o=this.o.B,this}):(this.pre=function(){return this.o.B===this.h&&(0,a.throwIteratorAccessError)(),this.o=this.o.B,this},this.next=function(){return this.o===this.h&&(0,a.throwIteratorAccessError)(),this.o=this.o.L,this})}get pointer(){return this.o===this.h&&(0,a.throwIteratorAccessError)(),this.o.l}set pointer(o){this.o===this.h&&(0,a.throwIteratorAccessError)(),this.o.l=o}copy(){return new Vs(this.o,this.h,this.container,this.iteratorType)}},r=class extends i.default{constructor(e=[]){super(),this.h={},this.p=this._=this.h.L=this.h.B=this.h;let o=this;e.forEach(function(u){o.pushBack(u)})}V(e){let{L:o,B:u}=e;o.B=u,u.L=o,e===this.p&&(this.p=u),e===this._&&(this._=o),this.i-=1}G(e,o){let u=o.B,p={l:e,L:o,B:u};o.B=p,u.L=p,o===this.h&&(this.p=p),u===this.h&&(this._=p),this.i+=1}clear(){this.i=0,this.p=this._=this.h.L=this.h.B=this.h}begin(){return new t(this.p,this.h,this)}end(){return new t(this.h,this.h,this)}rBegin(){return new t(this._,this.h,this,1)}rEnd(){return new t(this.h,this.h,this,1)}front(){return this.p.l}back(){return this._.l}getElementByPos(e){if(e<0||e>this.i-1)throw new RangeError;let o=this.p;for(;e--;)o=o.B;return o.l}eraseElementByPos(e){if(e<0||e>this.i-1)throw new RangeError;let o=this.p;for(;e--;)o=o.B;return this.V(o),this.i}eraseElementByValue(e){let o=this.p;for(;o!==this.h;)o.l===e&&this.V(o),o=o.B;return this.i}eraseElementByIterator(e){let o=e.o;return o===this.h&&(0,a.throwIteratorAccessError)(),e=e.next(),this.V(o),e}pushBack(e){return this.G(e,this._),this.i}popBack(){if(this.i===0)return;let e=this._.l;return this.V(this._),e}pushFront(e){return this.G(e,this.h),this.i}popFront(){if(this.i===0)return;let e=this.p.l;return this.V(this.p),e}setElementByPos(e,o){if(e<0||e>this.i-1)throw new RangeError;let u=this.p;for(;e--;)u=u.B;u.l=o}insert(e,o,u=1){if(e<0||e>this.i)throw new RangeError;if(u<=0)return this.i;if(e===0)for(;u--;)this.pushFront(o);else if(e===this.i)for(;u--;)this.pushBack(o);else{let p=this.p;for(let b=1;b<e;++b)p=p.B;let d=p.B;for(this.i+=u;u--;)p.B={l:o,L:p},p.B.L=p,p=p.B;p.B=d,d.L=p}return this.i}find(e){let o=this.p;for(;o!==this.h;){if(o.l===e)return new t(o,this.h,this);o=o.B}return this.end()}reverse(){if(this.i<=1)return;let e=this.p,o=this._,u=0;for(;u<<1<this.i;){let p=e.l;e.l=o.l,o.l=p,e=e.B,o=o.L,u+=1}}unique(){if(this.i<=1)return this.i;let e=this.p;for(;e!==this.h;){let o=e;for(;o.B!==this.h&&o.l===o.B.l;)o=o.B,this.i-=1;e.B=o.B,e.B.L=e,e=e.B}return this.i}sort(e){if(this.i<=1)return;let o=[];this.forEach(function(p){o.push(p)}),o.sort(e);let u=this.p;o.forEach(function(p){u.l=p,u=u.B})}merge(e){let o=this;if(this.i===0)e.forEach(function(u){o.pushBack(u)});else{let u=this.p;e.forEach(function(p){for(;u!==o.h&&u.l<=p;)u=u.B;o.G(p,u.L)})}return this.i}forEach(e){let o=this.p,u=0;for(;o!==this.h;)e(o.l,u++,this),o=o.B}[Symbol.iterator](){return(function*(){if(this.i===0)return;let e=this.p;for(;e!==this.h;)yield e.l,e=e.B}).bind(this)()}},n=r;f.default=n}),ql=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=a(qi()),s=zs();function a(n){return n&&n.t?n:{default:n}}var l=class Gs extends s.RandomIterator{constructor(e,o,u){super(e,u),this.container=o}copy(){return new Gs(this.o,this.container,this.iteratorType)}},t=class extends i.default{constructor(n=[],e=4096){super(),this.j=0,this.D=0,this.R=0,this.N=0,this.P=0,this.A=[];let o=(()=>{if(typeof n.length=="number")return n.length;if(typeof n.size=="number")return n.size;if(typeof n.size=="function")return n.size();throw new TypeError("Cannot get the length or size of the container")})();this.F=e,this.P=Math.max(Math.ceil(o/this.F),1);for(let d=0;d<this.P;++d)this.A.push(new Array(this.F));let u=Math.ceil(o/this.F);this.j=this.R=(this.P>>1)-(u>>1),this.D=this.N=this.F-o%this.F>>1;let p=this;n.forEach(function(d){p.pushBack(d)})}T(){let n=[],e=Math.max(this.P>>1,1);for(let o=0;o<e;++o)n[o]=new Array(this.F);for(let o=this.j;o<this.P;++o)n[n.length]=this.A[o];for(let o=0;o<this.R;++o)n[n.length]=this.A[o];n[n.length]=[...this.A[this.R]],this.j=e,this.R=n.length-1;for(let o=0;o<e;++o)n[n.length]=new Array(this.F);this.A=n,this.P=n.length}O(n){let e=this.D+n+1,o=e%this.F,u=o-1,p=this.j+(e-o)/this.F;return o===0&&(p-=1),p%=this.P,u<0&&(u+=this.F),{curNodeBucketIndex:p,curNodePointerIndex:u}}clear(){this.A=[new Array(this.F)],this.P=1,this.j=this.R=this.i=0,this.D=this.N=this.F>>1}begin(){return new l(0,this)}end(){return new l(this.i,this)}rBegin(){return new l(this.i-1,this,1)}rEnd(){return new l(-1,this,1)}front(){if(this.i!==0)return this.A[this.j][this.D]}back(){if(this.i!==0)return this.A[this.R][this.N]}pushBack(n){return this.i&&(this.N<this.F-1?this.N+=1:this.R<this.P-1?(this.R+=1,this.N=0):(this.R=0,this.N=0),this.R===this.j&&this.N===this.D&&this.T()),this.i+=1,this.A[this.R][this.N]=n,this.i}popBack(){if(this.i===0)return;let n=this.A[this.R][this.N];return this.i!==1&&(this.N>0?this.N-=1:this.R>0?(this.R-=1,this.N=this.F-1):(this.R=this.P-1,this.N=this.F-1)),this.i-=1,n}pushFront(n){return this.i&&(this.D>0?this.D-=1:this.j>0?(this.j-=1,this.D=this.F-1):(this.j=this.P-1,this.D=this.F-1),this.j===this.R&&this.D===this.N&&this.T()),this.i+=1,this.A[this.j][this.D]=n,this.i}popFront(){if(this.i===0)return;let n=this.A[this.j][this.D];return this.i!==1&&(this.D<this.F-1?this.D+=1:this.j<this.P-1?(this.j+=1,this.D=0):(this.j=0,this.D=0)),this.i-=1,n}getElementByPos(n){if(n<0||n>this.i-1)throw new RangeError;let{curNodeBucketIndex:e,curNodePointerIndex:o}=this.O(n);return this.A[e][o]}setElementByPos(n,e){if(n<0||n>this.i-1)throw new RangeError;let{curNodeBucketIndex:o,curNodePointerIndex:u}=this.O(n);this.A[o][u]=e}insert(n,e,o=1){if(n<0||n>this.i)throw new RangeError;if(n===0)for(;o--;)this.pushFront(e);else if(n===this.i)for(;o--;)this.pushBack(e);else{let u=[];for(let p=n;p<this.i;++p)u.push(this.getElementByPos(p));this.cut(n-1);for(let p=0;p<o;++p)this.pushBack(e);for(let p=0;p<u.length;++p)this.pushBack(u[p])}return this.i}cut(n){if(n<0)return this.clear(),0;let{curNodeBucketIndex:e,curNodePointerIndex:o}=this.O(n);return this.R=e,this.N=o,this.i=n+1,this.i}eraseElementByPos(n){if(n<0||n>this.i-1)throw new RangeError;if(n===0)this.popFront();else if(n===this.i-1)this.popBack();else{let e=[];for(let u=n+1;u<this.i;++u)e.push(this.getElementByPos(u));this.cut(n),this.popBack();let o=this;e.forEach(function(u){o.pushBack(u)})}return this.i}eraseElementByValue(n){if(this.i===0)return 0;let e=[];for(let u=0;u<this.i;++u){let p=this.getElementByPos(u);p!==n&&e.push(p)}let o=e.length;for(let u=0;u<o;++u)this.setElementByPos(u,e[u]);return this.cut(o-1)}eraseElementByIterator(n){let e=n.o;return this.eraseElementByPos(e),n=n.next(),n}find(n){for(let e=0;e<this.i;++e)if(this.getElementByPos(e)===n)return new l(e,this);return this.end()}reverse(){let n=0,e=this.i-1;for(;n<e;){let o=this.getElementByPos(n);this.setElementByPos(n,this.getElementByPos(e)),this.setElementByPos(e,o),n+=1,e-=1}}unique(){if(this.i<=1)return this.i;let n=1,e=this.getElementByPos(0);for(let o=1;o<this.i;++o){let u=this.getElementByPos(o);u!==e&&(e=u,this.setElementByPos(n++,u))}for(;this.i>n;)this.popBack();return this.i}sort(n){let e=[];for(let o=0;o<this.i;++o)e.push(this.getElementByPos(o));e.sort(n);for(let o=0;o<this.i;++o)this.setElementByPos(o,e[o])}shrinkToFit(){if(this.i===0)return;let n=[];this.forEach(function(e){n.push(e)}),this.P=Math.max(Math.ceil(this.i/this.F),1),this.i=this.j=this.R=this.D=this.N=0,this.A=[];for(let e=0;e<this.P;++e)this.A.push(new Array(this.F));for(let e=0;e<n.length;++e)this.pushBack(n[e])}forEach(n){for(let e=0;e<this.i;++e)n(this.getElementByPos(e),e,this)}[Symbol.iterator](){return(function*(){for(let n=0;n<this.i;++n)yield this.getElementByPos(n)}).bind(this)()}},r=t;f.default=r}),$l=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.TreeNodeEnableIndex=f.TreeNode=void 0;var i=class{constructor(a,l){this.ee=1,this.u=void 0,this.l=void 0,this.U=void 0,this.W=void 0,this.tt=void 0,this.u=a,this.l=l}L(){let a=this;if(a.ee===1&&a.tt.tt===a)a=a.W;else if(a.U)for(a=a.U;a.W;)a=a.W;else{let l=a.tt;for(;l.U===a;)a=l,l=a.tt;a=l}return a}B(){let a=this;if(a.W){for(a=a.W;a.U;)a=a.U;return a}else{let l=a.tt;for(;l.W===a;)a=l,l=a.tt;return a.W!==l?l:a}}te(){let a=this.tt,l=this.W,t=l.U;return a.tt===this?a.tt=l:a.U===this?a.U=l:a.W=l,l.tt=a,l.U=this,this.tt=l,this.W=t,t&&(t.tt=this),l}se(){let a=this.tt,l=this.U,t=l.W;return a.tt===this?a.tt=l:a.U===this?a.U=l:a.W=l,l.tt=a,l.W=this,this.tt=l,this.U=t,t&&(t.tt=this),l}};f.TreeNode=i;var s=class extends i{constructor(){super(...arguments),this.rt=1}te(){let a=super.te();return this.ie(),a.ie(),a}se(){let a=super.se();return this.ie(),a.ie(),a}ie(){this.rt=1,this.U&&(this.rt+=this.U.rt),this.W&&(this.rt+=this.W.rt)}};f.TreeNodeEnableIndex=s}),Qs=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=$l(),s=ut(),a=ct(),l=class extends s.Container{constructor(r=function(e,o){return e<o?-1:e>o?1:0},n=!1){super(),this.Y=void 0,this.v=r,n?(this.re=i.TreeNodeEnableIndex,this.M=function(e,o,u){let p=this.ne(e,o,u);if(p){let d=p.tt;for(;d!==this.h;)d.rt+=1,d=d.tt;let b=this.he(p);if(b){let{parentNode:h,grandParent:y,curNode:m}=b;h.ie(),y.ie(),m.ie()}}return this.i},this.V=function(e){let o=this.fe(e);for(;o!==this.h;)o.rt-=1,o=o.tt}):(this.re=i.TreeNode,this.M=function(e,o,u){let p=this.ne(e,o,u);return p&&this.he(p),this.i},this.V=this.fe),this.h=new this.re}X(r,n){let e=this.h;for(;r;){let o=this.v(r.u,n);if(o<0)r=r.W;else if(o>0)e=r,r=r.U;else return r}return e}Z(r,n){let e=this.h;for(;r;)this.v(r.u,n)<=0?r=r.W:(e=r,r=r.U);return e}$(r,n){let e=this.h;for(;r;){let o=this.v(r.u,n);if(o<0)e=r,r=r.W;else if(o>0)r=r.U;else return r}return e}rr(r,n){let e=this.h;for(;r;)this.v(r.u,n)<0?(e=r,r=r.W):r=r.U;return e}ue(r){for(;;){let n=r.tt;if(n===this.h)return;if(r.ee===1){r.ee=0;return}if(r===n.U){let e=n.W;if(e.ee===1)e.ee=0,n.ee=1,n===this.Y?this.Y=n.te():n.te();else if(e.W&&e.W.ee===1){e.ee=n.ee,n.ee=0,e.W.ee=0,n===this.Y?this.Y=n.te():n.te();return}else e.U&&e.U.ee===1?(e.ee=1,e.U.ee=0,e.se()):(e.ee=1,r=n)}else{let e=n.U;if(e.ee===1)e.ee=0,n.ee=1,n===this.Y?this.Y=n.se():n.se();else if(e.U&&e.U.ee===1){e.ee=n.ee,n.ee=0,e.U.ee=0,n===this.Y?this.Y=n.se():n.se();return}else e.W&&e.W.ee===1?(e.ee=1,e.W.ee=0,e.te()):(e.ee=1,r=n)}}}fe(r){if(this.i===1)return this.clear(),this.h;let n=r;for(;n.U||n.W;){if(n.W)for(n=n.W;n.U;)n=n.U;else n=n.U;[r.u,n.u]=[n.u,r.u],[r.l,n.l]=[n.l,r.l],r=n}this.h.U===n?this.h.U=n.tt:this.h.W===n&&(this.h.W=n.tt),this.ue(n);let e=n.tt;return n===e.U?e.U=void 0:e.W=void 0,this.i-=1,this.Y.ee=0,e}oe(r,n){return r===void 0?!1:this.oe(r.U,n)||n(r)?!0:this.oe(r.W,n)}he(r){for(;;){let n=r.tt;if(n.ee===0)return;let e=n.tt;if(n===e.U){let o=e.W;if(o&&o.ee===1){if(o.ee=n.ee=0,e===this.Y)return;e.ee=1,r=e;continue}else if(r===n.W){if(r.ee=0,r.U&&(r.U.tt=n),r.W&&(r.W.tt=e),n.W=r.U,e.U=r.W,r.U=n,r.W=e,e===this.Y)this.Y=r,this.h.tt=r;else{let u=e.tt;u.U===e?u.U=r:u.W=r}return r.tt=e.tt,n.tt=r,e.tt=r,e.ee=1,{parentNode:n,grandParent:e,curNode:r}}else n.ee=0,e===this.Y?this.Y=e.se():e.se(),e.ee=1}else{let o=e.U;if(o&&o.ee===1){if(o.ee=n.ee=0,e===this.Y)return;e.ee=1,r=e;continue}else if(r===n.U){if(r.ee=0,r.U&&(r.U.tt=e),r.W&&(r.W.tt=n),e.W=r.U,n.U=r.W,r.U=e,r.W=n,e===this.Y)this.Y=r,this.h.tt=r;else{let u=e.tt;u.U===e?u.U=r:u.W=r}return r.tt=e.tt,n.tt=r,e.tt=r,e.ee=1,{parentNode:n,grandParent:e,curNode:r}}else n.ee=0,e===this.Y?this.Y=e.te():e.te(),e.ee=1}return}}ne(r,n,e){if(this.Y===void 0){this.i+=1,this.Y=new this.re(r,n),this.Y.ee=0,this.Y.tt=this.h,this.h.tt=this.Y,this.h.U=this.Y,this.h.W=this.Y;return}let o,u=this.h.U,p=this.v(u.u,r);if(p===0){u.l=n;return}else if(p>0)u.U=new this.re(r,n),u.U.tt=u,o=u.U,this.h.U=o;else{let d=this.h.W,b=this.v(d.u,r);if(b===0){d.l=n;return}else if(b<0)d.W=new this.re(r,n),d.W.tt=d,o=d.W,this.h.W=o;else{if(e!==void 0){let h=e.o;if(h!==this.h){let y=this.v(h.u,r);if(y===0){h.l=n;return}else if(y>0){let m=h.L(),S=this.v(m.u,r);if(S===0){m.l=n;return}else S<0&&(o=new this.re(r,n),m.W===void 0?(m.W=o,o.tt=m):(h.U=o,o.tt=h))}}}if(o===void 0)for(o=this.Y;;){let h=this.v(o.u,r);if(h>0){if(o.U===void 0){o.U=new this.re(r,n),o.U.tt=o,o=o.U;break}o=o.U}else if(h<0){if(o.W===void 0){o.W=new this.re(r,n),o.W.tt=o,o=o.W;break}o=o.W}else{o.l=n;return}}}}return this.i+=1,o}I(r,n){for(;r;){let e=this.v(r.u,n);if(e<0)r=r.W;else if(e>0)r=r.U;else return r}return r||this.h}clear(){this.i=0,this.Y=void 0,this.h.tt=void 0,this.h.U=this.h.W=void 0}updateKeyByIterator(r,n){let e=r.o;if(e===this.h&&(0,a.throwIteratorAccessError)(),this.i===1)return e.u=n,!0;if(e===this.h.U)return this.v(e.B().u,n)>0?(e.u=n,!0):!1;if(e===this.h.W)return this.v(e.L().u,n)<0?(e.u=n,!0):!1;let o=e.L().u;if(this.v(o,n)>=0)return!1;let u=e.B().u;return this.v(u,n)<=0?!1:(e.u=n,!0)}eraseElementByPos(r){if(r<0||r>this.i-1)throw new RangeError;let n=0,e=this;return this.oe(this.Y,function(o){return r===n?(e.V(o),!0):(n+=1,!1)}),this.i}eraseElementByKey(r){if(this.i===0)return!1;let n=this.I(this.Y,r);return n===this.h?!1:(this.V(n),!0)}eraseElementByIterator(r){let n=r.o;n===this.h&&(0,a.throwIteratorAccessError)();let e=n.W===void 0;return r.iteratorType===0?e&&r.next():(!e||n.U===void 0)&&r.next(),this.V(n),r}forEach(r){let n=0;for(let e of this)r(e,n++,this)}getElementByPos(r){if(r<0||r>this.i-1)throw new RangeError;let n,e=0;for(let o of this){if(e===r){n=o;break}e+=1}return n}getHeight(){if(this.i===0)return 0;let r=function(n){return n?Math.max(r(n.U),r(n.W))+1:0};return r(this.Y)}},t=l;f.default=t}),Ys=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=ut(),s=ct(),a=class extends i.ContainerIterator{constructor(t,r,n){super(n),this.o=t,this.h=r,this.iteratorType===0?(this.pre=function(){return this.o===this.h.U&&(0,s.throwIteratorAccessError)(),this.o=this.o.L(),this},this.next=function(){return this.o===this.h&&(0,s.throwIteratorAccessError)(),this.o=this.o.B(),this}):(this.pre=function(){return this.o===this.h.W&&(0,s.throwIteratorAccessError)(),this.o=this.o.B(),this},this.next=function(){return this.o===this.h&&(0,s.throwIteratorAccessError)(),this.o=this.o.L(),this})}get index(){let t=this.o,r=this.h.tt;if(t===this.h)return r?r.rt-1:0;let n=0;for(t.U&&(n+=t.U.rt);t!==r;){let e=t.tt;t===e.W&&(n+=1,e.U&&(n+=e.U.rt)),t=e}return n}},l=a;f.default=l}),Hl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=l(Qs()),s=l(Ys()),a=ct();function l(e){return e&&e.t?e:{default:e}}var t=class Js extends s.default{constructor(o,u,p,d){super(o,u,d),this.container=p}get pointer(){return this.o===this.h&&(0,a.throwIteratorAccessError)(),this.o.u}copy(){return new Js(this.o,this.h,this.container,this.iteratorType)}},r=class extends i.default{constructor(e=[],o,u){super(o,u);let p=this;e.forEach(function(d){p.insert(d)})}*K(e){e!==void 0&&(yield*this.K(e.U),yield e.u,yield*this.K(e.W))}begin(){return new t(this.h.U||this.h,this.h,this)}end(){return new t(this.h,this.h,this)}rBegin(){return new t(this.h.W||this.h,this.h,this,1)}rEnd(){return new t(this.h,this.h,this,1)}front(){return this.h.U?this.h.U.u:void 0}back(){return this.h.W?this.h.W.u:void 0}insert(e,o){return this.M(e,void 0,o)}find(e){let o=this.I(this.Y,e);return new t(o,this.h,this)}lowerBound(e){let o=this.X(this.Y,e);return new t(o,this.h,this)}upperBound(e){let o=this.Z(this.Y,e);return new t(o,this.h,this)}reverseLowerBound(e){let o=this.$(this.Y,e);return new t(o,this.h,this)}reverseUpperBound(e){let o=this.rr(this.Y,e);return new t(o,this.h,this)}union(e){let o=this;return e.forEach(function(u){o.insert(u)}),this.i}[Symbol.iterator](){return this.K(this.Y)}},n=r;f.default=n}),zl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=l(Qs()),s=l(Ys()),a=ct();function l(e){return e&&e.t?e:{default:e}}var t=class Xs extends s.default{constructor(o,u,p,d){super(o,u,d),this.container=p}get pointer(){this.o===this.h&&(0,a.throwIteratorAccessError)();let o=this;return new Proxy([],{get(u,p){if(p==="0")return o.o.u;if(p==="1")return o.o.l},set(u,p,d){if(p!=="1")throw new TypeError("props must be 1");return o.o.l=d,!0}})}copy(){return new Xs(this.o,this.h,this.container,this.iteratorType)}},r=class extends i.default{constructor(e=[],o,u){super(o,u);let p=this;e.forEach(function(d){p.setElement(d[0],d[1])})}*K(e){e!==void 0&&(yield*this.K(e.U),yield[e.u,e.l],yield*this.K(e.W))}begin(){return new t(this.h.U||this.h,this.h,this)}end(){return new t(this.h,this.h,this)}rBegin(){return new t(this.h.W||this.h,this.h,this,1)}rEnd(){return new t(this.h,this.h,this,1)}front(){if(this.i===0)return;let e=this.h.U;return[e.u,e.l]}back(){if(this.i===0)return;let e=this.h.W;return[e.u,e.l]}lowerBound(e){let o=this.X(this.Y,e);return new t(o,this.h,this)}upperBound(e){let o=this.Z(this.Y,e);return new t(o,this.h,this)}reverseLowerBound(e){let o=this.$(this.Y,e);return new t(o,this.h,this)}reverseUpperBound(e){let o=this.rr(this.Y,e);return new t(o,this.h,this)}setElement(e,o,u){return this.M(e,o,u)}find(e){let o=this.I(this.Y,e);return new t(o,this.h,this)}getElementByKey(e){return this.I(this.Y,e).l}union(e){let o=this;return e.forEach(function(u){o.setElement(u[0],u[1])}),this.i}[Symbol.iterator](){return this.K(this.Y)}},n=r;f.default=n}),Zs=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=i;function i(s){let a=typeof s;return a==="object"&&s!==null||a==="function"}}),ea=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.HashContainerIterator=f.HashContainer=void 0;var i=ut(),s=l(Zs()),a=ct();function l(n){return n&&n.t?n:{default:n}}var t=class extends i.ContainerIterator{constructor(n,e,o){super(o),this.o=n,this.h=e,this.iteratorType===0?(this.pre=function(){return this.o.L===this.h&&(0,a.throwIteratorAccessError)(),this.o=this.o.L,this},this.next=function(){return this.o===this.h&&(0,a.throwIteratorAccessError)(),this.o=this.o.B,this}):(this.pre=function(){return this.o.B===this.h&&(0,a.throwIteratorAccessError)(),this.o=this.o.B,this},this.next=function(){return this.o===this.h&&(0,a.throwIteratorAccessError)(),this.o=this.o.L,this})}};f.HashContainerIterator=t;var r=class extends i.Container{constructor(){super(),this.H=[],this.g={},this.HASH_TAG=Symbol("@@HASH_TAG"),Object.setPrototypeOf(this.g,null),this.h={},this.h.L=this.h.B=this.p=this._=this.h}V(n){let{L:e,B:o}=n;e.B=o,o.L=e,n===this.p&&(this.p=o),n===this._&&(this._=e),this.i-=1}M(n,e,o){o===void 0&&(o=(0,s.default)(n));let u;if(o){let p=n[this.HASH_TAG];if(p!==void 0)return this.H[p].l=e,this.i;Object.defineProperty(n,this.HASH_TAG,{value:this.H.length,configurable:!0}),u={u:n,l:e,L:this._,B:this.h},this.H.push(u)}else{let p=this.g[n];if(p)return p.l=e,this.i;u={u:n,l:e,L:this._,B:this.h},this.g[n]=u}return this.i===0?(this.p=u,this.h.B=u):this._.B=u,this._=u,this.h.L=u,++this.i}I(n,e){if(e===void 0&&(e=(0,s.default)(n)),e){let o=n[this.HASH_TAG];return o===void 0?this.h:this.H[o]}else return this.g[n]||this.h}clear(){let n=this.HASH_TAG;this.H.forEach(function(e){delete e.u[n]}),this.H=[],this.g={},Object.setPrototypeOf(this.g,null),this.i=0,this.p=this._=this.h.L=this.h.B=this.h}eraseElementByKey(n,e){let o;if(e===void 0&&(e=(0,s.default)(n)),e){let u=n[this.HASH_TAG];if(u===void 0)return!1;delete n[this.HASH_TAG],o=this.H[u],delete this.H[u]}else{if(o=this.g[n],o===void 0)return!1;delete this.g[n]}return this.V(o),!0}eraseElementByIterator(n){let e=n.o;return e===this.h&&(0,a.throwIteratorAccessError)(),this.V(e),n.next()}eraseElementByPos(n){if(n<0||n>this.i-1)throw new RangeError;let e=this.p;for(;n--;)e=e.B;return this.V(e),this.i}};f.HashContainer=r}),Kl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=ea(),s=ct(),a=class ta extends i.HashContainerIterator{constructor(n,e,o,u){super(n,e,u),this.container=o}get pointer(){return this.o===this.h&&(0,s.throwIteratorAccessError)(),this.o.u}copy(){return new ta(this.o,this.h,this.container,this.iteratorType)}},l=class extends i.HashContainer{constructor(r=[]){super();let n=this;r.forEach(function(e){n.insert(e)})}begin(){return new a(this.p,this.h,this)}end(){return new a(this.h,this.h,this)}rBegin(){return new a(this._,this.h,this,1)}rEnd(){return new a(this.h,this.h,this,1)}front(){return this.p.u}back(){return this._.u}insert(r,n){return this.M(r,void 0,n)}getElementByPos(r){if(r<0||r>this.i-1)throw new RangeError;let n=this.p;for(;r--;)n=n.B;return n.u}find(r,n){let e=this.I(r,n);return new a(e,this.h,this)}forEach(r){let n=0,e=this.p;for(;e!==this.h;)r(e.u,n++,this),e=e.B}[Symbol.iterator](){return(function*(){let r=this.p;for(;r!==this.h;)yield r.u,r=r.B}).bind(this)()}},t=l;f.default=t}),Vl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),f.default=void 0;var i=ea(),s=l(Zs()),a=ct();function l(e){return e&&e.t?e:{default:e}}var t=class ra extends i.HashContainerIterator{constructor(o,u,p,d){super(o,u,d),this.container=p}get pointer(){this.o===this.h&&(0,a.throwIteratorAccessError)();let o=this;return new Proxy([],{get(u,p){if(p==="0")return o.o.u;if(p==="1")return o.o.l},set(u,p,d){if(p!=="1")throw new TypeError("props must be 1");return o.o.l=d,!0}})}copy(){return new ra(this.o,this.h,this.container,this.iteratorType)}},r=class extends i.HashContainer{constructor(e=[]){super();let o=this;e.forEach(function(u){o.setElement(u[0],u[1])})}begin(){return new t(this.p,this.h,this)}end(){return new t(this.h,this.h,this)}rBegin(){return new t(this._,this.h,this,1)}rEnd(){return new t(this.h,this.h,this,1)}front(){if(this.i!==0)return[this.p.u,this.p.l]}back(){if(this.i!==0)return[this._.u,this._.l]}setElement(e,o,u){return this.M(e,o,u)}getElementByKey(e,o){if(o===void 0&&(o=(0,s.default)(e)),o){let p=e[this.HASH_TAG];return p!==void 0?this.H[p].l:void 0}let u=this.g[e];return u?u.l:void 0}getElementByPos(e){if(e<0||e>this.i-1)throw new RangeError;let o=this.p;for(;e--;)o=o.B;return[o.u,o.l]}find(e,o){let u=this.I(e,o);return new t(u,this.h,this)}forEach(e){let o=0,u=this.p;for(;u!==this.h;)e([u.u,u.l],o++,this),u=u.B}[Symbol.iterator](){return(function*(){let e=this.p;for(;e!==this.h;)yield[e.u,e.l],e=e.B}).bind(this)()}},n=r;f.default=n}),Gl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"t",{value:!0}),Object.defineProperty(f,"Deque",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(f,"HashMap",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(f,"HashSet",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(f,"LinkList",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(f,"OrderedMap",{enumerable:!0,get:function(){return e.default}}),Object.defineProperty(f,"OrderedSet",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(f,"PriorityQueue",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(f,"Queue",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(f,"Stack",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(f,"Vector",{enumerable:!0,get:function(){return l.default}});var i=p(Bl()),s=p(Ll()),a=p(Dl()),l=p(Fl()),t=p(Wl()),r=p(ql()),n=p(Hl()),e=p(zl()),o=p(Kl()),u=p(Vl());function p(d){return d&&d.t?d:{default:d}}}),Ql=de((f,i)=>{le(),ce(),ue();var s=Gl().OrderedSet,a=at()("number-allocator:trace"),l=at()("number-allocator:error");function t(n,e){this.low=n,this.high=e}t.prototype.equals=function(n){return this.low===n.low&&this.high===n.high},t.prototype.compare=function(n){return this.low<n.low&&this.high<n.low?-1:n.low<this.low&&n.high<this.low?1:0};function r(n,e){if(!(this instanceof r))return new r(n,e);this.min=n,this.max=e,this.ss=new s([],(o,u)=>o.compare(u)),a("Create"),this.clear()}r.prototype.firstVacant=function(){return this.ss.size()===0?null:this.ss.front().low},r.prototype.alloc=function(){if(this.ss.size()===0)return a("alloc():empty"),null;let n=this.ss.begin(),e=n.pointer.low,o=n.pointer.high,u=e;return u+1<=o?this.ss.updateKeyByIterator(n,new t(e+1,o)):this.ss.eraseElementByPos(0),a("alloc():"+u),u},r.prototype.use=function(n){let e=new t(n,n),o=this.ss.lowerBound(e);if(!o.equals(this.ss.end())){let u=o.pointer.low,p=o.pointer.high;return o.pointer.equals(e)?(this.ss.eraseElementByIterator(o),a("use():"+n),!0):u>n?!1:u===n?(this.ss.updateKeyByIterator(o,new t(u+1,p)),a("use():"+n),!0):p===n?(this.ss.updateKeyByIterator(o,new t(u,p-1)),a("use():"+n),!0):(this.ss.updateKeyByIterator(o,new t(n+1,p)),this.ss.insert(new t(u,n-1)),a("use():"+n),!0)}return a("use():failed"),!1},r.prototype.free=function(n){if(n<this.min||n>this.max){l("free():"+n+" is out of range");return}let e=new t(n,n),o=this.ss.upperBound(e);if(o.equals(this.ss.end())){if(o.equals(this.ss.begin())){this.ss.insert(e);return}o.pre();let u=o.pointer.high;o.pointer.high+1===n?this.ss.updateKeyByIterator(o,new t(u,n)):this.ss.insert(e)}else if(o.equals(this.ss.begin()))if(n+1===o.pointer.low){let u=o.pointer.high;this.ss.updateKeyByIterator(o,new t(n,u))}else this.ss.insert(e);else{let u=o.pointer.low,p=o.pointer.high;o.pre();let d=o.pointer.low;o.pointer.high+1===n?n+1===u?(this.ss.eraseElementByIterator(o),this.ss.updateKeyByIterator(o,new t(d,p))):this.ss.updateKeyByIterator(o,new t(d,n)):n+1===u?(this.ss.eraseElementByIterator(o.next()),this.ss.insert(new t(n,p))):this.ss.insert(e)}a("free():"+n)},r.prototype.clear=function(){a("clear()"),this.ss.clear(),this.ss.insert(new t(this.min,this.max))},r.prototype.intervalCount=function(){return this.ss.size()},r.prototype.dump=function(){console.log("length:"+this.ss.size());for(let n of this.ss)console.log(n)},i.exports=r}),na=de((f,i)=>{le(),ce(),ue();var s=Ql();i.exports.NumberAllocator=s}),Yl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=Ul(),s=na(),a=class{aliasToTopic;topicToAlias;max;numberAllocator;length;constructor(l){l>0&&(this.aliasToTopic=new i.LRUCache({max:l}),this.topicToAlias={},this.numberAllocator=new s.NumberAllocator(1,l),this.max=l,this.length=0)}put(l,t){if(t===0||t>this.max)return!1;let r=this.aliasToTopic.get(t);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(t,l),this.topicToAlias[l]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.size,!0}getTopicByAlias(l){return this.aliasToTopic.get(l)}getAliasByTopic(l){let t=this.topicToAlias[l];return typeof t<"u"&&this.aliasToTopic.get(t),t}clear(){this.aliasToTopic.clear(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0}getLruAlias(){return this.numberAllocator.firstVacant()||[...this.aliasToTopic.keys()][this.aliasToTopic.size-1]}};f.default=a}),Jl=de(f=>{le(),ce(),ue();var i=f&&f.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(f,"__esModule",{value:!0});var s=Or(),a=i(Yl()),l=jt(),t=(r,n)=>{r.log("_handleConnack");let{options:e}=r,o=e.protocolVersion===5?n.reasonCode:n.returnCode;if(clearTimeout(r.connackTimer),delete r.topicAliasSend,n.properties){if(n.properties.topicAliasMaximum){if(n.properties.topicAliasMaximum>65535){r.emit("error",new Error("topicAliasMaximum from broker is out of range"));return}n.properties.topicAliasMaximum>0&&(r.topicAliasSend=new a.default(n.properties.topicAliasMaximum))}n.properties.serverKeepAlive&&e.keepalive&&(e.keepalive=n.properties.serverKeepAlive),n.properties.maximumPacketSize&&(e.properties||(e.properties={}),e.properties.maximumPacketSize=n.properties.maximumPacketSize)}if(o===0)r.reconnecting=!1,r._onConnect(n);else if(o>0){let u=new l.ErrorWithReasonCode(`Connection refused: ${s.ReasonCodes[o]}`,o);r.emit("error",u),r.options.reconnectOnConnackError&&r._cleanUp(!0)}};f.default=t}),Xl=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=(s,a,l)=>{s.log("handling pubrel packet");let t=typeof l<"u"?l:s.noop,{messageId:r}=a,n={cmd:"pubcomp",messageId:r};s.incomingStore.get(a,(e,o)=>{e?s._sendPacket(n,t):(s.emit("message",o.topic,o.payload,o),s.handleMessage(o,u=>{if(u)return t(u);s.incomingStore.del(o,s.noop),s._sendPacket(n,t)}))})};f.default=i}),Zl=de(f=>{le(),ce(),ue();var i=f&&f.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(f,"__esModule",{value:!0});var s=i(Ml()),a=i(Nl()),l=i(Jl()),t=i(Or()),r=i(Xl()),n=(e,o,u)=>{let{options:p}=e;if(p.protocolVersion===5&&p.properties&&p.properties.maximumPacketSize&&p.properties.maximumPacketSize<o.length)return e.emit("error",new Error(`exceeding packets size ${o.cmd}`)),e.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),e;switch(e.log("_handlePacket :: emitting packetreceive"),e.emit("packetreceive",o),o.cmd){case"publish":(0,s.default)(e,o,u);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":e.reschedulePing(),(0,t.default)(e,o),u();break;case"pubrel":e.reschedulePing(),(0,r.default)(e,o,u);break;case"connack":(0,l.default)(e,o),u();break;case"auth":e.reschedulePing(),(0,a.default)(e,o),u();break;case"pingresp":e.log("_handlePacket :: received pingresp"),e.reschedulePing(!0),u();break;case"disconnect":e.emit("disconnect",o),u();break;default:e.log("_handlePacket :: unknown command"),u();break}};f.default=n}),ia=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=class{nextId;constructor(){this.nextId=Math.max(1,Math.floor(Math.random()*65535))}allocate(){let s=this.nextId++;return this.nextId===65536&&(this.nextId=1),s}getLastAllocated(){return this.nextId===1?65535:this.nextId-1}register(s){return!0}deallocate(s){}clear(){}};f.default=i}),eu=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=class{aliasToTopic;max;length;constructor(s){this.aliasToTopic={},this.max=s}put(s,a){return a===0||a>this.max?!1:(this.aliasToTopic[a]=s,this.length=Object.keys(this.aliasToTopic).length,!0)}getTopicByAlias(s){return this.aliasToTopic[s]}clear(){this.aliasToTopic={}}};f.default=i}),tu=de(f=>{le(),ce(),ue();var i=f&&f.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(f,"__esModule",{value:!0}),f.TypedEventEmitter=void 0;var s=i((At(),Pe(yt))),a=jt(),l=class{};f.TypedEventEmitter=l,(0,a.applyMixin)(l,s.default)}),Pr=de((f,i)=>{le(),ce(),ue();function s(a){"@babel/helpers - typeof";return i.exports=s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},i.exports.__esModule=!0,i.exports.default=i.exports,s(a)}i.exports=s,i.exports.__esModule=!0,i.exports.default=i.exports}),ru=de((f,i)=>{le(),ce(),ue();var s=Pr().default;function a(l,t){if(s(l)!="object"||!l)return l;var r=l[Symbol.toPrimitive];if(r!==void 0){var n=r.call(l,t||"default");if(s(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(l)}i.exports=a,i.exports.__esModule=!0,i.exports.default=i.exports}),nu=de((f,i)=>{le(),ce(),ue();var s=Pr().default,a=ru();function l(t){var r=a(t,"string");return s(r)=="symbol"?r:r+""}i.exports=l,i.exports.__esModule=!0,i.exports.default=i.exports}),iu=de((f,i)=>{le(),ce(),ue();var s=nu();function a(l,t,r){return(t=s(t))in l?Object.defineProperty(l,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):l[t]=r,l}i.exports=a,i.exports.__esModule=!0,i.exports.default=i.exports}),ou=de((f,i)=>{le(),ce(),ue();function s(a){if(Array.isArray(a))return a}i.exports=s,i.exports.__esModule=!0,i.exports.default=i.exports}),su=de((f,i)=>{le(),ce(),ue();function s(a,l){var t=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if(t!=null){var r,n,e,o,u=[],p=!0,d=!1;try{if(e=(t=t.call(a)).next,l===0){if(Object(t)!==t)return;p=!1}else for(;!(p=(r=e.call(t)).done)&&(u.push(r.value),u.length!==l);p=!0);}catch(b){d=!0,n=b}finally{try{if(!p&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(d)throw n}}return u}}i.exports=s,i.exports.__esModule=!0,i.exports.default=i.exports}),au=de((f,i)=>{le(),ce(),ue();function s(a,l){(l==null||l>a.length)&&(l=a.length);for(var t=0,r=Array(l);t<l;t++)r[t]=a[t];return r}i.exports=s,i.exports.__esModule=!0,i.exports.default=i.exports}),lu=de((f,i)=>{le(),ce(),ue();var s=au();function a(l,t){if(l){if(typeof l=="string")return s(l,t);var r={}.toString.call(l).slice(8,-1);return r==="Object"&&l.constructor&&(r=l.constructor.name),r==="Map"||r==="Set"?Array.from(l):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(l,t):void 0}}i.exports=a,i.exports.__esModule=!0,i.exports.default=i.exports}),uu=de((f,i)=>{le(),ce(),ue();function s(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}i.exports=s,i.exports.__esModule=!0,i.exports.default=i.exports}),cu=de((f,i)=>{le(),ce(),ue();var s=ou(),a=su(),l=lu(),t=uu();function r(n,e){return s(n)||a(n,e)||l(n,e)||t()}i.exports=r,i.exports.__esModule=!0,i.exports.default=i.exports}),oa=de((f,i)=>{le(),ce(),ue(),(function(s,a){typeof f=="object"&&typeof i<"u"?a(f):typeof define=="function"&&define.amd?define(["exports"],a):(s=typeof globalThis<"u"?globalThis:s||self,a(s.fastUniqueNumbers={}))})(f,function(s){var a=function(b){return function(h){var y=b(h);return h.add(y),y}},l=function(b){return function(h,y){return b.set(h,y),y}},t=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,r=536870912,n=r*2,e=function(b,h){return function(y){var m=h.get(y),S=m===void 0?y.size:m<n?m+1:0;if(!y.has(S))return b(y,S);if(y.size<r){for(;y.has(S);)S=Math.floor(Math.random()*n);return b(y,S)}if(y.size>t)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;y.has(S);)S=Math.floor(Math.random()*t);return b(y,S)}},o=new WeakMap,u=l(o),p=e(u,o),d=a(p);s.addUniqueNumber=d,s.generateUniqueNumber=p})}),hu=de((f,i)=>{le(),ce(),ue();function s(l,t,r,n,e,o,u){try{var p=l[o](u),d=p.value}catch(b){return void r(b)}p.done?t(d):Promise.resolve(d).then(n,e)}function a(l){return function(){var t=this,r=arguments;return new Promise(function(n,e){var o=l.apply(t,r);function u(d){s(o,n,e,u,p,"next",d)}function p(d){s(o,n,e,u,p,"throw",d)}u(void 0)})}}i.exports=a,i.exports.__esModule=!0,i.exports.default=i.exports}),sa=de((f,i)=>{le(),ce(),ue();function s(a,l){this.v=a,this.k=l}i.exports=s,i.exports.__esModule=!0,i.exports.default=i.exports}),aa=de((f,i)=>{le(),ce(),ue();function s(a,l,t,r){var n=Object.defineProperty;try{n({},"",{})}catch{n=0}i.exports=s=function(e,o,u,p){function d(b,h){s(e,b,function(y){return this._invoke(b,h,y)})}o?n?n(e,o,{value:u,enumerable:!p,configurable:!p,writable:!p}):e[o]=u:(d("next",0),d("throw",1),d("return",2))},i.exports.__esModule=!0,i.exports.default=i.exports,s(a,l,t,r)}i.exports=s,i.exports.__esModule=!0,i.exports.default=i.exports}),la=de((f,i)=>{le(),ce(),ue();var s=aa();function a(){var l,t,r=typeof Symbol=="function"?Symbol:{},n=r.iterator||"@@iterator",e=r.toStringTag||"@@toStringTag";function o(S,g,_,I){var v=g&&g.prototype instanceof p?g:p,A=Object.create(v.prototype);return s(A,"_invoke",(function(E,k,C){var P,L,x,q=0,D=C||[],U=!1,ae={p:0,n:0,v:l,a:Q,f:Q.bind(l,4),d:function(K,re){return P=K,L=0,x=l,ae.n=re,u}};function Q(K,re){for(L=K,x=re,t=0;!U&&q&&!F&&t<D.length;t++){var F,Z=D[t],R=ae.p,J=Z[2];K>3?(F=J===re)&&(x=Z[(L=Z[4])?5:(L=3,3)],Z[4]=Z[5]=l):Z[0]<=R&&((F=K<2&&R<Z[1])?(L=0,ae.v=re,ae.n=Z[1]):R<J&&(F=K<3||Z[0]>re||re>J)&&(Z[4]=K,Z[5]=re,ae.n=J,L=0))}if(F||K>1)return u;throw U=!0,re}return function(K,re,F){if(q>1)throw TypeError("Generator is already running");for(U&&re===1&&Q(re,F),L=re,x=F;(t=L<2?l:x)||!U;){P||(L?L<3?(L>1&&(ae.n=-1),Q(L,x)):ae.n=x:ae.v=x);try{if(q=2,P){if(L||(K="next"),t=P[K]){if(!(t=t.call(P,x)))throw TypeError("iterator result is not an object");if(!t.done)return t;x=t.value,L<2&&(L=0)}else L===1&&(t=P.return)&&t.call(P),L<2&&(x=TypeError("The iterator does not provide a '"+K+"' method"),L=1);P=l}else if((t=(U=ae.n<0)?x:E.call(k,ae))!==u)break}catch(Z){P=l,L=1,x=Z}finally{q=1}}return{value:t,done:U}}})(S,_,I),!0),A}var u={};function p(){}function d(){}function b(){}t=Object.getPrototypeOf;var h=[][n]?t(t([][n]())):(s(t={},n,function(){return this}),t),y=b.prototype=p.prototype=Object.create(h);function m(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,b):(S.__proto__=b,s(S,e,"GeneratorFunction")),S.prototype=Object.create(y),S}return d.prototype=b,s(y,"constructor",b),s(b,"constructor",d),d.displayName="GeneratorFunction",s(b,e,"GeneratorFunction"),s(y),s(y,e,"Generator"),s(y,n,function(){return this}),s(y,"toString",function(){return"[object Generator]"}),(i.exports=a=function(){return{w:o,m}},i.exports.__esModule=!0,i.exports.default=i.exports)()}i.exports=a,i.exports.__esModule=!0,i.exports.default=i.exports}),ua=de((f,i)=>{le(),ce(),ue();var s=sa(),a=aa();function l(t,r){function n(o,u,p,d){try{var b=t[o](u),h=b.value;return h instanceof s?r.resolve(h.v).then(function(y){n("next",y,p,d)},function(y){n("throw",y,p,d)}):r.resolve(h).then(function(y){b.value=y,p(b)},function(y){return n("throw",y,p,d)})}catch(y){d(y)}}var e;this.next||(a(l.prototype),a(l.prototype,typeof Symbol=="function"&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),a(this,"_invoke",function(o,u,p){function d(){return new r(function(b,h){n(o,p,b,h)})}return e=e?e.then(d,d):d()},!0)}i.exports=l,i.exports.__esModule=!0,i.exports.default=i.exports}),ca=de((f,i)=>{le(),ce(),ue();var s=la(),a=ua();function l(t,r,n,e,o){return new a(s().w(t,r,n,e),o||Promise)}i.exports=l,i.exports.__esModule=!0,i.exports.default=i.exports}),fu=de((f,i)=>{le(),ce(),ue();var s=ca();function a(l,t,r,n,e){var o=s(l,t,r,n,e);return o.next().then(function(u){return u.done?u.value:o.next()})}i.exports=a,i.exports.__esModule=!0,i.exports.default=i.exports}),pu=de((f,i)=>{le(),ce(),ue();function s(a){var l=Object(a),t=[];for(var r in l)t.unshift(r);return function n(){for(;t.length;)if((r=t.pop())in l)return n.value=r,n.done=!1,n;return n.done=!0,n}}i.exports=s,i.exports.__esModule=!0,i.exports.default=i.exports}),du=de((f,i)=>{le(),ce(),ue();var s=Pr().default;function a(l){if(l!=null){var t=l[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(l);if(typeof l.next=="function")return l;if(!isNaN(l.length))return{next:function(){return l&&r>=l.length&&(l=void 0),{value:l&&l[r++],done:!l}}}}throw new TypeError(s(l)+" is not iterable")}i.exports=a,i.exports.__esModule=!0,i.exports.default=i.exports}),gu=de((f,i)=>{le(),ce(),ue();var s=sa(),a=la(),l=fu(),t=ca(),r=ua(),n=pu(),e=du();function o(){var u=a(),p=u.m(o),d=(Object.getPrototypeOf?Object.getPrototypeOf(p):p.__proto__).constructor;function b(m){var S=typeof m=="function"&&m.constructor;return!!S&&(S===d||(S.displayName||S.name)==="GeneratorFunction")}var h={throw:1,return:2,break:3,continue:3};function y(m){var S,g;return function(_){S||(S={stop:function(){return g(_.a,2)},catch:function(){return _.v},abrupt:function(I,v){return g(_.a,h[I],v)},delegateYield:function(I,v,A){return S.resultName=v,g(_.d,e(I),A)},finish:function(I){return g(_.f,I)}},g=function(I,v,A){_.p=S.prev,_.n=S.next;try{return I(v,A)}finally{S.next=_.n}}),S.resultName&&(S[S.resultName]=_.v,S.resultName=void 0),S.sent=_.v,S.next=_.n;try{return m.call(this,S)}finally{_.p=S.prev,_.n=S.next}}}return(i.exports=o=function(){return{wrap:function(m,S,g,_){return u.w(y(m),S,g,_&&_.reverse())},isGeneratorFunction:b,mark:u.m,awrap:function(m,S){return new s(m,S)},AsyncIterator:r,async:function(m,S,g,_,I){return(b(S)?t:l)(y(m),S,g,_,I)},keys:n,values:e}},i.exports.__esModule=!0,i.exports.default=i.exports)()}i.exports=o,i.exports.__esModule=!0,i.exports.default=i.exports}),yu=de((f,i)=>{le(),ce(),ue();var s=gu()();i.exports=s;try{regeneratorRuntime=s}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=s:Function("r","regeneratorRuntime = r")(s)}}),mu=de((f,i)=>{le(),ce(),ue(),(function(s,a){typeof f=="object"&&typeof i<"u"?a(f,iu(),cu(),oa(),hu(),yu()):typeof define=="function"&&define.amd?define(["exports","@babel/runtime/helpers/defineProperty","@babel/runtime/helpers/slicedToArray","fast-unique-numbers","@babel/runtime/helpers/asyncToGenerator","@babel/runtime/regenerator"],a):(s=typeof globalThis<"u"?globalThis:s||self,a(s.brokerFactory={},s._defineProperty,s._slicedToArray,s.fastUniqueNumbers,s._asyncToGenerator,s._regeneratorRuntime))})(f,function(s,a,l,t,r,n){var e=function(g){return typeof g.start=="function"},o=new WeakMap;function u(g,_){var I=Object.keys(g);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(g);_&&(v=v.filter(function(A){return Object.getOwnPropertyDescriptor(g,A).enumerable})),I.push.apply(I,v)}return I}function p(g){for(var _=1;_<arguments.length;_++){var I=arguments[_]!=null?arguments[_]:{};_%2?u(Object(I),!0).forEach(function(v){a(g,v,I[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(I)):u(Object(I)).forEach(function(v){Object.defineProperty(g,v,Object.getOwnPropertyDescriptor(I,v))})}return g}var d=function(g){return p(p({},g),{},{connect:function(_){var I=_.call;return r(n.mark(function v(){var A,E,k,C;return n.wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return A=new MessageChannel,E=A.port1,k=A.port2,P.next=1,I("connect",{port:E},[E]);case 1:return C=P.sent,o.set(k,C),P.abrupt("return",k);case 2:case"end":return P.stop()}},v)}))},disconnect:function(_){var I=_.call;return(function(){var v=r(n.mark(function A(E){var k;return n.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(k=o.get(E),k!==void 0){C.next=1;break}throw new Error("The given port is not connected.");case 1:return C.next=2,I("disconnect",{portId:k});case 2:case"end":return C.stop()}},A)}));return function(A){return v.apply(this,arguments)}})()},isSupported:function(_){var I=_.call;return function(){return I("isSupported")}}})};function b(g,_){var I=Object.keys(g);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(g);_&&(v=v.filter(function(A){return Object.getOwnPropertyDescriptor(g,A).enumerable})),I.push.apply(I,v)}return I}function h(g){for(var _=1;_<arguments.length;_++){var I=arguments[_]!=null?arguments[_]:{};_%2?b(Object(I),!0).forEach(function(v){a(g,v,I[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(I)):b(Object(I)).forEach(function(v){Object.defineProperty(g,v,Object.getOwnPropertyDescriptor(I,v))})}return g}var y=new WeakMap,m=function(g){if(y.has(g))return y.get(g);var _=new Map;return y.set(g,_),_},S=function(g){var _=d(g);return function(I){var v=m(I);I.addEventListener("message",function(D){var U=D.data,ae=U.id;if(ae!==null&&v.has(ae)){var Q=v.get(ae),K=Q.reject,re=Q.resolve;v.delete(ae),U.error===void 0?re(U.result):K(new Error(U.error.message))}}),e(I)&&I.start();for(var A=function(D){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,ae=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return new Promise(function(Q,K){var re=t.generateUniqueNumber(v);v.set(re,{reject:K,resolve:Q}),U===null?I.postMessage({id:re,method:D},ae):I.postMessage({id:re,method:D,params:U},ae)})},E=function(D,U){var ae=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];I.postMessage({id:null,method:D,params:U},ae)},k={},C=0,P=Object.entries(_);C<P.length;C++){var L=l(P[C],2),x=L[0],q=L[1];k=h(h({},k),{},a({},x,q({call:A,notify:E})))}return h({},k)}};s.createBroker=S})}),bu=de((f,i)=>{le(),ce(),ue(),(function(s,a){typeof f=="object"&&typeof i<"u"?a(f,Pr(),mu(),oa()):typeof define=="function"&&define.amd?define(["exports","@babel/runtime/helpers/typeof","broker-factory","fast-unique-numbers"],a):(s=typeof globalThis<"u"?globalThis:s||self,a(s.workerTimersBroker={},s._typeof,s.brokerFactory,s.fastUniqueNumbers))})(f,function(s,a,l,t){var r=new Map([[0,null]]),n=new Map([[0,null]]),e=l.createBroker({clearInterval:function(u){var p=u.call;return function(d){a(r.get(d))==="symbol"&&(r.set(d,null),p("clear",{timerId:d,timerType:"interval"}).then(function(){r.delete(d)}))}},clearTimeout:function(u){var p=u.call;return function(d){a(n.get(d))==="symbol"&&(n.set(d,null),p("clear",{timerId:d,timerType:"timeout"}).then(function(){n.delete(d)}))}},setInterval:function(u){var p=u.call;return function(d){for(var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,h=arguments.length,y=new Array(h>2?h-2:0),m=2;m<h;m++)y[m-2]=arguments[m];var S=Symbol(),g=t.generateUniqueNumber(r);r.set(g,S);var _=function(){return p("set",{delay:b,now:performance.timeOrigin+performance.now(),timerId:g,timerType:"interval"}).then(function(){var I=r.get(g);if(I===void 0)throw new Error("The timer is in an undefined state.");I===S&&(d.apply(void 0,y),r.get(g)===S&&_())})};return _(),g}},setTimeout:function(u){var p=u.call;return function(d){for(var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,h=arguments.length,y=new Array(h>2?h-2:0),m=2;m<h;m++)y[m-2]=arguments[m];var S=Symbol(),g=t.generateUniqueNumber(n);return n.set(g,S),p("set",{delay:b,now:performance.timeOrigin+performance.now(),timerId:g,timerType:"timeout"}).then(function(){var _=n.get(g);if(_===void 0)throw new Error("The timer is in an undefined state.");_===S&&(n.delete(g),d.apply(void 0,y))}),g}}}),o=function(u){var p=new Worker(u);return e(p)};s.load=o,s.wrap=e})}),vu=de((f,i)=>{le(),ce(),ue(),(function(s,a){typeof f=="object"&&typeof i<"u"?a(f,bu()):typeof define=="function"&&define.amd?define(["exports","worker-timers-broker"],a):(s=typeof globalThis<"u"?globalThis:s||self,a(s.workerTimers={},s.workerTimersBroker))})(f,function(s,a){var l=function(p,d){var b=null;return function(){if(b!==null)return b;var h=new Blob([d],{type:"application/javascript; charset=utf-8"}),y=URL.createObjectURL(h);return b=p(y),setTimeout(function(){return URL.revokeObjectURL(y)}),b}},t=`(()=>{var e={45:(e,t,r)=>{var n=r(738).default;e.exports=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n},e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,r)=>{var n=r(79);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,u,a,i=[],s=!0,c=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=u.call(r)).done)&&(i.push(n.value),i.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return i}},e.exports.__esModule=!0,e.exports.default=e.exports},172:e=>{e.exports=function(e,t){this.v=e,this.k=t},e.exports.__esModule=!0,e.exports.default=e.exports},293:e=>{function t(e,t,r,n,o,u,a){try{var i=e[u](a),s=i.value}catch(e){return void r(e)}i.done?t(s):Promise.resolve(s).then(n,o)}e.exports=function(e){return function(){var r=this,n=arguments;return new Promise((function(o,u){var a=e.apply(r,n);function i(e){t(a,o,u,i,s,"next",e)}function s(e){t(a,o,u,i,s,"throw",e)}i(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},373:e=>{e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports},389:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,u=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<u?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*u);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,s=r(i),c=a(s,i),f=t(c);e.addUniqueNumber=f,e.generateUniqueNumber=c}(t)},472:function(e,t,r){!function(e,t,r,n){"use strict";var o=function(e,t){return function(r){var o=t.get(r);if(void 0===o)return Promise.resolve(!1);var u=n(o,2),a=u[0],i=u[1];return e(a),t.delete(r),i(!1),Promise.resolve(!0)}},u=function(e,t){var r=function(n,o,u,a){var i=n-e.now();i>0?o.set(a,[t(r,i,n,o,u,a),u]):(o.delete(a),u(!0))};return r},a=function(e,t,r,n){return function(o,u,a){var i=o+u-t.timeOrigin,s=i-t.now();return new Promise((function(t){e.set(a,[r(n,s,i,e,t,a),t])}))}},i=new Map,s=o(globalThis.clearTimeout,i),c=new Map,f=o(globalThis.clearTimeout,c),l=u(performance,globalThis.setTimeout),p=a(i,performance,globalThis.setTimeout,l),d=a(c,performance,globalThis.setTimeout,l);r.createWorker(self,{clear:function(){var r=e(t.mark((function e(r){var n,o,u;return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.timerId,o=r.timerType,e.next=1,"interval"===o?s(n):f(n);case 1:return u=e.sent,e.abrupt("return",{result:u});case 2:case"end":return e.stop()}}),e)})));function n(e){return r.apply(this,arguments)}return n}(),set:function(){var r=e(t.mark((function e(r){var n,o,u,a,i;return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.delay,o=r.now,u=r.timerId,a=r.timerType,e.next=1,("interval"===a?p:d)(n,o,u);case 1:return i=e.sent,e.abrupt("return",{result:i});case 2:case"end":return e.stop()}}),e)})));function n(e){return r.apply(this,arguments)}return n}()})}(r(293),r(756),r(623),r(715))},546:e=>{function t(r,n,o,u){var a=Object.defineProperty;try{a({},"",{})}catch(r){a=0}e.exports=t=function(e,r,n,o){if(r)a?a(e,r,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[r]=n;else{var u=function(r,n){t(e,r,(function(e){return this._invoke(r,n,e)}))};u("next",0),u("throw",1),u("return",2)}},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n,o,u)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,r)=>{var n=r(738).default;e.exports=function(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(n(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports},623:function(e,t,r){!function(e,t,r,n,o){"use strict";var u={INTERNAL_ERROR:-32603,INVALID_PARAMS:-32602,METHOD_NOT_FOUND:-32601},a=function(e,t){return Object.assign(new Error(e),{status:t})},i=function(e){return a('The requested method called "'.concat(e,'" is not supported.'),u.METHOD_NOT_FOUND)},s=function(e){return a('The handler of the method called "'.concat(e,'" returned no required result.'),u.INTERNAL_ERROR)},c=function(e){return a('The handler of the method called "'.concat(e,'" returned an unexpected result.'),u.INTERNAL_ERROR)},f=function(e){return a('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),u.INVALID_PARAMS)},l=function(e,n){return function(){var o=t(r.mark((function t(o){var u,a,f,l,p,d,v,x,y,b,h,m,_,g,w;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u=o.data,a=u.id,f=u.method,l=u.params,p=n[f],t.prev=1,void 0!==p){t.next=2;break}throw i(f);case 2:if(void 0!==(d=void 0===l?p():p(l))){t.next=3;break}throw s(f);case 3:if(!(d instanceof Promise)){t.next=5;break}return t.next=4,d;case 4:g=t.sent,t.next=6;break;case 5:g=d;case 6:if(v=g,null!==a){t.next=8;break}if(void 0===v.result){t.next=7;break}throw c(f);case 7:t.next=10;break;case 8:if(void 0!==v.result){t.next=9;break}throw c(f);case 9:x=v.result,y=v.transferables,b=void 0===y?[]:y,e.postMessage({id:a,result:x},b);case 10:t.next=12;break;case 11:t.prev=11,w=t.catch(1),h=w.message,m=w.status,_=void 0===m?-32603:m,e.postMessage({error:{code:_,message:h},id:a});case 12:case"end":return t.stop()}}),t,null,[[1,11]])})));return function(e){return o.apply(this,arguments)}}()},p=function(){return new Promise((function(e){var t=new ArrayBuffer(0),r=new MessageChannel,n=r.port1,o=r.port2;n.onmessage=function(t){var r=t.data;return e(null!==r)},o.postMessage(t,[t])}))};function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var x=new Map,y=function(e,n,u){return v(v({},n),{},{connect:function(t){var r=t.port;r.start();var u=e(r,n),a=o.generateUniqueNumber(x);return x.set(a,(function(){u(),r.close(),x.delete(a)})),{result:a}},disconnect:function(e){var t=e.portId,r=x.get(t);if(void 0===r)throw f(t);return r(),{result:null}},isSupported:function(){var e=t(r.mark((function e(){var t,n,o;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,p();case 1:if(!e.sent){e.next=5;break}if(!((t=u())instanceof Promise)){e.next=3;break}return e.next=2,t;case 2:o=e.sent,e.next=4;break;case 3:o=t;case 4:return n=o,e.abrupt("return",{result:n});case 5:return e.abrupt("return",{result:!1});case 6:case"end":return e.stop()}}),e)})));function n(){return e.apply(this,arguments)}return n}()})},b=function(e,t){var r=y(b,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return!0}),n=l(e,r);return e.addEventListener("message",n),function(){return e.removeEventListener("message",n)}};e.createWorker=b,e.isSupported=p}(t,r(293),r(756),r(693),r(389))},633:(e,t,r)=>{var n=r(172),o=r(993),u=r(869),a=r(887),i=r(791),s=r(373),c=r(579);function f(){"use strict";var t=o(),r=t.m(f),l=(Object.getPrototypeOf?Object.getPrototypeOf(r):r.__proto__).constructor;function p(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))}var d={throw:1,return:2,break:3,continue:3};function v(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,d[e],t)},delegateYield:function(e,o,u){return t.resultName=o,r(n.d,c(e),u)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=f=function(){return{wrap:function(e,r,n,o){return t.w(v(e),r,n,o&&o.reverse())},isGeneratorFunction:p,mark:t.m,awrap:function(e,t){return new n(e,t)},AsyncIterator:i,async:function(e,t,r,n,o){return(p(t)?a:u)(v(e),t,r,n,o)},keys:s,values:c}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=f,e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,r)=>{var n=r(736);e.exports=function(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,r)=>{var n=r(987),o=r(156),u=r(122),a=r(752);e.exports=function(e,t){return n(e)||o(e,t)||u(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,r)=>{var n=r(738).default,o=r(45);e.exports=function(e){var t=o(e,"string");return"symbol"==n(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,r)=>{var n=r(633)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},791:(e,t,r)=>{var n=r(172),o=r(546);e.exports=function e(t,r){function u(e,o,a,i){try{var s=t[e](o),c=s.value;return c instanceof n?r.resolve(c.v).then((function(e){u("next",e,a,i)}),(function(e){u("throw",e,a,i)})):r.resolve(c).then((function(e){s.value=e,a(s)}),(function(e){return u("throw",e,a,i)}))}catch(e){i(e)}}var a;this.next||(o(e.prototype),o(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",(function(){return this}))),o(this,"_invoke",(function(e,t,n){function o(){return new r((function(t,r){u(e,n,t,r)}))}return a=a?a.then(o,o):o()}),!0)},e.exports.__esModule=!0,e.exports.default=e.exports},869:(e,t,r)=>{var n=r(887);e.exports=function(e,t,r,o,u){var a=n(e,t,r,o,u);return a.next().then((function(e){return e.done?e.value:a.next()}))},e.exports.__esModule=!0,e.exports.default=e.exports},887:(e,t,r)=>{var n=r(993),o=r(791);e.exports=function(e,t,r,u,a){return new o(n().w(e,t,r,u),a||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},993:(e,t,r)=>{var n=r(546);function o(){var t,r,u="function"==typeof Symbol?Symbol:{},a=u.iterator||"@@iterator",i=u.toStringTag||"@@toStringTag";function s(e,o,u,a){var i=o&&o.prototype instanceof f?o:f,s=Object.create(i.prototype);return n(s,"_invoke",function(e,n,o){var u,a,i,s=0,f=o||[],l=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return u=e,a=0,i=t,p.n=r,c}};function d(e,n){for(a=e,i=n,r=0;!l&&s&&!o&&r<f.length;r++){var o,u=f[r],d=p.p,v=u[2];e>3?(o=v===n)&&(i=u[(a=u[4])?5:(a=3,3)],u[4]=u[5]=t):u[0]<=d&&((o=e<2&&d<u[1])?(a=0,p.v=n,p.n=u[1]):d<v&&(o=e<3||u[0]>n||n>v)&&(u[4]=e,u[5]=n,p.n=v,a=0))}if(o||e>1)return c;throw l=!0,n}return function(o,f,v){if(s>1)throw TypeError("Generator is already running");for(l&&1===f&&d(f,v),a=f,i=v;(r=a<2?t:i)||!l;){u||(a?a<3?(a>1&&(p.n=-1),d(a,i)):p.n=i:p.v=i);try{if(s=2,u){if(a||(o="next"),r=u[o]){if(!(r=r.call(u,i)))throw TypeError("iterator result is not an object");if(!r.done)return r;i=r.value,a<2&&(a=0)}else 1===a&&(r=u.return)&&r.call(u),a<2&&(i=TypeError("The iterator does not provide a '"+o+"' method"),a=1);u=t}else if((r=(l=p.n<0)?i:e.call(n,p))!==c)break}catch(e){u=t,a=1,i=e}finally{s=1}}return{value:r,done:l}}}(e,u,a),!0),s}var c={};function f(){}function l(){}function p(){}r=Object.getPrototypeOf;var d=[][a]?r(r([][a]())):(n(r={},a,(function(){return this})),r),v=p.prototype=f.prototype=Object.create(d);function x(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,n(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e}return l.prototype=p,n(v,"constructor",p),n(p,"constructor",l),l.displayName="GeneratorFunction",n(p,i,"GeneratorFunction"),n(v),n(v,i,"Generator"),n(v,a,(function(){return this})),n(v,"toString",(function(){return"[object Generator]"})),(e.exports=o=function(){return{w:s,m:x}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var u=t[n]={exports:{}};return e[n].call(u.exports,u,u.exports,r),u.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";r(472)})()})();`,r=l(a.load,t),n=function(p){return r().clearInterval(p)},e=function(p){return r().clearTimeout(p)},o=function(){var p;return(p=r()).setInterval.apply(p,arguments)},u=function(){var p;return(p=r()).setTimeout.apply(p,arguments)};s.clearInterval=n,s.clearTimeout=e,s.setInterval=o,s.setTimeout=u})}),Rr=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0}),f.isReactNativeBrowser=f.isWebWorker=void 0;var i=()=>typeof window<"u"?typeof navigator<"u"&&navigator.userAgent?.toLowerCase().indexOf(" electron/")>-1&&Re?.versions?!Object.prototype.hasOwnProperty.call(Re.versions,"electron"):typeof window.document<"u":!1,s=()=>!!(typeof self=="object"&&self?.constructor?.name?.includes("WorkerGlobalScope")&&typeof Deno>"u"),a=()=>typeof navigator<"u"&&navigator.product==="ReactNative",l=i()||s()||a();f.isWebWorker=s(),f.isReactNativeBrowser=a(),f.default=l}),wu=de(f=>{le(),ce(),ue();var i=f&&f.__createBinding||(Object.create?function(o,u,p,d){d===void 0&&(d=p);var b=Object.getOwnPropertyDescriptor(u,p);(!b||("get"in b?!u.__esModule:b.writable||b.configurable))&&(b={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(o,d,b)}:function(o,u,p,d){d===void 0&&(d=p),o[d]=u[p]}),s=f&&f.__setModuleDefault||(Object.create?function(o,u){Object.defineProperty(o,"default",{enumerable:!0,value:u})}:function(o,u){o.default=u}),a=f&&f.__importStar||(function(){var o=function(u){return o=Object.getOwnPropertyNames||function(p){var d=[];for(var b in p)Object.prototype.hasOwnProperty.call(p,b)&&(d[d.length]=b);return d},o(u)};return function(u){if(u&&u.__esModule)return u;var p={};if(u!=null)for(var d=o(u),b=0;b<d.length;b++)d[b]!=="default"&&i(p,u,d[b]);return s(p,u),p}})();Object.defineProperty(f,"__esModule",{value:!0});var l=vu(),t=a(Rr()),r={set:l.setInterval,clear:l.clearInterval},n={set:(o,u)=>setInterval(o,u),clear:o=>clearInterval(o)},e=o=>{switch(o){case"native":return n;case"worker":return r;default:return t.default&&!t.isWebWorker&&!t.isReactNativeBrowser?r:n}};f.default=e}),ha=de(f=>{le(),ce(),ue();var i=f&&f.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(f,"__esModule",{value:!0});var s=i(wu()),a=class{_keepalive;timerId;timer;destroyed=!1;counter;client;_keepaliveTimeoutTimestamp;_intervalEvery;get keepaliveTimeoutTimestamp(){return this._keepaliveTimeoutTimestamp}get intervalEvery(){return this._intervalEvery}get keepalive(){return this._keepalive}constructor(l,t){this.client=l,this.timer=typeof t=="object"&&"set"in t&&"clear"in t?t:(0,s.default)(t),this.setKeepalive(l.options.keepalive)}clear(){this.timerId&&(this.timer.clear(this.timerId),this.timerId=null)}setKeepalive(l){if(l*=1e3,isNaN(l)||l<=0||l>2147483647)throw new Error(`Keepalive value must be an integer between 0 and 2147483647. Provided value is ${l}`);this._keepalive=l,this.reschedule(),this.client.log(`KeepaliveManager: set keepalive to ${l}ms`)}destroy(){this.clear(),this.destroyed=!0}reschedule(){if(this.destroyed)return;this.clear(),this.counter=0;let l=Math.ceil(this._keepalive*1.5);this._keepaliveTimeoutTimestamp=Date.now()+l,this._intervalEvery=Math.ceil(this._keepalive/2),this.timerId=this.timer.set(()=>{this.destroyed||(this.counter+=1,this.counter===2?this.client.sendPing():this.counter>2&&this.client.onKeepaliveTimeout())},this._intervalEvery)}};f.default=a}),Vn=de(f=>{le(),ce(),ue();var i=f&&f.__createBinding||(Object.create?function(v,A,E,k){k===void 0&&(k=E);var C=Object.getOwnPropertyDescriptor(A,E);(!C||("get"in C?!A.__esModule:C.writable||C.configurable))&&(C={enumerable:!0,get:function(){return A[E]}}),Object.defineProperty(v,k,C)}:function(v,A,E,k){k===void 0&&(k=E),v[k]=A[E]}),s=f&&f.__setModuleDefault||(Object.create?function(v,A){Object.defineProperty(v,"default",{enumerable:!0,value:A})}:function(v,A){v.default=A}),a=f&&f.__importStar||(function(){var v=function(A){return v=Object.getOwnPropertyNames||function(E){var k=[];for(var C in E)Object.prototype.hasOwnProperty.call(E,C)&&(k[k.length]=C);return k},v(A)};return function(A){if(A&&A.__esModule)return A;var E={};if(A!=null)for(var k=v(A),C=0;C<k.length;C++)k[C]!=="default"&&i(E,A,k[C]);return s(E,A),E}})(),l=f&&f.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(f,"__esModule",{value:!0});var t=l(Pl()),r=Tt(),n=l(Cl()),e=l(at()),o=a(Fs()),u=l(Ws()),p=l(Zl()),d=l(ia()),b=l(eu()),h=jt(),y=tu(),m=l(ha()),S=a(Rr()),g=globalThis.setImmediate||((...v)=>{let A=v.shift();(0,h.nextTick)(()=>{A(...v)})}),_={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:30*1e3,clean:!0,resubscribe:!0,subscribeBatchSize:null,writeCache:!0,timerVariant:"auto"},I=class Gn extends y.TypedEventEmitter{static VERSION=h.MQTTJS_VERSION;connected;disconnecting;disconnected;reconnecting;incomingStore;outgoingStore;options;queueQoSZero;_reconnectCount;log;messageIdProvider;outgoing;messageIdToTopic;noop;keepaliveManager;stream;queue;streamBuilder;_resubscribeTopics;connackTimer;reconnectTimer;_storeProcessing;_packetIdsDuringStoreProcessing;_storeProcessingQueue;_firstConnection;topicAliasRecv;topicAliasSend;_deferredReconnect;connackPacket;static defaultId(){return`mqttjs_${Math.random().toString(16).substr(2,8)}`}constructor(A,E){super(),this.options=E||{};for(let k in _)typeof this.options[k]>"u"?this.options[k]=_[k]:this.options[k]=E[k];this.log=this.options.log||(0,e.default)("mqttjs:client"),this.noop=this._noop.bind(this),this.log("MqttClient :: version:",Gn.VERSION),S.isWebWorker?this.log("MqttClient :: environment","webworker"):this.log("MqttClient :: environment",S.default?"browser":"node"),this.log("MqttClient :: options.protocol",E.protocol),this.log("MqttClient :: options.protocolVersion",E.protocolVersion),this.log("MqttClient :: options.username",E.username),this.log("MqttClient :: options.keepalive",E.keepalive),this.log("MqttClient :: options.reconnectPeriod",E.reconnectPeriod),this.log("MqttClient :: options.rejectUnauthorized",E.rejectUnauthorized),this.log("MqttClient :: options.properties.topicAliasMaximum",E.properties?E.properties.topicAliasMaximum:void 0),this.options.clientId=typeof E.clientId=="string"?E.clientId:Gn.defaultId(),this.log("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=E.protocolVersion===5&&E.customHandleAcks?E.customHandleAcks:(...k)=>{k[3](null,0)},this.options.writeCache||(t.default.writeToStream.cacheNumbers=!1),this.streamBuilder=A,this.messageIdProvider=typeof this.options.messageIdProvider>"u"?new d.default:this.options.messageIdProvider,this.outgoingStore=E.outgoingStore||new u.default,this.incomingStore=E.incomingStore||new u.default,this.queueQoSZero=E.queueQoSZero===void 0?!0:E.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.keepaliveManager=null,this.connected=!1,this.disconnecting=!1,this.reconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,E.properties&&E.properties.topicAliasMaximum>0&&(E.properties.topicAliasMaximum>65535?this.log("MqttClient :: options.properties.topicAliasMaximum is out of range"):this.topicAliasRecv=new b.default(E.properties.topicAliasMaximum)),this.on("connect",()=>{let{queue:k}=this,C=()=>{let P=k.shift();this.log("deliver :: entry %o",P);let L=null;if(!P){this._resubscribe();return}L=P.packet,this.log("deliver :: call _sendPacket for %o",L);let x=!0;L.messageId&&L.messageId!==0&&(this.messageIdProvider.register(L.messageId)||(x=!1)),x?this._sendPacket(L,q=>{P.cb&&P.cb(q),C()}):(this.log("messageId: %d has already used. The message is skipped and removed.",L.messageId),C())};this.log("connect :: sending queued packets"),C()}),this.on("close",()=>{this.log("close :: connected set to `false`"),this.connected=!1,this.log("close :: clearing connackTimer"),clearTimeout(this.connackTimer),this._destroyKeepaliveManager(),this.topicAliasRecv&&this.topicAliasRecv.clear(),this.log("close :: calling _setupReconnect"),this._setupReconnect()}),this.options.manualConnect||(this.log("MqttClient :: setting up stream"),this.connect())}handleAuth(A,E){E()}handleMessage(A,E){E()}_nextId(){return this.messageIdProvider.allocate()}getLastMessageId(){return this.messageIdProvider.getLastAllocated()}connect(){let A=new r.Writable,E=t.default.parser(this.options),k=null,C=[];this.log("connect :: calling method to clear reconnect"),this._clearReconnect(),this.disconnected&&!this.reconnecting&&(this.incomingStore=this.options.incomingStore||new u.default,this.outgoingStore=this.options.outgoingStore||new u.default,this.disconnecting=!1,this.disconnected=!1),this.log("connect :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),E.on("packet",D=>{this.log("parser :: on packet push to packets array."),C.push(D)});let P=()=>{this.log("work :: getting next packet in queue");let D=C.shift();if(D)this.log("work :: packet pulled from queue"),(0,p.default)(this,D,L);else{this.log("work :: no packets in queue");let U=k;k=null,this.log("work :: done flag is %s",!!U),U&&U()}},L=()=>{if(C.length)(0,h.nextTick)(P);else{let D=k;k=null,D()}};A._write=(D,U,ae)=>{k=ae,this.log("writable stream :: parsing buffer"),E.parse(D),P()};let x=D=>{this.log("streamErrorHandler :: error",D.message),D.code?(this.log("streamErrorHandler :: emitting error"),this.emit("error",D)):this.noop(D)};this.log("connect :: pipe stream to writable stream"),this.stream.pipe(A),this.stream.on("error",x),this.stream.on("close",()=>{this.log("(%s)stream :: on close",this.options.clientId),this._flushVolatile(),this.log("stream: emit close to MqttClient"),this.emit("close")}),this.log("connect: sending packet `connect`");let q={cmd:"connect",protocolId:this.options.protocolId,protocolVersion:this.options.protocolVersion,clean:this.options.clean,clientId:this.options.clientId,keepalive:this.options.keepalive,username:this.options.username,password:this.options.password,properties:this.options.properties};if(this.options.will&&(q.will={...this.options.will,payload:this.options.will?.payload}),this.topicAliasRecv&&(q.properties||(q.properties={}),this.topicAliasRecv&&(q.properties.topicAliasMaximum=this.topicAliasRecv.max)),this._writePacket(q),E.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return this.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket=="object"){let D={cmd:"auth",reasonCode:0,...this.options.authPacket};this._writePacket(D)}}return this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(()=>{this.log("!!connectTimeout hit!! Calling _cleanUp with force `true`"),this.emit("error",new Error("connack timeout")),this._cleanUp(!0)},this.options.connectTimeout),this}publish(A,E,k,C){this.log("publish :: message `%s` to topic `%s`",E,A);let{options:P}=this;typeof k=="function"&&(C=k,k=null),k=k||{},k={qos:0,retain:!1,dup:!1,...k};let{qos:L,retain:x,dup:q,properties:D,cbStorePut:U}=k;if(this._checkDisconnecting(C))return this;let ae=()=>{let Q=0;if((L===1||L===2)&&(Q=this._nextId(),Q===null))return this.log("No messageId left"),!1;let K={cmd:"publish",topic:A,payload:E,qos:L,retain:x,messageId:Q,dup:q};switch(P.protocolVersion===5&&(K.properties=D),this.log("publish :: qos",L),L){case 1:case 2:this.outgoing[K.messageId]={volatile:!1,cb:C||this.noop},this.log("MqttClient:publish: packet cmd: %s",K.cmd),this._sendPacket(K,void 0,U);break;default:this.log("MqttClient:publish: packet cmd: %s",K.cmd),this._sendPacket(K,C,U);break}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!ae())&&this._storeProcessingQueue.push({invoke:ae,cbStorePut:k.cbStorePut,callback:C}),this}publishAsync(A,E,k){return new Promise((C,P)=>{this.publish(A,E,k,(L,x)=>{L?P(L):C(x)})})}subscribe(A,E,k){let C=this.options.protocolVersion;typeof E=="function"&&(k=E),k=k||this.noop;let P=!1,L=[];typeof A=="string"?(A=[A],L=A):Array.isArray(A)?L=A:typeof A=="object"&&(P=A.resubscribe,delete A.resubscribe,L=Object.keys(A));let x=o.validateTopics(L);if(x!==null)return g(k,new Error(`Invalid topic ${x}`)),this;if(this._checkDisconnecting(k))return this.log("subscribe: discconecting true"),this;let q={qos:0};C===5&&(q.nl=!1,q.rap=!1,q.rh=0),E={...q,...E};let{properties:D}=E,U=[],ae=(re,F)=>{if(F=F||E,!Object.prototype.hasOwnProperty.call(this._resubscribeTopics,re)||this._resubscribeTopics[re].qos<F.qos||P){let Z={topic:re,qos:F.qos};C===5&&(Z.nl=F.nl,Z.rap=F.rap,Z.rh=F.rh,Z.properties=D),this.log("subscribe: pushing topic `%s` and qos `%s` to subs list",Z.topic,Z.qos),U.push(Z)}};if(Array.isArray(A)?A.forEach(re=>{this.log("subscribe: array topic %s",re),ae(re)}):Object.keys(A).forEach(re=>{this.log("subscribe: object topic %s, %o",re,A[re]),ae(re,A[re])}),!U.length)return k(null,[]),this;let Q=(re,F)=>{let Z={cmd:"subscribe",subscriptions:re,messageId:F};if(D&&(Z.properties=D),this.options.resubscribe){this.log("subscribe :: resubscribe true");let J=[];re.forEach(me=>{if(this.options.reconnectPeriod>0){let te={qos:me.qos};C===5&&(te.nl=me.nl||!1,te.rap=me.rap||!1,te.rh=me.rh||0,te.properties=me.properties),this._resubscribeTopics[me.topic]=te,J.push(me.topic)}}),this.messageIdToTopic[Z.messageId]=J}let R=new Promise((J,me)=>{this.outgoing[Z.messageId]={volatile:!0,cb(te,we){if(!te){let{granted:V}=we;for(let N=0;N<V.length;N+=1)re[N].qos=V[N]}te?me(new h.ErrorWithSubackPacket(te.message,we)):J(we)}}});return this.log("subscribe :: call _sendPacket"),this._sendPacket(Z),R},K=()=>{let re=this.options.subscribeBatchSize??U.length,F=[];for(let Z=0;Z<U.length;Z+=re){let R=U.slice(Z,Z+re),J=this._nextId();if(J===null)return this.log("No messageId left"),!1;F.push(Q(R,J))}return Promise.all(F).then(Z=>{k(null,U,Z.at(-1))}).catch(Z=>{k(Z,U,Z.packet)}),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!K())&&this._storeProcessingQueue.push({invoke:K,callback:k}),this}subscribeAsync(A,E){return new Promise((k,C)=>{this.subscribe(A,E,(P,L)=>{P?C(P):k(L)})})}unsubscribe(A,E,k){typeof A=="string"&&(A=[A]),typeof E=="function"&&(k=E),k=k||this.noop;let C=o.validateTopics(A);if(C!==null)return g(k,new Error(`Invalid topic ${C}`)),this;if(this._checkDisconnecting(k))return this;let P=()=>{let L=this._nextId();if(L===null)return this.log("No messageId left"),!1;let x={cmd:"unsubscribe",messageId:L,unsubscriptions:[]};return typeof A=="string"?x.unsubscriptions=[A]:Array.isArray(A)&&(x.unsubscriptions=A),this.options.resubscribe&&x.unsubscriptions.forEach(q=>{delete this._resubscribeTopics[q]}),typeof E=="object"&&E.properties&&(x.properties=E.properties),this.outgoing[x.messageId]={volatile:!0,cb:k},this.log("unsubscribe: call _sendPacket"),this._sendPacket(x),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!P())&&this._storeProcessingQueue.push({invoke:P,callback:k}),this}unsubscribeAsync(A,E){return new Promise((k,C)=>{this.unsubscribe(A,E,(P,L)=>{P?C(P):k(L)})})}end(A,E,k){this.log("end :: (%s)",this.options.clientId),(A==null||typeof A!="boolean")&&(k=k||E,E=A,A=!1),typeof E!="object"&&(k=k||E,E=null),this.log("end :: cb? %s",!!k),(!k||typeof k!="function")&&(k=this.noop);let C=()=>{this.log("end :: closeStores: closing incoming and outgoing stores"),this.disconnected=!0,this.incomingStore.close(L=>{this.outgoingStore.close(x=>{if(this.log("end :: closeStores: emitting end"),this.emit("end"),k){let q=L||x;this.log("end :: closeStores: invoking callback with args"),k(q)}})}),this._deferredReconnect?this._deferredReconnect():(this.options.reconnectPeriod===0||this.options.manualConnect)&&(this.disconnecting=!1)},P=()=>{this.log("end :: (%s) :: finish :: calling _cleanUp with force %s",this.options.clientId,A),this._cleanUp(A,()=>{this.log("end :: finish :: calling process.nextTick on closeStores"),(0,h.nextTick)(C)},E)};return this.disconnecting?(k(),this):(this._clearReconnect(),this.disconnecting=!0,!A&&Object.keys(this.outgoing).length>0?(this.log("end :: (%s) :: calling finish in 10ms once outgoing is empty",this.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,P,10))):(this.log("end :: (%s) :: immediately calling finish",this.options.clientId),P()),this)}endAsync(A,E){return new Promise((k,C)=>{this.end(A,E,P=>{P?C(P):k()})})}removeOutgoingMessage(A){if(this.outgoing[A]){let{cb:E}=this.outgoing[A];this._removeOutgoingAndStoreMessage(A,()=>{E(new Error("Message removed"))})}return this}reconnect(A){this.log("client reconnect");let E=()=>{A?(this.options.incomingStore=A.incomingStore,this.options.outgoingStore=A.outgoingStore):(this.options.incomingStore=null,this.options.outgoingStore=null),this.incomingStore=this.options.incomingStore||new u.default,this.outgoingStore=this.options.outgoingStore||new u.default,this.disconnecting=!1,this.disconnected=!1,this._deferredReconnect=null,this._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=E:E(),this}_flushVolatile(){this.outgoing&&(this.log("_flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(this.outgoing).forEach(A=>{this.outgoing[A].volatile&&typeof this.outgoing[A].cb=="function"&&(this.outgoing[A].cb(new Error("Connection closed")),delete this.outgoing[A])}))}_flush(){this.outgoing&&(this.log("_flush: queue exists? %b",!!this.outgoing),Object.keys(this.outgoing).forEach(A=>{typeof this.outgoing[A].cb=="function"&&(this.outgoing[A].cb(new Error("Connection closed")),delete this.outgoing[A])}))}_removeTopicAliasAndRecoverTopicName(A){let E;A.properties&&(E=A.properties.topicAlias);let k=A.topic.toString();if(this.log("_removeTopicAliasAndRecoverTopicName :: alias %d, topic %o",E,k),k.length===0){if(typeof E>"u")return new Error("Unregistered Topic Alias");if(k=this.topicAliasSend.getTopicByAlias(E),typeof k>"u")return new Error("Unregistered Topic Alias");A.topic=k}E&&delete A.properties.topicAlias}_checkDisconnecting(A){return this.disconnecting&&(A&&A!==this.noop?A(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting}_reconnect(){this.log("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this.connect()}),this.log("client already connected. disconnecting first.")):(this.log("_reconnect: calling connect"),this.connect())}_setupReconnect(){!this.disconnecting&&!this.reconnectTimer&&this.options.reconnectPeriod>0?(this.reconnecting||(this.log("_setupReconnect :: emit `offline` state"),this.emit("offline"),this.log("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),this.log("_setupReconnect :: setting reconnectTimer for %d ms",this.options.reconnectPeriod),this.reconnectTimer=setInterval(()=>{this.log("reconnectTimer :: reconnect triggered!"),this._reconnect()},this.options.reconnectPeriod)):this.log("_setupReconnect :: doing nothing...")}_clearReconnect(){this.log("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)}_cleanUp(A,E,k={}){if(E&&(this.log("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",E)),this.log("_cleanUp :: forced? %s",A),A)this.options.reconnectPeriod===0&&this.options.clean&&this._flush(),this.log("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{let C={cmd:"disconnect",...k};this.log("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(C,()=>{this.log("_cleanUp :: (%s) :: destroying stream",this.options.clientId),g(()=>{this.stream.end(()=>{this.log("_cleanUp :: (%s) :: stream destroyed",this.options.clientId)})})})}!this.disconnecting&&!this.reconnecting&&(this.log("_cleanUp :: client not disconnecting/reconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this._destroyKeepaliveManager(),E&&!this.connected&&(this.log("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",E),E())}_storeAndSend(A,E,k){this.log("storeAndSend :: store packet with cmd %s to outgoingStore",A.cmd);let C=A,P;if(C.cmd==="publish"&&(C=(0,n.default)(A),P=this._removeTopicAliasAndRecoverTopicName(C),P))return E&&E(P);this.outgoingStore.put(C,L=>{if(L)return E&&E(L);k(),this._writePacket(A,E)})}_applyTopicAlias(A){if(this.options.protocolVersion===5&&A.cmd==="publish"){let E;A.properties&&(E=A.properties.topicAlias);let k=A.topic.toString();if(this.topicAliasSend)if(E){if(k.length!==0&&(this.log("applyTopicAlias :: register topic: %s - alias: %d",k,E),!this.topicAliasSend.put(k,E)))return this.log("applyTopicAlias :: error out of range. topic: %s - alias: %d",k,E),new Error("Sending Topic Alias out of range")}else k.length!==0&&(this.options.autoAssignTopicAlias?(E=this.topicAliasSend.getAliasByTopic(k),E?(A.topic="",A.properties={...A.properties,topicAlias:E},this.log("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",k,E)):(E=this.topicAliasSend.getLruAlias(),this.topicAliasSend.put(k,E),A.properties={...A.properties,topicAlias:E},this.log("applyTopicAlias :: auto assign topic: %s - alias: %d",k,E))):this.options.autoUseTopicAlias&&(E=this.topicAliasSend.getAliasByTopic(k),E&&(A.topic="",A.properties={...A.properties,topicAlias:E},this.log("applyTopicAlias :: auto use topic: %s - alias: %d",k,E))));else if(E)return this.log("applyTopicAlias :: error out of range. topic: %s - alias: %d",k,E),new Error("Sending Topic Alias out of range")}}_noop(A){this.log("noop ::",A)}_writePacket(A,E){this.log("_writePacket :: packet: %O",A),this.log("_writePacket :: emitting `packetsend`"),this.emit("packetsend",A),this.log("_writePacket :: writing to stream");let k=t.default.writeToStream(A,this.stream,this.options);this.log("_writePacket :: writeToStream result %s",k),!k&&E&&E!==this.noop?(this.log("_writePacket :: handle events on `drain` once through callback."),this.stream.once("drain",E)):E&&(this.log("_writePacket :: invoking cb"),E())}_sendPacket(A,E,k,C){this.log("_sendPacket :: (%s) :: start",this.options.clientId),k=k||this.noop,E=E||this.noop;let P=this._applyTopicAlias(A);if(P){E(P);return}if(!this.connected){if(A.cmd==="auth"){this._writePacket(A,E);return}this.log("_sendPacket :: client not connected. Storing packet offline."),this._storePacket(A,E,k);return}if(C){this._writePacket(A,E);return}switch(A.cmd){case"publish":break;case"pubrel":this._storeAndSend(A,E,k);return;default:this._writePacket(A,E);return}switch(A.qos){case 2:case 1:this._storeAndSend(A,E,k);break;default:this._writePacket(A,E);break}this.log("_sendPacket :: (%s) :: end",this.options.clientId)}_storePacket(A,E,k){this.log("_storePacket :: packet: %o",A),this.log("_storePacket :: cb? %s",!!E),k=k||this.noop;let C=A;if(C.cmd==="publish"){C=(0,n.default)(A);let L=this._removeTopicAliasAndRecoverTopicName(C);if(L)return E&&E(L)}let P=C.qos||0;P===0&&this.queueQoSZero||C.cmd!=="publish"?this.queue.push({packet:C,cb:E}):P>0?(E=this.outgoing[C.messageId]?this.outgoing[C.messageId].cb:null,this.outgoingStore.put(C,L=>{if(L)return E&&E(L);k()})):E&&E(new Error("No connection to broker"))}_setupKeepaliveManager(){this.log("_setupKeepaliveManager :: keepalive %d (seconds)",this.options.keepalive),!this.keepaliveManager&&this.options.keepalive&&(this.keepaliveManager=new m.default(this,this.options.timerVariant))}_destroyKeepaliveManager(){this.keepaliveManager&&(this.log("_destroyKeepaliveManager :: destroying keepalive manager"),this.keepaliveManager.destroy(),this.keepaliveManager=null)}reschedulePing(A=!1){this.keepaliveManager&&this.options.keepalive&&(A||this.options.reschedulePings)&&this._reschedulePing()}_reschedulePing(){this.log("_reschedulePing :: rescheduling ping"),this.keepaliveManager.reschedule()}sendPing(){this.log("_sendPing :: sending pingreq"),this._sendPacket({cmd:"pingreq"})}onKeepaliveTimeout(){this.emit("error",new Error("Keepalive timeout")),this.log("onKeepaliveTimeout :: calling _cleanUp with force true"),this._cleanUp(!0)}_resubscribe(){this.log("_resubscribe");let A=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||this.options.protocolVersion>=4&&!this.connackPacket.sessionPresent)&&A.length>0)if(this.options.resubscribe)if(this.options.protocolVersion===5){this.log("_resubscribe: protocolVersion 5");for(let E=0;E<A.length;E++){let k={};k[A[E]]=this._resubscribeTopics[A[E]],k.resubscribe=!0,this.subscribe(k,{properties:k[A[E]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1}_onConnect(A){if(this.disconnected){this.emit("connect",A);return}this.connackPacket=A,this.messageIdProvider.clear(),this._setupKeepaliveManager(),this.connected=!0;let E=()=>{let k=this.outgoingStore.createStream(),C=()=>{k.destroy(),k=null,this._flushStoreProcessingQueue(),P()},P=()=>{this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={}};this.once("close",C),k.on("error",x=>{P(),this._flushStoreProcessingQueue(),this.removeListener("close",C),this.emit("error",x)});let L=()=>{if(!k)return;let x=k.read(1),q;if(!x){k.once("readable",L);return}if(this._storeProcessing=!0,this._packetIdsDuringStoreProcessing[x.messageId]){L();return}!this.disconnecting&&!this.reconnectTimer?(q=this.outgoing[x.messageId]?this.outgoing[x.messageId].cb:null,this.outgoing[x.messageId]={volatile:!1,cb(D,U){q&&q(D,U),L()}},this._packetIdsDuringStoreProcessing[x.messageId]=!0,this.messageIdProvider.register(x.messageId)?this._sendPacket(x,void 0,void 0,!0):this.log("messageId: %d has already used.",x.messageId)):k.destroy&&k.destroy()};k.on("end",()=>{let x=!0;for(let q in this._packetIdsDuringStoreProcessing)if(!this._packetIdsDuringStoreProcessing[q]){x=!1;break}this.removeListener("close",C),x?(P(),this._invokeAllStoreProcessingQueue(),this.emit("connect",A)):E()}),L()};E()}_invokeStoreProcessingQueue(){if(!this._storeProcessing&&this._storeProcessingQueue.length>0){let A=this._storeProcessingQueue[0];if(A&&A.invoke())return this._storeProcessingQueue.shift(),!0}return!1}_invokeAllStoreProcessingQueue(){for(;this._invokeStoreProcessingQueue(););}_flushStoreProcessingQueue(){for(let A of this._storeProcessingQueue)A.cbStorePut&&A.cbStorePut(new Error("Connection closed")),A.callback&&A.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)}_removeOutgoingAndStoreMessage(A,E){delete this.outgoing[A],this.outgoingStore.del({messageId:A},(k,C)=>{E(k,C),this.messageIdProvider.deallocate(A),this._invokeStoreProcessingQueue()})}};f.default=I}),_u=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=na(),s=class{numberAllocator;lastId;constructor(){this.numberAllocator=new i.NumberAllocator(1,65535)}allocate(){return this.lastId=this.numberAllocator.alloc(),this.lastId}getLastAllocated(){return this.lastId}register(a){return this.numberAllocator.use(a)}deallocate(a){this.numberAllocator.free(a)}clear(){this.numberAllocator.clear()}};f.default=s});function Su(){if(Qn)return tr;Qn=!0;let f=2147483647,i=36,s=1,a=26,l=38,t=700,r=72,n=128,e="-",o=/^xn--/,u=/[^\0-\x7F]/,p=/[\x2E\u3002\uFF0E\uFF61]/g,d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},b=i-s,h=Math.floor,y=String.fromCharCode;function m(P){throw new RangeError(d[P])}function S(P,L){let x=[],q=P.length;for(;q--;)x[q]=L(P[q]);return x}function g(P,L){let x=P.split("@"),q="";x.length>1&&(q=x[0]+"@",P=x[1]),P=P.replace(p,".");let D=P.split("."),U=S(D,L).join(".");return q+U}function _(P){let L=[],x=0,q=P.length;for(;x<q;){let D=P.charCodeAt(x++);if(D>=55296&&D<=56319&&x<q){let U=P.charCodeAt(x++);(U&64512)==56320?L.push(((D&1023)<<10)+(U&1023)+65536):(L.push(D),x--)}else L.push(D)}return L}let I=P=>String.fromCodePoint(...P),v=function(P){return P>=48&&P<58?26+(P-48):P>=65&&P<91?P-65:P>=97&&P<123?P-97:i},A=function(P,L){return P+22+75*(P<26)-((L!=0)<<5)},E=function(P,L,x){let q=0;for(P=x?h(P/t):P>>1,P+=h(P/L);P>b*a>>1;q+=i)P=h(P/b);return h(q+(b+1)*P/(P+l))},k=function(P){let L=[],x=P.length,q=0,D=n,U=r,ae=P.lastIndexOf(e);ae<0&&(ae=0);for(let Q=0;Q<ae;++Q)P.charCodeAt(Q)>=128&&m("not-basic"),L.push(P.charCodeAt(Q));for(let Q=ae>0?ae+1:0;Q<x;){let K=q;for(let F=1,Z=i;;Z+=i){Q>=x&&m("invalid-input");let R=v(P.charCodeAt(Q++));R>=i&&m("invalid-input"),R>h((f-q)/F)&&m("overflow"),q+=R*F;let J=Z<=U?s:Z>=U+a?a:Z-U;if(R<J)break;let me=i-J;F>h(f/me)&&m("overflow"),F*=me}let re=L.length+1;U=E(q-K,re,K==0),h(q/re)>f-D&&m("overflow"),D+=h(q/re),q%=re,L.splice(q++,0,D)}return String.fromCodePoint(...L)},C=function(P){let L=[];P=_(P);let x=P.length,q=n,D=0,U=r;for(let K of P)K<128&&L.push(y(K));let ae=L.length,Q=ae;for(ae&&L.push(e);Q<x;){let K=f;for(let F of P)F>=q&&F<K&&(K=F);let re=Q+1;K-q>h((f-D)/re)&&m("overflow"),D+=(K-q)*re,q=K;for(let F of P)if(F<q&&++D>f&&m("overflow"),F===q){let Z=D;for(let R=i;;R+=i){let J=R<=U?s:R>=U+a?a:R-U;if(Z<J)break;let me=Z-J,te=i-J;L.push(y(A(J+me%te,0))),Z=h(me/te)}L.push(y(A(Z,0))),U=E(D,re,Q===ae),D=0,++Q}++D,++q}return L.join("")};return tr={version:"2.3.1",ucs2:{decode:_,encode:I},decode:k,encode:C,toASCII:function(P){return g(P,function(L){return u.test(L)?"xn--"+C(L):L})},toUnicode:function(P){return g(P,function(L){return o.test(L)?k(L.slice(4).toLowerCase()):L})}},tr}var tr,Qn,dt,Eu=He(()=>{le(),ce(),ue(),tr={},Qn=!1,dt=Su(),dt.decode,dt.encode,dt.toASCII,dt.toUnicode,dt.ucs2,dt.version});function Au(){return Jn||(Jn=!0,Yn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var f={},i=Symbol("test"),s=Object(i);if(typeof i=="string"||Object.prototype.toString.call(i)!=="[object Symbol]"||Object.prototype.toString.call(s)!=="[object Symbol]")return!1;var a=42;f[i]=a;for(i in f)return!1;if(typeof Object.keys=="function"&&Object.keys(f).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(f).length!==0)return!1;var l=Object.getOwnPropertySymbols(f);if(l.length!==1||l[0]!==i||!Object.prototype.propertyIsEnumerable.call(f,i))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var t=Object.getOwnPropertyDescriptor(f,i);if(t.value!==a||t.enumerable!==!0)return!1}return!0}),Yn}function Iu(){return Zn||(Zn=!0,Xn=Error),Xn}function Tu(){return ti||(ti=!0,ei=EvalError),ei}function ku(){return ni||(ni=!0,ri=RangeError),ri}function xu(){return oi||(oi=!0,ii=ReferenceError),ii}function fa(){return ai||(ai=!0,si=SyntaxError),si}function Gt(){return ui||(ui=!0,li=TypeError),li}function Ou(){return hi||(hi=!0,ci=URIError),ci}function Pu(){if(fi)return rr;fi=!0;var f=typeof Symbol<"u"&&Symbol,i=Au();return rr=function(){return typeof f!="function"||typeof Symbol!="function"||typeof f("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:i()},rr}function Ru(){if(pi)return nr;pi=!0;var f={__proto__:null,foo:{}},i=Object;return nr=function(){return{__proto__:f}.foo===f.foo&&!(f instanceof i)},nr}function Cu(){if(di)return ir;di=!0;var f="Function.prototype.bind called on incompatible ",i=Object.prototype.toString,s=Math.max,a="[object Function]",l=function(n,e){for(var o=[],u=0;u<n.length;u+=1)o[u]=n[u];for(var p=0;p<e.length;p+=1)o[p+n.length]=e[p];return o},t=function(n,e){for(var o=[],u=e,p=0;u<n.length;u+=1,p+=1)o[p]=n[u];return o},r=function(n,e){for(var o="",u=0;u<n.length;u+=1)o+=n[u],u+1<n.length&&(o+=e);return o};return ir=function(n){var e=this;if(typeof e!="function"||i.apply(e)!==a)throw new TypeError(f+e);for(var o=t(arguments,1),u,p=function(){if(this instanceof u){var m=e.apply(this,l(o,arguments));return Object(m)===m?m:this}return e.apply(n,l(o,arguments))},d=s(0,e.length-o.length),b=[],h=0;h<d;h++)b[h]="$"+h;if(u=Function("binder","return function ("+r(b,",")+"){ return binder.apply(this,arguments); }")(p),e.prototype){var y=function(){};y.prototype=e.prototype,u.prototype=new y,y.prototype=null}return u},ir}function $i(){if(gi)return or;gi=!0;var f=Cu();return or=Function.prototype.bind||f,or}function Mu(){if(yi)return sr;yi=!0;var f=Function.prototype.call,i=Object.prototype.hasOwnProperty,s=$i();return sr=s.call(f,i),sr}function Nt(){if(mi)return ar;mi=!0;var f,i=Iu(),s=Tu(),a=ku(),l=xu(),t=fa(),r=Gt(),n=Ou(),e=Function,o=function(Q){try{return e('"use strict"; return ('+Q+").constructor;")()}catch{}},u=Object.getOwnPropertyDescriptor;if(u)try{u({},"")}catch{u=null}var p=function(){throw new r},d=u?(function(){try{return arguments.callee,p}catch{try{return u(arguments,"callee").get}catch{return p}}})():p,b=Pu()(),h=Ru()(),y=Object.getPrototypeOf||(h?function(Q){return Q.__proto__}:null),m={},S=typeof Uint8Array>"u"||!y?f:y(Uint8Array),g={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?f:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?f:ArrayBuffer,"%ArrayIteratorPrototype%":b&&y?y([][Symbol.iterator]()):f,"%AsyncFromSyncIteratorPrototype%":f,"%AsyncFunction%":m,"%AsyncGenerator%":m,"%AsyncGeneratorFunction%":m,"%AsyncIteratorPrototype%":m,"%Atomics%":typeof Atomics>"u"?f:Atomics,"%BigInt%":typeof BigInt>"u"?f:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?f:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?f:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?f:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":s,"%Float32Array%":typeof Float32Array>"u"?f:Float32Array,"%Float64Array%":typeof Float64Array>"u"?f:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?f:FinalizationRegistry,"%Function%":e,"%GeneratorFunction%":m,"%Int8Array%":typeof Int8Array>"u"?f:Int8Array,"%Int16Array%":typeof Int16Array>"u"?f:Int16Array,"%Int32Array%":typeof Int32Array>"u"?f:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":b&&y?y(y([][Symbol.iterator]())):f,"%JSON%":typeof JSON=="object"?JSON:f,"%Map%":typeof Map>"u"?f:Map,"%MapIteratorPrototype%":typeof Map>"u"||!b||!y?f:y(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?f:Promise,"%Proxy%":typeof Proxy>"u"?f:Proxy,"%RangeError%":a,"%ReferenceError%":l,"%Reflect%":typeof Reflect>"u"?f:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?f:Set,"%SetIteratorPrototype%":typeof Set>"u"||!b||!y?f:y(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?f:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":b&&y?y(""[Symbol.iterator]()):f,"%Symbol%":b?Symbol:f,"%SyntaxError%":t,"%ThrowTypeError%":d,"%TypedArray%":S,"%TypeError%":r,"%Uint8Array%":typeof Uint8Array>"u"?f:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?f:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?f:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?f:Uint32Array,"%URIError%":n,"%WeakMap%":typeof WeakMap>"u"?f:WeakMap,"%WeakRef%":typeof WeakRef>"u"?f:WeakRef,"%WeakSet%":typeof WeakSet>"u"?f:WeakSet};if(y)try{null.error}catch(Q){var _=y(y(Q));g["%Error.prototype%"]=_}var I=function Q(K){var re;if(K==="%AsyncFunction%")re=o("async function () {}");else if(K==="%GeneratorFunction%")re=o("function* () {}");else if(K==="%AsyncGeneratorFunction%")re=o("async function* () {}");else if(K==="%AsyncGenerator%"){var F=Q("%AsyncGeneratorFunction%");F&&(re=F.prototype)}else if(K==="%AsyncIteratorPrototype%"){var Z=Q("%AsyncGenerator%");Z&&y&&(re=y(Z.prototype))}return g[K]=re,re},v={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},A=$i(),E=Mu(),k=A.call(Function.call,Array.prototype.concat),C=A.call(Function.apply,Array.prototype.splice),P=A.call(Function.call,String.prototype.replace),L=A.call(Function.call,String.prototype.slice),x=A.call(Function.call,RegExp.prototype.exec),q=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,D=/\\(\\)?/g,U=function(Q){var K=L(Q,0,1),re=L(Q,-1);if(K==="%"&&re!=="%")throw new t("invalid intrinsic syntax, expected closing `%`");if(re==="%"&&K!=="%")throw new t("invalid intrinsic syntax, expected opening `%`");var F=[];return P(Q,q,function(Z,R,J,me){F[F.length]=J?P(me,D,"$1"):R||Z}),F},ae=function(Q,K){var re=Q,F;if(E(v,re)&&(F=v[re],re="%"+F[0]+"%"),E(g,re)){var Z=g[re];if(Z===m&&(Z=I(re)),typeof Z>"u"&&!K)throw new r("intrinsic "+Q+" exists, but is not available. Please file an issue!");return{alias:F,name:re,value:Z}}throw new t("intrinsic "+Q+" does not exist!")};return ar=function(Q,K){if(typeof Q!="string"||Q.length===0)throw new r("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof K!="boolean")throw new r('"allowMissing" argument must be a boolean');if(x(/^%?[^%]*%?$/,Q)===null)throw new t("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var re=U(Q),F=re.length>0?re[0]:"",Z=ae("%"+F+"%",K),R=Z.name,J=Z.value,me=!1,te=Z.alias;te&&(F=te[0],C(re,k([0,1],te)));for(var we=1,V=!0;we<re.length;we+=1){var N=re[we],ne=L(N,0,1),H=L(N,-1);if((ne==='"'||ne==="'"||ne==="`"||H==='"'||H==="'"||H==="`")&&ne!==H)throw new t("property names with quotes must have matching quotes");if((N==="constructor"||!V)&&(me=!0),F+="."+N,R="%"+F+"%",E(g,R))J=g[R];else if(J!=null){if(!(N in J)){if(!K)throw new r("base intrinsic for "+Q+" exists, but the property is not available.");return}if(u&&we+1>=re.length){var G=u(J,N);V=!!G,V&&"get"in G&&!("originalValue"in G.get)?J=G.get:J=J[N]}else V=E(J,N),J=J[N];V&&!me&&(g[R]=J)}}return J},ar}function Hi(){if(bi)return lr;bi=!0;var f=Nt(),i=f("%Object.defineProperty%",!0)||!1;if(i)try{i({},"a",{value:1})}catch{i=!1}return lr=i,lr}function pa(){if(vi)return ur;vi=!0;var f=Nt(),i=f("%Object.getOwnPropertyDescriptor%",!0);if(i)try{i([],"length")}catch{i=null}return ur=i,ur}function ju(){if(wi)return cr;wi=!0;var f=Hi(),i=fa(),s=Gt(),a=pa();return cr=function(l,t,r){if(!l||typeof l!="object"&&typeof l!="function")throw new s("`obj` must be an object or a function`");if(typeof t!="string"&&typeof t!="symbol")throw new s("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new s("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new s("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new s("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new s("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,e=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,p=!!a&&a(l,t);if(f)f(l,t,{configurable:o===null&&p?p.configurable:!o,enumerable:n===null&&p?p.enumerable:!n,value:r,writable:e===null&&p?p.writable:!e});else if(u||!n&&!e&&!o)l[t]=r;else throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},cr}function Nu(){if(_i)return hr;_i=!0;var f=Hi(),i=function(){return!!f};return i.hasArrayLengthDefineBug=function(){if(!f)return null;try{return f([],"length",{value:1}).length!==1}catch{return!0}},hr=i,hr}function Uu(){if(Si)return fr;Si=!0;var f=Nt(),i=ju(),s=Nu()(),a=pa(),l=Gt(),t=f("%Math.floor%");return fr=function(r,n){if(typeof r!="function")throw new l("`fn` is not a function");if(typeof n!="number"||n<0||n>4294967295||t(n)!==n)throw new l("`length` must be a positive 32-bit integer");var e=arguments.length>2&&!!arguments[2],o=!0,u=!0;if("length"in r&&a){var p=a(r,"length");p&&!p.configurable&&(o=!1),p&&!p.writable&&(u=!1)}return(o||u||!e)&&(s?i(r,"length",n,!0,!0):i(r,"length",n)),r},fr}function Bu(){if(Ei)return Rt;Ei=!0;var f=$i(),i=Nt(),s=Uu(),a=Gt(),l=i("%Function.prototype.apply%"),t=i("%Function.prototype.call%"),r=i("%Reflect.apply%",!0)||f.call(t,l),n=Hi(),e=i("%Math.max%");Rt=function(u){if(typeof u!="function")throw new a("a function is required");var p=r(f,t,arguments);return s(p,1+e(0,u.length-(arguments.length-1)),!0)};var o=function(){return r(f,l,arguments)};return n?n(Rt,"apply",{value:o}):Rt.apply=o,Rt}function Lu(){if(Ai)return pr;Ai=!0;var f=Nt(),i=Bu(),s=i(f("String.prototype.indexOf"));return pr=function(a,l){var t=f(a,!!l);return typeof t=="function"&&s(a,".prototype.")>-1?i(t):t},pr}var Yn,Jn,Xn,Zn,ei,ti,ri,ni,ii,oi,si,ai,li,ui,ci,hi,rr,fi,nr,pi,ir,di,or,gi,sr,yi,ar,mi,lr,bi,ur,vi,cr,wi,hr,_i,fr,Si,Rt,Ei,pr,Ai,Du=He(()=>{le(),ce(),ue(),Yn={},Jn=!1,Xn={},Zn=!1,ei={},ti=!1,ri={},ni=!1,ii={},oi=!1,si={},ai=!1,li={},ui=!1,ci={},hi=!1,rr={},fi=!1,nr={},pi=!1,ir={},di=!1,or={},gi=!1,sr={},yi=!1,ar={},mi=!1,lr={},bi=!1,ur={},vi=!1,cr={},wi=!1,hr={},_i=!1,fr={},Si=!1,Rt={},Ei=!1,pr={},Ai=!1});function zi(f){throw new Error("Node.js process "+f+" is not supported by JSPM core outside of Node.js")}function Fu(){!Et||!_t||(Et=!1,_t.length?et=_t.concat(et):zt=-1,et.length&&da())}function da(){if(!Et){var f=setTimeout(Fu,0);Et=!0;for(var i=et.length;i;){for(_t=et,et=[];++zt<i;)_t&&_t[zt].run();zt=-1,i=et.length}_t=null,Et=!1,clearTimeout(f)}}function Wu(f){var i=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)i[s-1]=arguments[s];et.push(new ga(f,i)),et.length===1&&!Et&&setTimeout(da,0)}function ga(f,i){this.fun=f,this.array=i}function De(){}function qu(f){zi("_linkedBinding")}function $u(f){zi("dlopen")}function Hu(){return[]}function zu(){return[]}function Ku(f,i){if(!f)throw new Error(i||"assertion error")}function Vu(){return!1}function Gu(){return ot.now()/1e3}function jr(f){var i=Math.floor((Date.now()-ot.now())*.001),s=ot.now()*.001,a=Math.floor(s)+i,l=Math.floor(s%1*1e9);return f&&(a=a-f[0],l=l-f[1],l<0&&(a--,l+=dr)),[a,l]}function ft(){return Ki}function Qu(f){return[]}var et,Et,_t,zt,Ji,Xi,Zi,eo,to,ro,no,io,oo,so,ao,lo,uo,co,ho,fo,po,go,yo,mo,bo,Jt,vo,wo,_o,So,Eo,Ao,Io,To,ko,xo,Oo,Po,Ro,Co,Mo,jo,No,Uo,Bo,Lo,Do,Fo,Wo,qo,$o,ot,Nr,dr,Ho,zo,Ko,Vo,Go,Qo,Yo,Jo,Xo,Zo,es,Ki,ya=He(()=>{le(),ce(),ue(),et=[],Et=!1,zt=-1,ga.prototype.run=function(){this.fun.apply(null,this.array)},Ji="browser",Xi="x64",Zi="browser",eo={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},to=["/usr/bin/node"],ro=[],no="v16.8.0",io={},oo=function(f,i){console.warn((i?i+": ":"")+f)},so=function(f){zi("binding")},ao=function(f){return 0},lo=function(){return"/"},uo=function(f){},co={name:"node",sourceUrl:"",headersUrl:"",libUrl:""},ho=De,fo=[],po={},go=!1,yo={},mo=De,bo=De,Jt=function(){return{}},vo=Jt,wo=Jt,_o=De,So=De,Eo=De,Ao={},Io={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},To=De,ko=De,xo=De,Oo=De,Po=De,Ro=De,Co=De,Mo=void 0,jo=void 0,No=void 0,Uo=De,Bo=2,Lo=1,Do="/bin/usr/node",Fo=9229,Wo="node",qo=[],$o=De,ot={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0},ot.now===void 0&&(Nr=Date.now(),ot.timing&&ot.timing.navigationStart&&(Nr=ot.timing.navigationStart),ot.now=()=>Date.now()-Nr),dr=1e9,jr.bigint=function(f){var i=jr(f);return typeof BigInt>"u"?i[0]*dr+i[1]:BigInt(i[0]*dr)+BigInt(i[1])},Ho=10,zo={},Ko=0,Vo=ft,Go=ft,Qo=ft,Yo=ft,Jo=ft,Xo=De,Zo=ft,es=ft,Ki={version:no,versions:io,arch:Xi,platform:Zi,release:co,_rawDebug:ho,moduleLoadList:fo,binding:so,_linkedBinding:qu,_events:zo,_eventsCount:Ko,_maxListeners:Ho,on:ft,addListener:Vo,once:Go,off:Qo,removeListener:Yo,removeAllListeners:Jo,emit:Xo,prependListener:Zo,prependOnceListener:es,listeners:Qu,domain:po,_exiting:go,config:yo,dlopen:$u,uptime:Gu,_getActiveRequests:Hu,_getActiveHandles:zu,reallyExit:mo,_kill:bo,cpuUsage:Jt,resourceUsage:vo,memoryUsage:wo,kill:_o,exit:So,openStdin:Eo,allowedNodeEnvironmentFlags:Ao,assert:Ku,features:Io,_fatalExceptions:To,setUncaughtExceptionCaptureCallback:ko,hasUncaughtExceptionCaptureCallback:Vu,emitWarning:oo,nextTick:Wu,_tickCallback:xo,_debugProcess:Oo,_debugEnd:Po,_startProfilerIdleNotifier:Ro,_stopProfilerIdleNotifier:Co,stdout:Mo,stdin:No,stderr:jo,abort:Uo,umask:ao,chdir:uo,cwd:lo,env:eo,title:Ji,argv:to,execArgv:ro,pid:Bo,ppid:Lo,execPath:Do,debugPort:Fo,hrtime:jr,argv0:Wo,_preload_modules:qo,setSourceMapsEnabled:$o}});function Yu(){if(Ii)return gr;Ii=!0;var f=Ki;function i(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}function s(t,r){for(var n="",e=0,o=-1,u=0,p,d=0;d<=t.length;++d){if(d<t.length)p=t.charCodeAt(d);else{if(p===47)break;p=47}if(p===47){if(!(o===d-1||u===1))if(o!==d-1&&u===2){if(n.length<2||e!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var b=n.lastIndexOf("/");if(b!==n.length-1){b===-1?(n="",e=0):(n=n.slice(0,b),e=n.length-1-n.lastIndexOf("/")),o=d,u=0;continue}}else if(n.length===2||n.length===1){n="",e=0,o=d,u=0;continue}}r&&(n.length>0?n+="/..":n="..",e=2)}else n.length>0?n+="/"+t.slice(o+1,d):n=t.slice(o+1,d),e=d-o-1;o=d,u=0}else p===46&&u!==-1?++u:u=-1}return n}function a(t,r){var n=r.dir||r.root,e=r.base||(r.name||"")+(r.ext||"");return n?n===r.root?n+e:n+t+e:e}var l={resolve:function(){for(var t="",r=!1,n,e=arguments.length-1;e>=-1&&!r;e--){var o;e>=0?o=arguments[e]:(n===void 0&&(n=f.cwd()),o=n),i(o),o.length!==0&&(t=o+"/"+t,r=o.charCodeAt(0)===47)}return t=s(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(i(t),t.length===0)return".";var r=t.charCodeAt(0)===47,n=t.charCodeAt(t.length-1)===47;return t=s(t,!r),t.length===0&&!r&&(t="."),t.length>0&&n&&(t+="/"),r?"/"+t:t},isAbsolute:function(t){return i(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,r=0;r<arguments.length;++r){var n=arguments[r];i(n),n.length>0&&(t===void 0?t=n:t+="/"+n)}return t===void 0?".":l.normalize(t)},relative:function(t,r){if(i(t),i(r),t===r||(t=l.resolve(t),r=l.resolve(r),t===r))return"";for(var n=1;n<t.length&&t.charCodeAt(n)===47;++n);for(var e=t.length,o=e-n,u=1;u<r.length&&r.charCodeAt(u)===47;++u);for(var p=r.length,d=p-u,b=o<d?o:d,h=-1,y=0;y<=b;++y){if(y===b){if(d>b){if(r.charCodeAt(u+y)===47)return r.slice(u+y+1);if(y===0)return r.slice(u+y)}else o>b&&(t.charCodeAt(n+y)===47?h=y:y===0&&(h=0));break}var m=t.charCodeAt(n+y),S=r.charCodeAt(u+y);if(m!==S)break;m===47&&(h=y)}var g="";for(y=n+h+1;y<=e;++y)(y===e||t.charCodeAt(y)===47)&&(g.length===0?g+="..":g+="/..");return g.length>0?g+r.slice(u+h):(u+=h,r.charCodeAt(u)===47&&++u,r.slice(u))},_makeLong:function(t){return t},dirname:function(t){if(i(t),t.length===0)return".";for(var r=t.charCodeAt(0),n=r===47,e=-1,o=!0,u=t.length-1;u>=1;--u)if(r=t.charCodeAt(u),r===47){if(!o){e=u;break}}else o=!1;return e===-1?n?"/":".":n&&e===1?"//":t.slice(0,e)},basename:function(t,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');i(t);var n=0,e=-1,o=!0,u;if(r!==void 0&&r.length>0&&r.length<=t.length){if(r.length===t.length&&r===t)return"";var p=r.length-1,d=-1;for(u=t.length-1;u>=0;--u){var b=t.charCodeAt(u);if(b===47){if(!o){n=u+1;break}}else d===-1&&(o=!1,d=u+1),p>=0&&(b===r.charCodeAt(p)?--p===-1&&(e=u):(p=-1,e=d))}return n===e?e=d:e===-1&&(e=t.length),t.slice(n,e)}else{for(u=t.length-1;u>=0;--u)if(t.charCodeAt(u)===47){if(!o){n=u+1;break}}else e===-1&&(o=!1,e=u+1);return e===-1?"":t.slice(n,e)}},extname:function(t){i(t);for(var r=-1,n=0,e=-1,o=!0,u=0,p=t.length-1;p>=0;--p){var d=t.charCodeAt(p);if(d===47){if(!o){n=p+1;break}continue}e===-1&&(o=!1,e=p+1),d===46?r===-1?r=p:u!==1&&(u=1):r!==-1&&(u=-1)}return r===-1||e===-1||u===0||u===1&&r===e-1&&r===n+1?"":t.slice(r,e)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return a("/",t)},parse:function(t){i(t);var r={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return r;var n=t.charCodeAt(0),e=n===47,o;e?(r.root="/",o=1):o=0;for(var u=-1,p=0,d=-1,b=!0,h=t.length-1,y=0;h>=o;--h){if(n=t.charCodeAt(h),n===47){if(!b){p=h+1;break}continue}d===-1&&(b=!1,d=h+1),n===46?u===-1?u=h:y!==1&&(y=1):u!==-1&&(y=-1)}return u===-1||d===-1||y===0||y===1&&u===d-1&&u===p+1?d!==-1&&(p===0&&e?r.base=r.name=t.slice(1,d):r.base=r.name=t.slice(p,d)):(p===0&&e?(r.name=t.slice(1,u),r.base=t.slice(1,d)):(r.name=t.slice(p,u),r.base=t.slice(p,d)),r.ext=t.slice(u,d)),p>0?r.dir=t.slice(0,p-1):e&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};return l.posix=l,gr=l,gr}var gr,Ii,Ti,Ju=He(()=>{le(),ce(),ue(),ya(),gr={},Ii=!1,Ti=Yu()}),ma={};Ct(ma,{URL:()=>ka,Url:()=>Sa,default:()=>Fe,fileURLToPath:()=>va,format:()=>Ea,parse:()=>Ta,pathToFileURL:()=>wa,resolve:()=>Aa,resolveObject:()=>Ia});function Xu(){if(ki)return yr;ki=!0;var f=typeof Map=="function"&&Map.prototype,i=Object.getOwnPropertyDescriptor&&f?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,s=f&&i&&typeof i.get=="function"?i.get:null,a=f&&Map.prototype.forEach,l=typeof Set=="function"&&Set.prototype,t=Object.getOwnPropertyDescriptor&&l?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,r=l&&t&&typeof t.get=="function"?t.get:null,n=l&&Set.prototype.forEach,e=typeof WeakMap=="function"&&WeakMap.prototype,o=e?WeakMap.prototype.has:null,u=typeof WeakSet=="function"&&WeakSet.prototype,p=u?WeakSet.prototype.has:null,d=typeof WeakRef=="function"&&WeakRef.prototype,b=d?WeakRef.prototype.deref:null,h=Boolean.prototype.valueOf,y=Object.prototype.toString,m=Function.prototype.toString,S=String.prototype.match,g=String.prototype.slice,_=String.prototype.replace,I=String.prototype.toUpperCase,v=String.prototype.toLowerCase,A=RegExp.prototype.test,E=Array.prototype.concat,k=Array.prototype.join,C=Array.prototype.slice,P=Math.floor,L=typeof BigInt=="function"?BigInt.prototype.valueOf:null,x=Object.getOwnPropertySymbols,q=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,D=typeof Symbol=="function"&&typeof Symbol.iterator=="object",U=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===D||!0)?Symbol.toStringTag:null,ae=Object.prototype.propertyIsEnumerable,Q=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(z){return z.__proto__}:null);function K(z,ie){if(z===1/0||z===-1/0||z!==z||z&&z>-1e3&&z<1e3||A.call(/e/,ie))return ie;var Ie=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof z=="number"){var Te=z<0?-P(-z):P(z);if(Te!==z){var ke=String(Te),Oe=g.call(ie,ke.length+1);return _.call(ke,Ie,"$&_")+"."+_.call(_.call(Oe,/([0-9]{3})/g,"$&_"),/_$/,"")}}return _.call(ie,Ie,"$&_")}var re=_a,F=re.custom,Z=G(F)?F:null;yr=function z(ie,Ie,Te,ke){var Oe=Ie||{};if(oe(Oe,"quoteStyle")&&Oe.quoteStyle!=="single"&&Oe.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oe(Oe,"maxStringLength")&&(typeof Oe.maxStringLength=="number"?Oe.maxStringLength<0&&Oe.maxStringLength!==1/0:Oe.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ve=oe(Oe,"customInspect")?Oe.customInspect:!0;if(typeof Ve!="boolean"&&Ve!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oe(Oe,"indent")&&Oe.indent!==null&&Oe.indent!==" "&&!(parseInt(Oe.indent,10)===Oe.indent&&Oe.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oe(Oe,"numericSeparator")&&typeof Oe.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Ge=Oe.numericSeparator;if(typeof ie>"u")return"undefined";if(ie===null)return"null";if(typeof ie=="boolean")return ie?"true":"false";if(typeof ie=="string")return se(ie,Oe);if(typeof ie=="number"){if(ie===0)return 1/0/ie>0?"0":"-0";var Be=String(ie);return Ge?K(ie,Be):Be}if(typeof ie=="bigint"){var Qe=String(ie)+"n";return Ge?K(ie,Qe):Qe}var kt=typeof Oe.depth>"u"?5:Oe.depth;if(typeof Te>"u"&&(Te=0),Te>=kt&&kt>0&&typeof ie=="object")return me(ie)?"[Array]":"[Object]";var Ye=X(Oe,Te);if(typeof ke>"u")ke=[];else if(ee(ke,ie)>=0)return"[Circular]";function ze(Je,ht,vt){if(ht&&(ke=C.call(ke),ke.push(ht)),vt){var Xe={depth:Oe.depth};return oe(Oe,"quoteStyle")&&(Xe.quoteStyle=Oe.quoteStyle),z(Je,Xe,Te+1,ke)}return z(Je,Oe,Te+1,ke)}if(typeof ie=="function"&&!we(ie)){var Qt=W(ie),xt=Se(ie,ze);return"[Function"+(Qt?": "+Qt:" (anonymous)")+"]"+(xt.length>0?" { "+k.call(xt,", ")+" }":"")}if(G(ie)){var Ut=D?_.call(String(ie),/^(Symbol\(.*\))_[^)]*$/,"$1"):q.call(ie);return typeof ie=="object"&&!D?c(Ut):Ut}if(ve(ie)){for(var O="<"+v.call(String(ie.nodeName)),j=ie.attributes||[],_e=0;_e<j.length;_e++)O+=" "+j[_e].name+"="+R(J(j[_e].value),"double",Oe);return O+=">",ie.childNodes&&ie.childNodes.length&&(O+="..."),O+="</"+v.call(String(ie.nodeName))+">",O}if(me(ie)){if(ie.length===0)return"[]";var Ee=Se(ie,ze);return Ye&&!B(Ee)?"["+he(Ee,Ye)+"]":"[ "+k.call(Ee,", ")+" ]"}if(V(ie)){var Ae=Se(ie,ze);return!("cause"in Error.prototype)&&"cause"in ie&&!ae.call(ie,"cause")?"{ ["+String(ie)+"] "+k.call(E.call("[cause]: "+ze(ie.cause),Ae),", ")+" }":Ae.length===0?"["+String(ie)+"]":"{ ["+String(ie)+"] "+k.call(Ae,", ")+" }"}if(typeof ie=="object"&&Ve){if(Z&&typeof ie[Z]=="function"&&re)return re(ie,{depth:kt-Te});if(Ve!=="symbol"&&typeof ie.inspect=="function")return ie.inspect()}if(fe(ie)){var je=[];return a&&a.call(ie,function(Je,ht){je.push(ze(ht,ie,!0)+" => "+ze(Je,ie))}),T("Map",s.call(ie),je,Ye)}if($(ie)){var We=[];return n&&n.call(ie,function(Je){We.push(ze(Je,ie))}),T("Set",r.call(ie),We,Ye)}if(pe(ie))return w("WeakMap");if(ge(ie))return w("WeakSet");if(be(ie))return w("WeakRef");if(ne(ie))return c(ze(Number(ie)));if(Y(ie))return c(ze(L.call(ie)));if(H(ie))return c(h.call(ie));if(N(ie))return c(ze(String(ie)));if(typeof window<"u"&&ie===window)return"{ [object Window] }";if(typeof globalThis<"u"&&ie===globalThis||typeof mr<"u"&&ie===mr)return"{ [object globalThis] }";if(!te(ie)&&!we(ie)){var Ke=Se(ie,ze),Bt=Q?Q(ie)===Object.prototype:ie instanceof Object||ie.constructor===Object,Lt=ie instanceof Object?"":"null prototype",Dt=!Bt&&U&&Object(ie)===ie&&U in ie?g.call(M(ie),8,-1):Lt?"Object":"",Yt=Bt||typeof ie.constructor!="function"?"":ie.constructor.name?ie.constructor.name+" ":"",bt=Yt+(Dt||Lt?"["+k.call(E.call([],Dt||[],Lt||[]),": ")+"] ":"");return Ke.length===0?bt+"{}":Ye?bt+"{"+he(Ke,Ye)+"}":bt+"{ "+k.call(Ke,", ")+" }"}return String(ie)};function R(z,ie,Ie){var Te=(Ie.quoteStyle||ie)==="double"?'"':"'";return Te+z+Te}function J(z){return _.call(String(z),/"/g,""")}function me(z){return M(z)==="[object Array]"&&(!U||!(typeof z=="object"&&U in z))}function te(z){return M(z)==="[object Date]"&&(!U||!(typeof z=="object"&&U in z))}function we(z){return M(z)==="[object RegExp]"&&(!U||!(typeof z=="object"&&U in z))}function V(z){return M(z)==="[object Error]"&&(!U||!(typeof z=="object"&&U in z))}function N(z){return M(z)==="[object String]"&&(!U||!(typeof z=="object"&&U in z))}function ne(z){return M(z)==="[object Number]"&&(!U||!(typeof z=="object"&&U in z))}function H(z){return M(z)==="[object Boolean]"&&(!U||!(typeof z=="object"&&U in z))}function G(z){if(D)return z&&typeof z=="object"&&z instanceof Symbol;if(typeof z=="symbol")return!0;if(!z||typeof z!="object"||!q)return!1;try{return q.call(z),!0}catch{}return!1}function Y(z){if(!z||typeof z!="object"||!L)return!1;try{return L.call(z),!0}catch{}return!1}var ye=Object.prototype.hasOwnProperty||function(z){return z in(this||mr)};function oe(z,ie){return ye.call(z,ie)}function M(z){return y.call(z)}function W(z){if(z.name)return z.name;var ie=S.call(m.call(z),/^function\s*([\w$]+)/);return ie?ie[1]:null}function ee(z,ie){if(z.indexOf)return z.indexOf(ie);for(var Ie=0,Te=z.length;Ie<Te;Ie++)if(z[Ie]===ie)return Ie;return-1}function fe(z){if(!s||!z||typeof z!="object")return!1;try{s.call(z);try{r.call(z)}catch{return!0}return z instanceof Map}catch{}return!1}function pe(z){if(!o||!z||typeof z!="object")return!1;try{o.call(z,o);try{p.call(z,p)}catch{return!0}return z instanceof WeakMap}catch{}return!1}function be(z){if(!b||!z||typeof z!="object")return!1;try{return b.call(z),!0}catch{}return!1}function $(z){if(!r||!z||typeof z!="object")return!1;try{r.call(z);try{s.call(z)}catch{return!0}return z instanceof Set}catch{}return!1}function ge(z){if(!p||!z||typeof z!="object")return!1;try{p.call(z,p);try{o.call(z,o)}catch{return!0}return z instanceof WeakSet}catch{}return!1}function ve(z){return!z||typeof z!="object"?!1:typeof HTMLElement<"u"&&z instanceof HTMLElement?!0:typeof z.nodeName=="string"&&typeof z.getAttribute=="function"}function se(z,ie){if(z.length>ie.maxStringLength){var Ie=z.length-ie.maxStringLength,Te="... "+Ie+" more character"+(Ie>1?"s":"");return se(g.call(z,0,ie.maxStringLength),ie)+Te}var ke=_.call(_.call(z,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,xe);return R(ke,"single",ie)}function xe(z){var ie=z.charCodeAt(0),Ie={8:"b",9:"t",10:"n",12:"f",13:"r"}[ie];return Ie?"\\"+Ie:"\\x"+(ie<16?"0":"")+I.call(ie.toString(16))}function c(z){return"Object("+z+")"}function w(z){return z+" { ? }"}function T(z,ie,Ie,Te){var ke=Te?he(Ie,Te):k.call(Ie,", ");return z+" ("+ie+") {"+ke+"}"}function B(z){for(var ie=0;ie<z.length;ie++)if(ee(z[ie],`
|
|
4
|
-
`)>=0)return!1;return!0}function X(z,ie){var Ie;if(z.indent===" ")Ie=" ";else if(typeof z.indent=="number"&&z.indent>0)Ie=k.call(Array(z.indent+1)," ");else return null;return{base:Ie,prev:k.call(Array(ie+1),Ie)}}function he(z,ie){if(z.length===0)return"";var Ie=`
|
|
5
|
-
`+ie.prev+ie.base;return Ie+k.call(z,","+Ie)+`
|
|
6
|
-
`+ie.prev}function Se(z,ie){var Ie=me(z),Te=[];if(Ie){Te.length=z.length;for(var ke=0;ke<z.length;ke++)Te[ke]=oe(z,ke)?ie(z[ke],z):""}var Oe=typeof x=="function"?x(z):[],Ve;if(D){Ve={};for(var Ge=0;Ge<Oe.length;Ge++)Ve["$"+Oe[Ge]]=Oe[Ge]}for(var Be in z)oe(z,Be)&&(Ie&&String(Number(Be))===Be&&Be<z.length||D&&Ve["$"+Be]instanceof Symbol||(A.call(/[^\w$]/,Be)?Te.push(ie(Be,z)+": "+ie(z[Be],z)):Te.push(Be+": "+ie(z[Be],z))));if(typeof x=="function")for(var Qe=0;Qe<Oe.length;Qe++)ae.call(z,Oe[Qe])&&Te.push("["+ie(Oe[Qe])+"]: "+ie(z[Oe[Qe]],z));return Te}return yr}function Zu(){if(xi)return br;xi=!0;var f=Nt(),i=Lu(),s=Xu(),a=Gt(),l=f("%WeakMap%",!0),t=f("%Map%",!0),r=i("WeakMap.prototype.get",!0),n=i("WeakMap.prototype.set",!0),e=i("WeakMap.prototype.has",!0),o=i("Map.prototype.get",!0),u=i("Map.prototype.set",!0),p=i("Map.prototype.has",!0),d=function(m,S){for(var g=m,_;(_=g.next)!==null;g=_)if(_.key===S)return g.next=_.next,_.next=m.next,m.next=_,_},b=function(m,S){var g=d(m,S);return g&&g.value},h=function(m,S,g){var _=d(m,S);_?_.value=g:m.next={key:S,next:m.next,value:g}},y=function(m,S){return!!d(m,S)};return br=function(){var m,S,g,_={assert:function(I){if(!_.has(I))throw new a("Side channel does not contain "+s(I))},get:function(I){if(l&&I&&(typeof I=="object"||typeof I=="function")){if(m)return r(m,I)}else if(t){if(S)return o(S,I)}else if(g)return b(g,I)},has:function(I){if(l&&I&&(typeof I=="object"||typeof I=="function")){if(m)return e(m,I)}else if(t){if(S)return p(S,I)}else if(g)return y(g,I);return!1},set:function(I,v){l&&I&&(typeof I=="object"||typeof I=="function")?(m||(m=new l),n(m,I,v)):t?(S||(S=new t),u(S,I,v)):(g||(g={key:{},next:null}),h(g,I,v))}};return _},br}function Vi(){if(Oi)return vr;Oi=!0;var f=String.prototype.replace,i=/%20/g,s={RFC1738:"RFC1738",RFC3986:"RFC3986"};return vr={default:s.RFC3986,formatters:{RFC1738:function(a){return f.call(a,i,"+")},RFC3986:function(a){return String(a)}},RFC1738:s.RFC1738,RFC3986:s.RFC3986},vr}function ba(){if(Pi)return wr;Pi=!0;var f=Vi(),i=Object.prototype.hasOwnProperty,s=Array.isArray,a=(function(){for(var m=[],S=0;S<256;++S)m.push("%"+((S<16?"0":"")+S.toString(16)).toUpperCase());return m})(),l=function(m){for(;m.length>1;){var S=m.pop(),g=S.obj[S.prop];if(s(g)){for(var _=[],I=0;I<g.length;++I)typeof g[I]<"u"&&_.push(g[I]);S.obj[S.prop]=_}}},t=function(m,S){for(var g=S&&S.plainObjects?Object.create(null):{},_=0;_<m.length;++_)typeof m[_]<"u"&&(g[_]=m[_]);return g},r=function m(S,g,_){if(!g)return S;if(typeof g!="object"){if(s(S))S.push(g);else if(S&&typeof S=="object")(_&&(_.plainObjects||_.allowPrototypes)||!i.call(Object.prototype,g))&&(S[g]=!0);else return[S,g];return S}if(!S||typeof S!="object")return[S].concat(g);var I=S;return s(S)&&!s(g)&&(I=t(S,_)),s(S)&&s(g)?(g.forEach(function(v,A){if(i.call(S,A)){var E=S[A];E&&typeof E=="object"&&v&&typeof v=="object"?S[A]=m(E,v,_):S.push(v)}else S[A]=v}),S):Object.keys(g).reduce(function(v,A){var E=g[A];return i.call(v,A)?v[A]=m(v[A],E,_):v[A]=E,v},I)},n=function(m,S){return Object.keys(S).reduce(function(g,_){return g[_]=S[_],g},m)},e=function(m,S,g){var _=m.replace(/\+/g," ");if(g==="iso-8859-1")return _.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(_)}catch{return _}},o=1024,u=function(m,S,g,_,I){if(m.length===0)return m;var v=m;if(typeof m=="symbol"?v=Symbol.prototype.toString.call(m):typeof m!="string"&&(v=String(m)),g==="iso-8859-1")return escape(v).replace(/%u[0-9a-f]{4}/gi,function(x){return"%26%23"+parseInt(x.slice(2),16)+"%3B"});for(var A="",E=0;E<v.length;E+=o){for(var k=v.length>=o?v.slice(E,E+o):v,C=[],P=0;P<k.length;++P){var L=k.charCodeAt(P);if(L===45||L===46||L===95||L===126||L>=48&&L<=57||L>=65&&L<=90||L>=97&&L<=122||I===f.RFC1738&&(L===40||L===41)){C[C.length]=k.charAt(P);continue}if(L<128){C[C.length]=a[L];continue}if(L<2048){C[C.length]=a[192|L>>6]+a[128|L&63];continue}if(L<55296||L>=57344){C[C.length]=a[224|L>>12]+a[128|L>>6&63]+a[128|L&63];continue}P+=1,L=65536+((L&1023)<<10|k.charCodeAt(P)&1023),C[C.length]=a[240|L>>18]+a[128|L>>12&63]+a[128|L>>6&63]+a[128|L&63]}A+=C.join("")}return A},p=function(m){for(var S=[{obj:{o:m},prop:"o"}],g=[],_=0;_<S.length;++_)for(var I=S[_],v=I.obj[I.prop],A=Object.keys(v),E=0;E<A.length;++E){var k=A[E],C=v[k];typeof C=="object"&&C!==null&&g.indexOf(C)===-1&&(S.push({obj:v,prop:k}),g.push(C))}return l(S),m},d=function(m){return Object.prototype.toString.call(m)==="[object RegExp]"},b=function(m){return!m||typeof m!="object"?!1:!!(m.constructor&&m.constructor.isBuffer&&m.constructor.isBuffer(m))},h=function(m,S){return[].concat(m,S)},y=function(m,S){if(s(m)){for(var g=[],_=0;_<m.length;_+=1)g.push(S(m[_]));return g}return S(m)};return wr={arrayToObject:t,assign:n,combine:h,compact:p,decode:e,encode:u,isBuffer:b,isRegExp:d,maybeMap:y,merge:r},wr}function ec(){if(Ri)return _r;Ri=!0;var f=Zu(),i=ba(),s=Vi(),a=Object.prototype.hasOwnProperty,l={brackets:function(y){return y+"[]"},comma:"comma",indices:function(y,m){return y+"["+m+"]"},repeat:function(y){return y}},t=Array.isArray,r=Array.prototype.push,n=function(y,m){r.apply(y,t(m)?m:[m])},e=Date.prototype.toISOString,o=s.default,u={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:i.encode,encodeValuesOnly:!1,format:o,formatter:s.formatters[o],indices:!1,serializeDate:function(y){return e.call(y)},skipNulls:!1,strictNullHandling:!1},p=function(y){return typeof y=="string"||typeof y=="number"||typeof y=="boolean"||typeof y=="symbol"||typeof y=="bigint"},d={},b=function y(m,S,g,_,I,v,A,E,k,C,P,L,x,q,D,U,ae,Q){for(var K=m,re=Q,F=0,Z=!1;(re=re.get(d))!==void 0&&!Z;){var R=re.get(m);if(F+=1,typeof R<"u"){if(R===F)throw new RangeError("Cyclic object value");Z=!0}typeof re.get(d)>"u"&&(F=0)}if(typeof C=="function"?K=C(S,K):K instanceof Date?K=x(K):g==="comma"&&t(K)&&(K=i.maybeMap(K,function(M){return M instanceof Date?x(M):M})),K===null){if(v)return k&&!U?k(S,u.encoder,ae,"key",q):S;K=""}if(p(K)||i.isBuffer(K)){if(k){var J=U?S:k(S,u.encoder,ae,"key",q);return[D(J)+"="+D(k(K,u.encoder,ae,"value",q))]}return[D(S)+"="+D(String(K))]}var me=[];if(typeof K>"u")return me;var te;if(g==="comma"&&t(K))U&&k&&(K=i.maybeMap(K,k)),te=[{value:K.length>0?K.join(",")||null:void 0}];else if(t(C))te=C;else{var we=Object.keys(K);te=P?we.sort(P):we}var V=E?S.replace(/\./g,"%2E"):S,N=_&&t(K)&&K.length===1?V+"[]":V;if(I&&t(K)&&K.length===0)return N+"[]";for(var ne=0;ne<te.length;++ne){var H=te[ne],G=typeof H=="object"&&typeof H.value<"u"?H.value:K[H];if(!(A&&G===null)){var Y=L&&E?H.replace(/\./g,"%2E"):H,ye=t(K)?typeof g=="function"?g(N,Y):N:N+(L?"."+Y:"["+Y+"]");Q.set(m,F);var oe=f();oe.set(d,Q),n(me,y(G,ye,g,_,I,v,A,E,g==="comma"&&U&&t(K)?null:k,C,P,L,x,q,D,U,ae,oe))}}return me},h=function(y){if(!y)return u;if(typeof y.allowEmptyArrays<"u"&&typeof y.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof y.encodeDotInKeys<"u"&&typeof y.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(y.encoder!==null&&typeof y.encoder<"u"&&typeof y.encoder!="function")throw new TypeError("Encoder has to be a function.");var m=y.charset||u.charset;if(typeof y.charset<"u"&&y.charset!=="utf-8"&&y.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var S=s.default;if(typeof y.format<"u"){if(!a.call(s.formatters,y.format))throw new TypeError("Unknown format option provided.");S=y.format}var g=s.formatters[S],_=u.filter;(typeof y.filter=="function"||t(y.filter))&&(_=y.filter);var I;if(y.arrayFormat in l?I=y.arrayFormat:"indices"in y?I=y.indices?"indices":"repeat":I=u.arrayFormat,"commaRoundTrip"in y&&typeof y.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var v=typeof y.allowDots>"u"?y.encodeDotInKeys===!0?!0:u.allowDots:!!y.allowDots;return{addQueryPrefix:typeof y.addQueryPrefix=="boolean"?y.addQueryPrefix:u.addQueryPrefix,allowDots:v,allowEmptyArrays:typeof y.allowEmptyArrays=="boolean"?!!y.allowEmptyArrays:u.allowEmptyArrays,arrayFormat:I,charset:m,charsetSentinel:typeof y.charsetSentinel=="boolean"?y.charsetSentinel:u.charsetSentinel,commaRoundTrip:y.commaRoundTrip,delimiter:typeof y.delimiter>"u"?u.delimiter:y.delimiter,encode:typeof y.encode=="boolean"?y.encode:u.encode,encodeDotInKeys:typeof y.encodeDotInKeys=="boolean"?y.encodeDotInKeys:u.encodeDotInKeys,encoder:typeof y.encoder=="function"?y.encoder:u.encoder,encodeValuesOnly:typeof y.encodeValuesOnly=="boolean"?y.encodeValuesOnly:u.encodeValuesOnly,filter:_,format:S,formatter:g,serializeDate:typeof y.serializeDate=="function"?y.serializeDate:u.serializeDate,skipNulls:typeof y.skipNulls=="boolean"?y.skipNulls:u.skipNulls,sort:typeof y.sort=="function"?y.sort:null,strictNullHandling:typeof y.strictNullHandling=="boolean"?y.strictNullHandling:u.strictNullHandling}};return _r=function(y,m){var S=y,g=h(m),_,I;typeof g.filter=="function"?(I=g.filter,S=I("",S)):t(g.filter)&&(I=g.filter,_=I);var v=[];if(typeof S!="object"||S===null)return"";var A=l[g.arrayFormat],E=A==="comma"&&g.commaRoundTrip;_||(_=Object.keys(S)),g.sort&&_.sort(g.sort);for(var k=f(),C=0;C<_.length;++C){var P=_[C];g.skipNulls&&S[P]===null||n(v,b(S[P],P,A,E,g.allowEmptyArrays,g.strictNullHandling,g.skipNulls,g.encodeDotInKeys,g.encode?g.encoder:null,g.filter,g.sort,g.allowDots,g.serializeDate,g.format,g.formatter,g.encodeValuesOnly,g.charset,k))}var L=v.join(g.delimiter),x=g.addQueryPrefix===!0?"?":"";return g.charsetSentinel&&(g.charset==="iso-8859-1"?x+="utf8=%26%2310003%3B&":x+="utf8=%E2%9C%93&"),L.length>0?x+L:""},_r}function tc(){if(Ci)return Sr;Ci=!0;var f=ba(),i=Object.prototype.hasOwnProperty,s=Array.isArray,a={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:f.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},l=function(d){return d.replace(/&#(\d+);/g,function(b,h){return String.fromCharCode(parseInt(h,10))})},t=function(d,b){return d&&typeof d=="string"&&b.comma&&d.indexOf(",")>-1?d.split(","):d},r="utf8=%26%2310003%3B",n="utf8=%E2%9C%93",e=function(d,b){var h={__proto__:null},y=b.ignoreQueryPrefix?d.replace(/^\?/,""):d;y=y.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var m=b.parameterLimit===1/0?void 0:b.parameterLimit,S=y.split(b.delimiter,m),g=-1,_,I=b.charset;if(b.charsetSentinel)for(_=0;_<S.length;++_)S[_].indexOf("utf8=")===0&&(S[_]===n?I="utf-8":S[_]===r&&(I="iso-8859-1"),g=_,_=S.length);for(_=0;_<S.length;++_)if(_!==g){var v=S[_],A=v.indexOf("]="),E=A===-1?v.indexOf("="):A+1,k,C;E===-1?(k=b.decoder(v,a.decoder,I,"key"),C=b.strictNullHandling?null:""):(k=b.decoder(v.slice(0,E),a.decoder,I,"key"),C=f.maybeMap(t(v.slice(E+1),b),function(L){return b.decoder(L,a.decoder,I,"value")})),C&&b.interpretNumericEntities&&I==="iso-8859-1"&&(C=l(C)),v.indexOf("[]=")>-1&&(C=s(C)?[C]:C);var P=i.call(h,k);P&&b.duplicates==="combine"?h[k]=f.combine(h[k],C):(!P||b.duplicates==="last")&&(h[k]=C)}return h},o=function(d,b,h,y){for(var m=y?b:t(b,h),S=d.length-1;S>=0;--S){var g,_=d[S];if(_==="[]"&&h.parseArrays)g=h.allowEmptyArrays&&(m===""||h.strictNullHandling&&m===null)?[]:[].concat(m);else{g=h.plainObjects?Object.create(null):{};var I=_.charAt(0)==="["&&_.charAt(_.length-1)==="]"?_.slice(1,-1):_,v=h.decodeDotInKeys?I.replace(/%2E/g,"."):I,A=parseInt(v,10);!h.parseArrays&&v===""?g={0:m}:!isNaN(A)&&_!==v&&String(A)===v&&A>=0&&h.parseArrays&&A<=h.arrayLimit?(g=[],g[A]=m):v!=="__proto__"&&(g[v]=m)}m=g}return m},u=function(d,b,h,y){if(d){var m=h.allowDots?d.replace(/\.([^.[]+)/g,"[$1]"):d,S=/(\[[^[\]]*])/,g=/(\[[^[\]]*])/g,_=h.depth>0&&S.exec(m),I=_?m.slice(0,_.index):m,v=[];if(I){if(!h.plainObjects&&i.call(Object.prototype,I)&&!h.allowPrototypes)return;v.push(I)}for(var A=0;h.depth>0&&(_=g.exec(m))!==null&&A<h.depth;){if(A+=1,!h.plainObjects&&i.call(Object.prototype,_[1].slice(1,-1))&&!h.allowPrototypes)return;v.push(_[1])}if(_){if(h.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+h.depth+" and strictDepth is true");v.push("["+m.slice(_.index)+"]")}return o(v,b,h,y)}},p=function(d){if(!d)return a;if(typeof d.allowEmptyArrays<"u"&&typeof d.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof d.decodeDotInKeys<"u"&&typeof d.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(d.decoder!==null&&typeof d.decoder<"u"&&typeof d.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof d.charset<"u"&&d.charset!=="utf-8"&&d.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var b=typeof d.charset>"u"?a.charset:d.charset,h=typeof d.duplicates>"u"?a.duplicates:d.duplicates;if(h!=="combine"&&h!=="first"&&h!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var y=typeof d.allowDots>"u"?d.decodeDotInKeys===!0?!0:a.allowDots:!!d.allowDots;return{allowDots:y,allowEmptyArrays:typeof d.allowEmptyArrays=="boolean"?!!d.allowEmptyArrays:a.allowEmptyArrays,allowPrototypes:typeof d.allowPrototypes=="boolean"?d.allowPrototypes:a.allowPrototypes,allowSparse:typeof d.allowSparse=="boolean"?d.allowSparse:a.allowSparse,arrayLimit:typeof d.arrayLimit=="number"?d.arrayLimit:a.arrayLimit,charset:b,charsetSentinel:typeof d.charsetSentinel=="boolean"?d.charsetSentinel:a.charsetSentinel,comma:typeof d.comma=="boolean"?d.comma:a.comma,decodeDotInKeys:typeof d.decodeDotInKeys=="boolean"?d.decodeDotInKeys:a.decodeDotInKeys,decoder:typeof d.decoder=="function"?d.decoder:a.decoder,delimiter:typeof d.delimiter=="string"||f.isRegExp(d.delimiter)?d.delimiter:a.delimiter,depth:typeof d.depth=="number"||d.depth===!1?+d.depth:a.depth,duplicates:h,ignoreQueryPrefix:d.ignoreQueryPrefix===!0,interpretNumericEntities:typeof d.interpretNumericEntities=="boolean"?d.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:typeof d.parameterLimit=="number"?d.parameterLimit:a.parameterLimit,parseArrays:d.parseArrays!==!1,plainObjects:typeof d.plainObjects=="boolean"?d.plainObjects:a.plainObjects,strictDepth:typeof d.strictDepth=="boolean"?!!d.strictDepth:a.strictDepth,strictNullHandling:typeof d.strictNullHandling=="boolean"?d.strictNullHandling:a.strictNullHandling}};return Sr=function(d,b){var h=p(b);if(d===""||d===null||typeof d>"u")return h.plainObjects?Object.create(null):{};for(var y=typeof d=="string"?e(d,h):d,m=h.plainObjects?Object.create(null):{},S=Object.keys(y),g=0;g<S.length;++g){var _=S[g],I=u(_,y[_],h,typeof d=="string");m=f.merge(m,I,h)}return h.allowSparse===!0?m:f.compact(m)},Sr}function rc(){if(Mi)return Er;Mi=!0;var f=ec(),i=tc(),s=Vi();return Er={formats:s,parse:i,stringify:f},Er}function nc(){if(ji)return gt;ji=!0;var f=dt;function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,l=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,t=["<",">",'"',"`"," ","\r",`
|
|
7
|
-
`," "],r=["{","}","|","\\","^","`"].concat(t),n=["'"].concat(r),e=["%","/","?",";","#"].concat(n),o=["/","?","#"],u=255,p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},h={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=rc();function S(v,A,E){if(v&&typeof v=="object"&&v instanceof i)return v;var k=new i;return k.parse(v,A,E),k}i.prototype.parse=function(v,A,E){if(typeof v!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof v);var k=v.indexOf("?"),C=k!==-1&&k<v.indexOf("#")?"?":"#",P=v.split(C),L=/\\/g;P[0]=P[0].replace(L,"/"),v=P.join(C);var x=v;if(x=x.trim(),!E&&v.split("#").length===1){var q=l.exec(x);if(q)return this.path=x,this.href=x,this.pathname=q[1],q[2]?(this.search=q[2],A?this.query=m.parse(this.search.substr(1)):this.query=this.search.substr(1)):A&&(this.search="",this.query={}),this}var D=s.exec(x);if(D){D=D[0];var U=D.toLowerCase();this.protocol=U,x=x.substr(D.length)}if(E||D||x.match(/^\/\/[^@/]+@[^@/]+/)){var ae=x.substr(0,2)==="//";ae&&!(D&&h[D])&&(x=x.substr(2),this.slashes=!0)}if(!h[D]&&(ae||D&&!y[D])){for(var Q=-1,K=0;K<o.length;K++){var re=x.indexOf(o[K]);re!==-1&&(Q===-1||re<Q)&&(Q=re)}var F,Z;Q===-1?Z=x.lastIndexOf("@"):Z=x.lastIndexOf("@",Q),Z!==-1&&(F=x.slice(0,Z),x=x.slice(Z+1),this.auth=decodeURIComponent(F)),Q=-1;for(var K=0;K<e.length;K++){var re=x.indexOf(e[K]);re!==-1&&(Q===-1||re<Q)&&(Q=re)}Q===-1&&(Q=x.length),this.host=x.slice(0,Q),x=x.slice(Q),this.parseHost(),this.hostname=this.hostname||"";var R=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!R)for(var J=this.hostname.split(/\./),K=0,me=J.length;K<me;K++){var te=J[K];if(te&&!te.match(p)){for(var we="",V=0,N=te.length;V<N;V++)te.charCodeAt(V)>127?we+="x":we+=te[V];if(!we.match(p)){var ne=J.slice(0,K),H=J.slice(K+1),G=te.match(d);G&&(ne.push(G[1]),H.unshift(G[2])),H.length&&(x="/"+H.join(".")+x),this.hostname=ne.join(".");break}}}this.hostname.length>u?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=f.toASCII(this.hostname));var Y=this.port?":"+this.port:"",ye=this.hostname||"";this.host=ye+Y,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),x[0]!=="/"&&(x="/"+x))}if(!b[U])for(var K=0,me=n.length;K<me;K++){var oe=n[K];if(x.indexOf(oe)!==-1){var M=encodeURIComponent(oe);M===oe&&(M=escape(oe)),x=x.split(oe).join(M)}}var W=x.indexOf("#");W!==-1&&(this.hash=x.substr(W),x=x.slice(0,W));var ee=x.indexOf("?");if(ee!==-1?(this.search=x.substr(ee),this.query=x.substr(ee+1),A&&(this.query=m.parse(this.query)),x=x.slice(0,ee)):A&&(this.search="",this.query={}),x&&(this.pathname=x),y[U]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var Y=this.pathname||"",fe=this.search||"";this.path=Y+fe}return this.href=this.format(),this};function g(v){return typeof v=="string"&&(v=S(v)),v instanceof i?v.format():i.prototype.format.call(v)}i.prototype.format=function(){var v=this.auth||"";v&&(v=encodeURIComponent(v),v=v.replace(/%3A/i,":"),v+="@");var A=this.protocol||"",E=this.pathname||"",k=this.hash||"",C=!1,P="";this.host?C=v+this.host:this.hostname&&(C=v+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(C+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(P=m.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var L=this.search||P&&"?"+P||"";return A&&A.substr(-1)!==":"&&(A+=":"),this.slashes||(!A||y[A])&&C!==!1?(C="//"+(C||""),E&&E.charAt(0)!=="/"&&(E="/"+E)):C||(C=""),k&&k.charAt(0)!=="#"&&(k="#"+k),L&&L.charAt(0)!=="?"&&(L="?"+L),E=E.replace(/[?#]/g,function(x){return encodeURIComponent(x)}),L=L.replace("#","%23"),A+C+E+L+k};function _(v,A){return S(v,!1,!0).resolve(A)}i.prototype.resolve=function(v){return this.resolveObject(S(v,!1,!0)).format()};function I(v,A){return v?S(v,!1,!0).resolveObject(A):A}return i.prototype.resolveObject=function(v){if(typeof v=="string"){var A=new i;A.parse(v,!1,!0),v=A}for(var E=new i,k=Object.keys(this),C=0;C<k.length;C++){var P=k[C];E[P]=this[P]}if(E.hash=v.hash,v.href==="")return E.href=E.format(),E;if(v.slashes&&!v.protocol){for(var L=Object.keys(v),x=0;x<L.length;x++){var q=L[x];q!=="protocol"&&(E[q]=v[q])}return y[E.protocol]&&E.hostname&&!E.pathname&&(E.pathname="/",E.path=E.pathname),E.href=E.format(),E}if(v.protocol&&v.protocol!==E.protocol){if(!y[v.protocol]){for(var D=Object.keys(v),U=0;U<D.length;U++){var ae=D[U];E[ae]=v[ae]}return E.href=E.format(),E}if(E.protocol=v.protocol,!v.host&&!h[v.protocol]){for(var me=(v.pathname||"").split("/");me.length&&!(v.host=me.shift()););v.host||(v.host=""),v.hostname||(v.hostname=""),me[0]!==""&&me.unshift(""),me.length<2&&me.unshift(""),E.pathname=me.join("/")}else E.pathname=v.pathname;if(E.search=v.search,E.query=v.query,E.host=v.host||"",E.auth=v.auth,E.hostname=v.hostname||v.host,E.port=v.port,E.pathname||E.search){var Q=E.pathname||"",K=E.search||"";E.path=Q+K}return E.slashes=E.slashes||v.slashes,E.href=E.format(),E}var re=E.pathname&&E.pathname.charAt(0)==="/",F=v.host||v.pathname&&v.pathname.charAt(0)==="/",Z=F||re||E.host&&v.pathname,R=Z,J=E.pathname&&E.pathname.split("/")||[],me=v.pathname&&v.pathname.split("/")||[],te=E.protocol&&!y[E.protocol];if(te&&(E.hostname="",E.port=null,E.host&&(J[0]===""?J[0]=E.host:J.unshift(E.host)),E.host="",v.protocol&&(v.hostname=null,v.port=null,v.host&&(me[0]===""?me[0]=v.host:me.unshift(v.host)),v.host=null),Z=Z&&(me[0]===""||J[0]==="")),F)E.host=v.host||v.host===""?v.host:E.host,E.hostname=v.hostname||v.hostname===""?v.hostname:E.hostname,E.search=v.search,E.query=v.query,J=me;else if(me.length)J||(J=[]),J.pop(),J=J.concat(me),E.search=v.search,E.query=v.query;else if(v.search!=null){if(te){E.host=J.shift(),E.hostname=E.host;var we=E.host&&E.host.indexOf("@")>0?E.host.split("@"):!1;we&&(E.auth=we.shift(),E.hostname=we.shift(),E.host=E.hostname)}return E.search=v.search,E.query=v.query,(E.pathname!==null||E.search!==null)&&(E.path=(E.pathname?E.pathname:"")+(E.search?E.search:"")),E.href=E.format(),E}if(!J.length)return E.pathname=null,E.search?E.path="/"+E.search:E.path=null,E.href=E.format(),E;for(var V=J.slice(-1)[0],N=(E.host||v.host||J.length>1)&&(V==="."||V==="..")||V==="",ne=0,H=J.length;H>=0;H--)V=J[H],V==="."?J.splice(H,1):V===".."?(J.splice(H,1),ne++):ne&&(J.splice(H,1),ne--);if(!Z&&!R)for(;ne--;ne)J.unshift("..");Z&&J[0]!==""&&(!J[0]||J[0].charAt(0)!=="/")&&J.unshift(""),N&&J.join("/").substr(-1)!=="/"&&J.push("");var G=J[0]===""||J[0]&&J[0].charAt(0)==="/";if(te){E.hostname=G?"":J.length?J.shift():"",E.host=E.hostname;var we=E.host&&E.host.indexOf("@")>0?E.host.split("@"):!1;we&&(E.auth=we.shift(),E.hostname=we.shift(),E.host=E.hostname)}return Z=Z||E.host&&J.length,Z&&!G&&J.unshift(""),J.length>0?E.pathname=J.join("/"):(E.pathname=null,E.path=null),(E.pathname!==null||E.search!==null)&&(E.path=(E.pathname?E.pathname:"")+(E.search?E.search:"")),E.auth=v.auth||E.auth,E.slashes=E.slashes||v.slashes,E.href=E.format(),E},i.prototype.parseHost=function(){var v=this.host,A=a.exec(v);A&&(A=A[0],A!==":"&&(this.port=A.substr(1)),v=v.substr(0,v.length-A.length)),v&&(this.hostname=v)},gt.parse=S,gt.resolve=_,gt.resolveObject=I,gt.format=g,gt.Url=i,gt}function va(f){if(typeof f=="string")f=new URL(f);else if(!(f instanceof URL))throw new Deno.errors.InvalidData("invalid argument path , must be a string or URL");if(f.protocol!=="file:")throw new Deno.errors.InvalidData("invalid url scheme");return Ir?ic(f):oc(f)}function ic(f){let i=f.hostname,s=f.pathname;for(let a=0;a<s.length;a++)if(s[a]==="%"){let l=s.codePointAt(a+2)||32;if(s[a+1]==="2"&&l===102||s[a+1]==="5"&&l===99)throw new Deno.errors.InvalidData("must not include encoded \\ or / characters")}if(s=s.replace(Ca,"\\"),s=decodeURIComponent(s),i!=="")return`\\\\${i}${s}`;{let a=s.codePointAt(1)|32,l=s[2];if(a<Pa||a>Ra||l!==":")throw new Deno.errors.InvalidData("file url path must be absolute");return s.slice(1)}}function oc(f){if(f.hostname!=="")throw new Deno.errors.InvalidData("invalid file url hostname");let i=f.pathname;for(let s=0;s<i.length;s++)if(i[s]==="%"){let a=i.codePointAt(s+2)||32;if(i[s+1]==="2"&&a===102)throw new Deno.errors.InvalidData("must not include encoded / characters")}return decodeURIComponent(i)}function wa(f){let i=Ti.resolve(f),s=f.charCodeAt(f.length-1);(s===Oa||Ir&&s===xa)&&i[i.length-1]!==Ti.sep&&(i+="/");let a=new URL("file://");return i.includes("%")&&(i=i.replace(Ma,"%25")),!Ir&&i.includes("\\")&&(i=i.replace(ja,"%5C")),i.includes(`
|
|
8
|
-
`)&&(i=i.replace(Na,"%0A")),i.includes("\r")&&(i=i.replace(Ua,"%0D")),i.includes(" ")&&(i=i.replace(Ba,"%09")),a.pathname=i,a}var _a,yr,ki,mr,br,xi,vr,Oi,wr,Pi,_r,Ri,Sr,Ci,Er,Mi,gt,ji,Fe,ts,Sa,Ea,Aa,Ia,Ta,ka,xa,Oa,Pa,Ra,Ir,Ca,Ma,ja,Na,Ua,Ba,sc=He(()=>{le(),ce(),ue(),Eu(),Du(),Ju(),ya(),_a=Object.freeze(Object.create(null)),yr={},ki=!1,mr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:global,br={},xi=!1,vr={},Oi=!1,wr={},Pi=!1,_r={},Ri=!1,Sr={},Ci=!1,Er={},Mi=!1,gt={},ji=!1,Fe=nc(),Fe.parse,Fe.resolve,Fe.resolveObject,Fe.format,Fe.Url,ts=typeof Deno<"u"?Deno.build.os==="windows"?"win32":Deno.build.os:void 0,Fe.URL=typeof URL<"u"?URL:null,Fe.pathToFileURL=wa,Fe.fileURLToPath=va,Sa=Fe.Url,Ea=Fe.format,Aa=Fe.resolve,Ia=Fe.resolveObject,Ta=Fe.parse,ka=Fe.URL,xa=92,Oa=47,Pa=97,Ra=122,Ir=ts==="win32",Ca=/\//g,Ma=/%/g,ja=/\\/g,Na=/\n/g,Ua=/\r/g,Ba=/\t/g}),ac=de((f,i)=>{le(),ce(),ue(),i.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}}),Gi=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0}),f.BufferedDuplex=void 0,f.writev=a;var i=Tt(),s=(Ue(),Pe(Ne));function a(t,r){let n=new Array(t.length);for(let e=0;e<t.length;e++)typeof t[e].chunk=="string"?n[e]=s.Buffer.from(t[e].chunk,"utf8"):n[e]=t[e].chunk;this._write(s.Buffer.concat(n),"binary",r)}var l=class extends i.Duplex{socket;proxy;isSocketOpen;writeQueue;constructor(t,r,n){super({objectMode:!0}),this.proxy=r,this.socket=n,this.writeQueue=[],t.objectMode||(this._writev=a.bind(this)),this.isSocketOpen=!1,this.proxy.on("data",e=>{!this.destroyed&&this.readable&&this.push(e)})}_read(t){this.proxy.read(t)}_write(t,r,n){this.isSocketOpen?this.writeToProxy(t,r,n):this.writeQueue.push({chunk:t,encoding:r,cb:n})}_final(t){this.writeQueue=[],this.proxy.end(t)}_destroy(t,r){this.writeQueue=[],this.proxy.destroy(),r(t)}socketReady(){this.emit("connect"),this.isSocketOpen=!0,this.processWriteQueue()}writeToProxy(t,r,n){this.proxy.write(t,r)===!1?this.proxy.once("drain",n):n()}processWriteQueue(){for(;this.writeQueue.length>0;){let{chunk:t,encoding:r,cb:n}=this.writeQueue.shift();this.writeToProxy(t,r,n)}}};f.BufferedDuplex=l}),Xt=de(f=>{le(),ce(),ue();var i=f&&f.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(f,"__esModule",{value:!0}),f.streamBuilder=f.browserStreamBuilder=void 0;var s=(Ue(),Pe(Ne)),a=i(ac()),l=i(at()),t=Tt(),r=i(Rr()),n=Gi(),e=(0,l.default)("mqttjs:ws"),o=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];function u(S,g){let _=`${S.protocol}://${S.hostname}:${S.port}${S.path}`;return typeof S.transformWsUrl=="function"&&(_=S.transformWsUrl(_,S,g)),_}function p(S){let g=S;return S.port||(S.protocol==="wss"?g.port=443:g.port=80),S.path||(g.path="/"),S.wsOptions||(g.wsOptions={}),!r.default&&!S.forceNativeWebSocket&&S.protocol==="wss"&&o.forEach(_=>{Object.prototype.hasOwnProperty.call(S,_)&&!Object.prototype.hasOwnProperty.call(S.wsOptions,_)&&(g.wsOptions[_]=S[_])}),g}function d(S){let g=p(S);if(g.hostname||(g.hostname=g.host),!g.hostname){if(typeof document>"u")throw new Error("Could not determine host. Specify host manually.");let _=new URL(document.URL);g.hostname=_.hostname,g.port||(g.port=Number(_.port))}return g.objectMode===void 0&&(g.objectMode=!(g.binary===!0||g.binary===void 0)),g}function b(S,g,_){e("createWebSocket"),e(`protocol: ${_.protocolId} ${_.protocolVersion}`);let I=_.protocolId==="MQIsdp"&&_.protocolVersion===3?"mqttv3.1":"mqtt";e(`creating new Websocket for url: ${g} and protocol: ${I}`);let v;return _.createWebsocket?v=_.createWebsocket(g,[I],_):v=new a.default(g,[I],_.wsOptions),v}function h(S,g){let _=g.protocolId==="MQIsdp"&&g.protocolVersion===3?"mqttv3.1":"mqtt",I=u(g,S),v;return g.createWebsocket?v=g.createWebsocket(I,[_],g):v=new WebSocket(I,[_]),v.binaryType="arraybuffer",v}var y=(S,g)=>{e("streamBuilder");let _=p(g);_.hostname=_.hostname||_.host||"localhost";let I=u(_,S),v=b(S,I,_),A=a.default.createWebSocketStream(v,_.wsOptions);return A.url=I,v.on("close",()=>{A.destroy()}),A};f.streamBuilder=y;var m=(S,g)=>{e("browserStreamBuilder");let _,I=d(g).browserBufferSize||1024*512,v=g.browserBufferTimeout||1e3,A=!g.objectMode,E=h(S,g),k=P(g,U,ae);g.objectMode||(k._writev=n.writev.bind(k)),k.on("close",()=>{E.close()});let C=typeof E.addEventListener<"u";E.readyState===E.OPEN?(_=k,_.socket=E):(_=new n.BufferedDuplex(g,k,E),C?E.addEventListener("open",L):E.onopen=L),C?(E.addEventListener("close",x),E.addEventListener("error",q),E.addEventListener("message",D)):(E.onclose=x,E.onerror=q,E.onmessage=D);function P(Q,K,re){let F=new t.Transform({objectMode:Q.objectMode});return F._write=K,F._flush=re,F}function L(){e("WebSocket onOpen"),_ instanceof n.BufferedDuplex&&_.socketReady()}function x(Q){e("WebSocket onClose",Q),_.end(),_.destroy()}function q(Q){e("WebSocket onError",Q);let K=new Error("WebSocket error");K.event=Q,_.destroy(K)}async function D(Q){if(!k||!k.readable||!k.writable)return;let{data:K}=Q;K instanceof ArrayBuffer?K=s.Buffer.from(K):K instanceof Blob?K=s.Buffer.from(await new Response(K).arrayBuffer()):K=s.Buffer.from(K,"utf8"),k.push(K)}function U(Q,K,re){if(E.bufferedAmount>I){setTimeout(U,v,Q,K,re);return}A&&typeof Q=="string"&&(Q=s.Buffer.from(Q,"utf8"));try{E.send(Q)}catch(F){return re(F)}re()}function ae(Q){E.close(),Q()}return _};f.browserStreamBuilder=m}),Qi={};Ct(Qi,{Server:()=>Ce,Socket:()=>Ce,Stream:()=>Ce,_createServerHandle:()=>Ce,_normalizeArgs:()=>Ce,_setSimultaneousAccepts:()=>Ce,connect:()=>Ce,createConnection:()=>Ce,createServer:()=>Ce,default:()=>La,isIP:()=>Ce,isIPv4:()=>Ce,isIPv6:()=>Ce});function Ce(){throw new Error("Node.js net module is not supported by JSPM core outside of Node.js")}var La,Da=He(()=>{le(),ce(),ue(),La={_createServerHandle:Ce,_normalizeArgs:Ce,_setSimultaneousAccepts:Ce,connect:Ce,createConnection:Ce,createServer:Ce,isIP:Ce,isIPv4:Ce,isIPv6:Ce,Server:Ce,Socket:Ce,Stream:Ce}}),Fa=de((f,i)=>{le(),ce(),ue(),i.exports={}}),rs=de(f=>{le(),ce(),ue();var i=f&&f.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(f,"__esModule",{value:!0});var s=i((Da(),Pe(Qi))),a=i(at()),l=i(Fa()),t=(0,a.default)("mqttjs:tcp"),r=(n,e)=>{if(e.port=e.port||1883,e.hostname=e.hostname||e.host||"localhost",e.socksProxy)return(0,l.default)(e.hostname,e.port,e.socksProxy,{timeout:e.socksTimeout});let{port:o,path:u}=e,p=e.hostname;return t("port %d and host %s",o,p),s.default.createConnection({port:o,host:p,path:u})};f.default=r}),Wa={};Ct(Wa,{default:()=>qa});var qa,lc=He(()=>{le(),ce(),ue(),qa={}}),ns=de(f=>{le(),ce(),ue();var i=f&&f.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(f,"__esModule",{value:!0});var s=(lc(),Pe(Wa)),a=i((Da(),Pe(Qi))),l=i(at()),t=i(Fa()),r=(0,l.default)("mqttjs:tls");function n(o){let{host:u,port:p,socksProxy:d,...b}=o;if(d!==void 0){let h=(0,t.default)(u,p,d,{timeout:o.socksTimeout});return(0,s.connect)({...b,socket:h})}return(0,s.connect)(o)}var e=(o,u)=>{u.port=u.port||8883,u.host=u.hostname||u.host||"localhost",a.default.isIP(u.host)===0&&(u.servername=u.host),u.rejectUnauthorized=u.rejectUnauthorized!==!1,delete u.path,r("port %d host %s rejectUnauthorized %b",u.port,u.host,u.rejectUnauthorized);let p=n(u);p.on("secureConnect",()=>{u.rejectUnauthorized&&!p.authorized?p.emit("error",new Error("TLS not authorized")):p.removeListener("error",d)});function d(b){u.rejectUnauthorized&&o.emit("error",b),p.end()}return p.on("error",d),p};f.default=e}),is=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=(Ue(),Pe(Ne)),s=Tt(),a=Gi(),l,t,r;function n(){let d=new s.Transform;return d._write=(b,h,y)=>{l.send({data:b.buffer,success(){y()},fail(m){y(new Error(m))}})},d._flush=b=>{l.close({success(){b()}})},d}function e(d){d.hostname||(d.hostname="localhost"),d.path||(d.path="/"),d.wsOptions||(d.wsOptions={})}function o(d,b){let h=d.protocol==="wxs"?"wss":"ws",y=`${h}://${d.hostname}${d.path}`;return d.port&&d.port!==80&&d.port!==443&&(y=`${h}://${d.hostname}:${d.port}${d.path}`),typeof d.transformWsUrl=="function"&&(y=d.transformWsUrl(y,d,b)),y}function u(){l.onOpen(()=>{r.socketReady()}),l.onMessage(d=>{let{data:b}=d;b instanceof ArrayBuffer?b=i.Buffer.from(b):b=i.Buffer.from(b,"utf8"),t.push(b)}),l.onClose(()=>{r.emit("close"),r.end(),r.destroy()}),l.onError(d=>{let b=new Error(d.errMsg);r.destroy(b)})}var p=(d,b)=>{if(b.hostname=b.hostname||b.host,!b.hostname)throw new Error("Could not determine host. Specify host manually.");let h=b.protocolId==="MQIsdp"&&b.protocolVersion===3?"mqttv3.1":"mqtt";e(b);let y=o(b,d);l=wx.connectSocket({url:y,protocols:[h]}),t=n(),r=new a.BufferedDuplex(b,t,l),r._destroy=(S,g)=>{l.close({success(){g&&g(S)}})};let m=r.destroy;return r.destroy=(S,g)=>(r.destroy=m,setTimeout(()=>{l.close({fail(){r._destroy(S,g)}})},0),r),u(),r};f.default=p}),os=de(f=>{le(),ce(),ue(),Object.defineProperty(f,"__esModule",{value:!0});var i=(Ue(),Pe(Ne)),s=Tt(),a=Gi(),l,t,r,n=!1;function e(){let b=new s.Transform;return b._write=(h,y,m)=>{l.sendSocketMessage({data:h.buffer,success(){m()},fail(){m(new Error)}})},b._flush=h=>{l.closeSocket({success(){h()}})},b}function o(b){b.hostname||(b.hostname="localhost"),b.path||(b.path="/"),b.wsOptions||(b.wsOptions={})}function u(b,h){let y=b.protocol==="alis"?"wss":"ws",m=`${y}://${b.hostname}${b.path}`;return b.port&&b.port!==80&&b.port!==443&&(m=`${y}://${b.hostname}:${b.port}${b.path}`),typeof b.transformWsUrl=="function"&&(m=b.transformWsUrl(m,b,h)),m}function p(){n||(n=!0,l.onSocketOpen(()=>{r.socketReady()}),l.onSocketMessage(b=>{if(typeof b.data=="string"){let h=i.Buffer.from(b.data,"base64");t.push(h)}else{let h=new FileReader;h.addEventListener("load",()=>{if(h.result instanceof ArrayBuffer){t.push(i.Buffer.from(h.result));return}t.push(i.Buffer.from(h.result,"utf-8"))}),h.readAsArrayBuffer(b.data)}}),l.onSocketClose(()=>{r.end(),r.destroy()}),l.onSocketError(b=>{r.destroy(b)}))}var d=(b,h)=>{if(h.hostname=h.hostname||h.host,!h.hostname)throw new Error("Could not determine host. Specify host manually.");let y=h.protocolId==="MQIsdp"&&h.protocolVersion===3?"mqttv3.1":"mqtt";o(h);let m=u(h,b);return l=h.my,l.connectSocket({url:m,protocols:y}),t=e(),r=new a.BufferedDuplex(h,t,l),p(),r};f.default=d}),uc=de(f=>{le(),ce(),ue();var i=f&&f.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(f,"__esModule",{value:!0}),f.connectAsync=u;var s=i(at()),a=i((sc(),Pe(ma))),l=i(Vn()),t=i(Rr());typeof Re?.nextTick!="function"&&(Re.nextTick=setImmediate);var r=(0,s.default)("mqttjs"),n=null;function e(p){let d;if(p.auth)if(d=p.auth.match(/^(.+):(.+)$/),d){let[,b,h]=d;p.username=b,p.password=h}else p.username=p.auth}function o(p,d){if(r("connecting to an MQTT broker..."),typeof p=="object"&&!d&&(d=p,p=""),d=d||{},p&&typeof p=="string"){let y=a.default.parse(p,!0),m={};if(y.port!=null&&(m.port=Number(y.port)),m.host=y.hostname,m.query=y.query,m.auth=y.auth,m.protocol=y.protocol,m.path=y.path,d={...m,...d},!d.protocol)throw new Error("Missing protocol");d.protocol=d.protocol.replace(/:$/,"")}if(d.unixSocket=d.unixSocket||d.protocol?.includes("+unix"),d.unixSocket?d.protocol=d.protocol.replace("+unix",""):!d.protocol?.startsWith("ws")&&!d.protocol?.startsWith("wx")&&delete d.path,e(d),d.query&&typeof d.query.clientId=="string"&&(d.clientId=d.query.clientId),t.default||d.unixSocket?d.socksProxy=void 0:d.socksProxy===void 0&&typeof Re<"u"&&(d.socksProxy=Re.env.MQTTJS_SOCKS_PROXY),d.cert&&d.key)if(d.protocol){if(["mqtts","wss","wxs","alis"].indexOf(d.protocol)===-1)switch(d.protocol){case"mqtt":d.protocol="mqtts";break;case"ws":d.protocol="wss";break;case"wx":d.protocol="wxs";break;case"ali":d.protocol="alis";break;default:throw new Error(`Unknown protocol for secure connection: "${d.protocol}"!`)}}else throw new Error("Missing secure protocol key");if(n||(n={},!t.default&&!d.forceNativeWebSocket?(n.ws=Xt().streamBuilder,n.wss=Xt().streamBuilder,n.mqtt=rs().default,n.tcp=rs().default,n.ssl=ns().default,n.tls=n.ssl,n.mqtts=ns().default):(n.ws=Xt().browserStreamBuilder,n.wss=Xt().browserStreamBuilder,n.wx=is().default,n.wxs=is().default,n.ali=os().default,n.alis=os().default)),!n[d.protocol]){let y=["mqtts","wss"].indexOf(d.protocol)!==-1;d.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((m,S)=>y&&S%2===0?!1:typeof n[m]=="function")[0]}if(d.clean===!1&&!d.clientId)throw new Error("Missing clientId for unclean clients");d.protocol&&(d.defaultProtocol=d.protocol);function b(y){return d.servers&&((!y._reconnectCount||y._reconnectCount===d.servers.length)&&(y._reconnectCount=0),d.host=d.servers[y._reconnectCount].host,d.port=d.servers[y._reconnectCount].port,d.protocol=d.servers[y._reconnectCount].protocol?d.servers[y._reconnectCount].protocol:d.defaultProtocol,d.hostname=d.host,y._reconnectCount++),r("calling streambuilder for",d.protocol),n[d.protocol](y,d)}let h=new l.default(b,d);return h.on("error",()=>{}),h}function u(p,d,b=!0){return new Promise((h,y)=>{let m=o(p,d),S={connect:_=>{g(),h(m)},end:()=>{g(),h(m)},error:_=>{g(),m.end(),y(_)}};b===!1&&(S.close=()=>{S.error(new Error("Couldn't connect to server"))});function g(){Object.keys(S).forEach(_=>{m.off(_,S[_])})}Object.keys(S).forEach(_=>{m.on(_,S[_])})})}f.default=o}),ss=de(f=>{le(),ce(),ue();var i=f&&f.__createBinding||(Object.create?function(b,h,y,m){m===void 0&&(m=y);var S=Object.getOwnPropertyDescriptor(h,y);(!S||("get"in S?!h.__esModule:S.writable||S.configurable))&&(S={enumerable:!0,get:function(){return h[y]}}),Object.defineProperty(b,m,S)}:function(b,h,y,m){m===void 0&&(m=y),b[m]=h[y]}),s=f&&f.__setModuleDefault||(Object.create?function(b,h){Object.defineProperty(b,"default",{enumerable:!0,value:h})}:function(b,h){b.default=h}),a=f&&f.__importStar||(function(){var b=function(h){return b=Object.getOwnPropertyNames||function(y){var m=[];for(var S in y)Object.prototype.hasOwnProperty.call(y,S)&&(m[m.length]=S);return m},b(h)};return function(h){if(h&&h.__esModule)return h;var y={};if(h!=null)for(var m=b(h),S=0;S<m.length;S++)m[S]!=="default"&&i(y,h,m[S]);return s(y,h),y}})(),l=f&&f.__exportStar||function(b,h){for(var y in b)y!=="default"&&!Object.prototype.hasOwnProperty.call(h,y)&&i(h,b,y)},t=f&&f.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(f,"__esModule",{value:!0}),f.ReasonCodes=f.KeepaliveManager=f.UniqueMessageIdProvider=f.DefaultMessageIdProvider=f.Store=f.MqttClient=f.connectAsync=f.connect=f.Client=void 0;var r=t(Vn());f.MqttClient=r.default;var n=t(ia());f.DefaultMessageIdProvider=n.default;var e=t(_u());f.UniqueMessageIdProvider=e.default;var o=t(Ws());f.Store=o.default;var u=a(uc());f.connect=u.default,Object.defineProperty(f,"connectAsync",{enumerable:!0,get:function(){return u.connectAsync}});var p=t(ha());f.KeepaliveManager=p.default,f.Client=r.default,l(Vn(),f),l(jt(),f),l(Fs(),f);var d=Or();Object.defineProperty(f,"ReasonCodes",{enumerable:!0,get:function(){return d.ReasonCodes}})}),cc=de(f=>{le(),ce(),ue();var i=f&&f.__createBinding||(Object.create?function(r,n,e,o){o===void 0&&(o=e);var u=Object.getOwnPropertyDescriptor(n,e);(!u||("get"in u?!n.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return n[e]}}),Object.defineProperty(r,o,u)}:function(r,n,e,o){o===void 0&&(o=e),r[o]=n[e]}),s=f&&f.__setModuleDefault||(Object.create?function(r,n){Object.defineProperty(r,"default",{enumerable:!0,value:n})}:function(r,n){r.default=n}),a=f&&f.__importStar||(function(){var r=function(n){return r=Object.getOwnPropertyNames||function(e){var o=[];for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&(o[o.length]=u);return o},r(n)};return function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var o=r(n),u=0;u<o.length;u++)o[u]!=="default"&&i(e,n,o[u]);return s(e,n),e}})(),l=f&&f.__exportStar||function(r,n){for(var e in r)e!=="default"&&!Object.prototype.hasOwnProperty.call(n,e)&&i(n,r,e)};Object.defineProperty(f,"__esModule",{value:!0});var t=a(ss());f.default=t,l(ss(),f)});const hc=cc();const fc={inbound:"apps/{appId}/users/{userId}/messages/{conversationId}/clientadded",inboundUpdate:"apps/{appId}/users/{userId}/messages/{conversationId}/{messageId}/update",outbound:"apps/{appId}/outgoing/users/{userId}/messages/{conversationId}/outgoing",presence:"apps/{appId}/users/{userId}/presence/{clientId}",wildcardSubscribe:"apps/{appId}/users/{userId}/#"},pc=300,dc={templateId:"7",type:"link",isDeepLink:!0},gc={channelType:"group",channel:"chat21",requestChannel:"chat21",platform:"WEBSITE",medium:"CHATBUDDY"};class $a{client=null;config;currentToken;clientId;appId;topics;messageHandlers=[];stateHandlers=[];statusUpdateHandlers=[];subscribedTopics=new Set;reconnectAttempt=0;maxReconnectAttempts;reconnectMaxDelayMs;disposed=!1;reconnectTimer=null;inboundRegex;inboundUpdateRegex;constructor(i){this.config=i,this.currentToken=i.jwtToken,this.appId=i.appId??"tilechat",this.clientId=i.clientId??`aikaara_${i.userId}_${Date.now()}`,this.topics={...fc,...i.topicTemplates??{}},this.maxReconnectAttempts=i.maxReconnectAttempts??10,this.reconnectMaxDelayMs=i.reconnectMaxDelayMs??3e4,this.inboundRegex=this.buildTopicRegex(this.topics.inbound,["conversationId"]),this.inboundUpdateRegex=this.buildTopicRegex(this.topics.inboundUpdate,["conversationId","messageId"])}async connect(){if(this.disposed)return;const i=this.renderPresenceTopic(),s=this.config.presencePayloadDisconnected??{disconnected:!0},a={clientId:this.clientId,username:this.config.mqttUsername??"JWT",password:this.currentToken,clean:!0,reconnectPeriod:0,connectTimeout:this.config.connectTimeoutMs??1e4,keepalive:this.config.keepAliveSec??60,protocolVersion:this.config.protocolVersion??3,protocolId:this.config.protocolId??"MQIsdp"};return this.config.enablePresence!==!1&&(a.will={topic:i,payload:Buffer.from(JSON.stringify(s)),qos:0,retain:!1}),new Promise((l,t)=>{this.client=hc.connect(this.config.mqttEndpoint,a),this.client.on("connect",()=>{if(this.reconnectAttempt=0,this.notifyStateChange(!0),this.config.enablePresence!==!1){const r=this.config.presencePayloadConnected??{connected:!0};this.client.publish(i,JSON.stringify(r),{qos:0,retain:!1})}l()}),this.client.on("message",(r,n)=>{this.dispatchInbound(r,n)}),this.client.on("close",()=>{this.notifyStateChange(!1),this.disposed||this.scheduleReconnect()}),this.client.on("error",r=>{this.reconnectAttempt===0&&t(r)})})}subscribeWildcard(){if(!this.client)return;const i=this.renderTemplate(this.topics.wildcardSubscribe,{});this.subscribedTopics.has(i)||(this.client.subscribe(i,{qos:this.config.subscribeQos??2}),this.subscribedTopics.add(i))}subscribeToConversation(i){if(!this.client)return;if(this.config.wildcardSubscribe){this.subscribeWildcard();return}const s=this.renderInboundTopic(i);this.subscribedTopics.has(s)||(this.client.subscribe(s,{qos:this.config.subscribeQos??2}),this.subscribedTopics.add(s))}unsubscribeFromConversation(i){if(!this.client)return;const s=this.renderInboundTopic(i);this.subscribedTopics.has(s)&&(this.client.unsubscribe(s),this.subscribedTopics.delete(s))}publishMessage(i,s,a={}){if(!this.client)return;const l=this.buildOutgoingEnvelope(i,{text:s,type:"text",...a});this.publishEnvelope(i,l)}publishFileMessage(i,s){if(!this.client)return;const a={...dc,...this.config.fileTemplate??{},...yc(s)},l={metadata:{contentType:"300",templateId:a.templateId,payload:{...a.headerImgSrc?{headerImgSrc:a.headerImgSrc}:{},elements:[{description:s.description??s.fileName,action:{url:s.fileUrl,type:a.type??"link",isDeepLink:a.isDeepLink??!0}}]},...s.metadata??{}}},t={fileMessage:!0,...s.cloudFileId?{cloudFileId:s.cloudFileId}:{},...s.attributes??{}},r=this.buildOutgoingEnvelope(i,{text:JSON.stringify(l),type:"html",attributes:t,metadata:l.metadata});this.publishEnvelope(i,r)}publishRaw(i,s){this.client&&this.publishEnvelope(i,s)}publishReadReceipt(i,s,a=pc){if(!this.client)return;const l=this.renderTemplate(this.topics.inboundUpdate,{conversationId:i,messageId:s});this.client.publish(l,JSON.stringify({status:a}),{qos:this.config.publishQos??0,retain:!1})}publishChatInitiated(i,s={}){if(!this.client)return;const a=this.buildOutgoingEnvelope(i,{text:"CHAT_INITIATED",type:"text",attributes:{subtype:"info",...s}});this.publishEnvelope(i,a)}onMessage(i){return this.messageHandlers.push(i),()=>{this.messageHandlers=this.messageHandlers.filter(s=>s!==i)}}onStateChange(i){return this.stateHandlers.push(i),()=>{this.stateHandlers=this.stateHandlers.filter(s=>s!==i)}}onStatusUpdate(i){return this.statusUpdateHandlers.push(i),()=>{this.statusUpdateHandlers=this.statusUpdateHandlers.filter(s=>s!==i)}}disconnect(){this.disposed=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.client&&(this.subscribedTopics.forEach(i=>this.client.unsubscribe(i)),this.subscribedTopics.clear(),this.client.end(!0),this.client=null),this.messageHandlers=[],this.stateHandlers=[],this.statusUpdateHandlers=[]}get isConnected(){return this.client?.connected??!1}async scheduleReconnect(){if(this.reconnectAttempt>=this.maxReconnectAttempts||this.disposed)return;const i=Math.min(1e3*Math.pow(2,this.reconnectAttempt),this.reconnectMaxDelayMs);this.reconnectAttempt++,this.reconnectTimer=setTimeout(async()=>{if(!this.disposed){if(this.config.tokenProvider)try{this.currentToken=await this.config.tokenProvider()}catch{}try{await this.connect();const s=[...this.subscribedTopics];this.subscribedTopics.clear(),s.forEach(a=>{this.client&&(this.client.subscribe(a,{qos:this.config.subscribeQos??2}),this.subscribedTopics.add(a))})}catch{}}},i)}notifyStateChange(i){this.stateHandlers.forEach(s=>s(i))}dispatchInbound(i,s){let a=null;try{a=JSON.parse(s.toString())}catch{return}if(!a)return;const l=i.match(this.inboundUpdateRegex);if(l){const e=l.groups?.conversationId??"",o=l.groups?.messageId??"",u=typeof a.status=="number"?a.status:Number(a.status??0),p={conversationId:e,messageId:o,status:u,raw:a};this.statusUpdateHandlers.forEach(d=>d(p)),this.messageHandlers.forEach(d=>d(a,{topic:i,conversationId:e,messageId:o,kind:"update"}));return}const t=i.match(this.inboundRegex),r=t?.groups?.conversationId,n={topic:i,conversationId:r,messageId:typeof a.message_id=="string"?a.message_id:void 0,kind:t?"clientadded":"unknown"};this.messageHandlers.forEach(e=>e(a,n))}buildOutgoingEnvelope(i,s){const a={...gc,...this.config.messageDefaults??{}},l=this.config.senderFullname??this.config.userName??this.config.userId,t=this.config.recipientFullnameResolver?.(i),r={projectId:this.config.projectId,...a.departmentId?{departmentId:a.departmentId}:{},...this.config.userName?{userFullname:this.config.userName}:{},...a.channel?{channel:a.channel}:{},...a.requestChannel?{request_channel:a.requestChannel}:{},...a.attributes??{},...s.attributes??{}};return{type:"text",sender:this.config.userId,sender_fullname:l,senderFullname:l,recipient:i,...t?{recipient_fullname:t}:{},...a.channelType?{channel_type:a.channelType}:{},...a.medium?{medium:a.medium}:{},...a.platform?{platform:a.platform}:{},app_id:this.appId,timestamp:Date.now(),...s,attributes:r}}publishEnvelope(i,s){if(!this.client)return;const a=this.renderOutboundTopic(i);this.client.publish(a,JSON.stringify(s),{qos:this.config.publishQos??0,retain:this.config.publishRetain??!1})}renderInboundTopic(i){return this.renderTemplate(this.topics.inbound,{conversationId:i})}renderOutboundTopic(i){return this.renderTemplate(this.topics.outbound,{conversationId:i})}renderPresenceTopic(){return this.renderTemplate(this.topics.presence,{})}renderTemplate(i,s){const a={appId:this.appId,userId:this.config.userId,projectId:this.config.projectId,clientId:this.clientId,...s};return i.replace(/\{(\w+)\}/g,(l,t)=>a[t]??"")}buildTopicRegex(i,s){const a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{(\w+)\\\}/g,(l,t)=>{const r={appId:this.appId,userId:this.config.userId,projectId:this.config.projectId,clientId:this.clientId};if(s.includes(t))return`(?<${t}>[^/]+)`;const n=r[t];return n?n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):"[^/]+"});return new RegExp(`^${a}$`)}}function yc(f){const i={};for(const[s,a]of Object.entries(f))a!==void 0&&(i[s]=a);return i}function Ha(f,i){return(f.sender??"").toString()===i}function za(f,i){const s=(f.sender??"").toString(),a=i.systemSenders??["metadata","system"],l=i.botSenderPrefix??"bot_";return s?s===i.userId?"user":s.startsWith(l)?"assistant":a.includes(s)?"system":"agent":"system"}function Yi(f){const i={raw:f},s=f.metadata;if(s&&typeof s=="object"&&(typeof s.contentType=="string"&&(i.contentType=s.contentType),typeof s.templateId=="string"&&(i.templateId=s.templateId),s.payload!==void 0&&(i.payload=s.payload)),typeof f.text=="string"&&f.text.trim().startsWith("{"))try{const a=JSON.parse(f.text);typeof a.message=="string"&&(i.innerMessage=a.message);const l=a.metadata;l&&typeof l=="object"&&(!i.contentType&&typeof l.contentType=="string"&&(i.contentType=l.contentType),!i.templateId&&typeof l.templateId=="string"&&(i.templateId=l.templateId),i.payload===void 0&&l.payload!==void 0&&(i.payload=l.payload))}catch{}return i}function Ka(f){const i=Yi(f);if(i.contentType!=="300")return null;const s=i.payload,a=s&&Array.isArray(s.elements)?s.elements:null;if(!a||a.length===0)return null;const l=a[0],t=l.action,r=t&&typeof t.url=="string"?t.url:void 0,n=typeof l.description=="string"?l.description:void 0,e=f.attributes,o=e&&typeof e.cloudFileId=="string"?e.cloudFileId:void 0;return!r&&!n?null:{fileName:n,fileUrl:r,cloudFileId:o,templateId:i.templateId}}function mc(f,i,s){const a=za(f,s),l=Yi(f),t=Ka(f);let r="";l.innerMessage?r=l.innerMessage:typeof f.text=="string"&&(f.text.trim().startsWith("{")?l.contentType!=="300"&&(r=f.text):r=f.text);const n=typeof f.message_id=="string"?f.message_id:`td_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,e=typeof f.timestamp=="number"?new Date(f.timestamp).toISOString():new Date().toISOString(),o=a==="assistant"?"assistant":a==="agent"?"agent":a==="system"?"system":"user",u=typeof f.status=="number"?bc(f.status):"delivered",p={id:n,externalId:n,conversationId:i,role:o,content:r,createdAt:e,status:u,metadata:{sender:f.sender,sender_fullname:f.sender_fullname??f.senderFullname,app_id:f.app_id,attributes:f.attributes}};return l.contentType&&(p.template={contentType:l.contentType,templateId:l.templateId,payload:l.payload}),t?.fileUrl&&(p.attachments=[{fileName:t.fileName??"file",fileUrl:t.fileUrl,cloudFileId:t.cloudFileId}]),{message:p,template:l}}function bc(f){return f<0?"error":f>=250?"read":f>=150?"delivered":"sent"}class vc extends Ni{connection=null;tiledesk=null;api;messageStore;conversationManager;subscription=null;config;mode;uploadAdapter;tiledeskUnsubs=[];constructor(i,s){super(),this.config=i,this.mode=i.transport??"aikaara",this.uploadAdapter=s?.uploadAdapter??null,this.api=new us(i.baseUrl,i.userToken,i.apiKey,i.authToken),this.messageStore=new cs,this.conversationManager=new hs(i.conversationId),this.usesAikaara()&&(this.connection=new ls(i),this.connection.on("connection:state",a=>{this.emit("connection:state",a),this.config.onConnectionStateChange?.(a)}),this.connection.on("error",a=>{this.emit("error",a),this.config.onError?.(a)})),this.usesTiledesk()&&this.initTiledeskTransport()}usesAikaara(){return this.mode==="aikaara"||this.mode==="dual"}usesTiledesk(){return this.mode==="tiledesk"||this.mode==="dual"}initTiledeskTransport(){const i=this.config.tiledesk,s=this.config.tiledeskIdentity;if(!i)throw new Error("AikaaraChatClient: tiledesk transport requires `config.tiledesk` (TiledeskTransportConfig)");if(!s?.userId)throw new Error("AikaaraChatClient: tiledesk transport requires `config.tiledeskIdentity.userId`");this.tiledesk=new $a({...i,userId:s.userId,userName:s.userName??i.userName,senderFullname:s.senderFullname??i.senderFullname,messageDefaults:{...i.messageDefaults,departmentId:s.departmentId??i.messageDefaults?.departmentId}}),this.tiledeskUnsubs.push(this.tiledesk.onStateChange(a=>{const l=a?"connected":"disconnected";this.emit("connection:state",l),this.config.onConnectionStateChange?.(l)})),this.tiledeskUnsubs.push(this.tiledesk.onMessage((a,l)=>this.handleTiledeskMessage(a,l))),this.tiledeskUnsubs.push(this.tiledesk.onStatusUpdate(a=>this.handleTiledeskStatusUpdate(a)))}async connect(){if(this.usesAikaara()&&this.connection){if(await this.connection.connect(),!this.conversationManager.conversationId){const i=await this.api.createConversation({systemPromptId:this.config.systemPromptId,channel:this.config.channel||"widget",extUid:this.config.extUid});this.conversationManager.conversationId=String(i.id)}this.subscription=await this.connection.subscribeToConversation(this.conversationManager.conversationId),this.subscription.onReceived(i=>{this.handleBroadcast(i)}),await this.loadHistory()}this.usesTiledesk()&&this.tiledesk&&(await this.tiledesk.connect(),this.config.tiledesk?.wildcardSubscribe??!0?this.tiledesk.subscribeWildcard():this.conversationManager.conversationId&&this.tiledesk.subscribeToConversation(this.conversationManager.conversationId))}async sendMessage(i){const s=this.conversationManager.conversationId;if(!s)throw new Error("No active conversation");const a=this.messageStore.addOptimistic("user",i,s);if(this.emit("message:sent",a),this.config.onMessage?.(a),this.mode==="tiledesk"&&this.tiledesk){this.tiledesk.publishMessage(s,i);return}this.mode==="dual"&&this.tiledesk&&this.tiledesk.publishMessage(s,i),this.usesAikaara()&&this.connection&&this.connection.sendMessage(s,i)}async sendFile(i,s){if(!this.uploadAdapter)throw new Error("AikaaraChatClient: sendFile requires an UploadAdapter");const a=this.conversationManager.conversationId;if(!a)throw new Error("No active conversation");const l=await this.uploadAdapter.upload(i,{conversationId:a,userId:this.config.tiledeskIdentity?.userId??this.config.userToken,projectId:this.config.tiledesk?.projectId,appId:this.config.tiledesk?.appId});if(this.usesTiledesk()&&this.tiledesk){const t={fileName:l.fileName,fileUrl:l.url,cloudFileId:l.cloudFileId};this.tiledesk.publishFileMessage(a,t)}s?.caption&&await this.sendMessage(s.caption)}initiateTiledeskChat(i={}){const s=this.conversationManager.conversationId;!this.tiledesk||!s||this.tiledesk.publishChatInitiated(s,i)}markTiledeskRead(i){const s=this.conversationManager.conversationId;!this.tiledesk||!s||this.tiledesk.publishReadReceipt(s,i)}setUploadAdapter(i){this.uploadAdapter=i}async sendUserEvent(i,s,a){const l=this.conversationManager.conversationId;if(!l)throw new Error("No active conversation");this.connection&&this.connection.sendUserEvent(l,i,s,a)}async loadHistory(){const i=this.conversationManager.conversationId;if(!i)return[];try{const s=await this.api.getMessages(i);return this.messageStore.setMessages(s),s}catch{return[]}}get messages(){return this.messageStore.messages}get conversationId(){return this.conversationManager.conversationId}get isConnected(){if(this.mode==="tiledesk")return this.tiledesk?.isConnected??!1;if(this.mode==="dual"){const i=this.connection?.connectionState==="connected",s=this.tiledesk?.isConnected??!1;return i&&s}return this.connection?.connectionState==="connected"}async setContext(i){const s=this.conversationManager.conversationId;s&&await this.api.updateContext(s,{current_page:i.currentPage,entity_type:i.entityType,entity_id:i.entityId,project_id:i.projectId,available_routes:i.availableRoutes,custom_context:i.custom})}async disconnect(){this.subscription&&(this.subscription=null),this.connection&&await this.connection.disconnect(),this.tiledesk&&(this.tiledeskUnsubs.forEach(i=>i()),this.tiledeskUnsubs=[],this.tiledesk.disconnect(),this.tiledesk=null)}handleTiledeskMessage(i,s){if(s.kind==="update")return;const a=s.conversationId??this.conversationManager.conversationId;if(!a)return;const l=this.config.tiledeskIdentity?.userId??"",{message:t,template:r}=mc(i,a,{userId:l,systemSenders:this.config.tiledesk?.messageDefaults?.attributes?.systemSenders});if(this.mode==="dual"&&t.role==="assistant")return;if(Ha(i,l)){const o=this.messageStore.reconcileOptimistic(t);if(o){this.emit("message:updated",o);return}}const{message:n,deduped:e}=this.messageStore.upsertRemoteMessage(t);if(e?this.emit("message:updated",n):(this.emit("message:received",n),this.config.onMessage?.(n)),r.contentType){const o={messageId:n.id,conversationId:a,role:t.role==="tool"?"system":t.role,contentType:r.contentType,templateId:r.templateId,payload:r.payload,innerMessage:r.innerMessage,raw:i};this.config.onTemplateMessage?.(o)}}handleTiledeskStatusUpdate(i){i.status>=250?this.messageStore.updateMessageStatus(i.messageId,"read"):i.status>=150&&this.messageStore.updateMessageStatus(i.messageId,"delivered")}parseActionResult(i){try{const s=typeof i=="string"?JSON.parse(i):i;if(!s||typeof s!="object")return;s.navigate_to?this.emit("action:navigate",s):s.action==="edit_entity"?this.emit("action:edit_entity",s):s.action==="save_entity"?this.emit("action:save_entity",s):s.action==="test_tool"&&this.emit("action:test_tool",s)}catch{}}handleBroadcast(i){const s=this.conversationManager.conversationId;switch(i.type){case"status":{const a=i.status;this.emit("status",a),this.config.onStatusChange?.(a),a==="processing"&&this.emit("typing:start",void 0);break}case"error":{const a=new Error(i.message||"Unknown error");this.emit("error",a),this.config.onError?.(a);break}case"message_start":{if(i.role==="assistant"){const a=this.messageStore.addStreamingMessage(s);this.emit("stream:start",{messageId:a.id}),this.emit("typing:start",void 0)}break}case"message_update":{const a=i.delta||"",l=i.content||"";l?this.messageStore.updateStreaming(l):a&&this.messageStore.appendToStreaming(a);const t=this.messageStore.streamingContent;this.emit("stream:update",{delta:a,content:t}),this.config.onStreamUpdate?.(a,t);break}case"message_end":{const a=i.usage,l=this.messageStore.finalizeStreaming(a?{tokensInput:a.tokens_input||0,tokensOutput:a.tokens_output||0}:void 0);this.emit("typing:stop",void 0),l&&(this.emit("stream:end",{messageId:l.id,usage:a?{tokensInput:a.tokens_input||0,tokensOutput:a.tokens_output||0}:void 0}),this.emit("message:received",l),this.config.onMessage?.(l));break}case"message_queued":{const a=this.messageStore.messages.findLast(l=>l.status==="sending");a&&this.messageStore.confirmOptimistic(a.id);break}case"tool_execution_start":{this.emit("tool:start",{toolName:i.tool_name||"",args:i.args||{}}),this.emit("status",i.type);break}case"tool_execution_end":{this.emit("tool:end",{toolName:i.tool_name||"",result:i.result,isError:!!i.is_error}),this.emit("status",i.type),this.parseActionResult(i.result);break}case"tool_execution_update":case"agent_start":case"agent_end":case"turn_start":case"turn_end":case"auto_retry_start":case"auto_retry_end":case"cancelled":this.emit("status",i.type);break}}}exports.ActionCableClient=Ur;exports.AikaaraChatClient=vc;exports.ApiClient=us;exports.ChannelSubscription=as;exports.ConnectionManager=ls;exports.ConversationManager=hs;exports.DEFAULT_BORDER_RADIUS=Xa;exports.DEFAULT_FONT_FAMILY=Za;exports.DEFAULT_OFFSET=nl;exports.DEFAULT_PLACEHOLDER=el;exports.DEFAULT_POSITION=tl;exports.DEFAULT_PRIMARY_COLOR=Ja;exports.DEFAULT_THEME=rl;exports.DEFAULT_WIDGET_HEIGHT=Ya;exports.DEFAULT_WIDGET_WIDTH=Qa;exports.EventEmitter=Ni;exports.MessageStore=cs;exports.TiledeskTransport=$a;exports.extractTiledeskFileEnvelope=Ka;exports.inferTiledeskRole=za;exports.isTiledeskSelfEcho=Ha;exports.parseTiledeskTemplate=Yi;
|