coze-bridge 0.1.73 → 0.1.74
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/index.js +92 -91
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -5,28 +5,28 @@ import { dirname as __coze_dirname } from 'node:path';
|
|
|
5
5
|
const require = __coze_createRequire(import.meta.url);
|
|
6
6
|
const __filename = __coze_fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __coze_dirname(__filename);
|
|
8
|
-
var
|
|
9
|
-
`):
|
|
10
|
-
`)}function j(
|
|
11
|
-
${
|
|
12
|
-
`)[0]?.trim()||void 0}catch{return}}async function
|
|
13
|
-
`)[0]?.trim()||void 0}catch{return}}async function
|
|
14
|
-
`,a=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{i?.mode!==void 0?await no(a,o,{encoding:"utf8",mode:i.mode}):await no(a,o,"utf8"),await to(a,n),i?.mode!==void 0&&await of(n,i.mode)}catch(c){await to(a,a).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(a,{force:!0}).catch(()=>{}),c}}var Hn=Ge(()=>{"use strict"});import{promises as ro}from"node:fs";import{homedir as ff}from"node:os";import{sep as uf,join as Ce,resolve as io}from"node:path";function X(n){let e=n??ff(),i=Ce(e,".coze"),o=Ce(i,"bridge"),a=Ce(o,"lib");return{cozeRoot:i,bridgeRoot:o,libDir:a,libEntry:Ce(a,"index.js"),binDir:Ce(o,"bin"),pidFile:Ce(o,"bridge.pid"),portFile:Ce(o,"bridge.port"),tokenFile:Ce(o,"bridge.token"),patTokenFile:Ce(o,"pat-token"),logFile:Ce(o,"bridge.log"),installLock:Ce(o,"install.lock"),configFile:Ce(o,"config.json"),agentsRoot:Ce(i,"agents")}}function Qe(n,e=X()){let i=Ce(e.agentsRoot,n);return{root:i,config:Ce(i,"config.json"),workspace:Ce(i,"workspace"),logs:Ce(i,"logs")}}async function so(n,e){let i=await ro.realpath(io(n)).catch(()=>null);if(!i)return!1;let o=await ro.realpath(io(e)).catch(()=>null);if(!o)return!1;let a=process.platform==="win32"?i.toLowerCase():i,c=process.platform==="win32"?o.toLowerCase():o;return a===c||a.startsWith(c+uf)}var Ae=Ge(()=>{"use strict"});var Kn={};di(Kn,{AGENT_CONFIG_FILE_MODE:()=>Gn,enforceAgentConfigMode:()=>gf,loadAgentConfig:()=>ke,persistAgentSessions:()=>gi,persistAgentSkills:()=>jn,saveAgentConfig:()=>Re});import{chmod as xf,stat as lf}from"node:fs/promises";function ke(n,e){return Bt(Qe(n,e).config)}function Re(n,e){return qn(Qe(n.agentId,e).config,n,{mode:Gn})}async function gf(n,e){if(process.platform==="win32")return;let i=Qe(n,e).config;try{let o=await lf(i);if(!o.isFile())return;let a=o.mode&511;a!==Gn&&(await xf(i,Gn),oo.warn("agent config mode auto-corrected to 0600",{path:i,from:a.toString(8)}))}catch(o){if(o.code==="ENOENT")return;oo.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:i,err:String(o)})}}async function gi(n,e,i){let o=await ke(n,i);o&&(o.sessions=Object.fromEntries(e),await Re(o,i))}async function jn(n,e,i){let o=await ke(n,i);o&&(o.skills=e,await Re(o,i))}var oo,Gn,ut=Ge(()=>{"use strict";Hn();Y();Ae();oo=j("agent-config"),Gn=384});var pi=ee((kp,uo)=>{uo.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Jn=ee(lo=>{var xo={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Ef(n){return function(...e){return e.length&&(n=n.replace(/\{(\d)\}/g,(i,o)=>e[o]||"")),new Error("ADM-ZIP: "+n)}}for(let n of Object.keys(xo))lo[n]=Ef(xo[n])});var wo=ee((Rp,mo)=>{var bf=ie("fs"),_e=ie("path"),go=pi(),vf=Jn(),Sf=typeof process=="object"&&process.platform==="win32",ho=n=>typeof n=="object"&&n!==null,po=new Uint32Array(256).map((n,e)=>{for(let i=0;i<8;i++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function le(n){this.sep=_e.sep,this.fs=bf,ho(n)&&ho(n.fs)&&typeof n.fs.statSync=="function"&&(this.fs=n.fs)}mo.exports=le;le.prototype.makeDir=function(n){let e=this;function i(o){let a=o.split(e.sep)[0];o.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){a+=e.sep+c;var f;try{f=e.fs.statSync(a)}catch(x){if(x.message&&x.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw x}if(f&&f.isFile())throw vf.FILE_IN_THE_WAY(`"${a}"`)}})}i(n)};le.prototype.writeFileTo=function(n,e,i,o){let a=this;if(a.fs.existsSync(n)){if(!i)return!1;var c=a.fs.statSync(n);if(c.isDirectory())return!1}var f=_e.dirname(n);a.fs.existsSync(f)||a.makeDir(f);var x;try{x=a.fs.openSync(n,"w",438)}catch{a.fs.chmodSync(n,438),x=a.fs.openSync(n,"w",438)}if(x)try{a.fs.writeSync(x,e,0,e.length,0)}finally{a.fs.closeSync(x)}return a.fs.chmodSync(n,o||438),!0};le.prototype.writeFileToAsync=function(n,e,i,o,a){typeof o=="function"&&(a=o,o=void 0);let c=this;c.fs.exists(n,function(f){if(f&&!i)return a(!1);c.fs.stat(n,function(x,g){if(f&&g.isDirectory())return a(!1);var p=_e.dirname(n);c.fs.exists(p,function(y){y||c.makeDir(p),c.fs.open(n,"w",438,function(v,A){v?c.fs.chmod(n,438,function(){c.fs.open(n,"w",438,function(E,b){c.fs.write(b,e,0,e.length,0,function(){c.fs.close(b,function(){c.fs.chmod(n,o||438,function(){a(!0)})})})})}):A?c.fs.write(A,e,0,e.length,0,function(){c.fs.close(A,function(){c.fs.chmod(n,o||438,function(){a(!0)})})}):c.fs.chmod(n,o||438,function(){a(!0)})})})})})};le.prototype.findFiles=function(n){let e=this;function i(o,a,c){typeof a=="boolean"&&(c=a,a=void 0);let f=[];return e.fs.readdirSync(o).forEach(function(x){let g=_e.join(o,x),p=e.fs.statSync(g);(!a||a.test(g))&&f.push(_e.normalize(g)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(f=f.concat(i(g,a,c)))}),f}return i(n,void 0,!0)};le.prototype.findFilesAsync=function(n,e){let i=this,o=[];i.fs.readdir(n,function(a,c){if(a)return e(a);let f=c.length;if(!f)return e(null,o);c.forEach(function(x){x=_e.join(n,x),i.fs.stat(x,function(g,p){if(g)return e(g);p&&(o.push(_e.normalize(x)+(p.isDirectory()?i.sep:"")),p.isDirectory()?i.findFilesAsync(x,function(y,v){if(y)return e(y);o=o.concat(v),--f||e(null,o)}):--f||e(null,o))})})})};le.prototype.getAttributes=function(){};le.prototype.setAttributes=function(){};le.crc32update=function(n,e){return po[(n^e)&255]^n>>>8};le.crc32=function(n){typeof n=="string"&&(n=Buffer.from(n,"utf8"));let e=n.length,i=-1;for(let o=0;o<e;)i=le.crc32update(i,n[o++]);return~i>>>0};le.methodToString=function(n){switch(n){case go.STORED:return"STORED ("+n+")";case go.DEFLATED:return"DEFLATED ("+n+")";default:return"UNSUPPORTED ("+n+")"}};le.canonical=function(n){if(!n)return"";let e=_e.posix.normalize("/"+n.split("\\").join("/"));return _e.join(".",e)};le.zipnamefix=function(n){if(!n)return"";let e=_e.posix.normalize("/"+n.split("\\").join("/"));return _e.posix.join(".",e)};le.findLast=function(n,e){if(!Array.isArray(n))throw new TypeError("arr is not array");let i=n.length>>>0;for(let o=i-1;o>=0;o--)if(e(n[o],o,n))return n[o]};le.sanitize=function(n,e){n=_e.resolve(_e.normalize(n));for(var i=e.split("/"),o=0,a=i.length;o<a;o++){var c=_e.normalize(_e.join(n,i.slice(o,a).join(_e.sep)));if(c.indexOf(n)===0)return c}return _e.normalize(_e.join(n,_e.basename(e)))};le.toBuffer=function(e,i){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?i(e):Buffer.alloc(0)};le.readBigUInt64LE=function(n,e){let i=n.readUInt32LE(e);return n.readUInt32LE(e+4)*4294967296+i};le.fromDOS2Date=function(n){return new Date((n>>25&127)+1980,Math.max((n>>21&15)-1,0),Math.max(n>>16&31,1),n>>11&31,n>>5&63,(n&31)<<1)};le.fromDate2DOS=function(n){let e=0,i=0;return n.getFullYear()>1979&&(e=(n.getFullYear()-1980&127)<<9|n.getMonth()+1<<5|n.getDate(),i=n.getHours()<<11|n.getMinutes()<<5|n.getSeconds()>>1),e<<16|i};le.isWin=Sf;le.crcTable=po});var yo=ee((Lp,_o)=>{var If=ie("path");_o.exports=function(n,{fs:e}){var i=n||"",o=c(),a=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return i&&e.existsSync(i)?(a=e.statSync(i),o.directory=a.isDirectory(),o.mtime=a.mtime,o.atime=a.atime,o.executable=(73&a.mode)!==0,o.readonly=(128&a.mode)===0,o.hidden=If.basename(i)[0]==="."):console.warn("Invalid path: "+i),{get directory(){return o.directory},get readOnly(){return o.readonly},get hidden(){return o.hidden},get mtime(){return o.mtime},get atime(){return o.atime},get executable(){return o.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:i,isDirectory:o.directory,isReadOnly:o.readonly,isHidden:o.hidden,isExecutable:o.executable,mTime:o.mtime,aTime:o.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var bo=ee((Op,Eo)=>{Eo.exports={efs:!0,encode:n=>Buffer.from(n,"utf8"),decode:n=>n.toString("utf8")}});var Ut=ee((Mp,Ft)=>{Ft.exports=wo();Ft.exports.Constants=pi();Ft.exports.Errors=Jn();Ft.exports.FileAttr=yo();Ft.exports.decoder=bo()});var So=ee((Bp,vo)=>{var xt=Ut(),H=xt.Constants;vo.exports=function(){var n=20,e=10,i=0,o=0,a=0,c=0,f=0,x=0,g=0,p=0,y=0,v=0,A=0,E=0,b=0;n|=xt.isWin?2560:768,i|=H.FLG_EFS;let I={extraLen:0},S=m=>Math.max(0,m)>>>0,D=m=>Math.max(0,m)&65535,O=m=>Math.max(0,m)&255;return a=xt.fromDate2DOS(new Date),{get made(){return n},set made(m){n=m},get version(){return e},set version(m){e=m},get flags(){return i},set flags(m){i=m},get flags_efs(){return(i&H.FLG_EFS)>0},set flags_efs(m){m?i|=H.FLG_EFS:i&=~H.FLG_EFS},get flags_desc(){return(i&H.FLG_DESC)>0},set flags_desc(m){m?i|=H.FLG_DESC:i&=~H.FLG_DESC},get method(){return o},set method(m){switch(m){case H.STORED:this.version=10;case H.DEFLATED:default:this.version=20}o=m},get time(){return xt.fromDOS2Date(this.timeval)},set time(m){m=new Date(m),this.timeval=xt.fromDate2DOS(m)},get timeval(){return a},set timeval(m){a=S(m)},get timeHighByte(){return O(a>>>8)},get crc(){return c},set crc(m){c=S(m)},get compressedSize(){return f},set compressedSize(m){f=S(m)},get size(){return x},set size(m){x=S(m)},get fileNameLength(){return g},set fileNameLength(m){g=m},get extraLength(){return p},set extraLength(m){p=m},get extraLocalLength(){return I.extraLen},set extraLocalLength(m){I.extraLen=m},get commentLength(){return y},set commentLength(m){y=m},get diskNumStart(){return v},set diskNumStart(m){v=S(m)},get inAttr(){return A},set inAttr(m){A=S(m)},get attr(){return E},set attr(m){E=S(m)},get fileAttr(){return(E||0)>>16&4095},get offset(){return b},set offset(m){b=S(m)},get encrypted(){return(i&H.FLG_ENC)===H.FLG_ENC},get centralHeaderSize(){return H.CENHDR+g+p+y},get realDataOffset(){return b+H.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(m){var C=m.slice(b,b+H.LOCHDR);if(C.readUInt32LE(0)!==H.LOCSIG)throw xt.Errors.INVALID_LOC();I.version=C.readUInt16LE(H.LOCVER),I.flags=C.readUInt16LE(H.LOCFLG),I.flags_desc=(I.flags&H.FLG_DESC)>0,I.method=C.readUInt16LE(H.LOCHOW),I.time=C.readUInt32LE(H.LOCTIM),I.crc=C.readUInt32LE(H.LOCCRC),I.compressedSize=C.readUInt32LE(H.LOCSIZ),I.size=C.readUInt32LE(H.LOCLEN),I.fnameLen=C.readUInt16LE(H.LOCNAM),I.extraLen=C.readUInt16LE(H.LOCEXT);let k=b+H.LOCHDR+I.fnameLen,F=k+I.extraLen;return m.slice(k,F)},loadFromBinary:function(m){if(m.length!==H.CENHDR||m.readUInt32LE(0)!==H.CENSIG)throw xt.Errors.INVALID_CEN();n=m.readUInt16LE(H.CENVEM),e=m.readUInt16LE(H.CENVER),i=m.readUInt16LE(H.CENFLG),o=m.readUInt16LE(H.CENHOW),a=m.readUInt32LE(H.CENTIM),c=m.readUInt32LE(H.CENCRC),f=m.readUInt32LE(H.CENSIZ),x=m.readUInt32LE(H.CENLEN),g=m.readUInt16LE(H.CENNAM),p=m.readUInt16LE(H.CENEXT),y=m.readUInt16LE(H.CENCOM),v=m.readUInt16LE(H.CENDSK),A=m.readUInt16LE(H.CENATT),E=m.readUInt32LE(H.CENATX),b=m.readUInt32LE(H.CENOFF)},localHeaderToBinary:function(){var m=Buffer.alloc(H.LOCHDR);return m.writeUInt32LE(H.LOCSIG,0),m.writeUInt16LE(e,H.LOCVER),m.writeUInt16LE(i,H.LOCFLG),m.writeUInt16LE(o,H.LOCHOW),m.writeUInt32LE(a,H.LOCTIM),m.writeUInt32LE(c,H.LOCCRC),m.writeUInt32LE(f,H.LOCSIZ),m.writeUInt32LE(x,H.LOCLEN),m.writeUInt16LE(g,H.LOCNAM),m.writeUInt16LE(I.extraLen,H.LOCEXT),m},centralHeaderToBinary:function(){var m=Buffer.alloc(H.CENHDR+g+p+y);return m.writeUInt32LE(H.CENSIG,0),m.writeUInt16LE(n,H.CENVEM),m.writeUInt16LE(e,H.CENVER),m.writeUInt16LE(i,H.CENFLG),m.writeUInt16LE(o,H.CENHOW),m.writeUInt32LE(a,H.CENTIM),m.writeUInt32LE(c,H.CENCRC),m.writeUInt32LE(f,H.CENSIZ),m.writeUInt32LE(x,H.CENLEN),m.writeUInt16LE(g,H.CENNAM),m.writeUInt16LE(p,H.CENEXT),m.writeUInt16LE(y,H.CENCOM),m.writeUInt16LE(v,H.CENDSK),m.writeUInt16LE(A,H.CENATT),m.writeUInt32LE(E,H.CENATX),m.writeUInt32LE(b,H.CENOFF),m},toJSON:function(){let m=function(C){return C+" bytes"};return{made:n,version:e,flags:i,method:xt.methodToString(o),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:m(f),size:m(x),fileNameLength:m(g),extraLength:m(p),commentLength:m(y),diskNumStart:v,inAttr:A,attr:E,offset:b,centralHeaderSize:m(H.CENHDR+g+p+y)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Co=ee((zp,Io)=>{var qt=Ut(),fe=qt.Constants;Io.exports=function(){var n=0,e=0,i=0,o=0,a=0;return{get diskEntries(){return n},set diskEntries(c){n=e=c},get totalEntries(){return e},set totalEntries(c){e=n=c},get size(){return i},set size(c){i=c},get offset(){return o},set offset(c){o=c},get commentLength(){return a},set commentLength(c){a=c},get mainHeaderSize(){return fe.ENDHDR+a},loadFromBinary:function(c){if((c.length!==fe.ENDHDR||c.readUInt32LE(0)!==fe.ENDSIG)&&(c.length<fe.ZIP64HDR||c.readUInt32LE(0)!==fe.ZIP64SIG))throw qt.Errors.INVALID_END();c.readUInt32LE(0)===fe.ENDSIG?(n=c.readUInt16LE(fe.ENDSUB),e=c.readUInt16LE(fe.ENDTOT),i=c.readUInt32LE(fe.ENDSIZ),o=c.readUInt32LE(fe.ENDOFF),a=c.readUInt16LE(fe.ENDCOM)):(n=qt.readBigUInt64LE(c,fe.ZIP64SUB),e=qt.readBigUInt64LE(c,fe.ZIP64TOT),i=qt.readBigUInt64LE(c,fe.ZIP64SIZE),o=qt.readBigUInt64LE(c,fe.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(fe.ENDHDR+a);return c.writeUInt32LE(fe.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(n,fe.ENDSUB),c.writeUInt16LE(e,fe.ENDTOT),c.writeUInt32LE(i,fe.ENDSIZ),c.writeUInt32LE(o,fe.ENDOFF),c.writeUInt16LE(a,fe.ENDCOM),c.fill(" ",fe.ENDHDR),c},toJSON:function(){let c=function(f,x){let g=f.toString(16).toUpperCase();for(;g.length<x;)g="0"+g;return"0x"+g};return{diskEntries:n,totalEntries:e,size:i+" bytes",offset:c(o,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var wi=ee(mi=>{mi.EntryHeader=So();mi.MainHeader=Co()});var To=ee((Up,Ao)=>{Ao.exports=function(n){var e=ie("zlib"),i={chunkSize:(parseInt(n.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(n,i)},deflateAsync:function(o){var a=e.createDeflateRaw(i),c=[],f=0;a.on("data",function(x){c.push(x),f+=x.length}),a.on("end",function(){var x=Buffer.alloc(f),g=0;x.fill(0);for(var p=0;p<c.length;p++){var y=c[p];y.copy(x,g),g+=y.length}o&&o(x)}),a.end(n)}}}});var Po=ee((qp,Do)=>{var Cf=+(process.versions?process.versions.node:"").split(".")[0]||0;Do.exports=function(n,e){var i=ie("zlib");let o=Cf>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return i.inflateRawSync(n,o)},inflateAsync:function(a){var c=i.createInflateRaw(o),f=[],x=0;c.on("data",function(g){f.push(g),x+=g.length}),c.on("end",function(){var g=Buffer.alloc(x),p=0;g.fill(0);for(var y=0;y<f.length;y++){var v=f[y];v.copy(g,p),p+=v.length}a&&a(g)}),c.end(n)}}}});var Oo=ee((Hp,Lo)=>{"use strict";var{randomFillSync:ko}=ie("crypto"),Af=Jn(),Tf=new Uint32Array(256).map((n,e)=>{for(let i=0;i<8;i++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Ro=(n,e)=>Math.imul(n,e)>>>0,No=(n,e)=>Tf[(n^e)&255]^n>>>8,ln=()=>typeof ko=="function"?ko(Buffer.alloc(12)):ln.node();ln.node=()=>{let n=Buffer.alloc(12),e=n.length;for(let i=0;i<e;i++)n[i]=Math.random()*256&255;return n};var $n={genSalt:ln};function Vn(n){let e=Buffer.isBuffer(n)?n:Buffer.from(n);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let i=0;i<e.length;i++)this.updateKeys(e[i])}Vn.prototype.updateKeys=function(n){let e=this.keys;return e[0]=No(e[0],n),e[1]+=e[0]&255,e[1]=Ro(e[1],134775813)+1,e[2]=No(e[2],e[1]>>>24),n};Vn.prototype.next=function(){let n=(this.keys[2]|2)>>>0;return Ro(n,n^1)>>8&255};function Df(n){let e=new Vn(n);return function(i){let o=Buffer.alloc(i.length),a=0;for(let c of i)o[a++]=e.updateKeys(c^e.next());return o}}function Pf(n){let e=new Vn(n);return function(i,o,a=0){o||(o=Buffer.alloc(i.length));for(let c of i){let f=e.next();o[a++]=c^f,e.updateKeys(c)}return o}}function kf(n,e,i){if(!n||!Buffer.isBuffer(n)||n.length<12)return Buffer.alloc(0);let o=Df(i),a=o(n.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw Af.WRONG_PASSWORD();return o(n.slice(12))}function Nf(n){Buffer.isBuffer(n)&&n.length>=12?$n.genSalt=function(){return n.slice(0,12)}:n==="node"?$n.genSalt=ln.node:$n.genSalt=ln}function Rf(n,e,i,o=!1){n==null&&(n=Buffer.alloc(0)),Buffer.isBuffer(n)||(n=Buffer.from(n.toString()));let a=Pf(i),c=$n.genSalt();c[11]=e.crc>>>24&255,o&&(c[10]=e.crc>>>16&255);let f=Buffer.alloc(n.length+12);return a(c,f),a(n,f,12)}Lo.exports={decrypt:kf,encrypt:Rf,_salter:Nf}});var Mo=ee(Zn=>{Zn.Deflater=To();Zn.Inflater=Po();Zn.ZipCrypto=Oo()});var yi=ee((jp,Bo)=>{var te=Ut(),Lf=wi(),ge=te.Constants,_i=Mo();Bo.exports=function(n,e){var i=new Lf.EntryHeader,o=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,f=null,x=Buffer.alloc(0),g=Buffer.alloc(0),p=!0;let y=n,v=typeof y.decoder=="object"?y.decoder:te.decoder;p=v.hasOwnProperty("efs")?v.efs:!1;function A(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(g=i.loadLocalHeaderFromBinary(e),e.slice(i.realDataOffset,i.realDataOffset+i.compressedSize))}function E(m){if(!i.flags_desc&&!i.localHeader.flags_desc){if(te.crc32(m)!==i.localHeader.crc)return!1}else{let C={},k=i.realDataOffset+i.compressedSize;if(e.readUInt32LE(k)==ge.LOCSIG||e.readUInt32LE(k)==ge.CENSIG)throw te.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==ge.EXTSIG)C.crc=e.readUInt32LE(k+ge.EXTCRC),C.compressedSize=e.readUInt32LE(k+ge.EXTSIZ),C.size=e.readUInt32LE(k+ge.EXTLEN);else if(e.readUInt16LE(k+12)===19280)C.crc=e.readUInt32LE(k+ge.EXTCRC-4),C.compressedSize=e.readUInt32LE(k+ge.EXTSIZ-4),C.size=e.readUInt32LE(k+ge.EXTLEN-4);else throw te.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==i.compressedSize||C.size!==i.size||C.crc!==i.crc)throw te.Errors.DESCRIPTOR_FAULTY();if(te.crc32(m)!==C.crc)return!1}return!0}function b(m,C,k){if(typeof C>"u"&&typeof m=="string"&&(k=m,m=void 0),c)return m&&C&&C(Buffer.alloc(0),te.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=A();if(F.length===0)return m&&C&&C(F),F;if(i.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw te.Errors.INVALID_PASS_PARAM();F=_i.ZipCrypto.decrypt(F,i,k)}var B=Buffer.alloc(i.size);switch(i.method){case te.Constants.STORED:if(F.copy(B),E(B))return m&&C&&C(B),B;throw m&&C&&C(B,te.Errors.BAD_CRC()),te.Errors.BAD_CRC();case te.Constants.DEFLATED:var P=new _i.Inflater(F,i.size);if(m)P.inflateAsync(function(M){M.copy(M,0),C&&(E(M)?C(M):C(M,te.Errors.BAD_CRC()))});else{if(P.inflate(B).copy(B,0),!E(B))throw te.Errors.BAD_CRC(`"${v.decode(o)}"`);return B}break;default:throw m&&C&&C(Buffer.alloc(0),te.Errors.UNKNOWN_METHOD()),te.Errors.UNKNOWN_METHOD()}}function I(m,C){if((!f||!f.length)&&Buffer.isBuffer(e))return m&&C&&C(A()),A();if(f.length&&!c){var k;switch(i.method){case te.Constants.STORED:return i.compressedSize=i.size,k=Buffer.alloc(f.length),f.copy(k),m&&C&&C(k),k;default:case te.Constants.DEFLATED:var F=new _i.Deflater(f);if(m)F.deflateAsync(function(P){k=Buffer.alloc(P.length),i.compressedSize=P.length,P.copy(k),C&&C(k)});else{var B=F.deflate();return i.compressedSize=B.length,B}F=null;break}}else if(m&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function S(m,C){return te.readBigUInt64LE(m,C)}function D(m){try{for(var C=0,k,F,B;C+4<m.length;)k=m.readUInt16LE(C),C+=2,F=m.readUInt16LE(C),C+=2,B=m.slice(C,C+F),C+=F,ge.ID_ZIP64===k&&O(B)}catch{throw te.Errors.EXTRA_FIELD_PARSE_ERROR()}}function O(m){var C,k,F,B;m.length>=ge.EF_ZIP64_SCOMP&&(C=S(m,ge.EF_ZIP64_SUNCOMP),i.size===ge.EF_ZIP64_OR_32&&(i.size=C)),m.length>=ge.EF_ZIP64_RHO&&(k=S(m,ge.EF_ZIP64_SCOMP),i.compressedSize===ge.EF_ZIP64_OR_32&&(i.compressedSize=k)),m.length>=ge.EF_ZIP64_DSN&&(F=S(m,ge.EF_ZIP64_RHO),i.offset===ge.EF_ZIP64_OR_32&&(i.offset=F)),m.length>=ge.EF_ZIP64_DSN+4&&(B=m.readUInt32LE(ge.EF_ZIP64_DSN),i.diskNumStart===ge.EF_ZIP64_OR_16&&(i.diskNumStart=B))}return{get entryName(){return v.decode(o)},get rawEntryName(){return o},set entryName(m){o=te.toBuffer(m,v.encode);var C=o[o.length-1];c=C===47||C===92,i.fileNameLength=o.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return x},set extra(m){x=m,i.extraLength=m.length,D(m)},get comment(){return v.decode(a)},set comment(m){if(a=te.toBuffer(m,v.encode),i.commentLength=a.length,a.length>65535)throw te.Errors.COMMENT_TOO_LONG()},get name(){var m=v.decode(o);return c?m.substr(m.length-1).split("/").pop():m.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(m){I(!0,m)},setData:function(m){f=te.toBuffer(m,te.decoder.encode),!c&&f.length?(i.size=f.length,i.method=te.Constants.DEFLATED,i.crc=te.crc32(m),i.changed=!0):i.method=te.Constants.STORED},getData:function(m){return i.changed?f:b(!1,null,m)},getDataAsync:function(m,C){i.changed?m(f):b(!0,m,C)},set attr(m){i.attr=m},get attr(){return i.attr},set header(m){i.loadFromBinary(m)},get header(){return i},packCentralHeader:function(){i.flags_efs=this.efs,i.extraLength=x.length;var m=i.centralHeaderToBinary(),C=te.Constants.CENHDR;return o.copy(m,C),C+=o.length,x.copy(m,C),C+=i.extraLength,a.copy(m,C),m},packLocalHeader:function(){let m=0;i.flags_efs=this.efs,i.extraLocalLength=g.length;let C=i.localHeaderToBinary(),k=Buffer.alloc(C.length+o.length+i.extraLocalLength);return C.copy(k,m),m+=C.length,o.copy(k,m),m+=o.length,g.copy(k,m),m+=g.length,k},toJSON:function(){let m=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:i.toJSON(),compressedData:m(e),data:m(f)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Uo=ee((Kp,Fo)=>{var zo=yi(),Of=wi(),Te=Ut();Fo.exports=function(n,e){var i=[],o={},a=Buffer.alloc(0),c=new Of.MainHeader,f=!1,x=null;let g=new Set,p=e,{noSort:y,decoder:v}=p;n?b(p.readEntries):f=!0;function A(){let S=new Set;for(let D of Object.keys(o)){let O=D.split("/");if(O.pop(),!!O.length)for(let m=0;m<O.length;m++){let C=O.slice(0,m+1).join("/")+"/";S.add(C)}}for(let D of S)if(!(D in o)){let O=new zo(p);O.entryName=D,O.attr=16,O.temporary=!0,i.push(O),o[O.entryName]=O,g.add(O)}}function E(){if(f=!0,o={},c.diskEntries>(n.length-c.offset)/Te.Constants.CENHDR)throw Te.Errors.DISK_ENTRY_TOO_LARGE();i=new Array(c.diskEntries);for(var S=c.offset,D=0;D<i.length;D++){var O=S,m=new zo(p,n);m.header=n.slice(O,O+=Te.Constants.CENHDR),m.entryName=n.slice(O,O+=m.header.fileNameLength),m.header.extraLength&&(m.extra=n.slice(O,O+=m.header.extraLength)),m.header.commentLength&&(m.comment=n.slice(O,O+m.header.commentLength)),S+=m.header.centralHeaderSize,i[D]=m,o[m.entryName]=m}g.clear(),A()}function b(S){var D=n.length-Te.Constants.ENDHDR,O=Math.max(0,D-65535),m=O,C=n.length,k=-1,F=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(O=0),D;D>=m;D--)if(n[D]===80){if(n.readUInt32LE(D)===Te.Constants.ENDSIG){k=D,F=D,C=D+Te.Constants.ENDHDR,m=D-Te.Constants.END64HDR;continue}if(n.readUInt32LE(D)===Te.Constants.END64SIG){m=O;continue}if(n.readUInt32LE(D)===Te.Constants.ZIP64SIG){k=D,C=D+Te.readBigUInt64LE(n,D+Te.Constants.ZIP64SIZE)+Te.Constants.ZIP64LEAD;break}}if(k==-1)throw Te.Errors.INVALID_FORMAT();c.loadFromBinary(n.slice(k,C)),c.commentLength&&(a=n.slice(F+Te.Constants.ENDHDR)),S&&E()}function I(){i.length>1&&!y&&i.sort((S,D)=>S.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return f||E(),i.filter(S=>!g.has(S))},get comment(){return v.decode(a)},set comment(S){a=Te.toBuffer(S,v.encode),c.commentLength=a.length},getEntryCount:function(){return f?i.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return f||E(),o[S]||null},setEntry:function(S){f||E(),i.push(S),o[S.entryName]=S,c.totalEntries=i.length},deleteFile:function(S,D=!0){f||E();let O=o[S];this.getEntryChildren(O,D).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){f||E();let D=o[S],O=i.indexOf(D);O>=0&&(i.splice(O,1),delete o[S],c.totalEntries=i.length)},getEntryChildren:function(S,D=!0){if(f||E(),typeof S=="object")if(S.isDirectory&&D){let O=[],m=S.entryName;for(let C of i)C.entryName.startsWith(m)&&O.push(C);return O}else return[S];return[]},getChildCount:function(S){if(S&&S.isDirectory){let D=this.getEntryChildren(S);return D.includes(S)?D.length-1:D.length}return 0},compressToBuffer:function(){f||E(),I();let S=[],D=[],O=0,m=0;c.size=0,c.offset=0;let C=0;for(let B of this.entries){let P=B.getCompressedData();B.header.offset=m;let M=B.packLocalHeader(),U=M.length+P.length;m+=U,S.push(M),S.push(P);let J=B.packCentralHeader();D.push(J),c.size+=J.length,O+=U+J.length,C++}O+=c.mainHeaderSize,c.offset=m,c.totalEntries=C,m=0;let k=Buffer.alloc(O);for(let B of S)B.copy(k,m),m+=B.length;for(let B of D)B.copy(k,m),m+=B.length;let F=c.toBinary();return a&&a.copy(F,Te.Constants.ENDHDR),F.copy(k,m),n=k,f=!1,k},toAsyncBuffer:function(S,D,O,m){try{f||E(),I();let C=[],k=[],F=0,B=0,P=0;c.size=0,c.offset=0;let M=function(U){if(U.length>0){let J=U.shift(),ne=J.entryName+J.extra.toString();O&&O(ne),J.getCompressedDataAsync(function(ae){m&&m(ne),J.header.offset=B;let pe=J.packLocalHeader(),Ie=pe.length+ae.length;B+=Ie,C.push(pe),C.push(ae);let Fe=J.packCentralHeader();k.push(Fe),c.size+=Fe.length,F+=Ie+Fe.length,P++,M(U)})}else{F+=c.mainHeaderSize,c.offset=B,c.totalEntries=P,B=0;let J=Buffer.alloc(F);C.forEach(function(ae){ae.copy(J,B),B+=ae.length}),k.forEach(function(ae){ae.copy(J,B),B+=ae.length});let ne=c.toBinary();a&&a.copy(ne,Te.Constants.ENDHDR),ne.copy(J,B),n=J,f=!1,S(J)}};M(Array.from(this.entries))}catch(C){D(C)}}}}});var Go=ee((Wp,Ho)=>{var xe=Ut(),ue=ie("path"),Mf=yi(),Bf=Uo(),St=(...n)=>xe.findLast(n,e=>typeof e=="boolean"),qo=(...n)=>xe.findLast(n,e=>typeof e=="string"),zf=(...n)=>xe.findLast(n,e=>typeof e=="function"),Ff={noSort:!1,readEntries:!1,method:xe.Constants.NONE,fs:null};Ho.exports=function(n,e){let i=null,o=Object.assign(Object.create(null),Ff);n&&typeof n=="object"&&(n instanceof Uint8Array||(Object.assign(o,n),n=o.input?o.input:void 0,o.input&&delete o.input),Buffer.isBuffer(n)&&(i=n,o.method=xe.Constants.BUFFER,n=void 0)),Object.assign(o,e);let a=new xe(o);if((typeof o.decoder!="object"||typeof o.decoder.encode!="function"||typeof o.decoder.decode!="function")&&(o.decoder=xe.decoder),n&&typeof n=="string")if(a.fs.existsSync(n))o.method=xe.Constants.FILE,o.filename=n,i=a.fs.readFileSync(n);else throw xe.Errors.INVALID_FILENAME();let c=new Bf(i,o),{canonical:f,sanitize:x,zipnamefix:g}=xe;function p(E){if(E&&c){var b;if(typeof E=="string"&&(b=c.getEntry(ue.posix.normalize(E))),typeof E=="object"&&typeof E.entryName<"u"&&typeof E.header<"u"&&(b=c.getEntry(E.entryName)),b)return b}return null}function y(E){let{join:b,normalize:I,sep:S}=ue.posix;return b(ue.isAbsolute(E)?"/":".",I(S+E.split("\\").join(S)+S))}function v(E){return E instanceof RegExp?(function(b){return function(I){return b.test(I)}})(E):typeof E!="function"?()=>!0:E}let A=(E,b)=>{let I=b.slice(-1);return I=I===a.sep?a.sep:"",ue.relative(E,b)+I};return{readFile:function(E,b){var I=p(E);return I&&I.getData(b)||null},childCount:function(E){let b=p(E);if(b)return c.getChildCount(b)},readFileAsync:function(E,b){var I=p(E);I?I.getDataAsync(b):b(null,"getEntry failed for:"+E)},readAsText:function(E,b){var I=p(E);if(I){var S=I.getData();if(S&&S.length)return S.toString(b||"utf8")}return""},readAsTextAsync:function(E,b,I){var S=p(E);S?S.getDataAsync(function(D,O){if(O){b(D,O);return}D&&D.length?b(D.toString(I||"utf8")):b("")}):b("")},deleteFile:function(E,b=!0){var I=p(E);I&&c.deleteFile(I.entryName,b)},deleteEntry:function(E){var b=p(E);b&&c.deleteEntry(b.entryName)},addZipComment:function(E){c.comment=E},getZipComment:function(){return c.comment||""},addZipEntryComment:function(E,b){var I=p(E);I&&(I.comment=b)},getZipEntryComment:function(E){var b=p(E);return b&&b.comment||""},updateFile:function(E,b){var I=p(E);I&&I.setData(b)},addLocalFile:function(E,b,I,S){if(a.fs.existsSync(E)){b=b?y(b):"";let D=ue.win32.basename(ue.win32.normalize(E));b+=I||D;let O=a.fs.statSync(E),m=O.isFile()?a.fs.readFileSync(E):Buffer.alloc(0);O.isDirectory()&&(b+=a.sep),this.addFile(b,m,S,O)}else throw xe.Errors.FILE_NOT_FOUND(E)},addLocalFileAsync:function(E,b){E=typeof E=="object"?E:{localPath:E};let I=ue.resolve(E.localPath),{comment:S}=E,{zipPath:D,zipName:O}=E,m=this;a.fs.stat(I,function(C,k){if(C)return b(C,!1);D=D?y(D):"";let F=ue.win32.basename(ue.win32.normalize(I));if(D+=O||F,k.isFile())a.fs.readFile(I,function(B,P){return B?b(B,!1):(m.addFile(D,P,S,k),setImmediate(b,void 0,!0))});else if(k.isDirectory())return D+=a.sep,m.addFile(D,Buffer.alloc(0),S,k),setImmediate(b,void 0,!0)})},addLocalFolder:function(E,b,I){if(I=v(I),b=b?y(b):"",E=ue.normalize(E),a.fs.existsSync(E)){let S=a.findFiles(E),D=this;if(S.length)for(let O of S){let m=ue.join(b,A(E,O));I(m)&&D.addLocalFile(O,ue.dirname(m))}}else throw xe.Errors.FILE_NOT_FOUND(E)},addLocalFolderAsync:function(E,b,I,S){S=v(S),I=I?y(I):"",E=ue.normalize(E);var D=this;a.fs.open(E,"r",function(O){if(O&&O.code==="ENOENT")b(void 0,xe.Errors.FILE_NOT_FOUND(E));else if(O)b(void 0,O);else{var m=a.findFiles(E),C=-1,k=function(){if(C+=1,C<m.length){var F=m[C],B=A(E,F).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(B)?a.fs.stat(F,function(P,M){P&&b(void 0,P),M.isFile()?a.fs.readFile(F,function(U,J){U?b(void 0,U):(D.addFile(I+B,J,"",M),k())}):(D.addFile(I+B+"/",Buffer.alloc(0),"",M),k())}):process.nextTick(()=>{k()})}else b(!0,void 0)};k()}})},addLocalFolderAsync2:function(E,b){let I=this;E=typeof E=="object"?E:{localPath:E},localPath=ue.resolve(y(E.localPath));let{zipPath:S,filter:D,namefix:O}=E;D instanceof RegExp?D=(function(k){return function(F){return k.test(F)}})(D):typeof D!="function"&&(D=function(){return!0}),S=S?y(S):"",O=="latin1"&&(O=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof O!="function"&&(O=k=>k);let m=k=>ue.join(S,O(A(localPath,k))),C=k=>ue.win32.basename(ue.win32.normalize(O(k)));a.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?b(void 0,xe.Errors.FILE_NOT_FOUND(localPath)):k?b(void 0,k):a.findFilesAsync(localPath,function(F,B){if(F)return b(F);B=B.filter(P=>D(m(P))),B.length||b(void 0,!1),setImmediate(B.reverse().reduce(function(P,M){return function(U,J){if(U||J===!1)return setImmediate(P,U,!1);I.addLocalFileAsync({localPath:M,zipPath:ue.dirname(m(M)),zipName:C(M)},P)}},b))})})},addLocalFolderPromise:function(E,b){return new Promise((I,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:E},b),(D,O)=>{D&&S(D),O&&I(this)})})},addFile:function(E,b,I,S){E=g(E);let D=p(E),O=D!=null;O||(D=new Mf(o),D.entryName=E),D.comment=I||"";let m=typeof S=="object"&&S instanceof a.fs.Stats;m&&(D.header.time=S.mtime);var C=D.isDirectory?16:0;let k=D.isDirectory?16384:32768;return m?k|=4095&S.mode:typeof S=="number"?k|=4095&S:k|=D.isDirectory?493:420,C=(C|k<<16)>>>0,D.attr=C,D.setData(b),O||c.setEntry(D),D},getEntries:function(E){return c.password=E,c?c.entries:[]},getEntry:function(E){return p(E)},getEntryCount:function(){return c.getEntryCount()},forEach:function(E){return c.forEach(E)},extractEntryTo:function(E,b,I,S,D,O){S=St(!1,S),D=St(!1,D),I=St(!0,I),O=qo(D,O);var m=p(E);if(!m)throw xe.Errors.NO_ENTRY();var C=f(m.entryName),k=x(b,O&&!m.isDirectory?O:I?C:ue.basename(C));if(m.isDirectory){var F=c.getEntryChildren(m);return F.forEach(function(M){if(M.isDirectory)return;var U=M.getData();if(!U)throw xe.Errors.CANT_EXTRACT_FILE();var J=f(M.entryName),ne=x(b,I?J:ue.basename(J));let ae=D?M.header.fileAttr:void 0;a.writeFileTo(ne,U,S,ae)}),!0}var B=m.getData(c.password);if(!B)throw xe.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(k)&&!S)throw xe.Errors.CANT_OVERRIDE();let P=D?E.header.fileAttr:void 0;return a.writeFileTo(k,B,S,P),!0},test:function(E){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var I=c.entries[b].getData(E);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(E,b,I,S){if(I=St(!1,I),S=qo(I,S),b=St(!1,b),!c)throw xe.Errors.NO_ZIP();c.entries.forEach(function(D){var O=x(E,f(D.entryName));if(D.isDirectory){a.makeDir(O);return}var m=D.getData(S);if(!m)throw xe.Errors.CANT_EXTRACT_FILE();let C=I?D.header.fileAttr:void 0;a.writeFileTo(O,m,b,C);try{a.fs.utimesSync(O,D.header.time,D.header.time)}catch{throw xe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(E,b,I,S){if(S=zf(b,I,S),I=St(!1,I),b=St(!1,b),!S)return new Promise((k,F)=>{this.extractAllToAsync(E,b,I,function(B){B?F(B):k(this)})});if(!c){S(xe.Errors.NO_ZIP());return}E=ue.resolve(E);let D=k=>x(E,ue.normalize(f(k.entryName))),O=(k,F)=>new Error(k+': "'+F+'"'),m=[],C=[];c.entries.forEach(k=>{k.isDirectory?m.push(k):C.push(k)});for(let k of m){let F=D(k),B=I?k.header.fileAttr:void 0;try{a.makeDir(F),B&&a.fs.chmodSync(F,B),a.fs.utimesSync(F,k.header.time,k.header.time)}catch{S(O("Unable to create folder",F))}}C.reverse().reduce(function(k,F){return function(B){if(B)k(B);else{let P=ue.normalize(f(F.entryName)),M=x(E,P);F.getDataAsync(function(U,J){if(J)k(J);else if(!U)k(xe.Errors.CANT_EXTRACT_FILE());else{let ne=I?F.header.fileAttr:void 0;a.writeFileToAsync(M,U,b,ne,function(ae){ae||k(O("Unable to write file",M)),a.fs.utimes(M,F.header.time,F.header.time,function(pe){pe?k(O("Unable to set times",M)):k()})})}})}}},S)()},writeZip:function(E,b){if(arguments.length===1&&typeof E=="function"&&(b=E,E=""),!E&&o.filename&&(E=o.filename),!!E){var I=c.compressToBuffer();if(I){var S=a.writeFileTo(E,I,!0);typeof b=="function"&&b(S?null:new Error("failed"),"")}}},writeZipPromise:function(E,b){let{overwrite:I,perm:S}=Object.assign({overwrite:!0},b);return new Promise((D,O)=>{!E&&o.filename&&(E=o.filename),E||O("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(m=>{let C=k=>k?D(k):O("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(E,m,I,S,C)},O)})},toBufferPromise:function(){return new Promise((E,b)=>{c.toAsyncBuffer(E,b)})},toBuffer:function(E,b,I,S){return typeof E=="function"?(c.toAsyncBuffer(E,b,I,S),null):c.compressToBuffer()}}}});var dc=ee(se=>{"use strict";function W(n,e){n=n-278;let i=vr(),o=i[n];if(W.sBvPyE===void 0){var a=function(g){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",y="",v="";for(let A=0,E,b,I=0;b=g.charAt(I++);~b&&(E=A%4?E*64+b:b,A++%4)?y+=String.fromCharCode(255&E>>(-2*A&6)):0)b=p.indexOf(b);for(let A=0,E=y.length;A<E;A++)v+="%"+("00"+y.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(v)};W.ewRsnh=a,W.MKVBHr={},W.sBvPyE=!0}let c=i[0],f=n+c,x=W.MKVBHr[f];return x?o=x:(o=W.ewRsnh(o),W.MKVBHr[f]=o),o}var z=W;(function(n,e){let i=W,o=n();for(;;)try{if(-parseInt(i(1225))/1*(-parseInt(i(1143))/2)+-parseInt(i(1284))/3+parseInt(i(801))/4+-parseInt(i(1249))/5+parseInt(i(1236))/6*(parseInt(i(676))/7)+-parseInt(i(778))/8+parseInt(i(1602))/9===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(vr,900282);var tl=Object[z(1690)+"operty"],nl=Object[z(1386)+z(976)+z(762)],ic=(n,e)=>function(){return n&&(e=(0,n[nl(n)[0]])(n=0)),e},rl=(n,e)=>{let i=z,o={bbNrz:function(c,f,x,g){return c(f,x,g)}};for(var a in e)o[i(1492)](tl,n,a,{get:e[a],enumerable:!0})};function il(){return Qa||(Qa=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function sl(){let n=z;return ec||(ec=[IDBCursor[n(767)+"e"].advance,IDBCursor[n(767)+"e"][n(316)],IDBCursor[n(767)+"e"][n(316)+n(1036)+"ey"]])}function ol(n){let e=z,i={jMxrM:function(a,c){return a(c)},ZBVvA:"success",QVlgb:e(1722),Lcdce:function(a,c){return a instanceof c}},o=new Promise((a,c)=>{let f=e,x={SDHTJ:f(352)},g=()=>{let v=f;n[v(913)+"entListe"+v(1353)](x[v(1374)],p),n[v(913)+v(351)+v(1353)](v(1722),y)},p=()=>{let v=f;i[v(515)](a,Ye(n[v(701)])),g()},y=()=>{c(n[f(1722)]),g()};n.addEventListener(i[f(1113)],p),n.addEventListener(i.QVlgb,y)});return o[e(1717)](a=>{let c=e;i[c(690)](a,IDBCursor)&&qi[c(452)](a,n)})[e(956)](()=>{}),Er[e(452)](o,n),o}function al(n){let e=z,i={VXtWg:e(1448),dvonO:e(1722),HeoaH:"abort",LCBdB:function(a,c){return a===c},QOANf:e(790),pTLst:function(a){return a()},LKZwu:function(a){return a()},EqupR:e(1093)+"or"};if(yr[e(785)](n))return;let o=new Promise((a,c)=>{let f=e,x=()=>{let y=W;n["removeEv"+y(351)+y(1353)](i[y(784)],g),n[y(913)+y(351)+y(1353)](i[y(592)],p),n[y(913)+y(351)+y(1353)](i.HeoaH,p)},g=()=>{let y=W;i[y(569)]("NVgMA",i[y(994)])?(i[y(1319)](a),i[y(324)](x)):(this[y(1534)+y(382)+y(293)]=_0x4e537c,_0x3aa2d3?this[y(1651)+y(386)]():this[y(1651)+y(1462)]())},p=()=>{let y=W;c(n.error||new DOMException(i[y(728)],i[y(728)])),i[y(1319)](x)};n[f(1693)+"Listener"](i[f(784)],g),n[f(1693)+f(1282)](i[f(592)],p),n["addEvent"+f(1282)](i[f(1043)],p)});yr[e(452)](n,o)}function cl(n){br={xpBcH:function(i,o){return i(o)}}.xpBcH(n,br)}function dl(n){let e=z,i={fVApp:function(o,a){return o(a)},bjOCY:function(o,a){return o(a)},uccWv:function(o,a){return o in a},YcfnX:e(1648)+"oreNames",gxLwo:function(o){return o()},thQOc:e(1509)};if(n===IDBDatabase.prototype[e(1582)+e(1063)]&&!i[e(1361)](i[e(981)],IDBTransaction[e(767)+"e"]))return function(o,...a){let c=e,f=n[c(607)](i.fVApp(An,this),o,...a);return Ui.set(f,o[c(875)]?o[c(875)]():[o]),i.bjOCY(Ye,f)};if(i[e(1078)](sl)[e(1307)](n))if(e(1509)!==i[e(709)])_0x57f532[e(1526)](_0x11731f);else return function(...o){let a=e;return n[a(461)](i[a(615)](An,this),o),Ye(qi[a(999)](this))};return function(...o){let a=e;return Ye(n[a(461)](i[a(615)](An,this),o))}}function fl(n){let e=z,i={UgVOe:"function",UpzlF:function(o){return o()}};return typeof n===i[e(1346)]?dl(n):(n instanceof IDBTransaction&&al(n),sc(n,i.UpzlF(il))?new Proxy(n,br):n)}function Ye(n){let e=z,i={Yvvyc:function(a,c){return a instanceof c},BoDYK:function(a,c){return a(c)},dCtBo:function(a,c){return a(c)},VBjtr:function(a,c){return a!==c}};if(i[e(863)](n,IDBRequest))return i[e(1556)](ol,n);if(wr[e(785)](n))return wr[e(999)](n);let o=i[e(1029)](fl,n);return i[e(1552)](o,n)&&(wr.set(n,o),Er[e(452)](o,n)),o}var sc,Qa,ec,qi,yr,Ui,wr,Er,br,An,tc=ic({"node_modules/idb/build/wrap-idb-value.js"(){let n=z,e={afSZq:function(i,o){return i===o},ybRfC:"done",RtETJ:function(i,o){return i===o},TWKss:n(683),irieJ:function(i,o,a){return i(o,a)},TkiVT:function(i,o){return i instanceof o},iKrZe:"AwYjb",EMsod:n(524),zkbvF:function(i,o){return i in o}};sc=(i,o)=>o.some(a=>i instanceof a),qi=new WeakMap,yr=new WeakMap,Ui=new WeakMap,wr=new WeakMap,Er=new WeakMap,br={get(i,o,a){let c=n;if(i instanceof IDBTransaction){if(e[c(857)](o,e[c(1691)]))return yr[c(999)](i);if(e[c(1267)](o,"objectSt"+c(926)))return i[c(1648)+c(926)]||Ui[c(999)](i);if(e.RtETJ(o,e[c(1148)]))return a["objectSt"+c(926)][1]?void 0:a[c(1648)+c(284)](a[c(1648)+c(926)][0])}return Ye(i[o])},set(i,o,a){return i[o]=a,!0},has(i,o){let a=n;if(e[a(1641)](i,IDBTransaction)&&(e[a(1267)](o,e[a(1691)])||o===e[a(1148)]))if(e.RtETJ(e[a(792)],e[a(675)]))_0x6950d1(this["_interva"+a(679)+"Id"]),this["_interva"+a(679)+"Id"]=e.irieJ(_0xc72959,()=>{let c=a;this[c(1589)+c(572)]()},this._interval);else return!0;return e[a(1479)](o,i)}},An=i=>Er.get(i)}}),oc={};rl(oc,{deleteDB:()=>xl,openDB:()=>ul,unwrap:()=>An,wrap:()=>Ye});function ul(n,e,{blocked:i,upgrade:o,blocking:a,terminated:c}={}){let f=z,x={oWada:"vjVwv",KfWox:function(y,v,A,E,b){return y(v,A,E,b)},UMyip:function(y,v){return y(v)},GCvlj:function(y,v){return y(v)},XdDFw:f(661),ATMOr:function(y,v){return y(v)},SgoHE:f(1681)+"eeded",sCllt:f(1523)},g=indexedDB.open(n,e),p=x[f(1071)](Ye,g);return o&&g[f(1693)+f(1282)](x.SgoHE,y=>{let v=f;v(491)===x[v(459)]?this[v(1047)+"T"]?_0x33192e[v(1012)+"kStatusC"+v(1253)](({isConnected:A})=>{let E=v;this["_miniNavigatorOn"+E(293)]=A,A?this[E(1651)+"nLine"]():this._handleOffLine()}):this._isMiniWX&&_0x35f53["onNetworkStatusC"+v(1253)](({isConnected:A})=>{let E=v;this[E(1534)+E(382)+"line"]=A,A?this[E(1651)+"nLine"]():this[E(1651)+"ffLine"]()}):x[v(1369)](o,x.UMyip(Ye,g[v(701)]),y[v(1518)+"on"],y[v(523)+"on"],x[v(1125)](Ye,g[v(1582)+v(1063)]))}),i&&g["addEvent"+f(1282)](x[f(1699)],()=>i()),p[f(1717)](y=>{let v=f;c&&y[v(1693)+"Listener"](x[v(1219)],()=>c()),a&&y[v(1693)+v(1282)]("versionc"+v(1253),()=>a())})[f(956)](()=>{}),p}function xl(n,{blocked:e}={}){let i=z,o={rusxt:"blocked",ikneF:function(c,f){return c(f)}},a=indexedDB[i(642)+"tabase"](n);return e&&a[i(1693)+"Listener"](o[i(1306)],()=>e()),o[i(627)](Ye,a)[i(1717)](()=>{})}function nc(n,e){let i=z,o={ksObW:function(g,p){return g+p},vXzLN:function(g,p){return g*p},cbvZI:function(g,p){return g*p},dDXUc:function(g,p){return g instanceof p},fYFpI:function(g,p){return g in p},SSOaA:i(1e3),SzGgQ:function(g,p){return g===p},qZxZK:i(436),ldzge:"PhVzx",OFdOa:function(g,p){return g!==p}};if(!(o[i(1329)](n,IDBDatabase)&&!o[i(544)](e,n)&&typeof e===o[i(1238)]))return o[i(629)](o.qZxZK,o.ldzge)?o[i(469)](o.vXzLN(1e4,_0x40e8d[i(1597)]()),_0x13f8a9[i(1241)](o[i(897)](1e4,_0x1bb743[i(731)]()))):void 0;if(_r[i(999)](e))return _r[i(999)](e);let a=e[i(1528)](/FromIndex$/,""),c=o[i(787)](e,a),f=cc.includes(a);if(!(a in(c?IDBIndex:IDBObjectStore)[i(767)+"e"])||!(f||ac[i(1307)](a)))return;let x=async function(g,...p){let y=i,v=this[y(1582)+y(1063)](g,f?"readwrite":"readonly"),A=v.store;return c&&(A=A[y(1605)](p[y(393)]())),(await Promise[y(1486)]([A[a](...p),f&&v[y(608)]]))[0]};return _r[i(452)](e,x),x}var ac,cc,_r,ll=ic({"node_modules/idb/build/index.js"(){let n=z,e={fJBzs:n(1723)+"0|2",HBlMh:function(a,c){return a(c)},DdTCP:n(999),gzXAc:n(516),MhSIM:n(810)+"ys",LXrod:function(a){return a()},ZUFSC:"put",YJLAH:n(1590)},i=e[n(1407)][n(1296)]("|"),o=0;for(;;){switch(i[o++]){case"0":_r=new Map;continue;case"1":tc();continue;case"2":e[n(1287)](cl,a=>({...a,get:(c,f,x)=>nc(c,f)||a[n(999)](c,f,x),has:(c,f)=>!!nc(c,f)||a[n(785)](c,f)}));continue;case"3":ac=[e[n(1470)],"getKey",e[n(695)],e[n(579)],n(1356)];continue;case"4":e[n(1412)](tc);continue;case"5":cc=[e[n(1109)],e[n(831)],n(1205),n(699)];continue}break}}}),gl={idb:function(n){let e=z;n[e(674)]=Promise[e(923)]()[e(1717)](()=>(ll(),oc))[e(1717)](function(i){return i})}},rc={};function vr(){let n=["y2LguNi","qunnz2W","y3jLyxrLt2i","q0Xpu0LorW","CNjTwem","CvvuB0q","x3DZsw5ZDge","sM5Xr0i","z2PWDwG","v256Bvm","Auv5CMC","zMzmAw5L","D2vI","CvvtqKm","ywDL","yMrFzgLK","txzMAKe","BKPMsvu","x3fVC0rc","rgruq1a","z2LODuG","y3jLyxrLt3a","DxL6sg4","q3zAvKy","vLLwuuO","Ec11C2uT","CNnVCL9Uyw0","Dw5ZAwDUzwq","EMTIDKy","DgHHBIbSB2m","t2TLBKO","zgDVBvm","DMvYC2LVBMm","Du1cqMS","BMCGB3iGyw4","ywXS","t2nfwvq","ALDtufu","DMLJzuLeig8","B25LCNjVCG","A0P0zeu","yMjoCNO","B3rnsNG","zgDHruy","Fdv8mhW3Fde","zufJAW","q1Hgvvq","vw1Ky24","C0POwgW","qwP0zfC","ywXPzcb1CMW","tvHSBxi","AwXSihvZzsa","BwLUzW","Eu1ey3K","Dg9hzw5LCMe","q2juD3i","AgnNvMu","A0TrDhC","ywDLrxzLBNq","Bg9NsurozxC","x2rLyNvN","x21LC3nHz2u","D2D5svK","y2uGBM90igK","whv0D0u","CMvZzxrdB3u","B2XKvMvYC2K","CxDUr1u","zxH0ugf5Bg8","A21jr0y","BMnVzgLUzW","yMXVy2TLza","u1rKsuu","x2rPC2nVBM4","Bg9N","B0zeC3i","CMvWBgfJzq","ANPArhu","C1L3wgy","ign1CNnVCIa","ignVzgu6ia","ywnRx2nVzgu","x21PBMLoyxy","DMvY","CYbHBhjLywq","B25nzxnZywC","t1P5wNC","zNvbC1q","ywrKt25L","wfDXwwq","yxLMy2i","x3jLy29UBMu","CgfNzxnOB3C","B2nRzxrtDwm","Ae9Wzw5fDMu","teTOsu4","C2v0zgi","x2rYB3bhBg8","t3fusMK","uurJqu4","vKjQDhi","x3DHAxq","ywXmwNe","x29UugfNzu4","qM9ewuS","t29fsu8","y3jLyxrLq2W","CYbWyxjHBxm","u3rYyxrLz3K","C2nYAxb0","DeHmugW","Dgv4Dc9Qyxy","qunbAxO","qKTOBhO","qMjky0q","suvtx0vsuK8","CMfNzvn5BMm","ALHcBM4","B3LTC3K","C3Hpv1i","yNrrv3O","rgzSse8","rLjptLrjrvi","yxKSig5LDhC","vg1steG","s1v5AKu","BLngy2u","wfbpwuq","uMvHzcbWyxm","rNnqquy","DhjHBNnHy3q","DeLUDgvYy2u","C3jJ","zxf1ywXZ","C0r0uva","B3nLza","C3rYAw5NAwy","zMX1C2HfEha","ywrK","zg5XEwK","zMzLCG","rK1JBeS","BMfyCM8","ywnRDxbfBMq","C2vYDMvYvgK","BM93","Dhr3Awq","x2LUDgvYDMe","v2LUzg93","zNvUy3rPB24","mJaXnZG4mtLOs3vAywm","yNL0zu9MzNm","CeHqyNa","Aw5KzxG","BMCGDxjSoIa","igzPzwXKoIa","zxjFDhrS","wKTYEvq","CNDSrvq","EvzvAwC","ywXSq3vYC28","rxHZt1O","x2XPC3rLBMu","qMTnELm","vg5Tv1a","x2LUAxrhBg8","CM92AwrLihC","B2nRzxrgywK","zNjVBNrPzxi","qNbRExe","zNjVBu51Bwi","zw5HyMXLvhi","CMvJzxzPzwq","DhLZzuC","DKTkCKu","ywnOzwqSihC","B0PqteO","zsbHihn0CMK","Bxf2twS","AwPAywq","twLZC2LUzYa","r3j4ELC","zxzVv0m","uLjpuG","zLzjvMm","q0Xpu0ve","A0XoqK4","t0nSD2e","AefjzLy","vgTPvLq","A2Per1O","rerYsgm","aaaaaaaaaaa","vw5PBxbSzw0","r3LuAwy","s3vpqMK","B2jQzwn0u3q","Aw5PDcbrB1m","yvLbC2W","x2HHBMrSzu8","qvHZtuO","BxnN","rKDOvKy","u2vYDMLJzvC","CNnUAuy","ALbhyMm","C0zRuve","CgfNzwHPzgu","tuL1DMu","DxjS","D2fZq2XLyw4","qM9Pq0C","ALHcwue","y3vYC29Yx24","s3rgvxK","v1rlBxq","Bg94r1u","CMvJzwL2zwq","yNvMzMvYzwq","mxW0Fdn8mhW","DhjPzxmGCMu","CM92AwrLigi","q09otKvdveK","qvrWr3y","y3jLyxrLrwW","DfbjD1q","uKDlt2W","A1n0yxr1C0m","su9oBfu","DxbNCMfKzw4","AgvHzgvY","Cgf5Bg9Hzeu","BMfKBe8","y1vzzNq","zM9Yy2u","y3vYCMvUDeK","u2jZshy","y3vYC29YlNm","zgvMAw5Luhi","EwjszKm","x2LZtM9Kzq","ywrKrxzLBNq","tK9MDMC","B25SAw5L","wM5WvwG","sNHSyMO","x2LZtwLUAvC","C0nSBhq","D24GCMvHC28","vKjiv3m","twzVtKK","qKLLDNG","s01Su0S","BM5zvvi","t3rkyuW","uMnPrLy","sMLvA3e","vvntyMi","Aw5KzxHpzG","CM92AwrLihy","AvvZwxq","y3vYC29Yx2y","CMvTB3zLq2G","C3fIsei","v1jfwLi","DgHLBG","yxnL","De1HBMfNzxi","B2zMC2v0","tNPZu0K","zxjYB3i","mxW0Fdn8nxW","z3vXr2e","t090AK8","A2zwy2y","B3vUDa","zMLSzw5HBwu","mxWWFdr8m3W","yNbYD0O","u0POvhO","CKX6zLq","CezfB0W","tNfoAfa","BhrPCgXLihq","tvfYt1O","yxrHlcbKyxq","Cuzgq3O","D2DurMO","u0PpAhK","BKzxqNC","ywWGy3vYC28","zNLJuuq","BKHiu3O","zgv2AwnLx2K","BwTTCeS","D2LSBfjLy28","BwPmvuu","BxPjuw8","D3nzD08","A3Hqr2y","rezSCKW","y29Uy2f0","x2LZv29YA2u","yKDoz08","B3jL","x2rPC3bHDgm","ALftsLy","AMzVDuu","zw5NDgG","B3L3reG","Cxv5B2K","Dg9Y","C3rVCcbPBw0","BgLUzq","wwHcCKm","AMvJDfn0B3i","vLPcseu","y3r4","AhD2r2W","rxnUwe4","CgfYC2u","y1HYsMi","vxbKyxrLq28","x3jLBw92zvC","q3HdwM0","v0fMALm","DwXwzwu","y0rbs20","CgPIr04","BMrQtKy","z0zzqwG","ChjVDg9JB2W","vg9ds3y","y2HnyxHuCMK","AxnAzxjV","x25HDMLNyxq","y29UDgLUDwu","zgf0yq","EfjvtwG","DgTfzhm","B2zMBgLUzq","B25fCNjVCG","Cg9W","t2vfAfq","teTAD3u","De5XuxC","DMfS","Bvz6whu","ihzHBgLKihm","CNjVCK1LC3m","CMvHzfvjBNq","tvjwrxi","Chv0","BvfbD1O","tuvtu0fhrv8","C2vUDa","yw5ZzM9YBvq","CgjcrMm","BgLTAxq","t0vgtKe","qKnYEwu","Dw5RBM93BIa","q2XStKW","wKruseO","zeD0wu0","ExbL","ufHbqLa","q3Ltuw4","BLbPuwK","AxnszwfKEq","uNPLqxm","zw50tgLZDgu","C3vJy2vZCW","x3bHDgHlzxK","DhbtC00","yMLUza","ChLXtu0","ywDLsgLKzq","yKzbt2y","uvbiAvC","BKrfr0K","ywXSB2nvBNm","s1DICg0","Bg9Nsurhzw4","Bg9IywXty28","wK9jqwW","sujdy28","BNHKsgG","qMTozvq","l3DZl3yY","y2jvALe","AKrmtvu","twvZC2fNzuu","zxjYtM8","BfHXu2S","uu1ysMW","vxjYEu0","D2Xwsvq","D3njv2G","AKTiDeO","BNrfBMrWB2K","yNL0zuXLBMC","AwDHDg9Yt24","qvfQDvO","B25dBg9Zzq","CwT1r3i","BKXPBMu","uuj3vLy","AxnQAei","BMrWB2LUDfq","tvz0s00","x3jLywr5q2W","tujIs2G","C2HPzNq","BvjeCue","CMvQzwn0","u3j5uNm","u0nSDMC","BNnuEeG","EvDlqNu","BwH3CMu","DMfSDwvZ","CgLUz09Uy2u","Aw1ZEeO","B25mAw5L","Axnby2TdBgu","B2nRzxq","B2PyquW","seDwqLO","D3jPDgu","y21ez0W","AeD2rfa","CwvKvuW","thbgug0","Bxj1DKK","uLbmrKm","ywDLu2HVDW","B3bLCNr5","x3bPBMC","BuXqDge","yMfSu2nVCgu","EwPzzxa","y3vYDMfSDwu","zLbvtwS","ELbQANq","C3nrDfC","DfzdzKu","wKfuuee","AwXLtMfTzq","CMvuC3e","vuHnvfO","Cu9Qsgi","EunVthm","q1DZwxi","s0LSswS","AvLJBwO","BKPpAve","CK5WsKS","EgT3Eve","s09WAey","rxj0AhO","B09Iwhi","B21tqNe","ru9JBgq","qMvfqKu","BgfbCge","BgvY","t1bftG","ywX3yxLZ","A2v5","y2HHCKnVzgu","BKn3Cxy","C2v0","DhjPzxm","C1vAz2i","D1vlqNq","AgvKtwf4uMu","t3bLBKv2zw4","y3ruAw1LB3u","B1DHzge","zMnRs0K","yxbWBhK","t2rTB1u","twzcqLG","BwvZC2fNzq","CgLUz0LUDgu","DgvmB2Djre4","zK1uyLC","ExrLq3i","A3npyLC","svn4DuC","C1jrz1K","x0vysvnu","DeLK","vxnhAfK","Dg9tDhjPBMC","vNDYvuG","A01OCMq","DNr2vLi","Cg93","DKzhuvi","wxfkA24","tvvzzg4","AevYCM9Yrxy","ugn0EvK","rxH5teO","Cer5y2y","uxfhtMu","igXHCMDLCIa","B25JBg9Zzq","EfvZzuvUDG","BNDPzxq","C2DPza","z1jOtLq","DwvbzKO","Bwv0Ag9K","AKz2Cum","B25tDgfYDfi","DMvYC2LVBG","tfbsAeK","zw1PDa","EfHrCNG","B1n3tMC","ENv3zM4","ihn1y2nLC3m","q1bkAKi","q3vZDg9Tq2W","y29UC3rYDwm","zw5HyMXLuw8","svDtsLu","zw50","yw5Nzq","BwvY","lcbTyxGGCMu","DfLytg4","AK14CK0","z2v0qwXS","rxLlDw4","tKfku04","tg9JAW","q291BNq","yNL0zxm","zuHHrgu","BMv3vMvYC2K","qM5mCvC","DfPOCvK","CMvWBgfJzui","wejcAvq","D3m6lY8","Dgv4Dc9WBge","s0XSyxK","u2vXsuq","DfLXBNe","C1fhv24","CNLfzvK","DcbSAw1PDa","CLzHBhvLCW","Dezjv0m","zKDesLG","txzqALG","qwHVz0S","rg9uBgC","x2zVCM1HDeu","C0nVDw50zxi","zLLgCeK","ywnRpwzYB24","AMHzt0S","y29UBMvJDeu","tfHtAfi","CMTLCKDSB2i","A2v0ignVBNm","tLfRDLa","sg5Zzeq","B25hzgC","zvvYBa","tMvzrNa","uwzerMO","x19LC01Vzhu","CM92AwrLige","CuLAwvu","r3vOEgC","tfLjzLu","rLDgtLC","tvLIzLy","x29WDgLVBNm","x29UvgLTzw8","C1jQz3K","v3b0A0y","wvnwseG","tenczei","uMHABvi","q3vZDg9Trxi","AxjLza","z2vY","tu1Ovuu","ywTqyum","yM9KEq","yMLUyxj5","y09Wzw4","twHtsu0","DxrMofDYAxq","Aurzq0W","BezSDxnO","zw5JB2rLrNi","z0TNvvO","B1nOrLe","rMPqDNG","vK5zrvi","B0vkz2q","zNjVBujPDhm","uhn4z3G","BwvKAwf0zwW","zhzVBK8","sxzowuC","zNnJCvK","s2ngC0C","zenJqM4","DgLUzYbZzxi","BeTtufG","yNPbve0","r3H3Dfe","swTZs0m","ywXty29Wzq","CgT6s0m","BxLUrLa","AxnmB25N","B2LUDfjLywm","y2fSBa","zg9Uzq","DevWzfK","AgvHzgvYCW","yxbWBgLJyxq","ihjLy29UBMu","EwHWC0e","jMPZy2fSBgi","zLzbCha","vg52BKS","Dw1hshG","uvbxCgG","tMDlv3y","zcWGDw5RBM8","yxjQvNO","BNvTyMvY","AxnrB1nnzxm","ywzL","rLDt","x2rLC3rYB3K","AwTUzuy","DNjfwfm","u3Phz1e","Aw5N","Bxz5wge","zw5HyMXLqxu","ugnbEva","z1rPBwvVDxq","B3jRzxjhBg8","Ee1ADem","B25pCgvU","DxrVuMvJB24","yxLyt1q","B3bLBG","BfzVDMW","zgvSzxrLrge","AM9PBG","ChrVCG","zv90Aw1LB3u","ugzcD0m","v3LIELa","C2nnuuS","uMvJB25Uzwm","z2vtEw5J","tgfcrva","vvH5zKy","B2vTDwe","zwvbthi","BgLZDgvUtMu","wvr0tMy","Bef4zuO","yw1L","x2HHBMrSzvi","z29PBMCGyxC","y2XVC2u","Bg92Bxy","B29dzuW","z2DJqMi","vu9qvvy","CgLYC1u","t3DpEva","x2jPBMfYEvq","yxrLq291BNq","CNzHBfzHBhu","zuXLBe0","nhW2Fdb8mNW","rg91AgS","zxHWB3j0CW","ru1ZB2q","mJf1s1zRBhi","A0XereO","ExHItMe","BfrPBwvVDxq","BwvZC2fNzv8","nhWXFdn8mNW","y2XVC2uSihC","C3rVCMu","x3bYB3rVy28","CYbPBNn0yw4","Cgu6ia","CuD6txm","BhjyAKS","CMvHC29U","tgnKy2u","BMDuAw1LCG","EwfTtvq","CMvZzxruCMK","x3bPBMDmB3m","z3Pyqwm","B25tDg9Wsw0","zgrbDLC","v0Tgt0m","y2XLyxi","tuLZvwy","CMvZDwX0","u2PbzLG","B3vICwK","yKjHvhy","DgLTzw91Da","rxvYsue","mxW1Fdm","C2fNzq","DgHrt2m","A1njCvC","tvzgC3y","x2fKzfDZtgK","AgvlBNG","vfLNvMe","ugTxrMS","DuvhvNK","D3jPDgvvAw4","q29UzMLN","wgneve0","tvPjDu8","CKP2D1O","Aw5Lza","yw5Hz2vY","yu95CNm","BefSEMm","BxnNsuq","m3WYFdr8mxW","rxf1Cfi","DhLWzq","zMzMzG","CMfUzg9T","tujWtwe","D2vRz08","Ec1TC2CTCw8","y29UBMvJDgK","tNjXuNK","B3jou1e","vwTIy3u","qKTNDwe","rNDrthm","Cgf5Bg9Hza","tLjusxq","x29Uq2XVC2u","DxH5rNG","vvz4yKG","DgvZDa","thvgAgW","x2LUAxrqCM8","CMLLC0nVDw4","BgTZD1y","wxretKy","ywrKq291BNq","ENzhvey","BgvUz3rO","ANL4rM8","DcbVzIbYyw4","x3vYBa","D1zKr1y","tvPUyMy","qKXoDhq","r1vsA0S","BwvZ","ihrYEsbYzwm","vgLvDuu","yMfSrxzLBNq","qK1wDNK","ChjVDg90Exa","rKLmrv9ot1q","uMjHzgS","q0rXyNK","BNLZqMK","ufPjtM4","BNPiD2K","Dw50","tMrmAKy","BMrWB2LUDca","z3HUs1C","nda0nJaWoejLtgfhza","swjIvMK","EMXHBem","tMfWEvy","tvbXEKm","rLjQExi","vLH0v2C","AgfZ","tg9Nsuq","t0zKt2e","Dg9iyxnO","yxDXA1G","tLzNtue","tMvHwxu","AuTYwMu","tgvVshy","rNf2rw0","x2nSzwfYugK","tMnjzem","y29UBMvJDca","AwXK","qMXguuy","x29UrxjYB3i","mJu2mZeXnMztCxrmDq","wfzgC3q","wLbJr0e","ru53Bvu","DxnLCKLW","CMvUDevUzha","yK9MwKi","BwLozLG","tuHcwfm","z2v0qwXSs2u","sw1JEwC","zw1LBNq","y3jLyxrLtwu","v2vIu29JA2u","EhfTswy","v3zAsgC","id4G","C0D2BLO","reiGzMfPBgu","vxvevMi","x2nYzwf0zvm","uMTWt2W","C1DIuvC","BgLUzw5V","tKP3B0C","BwfW","x2DLDeLUDgu","t2vstMm","B3bLBIa","Ec1TC2CTy3u","wuPmquG","u2TPCcbWyxm","A1HuqMO","z2v0sxrLBq","D0HSwxe","qu14AKu","wfrwsge","EuvnwKW","y3jLyxrLuMu","q09oveLovuu","vMLsAuy","ysbTDxn0igi","CMfTzq","rhjuBNy","rxjYB3jdB2q","EeXSv1u","x2TLEvbHDgG","Cgf5Bg9Hzfq","q1LMwvO","Dhj1y3rVCIa","vMzkEfO","ugTOzvq","yxGGCMv0CMK","BIWGAg9ZDg4","y3vYCMvUDeu","r05cBu8","ywztwNe","C2vYDMLJzs0","zNjHBwvuExa","ALjXAxq","z2Xtt1i","DgLTzw91DcW","wxz2Ewm","x3DZ","q2LbD1m","BwDLrva","CgjICdi","tKvOwMi","zwn0","D3b3B1y","y2rQyMq","zxjFCw9Zx2e","rgnHzu0","tuzODNa","C29YDa","EvjLy29UBMu","yxv0B21HDgK","Au1eugi","ChnHy1a","ig1LC3nHz2u","u0DkvLi","zg9Xq2q","s2LdrfO","v1jUrKm","C3vIC3rYAw4","CKPdqLC","EhfTAwK","B0rYBgm","DhDVCMTdAge","x1fVu01HBMe","z3LvB2q","DNHiDLm","C2vYDMLJzq","AxnbCNjHEq","B21xuhq","CxjpAM0","y2j2wKK","BNruCMLLC0m","BwvZC2fNztO","C3nHz2vfDMu","DMvUDa","C3rHCNq","BeTozgS","whLrqNG","r3H3zge","vwPiEMi","vfPKtfu","zMvY","zgvcuvK","uKHRsM8","EuHptLi","AKTUDK0","CMvTB3zLrxy","C3vIyxjYyxK","C25SqLi","ENrNt0q","BeHHBMrSzxi","z2u6ia","DujzCwG","zw5XDwv1zq","Dfbiz0C","zMDeBxO","CMvZB2X2zq","rxzLBNq","DhjPBq","B3jLtMfTzxm","Cg9PBNrbBMq","Dg9cExrLC0i","u2HHCMvKv28","vgLTzw91Da","CNH3Dhq","zw5KCg9PBNq","ChbL","y2XLyxjtDg8","A2v5CW","rgDhsMy","BNPMtwm","mtf8oxW2FdG","x2LUAxq","rhjqsNG","r3DADhy","y29SBM8","y2XVC2veqG","veP6A2S","D29VEeq","CLvSs1e","nxWXFdb8nhW","t1bftL9fuLi","zu5JBw0","CMn1se0","ze5cwMC","zNzzAfC","zuvhqKW","x3nLBMrby2S","B2fK","y2f0y2G","A3nLrMO","D2DfDMm","ANDYqNC","y3vYC29Y","ihrPBwvZ","CMvHzhLtDge","BNnIvfq","r2jPAKO","su5SC2e","shfUufe","CM9YrxzLBNq","thHtu1y","z2v0q3vYC28","r1zhufy","qxfyy2i","x2vUzhbVAw4","yNnVBuu","y29UBMvJDa","BMv4DcGPigm","B3bLCNr5tMe","y0nnBxK","B3nLrxzLBNq","suveDNC","CNnVCL92ywW","wwnMBLG","uw5xyxO","BK9Vu0S","zuzbAg4","zgvIDwC","sMLRDhG","yvnYwM4","Ehvnwxe","yLLfs0C","vKzYy24","D2nWB2G","rxH2sM0","yuLHCeW","uu9btMy","yxKSihrYEsa","zgLZCgf0y2G","B25TzxnZywC","ANrvANe","z2v0","C3rYAw5N","ALvLzLe","CMvXDwLYzwq","y3jLyxrLrxi","ywrSu2m","vKLACfy","yxjYyxLIDwy","shfZtMO","AxnrB1nby2S","Aw47y2HHCNm","zw5JB2rPBMC","zxjHDg9Y","B25ozxr3B3i","EerQAfK","DMfSDwu","DMDTs1y","BMDLza","zw5fDMvUDa","s0niy3y","B1DyENq","tuzZreO","ywnRtxnNswq","AuTuvhu","wLbWAw0","DMvOsvG","C09SwLG","mhWZFdj8mxW","BNHVweu","re5ntum","zen0qM8","rLLVyvu","z2v0u3rVCMe","z25eEu8","rNjVBNrPzxi","vuzwtwi","yNLL","uhjPBwfYEuS","Ae1LC3nHz2u","wvDXDfi","Aw5KzxGGB3u","rg10B0y","vK5WCvO","yu5Hzxm","sgvVyuG","CMvJB25Uzwm","yw1xAxe","u3fsCfu","x2LZtwLUAvq","BM5Ly3q","EMfQs3C","y2HLy2Tszwe","C3rLBMvYCW","q1PlChu","EKTWBeC","tKfusvzfx0u","zwnVBM5Ly3q","yNvMzMvY","sfnQCwy","C2v0u3rVCMe","Ahr0Chm6","y2HnyxHdB3u","rxDiEhq","swHpEMy","Aw9U","zKvvze8","ANrgEvq","Dxrjza","AuHvveW","BMnLq2XVC2u","rNvktNO","rwnrANi","qvrnt3i","ruXlqwO","CvbXEwC","BM9Uzv9UB24","BMfTzq","AhfnDLu","BLPRv0e","z3HmD28","x3nLCuLK","tvDoyuW","C2v0y3vYC28","Dg9mB3DLCKm","z2vrDwv1zuW","mdaWma","Bwf4twvZC2e","x2n1CNnVCKy","vgHsu3G","CgXLyxnLiha","CeTzzwe","tufyx1jfvfi","EuPRAMO","uunPzvK","qwjVCNrfCNi","BNrbBMrvCgq","rvH6twK","tNvvzgO","igzHAwWSig0","CgXRrNK","q1fMvLi","v1PoCui","AenSB3nLrxy","Efrurw52","x2HHBMrSzva","lcbxzwjtB2m","zwrmqNC","BuTYqM0","ihrPBwvVDxq","B3bLBKrc","wLvgu0m","zcWG","Cw9Z","DhzYseq","wKjwDKe","wgLXChy","qLvgB0C","yxbWzw5Kq2G","EMX2EK4","vw5Oyw5KBgu","A0fXELG","ANjdree","swTOzei","CeffBg4","CxDQtKC","BwLUAvbYB2C","r0n2BgO","zxjFBxnNAwq","t0HxEeC","uNvuvvK","v2vPEgLUsLm","wxbcv3y","zMXMD3q","Cwf5y1O","x3bYzwzPEa","su9rvNO","ueHYv0q","yuH5sLG","AwzUD3i","CurhAva","yxv0BW","BMrLEa","yKHLyKC","Aw9Ul2PZB24","ndiYndeYy29nvhPe","C1j0Dgi","AefJA01LC3m","uLnODLG","ExLAqxi","vfDlC3m","tMfTzq","quXm","sgLhAg0","BNrLCG","pxv0zI04","vu5dDwu","Ef9MCM9UDgK","uhLnyMO","EKjWrfm","rvjst1i","su5ewxC","zKXRCe8","A1Dez1i","BMvJDa","x2n1CNnVCK0","Bg93","AfLUq1O","q29Kzq","icSG","x2LZqNjVD3m","uLL5Axe","EhH2svO","Aw1LCYbPBIa","s2POCg8","CwX3A0e","tgT0AvC","Bhm6ia","vNbgvhC","BeTiuKO","r21nshe","rLfMDNK","q3PSD1K","CMjQvKe","CNzHBa","qNfJEfC","zxq9DxrMltG","CgvYC2LZDgu","ELLjCeu","AuPgtNa","vfjYshG","D05PExy","C2vUza","CMzkshm","rwfPA0m","y29UBMvJDfm","zKzSDhK","Dg9oDw1Izxi","CgLjDw4","uMPVzNO","zwrPyxrLBhK","rNvxCgG","zNv5BLC","C1jXy3u","sw1AAxa","wKXfwxm","vgfN","zgvSzxrL","ywnOzwq","mdaWmdaWmda","r0PktKm","su93C0S","rxbqu3G","B0DQA0K","nNWZFdb8nW","txfirLy","CIb0DhDjra","z2LSyxO","AujKzuO","yw51Ce1LC3m","yM9L","wgrerNC","yw1Lu3bHy2u","C2XPy2u","zMLUza","rgvKAwnHDgu","B3jpBMXPBMu","ngPkzhPTAW","DKDqCKm","yLP5A3G","q3v2ufy","weTZuNu","x194x21Zz18","BvDeDuu","zxH0zw5ZAw8","rvfLsva","zgvJB2rLzey","Cg9PBNrdB24","mJiWnte4nMXvveHzBW","ywDWwgu","u1npyue","CMfTugfYyw0","zLvrA0y","zMXVB3i","CMvZzxrfBMq","wwjty2G","x2n1CNnVCK4","txj6yKC","ugXqCvy","Durszwe","B2zM","odG2ntG2mer4CKrwtW","uePqEuO","t2jQzwn0","Dfbouha","AgfUz2u","Dhvruvq","AxmGDw5Kzwy","D1bHwfK","ChjVy2vZCW","Cereu0e","uwzuvNe","DxrPvva","A1PlsuG","wLj1DKC","zfDVCMTLCKC","sxvstKW","zv9ZDwnJzxm","EsbJBg9Zzwq","uNrfveO","AwTgsLi","zNjVBuHHC2G","vMDjA1m","t3D5tu4","zcbLCNjVCI4","sxbUyNi","wwjAzKC","zuv0AuS","Aw50zwDLCIa","rNnrCKK","CuXbuKe","sMrcALe","Bfbuv3C","AKf4C1C","tgLZDgvUzxi","zNDjEKy","ndK1mZi0nMDNsgz0yG","Dw5KzwzPBMu","BMvLzf9Hy2S","sejStwG","mNWZ","zMLSDgvY","z2v0q3vYCMu","A3bQwNC","rMH1u08","uMDewMK","Bwu6ia","CgnmzNe","C3bSAxq","zM9YrwfJAa","ChvZAa","uxvLDwu","EvrLsxi","sLrrteC","ANjuuw0","v0j4u0e","vezSuwW","yMLUyxj5vhK","CNvZEhq","Aw5JBhvKzxm","Dgv4DfbHEwW","x2rItMfTzq","rMTNu20","zgvS","t2nsru0","AurjBK0","ChPdD0G","A1vbAhC","rwP1tM0","Aw9UvgLTzw8","x3nVy2TLDa","CfrmC3q","y2HLy2TdDxi","Ahr0Ca","ue15v2C","EhbzsNy","rxP5yK8","z2PAuuq","BK1urwC","yxnZAwDU","v1Lpzg8","zeryvwm","AKPuv0S","yxnJCMLWDa","zxmGCMvHy2G","CNnVCKzPBgu","u29mqLq","y29Kzq","rLPwChq","tKDFrvjst1i","ywnRx2LK","B25VCgvU","x2LZsw5PDa","quzgvLK","y2vZC0HHBMq","v0r5BgK","C3Dcshy","zxjYtxnN","vwDwt2u","x2DLBMvYyxq","C2vUzf9Hy2S","DwzcvwW","CwTIBMC","qw1VDw50","rwDqD1O","BMvY","qLPUqwy","zNDZxZeUmc4","y291BNq","wK9TruC","CMHyCNK","BeLAB2C","sLnptLa","DwnJv3y","rNfdvMm","EMjIBum","svvrDvC","nxWYFdr8mxW","Dgj1ruu","CMnNDhi","CxLNBLi","s2zxB3G","Bvz2BLm","Bwf4uMv0CMK","sgXrwu0","BwLZzq","u0riveO","C3jmtw4","EuDptLO","CgLUz0XVC3m","s0j5BwK","zMLN","nxWXFdr8mNW","wePjuMm","ANDsEg0","Bwf4tg9ZC0m","v2Lyy3O","x3bPBMDqB24","z2v0t3DUuhi","rKnYvLO","weHAvg0","x2nVBM5Ly3q","zxjFCw9Z","B25vDve","vMXTA2m","C0jf","A3LTu1y","rwvhAgO","wef3Cge","CMvKDwnL","ANfWzgi","BgfdwfG","rgfNsM8","uMT1zMy","swTOvxm","yw1LoIa","DuzNq3y","ugzbDvy","zuThvxu","zKPcENm","zNjVBuj5Dgu","ihzHBgLKigq","CgLUz19VBMm","BMCGzMfPBgu","tfHYB2q","q0zYreS","AgfZt3DUuhi","B25Uzwn0Aw4","zNjVBunOyxi","vNPMtNa","AeLTqMe","C2v0q3vYC28","EKf1r1O","B25szwnLAxy","BhPfwvu","BLfXrvC","B2fbuhC","z29MDhO","zw50zwqGDhK","x29UtwvZC2e","qMXgveS","EfbYs0m","AgLNAa","x0rctMfTzq","qNL2EhC","ExHpu08","C0XPC3rLBMu","qw93v1C","zwzABhm","y25IC1y","zxjFAxnFywm","AxHXsMq","BKLjD1e","rgjWswS","x2nSzwfYvgK","sKvltNG","rfLxALu","x29Ut3bLBG","y29UDgv4Da","BfPkzuW","y29TCgXLDgu","DxrZqu4","D0rsDLu"];return vr=function(){return n},vr()}function Ze(n){let e=z,i={hxwdT:function(c,f){return c!==f}};var o=rc[n];if(i.hxwdT(void 0,o))return o.exports;var a=rc[n]={exports:{}};return gl[n](a,a[e(674)],Ze),a[e(674)]}Ze.d=(n,e)=>{let i=W;for(var o in e)Ze.o(e,o)&&!Ze.o(n,o)&&Object[i(1690)+i(417)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=z;Ze.o=(e,i)=>Object[n(767)+"e"][n(1414)+n(417)].call(e,i)})(),(()=>{let n=z,e={rcgtr:function(i,o,a){return i(o,a)},PfAuV:n(1722),XrQqe:function(i,o){return i!==o},wHlYq:n(548),OOtjO:n(1395),oDrlc:function(i,o){return i!=o},quyoi:n(1285)+"d",dNBZg:"Module"};Ze.r=i=>{let o=n,a={SoLBT:function(c,f,x){return e[W(1367)](c,f,x)},sqbHB:e[o(1405)],yVUig:"close"};if(e.XrQqe(e[o(835)],e[o(1725)]))e[o(888)](e[o(290)],typeof Symbol)&&Symbol[o(475)+o(1204)]&&Object["definePr"+o(417)](i,Symbol[o(475)+o(1204)],{value:e[o(951)]}),Object[o(1690)+o(417)](i,o(557)+"le",{value:!0});else{let c=a.SoLBT(_0x203cdb,a[o(1715)],{message:se["_formatE"+o(329)+o(1465)](_0x2310ba)});se[o(500)](a[o(1715)],c);let f=a[o(1334)](_0x29bf69,a[o(1611)],{reason:se["_formatE"+o(329)+o(1465)](_0x8b83ff)});se.emit(a[o(1611)],f)}}})();var we={};(()=>{let n=z,e={tFIWC:function(s,t){return s+t},qGzMs:function(s,t){return s+t},MFsDJ:function(s,t){return s+t},jXBYA:function(s,t){return s*t},hImBa:function(s,t){return s+t},jJTWK:function(s,t){return s(t)},CPJjB:function(s,t){return s+t},GrxzW:"0000",mhwre:n(730),wFoTq:function(s,t){return s(t)},jQSJV:n(1207)+n(1207)+n(1207)+"00000000",XHZTm:n(1669),pbBFc:function(s){return s()},Zcnil:"idb",YWqtR:n(1689)+"ervice",JDoeJ:n(1682),alLZq:"service-"+n(1075),hGvDP:function(s,t,r,d){return s(t,r,d)},ueAfJ:n(422),PHrWD:function(s,t){return s>t},fFlty:function(s,t){return s>t},TYgVa:function(s,t){return s<t},JTQLG:function(s,t){return s!==t},loxGU:n(1170),eNcmm:function(s,t){return s-t},ATpGv:function(s,t){return s===t},naXro:n(1473),zuwfn:n(596),wcpoh:function(s,t){return s!==t},MZnbf:"Wciuv",FMclK:function(s,t){return s-t},bjAgo:n(312),nOoSK:function(s,t){return s!==t},XyQBx:n(1464),fuynW:function(s,t){return s!==t},IONlU:function(s,t,r){return s(t,r)},EsnXN:function(s,t,r){return s(t,r)},nsbTT:function(s,t){return s(t)},yxOSO:function(s,t){return s(t)},YSVHH:"bHebG",oywDH:function(s,t){return s(t)},USSbb:function(s,t){return s(t)},vKJrE:function(s,t){return s>>>t},kzxQb:function(s,t){return s(t)},oSwNg:n(1632)+"required"+n(1607)+n(449),sFkQQ:function(s,t){return s===t},XJIRc:n(1632)+"required"+n(1607)+"value",fckKI:function(s,t){return s(t)},sRqcu:n(1365)+"3|0",oJPLJ:n(334)+n(1158),OZyZw:"OPEN_ERROR",DmtoF:n(1090)+"IES_ERROR",mkmpK:function(s,t,r){return s(t,r)},mVvnS:function(s,t,r){return s(t,r)},eeALr:function(s,t,r){return s(t,r)},RciFV:function(s,t){return s!==t},wekgO:function(s,t,r){return s(t,r)},WTKmt:function(s,t){return s(t)},CbTwr:function(s,t){return s!==t},tgjtM:function(s){return s()},OeEhT:function(s,t,r){return s(t,r)},fMTbW:function(s,t,r){return s(t,r)},miNfX:function(s,t,r){return s(t,r)},NBVqG:function(s,t){return s!==t},omSBq:n(1482),qUToD:function(s,t,r){return s(t,r)},xXQrx:function(s,t){return s!==t},IEDvw:function(s,t,r){return s(t,r)},MHBXS:function(s,t,r){return s(t,r)},zlalC:function(s,t){return s!==t},ZKryT:function(s,t){return s!==t},jRqit:function(s,t,r){return s(t,r)},ayXOT:function(s,t){return s(t)},oEJgd:function(s,t){return s(t)},LpFPm:function(s,t,r){return s(t,r)},BZnAf:function(s,t,r){return s(t,r)},CiAwS:function(s,t){return s(t)},KWbpm:function(s,t,r){return s(t,r)},ssQtW:function(s,t){return s(t)},OdmoU:function(s,t,r){return s(t,r)},xpYJv:function(s,t,r){return s(t,r)},zbbmC:function(s,t,r){return s(t,r)},iKTTu:function(s,t){return s(t)},MvfjA:function(s,t){return s&t},qkuGr:n(1632)+n(1002)+" field: "+n(495),mRDqA:function(s,t){return s(t)},KtFUy:function(s,t){return s+t},PyMbj:function(s,t){return s(t)},QJURB:n(1645)+n(1426)+n(686),eObad:function(s,t){return s instanceof t},jPGbc:function(s,t){return s===t},JuQyF:n(1062),sOlZX:function(s,t){return s===t},EgPwZ:function(s,t,r){return s(t,r)},oWXzt:function(s,t,r){return s(t,r)},wUKBt:n(636),tPHgG:n(1030),HlQYM:function(s,t){return s(t)},AaUwZ:n(1041),vaOdH:n(1254),KIlIk:function(s,t){return s>=t},mgeEP:"close",NqNhP:n(1483)+n(1253),EOcld:n(1484),VFrcn:n(822),jyxFo:function(s,t){return s>t},KcFsG:function(s,t,r,d){return s(t,r,d)},TmRLH:function(s,t,r){return s(t,r)},xuMYq:n(1722),cPgYw:function(s,t,r){return s(t,r)},wDRvU:function(s,t){return s+t},TRrHx:function(s,t,r){return s(t,r)},tPIwT:function(s,t){return s+t},XWqYd:function(s,t){return s+t},ASTnI:function(s,t){return s+t},YTtNf:function(s,t){return s|t},PZINn:function(s,t){return s<<t},gnDyO:function(s,t){return s&t},yWKBu:function(s,t){return s<t},FMMiz:function(s,t){return s(t)},xPrKC:function(s,t){return s==t},LxSSV:function(s,t){return s+t},otMJx:function(s,t){return s!==t},NuUdj:function(s,t){return s<<t},Ukbcu:function(s,t){return s|t},BMVvy:function(s,t){return s<<t},DagJo:function(s,t){return s<=t},CySQn:function(s,t){return s(t)},wgTFj:function(s,t){return s>=t},CQfVR:function(s,t){return s+t},xqmii:function(s,t){return s+t},lrXjK:function(s,t){return s+t},rNpJK:function(s,t){return s|t},UuDVb:function(s,t){return s<<t},mzIQo:function(s,t){return s&t},WybzP:function(s,t){return s<<t},eEGBL:function(s,t){return s&t},KiCDZ:function(s,t){return s&t},IksKC:function(s,t,r){return s(t,r)},PctyY:function(s,t){return s+t},WRnFC:function(s,t){return s>>t},FhuSO:function(s,t){return s+t},CYfYZ:function(s,t){return s<<t},pjbGN:function(s,t){return s<t},iMDPb:function(s,t,r){return s(t,r)},mqvMk:function(s,t){return s<=t},bprwJ:function(s,t){return s<t},Xiqpv:function(s,t){return s&t},EjuNm:function(s,t){return s<t},wVdGV:function(s,t){return s&t},MBbKh:function(s,t){return s|t},ZOmEG:function(s,t){return s&t},FuWph:function(s,t){return s>>t},ImZip:function(s,t){return s|t},kZKIH:function(s,t){return s&t},BLNtt:function(s,t){return s|t},XKsRu:function(s,t){return s+t},oaAPw:function(s,t,r){return s(t,r)},gilaz:function(s,t,r){return s(t,r)},dfybv:n(1064),GbijJ:function(s,t){return s(t)},WvZHg:function(s,t){return s<t},IOwsK:function(s,t){return s<<t},yamMT:function(s,t){return s&t},CWsYr:n(1007),AicUK:n(1521),Douhk:function(s,t,r){return s(t,r)},fvYhW:function(s,t){return s&t},kjDGZ:function(s){return s()},vgmKV:function(s,t){return s===t},bYRDK:n(310),GJJNC:function(s,t){return s(t)},tyseG:function(s,t){return s<<t},lovmv:function(s,t){return s&t},GNBmO:function(s,t){return s(t)},QDcAN:function(s,t){return s&t},LPRhI:function(s,t){return s&t},NanhN:n(905),MrzbG:function(s,t){return s(t)},czIkQ:function(s,t){return s<<t},goftz:function(s,t){return s&t},KXtgB:function(s,t){return s(t)},vrEXS:function(s,t){return s&t},MMhUE:function(s,t){return s(t)},JEKNx:function(s,t){return s|t},DbpIk:n(640),DcaeM:function(s,t){return s!==t},CzlwY:n(429),ijZad:function(s,t){return s>>>t},awqkX:function(s,t){return s|t},psacP:function(s,t){return s===t},GIBGH:function(s,t){return s<t},rNTrU:function(s,t){return s!==t},gyUod:function(s,t){return s&t},cCMmy:function(s,t){return s|t},PXABP:function(s,t){return s>>>t},uBYqh:function(s,t){return s&t},pFEoL:function(s,t){return s+t},zYIpE:function(s,t){return s&t},tVCfE:function(s,t){return s!==t},DoTlg:function(s,t){return s>>>t},OHWxG:function(s,t){return s&t},heKnx:function(s,t){return s+t},fPEHY:function(s,t){return s&t},OckHw:n(1444),PcAyP:function(s,t){return s|t},IvNYG:function(s,t){return s<<t},oemua:function(s,t){return s<<t},tkEds:function(s,t){return s<<t},pDDSA:function(s,t){return s<<t},KCHcv:function(s,t){return s<<t},MIsUf:function(s,t){return s<<t},jrTQm:function(s,t){return s<<t},xLlWU:function(s,t){return s|t},VpFTw:function(s,t){return s===t},wgEvc:function(s,t){return s>>>t},jLubx:function(s,t){return s<<t},yZInN:function(s,t){return s<<t},ifnwr:function(s,t){return s>>>t},ndjNF:function(s,t){return s|t},nHHSz:function(s,t){return s<<t},nEoWV:function(s,t){return s>>>t},kSIqW:function(s,t){return s>>>t},NRTIt:function(s,t){return s&t},adlSc:function(s,t){return s(t)},Jiktx:function(s,t){return s>=t},jKHtJ:function(s,t){return s+t},tQOUd:function(s,t){return s|t},vzzPL:function(s,t){return s%t},OqTJi:function(s,t){return s/t},guqGa:function(s,t){return s+t},FRjyr:n(1580)+n(535),evoWC:"skXSp",TnmWP:function(s,t){return s*t},akPaC:function(s,t){return s>>>t},FQfvy:function(s,t){return s+t},RShvX:function(s,t){return s*t},jpbDw:function(s,t){return s>>>t},GmMHq:function(s,t){return s===t},VBHWs:function(s,t){return s>>>t},nIIwQ:function(s,t){return s&t},qCbJW:function(s,t){return s>>>t},WYOdo:function(s,t){return s&t},HqnPQ:function(s,t){return s>>>t},nsTxH:function(s,t){return s>>>t},OwyMN:function(s,t){return s+t},nQqEW:function(s,t){return s>>>t},pKYea:function(s,t){return s+t},BKhlz:function(s,t){return s>>>t},UFVMb:function(s,t){return s>>>t},yEMZL:function(s,t){return s|t},piIun:function(s,t){return s<<t},CFrDK:function(s,t){return s<<t},RHxAQ:function(s,t){return s>>>t},DrTnv:function(s,t){return s>>>t},MqHFV:function(s,t){return s===t},NrqRy:function(s,t){return s+t},mjLUE:function(s,t){return s&t},jhYOK:function(s,t){return s&t},gexrv:function(s,t){return s>>>t},sYwXf:function(s,t){return s>>>t},GwZtv:function(s,t){return s&t},RgDZi:function(s,t){return s&t},BlFQF:function(s,t){return s>>>t},PJPyJ:function(s,t){return s>>>t},fycQD:function(s,t){return s>>>t},BqcxW:function(s,t){return s>>>t},glSOR:function(s,t){return s>>>t},wMinq:function(s,t){return s&t},BIevx:function(s,t){return s&t},rJvwZ:n(1054)+n(1635),fPUMk:n(672)+n(707),YQLgy:n(1344),MWNaL:function(s,t){return s-t},qwjNG:function(s,t){return s!==t},bBaTv:n(1119),EurIA:"YJEQm",eEtiK:n(1128),MfBBX:function(s,t){return s>=t},lKHRJ:function(s,t){return s&t},INlsa:n(1586),YqJkn:function(s,t){return s===t},tPNPp:function(s,t){return s instanceof t},ufBUl:function(s,t){return s+t},EwHxt:function(s,t){return s===t},lXqSk:function(s,t){return s===t},oObXr:function(s,t){return s<t},KLlay:n(744),WDyli:n(464),PMyWg:function(s,t){return s===t},qnJgF:n(331),tbuEE:n(529)+"in;charset=utf-8",tYXLn:function(s,t){return s===t},ELKAj:function(s,t){return s===t},jwRxm:"IlHfV",ISxuG:n(1574)+">",SJOhy:function(s,t){return s||t},zajKw:function(s,t){return s!=t},OwOyP:n(727)+"0",nFWBw:function(s,t){return s!=t},hAIfV:"undefined",umGHx:function(s,t){return s<t},VZBHE:function(s,t){return s===t},pyqMM:function(s,t){return s+t},DFlrL:function(s,t){return s<t},YbSch:function(s,t){return s-t},ENwmU:function(s,t){return s&t},aNaes:function(s,t){return s<t},Kjhpo:function(s,t){return s<<t},tZhqY:function(s,t){return s>=t},Bpkyq:function(s,t){return s&t},UjHzb:function(s,t){return s<<t},QfDFj:function(s,t){return s&t},BeEBE:function(s,t){return s&t},vxHvS:function(s,t){return s+t},WZNqB:function(s,t){return s&t},gihuH:function(s,t){return s<t},HDqoL:function(s,t){return s&t},ysZHy:function(s,t){return s+t},kJtdE:function(s,t){return s>>t},MUYdn:function(s,t){return s|t},SqRpU:function(s,t){return s&t},zbFBA:function(s,t){return s|t},wooxD:function(s,t){return s&t},hYnCZ:function(s,t){return s>>t},OoEIO:function(s,t){return s+t},KuOBi:function(s,t){return s+t},VYVQJ:function(s,t){return s<<t},YtDNF:function(s,t){return s|t},jtFyT:function(s,t){return s&t},mVzXu:function(s,t){return s|t},orNSQ:function(s,t){return s&t},pzCwH:function(s,t){return s-t},tvrHD:function(s,t){return s(t)},RYyiq:function(s,t){return s!=t},ggcBb:n(1e3),ojXAL:function(s,t){return s instanceof t},KgneZ:function(s,t){return s instanceof t},qkbng:function(s,t){return s!=t},ndesr:n(1218),QPHiW:n(933),MVFsv:n(341)+n(689),laCXX:n(1561),kymSV:n(1563)+n(1331),nlbwz:n(1321),mQAwZ:n(614)+n(545)+"tierJSONP",MFhvp:function(s,t){return s(t)},zKplG:function(s,t){return s(t)},FCrVZ:"wsIWh",ZLEYs:n(1404),MIuve:n(1044)+"t",BbJcD:n(1120),uZbLN:"yPnAe",yJkjj:n(352),Vwtbw:n(1562),NOfvg:n(335),vtvVR:n(833),kseFj:function(s,t){return s&t},omWPt:n(660)+n(995)+n(1044)+"ting ser"+n(1535),QCieY:n(1581),AjtdW:n(1529),hwadr:function(s,t){return s!==t},ZATPA:n(1368),VfJxZ:n(376),rLzfT:n(1524),wzajB:function(s,t){return s||t},sxOWR:function(s,t){return s||t},ExsOZ:function(s,t){return s||t},MZIuO:function(s,t){return s||t},deBQY:n(1649)+n(819)+"d",ZPcGA:function(s,t){return s+t},ARhEH:function(s,t){return s>>>t},aFZNb:function(s,t){return s(t)},qWUWx:n(1045),srLMn:function(s,t){return s===t},XBBiT:n(641),LaBEP:function(s,t){return s(t)},sEnmL:n(1155)+n(1390),sRjgy:"x_fronti"+n(872)+"ck",PgGUN:function(s,t,r,d){return s(t,r,d)},FwQLs:n(1155)+n(1438)+"k",ixqJd:n(1155)+"er_ack_m"+n(492),mLPta:function(s,t,r,d){return s(t,r,d)},mKrBm:"is_ack",sUZgb:function(s,t){return s&&t},NEhZb:function(s,t){return s||t},KBymi:n(1533),yxbNa:function(s){return s()},cxlzV:function(s,t){return s(t)},uDRea:function(s,t){return s(t)},ryEeY:n(611)+"ion/json;charset"+n(1153),gSRRe:n(1074)+"e",yjYep:n(577),xRUMh:function(s){return s()},yHONR:n(587),bFAOf:function(s,t){return s>t},ZRuvG:function(s,t){return s(t)},PfBwC:function(s,t){return s&t},EzybO:function(s,t){return s===t},MPqzC:n(1569),wPaXY:function(s,t){return s(t)},mruvI:function(s,t){return s+t},iDYCL:function(s,t){return s+t},fVIVc:n(1039)+n(756)+n(918),OkenJ:n(1167),iYcmj:function(s,t){return s||t},jqpdb:n(817),xqmIf:function(s,t){return s+t},tpSsM:function(s,t){return s+t},ZtUxQ:function(s,t){return s+t},BlFTK:function(s,t){return s+t},tEpdY:function(s,t){return s+t},UOPUV:function(s,t){return s+t},WAfjS:function(s,t){return s|t},cKEwS:function(s,t){return s|t},DDrHc:function(s,t){return s+t},SJhTz:function(s,t){return s+t},IWSJU:function(s,t){return s!==t},XPOYD:function(s,t){return s>>>t},EddPi:function(s,t){return s+t},lzEYU:function(s,t){return s>>>t},TnvnK:function(s,t){return s>>>t},CVsoC:function(s,t){return s+t},SGJVR:function(s,t){return s+t},qrOjm:function(s,t){return s&t},nnYUR:function(s,t){return s+t},utiUP:n(681)+n(938)+n(1495)+"0",lKNdk:function(s,t){return s<t},fMMoe:function(s,t){return s|t},jAxsW:function(s,t){return s|t},efZls:function(s,t){return s<<t},WnzmS:function(s,t){return s>>>t},PZjjo:function(s,t){return s>>>t},LKhIN:function(s,t){return s<<t},nxoXE:function(s,t){return s&t},NeYFp:function(s,t){return s&t},kWDgR:function(s,t){return s>t},sGvnZ:function(s,t){return s|t},mvyXa:function(s,t){return s>>>t},rJCBW:function(s,t){return s<<t},jKnvM:function(s,t){return s!==t},LJueJ:n(551),BoiCG:n(342),jfouE:function(s,t){return s(t)},bYEKG:n(893),FqvEm:function(s,t){return s(t)},oymsy:n(1713)+"ile_name",aOyrs:function(s,t){return s<t},iEyrg:function(s,t,r){return s(t,r)},BHJMZ:function(s,t){return s+t},FGhVF:n(768)+n(472),nCwqv:function(s,t){return s!==t},gjRVd:"jsOjn",sWbQW:n(747),fLkpO:function(s,t,r){return s(t,r)},zAuGZ:n(1665)+n(658),AqXcb:n(1612)+n(536),Ctgmj:n(1150),TFlQl:"INSTANT",CxCZm:n(840),rUlKQ:function(s,t,r,d){return s(t,r,d)},vGPrC:n(1548),agpXe:function(s,t){return s(t)},Rjofz:"pIDyY",kpjZw:"XkpHi",tXizn:n(1081)+"r",yhpsA:n(1364),kUAhw:function(s,t){return s||t},sRQgY:function(s,t){return s*t},dGtYM:function(s,t,r,d){return s(t,r,d)},VUjvW:function(s,t,r,d){return s(t,r,d)},ztgOD:"x_fronti"+n(1126),aIapL:n(734)+"s",kfVcf:"x-msg-cu"+n(1477)+"e",qlwkA:function(s,t,r){return s(t,r)},MfoNI:function(s,t){return s===t},XcDTM:n(1362),SZuPB:function(s,t){return s===t},eKGUu:"JyVDe",wlVIT:function(s){return s()},TiUuE:function(s){return s()},bGNgO:function(s){return s()},nPiQi:function(s,t){return s===t},cXrJb:function(s,t){return s===t},fwIzF:function(s){return s()},bZykx:n(779),ROqrg:"RSMQc",EpPSx:function(s,t){return s(t)},wNiyv:n(1410)+n(1265)+"s",gxnKW:n(1410)+"e_timeout",JdBjQ:function(s,t){return s!==t},pirsU:n(1052),yCoLs:function(s,t){return s!==t},mynFP:function(s,t,r){return s(t,r)},YdJoe:function(s,t,r){return s(t,r)},TZdLU:function(s,t){return s+t},fGDJX:n(598),BkNeT:function(s,t){return s===t},rwlET:function(s,t){return s===t},ViRiF:n(1139),ExyLJ:n(1151),WptkF:function(s,t){return s===t},bzATM:n(618),DNMMC:"kkSwN",qPqyg:function(s,t){return s!==t},bOfZB:function(s,t,r){return s(t,r)},gKNzK:function(s,t,r){return s(t,r)},OcEYT:n(412),yteCr:function(s,t,r){return s(t,r)},gRhNT:n(1006)+n(908),QqGNe:n(867),onGdg:function(s,t){return s/t},IkhUs:n(1088)+n(1618)+n(1559)+n(1104)+n(550)+n(850)+n(1255)+n(722),rrmXC:n(915),fQQOd:function(s,t,r){return s(t,r)},UsGhY:n(1695),FZVpt:n(320),DWOIh:n(1659),kGKGl:n(1544),sRttb:n(584),RPLFC:n(1564),qwnGU:function(s,t){return s!==t},XAwpa:function(s,t){return s!==t},isjhB:function(s,t){return s==t},cmDgL:n(1059),OClwa:n(528),edLBw:n(1466),dnqyi:n(1598),oShFQ:n(1601),QfTVq:n(1463),pcLfq:"pkzKC",kLDDJ:n(796),Rkuff:n(793),Vlmkc:function(s,t,r){return s(t,r)},jUefQ:function(s,t){return s!==t},fvEMT:n(1154),jtUjq:"bfgCq",DYgkO:function(s,t){return s||t},VXzww:function(s,t,r){return s(t,r)},AQjuZ:n(902),imsxJ:function(s,t){return s>t},MQrOZ:function(s,t,r){return s(t,r)},AFFVY:n(1671)+"2",HSjqf:function(s,t){return s===t},RYtHm:function(s,t){return s===t},BKgua:function(s,t){return s*t},gjZQD:function(s,t){return s===t},qIZYU:n(1159),onUuQ:function(s,t){return s===t},AhogK:function(s,t,r){return s(t,r)},utsAN:n(705),yMDcy:n(1023),pDycf:n(1696),BUFoG:n(862)+n(763)+n(1415)+"g",MXlmr:function(s,t){return s===t},KMlSK:function(s,t){return s|t},nadlO:function(s,t){return s<<t},kxPGf:function(s,t){return s<=t},KUyjE:function(s,t){return s===t},LEwqB:n(1026)+"4",hLYra:n(294),OtJaL:function(s,t){return s>t},doqCd:function(s,t){return s+t},Imcyg:function(s,t){return s(t)},Guhxg:function(s,t){return s&t},oGjkI:function(s,t){return s||t},cbUjQ:function(s,t){return s>>>t},nZkWA:function(s,t){return s+t},rsniF:function(s,t){return s!==t},IOQVz:n(1130),GyTif:n(775),nzHwi:function(s,t,r){return s(t,r)},eHaDe:n(697),lAlzc:function(s,t,r){return s(t,r)},tNqQw:n(1035),dgaEF:"going aw"+n(1575)+"ork offline",ZUEcn:function(s,t,r){return s(t,r)},lZJeL:function(s,t,r){return s(t,r)},WKFOC:n(340),XTVHa:n(1118)+n(1272),zvgej:function(s,t){return s+t},WiXcz:function(s,t){return s===t},pHPbp:n(1716),GIzYo:function(s,t){return s+t},sQGWn:function(s,t){return s===t},wsYwO:"pJrtu",EXzMi:n(745),yPHcs:n(1380)+n(1212),zUmus:function(s,t){return s===t},fuAsT:n(682)+n(1536)+n(1266),eFAhn:n(682)+n(685)+n(1515)+"nitialized",uPPuQ:"3|1|4|2|0",SClvg:function(s,t){return s+t},zvGTF:function(s,t,r,d){return s(t,r,d)},RGKOl:function(s,t){return s<t},ZOIAl:n(1088)+n(558)+n(1409)+n(1737)+n(842)+n(1629)+n(1485)+" arraybu"+n(1592),wpwoV:function(s,t){return s==t},RhZmR:function(s,t){return s instanceof t},AowWW:function(s,t){return s(t)},xplCR:function(s,t){return s(t)},rhXry:function(s,t){return s===t},qOjHb:n(1121),FQfUC:n(769),OcREM:n(920),SryRs:function(s,t){return s|t},lIZog:function(s,t){return s<<t},oFDsr:function(s,t){return s|t},Nyuqb:function(s,t){return s>>>t},fscqY:function(s,t){return s<<t},wPJeN:function(s,t){return s|t},tYqnq:function(s,t){return s<<t},laApa:"manual r"+n(1055)+n(630),BkMzS:function(s,t){return s!==t},YbZfG:n(1278),kLNBN:n(1157),lPTWw:n(828),CuvPV:function(s,t){return s(t)},PkWFk:n(1644),nhPdY:function(s,t){return s*t},MBpMa:function(s,t){return s/t},CvZVF:function(s,t){return s===t},CDqby:n(1600),DgGJf:function(s,t){return s!=t},uTAXd:function(s,t){return s===t},HHdpm:function(s,t){return s===t},jDLMU:n(1223)+n(1263)+n(364)+"pe",IBCco:function(s,t){return s!=t},wgyIY:function(s,t){return s!=t},jFvqC:n(1251),aHyJX:function(s,t){return s==t},fgDmz:function(s,t){return s!=t},xRNPN:function(s,t){return s!=t},scMQK:function(s,t){return s!=t},Polhm:function(s,t){return s===t},NapyV:function(s,t){return s===t},uEGVy:n(1655)+n(635)+n(420),KeQhs:function(s,t){return s!=t},NAJSN:function(s,t){return s!=t},ooCeL:function(s,t){return s===t},xkwyQ:function(s,t){return s!=t},XutwE:n(1230)+"qos__"};Ze.r(we),Ze.d(we,{FWS:()=>Od,CustomErrorEvent:()=>Ds,createCloseEvent:()=>Ue,ReconnectEvent:()=>Ts,createErrorEvent:()=>Me,decodedFrame:()=>kt,createOpenEvent:()=>Os,CustomCloseEvent:()=>Ps,createReconnectEvent:()=>Yr,FrontierMessageEvent:()=>Ns,encodeFrame:()=>Ne,createMessageEvent:()=>Ls,OpenEvent:()=>Rs,ErrorCode:()=>dt,Event:()=>Rt,MessageEvent:()=>ks});let i="";function o(s=""){let t=n,r="02",d=""+Date[t(1597)](),u=i||(i=g(s)),l=Math.random().toString(16).slice(-6);return e[t(537)](e[t(687)](r,d)+u,l)}function a(){let s=n;return e[s(1020)](e.jXBYA(1e4,Date.now()),Math[s(1241)](e[s(1664)](1e4,Math.random())))}function c(s){let t=n;return e[t(1020)](Array(8).join("0"),parseInt(s,10)[t(475)](2))[t(1221)](-8)}function f(s){let t=n;return e[t(1418)](e[t(1330)](Array,4)[t(643)]("0"),parseInt(s,2)[t(475)](16)).slice(-4)}function x(s){let t=n,r=s.split(/\./)[t(826)](l=>c(l)),d=[];return d[0]=e[t(1330)](f,e[t(505)](r[0],r[1])),d[1]=f(r[2]+r[3]),[e[t(1633)],t(1084),e.GrxzW,"0000",e[t(1633)],e[t(400)],d[0],d[1]][t(643)]("")}function g(s){let t=n,r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(746)](s),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[t(746)](s);return r?e[t(1330)](x,s):d?e.wFoTq(p,s):e[t(286)]}function p(s){let t=n,r={hGZNQ:e[t(1038)],cnbsV:function(R,N,L,q){return R(N,L,q)},QnWaz:e.JDoeJ,iZfYF:"service",HnsdD:e[t(1554)],flfwt:function(R,N,L,q){return e[t(411)](R,N,L,q)},bsomE:e.ueAfJ,SjAfX:function(R,N){return e.wFoTq(R,N)},MVtKM:function(R,N,L){return R(N,L)}},d="",u=[],l=0,_=0,w=!0,h=e[t(1633)];if(e[t(1135)](s[t(1710)]("::"),-1)){let R=s[t(1296)]("::");for(let L=0;L<R[t(754)];L++){let q=R[L];if(e[t(1194)](q.indexOf(":"),0)){let G=q[t(1296)](":");w&&(l=G.length),_+=G[t(754)];for(let Q=0;e[t(714)](Q,G[t(754)]);Q++)if(G[Q].length!==4)if(e[t(1301)](e[t(1668)],t(1170)))this[t(1512)](e[t(1388)],_0x334ca8[t(464)]),e[t(337)](_0x327a88);else{let Pe=h[t(885)+"g"](0,e.eNcmm(4,G[Q].length)),ce=Pe[t(281)](G[Q]);u[t(1298)](ce)}else u.push(G[Q]);w=!1}else if(e[t(1675)](e[t(1594)],e[t(503)]))_0x2bce58[t(1526)](r.hGZNQ,_0x1b819f,_0x1d6b56[t(893)]),_0x31e4c3=r[t(1437)](_0x319182,0,_0x1102ac,_0x28c207),_0x3305a1[t(1526)](r[t(982)],_0x139eb1),_0x460cbe=_0xd4f884(_0x17e940,_0x24ae47,_0x41ac97[t(893)]||0),_0x1081f7.log(r.iZfYF,_0x4f63ed),_0x40c417=r[t(1437)](_0x3af0d8,_0x161839[_0x4d9a60[t(1665)+"ame"]],_0xc62e1e,_0x210deb),_0x21c671[t(1526)](r[t(552)],_0x5ad158),_0x52cae2=r[t(1131)](_0x1028d6,_0x1ca408[t(1665)+t(658)],_0x2c6871,_0xf9964c),_0x5d7a7f[t(1526)](t(1075),_0x142676),_0x43b01f=r[t(1437)](_0x38e813,_0x77522a[t(1622)+"er"](_0x15f142.cursor||_0x3f143b),_0x1dbb74,_0x1d22a0),_0x59ae2b[t(1526)](r[t(973)],_0x4eccde);else{if(q.length!==4){if(e.wcpoh(e[t(759)],e[t(759)]))return _0x1c1aae||(_0x269240=_0x111132[t(923)]().then(_0x4814d7[t(355)](_0x43f361,e.Zcnil))),_0x2dfba5;{let G=h[t(885)+"g"](0,e[t(949)](4,q[t(754)])),Q=G[t(281)](q);u.push(Q)}}else u[t(1298)](q);w&&(l+=1),_+=1,w=!1}}let N="";for(let L=0;e[t(714)](L,e.FMclK(8,_));L++)N=N.concat(h);for(let L=0;e[t(714)](L,u[t(754)]);L++)e[t(1675)](L,l)?e[t(1675)](t(375),e.bjAgo)?(_0x427632=r[t(702)](_0x1637ed,_0x2c9107),_0x4ebaab=0):(d=d[t(281)](N),d=d[t(281)](u[L])):d=d[t(281)](u[L]);return d}{let R=s[t(1296)](":");for(let N=0;N<R[t(754)];N++)if(e[t(983)](t(1464),e[t(904)])){let L=this["_endpoin"+t(1719)]?.[t(1290)+t(380)+"nt"]();this["_dispatc"+t(1101)+t(510)](r[t(390)](_0x2bc55e,t(661),{code:_0x56eb90[t(1335)],reason:t(735)+"ng faile"+t(620)+"wn reaso"+t(854)+t(1403)+L})),this[t(972)+t(1719)]?.[t(1242)+"pointConfig"](),this[t(694)+"sCounter"]?.[t(1517)+t(1152)]();return}else{let L=R[N];if(e.wcpoh(4,R[N][t(754)])){let q=h[t(885)+"g"](0,4-R[N][t(754)]),G=q[t(281)](L);d=d[t(281)](G)}else d=d.concat(L)}return d}}function y(s,t){let r=n,d=s.key;e[r(1200)](void 0,d)&&(e[r(1680)](V,t,10),e.IONlU(Ie,t,d));let u=s[r(1014)];e[r(1301)](void 0,u)&&(e[r(299)](V,t,18),e[r(1680)](Ie,t,u))}function v(s){let t=n;if(e[t(568)]===t(1141)){let r={};e:for(;!e[t(289)](M,s);){let d=e[t(1709)](me,s);switch(e[t(1626)](d,3)){case 0:break e;case 1:r[t(449)]=e[t(299)](pe,s,e.kzxQb(me,s));break;case 2:r[t(1014)]=pe(s,me(s));break;default:e.IONlU(D,s,7&d)}}if(r[t(449)]===void 0)throw new Error(e[t(502)]);if(e.sFkQQ(void 0,r[t(1014)]))throw new Error(e[t(1381)]);return r}else{let r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(746)](_0x86de71),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[t(746)](_0x8ffa2c);return r?e[t(963)](_0x25003d,_0x1225c9):d?e[t(1433)](_0x486c84,_0x520e93):e[t(286)]}}function A(s){let t=n,r=e[t(337)](C);return e[t(1680)](E,s,r),e[t(460)](B,r)}function E(s,t){let r=n,d={CXFUT:e[r(1201)],KdKsN:e[r(1628)],ZmLZC:r(1674)+r(1337),pAEln:e[r(1538)],iHUTL:e.DmtoF,RzeAs:r(1054)+r(1635)},u=s[r(531)];e.nOoSK(void 0,u)&&(e[r(1746)](V,t,8),he(t,u));let l=s.LogID;e.wcpoh(void 0,l)&&(e[r(1746)](V,t,16),e[r(1370)](he,t,l));let _=s[r(893)];e[r(983)](void 0,_)&&(e[r(654)](V,t,24),he(t,e[r(460)](O,_)));let w=s[r(495)];e[r(1707)](void 0,w)&&(e[r(733)](V,t,32),he(t,e[r(1667)](O,w)));let h=s[r(610)];if(e[r(1507)](void 0,h))for(let ce of h){V(t,42);let de=e.tgjtM(C);e.OeEhT(y,ce,de),V(t,de.limit),Fe(t,de),e[r(289)](k,de)}let R=s["payloadE"+r(1522)];e.nOoSK(void 0,R)&&(e[r(323)](V,t,50),e[r(467)](Ie,t,R));let N=s[r(848)+"ype"];e[r(991)](void 0,N)&&(e[r(654)](V,t,58),e.miNfX(Ie,t,N));let L=s.payload;e.wcpoh(void 0,L)&&(V(t,66),V(t,L[r(754)]),ae(t,L));let q=s.LogIDNew;if(e.NBVqG(void 0,q)){if(e[r(1658)](e[r(442)],r(944)))return _0x3ee358[r(923)]();e[r(1680)](V,t,74),e.qUToD(Ie,t,q)}let G=s[r(1596)+r(1504)];e.xXQrx(void 0,G)&&(e[r(979)](V,t,82),e[r(809)](Ie,t,G));let Q=s[r(726)];e[r(780)](void 0,Q)&&(V(t,90),e.IONlU(Ie,t,Q));let Pe=s.frameType;if(e[r(983)](void 0,Pe))if(e.ZKryT(r(343),r(1458)))e[r(1680)](V,t,96),e[r(860)](he,t,e.WTKmt(O,Pe));else{let ce=d[r(1497)][r(1296)]("|"),de=0;for(;;){switch(ce[de++]){case"0":return _0x3ffeb5;case"1":_0x481569[_0x5d8b57[d.KdKsN]=5004]=d.KdKsN;continue;case"2":_0x240c74[_0x1d9785[d.ZmLZC]=5002]=d.ZmLZC;continue;case"3":_0x42f00a[_0x3e9ce4[d.pAEln]=5005]=d[r(1122)];continue;case"4":_0x224252[_0x5b03a2[r(1090)+"IES_ERROR"]=5003]=d[r(1067)];continue;case"5":_0x362863[_0x64f13d[d[r(350)]]=5001]=d[r(350)];continue}break}}}function b(s){let t=n;return e[t(1709)](I,e[t(639)](F,s))}function I(s){let t=n;if(t(1005)!==t(1013)){let r={};e:for(;!e[t(1667)](M,s);){let d=e.oEJgd(me,s);switch(d>>>3){case 0:break e;case 1:r[t(531)]=e[t(413)](Pt,s,!0);break;case 2:r[t(786)]=e[t(1354)](Pt,s,!0);break;case 3:r[t(893)]=me(s);break;case 4:r[t(495)]=e[t(1667)](me,s);break;case 5:{let u=e.CiAwS(S,s);(r[t(610)]||(r[t(610)]=[]))[t(1298)](e[t(1709)](v,s)),s[t(338)]=u;break}case 6:r["payloadE"+t(1522)]=e[t(362)](pe,s,e[t(425)](me,s));break;case 7:r[t(848)+t(345)]=e[t(462)](pe,s,me(s));break;case 8:r[t(741)]=e[t(733)](ne,s,me(s));break;case 9:r.LogIDNew=e[t(1323)](pe,s,me(s));break;case 10:r[t(1596)+t(1504)]=e[t(1363)](pe,s,e[t(1022)](me,s));break;case 11:r[t(726)]=pe(s,e[t(639)](me,s));break;case 12:r[t(859)+"e"]=e.wFoTq(me,s);break;default:D(s,e[t(1467)](7,d))}}if(e[t(1658)](void 0,r[t(531)]))throw new Error(t(1632)+t(1002)+t(1607)+t(531));if(e[t(1675)](void 0,r[t(786)]))throw new Error(t(1632)+t(1002)+t(1607)+"LogID");if(r[t(893)]===void 0)throw new Error("Missing required field: "+t(893));if(r[t(495)]===void 0)throw new Error(e[t(385)]);return r}else this["flushExp"+t(572)]()}function S(s){let t=n,r=e[t(394)](me,s),d=s[t(338)];return s.limit=e[t(1666)](s.offset,r),d}function D(s,t){let r=n;switch(t){case 0:for(;e[r(1467)](128,Ee(s)););break;case 2:P(s,e[r(1156)](me,s));break;case 5:e[r(860)](P,s,4);break;case 1:e[r(1363)](P,s,8);break;default:throw new Error(e.QJURB+t)}}function O(s){return s|=0,{low:s,high:s>>31,unsigned:s>=0}}let m=[];function C(){let s=n,t=m[s(322)]();return t?(t[s(1720)]=t[s(338)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(s){m[n(1298)](s)}function F(s){return{bytes:s,offset:0,limit:s.length}}function B(s){let t=n,r={EaikC:function(d,u){return e.eObad(d,u)}};if(e[t(1657)](e.JuQyF,t(1300)))KbKzKl[t(1192)](_0x207bd5,_0x31550c)&&_0x2b508b[t(452)](_0x185307,_0x22189);else{let d=s[t(521)],u=s[t(338)];return e[t(1025)](d.length,u)?d:d.subarray(0,u)}}function P(s,t){let r=n;if(e[r(455)]!==e[r(921)]){if(e.hImBa(s[r(1720)],t)>s[r(338)])throw new Error(r(832)+r(535));s[r(1720)]+=t}else e[r(1352)](_0xc6f088,_0x5da13e,66),e[r(1019)](_0x114a5f,_0x3513de,_0x10c64e.length),_0x521731(_0x508237,_0x43a54b)}function M(s){let t=n,r={bupEr:function(d,u){return e[W(289)](d,u)},NZmoB:function(d,u){return e[W(1372)](d,u)}};return e.jPGbc(e.AaUwZ,e.vaOdH)?(_0xa54cd0[t(461)](MKotpg.bupEr(_0x9066ab,this),_0x33ef11),MKotpg.NZmoB(_0x47ab9f,_0x436be0[t(999)](this))):e[t(434)](s[t(1720)],s[t(338)])}function U(s,t){let r=n,d=s.bytes,u=s[r(1720)],l=s[r(338)],_=u+t;if(e[r(1135)](_,d[r(754)]))if(e[r(443)]!==e[r(990)]){let w=new Uint8Array(e[r(1664)](2,_));w.set(d),s[r(521)]=w}else _0x336cb1&&_0x154a91.addEventListener(mmmSXp.mgeEP,()=>_0x2dc569()),_0x3d88d1&&_0x37d768["addEvent"+r(1282)](mmmSXp[r(1734)],()=>_0x5a1836());return s[r(1720)]=_,e[r(755)](_,l)&&(s.limit=_),u}function J(s,t){let r=n,d=s.offset;if(e[r(505)](d,t)>s[r(338)])throw new Error(r(1580)+r(535));return s.offset+=t,d}function ne(s,t){let r=n,d={gjpuh:function(u,l,_,w){return e[W(595)](u,l,_,w)},GGjeO:function(u,l,_){return e[W(1576)](u,l,_)},nBbwx:e[r(988)]};if(r(1076)===r(1076)){let u=e.cPgYw(J,s,t);return s.bytes[r(914)](u,e[r(1450)](u,t))}else try{d[r(1459)](_0x896dd8,this,_0x4615bb,[_0x48df1f,_0xa152fc,_0x4e16fd])}catch(u){let l=d.GGjeO(_0x1aa784,d.nBbwx,{message:u[r(464)],code:_0x15aab3[r(948)+"OR"],error:u});this[r(285)+r(483)+r(510)](l)}}function ae(s,t){let r=n,d=e.oWXzt(U,s,t[r(754)]);s[r(521)][r(452)](t,d)}function pe(s,t){let r=n,d=e[r(1188)](J,s,t),u=String[r(1416)+"Code"],l=s[r(521)],_="\uFFFD",w="";for(let h=0;e[r(714)](h,t);h++){let R=l[e[r(1677)](h,d)],N,L,q,G;e[r(1658)](128&R,0)?w+=u(R):e[r(1467)](224,R)===192?e[r(1541)](h,1)>=t?w+=_:(N=l[e.ASTnI(h,d)+1],e[r(780)](192&N,128)?w+=_:(G=e[r(656)](e[r(772)](31&R,6),e.gnDyO(63,N)),e[r(399)](G,128)?w+=_:(w+=e.FMMiz(u,G),h++))):e[r(1429)](e.MvfjA(240,R),224)?e[r(434)](e[r(968)](h,2),t)?w+=_:(N=l[h+d+1],L=l[e[r(1418)](e[r(1677)](h,d),2)],e[r(1493)]((N|e.NuUdj(L,8))&49344,32896)?w+=_:(G=e[r(738)](e[r(1096)](e[r(1467)](15,R),12),e.BMVvy(e.MvfjA(63,N),6))|e.gnDyO(63,L),e[r(714)](G,2048)||G>=55296&&e.DagJo(G,57343)?w+=_:(w+=e[r(347)](u,G),h+=2))):e.xPrKC(e[r(1032)](248,R),240)?e.wgTFj(e[r(1099)](h,3),t)?w+=_:(N=l[e[r(1677)](h,d)+1],L=l[e.xqmii(e.lrXjK(h,d),2)],q=l[h+d+3],e[r(1507)](e[r(1467)](e[r(656)](e[r(437)](N,e[r(820)](L,8)),e[r(772)](q,16)),12632256),8421504)?w+=_:(G=e[r(437)](e[r(738)](e[r(766)](e[r(1749)](7,R),18),e[r(820)](63&N,12)),e[r(647)](e[r(953)](63,L),6))|e[r(883)](63,q),G<65536||e[r(1194)](G,1114111)?w+=_:(G-=65536,w+=e[r(601)](u,e[r(484)](e.WRnFC(G,10),55296),e[r(1292)](e[r(1749)](1023,G),56320)),h+=3))):w+=_}return w}function Ie(s,t){let r=n,d=t.length,u=0;for(let w=0;w<d;w++){let h=t[r(450)+"At"](w);h>=55296&&h<=56319&&e.TYgVa(w+1,d)&&(h=e[r(1593)](e[r(688)](e.CYfYZ(h,10),t[r(450)+"At"](++w)),56613888)),u+=e[r(308)](h,128)?1:e[r(714)](h,2048)?2:e[r(714)](h,65536)?3:4}e[r(1019)](V,s,u);let l=e[r(878)](U,s,u),_=s[r(521)];for(let w=0;e[r(399)](w,d);w++){let h=t[r(450)+"At"](w);e.wgTFj(h,55296)&&e[r(1630)](h,56319)&&e[r(714)](e[r(1292)](w,1),d)&&(h=e.eNcmm(e.UuDVb(h,10)+t[r(450)+"At"](++w),56613888)),e.bprwJ(h,128)?_[l++]=h:(e[r(308)](h,2048)?_[l++]=e[r(437)](e[r(1114)](e[r(884)](h,6),31),192):(e.EjuNm(h,65536)?_[l++]=e[r(738)](e[r(758)](e.WRnFC(h,12),15),224):(_[l++]=e[r(392)](e[r(1357)](e.FuWph(h,18),7),240),_[l++]=e[r(1202)](e[r(1261)](h>>12,63),128)),_[l++]=e[r(760)](e[r(1199)](h,6)&63,128)),_[l++]=e[r(1202)](e.eEGBL(63,h),128))}}function Fe(s,t){let r=n,d=e[r(733)](U,s,t[r(338)]),u=s.bytes,l=t.bytes;for(let _=0,w=t[r(338)];e[r(399)](_,w);_++)u[e[r(1229)](_,d)]=l[_]}function Ee(s){let t=n;return s.bytes[e[t(1424)](J,s,1)]}function at(s,t){let r=n,d=e[r(1215)](U,s,1);s[r(521)][d]=t}function me(s){let t=n;if(e[t(1657)](e.dfybv,"HgeYT"))_0x4fa7af=_0x3fa3e4[t(281)](_0x1b937b),_0x111012=_0x3cae9d[t(281)](_0x5dd546[_0x24609b]);else{let r=0,d=0,u;do u=e.GbijJ(Ee,s),e[t(816)](r,32)&&(d|=e[t(1209)](e[t(692)](127,u),r)),r+=7;while(128&u);return d}}function V(s,t){let r=n;for(t>>>=0;e.KIlIk(t,128);){if(e[r(433)]===e.AicUK)return _0x2344ad[r(1648)+"oreNames"]||_0x2110bc[r(999)](_0x5cadd0);e[r(673)](at,s,e[r(392)](e.fvYhW(127,t),128)),t>>>=7}at(s,t)}function Pt(s,t){let r=n,d={yGONZ:function(u,l){return e[W(1626)](u,l)},wWxsc:function(u,l){return e.vKJrE(u,l)},aYAsl:function(u,l){return e.sFkQQ(u,l)},vehIX:function(u){return e.kjDGZ(u)}};if(e[r(1015)](e.bYRDK,r(1708)))return _0x456755[r(605)](_0x40b438)||(_0x10a9d5=_0x244daa[r(1622)+"er"](_0x12bb13)),this[r(1478)]!==_0x15f7b4[r(1478)]&&d[r(1376)](this[r(1430)],31)===1&&d.wWxsc(_0x363f4a[r(1430)],31)===1?!1:d[r(1650)](this[r(1430)],_0x4558ac.high)&&this[r(1164)]===_0x5538ec[r(1164)];{let u=0,l=0,_=0,w;if(w=e[r(1208)](Ee,s),u=127&w,e.gnDyO(128,w)&&(w=e.ssQtW(Ee,s),u|=e[r(1625)](e[r(662)](127,w),7),e.gnDyO(128,w)&&(w=e[r(856)](Ee,s),u|=e[r(772)](e[r(1551)](127,w),14),e[r(1114)](128,w)&&(w=Ee(s),u|=e[r(820)](e[r(883)](127,w),21),e.LPRhI(128,w)))))if(e.NanhN!==r(1451))w=e[r(1245)](Ee,s),l=e[r(1467)](127,w),128&w&&(w=e[r(1208)](Ee,s),l|=e.czIkQ(e[r(1357)](127,w),7),e[r(1425)](128,w)&&(w=Ee(s),l|=e[r(647)](127&w,14),e[r(758)](128,w)&&(w=e.KXtgB(Ee,s),l|=e[r(1625)](e.LPRhI(127,w),21),e.mzIQo(128,w)&&(w=e[r(1709)](Ee,s),_=127&w,e[r(628)](128,w)&&(w=e[r(574)](Ee,s),_|=e[r(772)](127&w,7))))));else{let h=tduZwN[r(1024)](_0x160c9e);return _0x18f9aa(_0xc2621f,h),_0x573b8e(h)}return{low:e[r(1202)](u,e[r(766)](l,28)),high:e[r(1443)](e[r(1626)](l,4),e[r(849)](_,24)),unsigned:t}}}function he(s,t){let r=n;if(e[r(873)](r(791),e[r(1180)])){let d=e[r(1626)](t[r(1164)],0),u=e[r(1631)](e[r(789)](e[r(1631)](t.low,28),t.high<<4),0),l=t[r(1430)]>>>24,_=l===0?e[r(879)](0,u)?d<16384?e.GIBGH(d,128)?1:2:e[r(1316)](d,2097152)?3:4:e.WvZHg(u,16384)?e[r(399)](u,128)?5:6:e[r(308)](u,2097152)?7:8:l<128?9:10,w=e[r(467)](U,s,_),h=s.bytes;switch(_){case 10:h[e[r(1292)](w,9)]=e[r(1631)](l,7)&1;case 9:h[e[r(1677)](w,8)]=e.rNTrU(9,_)?128|l:e[r(891)](127,l);case 8:h[e.xqmii(w,7)]=_!==8?e[r(977)](e.PXABP(u,21),128):e[r(662)](e[r(346)](u,21),127);case 7:h[e[r(687)](w,6)]=_!==7?u>>>14|128:e[r(919)](u>>>14,127);case 6:h[e[r(1229)](w,5)]=_!==6?e.BLNtt(u>>>7,128):e[r(953)](e[r(1631)](u,7),127);case 5:h[e[r(1733)](w,4)]=_!==5?e[r(760)](128,u):e[r(1186)](127,u);case 4:h[e[r(687)](w,3)]=e[r(426)](4,_)?e[r(437)](e[r(541)](d,21),128):e[r(1127)](d>>>21,127);case 3:h[e[r(713)](w,2)]=_!==3?e[r(541)](d,14)|128:e[r(952)](e[r(541)](d,14),127);case 2:h[e[r(1229)](w,1)]=_!==2?e[r(760)](d>>>7,128):e[r(662)](d>>>7,127);case 1:h[w]=_!==1?e[r(760)](128,d):e.fPEHY(127,d)}}else this[r(500)](e[r(1441)],e[r(860)](_0x3b755e,e[r(1441)],{..._0x4801e5,data:_0x43c9a5[r(1345)]||""}))}function kt(s){let t=n;if(e[t(1609)](e.OckHw,e.OckHw)){let r=e.qUToD(_0x5b246b,_0x995ee5,1);_0x1e5e2a.bytes[r]=_0x388ad7}else return e[t(1330)](b,s)}function Ne(s){return e[n(588)](A,s)}let Ss=65536,W0=e[n(715)],Nt=e.nhPdY(Ss,Ss),Is=e[n(1146)](Nt,Nt),Cs=e[n(732)](Is,2),ct=String[n(767)+"e"].charCodeAt;class re{constructor(t,r,d){let u=n;this[u(605)]=!0,this[u(1164)]=e[u(392)](0,t),this[u(1430)]=e[u(437)](0,r),this[u(1478)]=!!d}static isLong(t){let r=n;return t&&e[r(1015)](!0,t[r(605)])}static[n(589)](t,r,d){return new re(t,r,d)}static fromBytes(t,r,d){let u=n;return d?re[u(1408)+"sLE"](t,r):re[u(1408)+u(1393)](t,r)}static fromBytesLE(t,r){let d=n;return new re(e.PcAyP(e[d(738)](t[0],e[d(593)](t[1],8)),e[d(653)](t[2],16))|e[d(319)](t[3],24),e[d(789)](t[4],e[d(1258)](t[5],8))|e.KCHcv(t[6],16)|t[7]<<24,r)}static[n(1408)+n(1393)](t,r){let d=n;return new re(e.YTtNf(e[d(437)](e[d(700)](t[4],24),t[5]<<16)|e[d(1302)](t[6],8),t[7]),e[d(846)](e.ImZip(e[d(700)](t[0],24),t[1]<<16),e[d(849)](t[2],8))|t[3],r)}static[n(1269)](t){let r=n;return e.VpFTw(t,W0)?As:new re(e.wgEvc(e.awqkX(e[r(656)](ct[r(607)](t,0)|e[r(849)](ct[r(607)](t,1),8),e.jLubx(ct[r(607)](t,2),16)),e.yZInN(ct[r(607)](t,3),24)),0),e[r(1137)](e.ndjNF(e[r(437)](e[r(633)](ct[r(607)](t,4),e[r(1209)](ct.call(t,5),8)),ct[r(607)](t,6)<<16),e[r(1744)](ct.call(t,7),24)),0),!0)}[n(788)](){let t=n;return String[t(1416)+t(1166)](255&this[t(1164)],e[t(692)](this[t(1164)]>>>8,255),e.nEoWV(this[t(1164)],16)&255,this[t(1164)]>>>24,e[t(758)](255,this.high),e[t(499)](e.kSIqW(this.high,8),255),e[t(742)](e[t(958)](this[t(1430)],16),255),e.nEoWV(this[t(1430)],24))}static[n(1622)+"er"](t,r=!0){let d=n;if(e[d(1004)](isNaN,t))return r?J0:As;if(r){if(e[d(986)](t,Is))return V0}else{if(t<=-Cs)return Z0;if(e[d(379)](t,1)>=Cs)return $0}return re.fromBits(e.tQOUd(e.vzzPL(t,Nt),0),e[d(1550)](t,Nt)|0,r)}[n(1195)](){let t=n,r={HNeuV:function(d,u){return e[W(1724)](d,u)},qFFCz:e[t(783)]};if(e[t(1634)]===e[t(1634)])return this[t(1478)]?e[t(687)](e[t(1616)](this[t(1430)]>>>0,Nt),e[t(575)](this.low,0)):e[t(1179)](e[t(1146)](this[t(1430)],Nt),e.jpbDw(this[t(1164)],0));{let d=_0x443832[t(1720)];if(wJdnIi.HNeuV(d,_0x4c3f22)>_0x1b9761[t(338)])throw new _0x1a6f91(wJdnIi[t(1738)]);return _0x1cc958[t(1720)]+=_0x1a8e77,d}}[n(314)](){let t=n;return e[t(1178)](0,this[t(1430)])&&this[t(1164)]===0}[n(1590)](t){let r=n;re[r(605)](t)||(t=re[r(1622)+"er"](t));let d=e[r(1701)](this[r(1430)],16),u=e[r(1440)](65535,this[r(1430)]),l=e.qCbJW(this[r(1164)],16),_=e[r(1328)](65535,this[r(1164)]),w=e[r(966)](t[r(1430)],16),h=e[r(919)](65535,t.high),R=e[r(398)](t[r(1164)],16),N=e[r(883)](65535,t[r(1164)]),L=0,q=0,G=0,Q=0;return Q+=e[r(1271)](_,N),G+=e[r(1423)](Q,16),Q&=65535,G+=e[r(1089)](l,R),q+=e[r(1565)](G,16),G&=65535,q+=e.pKYea(u,h),L+=e[r(1034)](q,16),q&=65535,L+=e[r(1292)](d,w),L&=65535,re[r(589)](e[r(838)](e[r(1196)](G,16),Q),e[r(1413)](L,16)|q,this[r(1478)])}[n(1585)](t){let r=n;return re[r(605)](t)||(t=re[r(1622)+"er"](t)),this[r(1478)]!==t[r(1478)]&&e.RHxAQ(this[r(1430)],31)===1&&e[r(844)](t[r(1430)],31)===1?!1:e[r(1178)](this[r(1430)],t[r(1430)])&&e[r(879)](this[r(1164)],t[r(1164)])}[n(1540)](){let t=n;return this[t(1164)]===-1&&e[t(1213)](-1,this[t(1430)])?re[t(589)](0,0,this[t(1478)]):e[t(1657)](-1,this.low)?re[t(589)](0,e[t(713)](this[t(1430)],1),this.unsigned):re.fromBits(e[t(736)](this[t(1164)],1),this.high,this[t(1478)])}toBytes(t){return t?this.toBytesLE():this[n(928)+"E"]()}toBytesLE(){let t=n,r=this[t(1430)],d=this[t(1164)];return[255&d,e.mjLUE(d>>>8,255),e.jhYOK(e.gexrv(d,16),255),e[t(1530)](d,24),e[t(941)](255,r),e[t(1467)](r>>>8,255),e[t(1293)](e[t(799)](r,16),255),e.PJPyJ(r,24)]}toBytesBE(){let t=n,r=this[t(1430)],d=this[t(1164)];return[e[t(1743)](r,24),e[t(941)](e[t(1183)](r,16),255),e[t(1551)](e[t(861)](r,8),255),e.wMinq(255,r),e[t(1250)](d,24),e[t(1186)](d>>>16,255),e.jhYOK(d>>>8,255),e[t(1703)](255,d)]}}let As=new re(0,0,!1),J0=new re(0,0,!0),$0=re[n(589)](-1,2147483647,!1),V0=re.fromBits(-1,-1,!0),Z0=re[n(589)](0,-2147483648,!1);var dt=(function(s){let t=n;return s[s[e[t(721)]]=5001]="NATIVE_E"+t(1635),s[s["CONNECTI"+t(1337)]=5002]=t(1674)+t(1337),s[s[e[t(1040)]]=5003]=t(1090)+t(1567)+"R",s[s[e.oJPLJ]=5004]=e[t(1628)],s[s[t(948)+"OR"]=5005]=e[t(1538)],s})({});class Rt{constructor(t){let r=n;this[r(729)]=t,this.target=null}}class Ts extends Rt{constructor(t,r){let d=n;super(t),this[d(464)]=r&&r[d(464)]||null}}class Ds extends Rt{constructor(t,r){let d=n,u=e[d(423)][d(1296)]("|"),l=0;for(;;){switch(u[l++]){case"0":this[d(942)]=r&&r.colno||0;continue;case"1":this[d(824)]=r&&r[d(824)]||0;continue;case"2":this[d(1728)]=r&&r[d(1728)]||"";continue;case"3":this[d(1335)]=r&&r[d(1335)]||5001;continue;case"4":super(t);continue;case"5":this[d(464)]=r&&r.message||"";continue;case"6":this[d(1722)]=r&&r[d(1722)]||null;continue}break}}}class Ps extends Rt{constructor(t,r){let d=n,u="1|4|0|2|3".split("|"),l=0;for(;;){switch(u[l++]){case"0":this.reason=r&&r[d(689)]||"";continue;case"1":super(t);continue;case"2":this[d(1662)]=r&&r[d(1662)]||!1;continue;case"3":this[d(1747)+"nnect"]=r&&r[d(1747)+d(1048)]||!1;continue;case"4":this[d(1335)]=r&&r[d(1335)]||0;continue}break}}}class ks extends Rt{constructor(t,r){let d=n;super(t),this[d(317)]=r&&r.data||null}}class Ns extends ks{constructor(t,r){let d=n;super(t),this[d(317)]=r&&r.data||null,this[d(464)]=r&&r.message||null}}class Rs extends Rt{constructor(t,r){let d=n;super(t),this[d(317)]=r&&r[d(317)]||null}}function Me(s,{message:t,code:r,error:d}){return new Ds(s,{message:t,code:r,error:d})}function Ue(s,{code:t,reason:r,wasClean:d,willReconnect:u}){let l=n;if(e.zlalC(e.YQLgy,l(1344)))_0x42bf43+=_0x2c6755(_0x56d1d4),_0x1bb6c6++;else return new Ps(s,{code:t,reason:r,wasClean:d,willReconnect:u})}function Ls(s,{data:t,message:r}){return new Ns(s,{data:t,message:r})}function Os(s,{data:t}){return new Rs(s,{data:t})}function Yr(s,{message:t}){let r=n,d={PkheT:function(u,l){return u*l},rfJHs:function(u,l){return e[W(1080)](u,l)}};if(e[r(1123)](e.bBaTv,e[r(704)])){let{initReconnectInterval:u,maxReconnectInterval:l,reconnectIntervalGrowFactor:_}=this[r(564)],w=d[r(852)](u,_0x325c66.pow(_,d[r(1191)](_0x276d87,1)));return w>l?l:w}else return new Ts(s,{message:t})}class Ms{constructor(t,r){let d=n;this.endpoints=t,this.maxRetries=r,this[d(1687)+d(1140)]=0,this[d(855)+d(389)+d(749)+"t"]=0}[n(1242)+n(1235)+n(1379)](){let t=n;this[t(1687)+t(1140)]=0,this[t(855)+"ndpointT"+t(749)+"t"]=0}[n(693)+"es"](){let t=n;this[t(855)+"ndpointTriesCount"]=0}["getCurre"+n(380)+"nt"](){let t=n;return this[t(932)+"s"][this[t(1687)+"ndex"]]}[n(1290)+"ntEndpoi"+n(898)+n(1727)](){let t=n;return this[t(855)+"ndpointT"+t(749)+"t"]}[n(1050)+n(313)+"es"](){let t=n;if(e[t(706)]!==e[t(1275)])return!!(e[t(463)](this["currentI"+t(1140)],this[t(932)+"s"].length)||e[t(1213)](this[t(1687)+t(1140)],e[t(1593)](this[t(932)+"s"][t(754)],1))&&this[t(855)+t(389)+t(749)+"t"]===this[t(1371)+"es"]);this["_binaryT"+t(345)]=_0x4bfbed,this[t(864)]&&(this._ws[t(1305)+"pe"]=_0x5b5684)}[n(1320)+n(806)+n(606)+n(456)+n(453)](){let t=n;return e[t(1429)](this[t(1687)+t(1140)],this[t(932)+"s"][t(754)])?!0:this["currentE"+t(389)+t(749)+"t"]>this[t(1371)+"es"]}[n(526)+"ackupEndpointAnd"+n(302)+n(774)](){let t=n;if(e.xXQrx(t(1586),e[t(965)]))_0x19cedc=_0x3af29d(_0x379dfa),_0x3a513e|=e[t(1744)](e[t(1177)](127,_0x3a269c),21),e[t(1127)](128,_0x3364b6)&&(_0x56fd39=_0x1624fb(_0x32391d),_0x2514bf=127&_0x4bf346,e[t(546)](128,_0x4c0aab)&&(_0xcac40e=e[t(460)](_0x32ed05,_0x19e87f),_0x568256|=e[t(1196)](e.ZOmEG(127,_0xe5a466),7)));else return this[t(855)+t(389)+"riesCount"]=1,this["currentI"+t(1140)]++,this[t(932)+"s"][this[t(1687)+t(1140)]]}["getCurre"+n(380)+"ntAndUpd"+n(669)](){let t=n;return this[t(855)+t(389)+t(749)+"t"]++,this["getCurre"+t(380)+"nt"]()}}let Lt=(e[n(1640)]!=typeof globalThis&&n(1600)===globalThis[n(507)+n(291)][n(1075)]||e[n(1169)](e[n(1640)],typeof window)&&e[n(1474)](e[n(770)],window.constructor[n(1075)]))&&e[n(1049)](e[n(1640)],typeof document),yt=e[n(936)](e[n(1640)],typeof globalThis)&&(e.uTAXd(n(1251),globalThis[n(507)+"tor"].name)||e.HHdpm(e[n(371)],globalThis[n(507)+"tor"].name))&&e[n(366)](n(1285)+"d",typeof tt),on=(e[n(1514)](e.hAIfV,typeof globalThis)&&e[n(1675)](e[n(496)],globalThis["construc"+n(291)][n(1075)])||e[n(1136)](e.hAIfV,typeof globalThis)||e[n(922)](e[n(1640)],typeof globalThis)&&!!globalThis[n(1129)+"Bridge"])&&e.xRNPN(n(1285)+"d",typeof wx),an=e[n(648)](e[n(1640)],typeof globalThis)&&(e.Polhm(e.jDLMU,globalThis[n(507)+n(291)][n(1075)])||e[n(1384)](n(929)+n(549)+n(602),globalThis["construc"+n(291)].name)||e[n(781)](e[n(716)],globalThis["construc"+n(291)][n(1075)]))&&e.KeQhs(e.hAIfV,typeof self),Y0=e[n(1350)]("undefined",typeof globalThis)&&e[n(374)](e[n(496)],globalThis[n(507)+n(291)][n(1075)])&&e[n(518)](e[n(1640)],typeof global)&&e[n(663)](e[n(496)],global[n(507)+"tor"].name)&&e[n(438)](e.hAIfV,typeof process)&&!!process[n(498)];class Xr{constructor(){let t=n;this[t(1614)+"rs"]={}}[n(500)](t,...r){let d=n,u=this._listeners[t];if(u)u[d(1221)]()[d(1297)](l=>l.fn[d(461)](l[d(297)],r));else if(e[d(481)](e.xuMYq,t)&&!this.onerror){let l=r.length&&r[0];if(e[d(1252)](l,Error))throw l;let _=new Error(e[d(688)](d(1118)+d(1272),l?e[d(1349)](e[d(1541)](" (",l[d(464)]),")"):""));throw _[d(1446)]=l,l}return this}[n(1248)](t,r){let d=n;if(e[d(1061)](void 0,t))this[d(1614)+"rs"]={};else if(e[d(374)](void 0,r))this[d(1614)+"rs"][t]=null;else{let u=this._listeners[t];if(u)for(let l=0;e[d(441)](l,u.length);)u[l].fn===r?u.splice(l,1):++l}return this}on(t,r,d){let u=n;return(this[u(1614)+"rs"][t]||(this[u(1614)+"rs"][t]=[])).push({fn:r,ctx:d||this}),this}}class X0 extends Xr{[n(542)+n(329)+"age"](t){let r=n;if(e[r(530)]===e[r(530)])return t[r(1345)]||t[r(373)]?(r(899)+" "+(t[r(1345)]||"")+r(1532)+(t[r(373)]||""))[r(925)]():JSON[r(1588)+"y"](t);this._DBName=_0xee132b,this[r(353)]=_0x384bcd,this[r(1469)]=_0x4d3e1e?_0x3c8f08:_0x3f8575?_0x54a635:null}constructor(t,r,d){let u=n;super(),this[u(1318)]=null,on&&wx[u(1193)+u(406)]&&(this._socket=wx[u(1193)+"ocket"]({url:t,protocols:r,header:d,fail:this[u(821)+u(1619)+u(917)].bind(this),success:this["_createSocketSuc"+u(1342)+u(446)].bind(this)})),yt&&tt[u(1193)+"ocket"]&&(this[u(1318)]=tt[u(1193)+u(406)]({url:t,protocols:r,header:d,fail:this["_createSocketFai"+u(917)][u(355)](this),success:this[u(821)+u(1545)+"cessHandler"][u(355)](this)}))}[n(821)+n(1545)+n(1342)+n(446)](){let t=n;Promise.resolve()[t(1717)](()=>{this[t(712)+"steners"]()})}[n(821)+n(1619)+n(917)](t){let r=n;Promise[r(923)]()[r(1717)](()=>{let d=r,u=e[d(1456)](Me,e.xuMYq,{message:this[d(542)+"rrorMess"+d(1465)](t)});this[d(500)](d(1722),u);let l=e.mVvnS(Ue,e[d(866)],{reason:this[d(542)+"rrorMess"+d(1465)](t)});this[d(500)](e[d(866)],l)})}["_addWsLi"+n(1051)](){let t=n,r={ftYPH:function(d,u){return e[W(1322)](d,u)},NzsSI:e.qnJgF,rcuHM:e[t(1441)],AMxjE:function(d,u,l){return e[t(1354)](d,u,l)}};this._socket[t(637)](d=>{let u=t;r.ftYPH(r[u(1721)],"MRVEr")?this[u(500)](r[u(950)],r[u(836)](Os,r[u(950)],{...d,data:d[u(1345)]||""})):_0x498abd.resolve()[u(1717)](()=>{let l=u;this[l(712)+l(1051)]()})}),this[t(1318)][t(384)](d=>{let u=t;this[u(500)](e.mgeEP,e[u(808)](Ue,u(661),{...d}))}),this[t(1318)][t(1537)+"e"](d=>{let u=t;this[u(500)](e[u(1343)],e.TmRLH(Ls,e[u(1343)],{...d}))}),this[t(1318)][t(321)](d=>{let u=t;this.emit(e.xuMYq,e[u(1352)](Me,e[u(988)],{...d,message:d.errMsg||""}))})}[n(1190)](t){let r=n,d={jWSPU:e[r(988)],plkFy:function(u,l,_){return e[r(654)](u,l,_)},WiQPH:function(u,l){return e.mRDqA(u,l)},lkswV:function(u,l){return e[r(514)](u,l)},UXyfF:function(u,l,_){return u(l,_)}};if(e[r(1072)](e[r(1382)],e[r(1382)]))if(e[r(1252)](t,Uint8Array)){let u=t[r(1056)].slice(t[r(1603)+"et"],e[r(1089)](t[r(381)+"th"],t[r(1603)+"et"]));this[r(1318)]&&this[r(1318)][r(1190)]({data:u,fail:l=>{let _=r;this[_(500)](d[_(1488)],d[_(1098)](Me,d[_(1488)],{message:this[_(542)+_(329)+_(1465)](l)}))}})}else this._socket&&this[r(1318)][r(1190)]({data:t,fail:u=>{let l=r,_={NJwoG:function(w,h){return d.WiQPH(w,h)},EyKun:function(w,h){return w+h}};if(d[l(750)]("OIYrU","OIYrU"))this.emit(d[l(1488)],d[l(652)](Me,l(1722),{message:this[l(542)+l(329)+"age"](u)}));else{let h=""+_0x5ebed4[l(1597)](),R=_0x34c4f6||(_0x4da864=WfOsWF[l(825)](_0xd76da0,_0x17897c)),N=_0x25d5f1.random()[l(475)](16)[l(1221)](-6);return WfOsWF[l(517)](WfOsWF[l(517)]("02",h),R)+N}}});else return e[r(1429)](r(1e3),typeof _0x2333e1)?e[r(1366)]:""}[n(661)](t,r){let d=n;this[d(1318)]&&this._socket[d(661)]({code:t,reason:r})}[n(1693)+"Listener"](t,r){let d=n;d(1181)===d(1181)?this.on(t,r):this[d(564)][d(985)]&&_0x3bb8ee.log[d(461)](_0x1e5880,[e[d(470)],..._0x5adaae])}[n(913)+"entListe"+n(1353)](t,r){this.off(t,r)}get readyState(){let t=n;return this[t(1318)][t(962)+"te"]}get[n(1305)+"pe"](){let t=n;return this._socket[t(1305)+"pe"]}set binaryType(t){}get url(){let t=n;return this[t(1318)][t(1661)]}get[n(311)](){let t=n;return this[t(1318)][t(311)]}get[n(1232)+"ns"](){let t=n;return this[t(1318)][t(1232)+"ns"]}get[n(1670)+n(1351)](){return 0}}function Q0(s,t){let r=n;if(t)return new t(s[r(1661)],s[r(311)]);if(e[r(1740)](on,yt))return new X0(s[r(1661)],s[r(311)],s.headers);if(e[r(1740)](Lt,an)&&e[r(1049)](r(1285)+"d",typeof WebSocket)&&WebSocket)return new WebSocket(s[r(1661)],s[r(311)+"s"])}function ed(s){let t=n,r=e[t(667)][t(1296)]("|"),d=0;for(;;){switch(r[d++]){case"0":return!1;case"1":if((Lt||an)&&e[t(1741)](e[t(1640)],typeof WebSocket)&&WebSocket)return!0;continue;case"2":if(on&&wx[t(1193)+t(406)])return!0;continue;case"3":if(s)return!0;continue;case"4":if(yt&&tt[t(1193)+t(406)])return!0;continue}break}}function Bs(s,t,r){let d=n,u={WBxSA:d(975)+"alled mu"+d(1735)+d(1171)+d(1257),IuRNL:function(w,h){return e[d(1072)](w,h)}},l=-1;async function _(w){let h=d;return w<=l?Promise[h(395)](new Error(u[h(1303)])):(l=w,u[h(1264)](w,r[h(754)])?Promise[h(923)]():r[w][h(355)](s)(t,_[h(355)](null,w+1)))}e[d(1330)](_,0)}function zs(s){let t=n,r=0,d=0;for(let u=0;e[t(816)](u,s.length);++u)d=s[t(450)+"At"](u),d<128?r+=1:e[t(617)](d,2048)?r+=2:e[t(1061)](64512&d,55296)&&e[t(296)](e[t(1440)](64512,s.charCodeAt(e[t(356)](u,1))),56320)?(++u,r+=4):r+=3;return r}function Fs(s,t,r){let d=n;if(e[d(280)](e[d(1243)](r,t),1))return"";let u="";for(let l=t;e[d(1730)](l,r);){let _=s[l++];if(e[d(1400)](_,127))u+=String.fromCharCode(_);else if(_>=192&&e[d(441)](_,224))u+=String[d(1416)+d(1166)](e.ndjNF(e[d(1018)](e[d(952)](31,_),6),e[d(804)](63,s[l++])));else if(e[d(463)](_,224)&&e.aNaes(_,240))u+=String[d(1416)+"Code"](e[d(1172)](e[d(499)](15,_),12)|e[d(1096)](63&s[l++],6)|e[d(1425)](63,s[l++]));else if(e[d(525)](_,240)){let w=e[d(309)](e[d(846)](e[d(392)](e[d(1621)](7,_)<<18,e[d(906)](e[d(556)](63,s[l++]),12)),e[d(700)](e[d(444)](63,s[l++]),6)),63&s[l++])-65536;u+=String[d(1416)+d(1166)](e[d(1666)](55296,e[d(1199)](w,10))),u+=String[d(1416)+"Code"](e[d(892)](56320,e[d(1100)](1023,w)))}}return u}function Qr(s,t,r){let d=n,u=r,l,_;for(let w=0;w<s[d(754)];++w)if(l=s[d(450)+"At"](w),e[d(399)](l,128))t[r++]=l;else if(e.gihuH(l,2048))t[r++]=l>>6|192,t[r++]=e.HDqoL(63,l)|128;else if(e.Xiqpv(64512,l)===55296&&(64512&(_=s.charCodeAt(e.ysZHy(w,1))))===56320){let h=(d(947)+d(1288)).split("|"),R=0;for(;;){switch(h[R++]){case"0":t[r++]=e[d(760)](l>>18,240);continue;case"1":++w;continue;case"2":t[r++]=e[d(392)](e[d(1032)](e[d(1491)](l,6),63),128);continue;case"3":t[r++]=e[d(482)](e[d(1046)](63,l),128);continue;case"4":t[r++]=e.zbFBA(e[d(945)](e[d(1165)](l,12),63),128);continue;case"5":l=e[d(1557)](e[d(1647)](65536,e[d(1475)](e[d(1748)](1023,l),10)),e[d(742)](1023,_));continue}break}}else t[r++]=e.BLNtt(e[d(1491)](l,12),224),t[r++]=e[d(751)](e[d(1065)](e[d(884)](l,6),63),128),t[r++]=e[d(327)](e[d(737)](63,l),128);return e[d(1314)](r,u)}async function Us(s){let t=n;if(e[t(1429)](t(1e3),typeof s)){let r=new Uint8Array(e[t(1112)](zs,s));return e[t(411)](Qr,s,r,0),r}return s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s[t(1056)],s[t(1603)+"et"],s[t(381)+"th"])}function td(s){let t=n;try{return e[t(1169)](e[t(664)],typeof s)&&(e[t(407)](s,ArrayBuffer)||s[t(1056)]&&e.KgneZ(s[t(1056)],ArrayBuffer))||e.qkbng(e[t(664)],typeof s)?"":(JSON[t(300)](s),t(611)+"ion/json")}catch{return e[t(664)]==typeof s?"text/pla"+t(1009)+t(1184):""}}let nd=(s,t)=>{let r=n;switch(s){case e.ndesr:case e[r(359)]:return{[r(1476)+s]:1,"x-tt-env":t};default:return{}}};class rd{constructor(t){let r=n;this[r(1383)+"ount"]=t,this[r(1356)]=0}[n(752)](){let t=n;this[t(1356)]++}[n(1050)+n(1060)+"nt"](){let t=n;return e[t(1739)](this[t(1356)],this[t(1383)+t(1727)])}[n(1517)+n(1152)](t=0){let r=n;this[r(1383)+"ount"]=t,this[r(1356)]=0}}async function id(s){let t={arjVz:function(r,d){return e[W(1053)](r,d)},Psxgx:e.MVFsv};return new Promise(r=>{let d=W;if(!Lt)return e[d(1022)](r,e[d(711)]);try{let u=document[d(1676)+d(812)](e[d(1399)]);window[d(1620)+d(1360)]=l=>{let _=d;document[_(576)]["removeCh"+_(798)](u),window[_(1620)+_(1360)]=void 0,t[_(621)](r,l&&l[_(1653)]||t[_(590)])},u[d(729)]=e[d(1394)],u[d(1584)]=s.replace(/^ws/,e.nlbwz)+e[d(333)];try{document[d(576)][d(1116)+"ild"](u)}catch{document.body["removeCh"+d(798)](u)}}catch{window[d(1620)+d(1360)]=void 0,e[d(874)](r,e[d(711)])}})}function ft(s,t,r){let d=n;return!!s?.[d(1222)](u=>u.key===t&&u[d(1014)]===r)}function Ot(s,t){let r=n;if(r(378)===e[r(1387)])return s?.[r(1222)](d=>d[r(449)]===t)?.[r(1014)];_0x1d0e35[r(1453)+r(295)+"e"](_0x2d782e,{keyPath:_0x4b538e})}let ei=null;async function sd(){let s=n;return ei||(ei=Promise.resolve()[s(1717)](Ze[s(355)](Ze,e.Zcnil))),ei}class od extends Xr{constructor(t,r){let d=n;super(),this._dbName=t,this[d(847)]=r,this[d(1469)]=void 0,this[d(748)+d(1373)]=null}async[n(1108)](){await this._init()}async[n(939)](){let t=n;if(e[t(501)]("BzFVg",e[t(1203)])){if(this[t(1469)])return;if(this[t(748)+t(1373)])return this[t(748)+t(1373)];try{let r=this._dbName,d=this._keyPath;this[t(748)+t(1373)]=(async()=>{let u=t,{openDB:l}=await e[u(1642)](sd);this[u(1469)]=await e[u(595)](l,u(1620)+"_"+r,1,{upgrade(_){let w=u;_[w(1453)+w(295)+"e"](r,{keyPath:d})}})})(),await this._initPromise}catch(r){console[t(1526)](r)}finally{this["_initPro"+t(1373)]=null}}else this[t(864)]&&this[t(864)][t(661)](_0x447dab,_0x2003e8)}async[n(999)](t){let r=n;try{if(e[r(1566)]!==e.uZbLN)return await this[r(939)](),this[r(1469)]?.get(this[r(1309)],t);{this[r(626)+r(814)+"t"]();let d=e[r(809)](_0x3430c9,e[r(1660)],{message:r(292)+"ediately"+r(612)+"ct"});this[r(696)+"mediatelyReconnect"]&&this["onStopIm"+r(591)+"yReconnect"](d)}}catch(d){console[r(1526)](d)}}async[n(452)](t,r){let d=n;return await this[d(939)](),this[d(1469)]?.[d(332)](this[d(1309)],t)}async[n(1311)](t){let r=n,d={OEFNA:function(u,l){return e.CySQn(u,l)},cnKZn:e[r(1091)],rSSNZ:r(1410)+"e_success"};if(e[r(873)](e.Vwtbw,r(1562)))d[r(339)](_0x3e9f97,d.cnKZn),this[r(1248)](d.rSSNZ,_0x1fc8ab),this[r(1248)](r(1410)+"e_timeout",_0x5eac72);else try{return await this[r(939)](),this[r(1469)]?.[r(1205)](this._dbName,t)}catch(u){console[r(1526)](u)}}async clear(){let t=n;if(e[t(1658)](e[t(478)],t(833)))try{return await this[t(939)](),this[t(1469)]?.[t(699)](this[t(1309)])}catch(r){console[t(1526)](r)}else this._ws&&this[t(864)].send(_0x4d8917),this[t(1512)](e[t(1694)],_0x4aaeea)}async[n(935)](){let t=n;return await this._init(),this[t(1469)]?.[t(810)+"ys"](this[t(1309)])}async getAll(){let t=n;return await this[t(939)](),this[t(1469)]?.getAll(this[t(1309)])}async closeDB(){let t=n;if(e.qwjNG(e[t(1092)],e[t(1500)]))try{this._qosDB?.[t(661)](),this._qosDB=void 0}catch(r){if(e.hwadr(e[t(427)],e[t(427)])){let d=0,u=0,l;do l=e.USSbb(_0x24c29f,_0x3b8a13),d<32&&(u|=e[t(1302)](e[t(957)](127,l),d)),d+=7;while(128&l);return u}else console.log(r)}else{if(!this[t(315)+t(1224)]()||this[t(391)+"osed"])return;this[t(972)+t(1719)]?.[t(1242)+t(1235)+"fig"](),this[t(694)+t(543)]?.[t(1517)+"nter"](),this[t(864)]?this[t(1525)+t(869)](1001,e[t(895)],!0):this[t(1389)]()}}get[n(349)](){let t=n;if(e[t(1507)](e[t(851)],e[t(851)])){let r=_0x45eabe[t(1296)](/\./)[t(826)](l=>_0x51abfe(l)),d=[];return d[0]=e[t(856)](_0x425913,e.NrqRy(r[0],r[1])),d[1]=e[t(1245)](_0xac6fb3,r[2]+r[3]),[e[t(1633)],"0000",e[t(1633)],e[t(1633)],e[t(1633)],e[t(400)],d[0],d[1]][t(643)]("")}else try{return!!this[t(1469)]}catch(r){return console[t(1526)](r),!1}}}class ad{constructor(t,r){let d=n;this[d(1431)]=t,this[d(353)]=r,this[d(1469)]=localStorage}async[n(1108)](){}get _prefix(){let t=n;return t(1620)+"_"+this[t(1431)]}async[n(999)](t){let r=n,d=this._qosDB[r(834)](this[r(1133)]);return JSON[r(300)](e[r(1740)](d,"{}"))[t]}async[n(452)](t,r){let d=n,u=this[d(1469)][d(834)](this[d(1133)]),l=JSON[d(300)](e[d(1740)](u,"{}"));return l[r||t[this[d(353)]]]=t,this[d(1469)].setItem(this._prefix,JSON[d(1588)+"y"](l)),r||t[this[d(353)]]}async del(t){let r=n,d=this[r(1469)][r(834)](this[r(1133)]),u=JSON[r(300)](e[r(1740)](d,"{}"));return u[t]=void 0,this[r(1469)].setItem(this[r(1133)],JSON[r(1588)+"y"](u))}async[n(699)](){let t=n;return this._qosDB[t(699)]()}async[n(935)](){let t=n;if(e[t(1732)]!==e[t(1732)])this["maxLossC"+t(1727)]=_0x5d4dc9,this.count=0;else{let r=this[t(1469)][t(834)](this[t(1133)]),d=JSON[t(300)](e.wzajB(r,"{}"));return Object[t(935)](d)}}async getAll(){let t=n,r=this[t(1469)][t(834)](this[t(1133)]),d=JSON[t(300)](e[t(1571)](r,"{}"));return Object[t(401)](d)}[n(943)](){return Promise.resolve()}get[n(349)](){return!!this[n(1469)]}}class cd{constructor(t,r){let d=n;this[d(1431)]=t,this[d(353)]=r,this[d(1469)]=yt?tt:on?wx:null}async[n(1108)](){}get[n(1133)](){let t=n;return t(1620)+"_"+this[t(1431)]}async[n(999)](t){let r=n,d=this._qosDB[r(1031)+"geSync"](this._prefix);return JSON[r(300)](d||"{}")[t]}async set(t,r){let d=n,u=this[d(1469)][d(1031)+d(650)](this._prefix),l=JSON[d(300)](e[d(1613)](u,"{}"));return l[r||t[this[d(353)]]]=t,this._qosDB[d(1058)+"geSync"](this[d(1133)],JSON[d(1588)+"y"](l)),r||t[this[d(353)]]}async[n(1311)](t){let r=n,d=this[r(1469)]["getStora"+r(650)](this._prefix),u=JSON[r(300)](e.ExsOZ(d,"{}"));return u[t]=void 0,this[r(1469)][r(1058)+r(650)](this[r(1133)],JSON[r(1588)+"y"](u))}async[n(699)](){let t=n;return this._qosDB[t(934)+t(1568)]()}async[n(935)](){let t=n,r=this[t(1469)].getStorageInfoSync(this[t(1133)]),d=JSON.parse(r||"{}");return Object[t(935)](d)}async[n(516)](){let t=n,r=this[t(1469)][t(1031)+"geInfoSync"](this[t(1133)]),d=JSON[t(300)](e[t(720)](r,"{}"));return Object[t(401)](d)}[n(943)](){return Promise[n(923)]()}get[n(349)](){return!!this._qosDB}}function qs(s,t){let r=n;if(e[r(1613)](yt,yt))return new cd(s,t);if(e[r(1571)](Lt,an)&&e[r(1741)](e.hAIfV,typeof indexedDB))return new od(s,t);if((Lt||an)&&e[r(1169)](e.hAIfV,typeof localStorage))return new ad(s,t);throw new Error(e[r(909)])}class dd{constructor(){let t=n;this._intervalTimeoutId=null,this._interval=36e5,this[t(1469)]=e[t(1363)](qs,t(1111),t(680)+"id")}async[n(1599)+n(582)](){let t=n;clearInterval(this["_interva"+t(679)+"Id"]),this[t(1599)+t(679)+"Id"]=e[t(1576)](setInterval,()=>{let r=t;this[r(1589)+r(572)]()},this[t(1599)+"l"])}async[n(1108)](){let t=n;await this[t(1469)].openDB()[t(1717)](()=>{let r=t,d={ZUwJG:function(u,l){return e[W(803)](u,l)},TAAEf:function(u,l){return e.ARhEH(u,l)},qaycZ:function(u,l){return u*l},ayfcb:function(u,l){return e[W(861)](u,l)}};if(e[r(1061)](r(424),r(424)))this[r(1599)+"lFlush"]();else return this.unsigned?yKxvzK.ZUwJG(yKxvzK.TAAEf(this.high,0)*_0x2b7b53,this[r(1164)]>>>0):yKxvzK[r(1132)](this[r(1430)],_0x2f8a7e)+yKxvzK[r(1542)](this[r(1164)],0)})}async[n(1589)+n(572)](){let t=n;e.VZBHE(e.qWUWx,t(1045))?(await this[t(1469)]?.[t(516)]()||[]).filter(({timestamp:u})=>u<Date[t(1597)]())[t(1297)](u=>{let l=t;this[l(1469)]?.[l(1311)](u[l(680)+"id"])}):(_0x5ca44e.frontierJSONP=void 0,e.aFZNb(_0x79ce8f,e[t(711)]))}async[n(1311)](t){return this[n(1469)]?.del(t)}async[n(452)](t,r){let d=n;return this[d(1469)]?.[d(452)]({message_id:t,timestamp:r})}async get(t){let r=n;return e[r(1375)](e[r(527)],e[r(527)])?this[r(1469)]?.get(t):e[r(1176)](-1,this[r(1164)])&&this[r(1430)]===-1?_0x436f79[r(589)](0,0,this.unsigned):e[r(1015)](-1,this[r(1164)])?_0x562a71.fromBits(0,this[r(1430)]+1,this[r(1478)]):_0x58e83f[r(589)](this[r(1164)]+1,this[r(1430)],this[r(1478)])}async[n(943)](){let t=n;e[t(651)](clearInterval,this[t(1599)+t(679)+"Id"]),await this[t(1469)]?.[t(943)]()}get[n(349)](){let t=n;return this._qosDB?.[t(349)]}}function ti(s){let t=n,r=!!this[t(564)][t(508)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=ft(s[t(464)].headers,e.sEnmL,"2"),u=d&&e[t(411)](ft,s[t(464)][t(610)],e[t(566)],"1"),l=d&&e.PgGUN(ft,s[t(464)][t(610)],e[t(740)],"1"),_=l?e.fMTbW(Ot,s[t(464)][t(610)],e[t(1439)])?.[t(1296)](",")[t(1289)](Boolean)||[]:[];return{enabled:r,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:l,ackMsgIds:_}}async function Hs(){let s=n;return this[s(890)+s(573)]||(this._QoSManager=new dd),this["_QoSMana"+s(573)][s(349)]||await this[s(890)+"ger"].openDB(),this[s(890)+"ger"]}async function fd(s,t){let r=n,{enableAutoAck:d}=this[r(564)],u=e[r(411)](ft,s[r(464)][r(610)],r(1286),"1"),l=e.mLPta(ft,s.message[r(610)],e.mKrBm,"1"),_=ti[r(607)](this,s);if(e[r(454)](d,u)){let{SeqID:w,LogID:h,service:R,LogIDNew:N,method:L}=s[r(464)];this[r(954)]({SeqID:w,LogID:h,LogIDNew:N,service:R,method:L,headers:[{key:e.mKrBm,value:"1"},{key:r(1338),value:e[r(868)](N,"")},{key:e[r(1378)],value:"0"}]})}l&&!_.isQoSAck&&this[r(285)+r(1145)+"ageEvent"](s),e[r(1642)](t)}async function ud(s,t){let r=n;this._debug(r(1669),s.message),e.yxbNa(t)}async function xd(s,t){let r=n,d=e.cxlzV(kt,await e[r(1247)](Us,s.data));try{if(e[r(1252)](d[r(741)],Uint8Array)){let u=this[r(564)][r(1683)+r(1522)]instanceof Object?{force:!!this._options[r(1683)+r(1522)][r(1686)],encoding:this._options[r(1683)+r(1522)].encoding?this[r(564)]["payloadE"+r(1522)][r(1010)][r(1528)](/\s/g,"")[r(1082)+r(1718)]():""}:{force:!1,encoding:this[r(564)][r(1683)+"ncoding"]?this[r(564)][r(1683)+r(1522)][r(1528)](/\s/g,"")[r(1082)+"ase"]():""},l=d[r(1683)+r(1522)]?d[r(1683)+r(1522)][r(1528)](/\s/g,"")[r(1082)+r(1718)]():"",_=e[r(407)](this._options[r(848)+r(345)],Object)?{force:!!this._options[r(848)+r(345)][r(1686)],type:this[r(564)][r(848)+r(345)][r(729)]?this[r(564)]["payloadT"+r(345)].type[r(1528)](/\s/g,"")[r(1082)+r(1718)]():""}:{force:!1,type:this._options[r(848)+r(345)]?this[r(564)]["payloadT"+r(345)].replace(/\s/g,"")["toLowerC"+r(1718)]():""},w=d["payloadT"+r(345)]?d[r(848)+"ype"][r(1528)](/\s/g,"")[r(1082)+"ase"]():"",h=_[r(1686)]?_[r(729)]:w||_[r(729)],R=u[r(1686)]?u[r(1010)]:l||u[r(1010)],N=[e[r(1366)],r(611)+r(1142),e[r(534)],e[r(664)]],L=[e.gSRRe,e[r(421)]];this._options[r(1623)+r(336)+r(1520)+"ad"]&&N[r(1307)](h)&&(!R||L[r(1307)](R))?d[r(1308)+"oad"]=Fs(d.payload,0,d[r(741)].byteLength):d[r(1308)+r(955)]=""}else d["textPayl"+r(955)]=""}catch(u){d["textPayl"+r(955)]="",console[r(1526)](u)}s[r(464)]=d,e.xRUMh(t)}function ld(s,t,r){let d=n,u={aSrZn:function(l,_){return l===_},Ttgdh:d(992),MYbfV:e[d(911)],PlPqV:function(l,_){return e[d(358)](l,_)},udArP:function(l,_){return e[d(1262)](l,_)},rxwtt:function(l,_){return e[d(1330)](l,_)},nMTEg:function(l,_){return e[d(646)](l,_)},btQWz:function(l,_){return e[d(687)](l,_)},EQeIP:function(l,_){return l|_}};if(e[d(1324)](e[d(782)],e.MPqzC)){let l=e[d(1613)](r,8192),_=e.RHxAQ(l,1),w=null,h=l;return function(R){let N=d;if(u[N(987)](u.Ttgdh,u[N(563)]))for(var L in _0x1ccf00)_0x1ac869.o(_0x18e305,L)&&!_0x220ec9.o(_0x581c6f,L)&&_0x5930c0[N(1690)+N(417)](_0xe19291,L,{enumerable:!0,get:_0xd0b318[L]});else{if(R<1||u[N(1246)](R,_))return u.udArP(s,R);u.PlPqV(h+R,l)&&(w=u[N(931)](s,l),h=0);let q=t[N(607)](w,h,h+=R);return u[N(1326)](7,h)&&(h=u[N(1572)](u[N(1233)](7,h),1)),q}}}else return this["_endpoin"+d(1719)]?.["getCurrentEndpoi"+d(898)+"ount"]()||0}let gd=4294967295;function hd(s,t,r){let d=n;return e[d(1256)](RangeError,e[d(1349)](e[d(414)](e[d(581)](e[d(687)](e[d(1636)],s),e[d(1481)]),e[d(435)](t,1))+e[d(1398)],r))}function pd(s,t,r){let d=n;if(e.bFAOf(r,gd))throw new Error(d(1276)+"too large");let u=3;for(;e.tZhqY(u,0);){let l=e[d(758)](255,r);e[d(411)](ri,l,s,e[d(815)](t,u)),r>>>=8,u--}return e.heKnx(t,4)}function md(s,t){let r=n,d=0,u=t,l=t+4;for(;u<l;){let{value:_,offset:w}=e[r(462)](ni,s,u);u=w,d=d<<8>>>0,d+=_}return{value:d,offset:l}}function wd(s,t,r){let d=n;return s?e[d(280)](s[d(754)],40)?e[d(354)](e[d(595)](Qr,s,t,r),r):t.utf8Write?e[d(1666)](t.utf8Write(s,r),r):t[d(409)]?e[d(1450)](t[d(409)](s,r),r):e.ZtUxQ(e[d(419)](Qr,s,t,r),r):r}function _d(s,t){let r=n,d=new re(e.PcAyP(s[e[r(713)](t,4)]<<24,e.Kjhpo(s[e[r(1428)](t,5)],16))|e[r(319)](s[e[r(609)](t,6)],8)|s[e[r(665)](t,7)],e[r(305)](e.cKEwS(e.MIsUf(s[e[r(1643)](t,0)],24),s[e[r(1731)](t,1)]<<16),e[r(820)](s[t+2],8))|s[e[r(354)](t,3)],!0);return t+=8,{value:d,offset:e[r(1666)](t,8)}}function yd(s,t,r){let d=n,u={SpKTz:function(l){return e[W(1642)](l)}};if(e[d(509)]("KOphF",d(439)))_0xe41adf(_0x536082(_0x1ea776.result)),LSjJHn.SpKTz(_0x357430);else{let l=s[d(1164)],_=s[d(1430)];return t[r]=_>>>24,t[r+1]=e[d(799)](_,16)&255,t[e.CPJjB(r,2)]=e[d(1579)](_,8)&255,t[e[d(887)](r,3)]=255&_,t[e.EddPi(r,4)]=e[d(1183)](l,24),t[e.XKsRu(r,5)]=e[d(957)](e[d(1422)](l,16),255),t[r+6]=e[d(616)](l,8)&255,t[e.CVsoC(r,7)]=e[d(662)](255,l),r+=8,r}}function ni(s,t){let r=n;return s[r(330)+"8"]?{value:s[r(330)+"8"](t),offset:e[r(881)](t,1)}:{value:255&s[t],offset:t+1}}function ri(s,t,r){let d=n;return t[d(717)+"t8"]?t[d(717)+"t8"](s,r):t[r]=e[d(896)](255,s),e[d(1705)](r,1)}let Ed=function(s){return new Uint8Array(s)},bd=e.xkwyQ(e[n(1640)],typeof Buffer)?Buffer[n(361)+n(624)]:ld(Ed,Uint8Array[n(767)+"e"][n(914)]);(()=>{let s=n;if(e[s(912)](e.LJueJ,e[s(1663)])){let t=4294967295;return function(r,d,u=!0){let l=s,_=e[l(1260)][l(1296)]("|"),w=0;for(;;){switch(_[w++]){case"0":if(e[l(903)](r[d++],128))return{value:u?t:e.fMMoe(0,t),offset:d};continue;case"1":if(r[d++]<128)return{value:u?t:e[l(305)](0,t),offset:d};continue;case"2":if(e[l(308)](r[d++],128))return{value:u?t:e[l(1281)](0,t),offset:d};continue;case"3":t=(t|e[l(1436)](e[l(1425)](127,r[d]),7))>>>0;continue;case"4":t=e[l(1460)](127&r[d],0);continue;case"5":t=e.PZjjo(t|e[l(1547)](e[l(1027)](15,r[d]),28),0);continue;case"6":t=e[l(633)](t,e[l(555)](127,r[d])<<21)>>>0;continue;case"7":if(e[l(1161)](d+=5,r[l(754)]))throw d=r.length,hd(d,10,r[l(754)]);continue;case"8":if(r[d++]<128)return{value:u?t:0|t,offset:d};continue;case"9":if(r[d++]<128)return{value:u?t:e[l(818)](0,t),offset:d};continue;case"10":return{value:u?t:0|t,offset:d};case"11":t=e[l(631)](t|e[l(886)](e.jtFyT(127,r[d]),14),0);continue}break}}}else{let t=!!se[s(564)][s(508)+"S"];if(!t)return{enabled:t,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let r=_0x4d5afc(_0x3f41fa[s(464)][s(610)],e.sEnmL,"2"),d=r&&_0x254de2(_0x5607b8[s(464)][s(610)],e[s(566)],"1"),u=r&&e[s(411)](_0x187389,_0x5a4a57.message[s(610)],e[s(740)],"1"),l=u?_0x38de98(_0x49b3d9.message[s(610)],e[s(1439)])?.split(",").filter(_0x5a2b9c)||[]:[];return{enabled:t,isQoSMessage:r,isQoSAck:d,isAckCleanupMessage:u,ackMsgIds:l}}})();let vd=16,ii=32;function Sd(s){let t=n,r=0,d={};for(let u=0;e[t(1042)](u,s[t(754)]);u++)d[s[u]["cursor_n"+t(658)]]=e[t(287)](zs,s[u][t(1665)+t(658)]),r+=14+d[s[u][t(1665)+"ame"]];return[r,d]}function Gs(s,t,r){let d=n,u={sCaZa:e[d(1038)],Fekfm:function(R,N,L,q){return e[d(595)](R,N,L,q)},GURkK:function(R,N,L,q){return R(N,L,q)},cDAKm:e[d(989)],VgIkS:function(R,N,L,q){return e[d(595)](R,N,L,q)},DJvWc:d(1075),Erthz:e[d(494)]},[l,_]=e[d(794)](Sd,s),w=e.CySQn(bd,l),h=0;return s[d(1297)](R=>{let N=d;console[N(1526)](u.sCaZa,R,R.service),h=u.Fekfm(ri,0,w,h),console[N(1526)]("header",h),h=u[N(761)](pd,w,h,R[N(893)]||0),console[N(1526)](u[N(307)],h),h=ri(_[R[N(1665)+N(658)]],w,h),console[N(1526)](N(858)+"name",h),h=u[N(1270)](wd,R[N(1665)+N(658)],w,h),console[N(1526)](u.DJvWc,h),h=u.Fekfm(yd,re[N(1622)+"er"](R.cursor||t),w,h),console.log(u[N(440)],h)}),{frameType:ii,headers:[{key:e[d(1570)],value:r}],payload:w}}function Id(s){let t=n,r=0,d=[];for(;e[t(724)](r,s.byteLength);){let{offset:u}=ni(s,r);r=u;let l={cursor_name:"",cursor:0,service:0},{value:_,offset:w}=e.iEyrg(md,s,r);l[t(893)]=_,r=w;let{value:h,offset:R}=e.zbbmC(ni,s,r);r=R,l["cursor_n"+t(658)]=e[t(411)](Fs,s,r,e.BHJMZ(r,h)),r+=h;let{value:N,offset:L}=_d(s,r);l.cursor=N.toNumber(),r=L,d.push(l)}return d}function Cd(){let s=n;return{frameType:ii,headers:[{key:e[s(1570)],value:e[s(1654)]}],payload:void 0}}class Ad{constructor(t,r,d){let u=n;if(e[u(451)](e.gjRVd,e[u(823)]))this[u(1244)+u(1220)]=t,this[u(1086)+u(428)]=r,this["_message"+u(1560)]=d,this[u(1469)]=e[u(1160)](qs,this._cursorNameSpace,e[u(1420)]);else{let l=_0x398a8a[_0x575285];if(e[u(1609)](4,_0x5e2ab7[_0x317a0e][u(754)])){let _=_0x53961f[u(885)+"g"](0,4-_0x397e94[_0x43615b].length),w=_[u(281)](l);_0x5be4ab=_0x52dc98[u(281)](w)}else _0x1a92d5=_0x1aa766[u(281)](l)}}async[n(1108)](){let t=n;await this[t(1469)][t(1108)]()}async getCursors(){let t=n;if(!this[t(1469)][t(349)])return;let r=this[t(1513)+t(1560)],d=await this[t(1469)][t(516)]();switch(console[t(1526)](e[t(971)],d),r){case e.Ctgmj:return d&&d[t(754)]?e.mLPta(Gs,d,0,this[t(1086)+"ileName"]):void 0;case e[t(1304)]:return;case e[t(304)]:return d&&d.length?e[t(946)](Gs,d,0,this[t(1086)+"ileName"]):Cd()}}async[n(452)](t,r,d){let u=n;return console[u(1526)](e[u(1226)],t,r,d),this[u(1469)][u(452)]({cursor_name:t,cursor:r,service:d})}async setCursors(t){let r=n,d=e[r(1237)](Id,t);for(let u of d)if(e[r(509)](e[r(1197)],e[r(1291)]))console[r(1526)](e.tXizn,d),await this[r(1469)][r(452)](u);else return!!this[r(1469)]}async[n(999)](t){let r=n;return(await this._qosDB[r(999)](t))?.[r(960)]}async[n(943)](){let t=n;await this._qosDB[t(943)]()}["updateCu"+n(1333)+n(1149)](t){let r=n;this[r(1086)+r(428)]=t}get[n(349)](){let t=n;return this[t(1469)][t(349)]}}let Td=e[n(1516)];async function js(s){let t=n;if(t(1364)===e[t(613)]){if(!this[t(564)].enableQoS)return null;let{aID:r,fpID:d,messageStrategy:u}=this[t(564)],l=e[t(1315)](s,Td);try{return this["_cursorM"+t(723)]?s&&this[t(1163)+t(723)]["updateCu"+t(1333)+t(1149)](s):this[t(1163)+"anager"]=new Ad(d+"_"+r+"_"+l,l,u),this._cursorManager[t(349)]||await this[t(1163)+t(723)][t(1108)](),this._cursorManager}catch{return null}}else this[t(1469)]?.[t(661)](),this[t(1469)]=void 0}async function Dd(s,t){let r=n,d={kHKZk:function(G,Q){return e[W(471)](G,Q)}},u=e[r(344)](ft,s[r(464)][r(610)],r(1335),"-1"),l=e.VUjvW(ft,s.message[r(610)],e[r(1106)],"1"),_=Ot(s[r(464)].headers,e[r(916)]),w=e[r(963)](Number,Ot(s[r(464)][r(610)],r(1155)+r(1608)))||0,h=ti[r(607)](this,s),R=ft(s[r(464)][r(610)],e[r(993)],"2"),N=e.oaAPw(Ot,s.message.headers,e[r(1726)]),L=e[r(865)](Number,e[r(1173)](Ot,s[r(464)].headers,r(830)+r(980)+"ue"));if(h[r(1008)])return e[r(678)](t);let q=h[r(623)+r(708)]?await Hs[r(607)](this):null;if(e[r(1161)](s[r(464)].service,0)&&l&&!u||e.bFAOf(s[r(464)][r(893)],0)){if(_&&h[r(623)+"sage"]&&q)if(e[r(1702)](r(1362),e[r(719)])){if(!!!await q[r(999)](_))if(e.SZuPB(e[r(1406)],e.eKGUu))this[r(285)+r(1037)+r(924)](s),await q[r(452)](_,Date[r(1597)]()+w);else return this._isMiniTT||this[r(1698)+"X"]?this[r(1534)+"igatorOnline"]:(this[r(1168)+"er"]||this._isWorker)&&this[r(564)][r(655)+r(889)+"nged"]?_0x1d6d73[r(404)]:!0;return t()}else{let G=new _0x5b39d5(ZeQYQM.kHKZk(2,_0x47e6a7));G[r(452)](_0x29f8d6),_0x35444a.bytes=G}if(R){let G=await js[r(607)](this);if(!G)return this[r(285)+r(1037)+r(924)](s),e[r(377)](t);let Q=await G[r(999)](N)??-1;if(e[r(724)](Q,L))this[r(285)+"hMessage"+r(924)](s),G[r(452)](N,L,s[r(464)].service);else throw new Error(r(1624)+r(880)+r(1531)+L+(r(488)+r(1480)+r(1742)+"r ")+Q);return e[r(764)](t)}return this["_dispatchMessage"+r(924)](s),e[r(283)](t)}}async function Pd(s,t){let r=n,d=ti[r(607)](this,s);if(!d[r(623)+r(708)])return t();let u=await Hs[r(607)](this);if(d[r(405)+r(1217)+r(1465)]&&d.ackMsgIds.length)for(let l of d[r(1021)+"s"])await u[r(1311)](l);t()}async function kd(s,t){let r=n,d=e[r(348)](s[r(464)][r(859)+"e"],vd),u=e[r(301)](s[r(464)][r(859)+"e"],ii);if(!d&&!u)return e[r(318)](t);let l=e[r(1461)](Ot,s[r(464)][r(610)],e[r(1570)]);if(!l)return e[r(1283)](t);let _=await js[r(607)](this,l);if(!_)return t();if(d){let w=await _[r(969)+"rs"](),h={frameType:w?.[r(859)+"e"],SeqID:re[r(1622)+"er"](this[r(1079)]++),LogID:re.fromNumber(this[r(564)][r(363)+r(1011)]()),service:9e3,method:5,headers:w?.[r(610)],payload:w?.[r(741)]},R=A(h);this[r(864)]&&this[r(864)][r(962)+"te"]&&this[r(864)][r(1190)](R)}if(u){let w=s[r(464)][r(741)];w&&_[r(1419)+"rs"](w)}}let Nd=async function(s,t){let r=n;if(e[r(912)](e[r(1227)],e.ROqrg))this[r(1340)]=!1,e[r(1210)](clearTimeout,this["_connectionTimeo"+r(1066)]),e[r(377)](t);else return _0x258396||(_0x450338=[_0x5420c1,_0x20b7cf,_0x51b922,_0x473a84,_0xf24f47])},Rd=async function(s,t){let r=n;if(!this[r(864)]||this[r(864)][r(962)+"te"]!==this[r(447)])return e[r(1642)](t);let{pingInterval:d}=this[r(564)];this["_endpoin"+r(1719)]?.[r(1242)+r(1235)+r(1379)]();for(let l=0;e.TYgVa(l,this[r(1513)+r(1299)][r(754)]);l++)if(e[r(1279)](e[r(666)],r(1070))){let _=this._messageQueue[l];if(e[r(879)](this[r(864)][r(962)+"te"],this[r(447)])&&e[r(432)](null,_))this[r(864)]&&this[r(864)].send(_),this[r(1513)+r(1299)][l]=null;else break}else e[r(1237)](_0x28948a,r(705)),this[r(1248)](e[r(1189)],_0x44c370),this[r(1248)](e[r(777)],_0x211010);this[r(1513)+"Queue"]=this._messageQueue.filter(l=>!!l),this[r(1385)+r(634)+"Id"]=e[r(1173)](setTimeout,()=>this[r(418)](),d),this[r(285)+r(1546)+"nt"](s),this[r(1168)+"er"]&&this[r(864)]&&(this[r(864)].binaryType=this[r(668)+r(345)]);let u=this[r(972)+r(1719)]?.[r(1290)+r(380)+"nt"]();this._debug(r(829)+u+r(504)),t()},Ld=async function(s,t){let r=n,d=this[r(972)+r(1719)]?.[r(1290)+r(380)+"nt"]();this[r(1512)](r(829)+d),t()};class Od extends Xr{constructor(t){let r=n,d={Umdcn:function(u,l){return e.pzCwH(u,l)},lAxeJ:function(u,l){return e[W(460)](u,l)},NgKWv:function(u,l){return e[W(425)](u,l)},mWDuE:function(u,l){return e.ATpGv(u,l)},nysBi:e[r(1487)],iJFNp:function(u,l,_){return e[r(468)](u,l,_)},AXsMJ:function(u,l){return u===l},QsiBs:e[r(988)]};if(r(1452)===r(1117)){let{offset:u}=e[r(299)](_0x43bbd6,_0x307435,_0x432b5c);_0x54e7ab=u;let l={cursor_name:"",cursor:0,service:0},{value:_,offset:w}=e[r(604)](_0x3a01f5,_0x48bd82,_0x5143a6);l[r(893)]=_,_0x49c465=w;let{value:h,offset:R}=e.YdJoe(_0x7ba464,_0x387840,_0x9f0827);_0x963d6f=R,l.cursor_name=_0x31d6b9(_0x1237b5,_0x180676,e[r(907)](_0x232317,h)),_0x46dabb+=h;let{value:N,offset:L}=_0x3778b5(_0x2dcc8e,_0xd29b0a);l[r(960)]=N[r(1195)](),_0x525b05=L,_0x1206a1.push(l)}else{super(),this[r(1534)+r(382)+r(293)]=!0,this._isBrowser=Lt,this[r(1692)]=Y0,this[r(1047)+"T"]=yt,this._isMiniWX=on,this._isWorker=an,this._messageQueue=[],this[r(972)+"tManager"]=null,this[r(391)+"osed"]=!1,this[r(668)+"ype"]=e[r(493)],this[r(1389)+r(519)]=!1,this[r(1389)+r(1317)+r(1066)]=null,this["_reconne"+r(458)+r(473)]=null,this[r(1385)+r(634)+"Id"]=null,this._seqId=0,this[r(1340)]=!1,this[r(757)]="",this[r(890)+r(573)]=null,this[r(1163)+r(723)]=null,this["_pingLos"+r(543)]=null,this[r(684)+"ls"]=e[r(487)],this[r(1637)]=3,this[r(1674)+"NG"]=0,this[r(447)]=1,this[r(1454)]=2,this[r(1445)]=w=>{let h=r;try{e[h(595)](Bs,this,w,[Nd,Rd,Ld])}catch(R){if(e[h(538)]===h(598)){let N=e[h(1188)](Me,e[h(988)],{message:R[h(464)],code:dt[h(948)+"OR"],error:R});this[h(285)+h(483)+h(510)](N)}else{let N=_0x3563b9[h(885)+"g"](0,VeAoQY[h(1498)](4,_0x37dc4f[_0x499df5][h(754)])),L=N[h(281)](_0x174a38);_0x419b80=_0x54118e.concat(L)}}},this[r(1427)+"ge"]=async w=>{let h=r,{pingInterval:R,pingFrequency:N}=this[h(564)];if(e[h(368)]("hi",w[h(317)])&&h(448)===N||e[h(1610)](e[h(841)],N))if(e[h(485)]===e[h(485)])this[h(795)+h(691)](),this[h(500)](e[h(1189)],e[h(1091)]),this[h(1385)+h(634)+"Id"]=setTimeout(this[h(418)][h(355)](this),R);else return VeAoQY[h(657)](_0x5ef6db,_0x5664dc);if(w[h(317)]!=="hi")try{Bs(this,w,[xd,fd,Pd,kd,Dd,ud])}catch(L){if(e[h(567)](e[h(599)],e[h(599)])){let q=Me(h(1722),{message:L[h(464)],code:dt[h(334)+h(1158)],error:L});this["_dispatc"+h(483)+h(510)](q)}else{let q=this[h(972)+h(1719)]?.["getCurre"+h(380)+"nt"]();this[h(1512)](h(829)+q),_0x48c5da()}}},this[r(800)]=w=>{let h=r,R=this["_endpoin"+h(1719)]?.["checkRea"+h(313)+"es"](),N=this[h(972)+h(1719)]?.["getCurre"+h(380)+"nt"]();if(R&&!w.message)if(d[h(1231)](d[h(771)],d[h(771)])){let L=h(797)+N+(h(1097)+h(853)+"es reached");this[h(285)+h(483)+"ent"](d[h(1187)](Me,"error",{message:L,code:dt[h(1090)+"IES_ERROR"],error:w}));return}else{let L=new _0x375a86(VeAoQY[h(619)](_0x1c95e9,_0x1625cd));return _0xa029cc(_0x37f10f,L,0),L}this[h(864)]&&d[h(1652)](this[h(864)].readyState,this[h(447)])&&this[h(1525)+h(869)](),this[h(285)+"hErrorEv"+h(510)](d[h(1187)](Me,d.QsiBs,{message:w[h(464)],code:dt[h(1054)+h(1635)],error:w}))},this[r(743)]=async w=>{let h=r;if(e[h(368)](e[h(1028)],e[h(1028)])){this["_clearTi"+h(512)](),this[h(795)+"ngTimer"](),this["_removeW"+h(1434)+"rs"](),this._ws=null,this._connectLock=!1;let R=this[h(972)+h(1719)]?.["checkRea"+h(313)+"es"]();if(!R&&this[h(315)+h(1224)]()&&!this[h(391)+"osed"]){let N=this[h(972)+h(1719)]?.[h(1290)+h(380)+"nt"](),L=this._options[h(1044)+"tInterce"+h(644)](w[h(1335)],w[h(689)]);this[h(285)+h(1101)+"ent"](e[h(1461)](Ue,e[h(866)],{code:1006,reason:w.reason||h(735)+h(1411)+h(620)+h(1700)+h(854)+h(1403)+N,willReconnect:L})),L&&this[h(1389)]();return}if(e[h(1073)](1e3,w[h(1335)])&&this["_readyCl"+h(1587)]){this[h(285)+h(1101)+h(510)](Ue(e.mgeEP,{code:1e3,reason:"bye"})),this[h(972)+"tManager"]?.["resetEnd"+h(1235)+h(1379)](),this["_pingLos"+h(543)]?.resetCounter();return}if(e[h(912)](1e3,w[h(1335)])&&R){let N=this["_endpoin"+h(1719)]?.[h(1290)+"ntEndpoint"](),L=w.reason;L||(L=await e[h(964)](id,this[h(757)])),L="connecti"+h(1411)+h(1110)+L+(", hostna"+h(1294))+N+(h(513)+h(1672)+h(1206)),this["_dispatc"+h(1101)+h(510)](e[h(807)](Ue,"close",{code:w.code,reason:L}));let q=h(797)+N+(" fail, m"+h(853)+h(1332)+"ed");this["_dispatc"+h(483)+h(510)](e[h(601)](Me,"error",{message:q,code:dt[h(1090)+h(1567)+"R"]})),this[h(972)+h(1719)]?.[h(1242)+h(1235)+"fig"](),this[h(694)+h(543)]?.[h(1517)+h(1152)]();return}if(w.code!==1e3&&!w.reason){let N=this[h(972)+h(1719)]?.["getCurre"+h(380)+"nt"]();this["_dispatc"+h(1101)+"ent"](e.gKNzK(Ue,e[h(866)],{code:w[h(1335)],reason:h(735)+h(1411)+h(620)+h(1700)+h(854)+h(1403)+N})),this["_endpoin"+h(1719)]?.[h(1242)+h(1235)+"fig"](),this["_pingLos"+h(543)]?.[h(1517)+"nter"]();return}this[h(285)+h(1101)+h(510)](w),this["_endpoin"+h(1719)]?.[h(1242)+h(1235)+"fig"](),this["_pingLos"+h(543)]?.["resetCou"+h(1152)]()}else return _0x5bd3c4?.[h(1222)](R=>R[h(449)]===_0x12c237)?.[h(1014)]},this[r(489)]=null,this[r(1490)]=null,this[r(997)+"e"]=null,this[r(1339)]=null,this[r(497)+r(1055)]=null,this[r(1421)+r(1496)]=null,this[r(696)+"mediatel"+r(876)+"ct"]=null,this[r(1651)+r(386)]=this[r(1651)+"nLine"][r(355)](this),this[r(1651)+r(1462)]=this[r(1651)+r(1462)][r(355)](this),this["_handleP"+r(357)]=this[r(1103)+"ageHide"][r(355)](this),this[r(1103)+r(416)]=this["_handleP"+r(416)][r(355)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(553)](1,0),service:0,logIDGenerator:a,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[r(841)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[r(304)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:l}=t,_=Array[r(894)](u)?u:e[r(1429)](e[r(664)],typeof u)?[u]:[];if(!_||e[r(296)](0,_[r(754)]))throw new Error(r(1088)+r(1711)+r(1501));if(!e[r(963)](ed,l))throw new Error(e[r(1402)]);Object[r(1327)](this._options,t),this._endpointManager=new Ms(_,this[r(564)][r(1371)+"es"]),this["_pingLos"+r(543)]=new rd(this[r(564)][r(1377)+r(520)]),this[r(564)].automaticOpen&&(r(586)!==e[r(1455)]?(this[r(1340)]=!0,this._connect()):_0x359978[r(1526)](_0x5edf5d)),this[r(564)][r(655)+r(889)+r(1016)]&&(this[r(1047)+"T"]||this[r(1698)+"X"]?this[r(1555)+"etWorkCh"+r(511)]():this[r(1168)+"er"]&&this[r(1617)+r(765)+"Listener"]())}}["_handleO"+n(386)](){let t=n;this[t(564)]["disableA"+t(638)+t(1162)]||this["_readyCl"+t(1587)]||this[t(659)+t(1055)]()}[n(1651)+n(1462)](){let t=n;this[t(626)+"WebSocket"]();let r=e.fQQOd(Yr,e[t(1660)],{message:"stop imm"+t(1198)+t(612)+"ct"});this[t(696)+t(591)+t(876)+"ct"]&&this[t(696)+t(591)+t(876)+"ct"](r)}[n(1617)+n(765)+n(1282)](){let t=n;this._isBrowser&&window[t(1693)+t(1282)](e[t(474)],this[t(1651)+t(386)]),this[t(1168)+"er"]&&window[t(1693)+t(1282)](e[t(1336)],this[t(1651)+"ffLine"]),this._isBrowser&&window[t(1693)+t(1282)](e.DWOIh,this[t(1103)+t(357)]),this[t(1168)+"er"]&&window[t(1693)+t(1282)](e.kGKGl,this[t(1103)+t(416)])}["_dropGlo"+n(765)+n(1282)](){let t=n;this[t(1168)+"er"]&&window[t(913)+"entListener"](e.UsGhY,this[t(1651)+t(386)]),this[t(1168)+"er"]&&window["removeEv"+t(351)+"ner"](e.FZVpt,this["_handleO"+t(1462)]),this[t(1168)+"er"]&&window[t(913)+"entListe"+t(1353)](t(1659),this._handlePageHide),this._isBrowser&&window["removeEventListe"+t(1353)](e.kGKGl,this[t(1103)+t(416)])}[n(1103)+n(357)](t){let r=n;!t[r(1185)+"d"]&&(this._isBrowser&&window["removeEv"+r(351)+"ner"](r(1659),this[r(1103)+r(357)]),this[r(1168)+"er"]&&window[r(913)+r(351)+r(1353)](e.kGKGl,this["_handleP"+r(416)]),this.close()),this[r(1168)+"er"]&&window["removeEventListe"+r(1353)](e[r(474)],this[r(1651)+r(386)]),this[r(1168)+"er"]&&window["removeEv"+r(351)+"ner"](e[r(1336)],this[r(1651)+r(1462)])}[n(1103)+n(416)](t){let r=n;t.persisted&&(e[r(368)](e[r(1144)],e[r(415)])?(this[r(1687)+r(1140)]=0,this[r(855)+"ndpointT"+r(749)+"t"]=0):(this[r(315)+r(1224)]()&&(!this[r(864)]||e[r(1519)](this[r(864)][r(962)+"te"],this[r(447)])||e[r(1396)](this[r(864)][r(962)+"te"],this[r(1674)+"NG"]))&&this["_handleO"+r(386)](),this._isBrowser&&window["addEvent"+r(1282)](r(1695),this[r(1651)+r(386)]),this[r(1168)+"er"]&&window["addEvent"+r(1282)](e[r(1336)],this[r(1651)+r(1462)])))}async[n(1347)+n(554)](t){let r=n,{fpID:d,deviceID:u,bddID:l,ttwID:_,accessKey:w,aID:h,customParams:R={},enableAutoAck:N,enableQoS:L,QoSLevel:q,env:G}=this._options,Q,Pe,ce;this[r(1168)+"er"]||this[r(1698)+"X"]||this[r(1047)+"T"]?(Q=location&&e.isjhB(e[r(410)],location.protocol)?"wss://":e[r(1639)],Pe=t[r(1528)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),ce=/^wss(.*:\/\/)/[r(746)](t)?t:""+Q+Pe):(Q="wss://",Pe=t[r(1528)](/(^http)((?:[s]*:\/\/))/,""),ce=/(^ws)((?:[s]*:\/\/))/[r(746)](Pe)?Pe:""+Q+Pe);let de=l?e[r(1105)]:_?e[r(1591)]:r(1745)+"d",He=l||_||u;if(e[r(1315)](!He,!de))throw new Error("please p"+r(1673)+"ddID, de"+r(1489)+r(1214));let cn=e[r(585)]==typeof R?await R():R,Ks=G?e.iMDPb(nd,G[r(490)],G[r(1102)]):{},si=Object[r(1327)]({device_platform:e[r(1259)],version_code:r(1355)+"0",access_key:w,fpid:d,aid:h,[de]:He,xsack:N?1:0,xaack:N?1:0,xsqos:L?1:0,qos_level:L?q:void 0,qos_sdk_version:2,...Ks},cn),Md=Object[r(935)](si)[r(1397)]((oi,ai)=>si[ai]!==void 0?""+oi+(oi?"&":"?")+ai+"="+si[ai]:oi,"");return ce+r(369)+Md}async[n(1389)](){let t=n,r={MvPjX:function(d,u){return e.wgEvc(d,u)},LktiW:function(d,u){return e[W(1096)](d,u)}};if(!(this[t(1389)+t(519)]||this[t(391)+t(1587)])){this[t(1389)+t(519)]=!0;try{if(e[t(983)](e[t(1295)],t(603)))return _0x52adc9[t(923)]();{let d=this[t(972)+"tManager"]?.["checkCur"+t(806)+"ointReac"+t(456)+"tries"](),{timeoutInterval:u}=this[t(564)];if(d){let _=this[t(972)+t(1719)]?.["getCurre"+t(380)+"nt"](),w=this[t(972)+t(1719)]?.[t(526)+t(1595)+t(927)+"UpdateCo"+t(774)](),h=this[t(972)+t(1719)]?.[t(1290)+t(380)+t(898)+t(1727)]();if(w)if(e[t(677)]!==e[t(1401)]){let R=t(797)+_+(t(1107)+t(513)+t(1672)+t(1627)+t(1503)+"backup e"+t(776))+w+" to retry",N=e.cPgYw(Me,e[t(988)],{message:R,code:dt["MAX_RETR"+t(1567)+"R"]});this._debug(R),this[t(285)+t(483)+t(510)](N),this[t(757)]=await this[t(1347)+t(554)](w),this[t(1512)]("connect "+w+" "+h+t(961)),this[t(303)+"sListeners"]()}else _0x13cfd4[t(1526)](_0x14a0e7);else{let R=t(797)+_+(t(1107)+t(513)+t(1672)+"ached");this._debug(R),this["_dispatchErrorEv"+t(510)](e[t(1392)](Me,e.xuMYq,{message:R,code:dt[t(1090)+t(1567)+"R"]}));return}}else if(e[t(1001)](e.fvEMT,e[t(998)])){let _=this[t(972)+"tManager"]?.[t(1290)+t(380)+t(1094)+"ateCount"](),w=this[t(972)+"tManager"]?.[t(1290)+"ntEndpointTriesCount"]();this[t(757)]=await this["_generat"+t(554)](e.DYgkO(_,"")),this[t(1512)](t(797)+_+" "+w+t(961)),this["_removeW"+t(1434)+"rs"]()}else{let{value:_,offset:w}=_0x14112d(_0x1f9280,_0x54f2af);_0x4c5f32=w,_0x3c4c01=gUCgWK[t(539)](gUCgWK[t(1174)](_0x2ca9d9,8),0),_0x5ed1a4+=_}if(this[t(1340)])this[t(1340)]=!1;else{let _=e.VXzww(Yr,e[t(1660)],{message:e[t(383)]});this[t(497)+t(1055)]&&this[t(497)+t(1055)](_)}let l=this[t(972)+t(1719)]?.[t(1290)+"ntEndpointTriesC"+t(1727)]()||0;e[t(403)](l,1)&&await this[t(1553)](e.FMclK(l,1)),this._debug(t(735)+t(1606)+this[t(757)]+(" protoco"+t(1175))+this._protocols),this[t(864)]=e[t(1746)](Q0,{url:this[t(757)],protocols:[this._protocols],headers:this[t(564)][t(1124)+t(1239)+"s"].customHttpHeader},this[t(564)].ws),(this[t(1168)+"er"]||this[t(282)+"r"])&&this[t(864)]&&(this[t(864)][t(1305)+"pe"]=this[t(668)+t(345)]),this["_addWsLi"+t(1051)](),this[t(1389)+t(1317)+t(1066)]=e[t(1736)](setTimeout,this[t(565)+"ut"][t(355)](this),u)}}catch(d){throw this._connectLock=!1,d}}}[n(1442)+n(512)](){let t=n;if(e[t(1057)](t(430),t(430)))e.CiAwS(clearTimeout,this["_connectionTimeo"+t(1066)]),this["_connect"+t(1317)+"utId"]=null;else{let r=e[t(1341)][t(1296)]("|"),d=0;for(;;){switch(r[d++]){case"0":this[t(864)][t(1693)+t(1282)](e[t(1343)],this[t(1427)+"ge"]);continue;case"1":if(!this[t(864)])return;continue;case"2":this._ws[t(1693)+"Listener"](t(1722),this[t(800)]);continue;case"3":this._ws[t(1693)+t(1282)](e.mgeEP,this._onClose);continue;case"4":this._ws[t(1693)+t(1282)](e[t(1441)],this[t(1445)]);continue}break}}}["_clearPi"+n(691)](){let t=n;if(e.RYtHm(t(1069),t(1069)))e.CiAwS(clearTimeout,this[t(1385)+t(634)+"Id"]),e.FqvEm(clearTimeout,this[t(1543)+"ctTimeou"+t(473)]),this[t(1385)+t(634)+"Id"]=null,this[t(1543)+t(458)+t(473)]=null;else return}[n(1512)](...t){let r=n;this._options[r(985)]&&console[r(1526)][r(461)](console,[e[r(470)],...t])}[n(827)+n(670)+"e"](t){let r=n,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:l}=this[r(564)],_=e[r(739)](d,Math[r(479)](l,e[r(1314)](t,1)));return _>u?u:_}_ping(){let t=n;if(e[t(1325)](e[t(559)],e[t(559)])){if(this[t(864)]&&e[t(1391)](this[t(864)][t(962)+"te"],this.CONNECTING)){this[t(795)+t(691)](),this[t(1385)+t(634)+"Id"]=setTimeout(this[t(418)][t(355)](this),this._options[t(465)+"rval"]);return}if(!this._ws||e[t(451)](this[t(864)].readyState,this[t(447)]))return void this[t(659)+t(1055)]();this[t(864)]&&this[t(864)][t(1190)]("hi"),this[t(1543)+t(458)+"tId"]=e[t(540)](setTimeout,this[t(659)+t(1055)+t(930)][t(355)](this),this[t(564)]["pingTimeoutInter"+t(326)])}else return this[t(932)+"s"][this["currentI"+t(1140)]]}["_handleR"+n(1055)+n(930)](){let t=n;this["_pingLos"+t(543)]?.[t(752)](),this.emit(e[t(777)],e[t(1449)]),this[t(694)+t(543)]?.["checkRea"+t(1060)+"nt"]()?this[t(659)+"econnect"]():this._ping()}[n(315)+n(1224)](){let t=n,r={GVGPV:function(d,u,l){return e[W(1352)](d,u,l)}};if(e[t(1200)]("axsoA",e[t(1505)]))return this[t(1047)+"T"]||this[t(1698)+"X"]?this[t(1534)+t(382)+t(293)]:(this[t(1168)+"er"]||this[t(282)+"r"])&&this._options[t(655)+t(889)+t(1016)]?navigator[t(404)]:!0;PoVXLg[t(970)](_0x30cb52,_0x120b5a,16),_0x24ffe2(_0xc76f77,_0x17f6d8)}_handleReconnect(){let t=n;!this[t(315)+t(1224)]()||this["_readyCl"+t(1587)]||(this[t(972)+t(1719)]?.[t(1242)+t(1235)+t(1379)](),this["_pingLos"+t(543)]?.[t(1517)+t(1152)](),this[t(864)]?this._disconnect(1001,t(660)+t(995)+"reconnec"+t(597)+t(1535),!0):this[t(1389)]())}[n(1555)+"etWorkCh"+n(511)](){let t=n;this._isMiniTT?tt["onNetwor"+t(1679)+t(1253)](({isConnected:r})=>{let d=t;this[d(1534)+"igatorOn"+d(293)]=r,r?this._handleOnLine():this[d(1651)+"ffLine"]()}):this[t(1698)+"X"]&&wx[t(1012)+t(1679)+t(1253)](({isConnected:r})=>{let d=t;this[d(1534)+d(382)+d(293)]=r,r?this._handleOnLine():this._handleOffLine()})}[n(1553)](t){let r={AcZzC:function(d,u,l){return d(u,l)}};return new Promise(d=>{let u=W;r.AcZzC(setTimeout,d,this[u(827)+"rvalValue"](t))})}[n(1525)+n(869)](t=1e3,r="",d=!1){let u=n,l={ThRSx:function(_,w){return _(w)},Byvxw:e[u(711)]};if(e[u(1072)](e.pDycf,e[u(486)])){if(!this[u(864)])return;this[u(626)+u(814)+"t"](t,r,d)}else _0x525714[u(576)][u(1714)+u(798)](_0x54fec3),_0x97574b[u(1620)+"JSONP"]=void 0,jFhTbW[u(1087)](_0x286b21,_0x5a73f6&&_0x35b6b2[u(1653)]||jFhTbW[u(1432)])}_onTimeout(){let t=n,r=this[t(972)+t(1719)]?.["getCurre"+t(380)+"nt"]();this[t(1512)](t(797)+r+" timeout"),this[t(1525)+t(869)](1001,e[t(1115)],!0)}[n(954)](t){let r=n,d=e.yxOSO(Ne,t);this._ws&&e[r(1502)](this[r(864)][r(962)+"te"],this[r(447)])&&(this[r(864)]&&this[r(864)][r(1190)](d),this._debug(r(1348),t))}[n(303)+n(1434)+"rs"](){let t=n,r=(t(1729)+"2")[t(1296)]("|"),d=0;for(;;){switch(r[d++]){case"0":this._ws[t(913)+"entListe"+t(1353)](e[t(1441)],this[t(1445)]);continue;case"1":if(!this[t(864)])return;continue;case"2":this[t(864)]["removeEv"+t(351)+t(1353)](e[t(988)],this[t(800)]);continue;case"3":this[t(864)][t(913)+t(351)+t(1353)](t(464),this._onMessage);continue;case"4":this[t(864)][t(913)+"entListe"+t(1353)](e[t(866)],this._onClose);continue}break}}["_addWsLi"+n(1051)](){let t=n;if(e[t(1577)](t(306),"ulVee")){let r=e.LEwqB[t(1296)]("|"),d=0;for(;;){switch(r[d++]){case"0":if(!this[t(864)])return;continue;case"1":this[t(864)][t(1693)+t(1282)](e[t(1343)],this[t(1427)+"ge"]);continue;case"2":this._ws[t(1693)+t(1282)](t(661),this[t(743)]);continue;case"3":this[t(864)][t(1693)+t(1282)](e[t(1441)],this[t(1445)]);continue;case"4":this._ws[t(1693)+t(1282)](e[t(988)],this[t(800)]);continue}break}}else _0x4e0fbc=e.fMMoe(e[t(1704)](e[t(319)](e[t(945)](15,_0x2dd446),12),e[t(1684)](63&_0xa18eaa,6)),e.OHWxG(63,_0x3284d2)),e[t(441)](_0x1be746,2048)||e[t(434)](_0x591e43,55296)&&e[t(279)](_0x1c9e52,57343)?_0x58881a+=_0x5003cb:(_0x27284a+=e[t(1256)](_0x3a1293,_0x379486),_0x593278+=2)}["_wsInsta"+n(1068)](t=1e3,r=""){let d=n;if(e.fuynW(d(294),e.hLYra))return _0x359f7e?this.toBytesLE():this[d(928)+"E"]();try{this[d(864)]&&this._ws.close(t,r)}catch{}}[n(626)+"WebSocket"](t=1e3,r="",d=!1){let u=n,l={yyZAr:function(_,w){return e[W(1237)](_,w)},iBdeJ:function(_,w){return e[W(1077)](_,w)}};if(this[u(795)+u(691)](),this._clearTimer(),this[u(303)+"sListeners"](),this[u(1457)+"nceClose"](1e3,r),this[u(1389)+u(519)]=!1,d&&this[u(315)+u(1224)]()&&!this[u(391)+u(1587)])if(e[u(1656)](e[u(1134)],e[u(1646)])){if(this[u(972)+u(1719)]?.[u(1050)+u(313)+"es"]()){let w=this[u(972)+u(1719)]?.["getCurre"+u(380)+"nt"]();this["_dispatc"+u(1101)+u(510)](e[u(773)](Ue,u(661),{code:1006,reason:"connect "+w+(u(1107)+", max re"+u(1672)+u(1206)),wasClean:!0}))}else if(e[u(522)]===e[u(522)]){let w=this[u(564)][u(1044)+u(1583)+"ptor"](t,r);this[u(285)+u(1101)+u(510)](Ue(u(661),{code:t,reason:r,wasClean:!0,willReconnect:w})),w&&this[u(1389)]()}else{let w=nkUioT[u(1147)](_0x5d6d5c,_0x25cfc9),h=_0xd4a95[u(338)];return _0x47a038[u(338)]=nkUioT[u(1216)](_0x5c505f[u(1720)],w),h}return}else{let _={fckLz:function(L,q){return e[u(1471)](L,q)},Jxlbj:function(L,q){return e.OtJaL(L,q)},fUQkF:function(L,q){return e[u(1706)](L,q)},FkgSm:function(L,q){return e[u(882)](L,q)},nDEGI:function(L,q){return e[u(811)](L,q)},usvlT:function(L,q){return e[u(560)](L,q)},jwrBw:function(L,q){return e.KMlSK(L,q)}},w=e[u(1211)](_0x3c07d2,8192),h=e[u(370)](w,1),R=null,N=w;return function(L){let q=u;if(_.fckLz(L,1)||_[q(1697)](L,h))return _0x81c96f(L);_[q(1240)](_[q(1310)](N,L),w)&&(R=_[q(360)](_0x32738a,w),N=0);let G=_0x5b2e82[q(607)](R,N,N+=L);return _.usvlT(7,N)&&(N=_[q(959)](7,N)+1),G}}this._navigatorOnline()||this[u(391)+u(1587)]?this[u(285)+u(1101)+"ent"](e[u(725)](Ue,e[u(866)],{code:t,reason:e[u(325)]})):this[u(285)+u(1101)+"ent"](e.eeALr(Ue,e[u(866)],{code:1006,reason:e[u(1494)]})),this[u(864)]=null,this[u(972)+"tManager"]?.[u(1242)+u(1235)+u(1379)](),this["_pingLos"+u(543)]?.[u(1517)+u(1152)]()}[n(285)+"hOpenEvent"](t){let r=n,d={DrPJx:function(u,l){return u<l},nzfMc:function(u,l,_){return e.ZUEcn(u,l,_)},AMKxS:function(u,l,_){return e[W(1447)](u,l,_)},QBwVV:function(u,l,_,w){return u(l,_,w)},oubqi:function(u,l){return e[W(1077)](u,l)}};if(r(561)!==e[r(698)])this.emit(r(640),t),this[r(1339)]&&this[r(1339)](t);else{let u=0,l=[];for(;mLJsuW[r(940)](u,_0x4417bd[r(381)+"th"]);){let{offset:_}=mLJsuW.nzfMc(_0x2cf912,_0x4aa385,u);u=_;let w={cursor_name:"",cursor:0,service:0},{value:h,offset:R}=mLJsuW.AMKxS(_0x3edad4,_0x527d88,u);w[r(893)]=h,u=R;let{value:N,offset:L}=_0x5505a1(_0x53df4a,u);u=L,w[r(1665)+"ame"]=mLJsuW[r(387)](_0x5900ab,_0x1780b8,u,mLJsuW[r(703)](u,N)),u+=N;let{value:q,offset:G}=mLJsuW[r(937)](_0x45613d,_0x45d58c,u);w[r(960)]=q[r(1195)](),u=G,l[r(1298)](w)}return l}}[n(285)+"hMessage"+n(924)](t){let r=n;if(e.WiXcz(e[r(1604)],e.pHPbp))this[r(500)](e[r(1343)],t),this[r(997)+"e"]&&this.onmessage(t);else{let d=_0x59951b[r(754)]&&_0x3c537a[0];if(d instanceof _0x3de6e3)throw d;let u=new _0x431478(e[r(837)]+(d?e.zvgej(" ("+d.message,")"):""));throw u[r(1446)]=d,d}}["_dispatc"+n(1145)+n(1510)](t){let r=n;this[r(500)]("ack",t),this[r(1421)+r(1496)]&&this[r(1421)+r(1496)](t)}[n(285)+n(483)+n(510)](t){let r=n;this[r(500)](e[r(988)],t),this.onerror&&this[r(1490)](t)}[n(285)+n(1101)+n(510)](t){let r=n;this[r(500)](r(661),t),this[r(489)]&&this.onclose(t)}get[n(1305)+"pe"](){let t=n;return this[t(864)]?this[t(864)][t(1305)+"pe"]:this[t(668)+t(345)]}set[n(1305)+"pe"](t){let r=n;this[r(668)+"ype"]=t,this[r(864)]&&(this._ws[r(1305)+"pe"]=t)}get retryCount(){let t=n;return this[t(972)+"tManager"]?.[t(1290)+"ntEndpointTriesCount"]()||0}get[n(1670)+n(1351)](){let t=n,r=this[t(1513)+"Queue"][t(1397)]((d,u)=>(d+=u&&u[t(381)+"th"]||0,d),0);return e.GIzYo(r,this[t(864)]?this._ws[t(1670)+t(1351)]:0)}get[n(1232)+"ns"](){let t=n;return this[t(864)]?this._ws[t(1232)+"ns"]:""}get[n(311)](){let t=n;return this[t(864)]?this[t(864)][t(311)]:""}get[n(962)+"te"](){let t=n;return this[t(864)]?this[t(864)][t(962)+"te"]:this[t(564)][t(877)+t(578)]?this[t(1674)+"NG"]:this.CLOSED}get[n(1661)](){let t=n;if(e[t(533)](e[t(278)],e[t(1095)]))this[t(1356)]++;else return this[t(864)]?this[t(864)][t(1661)]:this[t(757)]}[n(661)](t=1e3,r){let d=n,u=e.yPHcs[d(1296)]("|"),l=0;for(;;){switch(u[l++]){case"0":if(e[d(1213)](this[d(864)][d(962)+"te"],this[d(1637)])||e.zUmus(this._ws[d(962)+"te"],this[d(1454)]))return void this[d(1512)](e[d(1539)]);continue;case"1":this["_clearTi"+d(512)]();continue;case"2":this[d(1549)+d(765)+d(1282)]();continue;case"3":if(!this[d(864)])return void this._debug(e[d(984)]);continue;case"4":this[d(795)+d(691)]();continue;case"5":this[d(391)+d(1587)]=!0;continue;case"6":this._QoSManager?.[d(943)]();continue;case"7":this[d(626)+d(814)+"t"](t,r);continue}break}}async[n(1190)](t,r){let d=n,u={sJhXl:e.uPPuQ,arFen:function(ce,de){return e[W(397)](ce,de)},hcgVe:function(ce,de,He,cn){return e[W(753)](ce,de,He,cn)},OpbWc:function(ce,de){return e[W(1678)](ce,de)},vFGQR:function(ce,de){return e[W(815)](ce,de)},nJfIU:function(ce,de,He,cn){return ce(de,He,cn)},wAtmV:function(ce,de){return e[W(1666)](ce,de)}};if(e[d(388)](null,t))throw new Error(e[d(365)]);e[d(870)](d(622),typeof t)&&(t=JSON[d(1588)+"y"](t)),e[d(664)]!=typeof t&&!(t instanceof ArrayBuffer)&&!(t[d(1056)]&&e[d(570)](t[d(1056)],ArrayBuffer))&&(t=JSON[d(1588)+"y"](t));let l=await e[d(1435)](Us,t),_=e.xplCR(td,t),{method:w=0,service:h=this[d(564)][d(893)],logID:R=this[d(564)][d(363)+"erator"](),headers:N=this[d(564)][d(610)],payloadEncoding:L=this._options[d(1683)+"ncoding"],payloadType:q=this[d(564)][d(848)+d(345)],logIDNew:G=this._options[d(1511)+d(718)][d(632)+d(1506)+d(466)+"ew"]?o(this[d(564)][d(1511)+d(718)][d(805)]):""}=r||{};if(!h)throw new Error(d(1088)+"rovide a"+d(328)+"ervice");let Q={SeqID:re[d(1622)+"er"](this[d(1079)]++),LogID:re[d(1622)+"er"](R),service:h,method:w,headers:N,payloadEncoding:L instanceof Object?L.encoding?L[d(1010)]:"":L,payloadType:q instanceof Object?q.type?q.type:_:q||_,payload:l,LogIDNew:G},Pe=Ne(Q);if(this[d(864)]&&e[d(1358)](this[d(864)].readyState,this[d(447)]))if(e[d(1001)](e[d(431)],e.FQfUC))this[d(864)]&&this[d(864)][d(1190)](Pe),this[d(1512)](e.NOfvg,Q);else{let ce=u[d(1499)].split("|"),de=0;for(;;){switch(ce[de++]){case"0":return DuGfoe.arFen(DuGfoe[d(1508)](_0x5b0746,_0x440219,_0x10dea3,_0x24f7cf),_0x2638f7);case"1":if(DuGfoe.OpbWc(_0xafdb2a[d(754)],40))return DuGfoe[d(480)](DuGfoe[d(1468)](_0x3ee537,_0x2076fa,_0x4341f5,_0x24675a),_0x4f089c);continue;case"2":if(_0x2ce645[d(409)])return DuGfoe.wAtmV(_0x2e6a17[d(409)](_0x37502c,_0x5cecf1),_0x46dc59);continue;case"3":if(!_0x30c266)return _0x103c66;continue;case"4":if(_0xdc0f8f[d(580)+"e"])return DuGfoe[d(480)](_0xc3398c[d(580)+"e"](_0x45825d,_0x2682d1),_0x592424);continue}break}}else e[d(724)](this[d(1513)+"Queue"][d(754)],this[d(564)][d(1085)+d(1083)+d(288)])?(this._messageQueue[d(1298)](Pe),this[d(1512)](e[d(1312)],Q)):(this[d(1513)+d(1299)][d(393)](),this[d(1513)+"Queue"][d(1298)](Pe));return{seqID:this._seqId,logID:R,logIDNew:G}}async[n(1044)+"t"](t){let r=n,d={RHkJo:function(_,w){return _>>>w},XVFst:function(_,w){return e[W(945)](_,w)},SrzKd:function(_,w){return e[W(714)](_,w)},VzfNp:function(_,w){return e[W(396)](_,w)},cdjbd:function(_,w){return e[W(710)](_,w)},kWkCd:function(_,w){return e[W(1359)](_,w)},OgUqc:function(_,w){return e[W(1527)](_,w)},nSFce:function(_,w){return e.Nyuqb(_,w)},qDGiP:function(_,w){return _|w},iUsYt:function(_,w){return e[W(594)](_,w)},iDInM:function(_,w){return e[W(1046)](_,w)},FWFNW:function(_,w){return e.wPJeN(_,w)},kMhrd:function(_,w){return e.kSIqW(_,w)},hwvGl:function(_,w){return e[W(532)](_,w)},ikFJR:function(_,w){return _&w},SbsHv:function(_,w){return e.umGHx(_,w)},GxwtQ:function(_,w){return _<w},rayIH:function(_,w){return _>w},HKkyP:function(_,w,h,R){return e[W(411)](_,w,h,R)}},{url:u}=t||{},l=Array.isArray(u)?u:e[r(1429)](e[r(664)],typeof u)?[u]:[];if(t&&Object[r(1327)](this[r(564)],t),l&&l.length?this[r(972)+r(1719)]=new Ms(l,this[r(564)].maxRetries):this[r(972)+r(1719)]?.[r(1242)+r(1235)+r(1379)](),this["_pingLos"+r(543)]?.["resetCou"+r(1152)](this[r(564)][r(1377)+r(520)]),this[r(391)+r(1587)]=!1,this[r(864)]&&this[r(864)][r(962)+"te"]!==this[r(1637)])this["_disconn"+r(869)](1e3,e[r(445)],!0);else if(e[r(1615)](r(1278),e[r(1274)])){if(_0x2f1a4b=MMCdJQ[r(910)](MMCdJQ[r(802)](127,_0x368e00[_0x9524e1]),0),MMCdJQ.SrzKd(_0x5a717a[_0x3278c2++],128))return{value:_0x34fc0f?_0x188cdf:MMCdJQ[r(1417)](0,_0x3e5b94),offset:_0x1475b9};if(_0x5656cc=MMCdJQ[r(871)](_0x141969|MMCdJQ.kWkCd(127&_0x2beb0b[_0x372d46],7),0),_0x3d07b2[_0x3cb5f7++]<128)return{value:_0x1ed6cb?_0x4b8c4e:MMCdJQ.OgUqc(0,_0xf1ee5a),offset:_0x1bd6e3};if(_0x128521=MMCdJQ[r(1578)](MMCdJQ[r(1138)](_0x5a55f4,MMCdJQ[r(1712)](MMCdJQ[r(1313)](127,_0x526181[_0x1cb662]),14)),0),MMCdJQ.SrzKd(_0x50c3bd[_0x239a08++],128))return{value:_0x13ed2a?_0x1f8e52:MMCdJQ[r(562)](0,_0x3f35ac),offset:_0x118781};if(_0x10f0e1=MMCdJQ[r(477)](MMCdJQ[r(1138)](_0x9b9f55,MMCdJQ[r(298)](MMCdJQ[r(1268)](127,_0x3440cb[_0x3c36a2]),21)),0),MMCdJQ[r(1688)](_0xad487c[_0x152b1e++],128))return{value:_0x16cbad?_0x49b234:MMCdJQ.VzfNp(0,_0x308fdb),offset:_0x351299};if(_0x1251d8=(_0x323257|MMCdJQ[r(298)](MMCdJQ[r(1268)](15,_0x1c9e45[_0x2ed41b]),28))>>>0,MMCdJQ[r(600)](_0x27e133[_0x3096d7++],128))return{value:_0x6eabc2?_0x58e15c:MMCdJQ[r(1138)](0,_0xc6e1a5),offset:_0x3dcf02};if(MMCdJQ.rayIH(_0x40478d+=5,_0xefe749[r(754)]))throw _0xfbac24=_0x4479dd.length,MMCdJQ.HKkyP(_0x1006cc,_0x12a066,10,_0x599dbd[r(754)]);return{value:_0x1d9f05?_0x141123:MMCdJQ[r(1138)](0,_0x90f6dc),offset:_0x3e0bed}}else this[r(1340)]=!0,this[r(1389)]()}async[n(974)](){let t=n;if(!this[t(1389)+t(519)])if(e[t(1638)]!=="DtSJH")this[t(972)+t(1719)]?.["resetEnd"+t(1235)+t(1379)](),this[t(694)+t(543)]?.[t(1517)+t(1152)](),this["_readyCl"+t(1587)]=!1,this[t(1340)]=!0,this[t(1389)]();else{let r={nxdHh:function(d,u){return d(u)}};return function(...d){let u=t;return _0x346cad[u(461)](r[u(367)](_0xa89680,this),d),r.nxdHh(_0x250872,_0x12ad2c[u(999)](this))}}}[n(1693)+n(1282)](t,r){this.on(t,r)}[n(996)+n(924)](t){let r=n,{type:d}=t;this[r(500)](d,t)}[n(913)+n(351)+n(1353)](t,r){this[n(1248)](t,r)}[n(402)](){let t=n,r={FsQrI:e[t(1280)],HGVBZ:function(d,u){return e[t(1228)](d,u)},cUYft:"timeout",DflHO:e[t(1189)],eLelM:t(1410)+t(645)+"t"};return new Promise((d,u)=>{let l=t,_={MIJVm:function(R,N){return r[W(408)](R,N)},Ipnbr:"success",VwrUH:r[l(671)]};this[l(795)+l(691)](),this["_pingPon"+l(634)+"Id"]=setTimeout(this._ping.bind(this),this._options[l(465)+l(1182)]);let w=()=>{let R=l;_.MIJVm(d,_[R(1273)]),this.off(R(1410)+R(1265)+"s",w),this[R(1248)](_[R(476)],h)},h=()=>{let R=l;if(R(828)===r[R(1277)])r[R(408)](u,r[R(1685)]),this[R(1248)](r[R(1573)],w),this[R(1248)](r[R(671)],h);else{let N=_0x424936[R(607)](_0x146fc7(this),_0x572fdc,..._0x349538);return _0x2cfcba[R(452)](N,_0x3e4d7d.sort?_0x271576[R(875)]():[_0x362233]),_0x2d92d2(N)}};this.on(r[l(1573)],w),this.on(l(1410)+l(645)+"t",h),this[l(418)]()})}}})(),se[z(506)+z(978)]=we[z(506)+z(978)],se.CustomErrorEvent=we["CustomEr"+z(967)],se.ErrorCode=we[z(845)+"e"],se.Event=we[z(924)],se[z(625)]=we[z(625)],se[z(1033)+z(372)+z(901)]=we[z(1033)+z(372)+"vent"],se[z(372)+z(901)]=we[z(372)+z(901)],se[z(457)+"t"]=we[z(457)+"t"],se[z(649)+"tEvent"]=we[z(649)+"tEvent"],se[z(1558)+"oseEvent"]=we[z(1558)+"oseEvent"],se[z(1003)+z(967)]=we[z(1003)+z(967)],se.createMessageEvent=we["createMe"+z(900)+"nt"],se[z(1472)+z(1017)]=we["createOp"+z(1017)],se["createRe"+z(547)+z(901)]=we[z(839)+"connectE"+z(901)],se.decodedFrame=we[z(1234)+z(843)],se[z(583)+"ame"]=we[z(583)+z(658)];for(mr in we)[z(506)+"oseEvent",z(571)+"rorEvent",z(845)+"e",z(924),"FWS",z(1033)+z(372)+z(901),"MessageE"+z(901),"OpenEvent","ReconnectEvent",z(1558)+z(978),"createEr"+z(967),z(813)+z(900)+"nt",z(1472)+"enEvent","createRe"+z(547)+z(901),"decodedFrame","encodeFrame"].indexOf(mr)===-1&&(se[mr]=we[mr]);var mr;Object[z(1690)+z(417)](se,"__esModule",{value:!0})});var nt=ee((ny,xc)=>{"use strict";var fc=["nodebuffer","arraybuffer","fragments"],uc=typeof Blob<"u";uc&&fc.push("blob");xc.exports={BINARY_TYPES:fc,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:uc,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Tn=ee((ry,Sr)=>{"use strict";var{EMPTY_BUFFER:hl}=nt(),Hi=Buffer[Symbol.species];function pl(n,e){if(n.length===0)return hl;if(n.length===1)return n[0];let i=Buffer.allocUnsafe(e),o=0;for(let a=0;a<n.length;a++){let c=n[a];i.set(c,o),o+=c.length}return o<e?new Hi(i.buffer,i.byteOffset,o):i}function lc(n,e,i,o,a){for(let c=0;c<a;c++)i[o+c]=n[c]^e[c&3]}function gc(n,e){for(let i=0;i<n.length;i++)n[i]^=e[i&3]}function ml(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function Gi(n){if(Gi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new Hi(n):ArrayBuffer.isView(n)?e=new Hi(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),Gi.readOnly=!1),e}Sr.exports={concat:pl,mask:lc,toArrayBuffer:ml,toBuffer:Gi,unmask:gc};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ie("bufferutil");Sr.exports.mask=function(e,i,o,a,c){c<48?lc(e,i,o,a,c):n.mask(e,i,o,a,c)},Sr.exports.unmask=function(e,i){e.length<32?gc(e,i):n.unmask(e,i)}}catch{}});var mc=ee((iy,pc)=>{"use strict";var hc=Symbol("kDone"),ji=Symbol("kRun"),Ki=class{constructor(e){this[hc]=()=>{this.pending--,this[ji]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[ji]()}[ji](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[hc])}}};pc.exports=Ki});var Xt=ee((sy,Ec)=>{"use strict";var Dn=ie("zlib"),wc=Tn(),wl=mc(),{kStatusCode:_c}=nt(),_l=Buffer[Symbol.species],yl=Buffer.from([0,0,255,255]),Cr=Symbol("permessage-deflate"),rt=Symbol("total-length"),Zt=Symbol("callback"),wt=Symbol("buffers"),Yt=Symbol("error"),Ir,Wi=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Ir){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Ir=new wl(i)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Zt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let i=this._options,o=e.find(a=>!(i.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(i.serverMaxWindowBits===!1||typeof i.serverMaxWindowBits=="number"&&i.serverMaxWindowBits>a.server_max_window_bits)||typeof i.clientMaxWindowBits=="number"&&!a.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return i.serverNoContextTakeover&&(o.server_no_context_takeover=!0),i.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof i.serverMaxWindowBits=="number"&&(o.server_max_window_bits=i.serverMaxWindowBits),typeof i.clientMaxWindowBits=="number"?o.client_max_window_bits=i.clientMaxWindowBits:(o.client_max_window_bits===!0||i.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let i=e[0];if(this._options.clientNoContextTakeover===!1&&i.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!i.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(i.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&i.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return i}normalizeParams(e){return e.forEach(i=>{Object.keys(i).forEach(o=>{let a=i[o];if(a.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(a=a[0],o==="client_max_window_bits"){if(a!==!0){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else if(o==="server_max_window_bits"){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=c}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else throw new Error(`Unknown parameter "${o}"`);i[o]=a})}),e}decompress(e,i,o){Ir.add(a=>{this._decompress(e,i,(c,f)=>{a(),o(c,f)})})}compress(e,i,o){Ir.add(a=>{this._compress(e,i,(c,f)=>{a(),o(c,f)})})}_decompress(e,i,o){let a=this._isServer?"client":"server";if(!this._inflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Dn.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Dn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[Cr]=this,this._inflate[rt]=0,this._inflate[wt]=[],this._inflate.on("error",bl),this._inflate.on("data",yc)}this._inflate[Zt]=o,this._inflate.write(e),i&&this._inflate.write(yl),this._inflate.flush(()=>{let c=this._inflate[Yt];if(c){this._inflate.close(),this._inflate=null,o(c);return}let f=wc.concat(this._inflate[wt],this._inflate[rt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[rt]=0,this._inflate[wt]=[],i&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),o(null,f)})}_compress(e,i,o){let a=this._isServer?"server":"client";if(!this._deflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Dn.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Dn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[rt]=0,this._deflate[wt]=[],this._deflate.on("data",El)}this._deflate[Zt]=o,this._deflate.write(e),this._deflate.flush(Dn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=wc.concat(this._deflate[wt],this._deflate[rt]);i&&(c=new _l(c.buffer,c.byteOffset,c.length-4)),this._deflate[Zt]=null,this._deflate[rt]=0,this._deflate[wt]=[],i&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),o(null,c)})}};Ec.exports=Wi;function El(n){this[wt].push(n),this[rt]+=n.length}function yc(n){if(this[rt]+=n.length,this[Cr]._maxPayload<1||this[rt]<=this[Cr]._maxPayload){this[wt].push(n);return}this[Yt]=new RangeError("Max payload size exceeded"),this[Yt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Yt][_c]=1009,this.removeListener("data",yc),this.reset()}function bl(n){if(this[Cr]._inflate=null,this[Yt]){this[Zt](this[Yt]);return}n[_c]=1007,this[Zt](n)}});var Qt=ee((oy,Ar)=>{"use strict";var{isUtf8:bc}=ie("buffer"),{hasBlob:vl}=nt(),Sl=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Il(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function Ji(n){let e=n.length,i=0;for(;i<e;)if((n[i]&128)===0)i++;else if((n[i]&224)===192){if(i+1===e||(n[i+1]&192)!==128||(n[i]&254)===192)return!1;i+=2}else if((n[i]&240)===224){if(i+2>=e||(n[i+1]&192)!==128||(n[i+2]&192)!==128||n[i]===224&&(n[i+1]&224)===128||n[i]===237&&(n[i+1]&224)===160)return!1;i+=3}else if((n[i]&248)===240){if(i+3>=e||(n[i+1]&192)!==128||(n[i+2]&192)!==128||(n[i+3]&192)!==128||n[i]===240&&(n[i+1]&240)===128||n[i]===244&&n[i+1]>143||n[i]>244)return!1;i+=4}else return!1;return!0}function Cl(n){return vl&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}Ar.exports={isBlob:Cl,isValidStatusCode:Il,isValidUTF8:Ji,tokenChars:Sl};if(bc)Ar.exports.isValidUTF8=function(n){return n.length<24?Ji(n):bc(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ie("utf-8-validate");Ar.exports.isValidUTF8=function(e){return e.length<32?Ji(e):n(e)}}catch{}});var Xi=ee((ay,Dc)=>{"use strict";var{Writable:Al}=ie("stream"),vc=Xt(),{BINARY_TYPES:Tl,EMPTY_BUFFER:Sc,kStatusCode:Dl,kWebSocket:Pl}=nt(),{concat:$i,toArrayBuffer:kl,unmask:Nl}=Tn(),{isValidStatusCode:Rl,isValidUTF8:Ic}=Qt(),Tr=Buffer[Symbol.species],Be=0,Cc=1,Ac=2,Tc=3,Vi=4,Zi=5,Dr=6,Yi=class extends Al{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Tl[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Pl]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=Be}_write(e,i,o){if(this._opcode===8&&this._state==Be)return o();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(o)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let o=this._buffers[0];return this._buffers[0]=new Tr(o.buffer,o.byteOffset+e,o.length-e),new Tr(o.buffer,o.byteOffset,e)}let i=Buffer.allocUnsafe(e);do{let o=this._buffers[0],a=i.length-e;e>=o.length?i.set(this._buffers.shift(),a):(i.set(new Uint8Array(o.buffer,o.byteOffset,e),a),this._buffers[0]=new Tr(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return i}startLoop(e){this._loop=!0;do switch(this._state){case Be:this.getInfo(e);break;case Cc:this.getPayloadLength16(e);break;case Ac:this.getPayloadLength64(e);break;case Tc:this.getMask();break;case Vi:this.getData(e);break;case Zi:case Dr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let i=this.consume(2);if((i[0]&48)!==0){let a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let o=(i[0]&64)===64;if(o&&!this._extensions[vc.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(i[0]&128)===128,this._opcode=i[0]&15,this._payloadLength=i[1]&127,this._opcode===0){if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(i[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=Cc:this._payloadLength===127?this._state=Ac:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let i=this.consume(8),o=i.readUInt32BE(0);if(o>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=o*Math.pow(2,32)+i.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(i);return}this._masked?this._state=Tc:this._state=Vi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Vi}getData(e){let i=Sc;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}i=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Nl(i,this._mask)}if(this._opcode>7){this.controlMessage(i,e);return}if(this._compressed){this._state=Zi,this.decompress(i,e);return}i.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(i)),this.dataMessage(e)}decompress(e,i){this._extensions[vc.extensionName].decompress(e,this._fin,(a,c)=>{if(a)return i(a);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");i(f);return}this._fragments.push(c)}this.dataMessage(i),this._state===Be&&this.startLoop(i)})}dataMessage(e){if(!this._fin){this._state=Be;return}let i=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let a;this._binaryType==="nodebuffer"?a=$i(o,i):this._binaryType==="arraybuffer"?a=kl($i(o,i)):this._binaryType==="blob"?a=new Blob(o):a=o,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=Be):(this._state=Dr,setImmediate(()=>{this.emit("message",a,!0),this._state=Be,this.startLoop(e)}))}else{let a=$i(o,i);if(!this._skipUTF8Validation&&!Ic(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Zi||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=Be):(this._state=Dr,setImmediate(()=>{this.emit("message",a,!1),this._state=Be,this.startLoop(e)}))}}controlMessage(e,i){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Sc),this.end();else{let o=e.readUInt16BE(0);if(!Rl(o)){let c=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");i(c);return}let a=new Tr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ic(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");i(c);return}this._loop=!1,this.emit("conclude",o,a),this.end()}this._state=Be;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Be):(this._state=Dr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Be,this.startLoop(i)}))}createError(e,i,o,a,c){this._loop=!1,this._errored=!0;let f=new e(o?`Invalid WebSocket frame: ${i}`:i);return Error.captureStackTrace(f,this.createError),f.code=c,f[Dl]=a,f}};Dc.exports=Yi});var ts=ee((dy,Nc)=>{"use strict";var{Duplex:cy}=ie("stream"),{randomFillSync:Ll}=ie("crypto"),Pc=Xt(),{EMPTY_BUFFER:Ol,kWebSocket:Ml,NOOP:Bl}=nt(),{isBlob:en,isValidStatusCode:zl}=Qt(),{mask:kc,toBuffer:It}=Tn(),ze=Symbol("kByteLength"),Fl=Buffer.alloc(4),Pr=8*1024,Ct,tn=Pr,qe=0,Ul=1,ql=2,Qi=class n{constructor(e,i,o){this._extensions=i||{},o&&(this._generateMask=o,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=qe,this.onerror=Bl,this[Ml]=void 0}static frame(e,i){let o,a=!1,c=2,f=!1;i.mask&&(o=i.maskBuffer||Fl,i.generateMask?i.generateMask(o):(tn===Pr&&(Ct===void 0&&(Ct=Buffer.alloc(Pr)),Ll(Ct,0,Pr),tn=0),o[0]=Ct[tn++],o[1]=Ct[tn++],o[2]=Ct[tn++],o[3]=Ct[tn++]),f=(o[0]|o[1]|o[2]|o[3])===0,c=6);let x;typeof e=="string"?(!i.mask||f)&&i[ze]!==void 0?x=i[ze]:(e=Buffer.from(e),x=e.length):(x=e.length,a=i.mask&&i.readOnly&&!f);let g=x;x>=65536?(c+=8,g=127):x>125&&(c+=2,g=126);let p=Buffer.allocUnsafe(a?x+c:c);return p[0]=i.fin?i.opcode|128:i.opcode,i.rsv1&&(p[0]|=64),p[1]=g,g===126?p.writeUInt16BE(x,2):g===127&&(p[2]=p[3]=0,p.writeUIntBE(x,4,6)),i.mask?(p[1]|=128,p[c-4]=o[0],p[c-3]=o[1],p[c-2]=o[2],p[c-1]=o[3],f?[p,e]:a?(kc(e,o,p,c,x),[p]):(kc(e,o,e,0,x),[p,e])):[p,e]}close(e,i,o,a){let c;if(e===void 0)c=Ol;else{if(typeof e!="number"||!zl(e))throw new TypeError("First argument must be a valid error code number");if(i===void 0||!i.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let x=Buffer.byteLength(i);if(x>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+x),c.writeUInt16BE(e,0),typeof i=="string"?c.write(i,2):c.set(i,2)}}let f={[ze]:c.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==qe?this.enqueue([this.dispatch,c,!1,f,a]):this.sendFrame(n.frame(c,f),a)}ping(e,i,o){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):en(e)?(a=e.size,c=!1):(e=It(e),a=e.length,c=It.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[ze]:a,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};en(e)?this._state!==qe?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==qe?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}pong(e,i,o){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):en(e)?(a=e.size,c=!1):(e=It(e),a=e.length,c=It.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[ze]:a,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};en(e)?this._state!==qe?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==qe?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}send(e,i,o){let a=this._extensions[Pc.extensionName],c=i.binary?2:1,f=i.compress,x,g;typeof e=="string"?(x=Buffer.byteLength(e),g=!1):en(e)?(x=e.size,g=!1):(e=It(e),x=e.length,g=It.readOnly),this._firstFragment?(this._firstFragment=!1,f&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=x>=a._threshold),this._compress=f):(f=!1,c=0),i.fin&&(this._firstFragment=!0);let p={[ze]:x,fin:i.fin,generateMask:this._generateMask,mask:i.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:g,rsv1:f};en(e)?this._state!==qe?this.enqueue([this.getBlobData,e,this._compress,p,o]):this.getBlobData(e,this._compress,p,o):this._state!==qe?this.enqueue([this.dispatch,e,this._compress,p,o]):this.dispatch(e,this._compress,p,o)}getBlobData(e,i,o,a){this._bufferedBytes+=o[ze],this._state=ql,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let x=new Error("The socket was closed while the blob was being read");process.nextTick(es,this,x,a);return}this._bufferedBytes-=o[ze];let f=It(c);i?this.dispatch(f,i,o,a):(this._state=qe,this.sendFrame(n.frame(f,o),a),this.dequeue())}).catch(c=>{process.nextTick(Hl,this,c,a)})}dispatch(e,i,o,a){if(!i){this.sendFrame(n.frame(e,o),a);return}let c=this._extensions[Pc.extensionName];this._bufferedBytes+=o[ze],this._state=Ul,c.compress(e,o.fin,(f,x)=>{if(this._socket.destroyed){let g=new Error("The socket was closed while data was being compressed");es(this,g,a);return}this._bufferedBytes-=o[ze],this._state=qe,o.readOnly=!1,this.sendFrame(n.frame(x,o),a),this.dequeue()})}dequeue(){for(;this._state===qe&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ze],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ze],this._queue.push(e)}sendFrame(e,i){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],i),this._socket.uncork()):this._socket.write(e[0],i)}};Nc.exports=Qi;function es(n,e,i){typeof i=="function"&&i(e);for(let o=0;o<n._queue.length;o++){let a=n._queue[o],c=a[a.length-1];typeof c=="function"&&c(e)}}function Hl(n,e,i){es(n,e,i),n.onerror(e)}});var qc=ee((fy,Uc)=>{"use strict";var{kForOnEventAttribute:Pn,kListener:ns}=nt(),Rc=Symbol("kCode"),Lc=Symbol("kData"),Oc=Symbol("kError"),Mc=Symbol("kMessage"),Bc=Symbol("kReason"),nn=Symbol("kTarget"),zc=Symbol("kType"),Fc=Symbol("kWasClean"),it=class{constructor(e){this[nn]=null,this[zc]=e}get target(){return this[nn]}get type(){return this[zc]}};Object.defineProperty(it.prototype,"target",{enumerable:!0});Object.defineProperty(it.prototype,"type",{enumerable:!0});var At=class extends it{constructor(e,i={}){super(e),this[Rc]=i.code===void 0?0:i.code,this[Bc]=i.reason===void 0?"":i.reason,this[Fc]=i.wasClean===void 0?!1:i.wasClean}get code(){return this[Rc]}get reason(){return this[Bc]}get wasClean(){return this[Fc]}};Object.defineProperty(At.prototype,"code",{enumerable:!0});Object.defineProperty(At.prototype,"reason",{enumerable:!0});Object.defineProperty(At.prototype,"wasClean",{enumerable:!0});var rn=class extends it{constructor(e,i={}){super(e),this[Oc]=i.error===void 0?null:i.error,this[Mc]=i.message===void 0?"":i.message}get error(){return this[Oc]}get message(){return this[Mc]}};Object.defineProperty(rn.prototype,"error",{enumerable:!0});Object.defineProperty(rn.prototype,"message",{enumerable:!0});var kn=class extends it{constructor(e,i={}){super(e),this[Lc]=i.data===void 0?null:i.data}get data(){return this[Lc]}};Object.defineProperty(kn.prototype,"data",{enumerable:!0});var Gl={addEventListener(n,e,i={}){for(let a of this.listeners(n))if(!i[Pn]&&a[ns]===e&&!a[Pn])return;let o;if(n==="message")o=function(c,f){let x=new kn("message",{data:f?c:c.toString()});x[nn]=this,kr(e,this,x)};else if(n==="close")o=function(c,f){let x=new At("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});x[nn]=this,kr(e,this,x)};else if(n==="error")o=function(c){let f=new rn("error",{error:c,message:c.message});f[nn]=this,kr(e,this,f)};else if(n==="open")o=function(){let c=new it("open");c[nn]=this,kr(e,this,c)};else return;o[Pn]=!!i[Pn],o[ns]=e,i.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let i of this.listeners(n))if(i[ns]===e&&!i[Pn]){this.removeListener(n,i);break}}};Uc.exports={CloseEvent:At,ErrorEvent:rn,Event:it,EventTarget:Gl,MessageEvent:kn};function kr(n,e,i){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,i):n.call(e,i)}});var Nr=ee((uy,Hc)=>{"use strict";var{tokenChars:Nn}=Qt();function Xe(n,e,i){n[e]===void 0?n[e]=[i]:n[e].push(i)}function jl(n){let e=Object.create(null),i=Object.create(null),o=!1,a=!1,c=!1,f,x,g=-1,p=-1,y=-1,v=0;for(;v<n.length;v++)if(p=n.charCodeAt(v),f===void 0)if(y===-1&&Nn[p]===1)g===-1&&(g=v);else if(v!==0&&(p===32||p===9))y===-1&&g!==-1&&(y=v);else if(p===59||p===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${v}`);y===-1&&(y=v);let E=n.slice(g,y);p===44?(Xe(e,E,i),i=Object.create(null)):f=E,g=y=-1}else throw new SyntaxError(`Unexpected character at index ${v}`);else if(x===void 0)if(y===-1&&Nn[p]===1)g===-1&&(g=v);else if(p===32||p===9)y===-1&&g!==-1&&(y=v);else if(p===59||p===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${v}`);y===-1&&(y=v),Xe(i,n.slice(g,y),!0),p===44&&(Xe(e,f,i),i=Object.create(null),f=void 0),g=y=-1}else if(p===61&&g!==-1&&y===-1)x=n.slice(g,v),g=y=-1;else throw new SyntaxError(`Unexpected character at index ${v}`);else if(a){if(Nn[p]!==1)throw new SyntaxError(`Unexpected character at index ${v}`);g===-1?g=v:o||(o=!0),a=!1}else if(c)if(Nn[p]===1)g===-1&&(g=v);else if(p===34&&g!==-1)c=!1,y=v;else if(p===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${v}`);else if(p===34&&n.charCodeAt(v-1)===61)c=!0;else if(y===-1&&Nn[p]===1)g===-1&&(g=v);else if(g!==-1&&(p===32||p===9))y===-1&&(y=v);else if(p===59||p===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${v}`);y===-1&&(y=v);let E=n.slice(g,y);o&&(E=E.replace(/\\/g,""),o=!1),Xe(i,x,E),p===44&&(Xe(e,f,i),i=Object.create(null),f=void 0),x=void 0,g=y=-1}else throw new SyntaxError(`Unexpected character at index ${v}`);if(g===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");y===-1&&(y=v);let A=n.slice(g,y);return f===void 0?Xe(e,A,i):(x===void 0?Xe(i,A,!0):o?Xe(i,x,A.replace(/\\/g,"")):Xe(i,x,A),Xe(e,f,i)),e}function Kl(n){return Object.keys(n).map(e=>{let i=n[e];return Array.isArray(i)||(i=[i]),i.map(o=>[e].concat(Object.keys(o).map(a=>{let c=o[a];return Array.isArray(c)||(c=[c]),c.map(f=>f===!0?a:`${a}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Hc.exports={format:Kl,parse:jl}});var Mr=ee((gy,e0)=>{"use strict";var Wl=ie("events"),Jl=ie("https"),$l=ie("http"),Kc=ie("net"),Vl=ie("tls"),{randomBytes:Zl,createHash:Yl}=ie("crypto"),{Duplex:xy,Readable:ly}=ie("stream"),{URL:rs}=ie("url"),_t=Xt(),Xl=Xi(),Ql=ts(),{isBlob:eg}=Qt(),{BINARY_TYPES:Gc,CLOSE_TIMEOUT:tg,EMPTY_BUFFER:Rr,GUID:ng,kForOnEventAttribute:is,kListener:rg,kStatusCode:ig,kWebSocket:Se,NOOP:Wc}=nt(),{EventTarget:{addEventListener:sg,removeEventListener:og}}=qc(),{format:ag,parse:cg}=Nr(),{toBuffer:dg}=Tn(),Jc=Symbol("kAborted"),ss=[8,13],st=["CONNECTING","OPEN","CLOSING","CLOSED"],fg=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,oe=class n extends Wl{constructor(e,i,o){super(),this._binaryType=Gc[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Rr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,i===void 0?i=[]:Array.isArray(i)||(typeof i=="object"&&i!==null?(o=i,i=[]):i=[i]),$c(this,e,i,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Gc.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,i,o){let a=new Xl({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),c=new Ql(e,this._extensions,o.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[Se]=this,c[Se]=this,e[Se]=this,a.on("conclude",lg),a.on("drain",gg),a.on("error",hg),a.on("message",pg),a.on("ping",mg),a.on("pong",wg),c.onerror=_g,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),i.length>0&&e.unshift(i),e.on("close",Yc),e.on("data",Or),e.on("end",Xc),e.on("error",Qc),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[_t.extensionName]&&this._extensions[_t.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,i){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Oe(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,i,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Zc(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=i=void 0):typeof i=="function"&&(o=i,i=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){os(this,e,o);return}i===void 0&&(i=!this._isServer),this._sender.ping(e||Rr,i,o)}pong(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=i=void 0):typeof i=="function"&&(o=i,i=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){os(this,e,o);return}i===void 0&&(i=!this._isServer),this._sender.pong(e||Rr,i,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof i=="function"&&(o=i,i={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){os(this,e,o);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...i};this._extensions[_t.extensionName]||(a.compress=!1),this._sender.send(e||Rr,a,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Oe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(oe,"CONNECTING",{enumerable:!0,value:st.indexOf("CONNECTING")});Object.defineProperty(oe.prototype,"CONNECTING",{enumerable:!0,value:st.indexOf("CONNECTING")});Object.defineProperty(oe,"OPEN",{enumerable:!0,value:st.indexOf("OPEN")});Object.defineProperty(oe.prototype,"OPEN",{enumerable:!0,value:st.indexOf("OPEN")});Object.defineProperty(oe,"CLOSING",{enumerable:!0,value:st.indexOf("CLOSING")});Object.defineProperty(oe.prototype,"CLOSING",{enumerable:!0,value:st.indexOf("CLOSING")});Object.defineProperty(oe,"CLOSED",{enumerable:!0,value:st.indexOf("CLOSED")});Object.defineProperty(oe.prototype,"CLOSED",{enumerable:!0,value:st.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(oe.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(oe.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[is])return e[rg];return null},set(e){for(let i of this.listeners(n))if(i[is]){this.removeListener(n,i);break}typeof e=="function"&&this.addEventListener(n,e,{[is]:!0})}})});oe.prototype.addEventListener=sg;oe.prototype.removeEventListener=og;e0.exports=oe;function $c(n,e,i,o){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:tg,protocolVersion:ss[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=a.autoPong,n._closeTimeout=a.closeTimeout,!ss.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${ss.join(", ")})`);let c;if(e instanceof rs)c=e;else try{c=new rs(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),n._url=c.href;let f=c.protocol==="wss:",x=c.protocol==="ws+unix:",g;if(c.protocol!=="ws:"&&!f&&!x?g=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:x&&!c.pathname?g="The URL's pathname is empty":c.hash&&(g="The URL contains a fragment identifier"),g){let I=new SyntaxError(g);if(n._redirects===0)throw I;Lr(n,I);return}let p=f?443:80,y=Zl(16).toString("base64"),v=f?Jl.request:$l.request,A=new Set,E;if(a.createConnection=a.createConnection||(f?xg:ug),a.defaultPort=a.defaultPort||p,a.port=c.port||p,a.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":y,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(E=new _t({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=ag({[_t.extensionName]:E.offer()})),i.length){for(let I of i){if(typeof I!="string"||!fg.test(I)||A.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(I)}a.headers["Sec-WebSocket-Protocol"]=i.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(c.username||c.password)&&(a.auth=`${c.username}:${c.password}`),x){let I=a.path.split(":");a.socketPath=I[0],a.path=I[1]}let b;if(a.followRedirects){if(n._redirects===0){n._originalIpc=x,n._originalSecure=f,n._originalHostOrSocketPath=x?a.socketPath:c.host;let I=o&&o.headers;if(o={...o,headers:{}},I)for(let[S,D]of Object.entries(I))o.headers[S.toLowerCase()]=D}else if(n.listenerCount("redirect")===0){let I=x?n._originalIpc?a.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:c.host===n._originalHostOrSocketPath;(!I||n._originalSecure&&!f)&&(delete a.headers.authorization,delete a.headers.cookie,I||delete a.headers.host,a.auth=void 0)}a.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),b=n._req=v(a),n._redirects&&n.emit("redirect",n.url,b)}else b=n._req=v(a);a.timeout&&b.on("timeout",()=>{Oe(n,b,"Opening handshake has timed out")}),b.on("error",I=>{b===null||b[Jc]||(b=n._req=null,Lr(n,I))}),b.on("response",I=>{let S=I.headers.location,D=I.statusCode;if(S&&a.followRedirects&&D>=300&&D<400){if(++n._redirects>a.maxRedirects){Oe(n,b,"Maximum redirects exceeded");return}b.abort();let O;try{O=new rs(S,e)}catch{let C=new SyntaxError(`Invalid URL: ${S}`);Lr(n,C);return}$c(n,O,i,o)}else n.emit("unexpected-response",b,I)||Oe(n,b,`Unexpected server response: ${I.statusCode}`)}),b.on("upgrade",(I,S,D)=>{if(n.emit("upgrade",I),n.readyState!==oe.CONNECTING)return;b=n._req=null;let O=I.headers.upgrade;if(O===void 0||O.toLowerCase()!=="websocket"){Oe(n,S,"Invalid Upgrade header");return}let m=Yl("sha1").update(y+ng).digest("base64");if(I.headers["sec-websocket-accept"]!==m){Oe(n,S,"Invalid Sec-WebSocket-Accept header");return}let C=I.headers["sec-websocket-protocol"],k;if(C!==void 0?A.size?A.has(C)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":A.size&&(k="Server sent no subprotocol"),k){Oe(n,S,k);return}C&&(n._protocol=C);let F=I.headers["sec-websocket-extensions"];if(F!==void 0){if(!E){Oe(n,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=cg(F)}catch{Oe(n,S,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(B);if(P.length!==1||P[0]!==_t.extensionName){Oe(n,S,"Server indicated an extension that was not requested");return}try{E.accept(B[_t.extensionName])}catch{Oe(n,S,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[_t.extensionName]=E}n.setSocket(S,D,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(b,n):b.end()}function Lr(n,e){n._readyState=oe.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function ug(n){return n.path=n.socketPath,Kc.connect(n)}function xg(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Kc.isIP(n.host)?"":n.host),Vl.connect(n)}function Oe(n,e,i){n._readyState=oe.CLOSING;let o=new Error(i);Error.captureStackTrace(o,Oe),e.setHeader?(e[Jc]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Lr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function os(n,e,i){if(e){let o=eg(e)?e.size:dg(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(i){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${st[n.readyState]})`);process.nextTick(i,o)}}function lg(n,e){let i=this[Se];i._closeFrameReceived=!0,i._closeMessage=e,i._closeCode=n,i._socket[Se]!==void 0&&(i._socket.removeListener("data",Or),process.nextTick(Vc,i._socket),n===1005?i.close():i.close(n,e))}function gg(){let n=this[Se];n.isPaused||n._socket.resume()}function hg(n){let e=this[Se];e._socket[Se]!==void 0&&(e._socket.removeListener("data",Or),process.nextTick(Vc,e._socket),e.close(n[ig])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function jc(){this[Se].emitClose()}function pg(n,e){this[Se].emit("message",n,e)}function mg(n){let e=this[Se];e._autoPong&&e.pong(n,!this._isServer,Wc),e.emit("ping",n)}function wg(n){this[Se].emit("pong",n)}function Vc(n){n.resume()}function _g(n){let e=this[Se];e.readyState!==oe.CLOSED&&(e.readyState===oe.OPEN&&(e._readyState=oe.CLOSING,Zc(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Zc(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function Yc(){let n=this[Se];if(this.removeListener("close",Yc),this.removeListener("data",Or),this.removeListener("end",Xc),n._readyState=oe.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[Se]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",jc),n._receiver.on("finish",jc))}function Or(n){this[Se]._receiver.write(n)||this.pause()}function Xc(){let n=this[Se];n._readyState=oe.CLOSING,n._receiver.end(),this.end()}function Qc(){let n=this[Se];this.removeListener("error",Qc),this.on("error",Wc),n&&(n._readyState=oe.CLOSING,this.destroy())}});var i0=ee((py,r0)=>{"use strict";var hy=Mr(),{Duplex:yg}=ie("stream");function t0(n){n.emit("close")}function Eg(){!this.destroyed&&this._writableState.finished&&this.destroy()}function n0(n){this.removeListener("error",n0),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function bg(n,e){let i=!0,o=new yg({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(c,f){let x=!f&&o._readableState.objectMode?c.toString():c;o.push(x)||n.pause()}),n.once("error",function(c){o.destroyed||(i=!1,o.destroy(c))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(a,c){if(n.readyState===n.CLOSED){c(a),process.nextTick(t0,o);return}let f=!1;n.once("error",function(g){f=!0,c(g)}),n.once("close",function(){f||c(a),process.nextTick(t0,o)}),i&&n.terminate()},o._final=function(a){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(a)});return}n._socket!==null&&(n._socket._writableState.finished?(a(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){a()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(a,c,f){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(a,c,f)});return}n.send(a,f)},o.on("end",Eg),o.on("error",n0),o}r0.exports=bg});var as=ee((my,s0)=>{"use strict";var{tokenChars:vg}=Qt();function Sg(n){let e=new Set,i=-1,o=-1,a=0;for(a;a<n.length;a++){let f=n.charCodeAt(a);if(o===-1&&vg[f]===1)i===-1&&(i=a);else if(a!==0&&(f===32||f===9))o===-1&&i!==-1&&(o=a);else if(f===44){if(i===-1)throw new SyntaxError(`Unexpected character at index ${a}`);o===-1&&(o=a);let x=n.slice(i,o);if(e.has(x))throw new SyntaxError(`The "${x}" subprotocol is duplicated`);e.add(x),i=o=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(i===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let c=n.slice(i,a);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}s0.exports={parse:Sg}});var x0=ee((_y,u0)=>{"use strict";var Ig=ie("events"),Br=ie("http"),{Duplex:wy}=ie("stream"),{createHash:Cg}=ie("crypto"),o0=Nr(),Tt=Xt(),Ag=as(),Tg=Mr(),{CLOSE_TIMEOUT:Dg,GUID:Pg,kWebSocket:kg}=nt(),Ng=/^[+/0-9A-Za-z]{22}==$/,a0=0,c0=1,f0=2,cs=class extends Ig{constructor(e,i){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Dg,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Tg,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Br.createServer((o,a)=>{let c=Br.STATUS_CODES[426];a.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),a.end(c)}),this._server.listen(e.port,e.host,e.backlog,i)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=Rg(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,c,f)=>{this.handleUpgrade(a,c,f,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=a0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===f0){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Rn,this);return}if(e&&this.once("close",e),this._state!==c0)if(this._state=c0,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Rn,this):process.nextTick(Rn,this);else{let i=this._server;this._removeListeners(),this._removeListeners=this._server=null,i.close(()=>{Rn(this)})}}shouldHandle(e){if(this.options.path){let i=e.url.indexOf("?");if((i!==-1?e.url.slice(0,i):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,i,o,a){i.on("error",d0);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,x=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Dt(this,e,i,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){Dt(this,e,i,400,"Invalid Upgrade header");return}if(c===void 0||!Ng.test(c)){Dt(this,e,i,400,"Missing or invalid Sec-WebSocket-Key header");return}if(x!==13&&x!==8){Dt(this,e,i,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ln(i,400);return}let g=e.headers["sec-websocket-protocol"],p=new Set;if(g!==void 0)try{p=Ag.parse(g)}catch{Dt(this,e,i,400,"Invalid Sec-WebSocket-Protocol header");return}let y=e.headers["sec-websocket-extensions"],v={};if(this.options.perMessageDeflate&&y!==void 0){let A=new Tt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let E=o0.parse(y);E[Tt.extensionName]&&(A.accept(E[Tt.extensionName]),v[Tt.extensionName]=A)}catch{Dt(this,e,i,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${x===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(E,b,I,S)=>{if(!E)return Ln(i,b||401,I,S);this.completeUpgrade(v,c,p,e,i,o,a)});return}if(!this.options.verifyClient(A))return Ln(i,401)}this.completeUpgrade(v,c,p,e,i,o,a)}completeUpgrade(e,i,o,a,c,f,x){if(!c.readable||!c.writable)return c.destroy();if(c[kg])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>a0)return Ln(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Cg("sha1").update(i+Pg).digest("base64")}`],y=new this.options.WebSocket(null,void 0,this.options);if(o.size){let v=this.options.handleProtocols?this.options.handleProtocols(o,a):o.values().next().value;v&&(p.push(`Sec-WebSocket-Protocol: ${v}`),y._protocol=v)}if(e[Tt.extensionName]){let v=e[Tt.extensionName].params,A=o0.format({[Tt.extensionName]:[v]});p.push(`Sec-WebSocket-Extensions: ${A}`),y._extensions=e}this.emit("headers",p,a),c.write(p.concat(`\r
|
|
8
|
+
var zh=Object.create;var Wo=Object.defineProperty;var Fh=Object.getOwnPropertyDescriptor;var Uh=Object.getOwnPropertyNames;var qh=Object.getPrototypeOf,Hh=Object.prototype.hasOwnProperty;var ae=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var at=(t,e)=>()=>(t&&(e=t(t=0)),e);var ne=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ko=(t,e)=>{for(var r in e)Wo(t,r,{get:e[r],enumerable:!0})},jh=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Uh(e))!Hh.call(t,a)&&a!==r&&Wo(t,a,{get:()=>e[a],enumerable:!(s=Fh(e,a))||s.enumerable});return t};var ht=(t,e,r)=>(r=t!=null?zh(qh(t)):{},jh(e||!t||!t.__esModule?Wo(r,"default",{value:t,enumerable:!0}):r,t));function k0(t){$o=t}function P0(t){return zi[$o]<=zi[t]}function Fi(t){D0={...t}}function Kh(t){let e=(u,x=2)=>String(u).padStart(x,"0"),r=-t.getTimezoneOffset(),s=r>=0?"+":"-",a=Math.abs(r),c=e(Math.floor(a/60)),f=e(a%60);return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${s}${c}:${f}`}function Bi(t,e,r,s){if(zi[t]<zi[$o])return;let a=JSON.stringify({ts:Kh(new Date),level:t,module:e,msg:r,...D0,...s});t==="error"||t==="warn"?Wh.write(`${a}
|
|
9
|
+
`):Gh.write(`${a}
|
|
10
|
+
`)}function j(t){return{debug:(e,r)=>Bi("debug",t,e,r),info:(e,r)=>Bi("info",t,e,r),warn:(e,r)=>Bi("warn",t,e,r),error:(e,r)=>Bi("error",t,e,r),child:e=>j(`${t}.${e}`)}}var zi,$o,Gh,Wh,D0,ee=at(()=>{"use strict";zi={debug:10,info:20,warn:30,error:40},$o=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Gh=process.stdout,Wh=process.stderr,D0={}});import{execFile as $h,spawn as Yh,spawnSync as dE}from"node:child_process";import{promisify as Jh}from"node:util";function Vh(t){if(process.platform!=="win32")return!1;if(O0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(O0,"").toLowerCase();return Zh.has(r)}function L0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return Vh(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function Wn(t,e=[],r={}){return Yh(t,e,L0(t,r))}function Kn(t,e=[],r={}){return Xh(t,e,L0(t,r))}var Zh,O0,Xh,$n=at(()=>{"use strict";Zh=new Set(["npm","npx","yarn","pnpm","coze","tsx"]),O0=/\.(cmd|bat|ps1)$/i;Xh=Jh($h)});var z0={};Ko(z0,{_resetAcpInstallerForTests:()=>ap,_setInFlightForTests:()=>cp,ensureAcpInstalled:()=>mn,formatExecError:()=>B0,getAcpBinaryPath:()=>wn,getAcpPackageSpec:()=>Br,getInFlightInstall:()=>Jo,probeAcpVersion:()=>sp});function Br(t){let e=Yo[t];if(e)return`${e.npmPackage}@${e.versionSpec}`}function ip(t){let e=t?.code;if(e&&tp.has(e))return!0;let r=t instanceof Error?`${t.message}
|
|
11
|
+
${t.stack??""}`:String(t);return np.test(r)||rp.test(r)}function B0(t){if(t==null||typeof t!="object")return String(t);let e=t,r=[];e.message&&r.push(e.message),e.code!==void 0&&e.code!==null&&r.push(`code=${e.code}`),e.signal&&r.push(`signal=${e.signal}`);let s=e.stderr?.toString().trim();s&&r.push(`stderr=${s.slice(0,2e3)}`);let a=e.stdout?.toString().trim();return a&&r.push(`stdout=${a.slice(0,2e3)}`),r.length>0?r.join(" | "):String(t)}async function N0(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await Kn(e,[t],{timeout:M0});return r.split(`
|
|
12
|
+
`)[0]?.trim()||void 0}catch{return}}async function sp(t){let e=Yo[t];if(e)try{let{stdout:r}=await Kn(e.binary,["--version"],{timeout:M0});return r.split(`
|
|
13
|
+
`)[0]?.trim()||void 0}catch{return}}async function op(t,e,r){Nr.info("npm install -g start",{npmPackage:t,versionSpec:e}),await Kn("npm",["install","-g",`${t}@${e}`],{timeout:Qh,maxBuffer:10*1024*1024,...r?{signal:r}:{}}),Nr.info("npm install -g done",{npmPackage:t,versionSpec:e})}async function mn(t,e){let r=Yo[t];if(!r)return;let s=Mr.get(t);if(s)return s;let a=Lr.get(t);if(a&&Date.now()-a<ep)return;let c=Yn.get(t);if(c)return c;let f=(async()=>{let u=await N0(r.binary);if(u)return Mr.set(t,u),Nr.info("acp wrapper found on PATH",{binary:r.binary,path:u}),u;try{await op(r.npmPackage,r.versionSpec,e)}catch(h){let w=ip(h);Nr.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:r.npmPackage,transient:w,err:B0(h)}),w||Lr.set(t,Date.now());return}let x=await N0(r.binary);if(!x){Nr.warn("acp wrapper installed but binary not found on PATH",{binary:r.binary}),Lr.set(t,Date.now());return}return Mr.set(t,x),Lr.delete(t),x})().finally(()=>{Yn.delete(t)});return Yn.set(t,f),f}function wn(t){return Mr.get(t)}function Jo(t){return Yn.get(t)}function ap(){Mr.clear(),Lr.clear(),Yn.clear()}function cp(t,e){Yn.set(t,e)}var Nr,Yo,Qh,M0,ep,tp,np,rp,Mr,Lr,Yn,_n=at(()=>{"use strict";$n();ee();Nr=j("agents.acp-installer"),Yo={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp",versionSpec:"^0.37"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp",versionSpec:"^0.15"}};Qh=5e4,M0=5e3,ep=5*6e4,tp=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),np=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,rp=/fetch failed|request timed out|socket hang up|network timeout/i;Mr=new Map,Lr=new Map,Yn=new Map});import{chmod as fp,mkdir as up,readFile as lp,rename as q0,writeFile as H0}from"node:fs/promises";import{dirname as xp}from"node:path";async function Jn(t){try{let e=await lp(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Ui(t,e,r){await up(xp(t),{recursive:!0});let s=`${JSON.stringify(e,null,2)}
|
|
14
|
+
`,a=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await H0(a,s,{encoding:"utf8",mode:r.mode}):await H0(a,s,"utf8"),await q0(a,t),r?.mode!==void 0&&await fp(t,r.mode)}catch(c){await q0(a,a).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(a,{force:!0}).catch(()=>{}),c}}var qi=at(()=>{"use strict"});import{promises as j0}from"node:fs";import{homedir as hp}from"node:os";import{sep as pp,join as Me,resolve as G0}from"node:path";function te(t){let e=t??hp(),r=Me(e,".coze"),s=Me(r,"bridge"),a=Me(s,"lib");return{cozeRoot:r,bridgeRoot:s,libDir:a,libEntry:Me(a,"index.js"),binDir:Me(s,"bin"),pidFile:Me(s,"bridge.pid"),portFile:Me(s,"bridge.port"),tokenFile:Me(s,"bridge.token"),patTokenFile:Me(s,"pat-token"),logFile:Me(s,"bridge.log"),installLock:Me(s,"install.lock"),configFile:Me(s,"config.json"),agentsRoot:Me(r,"agents")}}function Dt(t,e=te()){let r=Me(e.agentsRoot,t);return{root:r,config:Me(r,"config.json"),workspace:Me(r,"workspace"),logs:Me(r,"logs")}}async function zr(t,e){let r=await j0.realpath(G0(t)).catch(()=>null);if(!r)return!1;let s=await j0.realpath(G0(e)).catch(()=>null);if(!s)return!1;let a=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?s.toLowerCase():s;return a===c||a.startsWith(c+pp)}var Be=at(()=>{"use strict"});var Gi={};Ko(Gi,{AGENT_CONFIG_FILE_MODE:()=>Hi,enforceAgentConfigMode:()=>wp,loadAgentConfig:()=>qe,persistAgentSessions:()=>Zo,persistAgentSkills:()=>ji,saveAgentConfig:()=>$e});import{chmod as gp,stat as mp}from"node:fs/promises";function qe(t,e){return Jn(Dt(t,e).config)}function $e(t,e){return Ui(Dt(t.agentId,e).config,t,{mode:Hi})}async function wp(t,e){if(process.platform==="win32")return;let r=Dt(t,e).config;try{let s=await mp(r);if(!s.isFile())return;let a=s.mode&511;a!==Hi&&(await gp(r,Hi),W0.warn("agent config mode auto-corrected to 0600",{path:r,from:a.toString(8)}))}catch(s){if(s.code==="ENOENT")return;W0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(s)})}}async function Zo(t,e,r){let s=await qe(t,r);s&&(s.sessions=Object.fromEntries(e),await $e(s,r))}async function ji(t,e,r){let s=await qe(t,r);s&&(s.skills=e,await $e(s,r))}var W0,Hi,$t=at(()=>{"use strict";qi();ee();Be();W0=j("agent-config"),Hi=384});var Xo=ne((ME,J0)=>{J0.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Ki=ne(V0=>{var Z0={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Cp(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,s)=>e[s]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(Z0))V0[t]=Cp(Z0[t])});var nd=ne((zE,td)=>{var Tp=ae("fs"),ve=ae("path"),X0=Xo(),Ap=Ki(),Rp=typeof process=="object"&&process.platform==="win32",Q0=t=>typeof t=="object"&&t!==null,ed=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function he(t){this.sep=ve.sep,this.fs=Tp,Q0(t)&&Q0(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}td.exports=he;he.prototype.makeDir=function(t){let e=this;function r(s){let a=s.split(e.sep)[0];s.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){a+=e.sep+c;var f;try{f=e.fs.statSync(a)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw u}if(f&&f.isFile())throw Ap.FILE_IN_THE_WAY(`"${a}"`)}})}r(t)};he.prototype.writeFileTo=function(t,e,r,s){let a=this;if(a.fs.existsSync(t)){if(!r)return!1;var c=a.fs.statSync(t);if(c.isDirectory())return!1}var f=ve.dirname(t);a.fs.existsSync(f)||a.makeDir(f);var u;try{u=a.fs.openSync(t,"w",438)}catch{a.fs.chmodSync(t,438),u=a.fs.openSync(t,"w",438)}if(u)try{a.fs.writeSync(u,e,0,e.length,0)}finally{a.fs.closeSync(u)}return a.fs.chmodSync(t,s||438),!0};he.prototype.writeFileToAsync=function(t,e,r,s,a){typeof s=="function"&&(a=s,s=void 0);let c=this;c.fs.exists(t,function(f){if(f&&!r)return a(!1);c.fs.stat(t,function(u,x){if(f&&x.isDirectory())return a(!1);var h=ve.dirname(t);c.fs.exists(h,function(w){w||c.makeDir(h),c.fs.open(t,"w",438,function(E,C){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,b){c.fs.write(b,e,0,e.length,0,function(){c.fs.close(b,function(){c.fs.chmod(t,s||438,function(){a(!0)})})})})}):C?c.fs.write(C,e,0,e.length,0,function(){c.fs.close(C,function(){c.fs.chmod(t,s||438,function(){a(!0)})})}):c.fs.chmod(t,s||438,function(){a(!0)})})})})})};he.prototype.findFiles=function(t){let e=this;function r(s,a,c){typeof a=="boolean"&&(c=a,a=void 0);let f=[];return e.fs.readdirSync(s).forEach(function(u){let x=ve.join(s,u),h=e.fs.statSync(x);(!a||a.test(x))&&f.push(ve.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(f=f.concat(r(x,a,c)))}),f}return r(t,void 0,!0)};he.prototype.findFilesAsync=function(t,e){let r=this,s=[];r.fs.readdir(t,function(a,c){if(a)return e(a);let f=c.length;if(!f)return e(null,s);c.forEach(function(u){u=ve.join(t,u),r.fs.stat(u,function(x,h){if(x)return e(x);h&&(s.push(ve.normalize(u)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(u,function(w,E){if(w)return e(w);s=s.concat(E),--f||e(null,s)}):--f||e(null,s))})})})};he.prototype.getAttributes=function(){};he.prototype.setAttributes=function(){};he.crc32update=function(t,e){return ed[(t^e)&255]^t>>>8};he.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let s=0;s<e;)r=he.crc32update(r,t[s++]);return~r>>>0};he.methodToString=function(t){switch(t){case X0.STORED:return"STORED ("+t+")";case X0.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};he.canonical=function(t){if(!t)return"";let e=ve.posix.normalize("/"+t.split("\\").join("/"));return ve.join(".",e)};he.zipnamefix=function(t){if(!t)return"";let e=ve.posix.normalize("/"+t.split("\\").join("/"));return ve.posix.join(".",e)};he.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let s=r-1;s>=0;s--)if(e(t[s],s,t))return t[s]};he.sanitize=function(t,e){t=ve.resolve(ve.normalize(t));for(var r=e.split("/"),s=0,a=r.length;s<a;s++){var c=ve.normalize(ve.join(t,r.slice(s,a).join(ve.sep)));if(c.indexOf(t)===0)return c}return ve.normalize(ve.join(t,ve.basename(e)))};he.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};he.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};he.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};he.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};he.isWin=Rp;he.crcTable=ed});var id=ne((FE,rd)=>{var Dp=ae("path");rd.exports=function(t,{fs:e}){var r=t||"",s=c(),a=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(a=e.statSync(r),s.directory=a.isDirectory(),s.mtime=a.mtime,s.atime=a.atime,s.executable=(73&a.mode)!==0,s.readonly=(128&a.mode)===0,s.hidden=Dp.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return s.directory},get readOnly(){return s.readonly},get hidden(){return s.hidden},get mtime(){return s.mtime},get atime(){return s.atime},get executable(){return s.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:s.directory,isReadOnly:s.readonly,isHidden:s.hidden,isExecutable:s.executable,mTime:s.mtime,aTime:s.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var od=ne((UE,sd)=>{sd.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Xn=ne((qE,Vn)=>{Vn.exports=nd();Vn.exports.Constants=Xo();Vn.exports.Errors=Ki();Vn.exports.FileAttr=id();Vn.exports.decoder=od()});var cd=ne((HE,ad)=>{var Yt=Xn(),q=Yt.Constants;ad.exports=function(){var t=20,e=10,r=0,s=0,a=0,c=0,f=0,u=0,x=0,h=0,w=0,E=0,C=0,y=0,b=0;t|=Yt.isWin?2560:768,r|=q.FLG_EFS;let v={extraLen:0},I=_=>Math.max(0,_)>>>0,k=_=>Math.max(0,_)&65535,L=_=>Math.max(0,_)&255;return a=Yt.fromDate2DOS(new Date),{get made(){return t},set made(_){t=_},get version(){return e},set version(_){e=_},get flags(){return r},set flags(_){r=_},get flags_efs(){return(r&q.FLG_EFS)>0},set flags_efs(_){_?r|=q.FLG_EFS:r&=~q.FLG_EFS},get flags_desc(){return(r&q.FLG_DESC)>0},set flags_desc(_){_?r|=q.FLG_DESC:r&=~q.FLG_DESC},get method(){return s},set method(_){switch(_){case q.STORED:this.version=10;case q.DEFLATED:default:this.version=20}s=_},get time(){return Yt.fromDOS2Date(this.timeval)},set time(_){_=new Date(_),this.timeval=Yt.fromDate2DOS(_)},get timeval(){return a},set timeval(_){a=I(_)},get timeHighByte(){return L(a>>>8)},get crc(){return c},set crc(_){c=I(_)},get compressedSize(){return f},set compressedSize(_){f=I(_)},get size(){return u},set size(_){u=I(_)},get fileNameLength(){return x},set fileNameLength(_){x=_},get extraLength(){return h},set extraLength(_){h=_},get extraLocalLength(){return v.extraLen},set extraLocalLength(_){v.extraLen=_},get commentLength(){return w},set commentLength(_){w=_},get diskNumStart(){return E},set diskNumStart(_){E=I(_)},get inAttr(){return C},set inAttr(_){C=I(_)},get attr(){return y},set attr(_){y=I(_)},get fileAttr(){return(y||0)>>16&4095},get offset(){return b},set offset(_){b=I(_)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+h+w},get realDataOffset(){return b+q.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(_){var T=_.slice(b,b+q.LOCHDR);if(T.readUInt32LE(0)!==q.LOCSIG)throw Yt.Errors.INVALID_LOC();v.version=T.readUInt16LE(q.LOCVER),v.flags=T.readUInt16LE(q.LOCFLG),v.flags_desc=(v.flags&q.FLG_DESC)>0,v.method=T.readUInt16LE(q.LOCHOW),v.time=T.readUInt32LE(q.LOCTIM),v.crc=T.readUInt32LE(q.LOCCRC),v.compressedSize=T.readUInt32LE(q.LOCSIZ),v.size=T.readUInt32LE(q.LOCLEN),v.fnameLen=T.readUInt16LE(q.LOCNAM),v.extraLen=T.readUInt16LE(q.LOCEXT);let O=b+q.LOCHDR+v.fnameLen,F=O+v.extraLen;return _.slice(O,F)},loadFromBinary:function(_){if(_.length!==q.CENHDR||_.readUInt32LE(0)!==q.CENSIG)throw Yt.Errors.INVALID_CEN();t=_.readUInt16LE(q.CENVEM),e=_.readUInt16LE(q.CENVER),r=_.readUInt16LE(q.CENFLG),s=_.readUInt16LE(q.CENHOW),a=_.readUInt32LE(q.CENTIM),c=_.readUInt32LE(q.CENCRC),f=_.readUInt32LE(q.CENSIZ),u=_.readUInt32LE(q.CENLEN),x=_.readUInt16LE(q.CENNAM),h=_.readUInt16LE(q.CENEXT),w=_.readUInt16LE(q.CENCOM),E=_.readUInt16LE(q.CENDSK),C=_.readUInt16LE(q.CENATT),y=_.readUInt32LE(q.CENATX),b=_.readUInt32LE(q.CENOFF)},localHeaderToBinary:function(){var _=Buffer.alloc(q.LOCHDR);return _.writeUInt32LE(q.LOCSIG,0),_.writeUInt16LE(e,q.LOCVER),_.writeUInt16LE(r,q.LOCFLG),_.writeUInt16LE(s,q.LOCHOW),_.writeUInt32LE(a,q.LOCTIM),_.writeUInt32LE(c,q.LOCCRC),_.writeUInt32LE(f,q.LOCSIZ),_.writeUInt32LE(u,q.LOCLEN),_.writeUInt16LE(x,q.LOCNAM),_.writeUInt16LE(v.extraLen,q.LOCEXT),_},centralHeaderToBinary:function(){var _=Buffer.alloc(q.CENHDR+x+h+w);return _.writeUInt32LE(q.CENSIG,0),_.writeUInt16LE(t,q.CENVEM),_.writeUInt16LE(e,q.CENVER),_.writeUInt16LE(r,q.CENFLG),_.writeUInt16LE(s,q.CENHOW),_.writeUInt32LE(a,q.CENTIM),_.writeUInt32LE(c,q.CENCRC),_.writeUInt32LE(f,q.CENSIZ),_.writeUInt32LE(u,q.CENLEN),_.writeUInt16LE(x,q.CENNAM),_.writeUInt16LE(h,q.CENEXT),_.writeUInt16LE(w,q.CENCOM),_.writeUInt16LE(E,q.CENDSK),_.writeUInt16LE(C,q.CENATT),_.writeUInt32LE(y,q.CENATX),_.writeUInt32LE(b,q.CENOFF),_},toJSON:function(){let _=function(T){return T+" bytes"};return{made:t,version:e,flags:r,method:Yt.methodToString(s),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:_(f),size:_(u),fileNameLength:_(x),extraLength:_(h),commentLength:_(w),diskNumStart:E,inAttr:C,attr:y,offset:b,centralHeaderSize:_(q.CENHDR+x+h+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var fd=ne((jE,dd)=>{var Qn=Xn(),ue=Qn.Constants;dd.exports=function(){var t=0,e=0,r=0,s=0,a=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return s},set offset(c){s=c},get commentLength(){return a},set commentLength(c){a=c},get mainHeaderSize(){return ue.ENDHDR+a},loadFromBinary:function(c){if((c.length!==ue.ENDHDR||c.readUInt32LE(0)!==ue.ENDSIG)&&(c.length<ue.ZIP64HDR||c.readUInt32LE(0)!==ue.ZIP64SIG))throw Qn.Errors.INVALID_END();c.readUInt32LE(0)===ue.ENDSIG?(t=c.readUInt16LE(ue.ENDSUB),e=c.readUInt16LE(ue.ENDTOT),r=c.readUInt32LE(ue.ENDSIZ),s=c.readUInt32LE(ue.ENDOFF),a=c.readUInt16LE(ue.ENDCOM)):(t=Qn.readBigUInt64LE(c,ue.ZIP64SUB),e=Qn.readBigUInt64LE(c,ue.ZIP64TOT),r=Qn.readBigUInt64LE(c,ue.ZIP64SIZE),s=Qn.readBigUInt64LE(c,ue.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(ue.ENDHDR+a);return c.writeUInt32LE(ue.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,ue.ENDSUB),c.writeUInt16LE(e,ue.ENDTOT),c.writeUInt32LE(r,ue.ENDSIZ),c.writeUInt32LE(s,ue.ENDOFF),c.writeUInt16LE(a,ue.ENDCOM),c.fill(" ",ue.ENDHDR),c},toJSON:function(){let c=function(f,u){let x=f.toString(16).toUpperCase();for(;x.length<u;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(s,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ea=ne(Qo=>{Qo.EntryHeader=cd();Qo.MainHeader=fd()});var ld=ne((WE,ud)=>{ud.exports=function(t){var e=ae("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(s){var a=e.createDeflateRaw(r),c=[],f=0;a.on("data",function(u){c.push(u),f+=u.length}),a.on("end",function(){var u=Buffer.alloc(f),x=0;u.fill(0);for(var h=0;h<c.length;h++){var w=c[h];w.copy(u,x),x+=w.length}s&&s(u)}),a.end(t)}}}});var hd=ne((KE,xd)=>{var kp=+(process.versions?process.versions.node:"").split(".")[0]||0;xd.exports=function(t,e){var r=ae("zlib");let s=kp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,s)},inflateAsync:function(a){var c=r.createInflateRaw(s),f=[],u=0;c.on("data",function(x){f.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),h=0;x.fill(0);for(var w=0;w<f.length;w++){var E=f[w];E.copy(x,h),h+=E.length}a&&a(x)}),c.end(t)}}}});var _d=ne(($E,wd)=>{"use strict";var{randomFillSync:pd}=ae("crypto"),Pp=Ki(),Op=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),md=(t,e)=>Math.imul(t,e)>>>0,gd=(t,e)=>Op[(t^e)&255]^t>>>8,Fr=()=>typeof pd=="function"?pd(Buffer.alloc(12)):Fr.node();Fr.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var $i={genSalt:Fr};function Yi(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}Yi.prototype.updateKeys=function(t){let e=this.keys;return e[0]=gd(e[0],t),e[1]+=e[0]&255,e[1]=md(e[1],134775813)+1,e[2]=gd(e[2],e[1]>>>24),t};Yi.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return md(t,t^1)>>8&255};function Lp(t){let e=new Yi(t);return function(r){let s=Buffer.alloc(r.length),a=0;for(let c of r)s[a++]=e.updateKeys(c^e.next());return s}}function Np(t){let e=new Yi(t);return function(r,s,a=0){s||(s=Buffer.alloc(r.length));for(let c of r){let f=e.next();s[a++]=c^f,e.updateKeys(c)}return s}}function Mp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let s=Lp(r),a=s(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw Pp.WRONG_PASSWORD();return s(t.slice(12))}function Bp(t){Buffer.isBuffer(t)&&t.length>=12?$i.genSalt=function(){return t.slice(0,12)}:t==="node"?$i.genSalt=Fr.node:$i.genSalt=Fr}function zp(t,e,r,s=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let a=Np(r),c=$i.genSalt();c[11]=e.crc>>>24&255,s&&(c[10]=e.crc>>>16&255);let f=Buffer.alloc(t.length+12);return a(c,f),a(t,f,12)}wd.exports={decrypt:Mp,encrypt:zp,_salter:Bp}});var yd=ne(Ji=>{Ji.Deflater=ld();Ji.Inflater=hd();Ji.ZipCrypto=_d()});var na=ne((JE,bd)=>{var re=Xn(),Fp=ea(),pe=re.Constants,ta=yd();bd.exports=function(t,e){var r=new Fp.EntryHeader,s=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,f=null,u=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let w=t,E=typeof w.decoder=="object"?w.decoder:re.decoder;h=E.hasOwnProperty("efs")?E.efs:!1;function C(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function y(_){if(!r.flags_desc&&!r.localHeader.flags_desc){if(re.crc32(_)!==r.localHeader.crc)return!1}else{let T={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==pe.LOCSIG||e.readUInt32LE(O)==pe.CENSIG)throw re.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==pe.EXTSIG)T.crc=e.readUInt32LE(O+pe.EXTCRC),T.compressedSize=e.readUInt32LE(O+pe.EXTSIZ),T.size=e.readUInt32LE(O+pe.EXTLEN);else if(e.readUInt16LE(O+12)===19280)T.crc=e.readUInt32LE(O+pe.EXTCRC-4),T.compressedSize=e.readUInt32LE(O+pe.EXTSIZ-4),T.size=e.readUInt32LE(O+pe.EXTLEN-4);else throw re.Errors.DESCRIPTOR_UNKNOWN();if(T.compressedSize!==r.compressedSize||T.size!==r.size||T.crc!==r.crc)throw re.Errors.DESCRIPTOR_FAULTY();if(re.crc32(_)!==T.crc)return!1}return!0}function b(_,T,O){if(typeof T>"u"&&typeof _=="string"&&(O=_,_=void 0),c)return _&&T&&T(Buffer.alloc(0),re.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=C();if(F.length===0)return _&&T&&T(F),F;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw re.Errors.INVALID_PASS_PARAM();F=ta.ZipCrypto.decrypt(F,r,O)}var z=Buffer.alloc(r.size);switch(r.method){case re.Constants.STORED:if(F.copy(z),y(z))return _&&T&&T(z),z;throw _&&T&&T(z,re.Errors.BAD_CRC()),re.Errors.BAD_CRC();case re.Constants.DEFLATED:var P=new ta.Inflater(F,r.size);if(_)P.inflateAsync(function(N){N.copy(N,0),T&&(y(N)?T(N):T(N,re.Errors.BAD_CRC()))});else{if(P.inflate(z).copy(z,0),!y(z))throw re.Errors.BAD_CRC(`"${E.decode(s)}"`);return z}break;default:throw _&&T&&T(Buffer.alloc(0),re.Errors.UNKNOWN_METHOD()),re.Errors.UNKNOWN_METHOD()}}function v(_,T){if((!f||!f.length)&&Buffer.isBuffer(e))return _&&T&&T(C()),C();if(f.length&&!c){var O;switch(r.method){case re.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(f.length),f.copy(O),_&&T&&T(O),O;default:case re.Constants.DEFLATED:var F=new ta.Deflater(f);if(_)F.deflateAsync(function(P){O=Buffer.alloc(P.length),r.compressedSize=P.length,P.copy(O),T&&T(O)});else{var z=F.deflate();return r.compressedSize=z.length,z}F=null;break}}else if(_&&T)T(Buffer.alloc(0));else return Buffer.alloc(0)}function I(_,T){return re.readBigUInt64LE(_,T)}function k(_){try{for(var T=0,O,F,z;T+4<_.length;)O=_.readUInt16LE(T),T+=2,F=_.readUInt16LE(T),T+=2,z=_.slice(T,T+F),T+=F,pe.ID_ZIP64===O&&L(z)}catch{throw re.Errors.EXTRA_FIELD_PARSE_ERROR()}}function L(_){var T,O,F,z;_.length>=pe.EF_ZIP64_SCOMP&&(T=I(_,pe.EF_ZIP64_SUNCOMP),r.size===pe.EF_ZIP64_OR_32&&(r.size=T)),_.length>=pe.EF_ZIP64_RHO&&(O=I(_,pe.EF_ZIP64_SCOMP),r.compressedSize===pe.EF_ZIP64_OR_32&&(r.compressedSize=O)),_.length>=pe.EF_ZIP64_DSN&&(F=I(_,pe.EF_ZIP64_RHO),r.offset===pe.EF_ZIP64_OR_32&&(r.offset=F)),_.length>=pe.EF_ZIP64_DSN+4&&(z=_.readUInt32LE(pe.EF_ZIP64_DSN),r.diskNumStart===pe.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return E.decode(s)},get rawEntryName(){return s},set entryName(_){s=re.toBuffer(_,E.encode);var T=s[s.length-1];c=T===47||T===92,r.fileNameLength=s.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return u},set extra(_){u=_,r.extraLength=_.length,k(_)},get comment(){return E.decode(a)},set comment(_){if(a=re.toBuffer(_,E.encode),r.commentLength=a.length,a.length>65535)throw re.Errors.COMMENT_TOO_LONG()},get name(){var _=E.decode(s);return c?_.substr(_.length-1).split("/").pop():_.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return v(!1,null)},getCompressedDataAsync:function(_){v(!0,_)},setData:function(_){f=re.toBuffer(_,re.decoder.encode),!c&&f.length?(r.size=f.length,r.method=re.Constants.DEFLATED,r.crc=re.crc32(_),r.changed=!0):r.method=re.Constants.STORED},getData:function(_){return r.changed?f:b(!1,null,_)},getDataAsync:function(_,T){r.changed?_(f):b(!0,_,T)},set attr(_){r.attr=_},get attr(){return r.attr},set header(_){r.loadFromBinary(_)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var _=r.centralHeaderToBinary(),T=re.Constants.CENHDR;return s.copy(_,T),T+=s.length,u.copy(_,T),T+=r.extraLength,a.copy(_,T),_},packLocalHeader:function(){let _=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let T=r.localHeaderToBinary(),O=Buffer.alloc(T.length+s.length+r.extraLocalLength);return T.copy(O,_),_+=T.length,s.copy(O,_),_+=s.length,x.copy(O,_),_+=x.length,O},toJSON:function(){let _=function(T){return"<"+(T&&T.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:_(e),data:_(f)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Sd=ne((ZE,vd)=>{var Ed=na(),Up=ea(),ze=Xn();vd.exports=function(t,e){var r=[],s={},a=Buffer.alloc(0),c=new Up.MainHeader,f=!1,u=null;let x=new Set,h=e,{noSort:w,decoder:E}=h;t?b(h.readEntries):f=!0;function C(){let I=new Set;for(let k of Object.keys(s)){let L=k.split("/");if(L.pop(),!!L.length)for(let _=0;_<L.length;_++){let T=L.slice(0,_+1).join("/")+"/";I.add(T)}}for(let k of I)if(!(k in s)){let L=new Ed(h);L.entryName=k,L.attr=16,L.temporary=!0,r.push(L),s[L.entryName]=L,x.add(L)}}function y(){if(f=!0,s={},c.diskEntries>(t.length-c.offset)/ze.Constants.CENHDR)throw ze.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var I=c.offset,k=0;k<r.length;k++){var L=I,_=new Ed(h,t);_.header=t.slice(L,L+=ze.Constants.CENHDR),_.entryName=t.slice(L,L+=_.header.fileNameLength),_.header.extraLength&&(_.extra=t.slice(L,L+=_.header.extraLength)),_.header.commentLength&&(_.comment=t.slice(L,L+_.header.commentLength)),I+=_.header.centralHeaderSize,r[k]=_,s[_.entryName]=_}x.clear(),C()}function b(I){var k=t.length-ze.Constants.ENDHDR,L=Math.max(0,k-65535),_=L,T=t.length,O=-1,F=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(L=0),k;k>=_;k--)if(t[k]===80){if(t.readUInt32LE(k)===ze.Constants.ENDSIG){O=k,F=k,T=k+ze.Constants.ENDHDR,_=k-ze.Constants.END64HDR;continue}if(t.readUInt32LE(k)===ze.Constants.END64SIG){_=L;continue}if(t.readUInt32LE(k)===ze.Constants.ZIP64SIG){O=k,T=k+ze.readBigUInt64LE(t,k+ze.Constants.ZIP64SIZE)+ze.Constants.ZIP64LEAD;break}}if(O==-1)throw ze.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,T)),c.commentLength&&(a=t.slice(F+ze.Constants.ENDHDR)),I&&y()}function v(){r.length>1&&!w&&r.sort((I,k)=>I.entryName.toLowerCase().localeCompare(k.entryName.toLowerCase()))}return{get entries(){return f||y(),r.filter(I=>!x.has(I))},get comment(){return E.decode(a)},set comment(I){a=ze.toBuffer(I,E.encode),c.commentLength=a.length},getEntryCount:function(){return f?r.length:c.diskEntries},forEach:function(I){this.entries.forEach(I)},getEntry:function(I){return f||y(),s[I]||null},setEntry:function(I){f||y(),r.push(I),s[I.entryName]=I,c.totalEntries=r.length},deleteFile:function(I,k=!0){f||y();let L=s[I];this.getEntryChildren(L,k).map(T=>T.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){f||y();let k=s[I],L=r.indexOf(k);L>=0&&(r.splice(L,1),delete s[I],c.totalEntries=r.length)},getEntryChildren:function(I,k=!0){if(f||y(),typeof I=="object")if(I.isDirectory&&k){let L=[],_=I.entryName;for(let T of r)T.entryName.startsWith(_)&&L.push(T);return L}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let k=this.getEntryChildren(I);return k.includes(I)?k.length-1:k.length}return 0},compressToBuffer:function(){f||y(),v();let I=[],k=[],L=0,_=0;c.size=0,c.offset=0;let T=0;for(let z of this.entries){let P=z.getCompressedData();z.header.offset=_;let N=z.packLocalHeader(),U=N.length+P.length;_+=U,I.push(N),I.push(P);let Y=z.packCentralHeader();k.push(Y),c.size+=Y.length,L+=U+Y.length,T++}L+=c.mainHeaderSize,c.offset=_,c.totalEntries=T,_=0;let O=Buffer.alloc(L);for(let z of I)z.copy(O,_),_+=z.length;for(let z of k)z.copy(O,_),_+=z.length;let F=c.toBinary();return a&&a.copy(F,ze.Constants.ENDHDR),F.copy(O,_),t=O,f=!1,O},toAsyncBuffer:function(I,k,L,_){try{f||y(),v();let T=[],O=[],F=0,z=0,P=0;c.size=0,c.offset=0;let N=function(U){if(U.length>0){let Y=U.shift(),se=Y.entryName+Y.extra.toString();L&&L(se),Y.getCompressedDataAsync(function(fe){_&&_(se),Y.header.offset=z;let we=Y.packLocalHeader(),Ne=we.length+fe.length;z+=Ne,T.push(we),T.push(fe);let st=Y.packCentralHeader();O.push(st),c.size+=st.length,F+=Ne+st.length,P++,N(U)})}else{F+=c.mainHeaderSize,c.offset=z,c.totalEntries=P,z=0;let Y=Buffer.alloc(F);T.forEach(function(fe){fe.copy(Y,z),z+=fe.length}),O.forEach(function(fe){fe.copy(Y,z),z+=fe.length});let se=c.toBinary();a&&a.copy(se,ze.Constants.ENDHDR),se.copy(Y,z),t=Y,f=!1,I(Y)}};N(Array.from(this.entries))}catch(T){k(T)}}}}});var Td=ne((VE,Cd)=>{var xe=Xn(),le=ae("path"),qp=na(),Hp=Sd(),yn=(...t)=>xe.findLast(t,e=>typeof e=="boolean"),Id=(...t)=>xe.findLast(t,e=>typeof e=="string"),jp=(...t)=>xe.findLast(t,e=>typeof e=="function"),Gp={noSort:!1,readEntries:!1,method:xe.Constants.NONE,fs:null};Cd.exports=function(t,e){let r=null,s=Object.assign(Object.create(null),Gp);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(s,t),t=s.input?s.input:void 0,s.input&&delete s.input),Buffer.isBuffer(t)&&(r=t,s.method=xe.Constants.BUFFER,t=void 0)),Object.assign(s,e);let a=new xe(s);if((typeof s.decoder!="object"||typeof s.decoder.encode!="function"||typeof s.decoder.decode!="function")&&(s.decoder=xe.decoder),t&&typeof t=="string")if(a.fs.existsSync(t))s.method=xe.Constants.FILE,s.filename=t,r=a.fs.readFileSync(t);else throw xe.Errors.INVALID_FILENAME();let c=new Hp(r,s),{canonical:f,sanitize:u,zipnamefix:x}=xe;function h(y){if(y&&c){var b;if(typeof y=="string"&&(b=c.getEntry(le.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(b=c.getEntry(y.entryName)),b)return b}return null}function w(y){let{join:b,normalize:v,sep:I}=le.posix;return b(le.isAbsolute(y)?"/":".",v(I+y.split("\\").join(I)+I))}function E(y){return y instanceof RegExp?(function(b){return function(v){return b.test(v)}})(y):typeof y!="function"?()=>!0:y}let C=(y,b)=>{let v=b.slice(-1);return v=v===a.sep?a.sep:"",le.relative(y,b)+v};return{readFile:function(y,b){var v=h(y);return v&&v.getData(b)||null},childCount:function(y){let b=h(y);if(b)return c.getChildCount(b)},readFileAsync:function(y,b){var v=h(y);v?v.getDataAsync(b):b(null,"getEntry failed for:"+y)},readAsText:function(y,b){var v=h(y);if(v){var I=v.getData();if(I&&I.length)return I.toString(b||"utf8")}return""},readAsTextAsync:function(y,b,v){var I=h(y);I?I.getDataAsync(function(k,L){if(L){b(k,L);return}k&&k.length?b(k.toString(v||"utf8")):b("")}):b("")},deleteFile:function(y,b=!0){var v=h(y);v&&c.deleteFile(v.entryName,b)},deleteEntry:function(y){var b=h(y);b&&c.deleteEntry(b.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,b){var v=h(y);v&&(v.comment=b)},getZipEntryComment:function(y){var b=h(y);return b&&b.comment||""},updateFile:function(y,b){var v=h(y);v&&v.setData(b)},addLocalFile:function(y,b,v,I){if(a.fs.existsSync(y)){b=b?w(b):"";let k=le.win32.basename(le.win32.normalize(y));b+=v||k;let L=a.fs.statSync(y),_=L.isFile()?a.fs.readFileSync(y):Buffer.alloc(0);L.isDirectory()&&(b+=a.sep),this.addFile(b,_,I,L)}else throw xe.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,b){y=typeof y=="object"?y:{localPath:y};let v=le.resolve(y.localPath),{comment:I}=y,{zipPath:k,zipName:L}=y,_=this;a.fs.stat(v,function(T,O){if(T)return b(T,!1);k=k?w(k):"";let F=le.win32.basename(le.win32.normalize(v));if(k+=L||F,O.isFile())a.fs.readFile(v,function(z,P){return z?b(z,!1):(_.addFile(k,P,I,O),setImmediate(b,void 0,!0))});else if(O.isDirectory())return k+=a.sep,_.addFile(k,Buffer.alloc(0),I,O),setImmediate(b,void 0,!0)})},addLocalFolder:function(y,b,v){if(v=E(v),b=b?w(b):"",y=le.normalize(y),a.fs.existsSync(y)){let I=a.findFiles(y),k=this;if(I.length)for(let L of I){let _=le.join(b,C(y,L));v(_)&&k.addLocalFile(L,le.dirname(_))}}else throw xe.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,b,v,I){I=E(I),v=v?w(v):"",y=le.normalize(y);var k=this;a.fs.open(y,"r",function(L){if(L&&L.code==="ENOENT")b(void 0,xe.Errors.FILE_NOT_FOUND(y));else if(L)b(void 0,L);else{var _=a.findFiles(y),T=-1,O=function(){if(T+=1,T<_.length){var F=_[T],z=C(y,F).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(z)?a.fs.stat(F,function(P,N){P&&b(void 0,P),N.isFile()?a.fs.readFile(F,function(U,Y){U?b(void 0,U):(k.addFile(v+z,Y,"",N),O())}):(k.addFile(v+z+"/",Buffer.alloc(0),"",N),O())}):process.nextTick(()=>{O()})}else b(!0,void 0)};O()}})},addLocalFolderAsync2:function(y,b){let v=this;y=typeof y=="object"?y:{localPath:y},localPath=le.resolve(w(y.localPath));let{zipPath:I,filter:k,namefix:L}=y;k instanceof RegExp?k=(function(O){return function(F){return O.test(F)}})(k):typeof k!="function"&&(k=function(){return!0}),I=I?w(I):"",L=="latin1"&&(L=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof L!="function"&&(L=O=>O);let _=O=>le.join(I,L(C(localPath,O))),T=O=>le.win32.basename(le.win32.normalize(L(O)));a.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?b(void 0,xe.Errors.FILE_NOT_FOUND(localPath)):O?b(void 0,O):a.findFilesAsync(localPath,function(F,z){if(F)return b(F);z=z.filter(P=>k(_(P))),z.length||b(void 0,!1),setImmediate(z.reverse().reduce(function(P,N){return function(U,Y){if(U||Y===!1)return setImmediate(P,U,!1);v.addLocalFileAsync({localPath:N,zipPath:le.dirname(_(N)),zipName:T(N)},P)}},b))})})},addLocalFolderPromise:function(y,b){return new Promise((v,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},b),(k,L)=>{k&&I(k),L&&v(this)})})},addFile:function(y,b,v,I){y=x(y);let k=h(y),L=k!=null;L||(k=new qp(s),k.entryName=y),k.comment=v||"";let _=typeof I=="object"&&I instanceof a.fs.Stats;_&&(k.header.time=I.mtime);var T=k.isDirectory?16:0;let O=k.isDirectory?16384:32768;return _?O|=4095&I.mode:typeof I=="number"?O|=4095&I:O|=k.isDirectory?493:420,T=(T|O<<16)>>>0,k.attr=T,k.setData(b),L||c.setEntry(k),k},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return h(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,b,v,I,k,L){I=yn(!1,I),k=yn(!1,k),v=yn(!0,v),L=Id(k,L);var _=h(y);if(!_)throw xe.Errors.NO_ENTRY();var T=f(_.entryName),O=u(b,L&&!_.isDirectory?L:v?T:le.basename(T));if(_.isDirectory){var F=c.getEntryChildren(_);return F.forEach(function(N){if(N.isDirectory)return;var U=N.getData();if(!U)throw xe.Errors.CANT_EXTRACT_FILE();var Y=f(N.entryName),se=u(b,v?Y:le.basename(Y));let fe=k?N.header.fileAttr:void 0;a.writeFileTo(se,U,I,fe)}),!0}var z=_.getData(c.password);if(!z)throw xe.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(O)&&!I)throw xe.Errors.CANT_OVERRIDE();let P=k?y.header.fileAttr:void 0;return a.writeFileTo(O,z,I,P),!0},test:function(y){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var v=c.entries[b].getData(y);if(!v)return!1}catch{return!1}return!0},extractAllTo:function(y,b,v,I){if(v=yn(!1,v),I=Id(v,I),b=yn(!1,b),!c)throw xe.Errors.NO_ZIP();c.entries.forEach(function(k){var L=u(y,f(k.entryName));if(k.isDirectory){a.makeDir(L);return}var _=k.getData(I);if(!_)throw xe.Errors.CANT_EXTRACT_FILE();let T=v?k.header.fileAttr:void 0;a.writeFileTo(L,_,b,T);try{a.fs.utimesSync(L,k.header.time,k.header.time)}catch{throw xe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,b,v,I){if(I=jp(b,v,I),v=yn(!1,v),b=yn(!1,b),!I)return new Promise((O,F)=>{this.extractAllToAsync(y,b,v,function(z){z?F(z):O(this)})});if(!c){I(xe.Errors.NO_ZIP());return}y=le.resolve(y);let k=O=>u(y,le.normalize(f(O.entryName))),L=(O,F)=>new Error(O+': "'+F+'"'),_=[],T=[];c.entries.forEach(O=>{O.isDirectory?_.push(O):T.push(O)});for(let O of _){let F=k(O),z=v?O.header.fileAttr:void 0;try{a.makeDir(F),z&&a.fs.chmodSync(F,z),a.fs.utimesSync(F,O.header.time,O.header.time)}catch{I(L("Unable to create folder",F))}}T.reverse().reduce(function(O,F){return function(z){if(z)O(z);else{let P=le.normalize(f(F.entryName)),N=u(y,P);F.getDataAsync(function(U,Y){if(Y)O(Y);else if(!U)O(xe.Errors.CANT_EXTRACT_FILE());else{let se=v?F.header.fileAttr:void 0;a.writeFileToAsync(N,U,b,se,function(fe){fe||O(L("Unable to write file",N)),a.fs.utimes(N,F.header.time,F.header.time,function(we){we?O(L("Unable to set times",N)):O()})})}})}}},I)()},writeZip:function(y,b){if(arguments.length===1&&typeof y=="function"&&(b=y,y=""),!y&&s.filename&&(y=s.filename),!!y){var v=c.compressToBuffer();if(v){var I=a.writeFileTo(y,v,!0);typeof b=="function"&&b(I?null:new Error("failed"),"")}}},writeZipPromise:function(y,b){let{overwrite:v,perm:I}=Object.assign({overwrite:!0},b);return new Promise((k,L)=>{!y&&s.filename&&(y=s.filename),y||L("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(_=>{let T=O=>O?k(O):L("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(y,_,v,I,T)},L)})},toBufferPromise:function(){return new Promise((y,b)=>{c.toAsyncBuffer(y,b)})},toBuffer:function(y,b,v,I){return typeof y=="function"?(c.toAsyncBuffer(y,b,v,I),null):c.compressToBuffer()}}}});var fl=ne(Ie=>{"use strict";var M=G;(function(t,e){let r=G,s=t();for(;;)try{if(parseInt(r(265))/1+parseInt(r(1506))/2*(parseInt(r(247))/3)+-parseInt(r(959))/4*(-parseInt(r(317))/5)+-parseInt(r(445))/6+-parseInt(r(428))/7+parseInt(r(1118))/8+parseInt(r(854))/9*(-parseInt(r(1419))/10)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(so,174294);var iy=Object[M(379)+M(217)],sy=Object[M(1394)+M(1488)+M(1103)],sl=(t,e)=>function(){return t&&(e=(0,t[sy(t)[0]])(t=0)),e},oy=(t,e)=>{let r=M,s={pQBRH:function(c,f,u,x){return c(f,u,x)}};for(var a in e)s[r(238)](iy,t,a,{get:e[a],enumerable:!0})};function ay(){return el||(el=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function cy(){let t=M;return tl||(tl=[IDBCursor[t(1383)+"e"][t(695)],IDBCursor[t(1383)+"e"][t(219)],IDBCursor[t(1383)+"e"][t(219)+"PrimaryKey"]])}function dy(t){let e=M,r={qmTsf:function(a,c){return a(c)},FoLMf:e(1076),CFcTr:function(a,c){return a instanceof c},mOaKv:function(a,c){return a+c},ZTwnU:function(a,c){return a!==c},PUcQf:e(1406),abDdl:function(a,c){return a(c)},ewJqc:function(a,c){return a instanceof c}},s=new Promise((a,c)=>{let f=e,u={zuQvX:r[f(1321)],GFjTs:function(E,C){return r[f(278)](E,C)},xeBjf:function(E,C){return r[f(981)](E,C)},qYzGC:function(E,C,y){return E(C,y)},UBltk:function(E,C){return r[f(469)](E,C)},bZiLP:f(365),UIOuv:r.PUcQf,qyCSN:function(E,C){return r[f(363)](E,C)},wwtnd:function(E){return E()}},x=()=>{let E=f,C={hwLxE:u[E(1101)],wokqW:function(y,b,v){return u[E(900)](y,b,v)}};if(u[E(897)](u[E(1342)],u.bZiLP)){let y={RKjiI:u[E(1101)]};if(u[E(1093)](_0x3a1cdd,_0x4abd81)){let b=_0x12cf52.buffer[E(1068)](_0x3ed3b4.byteOffset,u[E(1147)](_0x582e2b[E(1121)+"th"],_0x4de31d[E(970)+"et"]));this[E(316)]&&this._socket[E(437)]({data:b,fail:v=>{let I=E;this.emit(C[I(1642)],C[I(679)](_0x5e5541,I(1076),{message:this[I(212)+"rrorMess"+I(524)](v)}))}})}else this[E(316)]&&this._socket.send({data:_0x2235c,fail:b=>{let v=E;this[v(378)](v(1076),_0x354df8(y[v(1492)],{message:this[v(212)+v(1196)+"age"](b)}))}})}else t[E(926)+E(1604)+E(513)](u[E(562)],h),t[E(926)+E(1604)+E(513)](u[E(1101)],w)},h=()=>{a(r[f(530)](Tt,t.result)),x()},w=()=>{let E=f;u[E(586)](c,t[E(1076)]),u.wwtnd(x)};t["addEvent"+f(1117)](r[f(473)],h),t[f(1598)+f(1117)](r.FoLMf,w)});return s.then(a=>{let c=e;r[c(275)](a,IDBCursor)&&Cc[c(1082)](a,t)})[e(1589)](()=>{}),ro[e(1082)](s,t),s}function G(t,e){t=t-155;let r=so(),s=r[t];if(G.WbWQWC===void 0){var a=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",E="";for(let C=0,y,b,v=0;b=x.charAt(v++);~b&&(y=C%4?y*64+b:b,C++%4)?w+=String.fromCharCode(255&y>>(-2*C&6)):0)b=h.indexOf(b);for(let C=0,y=w.length;C<y;C++)E+="%"+("00"+w.charCodeAt(C).toString(16)).slice(-2);return decodeURIComponent(E)};G.nugDCt=a,G.DifgcG={},G.WbWQWC=!0}let c=r[0],f=t+c,u=G.DifgcG[f];return u?s=u:(s=G.nugDCt(s),G.DifgcG[f]=s),s}function fy(t){let e=M,r={BhocI:e(313),bmTrs:e(1076),QYqNP:function(a){return a()},weMZx:function(a){return a()},mNUKb:function(a,c){return a(c)},REuSC:e(1204)+"or",CoUdX:function(a){return a()},XbPXG:"abort"};if(no.has(t))return;let s=new Promise((a,c)=>{let f=e,u=()=>{let w=G;t[w(926)+w(1604)+"ner"](r.BhocI,x),t[w(926)+w(1604)+w(513)](r[w(155)],h),t[w(926)+w(1604)+w(513)](w(685),h)},x=()=>{r.QYqNP(a),r.weMZx(u)},h=()=>{let w=G;r[w(609)](c,t.error||new DOMException(r[w(1312)],r.REuSC)),r.CoUdX(u)};t["addEvent"+f(1117)](f(313),x),t[f(1598)+"Listener"](r[f(155)],h),t["addEvent"+f(1117)](r[f(902)],h)});no[e(1082)](t,s)}function uy(t){io={PEtyp:function(s,a){return s(a)}}[M(311)](t,io)}function ly(t){let e=M,r={jhfgQ:function(s,a){return s(a)},kOSjj:function(s,a){return s!=a},COBQH:e(1517),fokTo:function(s,a){return s instanceof a},wmevz:e(1412)+e(1388),GpoLN:function(s,a){return s(a)},MdRxo:function(s,a){return s===a},WQycK:function(s,a){return s in a},MHTWl:e(725)+e(509),Sqhia:function(s,a){return s!==a},EFQGx:e(429),EsWRC:function(s){return s()}};return r[e(1369)](t,IDBDatabase[e(1383)+"e"][e(1431)+"ion"])&&!r[e(1239)](r[e(800)],IDBTransaction[e(1383)+"e"])?r[e(1350)](e(831),r[e(1456)])?function(s,...a){let c=e,f=t.call(r[c(1633)](Si,this),s,...a);return Ic[c(1082)](f,s.sort?s.sort():[s]),r[c(1633)](Tt,f)}:r.kOSjj(r[e(549)],typeof _0x1befbb)&&(r.fokTo(_0x42f58d,_0x4ca73d)||_0x292be0[e(424)]&&r[e(1115)](_0x51bf8b[e(424)],_0x54b49f))||r.kOSjj(r[e(549)],typeof _0x3127e4)?"":(_0x685ebc[e(1328)](_0x9fe804),r[e(967)]):r[e(1463)](cy)[e(1327)](t)?function(...s){let a=e;return t[a(844)](r[a(1069)](Si,this),s),Tt(Cc[a(1177)](this))}:function(...s){return Tt(t[e(844)](Si(this),s))}}function xy(t){let e=M,r={UEJeO:function(s,a){return s===a},RSSrR:e(227),Xeqta:function(s,a){return s(a)},yGNle:function(s){return s()}};return r[e(723)](typeof t,r[e(676)])?r[e(623)](ly,t):(t instanceof IDBTransaction&&r[e(623)](fy,t),ol(t,r.yGNle(ay))?new Proxy(t,io):t)}function Tt(t){let e=M,r={hZNjt:function(a,c){return a(c)},EIUUu:function(a,c){return a(c)},SnoHJ:function(a,c){return a!==c}};if(t instanceof IDBRequest)return r[e(1429)](dy,t);if(eo[e(1052)](t))return eo.get(t);let s=r[e(1311)](xy,t);return r.SnoHJ(s,t)&&(eo[e(1082)](t,s),ro[e(1082)](s,t)),s}var ol,el,tl,Cc,no,Ic,eo,ro,io,Si,nl=sl({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={MrDaP:function(r,s){return r instanceof s},lDuWP:function(r,s){return r===s},KBSgd:"done",Qzlih:function(r,s){return r===s},PLPPM:t(725)+"oreNames",llAOU:t(1354),rZwis:function(r,s){return r(s)},QcrVw:function(r,s){return r in s}};ol=(r,s)=>s[t(1084)](a=>r instanceof a),Cc=new WeakMap,no=new WeakMap,Ic=new WeakMap,eo=new WeakMap,ro=new WeakMap,io={get(r,s,a){let c=t;if(e.MrDaP(r,IDBTransaction)){if(e[c(1555)](s,e[c(1283)]))return no[c(1177)](r);if(e.Qzlih(s,e[c(855)]))return r.objectStoreNames||Ic[c(1177)](r);if(s===e[c(1055)])return a[c(725)+c(509)][1]?void 0:a[c(725)+c(790)](a[c(725)+c(509)][0])}return e.rZwis(Tt,r[s])},set(r,s,a){return r[s]=a,!0},has(r,s){let a=t;return r instanceof IDBTransaction&&(e[a(1555)](s,e[a(1283)])||s===a(1354))?!0:e[a(1631)](s,r)}},Si=r=>ro.get(r)}}),al={};oy(al,{deleteDB:()=>py,openDB:()=>hy,unwrap:()=>Si,wrap:()=>Tt});function hy(t,e,{blocked:r,upgrade:s,blocking:a,terminated:c}={}){let f=M,u={ydcET:function(w,E,C,y,b){return w(E,C,y,b)},ETwUz:function(w,E){return w(E)},ltCVw:"close",zGWLb:"versionc"+f(653),QbeKc:"blocked"},x=indexedDB[f(1249)](t,e),h=u[f(1364)](Tt,x);return s&&x[f(1598)+f(1117)]("upgraden"+f(739),w=>{let E=f;u[E(1299)](s,Tt(x[E(696)]),w[E(440)+"on"],w[E(1513)+"on"],u[E(1364)](Tt,x[E(1431)+E(733)]))}),r&&x[f(1598)+f(1117)](u[f(1213)],()=>r()),h[f(264)](w=>{let E=f;c&&w[E(1598)+E(1117)](u[E(280)],()=>c()),a&&w[E(1598)+E(1117)](u[E(937)],()=>a())})[f(1589)](()=>{}),h}function py(t,{blocked:e}={}){let r=M,s={RxpkK:"blocked",yCmUG:function(c,f){return c(f)}},a=indexedDB["deleteDa"+r(769)](t);return e&&a.addEventListener(s[r(1502)],()=>e()),s.yCmUG(Tt,a)[r(264)](()=>{})}function rl(t,e){let r=M,s={bIFdo:r(1391)+"e",wLEKh:function(x,h){return x instanceof h},ijQEd:function(x,h){return x in h},IdnMq:function(x,h){return x===h},Apffz:r(1517),TgcWT:function(x,h){return x!==h}};if(!(s.wLEKh(t,IDBDatabase)&&!s.ijQEd(e,t)&&s[r(1031)](typeof e,s[r(788)])))return;if(to.get(e))return to[r(1177)](e);let a=e[r(1613)](/FromIndex$/,""),c=s[r(540)](e,a),f=dl[r(1327)](a);if(!s.ijQEd(a,(c?IDBIndex:IDBObjectStore)[r(1383)+"e"])||!(f||cl[r(1327)](a)))return;let u=async function(x,...h){let w=r,E=this["transact"+w(733)](x,f?s.bIFdo:w(573)),C=E.store;return c&&(C=C[w(616)](h.shift())),(await Promise[w(896)]([C[a](...h),f&&E[w(1616)]]))[0]};return to[r(1082)](e,u),u}var cl,dl,to,gy=sl({"node_modules/idb/build/index.js"(){let t=M,e={YcKIL:"2|3|1|5|"+t(1487),oPmgr:function(a,c){return a(c)},qzlAJ:t(171),UjXkc:t(1097)+"ys",WlOWA:"count",JmoHO:t(307),GSldZ:"add",dTeRz:t(868),fwBdq:t(1356)},r=e[t(1261)][t(620)]("|"),s=0;for(;;){switch(r[s++]){case"0":e[t(1381)](uy,a=>({...a,get:(c,f,u)=>rl(c,f)||a[t(1177)](c,f,u),has:(c,f)=>!!rl(c,f)||a[t(1052)](c,f)}));continue;case"1":cl=[t(1177),"getKey",e[t(744)],e[t(665)],e[t(947)]];continue;case"2":nl();continue;case"3":nl();continue;case"4":to=new Map;continue;case"5":dl=[e[t(941)],e[t(441)],e.dTeRz,e[t(1142)]];continue}break}}}),my={idb:function(t){let e=M;t.exports=Promise[e(337)]()[e(264)](()=>(gy(),al))[e(264)](function(r){return r})}},il={};function Ct(t){let e=M,r={yphBm:function(u,x){return u!==x}},s=(e(871)+"3")[e(620)]("|"),a=0;for(;;){switch(s[a++]){case"0":my[t](c,c[e(163)],Ct);continue;case"1":var c=il[t]={exports:{}};continue;case"2":var f=il[t];continue;case"3":return c[e(163)];case"4":if(r.yphBm(void 0,f))return f.exports;continue}break}}Ct.d=(t,e)=>{let r=G;for(var s in e)Ct.o(e,s)&&!Ct.o(t,s)&&Object[r(379)+"operty"](t,s,{enumerable:!0,get:e[s]})},(()=>{let t=M;Ct.o=(e,r)=>Object.prototype["hasOwnPr"+t(217)].call(e,r)})(),(()=>{let t=M,e={jtHsg:function(r,s){return r!=s},DOVNi:t(506)+"d",puLpv:t(466),shqxu:t(1122)+"le"};Ct.r=r=>{let s=t;e[s(1566)](e[s(682)],typeof Symbol)&&Symbol[s(602)+s(1392)]&&Object[s(379)+s(217)](r,Symbol[s(602)+"Tag"],{value:e.puLpv}),Object["definePr"+s(217)](r,e.shqxu,{value:!0})}})();var be={};function so(){let t=["yxKSihrYEsa","CgLUz19VBMm","AxjRvuW","rePRrK4","qNvHwhu","B1bTz3i","BwfW","ChjVDg90Exa","CgvYC2LZDgu","Cw9Zx18","Be5Ou1i","AhzkDLa","Aw9Ul2PZB24","rgvduKW","Ec1TC2CTy3u","CMvHzhDYAxq","vgfN","v1v1q28","z2v0t3DUuhi","Aw9UvgLTzw8","C2v0zgi","tgfrs2W","Ahfvvu4","mdaWmdaWmda","v01gu1u","y0vcAwm","u0zJAMS","AxnbCNjHEq","rufQC0C","qLbPzuK","C3vJy2vZCW","AM9PBG","y2LXAwm","D2DWyvC","CwnVCMq","Au5lBKS","yxbWBgLJyxq","yK1MDKK","x1fVu01HBMe","zMXVB3i","DgHHBIbSB2m","rLjptLrjrvi","twzQBK0","mtuXmgXIDKfXAq","z0LltMe","ywnOzwq","tuzWC0W","zxrxB3jRq2G","y3jLyxrLtwu","uNLXAwi","yMfSrxzLBNq","ALj6qMi","vvPkBg4","AfPoANq","AfLOwwu","DhjHBNnHy3q","ohWZFdeWFdC","Aw5msvu","Dgv4DfbHEwW","y1rNz0e","C2v0u3rVCMe","x29Ut3bLBG","Ahr0Ca","wvPqD1q","yMfJA3vWigu","A25JvMy","BwT2vuS","seLtBMK","tgHKvgG","BKPhsg4","EuHItui","zv9ZDwnJzxm","uhvAy0u","vgrPDgq","vhLLzhy","r2vvBhi","EuLADKq","r3rKy1u","CMfUzg9T","s0DZv2y","ruzrr3G","A2v0ignVBNm","whb6Ceu","zKnYy1a","rensB1G","tLLKD2i","wgLnsMi","rxnxuKm","verAs3i","D1L0y08","B2nRzxrtDwm","q3vZDg9Tq2W","Bfjrruu","DcbSAw1PDa","DergEge","u2HHCMvKv28","yKTrCgy","v2D4q08","C2DPza","De1Psvu","ywnRpwzYB24","yLvUrgm","EgX4wLq","BwLUAvbYB2C","u1zYu0S","vxbKyxrLq28","Ce1ry1K","yNvMzMvYzwq","wufIs2m","nhWXFdb8mNW","rLDt","nhWW","B3bLCNr5tMe","EgPqr2G","Bwf4tg9ZC0m","qujwB3y","uKTQAuK","ChrVCG","swLNvLe","mxW1Fdb8nNW","tNbVzwq","CM9YrxzLBNq","rKLmrv9ot1q","BwvKAwf0zwW","m3WXFdv8mte","su1zvM8","uNHWA0S","A05Wqvy","AxnMDKO","zNjVBu51Bwi","mJa2CerfugHJ","wKnZrfm","CgLUz0XVC3m","Dgvcsgm","C3jJ","Bg9Nsurhzw4","rxjYB3jdB2q","BMv3vMvYC2K","BKvVB1C","rhLjDeK","BvD1rfi","C3rYAw5N","B2zxCuO","l3DZl3yY","B2fK","y3jLyxrLuMu","s0HWEem","x2LUAxq","sfvdB2W","Ce9vAfi","B3jRig9MzMW","yLrJsfi","B2zMBgLUzq","rMnduNi","vMDJrKi","yw51Ce1LC3m","AxnFywnR","sLzkywS","t3jMCeS","D3Ddy0S","x2LUDgvYDMe","yxv0B21HDgK","yufhvvC","CgTzqwe","BMnVzgLUzW","u2TPCcbWyxm","zvD0tw4","wMH2ugG","zxrnELK","B2nRzxrgywK","tuXcv3e","AwXLx25HBwu","y25Uzxq","Bg9NsurozxC","t1bftG","B3zmzve","t2jQzwn0","y2XVC2veqG","s21QDuO","Ber1v1a","AgLNAa","wxbjCeC","A1rvANe","C2nYAxb0","qLfLyvK","CKrnt3O","zMLN","B2HHvwO","Ec11C2uT","zw1LBNq","ANriC2C","ign1CNnVCIa","vw5Oyw5KBgu","Ahzgvw4","z2vjBMzVu3K","B2jqsu0","yKjrt3C","ANvYu0i","BxzKzuy","vfDpExm","uNboBue","x3bYB3rVy28","BLPVq0e","CurlyuS","x2n1CNnVCK0","EKvPr3C","thfLteW","ywXty29Wzq","s0LgDfC","CMXIAwK","BefhAgW","DeLK","vgv2vKS","y2f0y2G","rMT1tvi","sMTMsuq","D2zyqxm","t2LRt1m","CMvUDevUzha","q3jJzxC","ELbjy0W","A2v5CW","ywrKrxzLBNq","uhjis0O","tKDFrvjst1i","AxjLza","Aw5Qu28","AMTcBeu","zw50tgLZDgu","B09VB3q","zwnVBM5Ly3q","BMDZuLa","vvrcBvu","BwLZzq","x29UrxjYB3i","Cwvbsxm","uxHzEhq","CMvWBgfJzq","ywXSzwqGBxu","C0Xf","zg9Uzq","x3DZsw5ZDge","B25fCNjVCG","rNzJqMu","zMLSzw5HBwu","s0zYv0W","thzMq2K","ChjVy2vZCW","BfLVDxO","DNLQAxC","suzODNi","sgTnqwu","tvj0s0q","B25tDgfYDfi","Cg1Prvi","uwnYvNC","DeHkrwu","AMHMz1e","y1ftr3G","rgvKAwnHDgu","DMXVv2m","C3zcug4","zMLUza","z05nC0W","sufQzMG","wu1gDLK","AhDmEeu","zNjVBujPDhm","yM1uCNm","whfqB3O","aaaaaaaaaaa","tuTWC1C","zcWGDw5RBM8","Ef9MCM9UDgK","Dg9oDw1Izxi","tu5LwNi","zxHWB3j0CW","ywnRDxbfBMq","icSG","z1Phrg8","Dg9hzw5LCMe","DMvUDa","yw1ZqNy","C2vYDMLJzq","z2v0qwXS","s25Ntui","sxHgsfu","yxbWzw5Kq2G","wvD2BMO","CMP5ugi","x2n1CNnVCKy","s05Lrw8","twLZC2LUzYa","z3rWA3y","Dxrjza","tvfOzNe","suTrv0m","zgf0yq","CeHqvKC","r1P5CLC","x2LZsw5PDa","CMTLCKDSB2i","zM9YrwfJAa","q2ruy20","y3jLyxrLq2W","rwTqt2W","zNjVBuHHC2G","D1rjDg8","y0fWD3K","BwXXDwe","Bvb1sw0","x2LZv29YA2u","yKznC3e","y3vYCMvUDeu","EezcD2O","y1HADMe","yKH4qxm","BNvTyMvY","yxv0BW","y2HLy2TdDxi","Ehnnuu0","BwLUzW","BKXPBMu","AgvHzgvYCW","seXlqve","x2zVCM1HDeu","DgrzA2e","twvZC2fNzuu","wKjNwMi","CMvJB25Uzwm","B3bLCNr5","y29UBMvJDgK","y29UDgLUDwu","ELLzExa","zwjLB1u","D3P5uxm","qMXMB28","tfLiBhu","tMHMufC","r014wMO","zNvUy3rPB24","wNbxCe4","Dw5ZAwDUzwq","ugLyt3i","y3r4","C2fSA3G","svblvLa","BMDuAw1LCG","DfzssMm","zujcqvy","wM5Kyum","CffcuKG","x2DLBMvYyxq","C2v0q3vYC28","u2vhBxK","vgLTzw91Da","twziy1O","sLnptLa","zw5fDMvUDa","D2LSBfjLy28","nJaWovPWyKrbtG","EvjLy29UBMu","BfHwtNi","Cw9gzfC","y2L1tKu","DgLLCKPtt04","sgLKA24","qw5bwK4","zLrvy0C","BNrfBMrWB2K","EgvxCfq","C3HjsxK","CufgwMO","x2nSzwfYugK","DwHiEhq","x3nLCuLK","mxWY","DgHLBG","mtK0nZaXEvvJAgLW","zwHbsei","ELLRzvC","rgfAAK8","vuLlz0m","r0Pntvu","reXxuxu","EuvfAMq","DMDyz1a","sxrWwwK","zxDkCwm","v2XytKq","teTuy1C","q0zJvhi","B25ozxr3B3i","BhrdvNC","EKDZv1e","ze9Wtw0","x3bHDgHlzxK","zgLZywjSzue","vuTwqMK","v2fjvM8","AwTZyuC","zMT6Exm","DKXWteK","Dg9cExrLCW","AhLOq00","s0zUthm","BwTfCK4","Bg9N","ANzOq0y","AgvKtwf4uMu","q0Hdtwy","uwXKBKS","z2vY","AxnrB1nnzxm","Aw5L","x29Uq2XVC2u","x2LZtwLUAvC","CMvHC29U","Bu5iEgm","z09cC3a","Chv0","t3rqENi","DhzxweW","Ae9Wzw5fDMu","uev0Exa","x2LUAxrhBg8","y29TCgXLDgu","EvnODgO","wwHjwNe","x3nVy2TLDa","mJCXmdKWrgzJEfDO","uePWDvG","D3m6lY8","z2LuyMG","BxzOrg8","wufsEe4","u1zVwue","ExHjs1C","CYbPBNn0yw4","lcbxzwjtB2m","ihrVihjLDhi","De5Auhu","CYbHBhjLywq","r2TozLi","AxnmB25N","yKPgDKO","DgLTzw91Da","BMv4DcGPigm","ueT0uwO","Cg9PBNrbBMq","CMvZB2X2zq","D2vI","y3vYC29Y","z2L6ALG","yLnbtfa","C2HUufK","yMTLt24","s0LMwuS","zLnZuuy","CMvJzwL2zwq","BeTmswG","uLjpuG","CNzHBa","CfHwtuW","AgL2s0u","u1DZCuq","ter3y24","tKHrCNG","y2HnyxHdB3u","Aw5Lza","B25dBg9Zzq","Dg9cExrLC0W","z29PBMCGyxC","C2zswwm","uLrIseG","tunHD2O","ywjezgW","zvvWzKy","s1zdEfe","y2HnyxHuCMK","rwzvzuy","sKTLyNG","B25SAw5L","Dg9iyxnO","BMTfAue","txzcqKC","qMrXB3K","Dw50","BgvY","DeLUDgvYy2u","AeTLC0C","zw1PDa","zgvMAw5Luhi","u0XxrgG","ANvpvhi","Cg9PBNrdB24","zu9uALi","thLezgS","BhDizfu","ywDLsgLKzq","yM9Yuuy","yw1LoIa","zxn6rhK","zMzmAw5L","C1rlwhq","BfrPBwvVDxq","DuD3Aeu","C3bSAwnL","zgvS","De91Bfy","CMvWBgfJzui","rvjst1i","De1HBMfNzxi","svHowvO","B1zZzeq","rNjlBLG","yuDrAe4","zK5Sswm","D3jPDgu","DfLowxe","lcbTyxGGCMu","DhbizwfKzxi","x2LZtM9Kzq","u3DxB3y","CM92AwrLige","EeTouMe","v2D6qwq","seLyrwO","BgLUzw5V","B1jJCha","vNjPvuy","DhjfrM8","q2TAy2e","ENLNCKK","wfPMt3i","r1zIqxC","y2XVC2uSihC","yNvMzMvY","CvLvEuW","rxrguhC","q29UzMLN","mJiYndy0ovnAsNvJDG","B3DKzhG","q1jSDgq","qNPfqMK","BNrLCG","vxrQq24","BgTRyvq","BgXPwgu","ExbL","C2vUza","t3nfrK4","x2XPC3rLBMu","B2XKvMvYC2K","r1nSzfO","ywnR","B29Vv2m","zNDZxZeUmc4","nJCXnZaWwfDrz21e","igzPzwXKoIa","yxnZAwDU","BMvvC3C","yxGGCMv0CMK","AwXK","swTHEgS","vgPJqMG","DhjPzxmGCMu","AunVqNq","zw5HyMXLqxu","BNruCMLLC0m","x29UugfNzu4","swTzsMO","x2fKzfDZtgK","C2fgC1C","C3nHz2vfDMu","EhjpzLG","tezXqK0","Eg1bqvK","ELnru1q","tw9KDwXL","ywnKEg0","D3bZA2O","wLr3BLu","CM92AwrLigi","zw5JB2rPBMC","B1nXswy","ufvJuwy","uvHMDuC","FdL8mxWXmhW","tffsvMO","A3fkyNm","Bef0Bhe","q0X1EK4","y2XcuLe","yM9qD3C","r1LHB08","qLLTtwy","DLLRAgC","uxHZuKe","x29UtwvZC2e","AKjXvgu","zLb1veC","D1Dbwem","BgvUz3rO","qM5IsKu","EhjhDLm","zxjFCw9Zx2e","AgvHzgvY","C1PyDfC","BMCGDxjSoIa","CuPZwu4","AMvJDfn0B3i","x2rLyNvN","EuDJzNq","ihn1y2nLC3m","CgLUz1rPBwu","vNPVDLq","DwHqr1C","Bg9IywXty28","Dw5KzwzPBMu","ueTJu2m","qw5Ms24","B3jLtMfTzxm","ywDLu2HVDW","C3rHCNq","BKDtwhm","BMvY","AwXLtMfTzq","AxnAzxjV","BvHsDuy","Au1Lz0G","DhjPzxm","vg1OyxG","BNrbBMrvCgq","Axnby2TdBgu","Defdy3e","v3Hptfq","ywDL","we1Ur24","BgLTAxq","zhveELu","ywrKq291BNq","vKDkEgK","Cw1uC2y","Cg9W","rejyq3y","ysbTDxn0igi","x2vUzhbVAw4","q0jREKO","svf4BMm","EuzyAgq","BKrAAhe","EhPQwxm","vgDJv1q","AgfIALq","suvtx0vsuK8","q291BNq","C0nVDw50zxi","t2XOCNq","BxnNsuq","wNLmBve","rxnMBLG","q09cuuG","pxv0zI04","uxvLDwu","mhW0Fdz8oxW","CgfNzxnOB3C","AwDHDg9Yt24","ihrYEsbYzwm","q0Xpu0ve","nxW0Fdb8m3W","x2rPC3bHDgm","sgnWENK","x2rPC2nVBM4","ywWGy3vYC28","vuLpDxy","z1L5q0K","yxKSig5LDhC","uufTsg8","Bhm6ia","zgncyu0","CMfNzvn5BMm","r2vLsKS","DvHlwg8","AgfZt3DUuhi","su5tvefova","CMvHzg9UBhK","r1LrD1q","uezuExe","seL1wfq","C2v0sxrLBq","wvHfA1C","zMX1C2HfEha","BMTJz3y","t1zvuNO","y1vHAgq","shDrue8","y3jLyxrLrwW","reXeA1m","CxLdu04","B3jpBMXPBMu","wM1HAhm","BNHSD3K","B25pCgvU","x21PBMLoyxy","zfvjtfq","x2LUAxrqCM8","C2fNzq","yvH3rMy","B2XQsKK","sKHKB1a","wgzSChC","CgXOB0y","EKn3vuu","mxW2Fdr8m3W","Dg9tDhjPBMC","CuvqDgq","BezSDxnO","z2vtEw5J","wffIqwC","zxmGCMvHy2G","z2nQDKq","Bu5vs2i","C2vUzf9Hy2S","ywTNu3G","y3vYC29Yx2y","tLz2qMS","qw1VDw50","AK91Dwe","Aw5KzxG","x3nLBMrby2S","zejbB0e","yMfSu2nVCgu","C3bSAxq","A1n0yxr1C0m","u3rYyxrLz3K","wgvXDge","yNL0zxm","z1jWsKy","CeXqz24","uK95u1q","BNPur2i","AxnszwfKEq","B2zM","tuvtu0fhrv8","zgvIDwC","CMvKDwnL","shfJs20","sKzbr3C","reTss3q","Bvb0zNC","v2Txt3q","Cgu6ia","wNjIEgO","tMnWtvu","x25HDMLNyxq","zMzLCG","tg9NsurozxC","B1bKCw0","CMjWtK4","txbHB2S","DKj5qKW","zxj2AwnL","q1HtzLC","tgf4zMe","B3nLrxzLBNq","AgfUz2u","q1v0ANi","ignVzgu6ia","r2DrrLq","Dw9Jqxm","x3jLywr5q2W","nhWY","Aw5KzxHpzG","tNblCfO","BufOCLC","CuzWBKK","EgzesLe","vwPyA2m","uM5ltge","t3rtsxK","vw53Cwm","zw50zwqGDhK","ELrNBwi","rwXdzwG","qLjADgy","q01LANa","x29UvgLTzw8","tuPIvwS","uLntCLi","Dg9Y","rNjVBNrPzxi","D29RCvC","Dg9cExrLC0i","r2P1C0C","re9wtMK","AgDguu0","BMCGzMfPBgu","ywjVCNq","uvjiBhK","uwL1qum","AgD5rhi","z2v0sxrLBq","Aw1LCYbPBIa","DvDzwwG","Ew1jELe","AevYCM9Yrxy","Cw5dvhK","ywr2yw5Jzq","CMvZDwX0","B3nLza","ihzHBgLKihm","ihrPBwvVDxq","BM5Ly3q","DxPWBvK","vfL4Bxm","ywXPzcb1CMW","wfzRruC","Bwf4twvZC2e","weT2rNK","D01hCfK","uhbZteW","mhWZFdr8nNW","Aw5KzxGGB3u","sK16AMK","D2nrCxi","ChDfzeS","sNDireu","y29Uy2f0","yKT1v3e","v01RuuS","zwTYt3C","BgLZDgvUtMu","DKLYvhu","CuTmtK0","s2vAr3K","vuvkzu8","y29UC3rYDwm","B2jQzwn0u3q","n3WXFdj8nq","v2vIu29JA2u","x2jPBMfYEvq","y3vZDg9Tshq","zu1wrK4","rxLnwwy","CgLUz09Uy2u","Aw9U","y29UBMvJDfm","Bfrtz08","t2PwtvG","wMzAq2e","zeDuv0i","zwvKzwq","v0fctw8","zuzVq0C","tufyx1jfvfi","zhDIs3u","CxPSquO","vwPlD3a","wNPQEeS","CNnVCL92ywW","CMLLC0nVDw4","uMvHzcbWyxm","zNjHBwvuExa","CMvXDwLYzwq","BgDQwNe","CNvfv3u","vvvrDKO","sM1QzNq","thfhCvi","y2vZC0HHBMq","Cgf5Bg9Hzfq","C2f2C0K","CMvHzhLtDge","DgLTzw91DcW","CMvHzfvjBNq","BwvZC2fNzv8","qNjPzgDL","EefiDLm","reiGzMfPBgu","CMvTB3zLq2G","Eu5jEwi","DgfIyxnL","x3bYzwzPEa","Bg93","uef5A0q","uLPrvKu","DxrMofDYAxq","qMT5A1O","B3bLBKrc","u0v2zfy","rfDAANq","ugrTyNO","BM93","Cuf1CNi","r1fQt0e","q29Kzq","x2HHBMrSzu8","wKPnvKK","y1LLD04","ze13CgG","qxbMzNO","igfYCMf5yNu","B3jL","te1Oy1e","y3ruAw1LB3u","C3vIC3rYAw4","C0XPC3rLBMu","BePwEKy","C3rYAw5NAwy","BMrWB2LUDfq","EhHkshG","y2fSBa","tuHuv2W","Bw1LsNi","Fdr8oxWY","yNLL","q2nyAgm","zsbHihn0CMK","D1vKsw0","A3PLC0m","A0vOA1i","igzHAwWSig0","x21LC3nHz2u","yMLUza","weHwwue","rgvLy04","DwTmzeS","CMfJBxK","zMnJA3G","rfnfBfK","BgLUzq","C3rLBMvYCW","shjvEvq","zw5JB2rLrNi","ugDpCMi","CevOAhK","CMvZzxruCMK","CMvZzxrdB3u","z3rYwLy","uenqrei","sfDUyvy","DMvYC2LVBG","ywXSq3vYC28","zvLsvhO","qu1cAfu","yxvsBhy","tg9Nsuq","v0vnAgi","t2jKtLK","Bwv0Ag9K","yw5Hz2vY","x3DHAxq","v0Xzt3e","tMDiqNq","vePqr00","B25nzxnZywC","yxbWBhK","B2zMC2v0","vNPdswS","CNnVCKzPBgu","EeTcAgq","zujTEKS","s0Xvt1K","DhjPBq","rwzVqNu","EuDjqxu","ntG3n3Duru94BW","ueXque0","mdaWma","t1v2uuO","zw5KCg9PBNq","CK9Ry1a","Dgv4Dc9WBge","uK5KEfi","shnivu0","CMvJzxzPzwq","Cvjtv1i","BMrLEa","CNzHBfzHBhu","CwDpthC","zgvSzxrL","x3vYBa","C2HPzNq","mNW0Fdf8mhW","zcWG","y29UBMvJDca","CM92AwrLihy","z2v0q3vYCMu","whjzr2W","Bwf4uMv0CMK","y3r3Bg4","rwfNCu0","x3bPBMDqB24","q0Xpu0LorW","yw5ZzM9YBvq","Dev2zw50","EePzEvK","ChvZAa","zxjYtM8","CgXLyxnLiha","B2nRzxq","sM1Kzuy","DvfYquy","ywn2vKm","x3fVC0rc","t25YuNy","C2vYDMvYvgK","BerIvw4","ywXS","vujSDgS","y3jLyxrLt3a","CKDWELG","CvL6r0m","rNruvvC","wgjqweC","zMLSDgvY","zLfzt2C","AvLcsLq","B0P6quO","yKTOzM0","ChjVDg9JB2W","uLDoqLq","y3vYC29Yx24","DMLJzuLeig8","uhz0qu8","vxPbr2S","BhnUtu8","Cxztrxe","Cu5ywLu","wu9lEwu","zKrIvKu","t1DNt1m","z1rPBwvVDxq","CMvZzxrfBMq","x2DLDeLUDgu","zvvYBa","BMDfwKG","yLPTy1u","CMvTB3zLrxy","CMfTugfYyw0","zxvxqK4","AhvXCeK","rfrfvMy","t2XJCLm","DMfSDwu","vw5urfi","BMfTzq","ywnRx2LK","D2fSz00","EKDxtgi","zMzMzG","twTLAg4","sxHyy24","sM1Vse8","B3vUDa","Dgn2twy","Axfvz2G","x3jLy29UBMu","wgz1Bgm","v2Xpv0e","zNjVBunOyxi","BfLPu0O","qMv6weO","B25JBg9Zzq","CgXAreC","D3nZoI8V","DuD4rgy","Cvzmtvi","vfHVqKq","BeTdBNu","uMXptLC","mJbHBMTnqNe","AuTyvuS","t1bftL9fuLi","r0zfqwy","v0TAvMS","tvv1t0u","zgLZCgf0y2G","Ae1LC3nHz2u","D21LDNO","ihrPBwvZ","DuLIvhK","yNL0zu9MzNm","zMvY","t2zwu0e","A3vSrLy","rgTtuwG","u2vpquu","yM9KEq","DgLUzYbZzxi","zNjVBuj5Dgu","Cwf1BMy","zuzvr2S","Bu9Hs3y","zxjFBxnNAwq","z0HKzxu","uxPfy1O","BLLxChy","D3P5wK8","DwrSs04","tK91yMq","uujYt1e","yKvirKK","A25pqNq","DNPAyMy","x2nVBM5Ly3q","tg1ku20","q09oveLovuu","r2zSC2i","AwXSihvZzsa","A2Lgy3i","ywrKt25L","u2vXsuq","m3WYFdeXFdq","DcbVzIbYyw4","wLrStLa","rNjcvxq","wuP0CfK","vhbgvhu","B21JB1i","tMDVDuG","D3jfEwO","y2HHCKnVzgu","z25OwKy","y29UBMvJDa","qvH1uee","y3vYCMvUDeK","EhPMDK4","uM5Pte8","zNjVBNrPzxi","uxbgD3y","tgPgvMq","z2v0q3vYC28","t015B3e","BxnN","AenSB3nLrxy","ywnRtxnNswq","CMjfueu","y2HLy2Tszwe","ywX3yxLZ","CxDTsK0","twPRsM8","q09otKvdveK","swrUtxe","Dw5RBM93BIa","uMvJB25Uzwm","BfbuB3y","BMrWB2LUDca","yxnL","rwrlD3G","yxLUAvy","wvPntgG","x2rLC3rYB3K","CNDorgi","BLD6q1e","sKTvA1q","BMvJDa","y09Wzw4","rKX6vxu","svrxwfC","AxmGDw5Kzwy","zNjVs1e","DgHeu2O","AefJA01LC3m","AgfZ","x2LZqNjVD3m","x2nSzwfYvgK","BgXbt1u","zMLkCha","txvyBMW","yw1L","Aw47y2HHCNm","vLPfBwe","mhW1FdH8nNW","tg9JAW","CM92AwrLihC","nxWYFda","DhDVCMTdAge","x0rctMfTzq","x3bPBMC","C2XPy2u","r3bVte4","sezXuLG","DfvjExC","B25LCNjVCG","AvrzvfK","Cgf5Bg9Hza","swzyBM8","zxjYB3i","Avjjq1O","CvjqD3e","B3bLBIa","B2nMCM4","ExPVy1u","C2v0","C21oDKW","C29Tzq","tw9WtK8","z2v0s2v5","uevyzxG","x2rItMfTzq","CMXNs1e","AMzXrgq","zxjFywnRx20","BeHHBMrSzxi","r0zQvhm","zwn0","vNDJCNC","A09uD0m","z2v0qwXSs2u","BxjsywW","DvjssM0","rKXfCum","ENvrDLG","rMPHu2W","BwvZ","mhWYFdf8nxW","y29UBMvJDeu","CfPyuKO","z2zeBxC","EhbWD3C","uwHWze8","zw5XDwv1zq","Dg9VigXHCMC","y0TzDgG","BfPWrK0","B3jRzxjhBg8","zM9Rvg8","txPosvq","tgLZDgvUzxi","mJq0ndmYAMHbr2rj","B25Uzwn0Aw4","DMfSDwvZ","yNL0zuXLBMC","x19LC01Vzhu","tNvrzgq","C2v0y3vYC28","zv90Aw1LB3u","zufJAW","B2LUDfjLywm","y3vYDMfSDwu","z2Tzu3q","rLL4D1q","B2ftvM4","C2vUDa","yMLUyxj5vhK","DfnXChO","yw5Nzq","CMXWze8","x3DZ","uLPSDgC","x3jLBw92zvC","x2TLEvbHDgG","tu5Urxi","zNDczhe","igXHCMDLCIa","BwfUDwfSihi","Efrurw52","qNDeCwG","EgvcAMy","uuXfz2W","x29WDgLVBNm","AK9WAu8","CMjMzg4","svfLs1a","yw1Lu3bHy2u","CMfTzq","zfjyzKK","AwPqtNu","ihjLy29UBMu","tMfTzq","ExjpEuy","u1roDMi","sgXdzgK","BeHZrMi","jMPZy2fSBgi","DwvRz0y","DxnLCKLW","tvbUA2y","zeflBgG","EvPWAMm","ue5kvNy","zgvJB2rLzey","z3zmA2G","yuLMEKK","DNfAtxi","vwngvwO","DvDpz2q","C1jbz2K","z2v0","zM9Yy2u","Ewj5q2u","qKfvBha","zLDNz1y","zw50","C3vIyxjYyxK","rKTmANq","BwvZC2fNztO","vMzZuLC","zxjHDg9Y","ihbYB3rVy28","B25szwnLAxy","sLvfzLq","Dhj1y3rVCIa","vxbWD3i","CYbWyxjHBxm","ywDLrxzLBNq","u2v2Efe","CNjVCK1LC3m","rhHiC2u","DMPsA04","te5kA2O","zw5HyMXLvhi","BML0AwfSAxO","C3rVCcbPBw0","DvPeu3G","qwjVCNrfCNi","BMnLq2XVC2u","B25VCgvU","uK9QquC","DMP1C1q","y29SBM8","zxH0zw5ZAw8","zxq9DxrMltG","ywzL","uwjLs2m","zNzNwhO","v2vPEgLUsLm","Cgf5Bg9Hzeu","BhrPCgXLihq","uM5kzgq","quH1D3C","EMD6q0u","mxWZFdj8mhW","D0HpuxK","vwPVtKG","AMvevem","CIb0DhDjra","yw1qzMy","Bu5mugu","DxbKyxrLq3u","u3njrha","BfzNvMO","D2fZq2XLyw4","y0nLDwi","rhPszwG","Fdj8ohW3Fde","B0Hzq04","EgPiDfy","rxzLBNq","CwDLthi","v1f5y0S","tMTOyNu","wvnes0u","B25tDg9Wsw0","DhzUyLO","y3jLyxrLrxi","shnsvvi","CLbOwvu","BwvY","AeviqwS","B3bLBG","zgrjrcWGzgu","ufDIDMq","tvjjrgq","BLjKv2G","Dg9mB3DLCKm","r05ODxu","zwDjs0W","BwzvCwS","uxfPt0G","DgvZDa","y29Kzq","wwnlsuW","rKnTs3a","zw5HyMXLuw8","q3vZDg9Trxi","DMfS","x2LZtwLUAvq","su9lq0q","DgfYz2v0","Dwvtzwq","wwztz3a","ihzHBgLKigq","BfzKDLa","C0fAwfK","D24GCMvHC28","uwPKEKO","Bwu6ia","ExPxs3m","x2HHBMrSzva","DMziweC","DxjS","A0fnwLC","tKfusvzfx0u","s0jtz2q","yxrLq291BNq","t295Ehy","C3vuDLK","vM9cwu0","ChbL","wuzJDuG","yxrHlcbKyxq","sxrXCgO","zxH0ugf5Bg8","tuTjEfe","Cezdr2m","Dhr3Awq","D0zqA20","A2v5","BxLtquS","EwrJrvq","DKn5s3C","x2HHBMrSzvi","zwDfAhG","x0vysvnu","Du9ez24","qvHdvNG","qurxug0","BMDLza","wK1rvM4","A25VALK","B25TzxnZywC","ruLvvxu","uKv1u0m","vw5PBxbSzw0","D012ue0","ueLbt1a","BNblsK0","s2TmEuq","vhPrCxC","C0jf","yLLevM8","rM9mtwy","ywrK","EvPpqvG","weH1Dwq","y1fRzvm","x3bPBMDmB3m","Aw5JBhvKzxm","CgfYC2u","BwvZC2fNzq","qMPNt3G","CM1TBhm","y291BNq","y2XVC2u","C3rXAMG","BvPqDMO","BIWGAg9ZDg4","uKDsDuS","A3P5DNu","CMfbr2i","END4D2G","uvbSuLe","yLPPtfa","q1vivxG","zfDVCMTLCKC","t3bLBKv2zw4","EhHlExK","DhLWzq","zxjYtxnN","BNzQqvu","u3fOAwe","EM1yq2u","wvfhCw8","EvDUwLe","C3rVCMu","Cen0v28","y2XLyxi","vMnXq3q","mxW0Fdn8mNW","quLZvNa","CgLUz0LUDgu","Bgvgrwy","veDlsKy","DuzUt28","rvr3vxO","s05rC0O","x2nYzwf0zvm","AwrI","DvnUsvy","twrsEg8","wLHTrgG","x2n1CNnVCK4","rMzXC0y","zxjFAxnFywm","z2v0u3rVCMe","lcbOB3n0BMe"];return so=function(){return t},so()}(()=>{let t=M,e={duDzU:function(o,n){return o instanceof n},YSDKE:function(o,n){return o===n},BzEBi:"BqYHE",KNeEo:function(o,n){return o(n)},PNJVv:function(o,n){return o+n},JmdeF:function(o,n){return o+n},dOpMm:t(391),jBqTe:function(o,n){return o+n},ebeoU:function(o,n){return o*n},zYkeW:function(o,n){return o*n},rDMOz:function(o,n,i){return o(n,i)},MuXnl:function(o,n){return o+n},YOKye:function(o,n,i){return o(n,i)},lgjZq:t(856),KHpxC:function(o,n){return o(n)},ofWqJ:t(1399)+t(1399)+t(1399)+t(1399),lNhSR:function(o,n){return o<n},oHYCN:function(o,n){return o>n},uIbTy:function(o,n){return o!==n},IFhvr:function(o,n){return o!==n},sxIIy:function(o,n){return o-n},WlXND:function(o,n){return o<n},YMFvY:function(o,n){return o!==n},gnhZF:function(o,n,i){return o(n,i)},cnnet:function(o,n){return o>>>n},qRSWR:function(o,n){return o(n)},Hcpzy:function(o,n,i){return o(n,i)},oSqIf:function(o,n){return o&n},LmJSm:function(o,n){return o===n},yIZvD:function(o,n){return o===n},kWuaj:t(179)+t(751)+" field: "+t(932),KIfYK:function(o){return o()},MCawj:function(o,n,i){return o(n,i)},MjkJo:function(o,n){return o(n)},GMxZj:"boe",QjdzJ:t(1288),NYdwb:function(o,n){return o>=n},bUnDc:t(1485)+"3",SVoYA:function(o,n){return o instanceof n},zwxwh:t(860)+t(1059)+t(1211),tHJEe:"applicat"+t(1388),cApwy:"applicat"+t(1388)+";charset"+t(550),HISni:"string",hivKE:"binary",kiFcr:function(o,n,i,d){return o(n,i,d)},MvBBG:function(o,n){return o===n},UzAGk:"SGZUa",VcqCt:function(o,n,i){return o(n,i)},YWvnj:function(o,n){return o!==n},Bdqoy:function(o,n,i){return o(n,i)},pMQcY:"HAUaQ",VXDxp:function(o,n,i){return o(n,i)},XKvFy:t(1439),nDZhq:function(o,n,i){return o(n,i)},amsBv:function(o,n,i){return o(n,i)},fPuTG:function(o,n,i){return o(n,i)},FrBUt:function(o){return o()},CcXhc:function(o,n,i){return o(n,i)},qJsYN:function(o,n,i){return o(n,i)},NgouH:function(o,n){return o(n)},QRHly:function(o,n){return o!==n},wcQqr:function(o,n,i){return o(n,i)},sfRYc:function(o,n,i){return o(n,i)},YARxN:function(o,n,i){return o(n,i)},YhIZq:function(o,n){return o!==n},Uppwr:function(o,n,i){return o(n,i)},HLKAQ:function(o,n){return o!==n},iRICZ:function(o,n){return o!==n},ADWPm:function(o,n,i){return o(n,i)},mPtfw:function(o,n){return o===n},OZBWK:"MLrFr",Zrbxj:t(1270),UtjCn:function(o,n){return o!==n},PAykD:t(833),DLDkS:t(928),mAhrW:function(o,n,i){return o(n,i)},jOpiO:function(o,n,i){return o(n,i)},DCRoX:t(992),IxXcn:function(o,n){return o(n)},XhCmW:function(o,n){return o(n)},saFsW:function(o,n){return o>>>n},jfqDd:function(o,n,i){return o(n,i)},OrfpK:function(o,n){return o(n)},bBQOw:function(o,n){return o(n)},qDKaK:function(o,n){return o(n)},tMiIU:function(o,n){return o(n)},pXVML:function(o,n,i){return o(n,i)},qKLNM:function(o,n){return o===n},mvdeF:"Missing "+t(751)+t(446)+t(1e3),fSsQF:"Missing "+t(751)+t(446)+t(834),AIunN:t(179)+"required"+t(446)+"method",KmjuJ:function(o,n,i){return o(n,i)},borQF:function(o,n){return o<n},VzCIk:t(1034),NuQdd:function(o,n){return o+n},ohaUj:function(o,n){return o&n},rjyPb:function(o,n,i){return o(n,i)},Crcew:function(o,n){return o+n},ocfrn:function(o,n){return o&n},wzyZO:function(o,n){return o(n)},yFXhd:function(o,n){return o!==n},MNnEr:t(857),xzfvN:t(1541)+"t limit",qgOLw:function(o,n){return o+n},vloWc:"eEcqG",MJbUk:function(o,n){return o>=n},MfHcZ:function(o,n){return o+n},qcord:function(o,n){return o>n},cewYJ:function(o,n,i){return o(n,i)},yGcft:function(o,n){return o+n},uekgF:function(o,n){return o+n},eWtMn:function(o,n){return o===n},ZJMVI:function(o,n){return o===n},VsVlh:function(o,n){return o&n},isfvJ:function(o,n){return o+n},wYtcO:function(o,n){return o|n},WABMo:function(o,n){return o<<n},eBBAV:function(o,n){return o&n},WUuCo:function(o,n){return o==n},MKIxQ:function(o,n){return o!==n},EfUeF:function(o,n){return o<<n},DKRKt:function(o,n){return o&n},habjT:function(o,n){return o<<n},juOTr:function(o,n){return o&n},ngsRP:function(o,n){return o(n)},EfoBu:function(o,n){return o==n},OikOS:function(o,n){return o>=n},tACcq:function(o,n){return o+n},GQjOA:function(o,n){return o+n},zygrI:function(o,n){return o+n},ZXmDh:function(o,n){return o+n},fWggV:function(o,n){return o!==n},egIKL:function(o,n){return o|n},iMegH:function(o,n){return o<<n},aAGUW:function(o,n){return o<<n},sAZXY:function(o,n){return o===n},Ryqib:t(1449),iTYTY:function(o,n){return o|n},MNeZr:function(o,n){return o<<n},gHdeu:function(o,n){return o&n},LvfCi:function(o,n){return o<n},dGTWB:function(o,n){return o>>n},zgzCE:function(o,n){return o+n},TJPGM:t(1076),hKesG:function(o,n,i){return o(n,i)},irkUL:function(o,n){return o>=n},YAbKc:function(o,n){return o+n},vCyKw:function(o,n){return o+n},rawck:function(o,n){return o<n},MUuOE:function(o,n,i){return o(n,i)},lAGhl:function(o,n){return o&n},CUtjr:function(o,n){return o!==n},mNLPe:t(1628),pEhhy:function(o,n){return o|n},bkeOn:function(o,n){return o&n},bKuWq:function(o,n){return o&n},bKhfm:function(o,n){return o<n},DeecN:function(o,n){return o+n},FHDEt:function(o,n,i){return o(n,i)},mfUqk:function(o,n){return o<<n},kncVf:function(o,n){return o>=n},HFqRX:function(o,n,i){return o(n,i)},dbEmV:function(o,n){return o&n},PWbvd:t(1032)+t(304),Npoed:function(o,n){return o(n)},oRFvi:function(o,n){return o&n},KLUOY:function(o,n){return o===n},JkfID:function(o,n){return o&n},trEFo:function(o,n){return o(n)},wTIto:function(o,n){return o&n},tOulV:function(o,n){return o&n},YZMLh:function(o,n){return o<<n},IxFHU:function(o,n){return o&n},ayniV:function(o,n){return o&n},nJGHn:function(o,n){return o(n)},GFEAf:function(o,n){return o<<n},dAKlh:function(o,n){return o<<n},LQRVj:function(o,n){return o&n},PEXex:function(o,n){return o(n)},ObdNY:function(o,n){return o&n},LqGqR:function(o,n){return o&n},MPnkf:function(o,n){return o<<n},WEMhb:function(o,n){return o|n},ciuNE:function(o,n){return o|n},RlONW:function(o,n){return o<<n},rbfdn:function(o,n){return o>>>n},pOUhR:function(o,n){return o|n},lYiSJ:function(o,n){return o<<n},OsEFN:function(o,n){return o|n},tdYka:function(o,n){return o|n},UIKgC:function(o,n){return o<<n},leFEf:function(o,n){return o!==n},voaMp:t(704),FjaSl:t(1267),wFPkm:function(o,n){return o|n},JKebx:function(o,n){return o>>>n},hvFUn:function(o,n){return o>>>n},wrEyj:function(o,n){return o<n},TXoBD:function(o,n){return o<n},hEHAk:function(o,n){return o<n},ZhvPh:function(o,n){return o&n},svBPn:function(o,n){return o>>>n},Itqpj:function(o,n){return o+n},PiXOr:function(o,n){return o!==n},KkLyD:function(o,n){return o|n},kEhkR:function(o,n){return o+n},VZEma:function(o,n){return o>>>n},nEooW:function(o,n){return o!==n},zqRqJ:function(o,n){return o>>>n},QxYxt:function(o,n){return o&n},vYkhg:function(o,n){return o>>>n},ZfZCa:function(o,n){return o!==n},MopNO:function(o,n){return o!==n},YwuWD:function(o,n){return o|n},rgboB:function(o,n){return o>>>n},ovLeQ:function(o,n){return o!==n},MRIDd:function(o,n){return o>>>n},ueSed:function(o,n){return o|n},nWzCQ:function(o,n){return o>>>n},gcjvD:function(o,n){return o&n},WaIVo:function(o,n){return o!==n},GtdcU:function(o,n){return o|n},TYxms:function(o,n){return o&n},wfXAs:function(o,n,i){return o(n,i)},QAmHo:t(410),ZpWpN:function(o,n){return o|n},uZDSx:function(o,n){return o|n},yzocU:function(o,n){return o|n},hgyDr:function(o,n){return o|n},ZCsDS:function(o,n){return o<<n},JMzji:function(o,n){return o<<n},OMyoq:function(o,n){return o|n},pBQwR:function(o,n){return o<<n},oVsdD:function(o,n){return o<<n},dMwph:function(o,n){return o===n},ciqic:function(o,n){return o|n},FYxwT:function(o,n){return o|n},IfXno:function(o,n){return o>>>n},AnfKn:function(o,n){return o|n},bKQpf:function(o,n){return o<<n},yxIKW:function(o,n){return o<<n},KNQsJ:function(o,n){return o<<n},pmiER:function(o,n){return o&n},CUHUx:function(o,n){return o&n},HUCol:function(o,n){return o>>>n},XHVYA:function(o,n){return o>>>n},YQGqo:function(o,n){return o&n},SWsqD:function(o,n){return o&n},XqPoz:function(o,n){return o&n},NhfPW:function(o,n){return o>>>n},hvJvP:function(o,n){return o+n},pCtWo:function(o,n){return o+n},zYYyp:function(o,n){return o!==n},lXVNr:function(o,n){return o<<n},cKYth:function(o,n){return o&n},tNZPu:t(718),KIFtW:function(o,n){return o<=n},hqUUN:function(o,n){return o+n},NTJlF:function(o,n){return o|n},PYfVJ:function(o,n){return o/n},LtEke:function(o,n){return o>>>n},zdpNn:function(o,n){return o>>>n},qRPwq:function(o,n){return o===n},rbEPE:function(o,n){return o>>>n},xzjYs:function(o,n){return o&n},acvVC:function(o,n){return o>>>n},wwCcK:function(o,n){return o>>>n},SeOAE:function(o,n){return o+n},tYNYq:function(o,n){return o|n},mlqua:function(o,n){return o>>>n},EOWjp:t(578),oljJI:function(o,n){return o===n},lwHdU:function(o,n){return o+n},uQrAF:t(274),SIVcQ:t(1199),KKjIZ:function(o,n){return o&n},xrGvS:function(o,n){return o>>>n},bZmcU:function(o,n){return o>>>n},WxOLT:function(o,n){return o&n},iyLbo:function(o,n){return o&n},WirHx:function(o,n){return o>>>n},FKLjt:function(o,n){return o&n},JCJnF:function(o,n){return o>>>n},AHuww:function(o,n){return o&n},xKBhd:"5|0|3|1|"+t(659),oPcSq:t(1030)+t(1600),RZltg:t(631)+t(398),BuaXu:t(742)+t(542)+"R",IQxnc:"OPEN_ERROR",ABVov:t(1282)+t(348),xtIjO:t(601)+t(1064),nRNGD:t(1358)+"0",Laxfa:t(1480),AnAZN:function(o,n){return o===n},cCeub:function(o,n){return o-n},stqjh:function(o,n){return o===n},BPieI:function(o,n){return o>n},Xflpw:function(o,n){return o===n},yzWKs:t(1568)+"d error.",TzQqw:function(o,n){return o+n},lAtlq:function(o,n){return o+n},clBRQ:function(o,n){return o(n)},knojY:t(333),fvgXz:t(1377)+"e_timeout",cXZva:t(822),tUIyw:t(1590),Ooyxv:function(o,n){return o===n},xfDJQ:"lpbye",xxKyy:"MKzHC",CpByg:t(547),sRAgi:t(1333),XMnGn:function(o,n,i){return o(n,i)},qnCTy:"3|0|4|1|2",JFAGw:function(o,n){return o<n},IPKVP:"UJwpB",KngMB:t(1329),GeeJK:function(o,n,i){return o(n,i)},MEbSQ:function(o,n,i){return o(n,i)},pkYAa:function(o,n){return o instanceof n},gVoXp:function(o,n){return o+n},hyhCM:t(1335),gOBsp:"TxgRU",nRdWh:"OOxnQ",iNKnK:function(o,n){return o(n)},uzpmY:function(o,n){return o>=n},YWDUn:function(o,n){return o<=n},IkYJj:t(1619),bSALP:function(o,n){return o||n},QBrOQ:function(o,n){return o||n},Zmahs:"undefined",omcoR:function(o,n){return o!==n},FrKnX:t(241),FLzUu:function(o,n){return o||n},GNhuu:function(o,n){return o+n},neUsw:function(o,n){return o<n},Ikaxk:function(o,n){return o<n},uXKXo:function(o,n){return o&n},OnpLd:function(o,n){return o+n},gtrZV:function(o,n){return o>=n},vByBL:function(o,n){return o&n},IAjfh:function(o,n){return o===n},BQeaY:t(754),fkzys:function(o,n){return o-n},smNvL:function(o,n){return o|n},giTbh:function(o,n){return o|n},VABxw:function(o,n){return o<<n},OWgOS:function(o,n){return o&n},YqiCv:function(o,n){return o<<n},zSQST:function(o,n){return o&n},PpsLL:function(o,n){return o<<n},KWLew:function(o,n){return o&n},JHdoP:function(o,n){return o>>n},wpskj:function(o,n){return o&n},iYBJT:function(o,n){return o<n},wJuDS:function(o,n){return o<n},tcvMf:function(o,n){return o===n},ruEQP:function(o,n){return o&n},RnKLa:function(o,n){return o===n},qNFfk:function(o,n){return o+n},qvSEq:function(o,n){return o+n},jkBlE:function(o,n){return o|n},RGRuK:function(o,n){return o&n},YHJlH:function(o,n){return o&n},XrYGl:function(o,n){return o-n},wUdIm:function(o,n){return o==n},KeZGy:function(o,n){return o!=n},Mkehn:function(o,n){return o instanceof n},NpKpZ:function(o,n){return o instanceof n},TpFTu:function(o,n){return o!=n},iKXUK:function(o,n){return o>=n},kzesC:function(o,n){return o>>n},rlgKQ:function(o,n){return o|n},tVRJc:"sAvPF",fcckx:t(1559),dcBaM:t(1438),QiuAC:t(1163)+t(1476)+t(252)+"P",lSDYX:function(o,n){return o!==n},zfcSN:t(253),kLhPg:"sFDia",etMzY:t(1367),Jmjft:function(o){return o()},walgM:"xvAhw",uODgn:t(158),xlxZT:function(o,n){return o!==n},PKtQj:"WnMbE",HrUyT:function(o,n){return o===n},cQkeS:t(1171),YZBiK:t(862),uSnIV:"VUkkL",ijPNu:"done",RjqZa:t(725)+"oreNames",uFnOo:t(1354),YeyHP:"GhGfx",JNfTY:function(o,n){return o||n},xjHtV:t(612)+t(1547),xeWpT:t(1498)+t(1303),huqpI:t(342),ROjAG:t(1353),tZImE:function(o,n){return o===n},OuYoY:"rbpNN",qAFZj:function(o,n){return o+n},mvhDo:t(1501),XZfOr:function(o,n){return o||n},HkMAe:function(o,n){return o||n},SsIDp:function(o,n){return o(n)},ctwln:function(o,n){return o!==n},ElCle:"froKQ",QldnK:function(o,n){return o||n},ZMQVn:function(o,n){return o||n},ILCQi:function(o,n){return o||n},IXNYZ:function(o,n){return o!=n},Xrwsm:"init QoS"+t(766)+"d",AXCVx:"qos",xRBPg:function(o,n){return o(n)},VgcFB:function(o,n,i){return o(n,i)},nZoCA:function(o,n){return o!==n},NVvBk:t(765),TDZKr:function(o,n,i,d){return o(n,i,d)},nkcgv:"x_frontier_qos",kzyvu:function(o,n,i,d){return o(n,i,d)},tDFxa:t(160)+t(493)+"ck",WaSPZ:function(o,n,i,d){return o(n,i,d)},ZBgZb:"x_fronti"+t(1373)+"k",wMGpY:"x_fronti"+t(1091)+t(1474),eBmzK:"RHqlW",lVdvP:function(o,n){return o(n)},dBAoA:t(638),pHPVG:function(o,n,i,d){return o(n,i,d)},AAYKC:"need_ack",bbMlv:function(o,n){return o&&n},vLpLI:function(o,n){return o!==n},npKJM:t(1532),mXRuF:t(935),qgeLr:t(346),kAMZW:function(o,n){return o||n},SFWIS:"none_none",yEEjd:function(o,n,i,d){return o(n,i,d)},qYUyL:"YdNJO",DSElY:function(o){return o()},Vfkrc:function(o,n){return o!==n},NgHBt:function(o,n){return o-n},DWZjt:t(1581),HwQPO:function(o,n){return o+n},MfjnM:function(o,n){return o+n},uGxDf:t(404),zPIcL:function(o,n){return o(n)},uhPGW:function(o,n){return o+n},GkNfR:t(165),rGpzX:function(o,n){return o||n},gpCkV:" > ",EtFPw:function(o,n){return o>n},Mpaok:"integer "+t(1111)+"e",GVbAw:function(o,n){return o>=n},DLWQu:function(o,n){return o===n},DTEVf:"syjBo",pqwvN:t(1302),VriUF:function(o,n){return o+n},vIrTu:function(o,n){return o>>>n},gcDPF:"jurSB",lYouz:t(1221)+"4",rOkcP:function(o,n){return o+n},zGsWQ:function(o,n,i,d){return o(n,i,d)},qaunf:function(o,n){return o+n},vfHXG:function(o,n){return o===n},SCnna:"LAKkJ",uoZvk:"zkbWj",EsfnX:function(o,n){return o+n},kqJbs:function(o,n){return o+n},knOBt:function(o,n){return o|n},DxHse:function(o,n){return o|n},eFUGk:function(o,n){return o|n},pLPgn:function(o,n){return o<<n},MQhfq:function(o,n){return o+n},wgpaW:function(o,n){return o<<n},ymIzQ:function(o,n){return o<<n},HfrIk:function(o,n){return o+n},PKcSc:function(o,n){return o+n},lhwQP:function(o,n){return o+n},ybyCe:function(o,n){return o>>>n},cYewN:function(o,n){return o+n},hYhYe:function(o,n){return o&n},RZQVE:function(o,n){return o+n},PCPDB:function(o,n){return o&n},inLIU:function(o,n){return o>>>n},JfSOT:function(o,n){return o+n},GYQwT:function(o,n){return o>>>n},lRQEE:function(o,n){return o+n},MLBWq:function(o,n){return o+n},sZXtW:function(o,n){return o&n},gizjX:function(o,n){return o&n},ZTlNP:function(o,n){return o+n},PJpuX:t(1500)+t(1234)+t(552)+"0",qaThV:function(o,n){return o|n},MFpsL:function(o,n){return o|n},mkErN:function(o,n){return o>>>n},vgXgP:function(o,n){return o&n},TjcBh:function(o,n){return o<<n},gYyCI:function(o,n){return o|n},qeAIs:function(o,n){return o<n},lKLIh:function(o,n){return o>>>n},HlCdi:function(o,n){return o|n},rgPlc:function(o,n,i,d){return o(n,i,d)},akgSx:function(o,n){return o|n},LjFVd:function(o,n){return o|n},sTolw:t(270),BezXJ:t(576),sNgRe:t(1495)+t(1432)+t(802),thDSj:t(494),gkYSt:"cursor.s"+t(649),mPuIm:t(1128),EdKwx:function(o,n,i,d){return o(n,i,d)},WKZVk:t(934),fDbVE:t(170),RWNBT:"service-name",DKSyJ:function(o,n){return o>n},KstSw:function(o,n){return o>n},dMkzz:function(o,n){return o(n)},XhGXr:function(o,n){return o(n)},fTUcG:function(o,n){return o<n},ElCeh:t(603),CBkzJ:function(o,n,i){return o(n,i)},OlcrS:function(o,n,i,d){return o(n,i,d)},xJYyY:function(o,n){return o+n},CCpEB:t(910)+t(1058),ruEWu:"ALL",zHlEe:t(572),PbigX:t(995),KFrWL:t(1396),xFBwj:function(o,n){return o>>>n},bFMsq:function(o,n){return o===n},jeDTC:t(1174),uhHxt:t(1124)+"r",eszDy:"naDVx",mySAK:t(463),Blfoo:function(o,n){return o||n},qwmJM:"YOESQ",JwHDE:function(o,n){return o-n},EAjsG:function(o,n,i,d){return o(n,i,d)},JVJak:t(160)+t(982),dRXfI:function(o,n,i){return o(n,i)},Pdmbz:"x_frontier_ttl",yZpjc:"x-msg-qos",XQbAg:"x-msg-cu"+t(747)+"ue",gIKNa:function(o,n){return o>n},GYaoO:"aSgpQ",xDhNL:t(1527),UbGbs:function(o){return o()},ngEZH:function(o){return o()},plhoF:"TLMWT",tsdow:function(o,n){return o===n},jnWvP:function(o){return o()},QXfuG:function(o,n,i){return o(n,i)},XpzpE:function(o){return o()},cQSGx:function(o,n){return o===n},tkPUM:"xtQCo",NlhdQ:function(o,n){return o(n)},OtSIy:function(o,n){return o<n},rmmls:function(o,n){return o!==n},HsRUR:function(o,n,i){return o(n,i)},EkPOl:function(o){return o()},zTgmb:function(o,n){return o===n},qVLMR:t(1027),CMejp:t(205),RNdxR:t(1377)+t(1447)+"s",hCGOE:t(1406),STNvb:function(o,n,i){return o(n,i)},ZndaC:"qipZY",yZOAX:t(1098),kulFV:function(o,n,i){return o(n,i)},VGJxi:function(o,n){return o===n},wzyQs:t(1041),UoVeY:t(912),oRcpp:function(o,n,i){return o(n,i)},jOuua:function(o,n,i){return o(n,i)},pFCGc:function(o,n){return o!==n},mvBxi:function(o,n){return o(n)},CYHoB:function(o,n,i){return o(n,i)},EyMYf:function(o,n,i){return o(n,i)},YFcuH:function(o,n,i){return o(n,i)},kZvrI:function(o,n){return o||n},UnTDR:t(557)+t(263),QqiOH:t(1177),bMfvI:t(1086),Blnpk:t(171),ehAHB:"count",BnbJE:t(307),tvnbZ:t(1322),bYDVo:t(1356),uRRJm:function(o){return o()},xppww:"arraybuf"+t(971),WLYOq:function(o,n){return o===n},hgFQM:t(887)+t(874)+t(703),oSUtP:t(887)+t(1063)+t(1193)+t(326)+t(1457)+t(1191)+t(1048)+t(356),BkykZ:t(628),lZpFM:t(1571),YJtpY:function(o,n){return o!==n},KFnLs:"GpKrU",cEBic:t(216)+"t",oaSVn:t(1528),uocAs:"pagehide",OtPzr:t(553),oOoot:t(369),LhdTh:t(1061)+t(1001)+t(475)+"7",bDhSe:function(o,n){return o&n},qMyuB:function(o,n){return o<n},plZDG:function(o,n){return o|n},lDbUn:function(o,n){return o>>>n},FcCRr:function(o,n){return o|n},tULmX:function(o,n){return o<<n},QPlRQ:function(o,n){return o&n},EPPLt:function(o,n){return o|n},FCmKp:function(o,n){return o<<n},Gflsb:function(o,n){return o&n},savsI:function(o,n){return o>n},prIYq:function(o,n){return o>>>n},hZJjw:function(o,n){return o===n},UXMNv:t(1576),mWuDR:t(592),IAbaz:t(467),VoBYM:t(319),yrOYB:t(953),kNpAV:"bd_did",Olhrt:"device_id",AMBhU:function(o,n){return o==n},LKTcW:"function",COpvx:t(338),bHxAs:t(444)+"0",pnuzv:t(663),JSGrU:t(353),ITWXW:function(o,n,i){return o(n,i)},qoFdW:t(511),NnvJy:function(o,n){return o(n)},yNIyb:function(o,n){return o(n)},MwlBG:t(1417)+">",wWAXC:function(o,n){return o*n},xZpDK:function(o,n){return o>n},UKVBi:function(o,n,i){return o(n,i)},CdTcm:function(o,n){return o|n},MzNIT:function(o,n){return o|n},QxsRA:function(o,n){return o|n},iksaG:function(o,n){return o<<n},nxlwy:function(o,n){return o<<n},FfqsF:function(o,n){return o<<n},IKQWC:t(972),wHOQy:t(359)+t(1376)+t(216)+t(977)+"ver",tvWXL:t(761)+t(555)+t(1119)+"g",CHCMf:t(610),RniLO:"3|1|0|4|2",nshwu:t(1249),BYmMf:t(224),Xfulc:t(815),ROyST:function(o,n,i){return o(n,i)},Tmhax:t(803),VHCWQ:t(359)+t(564)+t(1526)+t(301),UTBmU:t(354),iqUgh:t(893),kBmJo:function(o,n){return o+n},WkRea:function(o,n){return o===n},VLXdQ:function(o,n){return o+n},PIAOP:function(o,n){return o||n},oPdqm:t(781),vMitH:t(1233),iCoBt:t(479),lTSgO:"fFMMz",QpFwv:t(1389),OjVMX:t(709)+t(726),jKJFQ:t(423)+t(325)+"ce not i"+t(1201)+"ed",yClJm:function(o,n){return o===n},cEqxh:t(423)+t(329)+"y closed",NxtoS:"please p"+t(411)+t(1271)+t(1290)+t(533)+t(805)+"ng or an"+t(789)+t(643),hhCAr:t(204),leawH:function(o,n){return o(n)},yrOyF:function(o,n){return o(n)},pZXRJ:function(o,n){return o instanceof n},dwbKu:function(o,n){return o(n)},ZYuwG:t(1132),VzovT:function(o,n){return o<n},LyDdk:t(1110),TWOys:function(o,n){return o==n},wQvJq:"CWSoe",HWnaV:t(1588),XyNHG:"4|0|3|1|2",pwEdK:function(o,n,i){return o(n,i)},aXwFf:t(157),cTggA:function(o,n){return o===n},IQeKP:"Window",xKNRa:function(o,n){return o!=n},raAGb:function(o,n){return o===n},WgzAd:t(1552),eUpfF:t(1635)+t(1344)+t(505)+"pe",OVURz:function(o,n){return o!=n},CVxol:function(o,n){return o!=n},aGQhN:t(1471)+t(188)+t(1583),eOTjR:"ServiceW"+t(1114)+t(619),xrOfX:function(o,n){return o!=n},fQYOg:function(o,n){return o!=n},JUEfT:function(o,n){return o===n},LQSzN:function(o,n){return o!=n},TIGDz:"__x_msg_"+t(1385)};Ct.r(be),Ct.d(be,{FWS:()=>Bh,CustomErrorEvent:()=>h0,createCloseEvent:()=>ot,ReconnectEvent:()=>x0,createErrorEvent:()=>Qe,decodedFrame:()=>Un,createOpenEvent:()=>y0,CustomCloseEvent:()=>p0,createReconnectEvent:()=>Lo,FrontierMessageEvent:()=>m0,encodeFrame:()=>We,createMessageEvent:()=>_0,OpenEvent:()=>w0,ErrorCode:()=>Wt,Event:()=>Hn,MessageEvent:()=>g0});let r="";function s(o=""){let n=t;if(e[n(1241)](e.BzEBi,e[n(431)])){let d=""+Date[n(780)](),l=r||(r=e[n(178)](x,o)),g=Math[n(1454)]()[n(602)](16)[n(1068)](-6);return e[n(1169)](e[n(889)]("02",d)+l,g)}else mxNYVN[n(527)](_0x34caaf,_0x3f499c)&&_0x105324[n(1082)](_0xb626d5,_0xf3392f)}function a(){let o=t;return e[o(1241)](o(391),e[o(282)])?e.jBqTe(e[o(221)](1e4,Date[o(780)]()),Math.floor(e[o(267)](1e4,Math[o(1454)]()))):(_0x2c0290[o(294)](_0xb610d8),!1)}function c(o){let n=t;return(Array(8)[n(1407)]("0")+e[n(1561)](parseInt,o,10)[n(602)](2))[n(1068)](-8)}function f(o){let n=t;return e[n(1057)](Array(4).join("0"),e[n(917)](parseInt,o,2)[n(602)](16)).slice(-4)}function u(o){let n=t,i=o[n(620)](/\./)[n(1382)](g=>c(g)),d=[];return d[0]=f(e[n(1169)](i[0],i[1])),d[1]=f(i[2]+i[3]),[e[n(752)],n(856),e.lgjZq,n(856),e[n(752)],n(938),d[0],d[1]][n(1407)]("")}function x(o){let n=t,i=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/.test(o),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(1259)](o);return i?e[n(1522)](u,o):d?e[n(178)](h,o):e[n(1518)]}function h(o){let n=t,i="",d=[],l=0,g=0,m=!0,S=e[n(752)];if(o[n(660)]("::")>-1){let p=o.split("::");for(let A=0;e.lNhSR(A,p[n(490)]);A++){let B=p[A];if(e[n(1235)](B[n(660)](":"),0)){let H=B[n(620)](":");m&&(l=H[n(490)]),g+=H[n(490)];for(let W=0;e[n(1386)](W,H[n(490)]);W++)if(e[n(969)](4,H[W][n(490)])){let $=S.substring(0,4-H[W][n(490)]),Ee=$[n(715)](H[W]);d[n(885)](Ee)}else d[n(885)](H[W]);m=!1}else{if(e[n(1626)](4,B[n(490)])){let H=S.substring(0,e[n(258)](4,B[n(490)])),W=H[n(715)](B);d.push(W)}else d[n(885)](B);m&&(l+=1),g+=1,m=!1}}let D="";for(let A=0;e[n(276)](A,e[n(258)](8,g));A++)D=D[n(715)](S);for(let A=0;e[n(276)](A,d[n(490)]);A++)A===l&&(i=i[n(715)](D)),i=i[n(715)](d[A]);return i}{let p=o[n(620)](":");for(let D=0;e[n(276)](D,p[n(490)]);D++){let A=p[D];if(e[n(1626)](4,p[D][n(490)])){let B=S[n(793)+"g"](0,e[n(258)](4,p[D].length)),H=B[n(715)](A);i=i[n(715)](H)}else i=i[n(715)](A)}return i}}function w(o,n){let i=t,d=o.key;e.YMFvY(void 0,d)&&(e[i(1011)](V,n,10),e[i(1011)](Ne,n,d));let l=o[i(932)];l!==void 0&&(V(n,18),Ne(n,l))}function E(o){let n=t,i={};e:for(;!e.KHpxC(N,o);){let d=_e(o);switch(e.cnnet(d,3)){case 0:break e;case 1:i[n(1297)]=e[n(917)](we,o,e[n(178)](_e,o));break;case 2:i.value=e[n(917)](we,o,e[n(864)](_e,o));break;default:e[n(559)](k,o,e[n(472)](7,d))}}if(e.LmJSm(void 0,i.key))throw new Error(n(179)+n(751)+n(446)+n(1297));if(e[n(1452)](void 0,i[n(932)]))throw new Error(e.kWuaj);return i}function C(o){let n=e.KIfYK(T);return e.MCawj(y,o,n),e.MjkJo(z,n)}function y(o,n){let i=t,d={GeUlr:function(je,Ue){return e[G(323)](je,Ue)},rlpdO:e[i(1340)],wMvPM:e.tHJEe,AIsVp:e[i(195)],qsDBc:e[i(1443)],qSgjX:e[i(351)],CRltd:function(je,Ue,Rt,gn){return e[i(998)](je,Ue,Rt,gn)}},l=o.SeqID;if(e.IFhvr(void 0,l)){if(e.MvBBG(e[i(913)],i(1146)))return this._socket[i(1280)];e[i(1357)](V,n,8),e[i(362)](ge,n,l)}let g=o[i(834)];e[i(175)](void 0,g)&&(V(n,16),e.Bdqoy(ge,n,g));let m=o[i(170)];if(e[i(175)](void 0,m))if(e.yIZvD(i(853),e[i(1482)]))switch(_0x2115cc){case e[i(226)]:case e[i(1275)]:return{[i(1564)+_0x39dfcb]:1,"x-tt-env":_0x53d0f0};default:return{}}else e.VXDxp(V,n,24),e[i(559)](ge,n,e[i(1522)](L,m));let S=o[i(837)];if(S!==void 0)if(e[i(1626)](e.XKvFy,e[i(706)]))if(_0x2ac8fc[i(1074)]instanceof _0x5cdc3e){let je=this[i(1149)][i(1216)+"ncoding"]instanceof _0x108bbd?{force:!!this._options[i(1216)+i(1540)].force,encoding:this[i(1149)]["payloadE"+i(1540)][i(471)]?this[i(1149)].payloadEncoding.encoding[i(1613)](/\s/g,"")[i(1254)+"ase"]():""}:{force:!1,encoding:this._options["payloadE"+i(1540)]?this[i(1149)].payloadEncoding[i(1613)](/\s/g,"")["toLowerC"+i(1036)]():""},Ue=_0x3fa030[i(1216)+i(1540)]?_0x4e6bad[i(1216)+"ncoding"][i(1613)](/\s/g,"")[i(1254)+i(1036)]():"",Rt=d[i(1451)](this[i(1149)]["payloadT"+i(436)],_0x1bc7ff)?{force:!!this._options.payloadType.force,type:this[i(1149)][i(758)+i(436)][i(1347)]?this._options[i(758)+i(436)][i(1347)][i(1613)](/\s/g,"")[i(1254)+"ase"]():""}:{force:!1,type:this[i(1149)][i(758)+i(436)]?this._options[i(758)+i(436)][i(1613)](/\s/g,"")[i(1254)+i(1036)]():""},gn=_0x2c93e1[i(758)+"ype"]?_0x1a6284[i(758)+"ype"][i(1613)](/\s/g,"")["toLowerC"+i(1036)]():"",Ni=Rt[i(1178)]?Rt[i(1347)]:gn||Rt.type,Mi=je.force?je[i(471)]:Ue||je.encoding,Or=[d[i(1136)],d[i(1314)],d[i(1359)],d.qsDBc],Ho=["none_none",d.qSgjX];this[i(1149)][i(1200)+"ansformT"+i(1292)+"ad"]&&Or[i(1327)](Ni)&&(!Mi||Ho[i(1327)](Mi))?_0x3a4130[i(1434)+i(1520)]=d[i(430)](_0x204235,_0x2e18b4[i(1074)],0,_0xe7b5b5[i(1074)].byteLength):_0x29c409.textPayload=""}else _0x1a8728.textPayload="";else e[i(538)](V,n,32),e[i(169)](ge,n,L(S));let p=o[i(210)];if(p!==void 0)for(let je of p){e[i(488)](V,n,42);let Ue=e[i(1004)](T);e.CcXhc(w,je,Ue),V(n,Ue[i(526)]),e[i(497)](st,n,Ue),e[i(1008)](O,Ue)}let D=o[i(1216)+i(1540)];e[i(686)](void 0,D)&&(e[i(712)](V,n,50),e[i(360)](Ne,n,D));let A=o[i(758)+i(436)];A!==void 0&&(e[i(1561)](V,n,58),e.YARxN(Ne,n,A));let B=o[i(1074)];e[i(315)](void 0,B)&&(e.Bdqoy(V,n,66),e[i(1357)](V,n,B[i(490)]),e[i(1192)](fe,n,B));let H=o[i(644)];e[i(211)](void 0,H)&&(V(n,74),e[i(804)](Ne,n,H));let W=o[i(894)+i(208)];e[i(1077)](void 0,W)&&(e[i(1306)](V,n,82),Ne(n,W));let $=o.msgID;if(e[i(315)](void 0,$))if(e.mPtfw(e.OZBWK,e[i(640)])){if(_0x3755eb<=-_0x483616)return _0x2dbeed;if(e.NYdwb(e[i(1169)](_0x1f8e48,1),_0x1ff02f))return _0x46daa7}else V(n,90),Ne(n,$);let Ee=o[i(750)+"e"];if(e[i(433)](void 0,Ee)){if(e.uIbTy(e[i(772)],e[i(585)]))e[i(662)](V,n,96),e[i(1150)](ge,n,L(Ee));else if(!this[i(993)+i(1062)]){let je=e[i(1477)][i(620)]("|"),Ue=0;for(;;){switch(je[Ue++]){case"0":this[i(658)+"osed"]=!1;continue;case"1":this[i(1326)+"sCounter"]?.[i(825)+i(432)]();continue;case"2":this[i(187)]=!0;continue;case"3":this[i(993)]();continue;case"4":this[i(534)+i(399)]?.[i(921)+i(382)+i(1562)]();continue}break}}}}function b(o){let n=t;return e[n(686)](n(380),e[n(1460)])?e[n(940)](v,e[n(178)](F,o)):e[n(1461)](this[n(1332)],this["maxLossC"+n(942)])}function v(o){let n=t,i={};e:for(;!e[n(1029)](N,o);){let d=e.XhCmW(_e,o);switch(e.saFsW(d,3)){case 0:break e;case 1:i[n(1e3)]=e[n(497)](Fn,o,!0);break;case 2:i[n(834)]=e[n(1090)](Fn,o,!0);break;case 3:i[n(170)]=_e(o);break;case 4:i[n(837)]=e.OrfpK(_e,o);break;case 5:{let l=e[n(1522)](I,o);(i[n(210)]||(i[n(210)]=[]))[n(885)](E(o)),o[n(526)]=l;break}case 6:i[n(1216)+n(1540)]=e[n(1090)](we,o,e[n(1572)](_e,o));break;case 7:i[n(758)+n(436)]=we(o,_e(o));break;case 8:i[n(1074)]=e.fPuTG(se,o,e[n(1029)](_e,o));break;case 9:i[n(644)]=e[n(362)](we,o,e[n(940)](_e,o));break;case 10:i[n(894)+n(208)]=e.qJsYN(we,o,e[n(1579)](_e,o));break;case 11:i[n(546)]=we(o,e[n(1475)](_e,o));break;case 12:i.frameType=e[n(940)](_e,o);break;default:e[n(350)](k,o,e[n(472)](7,d))}}if(e.qKLNM(void 0,i.SeqID))throw new Error(e[n(1574)]);if(e[n(994)](void 0,i[n(834)]))throw new Error(e[n(345)]);if(e[n(1452)](void 0,i[n(170)]))throw new Error(n(179)+n(751)+n(446)+n(170));if(i[n(837)]===void 0)throw new Error(e.AIunN);return i}function I(o){let n=t;if(e[n(846)]!=="UsCrb"){let i=_e(o),d=o[n(526)];return o.limit=e[n(1123)](o[n(845)],i),d}else{let i=e[n(1554)](_0x393a1e,_0x15fc4a,_0x210f6f[n(526)]),d=_0x529379[n(624)],l=_0x3cae77[n(624)];for(let g=0,m=_0x15a104[n(526)];e[n(387)](g,m);g++)d[e[n(889)](g,i)]=l[g]}}function k(o,n){let i=t;switch(n){case 0:for(;e[i(1563)](128,e[i(1029)](Te,o)););break;case 2:P(o,e[i(1579)](_e,o));break;case 5:e[i(917)](P,o,4);break;case 1:e[i(176)](P,o,8);break;default:throw new Error(e[i(1595)](i(1313)+i(669)+i(639),n))}}function L(o){return o|=0,{low:o,high:o>>31,unsigned:o>=0}}let _=[];function T(){let o=t,n=_[o(531)]();return n?(n[o(845)]=n[o(526)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(o){_[t(885)](o)}function F(o){let n=t,i={TGKJF:function(d,l){return e[G(1080)](d,l)},yShtj:function(d,l){return e[G(986)](d,l)},vqZMr:function(d,l){return d<<l},nYWpv:function(d,l){return d&l}};if(e[n(537)](e[n(1141)],"OUvQJ"))_0x28f0a2=_0x1ac50c(_0x10fa44),_0xfd3dc5=i[n(1362)](127,_0x40026a),i[n(1362)](128,_0x24c50a)&&(_0x542571=i[n(314)](_0x2bf120,_0x529486),_0x54d7a0|=i[n(1173)](i[n(985)](127,_0x5d42b8),7));else return{bytes:o,offset:0,limit:o[n(490)]}}function z(o){let n=t,i=o[n(624)],d=o.limit;return e.yIZvD(i[n(490)],d)?i:i.subarray(0,d)}function P(o,n){let i=t;if(e[i(1235)](o[i(845)]+n,o[i(526)]))throw new Error(e[i(1015)]);o[i(845)]+=n}function N(o){let n=t;return e[n(175)](e[n(1636)],e[n(1636)])?e[n(867)](_0x48cc54(4)[n(1407)]("0"),e[n(662)](_0x2649cb,_0x36bd3a,2).toString(16)).slice(-4):e[n(675)](o[n(845)],o[n(526)])}function U(o,n){let i=t,d=o[i(624)],l=o.offset,g=o.limit,m=e[i(243)](l,n);if(m>d[i(490)]){let S=new Uint8Array(2*m);S[i(1082)](d),o[i(624)]=S}return o[i(845)]=m,m>g&&(o[i(526)]=m),l}function Y(o,n){let i=t,d=o[i(845)];if(e[i(1410)](e[i(1169)](d,n),o.limit))throw new Error(i(749)+i(1469));return o[i(845)]+=n,d}function se(o,n){let i=t,d=e.cewYJ(Y,o,n);return o[i(624)].subarray(d,e.yGcft(d,n))}function fe(o,n){let i=t,d=e[i(497)](U,o,n[i(490)]);o[i(624)][i(1082)](n,d)}function we(o,n){let i=t,d={HIXEj:function(D,A){return D==A},DJkFN:e[i(1443)],QhpdO:e.zwxwh},l=Y(o,n),g=String[i(948)+i(783)],m=o[i(624)],S="\uFFFD",p="";for(let D=0;D<n;D++){let A=m[e.uekgF(D,l)],B,H,W,$;if(e[i(1542)](e[i(1563)](128,A),0))p+=g(A);else if(e[i(785)](e.VsVlh(224,A),192))e[i(1504)](D,1)>=n?p+=S:(B=m[e.Crcew(e[i(1169)](D,l),1)],e[i(211)](192&B,128)?p+=S:($=e[i(1465)](e.WABMo(e[i(472)](31,A),6),e[i(236)](63,B)),$<128?p+=S:(p+=g($),D++)));else if(e[i(1393)](e[i(472)](240,A),224))e[i(487)](D,2)>=n?p+=S:(B=m[e[i(1504)](D,l)+1],H=m[e[i(1504)](D+l,2)],e[i(1293)](e[i(1080)](e[i(1465)](B,e.EfUeF(H,8)),49344),32896)?p+=S:($=e[i(1465)](e[i(1465)](e[i(740)](e.DKRKt(15,A),12),e[i(541)](e.oSqIf(63,B),6)),e.juOTr(63,H)),$<2048||e.NYdwb($,55296)&&$<=57343?p+=S:(p+=e[i(1607)](g,$),D+=2)));else if(e[i(852)](e[i(381)](248,A),240))if(e.OikOS(e.tACcq(D,3),n))p+=S;else if(B=m[e[i(782)](e.MfHcZ(D,l),1)],H=m[e[i(420)](e[i(1370)](D,l),2)],W=m[e[i(1057)](D+l,3)],e[i(1181)](e[i(381)](e[i(1465)](e[i(1256)](B,e.iMegH(H,8)),e[i(1538)](W,16)),12632256),8421504))p+=S;else{if(e[i(1273)](e[i(1425)],"gfLrQ"))return d[i(414)](d[i(1379)],typeof _0x118dc5)?d[i(1109)]:"";$=e.iTYTY(e[i(162)](7&A,18)|e.habjT(e[i(983)](63,B),12)|e[i(1538)](63&H,6),e[i(1563)](63,W)),e[i(1622)]($,65536)||e[i(1410)]($,1114111)?p+=S:($-=65536,p+=g(e[i(243)](e[i(738)]($,10),55296),e[i(1220)](e[i(472)](1023,$),56320)),D+=3)}else p+=S}return p}function Ne(o,n){let i=t,d=n[i(490)],l=0;for(let S=0;e[i(1386)](S,d);S++){let p=n[i(1010)+"At"](S);e[i(1378)](p,55296)&&p<=56319&&e[i(1484)](S,1)<d&&(p=e[i(1300)](p<<10,n[i(1010)+"At"](++S))-56613888),l+=p<128?1:e.LvfCi(p,2048)?2:e.rawck(p,65536)?3:4}V(o,l);let g=e[i(964)](U,o,l),m=o[i(624)];for(let S=0;e.WlXND(S,d);S++){let p=n[i(1010)+"At"](S);e[i(1593)](p,55296)&&p<=56319&&e[i(1484)](S,1)<d&&(p=e[i(1300)](e[i(517)](p,10),n[i(1010)+"At"](++S))-56613888),p<128?m[g++]=p:(e[i(387)](p,2048)?m[g++]=e[i(381)](e[i(738)](p,6),31)|192:(e[i(1622)](p,65536)?m[g++]=e[i(1256)](e.lAGhl(e[i(738)](p,12),15),224):e[i(654)](e.mNLPe,e[i(1227)])?this[i(378)](e.TJPGM,e[i(377)](_0x215f8b,e.TJPGM,{message:this[i(212)+"rrorMessage"](_0x38658)})):(m[g++]=e[i(823)](p>>18&7,240),m[g++]=e.wYtcO(e[i(738)](p,12)&63,128)),m[g++]=e[i(1073)](e[i(343)](p>>6,63),128)),m[g++]=e[i(823)](e[i(716)](63,p),128))}}function st(o,n){let i=t,d=e[i(373)](U,o,n[i(526)]),l=o.bytes,g=n[i(624)];for(let m=0,S=n[i(526)];e[i(907)](m,S);m++)l[e.DeecN(m,d)]=g[m]}function Te(o){return o[t(624)][e.FHDEt(Y,o,1)]}function jt(o,n){let i=t,d=U(o,1);o[i(624)][d]=n}function _e(o){let n=t,i=0,d=0,l;do l=e[n(1572)](Te,o),e.lNhSR(i,32)&&(d|=e.mfUqk(127&l,i)),i+=7;while(e[n(1563)](128,l));return d}function V(o,n){let i=t;for(n>>>=0;e[i(1441)](n,128);)e[i(1070)](jt,o,e[i(1465)](e.dbEmV(127,n),128)),n>>>=7;e[i(538)](jt,o,n)}function Fn(o,n){let i=t,d=0,l=0,g=0,m;return m=e[i(1496)](Te,o),d=e.oRFvi(127,m),e[i(636)](128,m)&&(e[i(850)](i(1402),i(1402))?(m=Te(o),d|=e.aAGUW(e[i(1591)](127,m),7),128&m&&(m=e[i(418)](Te,o),d|=e[i(367)](e[i(194)](127,m),14),e[i(396)](128,m)&&(m=Te(o),d|=e[i(1039)](e[i(396)](127,m),21),e[i(173)](128,m)&&(m=e.OrfpK(Te,o),l=127&m,e[i(1038)](128,m)&&(m=e[i(1445)](Te,o),l|=e[i(962)](e[i(1080)](127,m),7),e[i(1591)](128,m)&&(m=e[i(1008)](Te,o),l|=e.dAKlh(e.LQRVj(127,m),14),128&m&&(m=e[i(940)](Te,o),l|=e[i(517)](e[i(396)](127,m),21),128&m&&(m=e[i(1087)](Te,o),g=e[i(836)](127,m),e[i(756)](128,m)&&(m=Te(o),g|=e.MPnkf(e[i(381)](127,m),7)))))))))):(_0x5d5fe5.frontierJSONP=void 0,e.qRSWR(_0x1d53ce,e[i(1251)]))),{low:e.WEMhb(d,l<<28),high:e[i(251)](e.saFsW(l,4),e[i(958)](g,24)),unsigned:n}}function ge(o,n){let i=t;if(e.leFEf(e.voaMp,e[i(1102)])){let d=e[i(1151)](n[i(771)],0),l=e[i(1548)](e[i(1296)](e[i(368)](n[i(771)],28),n.high<<4),0),g=e.hvFUn(n[i(1556)],24),m=e[i(721)](0,g)?e[i(785)](0,l)?e[i(1009)](d,16384)?d<128?1:2:e[i(1386)](d,2097152)?3:4:l<16384?e[i(956)](l,128)?5:6:e[i(1248)](l,2097152)?7:8:g<128?9:10,S=e[i(488)](U,o,m),p=o[i(624)];switch(m){case 10:p[S+9]=e[i(1543)](e.svBPn(g,7),1);case 9:p[e[i(1291)](S,8)]=e[i(1361)](9,m)?e[i(438)](128,g):e[i(1586)](127,g);case 8:p[e[i(500)](S,7)]=e[i(230)](8,m)?e[i(1317)](e[i(460)](l,21),128):e.VsVlh(e[i(1151)](l,21),127);case 7:p[e.kEhkR(S,6)]=e[i(686)](7,m)?e[i(1073)](e[i(1060)](l,14),128):l>>>14&127;case 6:p[e[i(1057)](S,5)]=e.nEooW(6,m)?e.pOUhR(e.zqRqJ(l,7),128):e[i(1612)](e[i(484)](l,7),127);case 5:p[S+4]=e[i(737)](5,m)?e[i(1296)](128,l):127&l;case 4:p[e[i(813)](S,3)]=e[i(1085)](4,m)?e.YwuWD(d>>>21,128):e.gHdeu(e.rgboB(d,21),127);case 3:p[e.tACcq(S,2)]=e[i(1551)](3,m)?e.OsEFN(d>>>14,128):e[i(1252)](d,14)&127;case 2:p[S+1]=m!==2?e[i(1269)](e[i(1042)](d,7),128):e[i(608)](e[i(1060)](d,7),127);case 1:p[S]=e[i(286)](1,m)?e[i(1453)](128,d):e[i(702)](127,d)}}else return e.yIZvD(_0x3d033a,_0x1f7654)?_0x49a406:new _0x64153c(e[i(1151)](e[i(1525)](_0x188db6[i(799)](_0x1e4cd7,0)|e[i(162)](_0x4f7496[i(799)](_0x5dda87,1),8),_0x3c4bfa[i(799)](_0x27ee39,2)<<16)|e[i(949)](_0x365b5d[i(799)](_0x3f677f,3),24),0),e[i(438)](e[i(251)](e[i(213)](_0x15914d.call(_0x55b30c,4),e[i(269)](_0x524b74[i(799)](_0x2f40d3,5),8)),e[i(962)](_0x3d1af0.call(_0xfe050a,6),16)),_0x2d2539[i(799)](_0x5cdefe,7)<<24)>>>0,!0)}function Un(o){let n=t,i={FVdza:function(d,l,g){return e[G(1592)](d,l,g)}};if(e[n(565)]===e[n(565)])return b(o);{let{value:d,offset:l}=i.FVdza(_0x11dcf8,_0x25687f,_0x5d5628);_0x50cf9a=l,_0x4fcb66=_0x3234b1<<8>>>0,_0x370b44+=d}}function We(o){return e[t(1029)](C,o)}let d0=65536,Yx=e[t(595)],qn=e.zYkeW(d0,d0),f0=e[t(267)](qn,qn),u0=f0/2,Gt=String[t(1383)+"e"][t(1010)+"At"];class oe{constructor(n,i,d){let l=t;this[l(331)]=!0,this.low=e[l(228)](0,n),this[l(1556)]=e[l(1203)](0,i),this.unsigned=!!d}static[t(331)](n){let i=t;return n&&e[i(1542)](!0,n[i(331)])}static fromBits(n,i,d){return new oe(n,i,d)}static[t(978)+"s"](n,i,d){let l=t;return d?oe["fromByte"+l(1615)](n,i):oe[l(978)+l(1319)](n,i)}static[t(978)+"sLE"](n,i){let d=t;return new oe(e[d(1081)](e[d(688)](n[0],n[1]<<8),n[2]<<16)|e.RlONW(n[3],24),e.wYtcO(e[d(1465)](n[4],e[d(1507)](n[5],8))|e[d(711)](n[6],16),e[d(1507)](n[7],24)),i)}static["fromByte"+t(1319)](n,i){let d=t;return new oe(e[d(688)](e[d(1021)](n[4]<<24,n[5]<<16)|e.pBQwR(n[6],8),n[7]),e[d(688)](e[d(835)](e[d(1081)](e[d(541)](n[0],24),e[d(1166)](n[1],16)),e.oVsdD(n[2],8)),n[3]),i)}static[t(193)](n){let i=t;return e[i(787)](n,Yx)?l0:new oe((e[i(1408)](e[i(1130)](Gt[i(799)](n,0),Gt.call(n,1)<<8),Gt[i(799)](n,2)<<16)|e.habjT(Gt[i(799)](n,3),24))>>>0,e[i(1075)](e[i(1256)](e[i(508)](e[i(823)](Gt[i(799)](n,4),e[i(1472)](Gt.call(n,5),8)),e[i(324)](Gt[i(799)](n,6),16)),e[i(1365)](Gt[i(799)](n,7),24)),0),!0)}[t(370)](){let n=t;return String[n(948)+n(783)](e[n(1630)](255,this[n(771)]),e[n(1343)](e[n(1524)](this[n(771)],8),255),e[n(1038)](this[n(771)]>>>16,255),e[n(812)](this[n(771)],24),e[n(1352)](255,this[n(1556)]),e[n(352)](this[n(1556)]>>>8,255),e[n(156)](e[n(484)](this[n(1556)],16),255),e.NhfPW(this[n(1556)],24))}static[t(1505)+"er"](n,i=!0){let d=t,l={KGsWf:function(g,m){return e[G(1387)](g,m)},XHuud:function(g,m){return e[G(1355)](g,m)},PrHKJ:function(g,m){return e[G(220)](g,m)},vjusT:function(g,m){return g|m},AqrGT:function(g,m){return g<<m},LaQKl:function(g,m){return e[G(249)](g,m)},Nkhbu:function(g,m){return e[G(1112)](g,m)},Unwqc:function(g,m){return e[G(907)](g,m)},lHsFb:function(g,m){return g>m},FLEqC:function(g,m){return e[G(1612)](g,m)}};if(e[d(1534)](isNaN,n))return i?Jx:l0;if(i)if(e[d(328)]===e[d(328)]){if(e[d(675)](n,f0))return Vx}else _0x5103f4=_0x1d3455[svCYUY[d(1455)](_0x2ddcec+_0x2b5606,1)],_0x1d949b=_0x32bce4[svCYUY.KGsWf(_0x5ce60c,_0x561588)+2],_0x396d16=_0x1fd8f6[svCYUY.XHuud(svCYUY[d(1324)](_0x546460,_0x4718cd),3)],svCYUY[d(1599)](svCYUY[d(1208)](svCYUY[d(1208)](_0x4a696d,_0x580025<<8),svCYUY.AqrGT(_0x4367a9,16))&12632256,8421504)?_0x4c88af+=_0x43f9b7:(_0x279312=svCYUY.vjusT(svCYUY.vjusT((7&_0x2fedcd)<<18,svCYUY[d(1397)](63&_0x1f14d9,12))|svCYUY.LaQKl(svCYUY.Nkhbu(63,_0x592b03),6),svCYUY[d(1240)](63,_0x5f4133)),svCYUY[d(668)](_0x54e082,65536)||svCYUY[d(1162)](_0x590aa6,1114111)?_0x5218fc+=_0x27868a:(_0x43881a-=65536,_0x4df88b+=_0x58e9d((_0x5416bf>>10)+55296,svCYUY.XHuud(svCYUY[d(1100)](1023,_0x53424d),56320)),_0x4673f1+=3));else{if(e[d(1584)](n,-u0))return Xx;if(e.OikOS(e[d(1398)](n,1),u0))return Zx}return oe[d(1643)](n%qn|0,e.NTJlF(e.PYfVJ(n,qn),0),i)}[t(161)](){let n=t;return n(746)!=="ZzjxK"?_0x4c93e9["objectSt"+n(509)][1]?void 0:_0x583d0e[n(725)+n(790)](_0x18e467[n(725)+n(509)][0]):this[n(229)]?e.MuXnl(e[n(267)](e.LtEke(this[n(1556)],0),qn),e[n(225)](this[n(771)],0)):e[n(221)](this[n(1556)],qn)+e.zdpNn(this[n(771)],0)}[t(515)](){let n=t;return e[n(1078)](0,this.high)&&e[n(1078)](0,this[n(771)])}[t(1322)](n){let i=t;oe[i(331)](n)||(n=oe[i(1505)+"er"](n));let d=e[i(1025)](this.high,16),l=e.ayniV(65535,this.high),g=e[i(460)](this[i(771)],16),m=e[i(539)](65535,this[i(771)]),S=n.high>>>16,p=e[i(194)](65535,n[i(1556)]),D=e.HUCol(n[i(771)],16),A=e[i(173)](65535,n[i(771)]),B=0,H=0,W=0,$=0;return $+=e[i(889)](m,A),W+=e[i(1637)]($,16),$&=65535,W+=g+D,H+=e[i(891)](W,16),W&=65535,H+=e[i(1123)](l,p),B+=e[i(1535)](H,16),H&=65535,B+=e[i(975)](d,S),B&=65535,oe[i(1643)](e.WEMhb(e[i(1257)](W,16),$),e[i(406)](e[i(740)](B,16),H),this[i(229)])}equals(n){let i=t;return oe[i(331)](n)||(n=oe.fromNumber(n)),e[i(315)](this[i(229)],n[i(229)])&&e[i(1273)](e[i(460)](this[i(1556)],31),1)&&e.eWtMn(e[i(196)](n[i(1556)],31),1)?!1:e[i(721)](this[i(1556)],n[i(1556)])&&this[i(771)]===n[i(771)]}[t(999)](){let n=t;if(e.QRHly(n(464),e.EOWjp))return this[n(771)]===-1&&e[n(596)](-1,this[n(1556)])?oe[n(1643)](0,0,this.unsigned):e[n(637)](-1,this[n(771)])?oe.fromBits(0,e[n(385)](this.high,1),this[n(229)]):oe.fromBits(e[n(1123)](this[n(771)],1),this[n(1556)],this[n(229)]);_0x363a35(_0x24f61e[n(1076)]||new _0xe463d5("AbortError","AbortError")),_0x14812a()}[t(290)](n){return n?this[t(358)+"E"]():this.toBytesBE()}[t(358)+"E"](){let n=t;if(e[n(890)]===e.SIVcQ)try{this._qosDB?.[n(1333)](),this[n(892)]=void 0}catch(i){_0x267b5c[n(294)](i)}else{let i=this.high,d=this[n(771)];return[e.KKjIZ(255,d),e[n(492)](d,8)&255,e[n(472)](d>>>16,255),e[n(925)](d,24),e[n(1112)](255,i),e[n(523)](e[n(1042)](i,8),255),e.iyLbo(e.WirHx(i,16),255),i>>>24]}}toBytesBE(){let n=t,i=this.high,d=this.low;return[i>>>24,e[n(476)](e[n(925)](i,16),255),e[n(1184)](e.VZEma(i,8),255),255&i,e.JCJnF(d,24),d>>>16&255,d>>>8&255,e[n(1219)](255,d)]}}let l0=new oe(0,0,!1),Jx=new oe(0,0,!0),Zx=oe[t(1643)](-1,2147483647,!1),Vx=oe[t(1643)](-1,-1,!0),Xx=oe.fromBits(0,-2147483648,!1);var Wt=(function(o){let n=t,i=e[n(848)][n(620)]("|"),d=0;for(;;){switch(i[d++]){case"0":o[o[n(1030)+n(1600)]=5002]=e.oPcSq;continue;case"1":o[o[e.RZltg]=5004]=e[n(1138)];continue;case"2":return o;case"3":o[o[e[n(1380)]]=5003]=e[n(1380)];continue;case"4":o[o[e[n(536)]]=5005]=e[n(536)];continue;case"5":o[o[e[n(1491)]]=5001]=n(1282)+n(348);continue}break}})({});class Hn{constructor(n){let i=t;this[i(1347)]=n,this[i(1268)]=null}}class x0 extends Hn{constructor(n,i){let d=t;super(n),this.message=i&&i[d(1329)]||null}}class h0 extends Hn{constructor(n,i){let d=t,l=e.xtIjO[d(620)]("|"),g=0;for(;;){switch(l[g++]){case"0":this.code=i&&i[d(1260)]||5001;continue;case"1":super(n);continue;case"2":this[d(1329)]=i&&i[d(1329)]||"";continue;case"3":this.filename=i&&i[d(1620)]||"";continue;case"4":this.colno=i&&i[d(1209)]||0;continue;case"5":this[d(415)]=i&&i[d(415)]||0;continue;case"6":this[d(1076)]=i&&i.error||null;continue}break}}}class p0 extends Hn{constructor(n,i){let d=t,l=e.nRNGD.split("|"),g=0;for(;;){switch(l[g++]){case"0":this[d(246)+d(700)]=i&&i[d(246)+d(700)]||!1;continue;case"1":super(n);continue;case"2":this.wasClean=i&&i[d(1231)]||!1;continue;case"3":this.reason=i&&i[d(304)]||"";continue;case"4":this.code=i&&i[d(1260)]||0;continue}break}}}class g0 extends Hn{constructor(n,i){let d=t;super(n),this[d(184)]=i&&i[d(184)]||null}}class m0 extends g0{constructor(n,i){let d=t;super(n),this.data=i&&i[d(184)]||null,this[d(1329)]=i&&i[d(1329)]||null}}class w0 extends Hn{constructor(n,i){let d=t;super(n),this.data=i&&i[d(184)]||null}}function Qe(o,{message:n,code:i,error:d}){return new h0(o,{message:n,code:i,error:d})}function ot(o,{code:n,reason:i,wasClean:d,willReconnect:l}){return new p0(o,{code:n,reason:i,wasClean:d,willReconnect:l})}function _0(o,{data:n,message:i}){return new m0(o,{data:n,message:i})}function y0(o,{data:n}){let i=t;return e[i(1181)]("OAjsB",e[i(651)])?new w0(o,{data:n}):_0x1e955e}function Lo(o,{message:n}){return new x0(o,{message:n})}class b0{constructor(n,i){let d=t;this[d(858)+"s"]=n,this[d(877)+"es"]=i,this["currentI"+d(865)]=0,this[d(200)+d(797)+d(748)+"t"]=0}[t(921)+t(382)+"fig"](){let n=t;this[n(1014)+n(865)]=0,this.currentEndpointTriesCount=0}[t(824)+"es"](){let n=t;this[n(200)+n(797)+n(748)+"t"]=0}[t(875)+"ntEndpoint"](){let n=t;return this[n(858)+"s"][this[n(1014)+"ndex"]]}[t(875)+t(256)+t(456)+t(942)](){let n=t;return this[n(200)+n(797)+n(748)+"t"]}[t(1026)+t(366)+"es"](){let n=t;return!!(e[n(1461)](this[n(1014)+n(865)],this[n(858)+"s"][n(490)])||e[n(254)](this[n(1014)+n(865)],e[n(1232)](this[n(858)+"s"][n(490)],1))&&e[n(1334)](this["currentE"+n(797)+n(748)+"t"],this[n(877)+"es"]))}[t(206)+t(1594)+t(1127)+t(296)+t(518)](){let n=t;return e[n(852)](this[n(1014)+n(865)],this[n(858)+"s"].length)?!0:e[n(1405)](this[n(200)+n(797)+"riesCount"],this[n(877)+"es"])}[t(397)+t(164)+"pointAnd"+t(1481)+"unt"](){let n=t;return this["currentE"+n(797)+n(748)+"t"]=1,this[n(1014)+n(865)]++,this[n(858)+"s"][this["currentI"+n(865)]]}[t(875)+t(256)+"ntAndUpd"+t(1284)](){let n=t;return this[n(200)+n(797)+n(748)+"t"]++,this[n(875)+n(256)+"nt"]()}}let jn=(e[t(400)](e.Zmahs,typeof globalThis)&&e[t(1435)](e[t(1152)],globalThis["construc"+t(677)][t(934)])||e[t(588)]!=typeof window&&e.IQeKP===window["construc"+t(677)][t(934)])&&e[t(400)](e[t(588)],typeof document),pn=e[t(412)](e.Zmahs,typeof globalThis)&&(e[t(1339)](e.WgzAd,globalThis[t(724)+"tor"][t(934)])||e[t(1078)](e[t(364)],globalThis[t(724)+t(677)][t(934)]))&&e.TpFTu(e[t(588)],typeof tt),kr=(t(506)+"d"!=typeof globalThis&&e.WgzAd===globalThis["construc"+t(677)][t(934)]||e[t(1575)](e.Zmahs,typeof globalThis)||e[t(581)](e[t(588)],typeof globalThis)&&!!globalThis[t(1215)+t(764)])&&e.CVxol(e.Zmahs,typeof wx),Pr=e[t(588)]!=typeof globalThis&&(e[t(820)](e[t(364)],globalThis[t(724)+t(677)][t(934)])||e.LmJSm(e[t(403)],globalThis["construc"+t(677)][t(934)])||e[t(1542)](e[t(383)],globalThis[t(724)+"tor"][t(934)]))&&e[t(462)](t(506)+"d",typeof self),Qx=e[t(904)](e[t(588)],typeof globalThis)&&e[t(1190)](e[t(413)],globalThis[t(724)+t(677)][t(934)])&&e[t(1006)](t(506)+"d",typeof global)&&e[t(666)](e[t(413)],global[t(724)+t(677)][t(934)])&&e[t(588)]!=typeof process&&!!process[t(829)];class No{constructor(){let n=t;this[n(439)+"rs"]={}}[t(378)](n,...i){let d=t,l=this._listeners[n];if(l)l[d(1068)]()[d(189)](g=>g.fn[d(844)](g[d(231)],i));else if(e[d(598)](e[d(842)],n)&&!this[d(1072)]){let g=i[d(490)]&&i[0];if(g instanceof Error)throw g;let m=new Error(e[d(867)](e[d(1277)],g?e[d(1318)](e[d(478)](" (",g[d(1329)]),")"):""));throw m.context=g,g}return this}off(n,i){let d=t,l={GZyrW:function(g,m){return e[G(480)](g,m)},RnJdd:e[d(1309)],DaZjO:e[d(1214)]};if(e[d(654)](e[d(202)],e[d(1071)])){if(e[d(1285)](void 0,n))this._listeners={};else if(e[d(1241)](void 0,i))this[d(439)+"rs"][n]=null;else if(e[d(664)]===e[d(1346)])l[d(186)](_0x44002b,l[d(1218)]),this.off(d(1377)+d(1447)+"s",_0x185e33),this.off(l[d(268)],_0x399ae8);else{let g=this._listeners[n];if(g)for(let m=0;e[d(387)](m,g[d(490)]);)e[d(1542)](g[m].fn,i)?g[d(394)](m,1):++m}return this}else{let g={UjKwp:function(m,S){return m(S)}};return function(...m){let S=d;return _0x19031e.apply(g[S(745)](_0x35bded,this),m),_0x28ce00(_0x406d44[S(1177)](this))}}}on(n,i,d){let l=t;return(this._listeners[n]||(this[l(439)+"rs"][n]=[])).push({fn:i,ctx:d||this}),this}}class eh extends No{["_formatE"+t(1196)+"age"](n){let i=t;return n.errMsg||n[i(886)]?(i(1185)+" "+(n.errMsg||"")+i(655)+(n[i(886)]||""))[i(851)]():JSON[i(796)+"y"](n)}constructor(n,i,d){let l=t;super(),this[l(316)]=null,kr&&wx.connectSocket&&(this[l(316)]=wx["connectS"+l(888)]({url:n,protocols:i,header:d,fail:this[l(1366)+l(1545)+l(1092)].bind(this),success:this[l(1366)+l(1466)+l(757)+l(375)].bind(this)})),pn&&tt[l(734)+l(888)]&&(this[l(316)]=tt[l(734)+"ocket"]({url:n,protocols:i,header:d,fail:this[l(1366)+"ocketFai"+l(1092)].bind(this),success:this[l(1366)+"ocketSuc"+l(757)+"ler"][l(811)](this)}))}[t(1366)+t(1466)+t(757)+t(375)](){let n=t;if(e[n(1514)](n(547),e.CpByg))return!!_0x1fecfc?.[n(1638)](i=>i[n(1297)]===_0x2ae0e0&&i.value===_0x2d909f);Promise[n(337)]().then(()=>{this[n(459)+"steners"]()})}[t(1366)+t(1545)+t(1092)](n){let i=t,d={vyjiw:function(l,g,m){return e[G(176)](l,g,m)},lJVzF:e[i(842)],oJzAJ:i(1333)};Promise[i(337)]()[i(264)](()=>{let l=i,g=d.vyjiw(Qe,d[l(795)],{message:this["_formatE"+l(1196)+l(524)](n)});this[l(378)](d[l(795)],g);let m=d[l(1625)](ot,d[l(906)],{reason:this[l(212)+l(1196)+l(524)](n)});this[l(378)](d[l(906)],m)})}[t(459)+"steners"](){let n=t,i={NcpMU:e.sRAgi,uWYYh:function(d,l,g){return e[G(525)](d,l,g)},UZJln:e[n(694)],QLEgl:function(d,l){return e[n(635)](d,l)},FtTUW:function(d,l,g,m){return d(l,g,m)},lfOlT:function(d,l){return e[n(596)](d,l)},wNyON:e[n(233)],boPww:e[n(172)],zCwUE:n(1076)};this[n(316)][n(590)](d=>{let l=n;this[l(378)](l(1249),e[l(1150)](y0,l(1249),{...d,data:d[l(1348)]||""}))}),this._socket[n(357)](d=>{let l=n;this[l(378)](i[l(641)],i[l(691)](ot,i[l(641)],{...d}))}),this[n(316)][n(843)+"e"](d=>{let l=n,g={rlbii:i[l(1428)],injSo:function(m,S){return i[l(1148)](m,S)},CXSfW:function(m,S,p,D){return i[l(901)](m,S,p,D)},HqcKm:function(m,S){return m+S}};if(i.lfOlT(i.wNyON,l(443))){let m=g[l(1585)][l(620)]("|"),S=0;for(;;){switch(m[S++]){case"0":if(g[l(1602)](_0x4b8ebb[l(490)],40))return g[l(650)](_0x303cae,_0x2b827a,_0x46f10f,_0x3b6239)+_0x2ed27b;continue;case"1":if(_0x48dca7[l(405)])return _0x45b6b2[l(405)](_0x28df20,_0x398e1b)+_0x451629;continue;case"2":return g[l(634)](_0x4c667e(_0x1bfa80,_0xd06a9b,_0x55bdca),_0x369c95);case"3":if(!_0xb3c795)return _0x4ab3e4;continue;case"4":if(_0x1b6020[l(774)+"e"])return g[l(634)](_0x3627ca[l(774)+"e"](_0x357f64,_0x394279),_0x375792);continue}break}}else this[l(378)](i[l(481)],i[l(691)](_0,l(1329),{...d}))}),this._socket[n(1618)](d=>{let l=n;this[l(378)](i[l(600)],Qe(l(1076),{...d,message:d[l(1348)]||""}))})}[t(437)](n){let i=t,d={dtwou:e[i(842)],eMVFN:function(l,g,m){return e[i(569)](l,g,m)},BptXo:function(l,g,m){return e.MEbSQ(l,g,m)}};if(e.pkYAa(n,Uint8Array)){let l=n.buffer[i(1068)](n[i(970)+"et"],e.gVoXp(n.byteLength,n[i(970)+"et"]));this._socket&&this[i(316)][i(437)]({data:l,fail:g=>{let m=i;this[m(378)](d.dtwou,d[m(730)](Qe,"error",{message:this[m(212)+m(1196)+m(524)](g)}))}})}else this._socket&&this[i(316)][i(437)]({data:n,fail:l=>{let g=i;this[g(378)](g(1076),d.BptXo(Qe,g(1076),{message:this[g(212)+g(1196)+"age"](l)}))}})}[t(1333)](n,i){let d=t;if(e[d(291)]===e[d(306)])return 0;this[d(316)]&&this[d(316)][d(1333)]({code:n,reason:i})}[t(1598)+t(1117)](n,i){this.on(n,i)}[t(926)+"entListe"+t(513)](n,i){this.off(n,i)}get[t(760)+"te"](){let n=t;return this[n(316)][n(760)+"te"]}get[t(1133)+"pe"](){let n=t;return this._socket[n(1133)+"pe"]}set[t(1133)+"pe"](n){}get[t(1280)](){let n=t;if(e[n(1334)]("FxnNV",e[n(1253)])){let i=_0xf61975[n(531)]();return i?(i[n(845)]=i[n(526)]=0,i):{bytes:new _0x27ee4f(64),offset:0,limit:0}}else return this[n(316)][n(1280)]}get protocol(){let n=t;return this._socket[n(908)]}get extensions(){return this._socket.extensions}get["buffered"+t(614)](){let n=t,i={JszXV:function(d,l){return e[G(1411)](d,l)},suTvY:function(d,l){return e[G(701)](d,l)},GgQFT:function(d,l){return e.YWDUn(d,l)},Vwcrw:function(d,l){return e[G(1408)](d,l)},QzEcZ:function(d,l){return e[G(251)](d,l)},OAQbG:function(d,l){return d/l}};if(e[n(458)]!=="FvcBe"){if(ulOiPL.JszXV(_0x58ae89,_0x2e9415))return _0x4a0150?_0x1e8d43:_0x893d64;if(_0x19b875){if(ulOiPL[n(1286)](_0x12972a,_0x5d3f36))return _0x558f7e}else{if(ulOiPL[n(656)](_0x4423a3,-_0x2cd51a))return _0x28a70b;if(_0x34496f+1>=_0x1e8a32)return _0x3d0d5f}return _0x1daa6e.fromBits(ulOiPL[n(1095)](_0x52c8f8%_0x59e8ce,0),ulOiPL[n(984)](ulOiPL.OAQbG(_0x810540,_0x5258b9),0),_0x42d364)}else return 0}}function th(o,n){let i=t;if(n)return new n(o.url,o[i(908)]);if(e[i(341)](kr,pn))return new eh(o.url,o[i(908)],o[i(210)]);if(e[i(989)](jn,Pr)&&e[i(588)]!=typeof WebSocket&&WebSocket)return new WebSocket(o[i(1280)],o.protocols)}function nh(o){let n=t,i={vjRkN:function(d,l){return e[G(1007)](d,l)}};if(e.Xflpw(e[n(402)],n(166))){let d=_0xcb621a[_0x29b122];if(cTuEus[n(1198)](4,_0x5abc86[_0x159967][n(490)])){let l=_0x365a21[n(793)+"g"](0,4-_0x1e7c95[_0xf6d4b][n(490)]),g=l[n(715)](d);_0x2cc544=_0xb980cf[n(715)](g)}else _0x1e6065=_0x46d076.concat(d)}else return!!(o||kr&&wx["connectS"+n(888)]||pn&&tt[n(734)+n(888)]||e[n(1046)](jn,Pr)&&e[n(588)]!=typeof WebSocket&&WebSocket)}function E0(o,n,i){let d={XiMJb:function(m,S){return e[G(1584)](m,S)},salkx:function(m,S){return e[G(1273)](m,S)},VfsRW:function(m,S){return e[G(1255)](m,S)}},l=-1;async function g(m){let S=G;return d[S(1462)](m,l)?Promise.reject(new Error(S(334)+S(1614)+S(1217)+S(690)+S(1623))):(l=m,d[S(232)](m,i[S(490)])?Promise[S(337)]():i[m][S(811)](o)(n,g[S(811)](null,d[S(1186)](m,1))))}g(0)}function v0(o){let n=t,i=0,d=0;for(let l=0;e[n(448)](l,o.length);++l)d=o[n(1010)+"At"](l),e[n(1009)](d,128)?i+=1:e[n(451)](d,2048)?i+=2:e.LmJSm(e[n(570)](64512,d),55296)&&e[n(1273)](e.AHuww(64512,o.charCodeAt(e.OnpLd(l,1))),56320)?(++l,i+=4):i+=3;return i}function S0(o,n,i){let d=t;if(e[d(276)](i-n,1))return"";let l="";for(let g=n;g<i;){let m=o[g++];if(m<=127)l+=String.fromCharCode(m);else if(e[d(826)](m,192)&&e[d(635)](m,224))l+=String["fromChar"+d(783)](e[d(438)](e[d(962)](e[d(343)](31,m),6),e[d(702)](63,o[g++])));else if(m>=224&&e.TXoBD(m,240))l+=String["fromChar"+d(783)](e[d(1525)](e[d(711)](e[d(1591)](15,m),12)|(63&o[g++])<<6,e[d(648)](63,o[g++])));else if(m>=240){if(e[d(1640)](e[d(1560)],d(1557)))return _0x162f99?.find(S=>S.key===_0x49a5cb)?.[d(932)];{let S=e[d(288)](e[d(1083)](e[d(320)](e.VABxw(e[d(919)](7,m),18),e.YqiCv(e[d(465)](63,o[g++]),12))|e[d(708)](63&o[g++],6),e.KWLew(63,o[g++])),65536);l+=String[d(948)+d(783)](e[d(1220)](55296,e[d(597)](S,10))),l+=String["fromChar"+d(783)](e[d(808)](56320,e[d(468)](1023,S)))}}}return l}function Mo(o,n,i){let d=t,l=i,g,m;for(let S=0;e[d(1622)](S,o[d(490)]);++S)if(g=o[d(1010)+"At"](S),e[d(905)](g,128))n[i++]=g;else if(e.wJuDS(g,2048))n[i++]=e[d(597)](g,6)|192,n[i++]=e[d(1130)](63&g,128);else if(e[d(943)](e.ruEQP(64512,g),55296)&&e[d(666)](64512&(m=o[d(1010)+"At"](e.qNFfk(S,1))),56320)){let p=(d(1104)+"3|4")[d(620)]("|"),D=0;for(;;){switch(p[D++]){case"0":g=e[d(1164)](e[d(915)](65536,e[d(648)](1023,g)<<10),e[d(1343)](1023,m));continue;case"1":n[i++]=e[d(1603)](e.JHdoP(g,18),240);continue;case"2":++S;continue;case"3":n[i++]=e[d(1337)](e.JHdoP(g,6),63)|128;continue;case"4":n[i++]=e.egIKL(e[d(173)](63,g),128);continue;case"5":n[i++]=e.ruEQP(e[d(597)](g,12),63)|128;continue}break}}else n[i++]=g>>12|224,n[i++]=e.KkLyD(e[d(597)](g,6)&63,128),n[i++]=e.YHJlH(63,g)|128;return e[d(876)](i,l)}async function I0(o){let n=t;if(e[n(806)](n(1517),typeof o)){let i=new Uint8Array(v0(o));return Mo(o,i,0),i}return e.duDzU(o,ArrayBuffer)?new Uint8Array(o):new Uint8Array(o[n(424)],o.byteOffset,o[n(1121)+"th"])}function rh(o){let n=t;try{return e[n(722)](e.HISni,typeof o)&&(e[n(939)](o,ArrayBuffer)||o.buffer&&e[n(661)](o[n(424)],ArrayBuffer))||e[n(1006)](e[n(1443)],typeof o)?"":(JSON.parse(o),e[n(1632)])}catch{return e.EfoBu(e[n(1443)],typeof o)?e.zwxwh:""}}let ih=(o,n)=>{let i=t;switch(o){case e[i(226)]:case e.QjdzJ:return{[i(1564)+o]:1,"x-tt-env":n};default:return{}}};class sh{constructor(n){let i=t;this[i(1490)+i(942)]=n,this[i(1332)]=0}[t(528)](){let n=t;this[n(1332)]++}[t(1026)+"chMaxCount"](){let n=t;return e[n(960)](this.count,this[n(1490)+n(942)])}[t(825)+t(432)](n=0){let i=t;this["maxLossC"+i(942)]=n,this[i(1332)]=0}}async function oh(o){let n=t;if(e.lSDYX(e.zfcSN,e.zfcSN))_0x26a1d3[_0x3e6e02++]=e[n(807)](_0x240361,6)|192,_0x3b376b[_0x4eeead++]=e[n(1089)](e[n(352)](63,_0x1ca53b),128);else return new Promise(i=>{let d=n,l={fCrcP:function(g,m){return e[G(1078)](g,m)},NOubd:e[d(235)],jvhCF:"KPrlk",gRpJF:function(g,m){return g(m)},LMhcQ:"unknown "+d(304)};if(!jn)return i(d(1032)+d(304));try{let g=document[d(584)+d(1565)](e[d(816)]);window["frontier"+d(244)]=m=>{let S=d;l[S(1459)](l[S(988)],l[S(295)])?this[S(630)](_0x24c4c5,_0x9e06d0):(document[S(976)][S(767)+S(450)](g),window[S(1017)+S(244)]=void 0,l[S(625)](i,m&&m[S(1022)]||l[S(791)]))},g[d(1347)]="text/javascript",g[d(1510)]=e[d(1300)](o.replace(/^ws/,e[d(567)]),e[d(687)]);try{document[d(976)][d(174)+d(450)](g)}catch{document.body[d(767)+d(450)](g)}}catch{window[d(1017)+d(244)]=void 0,e[d(418)](i,e[d(1251)])}})}function Kt(o,n,i){let d=t;return!!o?.[d(1638)](l=>l[d(1297)]===n&&l.value===i)}function Gn(o,n){let i=t,d={DBXCv:e.TJPGM,nGSXs:function(l,g,m){return l(g,m)},BRZtf:e[i(1176)]};if(e.kLhPg!==e.kLhPg){let l=_0x460100(woBMUs[i(532)],{message:this[i(212)+i(1196)+i(524)](_0x2e8e23)});this[i(378)](woBMUs[i(532)],l);let g=woBMUs[i(512)](_0x43c240,woBMUs[i(672)],{reason:this[i(212)+i(1196)+i(524)](_0x484a0d)});this[i(378)](woBMUs.BRZtf,g)}else return o?.find(l=>l[i(1297)]===n)?.value}let Bo=null;async function ah(){return Bo||(Bo=Promise[t(337)]().then(Ct.bind(Ct,e.etMzY))),Bo}class ch extends No{constructor(n,i){let d=t;super(),this[d(1088)]=n,this._keyPath=i,this._qosDB=void 0,this[d(593)+"mise"]=null}async[t(776)](){await this[t(1523)]()}async[t(1523)](){let n=t,i={DyItI:function(d){return e[G(755)](d)},teBHc:function(d,l,g,m){return d(l,g,m)}};if(!this[n(892)]){if(this["_initPro"+n(1609)])return this[n(593)+n(1609)];try{let d=this[n(1088)],l=this[n(1140)];this[n(593)+n(1609)]=(async()=>{let g=n,{openDB:m}=await i[g(1515)](ah);this[g(892)]=await i[g(1509)](m,g(1017)+"_"+d,1,{upgrade(S){S["createOb"+g(498)+"e"](d,{keyPath:l})}})})(),await this[n(593)+n(1609)]}catch(d){console.log(d)}finally{this[n(593)+n(1609)]=null}}}async[t(1177)](n){let i=t;try{return await this[i(1523)](),this[i(892)]?.[i(1177)](this[i(1088)],n)}catch(d){console[i(294)](d)}}async[t(1082)](n,i){let d=t;return e[d(936)]!==e[d(936)]?_0xa8fbe7?this.toBytesLE():this[d(680)+"E"]():(await this[d(1523)](),this[d(892)]?.put(this._dbName,n))}async[t(395)](n){let i=t;try{return await this[i(1523)](),this[i(892)]?.[i(868)](this._dbName,n)}catch(d){console[i(294)](d)}}async[t(1356)](){let n=t;try{return await this[n(1523)](),this[n(892)]?.clear(this[n(1088)])}catch(i){console[n(294)](i)}}async[t(1597)](){let n=t;if(e[n(1304)]==="MKpsW")return await this[n(1523)](),this[n(892)]?.[n(1097)+"ys"](this[n(1088)]);_0x39ed1a[n(294)](_0x468ed)}async getAll(){let n=t;return await this[n(1523)](),this._qosDB?.[n(171)](this[n(1088)])}async[t(1553)](){let n=t;try{this[n(892)]?.[n(1333)](),this._qosDB=void 0}catch(i){console[n(294)](i)}}get[t(629)](){let n=t;try{return e[n(1478)](e[n(335)],e[n(335)])?!!this._qosDB:!!this[n(892)]}catch(i){return e[n(820)](e[n(1325)],e.YZBiK)?new _0x2e2805(d=>{let l=n;_0x933984(d,this[l(922)+l(866)+"e"](_0x48aade))}):(console[n(294)](i),!1)}}}class dh{constructor(n,i){let d=t;this[d(1066)]=n,this._pathKey=i,this[d(892)]=localStorage}async[t(776)](){}get _prefix(){return t(1017)+"_"+this._DBName}async[t(1177)](n){let i=t,d=this[i(892)].getItem(this[i(770)]);return JSON[i(1328)](e.QBrOQ(d,"{}"))[n]}async set(n,i){let d=t,l=this._qosDB[d(689)](this[d(770)]),g=JSON.parse(e[d(1046)](l,"{}"));return g[i||n[this[d(283)]]]=n,this[d(892)][d(577)](this[d(770)],JSON[d(796)+"y"](g)),i||n[this[d(283)]]}async[t(395)](n){let i=t,d=this[i(892)].getItem(this._prefix),l=JSON[i(1328)](e[i(1046)](d,"{}"));return l[n]=void 0,this[i(892)].setItem(this[i(770)],JSON[i(796)+"y"](l))}async[t(1356)](){let n=t,i={uWOgd:function(d,l){return e[G(372)](d,l)}};if(e[n(1368)]!==n(1427))return this[n(892)][n(1356)]();{let d=_0x184f0c.bytes,l=_0x355c6a.limit;return dDhhIO[n(1175)](d[n(490)],l)?d:d[n(1183)](0,l)}}async[t(1597)](){let n=t;if(n(1246)!==e.YeyHP){let i=this._qosDB.getItem(this[n(770)]),d=JSON.parse(e.JNfTY(i,"{}"));return Object[n(1597)](d)}else{if(_0x125bf9===mxNYVN[n(1156)])return _0x1956ef.get(_0x48f513);if(_0x7dfa71===mxNYVN.RjqZa)return _0x29358a[n(725)+n(509)]||_0x44a41a[n(1177)](_0x4ba8fc);if(mxNYVN[n(721)](_0x4a0255,mxNYVN[n(1363)]))return _0x708c35[n(725)+n(509)][1]?void 0:_0x527f84[n(725)+"ore"](_0x4546d5[n(725)+"oreNames"][0])}}async[t(171)](){let n=t;if(e[n(943)](e[n(929)],e[n(1207)]))return{frameType:_0x529940,headers:[{key:e[n(1236)],value:e[n(257)]}],payload:void 0};{let i=this[n(892)][n(689)](this._prefix),d=JSON.parse(e.FLzUu(i,"{}"));return Object.values(d)}}[t(1553)](){return Promise[t(337)]()}get[t(629)](){let n=t,i={xsMQM:n(1333)};if(e.tZImE(e.OuYoY,n(646)))return!!this[n(892)];_0x5b5c35&&_0x561bd5[n(1598)+n(1117)](LjGrtQ[n(207)],()=>_0x173282()),_0x43ecff&&_0xa80822["addEvent"+n(1117)]("versionc"+n(653),()=>_0x3e4850())}}class fh{constructor(n,i){let d=t;this[d(1066)]=n,this._pathKey=i,this[d(892)]=pn?tt:kr?wx:null}async openDB(){}get[t(770)](){let n=t;return n(1017)+"_"+this[n(1066)]}async[t(1177)](n){let i=t,d={WgxCO:function(l,g){return e.qAFZj(l,g)},bJFvJ:function(l,g){return e[G(236)](l,g)},uGwhE:function(l,g){return l+g}};if(e.YWvnj(e[i(321)],"IMYVo"))return _0x729400[i(762)+"8"]?{value:_0x4cf773[i(762)+"8"](_0x1591a3),offset:d[i(1473)](_0x402022,1)}:{value:d[i(332)](255,_0x40e69c[_0x5ef02f]),offset:d[i(393)](_0x1ab37d,1)};{let l=this[i(892)][i(1374)+"geSync"](this._prefix);return JSON[i(1328)](e.FLzUu(l,"{}"))[n]}}async[t(1082)](n,i){let d=t,l=this[d(892)][d(1374)+d(605)](this._prefix),g=JSON[d(1328)](e[d(421)](l,"{}"));return g[i||n[this[d(283)]]]=n,this[d(892)][d(1436)+d(605)](this._prefix,JSON.stringify(g)),i||n[this._pathKey]}async[t(395)](n){let i=t,d=this._qosDB.getStorageSync(this[i(770)]),l=JSON.parse(e.HkMAe(d,"{}"));return l[n]=void 0,this._qosDB[i(1436)+i(605)](this[i(770)],JSON[i(796)+"y"](l))}async clear(){let n=t;return this[n(892)]["clearSto"+n(568)]()}async[t(1597)](){let n=t,i={uGrnf:function(d,l,g){return d(l,g)},AXuPA:function(d,l){return e[G(1229)](d,l)}};if(e[n(878)](e.ElCle,n(1049)))KqpvAi.uGrnf(_0x52f42e,_0x4231ee,96),_0x3c12fe(_0x5cc615,KqpvAi[n(1013)](_0x244b0b,_0x3e686a));else{let d=this[n(892)][n(1374)+"geInfoSync"](this[n(770)]),l=JSON.parse(e[n(298)](d,"{}"));return Object[n(1597)](l)}}async[t(171)](){let n=t,i=this[n(892)][n(1374)+n(1570)+"nc"](this[n(770)]),d=JSON[n(1328)](e[n(989)](i,"{}"));return Object.values(d)}[t(1553)](){return Promise[t(337)]()}get[t(629)](){return!!this[t(892)]}}function C0(o,n){let i=t;if(e[i(341)](pn,pn))return new fh(o,n);if(e[i(1308)](jn,Pr)&&e.KeZGy(e[i(588)],typeof indexedDB))return new ch(o,n);if(e.ILCQi(jn,Pr)&&e.IXNYZ(e[i(588)],typeof localStorage))return new dh(o,n);throw new Error(e.Xrwsm)}class uh{constructor(){let n=t;this["_interva"+n(392)+"Id"]=null,this[n(1536)+"l"]=36e5,this[n(892)]=e[n(176)](C0,e[n(1305)],n(763)+"id")}async["_interva"+t(604)](){let n=t;e.xRBPg(clearInterval,this[n(1536)+n(392)+"Id"]),this[n(1536)+n(392)+"Id"]=e[n(1530)](setInterval,()=>{this[n(579)+"ired"]()},this[n(1536)+"l"])}async[t(776)](){let n=t;await this[n(892)].openDB()[n(264)](()=>{let i=n;this[i(1536)+i(604)]()})}async[t(579)+t(1601)](){let n=t;(await this[n(892)]?.[n(171)]()||[])[n(903)](({timestamp:l})=>l<Date[n(780)]())[n(189)](l=>{let g=n;this[g(892)]?.del(l[g(763)+"id"])})}async del(n){let i=t;return this[i(892)]?.[i(395)](n)}async[t(1082)](n,i){return this[t(892)]?.set({message_id:n,timestamp:i})}async[t(1177)](n){let i=t;return e[i(1578)](i(765),e[i(613)])?new _0x22f1d1(_0x409beb,{data:_0x4f1511}):this._qosDB?.get(n)}async[t(1553)](){let n=t;clearInterval(this[n(1536)+n(392)+"Id"]),await this[n(892)]?.closeDB()}get[t(629)](){let n=t;return this[n(892)]?.[n(629)]}}function zo(o){let n=t,i=!!this[n(1149)].enableQoS;if(!i)return{enabled:i,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1464)](Kt,o[n(1329)].headers,e[n(580)],"2"),l=d&&e[n(1338)](Kt,o.message[n(210)],e[n(1470)],"1"),g=d&&e.WaSPZ(Kt,o[n(1329)][n(210)],e[n(215)],"1"),m=g?Gn(o.message[n(210)],e[n(707)])?.[n(620)](",").filter(Boolean)||[]:[];return{enabled:i,isQoSMessage:d,isQoSAck:l,isAckCleanupMessage:g,ackMsgIds:m}}async function T0(){let o=t;return e[o(1514)]("RHqlW",e[o(849)])?(_0x30f8d7||(_0x1a963c=_0x3faa38[o(337)]()[o(264)](_0x1854d1[o(811)](_0x34ebaf,e[o(1544)]))),_0x175f17):(this[o(1414)+o(299)]||(this[o(1414)+o(299)]=new uh),this[o(1414)+o(299)].isReady||await this[o(1414)+o(299)][o(776)](),this[o(1414)+"ger"])}async function lh(o,n){let i=t,d={uDeax:function(l,g){return l(g)},aIfzI:function(l,g){return e[G(1272)](l,g)},EzrDD:function(l,g){return e[G(243)](l,g)},qNXZU:i(856),tSqpz:i(938),yHbMB:function(l,g,m){return l(g,m)}};if(e[i(537)](e[i(618)],e[i(618)])){let l=_0x38121f[i(620)](/\./)[i(1382)](S=>_0x244504(S)),g=[];return g[0]=tFZtWM.uDeax(_0x56f513,l[0]+l[1]),g[1]=tFZtWM[i(1172)](_0x5879de,tFZtWM.EzrDD(l[2],l[3])),[tFZtWM[i(916)],tFZtWM[i(916)],tFZtWM[i(916)],tFZtWM[i(916)],tFZtWM[i(916)],tFZtWM[i(1134)],g[0],g[1]][i(1407)]("")}else{let{enableAutoAck:l}=this[i(1149)],g=e[i(185)](Kt,o.message[i(210)],e.AAYKC,"1"),m=Kt(o[i(1329)].headers,i(1532),"1"),S=zo[i(799)](this,o);if(e.bbMlv(l,g))if(e[i(289)](i(1489),i(1489)))this[i(378)]("message",tFZtWM[i(1446)](_0x1a84d4,"message",{..._0x495df8}));else{let{SeqID:p,LogID:D,service:A,LogIDNew:B,method:H}=o[i(1329)];this[i(617)]({SeqID:p,LogID:D,LogIDNew:B,service:A,method:H,headers:[{key:e[i(1316)],value:"1"},{key:e[i(516)],value:e[i(989)](B,"")},{key:"ack_code",value:"0"}]})}m&&!S.isQoSAck&&this["_dispatc"+i(1051)+i(1194)](o),n()}}async function xh(o,n){let i=t;this[i(499)](e[i(1238)],o[i(1329)]),n()}async function hh(o,n){let i=t,d=e[i(986)](Un,await e.NgouH(I0,o[i(184)]));try{if(d.payload instanceof Uint8Array){let l=e.Mkehn(this[i(1149)]["payloadE"+i(1540)],Object)?{force:!!this[i(1149)]["payloadE"+i(1540)][i(1178)],encoding:this._options[i(1216)+i(1540)].encoding?this[i(1149)]["payloadE"+i(1540)][i(471)][i(1613)](/\s/g,"")[i(1254)+i(1036)]():""}:{force:!1,encoding:this[i(1149)][i(1216)+i(1540)]?this._options[i(1216)+"ncoding"][i(1613)](/\s/g,"")[i(1254)+i(1036)]():""},g=d["payloadE"+i(1540)]?d.payloadEncoding[i(1613)](/\s/g,"")[i(1254)+i(1036)]():"",m=this._options[i(758)+"ype"]instanceof Object?{force:!!this[i(1149)][i(758)+i(436)][i(1178)],type:this[i(1149)][i(758)+i(436)][i(1347)]?this[i(1149)][i(758)+i(436)][i(1347)][i(1613)](/\s/g,"")[i(1254)+i(1036)]():""}:{force:!1,type:this[i(1149)][i(758)+i(436)]?this[i(1149)][i(758)+i(436)].replace(/\s/g,"")["toLowerC"+i(1036)]():""},S=d[i(758)+i(436)]?d[i(758)+i(436)].replace(/\s/g,"")[i(1254)+i(1036)]():"",p=m.force?m[i(1347)]:S||m[i(1347)],D=l[i(1178)]?l[i(471)]:g||l[i(471)],A=["text/plain;chars"+i(1211),e[i(1632)],e[i(195)],"string"],B=[e.SFWIS,e[i(351)]];this[i(1149)][i(1200)+i(882)+i(1292)+"ad"]&&A.includes(p)&&(!D||B[i(1327)](D))?d.textPayload=e.yEEjd(S0,d[i(1074)],0,d.payload[i(1121)+"th"]):d[i(1434)+i(1520)]=""}else d[i(1434)+i(1520)]=""}catch(l){if(e.qYUyL!==e[i(425)]){let g=this[i(892)]["getStora"+i(605)](this._prefix);return _0x4d149a.parse(e[i(1281)](g,"{}"))[_0x442d99]}else d["textPayl"+i(1520)]="",console[i(294)](l)}o[i(1329)]=d,e[i(817)](n)}function ph(o,n,i){let d=t,l={kTUjq:function(D,A){return e.bKhfm(D,A)},WMFSU:function(D,A){return e.Vfkrc(D,A)},udlKN:function(D,A){return e[G(841)](D,A)},PFTyq:e[d(778)],dgdDd:function(D,A){return e.borQF(D,A)},UsCKX:function(D,A){return e[d(1405)](D,A)},eFoCG:function(D,A){return e[d(1484)](D,A)},lVgVj:function(D,A){return e.IxXcn(D,A)},lliXe:function(D,A){return D&A},IigVQ:function(D,A){return e[d(583)](D,A)},uKeaD:function(D,A){return e[d(213)](D,A)}},g=e[d(421)](i,8192),m=g>>>1,S=null,p=g;return function(D){let A=d;if(l[A(1400)](l[A(575)],A(1581))){let B=_0xbe562b[A(620)](":");for(let H=0;prJvgk[A(1558)](H,B.length);H++){let W=B[H];if(prJvgk.WMFSU(4,B[H].length)){let $=_0x245199[A(793)+"g"](0,prJvgk[A(987)](4,B[H][A(490)])),Ee=$[A(715)](W);_0x7c74b6=_0x52e300[A(715)](Ee)}else _0x1ddaf8=_0x384fc0.concat(W)}return _0x31c031}else{if(l.dgdDd(D,1)||D>m)return o(D);l.UsCKX(l[A(741)](p,D),g)&&(S=l[A(1230)](o,g),p=0);let B=n[A(799)](S,p,p+=D);return l[A(435)](7,p)&&(p=l[A(1494)](l.uKeaD(7,p),1)),B}}}let gh=4294967295;function mh(o,n,i){let d=t;if(e[d(1452)](e[d(954)],d(582))){let g=""+_0x41a08d[d(780)](),m=_0x47f98a||(_0x48f45f=e.xRBPg(_0xe4989a,_0x3d8ac1)),S=_0x41e91c.random()[d(602)](16).slice(-6);return e[d(1418)]("02",g)+m+S}else return e[d(1596)](RangeError,e.qgOLw(e[d(1164)](e[d(504)](d(710)+d(1002)+"ge: ",o)+e[d(330)],e[d(899)](n,1)),e.gpCkV)+i)}function wh(o,n,i){let d=t;if(e[d(426)](i,gh))throw new Error(e[d(647)]);let l=3;for(;e[d(422)](l,0);)if(e[d(271)](e[d(930)],e.pqwvN))_0x1ba7a9[d(1082)](_0x49b1ba,_0x1e2081),_0x3aeeeb.set(_0x3359b4,_0x11be58);else{let g=e.wpskj(255,i);e.kiFcr(Uo,g,o,e.ZXmDh(n,l)),i>>>=8,l--}return e[d(417)](n,4)}function _h(o,n){let i=t,d=0,l=n,g=n+4;for(;e[i(635)](l,g);){let{value:m,offset:S}=Fo(o,l);l=S,d=e[i(720)](d<<8,0),d+=m}return{value:d,offset:g}}function yh(o,n,i){let d=t;if(e[d(1640)](d(1573),e.gcDPF)){let l=e[d(1624)][d(620)]("|"),g=0;for(;;){switch(l[g++]){case"0":if(n[d(405)])return e[d(859)](n[d(405)](o,i),i);continue;case"1":if(!o)return i;continue;case"2":if(n[d(774)+"e"])return e[d(1595)](n[d(774)+"e"](o,i),i);continue;case"3":if(e[d(276)](o[d(490)],40))return e[d(417)](e[d(281)](Mo,o,n,i),i);continue;case"4":return e[d(979)](Mo(o,n,i),i)}break}}else return new _0x521708(_0x5a18b8,{data:_0x3122bf,message:_0x195f8c})}function bh(o,n){let i=t,d={nvjAU:e.TJPGM};if(e[i(1279)](e.SCnna,e.uoZvk)){let l=_0x4d35a0(d[i(1349)],{message:_0x33294b[i(1329)],code:_0x4a8042[i(961)+"OR"],error:_0x47a68c});this["_dispatchErrorEv"+i(1182)](l)}else{let l=new oe(e.tYNYq(e[i(401)](o[e[i(548)](n,4)],24)|e[i(367)](o[e[i(889)](n,5)],16)|e[i(1167)](o[e[i(477)](n,6)],8),o[e[i(487)](n,7)]),e[i(991)](e[i(1197)](e[i(980)](e[i(626)](o[e[i(182)](n,0)],24),e[i(1409)](o[n+1],16)),e[i(692)](o[e.HfrIk(n,2)],8)),o[e[i(507)](n,3)]),!0);return n+=8,{value:l,offset:n+8}}}function Eh(o,n,i){let d=t,l=o[d(771)],g=o[d(1556)];return n[i]=e[d(1060)](g,24),n[e.lhwQP(i,1)]=e[d(1179)](g,16)&255,n[e[d(786)](i,2)]=e[d(1430)](g>>>8,255),n[i+3]=255&g,n[e[d(773)](i,4)]=l>>>24,n[e[d(522)](i,5)]=e[d(827)](e[d(1433)](l,16),255),n[e.JfSOT(i,6)]=e[d(343)](e[d(574)](l,8),255),n[e[d(1468)](i,7)]=e[d(1630)](255,l),i+=8,i}function Fo(o,n){let i=t;return o[i(762)+"8"]?{value:o[i(762)+"8"](n),offset:e[i(1546)](n,1)}:{value:e[i(495)](255,o[n]),offset:e[i(259)](n,1)}}function Uo(o,n,i){let d=t;return n.writeUint8?n.writeUint8(o,i):n[i]=e[d(340)](255,o),e[d(1003)](i,1)}let vh=function(o){return new Uint8Array(o)},Sh=e.LQSzN("undefined",typeof Buffer)?Buffer["allocUns"+t(1212)]:e[t(1554)](ph,vh,Uint8Array[t(1383)+"e"][t(1183)]),Ih=16,qo=32;function Ch(o){let n=t,i=0,d={};for(let l=0;l<o[n(490)];l++)d[o[l][n(910)+"ame"]]=v0(o[l][n(910)+n(1058)]),i+=14+d[o[l]["cursor_n"+n(1058)]];return[i,d]}function A0(o,n,i){let d=t,l={BjgOx:function(D,A){return e[G(420)](D,A)},kOTwC:function(D,A){return e.DKSyJ(D,A)},gfDmw:function(D,A){return e[G(267)](D,A)},KQqCD:function(D,A){return e.KstSw(D,A)}},[g,m]=e.dMkzz(Ch,o),S=e.XhGXr(Sh,g),p=0;return o[d(189)](D=>{let A=d;if(e[A(1641)](e.sTolw,e[A(950)])){let B=e.sNgRe.split("|"),H=0;for(;;){switch(B[H++]){case"0":console.log(e[A(1050)],p);continue;case"1":console.log(e[A(1129)],D,D.service);continue;case"2":console[A(294)](e[A(197)],p);continue;case"3":p=e[A(1037)](Uo,m[D[A(910)+A(1058)]],S,p);continue;case"4":console[A(294)](e[A(963)],p);continue;case"5":p=e.WaSPZ(Uo,0,S,p);continue;case"6":p=e[A(1338)](wh,S,p,D.service||0);continue;case"7":p=e[A(1338)](yh,D[A(910)+A(1058)],S,p);continue;case"8":console.log(e[A(918)],p);continue;case"9":p=e[A(1338)](Eh,oe[A(1505)+"er"](D[A(339)]||n),S,p);continue;case"10":console.log(e[A(909)],p);continue}break}}else{let B=_0x54555f.bytes,H=_0x2c3e75[A(845)],W=_0x1037ce[A(526)],$=TiuYyR[A(1330)](H,_0xb1dbef);if(TiuYyR[A(1096)]($,B[A(490)])){let Ee=new _0x23b895(TiuYyR[A(1107)](2,$));Ee[A(1082)](B),_0xbc779b[A(624)]=Ee}return _0x51d39c.offset=$,TiuYyR.KQqCD($,W)&&(_0xfb5f1d.limit=$),H}}),{frameType:qo,headers:[{key:d(612)+d(1547),value:i}],payload:S}}function Th(o){let n=t,i={UjoNH:function(g,m){return e[G(255)](g,m)},gWekd:function(g,m){return e[G(1410)](g,m)},CkZca:function(g,m){return e[G(1496)](g,m)},XhWJR:function(g,m){return e[G(889)](g,m)},DkSQh:function(g,m){return e[G(1073)](g,m)}},d=0,l=[];for(;e.qeAIs(d,o[n(1121)+"th"]);)if(n(603)===e[n(671)]){let{offset:g}=e[n(535)](Fo,o,d);d=g;let m={cursor_name:"",cursor:0,service:0},{value:S,offset:p}=e[n(917)](_h,o,d);m[n(170)]=S,d=p;let{value:D,offset:A}=e[n(804)](Fo,o,d);d=A,m[n(910)+n(1058)]=e[n(931)](S0,o,d,e[n(884)](d,D)),d+=D;let{value:B,offset:H}=bh(o,d);m[n(339)]=B[n(161)](),d=H,l[n(885)](m)}else{if(JKSYhh[n(1223)](_0x299e0b,1)||JKSYhh.gWekd(_0x41e591,_0x332145))return JKSYhh[n(419)](_0x425db1,_0x17ea40);JKSYhh.gWekd(_0x23a82e+_0x10a68c,_0x23faaf)&&(_0x3055cb=JKSYhh[n(419)](_0x541461,_0x16e2dc),_0x2473d8=0);let g=_0x327453[n(799)](_0x550d95,_0x11c669,_0x3261a6+=_0x2591a2);return 7&_0x45b1fe&&(_0x321246=JKSYhh.XhWJR(JKSYhh[n(974)](7,_0x1e746c),1)),g}return l}function Ah(){return{frameType:qo,headers:[{key:e[t(1236)],value:e.xeWpT}],payload:void 0}}class Rh{constructor(n,i,d){let l=t;this[l(1371)+l(1153)]=n,this[l(177)+l(514)]=i,this[l(810)+l(622)]=d,this[l(892)]=e[l(322)](C0,this[l(1371)+l(1153)],e.CCpEB)}async[t(776)](){await this[t(892)].openDB()}async getCursors(){let n=t;if(!this[n(892)][n(629)])return;let i=this[n(810)+n(622)],d=await this[n(892)][n(171)]();switch(console[n(294)](n(830)+"rValues",d),i){case e[n(753)]:return d&&d[n(490)]?e[n(272)](A0,d,0,this[n(177)+n(514)]):void 0;case e.zHlEe:return;case e.PbigX:return d&&d[n(490)]?e[n(1037)](A0,d,0,this[n(177)+n(514)]):Ah()}}async[t(1082)](n,i,d){let l=t;return console.log(e[l(1621)],n,i,d),this[l(892)][l(1082)]({cursor_name:n,cursor:i,service:d})}async[t(240)+"rs"](n){let i=t,d=Th(n);for(let l of d)if(e[i(199)]("UcFUj",e[i(1224)]))console[i(294)](e[i(261)],d),await this[i(892)].set(l);else return _0x151092.isLong(_0x4330a0)||(_0x12abd9=_0x90c5e9[i(1505)+"er"](_0x18ca28)),this[i(229)]!==_0x75f73.unsigned&&e[i(850)](e[i(201)](this[i(1556)],31),1)&&e[i(850)](e[i(1548)](_0x274b32[i(1556)],31),1)?!1:e.HrUyT(this[i(1556)],_0x222a7d[i(1556)])&&this[i(771)]===_0x14295c[i(771)]}async[t(1177)](n){let i=t;return(await this[i(892)][i(1177)](n))?.cursor}async[t(1553)](){await this[t(892)].closeDB()}[t(1228)+t(847)+"Name"](n){let i=t;this[i(177)+i(514)]=n}get isReady(){let n=t,i={iCirL:function(d,l){return e[G(940)](d,l)}};return e[n(1273)](e[n(389)],e[n(1298)])?(_0x2abc8b.apply(_0x1b43fd(this),_0x474686),ttGplA.iCirL(_0x101dae,_0x3b68cd[n(1177)](this))):this._qosDB[n(629)]}}let Dh=e.TIGDz;async function R0(o){let n=t;if(!this[n(1149)][n(1263)+"S"])return null;let{aID:i,fpID:d,messageStrategy:l}=this[n(1149)],g=e[n(223)](o,Dh);try{return this[n(1580)+n(838)]?o&&this[n(1580)+"anager"][n(1228)+n(847)+n(1158)](o):this[n(1580)+"anager"]=new Rh(d+"_"+i+"_"+g,g,l),this["_cursorM"+n(838)][n(629)]||await this["_cursorM"+n(838)][n(776)](),this[n(1580)+"anager"]}catch{return e[n(1028)]===e[n(1028)]?null:this["currentE"+n(797)+"riesCount"]}}async function kh(o,n){let i=t,d={ukLdK:function(W,$){return e[G(714)](W,$)}},l=Kt(o[i(1329)][i(210)],i(1260),"-1"),g=e[i(1404)](Kt,o[i(1329)][i(210)],e.npKJM,"1"),m=e[i(322)](Gn,o[i(1329)][i(210)],e[i(1533)]),S=Number(e[i(1155)](Gn,o[i(1329)].headers,e[i(779)]))||0,p=zo[i(799)](this,o),D=e[i(998)](Kt,o[i(1329)][i(210)],e[i(1168)],"2"),A=e.Bdqoy(Gn,o[i(1329)][i(210)],i(1390)+"rsor_name"),B=e.trEFo(Number,Gn(o[i(1329)][i(210)],e[i(606)]));if(p.isQoSAck)return n();let H=p[i(300)+i(594)]?await T0.call(this):null;if(e[i(1235)](o[i(1329)][i(170)],0)&&g&&!l||e[i(1420)](o[i(1329)].service,0)){if(m&&p[i(300)+i(594)]&&H){if(!!!await H.get(m))if(e.xlxZT(e[i(482)],e.xDhNL))this[i(558)+i(966)+i(1237)](o),await H.set(m,e[i(504)](Date.now(),S));else{let $=_0x1a1471[i(793)+"g"](0,GFmqeC[i(814)](4,_0x43a81b[_0x42f278][i(490)])),Ee=$[i(715)](_0x4b7282[_0x2c489f]);_0xefcb5[i(885)](Ee)}return e.UbGbs(n)}if(D){let W=await R0[i(799)](this);if(!W)return this._dispatchMessageEvent(o),n();let $=await W.get(A)??-1;if(e.TXoBD($,B))this[i(558)+i(966)+i(1237)](o),W[i(1082)](A,B,o[i(1329)][i(170)]);else throw new Error(i(863)+" message"+i(1567)+B+(i(1143)+i(1416)+i(561)+"r ")+$);return e[i(924)](n)}return this[i(558)+i(966)+i(1237)](o),e[i(817)](n)}}async function Ph(o,n){let i=t,d=zo.call(this,o);if(!d[i(300)+i(594)])return n();let l=await T0[i(799)](this);if(d[i(521)+i(1531)+i(524)]&&d[i(1024)+"s"][i(490)])for(let g of d[i(1024)+"s"])await l[i(395)](g);n()}async function Oh(o,n){let i=t;if(e[i(372)](e[i(599)],e.plhoF)){let d=o[i(1329)].frameType===Ih,l=e.tsdow(o[i(1329)][i(750)+"e"],qo);if(e.bbMlv(!d,!l))return e.jnWvP(n);let g=e[i(474)](Gn,o.message.headers,e.xjHtV);if(!g)return e[i(1458)](n);let m=await R0[i(799)](this,g);if(!m)return n();if(d)if(e.cQSGx("xtQCo",e.tkPUM)){let S=await m[i(1020)+"rs"](),p={frameType:S?.[i(750)+"e"],SeqID:oe.fromNumber(this[i(262)]++),LogID:oe[i(1505)+"er"](this[i(1149)][i(1511)+i(1187)]()),service:9e3,method:5,headers:S?.[i(210)],payload:S?.payload},D=e[i(1522)](C,p);this[i(1137)]&&this[i(1137)][i(760)+"te"]&&this[i(1137)][i(437)](D)}else _0x16a32f.o=(S,p)=>_0x2404ad.prototype[i(571)+i(217)].call(S,p);if(l){let S=o.message[i(1074)];S&&m[i(240)+"rs"](S)}}else return this._ws?this._ws.extensions:""}let Lh=async function(o,n){let i=t;this._isInit=!1,e.NlhdQ(clearTimeout,this[i(993)+"ionTimeo"+i(181)]),n()},Nh=async function(o,n){let i=t;if(!this._ws||this[i(1137)][i(760)+"te"]!==this[i(1550)])return e[i(344)](n);let{pingInterval:d}=this[i(1149)];this[i(534)+i(399)]?.[i(921)+i(382)+"fig"]();for(let g=0;e[i(667)](g,this[i(810)+"Queue"][i(490)]);g++){let m=this[i(810)+i(551)][g];if(this[i(1137)].readyState===this[i(1550)]&&e[i(1331)](null,m))this[i(1137)]&&this[i(1137)][i(437)](m),this["_message"+i(551)][g]=null;else break}this[i(810)+i(551)]=this[i(810)+"Queue"][i(903)](g=>!!g),this[i(880)+"gTimeoutId"]=e[i(1245)](setTimeout,()=>this._ping(),d),this[i(558)+i(310)+"nt"](o),this[i(1053)+"er"]&&this[i(1137)]&&(this[i(1137)][i(1133)+"pe"]=this[i(728)+i(436)]);let l=this[i(534)+i(399)]?.["getCurre"+i(256)+"nt"]();this[i(499)](i(1079)+l+i(501)),n()},Mh=async function(o,n){let i=t,d=this[i(534)+"tManager"]?.[i(875)+i(256)+"nt"]();this[i(499)](i(1079)+d),e[i(192)](n)};class Bh extends No{constructor(n){let i=t,d={SuKfI:function(S,p,D){return e[G(1289)](S,p,D)},wSIzB:function(S,p){return e.kZvrI(S,p)},nkEiA:e[i(933)],RTbHH:e[i(1258)],mkvUK:e[i(1413)],fiJpp:e.Blnpk,Tyedv:e[i(266)],xxJHx:function(S,p){return e[i(1087)](S,p)},amPff:e[i(491)],bEHFI:e[i(1243)],LqeLL:e[i(1320)],WMkQK:function(S){return e[i(1099)](S)}};super(),this["_miniNav"+i(554)+i(818)]=!0,this[i(1053)+"er"]=jn,this[i(409)]=Qx,this._isMiniTT=pn,this._isMiniWX=kr,this[i(198)+"r"]=Pr,this["_message"+i(551)]=[],this[i(534)+"tManager"]=null,this[i(658)+i(697)]=!1,this[i(728)+i(436)]=e[i(1108)],this[i(993)+"Lock"]=!1,this[i(993)+"ionTimeoutId"]=null,this["_reconne"+i(792)+i(1587)]=null,this[i(880)+i(920)+"Id"]=null,this[i(262)]=0,this[i(187)]=!1,this[i(869)]="",this["_QoSMana"+i(299)]=null,this["_cursorM"+i(838)]=null,this[i(1326)+i(544)]=null,this._protocols="pbbp2",this[i(556)]=3,this.CONNECTING=0,this[i(1550)]=1,this[i(881)]=2,this[i(1437)]=S=>{let p=i;try{E0(this,S,[Lh,Nh,Mh])}catch(D){let A=d.SuKfI(Qe,p(1076),{message:D.message,code:Wt[p(961)+"OR"],error:D});this[p(558)+p(693)+"ent"](A)}},this[i(486)+"ge"]=async S=>{let p=i,{pingInterval:D,pingFrequency:A}=this[p(1149)];if((S[p(184)]==="hi"&&e[p(670)](e[p(955)],A)||e[p(721)](e[p(673)],A))&&(this["_clearPi"+p(234)](),this[p(378)](e[p(861)],e.hCGOE),this[p(880)+"gTimeoutId"]=e[p(1160)](setTimeout,this[p(1067)][p(811)](this),D)),!e[p(254)]("hi",S[p(184)]))try{if(e[p(237)]!==e.ZndaC){let H=this[p(892)][p(689)](this[p(770)]),W=_0x27b216[p(1328)](FHcHLr.wSIzB(H,"{}"));return W[_0x2cfbfb||_0x22773d[this._pathKey]]=_0x2981aa,this[p(892)][p(577)](this._prefix,_0x56ea29[p(796)+"y"](W)),_0x113e71||_0x1554e5[this[p(283)]]}else e.WaSPZ(E0,this,S,[hh,lh,Ph,Oh,kh,xh])}catch(H){if(e.cQSGx(e[p(1323)],"mrRal")){let W=e[p(973)](Qe,e[p(842)],{message:H[p(1329)],code:Wt[p(631)+"ERROR"],error:H});this[p(558)+p(693)+"ent"](W)}else for(var B in _0x31ff32)_0x170a9a.o(_0x325896,B)&&!_0xda1f27.o(_0x3a53db,B)&&_0x8400bd[p(379)+p(217)](_0x3867b6,B,{enumerable:!0,get:_0x16b46e[B]})}},this[i(1610)]=S=>{let p=i;if(e[p(529)](e[p(222)],e.UoVeY)){let D=d[p(371)].split("|"),A=0;for(;;){switch(D[A++]){case"0":_0x56a028=[FHcHLr[p(361)],FHcHLr[p(1442)],FHcHLr[p(1056)],p(1097)+"ys",FHcHLr[p(1450)]];continue;case"1":_0x170c5e=new _0x16c6b6;continue;case"2":FHcHLr[p(798)](_0x4011d6,B=>({...B,get:(H,W,$)=>_0x2258f8(H,W)||B[p(1177)](H,W,$),has:(H,W)=>!!_0x4c289e(H,W)||B.has(H,W)}));continue;case"3":_0x390851=[FHcHLr[p(1226)],FHcHLr[p(990)],p(868),FHcHLr[p(1582)]];continue;case"4":FHcHLr[p(717)](_0x27c0b4);continue;case"5":FHcHLr.WMkQK(_0xd3627f);continue}break}}else{let D=this[p(534)+p(399)]?.[p(1026)+p(366)+"es"](),A=this[p(534)+p(399)]?.[p(875)+p(256)+"nt"]();if(D&&!S[p(1329)]){let B=p(873)+A+(p(809)+p(449)+p(607)+"ed");this[p(558)+p(693)+p(1182)](Qe(e[p(842)],{message:B,code:Wt["MAX_RETR"+p(542)+"R"],error:S}));return}this[p(1137)]&&this._ws[p(760)+"te"]===this.OPEN&&this[p(560)+"ect"](),this[p(558)+"hErrorEv"+p(1182)](Qe(p(1076),{message:S[p(1329)],code:Wt[p(1282)+p(348)],error:S}))}},this[i(302)]=async S=>{let p=i;this["_clearTi"+p(1247)](),this[p(260)+p(234)](),this["_removeW"+p(794)+"rs"](),this[p(1137)]=null,this[p(993)+p(1062)]=!1;let D=this[p(534)+"tManager"]?.[p(1026)+p(366)+"es"]();if(!D&&this[p(642)+p(587)]()&&!this[p(658)+p(697)]){let A=this["_endpoin"+p(399)]?.[p(875)+p(256)+"nt"](),B=this[p(1149)].reconnectInterceptor(S[p(1260)],S[p(304)]);this[p(558)+p(1023)+p(1182)](e[p(416)](ot,p(1333),{code:1006,reason:S[p(304)]||p(218)+p(684)+p(159)+p(1274)+"n, hostn"+p(388)+A,willReconnect:B})),B&&this[p(993)]();return}if(e[p(211)](1e3,S.code)&&this[p(658)+p(697)]){this["_dispatc"+p(1023)+"ent"](e.jOuua(ot,e[p(1176)],{code:1e3,reason:"bye"})),this["_endpoin"+p(399)]?.[p(921)+p(382)+"fig"](),this[p(1326)+"sCounter"]?.[p(825)+"nter"]();return}if(e[p(1294)](1e3,S[p(1260)])&&D){let A=this["_endpoin"+p(399)]?.[p(875)+p(256)+"nt"](),B=S[p(304)];B||(B=await e.mvBxi(oh,this._url)),B=p(218)+p(684)+p(872)+B+(p(1375)+p(1276))+A+(p(407)+p(453)+p(1421)),this["_dispatc"+p(1023)+"ent"](e.CYHoB(ot,e[p(1176)],{code:S[p(1260)],reason:B}));let H=p(873)+A+(p(809)+"ax retri"+p(607)+"ed");this[p(558)+p(693)+"ent"](e[p(731)](Qe,e[p(842)],{message:H,code:Wt[p(742)+p(542)+"R"]})),this[p(534)+"tManager"]?.[p(921)+p(382)+p(1562)](),this[p(1326)+p(544)]?.[p(825)+"nter"]();return}if(e.YWvnj(1e3,S.code)&&!S[p(304)]){let A=this[p(534)+"tManager"]?.[p(875)+p(256)+"nt"]();this[p(558)+p(1023)+p(1182)](e[p(1561)](ot,e[p(1176)],{code:S[p(1260)],reason:"connecti"+p(684)+"d, unkno"+p(1274)+p(1336)+"ame: "+A})),this[p(534)+p(399)]?.["resetEnd"+p(382)+p(1562)](),this[p(1326)+"sCounter"]?.[p(825)+p(432)]();return}this[p(558)+p(1023)+p(1182)](S),this["_endpoin"+p(399)]?.[p(921)+p(382)+p(1562)](),this[p(1326)+"sCounter"]?.[p(825)+p(432)]()},this[i(951)]=null,this.onerror=null,this[i(1310)+"e"]=null,this[i(1206)]=null,this[i(1629)+i(1606)]=null,this["onReceiv"+i(1126)]=null,this[i(1242)+i(1499)+i(248)+"ct"]=null,this[i(784)+i(209)]=this[i(784)+i(209)][i(811)](this),this[i(784)+i(390)]=this[i(784)+i(390)][i(811)](this),this[i(1278)+i(386)]=this[i(1278)+i(386)][i(811)](this),this[i(1278)+i(510)]=this[i(1278)+i(510)][i(811)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:1/0,service:0,logIDGenerator:a,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[i(673)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.PbigX,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:l,ws:g}=n,m=Array.isArray(l)?l:e[i(806)]("string",typeof l)?[l]:[];if(!m||e[i(840)](0,m[i(490)]))throw new Error(e[i(683)]);if(!e[i(1534)](nh,g))throw new Error(e.oSUtP);Object[i(447)](this[i(1149)],n),this[i(534)+i(399)]=new b0(m,this[i(1149)].maxRetries),this["_pingLos"+i(544)]=new sh(this[i(1149)][i(1508)+i(543)]),this._options[i(1537)+i(1045)]&&(this[i(187)]=!0,this[i(993)]()),this[i(1149)][i(719)+i(1065)+i(1307)]&&(this._isMiniTT||this._isMiniWX?this[i(457)+i(1423)+i(1135)]():this._isBrowser&&this[i(312)+"balEvent"+i(1117)]())}[t(784)+t(209)](){let n=t,i={gtpkv:function(d,l){return e[G(1300)](d,l)},SevxQ:function(d,l){return d*l}};if(e[n(1514)](e[n(775)],e[n(1113)])){if(this._options[n(284)+"utoRecon"+n(1044)]||this[n(658)+"osed"])return;this[n(1301)+n(1606)]()}else return meNkQP[n(180)](meNkQP[n(1195)](1e4,_0x970d79.now()),_0x209f35[n(1415)](meNkQP[n(1195)](1e4,_0x1f650f[n(1454)]())))}[t(784)+t(390)](){let n=t;if(e[n(1005)](e.KFnLs,e[n(292)]))return _0x10a0a9[n(845)]>=_0x52c08b[n(526)];{this[n(1040)+n(727)+"t"]();let i=e[n(615)](Lo,e[n(1401)],{message:n(1202)+"ediately"+n(1157)+"ct"});this[n(1242)+"mediatelyReconnect"]&&this[n(1242)+n(1499)+"yReconnect"](i)}}[t(312)+t(1426)+t(1117)](){let n=t;this[n(1053)+"er"]&&window[n(1598)+n(1117)](n(369),this["_handleO"+n(209)]),this[n(1053)+"er"]&&window[n(1598)+n(1117)](e.oaSVn,this[n(784)+n(390)]),this[n(1053)+"er"]&&window["addEvent"+n(1117)](e[n(657)],this[n(1278)+n(386)]),this[n(1053)+"er"]&&window[n(1598)+n(1117)](e.OtPzr,this["_handleP"+n(510)])}["_dropGlo"+t(1426)+t(1117)](){let n=t;this[n(1053)+"er"]&&window[n(926)+n(1604)+n(513)](e[n(1605)],this["_handleO"+n(209)]),this._isBrowser&&window[n(926)+n(1604)+n(513)]("offline",this[n(784)+n(390)]),this[n(1053)+"er"]&&window[n(926)+n(1604)+n(513)](e[n(657)],this[n(1278)+n(386)]),this._isBrowser&&window[n(926)+n(1604)+n(513)](e.OtPzr,this[n(1278)+n(510)])}[t(1278)+"ageHide"](n){let i=t;!n[i(1384)+"d"]&&(this._isBrowser&&window[i(926)+i(1604)+i(513)](e[i(657)],this["_handleP"+i(386)]),this._isBrowser&&window[i(926)+i(1604)+i(513)](e[i(308)],this._handlePageShow),this.close()),this[i(1053)+"er"]&&window[i(926)+i(1604)+i(513)](e.oOoot,this[i(784)+i(209)]),this[i(1053)+"er"]&&window[i(926)+i(1604)+i(513)](e[i(1131)],this[i(784)+i(390)])}[t(1278)+t(510)](n){let i=t;if(n.persisted)if(e.hZJjw(e.UXMNv,e[i(1516)])){let d=e[i(1444)][i(620)]("|"),l=0;for(;;){switch(d[l++]){case"0":_0xe1356d=e.bDhSe(127,_0xa5f189[_0x325cf2])>>>0;continue;case"1":if(e[i(907)](_0x24453e[_0x1a4258++],128))return{value:_0x8c3680?_0x483db3:e[i(1019)](0,_0x550e7a),offset:_0x5c22eb};continue;case"2":if(e.OtSIy(_0x44e4ff[_0x2a6df7++],128))return{value:_0x56be1e?_0x387037:0|_0x5990f0,offset:_0x6546be};continue;case"3":_0xa2034a=e.akgSx(_0x40d8ae,e[i(352)](127,_0x1934a8[_0x1485ae])<<14)>>>0;continue;case"4":if(e[i(451)](_0x5d6941[_0x6ed16++],128))return{value:_0x1acd66?_0x597610:e[i(563)](0,_0x1fec25),offset:_0x131fc4};continue;case"5":if(e.qMyuB(_0x220fe9[_0x1f9b60++],128))return{value:_0x337ac4?_0x19bb7d:e[i(952)](0,_0x1a2ae9),offset:_0x2c513e};continue;case"6":if(e[i(667)](_0x4e8baa[_0x33ad9c++],128))return{value:_0xe92309?_0x2b36b9:e.eFUGk(0,_0x5c93cf),offset:_0x3f19c3};continue;case"7":return{value:_0x57ac33?_0x3bcf39:e[i(1422)](0,_0x38c061),offset:_0x3ad37a};case"8":_0x4acea6=e[i(895)](e[i(1529)](_0x1b0cc9,e.tULmX(e[i(1341)](127,_0x47c0fe[_0x226563]),7)),0);continue;case"9":_0x114ce0=e[i(812)](e.EPPLt(_0xf62a5f,e[i(1262)](e[i(996)](15,_0x12e46b[_0x57256d]),28)),0);continue;case"10":if(e[i(759)](_0x242f21+=5,_0x5b226d[i(490)]))throw _0x7122c8=_0x5d87a1.length,_0x4c9d69(_0x524acb,10,_0x2c4136[i(490)]);continue;case"11":_0x233af0=e.prIYq(e[i(835)](_0x4611f3,e[i(452)](e.bkeOn(127,_0x23d671[_0xb3c230]),21)),0);continue}break}}else this[i(642)+i(587)]()&&(!this._ws||this[i(1137)][i(760)+"te"]!==this[i(1550)]||e.YhIZq(this[i(1137)][i(760)+"te"],this.CONNECTING))&&this[i(784)+"nLine"](),this[i(1053)+"er"]&&window[i(1598)+"Listener"](e[i(1605)],this._handleOnLine),this._isBrowser&&window[i(1598)+i(1117)](e[i(1131)],this[i(784)+"ffLine"])}async["_generat"+t(923)](n){let i=t,{fpID:d,deviceID:l,bddID:g,ttwID:m,accessKey:S,aID:p,customParams:D={},enableAutoAck:A,enableQoS:B,QoSLevel:H,env:W}=this[i(1149)],$,Ee,je;if(this[i(1053)+"er"]||this[i(303)+"X"]||this[i(1266)+"T"])if(e[i(1634)](e.IAbaz,i(467)))$=location&&e[i(1393)]("https:",location[i(908)])?i(953):e[i(1287)],Ee=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),je=/^wss(.*:\/\/)/[i(1259)](n)?n:""+$+Ee;else for(var Ue in _0x4ec337)_0x170330(_0x46ba3c,Ue,{get:_0x156e8e[Ue],enumerable:!0});else $=e.yrOYB,Ee=n[i(1613)](/(^http)((?:[s]*:\/\/))/,""),je=/(^ws)((?:[s]*:\/\/))/[i(1259)](Ee)?Ee:""+$+Ee;let Rt=g?e[i(1503)]:m?i(1295):e[i(545)],gn=g||m||l;if(!gn||!Rt)throw new Error(i(887)+i(470)+i(1250)+i(911)+i(1225));let Ni=e.AMBhU(e[i(277)],typeof D)?await e[i(344)](D):D,Mi=W?e[i(416)](ih,W.xUseEnv,W[i(1145)]):{},Or=Object[i(447)]({device_platform:e.COpvx,version_code:e[i(203)],access_key:S,fpid:d,aid:p,[Rt]:gn,xsack:A?1:0,xaack:A?1:0,xsqos:B?1:0,qos_level:B?H:void 0,qos_sdk_version:2,...Mi},Ni),Ho=Object[i(1597)](Or)[i(633)]((jo,Go)=>Or[Go]!==void 0?""+jo+(jo?"&":"?")+Go+"="+Or[Go]:jo,"");return je+i(1519)+Ho}async[t(993)](){let n=t;if(!(this["_connect"+n(1062)]||this[n(658)+"osed"])){this[n(993)+n(1062)]=!0;try{let i=this["_endpoin"+n(399)]?.[n(206)+n(1594)+n(1127)+n(296)+n(518)](),{timeoutInterval:d}=this[n(1149)];if(i){let g=this[n(534)+n(399)]?.["getCurre"+n(256)+"nt"](),m=this["_endpoin"+n(399)]?.[n(397)+"ackupEnd"+n(336)+"UpdateCo"+n(374)](),S=this[n(534)+n(399)]?.["getCurre"+n(256)+n(456)+"ount"]();if(m)if(e.pnuzv!==e.JSGrU){let p=n(873)+g+(n(699)+n(407)+n(453)+"ached, w"+n(997)+n(1440)+n(1035))+m+(n(327)+"y"),D=Qe(e.TJPGM,{message:p,code:Wt[n(742)+n(542)+"R"]});this[n(499)](p),this["_dispatc"+n(693)+n(1182)](D),this[n(869)]=await this["_generat"+n(923)](m),this[n(499)](n(873)+m+" "+S+n(968)),this[n(1139)+n(794)+"rs"]()}else _0x2d3333[n(294)](_0x50821e);else{let p=n(873)+g+(n(699)+n(407)+"tries re"+n(1421));this[n(499)](p),this[n(558)+n(693)+n(1182)](Qe(e[n(842)],{message:p,code:Wt[n(742)+n(542)+"R"]}));return}}else{let g=this[n(534)+n(399)]?.[n(875)+"ntEndpoi"+n(520)+n(1284)](),m=this[n(534)+n(399)]?.[n(875)+n(256)+n(456)+n(942)]();this[n(869)]=await this[n(239)+n(923)](g||""),this[n(499)](n(873)+g+" "+m+n(968)),this[n(1139)+"sListeners"]()}if(this[n(187)])this[n(187)]=!1;else{let g=e[n(1047)](Lo,"reconnect",{message:e[n(250)]});this[n(1629)+n(1606)]&&this[n(1629)+"econnect"](g)}let l=this[n(534)+"tManager"]?.["getCurre"+n(256)+"ntTriesC"+n(942)]()||0;l>1&&await this[n(839)](e[n(1232)](l,1)),this[n(499)]("connecti"+n(496)+this[n(869)]+(n(1188)+n(566))+this._protocols),this[n(1137)]=e[n(1070)](th,{url:this[n(869)],protocols:[this[n(1577)+"ls"]],headers:this[n(1149)][n(1479)+n(927)+"s"][n(729)+n(408)]},this._options.ws),(this[n(1053)+"er"]||this._isWorker)&&this[n(1137)]&&(this._ws[n(1133)+"pe"]=this[n(728)+n(436)]),this[n(459)+n(819)](),this[n(993)+"ionTimeoutId"]=setTimeout(this[n(674)+"ut"][n(811)](this),d)}catch(i){throw this[n(993)+"Lock"]=!1,i}}}[t(1054)+t(1247)](){let n=t;e.NnvJy(clearTimeout,this[n(993)+n(1395)+n(181)]),this[n(993)+n(1395)+"utId"]=null}[t(260)+"ngTimer"](){let n=t;e[n(768)](clearTimeout,this["_pingPon"+n(920)+"Id"]),e[n(1522)](clearTimeout,this[n(945)+n(792)+n(1587)]),this[n(880)+n(920)+"Id"]=null,this[n(945)+n(792)+n(1587)]=null}_debug(...n){let i=t;this[i(1149)][i(632)]&&console[i(294)][i(844)](console,[e.MwlBG,...n])}[t(922)+t(866)+"e"](n){let i=t,{initReconnectInterval:d,maxReconnectInterval:l,reconnectIntervalGrowFactor:g}=this[i(1149)],m=e[i(489)](d,Math.pow(g,n-1));return e.xZpDK(m,l)?l:m}[t(1067)](){let n=t;if(this._ws&&this[n(1137)][n(760)+"te"]===this[n(1030)+"NG"]){this[n(260)+n(234)](),this["_pingPon"+n(920)+"Id"]=e[n(285)](setTimeout,this[n(1067)][n(811)](this),this._options["pingInte"+n(349)]);return}if(!this[n(1137)]||this[n(1137)].readyState!==this.OPEN)return void this[n(1301)+n(1606)]();this[n(1137)]&&this[n(1137)].send("hi"),this[n(945)+n(792)+n(1587)]=e.jfqDd(setTimeout,this[n(1301)+n(1606)+n(242)][n(811)](this),this[n(1149)][n(502)+"outInter"+n(1265)])}[t(1301)+t(1606)+t(242)](){let n=t;if(e.IKQWC===e[n(183)])this[n(1326)+n(544)]?.[n(528)](),this[n(378)](e.fvgXz,e[n(1309)]),this[n(1326)+n(544)]?.[n(1026)+n(355)+"nt"]()?this["_handleR"+n(1606)]():this[n(1067)]();else return new _0x1a1723(e[n(190)](e[n(1116)](e[n(485)](_0x5cfcd6[0],e[n(287)](_0x11329f[1],8)),e.bKQpf(_0x4a05cd[2],16)),e[n(589)](_0x49da76[3],24)),e[n(1525)](e[n(1021)](e.gYyCI(_0x1b03be[4],e[n(1372)](_0x239582[5],8)),_0x54878c[6]<<16),e.FfqsF(_0x334b2e[7],24)),_0x1439cc)}[t(642)+t(587)](){let n=t;return this[n(1266)+"T"]||this[n(303)+"X"]?this[n(591)+n(554)+n(818)]:(this._isBrowser||this[n(198)+"r"])&&this[n(1149)]["listenNe"+n(1065)+n(1307)]?navigator.onLine:!0}[t(1301)+t(1606)](){let n=t;!this["_navigat"+n(587)]()||this["_readyCl"+n(697)]||(this[n(534)+"tManager"]?.[n(921)+"pointCon"+n(1562)](),this[n(1326)+n(544)]?.[n(825)+n(432)](),this[n(1137)]?this[n(560)+n(1094)](1001,e[n(1222)],!0):this[n(993)]())}[t(457)+t(1423)+t(1135)](){let n=t;this[n(1266)+"T"]?tt[n(279)+n(621)+n(653)](({isConnected:i})=>{let d=n;this[d(591)+d(554)+d(818)]=i,i?this[d(784)+d(209)]():this[d(784)+d(390)]()}):this._isMiniWX&&wx[n(279)+n(621)+n(653)](({isConnected:i})=>{let d=n;this[d(591)+d(554)+d(818)]=i,i?this[d(784)+d(209)]():this[d(784)+"ffLine"]()})}_wait(n){return new Promise(i=>{let d=G;e[d(964)](setTimeout,i,this[d(922)+d(866)+"e"](n))})}[t(560)+t(1094)](n=1e3,i="",d=!1){let l=t;this[l(1137)]&&this[l(1040)+l(727)+"t"](n,i,d)}[t(674)+"ut"](){let n=t,i=this[n(534)+n(399)]?.["getCurre"+n(256)+"nt"]();this[n(499)](n(873)+i+n(699)),this[n(560)+n(1094)](1001,e[n(309)],!0)}[t(617)](n){let i=t,d=e[i(1579)](We,n);this[i(1137)]&&this[i(1137)][i(760)+"te"]===this.OPEN&&(this[i(1137)]&&this[i(1137)][i(437)](d),this._debug(e[i(297)],n))}[t(1139)+"sListeners"](){let n=t,i=e[n(1016)].split("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(1137)][n(926)+n(1604)+"ner"](e[n(1176)],this._onClose);continue;case"1":this[n(1137)][n(926)+n(1604)+"ner"](e.nshwu,this[n(1437)]);continue;case"2":this[n(1137)][n(926)+"entListe"+n(513)](e.TJPGM,this[n(1610)]);continue;case"3":if(!this[n(1137)])return;continue;case"4":this[n(1137)][n(926)+"entListe"+n(513)](e[n(172)],this[n(486)+"ge"]);continue}break}}[t(459)+"steners"](){let n=t;this[n(1137)]&&(this[n(1137)]["addEvent"+n(1117)](e.nshwu,this[n(1437)]),this[n(1137)]["addEvent"+n(1117)]("close",this[n(302)]),this._ws[n(1598)+n(1117)](n(1329),this._onMessage),this[n(1137)][n(1598)+n(1117)]("error",this._onError))}[t(1617)+"nceClose"](n=1e3,i=""){let d=t;try{this[d(1137)]&&this[d(1137)].close(n,i)}catch{}}[t(1040)+t(727)+"t"](n=1e3,i="",d=!1){let l=t;if(e[l(483)]===e[l(946)])return _0x36408b.resolve();if(this["_clearPi"+l(234)](),this["_clearTi"+l(1247)](),this._removeWsListeners(),this[l(1617)+l(1205)](1e3,i),this[l(993)+l(1062)]=!1,d&&this[l(642)+l(587)]()&&!this[l(658)+"osed"]){if(this["_endpoin"+l(399)]?.[l(1026)+"chMaxTries"]()){let m=this[l(534)+l(399)]?.[l(875)+l(256)+"nt"]();this["_dispatc"+l(1023)+l(1182)](e[l(627)](ot,e[l(1176)],{code:1006,reason:l(873)+m+(l(699)+l(407)+l(453)+"ached"),wasClean:!0}))}else{let m=this._options[l(216)+l(376)+"ptor"](n,i);this[l(558)+l(1023)+l(1182)](ot(e[l(1176)],{code:n,reason:i,wasClean:!0,willReconnect:m})),m&&this._connect()}return}this[l(642)+l(587)]()||this["_readyCl"+l(697)]?this[l(558)+l(1023)+l(1182)](ot(e[l(1176)],{code:n,reason:e[l(519)]})):this[l(558)+l(1023)+l(1182)](e[l(360)](ot,e.sRAgi,{code:1006,reason:e.VHCWQ})),this[l(1137)]=null,this["_endpoin"+l(399)]?.[l(921)+l(382)+l(1562)](),this[l(1326)+"sCounter"]?.[l(825)+"nter"]()}[t(558)+"hOpenEvent"](n){let i=t;this.emit("open",n),this.onopen&&this[i(1206)](n)}[t(558)+t(966)+t(1237)](n){let i=t;this.emit(e[i(172)],n),this[i(1310)+"e"]&&this[i(1310)+"e"](n)}[t(558)+t(1051)+t(1194)](n){let i=t;this[i(378)](i(442),n),this["onReceiv"+i(1126)]&&this[i(1189)+i(1126)](n)}[t(558)+"hErrorEvent"](n){let i=t;if(e.ZfZCa(i(681),e[i(1608)]))this[i(378)](e[i(842)],n),this.onerror&&this[i(1072)](n);else{this[i(260)+i(234)](),this[i(880)+i(920)+"Id"]=e[i(1192)](_0x5037df,this[i(1067)].bind(this),this._options[i(1360)+"rval"]);return}}[t(558)+t(1023)+t(1182)](n){let i=t;this.emit(e[i(1176)],n),this.onclose&&this[i(951)](n)}get[t(1133)+"pe"](){let n=t;return this[n(1137)]?this[n(1137)][n(1133)+"pe"]:this[n(728)+n(436)]}set[t(1133)+"pe"](n){let i=t;this[i(728)+"ype"]=n,this[i(1137)]&&(this[i(1137)].binaryType=n)}get retryCount(){let n=t;return this[n(534)+n(399)]?.[n(875)+n(256)+n(456)+n(942)]()||0}get["buffered"+t(614)](){let n=t,i={zmXCe:function(d,l,g){return e.HFqRX(d,l,g)},JKUkT:function(d,l,g,m){return e[G(1404)](d,l,g,m)},NOgkX:function(d,l){return e.kBmJo(d,l)}};if(e.WkRea(n(1639),n(879)))this[n(591)+n(554)+"line"]=_0x149298,_0x2f6775?this[n(784)+"nLine"]():this[n(784)+n(390)]();else{let d=this["_message"+n(551)][n(633)]((l,g)=>{let m=n;if(e.iqUgh!==e[m(944)]){let{offset:S}=PvXqus[m(1351)](_0x5937de,_0x1e799c,_0x39cd40);_0x11bc73=S;let p={cursor_name:"",cursor:0,service:0},{value:D,offset:A}=_0x3cbb96(_0x141885,_0x14df95);p.service=D,_0x5d8037=A;let{value:B,offset:H}=PvXqus[m(1351)](_0x1400f3,_0x2e68e3,_0x89fc2e);_0x5d7d5f=H,p[m(910)+m(1058)]=PvXqus[m(1043)](_0x23872e,_0x45e9fe,_0x43a3aa,PvXqus.NOgkX(_0x3df907,B)),_0x41d72b+=B;let{value:W,offset:$}=_0x486a10(_0x356a75,_0x38678d);p.cursor=W[m(161)](),_0xa5076c=$,_0x4927cb[m(885)](p)}else return l+=g&&g[m(1121)+"th"]||0,l},0);return e.VLXdQ(d,this[n(1137)]?this[n(1137)][n(1483)+n(614)]:0)}}get[t(1210)+"ns"](){let n=t;return this[n(1137)]?this[n(1137)].extensions:""}get protocol(){let n=t;return this[n(1137)]?this[n(1137)][n(908)]:""}get[t(760)+"te"](){let n=t,i={tlhhd:function(d,l){return e[G(1315)](d,l)}};if(e.hZJjw(e[n(645)],e[n(645)]))return this._ws?this[n(1137)][n(760)+"te"]:this[n(1149)]["automati"+n(1045)]?this[n(1030)+"NG"]:this[n(556)];{let d=this[n(892)][n(1374)+n(1570)+"nc"](this._prefix),l=_0x5b1bfa[n(1328)](btjvXk.tlhhd(d,"{}"));return _0x1eb3b4[n(1120)](l)}}get[t(1280)](){let n=t;if(e.vMitH===e[n(454)]){if(this[n(260)+n(234)](),this[n(1054)+n(1247)](),this[n(1139)+n(794)+"rs"](),this[n(1617)+n(1205)](1e3,_0x43807e),this[n(993)+n(1062)]=!1,_0xddb866&&this["_navigat"+n(587)]()&&!this[n(658)+n(697)]){if(this[n(534)+n(399)]?.["checkRea"+n(366)+"es"]()){let d=this[n(534)+"tManager"]?.[n(875)+n(256)+"nt"]();this[n(558)+n(1023)+n(1182)](_0x1f904d(e.sRAgi,{code:1006,reason:n(873)+d+(" timeout"+n(407)+n(453)+n(1421)),wasClean:!0}))}else{let d=this[n(1149)]["reconnec"+n(376)+n(1493)](_0x1fa316,_0x153d8d);this["_dispatc"+n(1023)+n(1182)](_0x306c66(n(1333),{code:_0x97ef2c,reason:_0x128979,wasClean:!0,willReconnect:d})),d&&this._connect()}return}this._navigatorOnline()||this[n(658)+n(697)]?this[n(558)+n(1023)+"ent"](_0x274e7f(e.sRAgi,{code:_0x4e1b27,reason:n(803)})):this[n(558)+n(1023)+n(1182)](e[n(1592)](_0x408f50,e[n(1176)],{code:1006,reason:"going away, network offline"})),this[n(1137)]=null,this["_endpoin"+n(399)]?.["resetEnd"+n(382)+n(1562)](),this[n(1326)+n(544)]?.[n(825)+n(432)]()}else return this[n(1137)]?this._ws.url:this[n(869)]}[t(1333)](n=1e3,i){let d=t;if(e[d(1542)](e[d(735)],e[d(1018)]))return d(1017)+"_"+this._DBName;{let l=e[d(736)][d(620)]("|"),g=0;for(;;){switch(l[g++]){case"0":this[d(658)+"osed"]=!0;continue;case"1":if(!this[d(1137)])return void this[d(499)](e.jKJFQ);continue;case"2":if(e.KLUOY(this._ws[d(760)+"te"],this[d(556)])||e.yClJm(this._ws[d(760)+"te"],this.CLOSING))return void this[d(499)](e.cEqxh);continue;case"3":this[d(1054)+"mer"]();continue;case"4":this[d(260)+d(234)]();continue;case"5":this[d(1040)+d(727)+"t"](n,i);continue;case"6":this["_dropGlobalEvent"+d(1117)]();continue;case"7":this._QoSManager?.[d(1553)]();continue}break}}}async[t(437)](n,i){let d=t;if(e.EfoBu(null,n))throw new Error(e.NxtoS);e[d(832)](e.hhCAr,typeof n)&&(n=JSON.stringify(n)),typeof n!="string"&&!e[d(1539)](n,ArrayBuffer)&&!(n[d(424)]&&e[d(939)](n.buffer,ArrayBuffer))&&(n=JSON[d(796)+"y"](n));let l=await I0(n),g=e.leawH(rh,n),{method:m=0,service:S=this[d(1149)].service,logID:p=this[d(1149)][d(1511)+d(1187)](),headers:D=this[d(1149)].headers,payloadEncoding:A=this[d(1149)][d(1216)+d(1540)],payloadType:B=this[d(1149)]["payloadT"+d(436)],logIDNew:H=this._options[d(1549)+d(427)][d(455)+d(167)+"teLogIDNew"]?e[d(1159)](s,this[d(1149)][d(1549)+"Config"][d(1165)]):""}=e[d(1627)](i,{});if(!S)throw new Error(d(887)+d(411)+d(698)+d(649));let W={SeqID:oe[d(1505)+"er"](this._seqId++),LogID:oe[d(1505)+"er"](p),service:S,method:m,headers:D,payloadEncoding:e[d(1106)](A,Object)?A.encoding?A[d(471)]:"":A,payloadType:e.NpKpZ(B,Object)?B.type?B[d(1347)]:g:B||g,payload:l,LogIDNew:H},$=e[d(743)](We,W);return this._ws&&e[d(850)](this._ws.readyState,this[d(1550)])?(this[d(1137)]&&this[d(1137)][d(437)]($),this[d(499)](e.ZYuwG,W)):e[d(503)](this[d(810)+d(551)][d(490)],this._options[d(705)+"geQueueLength"])?(this[d(810)+"Queue"][d(885)]($),this[d(499)](e[d(384)],W)):(this[d(810)+d(551)][d(870)](),this[d(810)+d(551)][d(885)]($)),{seqID:this[d(262)],logID:p,logIDNew:H}}async[t(216)+"t"](n){let i=t,{url:d}=n||{},l=Array[i(1403)](d)?d:e[i(1575)](e[i(1443)],typeof d)?[d]:[];n&&Object.assign(this[i(1149)],n),l&&l.length?this[i(534)+i(399)]=new b0(l,this[i(1149)][i(877)+"es"]):this[i(534)+i(399)]?.[i(921)+i(382)+i(1562)](),this[i(1326)+i(544)]?.[i(825)+i(432)](this[i(1149)][i(1508)+i(543)]),this[i(658)+i(697)]=!1,this[i(1137)]&&this._ws.readyState!==this[i(556)]?this[i(560)+i(1094)](1e3,i(1144)+i(1606)+"ing",!0):(this[i(187)]=!0,this[i(993)]())}async[t(1012)](){let n=t;if(e.wQvJq===e[n(828)])this[n(1137)]&&this[n(1137)][n(1333)](_0x3a56d2,_0x5d4fb9);else if(!this[n(993)+"Lock"]){let i=e.XyNHG[n(620)]("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(1326)+"sCounter"]?.[n(825)+n(432)]();continue;case"1":this[n(187)]=!0;continue;case"2":this[n(993)]();continue;case"3":this[n(658)+"osed"]=!1;continue;case"4":this[n(534)+"tManager"]?.[n(921)+"pointCon"+n(1562)]();continue}break}}}[t(1598)+t(1117)](n,i){this.on(n,i)}[t(965)+t(1237)](n){let i=t,{type:d}=n;this[i(378)](d,n)}["removeEv"+t(1604)+t(513)](n,i){this[t(630)](n,i)}[t(732)](){let n=t,i={lkkaT:"timeout",lKCnu:e[n(861)],SEvdV:"ping_onc"+n(1125)+"t",lsnMO:function(d,l){return d(l)},BAUlp:e.hCGOE,mNHxc:function(d,l,g){return e[n(713)](d,l,g)}};return new Promise((d,l)=>{let g=n,m={OSaBz:function(D,A){return i[G(914)](D,A)},PuZcE:i[g(1180)],mmeJr:i[g(957)]};this[g(260)+g(234)](),this["_pingPon"+g(920)+"Id"]=i[g(305)](setTimeout,this[g(1067)][g(811)](this),this[g(1149)][g(1360)+g(349)]);let S=()=>{let D=g;m.OSaBz(d,m[D(1448)]),this[D(630)](m[D(801)],S),this[D(630)](D(1377)+D(1125)+"t",p)},p=()=>{let D=g;l(i[D(434)]),this[D(630)](i.lKCnu,S),this[D(630)](i[D(777)],p)};this.on(i.lKCnu,S),this.on(i[g(777)],p),this[g(1067)]()})}}})(),Ie[M(1467)+M(652)]=be["CustomCl"+M(652)],Ie[M(1264)+M(1497)]=be[M(1264)+"rorEvent"],Ie[M(1512)+"e"]=be[M(1512)+"e"],Ie[M(1237)]=be[M(1237)],Ie.FWS=be[M(1486)],Ie[M(678)+M(214)+M(168)]=be["Frontier"+M(214)+M(168)],Ie[M(214)+"vent"]=be[M(214)+"vent"],Ie[M(1345)+"t"]=be.OpenEvent,Ie[M(1033)+M(883)]=be["Reconnec"+M(883)],Ie["createCl"+M(652)]=be[M(191)+"oseEvent"],Ie[M(1244)+M(1497)]=be[M(1244)+M(1497)],Ie[M(1424)+"ssageEvent"]=be[M(1424)+M(461)+"nt"],Ie["createOp"+M(245)]=be[M(898)+M(245)],Ie[M(1521)+M(1105)+M(168)]=be[M(1521)+"connectE"+M(168)],Ie[M(1170)+M(1154)]=be[M(1170)+M(1154)],Ie[M(821)+M(1058)]=be["encodeFr"+M(1058)];for(Qs in be)["CustomCloseEvent",M(1264)+M(1497),"ErrorCode",M(1237),M(1486),M(678)+M(214)+M(168),M(214)+M(168),"OpenEvent",M(1033)+M(883),M(191)+M(652),"createEr"+M(1497),"createMe"+M(461)+"nt","createOpenEvent",M(1521)+M(1105)+M(168),"decodedF"+M(1154),"encodeFr"+M(1058)].indexOf(Qs)===-1&&(Ie[Qs]=be[Qs]);var Qs;Object[M(379)+M(217)](Ie,"__esModule",{value:!0})});var zt=ne((EI,xl)=>{"use strict";var ul=["nodebuffer","arraybuffer","fragments"],ll=typeof Blob<"u";ll&&ul.push("blob");xl.exports={BINARY_TYPES:ul,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ll,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ii=ne((vI,oo)=>{"use strict";var{EMPTY_BUFFER:wy}=zt(),Tc=Buffer[Symbol.species];function _y(t,e){if(t.length===0)return wy;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),s=0;for(let a=0;a<t.length;a++){let c=t[a];r.set(c,s),s+=c.length}return s<e?new Tc(r.buffer,r.byteOffset,s):r}function hl(t,e,r,s,a){for(let c=0;c<a;c++)r[s+c]=t[c]^e[c&3]}function pl(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function yy(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Ac(t){if(Ac.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Tc(t):ArrayBuffer.isView(t)?e=new Tc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Ac.readOnly=!1),e}oo.exports={concat:_y,mask:hl,toArrayBuffer:yy,toBuffer:Ac,unmask:pl};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ae("bufferutil");oo.exports.mask=function(e,r,s,a,c){c<48?hl(e,r,s,a,c):t.mask(e,r,s,a,c)},oo.exports.unmask=function(e,r){e.length<32?pl(e,r):t.unmask(e,r)}}catch{}});var wl=ne((SI,ml)=>{"use strict";var gl=Symbol("kDone"),Rc=Symbol("kRun"),Dc=class{constructor(e){this[gl]=()=>{this.pending--,this[Rc]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Rc]()}[Rc](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[gl])}}};ml.exports=Dc});var Sr=ne((II,El)=>{"use strict";var Ci=ae("zlib"),_l=Ii(),by=wl(),{kStatusCode:yl}=zt(),Ey=Buffer[Symbol.species],vy=Buffer.from([0,0,255,255]),co=Symbol("permessage-deflate"),Ft=Symbol("total-length"),Er=Symbol("callback"),xn=Symbol("buffers"),vr=Symbol("error"),ao,kc=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ao){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ao=new by(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Er];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,s=e.find(a=>!(r.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>a.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!a.client_max_window_bits));if(!s)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(s.server_no_context_takeover=!0),r.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(s.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?s.client_max_window_bits=r.clientMaxWindowBits:(s.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(s=>{let a=r[s];if(a.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(a=a[0],s==="client_max_window_bits"){if(a!==!0){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${s}": ${a}`);a=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${a}`)}else if(s==="server_max_window_bits"){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${s}": ${a}`);a=c}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${a}`)}else throw new Error(`Unknown parameter "${s}"`);r[s]=a})}),e}decompress(e,r,s){ao.add(a=>{this._decompress(e,r,(c,f)=>{a(),s(c,f)})})}compress(e,r,s){ao.add(a=>{this._compress(e,r,(c,f)=>{a(),s(c,f)})})}_decompress(e,r,s){let a=this._isServer?"client":"server";if(!this._inflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Ci.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Ci.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[co]=this,this._inflate[Ft]=0,this._inflate[xn]=[],this._inflate.on("error",Iy),this._inflate.on("data",bl)}this._inflate[Er]=s,this._inflate.write(e),r&&this._inflate.write(vy),this._inflate.flush(()=>{let c=this._inflate[vr];if(c){this._inflate.close(),this._inflate=null,s(c);return}let f=_l.concat(this._inflate[xn],this._inflate[Ft]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ft]=0,this._inflate[xn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),s(null,f)})}_compress(e,r,s){let a=this._isServer?"server":"client";if(!this._deflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Ci.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Ci.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Ft]=0,this._deflate[xn]=[],this._deflate.on("data",Sy)}this._deflate[Er]=s,this._deflate.write(e),this._deflate.flush(Ci.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=_l.concat(this._deflate[xn],this._deflate[Ft]);r&&(c=new Ey(c.buffer,c.byteOffset,c.length-4)),this._deflate[Er]=null,this._deflate[Ft]=0,this._deflate[xn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),s(null,c)})}};El.exports=kc;function Sy(t){this[xn].push(t),this[Ft]+=t.length}function bl(t){if(this[Ft]+=t.length,this[co]._maxPayload<1||this[Ft]<=this[co]._maxPayload){this[xn].push(t);return}this[vr]=new RangeError("Max payload size exceeded"),this[vr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[vr][yl]=1009,this.removeListener("data",bl),this.reset()}function Iy(t){if(this[co]._inflate=null,this[vr]){this[Er](this[vr]);return}t[yl]=1007,this[Er](t)}});var Ir=ne((CI,fo)=>{"use strict";var{isUtf8:vl}=ae("buffer"),{hasBlob:Cy}=zt(),Ty=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Ay(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Pc(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function Ry(t){return Cy&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}fo.exports={isBlob:Ry,isValidStatusCode:Ay,isValidUTF8:Pc,tokenChars:Ty};if(vl)fo.exports.isValidUTF8=function(t){return t.length<24?Pc(t):vl(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ae("utf-8-validate");fo.exports.isValidUTF8=function(e){return e.length<32?Pc(e):t(e)}}catch{}});var Bc=ne((TI,Dl)=>{"use strict";var{Writable:Dy}=ae("stream"),Sl=Sr(),{BINARY_TYPES:ky,EMPTY_BUFFER:Il,kStatusCode:Py,kWebSocket:Oy}=zt(),{concat:Oc,toArrayBuffer:Ly,unmask:Ny}=Ii(),{isValidStatusCode:My,isValidUTF8:Cl}=Ir(),uo=Buffer[Symbol.species],rt=0,Tl=1,Al=2,Rl=3,Lc=4,Nc=5,lo=6,Mc=class extends Dy{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||ky[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Oy]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=rt}_write(e,r,s){if(this._opcode===8&&this._state==rt)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=new uo(s.buffer,s.byteOffset+e,s.length-e),new uo(s.buffer,s.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let s=this._buffers[0],a=r.length-e;e>=s.length?r.set(this._buffers.shift(),a):(r.set(new Uint8Array(s.buffer,s.byteOffset,e),a),this._buffers[0]=new uo(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case rt:this.getInfo(e);break;case Tl:this.getPayloadLength16(e);break;case Al:this.getPayloadLength64(e);break;case Rl:this.getMask();break;case Lc:this.getData(e);break;case Nc:case lo:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let s=(r[0]&64)===64;if(s&&!this._extensions[Sl.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(s){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(s){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=Tl:this._payloadLength===127?this._state=Al:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),s=r.readUInt32BE(0);if(s>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=s*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Rl:this._state=Lc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Lc}getData(e){let r=Il;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Ny(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Nc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Sl.extensionName].decompress(e,this._fin,(a,c)=>{if(a)return r(a);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(f);return}this._fragments.push(c)}this.dataMessage(r),this._state===rt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=rt;return}let r=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let a;this._binaryType==="nodebuffer"?a=Oc(s,r):this._binaryType==="arraybuffer"?a=Ly(Oc(s,r)):this._binaryType==="blob"?a=new Blob(s):a=s,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=rt):(this._state=lo,setImmediate(()=>{this.emit("message",a,!0),this._state=rt,this.startLoop(e)}))}else{let a=Oc(s,r);if(!this._skipUTF8Validation&&!Cl(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Nc||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=rt):(this._state=lo,setImmediate(()=>{this.emit("message",a,!1),this._state=rt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Il),this.end();else{let s=e.readUInt16BE(0);if(!My(s)){let c=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let a=new uo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Cl(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",s,a),this.end()}this._state=rt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=rt):(this._state=lo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=rt,this.startLoop(r)}))}createError(e,r,s,a,c){this._loop=!1,this._errored=!0;let f=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(f,this.createError),f.code=c,f[Py]=a,f}};Dl.exports=Mc});var Uc=ne((RI,Ol)=>{"use strict";var{Duplex:AI}=ae("stream"),{randomFillSync:By}=ae("crypto"),kl=Sr(),{EMPTY_BUFFER:zy,kWebSocket:Fy,NOOP:Uy}=zt(),{isBlob:Cr,isValidStatusCode:qy}=Ir(),{mask:Pl,toBuffer:Ln}=Ii(),it=Symbol("kByteLength"),Hy=Buffer.alloc(4),xo=8*1024,Nn,Tr=xo,xt=0,jy=1,Gy=2,zc=class t{constructor(e,r,s){this._extensions=r||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=xt,this.onerror=Uy,this[Fy]=void 0}static frame(e,r){let s,a=!1,c=2,f=!1;r.mask&&(s=r.maskBuffer||Hy,r.generateMask?r.generateMask(s):(Tr===xo&&(Nn===void 0&&(Nn=Buffer.alloc(xo)),By(Nn,0,xo),Tr=0),s[0]=Nn[Tr++],s[1]=Nn[Tr++],s[2]=Nn[Tr++],s[3]=Nn[Tr++]),f=(s[0]|s[1]|s[2]|s[3])===0,c=6);let u;typeof e=="string"?(!r.mask||f)&&r[it]!==void 0?u=r[it]:(e=Buffer.from(e),u=e.length):(u=e.length,a=r.mask&&r.readOnly&&!f);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(a?u+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(u,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(u,4,6)),r.mask?(h[1]|=128,h[c-4]=s[0],h[c-3]=s[1],h[c-2]=s[2],h[c-1]=s[3],f?[h,e]:a?(Pl(e,s,h,c,u),[h]):(Pl(e,s,e,0,u),[h,e])):[h,e]}close(e,r,s,a){let c;if(e===void 0)c=zy;else{if(typeof e!="number"||!qy(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let f={[it]:c.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==xt?this.enqueue([this.dispatch,c,!1,f,a]):this.sendFrame(t.frame(c,f),a)}ping(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Cr(e)?(a=e.size,c=!1):(e=Ln(e),a=e.length,c=Ln.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[it]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Cr(e)?this._state!==xt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==xt?this.enqueue([this.dispatch,e,!1,f,s]):this.sendFrame(t.frame(e,f),s)}pong(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Cr(e)?(a=e.size,c=!1):(e=Ln(e),a=e.length,c=Ln.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[it]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Cr(e)?this._state!==xt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==xt?this.enqueue([this.dispatch,e,!1,f,s]):this.sendFrame(t.frame(e,f),s)}send(e,r,s){let a=this._extensions[kl.extensionName],c=r.binary?2:1,f=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):Cr(e)?(u=e.size,x=!1):(e=Ln(e),u=e.length,x=Ln.readOnly),this._firstFragment?(this._firstFragment=!1,f&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=u>=a._threshold),this._compress=f):(f=!1,c=0),r.fin&&(this._firstFragment=!0);let h={[it]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:f};Cr(e)?this._state!==xt?this.enqueue([this.getBlobData,e,this._compress,h,s]):this.getBlobData(e,this._compress,h,s):this._state!==xt?this.enqueue([this.dispatch,e,this._compress,h,s]):this.dispatch(e,this._compress,h,s)}getBlobData(e,r,s,a){this._bufferedBytes+=s[it],this._state=Gy,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Fc,this,u,a);return}this._bufferedBytes-=s[it];let f=Ln(c);r?this.dispatch(f,r,s,a):(this._state=xt,this.sendFrame(t.frame(f,s),a),this.dequeue())}).catch(c=>{process.nextTick(Wy,this,c,a)})}dispatch(e,r,s,a){if(!r){this.sendFrame(t.frame(e,s),a);return}let c=this._extensions[kl.extensionName];this._bufferedBytes+=s[it],this._state=jy,c.compress(e,s.fin,(f,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Fc(this,x,a);return}this._bufferedBytes-=s[it],this._state=xt,s.readOnly=!1,this.sendFrame(t.frame(u,s),a),this.dequeue()})}dequeue(){for(;this._state===xt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][it],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][it],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Ol.exports=zc;function Fc(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let a=t._queue[s],c=a[a.length-1];typeof c=="function"&&c(e)}}function Wy(t,e,r){Fc(t,e,r),t.onerror(e)}});var Hl=ne((DI,ql)=>{"use strict";var{kForOnEventAttribute:Ti,kListener:qc}=zt(),Ll=Symbol("kCode"),Nl=Symbol("kData"),Ml=Symbol("kError"),Bl=Symbol("kMessage"),zl=Symbol("kReason"),Ar=Symbol("kTarget"),Fl=Symbol("kType"),Ul=Symbol("kWasClean"),Ut=class{constructor(e){this[Ar]=null,this[Fl]=e}get target(){return this[Ar]}get type(){return this[Fl]}};Object.defineProperty(Ut.prototype,"target",{enumerable:!0});Object.defineProperty(Ut.prototype,"type",{enumerable:!0});var Mn=class extends Ut{constructor(e,r={}){super(e),this[Ll]=r.code===void 0?0:r.code,this[zl]=r.reason===void 0?"":r.reason,this[Ul]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Ll]}get reason(){return this[zl]}get wasClean(){return this[Ul]}};Object.defineProperty(Mn.prototype,"code",{enumerable:!0});Object.defineProperty(Mn.prototype,"reason",{enumerable:!0});Object.defineProperty(Mn.prototype,"wasClean",{enumerable:!0});var Rr=class extends Ut{constructor(e,r={}){super(e),this[Ml]=r.error===void 0?null:r.error,this[Bl]=r.message===void 0?"":r.message}get error(){return this[Ml]}get message(){return this[Bl]}};Object.defineProperty(Rr.prototype,"error",{enumerable:!0});Object.defineProperty(Rr.prototype,"message",{enumerable:!0});var Ai=class extends Ut{constructor(e,r={}){super(e),this[Nl]=r.data===void 0?null:r.data}get data(){return this[Nl]}};Object.defineProperty(Ai.prototype,"data",{enumerable:!0});var Ky={addEventListener(t,e,r={}){for(let a of this.listeners(t))if(!r[Ti]&&a[qc]===e&&!a[Ti])return;let s;if(t==="message")s=function(c,f){let u=new Ai("message",{data:f?c:c.toString()});u[Ar]=this,ho(e,this,u)};else if(t==="close")s=function(c,f){let u=new Mn("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Ar]=this,ho(e,this,u)};else if(t==="error")s=function(c){let f=new Rr("error",{error:c,message:c.message});f[Ar]=this,ho(e,this,f)};else if(t==="open")s=function(){let c=new Ut("open");c[Ar]=this,ho(e,this,c)};else return;s[Ti]=!!r[Ti],s[qc]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[qc]===e&&!r[Ti]){this.removeListener(t,r);break}}};ql.exports={CloseEvent:Mn,ErrorEvent:Rr,Event:Ut,EventTarget:Ky,MessageEvent:Ai};function ho(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var po=ne((kI,jl)=>{"use strict";var{tokenChars:Ri}=Ir();function At(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function $y(t){let e=Object.create(null),r=Object.create(null),s=!1,a=!1,c=!1,f,u,x=-1,h=-1,w=-1,E=0;for(;E<t.length;E++)if(h=t.charCodeAt(E),f===void 0)if(w===-1&&Ri[h]===1)x===-1&&(x=E);else if(E!==0&&(h===32||h===9))w===-1&&x!==-1&&(w=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);w===-1&&(w=E);let y=t.slice(x,w);h===44?(At(e,y,r),r=Object.create(null)):f=y,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(u===void 0)if(w===-1&&Ri[h]===1)x===-1&&(x=E);else if(h===32||h===9)w===-1&&x!==-1&&(w=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);w===-1&&(w=E),At(r,t.slice(x,w),!0),h===44&&(At(e,f,r),r=Object.create(null),f=void 0),x=w=-1}else if(h===61&&x!==-1&&w===-1)u=t.slice(x,E),x=w=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(a){if(Ri[h]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);x===-1?x=E:s||(s=!0),a=!1}else if(c)if(Ri[h]===1)x===-1&&(x=E);else if(h===34&&x!==-1)c=!1,w=E;else if(h===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(h===34&&t.charCodeAt(E-1)===61)c=!0;else if(w===-1&&Ri[h]===1)x===-1&&(x=E);else if(x!==-1&&(h===32||h===9))w===-1&&(w=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);w===-1&&(w=E);let y=t.slice(x,w);s&&(y=y.replace(/\\/g,""),s=!1),At(r,u,y),h===44&&(At(e,f,r),r=Object.create(null),f=void 0),u=void 0,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=E);let C=t.slice(x,w);return f===void 0?At(e,C,r):(u===void 0?At(r,C,!0):s?At(r,u,C.replace(/\\/g,"")):At(r,u,C),At(e,f,r)),e}function Yy(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(a=>{let c=s[a];return Array.isArray(c)||(c=[c]),c.map(f=>f===!0?a:`${a}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}jl.exports={format:Yy,parse:$y}});var _o=ne((LI,tx)=>{"use strict";var Jy=ae("events"),Zy=ae("https"),Vy=ae("http"),Kl=ae("net"),Xy=ae("tls"),{randomBytes:Qy,createHash:e1}=ae("crypto"),{Duplex:PI,Readable:OI}=ae("stream"),{URL:Hc}=ae("url"),hn=Sr(),t1=Bc(),n1=Uc(),{isBlob:r1}=Ir(),{BINARY_TYPES:Gl,CLOSE_TIMEOUT:i1,EMPTY_BUFFER:go,GUID:s1,kForOnEventAttribute:jc,kListener:o1,kStatusCode:a1,kWebSocket:Le,NOOP:$l}=zt(),{EventTarget:{addEventListener:c1,removeEventListener:d1}}=Hl(),{format:f1,parse:u1}=po(),{toBuffer:l1}=Ii(),Yl=Symbol("kAborted"),Gc=[8,13],qt=["CONNECTING","OPEN","CLOSING","CLOSED"],x1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,de=class t extends Jy{constructor(e,r,s){super(),this._binaryType=Gl[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=go,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(s=r,r=[]):r=[r]),Jl(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Gl.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,s){let a=new t1({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),c=new n1(e,this._extensions,s.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[Le]=this,c[Le]=this,e[Le]=this,a.on("conclude",g1),a.on("drain",m1),a.on("error",w1),a.on("message",_1),a.on("ping",y1),a.on("pong",b1),c.onerror=E1,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Xl),e.on("data",wo),e.on("end",Ql),e.on("error",ex),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[hn.extensionName]&&this._extensions[hn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Xe(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Vl(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Wc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||go,r,s)}pong(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Wc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||go,r,s)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(s=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Wc(this,e,s);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[hn.extensionName]||(a.compress=!1),this._sender.send(e||go,a,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Xe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(de,"CONNECTING",{enumerable:!0,value:qt.indexOf("CONNECTING")});Object.defineProperty(de.prototype,"CONNECTING",{enumerable:!0,value:qt.indexOf("CONNECTING")});Object.defineProperty(de,"OPEN",{enumerable:!0,value:qt.indexOf("OPEN")});Object.defineProperty(de.prototype,"OPEN",{enumerable:!0,value:qt.indexOf("OPEN")});Object.defineProperty(de,"CLOSING",{enumerable:!0,value:qt.indexOf("CLOSING")});Object.defineProperty(de.prototype,"CLOSING",{enumerable:!0,value:qt.indexOf("CLOSING")});Object.defineProperty(de,"CLOSED",{enumerable:!0,value:qt.indexOf("CLOSED")});Object.defineProperty(de.prototype,"CLOSED",{enumerable:!0,value:qt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(de.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(de.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[jc])return e[o1];return null},set(e){for(let r of this.listeners(t))if(r[jc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[jc]:!0})}})});de.prototype.addEventListener=c1;de.prototype.removeEventListener=d1;tx.exports=de;function Jl(t,e,r,s){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:i1,protocolVersion:Gc[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=a.autoPong,t._closeTimeout=a.closeTimeout,!Gc.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${Gc.join(", ")})`);let c;if(e instanceof Hc)c=e;else try{c=new Hc(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let f=c.protocol==="wss:",u=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!f&&!u?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let v=new SyntaxError(x);if(t._redirects===0)throw v;mo(t,v);return}let h=f?443:80,w=Qy(16).toString("base64"),E=f?Zy.request:Vy.request,C=new Set,y;if(a.createConnection=a.createConnection||(f?p1:h1),a.defaultPort=a.defaultPort||h,a.port=c.port||h,a.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":w,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(y=new hn({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=f1({[hn.extensionName]:y.offer()})),r.length){for(let v of r){if(typeof v!="string"||!x1.test(v)||C.has(v))throw new SyntaxError("An invalid or duplicated subprotocol was specified");C.add(v)}a.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(c.username||c.password)&&(a.auth=`${c.username}:${c.password}`),u){let v=a.path.split(":");a.socketPath=v[0],a.path=v[1]}let b;if(a.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=f,t._originalHostOrSocketPath=u?a.socketPath:c.host;let v=s&&s.headers;if(s={...s,headers:{}},v)for(let[I,k]of Object.entries(v))s.headers[I.toLowerCase()]=k}else if(t.listenerCount("redirect")===0){let v=u?t._originalIpc?a.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!v||t._originalSecure&&!f)&&(delete a.headers.authorization,delete a.headers.cookie,v||delete a.headers.host,a.auth=void 0)}a.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),b=t._req=E(a),t._redirects&&t.emit("redirect",t.url,b)}else b=t._req=E(a);a.timeout&&b.on("timeout",()=>{Xe(t,b,"Opening handshake has timed out")}),b.on("error",v=>{b===null||b[Yl]||(b=t._req=null,mo(t,v))}),b.on("response",v=>{let I=v.headers.location,k=v.statusCode;if(I&&a.followRedirects&&k>=300&&k<400){if(++t._redirects>a.maxRedirects){Xe(t,b,"Maximum redirects exceeded");return}b.abort();let L;try{L=new Hc(I,e)}catch{let T=new SyntaxError(`Invalid URL: ${I}`);mo(t,T);return}Jl(t,L,r,s)}else t.emit("unexpected-response",b,v)||Xe(t,b,`Unexpected server response: ${v.statusCode}`)}),b.on("upgrade",(v,I,k)=>{if(t.emit("upgrade",v),t.readyState!==de.CONNECTING)return;b=t._req=null;let L=v.headers.upgrade;if(L===void 0||L.toLowerCase()!=="websocket"){Xe(t,I,"Invalid Upgrade header");return}let _=e1("sha1").update(w+s1).digest("base64");if(v.headers["sec-websocket-accept"]!==_){Xe(t,I,"Invalid Sec-WebSocket-Accept header");return}let T=v.headers["sec-websocket-protocol"],O;if(T!==void 0?C.size?C.has(T)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":C.size&&(O="Server sent no subprotocol"),O){Xe(t,I,O);return}T&&(t._protocol=T);let F=v.headers["sec-websocket-extensions"];if(F!==void 0){if(!y){Xe(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=u1(F)}catch{Xe(t,I,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(z);if(P.length!==1||P[0]!==hn.extensionName){Xe(t,I,"Server indicated an extension that was not requested");return}try{y.accept(z[hn.extensionName])}catch{Xe(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[hn.extensionName]=y}t.setSocket(I,k,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(b,t):b.end()}function mo(t,e){t._readyState=de.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function h1(t){return t.path=t.socketPath,Kl.connect(t)}function p1(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Kl.isIP(t.host)?"":t.host),Xy.connect(t)}function Xe(t,e,r){t._readyState=de.CLOSING;let s=new Error(r);Error.captureStackTrace(s,Xe),e.setHeader?(e[Yl]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(mo,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Wc(t,e,r){if(e){let s=r1(e)?e.size:l1(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${qt[t.readyState]})`);process.nextTick(r,s)}}function g1(t,e){let r=this[Le];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Le]!==void 0&&(r._socket.removeListener("data",wo),process.nextTick(Zl,r._socket),t===1005?r.close():r.close(t,e))}function m1(){let t=this[Le];t.isPaused||t._socket.resume()}function w1(t){let e=this[Le];e._socket[Le]!==void 0&&(e._socket.removeListener("data",wo),process.nextTick(Zl,e._socket),e.close(t[a1])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Wl(){this[Le].emitClose()}function _1(t,e){this[Le].emit("message",t,e)}function y1(t){let e=this[Le];e._autoPong&&e.pong(t,!this._isServer,$l),e.emit("ping",t)}function b1(t){this[Le].emit("pong",t)}function Zl(t){t.resume()}function E1(t){let e=this[Le];e.readyState!==de.CLOSED&&(e.readyState===de.OPEN&&(e._readyState=de.CLOSING,Vl(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Vl(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Xl(){let t=this[Le];if(this.removeListener("close",Xl),this.removeListener("data",wo),this.removeListener("end",Ql),t._readyState=de.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Le]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Wl),t._receiver.on("finish",Wl))}function wo(t){this[Le]._receiver.write(t)||this.pause()}function Ql(){let t=this[Le];t._readyState=de.CLOSING,t._receiver.end(),this.end()}function ex(){let t=this[Le];this.removeListener("error",ex),this.on("error",$l),t&&(t._readyState=de.CLOSING,this.destroy())}});var sx=ne((MI,ix)=>{"use strict";var NI=_o(),{Duplex:v1}=ae("stream");function nx(t){t.emit("close")}function S1(){!this.destroyed&&this._writableState.finished&&this.destroy()}function rx(t){this.removeListener("error",rx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function I1(t,e){let r=!0,s=new v1({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,f){let u=!f&&s._readableState.objectMode?c.toString():c;s.push(u)||t.pause()}),t.once("error",function(c){s.destroyed||(r=!1,s.destroy(c))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(a,c){if(t.readyState===t.CLOSED){c(a),process.nextTick(nx,s);return}let f=!1;t.once("error",function(x){f=!0,c(x)}),t.once("close",function(){f||c(a),process.nextTick(nx,s)}),r&&t.terminate()},s._final=function(a){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(a)});return}t._socket!==null&&(t._socket._writableState.finished?(a(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){a()}),t.close()))},s._read=function(){t.isPaused&&t.resume()},s._write=function(a,c,f){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(a,c,f)});return}t.send(a,f)},s.on("end",S1),s.on("error",rx),s}ix.exports=I1});var Kc=ne((BI,ox)=>{"use strict";var{tokenChars:C1}=Ir();function T1(t){let e=new Set,r=-1,s=-1,a=0;for(a;a<t.length;a++){let f=t.charCodeAt(a);if(s===-1&&C1[f]===1)r===-1&&(r=a);else if(a!==0&&(f===32||f===9))s===-1&&r!==-1&&(s=a);else if(f===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${a}`);s===-1&&(s=a);let u=t.slice(r,s);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,a);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}ox.exports={parse:T1}});var xx=ne((FI,lx)=>{"use strict";var A1=ae("events"),yo=ae("http"),{Duplex:zI}=ae("stream"),{createHash:R1}=ae("crypto"),ax=po(),Bn=Sr(),D1=Kc(),k1=_o(),{CLOSE_TIMEOUT:P1,GUID:O1,kWebSocket:L1}=zt(),N1=/^[+/0-9A-Za-z]{22}==$/,cx=0,dx=1,ux=2,$c=class extends A1{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:P1,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:k1,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=yo.createServer((s,a)=>{let c=yo.STATUS_CODES[426];a.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),a.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=M1(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,c,f)=>{this.handleUpgrade(a,c,f,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=cx}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===ux){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Di,this);return}if(e&&this.once("close",e),this._state!==dx)if(this._state=dx,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Di,this):process.nextTick(Di,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Di(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,s,a){r.on("error",fx);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){zn(this,e,r,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){zn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!N1.test(c)){zn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){zn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ki(r,400);return}let x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=D1.parse(x)}catch{zn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&w!==void 0){let C=new Bn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=ax.parse(w);y[Bn.extensionName]&&(C.accept(y[Bn.extensionName]),E[Bn.extensionName]=C)}catch{zn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let C={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(C,(y,b,v,I)=>{if(!y)return ki(r,b||401,v,I);this.completeUpgrade(E,c,h,e,r,s,a)});return}if(!this.options.verifyClient(C))return ki(r,401)}this.completeUpgrade(E,c,h,e,r,s,a)}completeUpgrade(e,r,s,a,c,f,u){if(!c.readable||!c.writable)return c.destroy();if(c[L1])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>cx)return ki(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${R1("sha1").update(r+O1).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(s.size){let E=this.options.handleProtocols?this.options.handleProtocols(s,a):s.values().next().value;E&&(h.push(`Sec-WebSocket-Protocol: ${E}`),w._protocol=E)}if(e[Bn.extensionName]){let E=e[Bn.extensionName].params,C=ax.format({[Bn.extensionName]:[E]});h.push(`Sec-WebSocket-Extensions: ${C}`),w._extensions=e}this.emit("headers",h,a),c.write(h.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
17
|
-
`+Object.keys(
|
|
16
|
+
`)),c.removeListener("error",fx),w.setSocket(c,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(w),w.on("close",()=>{this.clients.delete(w),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Di,this)})),u(w,a)}};lx.exports=$c;function M1(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let s of Object.keys(e))t.removeListener(s,e[s])}}function Di(t){t._state=ux,t.emit("close")}function fx(){this.destroy()}function ki(t,e,r,s){r=r||yo.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${yo.STATUS_CODES[e]}\r
|
|
17
|
+
`+Object.keys(s).map(a=>`${a}: ${s[a]}`).join(`\r
|
|
18
18
|
`)+`\r
|
|
19
19
|
\r
|
|
20
|
-
`+
|
|
20
|
+
`+r)}function zn(t,e,r,s,a,c){if(t.listenerCount("wsClientError")){let f=new Error(a);Error.captureStackTrace(f,zn),t.emit("wsClientError",f,r,e)}else ki(r,s,a,c)}});import{existsSync as fb,openSync as ub}from"node:fs";import{mkdir as lb}from"node:fs/promises";import{dirname as xb}from"node:path";import{fileURLToPath as hb}from"node:url";function Vc(t=te()){return fb(t.libEntry)?t.libEntry:hb(new URL("../index.ts",import.meta.url))}async function Xc(t={}){let e=t.paths??te(),r=t.entryOverride??Vc(e);await lb(xb(e.logFile),{recursive:!0});let s=ub(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],f=Wn(process.execPath,c,{detached:!0,stdio:["ignore",s,s],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return pb.info("daemon spawned",{pid:f.pid,entry:r}),{pid:f.pid,entry:r}}var pb,Qc=at(()=>{"use strict";$n();ee();Be();pb=j("spawn-daemon")});import{spawn as Db}from"node:child_process";import{mkdir as kb,unlink as Pb,writeFile as Ob}from"node:fs/promises";import{dirname as Lb,join as Nb}from"node:path";function Ro(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Mx(t,e){return new Promise((r,s)=>{let a=Db(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Ao,r0,i0,Bx=at(()=>{"use strict";ee();Ao=j("supervisor.launchd"),r0="ai.coze.bridge",i0={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
21
21
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
22
22
|
<plist version="1.0">
|
|
23
23
|
<dict>
|
|
24
24
|
<key>Label</key>
|
|
25
|
-
<string>${
|
|
25
|
+
<string>${r0}</string>
|
|
26
26
|
<key>ProgramArguments</key>
|
|
27
27
|
<array>
|
|
28
|
-
<string>${
|
|
29
|
-
<string>${
|
|
28
|
+
<string>${Ro(t.nodeBin)}</string>
|
|
29
|
+
<string>${Ro(t.entry)}</string>
|
|
30
30
|
<string>--daemon</string>
|
|
31
31
|
</array>
|
|
32
32
|
<key>RunAtLoad</key>
|
|
@@ -36,60 +36,60 @@ ${n.stack??""}`:String(n);return Yd.test(i)||Xd.test(i)}function Ys(n){if(n==nul
|
|
|
36
36
|
<key>ThrottleInterval</key>
|
|
37
37
|
<integer>10</integer>
|
|
38
38
|
<key>StandardOutPath</key>
|
|
39
|
-
<string>${
|
|
39
|
+
<string>${Ro(t.logFile)}</string>
|
|
40
40
|
<key>StandardErrorPath</key>
|
|
41
|
-
<string>${
|
|
41
|
+
<string>${Ro(t.logFile)}</string>
|
|
42
42
|
</dict>
|
|
43
43
|
</plist>
|
|
44
|
-
`},configPath(
|
|
44
|
+
`},configPath(t){return Nb(t.homeDir,"Library","LaunchAgents",`${r0}.plist`)},async install(t){let e=this.configPath(t);await kb(Lb(e),{recursive:!0}),await Ob(e,this.renderConfig(t),"utf8"),Ao.info("plist written",{plistPath:e}),await Mx("launchctl",["load","-w",e]),Ao.info("launchd job loaded",{label:r0})},async uninstall(t){let e=this.configPath(t);await Mx("launchctl",["unload","-w",e]).catch(r=>Ao.warn("launchctl unload failed (ignored)",{err:String(r)})),await Pb(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Ao.info("launchd job removed",{plistPath:e})}}});import{spawn as Mb}from"node:child_process";import{mkdir as Bb,unlink as zb,writeFile as Fb}from"node:fs/promises";import{dirname as Ub,join as qb}from"node:path";function Po(t,e){return new Promise((r,s)=>{let a=Mb(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Do,ko,s0,zx=at(()=>{"use strict";ee();Do=j("supervisor.systemd"),ko="coze-bridge.service",s0={platform:"linux",renderConfig(t){return`[Unit]
|
|
45
45
|
Description=Coze Bridge daemon
|
|
46
46
|
After=network.target
|
|
47
47
|
|
|
48
48
|
[Service]
|
|
49
49
|
Type=simple
|
|
50
|
-
ExecStart=${
|
|
50
|
+
ExecStart=${t.nodeBin} ${t.entry} --daemon
|
|
51
51
|
Restart=always
|
|
52
52
|
RestartSec=3
|
|
53
|
-
StandardOutput=append:${
|
|
54
|
-
StandardError=append:${
|
|
53
|
+
StandardOutput=append:${t.logFile}
|
|
54
|
+
StandardError=append:${t.logFile}
|
|
55
55
|
|
|
56
56
|
[Install]
|
|
57
57
|
WantedBy=default.target
|
|
58
|
-
`},configPath(
|
|
58
|
+
`},configPath(t){return qb(t.homeDir,".config","systemd","user",ko)},async install(t){let e=this.configPath(t);await Bb(Ub(e),{recursive:!0}),await Fb(e,this.renderConfig(t),"utf8"),Do.info("systemd unit written",{unitPath:e}),await Po("systemctl",["--user","daemon-reload"]),await Po("systemctl",["--user","enable","--now",ko]),Do.info("systemd unit enabled",{unitName:ko})},async uninstall(t){let e=this.configPath(t);await Po("systemctl",["--user","disable","--now",ko]).catch(r=>Do.warn("systemctl disable failed (ignored)",{err:String(r)})),await zb(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await Po("systemctl",["--user","daemon-reload"]).catch(()=>{}),Do.info("systemd unit removed",{unitPath:e})}}});import{spawn as Hb}from"node:child_process";import{join as jb}from"node:path";function Fx(t,e){return new Promise((r,s)=>{let a=Hb(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var o0,Oo,a0,Ux=at(()=>{"use strict";ee();o0=j("supervisor.taskscheduler"),Oo="CozeBridge",a0={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
59
59
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
60
60
|
<RegistrationInfo>
|
|
61
61
|
<Description>Coze Bridge daemon</Description>
|
|
62
62
|
</RegistrationInfo>
|
|
63
63
|
<Triggers>
|
|
64
64
|
<LogonTrigger>
|
|
65
|
-
<UserId>${
|
|
65
|
+
<UserId>${t.userName}</UserId>
|
|
66
66
|
</LogonTrigger>
|
|
67
67
|
</Triggers>
|
|
68
68
|
<Principals>
|
|
69
69
|
<Principal>
|
|
70
|
-
<UserId>${
|
|
70
|
+
<UserId>${t.userName}</UserId>
|
|
71
71
|
<LogonType>InteractiveToken</LogonType>
|
|
72
72
|
<RunLevel>LeastPrivilege</RunLevel>
|
|
73
73
|
</Principal>
|
|
74
74
|
</Principals>
|
|
75
75
|
<Actions>
|
|
76
76
|
<Exec>
|
|
77
|
-
<Command>${
|
|
78
|
-
<Arguments>"${
|
|
77
|
+
<Command>${t.nodeBin}</Command>
|
|
78
|
+
<Arguments>"${t.entry}" --daemon</Arguments>
|
|
79
79
|
</Exec>
|
|
80
80
|
</Actions>
|
|
81
81
|
</Task>
|
|
82
|
-
`},configPath(
|
|
82
|
+
`},configPath(t){return jb(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Fx("schtasks",["/Create","/SC","ONLOGON","/TN",Oo,"/TR",r,"/RU",t.userName,"/F"]),o0.info("task scheduler entry created",{task:Oo,logFile:t.logFile})},async uninstall(t){await Fx("schtasks",["/Delete","/TN",Oo,"/F"]).catch(e=>o0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),o0.info("task scheduler entry removed",{task:Oo})}}});var qx={};Ko(qx,{buildContext:()=>$b,getSupervisor:()=>Kb,launchdSupervisor:()=>i0,systemdSupervisor:()=>s0,taskSchedulerSupervisor:()=>a0});import{homedir as Gb,userInfo as Wb}from"node:os";function Kb(t=process.platform){switch(t){case"darwin":return i0;case"linux":return s0;case"win32":return a0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function $b(){let t=te();return{nodeBin:process.execPath,entry:Vc(t),logFile:t.logFile,homeDir:Gb(),userName:Wb().username}}var Hx=at(()=>{"use strict";Be();Qc();Bx();zx();Ux()});ee();_n();var F0=j("acp-installer-warmup"),dp=["claude-code","codex"];async function U0(t={}){let e=t.ensure??mn,s=(await Promise.allSettled(dp.map(async a=>{let c=await e(a);F0.info("acp wrapper warmup ok",{framework:a,installed:!!c,path:c??""})}))).filter(a=>a.status==="rejected");s.length>0&&F0.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:s.length,reasons:s.map(a=>String(a.reason))})}$t();ee();import{readdir as vp}from"node:fs/promises";import{mkdir as K0,writeFile as $0}from"node:fs/promises";import{join as Vo}from"node:path";var _p={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Zn(t,e,r,s){await K0(t,{recursive:!0});let a=_p[e],c=Vo(t,a),f=yp(e,r,s);return await $0(c,f,"utf8"),c}async function Y0(t){let e=Vo(t,".claude");await K0(e,{recursive:!0});let r=Vo(e,"settings.local.json"),s=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await $0(r,s,"utf8"),r}function yp(t,e,r){let s=`# Coze Agent: ${e}
|
|
83
83
|
|
|
84
|
-
> framework: \`${
|
|
84
|
+
> framework: \`${t}\`
|
|
85
85
|
|
|
86
|
-
`,a=
|
|
87
|
-
`)?
|
|
86
|
+
`,a=r?.trim()?r.endsWith(`
|
|
87
|
+
`)?r:`${r}
|
|
88
88
|
`:`_No instructions provided._
|
|
89
|
-
`;return`${
|
|
89
|
+
`;return`${s}---
|
|
90
90
|
|
|
91
91
|
${a}
|
|
92
|
-
${
|
|
92
|
+
${bp()}`}function bp(){let t=process.platform==="win32"?"coze-bridge.cmd":"coze-bridge";return Ep.replace(/\bcoze-bridge\b(?!\.cmd)/g,t)}var Ep=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
93
93
|
|
|
94
94
|
\u6BCF\u6761\u7528\u6237\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u4E91\u7AEF\u6CE8\u5165\u7684 \`<coze-context>\` \u5757, \u5F62\u5982:
|
|
95
95
|
|
|
@@ -98,11 +98,11 @@ ${mf}`}var mf=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
|
98
98
|
sessionId: <\u5F53\u524D\u5BF9\u8BDD sessionId>
|
|
99
99
|
</coze-context>
|
|
100
100
|
|
|
101
|
-
\u4ECE\u4E2D\u63D0\u53D6\u4E24\u4E2A ID, \u7528 bash tool \u8C03 (
|
|
102
|
-
\
|
|
101
|
+
\u4ECE\u4E2D\u63D0\u53D6\u4E24\u4E2A ID, \u7528 bash tool \u8C03 \`coze-bridge\` (daemon \u5DF2\u628A\u5B83\u524D\u7F6E\u5230\u5B50\u8FDB\u7A0B PATH,
|
|
102
|
+
\u8DE8\u5E73\u53F0\u76F4\u63A5\u88F8\u547D\u4EE4\u8C03\u7528, \u65E0\u9700\u7EDD\u5BF9\u8DEF\u5F84):
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
coze-bridge send image <path> --agent-id <agentId> --session-id <sessionId> [--caption "\u8BF4\u660E\u6587\u5B57"]
|
|
105
|
+
coze-bridge send file <path> --agent-id <agentId> --session-id <sessionId> [--caption "..."] [--name "report.pdf"]
|
|
106
106
|
|
|
107
107
|
\u7EA6\u675F:
|
|
108
108
|
- path \u5FC5\u987B\u5728\u5F53\u524D workspace \u5B50\u6811\u4E0B (\u7EDD\u5BF9\u6216\u76F8\u5BF9\u7686\u53EF)
|
|
@@ -113,29 +113,30 @@ ${mf}`}var mf=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
|
113
113
|
- \`sessionId\` \u5FC5\u987B\u7528\u4E91\u7AEF \`<coze-context>\` \u7ED9\u7684 ID, **\u4E0D\u8981**\u81EA\u5DF1\u7F16\u6216\u8005\u7528\u5176\u5B83\u6765\u6E90
|
|
114
114
|
|
|
115
115
|
\u26A0\uFE0F \u751F\u6210\u6587\u4EF6\u540E\u8BF7**\u7B49\u6587\u4EF6\u5B8C\u6574\u5199\u76D8**\u518D send (\u7528 \`&&\` \u4E32\u884C, \u4E0D\u8981 \`&\` \u540E\u53F0)\u3002
|
|
116
|
-
`;var Le=j("agent-detail-sync"),_f=6e4,yf=5*6e4,Wn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let i=this.opts.paths.agentsRoot,o;try{o=await wf(i)}catch(a){Le.info("agents dir not found, skip detail sync",{root:i,err:String(a)});return}Le.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async a=>{let c=await ke(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Le.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(f){Le.warn("detail sync failed for agent, skipping",{agentId:a,err:String(f)})}}})),Le.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),i=[];for(let[o,a]of this.retryQueue)e>=a.dueAt&&i.push(o);if(i.length!==0){Le.info("retrying pending detail syncs",{count:i.length});for(let o of i)try{await this.syncOne(o)}catch(a){Le.debug("detail sync retry still failing, will try again",{agentId:o,err:String(a)})}}}async syncOne(e,i){let o=i??await ke(e,this.opts.paths);if(!o){Le.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(x){Le.warn("detail RPC failed, using local data",{agentId:e,err:String(x)});let g=this.retryQueue.get(e),p=g?Math.min(g.currentDelay*2,yf):_f;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(a.agentId&&a.agentId!==e){Le.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let c=!1,f=!1;if(a.agentName&&a.agentName!==o.agentName&&(o.agentName=a.agentName,c=!0),a.description!==void 0&&a.description!==o.description&&(o.description=a.description,c=!0),a.cozeIdentity&&a.cozeIdentity!==o.cozeIdentity&&(o.cozeIdentity=a.cozeIdentity,c=!0,f=!0),a.deployType&&Le.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Le.debug("detail sync: no diff",{agentId:e});return}await Re(o,this.opts.paths),Le.info("detail sync: config updated",{agentId:e,identityChanged:f,agentName:o.agentName}),f&&(await zt(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var fa=je(Go(),1);ut();import{spawn as aa}from"node:child_process";import{lstat as Ii,mkdir as Ci,readFile as ca,readdir as Hf,rm as Gf,stat as jf,writeFile as Ai}from"node:fs/promises";import{dirname as Kf,join as Je,normalize as Wf,relative as Pi,resolve as Ti,sep as da}from"node:path";var Ke={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function gn(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function jo(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ko(n){let e=n?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Wo(n){let{_meta:e,...i}=n;return{stripped:i,meta:e}}function Ht(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var T=class extends Error{code;retriable;cause;constructor(e,i,o){super(i),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};Y();Ae();function et(n,e){if(gn(n)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Yn(n){return n.startsWith("http://")||n.startsWith("https://")}function Xn(n){return n.endsWith("/")?n.slice(0,-1):n}Y();var Qn="1008033",Jo="1289";var $o="pbbp2",Vo="https://www.coze.cn",Zo="/api/coze_claw/resource/get_frontier_key",Uf="https://www.coze.cn",qf="wss://frontier.coze.cn";function er(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??Uf}function Yo(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??qf}function Gt(n){let e={},i=n?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,o=n?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return i&&(e["x-tt-env"]=i),o&&(e["x-use-ppe"]=o),e}function pn(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var hn=j("handshake");async function Ei(n){let e=er(n.endpoint),i=n.timeoutMs??1e4,o=`${Xn(e)}${Zo}?aid=${encodeURIComponent(Qn)}`,a={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...Gt(n.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),i);hn.info("frontier key handshake",{base:e});try{let x=await fetch(o,{method:"GET",headers:a,signal:c.signal}),g=x.headers.get("x-tt-logid")??"",p=x.headers.get("x-tt-trace-id")??"";if(!x.ok){let b=await x.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${x.status} logid=${g}: ${b.slice(0,200)}`)}let y=await x.json();if(y.code!==void 0&&y.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${y.code} msg=${y.msg??"-"} logid=${g}`);let v=y.data??{},A=typeof v.access_key=="string"&&v.access_key||typeof v.accessKey=="string"&&v.accessKey||void 0,E=typeof v.device_id=="string"&&v.device_id||typeof v.deviceId=="string"&&v.deviceId||void 0;if(!A||!E){let b=JSON.stringify(y).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${g}: ${b}`)}return hn.info("handshake ok",{remoteDeviceId:E,logid:g,traceId:p}),{accessKey:A,deviceId:E}}catch(x){if(x instanceof T)throw hn.error("handshake failed (bridge error)",{base:e,message:x.message,code:x.code}),x;if(x.name==="AbortError")throw hn.warn("handshake timeout",{base:e,timeoutMs:i}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${i}ms)`,{cause:x});let g=x.cause;throw hn.error("handshake error",{base:e,message:x instanceof Error?x.message:String(x),errno:g?.code,syscall:g?.syscall,cause:String(x).slice(0,300)}),new T("UPSTREAM_HANDSHAKE_FAILED",String(x),{cause:x})}finally{clearTimeout(f)}}var bi=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",We="auto";function Xo(n){return{model:n.model??We,...n.modelToken?{modelToken:n.modelToken}:{}}}function Qo(n){return!n||n===We}function ea(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=bi,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||We,n.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(n.modelInfo.contextWindow))):Qo(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function ta(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||We}"`):Qo(n.model)||e.push("-c",`model="${n.model}"`),n.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${bi}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"'),n.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${n.modelInfo.contextWindow}`)),e}function na(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function vi(n,e){let{ttEnv:i,usePpe:o}=pn(n),a={};return i&&(a["x-tt-env"]=i),o&&(a["x-use-ppe"]=o),e&&(a["x-mock-scenario"]=e),a}function ra(n,e,i){if(!n.modelToken)return{};let o=vi(e,i);return Object.keys(o).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(o).map(([c,f])=>`${c}:${f}`).join(`
|
|
117
|
-
`)}}function Si(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function ia(n,e,i){if(!n.modelToken)return null;let o=n.model||We,a=vi(e,i),c=["text"];n.modelInfo?.capabilities?.image===!0&&c.push("image");let f={baseUrl:`${bi}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:o,name:o,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(a).length>0&&(f.headers=a),f}function sa(n,e,i){if(!n.modelToken)return[];let o=vi(e,i),a=[];for(let[c,f]of Object.entries(o))a.push("-c",`model_providers.coze.http_headers.${c}="${f}"`);return a}var be=j("agent-handlers"),oa=5*1024*1024,Jf=1,$f=6,Vf=new Set(["node_modules",".git",".coze","dist","build",".next"]),tr=class{constructor(e){this.opts=e}opts;async listSkills(e){et(e._meta,"_agent/listSkills");let i=Ht(e._meta),o=await this.loadAgentCfg(i),a=o?.workspace??Qe(i).workspace,c=o?.skills??[],f=[];for(let x of c){let g=Je(a,x.relPath,"SKILL.md");await jf(g).then(y=>y.isFile()).catch(()=>!1)&&f.push(eu(x))}return{skills:f}}async addSkills(e){et(e._meta,"_agent/addSkills");let i=Ht(e._meta),o=await this.requireAgentCfg(i),a=e.skills??[],c=[...o.skills??[]],f=new Map(c.map((g,p)=>[g.skillId,p])),x=[];for(let g of a){let p=await ki({agentId:i,workspace:o.workspace,framework:o.framework,skill:g});Ni(c,f,p),x.push(g)}return await jn(i,c),this.reloadAgentSessions(i,"skills-added"),{installedSkills:x}}async removeSkills(e){et(e._meta,"_agent/removeSkills");let i=Ht(e._meta),o=await this.requireAgentCfg(i),a=new Set(e.skillIds??[]),c=o.skills??[],f=[];for(let x of c){if(!a.has(x.skillId)){f.push(x);continue}let g=Je(o.workspace,x.relPath);await Gf(g,{recursive:!0,force:!0}),be.info("skill removed",{agentId:i,skillId:x.skillId,relPath:x.relPath})}return await jn(i,f),this.reloadAgentSessions(i,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,i){this.reloadAgentSessions(e,i)}reloadAgentSessions(e,i){let o=this.opts.agents.get(e);if(o)for(let[a,c]of o.sessions){if(!c.downstream)continue;let f=c.acpSessionId;if(f&&o.activeTriggers.has(f)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,be.info("downstream busy, scheduling reload after turn",{reason:i,agentId:e,framework:o.framework,cloudId:a,acpId:f});continue}let g=c.downstream;c.downstream=void 0,be.info("killing downstream for workspace reload (idle)",{reason:i,agentId:e,framework:o.framework,cloudId:a,acpId:f}),g.stop(i).catch(p=>be.warn("downstream stop failed during reload (ignored)",{reason:i,agentId:e,cloudId:a,err:String(p)}))}}isRuntimePendingPermission(e){let i=this.opts.isRuntimePendingPermission;return!i||!e.downstream?!1:i(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return be.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let i=e.agentId,o=await ke(i);if(!o)throw new T("AGENT_NOT_FOUND",`agent not found: ${i}`);if(o.cozeIdentity===e.cozeIdentity)return be.info("_agent/update: cozeIdentity unchanged, noop",{agentId:i}),{ok:!0};try{await zt(o.workspace,o.framework,i,e.cozeIdentity)}catch(a){throw be.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:i,framework:o.framework,workspace:o.workspace,err:String(a)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${i}: ${String(a)}`,{cause:a})}return o.cozeIdentity=e.cozeIdentity,await Re(o),be.info("_agent/update: cozeIdentity rewritten",{agentId:i,framework:o.framework}),this.reloadAgentSessions(i,"identity-changed"),{ok:!0}}async disconnectAgent(e){let i=e.agentId;if(!i)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await ke(i);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Re(o),be.info("agent disconnected",{agentId:i,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(i,e.reason??"disconnect"),{ok:!0}):(be.warn("_agent/disconnect: agent not found, ignoring",{agentId:i}),{ok:!0})}async switchModel(e){if(et(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let i=e.model?.trim()?e.model:We,o=await ke(e.agentId);if(!o)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=i,e.modelInfo&&(o.modelInfo=e.modelInfo),await Re(o),be.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:i,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return be.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=i,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(f=>be.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(f)}));let c=[];for(let[f,x]of a.allSessionQueues())c.push(x.enqueue(async()=>{let g=a.sessions.get(f);g?.downstream&&(await g.downstream.stop(`switchModel: ${i}`).catch(()=>{}),g.downstream=void 0)}));return await Promise.all(c),be.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:i,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(et(e._meta,Ke.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${Ke.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Ke.RESET,e.reason),{ok:!0}}async repairAgent(e){if(et(e._meta,Ke.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${Ke.REPAIR}: missing agentId`);let i=await this.loadAgentCfg(e.agentId);if(i&&i.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${Ke.REPAIR} only allowed for openclaw, got ${i.framework}`);if(i&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,i.workspace)}catch(o){be.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Ke.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,i,o){if(!this.opts.detailSyncer){be.warn("detailSyncer not wired, skipping sync",{method:i,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){be.warn("detail sync failed (ignored)",{method:i,agentId:e,reason:o,err:String(a)})}}async getFileTree(e){et(e._meta,"_agent/getFileTree");let i=e._meta,o=Ht(i),a=await this.resolveWorkspace(o),c=e.filePath??"",f=this.safeJoin(a,c),x=await Ii(f).catch(()=>null);if(!x)throw new T("IPC_BAD_REQUEST",`path not found: ${c}`);if(x.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);let g=uu(e.depth);return x.isDirectory()?{tree:await fu(a,f,c,g)}:{tree:[{name:xu(c),path:xa(c||"."),isDir:!1,size:x.size,modifiedAt:Math.floor(x.mtimeMs)}]}}async getFileContent(e){et(e._meta,"_agent/getFileContent");let i=Ht(e._meta),o=await this.resolveWorkspace(i);if(!e.filePath)throw new T("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(o,e.filePath),c=await Ii(a).catch(()=>null);if(!c||!c.isFile())throw new T("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(c.size>oa)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${oa})`);let f=await ca(a);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:c.size}:{content:f.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let i=this.opts.agents.get(e);return i?i.workspace:(await ke(e).catch(()=>null))?.workspace??Qe(e).workspace}safeJoin(e,i){let o=Ti(e,i||"."),a=Pi(e,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${da}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${i}`);return o}loadAgentCfg(e){return ke(e)}async requireAgentCfg(e){let i=await this.loadAgentCfg(e);if(!i)throw new T("AGENT_NOT_FOUND",`no config for agent: ${e}`);return i}};function Zf(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new T("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new T("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Yf(n){return n==="claude-code"?Je(".claude","skills"):Je(".agents","skills")}var Xf=3e4,Qf=50*1024*1024,nr=3e4;async function ki(n){let{agentId:e,workspace:i,framework:o,skill:a}=n;if(!a.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let c=typeof a.content=="string"&&a.content.length>0,f=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!c&&!f)throw new T("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let x=Zf(a.skillName),g=Yf(o),p=Je(g,x),y=Je(i,p);if(await Ci(y,{recursive:!0}),c){let A=Buffer.from(a.content,"utf8");mn(A.length),await Ai(Je(y,"SKILL.md"),A,"utf8")}else{let A=await tu(a.downloadUrl);ru(A)?await au(A,y):iu(A)?await su(A,y):await Ai(Je(y,"SKILL.md"),A.toString("utf8"),"utf8")}let v={skillId:a.skillId,skillName:a.skillName,relPath:p,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return be.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:p,source:c?"content":"downloadUrl"}),v}function Ni(n,e,i){let o=e.get(i.skillId);if(o!==void 0){n[o]=i;return}e.set(i.skillId,n.length),n.push(i)}function eu(n){return{skillId:n.skillId,skillName:n.skillName,...n.description?{description:n.description}:{},...n.icon?{icon:n.icon}:{},...n.version?{version:n.version}:{},...n.config?{config:n.config}:{},...n.builtin?{builtin:n.builtin}:{}}}async function tu(n){if(!n)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);mn(e);let i=nu(n);return mn(i.length),i}if(n.startsWith("file:")){let e=new URL(n).pathname,i=await ca(e);return mn(i.length),i}if(Yn(n)){let e=new AbortController,i=setTimeout(()=>e.abort(),Xf);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let a=await o.arrayBuffer();return mn(a.byteLength),Buffer.from(a)}finally{clearTimeout(i)}}throw new T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function mn(n){if(n>Qf)throw new T("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function nu(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let i=!!e[2],o=e[3]??"";return i?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function ru(n){return n.length>=2&&n[0]===31&&n[1]===139}function iu(n){if(n.length<4||n[0]!==80||n[1]!==75)return!1;let e=n[2],i=n[3];return e===3&&i===4||e===5&&i===6}function Di(n){return n==="__MACOSX"||n.startsWith("__MACOSX/")}async function su(n,e){let i,o;try{i=new fa.default(n),o=i.getEntries()}catch(f){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of o){let x=f.entryName;if(!x||Di(x))continue;if(x.startsWith("/")||/^[A-Za-z]:[\\/]/.test(x))throw new T("IPC_BAD_REQUEST",`zip entry absolute path: ${x}`);if(x.split(/[/\\]/).some(p=>p===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${x}`);let g=f.header.attr>>>16&61440;if(g!==0&&g!==32768&&g!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${g.toString(16)} not allowed (symlink/hardlink/special): ${x}`)}let a=ou(o),c=Ti(e);for(let f of o){if(Di(f.entryName))continue;let x=f.entryName;if(a&&x.startsWith(a)&&(x=x.slice(a.length)),!x)continue;let g=Ti(e,x),p=Pi(c,g);if(p.startsWith("..")||p==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${x}`);if(f.isDirectory){await Ci(g,{recursive:!0});continue}await Ci(Kf(g),{recursive:!0});let y;try{y=f.getData()}catch(v){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${v.message}`,{cause:v})}await Ai(g,y)}}function ou(n){let e;for(let i of n){let o=i.entryName;if(!o||Di(o))continue;let a=o.indexOf("/");if(a<=0)return;let c=o.slice(0,a+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function au(n,e){await cu(n),await new Promise((i,o)=>{let a=aa("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),c="";a.stderr?.on("data",x=>{c+=String(x)});let f=setTimeout(()=>{a.kill("SIGKILL"),o(new T("IPC_BAD_REQUEST",`tar extract timeout (${nr}ms)`))},nr);a.on("error",x=>{clearTimeout(f),o(new T("IPC_BAD_REQUEST",`tar spawn failed: ${x.message}`,{cause:x}))}),a.on("exit",x=>{clearTimeout(f),x===0?i():o(new T("IPC_BAD_REQUEST",`tar exit ${x}${c?`: ${c.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)})}async function cu(n){let e=await new Promise((i,o)=>{let a=aa("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),c="",f="";a.stdout?.on("data",g=>{c+=String(g)}),a.stderr?.on("data",g=>{f+=String(g)});let x=setTimeout(()=>{a.kill("SIGKILL"),o(new T("IPC_BAD_REQUEST",`tar list timeout (${nr}ms)`))},nr);a.on("error",g=>{clearTimeout(x),o(new T("IPC_BAD_REQUEST",`tar list spawn failed: ${g.message}`))}),a.on("exit",g=>{clearTimeout(x),g===0?i(c):o(new T("IPC_BAD_REQUEST",`tar list exit ${g}${f?`: ${f.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)});for(let i of e.split(`
|
|
118
|
-
`)){let o=i.trim();if(!o)continue;let a=o.charCodeAt(0);if(a!==45&&a!==100)throw new T("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let f=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!f)continue;if(f.startsWith("/"))throw new T("IPC_BAD_REQUEST",`tar entry absolute path: ${f}`);if(f.split(/[/\\]/).some(g=>g===".."))throw new T("IPC_BAD_REQUEST",`tar entry contains '..': ${f}`)}}var du=5e3;async function fu(n,e,i,o){return ua(n,e,i,o,{count:0})}async function ua(n,e,i,o,a){if(o<=0)return[];let c;try{c=await Hf(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let x of c){if(Vf.has(x.name)||x.isSymbolicLink())continue;if(a.count>=du){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let g=Je(e,x.name),p=Wf(Je(i,x.name)),y=null;try{y=await Ii(g)}catch{continue}if(y.isSymbolicLink())continue;a.count++;let v={name:x.name,path:xa(Pi(n,g)),isDir:y.isDirectory(),size:y.size,modifiedAt:Math.floor(y.mtimeMs)};y.isDirectory()&&o>1&&(v.children=await ua(n,g,p,o-1,a)),f.push(v)}return f.sort((x,g)=>x.isDir!==g.isDir?x.isDir?-1:1:x.name.localeCompare(g.name)),f}function uu(n){return!n||n<=0?Jf:Math.min(n,$f)}function xu(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function xa(n){return n.split(da).join("/")}Y();import{readFileSync as vm}from"node:fs";import{dirname as Im,join as Cm}from"node:path";import{fileURLToPath as Tm}from"node:url";var jt="0.1.73";var lt=j("agent-health-reporter"),lu=1e4,wn=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??lu}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),lt.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),lt.info("heartbeat stopped"))}async tick(){if(this.inFlight){lt.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){lt.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let i=[];for(let f of this.opts.core.agents.values()){let x=gu(f);if(!x)continue;let g={agentId:f.agentId,status:x};f.patToken&&(g.patToken=f.patToken),f.accountId&&(g.accountId=f.accountId),i.push(g)}if(i.length===0)return;let o={agents:i,bridgeVersion:jt,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(f){lt.warn("heartbeat batch send failed",{count:i.length,err:String(f)})}let c=a?.authFailures;if(c&&c.length>0&&(lt.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(f){lt.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(i){lt.warn("onTickEnd hook failed",{err:String(i)})}}};function gu(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}ut();import{mkdir as Oi,rm as Vu}from"node:fs/promises";vt();vt();import{spawn as bu,spawnSync as vu}from"node:child_process";function _n(n,e,i){return i===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:i}}function yn(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Kt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function gt(n,e){return{jsonrpc:"2.0",id:n,error:e}}var rr=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Z={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function la(n){return"method"in n&&"id"in n&&n.id!==void 0}function ga(n){return"method"in n&&!("id"in n)}function ir(n){return!("method"in n)&&"id"in n}var hu={AGENT_NOT_FOUND:Z.AGENT_NOT_FOUND,AGENT_BUSY:Z.AGENT_BUSY,AGENT_DISCONNECTED:Z.AGENT_DISCONNECTED,AGENT_TIMEOUT:Z.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Z.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Z.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Z.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Z.INTERNAL_ERROR,BRIDGE_INTERNAL:Z.INTERNAL_ERROR,IPC_AUTH_FAILED:Z.INTERNAL_ERROR,IPC_BAD_REQUEST:Z.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Z.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Z.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Z.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Z.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Z.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Z.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Z.FILE_TOO_LARGE,UNSUPPORTED_MIME:Z.UNSUPPORTED_MIME,UPLOAD_FAILED:Z.UPLOAD_FAILED,UPSTREAM_NOT_READY:Z.UPSTREAM_NOT_READY,NPX_CACHE_CORRUPT:Z.INTERNAL_ERROR};function pu(n){if(n!=null)return n instanceof Error?{name:n.name,message:En(n.message)}:typeof n=="string"?En(n):typeof n=="object"?wu(n):n}var mu=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function En(n){let e=n;for(let[i,o]of mu)e=e.replace(i,o);return e}function wu(n){let e={};for(let[i,o]of Object.entries(n))typeof o=="string"?e[i]=En(o):e[i]=o;return e}function bn(n){if(n instanceof T){let e=pu(n.cause),i={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(i.cause=e),{code:hu[n.code]??Z.INTERNAL_ERROR,message:En(n.message),data:i}}return{code:Z.INTERNAL_ERROR,message:En(n instanceof Error?n.message:String(n))}}function ha(n){let e=n.data,i=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",o=!!e&&typeof e.message=="string"&&!!e.message,a=o?e?.message:n.message,c=n.data;if(o&&e){let{message:f,...x}=e;c=x}return new T(i,a,{retriable:e?.retriable??!1,cause:c})}function ma(n){return`${JSON.stringify(n)}
|
|
119
|
-
`}var pa=10*1024*1024,sr=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>pa){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${pa} bytes`)}),[]}let i=this.buffer.split(`
|
|
120
|
-
`);this.buffer=i.pop()??"";let o=[];for(let a of i){let c=a.replace(/\r$/,"").trim();if(c)try{o.push(JSON.parse(c))}catch(f){this.onError?.({line:c,error:f})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(i){return this.onError?.({line:e,error:i}),[]}}};var _a={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},Fm=Object.fromEntries(Object.entries(_a).map(([n,e])=>[e,n])),_u={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Wt=class{seq=0;next(e,i){this.seq+=1;let o=_a[e]??yu(e),a=_u[o]??[],c=[o,String(this.seq)];if(a.length>0){let f=a.map(g=>wa(i?.[g]??"")),x=Eu(f).join(":");x&&c.push(x)}else i&&Object.values(i).some(f=>f)&&c.push(Object.values(i).filter(Boolean).map(f=>wa(String(f))).join(":"));return c.join("_")}reset(){this.seq=0}};function yu(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function wa(n){return n.replace(/[:_\s]+/g,"-")}function Eu(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function ht(n,e){let i=process.env[n];if(!i)return e;let o=Number(i);return Number.isFinite(o)&&o>0?o:e}Y();var Su=ht("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Iu=200,Cu=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function Ri(n){return n.some(e=>Cu.test(e))}var Au=ht("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Tu=ht("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),ya=500;function Du(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=ya?n:`${e.slice(0,ya)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Ea(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let i=["/PID",String(n),"/T"];e==="SIGKILL"&&i.push("/F"),vu("taskkill",i,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var $e=class{constructor(e){this.opts=e;this.log=j(`downstream.${this.constructor.name}`),this.decoder=new sr({onError:i=>this.log.warn("decode line failed",{line:i.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Wt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",i=bu(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let a of this.decoder.push(o))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let a=o.trimEnd();this.stderrRing.push(a),this.stderrRing.length>Iu&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,a)=>{this.stopped=!0,(o!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&Ri(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),Et(this.framework).catch(x=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(x)})})));try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(new T("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${a})`));for(let f of this.exitHandlers)f(o,a)}),i.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new T("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let i=this.child,o=new Promise(c=>i.once("exit",()=>c()));Ea(i.pid,"SIGTERM");let a=setTimeout(()=>{i.killed||Ea(i.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,i=Au,o=Tu){return this.call("session/prompt",e,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(yn("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,i){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Kt(e,i))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,i){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(gt(e,i))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,i,o=Su,a=0){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),f=_n(c,e,i),x=(()=>{if(typeof i!="object"||i===null)return;let y=i.sessionId;return typeof y=="string"?y:void 0})(),g=o>0&&Number.isFinite(o),p=a>0&&Number.isFinite(a);return new Promise((y,v)=>{let A={resolve:y,reject:v,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};g&&(A.timer=setTimeout(()=>{this.pending.delete(c),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:o,...x?{sessionId:x}:{}}),v(new T("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o));let E=p?()=>{A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),A.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...x?{sessionId:x}:{}}),E?.();return}A.timer&&clearTimeout(A.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:a,...x?{sessionId:x}:{}}),v(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;A.armFrameIdle=E,this.pending.set(c,A),E?.();try{this.writeFrame(f)}catch(b){A.timer&&clearTimeout(A.timer),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.pending.delete(c),v(b)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(ma(e),i=>{i&&this.log.warn("stdin write callback err",{err:String(i)})})}dispatch(e){if(ir(e)){let i=e.id!==null?this.pending.get(e.id):void 0;if(!i){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),i.timer&&clearTimeout(i.timer),i.frameIdleTimer&&clearTimeout(i.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:i.method,code:e.error.code,message:e.error.message,data:e.error.data}),i.reject(ha(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:i.method}),i.reject(new T("AGENT_PROTOCOL_ERROR",`${i.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:i.method,result:Du(e.result)}),i.resolve(e.result));return}if(ga(e)){if(e.method==="session/update"){for(let i of this.pending.values())i.armFrameIdle?.();for(let i of this.updateHandlers)try{Promise.resolve(i(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(la(e)){let i=e;try{this.handleAgentRequest(i).catch(o=>this.log.error("agent request handler failed (async)",{method:i.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:i.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(gt(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let i of this.agentRequestHandlers)try{await i(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(gt(e.id,bn(o)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let i of this.pending.values())i.timer&&clearTimeout(i.timer),i.frameIdleTimer&&clearTimeout(i.frameIdleTimer),i.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var Pu=xn("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function ku(n){let e={};for(let[i,o]of Object.entries(n))o!==void 0&&(i.startsWith("CLAUDE")||i==="AI_AGENT"||i==="BAGGAGE"||(e[i]=o));return e}var or=class extends $e{framework="claude-code";constructor(e){let i=bt("claude-code"),[o,a]=i?[i,[]]:["npx",["-y",Pu]],c=e.command??o,f=e.args??a,x={command:c,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(x)}sanitizeEnv(e){return ku(e)}};vt();import{mkdtempSync as Nu,rmSync as Ru}from"node:fs";import{tmpdir as Lu}from"node:os";import{join as Ou}from"node:path";var Mu=xn("codex")??"@zed-industries/codex-acp@^0.15",ar=class extends $e{framework="codex";authMethodId;codexHomeDir;constructor(e){let i=bt("codex"),[o,a]=i?[i,[]]:["npx",["-y",Mu]],c=e.command??o,f=e.args??a,x=e.extraArgs?[...f,...e.extraArgs]:f,g=e.isolateCodexHome?Nu(Ou(Lu(),"coze-bridge-codex-home-")):void 0,p=g?{...e.env??{},CODEX_HOME:g}:e.env,y={command:c,args:x,cwd:e.cwd,...p?{env:p}:{}};super(y),this.authMethodId=e.authMethodId,this.codexHomeDir=g}async initialize(e){let i=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),i}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Ru(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Bu=3e4,Jt=class extends $e{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let i=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${i}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let a={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),this.agentId=e.agentId,this.sessionName=i,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Bu))}get acpSessionName(){return this.sessionName}};Y();Ae();function Li(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}vt();var $t=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((i,o)=>{this.slots.push({task:e,resolve:i,reject:o}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let i=await e.task();e.resolve(i)}catch(i){e.reject(i)}}}finally{this.running=!1}}}};var cr=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let i=this.sessionQueues.get(e);return(!i||i.isDisposed)&&(i=new $t,this.sessionQueues.set(e,i)),i}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let i=this.sessionQueues.get(e);return!!i&&!i.isDisposed}async dispose(e){this.status="stopped";let i=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(i);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let i=[];for(let[,o]of this.sessions)vn(o),o.downstream&&(i.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(i),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function vn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}Y();import{spawn as zu}from"node:child_process";import{constants as ba,access as Fu}from"node:fs/promises";import{delimiter as Uu,join as qu}from"node:path";var pt=j("framework-detector"),va={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Hu=[".exe",".cmd",".bat",".ps1"],mt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??zu,access:e.access??Fu}}async detect(e){let i=va[e],o=await this.which(i);if(!o)return pt.debug("framework binary not found",{framework:e,bin:i}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[c,f]=await Promise.all([this.probeVersion(o,a),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),x={path:o,version:c};return f&&(x.defaultAgent=f),x}async detectAll(){let e=await Promise.all(Object.keys(va).map(async o=>[o,await this.detect(o)])),i={};for(let[o,a]of e)a&&(i[o]=a);return i}async which(e){let i=this.env.pathEnv.split(Uu).filter(Boolean),o=this.env.platform==="win32"?["",...Hu]:[""];for(let a of i)for(let c of o){let f=qu(a,e+c);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let i=this.env.platform==="win32"?ba.F_OK:ba.X_OK;return await this.env.access(e,i),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let i=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!i)return pt.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(i.code!==0)return pt.warn("openclaw default agent probe: non-zero exit",{path:e,code:i.code,stdoutHead:i.stdout.slice(0,200)}),null;let o=i.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!o)return pt.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:i.stdout.slice(0,200)}),null;try{let a=JSON.parse(o[0]);if(!Array.isArray(a))return pt.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=a.find(f=>f?.isDefault===!0);return c?!c.id||!c.workspace?(pt.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(pt.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:a.length}),null)}catch(a){return pt.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(a),matchHead:o[0].slice(0,200)}),null}}async probeVersion(e,i=[]){let o=await this.runProbe(e,[...i,"--version"]);return o&&(ju(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,i){return new Promise(o=>{let a="",c=!1,f,x=g=>{c||(c=!0,f&&clearTimeout(f),o(g))};try{let g=this.env.spawn(e,i,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{g.kill("SIGKILL"),x(null)},15e3),g.stdout?.on("data",p=>{a+=p.toString("utf8")}),g.on("error",()=>x(null)),g.on("close",p=>x({code:p,stdout:a}))}catch{x(null)}})}},Gu=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function ju(n){return n.replace(Gu,"")}import{spawn as Ku}from"node:child_process";import{homedir as Wu}from"node:os";import{join as Ju}from"node:path";Hn();Y();async function Ca(){let n=Ju(Wu(),".openclaw/openclaw.json");return(await Bt(n))?.gateway?.auth?.token??""}var Sa=j("openclaw.config"),$u=[0,5e3,5e3],Ia="models.providers.",dr="agents.defaults.models",fr=class{command;env;retryDelaysMs;queue=new $t;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??$u}async withRetry(e,i){let o;for(let a=0;a<this.retryDelaysMs.length;a++){let c=this.retryDelaysMs[a]??0;c>0&&await new Promise(f=>setTimeout(f,c));try{return await i()}catch(f){o=f,Sa.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(f)})}}throw new T("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((i,o)=>{let a=Ku(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",o),a.on("close",f=>{f===0?i():o(new Error(`exit ${f}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,i){try{await this.runCli(e)}catch(o){let a=String(o);if(i.some(c=>a.includes(c)))return;throw o}}async bestEffortUnset(e,i){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",i])))}catch(o){Sa.warn(`${e} failed (best-effort)`,{configPath:i,err:String(o)})}}ensureProvider(e,i){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${Ia}${e}`,JSON.stringify(i),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Ia}${e}`)}addModelToAllowlist(e,i){let o={[e]:i?{alias:i}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${dr}[${e}]`,()=>this.runCli(["config","set",dr,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${dr}[${e}]`,`${dr}.${e}`)}ensureAgent(e,i,o){let a=["agents","add",e,"--workspace",i,"--non-interactive"];return o&&a.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var ve=j("agent-manager"),Zu=(n,e,i,o,a,c,f,x,g)=>{switch(n){case"claude-code":{let p={...a?{...ea(a),...ra(a,f,x)}:{},...g??{},IS_SANDBOX:"1"};return new or({cwd:i,env:p})}case"codex":{let y=[...a?[...ta(a),...sa(a,f,x)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],v={...a?na(a):{},...g??{}},A=!!a;return new ar({cwd:i,...y.length>0?{extraArgs:y}:{},...Object.keys(v).length>0?{env:v}:{},...A?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Jt({command:e,cwd:i,agentId:o,...c?{sessionName:Li(c)}:{}})}};function Mi(n){return n==="claude-code"||n==="codex"}var Yu={path:"",version:"cloud-deployed"},Xu={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Qu=6e4,ex=ht("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),ur=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Zu,this.createTimeoutMs=e.createTimeoutMs??Qu,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??ex,this.detectorFactory=e.detectorFactory??(()=>new mt)}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new fr({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=gn(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")ve.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(b=>ve.warn("dispose stale agent failed (ignored)",{err:String(b)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){ve.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let b=await ke(e.agentId,this.paths).catch(()=>null);b&&(b.patToken=e.patToken,await Re(b,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){ve.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let b=await ke(e.agentId,this.paths).catch(()=>null);b&&(b.modelInfo=e.modelInfo,await Re(b,this.paths))}return ve.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Qe(e.agentId,this.paths),f=gn(e._meta),x=e.framework==="openclaw"&&f==="local",g=x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??g??c.workspace,y=new AbortController,v=setTimeout(()=>y.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,E=!1;try{i&&Mi(e.framework)&&await Et(e.framework,y.signal);let b=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await Oi(c.root,{recursive:!0}),await Oi(p,{recursive:!0}),await Oi(c.logs,{recursive:!0}),b(),x||await zt(p,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await fo(p),b();let I=await ke(e.agentId,this.paths).catch(()=>null),S=Xo({model:e.model??I?.model}),D=jo(e._meta)??I?.accountId,O=e.patToken??I?.patToken,m=f==="cloud"?e.modelInfo??I?.modelInfo:void 0;if(A=new cr({agentId:e.agentId,framework:e.framework,workspace:p,model:S.model??We,deployType:f,...D?{accountId:D}:{},...O?{patToken:O}:{},...m?{modelInfo:m}:{}}),A.status="ok",I?.sessions){for(let[B,P]of Object.entries(I.sessions))A.sessions.set(B,{acpSessionId:P.acpSessionId,modelToken:P.modelToken,tokenGeneratedAt:P.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(I.sessions).length;F>0&&ve.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(A),E=!0;let C={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:I?.createdAt??Date.now(),sessions:I?.sessions??{},model:S.model};f==="cloud"&&(C.deployType="cloud"),D&&(C.accountId=D),O&&(C.patToken=O),m&&(C.modelInfo=m),I?.skills&&(C.skills=I.skills),I?.agentName&&(C.agentName=I.agentName),I?.description&&(C.description=I.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,p):ve.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let k=e.initialSkills??[];if(k.length>0){let F=[...C.skills??[]],B=new Map(F.map((U,J)=>[U.skillId,J])),P=await Promise.allSettled(k.map(U=>ki({agentId:e.agentId,workspace:p,framework:e.framework,skill:U}))),M=0;for(let[U,J]of P.entries()){let ne=k[U];ne&&(J.status==="fulfilled"?(Ni(F,B,J.value),M++):ve.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:ne.skillId,skillName:ne.skillName,err:String(J.reason)}))}M>0&&(C.skills=F,ve.info("initialSkills installed",{agentId:e.agentId,installed:M,requested:k.length}))}return await Re(C,this.paths),ve.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:p,framework:e.framework}}catch(b){throw ve.error("agent create failed, rolling back",{agentId:e.agentId,err:String(b)}),E&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Vu(c.root,{recursive:!0,force:!0}).catch(I=>ve.warn("rm agent dir failed (ignored)",{err:String(I)})),b instanceof T?b:new T("AGENT_SPAWN_FAILED",String(b),{cause:b})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,i,o,a,c){let x=this.config.frameworksCache?.[e.framework];if(!x)if(e.deployType==="cloud"&&Mi(e.framework))x=Yu;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(Mi(e.framework)&&!bt(e.framework)){let y=li(e.framework);y&&(ve.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([y.catch(()=>{}),new Promise(v=>setTimeout(v,this.spawnAwaitInstallMs))]))}let g=e.deployType==="cloud"?{model:e.model,modelToken:i,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:g,cloudSessionId:o,cozeEnv:a,mockScenario:c,command:x.path}):p=this.factory(e.framework,x.path,e.workspace,e.agentId,g,o,a,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(Xu),p}catch(y){let v=p instanceof $e?p.getStderrTail():[];v.length>0&&ve.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:y instanceof T?y.code:"unknown",recentStderr:v});let A=Ri(v);await p.stop("spawnSessionDownstream failed").catch(()=>{});let E=A?new T("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:y}):y;throw y instanceof T?new T(y.code,y.message,{retriable:y.retriable,cause:E}):new T("AGENT_SPAWN_FAILED",y instanceof Error?y.message:String(y),{cause:E})}}async buildOpenclawDownstream(e){let{session:i,modelConfig:o,cloudSessionId:a,cozeEnv:c,mockScenario:f,command:x}=e,g=Li(a);if(i.deployType==="local"){let A=this.config.frameworksCache?.openclaw?.defaultAgent;if(!A?.id||!A.workspace){ve.warn("openclaw default agent stale or missing, attempting lazy re-detect");let b=await this.detectorFactory().detect("openclaw");if(b?.defaultAgent?.id&&b?.defaultAgent?.workspace)ve.info("openclaw lazy re-detect success",{agentId:b.defaultAgent.id,workspace:b.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=b,A=b.defaultAgent;else throw new T("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent")}return new Jt({command:x,cwd:A.workspace,agentId:A.id,sessionName:g})}let p=await Ca(),y=o?ia(o,c,f):null,v;if(y){let A=Si(a),b=y.models[0]?.id??We,I=`${A}/${b}`;if(!this.ensuredProviders.has(I)){let S=this.getOpenclawConfig();await S.ensureProvider(A,y),await S.addModelToAllowlist(I),this.ensuredProviders.add(I)}v=I}return new Jt({command:x,cwd:i.workspace,agentId:i.agentId,sessionName:g,...p?{gatewayToken:p}:{},...v?{slashModelOnStart:v}:{}})}async openclawRepair(e,i){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,i)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let i=this.openclawConfigCache;for(let o of e.sessions.keys()){let a=Si(o),c=`${a}/${e.model}`,f=!0;try{await i.removeProvider(a)}catch(x){f=!1,ve.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(x)})}try{await i.removeModelFromAllowlist(c)}catch(x){f=!1,ve.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(x)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as ka}from"node:crypto";import{promises as ux}from"node:fs";import{basename as Na}from"node:path";import{promises as nx}from"node:fs";import{basename as rx}from"node:path";Y();var Aa=j("file-upload"),ix="/api/coze_claw/file/agent_upload",sx=6e4;async function Ta(n,e={}){let o=`${Xn(er(e.handshakeBase))}${ix}`,a=e.timeoutMs??sx,c=await nx.readFile(n.path),f=new FormData;f.append("agent_id",n.agentId),f.append("session_id",n.sessionId),f.append("file_name",n.name),f.append("file_content",new Blob([c],{type:n.mimeType}),n.name);let x={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Gt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},g=new AbortController,p=setTimeout(()=>g.abort(),a);Aa.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let y=await fetch(o,{method:"POST",headers:x,body:f,signal:g.signal}),v=y.headers.get("x-tt-logid")??"";if(!y.ok){let b=await y.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${y.status} logid=${v}: ${b.slice(0,200)}`)}let A=await y.json();if(A.code!==void 0&&A.code!==0)throw new T("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${v}`);let E=A.data?.file?.file_url;if(!E)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${v}: ${JSON.stringify(A).slice(0,200)}`);return Aa.info("file upload ok",{uri:E,logid:v}),{uri:E}}catch(y){throw y instanceof T?y:y.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${a}ms) for ${rx(n.path)}`):new T("UPLOAD_FAILED",String(y),{cause:y})}finally{clearTimeout(p)}}Y();import{promises as ox}from"node:fs";import{extname as ax}from"node:path";var cx=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function dx(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var fx={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Da(n){let e=await ox.open(n,"r");try{let i=Buffer.alloc(16);if(await e.read(i,0,16,0),dx(i))return"image/webp";for(let o of cx)if(o.prefix.every((a,c)=>i[c]===a))return o.mime}finally{await e.close()}return fx[ax(n).toLowerCase()]??"application/octet-stream"}Ae();var xr=j("agent-send"),Pa=50*1024*1024,xx=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Ra(n,e,i){let o=n.get(e);if(!o)throw new T("AGENT_NOT_FOUND",`agent=${e}`);if(n.disconnectedAgents.has(e))throw new T("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=o.sessions.get(i);if(!a)throw new T("AGENT_NOT_FOUND",`session=${i} not active in agent=${e}`);return{session:o,runtime:a}}async function La(n,e,i,o,a,c){let x;for(let g=0;g<=2;g++)try{await n.core.sendAgentFileUpdate(e,i,o,a);return}catch(p){x=p,g<2&&(xr.warn("sendAgentFileUpdate failed, retrying",{attempt:g+1,err:String(p)}),await new Promise(y=>setTimeout(y,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(x)}`,{cause:x})}async function Oa(n,e){let{session:i,runtime:o}=Ra(e.core,n.agentId,n.sessionId);if(!await so(n.path,i.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${i.workspace}`);let a=await ux.stat(n.path).catch(()=>null);if(!a||!a.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(a.size>Pa)throw new T("FILE_TOO_LARGE",`${a.size} bytes > limit ${Pa}`);let c=await Da(n.path);if(!xx.has(c))throw new T("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(n.kind==="image"&&!c.startsWith("image/"))throw new T("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let f=n.name??Na(n.path),x;try{x=await Ta({patToken:i.patToken??e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:c,name:f,sizeBytes:a.size,...i.accountId?{accountId:i.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw xr.warn("agent file upload failed",{agentId:n.agentId,sessionId:n.sessionId,path:n.path,sizeBytes:a.size,mime:c,code:p instanceof T?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let g={sessionUpdate:"agent_file",messageId:ka(),content:{type:n.kind==="image"?"image":"resource",uri:x.uri,mimeType:c,name:f,sizeBytes:a.size,...x.fileId!==void 0?{fileId:x.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await La(e,i,o,n.sessionId,g,"agent file uploaded to cloud but sendAgentFileUpdate failed"),xr.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:f,bytes:a.size,mime:c,uri:x.uri}),{ok:!0,uri:x.uri,bytes:a.size,mimeType:c,...x.fileId!==void 0?{fileId:x.fileId}:{}}}async function Ma(n,e){let{session:i,runtime:o}=Ra(e.core,n.agentId,n.sessionId);if(!n.mimeType)throw new T("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let a=n.name??Na(n.path),c={sessionUpdate:"group_file",messageId:ka(),content:{uri:n.path,name:a,mimeType:n.mimeType,...n.caption!==void 0?{caption:n.caption}:{}}};return await La(e,i,o,n.sessionId,c,"agent group file sendAgentFileUpdate failed"),xr.info("agent group file sent",{agentId:n.agentId,sessionId:n.sessionId,uri:n.path,name:a,mime:n.mimeType}),{ok:!0,uri:n.path,bytes:0,mimeType:n.mimeType}}import{execFile as lx}from"node:child_process";import{promisify as gx}from"node:util";function Ba(n,e){let i=n.split(".").map(Number),o=e.split(".").map(Number),a=Math.max(i.length,o.length);for(let c=0;c<a;c++){let f=i[c]??0,x=o[c]??0;if(f<x)return!0;if(f>x)return!1}return!1}Y();var hx=gx(lx),Ve=j("coze-cli-installer"),za="@coze/cli@latest",px="coze",Fa="0.1.7",mx=5e3,_x=5e3,yx=9e4,Ua=1e4,Sn=null,lr=!1;async function Bi(n,e={}){if(lr)return;if(Sn)return Sn;let i=e.exec??hx;return Sn=(async()=>{try{let o=await Ex(px,i),a=!1;if(o){let f=await bx(i);if(f===void 0)Ve.warn("coze-cli found but version unparseable, fall through to full install",{path:o});else if(Ba(f,Fa))Ve.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:o,version:f,min:Fa}),a=!0;else{Ve.info("coze-cli already on PATH with sufficient version, skip",{path:o,version:f}),lr=!0;return}}let c=a?"upgrade-only":"full";Ve.info("coze-cli install start",{package:za,mode:c});try{await i("npm",["i","-g","--prefer-online",za],{timeout:yx,maxBuffer:10*1024*1024}),Ve.info("coze-cli install ok")}catch(f){Ve.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(a){lr=!0;return}if(n.env)try{await i("coze",["config","set","xTTEnv",n.env],{timeout:Ua}),Ve.info("coze config set xTTEnv ok",{env:n.env})}catch(f){Ve.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await i("coze",["auth","login","--token",n.patToken],{timeout:Ua}),Ve.info("coze auth login ok")}catch(f){Ve.warn("coze auth login failed",{err:String(f)});return}lr=!0}finally{Sn=null}})(),Sn}async function Ex(n,e){let i=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(i,[n],{timeout:mx});return o.split(`
|
|
121
|
-
`)[0]?.trim()||void 0}catch{return}}async function bx(n){try{let{stdout:e,stderr:i}=await n("coze",["--version"],{timeout:_x});return(e||i).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Hn();Ae();var vx=10*6e4;function qa(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?vx:e}function gr(n){return Bt(n??X().configFile)}function Vt(n,e){return qn(e??X().configFile,n)}import{randomBytes as qx}from"node:crypto";import{createReadStream as Sx}from"node:fs";import{mkdir as Ix,readFile as Cx,realpath as Ax,stat as Tx,writeFile as Dx}from"node:fs/promises";import{basename as Px,dirname as zi,join as kx,relative as Nx,resolve as Ha,sep as Rx}from"node:path";import{createInterface as Lx}from"node:readline";Y();var ja=j("fs-rpc"),In=ht("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Ka(n,e){let i=Buffer.byteLength(n.content,"utf8");if(i>In)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${i} bytes > limit ${In} bytes`);let o=await Ja(n.path,e);return await Ix(zi(o),{recursive:!0}),await Dx(o,n.content,"utf8"),ja.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function Wa(n,e){let i=await Ja(n.path,e),o=await Tx(i),a=typeof n.line=="number"||typeof n.limit=="number";if(o.size>In&&!a)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${In} bytes`);let c;if(a&&o.size>In)c=await Ox(i,n.line??1,n.limit);else{let f=await Cx(i,"utf8");if(a){let x=f.split(`
|
|
122
|
-
`),
|
|
123
|
-
`)
|
|
124
|
-
`)}async function Ja(n,e){if(typeof n!="string"||n.length===0)throw new T("IPC_BAD_REQUEST","path must be a non-empty string");let[i,o]=await Promise.all([Ga(Ha(e)),Ga(Ha(n))]),a=Nx(i,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${Rx}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Ga(n){let e=[],i=n;for(;i!==zi(i);)try{let o=await Ax(i);return e.length?kx(o,...e.reverse()):o}catch{e.push(Px(i)),i=zi(i)}return n}Y();var $a=j("prompt-multimodal"),Va=10*1024*1024,Mx=15e3,Bx=6;async function Za(n){let e=new Array(n.length),i=0;async function o(){for(;i<n.length;){let c=i++,f=n[c];f!==void 0&&(e[c]=await zx(f))}}let a=Array.from({length:Math.min(Bx,n.length)},()=>o());return await Promise.all(a),e}function Ya(n){return n.some(e=>e.type==="image")}async function zx(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Yn(e.uri))return n;try{let{buf:i,contentType:o}=await Ux(e.uri),a=e.mimeType||Fx(o)||"application/octet-stream";return $a.info("image uri fetched and inlined",{uri:e.uri,bytes:i.length,mimeType:a}),{type:"image",data:i.toString("base64"),mimeType:a}}catch(i){return $a.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(i)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Fx(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function Ux(n){let e=new AbortController,i=setTimeout(()=>e.abort(),Mx);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let a=await o.arrayBuffer();if(a.byteLength>Va)throw new Error(`image too large: ${a.byteLength} bytes (max ${Va})`);return{buf:Buffer.from(a),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(i)}}ut();Y();var $=j("core"),Hx=3e4,Gx=/^(boe|ppe)_[A-Za-z0-9_-]+$/,jx=3e4,hr=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Wt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=qa(e.bridgeConfig)}registerExtension(e,i){this.extensions[e]=i}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(i=>i.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let i of this.registerHandlers)try{i(e.agentId)}catch(o){$.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(o)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&$.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,i,o){let a=o.downstream;a&&(a.onUpdate(c=>{o.loadingSession||this.forwardUpdate(e,c)}),a.onAgentRequest(c=>{this.handleAgentRequest(e,a,c)}),a.onExit((c,f)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:i,code:c,signal:f}),vn(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(a,"downstream exited")}))}hasPendingPermissionFor(e){for(let i of this.pendingUpstream.values())if(i.downstream===e)return!0;return!1}rejectPendingForDownstream(e,i){let o=[];for(let[a,c]of this.pendingUpstream)c.downstream===e&&o.push(a);if(o.length!==0){$.info("reject pendingUpstream entries (downstream gone)",{reason:i,count:o.length});for(let a of o){let c=this.pendingUpstream.get(a);if(c){this.pendingUpstream.delete(a),this.upstream.send(gt(a,{code:Z.INTERNAL_ERROR,message:`bridge downstream gone: ${i}`})).catch(f=>$.debug("send error response to upstream failed (ignored)",{err:String(f)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Z.INTERNAL_ERROR,message:`bridge: ${i}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,i=this.pendingBridge.size;if(!(e===0&&i===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:i});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:Z.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new T("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(ir(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let i="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&Gx.test(o)?this.currentCozeEnv=o:o&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){i!==null?await this.sendError(i,Z.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);i!==null&&await this.upstream.send(Kt(i,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);i!==null&&await this.upstream.send(Kt(i,a));return}if(e.method==="initialize"){i!==null&&await this.upstream.send(Kt(i,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}i!==null?await this.sendError(i,Z.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(a){$.error("handleFrame failed",{method:e.method,err:String(a)}),i!==null&&await this.upstream.send(gt(i,bn(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let i=e.params,o=i._meta?.cozeAgentId;if(!o)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(o);if(!a)throw this.disconnectedAgents.has(o)?new T("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${o}`);let c=typeof i.sessionId=="string"?i.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(a,e.method,i);let f=Date.now(),x=!1;try{let g=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,i));return x=!0,g}finally{$.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-f,ok:x})}}async dispatchSessionCall(e,i,o){e.lastActiveAt=Date.now();let{stripped:a}=Wo(o);switch(i){case"session/new":{let c=Kx();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,f=c.sessionId;if(!f)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let x=await this.ensureRuntime(e,f);if(x.replySeq=0,await this.ensureDownstream(e,f,x),!x.downstream||!x.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let g=o._meta?.cozeTriggerMsgId;g?e.activeTriggers.set(x.acpSessionId,g):e.activeTriggers.delete(x.acpSessionId);let p=Ko(o._meta);if(p?e.activeGroupIds.set(x.acpSessionId,p):e.activeGroupIds.delete(x.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Ya(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let y=await Za(c.prompt);try{let v=await x.downstream.sessionPrompt({...c,sessionId:x.acpSessionId,prompt:y});return x.lastActiveAt=Date.now(),v}finally{if(e.activeTriggers.delete(x.acpSessionId),e.activeGroupIds.delete(x.acpSessionId),x.reloadAfterTurn){x.reloadAfterTurn=!1;let v=x.downstream;v&&(x.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:x.acpSessionId}),v.stop("reload-after-turn").catch(A=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:f,err:String(A)})))}else x.downstream?.isAlive()&&this.armIdleTimer(e,f,x)}}case"session/cancel":{let f=a.sessionId;if(!f)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let x=e.sessions.get(f);if(e.hasSessionQueue(f)){let g=e.getSessionQueue(f);g.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:g.size}),g.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${f}`)))}return x?.downstream?.isAlive()&&x.acpSessionId&&await x.downstream.sessionCancel({sessionId:x.acpSessionId}),{ok:!0}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${i}`)}}async ensureRuntime(e,i){let o=e.sessions.get(i);if(o)return o;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,i):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(i,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,i){let o={sessionId:i,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(Ke.GEN_MODEL_TOKEN,o,jx);if(!a?.modelToken)throw new T("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${i})`);return a.modelToken}catch(a){throw a instanceof T&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new T("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,i,o){if(vn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,f=o.spawnFailCount??0,x=o.spawnFailedAt??0;if(f>=a&&Date.now()-x<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${i} spawn failed ${f} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-x))/1e3)}s`);let g;try{g=await this.sessionSpawner(e,o.modelToken,i,this.currentCozeEnv,this.currentMockScenario)}catch(p){throw o.spawnFailCount=f+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=a&&o.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:i,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),p}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=g,this.attachRuntimeHooks(e,i,o),o.acpSessionId){o.loadingSession=!0;try{await g.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:i,acpId:o.acpSessionId})}catch(p){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:i,acpId:o.acpSessionId,err:String(p)}),o.acpSessionId=void 0;let y=await g.sessionNew({cwd:e.workspace});o.acpSessionId=y.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let p=await g.sessionNew({cwd:e.workspace});o.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}g.afterSessionEstablished&&o.acpSessionId&&await g.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,i,o){if(vn(o),this.isRuntimeBusy(e,o)){$.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:i});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:i}),this.armIdleTimer(e,i,o);return}$.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:i});let a=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),a&&a.stop("idle timeout").catch(c=>$.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:i,err:String(c)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,i){if(i.acpSessionId&&e.activeTriggers.has(i.acpSessionId))return!0;let o=i.downstream;if(!o)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,i,o,a){let c={cozeAgentId:e.agentId,cozeReplySeqID:++i.replySeq};if(i.acpSessionId){let f=e.activeTriggers.get(i.acpSessionId);f&&(c.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i.acpSessionId);x&&(c.cozeGroupId=x)}await this.upstream.send(yn("session/update",{sessionId:o,update:a,_meta:c}))}forwardUpdate(e,i){let o=i.sessionId,a=this.reverseSessionId(e,o);if(!a){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let c=e.sessions.get(a);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(Jx(i)){$.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},x=e.activeTriggers.get(o);x&&(f.cozeTriggerMsgId=x);let g=e.activeGroupIds.get(o);g&&(f.cozeGroupId=g),this.upstream.send(yn("session/update",{...i,sessionId:a,_meta:f})).catch(p=>$.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,i,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,i,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,i,o);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),i.respondAgentRequestError(o.id,{code:Z.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,i,o){try{let a=e.workspace;if(o.method==="fs/write_text_file"){let c=o.params??{},f=await Ka(c,a);i.respondAgentRequest(o.id,f)}else{let c=o.params??{},f=await Wa(c,a);i.respondAgentRequest(o.id,f)}}catch(a){$.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(a)}),i.respondAgentRequestError(o.id,bn(a))}}forwardPermissionRequest(e,i,o){let a=this.upstreamIds.next("session/request_permission"),c=o.params??{},x=c.sessionId,g=x?e.activeTriggers.get(x):void 0,p={cozeAgentId:e.agentId};g&&(p.cozeTriggerMsgId=g);let y=x?e.activeGroupIds.get(x):void 0;y&&(p.cozeGroupId=y);let v=x?this.reverseSessionId(e,x):void 0,A={...c,...v?{sessionId:v}:{},_meta:p};this.pendingUpstream.set(a,{agentRequestId:o.id,agentId:e.agentId,downstream:i,method:o.method}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:x,cloudSessionId:v,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send(_n(a,"session/request_permission",A)).catch(E=>{this.pendingUpstream.delete(a),$.error("forward permission request failed",{agentId:e.agentId,err:String(E)}),i.respondAgentRequestError(o.id,{code:Z.INTERNAL_ERROR,message:`upstream send failed: ${String(E)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let i=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(i){this.pendingUpstream.delete(i.key);let a=i.value;e.error?($.info("upstream \u2192 permission response (error)",{agentId:a.agentId,upstreamId:e.id,method:a.method,error:e.error}),a.downstream.respondAgentRequestError(a.agentRequestId,e.error)):(a.method==="session/request_permission"&&Wx(e.result,a),$.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.agentRequestId,e.result));return}let o=this.lookupPending(this.pendingBridge,e.id,"bridge");if(o){this.pendingBridge.delete(o.key),clearTimeout(o.value.timer),e.error?o.value.reject(new rr(e.error)):o.value.resolve(e.result);return}$.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,i,o){let a=e.get(i);if(a)return{value:a,key:i};if(typeof i=="number"){let c=String(i),f=e.get(c);if(f)return $.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:i,normalizedId:c}),{value:f,key:c}}}sendRequest(e,i,o=Hx){let a=this.upstreamIds.next(e);return new Promise((c,f)=>{let x=setTimeout(()=>{this.pendingBridge.delete(a),f(new T("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(a,{method:e,resolve:c,reject:f,timer:x}),this.upstream.send(_n(a,e,i)).catch(g=>{let p=this.pendingBridge.get(a);p&&(clearTimeout(p.timer),this.pendingBridge.delete(a)),f(g)})})}async persistSessionMapping(e){if(this.paths)try{let i=new Map;for(let[o,a]of e.sessions){let c={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(c.acpSessionId=a.acpSessionId),i.set(o,c)}await gi(e.agentId,i,this.paths)}catch(i){$.warn("persist session mapping failed",{agentId:e.agentId,err:String(i)})}}reverseSessionId(e,i){for(let[o,a]of e.sessions.entries())if(a.acpSessionId===i)return o}sendError(e,i,o){return this.upstream.send(gt(e,{code:i,message:o,data:{bridgeVersion:jt}}))}};function Kx(){return qx(16).toString("hex")}function Wx(n,e){if(!n||typeof n!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let i=n;if("kind"in i&&!("outcome"in i)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=i.outcome;if(!o||typeof o!="object"){$.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let c=o.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:n})}function Jx(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let i=e.content;if(!i||typeof i!="object")return!1;let o=i;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}Y();Ae();import{randomBytes as $x}from"node:crypto";import{chmod as Vx,mkdir as Zx,writeFile as Xa}from"node:fs/promises";import{createServer as Yx}from"node:http";import{dirname as Xx}from"node:path";var Qx=1e6,Fi=j("ipc"),pr=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(i=>[`${i.method} ${i.path}`,i])),this.paths=e.paths??X()}async start(){this.token=$x(32).toString("hex");let e=Yx((o,a)=>{this.dispatch(o,a)});this.server=e,await new Promise((o,a)=>{e.once("error",a),e.listen(0,"127.0.0.1",()=>o())});let i=e.address();if(!i||typeof i!="object")throw new Error("failed to obtain IPC port");return this.port=i.port,await this.persistAuthFiles(),Fi.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((i,o)=>{e.close(a=>a?o(a):i())}),this.server=null)}async persistAuthFiles(){await Zx(Xx(this.paths.portFile),{recursive:!0}),await Xa(this.paths.portFile,String(this.port),"utf8"),await Xa(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Vx(this.paths.tokenFile,384)}catch(e){Fi.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,i){if(e.headers.authorization!==`Bearer ${this.token}`){Cn(i,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(a);if(!c){Cn(i,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await el(e)}catch(x){Cn(i,400,{error:"invalid json",detail:String(x)});return}try{let x=await c.handler(f,e);Cn(i,200,x??{ok:!0})}catch(x){Fi.error("IPC handler failed",{key:a,err:String(x)}),Cn(i,500,{error:x instanceof Error?x.message:String(x)})}}};function Cn(n,e,i){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(i))}async function el(n){let e=[],i=0;for await(let a of n){let c=a;if(i+=c.length,i>Qx)throw new Error("body too large");e.push(c)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}var y0=je(dc(),1);var Lg=je(i0(),1),Og=je(Nr(),1),Mg=je(Xt(),1),Bg=je(Xi(),1),zg=je(ts(),1),Fg=je(as(),1),l0=je(Mr(),1),Ug=je(x0(),1);var g0=l0.default;Y();var ye=j("upstream.frontier"),p0="application/json",m0="none",Hg=15e3,On=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){ye.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Vo,...Gt(this.opts.ppeOverride)};class i extends g0{constructor(b){super(b,$o,{headers:e})}send(b,...I){if($s("debug"))try{let S;typeof b=="string"?S=Buffer.from(b,"utf8"):b instanceof Buffer?S=b:b instanceof ArrayBuffer?S=new Uint8Array(b):ArrayBuffer.isView(b)?S=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):S=new Uint8Array(0);let D=Buffer.from(S.slice(0,128)).toString("hex");ye.debug("WS raw frame out",{bytes:S.byteLength,headHex:D})}catch(S){ye.warn("WS raw frame dump failed",{err:String(S)})}super.send(b,...I)}}let o=Yo(this.opts.urlOverride),a={url:o,ws:i,fpID:Jo,aID:Qn,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:p0,force:!0},payloadEncoding:{encoding:m0,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new y0.FWS(a),f=!1,x=null,g,p,y=new Promise((E,b)=>{g=E,p=b}),v=E=>{f||(f=!0,x&&(clearTimeout(x),x=null),E?p(E):g())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let E=this.openCount===1;ye.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:E,openCount:this.openCount}),E&&v();for(let b of this.connectHandlers)Promise.resolve(b({initial:E})).catch(I=>ye.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=E=>{this.opened=!1,ye.info("frontier closed",{code:E.code,reason:E.reason,willReconnect:E.willReconnect})},c.onerror=E=>{ye.warn("frontier error",{code:E.code,msg:E.message}),v(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${E.code} msg=${E.message??""}`))},c.onmessage=E=>this.handleMessage(E),this.fws=c;let A=this.opts.openTimeoutMs??Hg;x=setTimeout(()=>{v(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await y}catch(E){try{c.close(1e3,"open failed")}catch(b){ye.warn("fws close during start failure threw (ignored)",{err:String(b)})}throw this.fws=null,this.opened=!1,E}}async stop(e){let i=this.fws;if(i){this.fws=null,this.opened=!1;try{i.close(1e3,e??"bridge shutdown")}catch(o){ye.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let i=this.fws,o=e.method;if(!i)throw ye.warn("frontier send refused: upstream not started",{method:o}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let x=Date.now();throw x-this.lastSendRefusedLogAt>1e3?(ye.warn("frontier send refused: ws not open",{method:o,opened:this.opened,readyState:i.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=x,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new T("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${i.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let a=JSON.stringify(e),c=e;w0(c)||ye.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await i.send(a,{service:33555712,method:1,payloadType:p0,payloadEncoding:m0})}catch(x){throw ye.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(x)}),new T("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(x)}`,{cause:x})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let i=this.opts.getPatTokenForAgent;if(!i)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let a=i(o.cozeAgentId);a&&(o.cozePatToken=a)}handleMessage(e){let i=e.message?.service;if(i!==33555712){ye.debug("drop non-adapter frontier frame",{service:i});return}let o=Kg(e);if(!o){ye.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){ye.debug("frame received but no onFrame handler",{size:o.length});return}let a;try{a=JSON.parse(o)}catch(f){ye.warn("frontier message JSON parse failed",{err:String(f),head:o.slice(0,80)});return}let c=a;w0(c)||ye.info("frontier frame in",{logid:jg(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:Gg(o)}),Promise.resolve(this.handler(a)).catch(f=>ye.warn("frontier frame handler threw",{err:String(f)}))}};function w0(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var _0=2e3;function Gg(n){return n.length<=_0?n:`${n.slice(0,_0)}...<truncated, total ${n.length} chars>`}function jg(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Kg(n){let e=n.message;if(e?.textPayload)return e.textPayload;let i=e?.payload;if(!i)return null;try{return Buffer.from(i).toString("utf8")}catch{return null}}Y();var ds=j("upstream.switchable"),zr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,i){if(this.inner===e)return;ds.info("swap upstream",{reason:i});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw ds.error("swap target start failed, reverting",{err:String(a)}),this.inner=o,a}await o.stop(i??"swapped").catch(a=>ds.warn("previous upstream stop threw (ignored)",{err:String(a)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};Y();var fs=j("upstream"),sn=class{handler=null;async start(){fs.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){fs.info("NoopUpstream stopped",{reason:e})}async send(e){fs.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};Y();Y();Ae();import{promises as us}from"node:fs";import{dirname as Wg}from"node:path";var Jg=j("pat-token-store");async function E0(n=X()){try{let i=(await us.readFile(n.patTokenFile,"utf8")).trim();return i.length>0?i:null}catch(e){let i=e?.code;return i!=="ENOENT"&&Jg.warn("read pat-token failed (treating as missing)",{path:n.patTokenFile,code:i,message:e.message}),null}}async function Mn(n,e=X()){if(!n)throw new Error("writePatToken: empty patToken");await us.mkdir(Wg(e.patTokenFile),{recursive:!0}),await us.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}Ae();Ae();import{promises as Fr}from"node:fs";import{join as $g}from"node:path";function Vg(n){return`#!/bin/sh
|
|
125
|
-
exec node ${JSON.stringify(n)} "$@"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
`}async function b0(n,e=X()){let i=e.binDir;await Fr.mkdir(i,{recursive:!0});let o=$g(i,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.platform==="win32"?Zg(n):Vg(n);return await Fr.readFile(o,"utf8").catch(()=>null)===a||(await Fr.writeFile(o,a,"utf8"),process.platform!=="win32"&&await Fr.chmod(o,493)),i}Y();Ae();import{execSync as S0}from"node:child_process";import{readFileSync as I0,unlinkSync as Yg}from"node:fs";import{mkdir as Xg,readFile as C0,unlink as A0,writeFile as Qg}from"node:fs/promises";import{dirname as eh}from"node:path";function v0(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var th=j("single-instance"),Ur=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??X().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(th.warn("removing stale pid file",{stalePid:e}),await A0(this.pidFile).catch(()=>{})),await Xg(eh(this.pidFile),{recursive:!0}),await Qg(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await C0(this.pidFile,"utf8")).trim()===String(process.pid)&&await A0(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await C0(this.pidFile,"utf8"),i=Number.parseInt(e.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return v0(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let i=I0(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(i.includes("coze-bridge-daemon")||i.includes("lib/index.js"))}catch{}try{let i=S0(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return i.trim()?i.includes("coze-bridge-daemon")||i.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=S0(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let a=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return a.includes("node")||a.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{I0(this.pidFile,"utf8").trim()===String(process.pid)&&Yg(this.pidFile)}catch{}})}};var K=j("daemon"),nh="coze-bridge-daemon";async function D0(){let n=new Ur({processTitle:nh}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let i=await gr(),o=i??{};Un({pid:process.pid}),K.info(i?"loaded bridge config":"initialized bridge config");try{let P=new mt;o.frameworksCache=await P.detectAll(),K.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(P){K.warn("framework detection failed",{err:String(P)})}await Vt(o);let a=new zr(new sn),c=X(),f=null,x=new hr({upstream:a,paths:c,bridgeConfig:o,sessionSpawner:async(P,M,U,J)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(P,M,U,J)}});await ih(c,x);let g=new ur({paths:c,config:o,registry:x});f=g;let p,y,v=null,A={},E,b=null;x.registerExtension("_agent/create",async P=>g.createAgent(P.params)),x.registerExtension("_agent/health",async()=>({ok:!0}));let I={},S=new tr({agents:x.agents,disposeAndMarkDisconnected:async(P,M)=>{let U=x.agents.get(P);if(U){await g.cleanupOpenclawSessionProviders(U).catch(ne=>K.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(ne)}));let J=!0;try{await U.dispose(`disconnect: ${M}`)}catch(ne){J=!1,K.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(ne)}),U.status="error"}J&&(U.status="disconnected",x.unregister(P),x.disconnectedAgents.add(P))}else x.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!I.ref)throw new Error("agent-detail-sync not initialized yet");await I.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await g.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,M)=>{await g.openclawRepair(P,M)},isRuntimePendingPermission:P=>x.hasPendingPermissionFor(P)});x.registerExtension("_agent/listSkills",P=>S.listSkills(P.params)),x.registerExtension("_agent/addSkills",P=>S.addSkills(P.params)),x.registerExtension("_agent/removeSkills",P=>S.removeSkills(P.params)),x.registerExtension("_agent/getFileTree",P=>S.getFileTree(P.params)),x.registerExtension("_agent/getFileContent",P=>S.getFileContent(P.params)),x.registerExtension("_agent/update",P=>S.updateAgent(P.params)),x.registerExtension("_agent/disconnect",P=>S.disconnectAgent(P.params)),x.registerExtension("_agent/switchModel",P=>S.switchModel(P.params)),x.registerExtension("_agent/reset",P=>S.resetAgent(P.params)),x.registerExtension("_agent/repair",P=>S.repairAgent(P.params));let D=new Wn({paths:c,handlers:S,sendDetail:P=>x.sendRequest("_agent/detail",P)});I.ref=D;let O=async P=>{await Promise.allSettled(P.map(async M=>{try{await S.disconnectAgent({agentId:M.agentId,reason:`auth_failure: code=${M.code} ${M.message}`}),K.info("agent disconnected due to auth failure from heartbeat response",{agentId:M.agentId,code:M.code,message:M.message})}catch(U){K.warn("disconnect during authFailure handling failed (ignored)",{agentId:M.agentId,err:String(U)})}}))};a.onConnect(({initial:P})=>{K.info("frontier upstream connected, triggering detail sync",{initial:P}),D.syncAll(P?"initial-connect":"reconnect").catch(M=>K.warn("detail sync top-level error (ignored)",{err:String(M)}))});let m=new pr({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let P=x.getMockScenario();return{running:!0,pid:process.pid,agents:[...x.agents.keys()],deviceId:v??"",frameworksCache:o.frameworksCache??{},...P?{mockScenario:P}:{}}}},{method:"POST",path:"/pair",handler:async P=>{let M=P,U=M?.privatecode,J=M?.pairing_code;if(!U||!J)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let ne=pn(M.env),ae=M.handshake_url,pe=M.frontier_url,Ie=T0(M.env,ae,pe),Fe=!!p&&p!==U,Ee=y!==void 0&&y!==Ie,at=Fe||Ee,me=await Ei({privatecode:U,...ae?{endpoint:ae}:{},ppeOverride:ne});if(at){K.warn("pair config switched, resetting agents",{pcChanged:Fe,envChanged:Ee,previousPc:p?qr(p):"",nextPc:qr(U),previousEnvKey:y??"",nextEnvKey:Ie});for(let he of[...x.agents.values()])await he.dispose("pair config switch").catch(()=>{}),x.agents.delete(he.agentId);x.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on pair config switch",{count:x.disconnectedAgents.size}),x.disconnectedAgents.clear()),await a.swap(new sn,"pair switch").catch(()=>{})}v=me.deviceId,Un({deviceId:v,pid:process.pid}),Bi({patToken:U,env:M.env}).catch(he=>K.warn("coze-cli setup error (ignored)",{err:String(he)}));let V=new On({handshake:me,privatecode:U,...pe?{urlOverride:pe}:{},ppeOverride:ne,getPatTokenForAgent:he=>x.agents.get(he)?.patToken});await a.swap(V,"pair");try{let he=new mt;o.frameworksCache=await he.detectAll(),await Vt(o),K.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(he){K.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(he)})}let Pt=Object.keys(o.frameworksCache??{});try{let he=await x.sendRequest("_agent/pair",{pairCode:J,patToken:U,frameworks:Pt,_meta:{cozeDeviceId:v}});K.info("_agent/pair ok",{pairResult:he}),p=U,y=Ie,A=ne,E=ae,M.mock_scenario!==void 0&&(x.setMockScenario(M.mock_scenario),K.info("mock scenario set",{scenario:M.mock_scenario})),Mn(U,c).catch(Ne=>K.warn("writePatToken after /pair failed (ignored)",{err:String(Ne)})),b||(b=new wn({core:x,getDeviceId:()=>v??"",onTickEnd:()=>D.retryPending().catch(Ne=>K.warn("detailSync.retryPending failed (ignored)",{err:String(Ne)})),onAuthFailures:O})),b.start(),at&&Hr(c,g).catch(Ne=>K.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ne)}));let kt;return M.agent_id&&(kt=await sh(M.agent_id,c,g,Ne=>x.sendRequest("_agent/detail",Ne),U).catch(Ne=>(K.error("--agent-id ensureAgent failed",{agentId:M.agent_id,err:String(Ne)}),{ok:!1,agentId:M.agent_id??"",note:String(Ne)}))),{ok:!0,note:"paired with cloud",...kt?{agent:kt}:{}}}catch(he){return K.error("_agent/pair failed",{err:String(he)}),{ok:!1,note:`pair failed: ${String(he)}`}}}},{method:"POST",path:"/connect",handler:async P=>{let M=P,U=M?.privatecode;if(!U)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let J=pn(M.env),ne=M.handshake_url,ae=M.frontier_url,pe=T0(M.env,ne,ae);if(p===U&&y===pe){let V=await rh(c);return x.agents.size===0&&V?(K.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Hr(c,g).catch(Pt=>K.warn("connect-noop auto-revive error (ignored)",{err:String(Pt)}))):K.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Ie=!!p&&p!==U,Fe=y!==void 0&&y!==pe,Ee=Ie||Fe,at=await Ei({privatecode:U,...ne?{endpoint:ne}:{},ppeOverride:J});if(Ee){K.warn("connect config switched, resetting agents",{pcChanged:Ie,envChanged:Fe,previousPc:p?qr(p):"",nextPc:qr(U)});for(let V of[...x.agents.values()])await V.dispose("connect config switch").catch(()=>{}),x.agents.delete(V.agentId);x.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on connect config switch",{count:x.disconnectedAgents.size}),x.disconnectedAgents.clear()),await a.swap(new sn,"connect switch").catch(()=>{})}v=at.deviceId,Un({deviceId:v,pid:process.pid}),Bi({patToken:U,env:M.env}).catch(V=>K.warn("coze-cli setup error (ignored)",{err:String(V)}));let me=new On({handshake:at,privatecode:U,...ae?{urlOverride:ae}:{},ppeOverride:J,getPatTokenForAgent:V=>x.agents.get(V)?.patToken});return await a.swap(me,"connect"),p=U,y=pe,A=J,E=ne,M.mock_scenario!==void 0&&(x.setMockScenario(M.mock_scenario),K.info("mock scenario set",{scenario:M.mock_scenario})),b||(b=new wn({core:x,getDeviceId:()=>v??"",onTickEnd:()=>D.retryPending().catch(V=>K.warn("detailSync.retryPending failed (ignored)",{err:String(V)})),onAuthFailures:O})),b.start(),Ee&&Hr(c,g).catch(V=>K.warn("post-connect-switch auto-revive error (ignored)",{err:String(V)})),Mn(U,c).catch(V=>K.warn("writePatToken after /connect failed (ignored)",{err:String(V)})),K.info("/connect: WS established",{deviceId:v}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async P=>{let M=P;return{ok:!0,result:await g.createAgent(M)}}},{method:"POST",path:"/agent/send",handler:async P=>{let M=P;if(!M?.agentId||!M?.sessionId||!M?.kind||!M?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let U=M;return await(U.groupFile?Ma:Oa)(U,{core:x,patToken:p,handshakeBase:E,ppeOverride:A})}catch(U){if(U instanceof T)return{ok:!1,code:U.code,message:U.message};throw U}}},{method:"POST",path:"/refresh",handler:async()=>{K.info("IPC /refresh: re-detecting frameworks");let P=new mt;return o.frameworksCache=await P.detectAll(),await Vt(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(K.info("IPC /shutdown received"),setImmediate(()=>{B.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:C,token:k}=await m.start();try{await b0(c.libEntry,c)}catch(P){K.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(P)})}await x.start(),Hr(c,g).catch(P=>K.warn("auto-revive top-level error (ignored)",{err:String(P)})),eo().then(async()=>{let{probeAcpVersion:P}=await Promise.resolve().then(()=>(vt(),Xs));for(let M of["claude-code","codex"]){let U=await P(M);U?K.info("acp wrapper version",{framework:M,version:U}):K.warn("acp wrapper version probe failed (binary not on PATH?)",{framework:M})}}).catch(P=>K.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(P)}));let F=null,B={port:C,token:k,core:x,ipc:m,shutdown(P){return F||(K.info("daemon shutdown",{reason:P}),F=(async()=>{b?.stop(),await x.stop(P),await m.stop(),await n.release()})(),F)}};for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{B.shutdown(P).then(()=>process.exit(0))});return process.on("unhandledRejection",P=>{K.error("unhandledRejection",{reason:P instanceof Error?P.message:String(P),stack:P instanceof Error?P.stack:void 0})}),process.on("uncaughtException",P=>{K.error("uncaughtException (will exit, supervisor will restart)",{message:P.message,stack:P.stack,name:P.name}),process.exit(1)}),K.info("daemon ready",{port:C,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),B}async function rh(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function qr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function T0(n,e,i){return`${n??""}|${e??""}|${i??""}`}async function ih(n,e){let{readdir:i}=await import("node:fs/promises"),o;try{o=await i(n.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:c}=await Promise.resolve().then(()=>(ut(),Kn));for(let f of o){await c(f,n).catch(x=>K.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(x)}));try{let x=await a(f,n);x?.disconnectedAt&&(e.disconnectedAgents.add(f),K.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:x.disconnectedAt,reason:x.disconnectReason??""}))}catch(x){K.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(x)})}}}async function sh(n,e,i,o,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(ut(),Kn)),f=await c(n,e);if(f){K.info("--agent-id: local config found, reconnecting",{agentId:n,framework:f.framework,hadDisconnect:!!f.disconnectedAt});let y={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{}};return await i.createAgent(y),{ok:!0,agentId:n,note:f.disconnectedAt?"revived from local config":"connected from local config"}}K.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let x=await o({_meta:{cozeAgentId:n}});if(!x.framework)throw new T("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let g={agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...a?{patToken:a}:{},...x.deployType?{_meta:{cozeDeployType:x.deployType}}:{}};await i.createAgent(g);let p=x.deployType==="cloud"&&x.framework==="openclaw";return{ok:!0,agentId:n,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function Hr(n,e){let{readdir:i}=await import("node:fs/promises"),o;try{o=await i(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:a}=await Promise.resolve().then(()=>(ut(),Kn));K.info("auto-revive: scanning local agents on startup",{count:o.length});let c=0,f=0;for(let x of o){let g;try{g=await a(x,n)}catch(p){K.warn("auto-revive: load config failed (skipping)",{agentId:x,err:String(p)}),f+=1;continue}if(!g){f+=1;continue}if(g.disconnectedAt){K.info("auto-revive: skip disconnected agent",{agentId:x,disconnectedAt:g.disconnectedAt}),f+=1;continue}try{K.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:x,framework:g.framework});let p=oh(g);await e.createAgent({agentId:g.agentId,framework:g.framework,...g.cozeIdentity?{cozeIdentity:g.cozeIdentity}:{},...g.model?{model:g.model}:{},...p?{_meta:p}:{}}),c+=1}catch(p){K.warn("auto-revive: createAgent failed (skipping)",{agentId:x,framework:g.framework,err:String(p)}),f+=1}}return K.info("auto-revive: done",{revived:c,skipped:f,total:o.length}),{revived:c,skipped:f,total:o.length}}function oh(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}gs();Ae();import{readFile as P0}from"node:fs/promises";var ot=class{paths;constructor(e){this.paths=e??X()}async probe(e=1e3){let i=await Gr(this.paths);if(!i)return{kind:"not-running"};try{let o=await this.fetch(i,{method:"GET",path:"/status",timeoutMs:e});return o.status===200?{kind:"connected",...i}:{kind:"stale",reason:`unexpected status ${o.status}`}}catch(o){return{kind:"stale",reason:hh(o)}}}async request(e){let i=await Gr(this.paths);if(!i)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(i,e)}async fetch(e,i){let o=i.body!==void 0,a={Authorization:`Bearer ${e.token}`};o&&(a["content-type"]="application/json");let c=new AbortController,f=setTimeout(()=>c.abort(),i.timeoutMs??5e3);try{let x=await fetch(`http://127.0.0.1:${e.port}${i.path}`,{method:i.method,headers:a,body:o?JSON.stringify(i.body):void 0,signal:c.signal}),g=await x.text();return{status:x.status,body:gh(g)}}finally{clearTimeout(f)}}};async function Gr(n){try{let[e,i]=await Promise.all([P0(n.portFile,"utf8"),P0(n.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),a=i.trim();return!Number.isFinite(o)||o<=0||!a?null:{port:o,token:a}}catch(e){if(e.code==="ENOENT")return null;throw e}}function gh(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function hh(n){return n instanceof Error?n.message:String(n)}Y();Ae();import{copyFile as k0,mkdir as ph,readFile as hs,writeFile as mh}from"node:fs/promises";import{dirname as wh,resolve as ps,sep as jr}from"node:path";import{fileURLToPath as _h}from"node:url";Y();Ae();var N0=j("dist-install");function yh(n){let e=_h(n),i=wh(e),o=`${jr}src${jr}`;if(i.includes(o)||i.endsWith(`${jr}src${jr}cli`))return null;let a=ps(i,"index.js"),c=ps(i,"..","package.json");return{dist:a,pkgJson:c}}async function ms(n={}){let e=n.paths??X(),i=yh(import.meta.url),o=n.sourceDist??i?.dist,a=n.sourcePackageJson??i?.pkgJson;if(!o||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let c;try{c=JSON.parse(await hs(a,"utf8")).version??"unknown"}catch(v){return N0.warn("cannot read source package.json,skip dist install",{err:String(v)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(v)}`}}let f=await gr(e.configFile)??{},x=f.libVersion;if(x===c)try{return await hs(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await ph(e.libDir,{recursive:!0}),await k0(o,e.libEntry),await k0(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let g=ps(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
|
|
129
|
-
`;return await hs(g,"utf8").catch(()=>null)!==p&&await mh(g,p),f.libVersion=c,await Vt(f,e.configFile),N0.info("dist installed",{libEntry:e.libEntry,fromVersion:x,toVersion:c}),x?{kind:"version-changed",fromVersion:x,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}import{basename as Eh,resolve as bh}from"node:path";Ae();var vh=9e4,Sh={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,NPX_CACHE_CORRUPT:1};function Ih(n){return Sh[n]??1}async function R0(n,e={}){let i=e.paths??X();if(!n.agentId||!n.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
130
|
-
|
|
131
|
-
`),
|
|
132
|
-
`),
|
|
116
|
+
`;var Ye=j("agent-detail-sync"),Sp=6e4,Ip=5*6e4,Wi=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,s;try{s=await vp(r)}catch(a){Ye.info("agents dir not found, skip detail sync",{root:r,err:String(a)});return}Ye.info("starting detail sync",{reason:e,count:s.length}),await Promise.allSettled(s.map(async a=>{let c=await qe(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Ye.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(f){Ye.warn("detail sync failed for agent, skipping",{agentId:a,err:String(f)})}}})),Ye.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[s,a]of this.retryQueue)e>=a.dueAt&&r.push(s);if(r.length!==0){Ye.info("retrying pending detail syncs",{count:r.length});for(let s of r)try{await this.syncOne(s)}catch(a){Ye.debug("detail sync retry still failing, will try again",{agentId:s,err:String(a)})}}}async syncOne(e,r){let s=r??await qe(e,this.opts.paths);if(!s){Ye.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(u){Ye.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let x=this.retryQueue.get(e),h=x?Math.min(x.currentDelay*2,Ip):Sp;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(a.agentId&&a.agentId!==e){Ye.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let c=!1,f=!1;if(a.agentName&&a.agentName!==s.agentName&&(s.agentName=a.agentName,c=!0),a.description!==void 0&&a.description!==s.description&&(s.description=a.description,c=!0),a.cozeIdentity&&a.cozeIdentity!==s.cozeIdentity&&(s.cozeIdentity=a.cozeIdentity,c=!0,f=!0),a.deployType&&Ye.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Ye.debug("detail sync: no diff",{agentId:e});return}await $e(s,this.opts.paths),Ye.info("detail sync: config updated",{agentId:e,identityChanged:f,agentName:s.agentName}),f&&(await Zn(s.workspace,s.framework,e,s.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var uu=ht(Td(),1);import{lstat as fc,mkdir as uc,readFile as au,readdir as Vm,rm as Xm,stat as Qm,writeFile as lc}from"node:fs/promises";import{dirname as ew,join as vt,normalize as tw,relative as pc,resolve as xc,sep as cu}from"node:path";import{Readable as du}from"node:stream";import{pipeline as fu}from"node:stream/promises";import $p from"events";import Ke from"fs";import{EventEmitter as Za}from"node:events";import df from"node:stream";import{StringDecoder as Yp}from"node:string_decoder";import lf from"node:path";import cr from"node:fs";import{dirname as ag,parse as cg}from"path";import{EventEmitter as gg}from"events";import ka from"assert";import{Buffer as Dn}from"buffer";import*as Pd from"zlib";import mg from"zlib";import{posix as tr}from"node:path";import{basename as Gg}from"node:path";import vs from"fs";import wt from"fs";import Fd from"path";import{win32 as tm}from"node:path";import Kd from"path";import Tf from"node:fs";import wm from"node:assert";import{randomBytes as Af}from"node:crypto";import X from"node:fs";import Se from"node:path";import Rf from"fs";import Ps from"node:fs";import ri from"node:path";import Ve from"node:fs";import Im from"node:fs/promises";import Cs from"node:path";import{join as Uf}from"node:path";import Ze from"node:fs";import jf from"node:path";var Wp=Object.defineProperty,Kp=(t,e)=>{for(var r in e)Wp(t,r,{get:e[r],enumerable:!0})},Ad=typeof process=="object"&&process?process:{stdout:null,stderr:null},Jp=t=>!!t&&typeof t=="object"&&(t instanceof On||t instanceof df||Zp(t)||Vp(t)),Zp=t=>!!t&&typeof t=="object"&&t instanceof Za&&typeof t.pipe=="function"&&t.pipe!==df.Writable.prototype.pipe,Vp=t=>!!t&&typeof t=="object"&&t instanceof Za&&typeof t.write=="function"&&typeof t.end=="function",kt=Symbol("EOF"),Pt=Symbol("maybeEmitEnd"),Jt=Symbol("emittedEnd"),Zi=Symbol("emittingEnd"),Ur=Symbol("emittedError"),Vi=Symbol("closed"),Rd=Symbol("read"),Xi=Symbol("flush"),Dd=Symbol("flushChunk"),ct=Symbol("encoding"),er=Symbol("decoder"),Ae=Symbol("flowing"),qr=Symbol("paused"),sr=Symbol("resume"),Re=Symbol("buffer"),Ge=Symbol("pipes"),De=Symbol("bufferLength"),ra=Symbol("bufferPush"),Qi=Symbol("bufferShift"),He=Symbol("objectMode"),me=Symbol("destroyed"),ia=Symbol("error"),sa=Symbol("emitData"),kd=Symbol("emitEnd"),oa=Symbol("emitEnd2"),pt=Symbol("async"),aa=Symbol("abort"),es=Symbol("aborted"),Hr=Symbol("signal"),bn=Symbol("dataListeners"),Je=Symbol("discarded"),jr=t=>Promise.resolve().then(t),Xp=t=>t(),Qp=t=>t==="end"||t==="finish"||t==="prefinish",eg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,tg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),ff=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[sr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ng=class extends ff{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=s=>this.dest.emit("error",s),t.on("error",this.proxyErrors)}},rg=t=>!!t.objectMode,ig=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",On=class extends Za{[Ae]=!1;[qr]=!1;[Ge]=[];[Re]=[];[He];[ct];[pt];[er];[kt]=!1;[Jt]=!1;[Zi]=!1;[Vi]=!1;[Ur]=null;[De]=0;[me]=!1;[Hr];[es]=!1;[bn]=0;[Je]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");rg(e)?(this[He]=!0,this[ct]=null):ig(e)?(this[ct]=e.encoding,this[He]=!1):(this[He]=!1,this[ct]=null),this[pt]=!!e.async,this[er]=this[ct]?new Yp(this[ct]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Re]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ge]});let{signal:r}=e;r&&(this[Hr]=r,r.aborted?this[aa]():r.addEventListener("abort",()=>this[aa]()))}get bufferLength(){return this[De]}get encoding(){return this[ct]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[He]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[pt]}set async(t){this[pt]=this[pt]||!!t}[aa](){this[es]=!0,this.emit("abort",this[Hr]?.reason),this.destroy(this[Hr]?.reason)}get aborted(){return this[es]}set aborted(t){}write(t,e,r){if(this[es])return!1;if(this[kt])throw new Error("write after end");if(this[me])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let s=this[pt]?jr:Xp;if(!this[He]&&!Buffer.isBuffer(t)){if(tg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(eg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[He]?(this[Ae]&&this[De]!==0&&this[Xi](!0),this[Ae]?this.emit("data",t):this[ra](t),this[De]!==0&&this.emit("readable"),r&&s(r),this[Ae]):t.length?(typeof t=="string"&&!(e===this[ct]&&!this[er]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ct]&&(t=this[er].write(t)),this[Ae]&&this[De]!==0&&this[Xi](!0),this[Ae]?this.emit("data",t):this[ra](t),this[De]!==0&&this.emit("readable"),r&&s(r),this[Ae]):(this[De]!==0&&this.emit("readable"),r&&s(r),this[Ae])}read(t){if(this[me])return null;if(this[Je]=!1,this[De]===0||t===0||t&&t>this[De])return this[Pt](),null;this[He]&&(t=null),this[Re].length>1&&!this[He]&&(this[Re]=[this[ct]?this[Re].join(""):Buffer.concat(this[Re],this[De])]);let e=this[Rd](t||null,this[Re][0]);return this[Pt](),e}[Rd](t,e){if(this[He])this[Qi]();else{let r=e;t===r.length||t===null?this[Qi]():typeof r=="string"?(this[Re][0]=r.slice(t),e=r.slice(0,t),this[De]-=t):(this[Re][0]=r.subarray(t),e=r.subarray(0,t),this[De]-=t)}return this.emit("data",e),!this[Re].length&&!this[kt]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[kt]=!0,this.writable=!1,(this[Ae]||!this[qr])&&this[Pt](),this}[sr](){this[me]||(!this[bn]&&!this[Ge].length&&(this[Je]=!0),this[qr]=!1,this[Ae]=!0,this.emit("resume"),this[Re].length?this[Xi]():this[kt]?this[Pt]():this.emit("drain"))}resume(){return this[sr]()}pause(){this[Ae]=!1,this[qr]=!0,this[Je]=!1}get destroyed(){return this[me]}get flowing(){return this[Ae]}get paused(){return this[qr]}[ra](t){this[He]?this[De]+=1:this[De]+=t.length,this[Re].push(t)}[Qi](){return this[He]?this[De]-=1:this[De]-=this[Re][0].length,this[Re].shift()}[Xi](t=!1){do;while(this[Dd](this[Qi]())&&this[Re].length);!t&&!this[Re].length&&!this[kt]&&this.emit("drain")}[Dd](t){return this.emit("data",t),this[Ae]}pipe(t,e){if(this[me])return t;this[Je]=!1;let r=this[Jt];return e=e||{},t===Ad.stdout||t===Ad.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ge].push(e.proxyErrors?new ng(this,t,e):new ff(this,t,e)),this[pt]?jr(()=>this[sr]()):this[sr]()),t}unpipe(t){let e=this[Ge].find(r=>r.dest===t);e&&(this[Ge].length===1?(this[Ae]&&this[bn]===0&&(this[Ae]=!1),this[Ge]=[]):this[Ge].splice(this[Ge].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[Je]=!1,this[bn]++,!this[Ge].length&&!this[Ae]&&this[sr]();else if(t==="readable"&&this[De]!==0)super.emit("readable");else if(Qp(t)&&this[Jt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ur]){let s=e;this[pt]?jr(()=>s.call(this,this[Ur])):s.call(this,this[Ur])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[bn]=this.listeners("data").length,this[bn]===0&&!this[Je]&&!this[Ge].length&&(this[Ae]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[bn]=0,!this[Je]&&!this[Ge].length&&(this[Ae]=!1)),e}get emittedEnd(){return this[Jt]}[Pt](){!this[Zi]&&!this[Jt]&&!this[me]&&this[Re].length===0&&this[kt]&&(this[Zi]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Vi]&&this.emit("close"),this[Zi]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==me&&this[me])return!1;if(t==="data")return!this[He]&&!r?!1:this[pt]?(jr(()=>this[sa](r)),!0):this[sa](r);if(t==="end")return this[kd]();if(t==="close"){if(this[Vi]=!0,!this[Jt]&&!this[me])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[Ur]=r,super.emit(ia,r);let a=!this[Hr]||this.listeners("error").length?super.emit("error",r):!1;return this[Pt](),a}else if(t==="resume"){let a=super.emit("resume");return this[Pt](),a}else if(t==="finish"||t==="prefinish"){let a=super.emit(t);return this.removeAllListeners(t),a}let s=super.emit(t,...e);return this[Pt](),s}[sa](t){for(let r of this[Ge])r.dest.write(t)===!1&&this.pause();let e=this[Je]?!1:super.emit("data",t);return this[Pt](),e}[kd](){return this[Jt]?!1:(this[Jt]=!0,this.readable=!1,this[pt]?(jr(()=>this[oa]()),!0):this[oa]())}[oa](){if(this[er]){let e=this[er].end();if(e){for(let r of this[Ge])r.dest.write(e);this[Je]||super.emit("data",e)}}for(let e of this[Ge])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[He]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[He]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[He])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ct]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(me,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Je]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[kt])return e();let s,a,c=h=>{this.off("data",f),this.off("end",u),this.off(me,x),e(),a(h)},f=h=>{this.off("error",c),this.off("end",u),this.off(me,x),this.pause(),s({value:h,done:!!this[kt]})},u=()=>{this.off("error",c),this.off("data",f),this.off(me,x),e(),s({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,w)=>{a=w,s=h,this.once(me,x),this.once("error",c),this.once("end",u),this.once("data",f)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Je]=!1;let t=!1,e=()=>(this.pause(),this.off(ia,e),this.off(me,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let s=this.read();return s===null?e():{done:!1,value:s}};return this.once("end",e),this.once(ia,e),this.once(me,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[me])return t?this.emit("error",t):this.emit(me),this;this[me]=!0,this[Je]=!0,this[Re].length=0,this[De]=0;let e=this;return typeof e.close=="function"&&!this[Vi]&&e.close(),t?this.emit("error",t):this.emit(me),this}static get isStream(){return Jp}},sg=Ke.writev,on=Symbol("_autoClose"),lt=Symbol("_close"),Gr=Symbol("_ended"),ie=Symbol("_fd"),ca=Symbol("_finished"),Mt=Symbol("_flags"),da=Symbol("_flush"),Ra=Symbol("_handleChunk"),Da=Symbol("_makeBuf"),ti=Symbol("_mode"),ts=Symbol("_needDrain"),fr=Symbol("_onerror"),ur=Symbol("_onopen"),fa=Symbol("_onread"),or=Symbol("_onwrite"),an=Symbol("_open"),ut=Symbol("_path"),en=Symbol("_pos"),gt=Symbol("_queue"),ar=Symbol("_read"),ua=Symbol("_readSize"),Nt=Symbol("_reading"),Wr=Symbol("_remain"),la=Symbol("_size"),us=Symbol("_write"),En=Symbol("_writing"),ls=Symbol("_defaultFlag"),Rn=Symbol("_errored"),Va=class extends On{[Rn]=!1;[ie];[ut];[ua];[Nt]=!1;[la];[Wr];[on];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Rn]=!1,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[ut]=t,this[ua]=e.readSize||16*1024*1024,this[Nt]=!1,this[la]=typeof e.size=="number"?e.size:1/0,this[Wr]=this[la],this[on]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ie]=="number"?this[ar]():this[an]()}get fd(){return this[ie]}get path(){return this[ut]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[an](){Ke.open(this[ut],"r",(t,e)=>this[ur](t,e))}[ur](t,e){t?this[fr](t):(this[ie]=e,this.emit("open",e),this[ar]())}[Da](){return Buffer.allocUnsafe(Math.min(this[ua],this[Wr]))}[ar](){if(!this[Nt]){this[Nt]=!0;let t=this[Da]();if(t.length===0)return process.nextTick(()=>this[fa](null,0,t));Ke.read(this[ie],t,0,t.length,null,(e,r,s)=>this[fa](e,r,s))}}[fa](t,e,r){this[Nt]=!1,t?this[fr](t):this[Ra](e,r)&&this[ar]()}[lt](){if(this[on]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[fr](t){this[Nt]=!0,this[lt](),this.emit("error",t)}[Ra](t,e){let r=!1;return this[Wr]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[Wr]<=0)&&(r=!1,this[lt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ie]=="number"&&this[ar](),!1;case"error":return this[Rn]?!1:(this[Rn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},og=class extends Va{[an](){let t=!0;try{this[ur](null,Ke.openSync(this[ut],"r")),t=!1}finally{t&&this[lt]()}}[ar](){let t=!0;try{if(!this[Nt]){this[Nt]=!0;do{let e=this[Da](),r=e.length===0?0:Ke.readSync(this[ie],e,0,e.length,null);if(!this[Ra](r,e))break}while(!0);this[Nt]=!1}t=!1}finally{t&&this[lt]()}}[lt](){if(this[on]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.closeSync(t),this.emit("close")}}},Ts=class extends $p{readable=!1;writable=!0;[Rn]=!1;[En]=!1;[Gr]=!1;[gt]=[];[ts]=!1;[ut];[ti];[on];[ie];[ls];[Mt];[ca]=!1;[en];constructor(t,e){e=e||{},super(e),this[ut]=t,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[ti]=e.mode===void 0?438:e.mode,this[en]=typeof e.start=="number"?e.start:void 0,this[on]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[en]!==void 0?"r+":"w";this[ls]=e.flags===void 0,this[Mt]=e.flags===void 0?r:e.flags,this[ie]===void 0&&this[an]()}emit(t,...e){if(t==="error"){if(this[Rn])return!1;this[Rn]=!0}return super.emit(t,...e)}get fd(){return this[ie]}get path(){return this[ut]}[fr](t){this[lt](),this[En]=!0,this.emit("error",t)}[an](){Ke.open(this[ut],this[Mt],this[ti],(t,e)=>this[ur](t,e))}[ur](t,e){this[ls]&&this[Mt]==="r+"&&t&&t.code==="ENOENT"?(this[Mt]="w",this[an]()):t?this[fr](t):(this[ie]=e,this.emit("open",e),this[En]||this[da]())}end(t,e){return t&&this.write(t,e),this[Gr]=!0,!this[En]&&!this[gt].length&&typeof this[ie]=="number"&&this[or](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[Gr]?(this.emit("error",new Error("write() after end()")),!1):this[ie]===void 0||this[En]||this[gt].length?(this[gt].push(t),this[ts]=!0,!1):(this[En]=!0,this[us](t),!0)}[us](t){Ke.write(this[ie],t,0,t.length,this[en],(e,r)=>this[or](e,r))}[or](t,e){t?this[fr](t):(this[en]!==void 0&&typeof e=="number"&&(this[en]+=e),this[gt].length?this[da]():(this[En]=!1,this[Gr]&&!this[ca]?(this[ca]=!0,this[lt](),this.emit("finish")):this[ts]&&(this[ts]=!1,this.emit("drain"))))}[da](){if(this[gt].length===0)this[Gr]&&this[or](null,0);else if(this[gt].length===1)this[us](this[gt].pop());else{let t=this[gt];this[gt]=[],sg(this[ie],t,this[en],(e,r)=>this[or](e,r))}}[lt](){if(this[on]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},uf=class extends Ts{[an](){let t;if(this[ls]&&this[Mt]==="r+")try{t=Ke.openSync(this[ut],this[Mt],this[ti])}catch(e){if(e?.code==="ENOENT")return this[Mt]="w",this[an]();throw e}else t=Ke.openSync(this[ut],this[Mt],this[ti]);this[ur](null,t)}[lt](){if(this[on]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.closeSync(t),this.emit("close")}}[us](t){let e=!0;try{this[or](null,Ke.writeSync(this[ie],t,0,t.length,this[en])),e=!1}finally{if(e)try{this[lt]()}catch{}}}},dg=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),fg=t=>!!t.sync&&!!t.file,ug=t=>!t.sync&&!!t.file,lg=t=>!!t.sync&&!t.file,xg=t=>!t.sync&&!t.file,hg=t=>!!t.file,pg=t=>dg.get(t)||t,Xa=(t={})=>{if(!t)return{};let e={};for(let[r,s]of Object.entries(t)){let a=pg(r);e[a]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},fi=(t,e,r,s,a)=>Object.assign((c=[],f,u)=>{Array.isArray(c)&&(f=c,c={}),typeof f=="function"&&(u=f,f=void 0),f=f?Array.from(f):[];let x=Xa(c);if(a?.(x,f),fg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,f)}else if(ug(x)){let h=e(x,f);return u?h.then(()=>u(),u):h}else if(lg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,f)}else if(xg(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return s(x,f)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:s,validate:a}),wg=mg.constants||{ZLIB_VERNUM:4736},yt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},wg)),_g=Dn.concat,Od=Object.getOwnPropertyDescriptor(Dn,"concat"),yg=t=>t,xa=Od?.writable===!0||Od?.set!==void 0?t=>{Dn.concat=t?yg:_g}:t=>{},kn=Symbol("_superWrite"),ns=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ha=Symbol("flushFlag"),Qa=class extends On{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof Pd[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Pd[e](t)}catch(r){throw new ns(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new ns(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ka(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Dn.alloc(0),{[ha]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[kn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Dn.from(t,e)),this.#e)return;ka(this.#t,"zlib binding closed");let s=this.#t._handle,a=s.close;s.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},xa(!0);let f;try{let x=typeof t[ha]=="number"?t[ha]:this.#r;f=this.#t._processChunk(t,x),xa(!1)}catch(x){xa(!1),this.#o(new ns(x,this.write))}finally{this.#t&&(this.#t._handle=s,s.close=a,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",x=>this.#o(new ns(x,this.write)));let u;if(f)if(Array.isArray(f)&&f.length>0){let x=f[0];u=this[kn](Dn.from(x));for(let h=1;h<f.length;h++)u=this[kn](f[h])}else u=this[kn](Dn.from(f));return r&&r(),u}},xf=class extends Qa{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||yt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||yt.Z_FINISH,t.fullFlushFlag=yt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(yt.Z_SYNC_FLUSH),ka(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(s,a)=>{typeof s=="function"&&(a=s,s=this.flushFlag),this.flush(s),a?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},bg=class extends xf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[kn](t){return this.#e?(this.#e=!1,t[9]=255,super[kn](t)):super[kn](t)}},Eg=class extends xf{constructor(t){super(t,"Unzip")}},hf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||yt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||yt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=yt.BROTLI_OPERATION_FLUSH,super(t,e)}},vg=class extends hf{constructor(t){super(t,"BrotliCompress")}},Sg=class extends hf{constructor(t){super(t,"BrotliDecompress")}},pf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||yt.ZSTD_e_continue,t.finishFlush=t.finishFlush||yt.ZSTD_e_end,t.fullFlushFlag=yt.ZSTD_e_flush,super(t,e)}},Ig=class extends pf{constructor(t){super(t,"ZstdCompress")}},Cg=class extends pf{constructor(t){super(t,"ZstdDecompress")}},Tg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Rg(t,e):Ag(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Ag=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Rg=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var s=e.length;s>1;s--){var a=t&255;t=Math.floor(t/256),r?e[s-1]=gf(a):a===0?e[s-1]=0:(r=!0,e[s-1]=mf(a))}},Dg=t=>{let e=t[0],r=e===128?Pg(t.subarray(1,t.length)):e===255?kg(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},kg=t=>{for(var e=t.length,r=0,s=!1,a=e-1;a>-1;a--){var c=Number(t[a]),f;s?f=gf(c):c===0?f=c:(s=!0,f=mf(c)),f!==0&&(r-=f*Math.pow(256,e-a-1))}return r},Pg=t=>{for(var e=t.length,r=0,s=e-1;s>-1;s--){var a=Number(t[s]);a!==0&&(r+=a*Math.pow(256,e-s-1))}return r},gf=t=>(255^t)&255,mf=t=>(255^t)+1&255,Og={};Kp(Og,{code:()=>ec,isCode:()=>xs,isName:()=>Lg,name:()=>As});var xs=t=>As.has(t),Lg=t=>ec.has(t),As=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),ec=new Map(Array.from(As).map(t=>[t[1],t[0]])),Pn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,s){Buffer.isBuffer(t)?this.decode(t,e||0,r,s):t&&this.#n(t)}decode(t,e,r,s){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??vn(t,e,100),this.mode=r?.mode??s?.mode??tn(t,e+100,8),this.uid=r?.uid??s?.uid??tn(t,e+108,8),this.gid=r?.gid??s?.gid??tn(t,e+116,8),this.size=r?.size??s?.size??tn(t,e+124,12),this.mtime=r?.mtime??s?.mtime??pa(t,e+136,12),this.cksum=tn(t,e+148,12),s&&this.#n(s,!0),r&&this.#n(r);let a=vn(t,e+156,1);if(xs(a)&&(this.#e=a||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=vn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??s?.uname??vn(t,e+265,32),this.gname=r?.gname??s?.gname??vn(t,e+297,32),this.devmaj=r?.devmaj??s?.devmaj??tn(t,e+329,8)??0,this.devmin=r?.devmin??s?.devmin??tn(t,e+337,8)??0,t[e+475]!==0){let f=vn(t,e+345,155);this.path=f+"/"+this.path}else{let f=vn(t,e+345,130);f&&(this.path=f+"/"+this.path),this.atime=r?.atime??s?.atime??pa(t,e+476,12),this.ctime=r?.ctime??s?.ctime??pa(t,e+488,12)}let c=256;for(let f=e;f<e+148;f++)c+=t[f];for(let f=e+156;f<e+512;f++)c+=t[f];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,s=Ng(this.path||"",r),a=s[0],c=s[1];this.needPax=!!s[2],this.needPax=Sn(t,e,100,a)||this.needPax,this.needPax=nn(t,e+100,8,this.mode)||this.needPax,this.needPax=nn(t,e+108,8,this.uid)||this.needPax,this.needPax=nn(t,e+116,8,this.gid)||this.needPax,this.needPax=nn(t,e+124,12,this.size)||this.needPax,this.needPax=ga(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Sn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Sn(t,e+265,32,this.uname)||this.needPax,this.needPax=Sn(t,e+297,32,this.gname)||this.needPax,this.needPax=nn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=nn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Sn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Sn(t,e+345,155,c)||this.needPax:(this.needPax=Sn(t,e+345,130,c)||this.needPax,this.needPax=ga(t,e+476,12,this.atime)||this.needPax,this.needPax=ga(t,e+488,12,this.ctime)||this.needPax);let f=256;for(let u=e;u<e+148;u++)f+=t[u];for(let u=e+156;u<e+512;u++)f+=t[u];return this.cksum=f,nn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:As.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(ec.get(t));if(xs(e)||e==="Unsupported")this.#e=e;else if(xs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Ng=(t,e)=>{let r=t,s="",a,c=tr.parse(t).root||".";if(Buffer.byteLength(r)<100)a=[r,s,!1];else{s=tr.dirname(r),r=tr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(s)<=e?a=[r,s,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(s)<=e?a=[r.slice(0,99),s,!0]:(r=tr.join(tr.basename(s),r),s=tr.dirname(s));while(s!==c&&a===void 0);a||(a=[t.slice(0,99),"",!0])}return a},vn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),pa=(t,e,r)=>Mg(tn(t,e,r)),Mg=t=>t===void 0?void 0:new Date(t*1e3),tn=(t,e,r)=>Number(t[e])&128?Dg(t.subarray(e,e+r)):zg(t,e,r),Bg=t=>isNaN(t)?void 0:t,zg=(t,e,r)=>Bg(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Fg={12:8589934591,8:2097151},nn=(t,e,r,s)=>s===void 0?!1:s>Fg[r]||s<0?(Tg(s,t.subarray(e,e+r)),!0):(Ug(t,e,r,s),!1),Ug=(t,e,r,s)=>t.write(qg(s,r),e,r,"ascii"),qg=(t,e)=>Hg(Math.floor(t).toString(8),e),Hg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",ga=(t,e,r,s)=>s===void 0?!1:nn(t,e,r,s.getTime()/1e3),jg=new Array(156).join("\0"),Sn=(t,e,r,s)=>s===void 0?!1:(t.write(s+jg,e,r,"utf8"),s.length!==Buffer.byteLength(s)||s.length>r),Es=class wf{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),s=512*Math.ceil(1+r/512),a=Buffer.allocUnsafe(s);for(let c=0;c<512;c++)a[c]=0;new Pn({path:("PaxHeader/"+Gg(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(a),a.write(e,512,r,"utf8");for(let c=r+512;c<a.length;c++)a[c]=0;return a}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],s=r instanceof Date?r.getTime()/1e3:r,a=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+s+`
|
|
117
|
+
`,c=Buffer.byteLength(a),f=Math.floor(Math.log(c)/Math.log(10))+1;return c+f>=Math.pow(10,f)&&(f+=1),f+c+a}static parse(e,r,s=!1){return new wf(Wg(Kg(e),r),s)}},Wg=(t,e)=>e?Object.assign({},e,t):t,Kg=t=>t.replace(/\n$/,"").split(`
|
|
118
|
+
`).reduce($g,Object.create(null)),$g=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let s=e.split("="),a=s.shift();if(!a)return t;let c=a.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),f=s.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(f)*1e3):/^[0-9]+$/.test(f)?+f:f,t},Yg=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=Yg!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),_f=class extends On{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,s=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,s-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e))))}},Rs=(t,e,r,s={})=>{t.file&&(s.file=t.file),t.cwd&&(s.cwd=t.cwd),s.code=r instanceof Error&&r.code||e,s.tarCode=e,!t.strict&&s.recoverable!==!1?(r instanceof Error&&(s=Object.assign(r,s),r=r.message),t.emit("warn",e,r,s)):r instanceof Error?t.emit("error",Object.assign(r,s)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),s))},Jg=1024*1024,Pa=Buffer.from([31,139]),Oa=Buffer.from([40,181,47,253]),Zg=Math.max(Pa.length,Oa.length),et=Symbol("state"),In=Symbol("writeEntry"),Ot=Symbol("readEntry"),ma=Symbol("nextEntry"),Ld=Symbol("processEntry"),mt=Symbol("extendedHeader"),Kr=Symbol("globalExtendedHeader"),Zt=Symbol("meta"),Nd=Symbol("emitMeta"),ce=Symbol("buffer"),Lt=Symbol("queue"),Vt=Symbol("ended"),wa=Symbol("emittedEnd"),Cn=Symbol("emit"),ye=Symbol("unzip"),rs=Symbol("consumeChunk"),is=Symbol("consumeChunkSub"),_a=Symbol("consumeBody"),Md=Symbol("consumeMeta"),Bd=Symbol("consumeHeader"),$r=Symbol("consuming"),ya=Symbol("bufferConcat"),ss=Symbol("maybeEnd"),nr=Symbol("writing"),Xt=Symbol("aborted"),os=Symbol("onDone"),Tn=Symbol("sawValidEntry"),as=Symbol("sawNullBlock"),cs=Symbol("sawEOF"),zd=Symbol("closeStream"),Vg=()=>!0,di=class extends gg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Lt]=[];[ce];[Ot];[In];[et]="begin";[Zt]="";[mt];[Kr];[Vt]=!1;[ye];[Xt]=!1;[Tn];[as]=!1;[cs]=!1;[nr]=!1;[$r]=!1;[wa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(os,()=>{(this[et]==="begin"||this[Tn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(os,t.ondone):this.on(os,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Jg,this.filter=typeof t.filter=="function"?t.filter:Vg;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[zd]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Rs(this,t,e,r)}[Bd](t,e){this[Tn]===void 0&&(this[Tn]=!1);let r;try{r=new Pn(t,e,this[mt],this[Kr])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(r.nullBlock)this[as]?(this[cs]=!0,this[et]==="begin"&&(this[et]="header"),this[Cn]("eof")):(this[as]=!0,this[Cn]("nullBlock"));else if(this[as]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let s=r.type;if(/^(Symbolic)?Link$/.test(s)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(s)&&!/^(Global)?ExtendedHeader$/.test(s)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let a=this[In]=new _f(r,this[mt],this[Kr]);if(!this[Tn])if(a.remain){let c=()=>{a.invalid||(this[Tn]=!0)};a.on("end",c)}else this[Tn]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[Cn]("ignoredEntry",a),this[et]="ignore",a.resume()):a.size>0&&(this[Zt]="",a.on("data",c=>this[Zt]+=c),this[et]="meta"):(this[mt]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[Cn]("ignoredEntry",a),this[et]=a.remain?"ignore":"header",a.resume()):(a.remain?this[et]="body":(this[et]="header",a.end()),this[Ot]?this[Lt].push(a):(this[Lt].push(a),this[ma]())))}}}[zd](){queueMicrotask(()=>this.emit("close"))}[Ld](t){let e=!0;if(!t)this[Ot]=void 0,e=!1;else if(Array.isArray(t)){let[r,...s]=t;this.emit(r,...s)}else this[Ot]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ma]()),e=!1);return e}[ma](){do;while(this[Ld](this[Lt].shift()));if(this[Lt].length===0){let t=this[Ot];!t||t.flowing||t.size===t.remain?this[nr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[_a](t,e){let r=this[In];if(!r)throw new Error("attempt to consume body without entry??");let s=r.blockRemain??0,a=s>=t.length&&e===0?t:t.subarray(e,e+s);return r.write(a),r.blockRemain||(this[et]="header",this[In]=void 0,r.end()),a.length}[Md](t,e){let r=this[In],s=this[_a](t,e);return!this[In]&&r&&this[Nd](r),s}[Cn](t,e,r){this[Lt].length===0&&!this[Ot]?this.emit(t,e,r):this[Lt].push([t,e,r])}[Nd](t){switch(this[Cn]("meta",this[Zt]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[mt]=Es.parse(this[Zt],this[mt],!1);break;case"GlobalExtendedHeader":this[Kr]=Es.parse(this[Zt],this[Kr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[mt]??Object.create(null);this[mt]=e,e.path=this[Zt].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[mt]||Object.create(null);this[mt]=e,e.linkpath=this[Zt].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[Xt]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[Xt])return r?.(),!1;if((this[ye]===void 0||this.brotli===void 0&&this[ye]===!1)&&t){if(this[ce]&&(t=Buffer.concat([this[ce],t]),this[ce]=void 0),t.length<Zg)return this[ce]=t,r?.(),!0;for(let f=0;this[ye]===void 0&&f<Pa.length;f++)t[f]!==Pa[f]&&(this[ye]=!1);let a=!1;if(this[ye]===!1&&this.zstd!==!1){a=!0;for(let f=0;f<Oa.length;f++)if(t[f]!==Oa[f]){a=!1;break}}let c=this.brotli===void 0&&!a;if(this[ye]===!1&&c)if(t.length<512)if(this[Vt])this.brotli=!0;else return this[ce]=t,r?.(),!0;else try{new Pn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ye]===void 0||this[ye]===!1&&(this.brotli||a)){let f=this[Vt];this[Vt]=!1,this[ye]=this[ye]===void 0?new Eg({}):a?new Cg({}):new Sg({}),this[ye].on("data",x=>this[rs](x)),this[ye].on("error",x=>this.abort(x)),this[ye].on("end",()=>{this[Vt]=!0,this[rs]()}),this[nr]=!0;let u=!!this[ye][f?"end":"write"](t);return this[nr]=!1,r?.(),u}}this[nr]=!0,this[ye]?this[ye].write(t):this[rs](t),this[nr]=!1;let s=this[Lt].length>0?!1:this[Ot]?this[Ot].flowing:!0;return!s&&this[Lt].length===0&&this[Ot]?.once("drain",()=>this.emit("drain")),r?.(),s}[ya](t){t&&!this[Xt]&&(this[ce]=this[ce]?Buffer.concat([this[ce],t]):t)}[ss](){if(this[Vt]&&!this[wa]&&!this[Xt]&&!this[$r]){this[wa]=!0;let t=this[In];if(t&&t.blockRemain){let e=this[ce]?this[ce].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ce]&&t.write(this[ce]),t.end()}this[Cn](os)}}[rs](t){if(this[$r]&&t)this[ya](t);else if(!t&&!this[ce])this[ss]();else if(t){if(this[$r]=!0,this[ce]){this[ya](t);let e=this[ce];this[ce]=void 0,this[is](e)}else this[is](t);for(;this[ce]&&this[ce]?.length>=512&&!this[Xt]&&!this[cs];){let e=this[ce];this[ce]=void 0,this[is](e)}this[$r]=!1}(!this[ce]||this[Vt])&&this[ss]()}[is](t){let e=0,r=t.length;for(;e+512<=r&&!this[Xt]&&!this[cs];)switch(this[et]){case"begin":case"header":this[Bd](t,e),e+=512;break;case"ignore":case"body":e+=this[_a](t,e);break;case"meta":e+=this[Md](t,e);break;default:throw new Error("invalid state: "+this[et])}e<r&&(this[ce]=this[ce]?Buffer.concat([t.subarray(e),this[ce]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[Xt]||(this[ye]?(t&&this[ye].write(t),this[ye].end()):(this[Vt]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[ss]())),this}},ni=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},Xg=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},yf=(t,e)=>{let r=new Map(e.map(c=>[ni(c),!0])),s=t.filter,a=(c,f="")=>{let u=f||cg(c).root||".",x;if(c===u)x=!1;else{let h=r.get(c);x=h!==void 0?h:a(ag(c),u)}return r.set(c,x),x};t.filter=s?(c,f)=>s(c,f)&&a(ni(c)):c=>a(ni(c))},Qg=t=>{let e=new di(t),r=t.file,s;try{s=cr.openSync(r,"r");let a=cr.fstatSync(s),c=t.maxReadSize||16*1024*1024;if(a.size<c){let f=Buffer.allocUnsafe(a.size),u=cr.readSync(s,f,0,a.size,0);e.end(u===f.byteLength?f:f.subarray(0,u))}else{let f=0,u=Buffer.allocUnsafe(c);for(;f<a.size;){let x=cr.readSync(s,u,0,c,f);if(x===0)break;f+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof s=="number")try{cr.closeSync(s)}catch{}}},em=(t,e)=>{let r=new di(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("end",c),cr.stat(a,(u,x)=>{if(u)f(u);else{let h=new Va(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},lr=fi(Qg,em,t=>new di(t),t=>new di(t),(t,e)=>{e?.length&&yf(t,e),t.noResume||Xg(t)}),bf=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:nm,parse:Ud}=tm,tc=t=>{let e="",r=Ud(t);for(;nm(t)||r.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(s.length),e+=s,r=Ud(t)}return[e,t]},Ds=["|","<",">","?",":"],nc=Ds.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),rm=new Map(Ds.map((t,e)=>[t,nc[e]])),im=new Map(nc.map((t,e)=>[t,Ds[e]])),qd=t=>Ds.reduce((e,r)=>e.split(r).join(rm.get(r)),t),sm=t=>nc.reduce((e,r)=>e.split(r).join(im.get(r)),t),Ef=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),ni(e)+"/"+t):Z(t),om=16*1024*1024,Hd=Symbol("process"),jd=Symbol("file"),Gd=Symbol("directory"),La=Symbol("symlink"),Wd=Symbol("hardlink"),Yr=Symbol("header"),hs=Symbol("read"),Na=Symbol("lstat"),ps=Symbol("onlstat"),Ma=Symbol("onread"),Ba=Symbol("onreadlink"),za=Symbol("openfile"),Fa=Symbol("onopenfile"),rn=Symbol("close"),Ss=Symbol("mode"),Ua=Symbol("awaitDrain"),ba=Symbol("ondrain"),_t=Symbol("prefix"),vf=class extends On{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=Xa(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||om,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let s=!1;if(!this.preservePaths){let[c,f]=tc(this.path);c&&typeof f=="string"&&(this.path=f,s=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=sm(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||Fd.resolve(this.cwd,t)),this.path===""&&(this.path="./"),s&&this.warn("TAR_ENTRY_INFO",`stripping ${s} from absolute path`,{entry:this,path:s+this.path});let a=this.statCache.get(this.absolute);a?this[ps](a):this[Na]()}warn(t,e,r={}){return Rs(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Na](){wt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ps](e)})}[ps](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=dm(t),this.emit("stat",t),this[Hd]()}[Hd](){switch(this.type){case"File":return this[jd]();case"Directory":return this[Gd]();case"SymbolicLink":return this[La]();default:return this.end()}}[Ss](t){return bf(t,this.type==="Directory",this.portable)}[_t](t){return Ef(t,this.prefix)}[Yr](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Pn({path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](this.linkpath):this.linkpath,mode:this[Ss](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Es({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[Gd](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Yr](),this.end()}[La](){wt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ba](e)})}[Ba](t){this.linkpath=Z(t),this[Yr](),this.end()}[Wd](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(Fd.relative(this.cwd,t)),this.stat.size=0,this[Yr](),this.end()}[jd](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[Wd](e);this.linkCache.set(t,this.absolute)}if(this[Yr](),this.stat.size===0)return this.end();this[za]()}[za](){wt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Fa](e)})}[Fa](t){if(this.fd=t,this.#e)return this[rn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[hs]()}[hs](){let{fd:t,buf:e,offset:r,length:s,pos:a}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");wt.read(t,e,r,s,a,(c,f)=>{if(c)return this[rn](()=>this.emit("error",c));this[Ma](f)})}[rn](t=()=>{}){this.fd!==void 0&&wt.close(this.fd,t)}[Ma](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[ba]():this[Ua](()=>this[ba]())}[Ua](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let s=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[ba](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[rn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[hs]()}},am=class extends vf{sync=!0;[Na](){this[ps](wt.lstatSync(this.absolute))}[La](){this[Ba](wt.readlinkSync(this.absolute))}[za](){this[Fa](wt.openSync(this.absolute,"r"))}[hs](){let t=!0;try{let{fd:e,buf:r,offset:s,length:a,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let f=wt.readSync(e,r,s,a,c);this[Ma](f),t=!1}finally{if(t)try{this[rn](()=>{})}catch{}}}[Ua](t){t()}[rn](t=()=>{}){this.fd!==void 0&&wt.closeSync(this.fd),t()}},cm=class extends On{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return Rs(this,t,e,r)}constructor(t,e={}){let r=Xa(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:s}=t;if(s==="Unsupported")throw new Error("writing entry that should be ignored");this.type=s,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Z(t.path),this.mode=t.mode!==void 0?this[Ss](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let a=!1;if(!this.preservePaths){let[f,u]=tc(this.path);f&&typeof u=="string"&&(this.path=u,a=f)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Pn({path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),a&&this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute path`,{entry:this,path:a+this.path}),this.header.encode()&&!this.noPax&&super.write(new Es({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[_t](t){return Ef(t,this.prefix)}[Ss](t){return bf(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let s=t.length;if(s>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=s,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},dm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",fm=class dr{tail;head;length=0;static create(e=[]){return new dr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,s=e.prev;return r&&(r.prev=s),s&&(s.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=s),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,s=e.length;r<s;r++)lm(this,e[r]);return this.length}unshift(...e){for(var r=0,s=e.length;r<s;r++)xm(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let s=this.head,a=0;s;a++)e.call(r,s.value,a,this),s=s.next}forEachReverse(e,r){r=r||this;for(let s=this.tail,a=this.length-1;s;a--)e.call(r,s.value,a,this),s=s.prev}get(e){let r=0,s=this.head;for(;s&&r<e;r++)s=s.next;if(r===e&&s)return s.value}getReverse(e){let r=0,s=this.tail;for(;s&&r<e;r++)s=s.prev;if(r===e&&s)return s.value}map(e,r){r=r||this;let s=new dr;for(let a=this.head;a;)s.push(e.call(r,a.value,this)),a=a.next;return s}mapReverse(e,r){r=r||this;var s=new dr;for(let a=this.tail;a;)s.push(e.call(r,a.value,this)),a=a.prev;return s}reduce(e,r){let s,a=this.head;if(arguments.length>1)s=r;else if(this.head)a=this.head.next,s=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;a;c++)s=e(s,a.value,c),a=a.next;return s}reduceReverse(e,r){let s,a=this.tail;if(arguments.length>1)s=r;else if(this.tail)a=this.tail.prev,s=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;a;c--)s=e(s,a.value,c),a=a.prev;return s}toArray(){let e=new Array(this.length);for(let r=0,s=this.head;s;r++)e[r]=s.value,s=s.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,s=this.tail;s;r++)e[r]=s.value,s=s.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.head,c=0;for(c=0;a&&c<e;c++)a=a.next;for(;a&&c<r;c++,a=a.next)s.push(a.value);return s}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.length,c=this.tail;for(;c&&a>r;a--)c=c.prev;for(;c&&a>e;a--,c=c.prev)s.push(c.value);return s}splice(e,r=0,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let a=this.head;for(let f=0;a&&f<e;f++)a=a.next;let c=[];for(let f=0;a&&f<r;f++)c.push(a.value),a=this.removeNode(a);a?a!==this.tail&&(a=a.prev):a=this.tail;for(let f of s)a=um(this,a,f);return c}reverse(){let e=this.head,r=this.tail;for(let s=e;s;s=s.prev){let a=s.prev;s.prev=s.next,s.next=a}return this.head=r,this.tail=e,this}};function um(t,e,r){let s=e,a=e?e.next:t.head,c=new rc(r,s,a,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function lm(t,e){t.tail=new rc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function xm(t,e){t.head=new rc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var rc=class{list;next;prev;value;constructor(t,e,r,s){this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},$d=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Yd=Buffer.alloc(1024),gs=Symbol("onStat"),Jr=Symbol("ended"),dt=Symbol("queue"),Zr=Symbol("queue"),Qt=Symbol("current"),An=Symbol("process"),Vr=Symbol("processing"),ds=Symbol("processJob"),ft=Symbol("jobs"),Ea=Symbol("jobDone"),ms=Symbol("addFSEntry"),Jd=Symbol("addTarEntry"),qa=Symbol("stat"),Ha=Symbol("readdir"),ws=Symbol("onreaddir"),_s=Symbol("pipe"),Zd=Symbol("entry"),va=Symbol("entryOpt"),ys=Symbol("writeEntryClass"),Sf=Symbol("write"),Sa=Symbol("ondrain"),ks=class extends On{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[ys];onWriteEntry;[dt];[Zr]=new Map;[ft]=0;[Vr]=!1;[Jr]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[ys]=vf,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new bg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new vg(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Ig(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[Sa]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Sa]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[dt]=new fm,this[ft]=0,this.jobs=Number(t.jobs)||4,this[Vr]=!1,this[Jr]=!1}[Sf](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[Jr]=!0,this[An](),r&&r(),this}write(t){if(this[Jr])throw new Error("write after end");return t instanceof _f?this[Jd](t):this[ms](t),this.flowing}[Jd](t){let e=Z(Kd.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new $d(t.path,e);r.entry=new cm(t,this[va](r)),r.entry.on("end",()=>this[Ea](r)),this[ft]+=1,this[dt].push(r)}this[An]()}[ms](t){let e=Z(Kd.resolve(this.cwd,t));this[dt].push(new $d(t,e)),this[An]()}[qa](t){t.pending=!0,this[ft]+=1;let e=this.follow?"stat":"lstat";vs[e](t.absolute,(r,s)=>{t.pending=!1,this[ft]-=1,r?this.emit("error",r):this[gs](t,s)})}[gs](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[Qt])this[ds](t);else{let r=`${e.dev}:${e.ino}`,s=this[Zr].get(r);s?s.push(t):this[Zr].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[An]()}[Ha](t){t.pending=!0,this[ft]+=1,vs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[ft]-=1,e)return this.emit("error",e);this[ws](t,r)})}[ws](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[An]()}[An](){if(!this[Vr]){this[Vr]=!0;for(let t=this[dt].head;t&&this[ft]<this.jobs;t=t.next)if(this[ds](t.value),t.value.ignore){let e=t.next;this[dt].removeNode(t),t.next=e}this[Vr]=!1,this[Jr]&&this[dt].length===0&&this[ft]===0&&(this.zip?this.zip.end(Yd):(super.write(Yd),super.end()))}}get[Qt](){return this[dt]&&this[dt].head&&this[dt].head.value}[Ea](t){this[dt].shift(),this[ft]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,s=this[Zr].get(r);if(s){this[Zr].delete(r);for(let a of s)a.pending=!1,this[ds](a)}}this[An]()}[ds](t){if(t.pending&&t.pendingLink&&t===this[Qt]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[Qt]&&!t.piped&&this[_s](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[gs](t,e):this[qa](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[ws](t,e):this[Ha](t),!t.readdir)return}if(t.entry=this[Zd](t),!t.entry){t.ignore=!0;return}t===this[Qt]&&!t.piped&&this[_s](t)}}}[va](t){return{onwarn:(e,r,s)=>this.warn(e,r,s),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Zd](t){this[ft]+=1;try{return new this[ys](t.path,this[va](t)).on("end",()=>this[Ea](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Sa](){this[Qt]&&this[Qt].entry&&this[Qt].entry.resume()}[_s](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[ms](c+s)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",s=>{r.write(s)||e.pause()}):e.on("data",s=>{super.write(s)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Rs(this,t,e,r)}},ic=class extends ks{sync=!0;constructor(t){super(t),this[ys]=am}pause(){}resume(){}[qa](t){let e=this.follow?"statSync":"lstatSync";this[gs](t,vs[e](t.absolute))}[Ha](t){this[ws](t,vs.readdirSync(t.absolute))}[_s](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[ms](c+s)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",s=>{r.write(s)}):e.on("data",s=>{super[Sf](s)})}},hm=(t,e)=>{let r=new ic(t),s=new uf(t.file,{mode:t.mode||438});r.pipe(s),If(r,e)},pm=(t,e)=>{let r=new ks(t),s=new Ts(t.file,{mode:t.mode||438});r.pipe(s);let a=new Promise((c,f)=>{s.on("error",f),s.on("close",c),r.on("error",f)});return Cf(r,e).catch(c=>r.emit("error",c)),a},If=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?lr({file:lf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Cf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await lr({file:lf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(r);t.end()},gm=(t,e)=>{let r=new ic(t);return If(r,e),r},mm=(t,e)=>{let r=new ks(t);return Cf(r,e).catch(s=>r.emit("error",s)),r},mv=fi(hm,pm,gm,mm,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),_m=process.env.__FAKE_PLATFORM__||process.platform,Df=_m==="win32",{O_CREAT:kf,O_NOFOLLOW:Vd,O_TRUNC:Pf,O_WRONLY:Of}=Rf.constants,Lf=Number(process.env.__FAKE_FS_O_FILENAME__)||Rf.constants.UV_FS_O_FILEMAP||0,ym=Df&&!!Lf,bm=512*1024,Em=Lf|Pf|kf|Of,Xd=!Df&&typeof Vd=="number"?Vd|Pf|kf|Of:null,Nf=Xd!==null?()=>Xd:ym?t=>t<bm?Em:"w":()=>"w",ja=(t,e,r)=>{try{return Ps.lchownSync(t,e,r)}catch(s){if(s?.code!=="ENOENT")throw s}},Is=(t,e,r,s)=>{Ps.lchown(t,e,r,a=>{s(a&&a?.code!=="ENOENT"?a:null)})},vm=(t,e,r,s,a)=>{if(e.isDirectory())Mf(ri.resolve(t,e.name),r,s,c=>{if(c)return a(c);let f=ri.resolve(t,e.name);Is(f,r,s,a)});else{let c=ri.resolve(t,e.name);Is(c,r,s,a)}},Mf=(t,e,r,s)=>{Ps.readdir(t,{withFileTypes:!0},(a,c)=>{if(a){if(a.code==="ENOENT")return s();if(a.code!=="ENOTDIR"&&a.code!=="ENOTSUP")return s(a)}if(a||!c.length)return Is(t,e,r,s);let f=c.length,u=null,x=h=>{if(!u){if(h)return s(u=h);if(--f===0)return Is(t,e,r,s)}};for(let h of c)vm(t,h,e,r,x)})},Sm=(t,e,r,s)=>{e.isDirectory()&&Bf(ri.resolve(t,e.name),r,s),ja(ri.resolve(t,e.name),r,s)},Bf=(t,e,r)=>{let s;try{s=Ps.readdirSync(t,{withFileTypes:!0})}catch(a){let c=a;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return ja(t,e,r);throw c}for(let a of s)Sm(t,a,e,r);return ja(t,e,r)},zf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Os=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Cm=(t,e)=>{Ve.stat(t,(r,s)=>{(r||!s.isDirectory())&&(r=new zf(t,r?.code||"ENOTDIR")),e(r)})},Tm=(t,e,r)=>{t=Z(t);let s=e.umask??18,a=e.mode|448,c=(a&s)!==0,f=e.uid,u=e.gid,x=typeof f=="number"&&typeof u=="number"&&(f!==e.processUid||u!==e.processGid),h=e.preserve,w=e.unlink,E=Z(e.cwd),C=(b,v)=>{b?r(b):v&&x?Mf(v,f,u,I=>C(I)):c?Ve.chmod(t,a,r):r()};if(t===E)return Cm(t,C);if(h)return Im.mkdir(t,{mode:a,recursive:!0}).then(b=>C(null,b??void 0),C);let y=Z(Cs.relative(E,t)).split("/");Ga(E,y,a,w,E,void 0,C)},Ga=(t,e,r,s,a,c,f)=>{if(e.length===0)return f(null,c);let u=e.shift(),x=Z(Cs.resolve(t+"/"+u));Ve.mkdir(x,r,Ff(x,e,r,s,a,c,f))},Ff=(t,e,r,s,a,c,f)=>u=>{u?Ve.lstat(t,(x,h)=>{if(x)x.path=x.path&&Z(x.path),f(x);else if(h.isDirectory())Ga(t,e,r,s,a,c,f);else if(s)Ve.unlink(t,w=>{if(w)return f(w);Ve.mkdir(t,r,Ff(t,e,r,s,a,c,f))});else{if(h.isSymbolicLink())return f(new Os(t,t+"/"+e.join("/")));f(u)}}):(c=c||t,Ga(t,e,r,s,a,c,f))},Am=t=>{let e=!1,r;try{e=Ve.statSync(t).isDirectory()}catch(s){r=s?.code}finally{if(!e)throw new zf(t,r??"ENOTDIR")}},Rm=(t,e)=>{t=Z(t);let r=e.umask??18,s=e.mode|448,a=(s&r)!==0,c=e.uid,f=e.gid,u=typeof c=="number"&&typeof f=="number"&&(c!==e.processUid||f!==e.processGid),x=e.preserve,h=e.unlink,w=Z(e.cwd),E=b=>{b&&u&&Bf(b,c,f),a&&Ve.chmodSync(t,s)};if(t===w)return Am(w),E();if(x)return E(Ve.mkdirSync(t,{mode:s,recursive:!0})??void 0);let C=Z(Cs.relative(w,t)).split("/"),y;for(let b=C.shift(),v=w;b&&(v+="/"+b);b=C.shift()){v=Z(Cs.resolve(v));try{Ve.mkdirSync(v,s),y=y||v}catch{let I=Ve.lstatSync(v);if(I.isDirectory())continue;if(h){Ve.unlinkSync(v),Ve.mkdirSync(v,s),y=y||v;continue}else if(I.isSymbolicLink())return new Os(v,v+"/"+C.join("/"))}}return E(y)},Ia=Object.create(null),Qd=1e4,rr=new Set,Dm=t=>{rr.has(t)?rr.delete(t):Ia[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),rr.add(t);let e=Ia[t],r=rr.size-Qd;if(r>Qd/10){for(let s of rr)if(rr.delete(s),delete Ia[s],--r<=0)break}return e},km=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Pm=km==="win32",Om=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let s=e.at(-1);return s!==void 0&&(r=Uf(s,r)),e.push(r||"/"),e},[]),Lm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Pm?["win32 parallelization disabled"]:t.map(s=>ni(Uf(Dm(s))));let r=new Set(t.map(s=>Om(s)).reduce((s,a)=>s.concat(a)));this.#n.set(e,{dirs:r,paths:t});for(let s of t){let a=this.#e.get(s);a?a.push(e):this.#e.set(s,[e])}for(let s of r){let a=this.#e.get(s);if(!a)this.#e.set(s,[new Set([e])]);else{let c=a.at(-1);c instanceof Set?c.add(e):a.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(s=>s&&s[0]===t)&&r.every(s=>s&&s[0]instanceof Set&&s[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:s}=e,a=new Set;for(let c of r){let f=this.#e.get(c);if(!f||f?.[0]!==t)continue;let u=f[1];if(!u){this.#e.delete(c);continue}if(f.shift(),typeof u=="function")a.add(u);else for(let x of u)a.add(x)}for(let c of s){let f=this.#e.get(c),u=f?.[0];if(!(!f||!(u instanceof Set)))if(u.size===1&&f.length===1){this.#e.delete(c);continue}else if(u.size===1){f.shift();let x=f[0];typeof x=="function"&&a.add(x)}else u.delete(t)}return this.#r.delete(t),a.forEach(c=>this.#i(c)),!0}},Nm=()=>process.umask(),ef=Symbol("onEntry"),Wa=Symbol("checkFs"),tf=Symbol("checkFs2"),Ka=Symbol("isReusable"),nt=Symbol("makeFs"),$a=Symbol("file"),Ya=Symbol("directory"),bs=Symbol("link"),nf=Symbol("symlink"),rf=Symbol("hardlink"),ei=Symbol("ensureNoSymlink"),sf=Symbol("unsupported"),of=Symbol("checkPath"),Ca=Symbol("stripAbsolutePath"),sn=Symbol("mkdir"),ke=Symbol("onError"),fs=Symbol("pending"),af=Symbol("pend"),ir=Symbol("unpend"),Ta=Symbol("ended"),Aa=Symbol("maybeClose"),Ja=Symbol("skip"),ii=Symbol("doChown"),si=Symbol("uid"),oi=Symbol("gid"),ai=Symbol("checkedCwd"),Mm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,ci=Mm==="win32",Bm=1024,zm=(t,e)=>{if(!ci)return X.unlink(t,e);let r=t+".DELETE."+Af(16).toString("hex");X.rename(t,r,s=>{if(s)return e(s);X.unlink(r,e)})},Fm=t=>{if(!ci)return X.unlinkSync(t);let e=t+".DELETE."+Af(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},cf=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,sc=class extends di{[Ta]=!1;[ai]=!1;[fs]=0;reservations=new Lm;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[Ta]=!0,this[Aa]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Bm,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||ci,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Se.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Nm():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[ef](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Aa](){this[Ta]&&this[fs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ca](t,e){let r=t[e],{type:s}=t;if(!r||this.preservePaths)return!0;let[a,c]=tc(r),f=c.replaceAll(/\\/g,"/").split("/");if(f.includes("..")||ci&&/^[a-z]:\.\.$/i.test(f[0]??"")){if(e==="path"||s==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Se.posix.dirname(t.path),x=Se.posix.normalize(Se.posix.join(u,f.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return a&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute ${e}`,{entry:t,[e]:r})),!0}[of](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let s=Z(String(t.linkpath)).split("/");if(s.length>=this.strip)t.linkpath=s.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Ca](t,"path")||!this[Ca](t,"linkpath"))return!1;if(t.absolute=Se.isAbsolute(t.path)?Z(Se.resolve(t.path)):Z(Se.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:s}=Se.win32.parse(String(t.absolute));t.absolute=s+qd(String(t.absolute).slice(s.length));let{root:a}=Se.win32.parse(t.path);t.path=a+qd(t.path.slice(a.length))}return!0}[ef](t){if(!this[of](t))return t.resume();switch(wm.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Wa](t);default:return this[sf](t)}}[ke](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[ir](),e.resume())}[sn](t,e,r){Tm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[ii](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[si](t){return cf(this.uid,t.uid,this.processUid)}[oi](t){return cf(this.gid,t.gid,this.processGid)}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new Ts(String(t.absolute),{flags:Nf(t.size),mode:r,autoClose:!1});s.on("error",u=>{s.fd&&X.close(s.fd,()=>{}),s.write=()=>!0,this[ke](u,t),e()});let a=1,c=u=>{if(u){s.fd&&X.close(s.fd,()=>{}),this[ke](u,t),e();return}--a===0&&s.fd!==void 0&&X.close(s.fd,x=>{x?this[ke](x,t):this[ir](),e()})};s.on("finish",()=>{let u=String(t.absolute),x=s.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){a++;let h=t.atime||new Date,w=t.mtime;X.futimes(x,h,w,E=>E?X.utimes(u,h,w,C=>c(C&&E)):c())}if(typeof x=="number"&&this[ii](t)){a++;let h=this[si](t),w=this[oi](t);typeof h=="number"&&typeof w=="number"&&X.fchown(x,h,w,E=>E?X.chown(u,h,w,C=>c(C&&E)):c())}c()});let f=this.transform&&this.transform(t)||t;f!==t&&(f.on("error",u=>{this[ke](u,t),e()}),t.pipe(f)),f.pipe(s)}[Ya](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[sn](String(t.absolute),r,s=>{if(s){this[ke](s,t),e();return}let a=1,c=()=>{--a===0&&(e(),this[ir](),t.resume())};t.mtime&&!this.noMtime&&(a++,X.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ii](t)&&(a++,X.chown(String(t.absolute),Number(this[si](t)),Number(this[oi](t)),c)),c()})}[sf](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[nf](t,e){let r=Z(Se.relative(this.cwd,Se.resolve(Se.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[ei](t,this.cwd,r,()=>this[bs](t,String(t.linkpath),"symlink",e),s=>{this[ke](s,t),e()})}[rf](t,e){let r=Z(Se.resolve(this.cwd,String(t.linkpath))),s=Z(String(t.linkpath)).split("/");this[ei](t,this.cwd,s,()=>this[bs](t,r,"link",e),a=>{this[ke](a,t),e()})}[ei](t,e,r,s,a){let c=r.shift();if(this.preservePaths||c===void 0)return s();let f=Se.resolve(e,c);X.lstat(f,(u,x)=>{if(u)return s();if(x?.isSymbolicLink())return a(new Os(f,Se.resolve(f,r.join("/"))));this[ei](t,f,r,s,a)})}[af](){this[fs]++}[ir](){this[fs]--,this[Aa]()}[Ja](t){this[ir](),t.resume()}[Ka](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!ci}[Wa](t){this[af]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[tf](t,r))}[tf](t,e){let r=f=>{e(f)},s=()=>{this[sn](this.cwd,this.dmode,f=>{if(f){this[ke](f,t),r();return}this[ai]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let f=Z(Se.dirname(String(t.absolute)));if(f!==this.cwd)return this[sn](f,this.dmode,u=>{if(u){this[ke](u,t),r();return}c()})}c()},c=()=>{X.lstat(String(t.absolute),(f,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Ja](t),r();return}if(f||this[Ka](t,u))return this[nt](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,h=w=>this[nt](w??null,t,r);return x?X.chmod(String(t.absolute),Number(t.mode),h):h()}if(t.absolute!==this.cwd)return X.rmdir(String(t.absolute),x=>this[nt](x??null,t,r))}if(t.absolute===this.cwd)return this[nt](null,t,r);zm(String(t.absolute),x=>this[nt](x??null,t,r))})};this[ai]?a():s()}[nt](t,e,r){if(t){this[ke](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[$a](e,r);case"Link":return this[rf](e,r);case"SymbolicLink":return this[nf](e,r);case"Directory":case"GNUDumpDir":return this[Ya](e,r)}}[bs](t,e,r,s){X[r](e,String(t.absolute),a=>{a?this[ke](a,t):(this[ir](),t.resume()),s()})}},Xr=t=>{try{return[null,t()]}catch(e){return[e,null]}},qf=class extends sc{sync=!0;[nt](t,e){return super[nt](t,e,()=>{})}[Wa](t){if(!this[ai]){let a=this[sn](this.cwd,this.dmode);if(a)return this[ke](a,t);this[ai]=!0}if(t.absolute!==this.cwd){let a=Z(Se.dirname(String(t.absolute)));if(a!==this.cwd){let c=this[sn](a,this.dmode);if(c)return this[ke](c,t)}}let[e,r]=Xr(()=>X.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ja](t);if(e||this[Ka](t,r))return this[nt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[f]=c?Xr(()=>{X.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[nt](f,t)}let[a]=Xr(()=>X.rmdirSync(String(t.absolute)));this[nt](a,t)}let[s]=t.absolute===this.cwd?[]:Xr(()=>Fm(String(t.absolute)));this[nt](s,t)}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=f=>{let u;try{X.closeSync(a)}catch(x){u=x}(f||u)&&this[ke](f||u,t),e()},a;try{a=X.openSync(String(t.absolute),Nf(t.size),r)}catch(f){return s(f)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",f=>this[ke](f,t)),t.pipe(c)),c.on("data",f=>{try{X.writeSync(a,f,0,f.length)}catch(u){s(u)}}),c.on("end",()=>{let f=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,x=t.mtime;try{X.futimesSync(a,u,x)}catch(h){try{X.utimesSync(String(t.absolute),u,x)}catch{f=h}}}if(this[ii](t)){let u=this[si](t),x=this[oi](t);try{X.fchownSync(a,Number(u),Number(x))}catch(h){try{X.chownSync(String(t.absolute),Number(u),Number(x))}catch{f=f||h}}}s(f)})}[Ya](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[sn](String(t.absolute),r);if(s){this[ke](s,t),e();return}if(t.mtime&&!this.noMtime)try{X.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ii](t))try{X.chownSync(String(t.absolute),Number(this[si](t)),Number(this[oi](t)))}catch{}e(),t.resume()}[sn](t,e){try{return Rm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[ei](t,e,r,s,a){if(this.preservePaths||r.length===0)return s();let c=e;for(let f of r){c=Se.resolve(c,f);let[u,x]=Xr(()=>X.lstatSync(c));if(u)return s();if(x.isSymbolicLink())return a(new Os(c,Se.resolve(e,r.join("/"))))}s()}[bs](t,e,r,s){let a=`${r}Sync`;try{X[a](e,String(t.absolute)),s(),t.resume()}catch(c){return this[ke](c,t)}}},Um=t=>{let e=new qf(t),r=t.file,s=Tf.statSync(r),a=t.maxReadSize||16*1024*1024;new og(r,{readSize:a,size:s.size}).pipe(e)},qm=(t,e)=>{let r=new sc(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("close",c),Tf.stat(a,(u,x)=>{if(u)f(u);else{let h=new Va(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},Hf=fi(Um,qm,t=>new qf(t),t=>new sc(t),(t,e)=>{e?.length&&yf(t,e)}),Hm=(t,e)=>{let r=new ic(t),s=!0,a,c;try{try{a=Ze.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")a=Ze.openSync(t.file,"w+");else throw x}let f=Ze.fstatSync(a),u=Buffer.alloc(512);e:for(c=0;c<f.size;c+=512){for(let w=0,E=0;w<512;w+=E){if(E=Ze.readSync(a,u,w,u.length-w,c+w),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let x=new Pn(u);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>f.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}s=!1,jm(t,r,c,a,e)}finally{if(s)try{Ze.closeSync(a)}catch{}}},jm=(t,e,r,s,a)=>{let c=new uf(t.file,{fd:s,start:r});e.pipe(c),Wm(e,a)},Gm=(t,e)=>{e=Array.from(e);let r=new ks(t),s=(a,c,f)=>{let u=(C,y)=>{C?Ze.close(a,b=>f(C)):f(null,y)},x=0;if(c===0)return u(null,0);let h=0,w=Buffer.alloc(512),E=(C,y)=>{if(C||y===void 0)return u(C);if(h+=y,h<512&&y)return Ze.read(a,w,h,w.length-h,x+h,E);if(x===0&&w[0]===31&&w[1]===139)return u(new Error("cannot append to compressed archives"));if(h<512)return u(null,x);let b=new Pn(w);if(!b.cksumValid)return u(null,x);let v=512*Math.ceil((b.size??0)/512);if(x+v+512>c||(x+=v+512,x>=c))return u(null,x);t.mtimeCache&&b.mtime&&t.mtimeCache.set(String(b.path),b.mtime),h=0,Ze.read(a,w,0,512,x,E)};Ze.read(a,w,0,512,x,E)};return new Promise((a,c)=>{r.on("error",c);let f="r+",u=(x,h)=>{if(x&&x.code==="ENOENT"&&f==="r+")return f="w+",Ze.open(t.file,f,u);if(x||!h)return c(x);Ze.fstat(h,(w,E)=>{if(w)return Ze.close(h,()=>c(w));s(h,E.size,(C,y)=>{if(C)return c(C);let b=new Ts(t.file,{fd:h,start:y});r.pipe(b),b.on("error",c),b.on("close",a),Km(r,e)})})};Ze.open(t.file,f,u)})},Wm=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?lr({file:jf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Km=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await lr({file:jf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r);t.end()},Qr=fi(Hm,Gm,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!hg(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),Pv=fi(Qr.syncFile,Qr.asyncFile,Qr.syncNoFile,Qr.asyncNoFile,(t,e=[])=>{Qr.validate?.(t,e),$m(t)}),$m=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,s)=>e(r,s)&&!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0)):(r,s)=>!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0))};$t();var bt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function ui(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Gf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Wf(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Kf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function xr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}var R=class extends Error{code;retriable;cause;constructor(e,r,s){super(r),this.name="BridgeError",this.code=e,this.retriable=s?.retriable??!1,s?.cause!==void 0&&(this.cause=s.cause)}};ee();Be();function Bt(t,e){if(ui(t)!=="cloud")throw new R("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ls(t){return t.startsWith("http://")||t.startsWith("https://")}function Ns(t){return t.endsWith("/")?t.slice(0,-1):t}ee();var Ms="1008033",$f="1289";var Yf="pbbp2",Jf="https://www.coze.cn",Zf="/api/coze_claw/resource/get_frontier_key",Jm="https://www.coze.cn",Zm="wss://frontier.coze.cn";function Bs(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Jm}function Vf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Zm}function hr(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,s=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),s&&(e["x-use-ppe"]=s),e}function xi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var li=j("handshake");async function oc(t){let e=Bs(t.endpoint),r=t.timeoutMs??1e4,s=`${Ns(e)}${Zf}?aid=${encodeURIComponent(Ms)}`,a={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...hr(t.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),r);li.info("frontier key handshake",{base:e});try{let u=await fetch(s,{method:"GET",headers:a,signal:c.signal}),x=u.headers.get("x-tt-logid")??"",h=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let b=await u.text().catch(()=>"");throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${b.slice(0,200)}`)}let w=await u.json();if(w.code!==void 0&&w.code!==0)throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${x}`);let E=w.data??{},C=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,y=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!C||!y){let b=JSON.stringify(w).slice(0,500);throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${b}`)}return li.info("handshake ok",{remoteDeviceId:y,logid:x,traceId:h}),{accessKey:C,deviceId:y}}catch(u){if(u instanceof R)throw li.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw li.warn("handshake timeout",{base:e,timeoutMs:r}),new R("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw li.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:x?.code,syscall:x?.syscall,cause:String(u).slice(0,300)}),new R("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(f)}}var ac=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Et="auto";function Xf(t){return{model:t.model??Et,...t.modelToken?{modelToken:t.modelToken}:{}}}function Qf(t){return!t||t===Et}function eu(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=ac,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||Et,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):Qf(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function tu(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||Et}"`):Qf(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${ac}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"'),t.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${t.modelInfo.contextWindow}`)),e}function nu(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function cc(t,e){let{ttEnv:r,usePpe:s}=xi(t),a={};return r&&(a["x-tt-env"]=r),s&&(a["x-use-ppe"]=s),e&&(a["x-mock-scenario"]=e),a}function ru(t,e,r){if(!t.modelToken)return{};let s=cc(e,r);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,f])=>`${c}:${f}`).join(`
|
|
119
|
+
`)}}function dc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function iu(t,e,r){if(!t.modelToken)return null;let s=t.model||Et,a=cc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let f={baseUrl:`${ac}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:s,name:s,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(a).length>0&&(f.headers=a),f}function su(t,e,r){if(!t.modelToken)return[];let s=cc(e,r),a=[];for(let[c,f]of Object.entries(s))a.push("-c",`model_providers.coze.http_headers.${c}="${f}"`);return a}var Pe=j("agent-handlers"),ou=5*1024*1024,nw=1,rw=6,iw=new Set(["node_modules",".git",".coze","dist","build",".next"]),zs=class{constructor(e){this.opts=e}opts;async listSkills(e){Bt(e._meta,"_agent/listSkills");let r=xr(e._meta),s=await this.loadAgentCfg(r),a=s?.workspace??Dt(r).workspace,c=s?.skills??[],f=[];for(let u of c){let x=vt(a,u.relPath,"SKILL.md");await Qm(x).then(w=>w.isFile()).catch(()=>!1)&&f.push(dw(u))}return{skills:f}}async addSkills(e){Bt(e._meta,"_agent/addSkills");let r=xr(e._meta),s=await this.requireAgentCfg(r),a=e.skills??[],c=[...s.skills??[]],f=new Map(c.map((x,h)=>[x.skillId,h])),u=[];for(let x of a){let h=await gc({agentId:r,workspace:s.workspace,framework:s.framework,skill:x});mc(c,f,h),u.push(x)}return await ji(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Bt(e._meta,"_agent/removeSkills");let r=xr(e._meta),s=await this.requireAgentCfg(r),a=new Set(e.skillIds??[]),c=s.skills??[],f=[];for(let u of c){if(!a.has(u.skillId)){f.push(u);continue}let x=vt(s.workspace,u.relPath);await Xm(x,{recursive:!0,force:!0}),Pe.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await ji(r,f),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let s=this.opts.agents.get(e);if(s)for(let[a,c]of s.sessions){if(!c.downstream)continue;let f=c.acpSessionId;if(f&&s.activeTriggers.has(f)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Pe.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:f});continue}let x=c.downstream;c.downstream=void 0,Pe.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:f}),x.stop(r).catch(h=>Pe.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:a,err:String(h)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Pe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,s=await qe(r);if(!s)throw new R("AGENT_NOT_FOUND",`agent not found: ${r}`);if(s.cozeIdentity===e.cozeIdentity)return Pe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Zn(s.workspace,s.framework,r,e.cozeIdentity)}catch(a){throw Pe.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:s.framework,workspace:s.workspace,err:String(a)}),new R("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(a)}`,{cause:a})}return s.cozeIdentity=e.cozeIdentity,await $e(s),Pe.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:s.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new R("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let s=await qe(r);return s?(s.disconnectedAt=Date.now(),s.disconnectReason=e.reason??"",await $e(s),Pe.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(Pe.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Bt(e._meta,"_agent/switchModel"),!e.agentId)throw new R("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:Et,s=await qe(e.agentId);if(!s)throw new R("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);s.model=r,e.modelInfo&&(s.modelInfo=e.modelInfo),await $e(s),Pe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return Pe.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=r,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(f=>Pe.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(f)}));let c=[];for(let[f,u]of a.allSessionQueues())c.push(u.enqueue(async()=>{let x=a.sessions.get(f);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Pe.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Bt(e._meta,bt.RESET),!e.agentId)throw new R("IPC_BAD_REQUEST",`${bt.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,bt.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Bt(e._meta,bt.REPAIR),!e.agentId)throw new R("IPC_BAD_REQUEST",`${bt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new R("IPC_BAD_REQUEST",`${bt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(s){Pe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(s)})}return await this.runDetailSync(e.agentId,bt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,s){if(!this.opts.detailSyncer){Pe.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){Pe.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:s,err:String(a)})}}async getFileTree(e){Bt(e._meta,"_agent/getFileTree");let r=e._meta,s=xr(r),a=await this.resolveWorkspace(s),c=e.filePath??"",f=this.safeJoin(a,c),u=await fc(f).catch(()=>null);if(!u)throw new R("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await zr(f,a))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=yw(e.depth);return u.isDirectory()?{tree:await _w(a,f,c,x)}:{tree:[{name:bw(c),path:xu(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Bt(e._meta,"_agent/getFileContent");let r=xr(e._meta),s=await this.resolveWorkspace(r);if(!e.filePath)throw new R("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(s,e.filePath),c=await fc(a).catch(()=>null);if(!c||!c.isFile())throw new R("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await zr(a,s))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>ou)throw new R("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${ou})`);let f=await au(a);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:c.size}:{content:f.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await qe(e).catch(()=>null))?.workspace??Dt(e).workspace}safeJoin(e,r){let s=xc(e,r||"."),a=pc(e,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${cu}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return s}loadAgentCfg(e){return qe(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new R("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function sw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new R("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new R("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function ow(t){return t==="claude-code"?vt(".claude","skills"):vt(".agents","skills")}var aw=3e4,cw=50*1024*1024,pr=3e4;async function gc(t){let{agentId:e,workspace:r,framework:s,skill:a}=t;if(!a.skillName)throw new R("IPC_BAD_REQUEST","skill missing skillName");let c=typeof a.content=="string"&&a.content.length>0,f=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!c&&!f)throw new R("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let u=sw(a.skillName),x=ow(s),h=vt(x,u),w=vt(r,h);if(await uc(w,{recursive:!0}),c){let C=Buffer.from(a.content,"utf8");hi(C.length),await lc(vt(w,"SKILL.md"),C,"utf8")}else{let C=await fw(a.downloadUrl);lw(C)?await gw(C,w):xw(C)?await hw(C,w):await lc(vt(w,"SKILL.md"),C.toString("utf8"),"utf8")}let E={skillId:a.skillId,skillName:a.skillName,relPath:h,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return Pe.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:h,source:c?"content":"downloadUrl"}),E}function mc(t,e,r){let s=e.get(r.skillId);if(s!==void 0){t[s]=r;return}e.set(r.skillId,t.length),t.push(r)}function dw(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function fw(t){if(!t)throw new R("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);hi(e);let r=uw(t);return hi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await au(e);return hi(r.length),r}if(Ls(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),aw);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new R("IPC_BAD_REQUEST",`fetch skill failed HTTP ${s.status} ${t}`);let a=await s.arrayBuffer();return hi(a.byteLength),Buffer.from(a)}finally{clearTimeout(r)}}throw new R("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function hi(t){if(t>cw)throw new R("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function uw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new R("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],s=e[3]??"";return r?Buffer.from(s,"base64"):Buffer.from(decodeURIComponent(s),"utf8")}function lw(t){return t.length>=2&&t[0]===31&&t[1]===139}function xw(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function hc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function hw(t,e){let r,s;try{r=new uu.default(t),s=r.getEntries()}catch(f){throw new R("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of s){let u=f.entryName;if(!u||hc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new R("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(h=>h===".."))throw new R("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=f.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new R("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let a=pw(s),c=xc(e);for(let f of s){if(hc(f.entryName))continue;let u=f.entryName;if(a&&u.startsWith(a)&&(u=u.slice(a.length)),!u)continue;let x=xc(e,u),h=pc(c,x);if(h.startsWith("..")||h==="..")throw new R("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(f.isDirectory){await uc(x,{recursive:!0});continue}await uc(ew(x),{recursive:!0});let w;try{w=f.getData()}catch(E){throw new R("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${E.message}`,{cause:E})}await lc(x,w)}}function pw(t){let e;for(let r of t){let s=r.entryName;if(!s||hc(s))continue;let a=s.indexOf("/");if(a<=0)return;let c=s.slice(0,a+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function gw(t,e){await mw(t);let r=Hf({cwd:e,strip:1}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`))},pr);try{await fu(du.from(t),r)}catch(c){throw c instanceof R?c:s?new R("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`):new R("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}}async function mw(t){let e=[],r=lr({onReadEntry:c=>{let f=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${f.slice(0,100)}`);return}if(f.startsWith("/")||f.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(f)){e.push(`tar entry absolute path: ${f}`);return}f.split(/[/\\]/).some(h=>h==="..")&&e.push(`tar entry contains '..': ${f}`)}}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`))},pr);try{await fu(du.from(t),r)}catch(c){throw s?new R("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`):new R("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}if(e.length>0)throw new R("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var ww=5e3;async function _w(t,e,r,s){return lu(t,e,r,s,{count:0})}async function lu(t,e,r,s,a){if(s<=0)return[];let c;try{c=await Vm(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let u of c){if(iw.has(u.name)||u.isSymbolicLink())continue;if(a.count>=ww){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=vt(e,u.name),h=tw(vt(r,u.name)),w=null;try{w=await fc(x)}catch{continue}if(w.isSymbolicLink())continue;a.count++;let E={name:u.name,path:xu(pc(t,x)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&s>1&&(E.children=await lu(t,x,h,s-1,a)),f.push(E)}return f.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),f}function yw(t){return!t||t<=0?nw:Math.min(t,rw)}function bw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function xu(t){return t.split(cu).join("/")}ee();import{readFileSync as j2}from"node:fs";import{dirname as W2,join as K2}from"node:path";import{fileURLToPath as Y2}from"node:url";var gr="0.1.74";var cn=j("agent-health-reporter"),Ew=1e4,pi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Ew}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),cn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),cn.info("heartbeat stopped"))}async tick(){if(this.inFlight){cn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){cn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let f of this.opts.core.agents.values()){let u=vw(f);if(!u)continue;let x={agentId:f.agentId,status:u};f.patToken&&(x.patToken=f.patToken),f.accountId&&(x.accountId=f.accountId),r.push(x)}if(r.length===0)return;let s={agents:r,bridgeVersion:gr,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",s,5e3)}catch(f){cn.warn("heartbeat batch send failed",{count:r.length,err:String(f)})}let c=a?.authFailures;if(c&&c.length>0&&(cn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(f){cn.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){cn.warn("onTickEnd hook failed",{err:String(r)})}}};function vw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}$t();import{mkdir as yc,rm as n_}from"node:fs/promises";_n();_n();import{spawnSync as kw}from"node:child_process";function gi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function mi(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function mr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function dn(t,e){return{jsonrpc:"2.0",id:t,error:e}}var Fs=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Q={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function hu(t){return"method"in t&&"id"in t&&t.id!==void 0}function pu(t){return"method"in t&&!("id"in t)}function Us(t){return!("method"in t)&&"id"in t}var Sw={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,NPX_CACHE_CORRUPT:Q.INTERNAL_ERROR};function Iw(t){if(t!=null)return t instanceof Error?{name:t.name,message:wi(t.message)}:typeof t=="string"?wi(t):typeof t=="object"?Tw(t):t}var Cw=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function wi(t){let e=t;for(let[r,s]of Cw)e=e.replace(r,s);return e}function Tw(t){let e={};for(let[r,s]of Object.entries(t))typeof s=="string"?e[r]=wi(s):e[r]=s;return e}function _i(t){if(t instanceof R){let e=Iw(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:Sw[t.code]??Q.INTERNAL_ERROR,message:wi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:wi(t instanceof Error?t.message:String(t))}}function gu(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",s=!!e&&typeof e.message=="string"&&!!e.message,a=s?e?.message:t.message,c=t.data;if(s&&e){let{message:f,...u}=e;c=u}return new R(r,a,{retriable:e?.retriable??!1,cause:c})}function wu(t){return`${JSON.stringify(t)}
|
|
120
|
+
`}var mu=10*1024*1024,qs=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>mu){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${mu} bytes`)}),[]}let r=this.buffer.split(`
|
|
121
|
+
`);this.buffer=r.pop()??"";let s=[];for(let a of r){let c=a.replace(/\r$/,"").trim();if(c)try{s.push(JSON.parse(c))}catch(f){this.onError?.({line:c,error:f})}}return s}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var yu={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},sS=Object.fromEntries(Object.entries(yu).map(([t,e])=>[e,t])),Aw={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},wr=class{seq=0;next(e,r){this.seq+=1;let s=yu[e]??Rw(e),a=Aw[s]??[],c=[s,String(this.seq)];if(a.length>0){let f=a.map(x=>_u(r?.[x]??"")),u=Dw(f).join(":");u&&c.push(u)}else r&&Object.values(r).some(f=>f)&&c.push(Object.values(r).filter(Boolean).map(f=>_u(String(f))).join(":"));return c.join("_")}reset(){this.seq=0}};function Rw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function _u(t){return t.replace(/[:_\s]+/g,"-")}function Dw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}$n();function fn(t,e){let r=process.env[t];if(!r)return e;let s=Number(r);return Number.isFinite(s)&&s>0?s:e}ee();var Pw=fn("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Ow=200,Lw=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function wc(t){return t.some(e=>Lw.test(e))}var Nw=fn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Mw=fn("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),bu=500;function Bw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=bu?t:`${e.slice(0,bu)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Eu(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),kw("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var St=class{constructor(e){this.opts=e;this.log=j(`downstream.${this.constructor.name}`),this.decoder=new qs({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new wr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new R("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Wn(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=r,r.stdout?.setEncoding("utf8"),r.stdout?.on("data",s=>{try{for(let a of this.decoder.push(s))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),r.stderr?.setEncoding("utf8"),r.stderr?.on("data",s=>{let a=s.trimEnd();this.stderrRing.push(a),this.stderrRing.length>Ow&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),r.stdin?.on("error",s=>{this.log.warn("child stdin error",{err:String(s)})}),r.stdout?.on("error",s=>{this.log.warn("child stdout error",{err:String(s)})}),r.stderr?.on("error",s=>{this.log.warn("child stderr error",{err:String(s)})}),r.on("exit",(s,a)=>{this.stopped=!0,(s!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:s,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&wc(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),mn(this.framework).catch(u=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(u)})})));try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(new R("AGENT_PROTOCOL_ERROR",`agent exited (${s}/${a})`));for(let f of this.exitHandlers)f(s,a)}),r.on("error",s=>{this.log.error("child error",{err:String(s)}),this.failAllPending(new R("AGENT_SPAWN_FAILED",String(s),{cause:s}))}),this.log.info("downstream started",{command:this.opts.command,pid:r.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let r=this.child,s=new Promise(c=>r.once("exit",()=>c()));Eu(r.pid,"SIGTERM");let a=setTimeout(()=>{r.killed||Eu(r.pid,"SIGKILL")},5e3);try{await s}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r=Nw,s=Mw){return this.call("session/prompt",e,r,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(mi("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(mr(e,r))}catch(s){this.log.warn("respondAgentRequest write failed",{id:e,err:String(s)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(dn(e,r))}catch(s){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(s)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,s=Pw,a=0){if(!this.child||this.stopped)return Promise.reject(new R("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),f=gi(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let w=r.sessionId;return typeof w=="string"?w:void 0})(),x=s>0&&Number.isFinite(s),h=a>0&&Number.isFinite(a);return new Promise((w,E)=>{let C={resolve:w,reject:E,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};x&&(C.timer=setTimeout(()=>{this.pending.delete(c),C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:s,...u?{sessionId:u}:{}}),E(new R("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s));let y=h?()=>{C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),C.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...u?{sessionId:u}:{}}),y?.();return}C.timer&&clearTimeout(C.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:a,...u?{sessionId:u}:{}}),E(new R("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;C.armFrameIdle=y,this.pending.set(c,C),y?.();try{this.writeFrame(f)}catch(b){C.timer&&clearTimeout(C.timer),C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),this.pending.delete(c),E(b)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new R("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(wu(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Us(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(gu(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new R("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Bw(e.result)}),r.resolve(e.result));return}if(pu(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.armFrameIdle?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(s=>this.log.warn("update handler failed (async)",{err:String(s)}))}catch(s){this.log.warn("update handler threw sync, swallowed",{err:String(s)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(hu(e)){let r=e;try{this.handleAgentRequest(r).catch(s=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(s)}))}catch(s){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(s)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(dn(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(s){this.log.error("agentRequestHandler threw",{method:e.method,err:String(s)});try{this.writeFrame(dn(e.id,_i(s)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var zw=Br("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function Fw(t){let e={};for(let[r,s]of Object.entries(t))s!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=s));return e}var Hs=class extends St{framework="claude-code";constructor(e){let r=wn("claude-code"),[s,a]=r?[r,[]]:["npx",["-y",zw]],c=e.command??s,f=e.args??a,u={command:c,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(u)}sanitizeEnv(e){return Fw(e)}};_n();import{mkdtempSync as Uw,rmSync as qw}from"node:fs";import{tmpdir as Hw}from"node:os";import{join as jw}from"node:path";var Gw=Br("codex")??"@zed-industries/codex-acp@^0.15",js=class extends St{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=wn("codex"),[s,a]=r?[r,[]]:["npx",["-y",Gw]],c=e.command??s,f=e.args??a,u=e.extraArgs?[...f,...e.extraArgs]:f,x=e.isolateCodexHome?Uw(jw(Hw(),"coze-bridge-codex-home-")):void 0,h=x?{...e.env??{},CODEX_HOME:x}:e.env,w={command:c,args:u,cwd:e.cwd,...h?{env:h}:{}};super(w),this.authMethodId=e.authMethodId,this.codexHomeDir=x}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{qw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Ww=3e4,_r=class extends St{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",s=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&s.push("--token",e.gatewayToken);let a={command:e.command,args:s,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Ww))}get acpSessionName(){return this.sessionName}};ee();Be();function _c(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}_n();var yr=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,s)=>{this.slots.push({task:e,resolve:r,reject:s}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var Gs=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new yr,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let s of this.sessionQueues.values())s.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,s]of this.sessions)yi(s),s.downstream&&(r.push(s.downstream.stop(e).catch(()=>{})),s.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function yi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}$n();ee();import{constants as vu,access as Kw}from"node:fs/promises";import{delimiter as $w,join as Yw}from"node:path";var un=j("framework-detector"),Su={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Jw=[".exe",".cmd",".bat",".ps1"],ln=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Wn,access:e.access??Kw}}async detect(e){let r=Su[e],s=await this.which(r);if(!s)return un.debug("framework binary not found",{framework:e,bin:r}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[c,f]=await Promise.all([this.probeVersion(s,a),e==="openclaw"?this.probeOpenclawDefaultAgent(s):Promise.resolve(null)]),u={path:s,version:c};return f&&(u.defaultAgent=f),u}async detectAll(){let e=await Promise.all(Object.keys(Su).map(async s=>[s,await this.detect(s)])),r={};for(let[s,a]of e)a&&(r[s]=a);return r}async which(e){let r=this.env.pathEnv.split($w).filter(Boolean),s=this.env.platform==="win32"?["",...Jw]:[""];for(let a of r)for(let c of s){let f=Yw(a,e+c);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?vu.F_OK:vu.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return un.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return un.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let s=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!s)return un.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let a=JSON.parse(s[0]);if(!Array.isArray(a))return un.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=a.find(f=>f?.isDefault===!0);return c?!c.id||!c.workspace?(un.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(un.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:a.length}),null)}catch(a){return un.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(a),matchHead:s[0].slice(0,200)}),null}}async probeVersion(e,r=[]){let s=await this.runProbe(e,[...r,"--version"]);return s&&(Vw(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(s=>{let a="",c=!1,f,u=x=>{c||(c=!0,f&&clearTimeout(f),s(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{x.kill("SIGKILL"),u(null)},15e3),x.stdout?.on("data",h=>{a+=h.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",h=>u({code:h,stdout:a}))}catch{u(null)}})}},Zw=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Vw(t){return t.replace(Zw,"")}import{spawn as Xw}from"node:child_process";import{homedir as Qw}from"node:os";import{join as e_}from"node:path";qi();ee();async function Tu(){let t=e_(Qw(),".openclaw/openclaw.json");return(await Jn(t))?.gateway?.auth?.token??""}var Iu=j("openclaw.config"),t_=[0,5e3,5e3],Cu="models.providers.",Ws="agents.defaults.models",Ks=class{command;env;retryDelaysMs;queue=new yr;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??t_}async withRetry(e,r){let s;for(let a=0;a<this.retryDelaysMs.length;a++){let c=this.retryDelaysMs[a]??0;c>0&&await new Promise(f=>setTimeout(f,c));try{return await r()}catch(f){s=f,Iu.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(f)})}}throw new R("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${s?.message??"unknown"}`)}runCli(e){return new Promise((r,s)=>{let a=Xw(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`exit ${f}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(s){let a=String(s);if(r.some(c=>a.includes(c)))return;throw s}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(s){Iu.warn(`${e} failed (best-effort)`,{configPath:r,err:String(s)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${Cu}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Cu}${e}`)}addModelToAllowlist(e,r){let s={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Ws}[${e}]`,()=>this.runCli(["config","set",Ws,JSON.stringify(s),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Ws}[${e}]`,`${Ws}.${e}`)}ensureAgent(e,r,s){let a=["agents","add",e,"--workspace",r,"--non-interactive"];return s&&a.push("--model",s),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Oe=j("agent-manager"),r_=(t,e,r,s,a,c,f,u,x)=>{switch(t){case"claude-code":{let h={...a?{...eu(a),...ru(a,f,u)}:{},...x??{},IS_SANDBOX:"1"};return new Hs({cwd:r,env:h})}case"codex":{let w=[...a?[...tu(a),...su(a,f,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...a?nu(a):{},...x??{}},C=!!a;return new js({cwd:r,...w.length>0?{extraArgs:w}:{},...Object.keys(E).length>0?{env:E}:{},...C?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new _r({command:e,cwd:r,agentId:s,...c?{sessionName:_c(c)}:{}})}};function bc(t){return t==="claude-code"||t==="codex"}var i_={path:"",version:"cloud-deployed"},s_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},o_=6e4,a_=fn("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),$s=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??r_,this.createTimeoutMs=e.createTimeoutMs??o_,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??a_,this.detectorFactory=e.detectorFactory??(()=>new ln)}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new R("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Ks({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new R("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new R("IPC_BAD_REQUEST","framework required");let r=ui(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let s=this.registry.get(e.agentId);if(s){if(s.framework!==e.framework)throw new R("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${s.framework})`);if(s.status==="error")Oe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await s.dispose("rebuild after error").catch(b=>Oe.warn("dispose stale agent failed (ignored)",{err:String(b)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==s.patToken){Oe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),s.setPatToken(e.patToken);let b=await qe(e.agentId,this.paths).catch(()=>null);b&&(b.patToken=e.patToken,await $e(b,this.paths))}if(s.deployType==="cloud"&&e.modelInfo){Oe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),s.setModelInfo(e.modelInfo);let b=await qe(e.agentId,this.paths).catch(()=>null);b&&(b.modelInfo=e.modelInfo,await $e(b,this.paths))}return Oe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:s.agentId,workspace:s.workspace,framework:s.framework}}}if(!r&&!this.config.frameworksCache?.[e.framework])throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Dt(e.agentId,this.paths),f=ui(e._meta),u=e.framework==="openclaw"&&f==="local",x=u?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,h=e.workspace??x??c.workspace,w=new AbortController,E=setTimeout(()=>w.abort(new R("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),C,y=!1;try{r&&bc(e.framework)&&await mn(e.framework,w.signal);let b=()=>{if(w.signal.aborted)throw w.signal.reason instanceof Error?w.signal.reason:new R("AGENT_TIMEOUT","_agent/create aborted")};await yc(c.root,{recursive:!0}),await yc(h,{recursive:!0}),await yc(c.logs,{recursive:!0}),b(),u||await Zn(h,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Y0(h),b();let v=await qe(e.agentId,this.paths).catch(()=>null),I=Xf({model:e.model??v?.model}),k=Gf(e._meta)??v?.accountId,L=e.patToken??v?.patToken,_=f==="cloud"?e.modelInfo??v?.modelInfo:void 0;if(C=new Gs({agentId:e.agentId,framework:e.framework,workspace:h,model:I.model??Et,deployType:f,...k?{accountId:k}:{},...L?{patToken:L}:{},..._?{modelInfo:_}:{}}),C.status="ok",v?.sessions){for(let[z,P]of Object.entries(v.sessions))C.sessions.set(z,{acpSessionId:P.acpSessionId,modelToken:P.modelToken,tokenGeneratedAt:P.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(v.sessions).length;F>0&&Oe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(C),y=!0;let T={agentId:e.agentId,framework:e.framework,workspace:h,cozeIdentity:e.cozeIdentity,createdAt:v?.createdAt??Date.now(),sessions:v?.sessions??{},model:I.model};f==="cloud"&&(T.deployType="cloud"),k&&(T.accountId=k),L&&(T.patToken=L),_&&(T.modelInfo=_),v?.skills&&(T.skills=v.skills),v?.agentName&&(T.agentName=v.agentName),v?.description&&(T.description=v.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,h):Oe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let O=e.initialSkills??[];if(O.length>0){let F=[...T.skills??[]],z=new Map(F.map((U,Y)=>[U.skillId,Y])),P=await Promise.allSettled(O.map(U=>gc({agentId:e.agentId,workspace:h,framework:e.framework,skill:U}))),N=0;for(let[U,Y]of P.entries()){let se=O[U];se&&(Y.status==="fulfilled"?(mc(F,z,Y.value),N++):Oe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:se.skillId,skillName:se.skillName,err:String(Y.reason)}))}N>0&&(T.skills=F,Oe.info("initialSkills installed",{agentId:e.agentId,installed:N,requested:O.length}))}return await $e(T,this.paths),Oe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:h,framework:e.framework}}catch(b){throw Oe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(b)}),y&&C&&(await C.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await n_(c.root,{recursive:!0,force:!0}).catch(v=>Oe.warn("rm agent dir failed (ignored)",{err:String(v)})),b instanceof R?b:new R("AGENT_SPAWN_FAILED",String(b),{cause:b})}finally{clearTimeout(E)}}async spawnSessionDownstream(e,r,s,a,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&bc(e.framework))u=i_;else throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(bc(e.framework)&&!wn(e.framework)){let w=Jo(e.framework);w&&(Oe.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([w.catch(()=>{}),new Promise(E=>setTimeout(E,this.spawnAwaitInstallMs))]))}let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;e.framework==="openclaw"?h=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:s,cozeEnv:a,mockScenario:c,command:u.path}):h=this.factory(e.framework,u.path,e.workspace,e.agentId,x,s,a,c,this.buildBinShimPathEnv());try{return await h.start(),await h.initialize(s_),h}catch(w){let E=h instanceof St?h.getStderrTail():[];E.length>0&&Oe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof R?w.code:"unknown",recentStderr:E});let C=wc(E);await h.stop("spawnSessionDownstream failed").catch(()=>{});let y=C?new R("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:w}):w;throw w instanceof R?new R(w.code,w.message,{retriable:w.retriable,cause:y}):new R("AGENT_SPAWN_FAILED",w instanceof Error?w.message:String(w),{cause:y})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:s,cloudSessionId:a,cozeEnv:c,mockScenario:f,command:u}=e,x=_c(a);if(r.deployType==="local"){let C=this.config.frameworksCache?.openclaw?.defaultAgent;if(!C?.id||!C.workspace){Oe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let b=await this.detectorFactory().detect("openclaw");if(b?.defaultAgent?.id&&b?.defaultAgent?.workspace)Oe.info("openclaw lazy re-detect success",{agentId:b.defaultAgent.id,workspace:b.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=b,C=b.defaultAgent;else throw new R("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent")}return new _r({command:u,cwd:C.workspace,agentId:C.id,sessionName:x})}let h=await Tu(),w=s?iu(s,c,f):null,E;if(w){let C=dc(a),b=w.models[0]?.id??Et,v=`${C}/${b}`;if(!this.ensuredProviders.has(v)){let I=this.getOpenclawConfig();await I.ensureProvider(C,w),await I.addModelToAllowlist(v),this.ensuredProviders.add(v)}E=v}return new _r({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let s=this.getOpenclawConfig();await s.deleteAgent(e),await s.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let s of e.sessions.keys()){let a=dc(s),c=`${a}/${e.model}`,f=!0;try{await r.removeProvider(a)}catch(u){f=!1,Oe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){f=!1,Oe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as Pu}from"node:crypto";import{promises as w_}from"node:fs";import{basename as Ou}from"node:path";import{promises as d_}from"node:fs";import{basename as f_}from"node:path";ee();var Au=j("file-upload"),u_="/api/coze_claw/file/agent_upload",l_=6e4;async function Ru(t,e={}){let s=`${Ns(Bs(e.handshakeBase))}${u_}`,a=e.timeoutMs??l_,c=await d_.readFile(t.path),f=new FormData;f.append("agent_id",t.agentId),f.append("session_id",t.sessionId),f.append("file_name",t.name),f.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...hr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),a);Au.info("file upload start",{url:s,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let w=await fetch(s,{method:"POST",headers:u,body:f,signal:x.signal}),E=w.headers.get("x-tt-logid")??"";if(!w.ok){let b=await w.text().catch(()=>"");throw new R("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${E}: ${b.slice(0,200)}`)}let C=await w.json();if(C.code!==void 0&&C.code!==0)throw new R("UPLOAD_FAILED",`upload code=${C.code} msg=${C.msg??"-"} logid=${E}`);let y=C.data?.file?.file_url;if(!y)throw new R("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(C).slice(0,200)}`);return Au.info("file upload ok",{uri:y,logid:E}),{uri:y}}catch(w){throw w instanceof R?w:w.name==="AbortError"?new R("UPLOAD_FAILED",`upload timeout (${a}ms) for ${f_(t.path)}`):new R("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(h)}}ee();import{promises as x_}from"node:fs";import{extname as h_}from"node:path";var p_=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function g_(t){return t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}var m_={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Du(t){let e=await x_.open(t,"r");try{let r=Buffer.alloc(16);if(await e.read(r,0,16,0),g_(r))return"image/webp";for(let s of p_)if(s.prefix.every((a,c)=>r[c]===a))return s.mime}finally{await e.close()}return m_[h_(t).toLowerCase()]??"application/octet-stream"}Be();var Ys=j("agent-send"),ku=50*1024*1024,__=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Lu(t,e,r){let s=t.get(e);if(!s)throw new R("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new R("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=s.sessions.get(r);if(!a)throw new R("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:s,runtime:a}}async function Nu(t,e,r,s,a,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,s,a);return}catch(h){u=h,x<2&&(Ys.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(w=>setTimeout(w,5e3)))}throw new R("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function Mu(t,e){let{session:r,runtime:s}=Lu(e.core,t.agentId,t.sessionId);if(!await zr(t.path,r.workspace))throw new R("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let a=await w_.stat(t.path).catch(()=>null);if(!a||!a.isFile())throw new R("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(a.size>ku)throw new R("FILE_TOO_LARGE",`${a.size} bytes > limit ${ku}`);let c=await Du(t.path);if(!__.has(c))throw new R("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(t.kind==="image"&&!c.startsWith("image/"))throw new R("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let f=t.name??Ou(t.path),u;try{u=await Ru({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:f,sizeBytes:a.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(h){throw Ys.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:a.size,mime:c,code:h instanceof R?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId:Pu(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:f,sizeBytes:a.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Nu(e,r,s,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Ys.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:f,bytes:a.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:a.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function Bu(t,e){let{session:r,runtime:s}=Lu(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new R("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let a=t.name??Ou(t.path),c={sessionUpdate:"group_file",messageId:Pu(),content:{uri:t.path,name:a,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Nu(e,r,s,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Ys.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:a,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function zu(t,e){let r=t.split(".").map(Number),s=e.split(".").map(Number),a=Math.max(r.length,s.length);for(let c=0;c<a;c++){let f=r[c]??0,u=s[c]??0;if(f<u)return!0;if(f>u)return!1}return!1}$n();ee();var It=j("coze-cli-installer"),Fu="@coze/cli@latest",y_="coze",Uu="0.1.7",b_=5e3,E_=5e3,v_=9e4,qu=1e4,bi=null,Js=!1;async function Ec(t,e={}){if(Js)return;if(bi)return bi;let r=e.exec??Kn;return bi=(async()=>{try{let s=await S_(y_,r),a=!1;if(s){let f=await I_(r);if(f===void 0)It.warn("coze-cli found but version unparseable, fall through to full install",{path:s});else if(zu(f,Uu))It.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:s,version:f,min:Uu}),a=!0;else{It.info("coze-cli already on PATH with sufficient version, skip",{path:s,version:f}),Js=!0;return}}let c=a?"upgrade-only":"full";It.info("coze-cli install start",{package:Fu,mode:c});try{await r("npm",["i","-g","--prefer-online",Fu],{timeout:v_,maxBuffer:10*1024*1024}),It.info("coze-cli install ok")}catch(f){It.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(a){Js=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:qu}),It.info("coze config set xTTEnv ok",{env:t.env})}catch(f){It.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:qu}),It.info("coze auth login ok")}catch(f){It.warn("coze auth login failed",{err:String(f)});return}Js=!0}finally{bi=null}})(),bi}async function S_(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:s}=await e(r,[t],{timeout:b_});return s.split(`
|
|
122
|
+
`)[0]?.trim()||void 0}catch{return}}async function I_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:E_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}qi();Be();var C_=10*6e4;function Hu(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?C_:e}function Zs(t){return Jn(t??te().configFile)}function br(t,e){return Ui(e??te().configFile,t)}import{randomBytes as G_}from"node:crypto";import{createReadStream as T_}from"node:fs";import{mkdir as A_,readFile as R_,realpath as D_,stat as k_,writeFile as P_}from"node:fs/promises";import{basename as O_,dirname as vc,join as L_,relative as N_,resolve as ju,sep as M_}from"node:path";import{createInterface as B_}from"node:readline";ee();var Wu=j("fs-rpc"),Ei=fn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Ku(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Ei)throw new R("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Ei} bytes`);let s=await Yu(t.path,e);return await A_(vc(s),{recursive:!0}),await P_(s,t.content,"utf8"),Wu.info("fs/write_text_file ok",{path:s,size:t.content.length}),null}async function $u(t,e){let r=await Yu(t.path,e),s=await k_(r),a=typeof t.line=="number"||typeof t.limit=="number";if(s.size>Ei&&!a)throw new R("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${s.size} bytes > ${Ei} bytes`);let c;if(a&&s.size>Ei)c=await z_(r,t.line??1,t.limit);else{let f=await R_(r,"utf8");if(a){let u=f.split(`
|
|
123
|
+
`),x=Math.max(0,(t.line??1)-1),h=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,h).join(`
|
|
124
|
+
`)}else c=f}return Wu.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function z_(t,e,r){let s=B_({input:T_(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),c=typeof r=="number"?a+r:Number.POSITIVE_INFINITY,f=[],u=0;try{for await(let x of s)if(u>=a&&u<c&&f.push(x),u++,u>=c)break}finally{s.close()}return f.join(`
|
|
125
|
+
`)}async function Yu(t,e){if(typeof t!="string"||t.length===0)throw new R("IPC_BAD_REQUEST","path must be a non-empty string");let[r,s]=await Promise.all([Gu(ju(e)),Gu(ju(t))]),a=N_(r,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${M_}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return s}async function Gu(t){let e=[],r=t;for(;r!==vc(r);)try{let s=await D_(r);return e.length?L_(s,...e.reverse()):s}catch{e.push(O_(r)),r=vc(r)}return t}ee();var Ju=j("prompt-multimodal"),Zu=10*1024*1024,F_=15e3,U_=6;async function Vu(t){let e=new Array(t.length),r=0;async function s(){for(;r<t.length;){let c=r++,f=t[c];f!==void 0&&(e[c]=await q_(f))}}let a=Array.from({length:Math.min(U_,t.length)},()=>s());return await Promise.all(a),e}function Xu(t){return t.some(e=>e.type==="image")}async function q_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ls(e.uri))return t;try{let{buf:r,contentType:s}=await j_(e.uri),a=e.mimeType||H_(s)||"application/octet-stream";return Ju.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:a}),{type:"image",data:r.toString("base64"),mimeType:a}}catch(r){return Ju.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function H_(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function j_(t){let e=new AbortController,r=setTimeout(()=>e.abort(),F_);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new Error(`HTTP ${s.status} ${s.statusText}`);let a=await s.arrayBuffer();if(a.byteLength>Zu)throw new Error(`image too large: ${a.byteLength} bytes (max ${Zu})`);return{buf:Buffer.from(a),contentType:s.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}$t();ee();var J=j("core"),W_=3e4,K_=/^(boe|ppe)_[A-Za-z0-9_-]+$/,$_=3e4,Vs=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new wr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Hu(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),J.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){J.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),J.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(s){J.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(s)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&J.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,s){let a=s.downstream;a&&(a.onUpdate(c=>{s.loadingSession||this.forwardUpdate(e,c)}),a.onAgentRequest(c=>{this.handleAgentRequest(e,a,c)}),a.onExit((c,f)=>{J.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:f}),yi(s),s.downstream=void 0,s.replySeq=0,s.acpSessionId&&e.activeTriggers.delete(s.acpSessionId),this.rejectPendingForDownstream(a,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let s=[];for(let[a,c]of this.pendingUpstream)c.downstream===e&&s.push(a);if(s.length!==0){J.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:s.length});for(let a of s){let c=this.pendingUpstream.get(a);if(c){this.pendingUpstream.delete(a),this.upstream.send(dn(a,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(f=>J.debug("send error response to upstream failed (ignored)",{err:String(f)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Q.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){J.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,s]of this.pendingUpstream)try{s.downstream.respondAgentRequestError(s.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,s]of this.pendingBridge)clearTimeout(s.timer),s.reject(new R("UPSTREAM_DISCONNECTED",`${s.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Us(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,s=e.params?._meta?.cozeEnv;s&&K_.test(s)?this.currentCozeEnv=s:s&&J.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:s});try{if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):J.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);r!==null&&await this.upstream.send(mr(r,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(mr(r,a));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(mr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):J.warn("drop unknown notification",{method:e.method})}catch(a){J.error("handleFrame failed",{method:e.method,err:String(a)}),r!==null&&await this.upstream.send(dn(r,_i(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new R("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,s=r._meta?.cozeAgentId;if(!s)throw new R("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(s);if(!a)throw this.disconnectedAgents.has(s)?new R("AGENT_DISCONNECTED",`agent ${s} has been disconnected; cloud must _agent/create to revive`):new R("AGENT_NOT_FOUND",`agent not found: ${s}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(a,e.method,r);let f=Date.now(),u=!1;try{let x=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,r));return u=!0,x}finally{J.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-f,ok:u})}}async dispatchSessionCall(e,r,s){e.lastActiveAt=Date.now();let{stripped:a}=Kf(s);switch(r){case"session/new":{let c=Y_();return J.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return J.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,f=c.sessionId;if(!f)throw new R("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,f);if(u.replySeq=0,await this.ensureDownstream(e,f,u),!u.downstream||!u.acpSessionId)throw new R("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=s._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(u.acpSessionId,x):e.activeTriggers.delete(u.acpSessionId);let h=Wf(s._meta);if(h?e.activeGroupIds.set(u.acpSessionId,h):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Xu(c.prompt))throw new R("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await Vu(c.prompt);try{let E=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:w});return u.lastActiveAt=Date.now(),E}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.reloadAfterTurn){u.reloadAfterTurn=!1;let E=u.downstream;E&&(u.downstream=void 0,J.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:u.acpSessionId}),E.stop("reload-after-turn").catch(C=>J.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:f,err:String(C)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,f,u)}}case"session/cancel":{let f=a.sessionId;if(!f)throw new R("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(f);if(e.hasSessionQueue(f)){let x=e.getSessionQueue(f);x.size>0&&(J.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:x.size}),x.dispose(new R("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${f}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new R("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let s=e.sessions.get(r);if(s)return s;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let s={sessionId:r,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(bt.GEN_MODEL_TOKEN,s,$_);if(!a?.modelToken)throw new R("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return a.modelToken}catch(a){throw a instanceof R&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new R("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,r,s){if(yi(s),s.downstream?.isAlive())return;if(!this.sessionSpawner)throw new R("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,f=s.spawnFailCount??0,u=s.spawnFailedAt??0;if(f>=a&&Date.now()-u<c)throw new R("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${f} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,s.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(h){throw s.spawnFailCount=f+1,s.spawnFailedAt=Date.now(),s.spawnFailCount>=a&&s.acpSessionId&&(J.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:s.acpSessionId}),s.acpSessionId=void 0),h}if(s.spawnFailCount=0,s.spawnFailedAt=void 0,s.downstream=x,this.attachRuntimeHooks(e,r,s),s.acpSessionId){s.loadingSession=!0;try{await x.sessionLoad({sessionId:s.acpSessionId,cwd:e.workspace}),J.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId})}catch(h){J.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId,err:String(h)}),s.acpSessionId=void 0;let w=await x.sessionNew({cwd:e.workspace});s.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{s.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});s.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&s.acpSessionId&&await x.afterSessionEstablished(s.acpSessionId)}armIdleTimer(e,r,s){if(yi(s),this.isRuntimeBusy(e,s)){J.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}s.idleTimer=setTimeout(()=>{if(s.idleTimer=void 0,this.isRuntimeBusy(e,s)){J.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,s);return}J.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let a=s.downstream;s.downstream=void 0,s.acpSessionId&&e.activeTriggers.delete(s.acpSessionId),a&&a.stop("idle timeout").catch(c=>J.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),s.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let s=r.downstream;if(!s)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===s)return!0;return!1}async sendAgentFileUpdate(e,r,s,a){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let f=e.activeTriggers.get(r.acpSessionId);f&&(c.cozeTriggerMsgId=f);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(mi("session/update",{sessionId:s,update:a,_meta:c}))}forwardUpdate(e,r){let s=r.sessionId,a=this.reverseSessionId(e,s);if(!a){J.debug("drop update for unknown session",{agentId:e.agentId,acpId:s});return}let c=e.sessions.get(a);if(!c){J.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(Z_(r)){J.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:s});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(s);u&&(f.cozeTriggerMsgId=u);let x=e.activeGroupIds.get(s);x&&(f.cozeGroupId=x),this.upstream.send(mi("session/update",{...r,sessionId:a,_meta:f})).catch(h=>J.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}handleAgentRequest(e,r,s){if(s.method==="session/request_permission"){this.forwardPermissionRequest(e,r,s);return}if(s.method==="fs/write_text_file"||s.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,s);return}J.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:s.method}),r.respondAgentRequestError(s.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${s.method}`})}async handleFsRpcRequest(e,r,s){try{let a=e.workspace;if(s.method==="fs/write_text_file"){let c=s.params??{},f=await Ku(c,a);r.respondAgentRequest(s.id,f)}else{let c=s.params??{},f=await $u(c,a);r.respondAgentRequest(s.id,f)}}catch(a){J.warn("fs rpc handler failed",{agentId:e.agentId,method:s.method,err:String(a)}),r.respondAgentRequestError(s.id,_i(a))}}forwardPermissionRequest(e,r,s){let a=this.upstreamIds.next("session/request_permission"),c=s.params??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let w=u?e.activeGroupIds.get(u):void 0;w&&(h.cozeGroupId=w);let E=u?this.reverseSessionId(e,u):void 0,C={...c,...E?{sessionId:E}:{},_meta:h};this.pendingUpstream.set(a,{agentRequestId:s.id,agentId:e.agentId,downstream:r,method:s.method}),J.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:u,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(y=>({optionId:y.optionId,kind:y.kind,name:y.name}))}),this.upstream.send(gi(a,"session/request_permission",C)).catch(y=>{this.pendingUpstream.delete(a),J.error("forward permission request failed",{agentId:e.agentId,err:String(y)}),r.respondAgentRequestError(s.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(y)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let a=r.value;e.error?(J.info("upstream \u2192 permission response (error)",{agentId:a.agentId,upstreamId:e.id,method:a.method,error:e.error}),a.downstream.respondAgentRequestError(a.agentRequestId,e.error)):(a.method==="session/request_permission"&&J_(e.result,a),J.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.agentRequestId,e.result));return}let s=this.lookupPending(this.pendingBridge,e.id,"bridge");if(s){this.pendingBridge.delete(s.key),clearTimeout(s.value.timer),e.error?s.value.reject(new Fs(e.error)):s.value.resolve(e.result);return}J.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,s){let a=e.get(r);if(a)return{value:a,key:r};if(typeof r=="number"){let c=String(r),f=e.get(c);if(f)return J.warn(`${s} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:f,key:c}}}sendRequest(e,r,s=W_){let a=this.upstreamIds.next(e);return new Promise((c,f)=>{let u=setTimeout(()=>{this.pendingBridge.delete(a),f(new R("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s);this.pendingBridge.set(a,{method:e,resolve:c,reject:f,timer:u}),this.upstream.send(gi(a,e,r)).catch(x=>{let h=this.pendingBridge.get(a);h&&(clearTimeout(h.timer),this.pendingBridge.delete(a)),f(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[s,a]of e.sessions){let c={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(c.acpSessionId=a.acpSessionId),r.set(s,c)}await Zo(e.agentId,r,this.paths)}catch(r){J.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[s,a]of e.sessions.entries())if(a.acpSessionId===r)return s}sendError(e,r,s){return this.upstream.send(dn(e,{code:r,message:s,data:{bridgeVersion:gr}}))}};function Y_(){return G_(16).toString("hex")}function J_(t,e){if(!t||typeof t!="object"){J.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){J.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let s=r.outcome;if(!s||typeof s!="object"){J.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=s.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&J.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function Z_(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let s=r;return s.type!=="text"||typeof s.text!="string"?!1:s.text.startsWith("Model metadata for `")}ee();Be();import{randomBytes as V_}from"node:crypto";import{chmod as X_,mkdir as Q_,writeFile as Qu}from"node:fs/promises";import{createServer as ey}from"node:http";import{dirname as ty}from"node:path";var ny=1e6,Sc=j("ipc"),Xs=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??te()}async start(){this.token=V_(32).toString("hex");let e=ey((s,a)=>{this.dispatch(s,a)});this.server=e,await new Promise((s,a)=>{e.once("error",a),e.listen(0,"127.0.0.1",()=>s())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),Sc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,s)=>{e.close(a=>a?s(a):r())}),this.server=null)}async persistAuthFiles(){await Q_(ty(this.paths.portFile),{recursive:!0}),await Qu(this.paths.portFile,String(this.port),"utf8"),await Qu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await X_(this.paths.tokenFile,384)}catch(e){Sc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){vi(r,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(a);if(!c){vi(r,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await ry(e)}catch(u){vi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(f,e);vi(r,200,u??{ok:!0})}catch(u){Sc.error("IPC handler failed",{key:a,err:String(u)}),vi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function vi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function ry(t){let e=[],r=0;for await(let a of t){let c=a;if(r+=c.length,r>ny)throw new Error("body too large");e.push(c)}let s=Buffer.concat(e).toString("utf8");return s?JSON.parse(s):null}var Ex=ht(fl(),1);var B1=ht(sx(),1),z1=ht(po(),1),F1=ht(Sr(),1),U1=ht(Bc(),1),q1=ht(Uc(),1),H1=ht(Kc(),1),hx=ht(_o(),1),j1=ht(xx(),1);var px=hx.default;ee();var Ce=j("upstream.frontier"),mx="application/json",_x="none",W1=15e3,Pi=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Ce.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Jf,...hr(this.opts.ppeOverride)};class r extends px{constructor(b){super(b,Yf,{headers:e})}send(b,...v){if(P0("debug"))try{let I;typeof b=="string"?I=Buffer.from(b,"utf8"):b instanceof Buffer?I=b:b instanceof ArrayBuffer?I=new Uint8Array(b):ArrayBuffer.isView(b)?I=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):I=new Uint8Array(0);let k=Buffer.from(I.slice(0,128)).toString("hex");Ce.debug("WS raw frame out",{bytes:I.byteLength,headHex:k})}catch(I){Ce.warn("WS raw frame dump failed",{err:String(I)})}super.send(b,...v)}}let s=Vf(this.opts.urlOverride),a={url:s,ws:r,fpID:$f,aID:Ms,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:mx,force:!0},payloadEncoding:{encoding:_x,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new Ex.FWS(a),f=!1,u=null,x,h,w=new Promise((y,b)=>{x=y,h=b}),E=y=>{f||(f=!0,u&&(clearTimeout(u),u=null),y?h(y):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Ce.info("frontier opened",{url:s,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&E();for(let b of this.connectHandlers)Promise.resolve(b({initial:y})).catch(v=>Ce.warn("onConnect handler threw (ignored)",{err:String(v)}))},c.onclose=y=>{this.opened=!1,Ce.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Ce.warn("frontier error",{code:y.code,msg:y.message}),E(new R("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let C=this.opts.openTimeoutMs??W1;u=setTimeout(()=>{E(new R("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${C}ms (handshake or upgrade slow)`))},C),await c.connect();try{await w}catch(y){try{c.close(1e3,"open failed")}catch(b){Ce.warn("fws close during start failure threw (ignored)",{err:String(b)})}throw this.fws=null,this.opened=!1,y}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(s){Ce.warn("frontier close threw (ignored)",{err:String(s)})}}}async send(e){let r=this.fws,s=e.method;if(!r)throw Ce.warn("frontier send refused: upstream not started",{method:s}),new R("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Ce.warn("frontier send refused: ws not open",{method:s,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new R("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let a=JSON.stringify(e),c=e;yx(c)||Ce.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await r.send(a,{service:33555712,method:1,payloadType:mx,payloadEncoding:_x})}catch(u){throw Ce.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new R("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let s=e.params?._meta;if(!s?.cozeAgentId)return;let a=r(s.cozeAgentId);a&&(s.cozePatToken=a)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Ce.debug("drop non-adapter frontier frame",{service:r});return}let s=Y1(e);if(!s){Ce.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ce.debug("frame received but no onFrame handler",{size:s.length});return}let a;try{a=JSON.parse(s)}catch(f){Ce.warn("frontier message JSON parse failed",{err:String(f),head:s.slice(0,80)});return}let c=a;yx(c)||Ce.info("frontier frame in",{logid:$1(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:K1(s)}),Promise.resolve(this.handler(a)).catch(f=>Ce.warn("frontier frame handler threw",{err:String(f)}))}};function yx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var bx=2e3;function K1(t){return t.length<=bx?t:`${t.slice(0,bx)}...<truncated, total ${t.length} chars>`}function $1(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function Y1(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ee();var Yc=j("upstream.switchable"),bo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Yc.info("swap upstream",{reason:r});let s=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw Yc.error("swap target start failed, reverting",{err:String(a)}),this.inner=s,a}await s.stop(r??"swapped").catch(a=>Yc.warn("previous upstream stop threw (ignored)",{err:String(a)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ee();var Jc=j("upstream"),Dr=class{handler=null;async start(){Jc.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Jc.info("NoopUpstream stopped",{reason:e})}async send(e){Jc.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};ee();ee();Be();import{promises as Zc}from"node:fs";import{dirname as J1}from"node:path";var Z1=j("pat-token-store");async function vx(t=te()){try{let r=(await Zc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Z1.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Oi(t,e=te()){if(!t)throw new Error("writePatToken: empty patToken");await Zc.mkdir(J1(e.patTokenFile),{recursive:!0}),await Zc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Be();Be();import{promises as Eo}from"node:fs";import{join as V1}from"node:path";function X1(t,e){return`#!/bin/sh
|
|
126
|
+
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
127
|
+
`}function Q1(t,e){return`@echo off\r
|
|
128
|
+
"${e}" "${t}" %*\r
|
|
129
|
+
`}async function Sx(t,e=te()){let r=e.binDir;await Eo.mkdir(r,{recursive:!0});let s=V1(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.execPath,c=process.platform==="win32"?Q1(t,a):X1(t,a);return await Eo.readFile(s,"utf8").catch(()=>null)===c||(await Eo.writeFile(s,c,"utf8"),process.platform!=="win32"&&await Eo.chmod(s,493)),r}ee();Be();import{execSync as Cx}from"node:child_process";import{readFileSync as Tx,unlinkSync as eb}from"node:fs";import{mkdir as tb,readFile as Ax,unlink as Rx,writeFile as nb}from"node:fs/promises";import{dirname as rb}from"node:path";function Ix(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var ib=j("single-instance"),vo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??te().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(ib.warn("removing stale pid file",{stalePid:e}),await Rx(this.pidFile).catch(()=>{})),await tb(rb(this.pidFile),{recursive:!0}),await nb(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ax(this.pidFile,"utf8")).trim()===String(process.pid)&&await Rx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ax(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return Ix(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Tx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=Cx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let s=Cx(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!s||/^(INFO|信息)[::]/.test(s))return!1;let a=s.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return a.includes("node")||a.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{Tx(this.pidFile,"utf8").trim()===String(process.pid)&&eb(this.pidFile)}catch{}})}};var K=j("daemon"),sb="coze-bridge-daemon";async function kx(){let t=new vo({processTitle:sb}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Zs(),s=r??{};Fi({pid:process.pid}),K.info(r?"loaded bridge config":"initialized bridge config");try{let P=new ln;s.frameworksCache=await P.detectAll(),K.info("refreshed frameworks_cache",{detected:Object.keys(s.frameworksCache)})}catch(P){K.warn("framework detection failed",{err:String(P)})}await br(s);let a=new bo(new Dr),c=te(),f=null,u=new Vs({upstream:a,paths:c,bridgeConfig:s,sessionSpawner:async(P,N,U,Y)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(P,N,U,Y)}});await ab(c,u);let x=new $s({paths:c,config:s,registry:u});f=x;let h,w,E=null,C={},y,b=null;u.registerExtension("_agent/create",async P=>x.createAgent(P.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let v={},I=new zs({agents:u.agents,disposeAndMarkDisconnected:async(P,N)=>{let U=u.agents.get(P);if(U){await x.cleanupOpenclawSessionProviders(U).catch(se=>K.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(se)}));let Y=!0;try{await U.dispose(`disconnect: ${N}`)}catch(se){Y=!1,K.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(se)}),U.status="error"}Y&&(U.status="disconnected",u.unregister(P),u.disconnectedAgents.add(P))}else u.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!v.ref)throw new Error("agent-detail-sync not initialized yet");await v.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await x.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,N)=>{await x.openclawRepair(P,N)},isRuntimePendingPermission:P=>u.hasPendingPermissionFor(P)});u.registerExtension("_agent/listSkills",P=>I.listSkills(P.params)),u.registerExtension("_agent/addSkills",P=>I.addSkills(P.params)),u.registerExtension("_agent/removeSkills",P=>I.removeSkills(P.params)),u.registerExtension("_agent/getFileTree",P=>I.getFileTree(P.params)),u.registerExtension("_agent/getFileContent",P=>I.getFileContent(P.params)),u.registerExtension("_agent/update",P=>I.updateAgent(P.params)),u.registerExtension("_agent/disconnect",P=>I.disconnectAgent(P.params)),u.registerExtension("_agent/switchModel",P=>I.switchModel(P.params)),u.registerExtension("_agent/reset",P=>I.resetAgent(P.params)),u.registerExtension("_agent/repair",P=>I.repairAgent(P.params));let k=new Wi({paths:c,handlers:I,sendDetail:P=>u.sendRequest("_agent/detail",P)});v.ref=k;let L=async P=>{await Promise.allSettled(P.map(async N=>{try{await I.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),K.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(U){K.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(U)})}}))};a.onConnect(({initial:P})=>{K.info("frontier upstream connected, triggering detail sync",{initial:P}),k.syncAll(P?"initial-connect":"reconnect").catch(N=>K.warn("detail sync top-level error (ignored)",{err:String(N)}))});let _=new Xs({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let P=u.getMockScenario();return{running:!0,pid:process.pid,agents:[...u.agents.keys()],deviceId:E??"",frameworksCache:s.frameworksCache??{},...P?{mockScenario:P}:{}}}},{method:"POST",path:"/pair",handler:async P=>{let N=P,U=N?.privatecode,Y=N?.pairing_code;if(!U||!Y)throw new R("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let se=xi(N.env),fe=N.handshake_url,we=N.frontier_url,Ne=Dx(N.env,fe,we),st=!!h&&h!==U,Te=w!==void 0&&w!==Ne,jt=st||Te,_e=await oc({privatecode:U,...fe?{endpoint:fe}:{},ppeOverride:se});if(jt){K.warn("pair config switched, resetting agents",{pcChanged:st,envChanged:Te,previousPc:h?So(h):"",nextPc:So(U),previousEnvKey:w??"",nextEnvKey:Ne});for(let ge of[...u.agents.values()])await ge.dispose("pair config switch").catch(()=>{}),u.agents.delete(ge.agentId);u.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await a.swap(new Dr,"pair switch").catch(()=>{})}E=_e.deviceId,Fi({deviceId:E,pid:process.pid}),Ec({patToken:U,env:N.env}).catch(ge=>K.warn("coze-cli setup error (ignored)",{err:String(ge)}));let V=new Pi({handshake:_e,privatecode:U,...we?{urlOverride:we}:{},ppeOverride:se,getPatTokenForAgent:ge=>u.agents.get(ge)?.patToken});await a.swap(V,"pair");try{let ge=new ln;s.frameworksCache=await ge.detectAll(),await br(s),K.info("frameworks_cache refreshed before pair",{detected:Object.keys(s.frameworksCache)})}catch(ge){K.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ge)})}let Fn=Object.keys(s.frameworksCache??{});try{let ge=await u.sendRequest("_agent/pair",{pairCode:Y,patToken:U,frameworks:Fn,_meta:{cozeDeviceId:E}});K.info("_agent/pair ok",{pairResult:ge}),h=U,w=Ne,C=se,y=fe,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),K.info("mock scenario set",{scenario:N.mock_scenario})),Oi(U,c).catch(We=>K.warn("writePatToken after /pair failed (ignored)",{err:String(We)})),b||(b=new pi({core:u,getDeviceId:()=>E??"",onTickEnd:()=>k.retryPending().catch(We=>K.warn("detailSync.retryPending failed (ignored)",{err:String(We)})),onAuthFailures:L})),b.start(),jt&&Io(c,x).catch(We=>K.warn("post-pair-switch auto-revive error (ignored)",{err:String(We)}));let Un;return N.agent_id&&(Un=await cb(N.agent_id,c,x,We=>u.sendRequest("_agent/detail",We),U).catch(We=>(K.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(We)}),{ok:!1,agentId:N.agent_id??"",note:String(We)}))),{ok:!0,note:"paired with cloud",...Un?{agent:Un}:{}}}catch(ge){return K.error("_agent/pair failed",{err:String(ge)}),{ok:!1,note:`pair failed: ${String(ge)}`}}}},{method:"POST",path:"/connect",handler:async P=>{let N=P,U=N?.privatecode;if(!U)throw new R("IPC_BAD_REQUEST","/connect requires privatecode");let Y=xi(N.env),se=N.handshake_url,fe=N.frontier_url,we=Dx(N.env,se,fe);if(h===U&&w===we){let V=await ob(c);return u.agents.size===0&&V?(K.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Io(c,x).catch(Fn=>K.warn("connect-noop auto-revive error (ignored)",{err:String(Fn)}))):K.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Ne=!!h&&h!==U,st=w!==void 0&&w!==we,Te=Ne||st,jt=await oc({privatecode:U,...se?{endpoint:se}:{},ppeOverride:Y});if(Te){K.warn("connect config switched, resetting agents",{pcChanged:Ne,envChanged:st,previousPc:h?So(h):"",nextPc:So(U)});for(let V of[...u.agents.values()])await V.dispose("connect config switch").catch(()=>{}),u.agents.delete(V.agentId);u.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await a.swap(new Dr,"connect switch").catch(()=>{})}E=jt.deviceId,Fi({deviceId:E,pid:process.pid}),Ec({patToken:U,env:N.env}).catch(V=>K.warn("coze-cli setup error (ignored)",{err:String(V)}));let _e=new Pi({handshake:jt,privatecode:U,...fe?{urlOverride:fe}:{},ppeOverride:Y,getPatTokenForAgent:V=>u.agents.get(V)?.patToken});return await a.swap(_e,"connect"),h=U,w=we,C=Y,y=se,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),K.info("mock scenario set",{scenario:N.mock_scenario})),b||(b=new pi({core:u,getDeviceId:()=>E??"",onTickEnd:()=>k.retryPending().catch(V=>K.warn("detailSync.retryPending failed (ignored)",{err:String(V)})),onAuthFailures:L})),b.start(),Te&&Io(c,x).catch(V=>K.warn("post-connect-switch auto-revive error (ignored)",{err:String(V)})),Oi(U,c).catch(V=>K.warn("writePatToken after /connect failed (ignored)",{err:String(V)})),K.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async P=>{let N=P;return{ok:!0,result:await x.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async P=>{let N=P;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new R("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new R("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let U=N;return await(U.groupFile?Bu:Mu)(U,{core:u,patToken:h,handshakeBase:y,ppeOverride:C})}catch(U){if(U instanceof R)return{ok:!1,code:U.code,message:U.message};throw U}}},{method:"POST",path:"/refresh",handler:async()=>{K.info("IPC /refresh: re-detecting frameworks");let P=new ln;return s.frameworksCache=await P.detectAll(),await br(s),{ok:!0,frameworks:s.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(K.info("IPC /shutdown received"),setImmediate(()=>{z.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:T,token:O}=await _.start();try{await Sx(c.libEntry,c)}catch(P){K.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(P)})}await u.start(),Io(c,x).catch(P=>K.warn("auto-revive top-level error (ignored)",{err:String(P)})),U0().then(async()=>{let{probeAcpVersion:P}=await Promise.resolve().then(()=>(_n(),z0));for(let N of["claude-code","codex"]){let U=await P(N);U?K.info("acp wrapper version",{framework:N,version:U}):K.warn("acp wrapper version probe failed (binary not on PATH?)",{framework:N})}}).catch(P=>K.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(P)}));let F=null,z={port:T,token:O,core:u,ipc:_,shutdown(P){return F||(K.info("daemon shutdown",{reason:P}),F=(async()=>{b?.stop(),await u.stop(P),await _.stop(),await t.release()})(),F)}};for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{z.shutdown(P).then(()=>process.exit(0))});return process.on("unhandledRejection",P=>{K.error("unhandledRejection",{reason:P instanceof Error?P.message:String(P),stack:P instanceof Error?P.stack:void 0})}),process.on("uncaughtException",P=>{K.error("uncaughtException (will exit, supervisor will restart)",{message:P.message,stack:P.stack,name:P.name}),process.exit(1)}),K.info("daemon ready",{port:T,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(s.frameworksCache??{}),libVersion:s.libVersion??"dev"}),z}async function ob(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function So(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Dx(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function ab(t,e){let{readdir:r}=await import("node:fs/promises"),s;try{s=await r(t.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:c}=await Promise.resolve().then(()=>($t(),Gi));for(let f of s){await c(f,t).catch(u=>K.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(u)}));try{let u=await a(f,t);u?.disconnectedAt&&(e.disconnectedAgents.add(f),K.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:u.disconnectedAt,reason:u.disconnectReason??""}))}catch(u){K.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(u)})}}}async function cb(t,e,r,s,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>($t(),Gi)),f=await c(t,e);if(f){K.info("--agent-id: local config found, reconnecting",{agentId:t,framework:f.framework,hadDisconnect:!!f.disconnectedAt});let w={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{}};return await r.createAgent(w),{ok:!0,agentId:t,note:f.disconnectedAt?"revived from local config":"connected from local config"}}K.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await s({_meta:{cozeAgentId:t}});if(!u.framework)throw new R("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let x={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...a?{patToken:a}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(x);let h=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function Io(t,e){let{readdir:r}=await import("node:fs/promises"),s;try{s=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(s.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:a}=await Promise.resolve().then(()=>($t(),Gi));K.info("auto-revive: scanning local agents on startup",{count:s.length});let c=0,f=0;for(let u of s){let x;try{x=await a(u,t)}catch(h){K.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(h)}),f+=1;continue}if(!x){f+=1;continue}if(x.disconnectedAt){K.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),f+=1;continue}try{K.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let h=db(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...h?{_meta:h}:{}}),c+=1}catch(h){K.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:x.framework,err:String(h)}),f+=1}}return K.info("auto-revive: done",{revived:c,skipped:f,total:s.length}),{revived:c,skipped:f,total:s.length}}function db(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Qc();Be();import{readFile as Px}from"node:fs/promises";var Ht=class{paths;constructor(e){this.paths=e??te()}async probe(e=1e3){let r=await Co(this.paths);if(!r)return{kind:"not-running"};try{let s=await this.fetch(r,{method:"GET",path:"/status",timeoutMs:e});return s.status===200?{kind:"connected",...r}:{kind:"stale",reason:`unexpected status ${s.status}`}}catch(s){return{kind:"stale",reason:mb(s)}}}async request(e){let r=await Co(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let s=r.body!==void 0,a={Authorization:`Bearer ${e.token}`};s&&(a["content-type"]="application/json");let c=new AbortController,f=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:a,body:s?JSON.stringify(r.body):void 0,signal:c.signal}),x=await u.text();return{status:u.status,body:gb(x)}}finally{clearTimeout(f)}}};async function Co(t){try{let[e,r]=await Promise.all([Px(t.portFile,"utf8"),Px(t.tokenFile,"utf8")]),s=Number.parseInt(e.trim(),10),a=r.trim();return!Number.isFinite(s)||s<=0||!a?null:{port:s,token:a}}catch(e){if(e.code==="ENOENT")return null;throw e}}function gb(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function mb(t){return t instanceof Error?t.message:String(t)}ee();Be();import{copyFile as Ox,mkdir as wb,readFile as e0,writeFile as _b}from"node:fs/promises";import{homedir as JC}from"node:os";import{dirname as yb,resolve as t0,sep as To}from"node:path";import{fileURLToPath as bb}from"node:url";ee();Be();var Lx=j("dist-install");function Eb(t){let e=bb(t),r=yb(e),s=`${To}src${To}`;if(r.includes(s)||r.endsWith(`${To}src${To}cli`))return null;let a=t0(r,"index.js"),c=t0(r,"..","package.json");return{dist:a,pkgJson:c}}async function n0(t={}){let e=t.paths??te(),r=Eb(import.meta.url),s=t.sourceDist??r?.dist,a=t.sourcePackageJson??r?.pkgJson;if(!s||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let c;try{c=JSON.parse(await e0(a,"utf8")).version??"unknown"}catch(E){return Lx.warn("cannot read source package.json,skip dist install",{err:String(E)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(E)}`}}let f=await Zs(e.configFile)??{},u=f.libVersion;if(u===c)try{return await e0(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await wb(e.libDir,{recursive:!0}),await Ox(s,e.libEntry),await Ox(`${s}.map`,`${e.libEntry}.map`).catch(()=>{});let x=t0(e.libDir,"package.json"),h=`${JSON.stringify({type:"module"},null,2)}
|
|
130
|
+
`;return await e0(x,"utf8").catch(()=>null)!==h&&await _b(x,h),f.libVersion=c,await br(f,e.configFile),Lx.info("dist installed",{libEntry:e.libEntry,fromVersion:u,toVersion:c}),u?{kind:"version-changed",fromVersion:u,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}import{basename as vb,resolve as Sb}from"node:path";Be();var Ib=9e4,Cb={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,NPX_CACHE_CORRUPT:1};function Tb(t){return Cb[t]??1}async function Nx(t,e={}){let r=e.paths??te();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
131
|
+
`),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
|
|
132
|
+
`),3;let s=await Co(r).catch(()=>null);if(!s)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
133
|
+
`),4;let a={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:Sb(process.cwd(),t.path),...t.caption?{caption:t.caption}:{},...t.name?{name:t.name}:{},...t.groupFile?{groupFile:!0}:{},...t.mimeType?{mimeType:t.mimeType}:{}},c;try{c=await Ab(s,"/agent/send",a,Ib)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
|
|
133
134
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
134
|
-
`),
|
|
135
|
-
`);else{let f=
|
|
136
|
-
`)}else process.stdout.write(`Sent ${
|
|
137
|
-
`)}return 0}async function
|
|
138
|
-
`)}function
|
|
135
|
+
`),Tb(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
136
|
+
`);else{let f=t.name??vb(a.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${f} (uri=${u})
|
|
137
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${f} (${Rb(c.bytes)})
|
|
138
|
+
`)}return 0}async function Ab(t,e,r,s){let a=new AbortController,c=setTimeout(()=>a.abort(),s);try{let f=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:a.signal}),u=await f.text(),x=u?JSON.parse(u):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function Rb(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var jx=j("cli");function Fe(t,e){let r=[],s;for(let a=0;a<t.length;a++){let c=t[a];if(c===e){s=t[a+1],a+=1;continue}if(c.startsWith(`${e}=`)){s=c.slice(e.length+1);continue}r.push(c)}return{value:s,rest:r}}function Li(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
139
|
+
`)}function Yb(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="refresh")return{mode:"refresh"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return Jb(e.slice(1));if(e[0]==="connect")return Zb(e.slice(1));if(e.includes("--status"))return Li("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return Li("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return Li("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return Li("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return Li("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:s,rest:a}=Fe(r,"--pat-token");r=a;let{value:c,rest:f}=Fe(r,"--pair-code");r=f;let{value:u,rest:x}=Fe(r,"--env");r=x;let{value:h,rest:w}=Fe(r,"--handshake-url");r=w;let{value:E,rest:C}=Fe(r,"--frontier-url");r=C;let{value:y,rest:b}=Fe(r,"--mock-scenario");r=b;let{value:v}=Fe(r,"--agent-id");if(!s||!c)return{mode:"help"};let I={mode:"pair",privatecode:s,pairingCode:c};return u&&(I.env=u),h&&(I.handshakeUrl=h),E&&(I.frontierUrl=E),y&&(I.mockScenario=y),v&&(I.agentId=v),I}function Jb(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.startsWith("--"))return{mode:"help"};let s=t.slice(2),{value:a,rest:c}=Fe(s,"--caption");s=c;let{value:f,rest:u}=Fe(s,"--name");s=u;let{value:x,rest:h}=Fe(s,"--agent-id");s=h;let{value:w,rest:E}=Fe(s,"--session-id");s=E;let{value:C,rest:y}=Fe(s,"--mime");s=y;let b=s.includes("--group-file");s=s.filter(k=>k!=="--group-file");let v=s.includes("--json"),I={mode:"send",kind:e,path:r,json:v};return a&&(I.caption=a),f&&(I.name=f),x&&(I.agentId=x),w&&(I.sessionId=w),b&&(I.groupFile=!0),C&&(I.mimeType=C),I}function Zb(t){let e=t,{value:r,rest:s}=Fe(e,"--pat-token");e=s;let{value:a,rest:c}=Fe(e,"--env");e=c;let{value:f,rest:u}=Fe(e,"--handshake-url");e=u;let{value:x,rest:h}=Fe(e,"--frontier-url");e=h;let{value:w,rest:E}=Fe(e,"--mock-scenario");e=E;let C={mode:"connect"};return r&&(C.privatecode=r),a&&(C.env=a),f&&(C.handshakeUrl=f),x&&(C.frontierUrl=x),w&&(C.mockScenario=w),C}var Vb=`
|
|
139
140
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
140
141
|
|
|
141
142
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -202,47 +203,47 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
202
203
|
|
|
203
204
|
Internal:
|
|
204
205
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
205
|
-
`.trimStart();async function
|
|
206
|
-
`),0;case"daemon":{try{await
|
|
207
|
-
`),1;if(
|
|
208
|
-
`),1;let a=await
|
|
206
|
+
`.trimStart();async function Gx(t=process.argv,e={}){let r=Yb(t);switch(r.mode){case"help":return process.stdout.write(Vb),0;case"version":return process.stdout.write(`${gr}
|
|
207
|
+
`),0;case"daemon":{try{await kx()}catch(s){return jx.error("daemon start failed",{err:String(s)}),1}return new Promise(()=>{})}case"status":return Xb(e);case"stop":return Qb(e);case"refresh":return eE(e);case"purge":return tE(e);case"service-install":return nE(e);case"service-uninstall":return rE(e);case"pair":{let s={};return r.env&&(s.env=r.env),r.handshakeUrl&&(s.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(s.frontierUrl=r.frontierUrl),r.mockScenario&&(s.mockScenario=r.mockScenario),iE(r.privatecode,r.pairingCode,e,s,r.agentId)}case"connect":{let s={};return r.env&&(s.env=r.env),r.handshakeUrl&&(s.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(s.frontierUrl=r.frontierUrl),r.mockScenario&&(s.mockScenario=r.mockScenario),sE(r.privatecode,e,s)}case"send":return Nx({kind:r.kind,path:r.path,...r.agentId?{agentId:r.agentId}:{},...r.sessionId?{sessionId:r.sessionId}:{},...r.caption?{caption:r.caption}:{},...r.name?{name:r.name}:{},...r.groupFile?{groupFile:!0}:{},...r.mimeType?{mimeType:r.mimeType}:{},json:r.json},e)}}async function Wx(t){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(t.pidFile).catch(()=>{}),e(t.portFile).catch(()=>{}),e(t.tokenFile).catch(()=>{})])}async function Xb(t){let e=t.paths??te(),r=new Ht(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
208
|
+
`),1;if(s.kind==="stale")return await Wx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
209
|
+
`),1;let a=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
209
210
|
${JSON.stringify(a.body,null,2)}
|
|
210
|
-
`),0}async function
|
|
211
|
-
`),0;if(
|
|
212
|
-
`),0;try{return await
|
|
211
|
+
`),0}async function Qb(t){let e=t.paths??te(),r=new Ht(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
212
|
+
`),0;if(s.kind==="stale")return await Wx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
213
|
+
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
213
214
|
`),0}catch(a){return process.stdout.write(`coze-bridge: stop failed: ${String(a)}
|
|
214
|
-
`),1}}async function
|
|
215
|
-
`),1;try{let
|
|
216
|
-
${JSON.stringify(
|
|
217
|
-
`),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(
|
|
218
|
-
`),1)}catch(
|
|
219
|
-
`),1}}async function
|
|
215
|
+
`),1}}async function eE(t){let e=new Ht(t.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
216
|
+
`),1;try{let s=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return s.status===200?(process.stdout.write(`coze-bridge: refreshed
|
|
217
|
+
${JSON.stringify(s.body,null,2)}
|
|
218
|
+
`),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(s.body)}
|
|
219
|
+
`),1)}catch(s){return process.stderr.write(`coze-bridge: refresh failed: ${String(s)}
|
|
220
|
+
`),1}}async function c0(t){if(t.supervisor){let c=t.supervisor,f={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:()=>c.install(f),uninstall:()=>c.uninstall(f)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Hx(),qx)),s=e(),a=r();return{platform:s.platform,install:()=>s.install(a),uninstall:()=>s.uninstall(a)}}async function tE(t){let e=new Ht(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
220
221
|
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(f){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(f)}
|
|
221
|
-
`)}await new Promise(f=>setTimeout(f,500))}let
|
|
222
|
+
`)}await new Promise(f=>setTimeout(f,500))}let s=await c0(t);if(s)try{await s.uninstall(),process.stdout.write(`coze-bridge: ${s.platform} supervisor unregistered
|
|
222
223
|
`)}catch(f){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(f)}
|
|
223
|
-
`)}let a=
|
|
224
|
+
`)}let a=t.paths??te(),{rm:c}=await import("node:fs/promises");try{await c(a.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.bridgeRoot}
|
|
224
225
|
`)}catch(f){return process.stderr.write(`coze-bridge: remove failed: ${String(f)}
|
|
225
226
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
226
|
-
`),0}async function
|
|
227
|
+
`),0}async function nE(t){let e=await c0(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
227
228
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
228
|
-
`),0}catch(
|
|
229
|
-
`),1}}async function
|
|
230
|
-
`),0}catch(
|
|
231
|
-
`),1}}async function
|
|
232
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
233
|
-
`)}let
|
|
234
|
-
`),await f({paths:
|
|
235
|
-
`),1;let
|
|
236
|
-
`),1):(
|
|
229
|
+
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
230
|
+
`),1}}async function rE(t){let e=await c0(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
231
|
+
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
232
|
+
`),1}}async function iE(t,e,r,s={},a){let c=new Ht(r.paths),f=r.spawnDaemon??Xc;if(!r.skipDistInstall){let h=await n0({paths:r.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
233
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
234
|
+
`)}let u=await c.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
235
|
+
`),await f({paths:r.paths}),u=await Kx(c,r.waitTimeoutMs??1e4,r.sleep??$x),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
|
|
236
|
+
`),1;let x={privatecode:t,pairing_code:e};s.env&&(x.env=s.env),s.handshakeUrl&&(x.handshake_url=s.handshakeUrl),s.frontierUrl&&(x.frontier_url=s.frontierUrl),s.mockScenario&&(x.mock_scenario=s.mockScenario),a&&(x.agent_id=a);try{let h=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(h.status===200&&h.body?.ok){let w=h.body.agent;return w&&!w.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${w.agentId}): ${w.note}
|
|
237
|
+
`),1):(w?process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C agent ${w.agentId} \u5DF2\u5C31\u7EEA
|
|
237
238
|
`):process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
|
|
238
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
239
|
-
`),1}catch(
|
|
240
|
-
`),1}}async function
|
|
241
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
242
|
-
`)}let
|
|
243
|
-
`),await f({paths:e.paths}),
|
|
244
|
-
`),1;let
|
|
245
|
-
`),await
|
|
246
|
-
`),1)}catch(
|
|
247
|
-
`),1}}async function
|
|
239
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(h.body)}
|
|
240
|
+
`),1}catch(h){return process.stderr.write(`coze-bridge: pair failed: ${String(h)}
|
|
241
|
+
`),1}}async function sE(t,e,r={}){let s=e.paths??te(),a=t??await vx(s);if(!a)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new Ht(e.paths),f=e.spawnDaemon??Xc;if(!e.skipDistInstall){let h=await n0({paths:e.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
242
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
243
|
+
`)}let u=await c.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
244
|
+
`),await f({paths:e.paths}),u=await Kx(c,e.waitTimeoutMs??1e4,e.sleep??$x),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
|
|
245
|
+
`),1;let x={privatecode:a};r.env&&(x.env=r.env),r.handshakeUrl&&(x.handshake_url=r.handshakeUrl),r.frontierUrl&&(x.frontier_url=r.frontierUrl),r.mockScenario&&(x.mock_scenario=r.mockScenario);try{let h=await c.request({method:"POST",path:"/connect",body:x,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: connected (${h.body.note??"ok"})
|
|
246
|
+
`),await Oi(a,s).catch(w=>jx.warn("writePatToken after connect failed (ignored)",{err:String(w)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(h.body)}
|
|
247
|
+
`),1)}catch(h){return process.stderr.write(`coze-bridge: connect failed: ${String(h)}
|
|
248
|
+
`),1}}async function Kx(t,e,r){let s=Date.now()+e;for(;Date.now()<s;){let a=await t.probe(500);if(a.kind==="connected")return a;await r(200)}return t.probe(500)}function $x(t){return new Promise(e=>setTimeout(e,t))}ee();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&k0("warn");Gx(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
248
249
|
`),process.exit(1)});
|