coze-bridge 0.1.83-alpha.1 → 0.1.84
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 +70 -70
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,26 +5,26 @@ 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
|
|
11
|
-
`)}async function
|
|
12
|
-
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await Wd(o,i,{encoding:"utf8",mode:r.mode}):await Wd(o,i,"utf8"),await jd(o,t),r?.mode!==void 0&&await gp(t,r.mode)}catch(c){await jd(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Hi=it(()=>{"use strict"});import{promises as Kd}from"node:fs";import{homedir as _p}from"node:os";import{sep as Ep,join as Me,resolve as $d}from"node:path";function ee(t){let e=t??_p(),r=Me(e,".coze"),i=Me(r,"bridge"),o=Me(i,"lib");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Me(o,"index.js"),binDir:Me(i,"bin"),pidFile:Me(i,"bridge.pid"),portFile:Me(i,"bridge.port"),tokenFile:Me(i,"bridge.token"),patTokenFile:Me(i,"pat-token"),logFile:Me(i,"bridge.log"),installLock:Me(i,"install.lock"),configFile:Me(i,"config.json"),agentsRoot:Me(r,"agents")}}function Ot(t,e=ee()){let r=Me(e.agentsRoot,t);return{root:r,config:Me(r,"config.json"),workspace:Me(r,"workspace"),logs:Me(r,"logs")}}async function Mr(t,e){let r=await Kd.realpath($d(t)).catch(()=>null);if(!r)return!1;let i=await Kd.realpath($d(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+Ep)}var Be=it(()=>{"use strict"});var ji={};Ko(ji,{AGENT_CONFIG_FILE_MODE:()=>qi,enforceAgentConfigMode:()=>Sp,loadAgentConfig:()=>He,persistAgentSessions:()=>Yo,persistAgentSkills:()=>Gi,saveAgentConfig:()=>Je});import{chmod as bp,stat as vp}from"node:fs/promises";function He(t,e){return Jn(Ot(t,e).config)}function Je(t,e){return Ui(Ot(t.agentId,e).config,t,{mode:qi})}async function Sp(t,e){if(process.platform==="win32")return;let r=Ot(t,e).config;try{let i=await vp(r);if(!i.isFile())return;let o=i.mode&511;o!==qi&&(await bp(r,qi),Vd.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;Vd.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Yo(t,e,r){let i=await He(t,r);i&&(i.sessions=Object.fromEntries(e),await Je(i,r))}async function Gi(t,e,r){let i=await He(t,r);i&&(i.skills=e,await Je(i,r))}var Vd,qi,Zt=it(()=>{"use strict";Hi();Q();Be();Vd=q("agent-config"),qi=384});var Qo=te((Nb,Xd)=>{Xd.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=te(el=>{var Qd={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 Rp(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(Qd))el[t]=Rp(Qd[t])});var sl=te((Bb,il)=>{var kp=oe("fs"),Ee=oe("path"),tl=Qo(),Dp=Ki(),Op=typeof process=="object"&&process.platform==="win32",nl=t=>typeof t=="object"&&t!==null,rl=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=Ee.sep,this.fs=kp,nl(t)&&nl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}il.exports=he;he.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var l;try{l=e.fs.statSync(o)}catch(f){if(f.message&&f.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw f}if(l&&l.isFile())throw Dp.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};he.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var l=Ee.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var f;try{f=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),f=o.fs.openSync(t,"w",438)}if(f)try{o.fs.writeSync(f,e,0,e.length,0)}finally{o.fs.closeSync(f)}return o.fs.chmodSync(t,i||438),!0};he.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(f,h){if(l&&h.isDirectory())return o(!1);var x=Ee.dirname(t);c.fs.exists(x,function(m){m||c.makeDir(x),c.fs.open(t,"w",438,function(_,A){_?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,E){c.fs.write(E,e,0,e.length,0,function(){c.fs.close(E,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):A?c.fs.write(A,e,0,e.length,0,function(){c.fs.close(A,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};he.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(f){let h=Ee.join(i,f),x=e.fs.statSync(h);(!o||o.test(h))&&l.push(Ee.normalize(h)+(x.isDirectory()?e.sep:"")),x.isDirectory()&&c&&(l=l.concat(r(h,o,c)))}),l}return r(t,void 0,!0)};he.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(f){f=Ee.join(t,f),r.fs.stat(f,function(h,x){if(h)return e(h);x&&(i.push(Ee.normalize(f)+(x.isDirectory()?r.sep:"")),x.isDirectory()?r.findFilesAsync(f,function(m,_){if(m)return e(m);i=i.concat(_),--l||e(null,i)}):--l||e(null,i))})})})};he.prototype.getAttributes=function(){};he.prototype.setAttributes=function(){};he.crc32update=function(t,e){return rl[(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 i=0;i<e;)r=he.crc32update(r,t[i++]);return~r>>>0};he.methodToString=function(t){switch(t){case tl.STORED:return"STORED ("+t+")";case tl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};he.canonical=function(t){if(!t)return"";let e=Ee.posix.normalize("/"+t.split("\\").join("/"));return Ee.join(".",e)};he.zipnamefix=function(t){if(!t)return"";let e=Ee.posix.normalize("/"+t.split("\\").join("/"));return Ee.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 i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};he.sanitize=function(t,e){t=Ee.resolve(Ee.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Ee.normalize(Ee.join(t,r.slice(i,o).join(Ee.sep)));if(c.indexOf(t)===0)return c}return Ee.normalize(Ee.join(t,Ee.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=Op;he.crcTable=rl});var al=te((zb,ol)=>{var Pp=oe("path");ol.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Pp.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var dl=te((Fb,cl)=>{cl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Xn=te((Ub,Yn)=>{Yn.exports=sl();Yn.exports.Constants=Qo();Yn.exports.Errors=Ki();Yn.exports.FileAttr=al();Yn.exports.decoder=dl()});var fl=te((Hb,ll)=>{var Yt=Xn(),U=Yt.Constants;ll.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,f=0,h=0,x=0,m=0,_=0,A=0,y=0,E=0;t|=Yt.isWin?2560:768,r|=U.FLG_EFS;let S={extraLen:0},I=w=>Math.max(0,w)>>>0,R=w=>Math.max(0,w)&65535,P=w=>Math.max(0,w)&255;return o=Yt.fromDate2DOS(new Date),{get made(){return t},set made(w){t=w},get version(){return e},set version(w){e=w},get flags(){return r},set flags(w){r=w},get flags_efs(){return(r&U.FLG_EFS)>0},set flags_efs(w){w?r|=U.FLG_EFS:r&=~U.FLG_EFS},get flags_desc(){return(r&U.FLG_DESC)>0},set flags_desc(w){w?r|=U.FLG_DESC:r&=~U.FLG_DESC},get method(){return i},set method(w){switch(w){case U.STORED:this.version=10;case U.DEFLATED:default:this.version=20}i=w},get time(){return Yt.fromDOS2Date(this.timeval)},set time(w){w=new Date(w),this.timeval=Yt.fromDate2DOS(w)},get timeval(){return o},set timeval(w){o=I(w)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(w){c=I(w)},get compressedSize(){return l},set compressedSize(w){l=I(w)},get size(){return f},set size(w){f=I(w)},get fileNameLength(){return h},set fileNameLength(w){h=w},get extraLength(){return x},set extraLength(w){x=w},get extraLocalLength(){return S.extraLen},set extraLocalLength(w){S.extraLen=w},get commentLength(){return m},set commentLength(w){m=w},get diskNumStart(){return _},set diskNumStart(w){_=I(w)},get inAttr(){return A},set inAttr(w){A=I(w)},get attr(){return y},set attr(w){y=I(w)},get fileAttr(){return(y||0)>>16&4095},get offset(){return E},set offset(w){E=I(w)},get encrypted(){return(r&U.FLG_ENC)===U.FLG_ENC},get centralHeaderSize(){return U.CENHDR+h+x+m},get realDataOffset(){return E+U.LOCHDR+S.fnameLen+S.extraLen},get localHeader(){return S},loadLocalHeaderFromBinary:function(w){var T=w.slice(E,E+U.LOCHDR);if(T.readUInt32LE(0)!==U.LOCSIG)throw Yt.Errors.INVALID_LOC();S.version=T.readUInt16LE(U.LOCVER),S.flags=T.readUInt16LE(U.LOCFLG),S.flags_desc=(S.flags&U.FLG_DESC)>0,S.method=T.readUInt16LE(U.LOCHOW),S.time=T.readUInt32LE(U.LOCTIM),S.crc=T.readUInt32LE(U.LOCCRC),S.compressedSize=T.readUInt32LE(U.LOCSIZ),S.size=T.readUInt32LE(U.LOCLEN),S.fnameLen=T.readUInt16LE(U.LOCNAM),S.extraLen=T.readUInt16LE(U.LOCEXT);let k=E+U.LOCHDR+S.fnameLen,z=k+S.extraLen;return w.slice(k,z)},loadFromBinary:function(w){if(w.length!==U.CENHDR||w.readUInt32LE(0)!==U.CENSIG)throw Yt.Errors.INVALID_CEN();t=w.readUInt16LE(U.CENVEM),e=w.readUInt16LE(U.CENVER),r=w.readUInt16LE(U.CENFLG),i=w.readUInt16LE(U.CENHOW),o=w.readUInt32LE(U.CENTIM),c=w.readUInt32LE(U.CENCRC),l=w.readUInt32LE(U.CENSIZ),f=w.readUInt32LE(U.CENLEN),h=w.readUInt16LE(U.CENNAM),x=w.readUInt16LE(U.CENEXT),m=w.readUInt16LE(U.CENCOM),_=w.readUInt16LE(U.CENDSK),A=w.readUInt16LE(U.CENATT),y=w.readUInt32LE(U.CENATX),E=w.readUInt32LE(U.CENOFF)},localHeaderToBinary:function(){var w=Buffer.alloc(U.LOCHDR);return w.writeUInt32LE(U.LOCSIG,0),w.writeUInt16LE(e,U.LOCVER),w.writeUInt16LE(r,U.LOCFLG),w.writeUInt16LE(i,U.LOCHOW),w.writeUInt32LE(o,U.LOCTIM),w.writeUInt32LE(c,U.LOCCRC),w.writeUInt32LE(l,U.LOCSIZ),w.writeUInt32LE(f,U.LOCLEN),w.writeUInt16LE(h,U.LOCNAM),w.writeUInt16LE(S.extraLen,U.LOCEXT),w},centralHeaderToBinary:function(){var w=Buffer.alloc(U.CENHDR+h+x+m);return w.writeUInt32LE(U.CENSIG,0),w.writeUInt16LE(t,U.CENVEM),w.writeUInt16LE(e,U.CENVER),w.writeUInt16LE(r,U.CENFLG),w.writeUInt16LE(i,U.CENHOW),w.writeUInt32LE(o,U.CENTIM),w.writeUInt32LE(c,U.CENCRC),w.writeUInt32LE(l,U.CENSIZ),w.writeUInt32LE(f,U.CENLEN),w.writeUInt16LE(h,U.CENNAM),w.writeUInt16LE(x,U.CENEXT),w.writeUInt16LE(m,U.CENCOM),w.writeUInt16LE(_,U.CENDSK),w.writeUInt16LE(A,U.CENATT),w.writeUInt32LE(y,U.CENATX),w.writeUInt32LE(E,U.CENOFF),w},toJSON:function(){let w=function(T){return T+" bytes"};return{made:t,version:e,flags:r,method:Yt.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:w(l),size:w(f),fileNameLength:w(h),extraLength:w(x),commentLength:w(m),diskNumStart:_,inAttr:A,attr:y,offset:E,centralHeaderSize:w(U.CENHDR+h+x+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var hl=te((qb,ul)=>{var Qn=Xn(),le=Qn.Constants;ul.exports=function(){var t=0,e=0,r=0,i=0,o=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 i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return le.ENDHDR+o},loadFromBinary:function(c){if((c.length!==le.ENDHDR||c.readUInt32LE(0)!==le.ENDSIG)&&(c.length<le.ZIP64HDR||c.readUInt32LE(0)!==le.ZIP64SIG))throw Qn.Errors.INVALID_END();c.readUInt32LE(0)===le.ENDSIG?(t=c.readUInt16LE(le.ENDSUB),e=c.readUInt16LE(le.ENDTOT),r=c.readUInt32LE(le.ENDSIZ),i=c.readUInt32LE(le.ENDOFF),o=c.readUInt16LE(le.ENDCOM)):(t=Qn.readBigUInt64LE(c,le.ZIP64SUB),e=Qn.readBigUInt64LE(c,le.ZIP64TOT),r=Qn.readBigUInt64LE(c,le.ZIP64SIZE),i=Qn.readBigUInt64LE(c,le.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(le.ENDHDR+o);return c.writeUInt32LE(le.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,le.ENDSUB),c.writeUInt16LE(e,le.ENDTOT),c.writeUInt32LE(r,le.ENDSIZ),c.writeUInt32LE(i,le.ENDOFF),c.writeUInt16LE(o,le.ENDCOM),c.fill(" ",le.ENDHDR),c},toJSON:function(){let c=function(l,f){let h=l.toString(16).toUpperCase();for(;h.length<f;)h="0"+h;return"0x"+h};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ta=te(ea=>{ea.EntryHeader=fl();ea.MainHeader=hl()});var pl=te((jb,xl)=>{xl.exports=function(t){var e=oe("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(f){c.push(f),l+=f.length}),o.on("end",function(){var f=Buffer.alloc(l),h=0;f.fill(0);for(var x=0;x<c.length;x++){var m=c[x];m.copy(f,h),h+=m.length}i&&i(f)}),o.end(t)}}}});var ml=te((Wb,gl)=>{var Lp=+(process.versions?process.versions.node:"").split(".")[0]||0;gl.exports=function(t,e){var r=oe("zlib");let i=Lp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],f=0;c.on("data",function(h){l.push(h),f+=h.length}),c.on("end",function(){var h=Buffer.alloc(f),x=0;h.fill(0);for(var m=0;m<l.length;m++){var _=l[m];_.copy(h,x),x+=_.length}o&&o(h)}),c.end(t)}}}});var bl=te((Kb,El)=>{"use strict";var{randomFillSync:wl}=oe("crypto"),Np=Ki(),Mp=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}),_l=(t,e)=>Math.imul(t,e)>>>0,yl=(t,e)=>Mp[(t^e)&255]^t>>>8,Br=()=>typeof wl=="function"?wl(Buffer.alloc(12)):Br.node();Br.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:Br};function Vi(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])}Vi.prototype.updateKeys=function(t){let e=this.keys;return e[0]=yl(e[0],t),e[1]+=e[0]&255,e[1]=_l(e[1],134775813)+1,e[2]=yl(e[2],e[1]>>>24),t};Vi.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return _l(t,t^1)>>8&255};function Bp(t){let e=new Vi(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function zp(t){let e=new Vi(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Fp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Bp(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Np.WRONG_PASSWORD();return i(t.slice(12))}function Up(t){Buffer.isBuffer(t)&&t.length>=12?$i.genSalt=function(){return t.slice(0,12)}:t==="node"?$i.genSalt=Br.node:$i.genSalt=Br}function Hp(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=zp(r),c=$i.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}El.exports={decrypt:Fp,encrypt:Hp,_salter:Up}});var vl=te(Ji=>{Ji.Deflater=pl();Ji.Inflater=ml();Ji.ZipCrypto=bl()});var ra=te((Vb,Sl)=>{var ne=Xn(),qp=ta(),xe=ne.Constants,na=vl();Sl.exports=function(t,e){var r=new qp.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,f=Buffer.alloc(0),h=Buffer.alloc(0),x=!0;let m=t,_=typeof m.decoder=="object"?m.decoder:ne.decoder;x=_.hasOwnProperty("efs")?_.efs:!1;function A(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(h=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function y(w){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ne.crc32(w)!==r.localHeader.crc)return!1}else{let T={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==xe.LOCSIG||e.readUInt32LE(k)==xe.CENSIG)throw ne.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==xe.EXTSIG)T.crc=e.readUInt32LE(k+xe.EXTCRC),T.compressedSize=e.readUInt32LE(k+xe.EXTSIZ),T.size=e.readUInt32LE(k+xe.EXTLEN);else if(e.readUInt16LE(k+12)===19280)T.crc=e.readUInt32LE(k+xe.EXTCRC-4),T.compressedSize=e.readUInt32LE(k+xe.EXTSIZ-4),T.size=e.readUInt32LE(k+xe.EXTLEN-4);else throw ne.Errors.DESCRIPTOR_UNKNOWN();if(T.compressedSize!==r.compressedSize||T.size!==r.size||T.crc!==r.crc)throw ne.Errors.DESCRIPTOR_FAULTY();if(ne.crc32(w)!==T.crc)return!1}return!0}function E(w,T,k){if(typeof T>"u"&&typeof w=="string"&&(k=w,w=void 0),c)return w&&T&&T(Buffer.alloc(0),ne.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var z=A();if(z.length===0)return w&&T&&T(z),z;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw ne.Errors.INVALID_PASS_PARAM();z=na.ZipCrypto.decrypt(z,r,k)}var B=Buffer.alloc(r.size);switch(r.method){case ne.Constants.STORED:if(z.copy(B),y(B))return w&&T&&T(B),B;throw w&&T&&T(B,ne.Errors.BAD_CRC()),ne.Errors.BAD_CRC();case ne.Constants.DEFLATED:var D=new na.Inflater(z,r.size);if(w)D.inflateAsync(function(L){L.copy(L,0),T&&(y(L)?T(L):T(L,ne.Errors.BAD_CRC()))});else{if(D.inflate(B).copy(B,0),!y(B))throw ne.Errors.BAD_CRC(`"${_.decode(i)}"`);return B}break;default:throw w&&T&&T(Buffer.alloc(0),ne.Errors.UNKNOWN_METHOD()),ne.Errors.UNKNOWN_METHOD()}}function S(w,T){if((!l||!l.length)&&Buffer.isBuffer(e))return w&&T&&T(A()),A();if(l.length&&!c){var k;switch(r.method){case ne.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(l.length),l.copy(k),w&&T&&T(k),k;default:case ne.Constants.DEFLATED:var z=new na.Deflater(l);if(w)z.deflateAsync(function(D){k=Buffer.alloc(D.length),r.compressedSize=D.length,D.copy(k),T&&T(k)});else{var B=z.deflate();return r.compressedSize=B.length,B}z=null;break}}else if(w&&T)T(Buffer.alloc(0));else return Buffer.alloc(0)}function I(w,T){return ne.readBigUInt64LE(w,T)}function R(w){try{for(var T=0,k,z,B;T+4<w.length;)k=w.readUInt16LE(T),T+=2,z=w.readUInt16LE(T),T+=2,B=w.slice(T,T+z),T+=z,xe.ID_ZIP64===k&&P(B)}catch{throw ne.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(w){var T,k,z,B;w.length>=xe.EF_ZIP64_SCOMP&&(T=I(w,xe.EF_ZIP64_SUNCOMP),r.size===xe.EF_ZIP64_OR_32&&(r.size=T)),w.length>=xe.EF_ZIP64_RHO&&(k=I(w,xe.EF_ZIP64_SCOMP),r.compressedSize===xe.EF_ZIP64_OR_32&&(r.compressedSize=k)),w.length>=xe.EF_ZIP64_DSN&&(z=I(w,xe.EF_ZIP64_RHO),r.offset===xe.EF_ZIP64_OR_32&&(r.offset=z)),w.length>=xe.EF_ZIP64_DSN+4&&(B=w.readUInt32LE(xe.EF_ZIP64_DSN),r.diskNumStart===xe.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return _.decode(i)},get rawEntryName(){return i},set entryName(w){i=ne.toBuffer(w,_.encode);var T=i[i.length-1];c=T===47||T===92,r.fileNameLength=i.length},get efs(){return typeof x=="function"?x(this.entryName):x},get extra(){return f},set extra(w){f=w,r.extraLength=w.length,R(w)},get comment(){return _.decode(o)},set comment(w){if(o=ne.toBuffer(w,_.encode),r.commentLength=o.length,o.length>65535)throw ne.Errors.COMMENT_TOO_LONG()},get name(){var w=_.decode(i);return c?w.substr(w.length-1).split("/").pop():w.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return S(!1,null)},getCompressedDataAsync:function(w){S(!0,w)},setData:function(w){l=ne.toBuffer(w,ne.decoder.encode),!c&&l.length?(r.size=l.length,r.method=ne.Constants.DEFLATED,r.crc=ne.crc32(w),r.changed=!0):r.method=ne.Constants.STORED},getData:function(w){return r.changed?l:E(!1,null,w)},getDataAsync:function(w,T){r.changed?w(l):E(!0,w,T)},set attr(w){r.attr=w},get attr(){return r.attr},set header(w){r.loadFromBinary(w)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=f.length;var w=r.centralHeaderToBinary(),T=ne.Constants.CENHDR;return i.copy(w,T),T+=i.length,f.copy(w,T),T+=r.extraLength,o.copy(w,T),w},packLocalHeader:function(){let w=0;r.flags_efs=this.efs,r.extraLocalLength=h.length;let T=r.localHeaderToBinary(),k=Buffer.alloc(T.length+i.length+r.extraLocalLength);return T.copy(k,w),w+=T.length,i.copy(k,w),w+=i.length,h.copy(k,w),w+=h.length,k},toJSON:function(){let w=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:w(e),data:w(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Tl=te((Jb,Al)=>{var Il=ra(),Gp=ta(),ze=Xn();Al.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Gp.MainHeader,l=!1,f=null;let h=new Set,x=e,{noSort:m,decoder:_}=x;t?E(x.readEntries):l=!0;function A(){let I=new Set;for(let R of Object.keys(i)){let P=R.split("/");if(P.pop(),!!P.length)for(let w=0;w<P.length;w++){let T=P.slice(0,w+1).join("/")+"/";I.add(T)}}for(let R of I)if(!(R in i)){let P=new Il(x);P.entryName=R,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,h.add(P)}}function y(){if(l=!0,i={},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,R=0;R<r.length;R++){var P=I,w=new Il(x,t);w.header=t.slice(P,P+=ze.Constants.CENHDR),w.entryName=t.slice(P,P+=w.header.fileNameLength),w.header.extraLength&&(w.extra=t.slice(P,P+=w.header.extraLength)),w.header.commentLength&&(w.comment=t.slice(P,P+w.header.commentLength)),I+=w.header.centralHeaderSize,r[R]=w,i[w.entryName]=w}h.clear(),A()}function E(I){var R=t.length-ze.Constants.ENDHDR,P=Math.max(0,R-65535),w=P,T=t.length,k=-1,z=0;for(typeof x.trailingSpace=="boolean"&&x.trailingSpace&&(P=0),R;R>=w;R--)if(t[R]===80){if(t.readUInt32LE(R)===ze.Constants.ENDSIG){k=R,z=R,T=R+ze.Constants.ENDHDR,w=R-ze.Constants.END64HDR;continue}if(t.readUInt32LE(R)===ze.Constants.END64SIG){w=P;continue}if(t.readUInt32LE(R)===ze.Constants.ZIP64SIG){k=R,T=R+ze.readBigUInt64LE(t,R+ze.Constants.ZIP64SIZE)+ze.Constants.ZIP64LEAD;break}}if(k==-1)throw ze.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,T)),c.commentLength&&(o=t.slice(z+ze.Constants.ENDHDR)),I&&y()}function S(){r.length>1&&!m&&r.sort((I,R)=>I.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return l||y(),r.filter(I=>!h.has(I))},get comment(){return _.decode(o)},set comment(I){o=ze.toBuffer(I,_.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(I){this.entries.forEach(I)},getEntry:function(I){return l||y(),i[I]||null},setEntry:function(I){l||y(),r.push(I),i[I.entryName]=I,c.totalEntries=r.length},deleteFile:function(I,R=!0){l||y();let P=i[I];this.getEntryChildren(P,R).map(T=>T.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){l||y();let R=i[I],P=r.indexOf(R);P>=0&&(r.splice(P,1),delete i[I],c.totalEntries=r.length)},getEntryChildren:function(I,R=!0){if(l||y(),typeof I=="object")if(I.isDirectory&&R){let P=[],w=I.entryName;for(let T of r)T.entryName.startsWith(w)&&P.push(T);return P}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let R=this.getEntryChildren(I);return R.includes(I)?R.length-1:R.length}return 0},compressToBuffer:function(){l||y(),S();let I=[],R=[],P=0,w=0;c.size=0,c.offset=0;let T=0;for(let B of this.entries){let D=B.getCompressedData();B.header.offset=w;let L=B.packLocalHeader(),F=L.length+D.length;w+=F,I.push(L),I.push(D);let j=B.packCentralHeader();R.push(j),c.size+=j.length,P+=F+j.length,T++}P+=c.mainHeaderSize,c.offset=w,c.totalEntries=T,w=0;let k=Buffer.alloc(P);for(let B of I)B.copy(k,w),w+=B.length;for(let B of R)B.copy(k,w),w+=B.length;let z=c.toBinary();return o&&o.copy(z,ze.Constants.ENDHDR),z.copy(k,w),t=k,l=!1,k},toAsyncBuffer:function(I,R,P,w){try{l||y(),S();let T=[],k=[],z=0,B=0,D=0;c.size=0,c.offset=0;let L=function(F){if(F.length>0){let j=F.shift(),ie=j.entryName+j.extra.toString();P&&P(ie),j.getCompressedDataAsync(function(de){w&&w(ie),j.header.offset=B;let me=j.packLocalHeader(),Le=me.length+de.length;B+=Le,T.push(me),T.push(de);let dt=j.packCentralHeader();k.push(dt),c.size+=dt.length,z+=Le+dt.length,D++,L(F)})}else{z+=c.mainHeaderSize,c.offset=B,c.totalEntries=D,B=0;let j=Buffer.alloc(z);T.forEach(function(de){de.copy(j,B),B+=de.length}),k.forEach(function(de){de.copy(j,B),B+=de.length});let ie=c.toBinary();o&&o.copy(ie,ze.Constants.ENDHDR),ie.copy(j,B),t=j,l=!1,I(j)}};L(Array.from(this.entries))}catch(T){R(T)}}}}});var kl=te((Zb,Rl)=>{var ue=Xn(),fe=oe("path"),jp=ra(),Wp=Tl(),_n=(...t)=>ue.findLast(t,e=>typeof e=="boolean"),Cl=(...t)=>ue.findLast(t,e=>typeof e=="string"),Kp=(...t)=>ue.findLast(t,e=>typeof e=="function"),$p={noSort:!1,readEntries:!1,method:ue.Constants.NONE,fs:null};Rl.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),$p);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=ue.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new ue(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=ue.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=ue.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw ue.Errors.INVALID_FILENAME();let c=new Wp(r,i),{canonical:l,sanitize:f,zipnamefix:h}=ue;function x(y){if(y&&c){var E;if(typeof y=="string"&&(E=c.getEntry(fe.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(E=c.getEntry(y.entryName)),E)return E}return null}function m(y){let{join:E,normalize:S,sep:I}=fe.posix;return E(fe.isAbsolute(y)?"/":".",S(I+y.split("\\").join(I)+I))}function _(y){return y instanceof RegExp?(function(E){return function(S){return E.test(S)}})(y):typeof y!="function"?()=>!0:y}let A=(y,E)=>{let S=E.slice(-1);return S=S===o.sep?o.sep:"",fe.relative(y,E)+S};return{readFile:function(y,E){var S=x(y);return S&&S.getData(E)||null},childCount:function(y){let E=x(y);if(E)return c.getChildCount(E)},readFileAsync:function(y,E){var S=x(y);S?S.getDataAsync(E):E(null,"getEntry failed for:"+y)},readAsText:function(y,E){var S=x(y);if(S){var I=S.getData();if(I&&I.length)return I.toString(E||"utf8")}return""},readAsTextAsync:function(y,E,S){var I=x(y);I?I.getDataAsync(function(R,P){if(P){E(R,P);return}R&&R.length?E(R.toString(S||"utf8")):E("")}):E("")},deleteFile:function(y,E=!0){var S=x(y);S&&c.deleteFile(S.entryName,E)},deleteEntry:function(y){var E=x(y);E&&c.deleteEntry(E.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,E){var S=x(y);S&&(S.comment=E)},getZipEntryComment:function(y){var E=x(y);return E&&E.comment||""},updateFile:function(y,E){var S=x(y);S&&S.setData(E)},addLocalFile:function(y,E,S,I){if(o.fs.existsSync(y)){E=E?m(E):"";let R=fe.win32.basename(fe.win32.normalize(y));E+=S||R;let P=o.fs.statSync(y),w=P.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);P.isDirectory()&&(E+=o.sep),this.addFile(E,w,I,P)}else throw ue.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,E){y=typeof y=="object"?y:{localPath:y};let S=fe.resolve(y.localPath),{comment:I}=y,{zipPath:R,zipName:P}=y,w=this;o.fs.stat(S,function(T,k){if(T)return E(T,!1);R=R?m(R):"";let z=fe.win32.basename(fe.win32.normalize(S));if(R+=P||z,k.isFile())o.fs.readFile(S,function(B,D){return B?E(B,!1):(w.addFile(R,D,I,k),setImmediate(E,void 0,!0))});else if(k.isDirectory())return R+=o.sep,w.addFile(R,Buffer.alloc(0),I,k),setImmediate(E,void 0,!0)})},addLocalFolder:function(y,E,S){if(S=_(S),E=E?m(E):"",y=fe.normalize(y),o.fs.existsSync(y)){let I=o.findFiles(y),R=this;if(I.length)for(let P of I){let w=fe.join(E,A(y,P));S(w)&&R.addLocalFile(P,fe.dirname(w))}}else throw ue.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,E,S,I){I=_(I),S=S?m(S):"",y=fe.normalize(y);var R=this;o.fs.open(y,"r",function(P){if(P&&P.code==="ENOENT")E(void 0,ue.Errors.FILE_NOT_FOUND(y));else if(P)E(void 0,P);else{var w=o.findFiles(y),T=-1,k=function(){if(T+=1,T<w.length){var z=w[T],B=A(y,z).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(B)?o.fs.stat(z,function(D,L){D&&E(void 0,D),L.isFile()?o.fs.readFile(z,function(F,j){F?E(void 0,F):(R.addFile(S+B,j,"",L),k())}):(R.addFile(S+B+"/",Buffer.alloc(0),"",L),k())}):process.nextTick(()=>{k()})}else E(!0,void 0)};k()}})},addLocalFolderAsync2:function(y,E){let S=this;y=typeof y=="object"?y:{localPath:y},localPath=fe.resolve(m(y.localPath));let{zipPath:I,filter:R,namefix:P}=y;R instanceof RegExp?R=(function(k){return function(z){return k.test(z)}})(R):typeof R!="function"&&(R=function(){return!0}),I=I?m(I):"",P=="latin1"&&(P=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=k=>k);let w=k=>fe.join(I,P(A(localPath,k))),T=k=>fe.win32.basename(fe.win32.normalize(P(k)));o.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?E(void 0,ue.Errors.FILE_NOT_FOUND(localPath)):k?E(void 0,k):o.findFilesAsync(localPath,function(z,B){if(z)return E(z);B=B.filter(D=>R(w(D))),B.length||E(void 0,!1),setImmediate(B.reverse().reduce(function(D,L){return function(F,j){if(F||j===!1)return setImmediate(D,F,!1);S.addLocalFileAsync({localPath:L,zipPath:fe.dirname(w(L)),zipName:T(L)},D)}},E))})})},addLocalFolderPromise:function(y,E){return new Promise((S,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},E),(R,P)=>{R&&I(R),P&&S(this)})})},addFile:function(y,E,S,I){y=h(y);let R=x(y),P=R!=null;P||(R=new jp(i),R.entryName=y),R.comment=S||"";let w=typeof I=="object"&&I instanceof o.fs.Stats;w&&(R.header.time=I.mtime);var T=R.isDirectory?16:0;let k=R.isDirectory?16384:32768;return w?k|=4095&I.mode:typeof I=="number"?k|=4095&I:k|=R.isDirectory?493:420,T=(T|k<<16)>>>0,R.attr=T,R.setData(E),P||c.setEntry(R),R},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return x(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,E,S,I,R,P){I=_n(!1,I),R=_n(!1,R),S=_n(!0,S),P=Cl(R,P);var w=x(y);if(!w)throw ue.Errors.NO_ENTRY();var T=l(w.entryName),k=f(E,P&&!w.isDirectory?P:S?T:fe.basename(T));if(w.isDirectory){var z=c.getEntryChildren(w);return z.forEach(function(L){if(L.isDirectory)return;var F=L.getData();if(!F)throw ue.Errors.CANT_EXTRACT_FILE();var j=l(L.entryName),ie=f(E,S?j:fe.basename(j));let de=R?L.header.fileAttr:void 0;o.writeFileTo(ie,F,I,de)}),!0}var B=w.getData(c.password);if(!B)throw ue.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(k)&&!I)throw ue.Errors.CANT_OVERRIDE();let D=R?y.header.fileAttr:void 0;return o.writeFileTo(k,B,I,D),!0},test:function(y){if(!c)return!1;for(var E in c.entries)try{if(E.isDirectory)continue;var S=c.entries[E].getData(y);if(!S)return!1}catch{return!1}return!0},extractAllTo:function(y,E,S,I){if(S=_n(!1,S),I=Cl(S,I),E=_n(!1,E),!c)throw ue.Errors.NO_ZIP();c.entries.forEach(function(R){var P=f(y,l(R.entryName));if(R.isDirectory){o.makeDir(P);return}var w=R.getData(I);if(!w)throw ue.Errors.CANT_EXTRACT_FILE();let T=S?R.header.fileAttr:void 0;o.writeFileTo(P,w,E,T);try{o.fs.utimesSync(P,R.header.time,R.header.time)}catch{throw ue.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,E,S,I){if(I=Kp(E,S,I),S=_n(!1,S),E=_n(!1,E),!I)return new Promise((k,z)=>{this.extractAllToAsync(y,E,S,function(B){B?z(B):k(this)})});if(!c){I(ue.Errors.NO_ZIP());return}y=fe.resolve(y);let R=k=>f(y,fe.normalize(l(k.entryName))),P=(k,z)=>new Error(k+': "'+z+'"'),w=[],T=[];c.entries.forEach(k=>{k.isDirectory?w.push(k):T.push(k)});for(let k of w){let z=R(k),B=S?k.header.fileAttr:void 0;try{o.makeDir(z),B&&o.fs.chmodSync(z,B),o.fs.utimesSync(z,k.header.time,k.header.time)}catch{I(P("Unable to create folder",z))}}T.reverse().reduce(function(k,z){return function(B){if(B)k(B);else{let D=fe.normalize(l(z.entryName)),L=f(y,D);z.getDataAsync(function(F,j){if(j)k(j);else if(!F)k(ue.Errors.CANT_EXTRACT_FILE());else{let ie=S?z.header.fileAttr:void 0;o.writeFileToAsync(L,F,E,ie,function(de){de||k(P("Unable to write file",L)),o.fs.utimes(L,z.header.time,z.header.time,function(me){me?k(P("Unable to set times",L)):k()})})}})}}},I)()},writeZip:function(y,E){if(arguments.length===1&&typeof y=="function"&&(E=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var S=c.compressToBuffer();if(S){var I=o.writeFileTo(y,S,!0);typeof E=="function"&&E(I?null:new Error("failed"),"")}}},writeZipPromise:function(y,E){let{overwrite:S,perm:I}=Object.assign({overwrite:!0},E);return new Promise((R,P)=>{!y&&i.filename&&(y=i.filename),y||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(w=>{let T=k=>k?R(k):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,w,S,I,T)},P)})},toBufferPromise:function(){return new Promise((y,E)=>{c.toAsyncBuffer(y,E)})},toBuffer:function(y,E,S,I){return typeof y=="function"?(c.toAsyncBuffer(y,E,S,I),null):c.compressToBuffer()}}}});var hu=te(ve=>{"use strict";var M=$;(function(t,e){let r=$,i=t();for(;;)try{if(-parseInt(r(831))/1+-parseInt(r(1218))/2+parseInt(r(1255))/3*(-parseInt(r(991))/4)+-parseInt(r(288))/5+parseInt(r(1409))/6+parseInt(r(237))/7*(-parseInt(r(1502))/8)+parseInt(r(339))/9===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(so,537587);var Qy=Object[M(1383)+M(1537)],e_=Object[M(584)+M(1087)+M(533)],cu=(t,e)=>function(){return t&&(e=(0,t[e_(t)[0]])(t=0)),e},t_=(t,e)=>{let r=M,i={eKOjA:function(c,l,f,h){return c(l,f,h)}};for(var o in e)i[r(930)](Qy,t,o,{get:e[o],enumerable:!0})};function n_(){return ru||(ru=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function r_(){let t=M;return iu||(iu=[IDBCursor[t(575)+"e"].advance,IDBCursor[t(575)+"e"].continue,IDBCursor.prototype[t(716)+t(1057)+"ey"]])}function i_(t){let e=M,r={HMqfw:function(o,c){return o!==c},SLJxh:e(457),SxtkT:function(o,c){return o(c)},RXRAX:function(o){return o()},wsNMU:e(513),sSAQB:function(o,c,l){return o(c,l)},yvdoW:e(613),gfurR:"start",NnkQk:e(1417),zknou:e(1115),yTvPD:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,f={yjDIN:"success",Lyere:r.wsNMU,RiXRl:function(_,A,y){return _(A,y)},duucY:function(_,A,y){return r[$(1054)](_,A,y)}},h=()=>{let _=$;t[_(1044)+"entListe"+_(1194)](f[_(564)],x),t[_(1044)+"entListe"+_(1194)](f[_(733)],m)},x=()=>{let _=$;r.HMqfw(r.SLJxh,_(457))?(f[_(484)](_0x606fb0,_0x129954,96),f[_(1343)](_0x64f224,_0x5ec0e2,_0x2e4800(_0x55a109))):(r[_(883)](o,r[_(883)](kt,t[_(581)])),h())},m=()=>{r[$(883)](c,t.error),r.RXRAX(h)};t[l(1145)+l(225)](r[l(1284)],x),t[l(1145)+"Listener"](l(513),m)});return i[e(625)](o=>{let c=e,l={BZaiZ:"reconnect",QVVHn:r[c(274)]};if(r[c(1517)]!==r[c(1521)])r[c(661)](o,IDBCursor)&&Ac[c(1396)](o,t);else{let f=_0x360825(l.BZaiZ,{message:l[c(1483)]});this.onStartReconnect&&this[c(861)+c(1627)](f)}}).catch(()=>{}),ro[e(1396)](i,t),i}function s_(t){let e=M,r={wQSgj:e(1531),OjjTv:e(960),cHUIX:function(o,c){return o(c)}};if(no[e(548)](t))return;let i=new Promise((o,c)=>{let l=e,f={LmrTK:function(_){return _()},lIiDn:function(_,A){return r[$(775)](_,A)},cCmFu:l(1260)+"or"},h=()=>{let _=l;t[_(1044)+_(814)+_(1194)](r[_(1062)],x),t["removeEv"+_(814)+_(1194)]("error",m),t[_(1044)+_(814)+"ner"](r[_(348)],m)},x=()=>{let _=l;o(),f[_(1261)](h)},m=()=>{let _=l;f.lIiDn(c,t[_(513)]||new DOMException(f[_(1393)],f.cCmFu)),h()};t[l(1145)+l(225)](l(1531),x),t[l(1145)+l(225)](l(513),m),t["addEvent"+l(225)](r.OjjTv,m)});no.set(t,i)}function o_(t){io={cYUdC:function(i,o){return i(o)}}[M(637)](t,io)}function a_(t){let e=M,r={agpfO:function(i,o){return i(o)},cqMIV:function(i,o){return i(o)},XfnMU:function(i,o){return i===o},zgMwF:function(i,o){return i in o},fXBPO:e(700)+"oreNames"};return r[e(1049)](t,IDBDatabase.prototype[e(1550)+e(1021)])&&!r[e(1436)](r[e(946)],IDBTransaction[e(575)+"e"])?function(i,...o){let c=e,l=t[c(421)](r[c(1169)](bi,this),i,...o);return Ic.set(l,i[c(531)]?i[c(531)]():[i]),r[c(1169)](kt,l)}:r_()[e(662)](t)?function(...i){let o=e;return t[o(877)](r.agpfO(bi,this),i),kt(Ac[o(1151)](this))}:function(...i){let o=e;return kt(t.apply(r[o(555)](bi,this),i))}}function c_(t){let e=M,r={EpxnO:function(i,o){return i===o},RILfD:e(295),vFWCm:function(i,o){return i(o)},oaVoz:function(i,o){return i instanceof o},YEBCB:function(i,o){return i(o)},xJDGi:function(i){return i()}};return r.EpxnO(typeof t,r[e(1457)])?r[e(1616)](a_,t):(r[e(1561)](t,IDBTransaction)&&r[e(277)](s_,t),du(t,r[e(1250)](n_))?new Proxy(t,io):t)}function kt(t){let e=M,r={dKWiK:function(o,c){return o instanceof c},NukiQ:function(o,c){return o(c)},RHyeO:function(o,c){return o!==c},ozwIp:"FziNJ"};if(r[e(675)](t,IDBRequest))return r.NukiQ(i_,t);if(eo[e(548)](t))return eo.get(t);let i=r[e(895)](c_,t);return r[e(1574)](i,t)&&(r[e(1574)](r[e(589)],r.ozwIp)?_0x43c05d[e(857)+e(864)+"e"](_0x37967f,{keyPath:_0x47de7a}):(eo[e(1396)](t,i),ro[e(1396)](i,t))),i}var du,ru,iu,Ac,no,Ic,eo,ro,io,bi,su=cu({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={dxOna:function(r,i){return r instanceof i},NAOlr:function(r,i){return r===i},krVZu:"done",TmvZd:t(700)+"oreNames",WJCkm:function(r,i){return r===i},dhyhQ:t(708),fizPi:function(r,i){return r===i},qXPzf:t(1243),jogCO:function(r,i){return r(i)},cYCXX:function(r,i){return r in i}};du=(r,i)=>i.some(o=>r instanceof o),Ac=new WeakMap,no=new WeakMap,Ic=new WeakMap,eo=new WeakMap,ro=new WeakMap,io={get(r,i,o){let c=t;if(e[c(1313)](r,IDBTransaction)){if(e[c(631)](i,e.krVZu))return no[c(1151)](r);if(e[c(631)](i,e.TmvZd))if(e[c(754)](e[c(1335)],"YIWzx"))this._qosDB?.[c(1305)](),this[c(327)]=void 0;else return r[c(700)+c(1354)]||Ic[c(1151)](r);if(e[c(1006)](i,e[c(786)]))return o["objectSt"+c(1354)][1]?void 0:o[c(700)+c(353)](o[c(700)+c(1354)][0])}return e[c(1038)](kt,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return r instanceof IDBTransaction&&(e[o(754)](i,o(685))||e[o(631)](i,o(1243)))?!0:e[o(1374)](i,r)}},bi=r=>ro[t(1151)](r)}}),lu={};t_(lu,{deleteDB:()=>l_,openDB:()=>d_,unwrap:()=>bi,wrap:()=>kt});function d_(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=M,f={PkYcl:function(m,_,A,y,E){return m(_,A,y,E)},LIHYP:function(m,_){return m(_)},QkKHt:function(m){return m()},aqHGm:function(m,_){return m!==_},sjixG:"phIMY",aLSfu:l(422),NGRRv:l(1249)+l(1112),ayiTQ:l(670)+"eeded"},h=indexedDB.open(t,e),x=f[l(270)](kt,h);return i&&h[l(1145)+l(225)](f[l(862)],m=>{let _=l;f.PkYcl(i,f[_(270)](kt,h[_(581)]),m.oldVersion,m[_(658)+"on"],f[_(270)](kt,h[_(1550)+_(1021)]))}),r&&h["addEvent"+l(225)](l(231),()=>r()),x.then(m=>{let _=l,A={tGCUP:function(y){return f.QkKHt(y)}};if(f.aqHGm(f[_(1578)],f[_(1617)]))c&&m["addEvent"+_(225)](_(1305),()=>c()),o&&m[_(1145)+_(225)](f[_(1210)],()=>o());else{let y=this[_(1585)+"tManager"]?.["getCurre"+_(712)+"nt"]();this[_(1469)](_(764)+y),A.tGCUP(_0x3ca0fb)}}).catch(()=>{}),x}function l_(t,{blocked:e}={}){let r=M,i={HBYZh:r(231)},o=indexedDB[r(952)+r(927)](t);return e&&o[r(1145)+r(225)](i[r(1205)],()=>e()),kt(o)[r(625)](()=>{})}function ou(t,e){let r=M,i={EJWZu:"readwrite",MWxNg:function(h,x){return h in x},QomxR:function(h,x){return h===x}};if(!(t instanceof IDBDatabase&&!i[r(801)](e,t)&&i[r(1121)](typeof e,r(1248))))return;if(to[r(1151)](e))return to[r(1151)](e);let o=e[r(936)](/FromIndex$/,""),c=e!==o,l=uu.includes(o);if(!(o in(c?IDBIndex:IDBObjectStore)[r(575)+"e"])||!(l||fu[r(662)](o)))return;let f=async function(h,...x){let m=r,_=this[m(1550)+m(1021)](h,l?i[m(1308)]:"readonly"),A=_[m(1243)];return c&&(A=A.index(x.shift())),(await Promise[m(587)]([A[o](...x),l&&_[m(685)]]))[0]};return to.set(e,f),f}var fu,uu,to,f_=cu({"node_modules/idb/build/index.js"(){let t=M,e={RgodY:function(o){return o()},OVVcw:t(1253),qbiLS:"getAll",iWCtf:t(710)+"ys",KvMBA:t(1402),mVpwT:"put",OhMtg:t(1365),SVjOz:t(929),FNmfx:t(1288),FbaTz:function(o,c){return o(c)}},r=("5|0|2|3|"+t(758)).split("|"),i=0;for(;;){switch(r[i++]){case"0":e[t(317)](su);continue;case"1":to=new Map;continue;case"2":fu=["get",e[t(491)],e[t(239)],e[t(727)],e[t(1372)]];continue;case"3":uu=[e[t(641)],e.OhMtg,e.SVjOz,e[t(410)]];continue;case"4":e.FbaTz(o_,o=>({...o,get:(c,l,f)=>ou(c,l)||o[t(1151)](c,l,f),has:(c,l)=>!!ou(c,l)||o.has(c,l)}));continue;case"5":e[t(317)](su);continue}break}}}),u_={idb:function(t){let e=M,r={PFaTe:function(i,o){return i+o},MGgtZ:e(242)+e(769),kPBfp:function(i,o){return i!==o},MlmsB:e(1122),nblGm:e(524)};t.exports=Promise.resolve().then(()=>(f_(),lu))[e(625)](function(i){let o=e,c={KAUwZ:function(l,f){return r[$(1415)](l,f)},WtbAh:r[o(393)]};if(r[o(218)](r[o(1213)],r[o(887)]))return i;{let l=_0x25e8a8[o(1186)];if(c.KAUwZ(l,_0x518472)>_0x17acb2[o(1193)])throw new _0x4d4ebd(c.WtbAh);return _0x491884[o(1186)]+=_0x36ee0e,l}})}},au={};function Rt(t){let e=M,r={RiZPE:function(c,l){return c!==l}};var i=au[t];if(r.RiZPE(void 0,i))return i[e(248)];var o=au[t]={exports:{}};return u_[t](o,o.exports,Rt),o.exports}Rt.d=(t,e)=>{let r=$;for(var i in e)Rt.o(e,i)&&!Rt.o(t,i)&&Object["definePr"+r(1537)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Rt.o=(e,r)=>Object[t(575)+"e"][t(371)+"operty"][t(421)](e,r)})(),(()=>{let t=M,e={vdXNF:function(r,i){return r!=i},SQhHi:"undefined",DBeEI:t(408),TRNfg:t(916)+"le"};Rt.r=r=>{let i=t;e[i(460)](e[i(1090)],typeof Symbol)&&Symbol["toString"+i(1014)]&&Object[i(1383)+i(1537)](r,Symbol[i(471)+i(1014)],{value:e.DBeEI}),Object["definePr"+i(1537)](r,e[i(597)],{value:!0})}})();function so(){let t=["tuvtu0fhrv8","A0HiANa","CMfUzg9T","q25tr1a","ywDWzK8","rxDeB24","sKjgsNO","ywDLu2HVDW","AwrI","zgrjrcWGzgu","wg5AEfG","sLndvxu","BwvZC2fNzv8","wu1oA3y","rLDt","uxvLDwu","D294CKy","Fdn8oxW4Fde","vgLTzw91Da","EvLeCxG","ywXSq3vYC28","B2zMC2v0","r0jAzwy","B0vdu2m","zvD3wKe","tNzbAKu","zNDZxZeUmc4","x2HHBMrSzvi","BgLTAxq","BMvY","Axj4thy","r1L5tw8","ugz6wuq","sgrLrwi","tuPny3K","yxbWBgLJyxq","r09LyxO","y3n5t0m","CMncAgW","x2DLDeLUDgu","sejzwMG","yNnIsxO","yLPjAhu","BMCGDxjSoIa","u2DrB1u","tKDsuNy","B2nRzxrgywK","DwrNB1C","twXTC0i","vxbyv3K","qM9UD3i","zMXvAva","y3jLyxrLuMu","mJq5mdeYDMLqEe9j","D2Lnsxu","uxfOENO","A25Yvfe","BM93","yNzTuNm","x29UugfNzu4","AevYCM9Yrxy","rLjptLrjrvi","x29UvgLTzw8","zer4DhK","wMzHt0S","ihzHBgLKigq","tgPLuwe","Dw5ZAwDUzwq","BMHRBuK","AhLJBxO","DNPkALG","qKDMqLy","zgvS","yxDWB0q","D3jPDgvvAw4","ywnOzwqSihC","quXm","DMfSDwvZ","C3rVCMu","ChjVy2vZCW","A05vvMW","DxrVuMvJB24","B3nLrxzLBNq","C3rYAw5N","DMvYC2LVBMm","EePer2K","y2zlvfy","ue9sCwi","z2v0s2v5","y2HHCKnVzgu","mJK0ndCXEMDnqMTy","y2HLy2Tszwe","zMLSzw5HBwu","Bwv0Ag9K","AwfUve4","qwjVCNrfCNi","tg1YveS","DhDVCMTdAge","y29Uy2f0","DeD5ww8","zw50","zfzYBKy","sgvHANC","vu1RDey","D24GCMvHC28","D2z6yM4","CvDnuNu","tK1kve0","yM9KEq","y29UBMvJDfm","BMv4DcGPigm","wvDgy3u","sKzoCMy","EKPjtMO","x2LZv29YA2u","BvvIBvq","x3bPBMC","qu1fu00","zMLXwwq","ExzKB1C","AfL3DgO","vKfptgC","ihzHBgLKihm","y2XLyxi","x2LUAxrqCM8","EvfOt1e","lcbTyxGGCMu","C2fHsKe","DgntueO","rKLSrMu","uwDxy1G","tKrNs0C","ENrlwxy","CM92AwrLihC","ENrfrvC","ChPfwge","ywnRpwzYB24","DNzhANa","q0vpAK0","DKLdD2K","y2XVC2u","u1foC3G","Aw9Ul2PZB24","ruPxwNu","whryv0m","B2XKvMvYC2K","C0Xf","yxbWzw5Kq2G","zhHpBMe","tM95v28","BgLUzq","ChrVCG","yM9L","Ewn6vMm","DgHHBIbSB2m","DMXgr3u","y3jLyxrLtwu","rwXQEfa","qw1VDw50","yxnJCMLWDa","shLSr2O","y2vZC0HHBMq","y2XLyxjtDg8","zxjYtM8","zMLUza","mhW2Fdb8mxW","B2TTBui","D3nZoI8V","C3rYAw5NAwy","zvnRqw4","zgH5Afe","y2HLy2TdDxi","t1bftG","te5iy3C","rNjVBNrPzxi","C2fNzq","BezSDxnO","z2v0sxrLBq","zhv1y1K","vwXRy1G","BwLZzq","B3rftM0","y01RC1K","C3HvDMO","quDdELK","CLzHBhvLCW","DgnAq2K","ze54AMG","C2fJwKO","B3jLtMfTzxm","CMvHC29U","DenhrwG","AxnszwfKEq","zgn0zgm","Dw50","vMrxqxC","vwPjyMK","sKvPALm","BMCGB3iGyw4","tKDFrvjst1i","ywrK","Aw5Lza","BKDtDem","zef0Ahy","C0jsvfK","BLnizfq","DLPbCNO","s3znqKe","tfvizLC","y1LdwfG","uMLQDKK","tMXNque","zw1PDa","yxjYyxLIDwy","zw5JB2rPBMC","BwLUzW","z1rQvNe","aaaaaaaaaaa","zgvMAw5Luhi","y2HnyxHuCMK","s3DNwfa","x29UrxjYB3i","x2LUDgvYDMe","BMDHrvq","CLnVuNm","B25dBg9Zzq","vwLjweO","CNnVCL9Uyw0","y0nTrNu","Dgv4Dc9WBge","r0LrBhG","C2v0","Cg9PBNrdB24","rvHQuue","tvHfsgS","x2LUAxrhBg8","ywnRDxbfBMq","y291BNq","BerhCLe","zwjdDKC","q0rcy2m","BxnN","rKvPEfG","tgznBu4","nty1otqXmfrXzfLjCW","vNrNAwG","CgfYC2u","Bg93","sMfqufe","DMPuugO","uezHvgu","BwvZC2fNztO","vePYqM0","Bg5sDNm","u0fyrMy","BeHHBMrSzxi","yNvMzMvY","B3nLza","zMzmAw5L","BM5Ly3q","zgLZywjSzue","x21PBMLoyxy","v2vPEgLUsLm","Cgf5Bg9Hzfq","C3rLBMvYCW","EhLArKe","DvfUCuG","CNLUy2y","EvjLy29UBMu","z2u6ia","DvvTwMi","EMDnD0y","x2LZtwLUAvC","CLD3Cfa","CMvUDevUzha","C2vYDMvYvgK","zuPWCgq","yuXXsgO","Dg9oDw1Izxi","y29UBMvJDeu","v3jSAfe","Bu1OuMS","q29Kzq","vvDQvKq","CMvQzwn0","sxfvuK0","uhLsrK0","AgLNAa","u2TIsuC","B2fK","CMvZB2X2zq","Dg9cExrLCW","uKLmzKq","CKHcEMy","EwDMDKS","rKLmrv9ot1q","zxjFAxnFywm","yxv0B21HDgK","u3nnD1q","uLDZDKi","zgf0yq","zM9YrwfJAa","ChbPvhK","ugvvzuK","x2rLyNvN","sfPru2u","C1zruvi","EffYCfC","A2v5","x3vYBa","sLvMDKS","yxnZAwDU","CNnrEhu","x2LUAxq","x29UtwvZC2e","u2vYDMLJzvC","qwvQqMy","yvPKEMK","uvzwsg4","zxf1ywXZ","zMzMzG","C3LeqvK","tenbDMi","C2nYAxb0","BNjLwLi","DMzQENy","z1rPBwvVDxq","zKPjAMm","x2LZqNjVD3m","CgXLyxnLiha","zMLN","A09QExy","BM9Uzv9UB24","A25sz1y","r0H4Eeu","EKfMyNO","wLnVrvy","odG3mMjQyLvhBG","CMv0CNLdB3u","x2n1CNnVCKy","C2vUza","Dhvuy2m","u1vTtfm","Aw47y2HHCNm","AwDHDg9Yt24","Au5Uyxa","CMvTB3zLq2G","ENDQthG","q0Pqq0W","CgLUz0LUDgu","zxjHDg9Y","EeXXBMq","tM5RuwS","x29Ut3bLBG","y29UC3rYDwm","wuLlCKO","EMTUB3u","x3DZ","zxq9DxrMltG","ignVzgu6ia","DgLTzw91Da","ywDRz2W","zM9sv3e","zgvIDwC","Aw5PDcbrB1m","swTpsw4","y29TCgXLDgu","ihrPBwvZ","B25SAw5L","Dg9iyxnO","ugPpq1C","q291BNq","B3bLCNr5","BNrLCG","wfvOuNO","CwnXr1u","r0vvu3m","AuXAuNG","tM1Jq0O","B2nRzxq","Bg9Nsurhzw4","CNHktxC","zNjVBuHHC2G","s0vJswK","u2HHCMvKv28","DhjHBNnHy3q","yMfSrxzLBNq","ywXSzwqGBxu","t2jsuNy","BNvksgi","DgvmB2Djre4","r0jMwKi","BgLqA0S","Dhnurwu","y3vYCMvUDeu","B05TDg4","B2fwB3O","C0nfA0W","C3bSAwnL","y29UDgv4Da","v3DLte0","rxzLBNq","vMTNvKi","y2uGBM90igK","rgLwvMW","Bur6EwC","EvfrAvG","ywDLsgLKzq","txH2yNO","uKH5zu8","x2rYB3bhBg8","s2nZDfi","rxPyz2G","C2PPEeC","qxjxz1e","DMfSDwu","C1jytfC","zNjHBwvuExa","BKXPBMu","uMLuBha","x2vUzhbVAw4","AefJA01LC3m","CgfNzwHPzgu","yxKSihrYEsa","Dgv4Dc9Qyxy","x2HHBMrSzu8","x2LZtwLUAvq","x2nSzwfYvgK","B25VCgvU","B3jRzxjhBg8","AfPmzKK","zxjFBxnNAwq","BNb2rMi","yw1L","CMvXDwLYzwq","zMX1C2HfEha","wgjov3u","v1PzBg8","zxjYtxnN","ywnR","t2jQzwn0","CYbPBNn0yw4","DefXAfy","v0fMwe0","zw1LBNq","Ae9Wzw5fDMu","D3fkDxy","DKHsrNG","tKPlEuO","ywXSB2nvBNm","m3WY","DKzxq20","yuXtzNu","Du1gCha","s1jjq08","rvjst1i","ChrrExm","ywX3yxLZ","A1nhqKe","AgDIB1u","zgvJB2rLzey","B2nHz2i","zwnVBM5Ly3q","u2TPCcbWyxm","vw9qzxe","tM9Qt3m","A1bczNa","twvZC2fNzuu","C0nVDw50zxi","wNbxCfq","Axnby2TdBgu","s0vNAMm","ru5hzwC","tgLZDgvUzxi","BMnVzgLUzW","Aev3wuK","Ewrhrwy","q25iAgW","Bg9IywXty28","yMXVy2TLza","x2nYzwf0zvm","zuzxv08","BKDNvfC","ALHQyuy","CNjVCK1LC3m","nJa2ovzKA1fHtG","s1bwzgG","CwjPtfm","BfbsEKC","qNHcwg0","uMvHzcbWyxm","sefMuNa","zxHytu0","zgHovKm","CgjoDxG","rKPrA1a","zxHWB3j0CW","r0n6A0O","CMTLCKDSB2i","Dg9Y","yxvwqu4","BMrLEa","y3vYC29Y","vNj0vfC","tMfTzq","A0HhvwC","ywfiqMu","BMvLzf9Hy2S","Aw50zwDLCIa","vwfMq1K","wNLeCfC","A2v5CW","tg9NsurozxC","yxnAzLO","DfH0zva","BvHACKK","zvvyDK8","Cg9PBNrbBMq","teLiwva","zfrtBK0","zw5NDgG","C3bYEuy","z2z1CLi","uNbvBvG","DhftC2m","wuvcq0i","ywDLrxzLBNq","Cw1HAKe","z29PBMCGyxC","qNvnCKq","D1rnzwG","CMvHzhLtDge","mdaWmdaWmda","zwn0","Effuyw4","vgndC0i","mJe1ndi0me5KEhLWAW","CwfYvvK","x2XPC3rLBMu","AxPqzuS","Bg9N","C0HpsK0","tgfwwvG","zNvUy3rPB24","yNPtAKG","x2rLC3rYB3K","t1ffqu0","ExjUBfO","B1ziDgC","zw5HyMXLvhi","BMrWB2LUDfq","vvDXtKy","wKDNt2K","vKPQB24","vxLLBMW","rxjYB3jdB2q","x29WDgLVBNm","mdaWma","zuvnuNi","y3jLyxrLt3a","y3jLyxrLrxi","zM9Yy2u","Dev2zw50","uhnmDxe","uLjpuG","uMDVzfK","ExbL","teTIqwC","q3LZELK","r21oBha","rNnWr1e","BwLUAvbYB2C","t2fZs3q","yw5Nzq","B25JBg9Zzq","x3fVC0rc","uxbIsMu","r1j6EM0","C2vYDMLJzq","tNflDwe","q0zOwgm","AxnAzxjV","yMn3EMi","t2LSDgS","y3vYC29Yx24","qNHyDuC","uffyy1e","mtuXodK4nZzYrvbIvNq","zwvKzwq","CgjICdi","vK5oD04","DwvHrMu","EuTSy2q","Du9xEhC","Dg50CKW","tePtEuy","t2PQvhy","z25NDwW","yNrkqwq","DxneuNm","CMrxuMK","B3jL","DeLK","zKLrAvG","ign1CNnVCIa","Cg9Ysfe","DMvUDa","Cg93","B2nRzxrtDwm","ihrPBwvVDxq","BfrWEM0","AenSB3nLrxy","C2v0q3vYC28","tfzbvLy","BxLythi","BfvRBg8","CNDwD2i","uLvnqu8","uwDPtKO","AgfZt3DUuhi","x194x21Zz18","CMfTugfYyw0","DxHWuw0","zcWGDw5RBM8","reiGzMfPBgu","z3DQA0u","D0PQCKK","nhWWFdn8mNW","u1r3qNC","BwfW","vMv1A2S","CNzHBa","yMrjsNe","q1jVC3e","t3f2t1y","yMfJA3vWigu","z2v0q3vYC28","EwX0z0y","rgvKAwnHDgu","u3zpDNK","wfHTs3G","tuDNDfO","y0rbEhy","s3DmC1e","C3PszvK","y3vYC29YlNm","x25HDMLNyxq","Bwf4tg9ZC0m","we9RqKK","zNn3t0O","ELjxrhe","yKXvB1a","Ec1TC2CTCw8","D3jPDgu","B25tDg9Wsw0","CM92AwrLigi","tw9KDwXL","BezIrge","rK5TzNG","x3bYzwzPEa","AxnmB25N","Dgv4DfbHEwW","y29UBMvJDca","D3HerNm","twXyDMK","ywrICLy","qw5lzfm","AeHAuhu","yw51Ce1LC3m","y2fSBa","z2TZsvy","z2v0q3vYCMu","sNv0Efe","C2LVuMK","t1bet3e","uwLcuxG","y1zysue","zMXkz3K","uxHRvMO","wNbXEK8","Aw1LCYbPBIa","CMvJB25Uzwm","DKPQqNq","quXVr3a","C29kBNO","Aw9UvgLTzw8","AKnbCK4","tgvZvNi","rKnVCvy","Dhj1y3rVCIa","v2Tfwxy","x2nSzwfYugK","Ec11C2uT","x2LZtM9Kzq","vhHLs3i","qwLotNu","z1nczuK","ywnRx2nVzgu","DMvY","ELPWr20","v3nQq1u","sK53r1m","su5tvefova","yxnL","zxH0zw5ZAw8","sKLiB0e","x2jPBMfYEvq","B25mAw5L","DMrytKy","vuH4Cg4","x21LC3nHz2u","wg9Luha","BIWGAg9ZDg4","zufJAW","t0vlAue","B25pCgvU","x2LZsw5PDa","zM55AuS","DLjHzxK","Dg9tDhjPBMC","BNDKrwm","qMfNzeq","B3vUDa","z1zXzvy","BMvJDa","Agn0qKC","vxv1svu","CwLSv3q","BwvY","DMLJzuLeig8","AxrWEg0","y2HnyxHdB3u","uMLyuMW","C2v0u3rVCMe","EgPtu3e","x2TLEvbHDgG","wvLcq1a","ChvZAa","AgLoq0W","t1zwy3C","D09by2W","vxbKyxrLq28","AxnbCNjHEq","DgLTzw91DcW","zsbHihn0CMK","yMfSu2nVCgu","EgTvsKK","y2XVC2uSihC","Awn6tLy","DvbkB0e","ELv4vwS","BK1xBgC","Dg9cExrLC0W","qw9nCxG","ihjLy29UBMu","DuPpEha","AgvHzgvYCW","y3jLyxrLq2W","zgvtu3G","D2LSBfjLy28","yMLUyxj5vhK","zxjYB3i","BefRvNa","zxjFywnRx20","y3vYDMfSDwu","x2nVBM5Ly3q","BMXzC00","AwXK","CgLUz1rPBwu","pxv0zI04","DeHcCLa","C3vIyxjYyxK","s3ztyLq","Cgf5Bg9Hzeu","AgXNBw0","BfzhwMC","CgLUz19VBMm","BMv3tvG","zhrzBMK","C29YDa","tMDpwLO","BwvZ","DMHVuMq","uNL4Dw0","Ec1TC2CTy3u","DLLKDu4","uxvwAeG","D2vI","v2vIu29JA2u","x2n1CNnVCK0","rvHzqu8","DK5ztwC","igzPzwXKoIa","qxjeB3C","Dg9cExrLC0i","zhHRtvi","AgfZ","CMvWBgfJzui","z2vjBMzVu3K","C3vIC3rYAw4","ALb6EM0","q05SvhC","uNbZvM0","y3fnsvy","v0LyAgq","AxmGDw5Kzwy","sMPxreu","yw1LoIa","yNL0zxm","wfjYvfi","uMvJB25Uzwm","ywnRtxnNswq","EwPesu4","ueTwrMy","vKrbv1e","r3jSv00","EuH4D0u","CNPTCLG","CMfTzq","B25szwnLAxy","AxjLza","BwvKAwf0zwW","rvzjzw0","ChjVDg90Exa","BMCGzMfPBgu","AhjeyLq","tfzbAwC","D2fZq2XLyw4","B25TzxnZywC","CMvZDwX0","DMvYC2LVBG","tu9Jr0i","z2v0t3DUuhi","AMDhzgW","r1vqsg8","ywXS","r0fwtfm","B3P3sxa","s1LpCwC","wvHcwMm","CuzMrui","x2rPC2nVBM4","B3v0sw50zxi","v05lAMm","DhDjsfu","vfjozMC","zMLSDgvY","wgnIvLq","C1bvDNK","DNLzDwe","AvnIr2W","BK1wyMW","y2TJB3e","C2vYDMLJzs0","s2zIB0S","AMDMBMS","veDuyw8","D2rTtgC","zv90Aw1LB3u","AxLYAMy","tu5Aug8","C3vJy2vZCW","y29UBMvJDgK","qxrTt0S","zu1yBKC","t21tAxm","DgLLCKPtt04","venJwvy","seD2vMS","Bvvuwem","x3nLBMrby2S","s2v1qvO","CunLDgS","DgHLBG","C3bSAxq","yxrKAMq","Ahbzz3C","ExriAfK","zKT1tMe","tKfpBhi","yxrHlcbKyxq","tfr5vfK","wgTeAui","rfHUzuq","AhDPs1O","y1Lvzem","rgrJtue","BvfcAxO","BMrWB2LUDca","BvzWD1q","C2v0sxrLBq","D0PYDeW","igzHAwWSig0","v2jureW","lcbxzwjtB2m","qw5et00","tufyx1jfvfi","tKfusvzfx0u","ww1lCe0","ufrgq2S","AuzStKq","ywDL","CgLUz09Uy2u","x2n1CNnVCK4","rKjjyu4","x3bPBMDmB3m","BMv3vMvYC2K","BevOBvC","qxPPz20","Evr2ueq","Aw5JBhvKzxm","CLrODgG","DKPYDKq","uwrPyLC","rKTODg0","wejtCu4","yNL0zuXLBMC","C3jJ","DxbNCMfKzw4","yMLUyxj5","Bwu6ia","ug1LCNi","yvHAAMO","zeTxAuS","AxnrB1nby2S","zMvY","CLjguue","zxrxB3jRq2G","uM94zva","EhjgteK","CgfNzxnOB3C","z2v0u3rVCMe","ywXPzcb1CMW","zg9Uzq","u2vXsuq","t3bLBKv2zw4","C3n3ENu","swfksvG","q01OAgK","x2fKzfDZtgK","zw5KCg9PBNq","y0HJt3e","ug1xs20","y2XVC2veqG","x3nLCuLK","zLnoCeW","vgnXywS","EwXSCwi","B2jQzwn0u3q","uLD2veC","y3vYCMvUDeK","B1jir3q","BgvUz3rO","ENruywW","vMPnz20","Ef9MCM9UDgK","r1D6wwm","rurKz0e","z2v0qwXSs2u","yKziCKG","BNrfBMrWB2K","C0jf","sKDjBLy","DgvZDa","y29UDgLUDwu","igfYCMf5yNu","DxbKyxrLq3u","A2TAt2G","rvPAsxi","igXHCMDLCIa","uw15Dxq","EwLdvue","CePJwvu","AMDlwMu","x3bHDgHlzxK","AvDdDgy","rMvdr3K","CfPUyuu","wvfuzgu","B2zM","CMfNzvn5BMm","thLLCMu","yLDJsey","ANnIAgm","qNDmBgu","u0npDeC","B3bLBG","z1j2Cwe","y29UBMvJDa","zxj2AwnL","r2zxzuC","rgTmr1O","B09dqMC","DNresxe","AuTQzuu","zgLZCgf0y2G","C2v0zgi","B2TPCKe","tMziAwq","DxrMofDYAxq","v1zzt2i","mNWZFdb8nxW","v0PdA20","y1jez2q","A2zfEve","CIb0DhDjra","mxW0","DeT3Ehm","C0vkvhm","vufKuwe","x3bPBMDqB24","zhLyBLi","B3bLBIa","x3jLywr5q2W","BgLUzw5V","zNjVBunOyxi","v1bRzeG","DcbSAw1PDa","vvvjD2e","u2vuENm","BMnLq2XVC2u","sK13weO","yKHvA0e","y0HvsvG","Ahr0Ca","ugPJz04","AM9PBG","Bvjxsw8","yNnQCw0","Dg9mB3DLCKm","C2DPza","uMn1B2e","mhWXFdr8nxW","s1PmEMm","CvHqEMy","q3DRt0q","ChjNBMy","Cwz2ELu","CffzvNK","CM5izfK","swHvshG","sLrOBe8","Euftrey","x0rctMfTzq","ru1XzeS","nhWWFdv8mNW","whzIENC","DxnLCKLW","AxnFywnR","tvD4tMC","EKf6A2C","ywDUCwC","rMzrEeq","q09otKvdveK","yLD4rLe","x2rPC3bHDgm","q1jjBuK","sfbmBgm","s2LID0S","Aw1TrhK","B25LCNjVCG","ChjVDg9JB2W","zw50tgLZDgu","zMXVB3i","sfjSCwO","D1jNzu0","vxjlrvO","vw5Oyw5KBgu","reDizMe","z1fcBxu","Ce5bD0q","Aw5PALO","y0vyChq","C0TSC2i","BML0AwfSAxO","vhLHzNa","BMLQDLK","CMvZzxrdB3u","x2HHBMrSzva","ndC4mZK4rLPUAujQ","sevMDvq","se1zv2W","tvbAtwu","D0PJwwS","sKXvvu0","wxzhweS","rKDAyxa","DhjPzxm","y3fZyvK","CMvHzfvjBNq","DeLUDgvYy2u","zNjVBNrPzxi","uMnky3m","AeHpshq","tvv1qKG","B0zUwNa","y3r4","z2vtEw5J","u3LwvMK","yxKSig5LDhC","qvP0s0i","BgvY","qM1cD2G","u3rYyxrLz3K","Cw9Z","y3jLyxrLt2i","Bg9NsurozxC","Bwncyu0","q1LLsgG","B25tDgfYDfi","yxLPvfe","q3zkCLK","AMvJDfn0B3i","tg9JAW","CMvZzxruCMK","DxjS","DMfOAMu","vMvXzwq","AwXLx25HBwu","yw5ZzM9YBvq","mhW0Fdf8mNW","B25nzxnZywC","yMLUza","shDnBeW","q2TurM8","yxbWBhK","zNjVBuj5Dgu","BfrPBwvVDxq","wNf0yvy","B3bhuu8","z3PUD0K","u3H0A1q","t1jhu04","q0LuwxG","B2zMBgLUzq","BMjSr20","y0rbqwe","y3ruAw1LB3u","Dw5KzwzPBMu","y3Lxr2G","EfvZzuvUDG","qNndEgy","CMLLC0nVDw4","tNvRAve","nNWXFdD8na","CM92AwrLige","yxrLq291BNq","z2v0qwXS","yxv0BW","CMvwr00","AgvKtwf4uMu","zMzLCG","C0XPC3rLBMu","C3rHCNq","tw5prKy","CM9YrxzLBNq","CMvZzxrfBMq","Bu9vC28","wunsB0C","yNrvq2y","s0D4sg8","C21Mv3m","CwfLseW","x3bYB3rVy28","x19LC01Vzhu","zcWG","Ae1LC3nHz2u","q3vZDg9Trxi","DhjPzxmGCMu","sLnptLa","AwXSihvZzsa","Dg9VigXHCMC","rfPtzxO","mxWZFdr8mNW","DvHHr2C","DgfIyxnL","t1bftL9fuLi","zgvSzxrL","zuTpAKe","x2rItMfTzq","Cgf5Bg9Hza","vg1SwK4","qNjPzgDL","Au1Ttxi","CMvWBgfJzq","qKfpyM0","DKfRvxG","whLxwvK","De1LA3e","rMzfCxC","BNruCMLLC0m","A3Puz2y","ueffruy","wwjsseu","zLHcue8","wuDxALC","rxLprxu","sKfNDMG","q3vZDg9Tq2W","id4G","zgvSzxrLrge","DgfYz2v0","BgLZDgvUtMu","CNnVCKzPBgu","ywnOzwq","lcbOB3n0BMe","vw5PBxbSzw0","t09Owxa","ywjVCNq","x2zVCM1HDeu","jMPZy2fSBgi","wLfpENG","yw1Lu3bHy2u","B1neA2K","C1P2t04","AuDkAey","zvzPEg8","DxnwtM8","AND5r0i","BxnNsuq","tg9Nsuq","Dg9hzw5LCMe","u2LVvKy","zNjVBu51Bwi","yw5Hz2vY","r2rbyKG","v2XTy2S","DwvZzvO","q3nyvgO","sfnbELi","ENnRv3K","BNrbBMrvCgq","B3jpBMXPBMu","C3rpDNu","zM1lChe","Dg1HAwi","ywrKt25L","AK9VEhC","zxmGCMvHy2G","nhPOCgPNsG","A0L0CMW","s0PgAxi","wfjgtfO","C1PoDeG","quHsvey","yvPyDfu","x3jLBw92zvC","z2vY","zKXlAgC","vxPRBeK","C2vUzf9Hy2S","vNrNz0q","r0vWyvG","AwXLtMfTzq","zML6ugK","zw5JB2rLrNi","z3jVsuu","zxP6AxK","zNbhtha","twLZC2LUzYa","Aw1LuKm","uvrpzfy","vgfN","BLDyD00","zw5fDMvUDa","x29Uq2XVC2u","twjzvNO","Aw5KzxHpzG","BwHnyva","Aw9U","B3bLBKrc","sxzpug8","u3nnEKe","De1HBMfNzxi","rMjZCve","v1nSufm","m3WX","C2PZsgy","ig1LC3nHz2u","DcbVzIbYyw4","yxGGCMv0CMK","u252C0G","x3DHAxq","DhjPBq","v1fgy3m","DgThBhy","AM9Nq08","rMn4BhK","AxnrB1nnzxm","ue1iC0u","q3vtr0W","vhrqBeq","CMvTB3zLrxy","DMXgB3G","Dxrjza","ENrvDgm","AvLQqvG","wgzUtvu","C3rVCcbPBw0","B1H3Cha","wuLSrxC","q29UzMLN","C1nbuui","yu1Oue4","q3jkB0K","uhjPBwfYEuS","zw50zwqGDhK","yNL0zu9MzNm","x2DLBMvYyxq","Ahr0Chm6","D1ftz2O","uvvkELu","rwDeuMG","tM1OEeO","whn5ugO","wuX2ruS","CgLUz0XVC3m","tNjwvha","C2HPzNq","zw5XDwv1zq","DhLWzq","q0Xpu0LorW","ihbYB3rVy28","tgfxuwu","y09Wzw4","x3nVy2TLDa","A2v0ignVBNm","tfLtDe4","BwvZC2fNzq","DeXAuKe","B2LUDfjLywm","vfveDuO","D1rkrLq","icSG","vxjAugi","B3bLCNr5tMe","BffLzKy","qM5dr2O","u1fOsgK","EwzUAKu","zvf2ugC","AhPZCe8","Dw5RBM93BIa","BNvTyMvY","wMrPzMG","sMLkrwO","ysbTDxn0igi","B21jrvq","CgvYC2LZDgu","BMvcvuq","BMfTzq","mxWWFdr8mNW","zLrby1m","zvvYBa","sKHzD0m","tM5RB0O","s3LpALq","uMD4zhC","D3m6lY8","q0Xpu0ve","AgfUz2u","CNbWu2i","zgv2AwnLx2K","tLbrBxK","BMDuAw1LCG","yvvruKq","BunswwK","yKHjAg4","yLPrs0i","uw9TEfi","thDZsha","x3DZsw5ZDge","y29SBM8","Chv0","BLn5rgy","r2LAq0W","zKXIqNG","Bwf4uMv0CMK","DvLJrg8","yNvMzMvYzwq","EgDoEvO","qvHSzMG","B216ALm","Bwf4twvZC2e","r29by2O","veTTB1a","tfPozve","EMPysuG","C2XPy2u","shf0Chu","C2v0y3vYC28","A1n0yxr1C0m","y29Kzq","ywrKrxzLBNq","teTNq1G","B25Uzwn0Aw4","ywrKq291BNq","EKPZD2O","x1fVu01HBMe","z2v0","BNP2wxm","suvtx0vsuK8","zNjVBujPDhm","CM92AwrLihy","CNzHBfzHBhu","q05Iwvi","A0LxqxC","C3nHz2vfDMu","AxvYzfC","x3jLy29UBMu","sK1vq2m","tNLmsxK","q3jUv3C"];return so=function(){return t},so()}function $(t,e){t=t-218;let r=so(),i=r[t];if($.lpIyHc===void 0){var o=function(h){let x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",_="";for(let A=0,y,E,S=0;E=h.charAt(S++);~E&&(y=A%4?y*64+E:E,A++%4)?m+=String.fromCharCode(255&y>>(-2*A&6)):0)E=x.indexOf(E);for(let A=0,y=m.length;A<y;A++)_+="%"+("00"+m.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(_)};$.vgOFAh=o,$.fYeowE={},$.lpIyHc=!0}let c=r[0],l=t+c,f=$.fYeowE[l];return f?i=f:(i=$.vgOFAh(i),$.fYeowE[l]=i),i}var _e={};(()=>{let t=M,e={NgOZZ:function(a,n){return a(n)},NojOs:function(a,n){return a+n},kHHjp:function(a,n){return a+n},IhUHx:function(a,n){return a*n},VkgVB:function(a,n){return a===n},rsQxu:t(545),BGfBV:function(a,n){return a(n)},nSHdT:function(a,n,s){return a(n,s)},eSkAn:t(309),lAkVp:t(1485),FxkQn:t(284)+t(284)+t(284)+"00000000",uQnqH:function(a,n){return a>n},FGZap:function(a,n){return a<n},VrtTW:function(a,n){return a===n},iNnap:t(722),bFHrH:function(a,n){return a!==n},udgoW:function(a,n){return a-n},QgiNJ:function(a,n){return a!==n},mcBaM:function(a,n){return a-n},oRHGt:function(a,n){return a-n},stOvu:function(a,n){return a===n},jgKZe:function(a,n){return a>>>n},ptQys:function(a,n){return a(n)},tsTEe:function(a,n){return a===n},oEARG:t(1011)+t(1599)+" field: "+t(1473),saaJA:function(a,n){return a===n},tJvPE:t(1011)+t(1599)+t(544)+t(1580),JBFJz:function(a,n,s){return a(n,s)},kkZOh:function(a,n){return a<n},CITYx:function(a,n,s,d){return a(n,s,d)},vlFGu:function(a,n,s){return a(n,s)},PjcgN:function(a,n){return a!==n},LZNeQ:function(a,n){return a===n},ZWnRX:t(473),iLZRx:function(a,n,s){return a(n,s)},BsCxf:function(a,n){return a!==n},WSlPS:function(a,n,s){return a(n,s)},ixpLZ:function(a,n){return a(n)},AejBf:function(a){return a()},bdIJq:function(a,n,s){return a(n,s)},BwLle:function(a,n,s){return a(n,s)},kNUVl:function(a,n){return a(n)},XkDiB:function(a,n){return a!==n},EDdgA:function(a,n,s){return a(n,s)},jiygs:function(a,n,s){return a(n,s)},vktVB:function(a,n,s){return a(n,s)},kHRJj:function(a,n){return a!==n},mABeY:"IKqRG",jsbhc:function(a,n){return a!==n},NyLIy:function(a,n,s){return a(n,s)},KyOjT:function(a,n){return a!==n},ZpWpT:function(a,n,s){return a(n,s)},qfvzU:function(a,n,s){return a(n,s)},zskWy:function(a,n){return a(n)},aZXtU:function(a,n){return a(n)},tHBrP:function(a,n){return a>>>n},rnHdY:function(a,n,s){return a(n,s)},hwiKZ:function(a,n,s){return a(n,s)},vICwi:function(a,n){return a(n)},WZYlo:function(a,n,s){return a(n,s)},qCetk:function(a,n,s){return a(n,s)},yKlcd:function(a,n,s){return a(n,s)},vYduN:function(a,n){return a&n},fmKpq:function(a,n){return a===n},AMESM:t(1011)+t(1599)+t(544)+"LogID",CkTFo:function(a,n){return a===n},CizMH:t(1011)+t(1599)+" field: "+t(1258),oSDki:function(a,n,s){return a(n,s)},SgQoU:function(a,n){return a|n},inijZ:function(a,n){return a&n},RWsvB:function(a,n){return a===n},CNlTw:t(822),ugLDJ:function(a,n){return a(n)},bZIhu:function(a,n){return a+n},PTFCk:function(a,n){return a(n)},oOCBg:function(a,n,s){return a(n,s)},UwBAX:t(958)+t(1058)+"pe: ",UoPeq:function(a,n){return a>>n},UnvHh:t(1628)+t(769),KcstR:function(a,n){return a>=n},EXYAO:function(a,n){return a||n},BuueO:t(1618),jgGdl:function(a,n){return a===n},LVAig:t(847),dVrnF:function(a,n){return a===n},tkGlv:"VvMrk",LYStN:t(1407),jwyGB:function(a,n,s){return a(n,s)},tcZCi:function(a,n,s){return a(n,s)},Tyafp:function(a,n){return a<n},rWwpP:function(a,n){return a(n)},nPFQb:function(a,n){return a>=n},WbTDL:function(a,n){return a+n},KibwK:function(a,n){return a!==n},DdcMA:function(a,n){return a&n},tCGEh:function(a,n){return a|n},EyOEu:function(a,n){return a&n},JiJEj:function(a,n){return a==n},TcCsB:function(a,n){return a&n},nGStC:function(a,n){return a>=n},dctdc:function(a,n){return a|n},VVLJo:function(a,n){return a<<n},AtmOK:function(a,n){return a&n},cRDgd:function(a,n){return a<<n},tKwxs:function(a,n){return a&n},xQrpW:function(a,n){return a<n},GUPHo:function(a,n){return a<=n},ueaFe:function(a,n){return a(n)},mlBwF:function(a,n){return a==n},otENm:function(a,n){return a>=n},CJPCL:function(a,n){return a+n},OEKiA:function(a,n){return a+n},rdWRi:function(a,n){return a+n},qkIkA:function(a,n){return a!==n},WkEYv:function(a,n){return a&n},aUQRD:function(a,n){return a<<n},hiNCL:function(a,n){return a|n},Wlmck:function(a,n){return a<<n},sCWzo:function(a,n){return a&n},yczVc:function(a,n){return a&n},TKmoP:function(a,n){return a<<n},bWcHF:function(a,n){return a<n},FBIaN:function(a,n,s){return a(n,s)},cEXpt:t(1080),imeRC:function(a,n){return a<=n},QxkVj:function(a,n){return a<n},GrlWM:function(a,n){return a<n},GfWeG:function(a,n){return a<n},dAthv:function(a,n){return a<n},sioRi:function(a,n){return a+n},KZLzc:function(a,n){return a-n},ppiTy:function(a,n){return a|n},dNxjh:function(a,n){return a&n},UYnex:t(1577),bcwzb:function(a,n){return a|n},hHZPu:function(a,n){return a|n},VdWAw:function(a,n){return a&n},aLqHj:function(a,n){return a&n},sBRTY:function(a,n){return a|n},ydGEf:function(a,n){return a&n},omzjS:function(a,n,s){return a(n,s)},DXneD:function(a,n,s){return a(n,s)},prgnf:function(a,n){return a&n},agnqg:function(a,n){return a&n},sHOJM:function(a,n){return a<<n},CrnWw:function(a,n){return a&n},KYOqg:function(a,n){return a+n},LKgCX:function(a,n){return a===n},ytSGA:t(1231),nZlED:"OkhNd",YYBCP:function(a,n){return a>=n},kzTgf:function(a,n,s){return a(n,s)},HwMlL:t(670)+t(340),KGxHo:function(a,n,s,d,u){return a(n,s,d,u)},twIHU:function(a,n){return a!==n},wxDFs:t(660),yiCUA:function(a,n){return a(n)},vJjBt:function(a,n){return a&n},UzklI:function(a,n){return a&n},hgCmb:function(a,n){return a(n)},afrvn:function(a,n){return a&n},WfswT:function(a,n){return a(n)},ENGeg:function(a,n){return a<<n},FyyMu:function(a,n){return a&n},BIRAy:function(a,n){return a(n)},lUklo:function(a,n){return a<<n},CnHhl:function(a,n){return a>>>n},FJQkP:function(a,n){return a>>>n},FeCGy:function(a,n){return a<n},yfnjE:function(a,n){return a<n},nGsuu:function(a,n){return a<n},Fcxly:function(a,n,s){return a(n,s)},hzspO:function(a,n){return a!==n},ckcoq:function(a,n){return a+n},flUiP:function(a,n){return a>>>n},uOWxw:function(a,n){return a+n},sZNtH:function(a,n){return a|n},MlXvi:function(a,n){return a&n},NmFZP:function(a,n){return a+n},uJOxp:function(a,n){return a&n},hpYgw:function(a,n){return a+n},DGHfa:function(a,n){return a!==n},RcJcs:function(a,n){return a>>>n},agkgl:function(a,n){return a!==n},Rcuoa:function(a,n){return a|n},HSAzR:function(a,n){return a(n)},KPVdh:function(a,n){return a(n)},BmBwh:function(a,n){return a===n},Uzgoj:function(a,n){return a|n},LKSPS:function(a,n){return a|n},liPkK:function(a,n){return a|n},reVGM:function(a,n){return a|n},HylGj:function(a,n){return a<<n},CnSGP:function(a,n){return a|n},hlgmm:function(a,n){return a|n},bzSjH:function(a,n){return a<<n},Tcqak:function(a,n){return a<<n},wJcYk:function(a,n){return a===n},xgNyZ:function(a,n){return a|n},Veqed:function(a,n){return a|n},fTAcS:function(a,n){return a<<n},bHIhn:t(1531),tXteP:t(513),TGTao:function(a,n){return a!==n},JaPPQ:"YDYPv",AHRTF:function(a,n){return a&n},ianTN:function(a,n){return a&n},xLqnd:function(a,n){return a&n},GYyMo:function(a,n){return a&n},Uyenl:function(a,n){return a>>>n},neBUD:function(a,n){return a>>>n},YtLCl:function(a,n){return a<=n},JSCUu:function(a,n){return a|n},iMmMr:function(a,n){return a/n},OQEAM:function(a,n){return a*n},GiZCL:function(a,n){return a>>>n},pzEXa:function(a,n){return a&n},Lulnj:function(a,n){return a>>>n},VqNhi:function(a,n){return a&n},NvAjE:function(a,n){return a>>>n},SioVF:function(a,n){return a>>>n},aXZjj:function(a,n){return a|n},OasKt:function(a,n){return a<<n},CDBcc:function(a,n){return a===n},Heajw:function(a,n){return a>>>n},wRgeM:t(1094)+t(1355),UAdQa:t(1322),eUXvO:t(529),Ryxum:function(a,n){return a===n},VJjon:function(a,n){return a&n},EwDon:function(a,n){return a>>>n},HGvVk:function(a,n){return a>>>n},cfKTV:function(a,n){return a&n},MUuBH:function(a,n){return a&n},aZdzi:function(a,n){return a>>>n},NnkoJ:function(a,n){return a&n},OXXUI:function(a,n){return a>>>n},tGyYo:function(a,n){return a&n},immDy:function(a,n){return a&n},WsjCU:t(797)+t(1028),SnvsH:"CONNECTI"+t(1364),vCTWP:t(1165)+t(1620),TCcYV:t(928)+"OR",WAfXM:"NATIVE_E"+t(316),ygfvK:t(648)+"IES_ERROR",flJgy:"DaSKe",nuJHb:function(a,n){return a<<n},Bonwr:function(a,n){return a&n},mvdUT:function(a,n){return a&n},fswOJ:function(a,n){return a(n)},XcbVT:function(a,n){return a&n},aaHBe:t(603),NrVTp:t(1331),ZqtaV:t(960),YvGXK:t(436),dyXnR:function(a,n){return a>=n},irxLv:t(600),sKlsb:function(a,n){return a==n},sswzu:function(a,n){return a+n},LfMmN:t(819)+"d error.",GBfZB:t(227),zAzkg:function(a,n){return a instanceof n},sjsHf:function(a,n){return a+n},FstBV:function(a,n){return a+n},UMktF:function(a,n){return a+n},YWFcu:function(a,n){return a===n},LTyTY:function(a,n){return a===n},iFlND:"string",lTpzm:function(a,n,s,d){return a(n,s,d)},yASDF:function(a,n){return a===n},vNYMg:"NIjqY",syDAY:"close",LNHcw:t(1023),JThlO:"GhCbs",Hqtpu:t(738),VNNwN:function(a,n,s){return a(n,s)},ZGgOi:function(a,n){return a===n},btUCf:t(616),ZQOzx:t(1113),pAgQp:function(a,n){return a===n},MPZMe:t(577),ZpqzO:"TACJn",ttIjY:t(1619),XoePp:t(347),HMYWl:function(a,n){return a||n},KJFir:function(a,n){return a!=n},vtDIq:"undefined",vZArz:function(a,n){return a<n},WSaTF:function(a,n){return a&n},nSyDf:function(a,n){return a+n},yYDqx:function(a,n){return a<n},GAVLS:function(a,n){return a<n},foRWq:function(a,n){return a|n},SsMzA:function(a,n){return a&n},pQYVy:function(a,n){return a>=n},YGLXR:function(a,n){return a|n},MJMcy:function(a,n){return a&n},UrZPb:function(a,n){return a<<n},FKhtm:function(a,n){return a<<n},TtPlD:function(a,n){return a&n},yHxwE:function(a,n){return a>>n},KwLsQ:function(a,n){return a+n},CrJoI:function(a,n){return a&n},CYeHh:function(a){return a()},lPRzG:function(a,n){return a|n},pZnaE:function(a,n){return a|n},lnRvs:function(a,n){return a===n},FspGQ:function(a,n){return a===n},IkOIn:"lMOEW",GOeaz:t(784)+t(1615),kItrl:function(a,n){return a+n},EVIem:function(a,n){return a<<n},CFhXc:function(a,n){return a|n},ytHhY:function(a,n){return a|n},lFbDa:function(a,n){return a|n},YXBZc:function(a,n){return a|n},tuTcc:function(a,n){return a|n},dQtgT:function(a,n){return a|n},cyWGh:function(a,n){return a&n},tAqhV:function(a,n){return a>>n},dDxty:function(a,n){return a&n},cVXIA:"IPZYq",iSbGl:t(779),vHRFx:function(a,n){return a instanceof n},eQvPg:function(a,n){return a!==n},NqKua:"ORIFu",ZfaOK:t(760),VDAWQ:"applicat"+t(1307),OfbYj:t(1394)+t(1508)+"et=utf-8",hYwtj:t(1317),GCzkJ:"ppe",atdjd:function(a,n){return a(n)},mGIxi:function(a,n){return a===n},ABOmL:t(1099),GoAcj:t(1488),xQTan:t(1589)+t(1324),fnyiK:t(776),JjWDE:t(962)+t(1301)+t(618)+"P",uQbrd:function(a,n){return a instanceof n},ztUtc:function(a,n){return a(n)},bZQKB:function(a,n){return a!==n},JjbiT:t(1489),vvGjp:t(1498),NlgAA:t(1173),vJrvD:t(583),gznwI:t(475),GEUSs:function(a,n,s,d){return a(n,s,d)},UHqRZ:function(a,n){return a&n},jPzzm:function(a,n){return a instanceof n},GmNlp:function(a){return a()},CsXTj:t(888),JFNrf:"WDseR",lDGrQ:t(601),vjTPj:function(a,n){return a(n)},sCEkL:function(a,n){return a&n},xjSSq:function(a,n){return a===n},QZSfx:t(818),HgPkX:t(1348),DiVVl:t(1533),STwBw:t(886),BxBXm:t(1587),LaWQe:t(682),SvOvy:t(798),bsjqm:function(a,n){return a||n},HAfRp:function(a,n){return a||n},yUiLi:function(a,n){return a||n},hycmz:function(a,n){return a||n},rpvRR:function(a,n){return a instanceof n},sZXxI:function(a,n){return a+n},YbRHE:function(a,n){return a+n},kZgdT:t(1009),adbrV:function(a,n){return a||n},Qqhzz:function(a,n){return a!=n},RiTlp:t(1529)+t(376)+"d",GIQlx:function(a,n,s){return a(n,s)},nMWlg:t(856),xkUJI:t(1177)+"id",zwjLx:function(a,n){return a(n)},tDgWp:function(a,n){return a&n},SUmLS:function(a,n){return a===n},GBZef:"hTpjE",KfboK:t(989),IaJIX:t(707)+"er_qos",vAkUx:t(707)+"er_qos_ack",AiNNu:function(a,n,s,d){return a(n,s,d)},NmcCJ:t(707)+t(1461)+"k",zjXIH:function(a,n,s){return a(n,s)},itpxm:"x_fronti"+t(515)+t(782),Rgxdw:function(a,n,s,d){return a(n,s,d)},XBSqN:t(259),mDzyg:function(a,n,s,d){return a(n,s,d)},YGWjW:t(800),hctBG:function(a,n){return a&&n},bsbIz:"ack_id",iyrjf:function(a,n){return a||n},CMhhi:t(449),JNwGS:function(a,n){return a instanceof n},BnCGj:"applicat"+t(1307)+";charset"+t(521),usDRs:t(1497)+"e",PORqb:t(671),iGIhe:t(613),WQFcs:"DdkEv",LaVYX:function(a,n){return a+n},tntrL:"WwKKq",PsLuq:t(369),zJswj:function(a,n){return a+n},fJIjc:function(a,n){return a+n},YLvEK:"index ou"+t(1031)+t(1434),tLZRA:t(1085),cMksY:t(951),RijvI:function(a,n){return a!==n},yQhOQ:t(426),jgfnk:function(a,n){return a>n},QgWcX:t(260)+t(923)+"e",RpUmX:function(a,n){return a!==n},qcqGU:t(1088),CyszY:function(a,n){return a&n},bLUoP:function(a,n,s,d){return a(n,s,d)},wJrtL:function(a,n){return a!==n},GRzzm:t(884),TmlZN:function(a,n){return a<n},HdeEb:t(1203),FvOay:function(a,n){return a<<n},NJKyJ:t(925)+"0",fpGLp:function(a,n){return a+n},eJppd:function(a,n){return a+n},oXwpp:function(a,n){return a<n},iRNmV:function(a,n){return a+n},qarEz:function(a,n){return a<<n},OOhYp:function(a,n){return a+n},CRImI:function(a,n){return a|n},UlkcX:function(a,n){return a|n},PQXcQ:function(a,n){return a+n},rSoRs:function(a,n){return a<<n},EXjQA:function(a,n){return a<<n},OOnMU:function(a,n){return a+n},RoxeP:function(a,n){return a!==n},ZSoEV:t(1463),uXaGg:t(1581),eWwZA:function(a,n){return a>>>n},gngul:function(a,n){return a+n},vlFox:function(a,n){return a&n},facjG:function(a,n){return a>>>n},FfQxD:function(a,n){return a+n},XRFLZ:function(a,n){return a&n},EMqdK:function(a,n){return a>>>n},ALoGp:function(a,n){return a+n},yQeja:function(a,n){return a&n},WkSQq:"11|2|4|5"+t(1182)+t(1330)+"7",HPLlc:function(a,n){return a|n},JMwXJ:function(a,n){return a>n},yltgF:function(a,n,s,d){return a(n,s,d)},yrnlZ:function(a,n){return a|n},BnALK:function(a,n){return a<<n},porHQ:function(a,n){return a<n},TUDuJ:function(a,n){return a>>>n},ocagb:function(a,n){return a&n},XbNWu:function(a,n){return a|n},wTMeh:function(a,n){return a&n},phASO:function(a,n){return a|n},ueseZ:function(a,n){return a>>>n},gQBmu:function(a,n){return a!==n},QUJzU:t(647),VvJTB:function(a,n){return a<n},dxkMR:"header",XUhRz:t(330),YmKpM:t(1102),auVAN:"cursor_f"+t(870),FIlFe:t(1460)+"_EXIST",rRFQA:function(a,n,s){return a(n,s)},RpsVm:t(336)+"ame",bvmRs:function(a,n){return a===n},ArWgQ:t(1013),XRrTR:t(1241),BxXuG:t(454),iGJhF:function(a){return a()},tyMDw:t(748),WOpat:function(a,n){return a!==n},XsyPj:t(1064),OhxuO:function(a,n){return a<=n},vRaey:t(1158),sacZJ:t(1283),qCyEV:function(a,n){return a===n},qilWt:t(392),bHUkA:t(385),CSzGS:function(a,n){return a||n},mOUso:"code",AZtKB:function(a,n,s){return a(n,s)},pMOeK:t(707)+t(1596),BuMrD:"x_frontier_ttl",yQQiX:t(404)+"s",xrFLI:t(536)+t(1392)+"e",tsKSD:function(a,n,s){return a(n,s)},eVixo:"x-msg-cursor_value",ySgoc:function(a,n){return a>n},AnKdS:function(a,n){return a>n},eIcyG:function(a){return a()},GkjTG:t(966),NnEFa:t(806),SkbIG:function(a){return a()},xyZFA:function(a,n){return a<n},KrTXX:function(a){return a()},deSSx:"YQwgJ",ImtsJ:function(a){return a()},tmaib:function(a){return a()},hHOHt:function(a,n){return a(n)},WrlhQ:function(a){return a()},qWMRu:function(a,n){return a===n},smfWs:function(a,n){return a!==n},PAEEF:function(a){return a()},XOkBI:function(a,n){return a!==n},ngaET:t(1432),btJAd:t(472),dhNVC:function(a,n,s){return a(n,s)},spryF:function(a,n,s){return a(n,s)},wdmLg:function(a,n,s){return a(n,s)},JEijS:"bye",cHcOq:function(a,n){return a!==n},vzJjX:function(a,n){return a===n},nijvY:t(724),NMJTM:function(a,n,s){return a(n,s)},YIlEw:function(a,n,s){return a(n,s)},vhoRd:t(900),TxeKr:"ping_onc"+t(610)+"t",hZLfI:t(914),Oiltk:function(a,n){return a===n},mMhRk:t(1378)+t(677),IqURM:function(a,n){return a/n},eFWWO:t(1494)+t(1155)+t(684),uxpQm:function(a,n){return a(n)},KwgXP:t(1494)+t(1298)+"s params"+t(646)+t(1078)+t(441)+t(557)+t(1366),SAXFf:t(433)+"t",scrXa:function(a,n){return a||n},kOjyv:function(a,n){return a||n},NfHid:function(a,n){return a!==n},QiBQx:"pgPUH",CvJrY:function(a,n){return a==n},okirA:t(1061),JpjJo:t(1110),oNmtn:t(1332),UWqNF:t(1114)+"d",usVNo:function(a){return a()},Zdifh:t(1191)+"0",VjMgm:function(a,n){return a<=n},XnZxX:function(a,n){return a>=n},yscLC:function(a,n){return a+n},Veukk:function(a,n){return a|n},ztTal:t(246),gSBeI:t(1500),mhMaP:function(a,n){return a!==n},VtggD:t(328),aDJyb:function(a,n,s){return a(n,s)},sLXdu:function(a,n){return a||n},WVYOb:t(905),cDAxv:function(a,n){return a-n},ebCvG:function(a,n){return a(n)},dQKLz:function(a,n){return a(n)},XtXWC:"qmajA",cINLX:t(1226)+">",CwkOD:function(a,n){return a*n},cHQXi:function(a,n){return a>n},KEcIi:function(a,n){return a*n},MNZPo:function(a,n){return a>n},Mxvbz:function(a,n){return a===n},sZphA:t(556),RWvTG:function(a,n,s){return a(n,s)},FfEqw:function(a,n){return a!==n},UUIwa:"timeout",uPJoA:t(746),szReY:t(937),GHxxE:"going aw"+t(1588)+"reconnecting ser"+t(450),zyDgc:function(a,n,s){return a(n,s)},MXEHk:t(495)+" try rec"+t(1147)+"g",mXZrI:"send_ack",HEfuT:"0|2|1|4|3",mKWSf:t(1103)+"3",GEpaX:t(906),NDgKG:function(a,n,s){return a(n,s)},tMekq:function(a,n,s){return a(n,s)},oECSc:function(a,n,s){return a(n,s)},myXLr:t(1604),lVGZg:t(621),oVHtg:t(753)+t(896),Ibekc:"close, w"+t(1606)+t(1568)+t(826)+"ed",PKVFf:function(a,n){return a===n},UpXWy:t(499)+"s already closed",SQNsx:t(1494)+t(897)+t(1230)+t(632)+t(1098)+t(496)+t(1363)+t(717)+t(903),ugSfl:function(a,n){return a==n},kSGBA:function(a,n){return a(n)},mCRYi:function(a,n){return a||n},UHxpn:t(1494)+t(897)+t(1287)+t(741),XyWYY:function(a,n){return a instanceof n},vfjzv:function(a,n){return a instanceof n},fIQiX:t(1162),SCOtG:"kcUmP",eVzzR:"sent",GdAbH:t(1071),dTSnM:function(a,n){return a||n},UuuIU:"2|5|1|0|3|4",WNKjc:t(1365),kHGUg:t(929),YMNkv:t(1253),QuVhH:"getAllKeys",ObRRv:t(1402),CEOjM:function(a){return a()},eEMRr:t(697),KEgjc:t(379)+"1",gRvqa:function(a,n){return a(n)},wfzbn:t(528)+"e_success",WPkdH:function(a,n,s){return a(n,s)},jXjaF:t(1382),nlYsM:"Window",PfzYD:function(a,n){return a===n},sVQQR:t(1605),QdibW:t(390)+"dWorkerG"+t(230)+"pe",FIsmG:function(a,n){return a!=n},YQTde:function(a,n){return a!=n},LCAvb:function(a,n){return a!=n},aOrxP:function(a,n){return a===n},UafCY:t(1549)+t(250)+"alScope",KeuAZ:t(1480)+t(1594)+t(497),wiMIu:function(a,n){return a!=n},MbYVz:function(a,n){return a!=n}};Rt.r(_e),Rt.d(_e,{FWS:()=>Ux,CustomErrorEvent:()=>xd,createCloseEvent:()=>lt,ReconnectEvent:()=>hd,createErrorEvent:()=>nt,decodedFrame:()=>Un,createOpenEvent:()=>_d,CustomCloseEvent:()=>pd,createReconnectEvent:()=>Lo,FrontierMessageEvent:()=>md,encodeFrame:()=>Ke,createMessageEvent:()=>yd,OpenEvent:()=>wd,ErrorCode:()=>$t,Event:()=>qn,MessageEvent:()=>gd});let r="";function i(a=""){let n=t,s="02",d=""+Date.now(),u=r||(r=e[n(532)](h,a)),g=Math[n(1167)]().toString(16).slice(-6);return e.NojOs(e[n(1630)](e.NojOs(s,d),u),g)}function o(){let a=t;return e[a(1166)](e[a(792)](1e4,Date[a(1222)]()),Math[a(815)](e[a(792)](1e4,Math[a(1167)]())))}function c(a){let n=t,s={vahje:function(d,u){return d(u)},npvFb:function(d,u){return e.VkgVB(d,u)}};if(e[n(1477)]===e[n(1477)])return e[n(1630)](e[n(1236)](Array,8)[n(778)]("0"),e[n(1370)](parseInt,a,10)[n(471)](2)).slice(-8);{let d=s[n(868)](_0x4bf78c,_0x1211df);this[n(1522)]&&s[n(1597)](this._ws[n(283)+"te"],this.OPEN)&&(this[n(1522)]&&this[n(1522)][n(1505)](d),this[n(1469)](n(1002),_0x2c4ab3))}}function l(a){let n=t;return(Array(4)[n(778)]("0")+parseInt(a,2)[n(471)](16))[n(1140)](-4)}function f(a){let n=t,s=a[n(626)](/\./)[n(381)](g=>c(g)),d=[];return d[0]=l(s[0]+s[1]),d[1]=e.NgOZZ(l,e.NojOs(s[2],s[3])),[e.eSkAn,e[n(1334)],e.eSkAn,e[n(1334)],e.eSkAn,e[n(514)],d[0],d[1]][n(778)]("")}function h(a){let n=t,s=/(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}/[n(715)](a),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]))/.test(a);return s?e[n(532)](f,a):d?x(a):e.FxkQn}function x(a){let n=t,s="",d=[],u=0,g=0,v=!0,b=e[n(1334)];if(e.uQnqH(a[n(1019)]("::"),-1)){let p=a[n(626)]("::");for(let N=0;e[n(838)](N,p[n(704)]);N++)if(e.VrtTW(e[n(1510)],n(722))){let H=p[N];if(e[n(1431)](H[n(1019)](":"),0)){let W=H.split(":");v&&(u=W.length),g+=W.length;for(let K=0;e[n(838)](K,W[n(704)]);K++)if(e[n(711)](4,W[K][n(704)])){let Ae=b.substring(0,e[n(1212)](4,W[K][n(704)])),Ve=Ae.concat(W[K]);d[n(489)](Ve)}else d[n(489)](W[K]);v=!1}else{if(e.QgiNJ(4,H[n(704)])){let W=b[n(551)+"g"](0,e.mcBaM(4,H[n(704)])),K=W[n(1263)](H);d.push(K)}else d[n(489)](H);v&&(u+=1),g+=1,v=!1}}else _0x50b6f5.o=(H,W)=>_0x76fb32.prototype[n(371)+n(1537)][n(421)](H,W);let O="";for(let N=0;N<e[n(703)](8,g);N++)O=O[n(1263)](b);for(let N=0;N<d[n(704)];N++)e[n(985)](N,u)&&(s=s[n(1263)](O)),s=s[n(1263)](d[N]);return s}{let p=a[n(626)](":");for(let O=0;e.FGZap(O,p[n(704)]);O++){let N=p[O];if(e[n(711)](4,p[O].length)){let H=b.substring(0,4-p[O].length),W=H[n(1263)](N);s=s[n(1263)](W)}else s=s[n(1263)](N)}return s}}function m(a,n){let s=t;if(e[s(711)](s(291),s(291))){let d=_0x56f89e.pop();return d?(d[s(1186)]=d[s(1193)]=0,d):{bytes:new _0x2e2b3b(64),offset:0,limit:0}}else{let d=a[s(1473)];e[s(711)](void 0,d)&&(Z(n,10),e[s(1370)](Le,n,d));let u=a[s(1580)];e.bFHrH(void 0,u)&&(e[s(1370)](Z,n,18),Le(n,u))}}function _(a){let n=t,s={};e:for(;!e[n(532)](L,a);){let d=e.BGfBV(we,a);switch(e.jgKZe(d,3)){case 0:break e;case 1:s.key=me(a,e[n(1621)](we,a));break;case 2:s.value=e[n(1370)](me,a,e.NgOZZ(we,a));break;default:e[n(1370)](R,a,7&d)}}if(e[n(1558)](void 0,s[n(1473)]))throw new Error(e.oEARG);if(e[n(1292)](void 0,s.value))throw new Error(e.tJvPE);return s}function A(a){let n=t,s=T();return e[n(1171)](y,a,s),B(s)}function y(a,n){let s=t,d={lEhmW:function(Ge,Ne){return e[$(719)](Ge,Ne)},uUmZb:function(Ge,Ne){return Ge+Ne},aMhPN:function(Ge,Ne,rt,wn){return Ge(Ne,rt,wn)},qarUY:function(Ge,Ne,rt,wn){return e[$(885)](Ge,Ne,rt,wn)}},u=a.SeqID;e.bFHrH(void 0,u)&&(e.vlFGu(Z,n,8),e[s(1370)](pe,n,u));let g=a[s(972)];e[s(370)](void 0,g)&&(e.nSHdT(Z,n,16),e[s(1171)](pe,n,g));let v=a.service;if(e[s(777)](void 0,v))if(e[s(1138)](s(473),e.ZWnRX))e[s(1320)](Z,n,24),e[s(1542)](pe,n,e.BGfBV(P,v));else return _0x34cd1a?d[s(659)](_0x51c1e7[s(704)],40)?d.uUmZb(d[s(1055)](_0x1ba68e,_0x3e14a0,_0x4fa8ad,_0x4c4798),_0x45048d):_0x3f1584[s(751)+"e"]?d[s(1435)](_0x3af79e.utf8Write(_0x182bcb,_0x3659ae),_0x44435d):_0x4c656f[s(405)]?_0x143475[s(405)](_0x94048,_0x4b1b57)+_0x3cc215:d[s(289)](_0x5042a9,_0x4b2b3d,_0xad1961,_0x582d75)+_0x42ab10:_0x287979;let b=a[s(1258)];e.BsCxf(void 0,b)&&(e[s(1027)](Z,n,32),e[s(1370)](pe,n,e.ixpLZ(P,b)));let p=a.headers;if(p!==void 0)for(let Ge of p){e[s(1027)](Z,n,42);let Ne=e[s(1481)](T);e[s(384)](m,Ge,Ne),Z(n,Ne[s(1193)]),e[s(736)](dt,n,Ne),e[s(1245)](k,Ne)}let O=a["payloadE"+s(226)];e[s(634)](void 0,O)&&(e[s(709)](Z,n,50),e.jiygs(Le,n,O));let N=a["payloadT"+s(318)];N!==void 0&&(Z(n,58),e.vktVB(Le,n,N));let H=a.payload;e.kHRJj(void 0,H)&&(e.stOvu(e.mABeY,s(617))?this[s(1591)+"T"]||this[s(1437)+"X"]?this[s(1224)+"etWorkChange"]():this[s(1493)+"er"]&&this[s(1400)+s(1551)+s(225)]():(e[s(736)](Z,n,66),Z(n,H[s(704)]),de(n,H)));let W=a[s(264)];e[s(735)](void 0,W)&&(e[s(1163)](Z,n,74),Le(n,W));let K=a[s(1440)+s(1380)];K!==void 0&&(Z(n,82),Le(n,K));let Ae=a[s(971)];e[s(1108)](void 0,Ae)&&(e[s(221)](Z,n,90),Le(n,Ae));let Ve=a[s(1582)+"e"];Ve!==void 0&&(e.NyLIy(Z,n,96),e[s(789)](pe,n,P(Ve)))}function E(a){return e[t(982)](S,e.BGfBV(z,a))}function S(a){let n=t,s={};e:for(;!e[n(997)](L,a);){let d=e[n(1245)](we,a);switch(e[n(522)](d,3)){case 0:break e;case 1:s[n(686)]=e[n(709)](Fn,a,!0);break;case 2:s[n(972)]=e[n(789)](Fn,a,!0);break;case 3:s[n(330)]=we(a);break;case 4:s[n(1258)]=e.ptQys(we,a);break;case 5:{let u=I(a);(s[n(508)]||(s[n(508)]=[]))[n(489)](e.zskWy(_,a)),a[n(1193)]=u;break}case 6:s[n(525)+n(226)]=e.EDdgA(me,a,e[n(1621)](we,a));break;case 7:s[n(1428)+n(318)]=e[n(791)](me,a,e.aZXtU(we,a));break;case 8:s[n(932)]=e[n(636)](ie,a,e[n(1304)](we,a));break;case 9:s.LogIDNew=e.WZYlo(me,a,e[n(982)](we,a));break;case 10:s["serverTi"+n(1380)]=me(a,we(a));break;case 11:s.msgID=e[n(624)](me,a,we(a));break;case 12:s[n(1582)+"e"]=e[n(997)](we,a);break;default:e[n(344)](R,a,e[n(537)](7,d))}}if(s[n(686)]===void 0)throw new Error(n(1011)+n(1599)+n(544)+"SeqID");if(e[n(986)](void 0,s[n(972)]))throw new Error(e[n(1282)]);if(e.CkTFo(void 0,s[n(330)]))throw new Error(n(1011)+"required"+n(544)+n(330));if(e[n(255)](void 0,s[n(1258)]))throw new Error(e.CizMH);return s}function I(a){let n=t,s={Vtgih:function(d,u,g){return e[$(965)](d,u,g)},PMHsE:function(d,u){return e[$(1209)](d,u)},exXMM:function(d,u){return e[$(823)](d,u)}};if(e[n(1464)](e.CNlTw,e[n(553)])){let d=e.ugLDJ(we,a),u=a[n(1193)];return a[n(1193)]=e.bZIhu(a[n(1186)],d),u}else s[n(1410)](_0x27b8f7,_0xc1777b,s[n(1041)](s[n(244)](127,_0x447d8d),128)),_0x4f696f>>>=7}function R(a,n){let s=t;switch(n){case 0:for(;e.vYduN(128,e.PTFCk(Ie,a)););break;case 2:e[s(1163)](D,a,we(a));break;case 5:e[s(736)](D,a,4);break;case 1:e[s(744)](D,a,8);break;default:throw new Error(e[s(1207)](e.UwBAX,n))}}function P(a){let n=t;return a|=0,{low:a,high:e[n(1629)](a,31),unsigned:a>=0}}let w=[];function T(){let a=t,n=w.pop();return n?(n[a(1186)]=n[a(1193)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(a){w[t(489)](a)}function z(a){return{bytes:a,offset:0,limit:a[t(704)]}}function B(a){let n=t,s=a.bytes,d=a[n(1193)];return s[n(704)]===d?s:s[n(523)](0,d)}function D(a,n){let s=t;if(e.uQnqH(a[s(1186)]+n,a[s(1193)]))throw new Error(e.UnvHh);a.offset+=n}function L(a){let n=t;return e[n(1576)](a[n(1186)],a[n(1193)])}function F(a,n){let s=t;if(e.VrtTW(e.BuueO,e.BuueO)){let d=a.bytes,u=a[s(1186)],g=a[s(1193)],v=e.kHHjp(u,n);if(e.uQnqH(v,d[s(704)])){let b=new Uint8Array(e[s(792)](2,v));b.set(d),a[s(560)]=b}return a[s(1186)]=v,e[s(1431)](v,g)&&(a[s(1193)]=v),u}else{let d=this._qosDB[s(683)+"geSync"](this[s(411)]);return _0x4c106c[s(1411)](e[s(542)](d,"{}"))[_0x403e14]}}function j(a,n){let s=t,d=a.offset;if(e[s(1431)](d+n,a[s(1193)]))throw new Error(s(242)+s(769));return a[s(1186)]+=n,d}function ie(a,n){let s=t;if(e[s(585)](e[s(578)],s(847))){let d=j(a,n);return a[s(560)][s(523)](d,d+n)}else e[s(885)](_0x244ffe,this,_0x386c56,[_0x52b179,_0x1218fa,_0x1630b9,_0x2cdd5e,_0x4ba673,_0x539645])}function de(a,n){let s=t;if(e[s(1266)](e[s(1037)],e[s(1079)]))return this[s(327)]?.[s(1396)]({message_id:_0x12db2f,timestamp:_0x54b3db});{let d=e.jwyGB(F,a,n[s(704)]);a[s(560)][s(1396)](n,d)}}function me(a,n){let s=t,d=e[s(1351)](j,a,n),u=String[s(767)+s(1447)],g=a[s(560)],v="\uFFFD",b="";for(let p=0;e[s(827)](p,n);p++){let O=g[e[s(1166)](p,d)],N,H,W,K;e[s(1292)](128&O,0)?b+=e[s(1438)](u,O):e[s(876)](224&O,192)?e.nPFQb(e[s(645)](p,1),n)?b+=v:(N=g[e[s(1166)](p+d,1)],e[s(810)](e[s(638)](192,N),128)?b+=v:(K=e[s(1356)]((31&O)<<6,e.EyOEu(63,N)),K<128?b+=v:(b+=e[s(1304)](u,K),p++))):e.JiJEj(e[s(287)](240,O),224)?e[s(1367)](e[s(1630)](p,2),n)?b+=v:(N=g[p+d+1],H=g[e[s(1630)](p,d)+2],e[s(638)](N|H<<8,49344)!==32896?b+=v:(K=e[s(1358)](e[s(1358)](e.VVLJo(e[s(615)](15,O),12),e[s(755)](e[s(615)](63,N),6)),e.tKwxs(63,H)),e[s(1472)](K,2048)||e.nGStC(K,55296)&&e[s(586)](K,57343)?b+=v:(b+=e[s(343)](u,K),p+=2))):e.mlBwF(248&O,240)?e.otENm(p+3,n)?b+=v:(N=g[e.CJPCL(p+d,1)],H=g[e[s(1630)](e.OEKiA(p,d),2)],W=g[e[s(352)](e[s(1207)](p,d),3)],e.qkIkA(e[s(442)](e[s(1356)](N|H<<8,e[s(1117)](W,16)),12632256),8421504)?b+=v:(K=e[s(490)](e[s(1358)](e[s(1358)](e[s(978)](e.sCWzo(7,O),18),e[s(1318)](63,N)<<12),e.TKmoP(e[s(638)](63,H),6)),e[s(1318)](63,W)),e[s(734)](K,65536)||K>1114111?b+=v:(K-=65536,b+=e[s(656)](u,e[s(1630)](e[s(1629)](K,10),55296),e[s(1630)](e.AtmOK(1023,K),56320)),p+=3))):b+=v}return b}function Le(a,n){let s=t,d={mQBiz:e.cEXpt},u=n[s(704)],g=0;for(let p=0;p<u;p++){let O=n[s(1254)+"At"](p);e.KcstR(O,55296)&&e[s(1012)](O,56319)&&e.QxkVj(e.NojOs(p,1),u)&&(O=e[s(859)](e[s(755)](O,10)+n.charCodeAt(++p),56613888)),g+=e[s(567)](O,128)?1:O<2048?2:e[s(742)](O,65536)?3:4}e[s(1602)](Z,a,g);let v=e[s(624)](F,a,g),b=a.bytes;for(let p=0;p<u;p++){let O=n.charCodeAt(p);O>=55296&&O<=56319&&e.dAthv(e[s(425)](p,1),u)&&(O=e[s(785)](e.CJPCL(O<<10,n.charCodeAt(++p)),56613888)),O<128?b[v++]=O:(e.Tyafp(O,2048)?b[v++]=e[s(1467)](e[s(1352)](O>>6,31),192):e[s(1138)](s(1577),e.UYnex)?(e[s(1472)](O,65536)?b[v++]=e[s(334)](O>>12&15,224):(b[v++]=e[s(419)](e[s(537)](O>>18,7),240),b[v++]=e[s(1467)](e[s(1360)](e[s(1629)](O,12),63),128)),b[v++]=e[s(1356)](e[s(1442)](e[s(1629)](O,6),63),128)):(this[s(1377)](d[s(639)],_0x34682c),this.onmessage&&this[s(580)+"e"](_0x2a9f85)),b[v++]=e[s(1369)](e[s(228)](63,O),128))}}function dt(a,n){let s=t,d=e[s(1134)](F,a,n.limit),u=a[s(560)],g=n[s(560)];for(let v=0,b=n[s(1193)];e[s(734)](v,b);v++)u[e[s(1207)](v,d)]=g[v]}function Ie(a){let n=t;return a[n(560)][e[n(635)](j,a,1)]}function Wt(a,n){let s=e.BwLle(F,a,1);a.bytes[s]=n}function we(a){let n=t,s=0,d=0,u;do u=Ie(a),e[n(430)](s,32)&&(d|=e[n(788)](127,u)<<s),s+=7;while(e[n(948)](128,u));return d}function Z(a,n){let s=t;if(e.LKgCX(e.ytSGA,e.nZlED)){let d=e[s(703)](e.hHZPu(e[s(334)](e[s(490)](e.agnqg(7,_0x173080)<<18,e.sHOJM(63&_0x1180ad[_0x33917c++],12)),e.aUQRD(e[s(1164)](63,_0x5ee2c2[_0x27e277++]),6)),63&_0x172370[_0x3afb01++]),65536);_0x3c0c48+=_0x16dd6e[s(767)+s(1447)](55296+(d>>10)),_0x311d25+=_0x3e8076["fromChar"+s(1447)](e[s(590)](56320,e.ydGEf(1023,d)))}else{for(n>>>=0;e[s(488)](n,128);)Wt(a,e[s(1352)](127,n)|128),n>>>=7;e[s(943)](Wt,a,n)}}function Fn(a,n){let s=t,d={FbsqQ:function(u,g,v,b,p){return e[$(912)](u,g,v,b,p)},wJjrI:function(u,g){return e[$(982)](u,g)}};if(e[s(596)](e[s(415)],e.wxDFs))_0x1354cc[s(1145)+s(225)](LmtVVS[s(875)],u=>{let g=s;DduqyZ[g(1026)](_0x1a5c2d,DduqyZ[g(378)](_0x5a06e5,_0x10baba.result),u[g(1310)+"on"],u[g(658)+"on"],_0x79eb9d(_0x3125dc[g(1550)+g(1021)]))});else{let u=0,g=0,v=0,b;return b=e[s(1304)](Ie,a),u=e[s(228)](127,b),128&b&&(b=e[s(723)](Ie,a),u|=e[s(1117)](e[s(434)](127,b),7),128&b&&(b=e.yiCUA(Ie,a),u|=e.sHOJM(e[s(788)](127,b),14),e.aLqHj(128,b)&&(b=Ie(a),u|=e[s(1137)](e[s(759)](127,b),21),e[s(1001)](128,b)&&(b=e.PTFCk(Ie,a),g=e[s(823)](127,b),e[s(638)](128,b)&&(b=e.hgCmb(Ie,a),g|=e[s(823)](127,b)<<7,e.afrvn(128,b)&&(b=e.WfswT(Ie,a),g|=(127&b)<<14,128&b&&(b=e.WfswT(Ie,a),g|=e[s(224)](e.FyyMu(127,b),21),128&b&&(b=e.BIRAy(Ie,a),v=e.WkEYv(127,b),128&b&&(b=e[s(723)](Ie,a),v|=e[s(224)](e[s(1164)](127,b),7)))))))))),{low:e[s(1209)](u,e[s(367)](g,28)),high:e[s(1358)](g>>>4,e.cRDgd(v,24)),unsigned:n}}}function pe(a,n){let s=t,d=e[s(229)](n.low,0),u=e[s(247)](e.FJQkP(n.low,28)|e[s(224)](n[s(1452)],4),0),g=n[s(1452)]>>>24,v=e[s(876)](0,g)?e[s(986)](0,u)?e.Tyafp(d,16384)?e[s(1472)](d,128)?1:2:e[s(728)](d,2097152)?3:4:e[s(1091)](u,16384)?e[s(838)](u,128)?5:6:e[s(719)](u,2097152)?7:8:e.nGsuu(g,128)?9:10,b=e[s(1039)](F,a,v),p=a[s(560)];switch(v){case 10:p[e[s(425)](b,9)]=e[s(1360)](e[s(229)](g,7),1);case 9:p[b+8]=e[s(1093)](9,v)?e[s(1209)](128,g):127&g;case 8:p[e[s(604)](b,7)]=e[s(1093)](8,v)?e[s(419)](e[s(1216)](u,21),128):u>>>21&127;case 7:p[e.uOWxw(b,6)]=e[s(370)](7,v)?e[s(995)](e[s(247)](u,14),128):e.jgKZe(u,14)&127;case 6:p[b+5]=e[s(1108)](6,v)?e[s(229)](u,7)|128:e.MlXvi(e[s(247)](u,7),127);case 5:p[e.NmFZP(b,4)]=e.PjcgN(5,v)?128|u:e[s(507)](127,u);case 4:p[e[s(628)](b,3)]=e[s(1108)](4,v)?e[s(1356)](e[s(725)](d,21),128):d>>>21&127;case 3:p[e[s(1166)](b,2)]=e[s(820)](3,v)?e[s(1358)](e[s(522)](d,14),128):e[s(803)](e[s(844)](d,14),127);case 2:p[b+1]=e[s(634)](2,v)?e[s(490)](e[s(229)](d,7),128):d>>>7&127;case 1:p[b]=e[s(1526)](1,v)?e[s(783)](128,d):127&d}}function Un(a){return e[t(981)](E,a)}function Ke(a){return e[t(238)](A,a)}let dd=65536,Zh=e[t(235)],Hn=dd*dd,ld=e[t(1548)](Hn,Hn),fd=e[t(1450)](ld,2),Kt=String[t(575)+"e"][t(1254)+"At"];class se{constructor(n,s,d){let u=t;this[u(412)]=!0,this[u(1412)]=e[u(419)](0,n),this[u(1452)]=e[u(1358)](0,s),this[u(1232)]=!!d}static isLong(n){let s=t;return n&&e[s(854)](!0,n[s(412)])}static[t(1154)](n,s,d){return new se(n,s,d)}static[t(878)+"s"](n,s,d){let u=t;return d?se[u(878)+"sLE"](n,s):se[u(878)+u(713)](n,s)}static[t(878)+t(1311)](n,s){let d=t;return new se(e.Uzgoj(e.LKSPS(n[0],e.ENGeg(n[1],8)),n[2]<<16)|e[d(1117)](n[3],24),e[d(1557)](e[d(419)](e[d(901)](n[4],e[d(1325)](n[5],8)),e[d(978)](n[6],16)),n[7]<<24),s)}static["fromByte"+t(713)](n,s){let d=t;return new se(e[d(1168)](e[d(1369)](e[d(526)](e[d(1117)](n[4],24),e[d(367)](n[5],16)),e[d(296)](n[6],8)),n[7]),e[d(526)](e.CnSGP(n[0]<<24,e[d(698)](n[1],16)),n[2]<<8)|n[3],s)}static[t(1547)](n){let s=t;return e[s(835)](n,Zh)?ud:new se(e[s(247)](e[s(1132)](e[s(1209)](e[s(869)](Kt[s(421)](n,0),Kt[s(421)](n,1)<<8),Kt[s(421)](n,2)<<16),e.TKmoP(Kt[s(421)](n,3),24)),0),e[s(844)](e[s(419)](Kt[s(421)](n,4)|e[s(1104)](Kt[s(421)](n,5),8)|e[s(978)](Kt[s(421)](n,6),16),Kt[s(421)](n,7)<<24),0),!0)}[t(1534)](){let n=t,s={UjIbi:e[n(1119)],fLbBx:e[n(266)],rHBzf:function(d){return d()}};if(e[n(608)](e[n(1413)],e[n(1413)])){let d={AXlfh:function(b,p){return b(p)},hgboU:n(1260)+"or",wGoBO:function(b){let p=n;return CqyqoW[p(1458)](b)}},u=()=>{let b=n;_0x28d61b[b(1044)+b(814)+b(1194)](CqyqoW[b(1361)],g),_0x2c4092[b(1044)+b(814)+b(1194)](CqyqoW[b(1128)],v),_0x22d0b5["removeEv"+b(814)+b(1194)](b(960),v)},g=()=>{_0xe4e434(),CqyqoW.rHBzf(u)},v=()=>{let b=n;d[b(1133)](_0x4a8c08,_0x2ed75e.error||new _0x24b6a8(d[b(1624)],b(1260)+"or")),d.wGoBO(u)};_0x531edf[n(1145)+"Listener"](CqyqoW[n(1361)],g),_0x5aa27b[n(1145)+n(225)](CqyqoW[n(1128)],v),_0x256060[n(1145)+"Listener"](n(960),v)}else return String["fromChar"+n(1447)](e[n(823)](255,this.low),e[n(996)](e[n(1216)](this[n(1412)],8),255),e[n(1259)](this[n(1412)]>>>16,255),e[n(522)](this[n(1412)],24),e[n(1516)](255,this[n(1452)]),e[n(1196)](e[n(306)](this.high,8),255),e[n(1442)](e[n(1101)](this[n(1452)],16),255),e[n(725)](this[n(1452)],24))}static[t(975)+"er"](n,s=!0){let d=t;if(isNaN(n))return s?Yh:ud;if(s){if(n>=ld)return Qh}else{if(e.YtLCl(n,-fd))return ex;if(e[d(1367)](n+1,fd))return Xh}return se[d(1154)](e[d(1176)](n%Hn,0),e[d(901)](e[d(935)](n,Hn),0),s)}toNumber(){let n=t;return this[n(1232)]?e[n(298)](e[n(522)](this[n(1452)],0),Hn)+e[n(725)](this[n(1412)],0):e[n(298)](this.high,Hn)+(this.low>>>0)}[t(333)](){let n=t;return e.tsTEe(0,this.high)&&e[n(255)](0,this[n(1412)])}add(n){let s=t;se[s(412)](n)||(n=se.fromNumber(n));let d=e[s(1127)](this[s(1452)],16),u=e[s(1300)](65535,this[s(1452)]),g=e[s(306)](this[s(1412)],16),v=e.inijZ(65535,this.low),b=e.Lulnj(n[s(1452)],16),p=e.VqNhi(65535,n[s(1452)]),O=e.jgKZe(n[s(1412)],16),N=e[s(416)](65535,n[s(1412)]),H=0,W=0,K=0,Ae=0;return Ae+=v+N,K+=e[s(1101)](Ae,16),Ae&=65535,K+=g+O,W+=e[s(1190)](K,16),K&=65535,W+=u+p,H+=e[s(974)](W,16),W&=65535,H+=d+b,H&=65535,se[s(1154)](e[s(1325)](K,16)|Ae,e[s(674)](e[s(324)](H,16),W),this[s(1232)])}[t(1484)](n){let s=t;return se[s(412)](n)||(n=se[s(975)+"er"](n)),e[s(596)](this[s(1232)],n.unsigned)&&e[s(1405)](this[s(1452)]>>>31,1)&&e.Heajw(n[s(1452)],31)===1?!1:e.BmBwh(this[s(1452)],n[s(1452)])&&this[s(1412)]===n.low}[t(988)](){let n=t,s={nzvYs:function(d,u){return d(u)},gwjkE:e[n(817)]};if(e[n(893)](e[n(761)],e[n(268)]))return e[n(1567)](-1,this[n(1412)])&&e.Ryxum(-1,this[n(1452)])?se.fromBits(0,0,this[n(1232)]):e[n(876)](-1,this[n(1412)])?se[n(1154)](0,e.hpYgw(this[n(1452)],1),this[n(1232)]):se[n(1154)](this[n(1412)]+1,this[n(1452)],this[n(1232)]);_0x50a003[n(843)+n(921)]=void 0,s[n(1152)](_0x4f826a,s[n(377)])}[t(1456)](n){return n?this.toBytesLE():this.toBytesBE()}[t(504)+"E"](){let n=t,s=this[n(1452)],d=this[n(1412)];return[e[n(305)](255,d),e[n(1170)](d,8)&255,e.GYyMo(e[n(620)](d,16),255),d>>>24,e[n(1251)](255,s),e[n(996)](e[n(1216)](s,8),255),e[n(416)](e.neBUD(s,16),255),e[n(1216)](s,24)]}[t(546)+"E"](){let n=t,s=this.high,d=this[n(1412)];return[e[n(725)](s,24),e.yczVc(e.Lulnj(s,16),255),e[n(846)](e[n(1267)](s,8),255),255&s,e[n(1482)](d,24),e[n(1107)](e.OXXUI(d,16),255),e[n(1264)](e.neBUD(d,8),255),e[n(811)](255,d)]}}let ud=new se(0,0,!1),Yh=new se(0,0,!0),Xh=se[t(1154)](-1,2147483647,!1),Qh=se[t(1154)](-1,-1,!0),ex=se[t(1154)](0,-2147483648,!1);var $t=(function(a){let n=t,s=e[n(452)][n(626)]("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[e[n(1033)]]=5002]="CONNECTI"+n(1364);continue;case"1":return a;case"2":a[a["MESSAGE_"+n(1620)]=5004]=e.vCTWP;continue;case"3":a[a[e[n(619)]]=5005]=e.TCcYV;continue;case"4":a[a[e[n(1608)]]=5001]=e[n(1608)];continue;case"5":a[a[e[n(1459)]]=5003]=e[n(1459)];continue}break}})({});class qn{constructor(n){let s=t;if(e[s(255)](e[s(429)],e[s(429)]))this[s(1072)]=n,this[s(953)]=null;else return this[s(327)]["clearSto"+s(732)]()}}class hd extends qn{constructor(n,s){let d=t;super(n),this.message=s&&s[d(1080)]||null}}class xd extends qn{constructor(n,s){let d=t;super(n),this[d(513)]=s&&s[d(513)]||null,this[d(1124)]=s&&s[d(1124)]||0,this[d(1257)]=s&&s[d(1257)]||"",this[d(766)]=s&&s[d(766)]||0,this.message=s&&s[d(1080)]||"",this[d(1144)]=s&&s[d(1144)]||5001}}class pd extends qn{constructor(n,s){let d=t;super(n),this[d(1144)]=s&&s[d(1144)]||0,this[d(1355)]=s&&s[d(1355)]||"",this[d(579)]=s&&s.wasClean||!1,this[d(511)+"nnect"]=s&&s[d(511)+d(1424)]||!1}}class gd extends qn{constructor(n,s){let d=t;super(n),this[d(1465)]=s&&s[d(1465)]||null}}class md extends gd{constructor(n,s){let d=t;super(n),this[d(1465)]=s&&s[d(1465)]||null,this[d(1080)]=s&&s[d(1080)]||null}}class wd extends qn{constructor(n,s){let d=t;super(n),this[d(1465)]=s&&s[d(1465)]||null}}function nt(a,{message:n,code:s,error:d}){return new xd(a,{message:n,code:s,error:d})}function lt(a,{code:n,reason:s,wasClean:d,willReconnect:u}){return new pd(a,{code:n,reason:s,wasClean:d,willReconnect:u})}function yd(a,{data:n,message:s}){return new md(a,{data:n,message:s})}function _d(a,{data:n}){return new wd(a,{data:n})}function Lo(a,{message:n}){return new hd(a,{message:n})}class Ed{constructor(n,s){let d=t;e[d(1558)](e[d(258)],e[d(1069)])?(_0x4004bf=_0x2fa9b1(_0x2831c6),_0x25bd47|=e[d(1554)](e[d(1215)](127,_0x2a2636),21),128&_0xbeadcb&&(_0x2b8e62=e[d(1304)](_0x4768ce,_0x1f2097),_0x245671=127&_0x1213ad,e.mvdUT(128,_0x37e735)&&(_0x43032d=e.fswOJ(_0x17ae80,_0x464938),_0x52034e|=e[d(599)](127,_0x35273d)<<7))):(this[d(692)+"s"]=n,this[d(1129)+"es"]=s,this[d(702)+"ndex"]=0,this["currentE"+d(302)+d(894)+"t"]=0)}[t(908)+"pointCon"+t(1495)](){let n=t;this.currentIndex=0,this["currentE"+n(302)+n(894)+"t"]=0}[t(866)+"es"](){let n=t;this[n(1559)+"ndpointT"+n(894)+"t"]=0}[t(423)+t(712)+"nt"](){let n=t;return this[n(692)+"s"][this[n(702)+n(253)]]}[t(423)+t(712)+"ntTriesCount"](){let n=t;if(e[n(735)](n(592),e[n(837)]))return this[n(1559)+n(302)+"riesCount"];_0x3048c8[n(1044)+n(814)+n(1194)](n(1531),_0x33d5b7),_0x38f181[n(1044)+n(814)+n(1194)](LmtVVS[n(266)],_0x223b43),_0x17a20b["removeEv"+n(814)+"ner"](LmtVVS[n(880)],_0x1d56c7)}[t(1256)+t(1384)+"es"](){let n=t;return!!(e.dyXnR(this[n(702)+n(253)],this.endpoints.length)||e[n(1138)](this[n(702)+"ndex"],this[n(692)+"s"][n(704)]-1)&&this[n(1559)+n(302)+"riesCount"]===this.maxRetries)}[t(1336)+t(1439)+t(1082)+"hedMaxRetries"](){let n=t;if(e[n(1195)]!==n(881))return e[n(825)](this[n(702)+n(253)],this[n(692)+"s"][n(704)])?!0:e[n(1431)](this[n(1559)+n(302)+n(894)+"t"],this.maxRetries);_0x38b8a4(this[n(1387)+"lTimeoutId"]),this["_interva"+n(879)+"Id"]=e[n(744)](_0x382cd6,()=>{this["flushExp"+n(572)]()},this._interval)}[t(549)+t(1401)+"pointAndUpdateCo"+t(1359)](){let n=t;return this[n(1559)+n(302)+n(894)+"t"]=1,this[n(702)+n(253)]++,this[n(692)+"s"][this[n(702)+n(253)]]}[t(423)+"ntEndpoi"+t(983)+t(898)](){let n=t;return this["currentEndpointT"+n(894)+"t"]++,this.getCurrentEndpoint()}}let Gn=(e[t(993)](e[t(745)],typeof globalThis)&&e[t(1271)](e[t(518)],globalThis[t(1519)+t(251)][t(1102)])||e[t(993)](e[t(745)],typeof window)&&e[t(1197)](e[t(518)],window[t(1519)+"tor"].name))&&e[t(1220)](e[t(745)],typeof document),mn=e.Qqhzz(e[t(745)],typeof globalThis)&&(e[t(335)](e.sVQQR,globalThis["construc"+t(251)][t(1102)])||e[t(486)](e[t(665)],globalThis[t(1519)+"tor"][t(1102)]))&&e.FIsmG(e[t(745)],typeof tt),Or=(e[t(730)](e.vtDIq,typeof globalThis)&&e[t(985)](e[t(1471)],globalThis[t(1519)+"tor"].name)||e[t(1097)]("undefined",typeof globalThis)||e[t(745)]!=typeof globalThis&&!!globalThis[t(1427)+t(934)])&&typeof wx<"u",Pr=e[t(1487)](t(890)+"d",typeof globalThis)&&(e.aOrxP(e[t(665)],globalThis[t(1519)+t(251)][t(1102)])||e[t(486)](e[t(261)],globalThis[t(1519)+t(251)][t(1102)])||e[t(794)](e[t(623)],globalThis["construc"+t(251)][t(1102)]))&&e[t(730)]("undefined",typeof self),tx=e[t(1219)](e[t(745)],typeof globalThis)&&e[t(1223)](e[t(1471)],globalThis["construc"+t(251)][t(1102)])&&e.MbYVz(e[t(745)],typeof global)&&e[t(1235)](e[t(1471)],global[t(1519)+t(251)][t(1102)])&&e[t(1018)](e[t(745)],typeof process)&&!!process[t(582)];class No{constructor(){let n=t;this[n(290)+"rs"]={}}[t(1377)](n,...s){let d=t,u=this._listeners[n];if(u)u[d(1140)]()[d(1466)](g=>g.fn.apply(g[d(848)],s));else if(d(513)===n&&!this[d(812)])if(e[d(1556)]==="hEwYI"){let g=s.length&&s[0];if(e[d(802)](g,Error))throw g;let v=new Error(e[d(1029)](e[d(1408)],g?e.FstBV(e[d(1268)](" (",g.message),")"):""));throw v[d(1564)]=g,g}else{let g=this._listeners[_0x3e1d48];if(g)g[d(1140)]()[d(1466)](v=>v.fn[d(877)](v[d(848)],_0x2f61a1));else if(e[d(535)](d(513),_0x26e05c)&&!this[d(812)]){let v=_0x5b8920[d(704)]&&_0xd902e0[0];if(v instanceof _0x418ad4)throw v;let b=new _0x33062d(e[d(688)](e.LfMmN,v?e[d(466)](e[d(1207)](" (",v[d(1080)]),")"):""));throw b[d(1564)]=v,v}return this}return this}[t(731)](n,s){let d=t;if(e[d(1276)](void 0,n))this[d(290)+"rs"]={};else if(e[d(633)](void 0,s))this[d(290)+"rs"][n]=null;else{let u=this._listeners[n];if(u)for(let g=0;g<u[d(704)];)e[d(1464)](u[g].fn,s)?u[d(1563)](g,1):++g}return this}on(n,s,d){let u=t;return(this[u(290)+"rs"][n]||(this[u(290)+"rs"][n]=[]))[u(489)]({fn:s,ctx:d||this}),this}}class nx extends No{[t(961)+t(236)+t(653)](n){let s=t;return n[s(1603)]||n[s(1328)]?("message: "+(n.errMsg||"")+" code: "+(n[s(1328)]||"")).trim():JSON[s(1333)+"y"](n)}constructor(n,s,d){let u=t;super(),this[u(1077)]=null,Or&&wx[u(1274)+"ocket"]&&(this[u(1077)]=wx["connectS"+u(1544)]({url:n,protocols:s,header:d,fail:this[u(232)+u(1211)+u(1420)][u(874)](this),success:this[u(232)+u(360)+u(1326)+"ler"][u(874)](this)})),mn&&tt[u(1274)+u(1544)]&&(this[u(1077)]=tt[u(1274)+u(1544)]({url:n,protocols:s,header:d,fail:this[u(232)+u(1211)+u(1420)][u(874)](this),success:this[u(232)+u(360)+u(1326)+u(853)][u(874)](this)}))}["_createS"+t(360)+"cessHand"+t(853)](){let n=t;Promise.resolve()[n(625)](()=>{let s=n;this[s(691)+s(1429)]()})}[t(232)+"ocketFailHandler"](n){let s=t;if(e[s(1338)]===e[s(793)]){let d=this[s(327)]["getStora"+s(550)+"nc"](this[s(411)]),u=_0x209389[s(1411)](e[s(542)](d,"{}"));return _0x368b52[s(1242)](u)}else Promise[s(1455)]()[s(625)](()=>{let d=s,u={OqvOV:function(g,v){return g==v},EUZLR:e.iFlND,VAOLg:function(g,v){return g(v)},rzmrX:function(g,v,b,p){return e[$(362)](g,v,b,p)},zUxUk:function(g,v){return g instanceof v}};if(e[d(794)](d(850),e[d(543)])){if(u[d(386)](u.EUZLR,typeof _0x4046e7)){let g=new _0x5737bb(u[d(1286)](_0x3e6e63,_0x141323));return u[d(569)](_0x1d9dcf,_0x7dcf95,g,0),g}return u[d(502)](_0x6fe102,_0x291beb)?new _0x89e414(_0x1457bc):new _0x562ea9(_0xff5b4[d(1421)],_0x3c212e[d(1059)+"et"],_0x52a9a7[d(668)+"th"])}else{let g=e[d(789)](nt,d(513),{message:this[d(961)+d(236)+d(653)](n)});this[d(1377)](e[d(266)],g);let v=lt(e[d(1486)],{reason:this[d(961)+d(236)+d(653)](n)});this.emit(e[d(1486)],v)}})}[t(691)+t(1429)](){let n=t,s={csyOC:function(d,u){return e[$(304)](d,u)},PyRFM:e[n(911)],AFHnb:e.cEXpt,zJINj:function(d,u,g){return d(u,g)}};this[n(1077)][n(467)](d=>{let u=n;this[u(1377)](e[u(1141)],e[u(965)](_d,e.Hqtpu,{...d,data:d[u(1603)]||""}))}),this[n(1077)][n(1390)](d=>{let u=n;this[u(1377)](e.syDAY,e[u(342)](lt,e[u(1486)],{...d}))}),this[n(1077)][n(873)+"e"](d=>{let u=n;s[u(1202)](s.PyRFM,s[u(1451)])?this[u(1377)](s.AFHnb,s[u(1278)](yd,"message",{...d})):this[u(731)](_0x21edc2,_0x117a33)}),this._socket.onError(d=>{let u=n;this[u(1377)](e[u(266)],nt(e[u(266)],{...d,message:d.errMsg||""}))})}send(n){let s=t,d={nWXwM:function(u,g){return e.pAgQp(u,g)},asZfZ:function(u,g){return u+g},hyICK:s(513)};if(e[s(802)](n,Uint8Array)){if(e[s(834)]===e[s(431)])return ywefqJ[s(1015)](-1,this.low)&&this[s(1452)]===-1?_0x31de73[s(1154)](0,0,this.unsigned):this[s(1412)]===-1?_0x81b642[s(1154)](0,this[s(1452)]+1,this[s(1232)]):_0x34735c[s(1154)](ywefqJ[s(265)](this[s(1412)],1),this.high,this[s(1232)]);{let u=n[s(1421)][s(1140)](n.byteOffset,e[s(1630)](n[s(668)+"th"],n.byteOffset));this[s(1077)]&&this[s(1077)][s(1505)]({data:u,fail:g=>{let v=s;this[v(1377)]("error",e[v(656)](nt,e[v(266)],{message:this[v(961)+v(236)+v(653)](g)}))}})}}else this[s(1077)]&&this[s(1077)][s(1505)]({data:n,fail:u=>{let g=s;e.ZQOzx!==e[g(963)]?(_0xc1ed9c[g(1044)+"entListener"](g(613),_0x1b68b1),_0x20f3a7[g(1044)+"entListe"+g(1194)](ywefqJ.hyICK,_0xfb21d0)):this[g(1377)](e[g(266)],e[g(1602)](nt,e[g(266)],{message:this[g(961)+"rrorMess"+g(653)](u)}))}})}close(n,s){let d=t;if(d(630)!=="cnkhJ")this._socket&&this[d(1077)].close({code:n,reason:s});else try{return!!this[d(327)]}catch(u){return _0xf358b3[d(292)](u),!1}}["addEvent"+t(225)](n,s){this.on(n,s)}["removeEv"+t(814)+"ner"](n,s){this[t(731)](n,s)}get[t(283)+"te"](){let n=t;return this[n(1077)][n(283)+"te"]}get[t(512)+"pe"](){let n=t;return this[n(1077)][n(512)+"pe"]}set[t(512)+"pe"](n){}get[t(867)](){let n=t;return this._socket[n(867)]}get[t(813)](){let n=t;return this[n(1077)][n(813)]}get[t(456)+"ns"](){let n=t;return this[n(1077)][n(456)+"ns"]}get[t(1131)+t(1323)](){let n=t;return e[n(585)](e.ttIjY,e[n(463)])?new _0x448974(_0x2c0b03,_0x52c156,_0x40070b):0}}function rx(a,n){let s=t;if(n)return new n(a.url,a[s(813)]);if(e[s(542)](Or,mn))return new nx(a[s(867)],a.protocol,a[s(508)]);if(e[s(833)](Gn,Pr)&&e[s(993)](s(890)+"d",typeof WebSocket)&&WebSocket)return new WebSocket(a[s(867)],a.protocols)}function ix(a){let n=t,s=(n(872)+"3")[n(626)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(a)return!0;continue;case"1":if(mn&&tt[n(1274)+n(1544)])return!0;continue;case"2":if(e[n(542)](Gn,Pr)&&e.KJFir(e[n(745)],typeof WebSocket)&&WebSocket)return!0;continue;case"3":return!1;case"4":if(Or&&wx[n(1274)+n(1544)])return!0;continue}break}}function bd(a,n,s){let d=t,u={tqSsc:function(b,p){return e[$(1558)](b,p)},FVmWO:function(b,p){return b+p}},g=-1;async function v(b){let p=$;return b<=g?Promise[p(1449)](new Error(p(1275)+p(1552)+"ltiple t"+p(432)+p(1244))):(g=b,u[p(276)](b,s[p(704)])?Promise[p(1455)]():s[b][p(874)](a)(n,v[p(874)](null,u.FVmWO(b,1))))}e[d(238)](v,0)}function vd(a){let n=t,s=0,d=0;for(let u=0;e.bWcHF(u,a.length);++u)d=a[n(1254)+"At"](u),e[n(1371)](d,128)?s+=1:e[n(827)](d,2048)?s+=2:e[n(1567)](e.WSaTF(64512,d),55296)&&e.ZGgOi(e.AHRTF(64512,a[n(1254)+"At"](e[n(1126)](u,1))),56320)?(++u,s+=4):s+=3;return s}function Sd(a,n,s){let d=t;if(e.yYDqx(s-n,1))return"";let u="";for(let g=n;e[d(588)](g,s);){let v=a[g++];if(e[d(586)](v,127))u+=String[d(767)+d(1447)](v);else if(v>=192&&e[d(1368)](v,224))u+=String[d(767)+d(1447)](e[d(1527)](e[d(293)](e[d(1024)](31,v),6),e.tKwxs(63,a[g++])));else if(e[d(790)](v,224)&&e.FeCGy(v,240))u+=String[d(767)+d(1447)](e.YGLXR(e[d(1137)](15&v,12),e.nuJHb(e[d(1199)](63,a[g++]),6))|e[d(507)](63,a[g++]));else if(e[d(1346)](v,240)){let b=e[d(1212)](e.YGLXR(e[d(1086)](e.CrnWw(7,v),18)|e[d(296)](e[d(1251)](63,a[g++]),12),e[d(666)](e.tGyYo(63,a[g++]),6))|e[d(1043)](63,a[g++]),65536);u+=String[d(767)+d(1447)](e[d(1513)](55296,e[d(568)](b,10))),u+=String["fromChar"+d(1447)](e.KwLsQ(56320,e[d(1056)](1023,b)))}}return u}function Mo(a,n,s){let d=t,u=s,g,v;for(let b=0;b<a[d(704)];++b)if(g=a[d(1254)+"At"](b),e[d(1368)](g,128))n[s++]=g;else if(e[d(734)](g,2048))n[s++]=e[d(240)](e.UoPeq(g,6),192),n[s++]=e[d(729)](63&g,128);else if(e[d(1418)](e.FyyMu(64512,g),55296)&&e[d(1516)](64512,v=a[d(1254)+"At"](b+1))===56320)if(e[d(322)](e[d(1530)],e[d(1530)])){let p=e[d(1201)].split("|"),O=0;for(;;){switch(p[O++]){case"0":g=e[d(992)](65536,e[d(574)](1023&g,10))+(1023&v);continue;case"1":++b;continue;case"2":n[s++]=e[d(332)](e.NnkoJ(63,g),128);continue;case"3":n[s++]=e[d(629)](e[d(1024)](e.UoPeq(g,6),63),128);continue;case"4":n[s++]=e[d(409)](e[d(568)](g,18),240);continue;case"5":n[s++]=e[d(591)](e.CrnWw(g>>12,63),128);continue}break}}else{e[d(970)](_0x265940,_0x57e04f,42);let p=e[d(860)](_0x5cffb8);e[d(709)](_0x891723,_0x4482ad,p),_0x13b644(_0x40beee,p[d(1193)]),e[d(791)](_0x2063a4,_0x2c30ff,p),_0x211ce5(p)}else n[s++]=e[d(1506)](e[d(568)](g,12),224),n[s++]=e.dQtgT(e[d(891)](e[d(1607)](g,6),63),128),n[s++]=e.hHZPu(e[d(1228)](63,g),128);return s-u}async function Id(a){let n=t;if(e[n(1567)](e[n(428)],e[n(602)]))return _0x3a9444?.find(s=>s.key===_0x8eddb3)?.[n(1580)];if(e[n(825)](e.iFlND,typeof a)){let s=new Uint8Array(e[n(1438)](vd,a));return e[n(362)](Mo,a,s,0),s}return e.vHRFx(a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1421)],a[n(1059)+"et"],a[n(668)+"th"])}function sx(a){let n=t,s={EcYyP:function(d,u){return e[$(1092)](d,u)}};try{if(e.TGTao(e[n(331)],e[n(1229)]))return e.iFlND!=typeof a&&(e.zAzkg(a,ArrayBuffer)||a[n(1421)]&&e[n(1612)](a[n(1421)],ArrayBuffer))||e[n(652)]!=typeof a?"":(JSON[n(1411)](a),e[n(566)]);if(xckwgg.EcYyP(4,_0x1486bc[n(704)])){let d=_0x3347ae[n(551)+"g"](0,4-_0x4d19d9[n(704)]),u=d[n(1263)](_0x49756f);_0x553c59[n(489)](u)}else _0x5e5a61[n(489)](_0x4039ab);_0xf77062&&(_0x153114+=1),_0x5bd909+=1,_0x32a595=!1}catch{return e[n(825)](n(1248),typeof a)?e.OfbYj:""}}let ox=(a,n)=>{let s=t;switch(a){case e[s(1285)]:case e[s(249)]:return{[s(444)+a]:1,"x-tt-env":n};default:return{}}};class ax{constructor(n){let s=t;this[s(399)+s(474)]=n,this.count=0}[t(1148)](){let n=t;this[n(1402)]++}[t(1256)+t(483)+"nt"](){let n=t;return this[n(1402)]>=this[n(399)+n(474)]}[t(829)+t(1538)](n=0){let s=t;this[s(399)+s(474)]=n,this.count=0}}async function cx(a){let n=t,s={CuSGL:function(d,u){return e.uQbrd(d,u)},MAgnp:function(d,u){return e.ztUtc(d,u)},bXLus:function(d,u){return e[$(777)](d,u)}};if(e[n(1120)](e.JjbiT,e[n(1302)]))return new Promise(d=>{let u=n,g={zRWDq:e.wRgeM};if(!Gn)return e[u(627)](d,e[u(817)]);try{if(e.mGIxi(u(1470),e.ABOmL))_0x1abfea=_0x57d253(_0x2656b8),_0x2b8032=0;else{let v=document["createEl"+u(1609)](e[u(1136)]);window[u(843)+"JSONP"]=b=>{let p=u;document[p(1273)][p(1511)+p(519)](v),window["frontier"+p(921)]=void 0,d(b&&b[p(1406)]||g[p(402)])},v[u(1072)]=e[u(286)],v[u(669)]=a[u(936)](/^ws/,e[u(469)])+e[u(558)];try{document[u(1273)][u(1312)+u(519)](v)}catch{document[u(1273)]["removeCh"+u(519)](v)}}}catch{window[u(843)+u(921)]=void 0,d(e[u(817)])}});{if(ORrdjW[n(1042)](_0x3e7792,_0x299bee))return _0x273572(_0xbe8a89);if(_0x347ee1[n(548)](_0x279934))return _0x3a0997[n(1151)](_0x49a572);let d=ORrdjW.MAgnp(_0x12d95f,_0x151cd6);return ORrdjW.bXLus(d,_0x1e30dc)&&(_0x61d387[n(1396)](_0x2f8ae0,d),_0x9c58a1[n(1396)](d,_0x5b0acd)),d}}function Vt(a,n,s){let d=t;return!!a?.[d(1329)](u=>u[d(1473)]===n&&u[d(1580)]===s)}function jn(a,n){let s=t;return a?.find(d=>d[s(1473)]===n)?.[s(1580)]}let Bo=null;async function dx(){let a=t;return Bo||(Bo=Promise[a(1455)]().then(Rt[a(874)](Rt,e[a(1376)]))),Bo}class lx extends No{constructor(n,s){let d=t;super(),this[d(931)]=n,this._keyPath=s,this._qosDB=void 0,this[d(1289)+d(1345)]=null}async[t(1022)](){await this[t(1478)]()}async _init(){let n=t,s={zZpGm:function(d,u){return e.cfKTV(d,u)},JUfvK:function(d,u){return e.RcJcs(d,u)},groIE:function(d,u){return d>>>u},iurdW:function(d,u){return e.UHqRZ(d,u)}};if(!this._qosDB){if(this[n(1289)+n(1345)])return this["_initPro"+n(1345)];try{let d=this[n(931)],u=this[n(487)];this._initPromise=(async()=>{let g=n;if(e.BmBwh(e[g(664)],e[g(882)])){let v=this[g(1452)],b=this[g(1412)];return[kPQQuA[g(451)](255,b),kPQQuA[g(451)](kPQQuA[g(1475)](b,8),255),b>>>16&255,kPQQuA[g(1008)](b,24),kPQQuA.zZpGm(255,v),kPQQuA[g(451)](v>>>8,255),kPQQuA[g(1160)](kPQQuA.groIE(v,16),255),kPQQuA[g(1008)](v,24)]}else{let{openDB:v}=await dx();this._qosDB=await e[g(1541)](v,g(843)+"_"+d,1,{upgrade(b){b["createOb"+g(864)+"e"](d,{keyPath:u})}})}})(),await this[n(1289)+n(1345)]}catch(d){console.log(d)}finally{this[n(1289)+n(1345)]=null}}}async[t(1151)](n){let s=t;try{return await this[s(1478)](),this[s(327)]?.get(this[s(931)],n)}catch(d){console[s(292)](d)}}async set(n,s){let d=t;return await this._init(),this[d(327)]?.[d(1125)](this[d(931)],n)}async[t(1237)](n){let s=t;if(e[s(304)](e[s(980)],"cDAAa"))try{return await this[s(1478)](),this[s(327)]?.[s(929)](this[s(931)],n)}catch(d){console[s(292)](d)}else return LmtVVS[s(535)](typeof _0x1923b1,s(295))?LmtVVS.PTFCk(_0x14d78a,_0x551afa):(LmtVVS[s(552)](_0x411007,_0x3a97ae)&&LmtVVS[s(627)](_0xd22e81,_0x298495),LmtVVS[s(965)](_0x4affc9,_0x432e25,LmtVVS.GmNlp(_0x399088))?new _0x3f84ff(_0xd39a4f,_0x4c6f7c):_0x2c97af)}async clear(){let n=t;try{return await this._init(),this._qosDB?.[n(1288)](this[n(931)])}catch(s){console[n(292)](s)}}async[t(263)](){let n=t;return await this[n(1478)](),this[n(327)]?.[n(710)+"ys"](this[n(931)])}async[t(899)](){let n=t;return e[n(1277)]!==e[n(1403)]?(await this[n(1478)](),this._qosDB?.[n(899)](this._dbName)):_0x275d64["objectSt"+n(1354)][1]?void 0:_0x74e1d.objectStore(_0x2b68a8["objectSt"+n(1354)][0])}async[t(695)](){let n=t,s={PeUeI:function(d,u){return e[$(1414)](d,u)},rxJMw:function(d,u){return d&u},YCRoG:function(d,u){return e[$(1562)](d,u)},uTmcS:function(d,u){return e[$(1304)](d,u)},nGgTW:function(d,u){return d<<u}};try{this[n(327)]?.[n(1305)](),this._qosDB=void 0}catch(d){e.xjSSq(e.QZSfx,e.HgPkX)?(_0x4be9c6=wOLWBn[n(1468)](_0xa3a2d,_0xab244f),_0x36c036=wOLWBn[n(1546)](127,_0x2ec79a),wOLWBn[n(910)](128,_0x132d98)&&(_0x102ebb=wOLWBn.uTmcS(_0x457390,_0x533130),_0x4c6d9d|=wOLWBn[n(234)](wOLWBn[n(910)](127,_0x1c3c93),7))):console[n(292)](d)}}get isReady(){let n=t;try{return!!this[n(327)]}catch(s){return console[n(292)](s),!1}}}class fx{constructor(n,s){let d=t;d(1611)===e[d(391)]?(this[d(1493)+"er"]&&_0x430f3a[d(1044)+"entListe"+d(1194)](e[d(1569)],this[d(1590)+"nLine"]),this[d(1493)+"er"]&&_0x3a8382[d(1044)+"entListe"+d(1194)](e[d(380)],this[d(1590)+d(1423)]),this[d(1493)+"er"]&&_0x3fa447[d(1044)+"entListe"+d(1194)](e[d(241)],this["_handleP"+d(1572)]),this[d(1493)+"er"]&&_0x304695[d(1044)+d(814)+d(1194)](e[d(1075)],this[d(830)+d(1172)])):(this._DBName=n,this[d(726)]=s,this._qosDB=localStorage)}async[t(1022)](){}get _prefix(){let n=t;return n(843)+"_"+this[n(795)]}async[t(1151)](n){let s=t,d=this[s(327)][s(1342)](this[s(411)]);return JSON.parse(e.EXYAO(d,"{}"))[n]}async[t(1396)](n,s){let d=t,u=this._qosDB.getItem(this[d(411)]),g=JSON[d(1411)](e[d(780)](u,"{}"));return g[s||n[this[d(726)]]]=n,this[d(327)][d(642)](this[d(411)],JSON[d(1333)+"y"](g)),s||n[this._pathKey]}async[t(1237)](n){let s=t,d=this._qosDB[s(1342)](this[s(411)]),u=JSON[s(1411)](d||"{}");return u[n]=void 0,this[s(327)][s(642)](this[s(411)],JSON.stringify(u))}async[t(1288)](){let n=t;return this._qosDB[n(1288)]()}async[t(263)](){let n=t,s=this[n(327)][n(1342)](this[n(411)]),d=JSON[n(1411)](s||"{}");return Object[n(263)](d)}async[t(899)](){let n=t,s=this[n(327)][n(1342)](this[n(411)]),d=JSON.parse(e.HAfRp(s,"{}"));return Object[n(1242)](d)}[t(695)](){return Promise[t(1455)]()}get isReady(){return!!this[t(327)]}}class ux{constructor(n,s){let d=t;this._DBName=n,this[d(726)]=s,this[d(327)]=mn?tt:Or?wx:null}async[t(1022)](){}get _prefix(){return t(843)+"_"+this._DBName}async[t(1151)](n){let s=t,d=this._qosDB[s(683)+s(849)](this[s(411)]);return JSON[s(1411)](e[s(542)](d,"{}"))[n]}async set(n,s){let d=t,u=this[d(327)].getStorageSync(this[d(411)]),g=JSON[d(1411)](e[d(780)](u,"{}"));return g[s||n[this[d(726)]]]=n,this[d(327)][d(485)+"geSync"](this[d(411)],JSON[d(1333)+"y"](g)),s||n[this._pathKey]}async[t(1237)](n){let s=t,d=this._qosDB[s(683)+s(849)](this[s(411)]),u=JSON.parse(e.yUiLi(d,"{}"));return u[n]=void 0,this[s(327)][s(485)+s(849)](this[s(411)],JSON.stringify(u))}async[t(1288)](){let n=t;return this[n(327)][n(1327)+n(732)]()}async keys(){let n=t,s=this._qosDB[n(683)+n(550)+"nc"](this[n(411)]),d=JSON[n(1411)](e[n(1234)](s,"{}"));return Object[n(263)](d)}async[t(899)](){let n=t,s=this[n(327)][n(683)+"geInfoSync"](this[n(411)]),d=JSON[n(1411)](e.bsjqm(s,"{}"));return Object.values(d)}[t(695)](){return Promise[t(1455)]()}get isReady(){return!!this._qosDB}}function Ad(a,n){let s=t;if(e[s(876)](e.kZgdT,s(1106))){let d=_0xdc51d4[s(704)]&&_0x5c13f4[0];if(e.rpvRR(d,_0x3c0b9d))throw d;let u=new _0x156790(e.sZXxI(e[s(1408)],d?e[s(1268)](e[s(945)](" (",d[s(1080)]),")"):""));throw u[s(1564)]=d,d}else{if(e[s(243)](mn,mn))return new ux(a,n);if(e[s(417)](Gn,Pr)&&e[s(993)](e.vtDIq,typeof indexedDB))return new lx(a,n);if((Gn||Pr)&&e.Qqhzz(e[s(745)],typeof localStorage))return new fx(a,n);throw new Error(e[s(1584)])}}class hx{constructor(){let n=t;this[n(1387)+"lTimeoutId"]=null,this[n(1387)+"l"]=36e5,this._qosDB=e[n(1395)](Ad,e[n(503)],e[n(498)])}async["_interva"+t(1341)](){let n=t;e[n(1512)](clearInterval,this[n(1387)+n(879)+"Id"]),this["_interva"+n(879)+"Id"]=setInterval(()=>{let s=n;this[s(1600)+s(572)]()},this[n(1387)+"l"])}async[t(1022)](){let n=t;await this[n(327)].openDB()[n(625)](()=>{this[n(1387)+"lFlush"]()})}async[t(1600)+t(572)](){let n=t;(await this[n(327)]?.getAll()||[])[n(598)](({timestamp:u})=>u<Date[n(1222)]())[n(1466)](u=>{this[n(327)]?.del(u.message_id)})}async[t(1237)](n){let s=t;return this[s(327)]?.[s(1237)](n)}async set(n,s){let d=t;return e.SUmLS(d(840),e[d(1187)])?(_0x14be04[d(1239)+"t8"]?_0x40753d[d(1239)+"t8"](_0x1a6d25,_0x14eecc):_0x228247[_0x41701f]=e.tDgWp(255,_0x36996b),e[d(466)](_0x3dc3e5,1)):this[d(327)]?.[d(1396)]({message_id:n,timestamp:s})}async[t(1151)](n){return this[t(327)]?.get(n)}async[t(695)](){let n=t;e[n(982)](clearInterval,this[n(1387)+n(879)+"Id"]),await this[n(327)]?.[n(695)]()}get[t(1357)](){return this[t(327)]?.isReady}}function zo(a){let n=t;if(e[n(322)](e[n(606)],e[n(606)])){let s=!!this[n(308)].enableQoS;if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(885)](Vt,a[n(1080)][n(508)],e[n(689)],"2"),u=d&&e.lTpzm(Vt,a.message[n(508)],e[n(938)],"1"),g=d&&e[n(447)](Vt,a[n(1080)][n(508)],e[n(1543)],"1"),v=g?e.zjXIH(jn,a[n(1080)][n(508)],e[n(482)])?.[n(626)](",")[n(598)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:g,ackMsgIds:v}}else this[n(691)+n(1429)]()}async function Td(){let a=t;return this[a(1150)+a(999)]||(this[a(1150)+a(999)]=new hx),this[a(1150)+a(999)][a(1357)]||await this["_QoSMana"+a(999)].openDB(),this["_QoSMana"+a(999)]}async function xx(a,n){let s=t,{enableAutoAck:d}=this[s(308)],u=e[s(1109)](Vt,a[s(1080)].headers,e[s(667)],"1"),g=e[s(1570)](Vt,a[s(1080)][s(508)],e[s(947)],"1"),v=zo[s(421)](this,a);if(e[s(477)](d,u)){let{SeqID:b,LogID:p,service:O,LogIDNew:N,method:H}=a[s(1080)];this._sendAck({SeqID:b,LogID:p,LogIDNew:N,service:O,method:H,headers:[{key:s(800),value:"1"},{key:e[s(1206)],value:e[s(611)](N,"")},{key:e[s(690)],value:"0"}]})}g&&!v.isQoSAck&&this[s(807)+s(1586)+s(278)](a),e.CYeHh(n)}async function px(a,n){let s=t;this._debug("received",a[s(1080)]),n()}async function gx(a,n){let s=t,d=e[s(532)](Un,await Id(a[s(1465)]));try{if(d.payload instanceof Uint8Array){let u=e[s(453)](this[s(308)][s(525)+s(226)],Object)?{force:!!this._options[s(525)+s(226)][s(313)],encoding:this[s(308)][s(525)+s(226)].encoding?this[s(308)]["payloadE"+s(226)][s(1379)][s(936)](/\s/g,"")[s(781)+"ase"]():""}:{force:!1,encoding:this[s(308)]["payloadE"+s(226)]?this._options[s(525)+s(226)].replace(/\s/g,"")[s(781)+s(455)]():""},g=d[s(525)+s(226)]?d[s(525)+"ncoding"].replace(/\s/g,"")[s(781)+s(455)]():"",v=e.JNwGS(this[s(308)][s(1428)+s(318)],Object)?{force:!!this[s(308)][s(1428)+"ype"][s(313)],type:this[s(308)][s(1428)+s(318)][s(1072)]?this[s(308)][s(1428)+s(318)][s(1072)].replace(/\s/g,"")[s(781)+s(455)]():""}:{force:!1,type:this[s(308)].payloadType?this[s(308)][s(1428)+"ype"][s(936)](/\s/g,"")[s(781)+"ase"]():""},b=d[s(1428)+"ype"]?d["payloadT"+s(318)][s(936)](/\s/g,"")[s(781)+s(455)]():"",p=v.force?v[s(1072)]:b||v[s(1072)],O=u[s(313)]?u[s(1379)]:g||u[s(1379)],N=[s(1394)+s(1508)+s(1523),s(1200)+s(1307),e[s(1089)],e[s(652)]],H=[e[s(351)],e[s(1252)]];this[s(308)][s(301)+s(871)+"extPayload"]&&N.includes(p)&&(!O||H[s(662)](O))?d[s(413)+s(1454)]=Sd(d.payload,0,d.payload[s(668)+"th"]):d["textPayl"+s(1454)]=""}else d[s(413)+"oad"]=""}catch(u){d[s(413)+s(1454)]="",console.log(u)}a[s(1080)]=d,n()}function mx(a,n,s){let d=t,u={yllqb:function(g,v){return g(v)},LesVr:function(g,v){return g(v)},NmhxJ:function(g,v){return g(v)},LVAVV:function(g){return e[$(321)](g)},WweLM:function(g,v){return e[$(255)](g,v)},sJaIs:e[d(1036)],woxrF:function(g,v){return e[d(1431)](g,v)},PBaMr:function(g,v){return e[d(294)](g,v)}};if(e.SUmLS(e[d(346)],e[d(315)])){let g={IenUF:LmtVVS.iGIhe,UiIXJ:LmtVVS.tXteP},v=()=>{let O=d;_0xe7d8cf[O(1044)+O(814)+O(1194)](g.IenUF,b),_0x101bb1[O(1044)+"entListener"](g[O(1391)],p)},b=()=>{let O=d;rgqOmB.yllqb(_0x11b9cd,rgqOmB[O(439)](_0x507287,_0x4e4bfb[O(581)])),v()},p=()=>{let O=d;rgqOmB[O(1065)](_0x56d96f,_0x556c99[O(513)]),rgqOmB[O(365)](v)};_0x33fb2c[d(1145)+d(225)]("success",b),_0x556631[d(1145)+"Listener"](LmtVVS[d(266)],p)}else{let g=e.HMYWl(s,8192),v=e[d(974)](g,1),b=null,p=g;return function(O){let N=d;if(u[N(1565)](u.sJaIs,"swmAv"))return this[N(1077)][N(283)+"te"];{if(O<1||u[N(1181)](O,v))return a(O);u[N(1181)](p+O,g)&&(b=u[N(699)](a,g),p=0);let H=n.call(b,p,p+=O);return 7&p&&(p=u.PBaMr(7|p,1)),H}}}}let yx=4294967295;function _x(a,n,s){let d=t;return RangeError(e[d(395)](e[d(1149)](e[d(1492)](e[d(645)](e[d(1067)],a),e[d(1081)])+e[d(243)](n,1),e[d(1347)]),s))}function Ex(a,n,s){let d=t;if(e[d(1375)](e[d(1290)],e.yQhOQ))return!0;{if(e[d(607)](s,yx))throw new Error(e[d(1295)]);let u=3;for(;e[d(790)](u,0);)if(e.RpUmX(d(438),e[d(1540)])){let g=e[d(320)](255,s);e[d(403)](Uo,g,a,n+u),s>>>=8,u--}else return new _0x193e96(_0x3e62e4,{data:_0xf0a3b7});return n+4}}function bx(a,n){let s=t;if(e[s(643)](s(1238),e[s(329)])){let d=0,u=n,g=e[s(645)](n,4);for(;e[s(933)](u,g);)if(e[s(854)](e[s(1198)],e[s(1198)])){let{value:v,offset:b}=Fo(a,u);u=b,d=e.RcJcs(e.FvOay(d,8),0),d+=v}else return _0xb9d810+=_0x108405&&_0x573ea7.byteLength||0,_0x42d1e3;return{value:d,offset:g}}else _0x138749(_0x26214,this[s(1204)+s(1156)+"e"](_0x5cef36))}function vx(a,n,s){let d=t,u=e[d(1613)][d(626)]("|"),g=0;for(;;){switch(u[g++]){case"0":return e[d(1010)](Mo(a,n,s),s);case"1":if(!a)return s;continue;case"2":if(n[d(405)])return e[d(1441)](n[d(405)](a,s),s);continue;case"3":if(e[d(1051)](a[d(704)],40))return Mo(a,n,s)+s;continue;case"4":if(n[d(751)+"e"])return e.iRNmV(n.utf8Write(a,s),s);continue}break}}function Sx(a,n){let s=t,d=new se(e[s(1356)](e[s(869)](e.foRWq(e.qarEz(a[e[s(959)](n,4)],24),a[e[s(1268)](n,5)]<<16),a[n+6]<<8),a[e[s(1166)](n,7)]),e[s(808)](e[s(1344)](e.aUQRD(a[e[s(338)](n,0)],24),e[s(1389)](a[n+1],16)),e[s(1398)](a[e[s(1268)](n,2)],8))|a[e.OOnMU(n,3)],!0);return n+=8,{value:d,offset:e[s(1630)](n,8)}}function Ix(a,n,s){let d=t,u={oMPlW:e[d(1486)],iczNV:d(1249)+"hange"};if(e[d(680)](e[d(1501)],e[d(926)])){let g=a[d(1412)],v=a.high;return n[s]=e[d(1189)](v,24),n[e[d(349)](s,1)]=e[d(1045)](e.facjG(v,16),255),n[e[d(804)](s,2)]=e[d(994)](e[d(796)](v,8),255),n[s+3]=e[d(846)](255,v),n[e.zJswj(s,4)]=g>>>24,n[s+5]=g>>>16&255,n[e[d(435)](s,6)]=e.yQeja(e[d(974)](g,8),255),n[s+7]=255&g,s+=8,s}else _0x447112&&_0xd8bddb[d(1145)+d(225)](lNfNqV.oMPlW,()=>_0x1aab64()),_0x56c284&&_0x2d4f5f[d(1145)+d(225)](lNfNqV[d(500)],()=>_0x4961f0())}function Fo(a,n){let s=t;return a[s(841)+"8"]?{value:a.readUInt8(n),offset:e[s(345)](n,1)}:{value:255&a[n],offset:e[s(628)](n,1)}}function Uo(a,n,s){let d=t;return n[d(1239)+"t8"]?n[d(1239)+"t8"](a,s):n[s]=e[d(1045)](255,a),s+1}let Ax=function(a){return new Uint8Array(a)},Tx=e[t(730)]("undefined",typeof Buffer)?Buffer[t(1614)+"afe"]:e[t(1188)](mx,Ax,Uint8Array.prototype[t(523)]),Cx=16,Ho=32;function Rx(a){let n=t;if(e[n(821)](e[n(1063)],"eEypE")){let s=0,d={};for(let u=0;e.VvJTB(u,a[n(704)]);u++)d[a[u][n(336)+n(1598)]]=vd(a[u]["cursor_n"+n(1598)]),s+=14+d[a[u][n(336)+n(1598)]];return[s,d]}else{let s=this[n(1585)+"tManager"]?.[n(423)+"ntEndpoint"]();this["_dispatc"+n(363)+"ent"](e[n(791)](_0x3ec5a2,e[n(1486)],{code:_0x4d5384[n(1144)],reason:"connecti"+n(576)+"d, unknown reason, hostn"+n(559)+s})),this[n(1585)+n(1025)]?.[n(908)+n(1397)+n(1495)](),this[n(657)+"sCounter"]?.["resetCou"+n(1538)]();return}}function Cd(a,n,s){let d=t,u={ZyDpW:function(O,N,H,W){return O(N,H,W)},PmWKm:e[d(547)],kioyY:e[d(1539)],NbAFI:d(605)+d(1102),rThth:function(O,N,H,W){return O(N,H,W)},ztKYv:e[d(650)]},[g,v]=e[d(997)](Rx,a),b=Tx(g),p=0;return a[d(1466)](O=>{let N=d;console[N(292)](N(397)+N(741),O,O[N(330)]),p=u[N(262)](Uo,0,b,p),console.log(u[N(694)],p),p=u[N(262)](Ex,b,p,O[N(330)]||0),console.log(u.kioyY,p),p=Uo(v[O[N(336)+"ame"]],b,p),console[N(292)](u.NbAFI,p),p=u[N(663)](vx,O[N(336)+N(1598)],b,p),console[N(292)](u[N(1297)],p),p=u.ZyDpW(Ix,se.fromNumber(O.cursor||n),b,p),console[N(292)](N(516),p)}),{frameType:Ho,headers:[{key:e[d(252)],value:s}],payload:b}}function kx(a){let n=t,s=0,d=[];for(;e.kkZOh(s,a[n(668)+"th"]);){let{offset:u}=e[n(736)](Fo,a,s);s=u;let g={cursor_name:"",cursor:0,service:0},{value:v,offset:b}=e.vlFGu(bx,a,s);g[n(330)]=v,s=b;let{value:p,offset:O}=e[n(656)](Fo,a,s);s=O,g[n(336)+n(1598)]=e[n(885)](Sd,a,s,s+p),s+=p;let{value:N,offset:H}=Sx(a,s);g[n(254)]=N[n(1443)](),s=H,d[n(489)](g)}return d}function Dx(){let a=t;return{frameType:Ho,headers:[{key:e[a(252)],value:e[a(1294)]}],payload:void 0}}class Ox{constructor(n,s,d){let u=t;this[u(655)+u(964)]=n,this[u(1504)+u(1005)]=s,this[u(462)+u(855)]=d,this[u(327)]=e[u(678)](Ad,this[u(655)+u(964)],e[u(554)])}async openDB(){let n=t;e[n(1223)](e.ArWgQ,e[n(1579)])?await this._qosDB[n(1022)]():(_0x24b3f0(_0x1a37ee,66),_0x275e00(_0x330e53,_0x476e9a.length),_0x212bc3(_0x1806f6,_0x51fe21))}async[t(388)+"rs"](){let n=t;if(!this[n(327)][n(1357)])return;let s=this[n(462)+n(855)],d=await this[n(327)][n(899)]();switch(console[n(292)](n(1185)+n(1350),d),s){case e[n(561)]:return d&&d[n(704)]?e[n(1541)](Cd,d,0,this[n(1504)+"ileName"]):void 0;case e[n(337)]:return;case"CONTINUE":return d&&d[n(704)]?e.bLUoP(Cd,d,0,this[n(1504)+n(1005)]):e.iGJhF(Dx)}}async[t(1396)](n,s,d){let u=t;return console[u(292)](e.tyMDw,n,s,d),this[u(327)][u(1396)]({cursor_name:n,cursor:s,service:d})}async[t(364)+"rs"](n){let s=t,d=e[s(1047)](kx,n);for(let u of d)if(e.WOpat(e[s(1066)],e[s(1066)])){if(!this[s(1522)])return;this["_destroy"+s(540)+"t"](_0x38a3b5,_0x37db63,_0x43b908)}else console[s(292)](s(1142)+"r",d),await this[s(327)].set(u)}async[t(1151)](n){let s=t,d={RfTLn:function(u,g){return e.OhxuO(u,g)},SeTzs:function(u,g){return e.UMktF(u,g)},FhJMd:function(u,g){return e[$(785)](u,g)},AoMqx:function(u,g){return u<<g},DkLGZ:function(u,g){return u<g}};if(e[s(1120)](e[s(470)],e[s(1353)]))return(await this[s(327)][s(1151)](n))?.[s(254)];{let u=_0x1437c9[s(1254)+"At"](_0x237788);u>=55296&&xwVaVx.RfTLn(u,56319)&&xwVaVx[s(771)](_0xd474bc,1)<_0x10571f&&(u=xwVaVx.FhJMd(xwVaVx[s(771)](xwVaVx[s(505)](u,10),_0x163ac0.charCodeAt(++_0x22365b)),56613888)),_0xd50ac1+=xwVaVx[s(743)](u,128)?1:xwVaVx[s(743)](u,2048)?2:u<65536?3:4}}async[t(695)](){await this[t(327)].closeDB()}["updateCursorFile"+t(256)](n){let s=t;if(e.qCyEV(s(1520),s(816)))return _0x55b948[s(1455)]();this._cursorFileName=n}get[t(1357)](){let n=t;return this[n(327)][n(1357)]}}let Px=t(372)+"qos__";async function Rd(a){let n=t,s={DZSez:function(d,u,g){return e[$(736)](d,u,g)},iOmKr:function(d,u,g){return e[$(970)](d,u,g)}};if(e[n(479)]===e[n(774)])wBWvTY[n(924)](_0x295920,_0x4b74f9,16),wBWvTY.iOmKr(_0x5867e5,_0x4c39b7,_0x3bfda9);else{if(!this[n(308)].enableQoS)return null;let{aID:d,fpID:u,messageStrategy:g}=this[n(308)],v=e.CSzGS(a,Px);try{return this._cursorManager?a&&this[n(541)+n(976)][n(718)+n(955)+"Name"](a):this[n(541)+n(976)]=new Ox(u+"_"+d+"_"+v,v,g),this[n(541)+n(976)][n(1357)]||await this[n(541)+"anager"][n(1022)](),this[n(541)+n(976)]}catch{return null}}}async function Lx(a,n){let s=t,d=e[s(885)](Vt,a[s(1080)][s(508)],e[s(909)],"-1"),u=Vt(a[s(1080)][s(508)],e[s(947)],"1"),g=e.AZtKB(jn,a[s(1080)][s(508)],e.pMOeK),v=e[s(651)](Number,e[s(1163)](jn,a.message[s(508)],e[s(281)]))||0,b=zo[s(421)](this,a),p=Vt(a[s(1080)][s(508)],e[s(1571)],"2"),O=jn(a[s(1080)][s(508)],e[s(681)]),N=e[s(627)](Number,e.tsKSD(jn,a[s(1080)][s(508)],e[s(968)]));if(b[s(676)])return e[s(1481)](n);let H=b[s(1040)+s(1340)]?await Td.call(this):null;if(e.ySgoc(a[s(1080)][s(330)],0)&&u&&!d||e[s(418)](a[s(1080)][s(330)],0)){if(g&&b[s(1040)+s(1340)]&&H)return!!!await H[s(1151)](g)&&(this[s(807)+s(918)+s(1566)](a),await H[s(1396)](g,Date[s(1222)]()+v)),e.eIcyG(n);if(p){let W=await Rd.call(this);if(!W){if(e[s(1092)](e.GkjTG,e.NnEFa))return this[s(807)+s(918)+"Event"](a),e[s(1453)](n);this[s(398)+s(984)]()&&(!this[s(1522)]||e.KyOjT(this[s(1522)][s(283)+"te"],this.OPEN)||e[s(275)](this[s(1522)][s(283)+"te"],this[s(805)+"NG"]))&&this[s(1590)+s(1583)](),this[s(1493)+"er"]&&_0x4bf3fb[s(1145)+"Listener"](e.DiVVl,this[s(1590)+s(1583)]),this._isBrowser&&_0x57a738[s(1145)+s(225)](e[s(380)],this[s(1590)+s(1423)])}let K=await W[s(1151)](O)??-1;if(e[s(1430)](K,N))this[s(807)+s(918)+s(1566)](a),W[s(1396)](O,N,a[s(1080)][s(330)]);else throw new Error("recevied"+s(1030)+s(356)+N+(s(721)+s(1319)+"al cursor ")+K);return e.KrTXX(n)}return this["_dispatc"+s(918)+s(1566)](a),n()}}async function Nx(a,n){let s=t;if(e[s(322)](e[s(510)],s(1157)))return _0x3f7a17(_0xd8d6f0[s(877)](_0x26dca0(this),_0x34b9b2));{let d=zo[s(421)](this,a);if(!d.isQoSMessage)return n();let u=await Td[s(421)](this);if(d[s(222)+s(420)+s(653)]&&d[s(563)+"s"].length)for(let g of d.ackMsgIds)await u[s(1237)](g);e[s(321)](n)}}async function Mx(a,n){let s=t,d=a.message[s(1582)+"e"]===Cx,u=e[s(1223)](a[s(1080)][s(1582)+"e"],Ho);if(!d&&!u)return e.ImtsJ(n);let g=jn(a.message[s(508)],e[s(252)]);if(!g)return e[s(967)](n);let v=await Rd[s(421)](this,g);if(!v)return e[s(987)](n);if(d){let b=await v[s(388)+"rs"](),p={frameType:b?.["frameType"],SeqID:se[s(975)+"er"](this._seqId++),LogID:se[s(975)+"er"](this[s(308)][s(1545)+s(1515)]()),service:9e3,method:5,headers:b?.[s(508)],payload:b?.payload},O=A(p);this[s(1522)]&&this[s(1522)][s(283)+"te"]&&this[s(1522)][s(1505)](O)}if(u){let b=a.message[s(932)];b&&v[s(364)+"rs"](b)}}let Bx=async function(a,n){let s=t;this[s(468)]=!1,e[s(845)](clearTimeout,this[s(517)+s(437)+s(1046)]),e[s(1445)](n)},zx=async function(a,n){let s=t;if(!this[s(1522)]||e[s(1092)](this[s(1522)][s(283)+"te"],this.OPEN))return e.GmNlp(n);let{pingInterval:d}=this[s(308)];this[s(1585)+s(1025)]?.[s(908)+s(1397)+s(1495)]();for(let g=0;e[s(1184)](g,this["_message"+s(1180)][s(704)]);g++){let v=this["_message"+s(1180)][g];if(e.qWMRu(this._ws.readyState,this[s(1337)])&&e[s(913)](null,v))this._ws&&this[s(1522)][s(1505)](v),this["_message"+s(1180)][g]=null;else break}this[s(462)+s(1180)]=this[s(462)+s(1180)].filter(g=>!!g),this[s(762)+s(1491)+"Id"]=setTimeout(()=>this[s(1281)](),d),this["_dispatc"+s(1610)+"nt"](a),this[s(1493)+"er"]&&this[s(1522)]&&(this[s(1522)][s(512)+"pe"]=this[s(458)+s(318)]);let u=this[s(1585)+s(1025)]?.[s(423)+s(712)+"nt"]();this[s(1469)]("open "+u+" success"),e[s(1453)](n)},Fx=async function(a,n){let s=t,d=this[s(1585)+"tManager"]?.[s(423)+"ntEndpoint"]();this[s(1469)](s(764)+d),e[s(944)](n)};class Ux extends No{constructor(n){let s=t,d={rwVwb:function(b,p){return e[$(1507)](b,p)},tQjOO:e[s(534)],ztEEW:e.iGIhe,AGCzY:function(b,p,O){return b(p,O)},knrTQ:e.tXteP,GkUED:s(1525),JLUUM:s(528)+"e_success",PibMN:e[s(446)],nhkmI:s(440),kfEyQ:e[s(1595)],fLKhg:function(b,p){return e[s(335)](b,p)}};super(),this[s(1426)+s(1509)+s(1315)]=!0,this[s(1493)+"er"]=Gn,this[s(445)]=tx,this[s(1591)+"T"]=mn,this._isMiniWX=Or,this[s(1279)+"r"]=Pr,this["_message"+s(1180)]=[],this[s(1585)+"tManager"]=null,this[s(765)+s(1422)]=!1,this[s(458)+s(318)]=e[s(1446)],this[s(517)+s(865)]=!1,this[s(517)+s(437)+"utId"]=null,this[s(1161)+s(889)+s(354)]=null,this["_pingPon"+s(1491)+"Id"]=null,this[s(696)]=0,this[s(468)]=!1,this[s(1474)]="",this[s(1150)+s(999)]=null,this._cursorManager=null,this["_pingLos"+s(220)]=null,this._protocols=s(341),this.CLOSED=3,this.CONNECTING=0,this[s(1337)]=1,this[s(1073)]=2,this._onOpen=b=>{let p=s;try{e[p(1109)](bd,this,b,[Bx,zx,Fx])}catch(O){if(e[p(400)](e[p(1388)],e[p(350)])){let N=e[p(245)](nt,e[p(266)],{message:O.message,code:$t.OPEN_ERROR,error:O});this[p(807)+"hErrorEv"+p(1265)](N)}else return _0x58d6f9.errMsg||_0x1c28b1[p(1328)]?(p(1416)+" "+(_0x463e25[p(1603)]||"")+p(1524)+(_0x3bf49d[p(1328)]||""))[p(1035)]():_0x2e19b3.stringify(_0x3ff7de)}},this[s(1479)+"ge"]=async b=>{let p=s,{pingInterval:O,pingFrequency:N}=this[p(308)];if((d[p(368)]("hi",b[p(1465)])&&d[p(368)](p(1622),N)||d.tQjOO===N)&&(this["_clearPi"+p(1116)](),this[p(1377)]("ping_once_success",d[p(1299)]),this[p(762)+p(1491)+"Id"]=setTimeout(this[p(1281)][p(874)](this),O)),!d[p(368)]("hi",b[p(1465)]))try{bd(this,b,[gx,xx,Nx,Mx,Lx,px])}catch(H){let W=d[p(1349)](nt,d[p(1221)],{message:H.message,code:$t[p(1165)+p(1620)],error:H});this[p(807)+p(1225)+p(1265)](W)}},this[s(1386)]=b=>{let p=s,O={NoyWo:function(W,K){return W(K)},DcNgd:d.GkUED,Pmerr:d[p(836)],dtYni:d.PibMN},N=this[p(1585)+p(1025)]?.[p(1256)+p(1384)+"es"](),H=this[p(1585)+p(1025)]?.[p(423)+p(712)+"nt"]();if(N&&!b[p(1080)])if(d.rwVwb(d[p(1233)],d[p(756)]))O[p(1314)](_0x2fd6bb,O.DcNgd),this[p(731)](O[p(673)],_0x19d77f),this.off(O[p(530)],_0x30d285);else{let W=p(414)+H+(p(644)+"ax retries reached");this[p(807)+p(1225)+p(1265)](d.AGCzY(nt,d[p(1221)],{message:W,code:$t[p(648)+"IES_ERROR"],error:b}));return}this[p(1522)]&&d[p(1e3)](this[p(1522)][p(283)+"te"],this[p(1337)])&&this[p(593)+"ect"](),this[p(807)+p(1225)+p(1265)](nt(d[p(1221)],{message:b.message,code:$t[p(649)+p(316)],error:b}))},this[s(1017)]=async b=>{let p=s;this[p(1592)+p(480)](),this["_clearPi"+p(1116)](),this[p(998)+p(904)+"rs"](),this._ws=null,this[p(517)+p(865)]=!1;let O=this[p(1585)+p(1025)]?.[p(1256)+p(1384)+"es"]();if(!O&&this[p(398)+p(984)]()&&!this[p(765)+p(1422)]){let N=this[p(1585)+p(1025)]?.[p(423)+p(712)+"nt"](),H=this[p(308)][p(433)+p(842)+p(1316)](b.code,b[p(1355)]);this._dispatchCloseEvent(e[p(273)](lt,e[p(1486)],{code:1006,reason:b[p(1355)]||p(614)+p(576)+p(375)+p(1269)+"n, hostn"+p(559)+N,willReconnect:H})),H&&this[p(517)]();return}if(e[p(913)](1e3,b[p(1144)])&&this["_readyCl"+p(1422)]){this[p(807)+p(363)+p(1265)](e[p(609)](lt,e[p(1486)],{code:1e3,reason:e.JEijS})),this["_endpoin"+p(1025)]?.[p(908)+p(1397)+p(1495)](),this[p(657)+p(220)]?.[p(829)+p(1538)]();return}if(e[p(693)](1e3,b[p(1144)])&&O)if(e[p(1235)](p(724),e[p(828)])){let N=this[p(1585)+p(1025)]?.[p(423)+p(712)+"nt"](),H=b.reason;H||(H=await cx(this._url)),H=p(614)+p(576)+p(917)+H+(p(957)+p(672))+N+(p(1291)+p(920)+p(956)),this[p(807)+p(363)+"ent"](e[p(1272)](lt,e[p(1486)],{code:b[p(1144)],reason:H}));let W=p(414)+N+(p(644)+p(1032)+p(990)+"ed");this[p(807)+p(1225)+p(1265)](e[p(1052)](nt,e[p(266)],{message:W,code:$t[p(648)+"IES_ERROR"]})),this[p(1585)+p(1025)]?.[p(908)+"pointConfig"](),this[p(657)+p(220)]?.["resetCou"+p(1538)]();return}else _0x1f2a74[p(1455)]()[p(625)](()=>{let N=p;this[N(691)+N(1429)]()});if(b[p(1144)]!==1e3&&!b[p(1355)]){let N=this[p(1585)+p(1025)]?.[p(423)+"ntEndpoint"]();this[p(807)+p(363)+"ent"](lt(e[p(1486)],{code:b[p(1144)],reason:p(614)+"ng faile"+p(375)+p(1269)+p(464)+p(559)+N})),this[p(1585)+p(1025)]?.["resetEndpointCon"+p(1495)](),this[p(657)+p(220)]?.["resetCou"+p(1538)]();return}this[p(807)+p(363)+p(1265)](b),this[p(1585)+p(1025)]?.["resetEnd"+p(1397)+p(1495)](),this[p(657)+p(220)]?.["resetCou"+p(1538)]()},this[s(326)]=null,this[s(812)]=null,this[s(580)+"e"]=null,this[s(1593)]=null,this[s(861)+s(1627)]=null,this.onReceiveAck=null,this["onStopImmediatel"+s(1433)+"ct"]=null,this[s(1590)+s(1583)]=this[s(1590)+"nLine"][s(874)](this),this[s(1590)+"ffLine"]=this["_handleO"+s(1423)][s(874)](this),this[s(830)+s(1572)]=this[s(830)+"ageHide"][s(874)](this),this[s(830)+s(1172)]=this[s(830)+s(1172)][s(874)](this),this[s(308)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e.IqURM(1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[s(534)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:"CONTINUE",env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:g}=n,v=Array[s(494)](u)?u:e[s(652)]==typeof u?[u]:[];if(!v||v[s(704)]===0)throw new Error(e[s(233)]);if(!e[s(374)](ix,g))throw new Error(e[s(1385)]);Object[s(1476)](this[s(308)],n),this[s(1585)+s(1025)]=new Ed(v,this[s(308)][s(1129)+"es"]),this[s(657)+"sCounter"]=new ax(this[s(308)][s(1068)+s(1536)]),this._options[s(1462)+"cOpen"]&&(this[s(468)]=!0,this._connect()),this[s(308)][s(954)+"tworkChanged"]&&(this[s(1591)+"T"]||this._isMiniWX?this[s(1224)+s(679)+s(325)]():this[s(1493)+"er"]&&this[s(1400)+"balEvent"+s(225)]())}[t(1590)+"nLine"](){let n=t;this[n(308)][n(1425)+n(1246)+n(476)]||this[n(765)+n(1422)]||this[n(1192)+n(1627)]()}[t(1590)+t(1423)](){let n=t;this[n(297)+n(540)+"t"]();let s=e[n(852)](Lo,e[n(1419)],{message:n(1050)+"ediately"+n(506)+"ct"});this[n(406)+n(573)+n(1433)+"ct"]&&this[n(406)+n(573)+"yReconnect"](s)}["_initGlo"+t(1551)+t(225)](){let n=t;this[n(1493)+"er"]&&window[n(1145)+n(225)](e[n(1569)],this[n(1590)+n(1583)]),this._isBrowser&&window[n(1145)+"Listener"]("offline",this[n(1590)+n(1423)]),this[n(1493)+"er"]&&window[n(1145)+"Listener"](e[n(241)],this[n(830)+n(1572)]),this[n(1493)+"er"]&&window[n(1145)+n(225)](e[n(1075)],this[n(830)+n(1172)])}["_dropGlo"+t(1551)+t(225)](){let n=t;this[n(1493)+"er"]&&window[n(1044)+n(814)+n(1194)](e[n(1569)],this[n(1590)+n(1583)]),this[n(1493)+"er"]&&window[n(1044)+n(814)+n(1194)](e[n(380)],this[n(1590)+n(1423)]),this[n(1493)+"er"]&&window[n(1044)+n(814)+n(1194)](e[n(241)],this[n(830)+n(1572)]),this._isBrowser&&window[n(1044)+"entListe"+n(1194)](e.LaWQe,this[n(830)+n(1172)])}[t(830)+t(1572)](n){let s=t;!n.persisted&&(this[s(1493)+"er"]&&window[s(1044)+s(814)+s(1194)](s(1587),this[s(830)+s(1572)]),this[s(1493)+"er"]&&window[s(1044)+s(814)+s(1194)]("pageshow",this[s(830)+s(1172)]),this.close()),this[s(1493)+"er"]&&window[s(1044)+s(814)+s(1194)](e.DiVVl,this[s(1590)+s(1583)]),this[s(1493)+"er"]&&window[s(1044)+s(814)+s(1194)]("offline",this[s(1590)+s(1423)])}[t(830)+t(1172)](n){let s=t,d={gTjVq:function(u,g){return e.scrXa(u,g)},JGInV:function(u,g){return e[$(1496)](u,g)},Lfadc:function(u,g){return e[$(993)](u,g)},EZZIr:e[s(745)],eJncZ:e[s(1584)]};if(n[s(1100)+"d"])if(e[s(750)](e[s(427)],e[s(427)])){if(kokdse[s(1381)](_0x26ef49,_0x22b7f4))return new _0x10faa6(_0x357ccf,_0x1f93a3);if(kokdse[s(714)](_0x6d861a,_0x1fc89b)&&kokdse.Lfadc(kokdse.EZZIr,typeof _0x43f9d4))return new _0x45e8ee(_0x5a681e,_0x5bb0c3);if((_0x180821||_0x5c00f0)&&kokdse[s(720)]!=typeof _0x172775)return new _0x1bad9f(_0x259519,_0x59d74e);throw new _0x55cfb7(kokdse.eJncZ)}else this._navigatorOnline()&&(!this[s(1522)]||e.XOkBI(this[s(1522)][s(283)+"te"],this[s(1337)])||e[s(893)](this[s(1522)][s(283)+"te"],this.CONNECTING))&&this[s(1590)+s(1583)](),this._isBrowser&&window[s(1145)+s(225)](e[s(1569)],this[s(1590)+s(1583)]),this[s(1493)+"er"]&&window[s(1145)+s(225)](e[s(380)],this[s(1590)+s(1423)])}async[t(1060)+"eUrl"](n){let s=t,{fpID:d,deviceID:u,bddID:g,ttwID:v,accessKey:b,aID:p,customParams:O={},enableAutoAck:N,enableQoS:H,QoSLevel:W,env:K}=this[s(308)],Ae,Ve,Ge;this[s(1493)+"er"]||this[s(1437)+"X"]||this[s(1591)+"T"]?(Ae=location&&e[s(863)](e[s(749)],location[s(813)])?"wss://":e.JpjJo,Ve=n[s(936)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Ge=/^wss(.*:\/\/)/[s(715)](n)?n:""+Ae+Ve):(Ae=e[s(1560)],Ve=n.replace(/(^http)((?:[s]*:\/\/))/,""),Ge=/(^ws)((?:[s]*:\/\/))/.test(Ve)?Ve:""+Ae+Ve);let Ne=g?"bd_did":v?"ttwid":e[s(303)],rt=g||v||u;if(e[s(542)](!rt,!Ne))throw new Error(s(1494)+s(407)+s(1174)+s(481)+s(757));let wn=e[s(863)](s(295),typeof O)?await e[s(969)](O):O,kd=K?e[s(1139)](ox,K[s(892)],K.xTTEnv):{},qo=Object[s(1476)]({device_platform:s(539),version_code:e[s(1096)],access_key:b,fpid:d,aid:p,[Ne]:rt,xsack:N?1:0,xaack:N?1:0,xsqos:H?1:0,qos_level:H?W:void 0,qos_sdk_version:2,...kd},wn),Hx=Object[s(263)](qo).reduce((Go,jo)=>qo[jo]!==void 0?""+Go+(Go?"&":"?")+jo+"="+qo[jo]:Go,"");return Ge+"/ws/v2"+Hx}async _connect(){let n=t;if(e[n(810)](e[n(705)],e[n(448)])){if(this["_connect"+n(865)]||this[n(765)+"osed"])return;this["_connect"+n(865)]=!0;try{let s=this[n(1585)+n(1025)]?.[n(1336)+n(1439)+n(1082)+n(902)+n(839)](),{timeoutInterval:d}=this[n(308)];if(s){let g=this[n(1585)+"tManager"]?.[n(423)+n(712)+"nt"](),v=this[n(1585)+n(1025)]?.["replaceB"+n(1401)+n(269)+n(493)+n(1359)](),b=this[n(1585)+n(1025)]?.[n(423)+"ntEndpoi"+n(942)+"ount"]();if(v)if(e[n(1020)](e[n(1003)],e[n(1003)])){if(e[n(997)](_0x17c7de,_0x21c8d5))return _0x158b39?_0x114af7:_0x48ab44;if(_0x4041c9){if(e[n(763)](_0x1cd608,_0x3a3332))return _0x395a03}else{if(e[n(706)](_0x182742,-_0x342ecf))return _0x16bf3e;if(e[n(1175)](e.yscLC(_0x21a102,1),_0xceca3d))return _0x4fb67d}return _0x5d732f[n(1154)](e[n(382)](_0x274148%_0x279c60,0),_0x104ea1/_0x50534f|0,_0x521fa4)}else{let p=n(414)+g+(" timeout"+n(1291)+"tries re"+n(1240)+n(922)+n(387)+n(640))+v+" to retry",O=e[n(636)](nt,e.tXteP,{message:p,code:$t["MAX_RETR"+n(1153)+"R"]});this[n(1469)](p),this[n(807)+"hErrorEv"+n(1265)](O),this._url=await this[n(1060)+n(1105)](v),this[n(1469)](n(414)+v+" "+b+" times"),this[n(998)+"sListeners"]()}else{let p=n(414)+g+(" timeout"+n(1291)+n(920)+"ached");this[n(1469)](p),this[n(807)+n(1225)+n(1265)](e.aDJyb(nt,e.tXteP,{message:p,code:$t.MAX_RETRIES_ERROR}));return}}else{let g=this[n(1585)+n(1025)]?.[n(423)+"ntEndpoi"+n(983)+n(898)](),v=this[n(1585)+n(1025)]?.[n(423)+n(712)+"ntTriesC"+n(474)]();this[n(1474)]=await this[n(1060)+n(1105)](e.sLXdu(g,"")),this[n(1469)](n(414)+g+" "+v+n(1532)),this["_removeW"+n(904)+"rs"]()}if(this[n(468)])this._isInit=!1;else{let g=e[n(624)](Lo,e[n(1419)],{message:e[n(752)]});this[n(861)+n(1627)]&&this[n(861)+n(1627)](g)}let u=this["_endpoin"+n(1025)]?.["getCurre"+n(712)+n(942)+n(474)]()||0;e[n(773)](u,1)&&await this[n(1034)](e[n(394)](u,1)),this._debug("connecti"+n(1208)+this._url+(n(1074)+"ls: ")+this[n(915)+"ls"]),this[n(1522)]=rx({url:this[n(1474)],protocols:[this[n(915)+"ls"]],headers:this[n(308)][n(323)+n(373)+"s"].customHttpHeader},this[n(308)].ws),(this[n(1493)+"er"]||this._isWorker)&&this._ws&&(this[n(1522)].binaryType=this[n(458)+n(318)]),this._addWsListeners(),this[n(517)+n(437)+n(1046)]=e[n(1542)](setTimeout,this[n(1227)+"ut"][n(874)](this),d)}catch(s){throw this._connectLock=!1,s}}else return this._ws?this[n(1522)][n(283)+"te"]:this[n(308)][n(1462)+n(1076)]?this[n(805)+"NG"]:this[n(1111)]}[t(1592)+t(480)](){let n=t;e[n(1404)](clearTimeout,this["_connect"+n(437)+n(1046)]),this[n(517)+n(437)+n(1046)]=null}[t(443)+"ngTimer"](){let n=t;clearTimeout(this[n(762)+n(1491)+"Id"]),e.dQKLz(clearTimeout,this[n(1161)+n(889)+n(354)]),this["_pingPon"+n(1491)+"Id"]=null,this["_reconne"+n(889)+n(354)]=null}[t(1469)](...n){let s=t;if(s(279)!==e[s(1309)])return this[s(327)]?.[s(1357)];this[s(308)][s(1528)]&&console[s(292)][s(877)](console,[e.cINLX,...n])}[t(1204)+t(1156)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:g}=this._options,v=e[s(787)](d,Math[s(359)](g,e[s(394)](n,1)));return e.cHQXi(v,u)?u:v}[t(1281)](){let n=t;if(e[n(1573)](n(949),e.sZphA)){let s=_0x23cfc8[n(560)],d=_0x2eb849.offset,u=_0x5ded58.limit,g=d+_0x5254ce;if(e.cHQXi(g,s[n(704)])){let v=new _0x248ac8(e[n(1548)](2,g));v[n(1396)](s),_0x46dcf9[n(560)]=v}return _0x3319ce.offset=g,e[n(612)](g,u)&&(_0x38ddac[n(1193)]=g),d}else{if(this[n(1522)]&&this[n(1522)][n(283)+"te"]===this.CONNECTING){this["_clearPi"+n(1116)](),this["_pingPon"+n(1491)+"Id"]=e[n(701)](setTimeout,this[n(1281)].bind(this),this[n(308)][n(1514)+n(383)]);return}if(!this[n(1522)]||e[n(941)](this._ws[n(283)+"te"],this.OPEN))return void this[n(1192)+"econnect"]();this._ws&&this._ws[n(1505)]("hi"),this[n(1161)+n(889)+n(354)]=e[n(1395)](setTimeout,this[n(1192)+"econnectTimeout"][n(874)](this),this._options[n(520)+n(594)+"val"])}}[t(1192)+t(1627)+t(1183)](){let n=t;this[n(657)+n(220)]?.addCount(),this[n(1377)](n(528)+n(610)+"t",e[n(770)]),this[n(657)+n(220)]?.[n(1256)+n(483)+"nt"]()?this["_handleR"+n(1627)]():this[n(1281)]()}["_navigat"+t(984)](){let n=t;return this[n(1591)+"T"]||this[n(1437)+"X"]?this[n(1426)+n(1509)+n(1315)]:(this._isBrowser||this._isWorker)&&this[n(308)][n(954)+n(1262)+"nged"]?navigator[n(459)]:!0}["_handleR"+t(1627)](){let n=t;if(e[n(1276)](e[n(501)],e[n(396)])){let s=e[n(736)](_0x4c0108,_0x2c3170,1);_0x227da5[n(560)][s]=_0x231313}else{if(!this[n(398)+"orOnline"]()||this[n(765)+n(1422)])return;this[n(1585)+n(1025)]?.[n(908)+n(1397)+"fig"](),this["_pingLos"+n(220)]?.[n(829)+n(1538)](),this[n(1522)]?this["_disconn"+n(285)](1001,e[n(1499)],!0):this[n(517)]()}}["_onPageNetWorkCh"+t(325)](){let n=t;this[n(1591)+"T"]?tt["onNetwor"+n(1143)+n(1112)](({isConnected:s})=>{let d=n;this["_miniNav"+d(1509)+d(1315)]=s,s?this._handleOnLine():this[d(1590)+d(1423)]()}):this[n(1437)+"X"]&&wx["onNetwor"+n(1143)+n(1112)](({isConnected:s})=>{let d=n;this[d(1426)+d(1509)+d(1315)]=s,s?this[d(1590)+d(1583)]():this[d(1590)+d(1423)]()})}_wait(n){let s={wTJFT:function(d,u,g){return e.zyDgc(d,u,g)}};return new Promise(d=>{let u=$;s[u(1084)](setTimeout,d,this[u(1204)+u(1156)+"e"](n))})}[t(593)+t(285)](n=1e3,s="",d=!1){let u=t;this[u(1522)]&&this[u(297)+"WebSocket"](n,s,d)}[t(1227)+"ut"](){let n=t,s=this[n(1585)+n(1025)]?.[n(423)+"ntEndpoint"]();this[n(1469)](n(414)+s+n(361)),this[n(593)+n(285)](1001,e[n(1399)],!0)}[t(622)](n){let s=t,d=Ke(n);this._ws&&e[s(486)](this[s(1522)][s(283)+"te"],this.OPEN)&&(this[s(1522)]&&this[s(1522)].send(d),this._debug(e[s(267)],n))}["_removeW"+t(904)+"rs"](){let n=t,s=e[n(832)][n(626)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(!this._ws)return;continue;case"1":this._ws[n(1044)+n(814)+"ner"](e[n(1486)],this._onClose);continue;case"2":this[n(1522)][n(1044)+n(814)+n(1194)](e[n(1141)],this[n(1518)]);continue;case"3":this[n(1522)][n(1044)+n(814)+n(1194)](n(513),this[n(1386)]);continue;case"4":this[n(1522)].removeEventListener(e[n(824)],this[n(1479)+"ge"]);continue}break}}[t(691)+"steners"](){let n=t,s=e.mKWSf[n(626)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1522)][n(1145)+n(225)](n(738),this[n(1518)]);continue;case"1":if(!this[n(1522)])return;continue;case"2":this._ws[n(1145)+n(225)](n(1080),this[n(1479)+"ge"]);continue;case"3":this._ws[n(1145)+n(225)]("error",this[n(1386)]);continue;case"4":this._ws[n(1145)+n(225)](e.syDAY,this[n(1017)]);continue}break}}[t(1123)+t(772)](n=1e3,s=""){let d=t;if(e[d(1004)]===e[d(1004)])try{this[d(1522)]&&this[d(1522)][d(1305)](n,s)}catch{}else{let u=_0x43f497[d(551)+"g"](0,4-_0x11e569.length),g=u[d(1263)](_0x4bf1a7);_0x4dfd2f.push(g)}}[t(297)+t(540)+"t"](n=1e3,s="",d=!1){let u=t;if(this["_clearPi"+u(1116)](),this[u(1592)+u(480)](),this[u(998)+u(904)+"rs"](),this[u(1123)+"nceClose"](1e3,s),this[u(517)+u(865)]=!1,d&&this[u(398)+u(984)]()&&!this[u(765)+u(1422)]){if(this[u(1585)+u(1025)]?.["checkRea"+u(1384)+"es"]()){let v=this[u(1585)+u(1025)]?.[u(423)+u(712)+"nt"]();this["_dispatc"+u(363)+u(1265)](e[u(1296)](lt,e[u(1486)],{code:1006,reason:u(414)+v+(u(361)+", max re"+u(920)+u(956)),wasClean:!0}))}else{let v=this._options[u(433)+u(842)+u(1316)](n,s);this[u(807)+u(363)+u(1265)](lt(e[u(1486)],{code:n,reason:s,wasClean:!0,willReconnect:v})),v&&this[u(517)]()}return}this[u(398)+u(984)]()||this[u(765)+u(1422)]?this["_dispatc"+u(363)+u(1265)](e[u(940)](lt,e[u(1486)],{code:n,reason:e[u(1362)]})):this[u(807)+u(363)+u(1265)](e[u(1188)](lt,e[u(1486)],{code:1006,reason:u(280)+u(851)+"ork offline"})),this._ws=null,this["_endpoin"+u(1025)]?.[u(908)+u(1397)+"fig"](),this[u(657)+"sCounter"]?.[u(829)+u(1538)]()}[t(807)+t(1610)+"nt"](n){let s=t;this[s(1377)](e[s(1141)],n),this[s(1593)]&&this[s(1593)](n)}[t(807)+t(918)+t(1566)](n){let s=t;this[s(1377)](e.cEXpt,n),this[s(580)+"e"]&&this[s(580)+"e"](n)}[t(807)+t(1586)+t(278)](n){let s=t;this[s(1377)](e[s(366)],n),this[s(571)+"eAck"]&&this["onReceiv"+s(465)](n)}[t(807)+t(1225)+t(1265)](n){let s=t;this[s(1377)](e[s(266)],n),this.onerror&&this[s(812)](n)}[t(807)+t(363)+"ent"](n){let s=t;this[s(1377)](e[s(1486)],n),this[s(326)]&&this.onclose(n)}get binaryType(){let n=t;return this._ws?this[n(1522)][n(512)+"pe"]:this[n(458)+"ype"]}set binaryType(n){let s=t;this[s(458)+s(318)]=n,this[s(1522)]&&(this[s(1522)][s(512)+"pe"]=n)}get[t(1503)+"nt"](){let n=t;return this[n(1585)+n(1025)]?.[n(423)+n(712)+n(942)+n(474)]()||0}get["buffered"+t(1323)](){let n=t,s=this[n(462)+n(1180)].reduce((d,u)=>(d+=u&&u.byteLength||0,d),0);return e[n(345)](s,this[n(1522)]?this[n(1522)][n(1131)+"Amount"]:0)}get[t(456)+"ns"](){let n=t;return this._ws?this[n(1522)][n(456)+"ns"]:""}get[t(813)](){let n=t;return e[n(1138)](n(1280),e[n(527)])?(this[n(1559)+n(302)+n(894)+"t"]=1,this[n(702)+"ndex"]++,this[n(692)+"s"][this["currentI"+n(253)]]):this[n(1522)]?this[n(1522)].protocol:""}get readyState(){let n=t;return this._ws?this._ws.readyState:this[n(308)]["automati"+n(1076)]?this[n(805)+"NG"]:this[n(1111)]}get[t(867)](){let n=t;return this._ws?this[n(1522)][n(867)]:this[n(1474)]}[t(1305)](n=1e3,s){let d=t,u=e[d(300)][d(626)]("|"),g=0;for(;;){switch(u[g++]){case"0":this[d(443)+d(1116)]();continue;case"1":if(!this[d(1522)])return void this._debug(e.Ibekc);continue;case"2":this._readyClosed=!0;continue;case"3":this[d(1592)+"mer"]();continue;case"4":this[d(297)+"WebSocket"](n,s);continue;case"5":this[d(1575)+d(1551)+d(225)]();continue;case"6":this[d(1150)+d(999)]?.[d(695)]();continue;case"7":if(this[d(1522)].readyState===this[d(1111)]||e[d(565)](this[d(1522)][d(283)+"te"],this[d(1073)]))return void this[d(1469)](e[d(1214)]);continue}break}}async[t(1505)](n,s){let d=t;if(n==null)throw new Error(e[d(1306)]);e.ugSfl(d(1095),typeof n)&&(n=JSON[d(1333)+"y"](n)),e[d(1220)](e.iFlND,typeof n)&&!e.zAzkg(n,ArrayBuffer)&&!(n[d(1421)]&&n[d(1421)]instanceof ArrayBuffer)&&(n=JSON[d(1333)+"y"](n));let u=await e[d(401)](Id,n),g=e[d(1623)](sx,n),{method:v=0,service:b=this[d(308)][d(330)],logID:p=this[d(308)]["logIDGen"+d(1515)](),headers:O=this[d(308)][d(508)],payloadEncoding:N=this[d(308)][d(525)+"ncoding"],payloadType:H=this[d(308)][d(1428)+d(318)],logIDNew:W=this[d(308)][d(858)+d(1053)]["enableAu"+d(973)+d(1555)+"ew"]?i(this[d(308)]["logIDNew"+d(1053)][d(799)]):""}=e[d(1118)](s,{});if(!b)throw new Error(e[d(461)]);let K={SeqID:se[d(975)+"er"](this[d(696)]++),LogID:se[d(975)+"er"](p),service:b,method:v,headers:O,payloadEncoding:e[d(939)](N,Object)?N[d(1379)]?N.encoding:"":N,payloadType:e[d(1490)](H,Object)?H.type?H[d(1072)]:g:H||g,payload:u,LogIDNew:W},Ae=Ke(K);if(this[d(1522)]&&e[d(1146)](this[d(1522)].readyState,this[d(1337)]))if(e[d(355)]===e[d(737)]){let Ve=_0x40286a(_0x11d707,_0x1e898b.limit),Ge=_0x461c77.bytes,Ne=_0x1c5e0b[d(560)];for(let rt=0,wn=_0x25c381[d(1193)];rt<wn;rt++)Ge[rt+Ve]=Ne[rt]}else this[d(1522)]&&this[d(1522)].send(Ae),this[d(1469)](e.eVzzR,K);else e[d(838)](this[d(462)+d(1180)].length,this[d(308)][d(1135)+"geQueueL"+d(272)])?(this[d(462)+d(1180)][d(489)](Ae),this._debug(e[d(977)],K)):(this[d(462)+d(1180)][d(1070)](),this[d(462)+d(1180)][d(489)](Ae));return{seqID:this._seqId,logID:p,logIDNew:W}}async[t(433)+"t"](n){let s=t,{url:d}=e[s(271)](n,{}),u=Array[s(494)](d)?d:e.ugSfl(e[s(652)],typeof d)?[d]:[];n&&Object[s(1476)](this[s(308)],n),u&&u.length?this[s(1585)+s(1025)]=new Ed(u,this._options[s(1129)+"es"]):this[s(1585)+s(1025)]?.["resetEnd"+s(1397)+s(1495)](),this[s(657)+s(220)]?.["resetCou"+s(1538)](this[s(308)][s(1068)+s(1536)]),this[s(765)+"osed"]=!1,this[s(1522)]&&this[s(1522)][s(283)+"te"]!==this.CLOSED?this[s(593)+s(285)](1e3,"manual r"+s(1627)+"ing",!0):(this._isInit=!0,this[s(517)]())}async[t(740)](){let n=t,s={LUHfW:e[n(478)],PjOCW:n(1125),iYjAX:e[n(595)],GlteF:e[n(257)],LKbAg:e[n(1178)],JutxQ:e[n(538)],uYcDo:e[n(1553)],zVRKh:function(d){return e[n(1303)](d)},JSWLD:function(d,u){return e[n(627)](d,u)}};if(!this[n(517)+n(865)])if(e[n(310)]!==e[n(310)]){let d=s[n(1373)][n(626)]("|"),u=0;for(;;){switch(d[u++]){case"0":_0x5eaa6e=[uFcaJU[n(1535)],uFcaJU[n(1048)],uFcaJU.GlteF,n(1288)];continue;case"1":_0x4c89a1=[n(1151),uFcaJU[n(319)],n(899),uFcaJU[n(424)],uFcaJU[n(1130)]];continue;case"2":uFcaJU.zVRKh(_0x383ffe);continue;case"3":_0x44eff1=new _0x466e7a;continue;case"4":uFcaJU.JSWLD(_0x4bd259,g=>({...g,get:(v,b,p)=>_0x4f5a9e(v,b)||g[n(1151)](v,b,p),has:(v,b)=>!!_0x383890(v,b)||g[n(548)](v,b)}));continue;case"5":uFcaJU.zVRKh(_0x294f4f);continue}break}}else{let d=e[n(223)][n(626)]("|"),u=0;for(;;){switch(d[u++]){case"0":this["_pingLos"+n(220)]?.[n(829)+n(1538)]();continue;case"1":this[n(517)]();continue;case"2":this[n(468)]=!0;continue;case"3":this["_readyCl"+n(1422)]=!1;continue;case"4":this[n(1585)+n(1025)]?.[n(908)+n(1397)+n(1495)]();continue}break}}}addEventListener(n,s){this.on(n,s)}[t(747)+"Event"](n){let s=t,{type:d}=n;this[s(1377)](d,n)}[t(1044)+"entListe"+t(1194)](n,s){this[t(731)](n,s)}[t(654)](){return new Promise((n,s)=>{let d=$,u={ITTOZ:function(b,p){return e[$(739)](b,p)},tcSPJ:e.iGIhe,UWjVD:e.TxeKr,wOAcl:e[d(770)],oWttJ:e.wfzbn};this[d(443)+d(1116)](),this[d(762)+"gTimeoutId"]=e[d(768)](setTimeout,this[d(1281)][d(874)](this),this[d(308)][d(1514)+"rval"]);let g=()=>{let b=d;u.ITTOZ(n,u[b(1293)]),this[b(731)](b(528)+"e_success",g),this[b(731)](u[b(1448)],v)},v=()=>{let b=d;u.ITTOZ(s,u[b(492)]),this.off(u.oWttJ,g),this.off("ping_onc"+b(610)+"t",v)};this.on(e[d(1270)],g),this.on(e.TxeKr,v),this._ping()})}}})(),ve["CustomCl"+M(1247)]=_e[M(950)+M(1247)],ve.CustomErrorEvent=_e[M(919)+M(907)],ve[M(307)+"e"]=_e[M(307)+"e"],ve[M(1566)]=_e[M(1566)],ve.FWS=_e.FWS,ve["FrontierMessageE"+M(358)]=_e[M(1339)+M(219)+"vent"],ve[M(219)+M(358)]=_e[M(219)+M(358)],ve[M(687)+"t"]=_e.OpenEvent,ve["Reconnec"+M(314)]=_e[M(562)+M(314)],ve["createCl"+M(1247)]=_e[M(509)+M(1247)],ve[M(312)+"rorEvent"]=_e["createEr"+M(907)],ve[M(1321)+M(1159)+"nt"]=_e[M(1321)+M(1159)+"nt"],ve[M(311)+M(1016)]=_e[M(311)+M(1016)],ve[M(1217)+M(1444)+M(358)]=_e[M(1217)+M(1444)+M(358)],ve[M(1625)+M(570)]=_e[M(1625)+M(570)],ve[M(1007)+M(1598)]=_e[M(1007)+M(1598)];for(Qs in _e)["CustomCloseEvent",M(919)+M(907),"ErrorCode",M(1566),M(1179),M(1339)+M(219)+M(358),M(219)+M(358),"OpenEvent",M(562)+M(314),M(509)+"oseEvent","createEr"+M(907),M(1321)+M(1159)+"nt",M(311)+"enEvent","createRe"+M(1444)+M(358),"decodedF"+M(570),"encodeFrame"].indexOf(Qs)===-1&&(ve[Qs]=_e[Qs]);var Qs;Object[M(1383)+M(1537)](ve,M(916)+"le",{value:!0})});var Ut=te((wA,gu)=>{"use strict";var xu=["nodebuffer","arraybuffer","fragments"],pu=typeof Blob<"u";pu&&xu.push("blob");gu.exports={BINARY_TYPES:xu,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:pu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var vi=te((yA,oo)=>{"use strict";var{EMPTY_BUFFER:h_}=Ut(),Tc=Buffer[Symbol.species];function x_(t,e){if(t.length===0)return h_;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new Tc(r.buffer,r.byteOffset,i):r}function mu(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function wu(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function p_(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Cc(t){if(Cc.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),Cc.readOnly=!1),e}oo.exports={concat:x_,mask:mu,toArrayBuffer:p_,toBuffer:Cc,unmask:wu};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=oe("bufferutil");oo.exports.mask=function(e,r,i,o,c){c<48?mu(e,r,i,o,c):t.mask(e,r,i,o,c)},oo.exports.unmask=function(e,r){e.length<32?wu(e,r):t.unmask(e,r)}}catch{}});var Eu=te((_A,_u)=>{"use strict";var yu=Symbol("kDone"),Rc=Symbol("kRun"),kc=class{constructor(e){this[yu]=()=>{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[yu])}}};_u.exports=kc});var Ir=te((EA,Iu)=>{"use strict";var Si=oe("zlib"),bu=vi(),g_=Eu(),{kStatusCode:vu}=Ut(),m_=Buffer[Symbol.species],w_=Buffer.from([0,0,255,255]),co=Symbol("permessage-deflate"),Ht=Symbol("total-length"),vr=Symbol("callback"),pn=Symbol("buffers"),Sr=Symbol("error"),ao,Dc=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 g_(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[vr];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,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}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(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){ao.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){ao.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Si.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[co]=this,this._inflate[Ht]=0,this._inflate[pn]=[],this._inflate.on("error",__),this._inflate.on("data",Su)}this._inflate[vr]=i,this._inflate.write(e),r&&this._inflate.write(w_),this._inflate.flush(()=>{let c=this._inflate[Sr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=bu.concat(this._inflate[pn],this._inflate[Ht]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ht]=0,this._inflate[pn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Si.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Ht]=0,this._deflate[pn]=[],this._deflate.on("data",y_)}this._deflate[vr]=i,this._deflate.write(e),this._deflate.flush(Si.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=bu.concat(this._deflate[pn],this._deflate[Ht]);r&&(c=new m_(c.buffer,c.byteOffset,c.length-4)),this._deflate[vr]=null,this._deflate[Ht]=0,this._deflate[pn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};Iu.exports=Dc;function y_(t){this[pn].push(t),this[Ht]+=t.length}function Su(t){if(this[Ht]+=t.length,this[co]._maxPayload<1||this[Ht]<=this[co]._maxPayload){this[pn].push(t);return}this[Sr]=new RangeError("Max payload size exceeded"),this[Sr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Sr][vu]=1009,this.removeListener("data",Su),this.reset()}function __(t){if(this[co]._inflate=null,this[Sr]){this[vr](this[Sr]);return}t[vu]=1007,this[vr](t)}});var Ar=te((bA,lo)=>{"use strict";var{isUtf8:Au}=oe("buffer"),{hasBlob:E_}=Ut(),b_=[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 v_(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Oc(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 S_(t){return E_&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}lo.exports={isBlob:S_,isValidStatusCode:v_,isValidUTF8:Oc,tokenChars:b_};if(Au)lo.exports.isValidUTF8=function(t){return t.length<24?Oc(t):Au(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=oe("utf-8-validate");lo.exports.isValidUTF8=function(e){return e.length<32?Oc(e):t(e)}}catch{}});var Bc=te((vA,Pu)=>{"use strict";var{Writable:I_}=oe("stream"),Tu=Ir(),{BINARY_TYPES:A_,EMPTY_BUFFER:Cu,kStatusCode:T_,kWebSocket:C_}=Ut(),{concat:Pc,toArrayBuffer:R_,unmask:k_}=vi(),{isValidStatusCode:D_,isValidUTF8:Ru}=Ar(),fo=Buffer[Symbol.species],at=0,ku=1,Du=2,Ou=3,Lc=4,Nc=5,uo=6,Mc=class extends I_{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||A_[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[C_]=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=at}_write(e,r,i){if(this._opcode===8&&this._state==at)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new fo(i.buffer,i.byteOffset+e,i.length-e),new fo(i.buffer,i.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=r.length-e;e>=i.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new fo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case at:this.getInfo(e);break;case ku:this.getPayloadLength16(e);break;case Du:this.getPayloadLength64(e);break;case Ou:this.getMask();break;case Lc:this.getData(e);break;case Nc:case uo: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 o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let i=(r[0]&64)===64;if(i&&!this._extensions[Tu.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=ku:this._payloadLength===127?this._state=Du: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),i=r.readUInt32BE(0);if(i>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=i*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=Ou:this._state=Lc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Lc}getData(e){let r=Cu;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&&k_(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[Tu.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===at&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=at;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Pc(i,r):this._binaryType==="arraybuffer"?o=R_(Pc(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=at):(this._state=uo,setImmediate(()=>{this.emit("message",o,!0),this._state=at,this.startLoop(e)}))}else{let o=Pc(i,r);if(!this._skipUTF8Validation&&!Ru(o)){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",o,!1),this._state=at):(this._state=uo,setImmediate(()=>{this.emit("message",o,!1),this._state=at,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Cu),this.end();else{let i=e.readUInt16BE(0);if(!D_(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new fo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ru(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=at;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=at):(this._state=uo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=at,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[T_]=o,l}};Pu.exports=Mc});var Uc=te((IA,Mu)=>{"use strict";var{Duplex:SA}=oe("stream"),{randomFillSync:O_}=oe("crypto"),Lu=Ir(),{EMPTY_BUFFER:P_,kWebSocket:L_,NOOP:N_}=Ut(),{isBlob:Tr,isValidStatusCode:M_}=Ar(),{mask:Nu,toBuffer:Ln}=vi(),ct=Symbol("kByteLength"),B_=Buffer.alloc(4),ho=8*1024,Nn,Cr=ho,gt=0,z_=1,F_=2,zc=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=gt,this.onerror=N_,this[L_]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||B_,r.generateMask?r.generateMask(i):(Cr===ho&&(Nn===void 0&&(Nn=Buffer.alloc(ho)),O_(Nn,0,ho),Cr=0),i[0]=Nn[Cr++],i[1]=Nn[Cr++],i[2]=Nn[Cr++],i[3]=Nn[Cr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let f;typeof e=="string"?(!r.mask||l)&&r[ct]!==void 0?f=r[ct]:(e=Buffer.from(e),f=e.length):(f=e.length,o=r.mask&&r.readOnly&&!l);let h=f;f>=65536?(c+=8,h=127):f>125&&(c+=2,h=126);let x=Buffer.allocUnsafe(o?f+c:c);return x[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(x[0]|=64),x[1]=h,h===126?x.writeUInt16BE(f,2):h===127&&(x[2]=x[3]=0,x.writeUIntBE(f,4,6)),r.mask?(x[1]|=128,x[c-4]=i[0],x[c-3]=i[1],x[c-2]=i[2],x[c-1]=i[3],l?[x,e]:o?(Nu(e,i,x,c,f),[x]):(Nu(e,i,e,0,f),[x,e])):[x,e]}close(e,r,i,o){let c;if(e===void 0)c=P_;else{if(typeof e!="number"||!M_(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 f=Buffer.byteLength(r);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+f),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let l={[ct]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==gt?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Tr(e)?(o=e.size,c=!1):(e=Ln(e),o=e.length,c=Ln.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ct]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Tr(e)?this._state!==gt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==gt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Tr(e)?(o=e.size,c=!1):(e=Ln(e),o=e.length,c=Ln.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ct]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Tr(e)?this._state!==gt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==gt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[Lu.extensionName],c=r.binary?2:1,l=r.compress,f,h;typeof e=="string"?(f=Buffer.byteLength(e),h=!1):Tr(e)?(f=e.size,h=!1):(e=Ln(e),f=e.length,h=Ln.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=f>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let x={[ct]:f,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:h,rsv1:l};Tr(e)?this._state!==gt?this.enqueue([this.getBlobData,e,this._compress,x,i]):this.getBlobData(e,this._compress,x,i):this._state!==gt?this.enqueue([this.dispatch,e,this._compress,x,i]):this.dispatch(e,this._compress,x,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ct],this._state=F_,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Fc,this,f,o);return}this._bufferedBytes-=i[ct];let l=Ln(c);r?this.dispatch(l,r,i,o):(this._state=gt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(U_,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Lu.extensionName];this._bufferedBytes+=i[ct],this._state=z_,c.compress(e,i.fin,(l,f)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");Fc(this,h,o);return}this._bufferedBytes-=i[ct],this._state=gt,i.readOnly=!1,this.sendFrame(t.frame(f,i),o),this.dequeue()})}dequeue(){for(;this._state===gt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ct],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ct],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)}};Mu.exports=zc;function Fc(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function U_(t,e,r){Fc(t,e,r),t.onerror(e)}});var Wu=te((AA,ju)=>{"use strict";var{kForOnEventAttribute:Ii,kListener:Hc}=Ut(),Bu=Symbol("kCode"),zu=Symbol("kData"),Fu=Symbol("kError"),Uu=Symbol("kMessage"),Hu=Symbol("kReason"),Rr=Symbol("kTarget"),qu=Symbol("kType"),Gu=Symbol("kWasClean"),qt=class{constructor(e){this[Rr]=null,this[qu]=e}get target(){return this[Rr]}get type(){return this[qu]}};Object.defineProperty(qt.prototype,"target",{enumerable:!0});Object.defineProperty(qt.prototype,"type",{enumerable:!0});var Mn=class extends qt{constructor(e,r={}){super(e),this[Bu]=r.code===void 0?0:r.code,this[Hu]=r.reason===void 0?"":r.reason,this[Gu]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Bu]}get reason(){return this[Hu]}get wasClean(){return this[Gu]}};Object.defineProperty(Mn.prototype,"code",{enumerable:!0});Object.defineProperty(Mn.prototype,"reason",{enumerable:!0});Object.defineProperty(Mn.prototype,"wasClean",{enumerable:!0});var kr=class extends qt{constructor(e,r={}){super(e),this[Fu]=r.error===void 0?null:r.error,this[Uu]=r.message===void 0?"":r.message}get error(){return this[Fu]}get message(){return this[Uu]}};Object.defineProperty(kr.prototype,"error",{enumerable:!0});Object.defineProperty(kr.prototype,"message",{enumerable:!0});var Ai=class extends qt{constructor(e,r={}){super(e),this[zu]=r.data===void 0?null:r.data}get data(){return this[zu]}};Object.defineProperty(Ai.prototype,"data",{enumerable:!0});var H_={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Ii]&&o[Hc]===e&&!o[Ii])return;let i;if(t==="message")i=function(c,l){let f=new Ai("message",{data:l?c:c.toString()});f[Rr]=this,xo(e,this,f)};else if(t==="close")i=function(c,l){let f=new Mn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Rr]=this,xo(e,this,f)};else if(t==="error")i=function(c){let l=new kr("error",{error:c,message:c.message});l[Rr]=this,xo(e,this,l)};else if(t==="open")i=function(){let c=new qt("open");c[Rr]=this,xo(e,this,c)};else return;i[Ii]=!!r[Ii],i[Hc]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Hc]===e&&!r[Ii]){this.removeListener(t,r);break}}};ju.exports={CloseEvent:Mn,ErrorEvent:kr,Event:qt,EventTarget:H_,MessageEvent:Ai};function xo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var po=te((TA,Ku)=>{"use strict";var{tokenChars:Ti}=Ar();function Dt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function q_(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,f,h=-1,x=-1,m=-1,_=0;for(;_<t.length;_++)if(x=t.charCodeAt(_),l===void 0)if(m===-1&&Ti[x]===1)h===-1&&(h=_);else if(_!==0&&(x===32||x===9))m===-1&&h!==-1&&(m=_);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${_}`);m===-1&&(m=_);let y=t.slice(h,m);x===44?(Dt(e,y,r),r=Object.create(null)):l=y,h=m=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(f===void 0)if(m===-1&&Ti[x]===1)h===-1&&(h=_);else if(x===32||x===9)m===-1&&h!==-1&&(m=_);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${_}`);m===-1&&(m=_),Dt(r,t.slice(h,m),!0),x===44&&(Dt(e,l,r),r=Object.create(null),l=void 0),h=m=-1}else if(x===61&&h!==-1&&m===-1)f=t.slice(h,_),h=m=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(o){if(Ti[x]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);h===-1?h=_:i||(i=!0),o=!1}else if(c)if(Ti[x]===1)h===-1&&(h=_);else if(x===34&&h!==-1)c=!1,m=_;else if(x===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(x===34&&t.charCodeAt(_-1)===61)c=!0;else if(m===-1&&Ti[x]===1)h===-1&&(h=_);else if(h!==-1&&(x===32||x===9))m===-1&&(m=_);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${_}`);m===-1&&(m=_);let y=t.slice(h,m);i&&(y=y.replace(/\\/g,""),i=!1),Dt(r,f,y),x===44&&(Dt(e,l,r),r=Object.create(null),l=void 0),f=void 0,h=m=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(h===-1||c||x===32||x===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=_);let A=t.slice(h,m);return l===void 0?Dt(e,A,r):(f===void 0?Dt(r,A,!0):i?Dt(r,f,A.replace(/\\/g,"")):Dt(r,f,A),Dt(e,l,r)),e}function G_(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ku.exports={format:G_,parse:q_}});var yo=te((kA,ih)=>{"use strict";var j_=oe("events"),W_=oe("https"),K_=oe("http"),Ju=oe("net"),$_=oe("tls"),{randomBytes:V_,createHash:J_}=oe("crypto"),{Duplex:CA,Readable:RA}=oe("stream"),{URL:qc}=oe("url"),gn=Ir(),Z_=Bc(),Y_=Uc(),{isBlob:X_}=Ar(),{BINARY_TYPES:$u,CLOSE_TIMEOUT:Q_,EMPTY_BUFFER:go,GUID:e1,kForOnEventAttribute:Gc,kListener:t1,kStatusCode:n1,kWebSocket:Pe,NOOP:Zu}=Ut(),{EventTarget:{addEventListener:r1,removeEventListener:i1}}=Wu(),{format:s1,parse:o1}=po(),{toBuffer:a1}=vi(),Yu=Symbol("kAborted"),jc=[8,13],Gt=["CONNECTING","OPEN","CLOSING","CLOSED"],c1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ce=class t extends j_{constructor(e,r,i){super(),this._binaryType=$u[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?(i=r,r=[]):r=[r]),Xu(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){$u.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,i){let o=new Z_({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new Y_(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Pe]=this,c[Pe]=this,e[Pe]=this,o.on("conclude",f1),o.on("drain",u1),o.on("error",h1),o.on("message",x1),o.on("ping",p1),o.on("pong",g1),c.onerror=m1,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",th),e.on("data",wo),e.on("end",nh),e.on("error",rh),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[gn.extensionName]&&this._extensions[gn.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){et(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,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),eh(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Wc(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||go,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Wc(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||go,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Wc(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[gn.extensionName]||(o.compress=!1),this._sender.send(e||go,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){et(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(ce,"CONNECTING",{enumerable:!0,value:Gt.indexOf("CONNECTING")});Object.defineProperty(ce.prototype,"CONNECTING",{enumerable:!0,value:Gt.indexOf("CONNECTING")});Object.defineProperty(ce,"OPEN",{enumerable:!0,value:Gt.indexOf("OPEN")});Object.defineProperty(ce.prototype,"OPEN",{enumerable:!0,value:Gt.indexOf("OPEN")});Object.defineProperty(ce,"CLOSING",{enumerable:!0,value:Gt.indexOf("CLOSING")});Object.defineProperty(ce.prototype,"CLOSING",{enumerable:!0,value:Gt.indexOf("CLOSING")});Object.defineProperty(ce,"CLOSED",{enumerable:!0,value:Gt.indexOf("CLOSED")});Object.defineProperty(ce.prototype,"CLOSED",{enumerable:!0,value:Gt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(ce.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(ce.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Gc])return e[t1];return null},set(e){for(let r of this.listeners(t))if(r[Gc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Gc]:!0})}})});ce.prototype.addEventListener=r1;ce.prototype.removeEventListener=i1;ih.exports=ce;function Xu(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Q_,protocolVersion:jc[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,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=o.autoPong,t._closeTimeout=o.closeTimeout,!jc.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${jc.join(", ")})`);let c;if(e instanceof qc)c=e;else try{c=new qc(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 l=c.protocol==="wss:",f=c.protocol==="ws+unix:",h;if(c.protocol!=="ws:"&&!l&&!f?h=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!c.pathname?h="The URL's pathname is empty":c.hash&&(h="The URL contains a fragment identifier"),h){let S=new SyntaxError(h);if(t._redirects===0)throw S;mo(t,S);return}let x=l?443:80,m=V_(16).toString("base64"),_=l?W_.request:K_.request,A=new Set,y;if(o.createConnection=o.createConnection||(l?l1:d1),o.defaultPort=o.defaultPort||x,o.port=c.port||x,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(y=new gn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=s1({[gn.extensionName]:y.offer()})),r.length){for(let S of r){if(typeof S!="string"||!c1.test(S)||A.has(S))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(S)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),f){let S=o.path.split(":");o.socketPath=S[0],o.path=S[1]}let E;if(o.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=l,t._originalHostOrSocketPath=f?o.socketPath:c.host;let S=i&&i.headers;if(i={...i,headers:{}},S)for(let[I,R]of Object.entries(S))i.headers[I.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let S=f?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!S||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,S||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),E=t._req=_(o),t._redirects&&t.emit("redirect",t.url,E)}else E=t._req=_(o);o.timeout&&E.on("timeout",()=>{et(t,E,"Opening handshake has timed out")}),E.on("error",S=>{E===null||E[Yu]||(E=t._req=null,mo(t,S))}),E.on("response",S=>{let I=S.headers.location,R=S.statusCode;if(I&&o.followRedirects&&R>=300&&R<400){if(++t._redirects>o.maxRedirects){et(t,E,"Maximum redirects exceeded");return}E.abort();let P;try{P=new qc(I,e)}catch{let T=new SyntaxError(`Invalid URL: ${I}`);mo(t,T);return}Xu(t,P,r,i)}else t.emit("unexpected-response",E,S)||et(t,E,`Unexpected server response: ${S.statusCode}`)}),E.on("upgrade",(S,I,R)=>{if(t.emit("upgrade",S),t.readyState!==ce.CONNECTING)return;E=t._req=null;let P=S.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){et(t,I,"Invalid Upgrade header");return}let w=J_("sha1").update(m+e1).digest("base64");if(S.headers["sec-websocket-accept"]!==w){et(t,I,"Invalid Sec-WebSocket-Accept header");return}let T=S.headers["sec-websocket-protocol"],k;if(T!==void 0?A.size?A.has(T)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":A.size&&(k="Server sent no subprotocol"),k){et(t,I,k);return}T&&(t._protocol=T);let z=S.headers["sec-websocket-extensions"];if(z!==void 0){if(!y){et(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=o1(z)}catch{et(t,I,"Invalid Sec-WebSocket-Extensions header");return}let D=Object.keys(B);if(D.length!==1||D[0]!==gn.extensionName){et(t,I,"Server indicated an extension that was not requested");return}try{y.accept(B[gn.extensionName])}catch{et(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[gn.extensionName]=y}t.setSocket(I,R,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(E,t):E.end()}function mo(t,e){t._readyState=ce.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function d1(t){return t.path=t.socketPath,Ju.connect(t)}function l1(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ju.isIP(t.host)?"":t.host),$_.connect(t)}function et(t,e,r){t._readyState=ce.CLOSING;let i=new Error(r);Error.captureStackTrace(i,et),e.setHeader?(e[Yu]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(mo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Wc(t,e,r){if(e){let i=X_(e)?e.size:a1(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Gt[t.readyState]})`);process.nextTick(r,i)}}function f1(t,e){let r=this[Pe];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Pe]!==void 0&&(r._socket.removeListener("data",wo),process.nextTick(Qu,r._socket),t===1005?r.close():r.close(t,e))}function u1(){let t=this[Pe];t.isPaused||t._socket.resume()}function h1(t){let e=this[Pe];e._socket[Pe]!==void 0&&(e._socket.removeListener("data",wo),process.nextTick(Qu,e._socket),e.close(t[n1])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Vu(){this[Pe].emitClose()}function x1(t,e){this[Pe].emit("message",t,e)}function p1(t){let e=this[Pe];e._autoPong&&e.pong(t,!this._isServer,Zu),e.emit("ping",t)}function g1(t){this[Pe].emit("pong",t)}function Qu(t){t.resume()}function m1(t){let e=this[Pe];e.readyState!==ce.CLOSED&&(e.readyState===ce.OPEN&&(e._readyState=ce.CLOSING,eh(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function eh(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function th(){let t=this[Pe];if(this.removeListener("close",th),this.removeListener("data",wo),this.removeListener("end",nh),t._readyState=ce.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[Pe]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Vu),t._receiver.on("finish",Vu))}function wo(t){this[Pe]._receiver.write(t)||this.pause()}function nh(){let t=this[Pe];t._readyState=ce.CLOSING,t._receiver.end(),this.end()}function rh(){let t=this[Pe];this.removeListener("error",rh),this.on("error",Zu),t&&(t._readyState=ce.CLOSING,this.destroy())}});var ch=te((OA,ah)=>{"use strict";var DA=yo(),{Duplex:w1}=oe("stream");function sh(t){t.emit("close")}function y1(){!this.destroyed&&this._writableState.finished&&this.destroy()}function oh(t){this.removeListener("error",oh),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function _1(t,e){let r=!0,i=new w1({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let f=!l&&i._readableState.objectMode?c.toString():c;i.push(f)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(sh,i);return}let l=!1;t.once("error",function(h){l=!0,c(h)}),t.once("close",function(){l||c(o),process.nextTick(sh,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,l){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,l)});return}t.send(o,l)},i.on("end",y1),i.on("error",oh),i}ah.exports=_1});var Kc=te((PA,dh)=>{"use strict";var{tokenChars:E1}=Ar();function b1(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let l=t.charCodeAt(o);if(i===-1&&E1[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let f=t.slice(r,i);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}dh.exports={parse:b1}});var gh=te((NA,ph)=>{"use strict";var v1=oe("events"),_o=oe("http"),{Duplex:LA}=oe("stream"),{createHash:S1}=oe("crypto"),lh=po(),Bn=Ir(),I1=Kc(),A1=yo(),{CLOSE_TIMEOUT:T1,GUID:C1,kWebSocket:R1}=Ut(),k1=/^[+/0-9A-Za-z]{22}==$/,fh=0,uh=1,xh=2,$c=class extends v1{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:T1,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:A1,...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=_o.createServer((i,o)=>{let c=_o.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=D1(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,l)=>{this.handleUpgrade(o,c,l,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=fh}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===xh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ci,this);return}if(e&&this.once("close",e),this._state!==uh)if(this._state=uh,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(Ci,this):process.nextTick(Ci,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ci(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,i,o){r.on("error",hh);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){zn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){zn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!k1.test(c)){zn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){zn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ri(r,400);return}let h=e.headers["sec-websocket-protocol"],x=new Set;if(h!==void 0)try{x=I1.parse(h)}catch{zn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&m!==void 0){let A=new Bn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=lh.parse(m);y[Bn.extensionName]&&(A.accept(y[Bn.extensionName]),_[Bn.extensionName]=A)}catch{zn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(y,E,S,I)=>{if(!y)return Ri(r,E||401,S,I);this.completeUpgrade(_,c,x,e,r,i,o)});return}if(!this.options.verifyClient(A))return Ri(r,401)}this.completeUpgrade(_,c,x,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,f){if(!c.readable||!c.writable)return c.destroy();if(c[R1])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>fh)return Ri(c,503);let x=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${S1("sha1").update(r+C1).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(i.size){let _=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;_&&(x.push(`Sec-WebSocket-Protocol: ${_}`),m._protocol=_)}if(e[Bn.extensionName]){let _=e[Bn.extensionName].params,A=lh.format({[Bn.extensionName]:[_]});x.push(`Sec-WebSocket-Extensions: ${A}`),m._extensions=e}this.emit("headers",x,o),c.write(x.concat(`\r
|
|
8
|
+
var Hh=Object.create;var Ko=Object.defineProperty;var jh=Object.getOwnPropertyDescriptor;var Gh=Object.getOwnPropertyNames;var Wh=Object.getPrototypeOf,Kh=Object.prototype.hasOwnProperty;var ce=(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 rt=(t,e)=>()=>(t&&(e=t(t=0)),e);var re=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),$o=(t,e)=>{for(var r in e)Ko(t,r,{get:e[r],enumerable:!0})},$h=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Gh(e))!Kh.call(t,a)&&a!==r&&Ko(t,a,{get:()=>e[a],enumerable:!(s=jh(e,a))||s.enumerable});return t};var mt=(t,e,r)=>(r=t!=null?Hh(Wh(t)):{},$h(e||!t||!t.__esModule?Ko(r,"default",{value:t,enumerable:!0}):r,t));function L0(t){Zo=t}function P0(t){return Mi[Zo]<=Mi[t]}function Bi(t){k0={...t}}function Jh(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 Ni(t,e,r,s){if(Mi[t]<Mi[Zo])return;let a=JSON.stringify({ts:Jh(new Date),level:t,module:e,msg:r,...k0,...s});t==="error"||t==="warn"?Vh.write(`${a}
|
|
9
|
+
`):Zh.write(`${a}
|
|
10
|
+
`)}function H(t){return{debug:(e,r)=>Ni("debug",t,e,r),info:(e,r)=>Ni("info",t,e,r),warn:(e,r)=>Ni("warn",t,e,r),error:(e,r)=>Ni("error",t,e,r),child:e=>H(`${t}.${e}`)}}var Mi,Zo,Zh,Vh,k0,te=rt(()=>{"use strict";Mi={debug:10,info:20,warn:30,error:40},Zo=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Zh=process.stdout,Vh=process.stderr,k0={}});import{execFile as Yh,spawn as Xh,spawnSync as iv}from"node:child_process";import{promisify as Qh}from"node:util";function tp(t){if(process.platform!=="win32")return!1;if(O0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(O0,"").toLowerCase();return ep.has(r)}function N0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return tp(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function Vt(t,e=[],r={}){return Xh(t,e,N0(t,r))}function zi(t,e=[],r={}){return np(t,e,N0(t,r))}var ep,O0,np,Gn=rt(()=>{"use strict";ep=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp"]),O0=/\.(cmd|bat|ps1)$/i;np=Qh(Yh)});var T,We=rt(()=>{"use strict";T=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)}}});var q0={};$o(q0,{_resetAcpInstallerForTests:()=>up,_resetInstallTimeoutsForTests:()=>fp,_setBinaryPathCacheForTests:()=>hp,_setInFlightForTests:()=>xp,_setInstallTimeoutsForTests:()=>dp,buildInstallFailureMessage:()=>U0,ensureAcpInstalled:()=>$n,formatExecError:()=>z0,getAcpBinaryPath:()=>Mr,getAcpPackageSpec:()=>ap,getInFlightInstall:()=>Yo,npmInstallGlobal:()=>F0,pickWhichLine:()=>qi,probeAcpVersion:()=>lp,resolveAcpCommand:()=>Br});import{readFile as rp,realpath as ip,stat as sp}from"node:fs/promises";import{dirname as Vo,join as op}from"node:path";function ap(t){let e=Jo[t];if(e)return`${e.npmPackage}@${e.versionSpec}`}function dp(t,e){Fi=t,Ui=e}function fp(){Fi=5e4,Ui=5e3}function z0(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 M0(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await zi(e,[t],{timeout:cp});return qi(r)}catch{return}}function qi(t){let e=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=s=>e.find(a=>a.toLowerCase().endsWith(s));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}async function lp(t){let e=Jo[t];if(!e)return;let r=Mr(t);if(!r){He.warn("acp wrapper probe: binary path cache empty",{framework:t,binary:e.binary,hint:"ensureAcpInstalled \u6CA1\u8DD1\u8FC7 / \u88C5\u5931\u8D25 / \u4E4B\u524D negative cache 5min \u5185"});return}let s;try{s=await ip(r)}catch(c){He.warn("acp wrapper probe: realpath failed (symlink target \u4E0D\u5B58\u5728?)",{framework:t,binaryPath:r,err:String(c)});return}let a=Vo(s);for(let c=0;c<B0;c++){let f=op(a,"package.json");try{if(!(await sp(f)).isFile()){a=Vo(a);continue}let p=await rp(f,"utf8"),_=JSON.parse(p);if(_.name===e.npmPackage){if(typeof _.version=="string"&&_.version.length>0)return _.version;He.warn("acp wrapper probe: package.json \u627E\u5230\u4F46 version \u5B57\u6BB5\u7F3A",{framework:t,packageJsonPath:f});return}}catch(x){let p=x;p.code!=="ENOENT"&&He.warn("acp wrapper probe: package.json \u8BFB\u53D6\u5F02\u5E38",{framework:t,candidate:f,errCode:p?.code,err:String(x)})}let u=Vo(a);if(u===a)break;a=u}He.warn("acp wrapper probe: \u627E\u4E0D\u5230\u5339\u914D name \u7684 package.json (\u4E0A\u6EAF\u5230 max depth)",{framework:t,binaryPath:r,realBinary:s,expectedName:e.npmPackage,maxDepth:B0})}async function F0(t,e,r){let s=`${t}@${e}`;He.info("npm install -g start",{npmPackage:t,versionSpec:e});let a=Date.now(),c=process.platform==="win32";return new Promise((f,u)=>{let x=Vt("npm",["install","-g",s],{stdio:["ignore","pipe","pipe"],...c?{}:{detached:!0}});if(!x.pid){u(new Error(`failed to spawn npm: no pid (npmPackage=${t})`));return}let p=x.pid,_=10*1024*1024,E=[],C=[],y=0,b=0;x.stdout?.on("data",A=>{y+=A.length,y<_&&E.push(A)}),x.stderr?.on("data",A=>{b+=A.length,b<_&&C.push(A)});let S="running",I,R=A=>{try{return c?x.kill(A):process.kill(-p,A),!0}catch(D){return He.warn("npm install: kill failed (process already dead?)",{npmPackage:t,pid:p,sig:A,err:String(D)}),!1}},P=setTimeout(()=>{S="terminating",He.warn("npm install timeout, sending SIGTERM to process group",{npmPackage:t,versionSpec:e,pid:p,elapsedMs:Date.now()-a,timeoutMs:Fi,graceMs:Ui,stdoutBytes:y,stderrBytes:b}),R("SIGTERM"),I=setTimeout(()=>{S="killing",He.warn("npm install SIGTERM grace expired, escalating to SIGKILL",{npmPackage:t,versionSpec:e,pid:p,elapsedMs:Date.now()-a,stdoutBytes:y,stderrBytes:b}),R("SIGKILL")},Ui)},Fi),w=()=>{S="aborted",He.warn("npm install externally aborted, sending SIGKILL to process group",{npmPackage:t,versionSpec:e,pid:p,elapsedMs:Date.now()-a}),R("SIGKILL")};r&&(r.aborted?w():r.addEventListener("abort",w,{once:!0})),x.on("error",A=>{clearTimeout(P),I&&clearTimeout(I),r?.removeEventListener("abort",w),He.warn("npm install spawn error",{npmPackage:t,versionSpec:e,pid:p,err:String(A)}),u(new Error(`spawn npm failed: ${String(A)}`))}),x.on("close",(A,D)=>{clearTimeout(P),I&&clearTimeout(I),r?.removeEventListener("abort",w);let z=Buffer.concat(E).toString("utf8"),B=Buffer.concat(C).toString("utf8"),k=Date.now()-a;if(A===0&&S==="running"){He.info("npm install -g done",{npmPackage:t,versionSpec:e,elapsedMs:k}),f();return}He.warn("npm install -g exited non-success",{npmPackage:t,versionSpec:e,pid:p,phase:S,exitCode:A,signal:D,elapsedMs:k,stdoutBytes:y,stderrBytes:b});let M=Object.assign(new Error(`Command failed: npm install -g ${s}`+(D?` (killed by ${D})`:"")+(A!==null?` (exit ${A})`:"")+(S!=="running"?` (phase=${S})`:"")),{code:A,signal:D,stderr:B,stdout:z});u(M)})})}function U0(t){let{framework:e,npmPackage:r,versionSpec:s,command:a,reason:c,elapsedMs:f}=t;return["ACP wrapper \u5B89\u88C5\u5931\u8D25",`Framework: ${e}`,`Package: ${r}@${s}`,`\u6267\u884C\u547D\u4EE4: ${a}`,`\u5931\u8D25\u539F\u56E0: ${c}`,`\u8017\u65F6: ${f}ms`,"","\u6392\u67E5\u5EFA\u8BAE:"," 1. \u68C0\u67E5\u7F51\u7EDC: curl -v https://registry.npmjs.org"," 2. \u67E5\u770B\u5F53\u524D npm \u6E90: npm config get registry"," 3. \u56FD\u5185\u7F51\u7EDC\u5EFA\u8BAE\u5207\u955C\u50CF\u6E90:"," npm config set registry https://registry.npmmirror.com/"].join(`
|
|
11
|
+
`)}async function $n(t,e){let r=Jo[t];if(!r)throw new T("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let s=Wn.get(t);if(s)return s;let a=Kn.get(t);if(a)return a;let c=`npm install -g ${r.npmPackage}@${r.versionSpec}`,f=(x,p,_)=>new T("AGENT_DEPENDENCY_INSTALL_FAILED",U0({framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,command:c,reason:x,elapsedMs:p}),_!==void 0?{cause:_}:{}),u=(async()=>{let x=await M0(r.binary);if(x)return Wn.set(t,x),He.info("acp wrapper found on PATH",{binary:r.binary,path:x}),x;let p=Date.now();try{await F0(r.npmPackage,r.versionSpec,e)}catch(E){let C=z0(E);throw He.warn("acp wrapper install failed",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary,err:C}),f(C,Date.now()-p,E)}let _=await M0(r.binary);if(!_)throw He.warn("acp wrapper installed but binary not found on PATH",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary}),f(`npm install \u6210\u529F\u4F46 \`${process.platform==="win32"?"where":"which"} ${r.binary}\` \u627E\u4E0D\u5230 binary (npm prefix \u53EF\u80FD\u672A\u52A0\u5165 PATH, \u6216\u88AB\u88C5\u5230\u4E86 nvm/asdf \u522B\u7684\u7248\u672C\u4E0B)`,Date.now()-p);return Wn.set(t,_),_})().finally(()=>{Kn.delete(t)});return Kn.set(t,u),u}function Mr(t){return Wn.get(t)}function Br(t,e){if(e)return e;let r=Mr(t);if(!r)throw new T("BRIDGE_INTERNAL",`${t} ACP wrapper binary path cache miss (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function Yo(t){return Kn.get(t)}function up(){Wn.clear(),Kn.clear()}function xp(t,e){Kn.set(t,e)}function hp(t,e){Wn.set(t,e)}var He,Jo,Fi,Ui,cp,Wn,Kn,B0,wn=rt(()=>{"use strict";Gn();We();te();He=H("agents.acp-installer"),Jo={"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"}};Fi=5e4,Ui=5e3,cp=5e3;Wn=new Map,Kn=new Map;B0=6});import{chmod as gp,mkdir as mp,readFile as wp,rename as G0,writeFile as W0}from"node:fs/promises";import{dirname as _p}from"node:path";async function Zn(t){try{let e=await wp(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Hi(t,e,r){await mp(_p(t),{recursive:!0});let s=`${JSON.stringify(e,null,2)}
|
|
12
|
+
`,a=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await W0(a,s,{encoding:"utf8",mode:r.mode}):await W0(a,s,"utf8"),await G0(a,t),r?.mode!==void 0&&await gp(t,r.mode)}catch(c){await G0(a,a).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(a,{force:!0}).catch(()=>{}),c}}var ji=rt(()=>{"use strict"});import{promises as K0}from"node:fs";import{homedir as yp}from"node:os";import{sep as bp,join as ze,resolve as $0}from"node:path";function ne(t){let e=t??yp(),r=ze(e,".coze"),s=ze(r,"bridge"),a=ze(s,"lib");return{cozeRoot:r,bridgeRoot:s,libDir:a,libEntry:ze(a,"index.js"),binDir:ze(s,"bin"),pidFile:ze(s,"bridge.pid"),portFile:ze(s,"bridge.port"),tokenFile:ze(s,"bridge.token"),patTokenFile:ze(s,"pat-token"),logFile:ze(s,"bridge.log"),installLock:ze(s,"install.lock"),configFile:ze(s,"config.json"),agentsRoot:ze(r,"agents")}}function Lt(t,e=ne()){let r=ze(e.agentsRoot,t);return{root:r,config:ze(r,"config.json"),workspace:ze(r,"workspace"),logs:ze(r,"logs")}}async function zr(t,e){let r=await K0.realpath($0(t)).catch(()=>null);if(!r)return!1;let s=await K0.realpath($0(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+bp)}var Fe=rt(()=>{"use strict"});var Ki={};$o(Ki,{AGENT_CONFIG_FILE_MODE:()=>Gi,enforceAgentConfigMode:()=>Sp,loadAgentConfig:()=>je,persistAgentSessions:()=>Xo,persistAgentSkills:()=>Wi,saveAgentConfig:()=>Ve});import{chmod as Ep,stat as vp}from"node:fs/promises";function je(t,e){return Zn(Lt(t,e).config)}function Ve(t,e){return Hi(Lt(t.agentId,e).config,t,{mode:Gi})}async function Sp(t,e){if(process.platform==="win32")return;let r=Lt(t,e).config;try{let s=await vp(r);if(!s.isFile())return;let a=s.mode&511;a!==Gi&&(await Ep(r,Gi),Z0.warn("agent config mode auto-corrected to 0600",{path:r,from:a.toString(8)}))}catch(s){if(s.code==="ENOENT")return;Z0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(s)})}}async function Xo(t,e,r){let s=await je(t,r);s&&(s.sessions=Object.fromEntries(e),await Ve(s,r))}async function Wi(t,e,r){let s=await je(t,r);s&&(s.skills=e,await Ve(s,r))}var Z0,Gi,Jt=rt(()=>{"use strict";ji();te();Fe();Z0=H("agent-config"),Gi=384});var ea=re((Nv,X0)=>{X0.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 Zi=re(ed=>{var Q0={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 Rp(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(Q0))ed[t]=Rp(Q0[t])});var sd=re((Bv,id)=>{var Dp=ce("fs"),Ce=ce("path"),td=ea(),kp=Zi(),Lp=typeof process=="object"&&process.platform==="win32",nd=t=>typeof t=="object"&&t!==null,rd=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 me(t){this.sep=Ce.sep,this.fs=Dp,nd(t)&&nd(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}id.exports=me;me.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 kp.FILE_IN_THE_WAY(`"${a}"`)}})}r(t)};me.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=Ce.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};me.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 p=Ce.dirname(t);c.fs.exists(p,function(_){_||c.makeDir(p),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)})})})})})};me.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=Ce.join(s,u),p=e.fs.statSync(x);(!a||a.test(x))&&f.push(Ce.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(f=f.concat(r(x,a,c)))}),f}return r(t,void 0,!0)};me.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=Ce.join(t,u),r.fs.stat(u,function(x,p){if(x)return e(x);p&&(s.push(Ce.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(_,E){if(_)return e(_);s=s.concat(E),--f||e(null,s)}):--f||e(null,s))})})})};me.prototype.getAttributes=function(){};me.prototype.setAttributes=function(){};me.crc32update=function(t,e){return rd[(t^e)&255]^t>>>8};me.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let s=0;s<e;)r=me.crc32update(r,t[s++]);return~r>>>0};me.methodToString=function(t){switch(t){case td.STORED:return"STORED ("+t+")";case td.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};me.canonical=function(t){if(!t)return"";let e=Ce.posix.normalize("/"+t.split("\\").join("/"));return Ce.join(".",e)};me.zipnamefix=function(t){if(!t)return"";let e=Ce.posix.normalize("/"+t.split("\\").join("/"));return Ce.posix.join(".",e)};me.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]};me.sanitize=function(t,e){t=Ce.resolve(Ce.normalize(t));for(var r=e.split("/"),s=0,a=r.length;s<a;s++){var c=Ce.normalize(Ce.join(t,r.slice(s,a).join(Ce.sep)));if(c.indexOf(t)===0)return c}return Ce.normalize(Ce.join(t,Ce.basename(e)))};me.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};me.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};me.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)};me.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};me.isWin=Lp;me.crcTable=rd});var ad=re((zv,od)=>{var Pp=ce("path");od.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=Pp.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 dd=re((Fv,cd)=>{cd.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Yn=re((Uv,Jn)=>{Jn.exports=sd();Jn.exports.Constants=ea();Jn.exports.Errors=Zi();Jn.exports.FileAttr=ad();Jn.exports.decoder=dd()});var ld=re((qv,fd)=>{var Yt=Yn(),q=Yt.Constants;fd.exports=function(){var t=20,e=10,r=0,s=0,a=0,c=0,f=0,u=0,x=0,p=0,_=0,E=0,C=0,y=0,b=0;t|=Yt.isWin?2560:768,r|=q.FLG_EFS;let S={extraLen:0},I=w=>Math.max(0,w)>>>0,R=w=>Math.max(0,w)&65535,P=w=>Math.max(0,w)&255;return a=Yt.fromDate2DOS(new Date),{get made(){return t},set made(w){t=w},get version(){return e},set version(w){e=w},get flags(){return r},set flags(w){r=w},get flags_efs(){return(r&q.FLG_EFS)>0},set flags_efs(w){w?r|=q.FLG_EFS:r&=~q.FLG_EFS},get flags_desc(){return(r&q.FLG_DESC)>0},set flags_desc(w){w?r|=q.FLG_DESC:r&=~q.FLG_DESC},get method(){return s},set method(w){switch(w){case q.STORED:this.version=10;case q.DEFLATED:default:this.version=20}s=w},get time(){return Yt.fromDOS2Date(this.timeval)},set time(w){w=new Date(w),this.timeval=Yt.fromDate2DOS(w)},get timeval(){return a},set timeval(w){a=I(w)},get timeHighByte(){return P(a>>>8)},get crc(){return c},set crc(w){c=I(w)},get compressedSize(){return f},set compressedSize(w){f=I(w)},get size(){return u},set size(w){u=I(w)},get fileNameLength(){return x},set fileNameLength(w){x=w},get extraLength(){return p},set extraLength(w){p=w},get extraLocalLength(){return S.extraLen},set extraLocalLength(w){S.extraLen=w},get commentLength(){return _},set commentLength(w){_=w},get diskNumStart(){return E},set diskNumStart(w){E=I(w)},get inAttr(){return C},set inAttr(w){C=I(w)},get attr(){return y},set attr(w){y=I(w)},get fileAttr(){return(y||0)>>16&4095},get offset(){return b},set offset(w){b=I(w)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+p+_},get realDataOffset(){return b+q.LOCHDR+S.fnameLen+S.extraLen},get localHeader(){return S},loadLocalHeaderFromBinary:function(w){var A=w.slice(b,b+q.LOCHDR);if(A.readUInt32LE(0)!==q.LOCSIG)throw Yt.Errors.INVALID_LOC();S.version=A.readUInt16LE(q.LOCVER),S.flags=A.readUInt16LE(q.LOCFLG),S.flags_desc=(S.flags&q.FLG_DESC)>0,S.method=A.readUInt16LE(q.LOCHOW),S.time=A.readUInt32LE(q.LOCTIM),S.crc=A.readUInt32LE(q.LOCCRC),S.compressedSize=A.readUInt32LE(q.LOCSIZ),S.size=A.readUInt32LE(q.LOCLEN),S.fnameLen=A.readUInt16LE(q.LOCNAM),S.extraLen=A.readUInt16LE(q.LOCEXT);let D=b+q.LOCHDR+S.fnameLen,z=D+S.extraLen;return w.slice(D,z)},loadFromBinary:function(w){if(w.length!==q.CENHDR||w.readUInt32LE(0)!==q.CENSIG)throw Yt.Errors.INVALID_CEN();t=w.readUInt16LE(q.CENVEM),e=w.readUInt16LE(q.CENVER),r=w.readUInt16LE(q.CENFLG),s=w.readUInt16LE(q.CENHOW),a=w.readUInt32LE(q.CENTIM),c=w.readUInt32LE(q.CENCRC),f=w.readUInt32LE(q.CENSIZ),u=w.readUInt32LE(q.CENLEN),x=w.readUInt16LE(q.CENNAM),p=w.readUInt16LE(q.CENEXT),_=w.readUInt16LE(q.CENCOM),E=w.readUInt16LE(q.CENDSK),C=w.readUInt16LE(q.CENATT),y=w.readUInt32LE(q.CENATX),b=w.readUInt32LE(q.CENOFF)},localHeaderToBinary:function(){var w=Buffer.alloc(q.LOCHDR);return w.writeUInt32LE(q.LOCSIG,0),w.writeUInt16LE(e,q.LOCVER),w.writeUInt16LE(r,q.LOCFLG),w.writeUInt16LE(s,q.LOCHOW),w.writeUInt32LE(a,q.LOCTIM),w.writeUInt32LE(c,q.LOCCRC),w.writeUInt32LE(f,q.LOCSIZ),w.writeUInt32LE(u,q.LOCLEN),w.writeUInt16LE(x,q.LOCNAM),w.writeUInt16LE(S.extraLen,q.LOCEXT),w},centralHeaderToBinary:function(){var w=Buffer.alloc(q.CENHDR+x+p+_);return w.writeUInt32LE(q.CENSIG,0),w.writeUInt16LE(t,q.CENVEM),w.writeUInt16LE(e,q.CENVER),w.writeUInt16LE(r,q.CENFLG),w.writeUInt16LE(s,q.CENHOW),w.writeUInt32LE(a,q.CENTIM),w.writeUInt32LE(c,q.CENCRC),w.writeUInt32LE(f,q.CENSIZ),w.writeUInt32LE(u,q.CENLEN),w.writeUInt16LE(x,q.CENNAM),w.writeUInt16LE(p,q.CENEXT),w.writeUInt16LE(_,q.CENCOM),w.writeUInt16LE(E,q.CENDSK),w.writeUInt16LE(C,q.CENATT),w.writeUInt32LE(y,q.CENATX),w.writeUInt32LE(b,q.CENOFF),w},toJSON:function(){let w=function(A){return A+" bytes"};return{made:t,version:e,flags:r,method:Yt.methodToString(s),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:w(f),size:w(u),fileNameLength:w(x),extraLength:w(p),commentLength:w(_),diskNumStart:E,inAttr:C,attr:y,offset:b,centralHeaderSize:w(q.CENHDR+x+p+_)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var xd=re((Hv,ud)=>{var Xn=Yn(),xe=Xn.Constants;ud.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 xe.ENDHDR+a},loadFromBinary:function(c){if((c.length!==xe.ENDHDR||c.readUInt32LE(0)!==xe.ENDSIG)&&(c.length<xe.ZIP64HDR||c.readUInt32LE(0)!==xe.ZIP64SIG))throw Xn.Errors.INVALID_END();c.readUInt32LE(0)===xe.ENDSIG?(t=c.readUInt16LE(xe.ENDSUB),e=c.readUInt16LE(xe.ENDTOT),r=c.readUInt32LE(xe.ENDSIZ),s=c.readUInt32LE(xe.ENDOFF),a=c.readUInt16LE(xe.ENDCOM)):(t=Xn.readBigUInt64LE(c,xe.ZIP64SUB),e=Xn.readBigUInt64LE(c,xe.ZIP64TOT),r=Xn.readBigUInt64LE(c,xe.ZIP64SIZE),s=Xn.readBigUInt64LE(c,xe.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(xe.ENDHDR+a);return c.writeUInt32LE(xe.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,xe.ENDSUB),c.writeUInt16LE(e,xe.ENDTOT),c.writeUInt32LE(r,xe.ENDSIZ),c.writeUInt32LE(s,xe.ENDOFF),c.writeUInt16LE(a,xe.ENDCOM),c.fill(" ",xe.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 na=re(ta=>{ta.EntryHeader=ld();ta.MainHeader=xd()});var pd=re((Gv,hd)=>{hd.exports=function(t){var e=ce("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 p=0;p<c.length;p++){var _=c[p];_.copy(u,x),x+=_.length}s&&s(u)}),a.end(t)}}}});var md=re((Wv,gd)=>{var Op=+(process.versions?process.versions.node:"").split(".")[0]||0;gd.exports=function(t,e){var r=ce("zlib");let s=Op>=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),p=0;x.fill(0);for(var _=0;_<f.length;_++){var E=f[_];E.copy(x,p),p+=E.length}a&&a(x)}),c.end(t)}}}});var Ed=re((Kv,bd)=>{"use strict";var{randomFillSync:wd}=ce("crypto"),Np=Zi(),Mp=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}),yd=(t,e)=>Math.imul(t,e)>>>0,_d=(t,e)=>Mp[(t^e)&255]^t>>>8,Fr=()=>typeof wd=="function"?wd(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 Vi={genSalt:Fr};function Ji(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])}Ji.prototype.updateKeys=function(t){let e=this.keys;return e[0]=_d(e[0],t),e[1]+=e[0]&255,e[1]=yd(e[1],134775813)+1,e[2]=_d(e[2],e[1]>>>24),t};Ji.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return yd(t,t^1)>>8&255};function Bp(t){let e=new Ji(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 zp(t){let e=new Ji(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 Fp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let s=Bp(r),a=s(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw Np.WRONG_PASSWORD();return s(t.slice(12))}function Up(t){Buffer.isBuffer(t)&&t.length>=12?Vi.genSalt=function(){return t.slice(0,12)}:t==="node"?Vi.genSalt=Fr.node:Vi.genSalt=Fr}function qp(t,e,r,s=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let a=zp(r),c=Vi.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)}bd.exports={decrypt:Fp,encrypt:qp,_salter:Up}});var vd=re(Yi=>{Yi.Deflater=pd();Yi.Inflater=md();Yi.ZipCrypto=Ed()});var ia=re((Zv,Sd)=>{var ie=Yn(),Hp=na(),we=ie.Constants,ra=vd();Sd.exports=function(t,e){var r=new Hp.EntryHeader,s=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,f=null,u=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let _=t,E=typeof _.decoder=="object"?_.decoder:ie.decoder;p=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(w){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ie.crc32(w)!==r.localHeader.crc)return!1}else{let A={},D=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(D)==we.LOCSIG||e.readUInt32LE(D)==we.CENSIG)throw ie.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(D)==we.EXTSIG)A.crc=e.readUInt32LE(D+we.EXTCRC),A.compressedSize=e.readUInt32LE(D+we.EXTSIZ),A.size=e.readUInt32LE(D+we.EXTLEN);else if(e.readUInt16LE(D+12)===19280)A.crc=e.readUInt32LE(D+we.EXTCRC-4),A.compressedSize=e.readUInt32LE(D+we.EXTSIZ-4),A.size=e.readUInt32LE(D+we.EXTLEN-4);else throw ie.Errors.DESCRIPTOR_UNKNOWN();if(A.compressedSize!==r.compressedSize||A.size!==r.size||A.crc!==r.crc)throw ie.Errors.DESCRIPTOR_FAULTY();if(ie.crc32(w)!==A.crc)return!1}return!0}function b(w,A,D){if(typeof A>"u"&&typeof w=="string"&&(D=w,w=void 0),c)return w&&A&&A(Buffer.alloc(0),ie.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var z=C();if(z.length===0)return w&&A&&A(z),z;if(r.encrypted){if(typeof D!="string"&&!Buffer.isBuffer(D))throw ie.Errors.INVALID_PASS_PARAM();z=ra.ZipCrypto.decrypt(z,r,D)}var B=Buffer.alloc(r.size);switch(r.method){case ie.Constants.STORED:if(z.copy(B),y(B))return w&&A&&A(B),B;throw w&&A&&A(B,ie.Errors.BAD_CRC()),ie.Errors.BAD_CRC();case ie.Constants.DEFLATED:var k=new ra.Inflater(z,r.size);if(w)k.inflateAsync(function(M){M.copy(M,0),A&&(y(M)?A(M):A(M,ie.Errors.BAD_CRC()))});else{if(k.inflate(B).copy(B,0),!y(B))throw ie.Errors.BAD_CRC(`"${E.decode(s)}"`);return B}break;default:throw w&&A&&A(Buffer.alloc(0),ie.Errors.UNKNOWN_METHOD()),ie.Errors.UNKNOWN_METHOD()}}function S(w,A){if((!f||!f.length)&&Buffer.isBuffer(e))return w&&A&&A(C()),C();if(f.length&&!c){var D;switch(r.method){case ie.Constants.STORED:return r.compressedSize=r.size,D=Buffer.alloc(f.length),f.copy(D),w&&A&&A(D),D;default:case ie.Constants.DEFLATED:var z=new ra.Deflater(f);if(w)z.deflateAsync(function(k){D=Buffer.alloc(k.length),r.compressedSize=k.length,k.copy(D),A&&A(D)});else{var B=z.deflate();return r.compressedSize=B.length,B}z=null;break}}else if(w&&A)A(Buffer.alloc(0));else return Buffer.alloc(0)}function I(w,A){return ie.readBigUInt64LE(w,A)}function R(w){try{for(var A=0,D,z,B;A+4<w.length;)D=w.readUInt16LE(A),A+=2,z=w.readUInt16LE(A),A+=2,B=w.slice(A,A+z),A+=z,we.ID_ZIP64===D&&P(B)}catch{throw ie.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(w){var A,D,z,B;w.length>=we.EF_ZIP64_SCOMP&&(A=I(w,we.EF_ZIP64_SUNCOMP),r.size===we.EF_ZIP64_OR_32&&(r.size=A)),w.length>=we.EF_ZIP64_RHO&&(D=I(w,we.EF_ZIP64_SCOMP),r.compressedSize===we.EF_ZIP64_OR_32&&(r.compressedSize=D)),w.length>=we.EF_ZIP64_DSN&&(z=I(w,we.EF_ZIP64_RHO),r.offset===we.EF_ZIP64_OR_32&&(r.offset=z)),w.length>=we.EF_ZIP64_DSN+4&&(B=w.readUInt32LE(we.EF_ZIP64_DSN),r.diskNumStart===we.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return E.decode(s)},get rawEntryName(){return s},set entryName(w){s=ie.toBuffer(w,E.encode);var A=s[s.length-1];c=A===47||A===92,r.fileNameLength=s.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return u},set extra(w){u=w,r.extraLength=w.length,R(w)},get comment(){return E.decode(a)},set comment(w){if(a=ie.toBuffer(w,E.encode),r.commentLength=a.length,a.length>65535)throw ie.Errors.COMMENT_TOO_LONG()},get name(){var w=E.decode(s);return c?w.substr(w.length-1).split("/").pop():w.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return S(!1,null)},getCompressedDataAsync:function(w){S(!0,w)},setData:function(w){f=ie.toBuffer(w,ie.decoder.encode),!c&&f.length?(r.size=f.length,r.method=ie.Constants.DEFLATED,r.crc=ie.crc32(w),r.changed=!0):r.method=ie.Constants.STORED},getData:function(w){return r.changed?f:b(!1,null,w)},getDataAsync:function(w,A){r.changed?w(f):b(!0,w,A)},set attr(w){r.attr=w},get attr(){return r.attr},set header(w){r.loadFromBinary(w)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var w=r.centralHeaderToBinary(),A=ie.Constants.CENHDR;return s.copy(w,A),A+=s.length,u.copy(w,A),A+=r.extraLength,a.copy(w,A),w},packLocalHeader:function(){let w=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let A=r.localHeaderToBinary(),D=Buffer.alloc(A.length+s.length+r.extraLocalLength);return A.copy(D,w),w+=A.length,s.copy(D,w),w+=s.length,x.copy(D,w),w+=x.length,D},toJSON:function(){let w=function(A){return"<"+(A&&A.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:w(e),data:w(f)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ad=re((Vv,Cd)=>{var Id=ia(),jp=na(),Ue=Yn();Cd.exports=function(t,e){var r=[],s={},a=Buffer.alloc(0),c=new jp.MainHeader,f=!1,u=null;let x=new Set,p=e,{noSort:_,decoder:E}=p;t?b(p.readEntries):f=!0;function C(){let I=new Set;for(let R of Object.keys(s)){let P=R.split("/");if(P.pop(),!!P.length)for(let w=0;w<P.length;w++){let A=P.slice(0,w+1).join("/")+"/";I.add(A)}}for(let R of I)if(!(R in s)){let P=new Id(p);P.entryName=R,P.attr=16,P.temporary=!0,r.push(P),s[P.entryName]=P,x.add(P)}}function y(){if(f=!0,s={},c.diskEntries>(t.length-c.offset)/Ue.Constants.CENHDR)throw Ue.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var I=c.offset,R=0;R<r.length;R++){var P=I,w=new Id(p,t);w.header=t.slice(P,P+=Ue.Constants.CENHDR),w.entryName=t.slice(P,P+=w.header.fileNameLength),w.header.extraLength&&(w.extra=t.slice(P,P+=w.header.extraLength)),w.header.commentLength&&(w.comment=t.slice(P,P+w.header.commentLength)),I+=w.header.centralHeaderSize,r[R]=w,s[w.entryName]=w}x.clear(),C()}function b(I){var R=t.length-Ue.Constants.ENDHDR,P=Math.max(0,R-65535),w=P,A=t.length,D=-1,z=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(P=0),R;R>=w;R--)if(t[R]===80){if(t.readUInt32LE(R)===Ue.Constants.ENDSIG){D=R,z=R,A=R+Ue.Constants.ENDHDR,w=R-Ue.Constants.END64HDR;continue}if(t.readUInt32LE(R)===Ue.Constants.END64SIG){w=P;continue}if(t.readUInt32LE(R)===Ue.Constants.ZIP64SIG){D=R,A=R+Ue.readBigUInt64LE(t,R+Ue.Constants.ZIP64SIZE)+Ue.Constants.ZIP64LEAD;break}}if(D==-1)throw Ue.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(D,A)),c.commentLength&&(a=t.slice(z+Ue.Constants.ENDHDR)),I&&y()}function S(){r.length>1&&!_&&r.sort((I,R)=>I.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return f||y(),r.filter(I=>!x.has(I))},get comment(){return E.decode(a)},set comment(I){a=Ue.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,R=!0){f||y();let P=s[I];this.getEntryChildren(P,R).map(A=>A.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){f||y();let R=s[I],P=r.indexOf(R);P>=0&&(r.splice(P,1),delete s[I],c.totalEntries=r.length)},getEntryChildren:function(I,R=!0){if(f||y(),typeof I=="object")if(I.isDirectory&&R){let P=[],w=I.entryName;for(let A of r)A.entryName.startsWith(w)&&P.push(A);return P}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let R=this.getEntryChildren(I);return R.includes(I)?R.length-1:R.length}return 0},compressToBuffer:function(){f||y(),S();let I=[],R=[],P=0,w=0;c.size=0,c.offset=0;let A=0;for(let B of this.entries){let k=B.getCompressedData();B.header.offset=w;let M=B.packLocalHeader(),F=M.length+k.length;w+=F,I.push(M),I.push(k);let K=B.packCentralHeader();R.push(K),c.size+=K.length,P+=F+K.length,A++}P+=c.mainHeaderSize,c.offset=w,c.totalEntries=A,w=0;let D=Buffer.alloc(P);for(let B of I)B.copy(D,w),w+=B.length;for(let B of R)B.copy(D,w),w+=B.length;let z=c.toBinary();return a&&a.copy(z,Ue.Constants.ENDHDR),z.copy(D,w),t=D,f=!1,D},toAsyncBuffer:function(I,R,P,w){try{f||y(),S();let A=[],D=[],z=0,B=0,k=0;c.size=0,c.offset=0;let M=function(F){if(F.length>0){let K=F.shift(),oe=K.entryName+K.extra.toString();P&&P(oe),K.getCompressedDataAsync(function(le){w&&w(oe),K.header.offset=B;let be=K.packLocalHeader(),Be=be.length+le.length;B+=Be,A.push(be),A.push(le);let ct=K.packCentralHeader();D.push(ct),c.size+=ct.length,z+=Be+ct.length,k++,M(F)})}else{z+=c.mainHeaderSize,c.offset=B,c.totalEntries=k,B=0;let K=Buffer.alloc(z);A.forEach(function(le){le.copy(K,B),B+=le.length}),D.forEach(function(le){le.copy(K,B),B+=le.length});let oe=c.toBinary();a&&a.copy(oe,Ue.Constants.ENDHDR),oe.copy(K,B),t=K,f=!1,I(K)}};M(Array.from(this.entries))}catch(A){R(A)}}}}});var Dd=re((Jv,Rd)=>{var pe=Yn(),he=ce("path"),Gp=ia(),Wp=Ad(),_n=(...t)=>pe.findLast(t,e=>typeof e=="boolean"),Td=(...t)=>pe.findLast(t,e=>typeof e=="string"),Kp=(...t)=>pe.findLast(t,e=>typeof e=="function"),$p={noSort:!1,readEntries:!1,method:pe.Constants.NONE,fs:null};Rd.exports=function(t,e){let r=null,s=Object.assign(Object.create(null),$p);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=pe.Constants.BUFFER,t=void 0)),Object.assign(s,e);let a=new pe(s);if((typeof s.decoder!="object"||typeof s.decoder.encode!="function"||typeof s.decoder.decode!="function")&&(s.decoder=pe.decoder),t&&typeof t=="string")if(a.fs.existsSync(t))s.method=pe.Constants.FILE,s.filename=t,r=a.fs.readFileSync(t);else throw pe.Errors.INVALID_FILENAME();let c=new Wp(r,s),{canonical:f,sanitize:u,zipnamefix:x}=pe;function p(y){if(y&&c){var b;if(typeof y=="string"&&(b=c.getEntry(he.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 _(y){let{join:b,normalize:S,sep:I}=he.posix;return b(he.isAbsolute(y)?"/":".",S(I+y.split("\\").join(I)+I))}function E(y){return y instanceof RegExp?(function(b){return function(S){return b.test(S)}})(y):typeof y!="function"?()=>!0:y}let C=(y,b)=>{let S=b.slice(-1);return S=S===a.sep?a.sep:"",he.relative(y,b)+S};return{readFile:function(y,b){var S=p(y);return S&&S.getData(b)||null},childCount:function(y){let b=p(y);if(b)return c.getChildCount(b)},readFileAsync:function(y,b){var S=p(y);S?S.getDataAsync(b):b(null,"getEntry failed for:"+y)},readAsText:function(y,b){var S=p(y);if(S){var I=S.getData();if(I&&I.length)return I.toString(b||"utf8")}return""},readAsTextAsync:function(y,b,S){var I=p(y);I?I.getDataAsync(function(R,P){if(P){b(R,P);return}R&&R.length?b(R.toString(S||"utf8")):b("")}):b("")},deleteFile:function(y,b=!0){var S=p(y);S&&c.deleteFile(S.entryName,b)},deleteEntry:function(y){var b=p(y);b&&c.deleteEntry(b.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,b){var S=p(y);S&&(S.comment=b)},getZipEntryComment:function(y){var b=p(y);return b&&b.comment||""},updateFile:function(y,b){var S=p(y);S&&S.setData(b)},addLocalFile:function(y,b,S,I){if(a.fs.existsSync(y)){b=b?_(b):"";let R=he.win32.basename(he.win32.normalize(y));b+=S||R;let P=a.fs.statSync(y),w=P.isFile()?a.fs.readFileSync(y):Buffer.alloc(0);P.isDirectory()&&(b+=a.sep),this.addFile(b,w,I,P)}else throw pe.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,b){y=typeof y=="object"?y:{localPath:y};let S=he.resolve(y.localPath),{comment:I}=y,{zipPath:R,zipName:P}=y,w=this;a.fs.stat(S,function(A,D){if(A)return b(A,!1);R=R?_(R):"";let z=he.win32.basename(he.win32.normalize(S));if(R+=P||z,D.isFile())a.fs.readFile(S,function(B,k){return B?b(B,!1):(w.addFile(R,k,I,D),setImmediate(b,void 0,!0))});else if(D.isDirectory())return R+=a.sep,w.addFile(R,Buffer.alloc(0),I,D),setImmediate(b,void 0,!0)})},addLocalFolder:function(y,b,S){if(S=E(S),b=b?_(b):"",y=he.normalize(y),a.fs.existsSync(y)){let I=a.findFiles(y),R=this;if(I.length)for(let P of I){let w=he.join(b,C(y,P));S(w)&&R.addLocalFile(P,he.dirname(w))}}else throw pe.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,b,S,I){I=E(I),S=S?_(S):"",y=he.normalize(y);var R=this;a.fs.open(y,"r",function(P){if(P&&P.code==="ENOENT")b(void 0,pe.Errors.FILE_NOT_FOUND(y));else if(P)b(void 0,P);else{var w=a.findFiles(y),A=-1,D=function(){if(A+=1,A<w.length){var z=w[A],B=C(y,z).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(B)?a.fs.stat(z,function(k,M){k&&b(void 0,k),M.isFile()?a.fs.readFile(z,function(F,K){F?b(void 0,F):(R.addFile(S+B,K,"",M),D())}):(R.addFile(S+B+"/",Buffer.alloc(0),"",M),D())}):process.nextTick(()=>{D()})}else b(!0,void 0)};D()}})},addLocalFolderAsync2:function(y,b){let S=this;y=typeof y=="object"?y:{localPath:y},localPath=he.resolve(_(y.localPath));let{zipPath:I,filter:R,namefix:P}=y;R instanceof RegExp?R=(function(D){return function(z){return D.test(z)}})(R):typeof R!="function"&&(R=function(){return!0}),I=I?_(I):"",P=="latin1"&&(P=D=>D.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=D=>D);let w=D=>he.join(I,P(C(localPath,D))),A=D=>he.win32.basename(he.win32.normalize(P(D)));a.fs.open(localPath,"r",function(D){D&&D.code==="ENOENT"?b(void 0,pe.Errors.FILE_NOT_FOUND(localPath)):D?b(void 0,D):a.findFilesAsync(localPath,function(z,B){if(z)return b(z);B=B.filter(k=>R(w(k))),B.length||b(void 0,!1),setImmediate(B.reverse().reduce(function(k,M){return function(F,K){if(F||K===!1)return setImmediate(k,F,!1);S.addLocalFileAsync({localPath:M,zipPath:he.dirname(w(M)),zipName:A(M)},k)}},b))})})},addLocalFolderPromise:function(y,b){return new Promise((S,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},b),(R,P)=>{R&&I(R),P&&S(this)})})},addFile:function(y,b,S,I){y=x(y);let R=p(y),P=R!=null;P||(R=new Gp(s),R.entryName=y),R.comment=S||"";let w=typeof I=="object"&&I instanceof a.fs.Stats;w&&(R.header.time=I.mtime);var A=R.isDirectory?16:0;let D=R.isDirectory?16384:32768;return w?D|=4095&I.mode:typeof I=="number"?D|=4095&I:D|=R.isDirectory?493:420,A=(A|D<<16)>>>0,R.attr=A,R.setData(b),P||c.setEntry(R),R},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return p(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,b,S,I,R,P){I=_n(!1,I),R=_n(!1,R),S=_n(!0,S),P=Td(R,P);var w=p(y);if(!w)throw pe.Errors.NO_ENTRY();var A=f(w.entryName),D=u(b,P&&!w.isDirectory?P:S?A:he.basename(A));if(w.isDirectory){var z=c.getEntryChildren(w);return z.forEach(function(M){if(M.isDirectory)return;var F=M.getData();if(!F)throw pe.Errors.CANT_EXTRACT_FILE();var K=f(M.entryName),oe=u(b,S?K:he.basename(K));let le=R?M.header.fileAttr:void 0;a.writeFileTo(oe,F,I,le)}),!0}var B=w.getData(c.password);if(!B)throw pe.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(D)&&!I)throw pe.Errors.CANT_OVERRIDE();let k=R?y.header.fileAttr:void 0;return a.writeFileTo(D,B,I,k),!0},test:function(y){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var S=c.entries[b].getData(y);if(!S)return!1}catch{return!1}return!0},extractAllTo:function(y,b,S,I){if(S=_n(!1,S),I=Td(S,I),b=_n(!1,b),!c)throw pe.Errors.NO_ZIP();c.entries.forEach(function(R){var P=u(y,f(R.entryName));if(R.isDirectory){a.makeDir(P);return}var w=R.getData(I);if(!w)throw pe.Errors.CANT_EXTRACT_FILE();let A=S?R.header.fileAttr:void 0;a.writeFileTo(P,w,b,A);try{a.fs.utimesSync(P,R.header.time,R.header.time)}catch{throw pe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,b,S,I){if(I=Kp(b,S,I),S=_n(!1,S),b=_n(!1,b),!I)return new Promise((D,z)=>{this.extractAllToAsync(y,b,S,function(B){B?z(B):D(this)})});if(!c){I(pe.Errors.NO_ZIP());return}y=he.resolve(y);let R=D=>u(y,he.normalize(f(D.entryName))),P=(D,z)=>new Error(D+': "'+z+'"'),w=[],A=[];c.entries.forEach(D=>{D.isDirectory?w.push(D):A.push(D)});for(let D of w){let z=R(D),B=S?D.header.fileAttr:void 0;try{a.makeDir(z),B&&a.fs.chmodSync(z,B),a.fs.utimesSync(z,D.header.time,D.header.time)}catch{I(P("Unable to create folder",z))}}A.reverse().reduce(function(D,z){return function(B){if(B)D(B);else{let k=he.normalize(f(z.entryName)),M=u(y,k);z.getDataAsync(function(F,K){if(K)D(K);else if(!F)D(pe.Errors.CANT_EXTRACT_FILE());else{let oe=S?z.header.fileAttr:void 0;a.writeFileToAsync(M,F,b,oe,function(le){le||D(P("Unable to write file",M)),a.fs.utimes(M,z.header.time,z.header.time,function(be){be?D(P("Unable to set times",M)):D()})})}})}}},I)()},writeZip:function(y,b){if(arguments.length===1&&typeof y=="function"&&(b=y,y=""),!y&&s.filename&&(y=s.filename),!!y){var S=c.compressToBuffer();if(S){var I=a.writeFileTo(y,S,!0);typeof b=="function"&&b(I?null:new Error("failed"),"")}}},writeZipPromise:function(y,b){let{overwrite:S,perm:I}=Object.assign({overwrite:!0},b);return new Promise((R,P)=>{!y&&s.filename&&(y=s.filename),y||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(w=>{let A=D=>D?R(D):P("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(y,w,S,I,A)},P)})},toBufferPromise:function(){return new Promise((y,b)=>{c.toAsyncBuffer(y,b)})},toBuffer:function(y,b,S,I){return typeof y=="function"?(c.toAsyncBuffer(y,b,S,I),null):c.compressToBuffer()}}}});var xu=re(Ie=>{"use strict";var N=G;(function(t,e){let r=G,s=t();for(;;)try{if(parseInt(r(816))/1+-parseInt(r(1927))/2*(parseInt(r(1867))/3)+-parseInt(r(696))/4+-parseInt(r(838))/5+parseInt(r(1175))/6*(-parseInt(r(1784))/7)+parseInt(r(1503))/8*(-parseInt(r(1296))/9)+-parseInt(r(1888))/10*(-parseInt(r(603))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(io,946273);function G(t,e){t=t-416;let r=io(),s=r[t];if(G.WeWwWg===void 0){var a=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",E="";for(let C=0,y,b,S=0;b=x.charAt(S++);~b&&(y=C%4?y*64+b:b,C++%4)?_+=String.fromCharCode(255&y>>(-2*C&6)):0)b=p.indexOf(b);for(let C=0,y=_.length;C<y;C++)E+="%"+("00"+_.charCodeAt(C).toString(16)).slice(-2);return decodeURIComponent(E)};G.JVMKSh=a,G.olhsSL={},G.WeWwWg=!0}let c=r[0],f=t+c,u=G.olhsSL[f];return u?s=u:(s=G.JVMKSh(s),G.olhsSL[f]=s),s}var Q_=Object[N(906)+N(946)],ey=Object[N(1262)+N(1074)+"mes"],cu=(t,e)=>function(){return t&&(e=(0,t[{VdPPm:function(a,c){return a(c)}}.VdPPm(ey,t)[0]])(t=0)),e},ty=(t,e)=>{for(var r in e)Q_(t,r,{get:e[r],enumerable:!0})};function ny(){return ru||(ru=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ry(){let t=N;return iu||(iu=[IDBCursor[t(1528)+"e"].advance,IDBCursor[t(1528)+"e"][t(1687)],IDBCursor[t(1528)+"e"][t(1687)+"PrimaryKey"]])}function iy(t){let e=N,r={AtSXY:e(901),bLZwF:function(a,c){return a!==c},uTGKY:"LcPip",pSmIz:function(a,c){return a(c)},mFVpi:function(a){return a()},VvScK:e(1397),iYAtl:"message",ixHaq:e(833),COiOy:function(a,c){return a>=c},lWfZD:function(a,c){return a===c},tmbVv:function(a,c){return a-c},qcYXQ:function(a,c){return a===c},kroGT:function(a,c){return a!==c},XgRgb:e(1139),CJSYD:function(a,c){return a instanceof c},WLmKd:e(667),AfgmX:e(1317)},s=new Promise((a,c)=>{let f=e,u={CzbLU:r.VvScK,ffduq:r[f(1454)],rCosQ:r.AtSXY},x=()=>{let E=f;t["removeEv"+E(1895)+E(1594)](E(833),p),t[E(1679)+E(1895)+"ner"](r.AtSXY,_)},p=()=>{let E=f;if(r[E(849)](r[E(1704)],E(569))){if(!this[E(823)])return;this._ws["addEvent"+E(1467)](E(1582),this[E(1683)]),this[E(823)].addEventListener(u.CzbLU,this[E(1194)]),this[E(823)][E(1285)+E(1467)](u[E(1392)],this[E(461)+"ge"]),this._ws[E(1285)+"Listener"](u.rCosQ,this[E(736)])}else r[E(1541)](a,r[E(1541)](Dt,t.result)),r.mFVpi(x)},_=()=>{let E=f;r.pSmIz(c,t[E(901)]),x()};t[f(1285)+f(1467)](r[f(1004)],p),t["addEvent"+f(1467)](r[f(1363)],_)});return s[e(612)](a=>{let c=e;if(r[c(729)](r[c(1366)],r[c(1366)]))return!!(r.COiOy(this["currentI"+c(1702)],this.endpoints[c(1180)])||r[c(1267)](this[c(1745)+"ndex"],r[c(586)](this[c(1232)+"s"][c(1180)],1))&&r[c(581)](this["currentE"+c(623)+c(1089)+"t"],this.maxRetries));if(r[c(1857)](a,IDBCursor)){if(r[c(1168)]===r.AfgmX)return this[c(945)]>=this[c(703)+c(975)];Ac[c(1411)](a,t)}}).catch(()=>{}),oo[e(1411)](s,t),s}function sy(t){let e=N,r={CZfHG:function(a){return a()},AjfFP:"complete",HwjZJ:e(901),dRrOm:function(a,c){return a(c)},tIyuX:e(1093)+"or"};if(so[e(819)](t))return;let s=new Promise((a,c)=>{let f=e,u={KnBnK:r.AjfFP,szwdp:r[f(709)],NCzTH:function(E,C){return r[f(1216)](E,C)},oItfX:r.tIyuX,bNKzU:function(E){return r[f(1202)](E)}},x=()=>{let E=f;t[E(1679)+E(1895)+E(1594)](u[E(1856)],p),t["removeEv"+E(1895)+E(1594)](u[E(1929)],_),t["removeEv"+E(1895)+"ner"](E(1414),_)},p=()=>{r[f(1202)](a),x()},_=()=>{let E=f;u.NCzTH(c,t[E(901)]||new DOMException(u[E(527)],"AbortError")),u[E(578)](x)};t[f(1285)+f(1467)](r.AjfFP,p),t.addEventListener(r[f(709)],_),t[f(1285)+"Listener"](f(1414),_)});so[e(1411)](t,s)}function oy(t){ao={JPULU:function(s,a){return s(a)}}[N(752)](t,ao)}function io(){let t=["yxv0B21HDgK","Ec1TC2CTy3u","vKjfCxG","Cg9PBNrbBMq","DfPdyu4","zerfvei","ExPNyMq","B25LCNjVCG","uwrPv3y","CgXLyxnLiha","BwT4qwy","zxj2AwnL","q0Xpu0LorW","z2v0q3vYC28","wMjVsLC","q3vZDg9Tq2W","ugz3D0K","z2u6ia","qKD2yuG","Bwf4twvZC2e","C0fcDuu","rfz2rxO","zMLSDgvY","Efrurw52","tNLAzKy","CNnVCKzPBgu","zcbLCNjVCI4","Ahnwu2m","rKnkqKW","zsbHihn0CMK","Cerjwgm","D1retLy","q0vJrNa","mJu3odKWnejyuwPcvG","BwPZvfm","x2HHBMrSzvi","B2nRzxrtDwm","sNzSEue","BM9Ksxi","wfLvqLe","ExDhvLi","s2jzuNq","sLLer0W","BxnNsuq","C3nHz2vfDMu","BMjuAuG","CvPty20","B3bLBKrc","rNrnAuS","Aw50zwDLCIa","tLb3ugG","rejbzvu","rKTMt2G","v1jgAe8","zwn0","twngtxK","BMvLzf9Hy2S","Dg9tDhjPBMC","ChjVDg90Exa","z0DzBvG","Aw5N","D2PdANm","Bu9yv2y","zgLZywjSzue","r1Dqv3y","ywnR","DMnHAeK","s3fItKu","q2rsvMq","t3fpyxe","A09wyvK","CfnTsxO","wxnqq24","zwnVBM5Ly3q","y1n3r2m","yMfZs3O","s05gswS","t3bLBKv2zw4","DhLWzq","DLrsuvq","CNzHBa","z0fYBLK","zKrQufG","tMzbC2K","thDyDwu","y2HLy2TdDxi","z2v0","t0HZzvC","vKHVBMu","weX5y3C","C3vIC3rYAw4","tgXMDgK","s1Pvue8","x3bPBMDqB24","qK1zruy","BM93","AwXK","zhHnwLC","BwfW","Dg9hzw5LCMe","tvfque8","yxfuquO","uKD0Aey","uenRDw0","tfHvzvu","CM9YrxzLBNq","D0XUEfG","DNHozhe","ru9iExy","ELDvwKG","wMzVD1G","ywDLu2HVDW","B3bLBG","BNDcugy","C2DUC2S","x29WDgLVBNm","DhbizwfKzxi","qLrtC3y","vLvABe8","x1fVu01HBMe","zu1oyLi","s3zVAg8","v3z0AuK","ugjAEfm","BMvY","Bhm6ia","ywrpqKK","quzLDNu","uMnuqKO","zNjVBu51Bwi","CvvQwxO","rLDsq1e","CgfNzwHPzgu","ExLkzLa","wNrVtw0","EMzPthm","DNzNt0S","Ae9Wzw5fDMu","yNLL","re1fv2S","sLDYB0C","BfjUEuG","z29PBMCGyxC","vLn5ufq","EKHhB0K","y01zzuq","BLL2v04","x0vysvnu","Agrkq3i","q09otKvdveK","zevuzgO","q3LWELi","tfPYD3G","D09ewfe","qxL2Agm","rfLivNG","vhL0D0y","rKPTteq","mxWWFdn8mNW","ywX3yxLZ","DgfIyxnL","Ahr0Chm6","yvzTzuS","x3jLy29UBMu","DgLUzYbZzxi","Bvrowem","CKzTy08","AgfUz2u","rfHfAwG","DhDVCMTdAge","Cgf5Bg9Hzeu","AgvHzgvY","v3jIz3q","AgvHzgvYCW","s3DjrLC","tuHfvwi","AgvKtwf4uMu","Dunnr0K","zNjVBNrPzxi","sxvwufO","x3nLCuLK","rMnJBMG","CMvHzg9UBhK","DgLLCKPtt04","uxn3vKm","DxbKyxrLq3u","zMLSzw5HBwu","uxnKufq","Ce5ku0O","CuD3Afi","ExnrwNm","A0Dbrhy","EMzLyxG","qLfhsgu","wwzVz1e","sMvKr3K","vxftqMe","DurTz1u","CMvKDwnL","zvDHy2O","x2XPC3rLBMu","svDvCha","yw1L","B3jL","rfj4sey","tMPks3q","zhjuBwy","Ag5tr2K","CMvJzwL2zwq","CMvTB3zLrxy","x2rPC2nVBM4","Cw9ewuO","ywWGy3vYC28","x29Ut3bLBG","C2LZCwO","wuLJCgi","q0XOCMG","y29UDgLUDwu","whzMCwu","sgvcr2e","CM92AwrLige","C3bSAwnL","DgLTzw91Da","q3Dkr24","u01xCLe","uKDfv20","AgLts0q","BgP3thG","Dgrfru4","whLzs0S","txDirhG","CLLztfq","BMrLEa","D3jPDgu","Dvrhs1K","ywrKq291BNq","vgfN","Bg94y0u","D01nzvy","B2Xxrvq","zerOy3K","DMfSDwvZ","Dg9cExrLC0i","uNfxyxa","ENL5vKe","zM9Yy2u","A2j5swy","y0jurhO","A2XNrgm","q3HZrfi","qMvgs0e","DM9jDxG","CgLUz1rPBwu","y3jLyxrLrwW","wxP1vLO","wwX5r0e","tNHoEwW","zMzmAw5L","CMfNzvn5BMm","vNHNExy","tufyx1jfvfi","zLvozu8","u0rsDhy","ENfjBwS","Dwn2ze4","v2vIu29JA2u","ywnRtxnNswq","qMLSyKK","ihzHBgLKihm","ywrKt25L","tMDiv3K","q29Kzq","Dervqwu","zgvSzxrL","D3jPDgvvAw4","y3vYCMvUDeK","AMnKC0G","Dg9mB3DLCKm","sgXxtwG","BeT1EgG","rKncCMW","x2rLyNvN","AxnbCNjHEq","Dev2zw50","uenxDK0","vezdy0C","x2LZtwLUAvq","Cw9uBxa","yujMExe","aaaaaaaaaaa","yujlEwu","AwXSihvZzsa","tffRvee","x2LUDgvYDMe","DcbVzIbYyw4","Ec11C2uT","s3rKEgK","rMDPsxu","vej3q2O","CMvWBgfJzui","x2LUAxrhBg8","zK5zEg8","x2rItMfTzq","uuf0ywO","suHKB2q","y3vYC29YlNm","tg5QzMm","tNbcuvO","wu9hC1e","y09Wzw4","y0v4qKC","wwztseu","u0DVEK0","vu1fu3G","nZq5uefPtw5j","x2LZqNjVD3m","rLDt","x3nVy2TLDa","rvv0Avu","C2vUzf9Hy2S","zxmGCMvHy2G","r0vMy04","z2v0qwXS","CYbWyxjHBxm","uMvJB25Uzwm","ChfyD2C","r0vttxm","y29UBMvJDeu","uxLjELO","BwPvzeu","ANj1Cem","y3r4","zgvS","EhPtuMS","uerJsgW","yxKSihrYEsa","EhrstwK","yxbWBhK","CMvHzhLtDge","y2uGBM90igK","D09XAg4","y2zNww8","zNjHBwvuExa","DMvYC2LVBMm","x2LZtM9Kzq","zgDOv3u","C0vqDNK","zM5lCMi","C2vUza","BM5er3i","x3DZsw5ZDge","sxzWDva","BfjWteO","CgPArwi","r1zJvKK","igzPzwXKoIa","BMDuAw1LCG","BxLjrwK","uuPdwve","B25tDgfYDfi","yMTxDgC","wezqwee","B1bLu3K","svn4teS","B2Hrs1a","yvLWBwe","uKjlr0K","u2zzA1C","uevysvG","AMPMD1a","Bg9Nsurhzw4","yxGGCMv0CMK","zg9Uzq","Bwu6ia","yw1LoIa","yNr4we8","u0Thqui","uffNBfm","vfDduxC","Chzbvgu","Cg9PBNrdB24","x21LC3nHz2u","vwzbEM4","Aw5KzxGGB3u","B1H1s1u","DgLTzw91DcW","s25cBKS","q0Ptwuq","svPkzfC","wLLAwgW","CMvXDwLYzwq","y3jOC1i","uwPcELa","DwzIq2i","sLnov2O","quXm","u3b6BwG","mZaXotq3uNnTA2nf","C0fSsK4","ww1Xv2u","ignVzgu6ia","zw50zwqGDhK","yNzdC3m","CgfYC2u","x2vUzhbVAw4","BMv3vMvYC2K","DhjPzxm","yLnvC00","yxv0BW","ALLkzKq","seHrzva","zxjFAxnFywm","uKXjwKW","rhzcz1e","Dgv4Dc9WBge","zNjVBunOyxi","rhPLEe0","yNvMzMvYzwq","mteWndKWntbfALjhEKO","A1z6rK0","rg5bExi","tMfTzq","AuDnz0O","AxnrB1nby2S","vxrQwxq","zw50tgLZDgu","yxPAr08","uevVENm","u1L5wMe","mtb8oxWXmxW","u05bvuy","z1nbDw0","zNDZxZeUmc4","CvnorwS","De1HBMfNzxi","sK9VwLa","x2n1CNnVCKy","yxP0uLa","whLMDhy","DMrPvhi","vLHZv0u","t2XnBem","vvDoqvi","BIWGAg9ZDg4","q3PJrgm","qxDSt1m","qu1ICxm","sLbPBMG","ihrVihjLDhi","yKLPy1C","uM9fAMS","yMPtzKu","BMrvEeu","x29UugfNzu4","s1HWq0G","CMvJB25Uzwm","ChjVy2vZCW","nerKswTrtG","y2XVC2uSihC","C3P3zha","y29SBM8","zw5fDMvUDa","mdaWmdaWmda","C2v0u3rVCMe","uvjHAu8","u01Krfe","x2nYzwf0zvm","BMCGzMfPBgu","zxjFCw9Z","EePSvMu","C3Ltv3C","zcWG","ue55wLC","t3nqEwO","y3vlugC","CMvTB3zLq2G","B25ozxr3B3i","Cg9W","vw9eu1a","v2jJAeu","zxjFDhrS","t09trKy","shngDKm","s2TOyuW","sfvfwvu","ALP2quW","EKLWBeG","sKTIqvO","rKDMDLG","icSG","Dg9cExrLCW","q0j5u3a","Cgf5Bg9Hzfq","x3bYzwzPEa","DMvUDa","ugzNu2C","yxnJCMLWDa","BezSDxnO","CLfmwhG","ru9YqwG","ihn1y2nLC3m","twXbwgm","zxjFywnRx20","wKnxyLq","D3rSvK0","Cg9MzNm","B3nLza","r1DZtvC","zxjYtxnN","rMfjDvi","AKrSBva","DvbvwNq","x29UtwvZC2e","tufWBgq","C1jkBuy","CK1YBLa","v2LUzg93","q1nxqui","twLZC2LUzYa","ywnOzwq","rNjVBNrPzxi","B3HjyNO","C0Dmy3O","ChrRCwq","rNfwyMG","sgngs3C","EfvtDhe","DfrOtKy","qLjSDM0","BxfjrwG","C3rYAw5NAwy","wfzQswi","tg9JAW","t1viwgy","s3Dsy3K","yuDPsLC","BgLUzq","B25szwnLAxy","EgDQChu","yNL0zuXLBMC","ysbTDxn0igi","y3jLyxrLuMu","uK14CLu","s1HvvMq","Efzbtwm","x3nLBMrby2S","EgjuuLi","wMjTBK4","rvjst1i","zuX0zum","wMHovvy","ANDLvwu","zNvUy3rPB24","uhzUqNC","zw5HyMXLuw8","z2vjBMzVu3K","s0ztDeq","ywnRx2nVzgu","uuztqMi","tvzsEgS","Bwv0Ag9K","y2vZC0HHBMq","C1znAgS","yxnZAwDU","C0PzCeK","zufJAW","CMvHC29U","Dfv5B0S","wfDUBKS","ywLpyuu","s3vREfu","DeLWz3q","ChvZAa","EKLIt3O","rKrLvgm","u2Dtz3C","yu5XrLm","t1bftL9fuLi","B0L0zLG","v3HsAfO","Dw50","AffcAMO","s0Lmtw8","EsbJBg9Zzwq","x2fKzfDZtgK","zvvYBa","rwTIqLG","yvvvsMS","BML0AwfSAxO","u1n4sLO","yNbUy00","DxnLCKLW","u2vXsuq","y29UDgv4Da","vxDSzw8","wu1Ivw4","B25Uzwn0Aw4","r0LKDMq","sw9Luw4","teXmBem","DLn6q24","Bezrv1O","vevjEee","C2TVtKW","qKf5DvK","yxKSig5LDhC","vwnswKm","zxjYtM8","CKLsq0u","reXWCLO","uMLcv1G","C2XPy2u","x3bPBMC","tw9KDwXL","tuzbvgS","EMDOCey","CgjryLm","zMvY","Cw9zCM4","DKXNuvy","tgnqAxa","vfjvChu","rwT5ANu","DhjPBq","AMnluLC","D09tzfm","D29SsNC","EuPjr1K","sejhuLK","yK5lELu","DeLK","CxfHDxe","Cwnzwfe","zw5JB2rLrNi","Aw1gA0G","CYbPBNn0yw4","B3LXtMy","Dg1IvNy","AxnrB1nnzxm","DNPgq0e","u3Pss2y","wgTtB08","s2zzzwu","twfkz2i","AwPKtwS","yuXPCNG","zffmtwy","senRAuG","ENHfCg0","CefJsee","zLLLA2u","z2DZr3q","CMv0CNLdB3u","zM9YrwfJAa","ntv6B3LzrMi","D24GCMvHC28","q0Xpu0ve","zfDVCMTLCKC","EMztEgy","AwHSDgq","DKX4Cvq","qwT5ELC","qvnHvei","DgHLBG","y3jLyxrLt2i","CML6ug8","BejythO","DxjS","AKPYv2S","ExbL","Cwr0yLu","igXHCMDLCIa","DujoqMq","ufn2zfu","BMrWB2LUDfq","uuDPseW","x2DLBMvYyxq","C2vYDMLJzq","C0nVDw50zxi","x2nSzwfYvgK","BwvZC2fNzq","vND1uxm","BwvZC2fNzv8","y3vYC29Y","EezftwW","yMLUyxj5","CMnYtxq","tefiwue","DeLUDgvYy2u","B25dBg9Zzq","CwzLv1y","uKXiu0O","y29Uy2f0","rwThDMm","Dg9Y","yNL0zu9MzNm","x2LUAxrqCM8","ywnRpwzYB24","EfH4tgu","wwHbA3m","ExrKue8","zgXmuK8","x2rPC3bHDgm","t2DYvMy","y2f0y2G","Bg93","z2Hqtxa","z3rJA00","rvn4rLy","z1vdtg0","B3jRig9MzMW","D2TTq2K","C3zgBwC","AenSB3nLrxy","veL0q2e","rxzLBNq","tKPqqMW","A1n0yxr1C0m","A1DyD0m","nNWWFdr8mNW","CIb0DhDjra","C3vrDKC","BwLUAvbYB2C","rK54t24","y2HnyxHuCMK","txzvq2e","Bw1SqMu","zLP1vuW","ze9HBvK","vM9jtgu","DvLKs2O","y3ruAw1LB3u","yKfdCMq","lcbTyxGGCMu","uwXmtKe","B3v0sw50zxi","ihjLy29UBMu","zfnID0i","y29UBMvJDgK","txLMrhy","Dgv4DfbHEwW","tMf4twW","A0LXyxy","B25TzxnZywC","rLjptLrjrvi","wfrvsuq","BM1OEKi","nZmWotmZnLvMA3PSDG","DNbeyLC","yMvnD20","zgvJB2rLzey","zMLN","zvLMB0e","C0XPC3rLBMu","Bwf4tg9ZC0m","t01usLi","DcbSAw1PDa","v3LXBuu","EgPPCMm","tfHdBNe","shDQwKO","uwnJvMG","ruf6wKm","rLb0B0K","AgLNAa","zuPpsMC","CM55Efa","DuLzCgS","vvbjzKy","BMfTzq","zfD6y1i","x3jLBw92zvC","z01bCxG","Ahr0Ca","B2LUDfjLywm","CMfTugfYyw0","DgHHBIbSB2m","tejYt04","DfbjAhy","ywnRDxbfBMq","A3jVr1q","rKDfEgS","u2vYDMLJzvC","x3bPBMDmB3m","Cg93","wg5uAxu","ChzOvLu","x29UrxjYB3i","z2v0sxrLBq","wK1fvuW","C3vIyxjYyxK","wMHwAwi","nNW0Fdf8m3W","yKT3yLC","BwXMAK0","ywrK","B25sEwG","AM9PBG","sxzIC1K","vw5Oyw5KBgu","yNvMzMvY","o2nOyxjZzxq","zLPSvgu","sLbvtfu","DxrzCKi","Bgngr3y","x2nSzwfYugK","y3jLyxrLt3a","B25nzxnZywC","t2zhA3y","EgzzEvK","ChjVDg9JB2W","Chv0","z2v0q3vYCMu","yvP3wfy","C2v0sxrLBq","wNLuDuy","z1rPBwvVDxq","AeXjv1q","uMflwxC","A0jLChu","D1vMwMG","Dxrjza","ugjREgO","x2HHBMrSzva","y2XVC2veqG","ihrPBwvVDxq","CYbHBhjLywq","uLbKq0i","zeLkqwy","q3rbEuu","yxvTruK","twnlvxu","ANvUBxG","AgDlzvy","vwPUD0W","u3zMCwG","y29Kzq","ANvitLm","yw51Ce1LC3m","u2XQDKe","AxjLza","twvZC2fNzuu","zNjVBuj5Dgu","C2v0y3vYC28","Axnby2TdBgu","D3PRzve","vgX4rei","rgzTA28","tvrbsvC","u2HHCMvKv28","ywXPzcb1CMW","s3PxA0m","ywPPz1i","z2vY","BMntvNO","x194x21Zz18","Dw5KzwzPBMu","y2XLyxi","BgLZDgvUtMu","B3jLtMfTzxm","A0jfCeG","zcWGDw5RBM8","Efz3CKO","Dvjft1a","qMrhue4","yxrHlcbKyxq","mtyWodG0quDVsfHN","CM92AwrLihy","B25SAw5L","AgfZ","qNPetgO","zgvIDwC","v2vPEgLUsLm","x3DZ","r1LmAhy","qvb3A3a","sgnAs1q","t1bftG","CeHUsui","zw1LBNq","t3rHzMq","rKvTELu","Egnxzgq","C3vJy2vZCW","zuTovvm","vMXXzxC","svzZBgC","rNDerxC","mJG2mdK2nxfWvgvYwG","z2vrDwv1zuW","tMDuD3e","s3bQEgi","t0rwzxy","s0vmuKy","CMvZzxrfBMq","tLDsBeS","BeHdCe0","yMPruNa","DxbREeG","yKXAD0y","EKLQv2e","t2jQzwn0","zw5NDgG","yu1jyKi","vxP1BgC","shbJChC","vLnXz1i","zNjVBujPDhm","sMfMrfC","tvrcEvu","B3bLBIa","DgfYz2v0","DKL5yui","x2n1CNnVCK4","zevdv3e","wvnYAuq","r2v5r2G","Afvfsgq","C3rYAw5N","rhjisuq","B25tDg9Wsw0","AMXgv3G","ihrYEsbYzwm","B25fCNjVCG","uxrrvM4","uLjpuG","x3bHDgHlzxK","D1P6Eey","CMvZzxrdB3u","AMDIDvq","CMTLCKDSB2i","DuHcAwm","zMzhBge","yKXSD2q","wgLqr0m","yxjYyxLIDwy","ufjgr3i","vuzPwgu","DxrMofDYAxq","EwjwvLy","rKPkvNq","B0reC1u","wejuB0m","ugznyMG","sgz0BwW","CNH0wLG","rMvMqxu","B3jRzxjhBg8","zMLouK8","ue9pCeG","zxHWB3j0CW","zxjYB3i","re9fD1q","CMvZDwX0","B2XKvMvYC2K","EgPdDuy","zgvMAw5Luhi","yxnL","Aw5KzxG","CKf0s1O","BwLZzq","DxbNCMfKzw4","tKfusvzfx0u","BwvY","C3rVCcbPBw0","tertv3q","y3vYCMvUDeu","sKTnBge","s3nTsuy","wen3C3O","yxbWBgLJyxq","CNnVCL92ywW","refvwKC","C2jZufa","y1HZtxK","CMvHzhDYAxq","yuXuyxu","EuXewM8","D09UthO","BwPLz1q","B2LuEhG","BMnLq2XVC2u","Dg9VigXHCMC","y3vYC29Yx24","ywXSq3vYC28","y3vYC29Yx2y","x2TLEvbHDgG","ruDwwwG","A3bHqK4","z2v0qwXSs2u","AMnwzum","ve91u00","DNjHAum","x2rLC3rYB3K","Euf1zKy","y291BNq","B3bLCNr5","v2HWAuS","z3Lmy3a","B0PmyMi","uKvirKe","wwrVuvO","AvzwshC","BMzfDfa","ign1CNnVCIa","sxjsqxa","BNrfBMrWB2K","B1DMv00","BKXAs2K","uK5ht2K","BK9fAMi","tLnRzwi","AMvJDfn0B3i","B2zM","wLzuvwu","B2XZvwu","C0rbq2q","uNHIvMG","AxnFywnR","s2P2vwK","CgLUz19VBMm","swHMseK","wMrWuum","D0Pzwhm","ALH1veK","B3vUDa","DhjPzxmGCMu","CgfNzxnOB3C","BMCGB3iGyw4","y3jLyxrLtwu","BNruCMLLC0m","ve9QAhK","x2nVBM5Ly3q","z3fPDwe","B2nRzxrgywK","DNPysMC","vvDRt0C","Aw5PDcbrB1m","q29UzMLN","s3fWCwC","yKnkt0O","zhPmwMu","D2LSBfjLy28","rxbywey","B2jQzwn0u3q","rhLrDxC","Bg9ACvq","tuvtu0fhrv8","qLLsCfu","Dgj6vgm","BwvKAwf0zwW","Bg9N","yNbJCu4","id4G","AxHiyxe","rvbmrMS","zwrPyxrLBhK","EhbUzxe","tg1pwxq","yu9utNi","A0vcwKS","ihrPBwvZ","wKDgwfi","y29UBMvJDfm","D2fZq2XLyw4","z2v0u3rVCMe","tNvICgK","vfzIChC","z2XZCNC","wvDcruG","BgvY","DKD1vLC","Dhj1y3rVCIa","DuXpvMK","CgvYC2LZDgu","u3fkrvG","DMfSDwu","B2zMBgLUzq","zgPUwwG","uK94uuK","v3LdzhC","qxjKsxC","vxDguu4","Be1Yrw4","vLn4vfC","vgvMC0m","Cgf5Bg9Hza","CgLUz0XVC3m","AxbyzwO","tMfqshG","s0vMrgC","wLLAqMe","tg9Nsuq","BfHiDwO","Aw9U","B25QzuC","vvvmCfu","y3jLyxrLrxi","CMvUDevUzha","z3zxtvy","sfHyzfC","rLnorMu","EwfbyNy","yMXXsK0","BNLcqvm","igfYCMf5yNu","wfz4AxO","tgzks1K","AMfIEe0","BwfUDwfSihi","z2vtEw5J","tfrxvg0","zw5HyMXLvhi","twf2r2m","yw1Lu3bHy2u","CMvQzwn0","BvjTD2i","CMvHzfvjBNq","BgLUzw5V","Dw5ZAwDUzwq","DxLQAfq","wgTbquu","ywnRx2LK","EgzWDg0","B3bLCNr5tMe","ENbrCLi","yMLUza","zMzMzG","yMfJA3vWigu","zgf0yq","EKLxweq","uw5uD3m","uMHWDNm","y2fSBa","Cgu6ia","C3rVCMu","ihzHBgLKigq","C0TOruK","qNrqBwi","CMLLC0nVDw4","AxnszwfKEq","AM5uuue","uxzwvei","qwjVCNrfCNi","A2v5CW","CNzHBfzHBhu","zxLesva","C3jJ","D0HduuS","y2HHCKnVzgu","tKPTrwq","uvzXzMW","CMfUzg9T","AxnmB25N","BwLUzW","nhWXFdj8m3W","C0verwe","svfjwuK","ru9eDfu","tKDzv3G","yM9KEq","te5nDgi","s3ntueS","rKrIt2C","tg9NsurozxC","wLbtAwy","x29UvgLTzw8","wNHAs0G","uenksKC","B25VCgvU","CgLUz09Uy2u","CLzyt1i","zgv2AwnLx2K","EuX5r0m","rNnzy2y","wfPkru4","DgvZDa","D21rzNq","BeHHBMrSzxi","DgvmB2Djre4","tvbLCNq","ELPsAey","x2LUAxq","D1rlwfO","B2DuD1m","A05XDxq","EefRwfq","wNjOCwy","yxbWzw5Kq2G","EuXTvMu","uxvLDwu","yMrKD2q","rxrXwvu","tgrLAKW","BKjfqu4","tKDFrvjst1i","y0XcELm","uxnSEKu","x3fVC0rc","s3POt24","y2HLy2Tszwe","ufDYu1O","y2LAvem","yNL0zxm","t2jjsNK","x0rctMfTzq","Aw9UvgLTzw8","DeDHALi","ELjoA3y","tNHouK8","ser6r2W","te5ms0C","Dgjlu0u","rg5Ks04","x2n1CNnVCK0","ufjRuMC","x3jLywr5q2W","BgrVAKO","v0XTs2q","BMv4DcGPigm","AgPKzwC","CxjUq1q","EK12uhK","x3vYBa","Aw5KzxHpzG","nJu2nZzZEvDAwvm","uLvzrxu","wffoC2W","ywnXwwS","CMXVCNa","BgvUz3rO","sKvdtxa","B2rUvuu","BM9Uzv9UB24","rwnZB1e","y3LTuu4","B2zMC2v0","zgHJqMO","yMrFzgLK","Ae5HAu8","BMnVzgLUzW","jMPZy2fSBgi","x2rYB3bhBg8","zfj3sgm","x29Uq2XVC2u","C2vYDMvYvgK","zv90Aw1LB3u","CLDkzMS","y29UBMvJDca","x19LC01Vzhu","zw5JB2rPBMC","BfrPBwvVDxq","q1PMseC","rMDcsLe","u1vvtui","BvrTBuK","yKjgwfq","EMfmzuG","yvzurw8","tgr1uNa","qvrRBfO","zufrExG","vw5PBxbSzw0","CejZBvm","AwXLx25HBwu","mdaWma","zfjYt20","yKzwzMy","x2zVCM1HDeu","D1v5DwC","yM9L","BgLTAxq","qLH5B1a","wNfqtgK","yxrLq291BNq","vwTwvhi","tvzwsuW","suvtx0vsuK8","BM5Ly3q","rwTgzgK","whLtsuq","C1bWzNe","zw5KCg9PBNq","CNjVCK1LC3m","C2HPzNq","zxblwue","wvzjCu0","m3WXFdD8nq","m3WYFdr8mxW","BNrLCG","mNWZFdf8nhW","EMr2v0S","vxbKyxrLq28","rNvJAvm","uvzjDgm","BMCGDxjSoIa","AejVtvG","zxH0zw5ZAw8","AKHtz2q","zMX1C2HfEha","ChPjtgW","y29UC3rYDwm","vxv2wu8","wxzTDwK","CLPfuNm","zxrxB3jRq2G","zxjHDg9Y","yxnTvfC","wgHIExm","x21PBMLoyxy","yNvMA2O","DhLRtM8","z2v0t3DUuhi","DhjHBNnHy3q","B2fK","wfbtveS","u3rYyxrLz3K","BfDMwKq","x3bYB3rVy28","C3nrC2i","DxfTvwe","y3vYDMfSDwu","ChrVCG","Dg9iyxnO","r0vNBxC","AwDHDg9Yt24","D3m6lY8","z3LUwhG","yMfSrxzLBNq","AevYCM9Yrxy","Ec1TC2CTCw8","uvvdwgW","zg5NuM0","CMzjr28","BurMrwG","ywrKrxzLBNq","x2LZv29YA2u","m3WXFdb8nhW","AeL3r1e","vNPWBeC","Ef9MCM9UDgK","tvDiuxm","vwH5Dxq","v0XKsum","zvb1wee","B25mAw5L","mJDcwwvnA2S","y2HnyxHdB3u","x2jPBMfYEvq","BKXPBMu","uvH3rgK","zMLUza","sePjAeW","A1HMshK","zfbvt1q","AwXLtMfTzq","uLnvD1q","BwHNsgC","ue9QDei","uxLrs0i","t1ztDwi","zNrvsxC","Dg9cExrLC0W","CMvJzxzPzwq","zxq9DxrMltG","t0LtEgi","tMTls1e","sNDVBMy","Aw9Ul2PZB24","C2fNzq","vNzpsKy","u3zJDee","sufyuKS","ze10CMW","B3jpBMXPBMu","zfLirKu","C29YDa","BMP3u0q","v2nKruy","CMvWBgfJzq","CM92AwrLihC","seXSvgq","DMfS","vKncs2S","C2LxvhO","EwT2BeK","y2XLyxjtDg8","DgPyzgm","x2LZsw5PDa","zgLZCgf0y2G","BfPXt2m","sNvcswe","sLHfuuS","wMLszNO","v25PBKC","DMvY","ywzL","tujPsKW","C0Xf","Dhr3Awq","sLnptLa","wNbbz0y","Cw9Z","zw5XDwv1zq","CND0vLi","r3rvq04","D3nZoI8V","q3vZDg9Trxi","zxH0ugf5Bg8","reLptgW","DxPwCuq","vgLTzw91Da","AMzHzfy","qxrtwfK","CMfTzq","AeLMCfe","wgDsz2i","B3nLrxzLBNq","txfuCha","BNrbBMrvCgq","De1Kwve","x2LZtwLUAvC","zgHIExy","Aw47y2HHCNm","qM95z24","r0LqENy","wKjyzLi","qwj5C28","yLztt2y","C29Tzq","lcbxzwjtB2m","CMvZB2X2zq","wfvhwfi","y3jLyxrLq2W","vvHcC0m","C0jf","B1bSELO","ywvmrgi","AvPqtuG","zxjFCw9Zx2e","Ae1LC3nHz2u","AwjTBvC","zMzKDxe","yMfSu2nVCgu","C3rLBMvYCW","B2nRzxq","EuT0BeO","y2XVC2u","Be1yqxK","s0TJuKq","vMnNsKC","rxjYB3jdB2q","uNz6r2y","A2v5","uM56CLC","DgzHCfm","C05Ky2e","tgn2Aey","thDQB2q","whbYsNC","ufPYwMu","C2v0","uu5VCvC","AgfZt3DUuhi","ywjVCNq","x2DLDeLUDgu","y2ncshu","uLrUtKy","zMLWrhK","Aw5JBhvKzxm","EwvkyvC","CgLUz0LUDgu","rgfsB2u","ueDhvhq","rxPIENi","vK1rwwi","ue5ACMG","yMLUyxj5vhK","ywDL","x2HHBMrSzu8","BxnN","zw1PDa","C3rHCNq","yw5Hz2vY","C3bSAxq","EvjLy29UBMu","q09oveLovuu","x25HDMLNyxq","A3vsB0C","D21zD0i","vej6DuW","ywDLsgLKzq","rxvYCuC","A2jYtwy","D1jcyLu","EfvZzuvUDG","D2vI","uNfPsKu","D1LoyuO","yxbptwm","wwrowfe","zu9PEMu","qw1VDw50","zgvSzxrLrge","AvLbDgW","sKneBhe","yw5Nzq","wKfqzhy","s0XRyve","tgn5Cey","B25JBg9Zzq","weT1sMG","wNLpzfG","Bwf4uMv0CMK","igzHAwWSig0","ywXSzwqGBxu","zw50","tgLZDgvUzxi","CwTkvwW","q291BNq"];return io=function(){return t},io()}function ay(t){let e=N,r={MwHDx:function(s,a){return s(a)},AFevu:function(s,a){return s(a)},YzuVZ:function(s,a){return s|a},PSvdU:function(s,a){return s===a},HBGRY:function(s,a){return s(a)},UMESx:function(s,a){return s(a)},pNJSJ:function(s,a){return s===a},ciZTC:function(s,a){return s in a},TwyRG:e(994)+e(809),EbPRW:function(s){return s()}};return r[e(1658)](t,IDBDatabase.prototype.transaction)&&!r[e(1152)](r.TwyRG,IDBTransaction.prototype)?function(s,...a){let c=e,f=t.call(r[c(1700)](Si,this),s,...a);return Cc.set(f,s[c(1326)]?s.sort():[s]),r[c(1597)](Dt,f)}:r.EbPRW(ry)[e(1419)](t)?function(...s){let a=e;if(r[a(622)]("uiCRd","uiCRd"))return t[a(1807)](Si(this),s),r[a(577)](Dt,Ac[a(1556)](this));this[a(1103)]=!0,this[a(654)]=r[a(1724)](0,_0x54cd9e),this[a(713)]=0|_0x99c1c9,this[a(1069)]=!!_0x15d4bf}:function(...s){let a=e;return r[a(1783)](Dt,t[a(1807)](r[a(1597)](Si,this),s))}}function cy(t){let e=N,r={Cadzb:function(s,a){return s===a},FHHjB:e(501),tUyoK:function(s,a){return s(a)},BxFGW:function(s,a){return s instanceof a},DYHVx:function(s,a,c){return s(a,c)},QGiHL:function(s){return s()}};return r.Cadzb(typeof t,r.FHHjB)?r[e(516)](ay,t):(r.BxFGW(t,IDBTransaction)&&r[e(516)](sy,t),r[e(1625)](du,t,r[e(624)](ny))?new Proxy(t,ao):t)}function Dt(t){let e=N,r={GIPzv:function(a,c){return a instanceof c},zIWXD:function(a,c){return a(c)},fnKrb:function(a,c){return a(c)},hIwGQ:function(a,c){return a!==c},Uzulg:e(1746)};if(r[e(1375)](t,IDBRequest))return r[e(1080)](iy,t);if(no[e(819)](t))return no[e(1556)](t);let s=r[e(1817)](cy,t);if(r[e(1288)](s,t))if(r[e(1288)](r[e(854)],e(681)))no[e(1411)](t,s),oo[e(1411)](s,t);else return this[e(823)]?this[e(823)][e(1427)+"pe"]:this[e(1298)+"ype"];return s}var du,ru,iu,Ac,so,Cc,no,oo,ao,Si,su=cu({"node_modules/idb/build/wrap-idb-value.js"(){let t=N,e={HSylQ:t(629),VSxTW:function(r,s){return r===s},jcVeC:t(759),GWsMW:t(1842),KEfDg:function(r,s){return r===s},pvnjp:"objectSt"+t(809),rZERs:function(r,s){return r===s},aNqFS:t(1085),mhgHg:function(r,s){return r-s},Vxgyv:function(r,s){return r<s},kBEpH:function(r,s){return r>=s},juHNS:function(r,s){return r<s},zfiLs:function(r,s){return r|s},eWacj:function(r,s){return r<<s},xfptm:function(r,s){return r&s},tGajR:function(r,s){return r<s},rizPo:function(r,s){return r|s},KqbNE:function(r,s){return r<<s},ZVTUe:function(r,s){return r>=s},QnTws:function(r,s){return r-s},ZnUvz:function(r,s){return r|s},EWnhK:function(r,s){return r&s},FWRCQ:function(r,s){return r&s},KELRF:function(r,s){return r+s},Ezbzr:function(r,s){return r>>s},ZMEUL:"QdiWv",nLZKi:function(r,s){return r===s},QsdPT:function(r,s){return r in s}};du=(r,s)=>s[t(1379)](a=>r instanceof a),Ac=new WeakMap,so=new WeakMap,Cc=new WeakMap,no=new WeakMap,oo=new WeakMap,ao={get(r,s,a){let c=t,f={PNyZW:e.HSylQ};if(r instanceof IDBTransaction)if(e[c(1034)](e.jcVeC,e[c(940)])){if(e[c(1034)](s,e[c(456)]))return so[c(1556)](r);if(e[c(1040)](s,e.pvnjp))return r[c(994)+c(809)]||Cc.get(r);if(e[c(1254)](s,e[c(525)]))return a["objectSt"+c(809)][1]?void 0:a[c(994)+c(1673)](a[c(994)+"oreNames"][0])}else this[c(1431)](f.PNyZW,_0xeadd27(f[c(421)],{..._0xd0dec4}));return Dt(r[s])},set(r,s,a){let c=t;if(e[c(1040)](e[c(738)],c(1478)))return r[s]=a,!0;{if(e[c(1307)](_0x503268,_0x2ec007)<1)return"";let f="";for(let u=_0x2e5cc1;e[c(1729)](u,_0x553cb8);){let x=_0x6c4d1d[u++];if(x<=127)f+=_0x1d9de7[c(1885)+c(1741)](x);else if(e[c(810)](x,192)&&e[c(787)](x,224))f+=_0x2b3869[c(1885)+c(1741)](e[c(1605)](e.eWacj(e[c(1073)](31,x),6),e[c(1073)](63,_0x5483f4[u++])));else if(e[c(810)](x,224)&&e[c(1157)](x,240))f+=_0x42c15d[c(1885)+c(1741)](e[c(614)](e[c(1605)](e.eWacj(e[c(1073)](15,x),12),e[c(1537)](e.xfptm(63,_0x3ea29d[u++]),6)),e.xfptm(63,_0x8d88e9[u++])));else if(e[c(964)](x,240)){let p=e[c(1081)](e[c(1605)](e.ZnUvz((7&x)<<18,e[c(1537)](e.EWnhK(63,_0x6a9cdb[u++]),12)),e[c(1669)](e[c(1601)](63,_0x43cb8a[u++]),6))|e[c(1073)](63,_0xa37122[u++]),65536);f+=_0x331326[c(1885)+c(1741)](e[c(843)](55296,e[c(1424)](p,10))),f+=_0x27c62a["fromChar"+c(1741)](e[c(843)](56320,1023&p))}}return f}},has(r,s){let a=t;return r instanceof IDBTransaction&&(e[a(958)](s,e.GWsMW)||e[a(1040)](s,e[a(525)]))?!0:e[a(1657)](s,r)}},Si=r=>oo.get(r)}}),fu={};ty(fu,{deleteDB:()=>fy,openDB:()=>dy,unwrap:()=>Si,wrap:()=>Dt});function dy(t,e,{blocked:r,upgrade:s,blocking:a,terminated:c}={}){let f=N,u={FDeTc:f(1397),FhstX:f(911)+"eeded",jJrWk:"blocked"},x=indexedDB[f(1582)](t,e),p=Dt(x);return s&&x[f(1285)+"Listener"](u.FhstX,_=>{let E=f;s(Dt(x[E(903)]),_[E(904)+"on"],_[E(1875)+"on"],Dt(x[E(1263)+E(1044)]))}),r&&x[f(1285)+f(1467)](u[f(617)],()=>r()),p.then(_=>{let E=f;c&&_[E(1285)+E(1467)](u[E(523)],()=>c()),a&&_.addEventListener(E(1813)+E(1637),()=>a())})[f(653)](()=>{}),p}function fy(t,{blocked:e}={}){let r=N,s=indexedDB[r(1453)+r(1630)](t);return e&&s[r(1285)+r(1467)]("blocked",()=>e()),Dt(s)[r(612)](()=>{})}function ou(t,e){let r=N,s={RaKYw:function(x,p,_){return x(p,_)},ePuXA:r(925)+"e",YIcpb:r(1652),tIpgt:function(x,p){return x in p},yeJaW:function(x,p){return x===p},pTAIW:r(868),tZCaN:function(x,p){return x!==p},jabxM:function(x,p){return x!==p},VSyPT:"XVjIb"};if(!(t instanceof IDBDatabase&&!s[r(520)](e,t)&&s[r(1420)](typeof e,s.pTAIW)))return;if(ro.get(e))return ro.get(e);let a=e.replace(/FromIndex$/,""),c=s[r(1474)](e,a),f=uu.includes(a);if(!s[r(520)](a,(c?IDBIndex:IDBObjectStore)[r(1528)+"e"])||!(f||lu.includes(a)))if(s[r(1058)](s[r(1613)],r(480)))_0x381434(_0x1ae8af,16),s[r(768)](_0x5c00ff,_0x4778eb,_0x30d375);else return;let u=async function(x,...p){let _=r,E=this[_(1263)+"ion"](x,f?s[_(1294)]:s[_(1685)]),C=E[_(1085)];return c&&(C=C[_(908)](p[_(1234)]())),(await Promise.all([C[a](...p),f&&E[_(1842)]]))[0]};return ro[r(1411)](e,u),u}var lu,uu,ro,ly=cu({"node_modules/idb/build/index.js"(){let t=N,e={kpaBN:function(r){return r()},NJgqa:function(r){return r()},jDlmP:t(1556),JQOaV:t(1792),Xyftv:t(939)+"ys",qUjYz:"count",GfJNT:t(761),HLlTd:t(744),MaJgb:t(1743),EAzZC:t(807),qSNEk:function(r,s){return r(s)}};e[t(938)](su),e.NJgqa(su),lu=[e[t(459)],"getKey",e.JQOaV,e[t(1908)],e[t(1600)]],uu=[e.GfJNT,e[t(1331)],e[t(592)],e[t(711)]],ro=new Map,e[t(1903)](oy,r=>({...r,get:(s,a,c)=>ou(s,a)||r[t(1556)](s,a,c),has:(s,a)=>!!ou(s,a)||r[t(819)](s,a)}))}}),uy={idb:function(t){let e=N;t[e(900)]=Promise[e(1381)]()[e(612)](()=>(ly(),fu))[e(612)](function(r){return r})}},au={};function Rt(t){let e=N,r={XRPlN:e(1628)+"4"},s=r.XRPlN[e(1434)]("|"),a=0;for(;;){switch(s[a++]){case"0":if(c!==void 0)return c[e(900)];continue;case"1":var c=au[t];continue;case"2":uy[t](f,f[e(900)],Rt);continue;case"3":var f=au[t]={exports:{}};continue;case"4":return f.exports}break}}Rt.d=(t,e)=>{let r=G;for(var s in e)Rt.o(e,s)&&!Rt.o(t,s)&&Object[r(906)+r(946)](t,s,{enumerable:!0,get:e[s]})},(()=>{let t=N;Rt.o=(e,r)=>Object[t(1528)+"e"][t(1413)+t(946)][t(1083)](e,r)})(),(()=>{let t=N,e={QslzE:function(r,s){return r!=s},SYyZa:t(806)+"d",ruePq:t(562),YsPCn:t(1199)+"le"};Rt.r=r=>{let s=t;e[s(1147)](e[s(1898)],typeof Symbol)&&Symbol[s(1527)+s(1706)]&&Object[s(906)+s(946)](r,Symbol["toString"+s(1706)],{value:e.ruePq}),Object[s(906)+s(946)](r,e[s(1542)],{value:!0})}})();var Se={};(()=>{let t=N,e={uCMGI:function(o,n){return o(n)},CEcFp:function(o,n){return o+n},NpBQZ:function(o,n){return o+n},YdNXQ:function(o,n){return o*n},Uhyut:function(o,n){return o*n},hsVSc:function(o,n){return o+n},nOEjb:function(o,n){return o+n},iZPMH:t(1215),RTnNF:t(1077),MTAIW:function(o,n){return o(n)},IAUrc:t(1932)+"00000000"+t(1932)+"00000000",bIicW:function(o,n){return o(n)},SUUMB:function(o,n){return o+n},QzYOL:function(o,n){return o(n)},zpQrR:function(o,n){return o+n},lZqOc:function(o,n){return o||n},wYNaJ:function(o,n){return o>n},WRFhO:function(o,n){return o<n},fUNeO:t(1442),RSUwT:function(o,n){return o<n},bSUsM:function(o,n){return o!==n},Kpjxb:function(o,n){return o-n},PNZrh:function(o,n){return o!==n},ibmmW:function(o,n){return o===n},nmhzB:t(1230),tdEEN:t(697),eJOJg:t(1476),KNuOU:t(753),kbyIf:function(o,n){return o>>>n},PEXIX:function(o,n){return o&n},XFOMv:function(o,n){return o>>>n},ATklZ:function(o,n){return o+n},uyjhT:function(o,n){return o>>>n},FuciS:t(422),PCkum:t(1508),QtQVn:function(o,n,i){return o(n,i)},Lwjod:function(o,n,i){return o(n,i)},QyQKB:function(o,n){return o(n)},zIjWa:function(o,n){return o===n},BQGHe:function(o,n){return o===n},jjjTL:t(467)+t(1860)+" field: "+t(1026),bciCq:t(658),OlMlC:t(508),ykvlI:function(o){return o()},wAZao:"blocked",oDDsU:function(o,n,i){return o(n,i)},EcsoQ:function(o,n){return o>>>n},LBrON:function(o,n){return o!==n},xVwrJ:function(o,n,i){return o(n,i)},kVzFM:function(o,n){return o!==n},LLLlC:t(1732),BGvaH:function(o,n){return o!==n},TOuSM:function(o,n,i){return o(n,i)},vvgOK:function(o,n,i){return o(n,i)},kXfHy:function(o,n){return o(n)},apOMc:function(o,n,i){return o(n,i)},CDjhb:function(o,n){return o!==n},ihltd:function(o,n){return o(n)},TFCcG:t(1038),GeyGh:function(o,n,i){return o(n,i)},asmTW:function(o,n){return o!==n},jgbuT:t(1831),TlxDB:t(804),Kqpqg:function(o,n,i){return o(n,i)},IAXRK:function(o,n,i){return o(n,i)},glsrw:function(o,n,i){return o(n,i)},DyQuw:function(o,n,i){return o(n,i)},YfogQ:function(o,n,i){return o(n,i)},DMEWk:t(1475),cMYeD:function(o,n,i){return o(n,i)},Vlqew:function(o,n,i){return o(n,i)},dQLMf:function(o,n){return o(n)},yyJfP:function(o,n){return o(n)},ogTwS:function(o,n){return o(n)},RPdCB:function(o,n){return o(n)},Hpcpw:function(o,n){return o&n},UWkOG:t(467)+t(1860)+t(1825)+t(541),yJIGY:t(467)+t(1860)+t(1825)+t(626),hdJCr:t(467)+t(1860)+t(1825)+t(509),vzXJg:function(o,n,i){return o(n,i)},sgnsk:t(1212)+t(1871)+t(1084),dPUOT:function(o,n){return o>>n},aBKye:function(o,n){return o>=n},diSTU:function(o,n){return o!==n},LmOYt:t(797),CGcRj:"fYYxp",DBAeU:function(o,n){return o!==n},DXEih:t(1121),KzWkC:t(1163),bBFXT:"Skip pas"+t(705),WLdIC:function(o,n){return o>>n},pBsmS:t(1562),oWfWM:"Read pas"+t(705),rxtZX:function(o,n){return o+n},hjdeg:function(o,n){return o!=n},lRnyH:t(868),DOEwT:t(920)+t(1318),eYfoA:function(o,n,i){return o(n,i)},CrRBf:function(o,n){return o&n},svFmg:function(o,n){return o>=n},JCDlq:function(o,n){return o+n},IQIYI:function(o,n){return o+n},tykNo:function(o,n){return o|n},myIEi:function(o,n){return o&n},qqauq:function(o,n){return o&n},UfAzn:function(o,n){return o(n)},NyZfF:function(o,n){return o+n},lFQWZ:function(o,n){return o|n},TBwCj:function(o,n){return o<<n},fipDy:function(o,n){return o&n},iVVHw:function(o,n){return o&n},RvzGf:function(o,n){return o<=n},UcRZC:function(o,n){return o(n)},PDcHl:function(o,n){return o==n},upkxH:function(o,n){return o!==n},sEDEa:"ioiNb",lMXAy:function(o,n){return o+n},HXXdW:function(o,n){return o!==n},nbTiH:function(o,n){return o&n},dSbwB:function(o,n){return o|n},BeFKA:function(o,n){return o|n},dlLRO:function(o,n){return o|n},QFSBb:function(o,n){return o<<n},qoYrn:function(o,n){return o&n},UwFQN:function(o,n){return o<<n},APwkp:function(o,n){return o<<n},AwlOS:function(o,n){return o<n},ggsGt:function(o,n){return o&n},PlTRG:function(o,n){return o<n},ZqPLi:function(o,n){return o>=n},eLteC:function(o,n){return o<=n},XTUID:function(o,n){return o+n},YWBEH:function(o,n){return o-n},ZxZKH:function(o,n,i){return o(n,i)},KXpCH:function(o,n){return o<n},XKuJh:function(o,n){return o<n},hLIWT:function(o,n){return o<<n},VzplG:function(o,n){return o<n},imFkH:function(o,n){return o|n},aYpma:function(o,n){return o&n},sRJmF:function(o,n){return o|n},oxIbz:function(o,n){return o&n},POjdQ:function(o,n){return o|n},HCkiH:function(o,n){return o&n},WbchE:function(o,n){return o>>n},dIJAf:function(o,n,i){return o(n,i)},XZJEN:function(o,n){return o<n},QccVh:function(o,n){return o!==n},WvtiI:t(1248),kNqut:function(o,n,i){return o(n,i)},djnYh:t(1925)+"t",TWCQw:t(1675),aGiJW:function(o,n){return o<n},VHone:function(o,n){return o<<n},LduRp:function(o,n){return o&n},ZhNUV:t(1854),aeLDb:function(o,n){return o&n},Tubwu:"idb",NaPHx:function(o,n){return o(n)},PfwwI:"qUVtK",yjmPz:t(836),LfJKY:function(o,n){return o<<n},JYDGL:function(o,n){return o&n},rlorp:function(o,n){return o!==n},jrupC:"QlxCR",bVSOf:function(o,n){return o(n)},YmqWe:function(o,n){return o<<n},XyYKK:function(o,n){return o(n)},mmlBe:function(o,n){return o<<n},JafDW:function(o,n){return o&n},WyqmE:function(o,n){return o&n},ZPSif:function(o,n){return o<<n},QNoqW:function(o,n){return o&n},eKNUS:function(o,n){return o&n},HcZKT:function(o,n){return o<<n},Svfqh:function(o,n){return o|n},Boygn:function(o,n){return o>>>n},fYeke:function(o,n){return o<n},lBXLz:function(o,n){return o<n},bpncM:function(o,n){return o<n},TefsC:function(o,n){return o<n},uHBic:function(o,n){return o<n},QyIzZ:function(o,n){return o>>>n},JuBIa:function(o,n){return o&n},eAQyx:function(o,n){return o!==n},RUYEu:function(o,n){return o>>>n},junmx:function(o,n){return o+n},GIdvd:function(o,n){return o!==n},SKGAB:function(o,n){return o&n},onRyh:function(o,n){return o>>>n},UKqQs:function(o,n){return o+n},ISxLK:function(o,n){return o!==n},uYdKj:function(o,n){return o|n},wTdOd:function(o,n){return o+n},tDUAe:function(o,n){return o!==n},DaRoe:function(o,n){return o|n},UjnwL:function(o,n){return o>>>n},SMdDQ:function(o,n){return o+n},DAUZG:function(o,n){return o!==n},Qkghm:function(o,n){return o|n},bfOye:function(o,n){return o>>>n},ffGla:function(o,n){return o&n},SNAUF:function(o,n){return o+n},dRwHc:function(o,n){return o!==n},Updjj:function(o,n){return o!==n},pzILl:function(o,n){return o(n)},YfSHE:function(o,n){return o(n)},wUfZh:function(o,n){return o|n},GtUCN:function(o,n){return o>n},kBepu:function(o,n){return o&n},wZzxF:function(o,n){return o+n},ztFur:function(o,n){return o!==n},nYvWN:t(789),KfYee:function(o,n){return o===n},GEgmw:function(o,n){return o|n},uBNBd:function(o,n){return o|n},zfeax:function(o,n){return o>>n},vIyaB:function(o,n){return o&n},TRUpu:"QfEDV",ucvdN:function(o,n){return o|n},NgTwq:function(o,n){return o|n},bLlwd:function(o,n){return o|n},DRKQI:function(o,n){return o<<n},wTKXZ:function(o,n){return o<<n},KkhaL:function(o,n){return o|n},dETdj:function(o,n){return o|n},DrHID:function(o,n){return o|n},OVSub:function(o,n){return o|n},ghPMp:function(o,n){return o|n},zZNyr:function(o,n){return o&n},CwJGn:function(o,n){return o>>>n},XnTiu:function(o,n){return o&n},akEKP:function(o,n){return o>>>n},MaFFv:function(o,n){return o>>>n},wOSdS:function(o,n){return o>>>n},bjSfE:function(o,n){return o&n},MTByU:function(o,n){return o>>>n},FwDEw:function(o,n){return o+n},rcrMt:function(o,n){return o|n},OfGkv:"SXphp",TEIxA:function(o,n){return o+n},SvctA:function(o,n){return o*n},blqJM:function(o,n){return o>>>n},SNRQo:function(o,n){return o>>>n},NfAsi:function(o,n){return o+n},vLxqT:function(o,n){return o!==n},MApld:t(1017),dDhcy:function(o,n){return o===n},tjXdc:function(o,n){return o instanceof n},dECWq:t(901),Abyso:function(o,n,i){return o(n,i)},btxXO:function(o,n){return o!==n},TItCa:"wyfAl",pbQbS:function(o,n){return o>>>n},xjCuF:function(o,n){return o&n},FSNFe:function(o,n){return o>>>n},kqHYN:function(o,n){return o>>>n},BTSsv:function(o,n){return o>>>n},YVIqM:function(o,n){return o+n},qGwhR:function(o,n){return o|n},fDjPX:function(o,n){return o!==n},PGGTt:function(o,n){return o===n},ZyTuF:function(o,n){return o===n},XVxiz:function(o,n){return o+n},PfMbh:function(o,n,i){return o(n,i)},wOqhn:t(1432),XkAAE:"CdRVd",wkmCi:function(o,n){return o&n},FGExk:function(o,n){return o&n},ajigR:function(o,n){return o>>>n},KILMo:function(o,n){return o>>>n},RiBWX:function(o,n){return o>>>n},tMdYQ:function(o,n){return o>>>n},UXBsC:function(o,n){return o&n},QjBzP:"4|3|5|2|0|1",RcTBJ:t(526)+"OR",vsZFH:t(997)+t(497),kbrMf:"CONNECTI"+t(1145),UtjYt:t(912)+"RROR",gtckM:t(1730)+t(1227)+"R",qrnCT:function(o,n){return o===n},ZYZBa:t(483),vTRQT:t(678),uLOVi:"PZfFi",EkFdi:t(748)+t(1496),eOize:function(o,n){return o+n},xzSRk:function(o,n){return o===n},veHmX:function(o,n,i){return o(n,i)},WxRhZ:t(1397),FEmzU:"open",wmYwB:function(o,n,i){return o(n,i)},PQglS:function(o,n,i){return o(n,i)},AkyzW:t(629),bFVff:function(o,n){return o<n},RUByE:function(o,n){return o-n},vCWCn:function(o,n){return o+n},vcahI:function(o,n){return o|n},dzLZe:function(o,n){return o&n},HDzGl:function(o,n){return o&n},Ayvhc:function(o,n){return o&n},wmQft:function(o,n){return o|n},xsdNy:function(o,n){return o&n},gyLcp:function(o,n){return o>>n},jfadV:function(o,n){return o|n},UuvYO:function(o,n){return o&n},lXHuj:function(o,n){return o===n},kIqav:t(1244),BMYEF:function(o,n){return o+n},qZScm:t(1740),adOBI:t(813),XCwsz:function(o,n){return o*n},ZbmnN:function(o,n){return o-n},RLHSJ:function(o,n){return o>n},VCBKk:t(1791),qoTmp:t(1316),DWfua:"xCbnF",nnDGr:function(o,n){return o-n},PWrSZ:t(1382),Pbkxj:t(1774),ZyOdX:function(o,n){return o!=n},DIOLl:t(806)+"d",qfeWV:function(o,n){return o!=n},YosHP:t(1169)+t(1465)+"ltiple times in "+t(1926),ytdPO:function(o,n){return o!==n},bCJOJ:t(1591),GESMs:function(o,n){return o<n},xFEMl:function(o,n){return o<n},cfgYo:function(o,n){return o===n},XWnnK:function(o,n){return o&n},yAufF:function(o,n){return o+n},SGozM:function(o,n){return o<n},qbQRq:function(o,n){return o-n},KFStD:function(o,n){return o<=n},tbKSE:function(o,n){return o&n},BAyuY:function(o,n){return o&n},McNzn:function(o,n){return o&n},Nubpi:function(o,n){return o&n},BOyXj:function(o,n){return o-n},LXUeU:function(o,n){return o<<n},dOamY:function(o,n){return o&n},nMNgQ:function(o,n){return o<<n},sDACd:function(o,n){return o&n},NAtiG:function(o,n){return o+n},voIux:function(o,n){return o<n},YdoQZ:function(o,n){return o<n},YlyGA:function(o,n){return o|n},sPpfq:function(o,n){return o===n},GWPWv:function(o,n){return o===n},odnUE:function(o,n){return o&n},orhRL:function(o,n){return o&n},pnNYU:function(o,n){return o>>n},KKcRD:function(o,n){return o|n},wzkeQ:function(o,n){return o>>n},htGZM:function(o,n){return o&n},WyCdw:function(o,n){return o&n},OgrVf:function(o,n){return o|n},cXsMy:function(o,n){return o>>n},KXUVd:function(o,n){return o-n},sisqj:function(o,n){return o==n},EPLFk:t(1136),IvpuP:function(o,n){return o(n)},uPUZt:function(o,n,i,d){return o(n,i,d)},gMAqx:t(693)+">",wTDNV:t(1858),cYFSl:t(1726),YhAks:function(o,n){return o!=n},NGYWx:function(o,n){return o instanceof n},LdejL:function(o,n){return o!=n},sFRYp:t(1884)+"in;chars"+t(1314),XYUBQ:t(968),SSxJZ:t(1072),dhbyv:function(o,n){return o||n},rAtKZ:"hMOjY",hUEHd:function(o,n){return o>=n},uqmUa:"unknown "+t(515),UWNAR:t(1842),poffs:function(o,n){return o===n},VXsWE:function(o,n){return o===n},mqIEh:"text/jav"+t(445),FJJVt:function(o,n){return o+n},olWET:t(722),mOXWf:t(1778),wRBbU:function(o,n){return o===n},mjsTS:t(1644),zfSxf:function(o,n){return o===n},zHGoI:t(1511),ZAPdv:t(1608),sKhEI:t(1612)+t(554)+t(659)+"ine",QlLNA:function(o,n){return o!==n},tThNF:t(1327),kEBZK:"NplnN",LNLKG:function(o,n){return o&n},BdGPN:function(o,n){return o>>>n},CSWAB:function(o,n){return o>>>n},VcgJG:function(o,n){return o>>>n},QMdtN:t(1235),zMvPy:function(o,n){return o||n},dhcBj:function(o,n){return o||n},rWJfk:function(o,n){return o||n},IrRAp:function(o,n){return o||n},ufbCb:function(o,n){return o||n},Zrhqf:function(o,n){return o!=n},oPlzZ:t(987)+"DB failed",JHVqk:t(1733),ddLPD:t(1352),uIYpk:"message_id",cLBzS:function(o,n,i){return o(n,i)},SqJEX:t(1708),CypzR:t(1290)+t(417),MBiJL:"x_fronti"+t(1881)+"k",ynKtu:t(1290)+t(451)+"sgid",POOpH:function(o,n){return o&&n},VUZlO:t(1225),KsSPK:"wxeik",Lnjfc:t(506),loZqT:function(o){return o()},LuSKq:t(1678),sySWw:function(o,n){return o>>>n},TytwF:function(o,n){return o>>>n},zIAYz:function(o,n){return o<<n},VwuQs:function(o,n){return o>>>n},UFiXe:function(o,n){return o<n},srAQf:function(o,n){return o<n},hiSKD:function(o,n){return o<n},QUCXl:function(o,n){return o+n},mjUdE:function(o,n){return o&n},wJYXs:function(o,n){return o+n},SgcFL:function(o,n){return o|n},JECMp:function(o,n){return o&n},IvbsY:function(o,n){return o!==n},vzIRh:function(o,n){return o+n},mypkz:function(o,n){return o>>>n},wODXQ:function(o,n){return o>>>n},eyDIP:function(o,n){return o&n},bkWtg:function(o,n){return o(n)},jnTQA:function(o,n){return o(n)},mRmwb:function(o,n){return o===n},sgYFS:"xSCKR",XBToC:t(1100),JOoZP:function(o,n){return o instanceof n},jYJfD:t(920)+t(1318)+t(750)+"=utf-8",hNaiO:t(1183)+"e",xXxLe:t(634),lMrEn:function(o,n,i,d){return o(n,i,d)},MOTbc:t(969),ZCWbT:t(1815),IoeQn:function(o,n){return o||n},MvUCa:function(o,n){return o(n)},QTziK:function(o,n){return o+n},mDfEh:t(438),hQBjj:t(482),ROxQI:"integer "+t(932)+"e",tfapS:function(o,n){return o>=n},Llfti:function(o,n){return o+n},zxEpm:function(o,n){return o>>>n},EtqYU:function(o,n){return o+n},basKz:function(o,n){return o!==n},vSzCn:t(1636),xVAMc:t(1667),gNhgo:"1|0|3|2|4",OISxb:function(o,n){return o<n},ldojJ:function(o,n){return o===n},HlWMh:function(o,n){return o===n},JKbAZ:"DWbuE",QswVC:function(o,n){return o|n},aVmeK:function(o,n){return o|n},ohQKP:function(o,n){return o<<n},bvCss:function(o,n){return o+n},MRwAw:function(o,n){return o|n},mlfjM:function(o,n){return o+n},PEozs:function(o,n){return o<<n},VRZCM:function(o,n){return o+n},PRFGr:"2|1|3|0|4",rQLXx:function(o,n){return o===n},ZiRfz:t(717),srpxv:function(o,n){return o+n},dngRm:function(o,n){return o&n},qdtbU:function(o,n){return o+n},OMTJR:function(o,n){return o&n},McFMy:function(o,n){return o>>>n},gGYmX:function(o,n){return o+n},gnnhm:function(o,n){return o&n},aztRP:function(o,n){return o>>>n},pqXwg:function(o,n){return o&n},DvBgQ:function(o,n){return o+n},mFTvx:function(o,n){return o&n},bddwd:function(o,n){return o|n},HJysn:function(o,n){return o&n},dxMZW:function(o,n){return o&n},KukxU:function(o,n){return o>n},LcvhF:function(o,n){return o+n},FsYcf:function(o,n){return o+n},sAlJN:function(o,n){return o&n},zIbOz:"QtMLR",IhfHI:function(o,n){return o>>>n},aiOaE:function(o,n){return o<n},jZvAL:function(o,n){return o>>>n},RGthF:function(o,n){return o|n},jweUe:function(o,n){return o&n},twTTE:function(o,n){return o|n},acqYk:function(o,n){return o>n},sJYpI:t(1901),CzcDc:t(626),wOnLz:function(o,n,i,d){return o(n,i,d)},dWzcR:"service-"+t(718),QvVTB:t(718),oyqNf:t(1271),Vekof:function(o,n){return o(n)},RGEWm:"FILE_NOT"+t(1617),JedGy:function(o,n,i,d){return o(n,i,d)},yLDZo:t(1436),aUUJk:"setdb",pvATe:function(o,n){return o===n},XPSTK:t(440),aumEI:function(o,n){return o!==n},mjegT:function(o,n,i,d){return o(n,i,d)},Uwleo:function(o,n,i,d){return o(n,i,d)},tjFzP:t(1290)+"er_msgid",rfIGo:function(o,n){return o(n)},npuwm:t(1290)+t(429),aZwXV:function(o,n,i,d){return o(n,i,d)},BRlvm:t(1280)+"s",XLycw:function(o,n,i){return o(n,i)},ZpAgF:function(o,n){return o(n)},zdvWK:"x-msg-cu"+t(921)+"ue",suQvG:function(o,n){return o>n},LTmBD:function(o,n){return o>n},aOTNr:t(1676),HJIhL:t(1697),uzVqD:function(o,n){return o+n},pjZEb:function(o){return o()},MyfDv:function(o,n){return o==n},HUEYU:t(1631),vhwON:t(1356),lkLhY:"ws://",XRIGD:"yKtlJ",DVvEz:function(o){return o()},sEPvy:function(o){return o()},ssQsb:function(o,n){return o===n},vXfDU:function(o,n){return o===n},FOhlb:function(o){return o()},MlAXc:function(o){return o()},FKfOh:function(o,n){return o(n)},EODtU:function(o){return o()},WfZgX:function(o){return o()},kOVaY:t(1878),JXEQK:t(970)+"e_success",ybVVV:t(833),RpBDA:function(o,n){return o===n},DzexM:function(o,n,i,d){return o(n,i,d)},vdiTr:t(474),vLgQV:function(o,n,i){return o(n,i)},ptkqd:function(o,n,i){return o(n,i)},xbVLB:function(o,n){return o==n},ftUIw:function(o,n){return o!==n},aMIbB:t(1059)+"econnect"+t(1530),oYrsN:function(o,n,i){return o(n,i)},doCsC:function(o,n){return o!==n},wnApx:function(o,n,i){return o(n,i)},OfPOL:t(1771),nyBAS:t(1681),UqSBa:t(832),kuRoG:t(1325),ODVev:t(885)+t(566),hHFzB:"pbbp2",FqVbh:function(o,n){return o/n},PlVpy:t(1479)+t(817)+t(800),MavGc:function(o,n){return o(n)},iJaMV:function(o,n,i){return o(n,i)},pHnIB:t(914)+t(1006)+t(685)+"ct",KzhOn:t(1027),mkxAf:t(977),GYLhv:"online",FQkbY:function(o,n){return o>>n},sABuE:function(o,n){return o|n},ObIJy:function(o,n){return o&n},VSqgR:function(o,n){return o+n},jcKRW:t(1240)+"5|0",bufkj:function(o,n){return o|n},lHCpM:function(o,n){return o+n},azZGO:function(o,n){return o|n},ZYZXl:function(o,n){return o&n},xWmbv:function(o,n){return o>>n},eMNbR:function(o,n){return o|n},ZdpQC:function(o,n){return o&n},DRxHF:function(o,n){return o>>n},onjeG:t(590),loxcE:function(o,n){return o!==n},iVVBn:function(o,n){return o!==n},HsFvC:"7|8|0|2|"+t(741)+t(1899)+"5",vzFCA:function(o,n){return o>>>n},klgDc:function(o,n){return o>>>n},AcsJo:function(o,n){return o|n},LTWTm:function(o,n){return o<n},aLirx:function(o,n){return o|n},zIplH:function(o,n){return o>>>n},pAcHA:function(o,n){return o<<n},nfEtP:function(o,n,i,d){return o(n,i,d)},FCJBL:function(o,n){return o===n},ESxFV:"mwoxO",FPtoI:t(1349),tuMgu:t(1122)+"d",ASaTB:t(1479)+"rovide bddID, deviceID o"+t(669),FxuQV:"function",skoNL:t(1446),akHHj:t(1902)+"0",bKwbW:function(o,n){return o+n},cuKPg:function(o,n,i,d){return o(n,i,d)},Wrbgt:function(o,n){return o(n)},vdFZg:function(o,n,i){return o(n,i)},xjirc:function(o,n){return o===n},CtAyE:t(448),wUyug:t(1098),FCBrl:t(961),BXyoP:function(o,n){return o>n},XQNsl:function(o,n){return o-n},zZRhF:function(o,n,i){return o(n,i)},KNFIk:function(o,n){return o!==n},ZboJW:"yPsWG",hgKeV:t(690),WninG:function(o,n){return o(n)},PvnBw:function(o,n){return o===n},LDSWt:t(557),QVqfl:function(o,n){return o!==n},XprJw:function(o,n,i){return o(n,i)},ysQZs:function(o,n){return o!==n},FDbOg:t(1627),rMrnP:t(894),jlFWx:t(970)+t(1196)+"t",BzDLj:t(1692),RxbVh:function(o,n){return o+n},hnSGi:t(544),RBKGI:function(o,n,i){return o(n,i)},ZtoMm:"IMStn",MVVIL:"DstLt",mTNXC:t(1855)+t(872)+t(545)+"g",yzDeO:function(o,n){return o(n)},olsUe:t(1789),pvhVU:function(o,n){return o===n},xpneq:"oYxvO",noITo:t(1287)+"2",yLyGC:function(o,n){return o!==n},BilbI:t(1719),xJlVe:function(o,n,i){return o(n,i)},cymQN:function(o,n,i){return o(n,i)},CLhrh:t(427),joLbz:t(1277),JEJmy:t(1535),Yvmui:function(o,n){return o===n},REHFA:t(1882),sNdca:t(930),QRaiO:function(o,n){return o|n},HeBGa:function(o,n){return o<<n},AwMsX:function(o,n){return o<<n},WcdEF:"AErXQ",RMxrU:t(668)+t(1237),RqWap:t(1928)+t(584)+t(1809)+t(537)+"ed",wolJw:function(o,n){return o===n},JnTUU:function(o,n){return o==n},EkbBX:t(1479)+t(1690)+t(1086)+t(815)+t(489)+t(1499)+t(978)+t(1055)+"ffer",xgjpu:function(o,n){return o==n},OqOaq:function(o,n){return o!=n},LZwRG:function(o,n){return o(n)},FaIuR:function(o,n){return o(n)},LwXue:"sent",HFJgW:t(1353),gvWMV:t(949),QXwDi:function(o,n){return o||n},iBhZU:t(1238)+"0",NZrOs:"oGWFS",ZFWqS:function(o,n,i){return o(n,i)},Xhbys:function(o,n){return o===n},AMbqs:t(1459),Fccnh:t(453),Ktdxi:t(1759),HDZSd:t(465),fZuUL:function(o,n){return o===n},UULpU:t(851),SMWrQ:function(o,n){return o===n},EOHyv:"Dedicate"+t(606)+"lobalScope",DnAyr:function(o,n){return o!=n},qkJUl:t(799)+t(880)+"alScope",SgSgw:t(731)+t(897)+t(1393),crhsR:function(o,n,i){return o(n,i)},uHDjA:t(805)+"qos__"};Rt.r(Se),Rt.d(Se,{FWS:()=>Uh,CustomErrorEvent:()=>p0,createCloseEvent:()=>dt,ReconnectEvent:()=>h0,createErrorEvent:()=>nt,decodedFrame:()=>Fn,createOpenEvent:()=>b0,CustomCloseEvent:()=>g0,createReconnectEvent:()=>Mo,FrontierMessageEvent:()=>w0,encodeFrame:()=>$e,createMessageEvent:()=>y0,OpenEvent:()=>_0,ErrorCode:()=>$t,Event:()=>qn,MessageEvent:()=>m0});let r="";function s(o=""){let n=t,i="02",d=""+Date[n(1565)](),l=r||(r=e.uCMGI(x,o)),h=Math[n(1102)]()[n(1527)](16)[n(560)](-6);return e.CEcFp(e.CEcFp(e[n(1777)](i,d),l),h)}function a(){let o=t;return e[o(1450)](1e4,Date.now())+Math.floor(e[o(1292)](1e4,Math[o(1102)]()))}function c(o){let n=t;return e.CEcFp(e[n(1647)](Array,8)[n(746)]("0"),parseInt(o,10).toString(2))[n(560)](-8)}function f(o){let n=t;return e[n(1497)](e.uCMGI(Array,4).join("0"),parseInt(o,2)[n(1527)](16))[n(560)](-4)}function u(o){let n=t,i=o[n(1434)](/\./)[n(1568)](h=>c(h)),d=[];return d[0]=f(e.CEcFp(i[0],i[1])),d[1]=e[n(1647)](f,e.nOEjb(i[2],i[3])),["0000",e[n(1388)],e.iZPMH,e[n(1388)],e[n(1388)],e[n(1417)],d[0],d[1]][n(746)]("")}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}/[n(1126)](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(1126)](o);return i?u(o):d?e.MTAIW(p,o):e.IAUrc}function p(o){let n=t,i={DUauh:function(O,L){return e[G(1340)](O,L)}},d="",l=[],h=0,m=0,v=!0,g=e[n(1388)];if(e[n(1448)](o[n(1174)]("::"),-1)){let O=o.split("::");for(let U=0;e[n(1523)](U,O[n(1180)]);U++){let $=O[U];if(e[n(1448)]($.indexOf(":"),0))if(e[n(1731)]===e[n(1731)]){let j=$.split(":");v&&(h=j[n(1180)]),m+=j[n(1180)];for(let J=0;e[n(1306)](J,j.length);J++)if(e[n(1877)](4,j[J].length)){let ge=g[n(1560)+"g"](0,e.Kpjxb(4,j[J].length)),Q=ge[n(641)](j[J]);l[n(521)](Q)}else l[n(521)](j[J]);v=!1}else this.emit("message",_0xdfccd7),this.onmessage&&this[n(692)+"e"](_0x47b874);else{if(e[n(1426)](4,$[n(1180)]))if(e[n(1391)](e[n(695)],e[n(1698)])){let j=_0x53542a.split(/\./)[n(1568)](Q=>_0x20a57b(Q)),J=[];return J[0]=e[n(1919)](_0x12a876,e[n(1204)](j[0],j[1])),J[1]=e.QzYOL(_0x62c649,e[n(1075)](j[2],j[3])),[e[n(1388)],e[n(1388)],e[n(1388)],e.iZPMH,n(1215),e[n(1417)],J[0],J[1]][n(746)]("")}else{let j=g[n(1560)+"g"](0,4-$[n(1180)]),J=j[n(641)]($);l[n(521)](J)}else l[n(521)]($);v&&(h+=1),m+=1,v=!1}}let L="";for(let U=0;U<e[n(841)](8,m);U++)L=L[n(641)](g);for(let U=0;U<l.length;U++)if(e[n(1391)](U,h))if(e.ibmmW(e[n(714)],e.KNuOU)){let $=this[n(1148)][n(737)](this._prefix),j=_0x3745dc[n(1873)](i.DUauh($,"{}"));return j[_0x5f3594||_0x8a9ff7[this[n(876)]]]=_0x2ab149,this[n(1148)][n(764)](this[n(442)],_0x5f54a9.stringify(j)),_0x418309||_0x2d1983[this[n(876)]]}else d=d[n(641)](L),d=d[n(641)](l[U]);else d=d[n(641)](l[U]);return d}{let O=o.split(":");for(let L=0;L<O.length;L++){let U=O[L];if(O[L][n(1180)]!==4){let $=g[n(1560)+"g"](0,e[n(841)](4,O[L][n(1180)])),j=$[n(641)](U);d=d[n(641)](j)}else d=d[n(641)](U)}return d}}function _(o,n){let i=t,d={BYRpU:function(l,h){return e[G(1716)](l,h)},cSwGc:function(l,h){return l&h},OHseW:function(l,h){return e[G(960)](l,h)},ZGFXR:function(l,h){return e[G(1838)](l,h)},SfYkW:function(l,h){return e.XFOMv(l,h)},uvHex:function(l,h){return e[G(1210)](l,h)},rnyxP:function(l,h){return e[G(1497)](l,h)},cExBG:function(l,h){return e[G(1070)](l,h)},KGtNT:function(l,h){return l&h}};if(e[i(1877)](e[i(1243)],e[i(1573)])){let l=o[i(1403)];l!==void 0&&(e[i(874)](Y,n,10),e[i(1408)](Be,n,l));let h=o.value;e.bSUsM(void 0,h)&&(e[i(874)](Y,n,18),e[i(1408)](Be,n,h))}else{let l=_0x5ede6a[i(654)],h=_0x1016c6[i(713)];return _0x5c780e[_0x1a9630]=d[i(998)](h,24),_0x490646[_0x370b72+1]=h>>>16&255,_0x2038de[_0x3f2d87+2]=d.cSwGc(d[i(998)](h,8),255),_0x3e7509[d[i(1557)](_0x5ab007,3)]=d[i(1012)](255,h),_0x56592a[d[i(1557)](_0x2282fa,4)]=d[i(1837)](l,24),_0x5d1868[d.uvHex(_0x31fcd5,5)]=d[i(1012)](l>>>16,255),_0x451f8a[d[i(715)](_0x598a5a,6)]=d[i(1544)](d[i(1780)](l,8),255),_0x280c35[_0x4dfb35+7]=d.KGtNT(255,l),_0x1bec6b+=8,_0x3af7a7}}function E(o){let n=t,i={};e:for(;!M(o);){let d=e[n(1309)](Ee,o);switch(d>>>3){case 0:break e;case 1:i[n(1403)]=e[n(1408)](be,o,Ee(o));break;case 2:i[n(1026)]=e[n(1408)](be,o,Ee(o));break;default:R(o,e[n(1838)](7,d))}}if(e[n(850)](void 0,i[n(1403)]))throw new Error("Missing "+n(1860)+n(1825)+n(1403));if(e[n(1663)](void 0,i[n(1026)]))throw new Error(e.jjjTL);return i}function C(o){let n=t;if(e.bciCq===e[n(1911)])this[n(963)](_0x162a13,_0x439681);else{let i=e[n(1335)](A);return e.QtQVn(y,o,i),e[n(798)](B,i)}}function y(o,n){let i=t,d={HHQeP:e.wAZao,PfgSg:function(Q,ue){return Q(ue)},FtMiK:function(Q,ue){return e[G(1502)](Q,ue)},hMCWg:function(Q,ue,ft){return e[G(891)](Q,ue,ft)},rwtVR:function(Q,ue){return e[G(1184)](Q,ue)}},l=o[i(541)];e[i(726)](void 0,l)&&(e[i(812)](Y,n,8),e[i(891)](_e,n,l));let h=o.LogID;if(e[i(1889)](void 0,h))if(e.LBrON(e[i(548)],e[i(548)])){let Q=_0x1f76b2[i(1453)+"tabase"](_0x46ea4d);return _0x388930&&Q["addEvent"+i(1467)](HIvcwJ[i(1880)],()=>_0x44adfe()),HIvcwJ[i(444)](_0x197f7f,Q)[i(612)](()=>{})}else e[i(874)](Y,n,16),e.oDDsU(_e,n,h);let m=o.service;e[i(1488)](void 0,m)&&(e[i(941)](Y,n,24),e[i(1606)](_e,n,e.kXfHy(P,m)));let v=o[i(509)];e[i(1889)](void 0,v)&&(Y(n,32),e.apOMc(_e,n,P(v)));let g=o[i(1643)];if(e.CDjhb(void 0,g))for(let Q of g){Y(n,42);let ue=e[i(1335)](A);_(Q,ue),e[i(891)](Y,n,ue[i(1221)]),ct(n,ue),e[i(608)](D,ue)}let O=o[i(1640)+"ncoding"];if(e.kVzFM(void 0,O))if(e[i(1877)]("ipXej",e[i(1755)])){let Q=0,ue=_0x4d3952,ft=d[i(1518)](_0x17b7ac,4);for(;ue<ft;){let{value:Pr,offset:Go}=d.hMCWg(_0x2b8873,_0x1c0173,ue);ue=Go,Q=d[i(1354)](Q<<8,0),Q+=Pr}return{value:Q,offset:ft}}else e[i(866)](Y,n,50),e[i(941)](Be,n,O);let L=o["payloadT"+i(618)];if(e[i(1257)](void 0,L))if(e[i(879)]===e[i(796)])try{return!!this[i(1148)]}catch(Q){return _0x1d11de[i(1001)](Q),!1}else Y(n,58),e[i(866)](Be,n,L);let U=o[i(1036)];e[i(1488)](void 0,U)&&(Y(n,66),e[i(1606)](Y,n,U[i(1180)]),e[i(989)](le,n,U));let $=o[i(1114)];$!==void 0&&(e[i(1322)](Y,n,74),e.glsrw(Be,n,$));let j=o[i(1195)+"ming"];j!==void 0&&(Y(n,82),e[i(812)](Be,n,j));let J=o.msgID;J!==void 0&&(e[i(995)](Y,n,90),e[i(1664)](Be,n,J));let ge=o[i(1812)+"e"];if(e[i(1426)](void 0,ge)){if(e[i(1609)]!==e[i(1609)])return _0x2f8b0b?.[i(1301)](Q=>Q[i(1403)]===_0x5da30f)?.[i(1026)];e[i(1018)](Y,n,96),e[i(1615)](_e,n,P(ge))}}function b(o){return S(z(o))}function S(o){let n=t,i={};e:for(;!e[n(1309)](M,o);){let d=e[n(1303)](Ee,o);switch(e.EcsoQ(d,3)){case 0:break e;case 1:i[n(541)]=e.Vlqew(zn,o,!0);break;case 2:i[n(1042)]=e.xVwrJ(zn,o,!0);break;case 3:i[n(626)]=e[n(1919)](Ee,o);break;case 4:i[n(509)]=Ee(o);break;case 5:{let l=e[n(595)](I,o);(i.headers||(i[n(1643)]=[]))[n(521)](e[n(1603)](E,o)),o[n(1221)]=l;break}case 6:i[n(1640)+n(1190)]=e[n(1449)](be,o,e.ogTwS(Ee,o));break;case 7:i[n(441)+n(618)]=e[n(989)](be,o,Ee(o));break;case 8:i[n(1036)]=e.GeyGh(oe,o,e[n(608)](Ee,o));break;case 9:i.LogIDNew=be(o,Ee(o));break;case 10:i["serverTi"+n(1104)]=be(o,Ee(o));break;case 11:i[n(1513)]=e[n(835)](be,o,e[n(777)](Ee,o));break;case 12:i[n(1812)+"e"]=Ee(o);break;default:e[n(874)](R,o,e[n(855)](7,d))}}if(i[n(541)]===void 0)throw new Error(e[n(986)]);if(e[n(1663)](void 0,i[n(1042)]))throw new Error(n(467)+n(1860)+n(1825)+n(1042));if(i[n(626)]===void 0)throw new Error(e[n(576)]);if(e[n(850)](void 0,i[n(509)]))throw new Error(e[n(1618)]);return i}function I(o){let n=t,i=e.yyJfP(Ee,o),d=o[n(1221)];return o.limit=e[n(1210)](o.offset,i),d}function R(o,n){let i=t;switch(n){case 0:for(;128&e[i(1647)](Re,o););break;case 2:e[i(985)](k,o,e.QzYOL(Ee,o));break;case 5:e[i(891)](k,o,4);break;case 1:k(o,8);break;default:throw new Error(e[i(1584)]+n)}}function P(o){let n=t;return o|=0,{low:o,high:e[n(1304)](o,31),unsigned:e[n(1760)](o,0)}}let w=[];function A(){let o=t;if(e.diSTU(e[o(1008)],e.CGcRj)){let n=w[o(426)]();return n?(n[o(1186)]=n[o(1221)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}else return this._qosDB[o(1336)+o(1728)]()}function D(o){let n=t,i={zyyVA:"timeout,"+n(872)+n(545)+"g"};if(e[n(1521)](e[n(1638)],e[n(801)]))w.push(o);else{let d=this[n(1874)+"tManager"]?.[n(762)+n(956)+"nt"]();this._debug(n(1198)+d+n(775)),this[n(1680)+n(1524)](1001,i[n(1714)],!0)}}function z(o){return{bytes:o,offset:0,limit:o[t(1180)]}}function B(o){let n=t,i=o[n(1153)],d=o[n(1221)];return e.BQGHe(i.length,d)?i:i[n(739)](0,d)}function k(o,n){let i=t;if(e[i(1448)](e.nOEjb(o[i(1186)],n),o[i(1221)]))throw new Error(e[i(1206)]);o[i(1186)]+=n}function M(o){let n=t;return e.aBKye(o[n(1186)],o.limit)}function F(o,n){let i=t,d=o.bytes,l=o[i(1186)],h=o[i(1221)],m=e[i(1210)](l,n);if(m>d.length){let v=new Uint8Array(2*m);v[i(1411)](d),o[i(1153)]=v}return o[i(1186)]=m,e[i(1448)](m,h)&&(o.limit=m),l}function K(o,n){let i=t,d={MFATk:function(l,h){return e[G(1293)](l,h)},DpUeU:function(l,h){return e.aBKye(l,h)}};if(e[i(1213)]===i(1207))return _0x5ae0e3|=0,{low:_0x1b4202,high:iZQfZH[i(563)](_0x49143b,31),unsigned:iZQfZH.DpUeU(_0x707592,0)};{let l=o[i(1186)];if(e[i(1448)](e[i(1075)](l,n),o[i(1221)]))throw new Error(e[i(957)]);return o[i(1186)]+=n,l}}function oe(o,n){let i=t,d=e.Lwjod(K,o,n);return o[i(1153)].subarray(d,e[i(895)](d,n))}function le(o,n){let i=t,d=F(o,n.length);o[i(1153)].set(n,d)}function be(o,n){let i=t,d=e[i(701)](K,o,n),l=String[i(1885)+i(1741)],h=o.bytes,m="\uFFFD",v="";for(let g=0;e[i(1306)](g,n);g++){let O=h[e[i(1502)](g,d)],L,U,$,j;if((128&O)===0)v+=e[i(595)](l,O);else if(e.CrRBf(224,O)===192)e[i(661)](g+1,n)?v+=m:(L=h[e[i(1455)](e.IQIYI(g,d),1)],e[i(1877)](192&L,128)?v+=m:(j=e.tykNo(e[i(1827)](31,O)<<6,e[i(580)](63,L)),j<128?v+=m:(v+=e[i(1852)](l,j),g++)));else if(e.Hpcpw(240,O)==224)e[i(661)](e[i(1494)](g,2),n)?v+=m:(L=h[e.NyZfF(e[i(1107)](g,d),1)],U=h[g+d+2],e.PNZrh((L|U<<8)&49344,32896)?v+=m:(j=e[i(550)](e[i(1261)](e[i(1768)](e[i(1418)](15,O),12),e[i(1827)](63,L)<<6),e[i(952)](63,U)),e[i(1523)](j,2048)||e[i(661)](j,55296)&&e[i(1402)](j,57343)?v+=m:(v+=e[i(555)](l,j),g+=2)));else if(e[i(1804)](e[i(580)](248,O),240))if(g+3>=n)v+=m;else{if(e.upkxH(e[i(1106)],e[i(1106)]))return e.hjdeg("string",typeof _0x2b8a64)&&(_0x5f3efa instanceof _0x2d7a39||_0x5e5e3e[i(749)]&&_0x19552d[i(749)]instanceof _0x3fc598)||e[i(1170)](e[i(1611)],typeof _0x376ac4)?"":(_0x1ce6b0[i(1873)](_0x28e818),e[i(902)]);L=h[e[i(1107)](e[i(895)](g,d),1)],U=h[e.ATklZ(e[i(1398)](g,d),2)],$=h[g+d+3],e[i(1050)](e.nbTiH(e[i(1261)](e[i(686)](L,U<<8),$<<16),12632256),8421504)?v+=m:(j=e.BeFKA(e[i(650)](e[i(507)](e[i(567)](7,O),18),e[i(1032)](63&L,12)),e[i(825)](63&U,6))|e[i(567)](63,$),e[i(1915)](j,65536)||j>1114111?v+=m:(j-=65536,v+=e[i(1408)](l,e[i(1204)](e[i(1293)](j,10),55296),e[i(600)](1023,j)+56320),g+=3))}else v+=m}return v}function Be(o,n){let i=t,d=n[i(1180)],l=0;for(let v=0;e.PlTRG(v,d);v++){let g=n.charCodeAt(v);e[i(1223)](g,55296)&&e[i(498)](g,56319)&&e.XTUID(v,1)<d&&(g=e[i(1019)](e[i(960)](g<<10,n.charCodeAt(++v)),56613888)),l+=e[i(1915)](g,128)?1:g<2048?2:e[i(1915)](g,65536)?3:4}Y(o,l);let h=e.ZxZKH(F,o,l),m=o[i(1153)];for(let v=0;e[i(1924)](v,d);v++){let g=n[i(1099)+"At"](v);e[i(1760)](g,55296)&&e.RvzGf(g,56319)&&e[i(1461)](e[i(694)](v,1),d)&&(g=e.YWBEH(e.hLIWT(g,10)+n.charCodeAt(++v),56613888)),e[i(1289)](g,128)?m[h++]=g:(e[i(1306)](g,2048)?m[h++]=e[i(583)](e[i(1835)](g>>6,31),192):(e[i(1924)](g,65536)?m[h++]=e[i(463)](e[i(470)](e[i(1304)](g,12),15),224):(m[h++]=e.POjdQ(g>>18&7,240),m[h++]=e[i(463)](e[i(596)](e[i(1293)](g,12),63),128)),m[h++]=e[i(1418)](e[i(428)](g,6),63)|128),m[h++]=63&g|128)}}function ct(o,n){let i=t,d=e[i(778)](F,o,n[i(1221)]),l=o[i(1153)],h=n.bytes;for(let m=0,v=n.limit;e[i(1125)](m,v);m++)l[e[i(1210)](m,d)]=h[m]}function Re(o){let n=t;if(e[n(710)](e[n(1592)],e[n(1592)]))this[n(1148)]?.[n(1397)](),this[n(1148)]=void 0;else return o[n(1153)][K(o,1)]}function Wt(o,n){let i=t,d=e[i(1135)](F,o,1);o[i(1153)][d]=n}function Ee(o){let n=t,i=0,d=0,l;do if(e[n(1848)]!==n(884))l=e[n(1852)](Re,o),e.aGiJW(i,32)&&(d|=e[n(1558)](e[n(1209)](127,l),i)),i+=7;else{this[n(943)+n(1735)+"t"]();let h=_0x476f81(e.djnYh,{message:n(914)+n(1006)+n(685)+"ct"});this[n(870)+n(1e3)+"yReconnect"]&&this[n(870)+n(1e3)+n(1435)+"ct"](h)}while(e[n(596)](128,l));return d}function Y(o,n){let i=t;if(e[i(710)](e.ZhNUV,e[i(499)]))this._qosDB?.[i(1802)](_0x1ff3a5[i(631)+"id"]);else{for(n>>>=0;n>=128;)e[i(989)](Wt,o,e[i(583)](e[i(1387)](127,n),128)),n>>>=7;e.GeyGh(Wt,o,n)}}function zn(o,n){let i=t,d={PCWvM:e.Tubwu},l=0,h=0,m=0,v;if(v=e[i(1039)](Re,o),l=e.aYpma(127,v),e[i(470)](128,v)&&(v=e[i(1919)](Re,o),l|=(127&v)<<7,e[i(952)](128,v)))if(e[i(1486)]!==e.yjmPz){if(v=Re(o),l|=e[i(1057)](e.myIEi(127,v),14),e[i(1512)](128,v)&&(v=Re(o),l|=(127&v)<<21,e[i(855)](128,v))){if(e[i(1179)](e[i(1800)],e[i(1800)]))return _0x45ef7f||(_0x4ceba6=_0x36e64c[i(1381)]()[i(612)](_0x2f5b7[i(1076)](_0x196120,d[i(1754)]))),_0x5973bc;v=e[i(1378)](Re,o),h=e[i(1835)](127,v),e[i(580)](128,v)&&(v=e.MTAIW(Re,o),h|=e[i(1869)](e[i(1827)](127,v),7),128&v&&(v=e[i(1699)](Re,o),h|=e[i(675)](e[i(858)](127,v),14),e[i(706)](128,v)&&(v=e.UfAzn(Re,o),h|=e[i(1115)](e[i(706)](127,v),21),e.QNoqW(128,v)&&(v=e.QyQKB(Re,o),m=e[i(1827)](127,v),e.eKNUS(128,v)&&(v=Re(o),m|=e.HcZKT(e[i(855)](127,v),7))))))}}else _0x22c836[i(1001)](_0xa67de6);return{low:e[i(583)](l,h<<28),high:e[i(785)](h>>>4,m<<24),unsigned:n}}function _e(o,n){let i=t,d=e[i(1374)](n[i(654)],0),l=(e.XFOMv(n[i(654)],28)|e[i(1768)](n[i(713)],4))>>>0,h=n[i(713)]>>>24,m=e.zIjWa(0,h)?e[i(850)](0,l)?e[i(599)](d,16384)?e[i(615)](d,128)?1:2:e[i(539)](d,2097152)?3:4:e[i(484)](l,16384)?e[i(1035)](l,128)?5:6:e[i(881)](l,2097152)?7:8:e[i(615)](h,128)?9:10,v=e.eYfoA(F,o,m),g=o.bytes;switch(m){case 10:g[e[i(1455)](v,9)]=e[i(855)](e[i(1798)](h,7),1);case 9:g[e[i(895)](v,8)]=m!==9?128|h:e.JuBIa(127,h);case 8:g[v+7]=e[i(1211)](8,m)?e.RUYEu(l,21)|128:l>>>21&127;case 7:g[v+6]=e[i(1426)](7,m)?e.POjdQ(e[i(1798)](l,14),128):e[i(1827)](l>>>14,127);case 6:g[e[i(782)](v,5)]=e[i(546)](6,m)?e[i(785)](l>>>7,128):e.SKGAB(e[i(745)](l,7),127);case 5:g[e.UKqQs(v,4)]=e[i(1833)](5,m)?e[i(679)](128,l):127&l;case 4:g[e.wTdOd(v,3)]=e[i(1742)](4,m)?e[i(1422)](e[i(1184)](d,21),128):e[i(1846)](e[i(784)](d,21),127);case 3:g[e[i(1935)](v,2)]=e[i(922)](3,m)?e.Qkghm(e.bfOye(d,14),128):e.ffGla(e[i(1184)](d,14),127);case 2:g[e[i(1900)](v,1)]=e[i(1193)](2,m)?e.dlLRO(d>>>7,128):d>>>7&127;case 1:g[v]=e.Updjj(1,m)?e[i(550)](128,d):e[i(882)](127,d)}}function Fn(o){return e[t(1250)](b,o)}function $e(o){return e[t(1781)](C,o)}let f0=65536,Yx=e[t(1766)],Un=e[t(919)](f0,f0),l0=e.SvctA(Un,Un),u0=l0/2,Kt=String[t(1528)+"e"][t(1099)+"At"];class ae{constructor(n,i,d){let l=t;this[l(1103)]=!0,this[l(654)]=e[l(583)](0,n),this[l(713)]=e.wUfZh(0,i),this.unsigned=!!d}static isLong(n){let i=t,d={JvlyA:function(l,h){return e[G(1355)](l,h)},aqTAJ:function(l,h){return l>=h},aQbvY:function(l,h){return e[G(769)](l,h)},YSriD:function(l,h){return e[G(877)](l,h)},gArnY:function(l,h){return l+h}};if(e.ztFur(i(1031),e[i(1616)]))return n&&e.KfYee(!0,n[i(1103)]);{if(d[i(1507)](_0x3bd5c2,_0x44b6e1))throw new _0x4a473a(i(1519)+i(932)+"e");let l=3;for(;d[i(1571)](l,0);){let h=d.aQbvY(255,_0x362c30);_0x443e5e(h,_0x20f74d,d[i(865)](_0x553e41,l)),_0x454ea0>>>=8,l--}return d[i(1551)](_0x185858,4)}}static[t(857)](n,i,d){let l=t;if(e[l(570)]!==e.TRUpu)_0x3d0163[_0xf54710++]=e.GEgmw(_0x28b262>>12,224),_0xc8d323[_0x583ded++]=e[l(621)](e[l(1662)](_0x1c90fb,6)&63,128),_0x546c17[_0x3b53c6++]=e.GEgmw(e[l(862)](63,_0x3b32f9),128);else return new ae(n,i,d)}static[t(792)+"s"](n,i,d){let l=t;return d?ae[l(792)+l(1348)](n,i):ae[l(792)+l(1385)](n,i)}static[t(792)+t(1348)](n,i){let d=t;return new ae(e[d(1734)](e[d(840)](n[0],n[1]<<8),n[2]<<16)|e[d(1115)](n[3],24),e[d(650)](e[d(883)](e[d(770)](n[4],e.DRKQI(n[5],8)),e[d(675)](n[6],16)),e.wTKXZ(n[7],24)),i)}static[t(792)+t(1385)](n,i){let d=t;return new ae(e[d(583)](e[d(432)](e[d(1620)](n[4]<<24,e[d(675)](n[5],16)),e[d(1558)](n[6],8)),n[7]),e.KkhaL(e.lFQWZ(e[d(767)](n[0],24),e.DRKQI(n[1],16))|n[2]<<8,n[3]),i)}static fromHash(n){let i=t;return e[i(591)](n,Yx)?x0:new ae(e[i(1716)](e[i(869)](e[i(1310)](Kt[i(1083)](n,0)|e[i(1032)](Kt[i(1083)](n,1),8),Kt[i(1083)](n,2)<<16),e[i(826)](Kt[i(1083)](n,3),24)),0),(e[i(655)](e[i(869)](Kt[i(1083)](n,4),e[i(1869)](Kt[i(1083)](n,5),8)),Kt[i(1083)](n,6)<<16)|e[i(767)](Kt[i(1083)](n,7),24))>>>0,!0)}[t(1273)](){let n=t;return String["fromChar"+n(1741)](e.WyqmE(255,this[n(654)]),e.zZNyr(e[n(1693)](this[n(654)],8),255),e[n(734)](e.akEKP(this[n(654)],16),255),e.MaFFv(this[n(654)],24),e[n(952)](255,this[n(713)]),e[n(706)](e[n(574)](this[n(713)],8),255),e[n(1921)](e[n(859)](this[n(713)],16),255),e.wOSdS(this[n(713)],24))}static fromNumber(n,i=!0){let d=t;if(isNaN(n))return i?Xx:x0;if(i){if(e[d(1223)](n,l0))return eh}else{if(n<=-u0)return th;if(e[d(837)](n,1)>=u0)return Qx}return ae.fromBits(e.rcrMt(n%Un,0),n/Un|0,i)}toNumber(){let n=t;if(e.rlorp(e[n(758)],e[n(758)])){let{type:i}=_0x3abdaa;this[n(1431)](i,_0x49a811)}else return this[n(1069)]?e[n(551)](e[n(1321)](e[n(1053)](this[n(713)],0),Un),e.SNRQo(this[n(654)],0)):e[n(1553)](e.Uhyut(this.high,Un),e[n(745)](this[n(654)],0))}isZero(){let n=t;if(e[n(609)](e[n(462)],e[n(462)])){let i=this._listeners[_0x51d9cc];if(i)for(let d=0;d<i[n(1180)];)i[d].fn===_0x56e606?i[n(1691)](d,1):++d}else return e[n(1663)](0,this[n(713)])&&e[n(1710)](0,this[n(654)])}[t(744)](n){let i=t,d={NJPBl:e[i(864)],PbZxS:function(l,h,m){return e[i(1377)](l,h,m)}};if(e[i(1845)](e[i(663)],e[i(663)]))if(e[i(1337)](_0x393b74,_0x222455)){let l=_0x52fa64[i(749)][i(560)](_0x36836b[i(644)+"et"],e.lMXAy(_0x3e36a3[i(488)+"th"],_0x48d2f5[i(644)+"et"]));this[i(1787)]&&this[i(1787)][i(1818)]({data:l,fail:h=>{let m=i;this[m(1431)](d[m(665)],d[m(1593)](_0x90afd7,d[m(665)],{message:this[m(1218)+"rrorMess"+m(1428)](h)}))}})}else this[i(1787)]&&this._socket.send({data:_0x54e2ea,fail:l=>{let h=i;this[h(1431)](h(901),d[h(1593)](_0x2b52cc,h(901),{message:this["_formatE"+h(1233)+"age"](l)}))}});else{ae[i(1103)](n)||(n=ae[i(1599)+"er"](n));let l=e.pbQbS(this.high,16),h=e.xjCuF(65535,this.high),m=e.FSNFe(this.low,16),v=65535&this.low,g=e[i(1051)](n[i(713)],16),O=e[i(882)](65535,n.high),L=n[i(654)]>>>16,U=e[i(862)](65535,n[i(654)]),$=0,j=0,J=0,ge=0;return ge+=v+U,J+=e.kqHYN(ge,16),ge&=65535,J+=m+L,j+=e[i(1587)](J,16),J&=65535,j+=h+O,$+=j>>>16,j&=65535,$+=e[i(1236)](l,g),$&=65535,ae[i(857)](e[i(1659)](e[i(1133)](J,16),ge),$<<16|j,this[i(1069)])}}equals(n){let i=t;return ae.isLong(n)||(n=ae[i(1599)+"er"](n)),e[i(1552)](this.unsigned,n[i(1069)])&&e.KfYee(this[i(713)]>>>31,1)&&e[i(1423)](e[i(1587)](n[i(713)],31),1)?!1:e[i(1710)](this.high,n[i(713)])&&e[i(1391)](this.low,n[i(654)])}[t(1739)](){let n=t;return e[n(850)](-1,this[n(654)])&&e.PGGTt(-1,this[n(713)])?ae[n(857)](0,0,this[n(1069)]):e[n(765)](-1,this.low)?ae[n(857)](0,e[n(1056)](this[n(713)],1),this.unsigned):ae[n(857)](this.low+1,this[n(713)],this.unsigned)}[t(439)](n){return n?this.toBytesLE():this[t(1712)+"E"]()}[t(1312)+"E"](){let n=t;if(e[n(1833)](e[n(1071)],n(1538))){let i=e[n(893)](_0x226908,e[n(1028)],{message:e[n(1810)]});this[n(1829)+n(1543)]&&this[n(1829)+"econnect"](i)}else{let i=this.high,d=this.low;return[e[n(660)](255,d),e[n(730)](d>>>8,255),e[n(1341)](d>>>16,255),d>>>24,e[n(1838)](255,i),e.ajigR(i,8)&255,e[n(600)](e[n(859)](i,16),255),i>>>24]}}[t(1712)+"E"](){let n=t,i=this[n(713)],d=this[n(654)];return[e[n(859)](i,24),e[n(952)](e[n(565)](i,16),255),e[n(706)](e[n(531)](i,8),255),255&i,d>>>24,e.xjCuF(e[n(559)](d,16),255),e[n(834)](e[n(1370)](d,8),255),e[n(1384)](255,d)]}}let x0=new ae(0,0,!1),Xx=new ae(0,0,!0),Qx=ae[t(857)](-1,2147483647,!1),eh=ae[t(857)](-1,-1,!0),th=ae[t(857)](0,-2147483648,!1);var $t=(function(o){let n=t,i=e[n(1862)][n(1434)]("|"),d=0;for(;;){switch(i[d++]){case"0":o[o.OPEN_ERROR=5005]=e[n(1598)];continue;case"1":return o;case"2":o[o[e.vsZFH]=5004]=n(997)+"ERROR";continue;case"3":o[o[n(1619)+n(1145)]=5002]=e[n(1443)];continue;case"4":o[o[e[n(1894)]]=5001]=e.UtjYt;continue;case"5":o[o[e[n(656)]]=5003]=e[n(656)];continue}break}})({});class qn{constructor(n){let i=t;this.type=n,this[i(861)]=null}}class h0 extends qn{constructor(n,i){let d=t;super(n),this[d(629)]=i&&i[d(629)]||null}}class p0 extends qn{constructor(n,i){let d=t;if(e.qrnCT(e[d(1041)],e[d(1549)]))return _0x225332(_0x5aeb6b);super(n),this.error=i&&i[d(901)]||null,this[d(1930)]=i&&i[d(1930)]||0,this[d(1656)]=i&&i[d(1656)]||"",this[d(1068)]=i&&i[d(1068)]||0,this[d(629)]=i&&i.message||"",this[d(786)]=i&&i[d(786)]||5001}}class g0 extends qn{constructor(n,i){let d=t,l=(d(1105)+"0")[d(1434)]("|"),h=0;for(;;){switch(l[h++]){case"0":this[d(992)+d(1228)]=i&&i[d(992)+d(1228)]||!1;continue;case"1":this[d(786)]=i&&i[d(786)]||0;continue;case"2":this[d(515)]=i&&i[d(515)]||"";continue;case"3":this[d(1014)]=i&&i[d(1014)]||!1;continue;case"4":super(n);continue}break}}}class m0 extends qn{constructor(n,i){let d=t;super(n),this[d(1079)]=i&&i[d(1079)]||null}}class w0 extends m0{constructor(n,i){let d=t;super(n),this.data=i&&i.data||null,this[d(629)]=i&&i.message||null}}class _0 extends qn{constructor(n,i){super(n),this.data=i&&i.data||null}}function nt(o,{message:n,code:i,error:d}){let l=t;if(e[l(850)](e[l(1023)],l(1440)))_0x438cb9.body[l(1138)+l(1566)](_0x1d3fb8);else return new p0(o,{message:n,code:i,error:d})}function dt(o,{code:n,reason:i,wasClean:d,willReconnect:l}){return new g0(o,{code:n,reason:i,wasClean:d,willReconnect:l})}function y0(o,{data:n,message:i}){return new w0(o,{data:n,message:i})}function b0(o,{data:n}){return new _0(o,{data:n})}function Mo(o,{message:n}){return new h0(o,{message:n})}class E0{constructor(n,i){let d=t;this.endpoints=n,this[d(1463)+"es"]=i,this[d(1745)+d(1702)]=0,this[d(916)+d(623)+d(1089)+"t"]=0}["resetEnd"+t(1850)+"fig"](){let n=t;this[n(1745)+"ndex"]=0,this[n(916)+"ndpointTriesCount"]=0}resetTries(){let n=t;this["currentE"+n(623)+n(1089)+"t"]=0}[t(762)+t(956)+"nt"](){let n=t;return this[n(1232)+"s"][this["currentI"+n(1702)]]}[t(762)+t(956)+t(980)+t(975)](){return this["currentEndpointT"+t(1089)+"t"]}[t(1150)+t(673)+"es"](){let n=t;return!!(this[n(1745)+n(1702)]>=this[n(1232)+"s"][n(1180)]||this[n(1745)+n(1702)]===e[n(841)](this[n(1232)+"s"][n(1180)],1)&&e[n(765)](this[n(916)+n(623)+n(1089)+"t"],this[n(1463)+"es"]))}[t(1555)+"rentEndpointReachedMaxRetries"](){let n=t;return this[n(1745)+"ndex"]==this.endpoints[n(1180)]?!0:this["currentE"+n(623)+"riesCount"]>this[n(1463)+"es"]}[t(1769)+t(728)+"pointAnd"+t(1242)+t(529)](){let n=t;return this[n(916)+n(623)+"riesCount"]=1,this[n(1745)+n(1702)]++,this[n(1232)+"s"][this[n(1745)+n(1702)]]}[t(762)+t(956)+t(1369)+t(1224)](){let n=t;return this["currentE"+n(623)+n(1089)+"t"]++,this[n(762)+n(956)+"nt"]()}}let Hn=(e[t(1137)](e[t(1359)],typeof globalThis)&&e.xzSRk(e.HDZSd,globalThis["construc"+t(643)][t(718)])||e[t(639)](e[t(1359)],typeof window)&&t(465)===window[t(1251)+t(643)][t(718)])&&t(806)+"d"!=typeof document,mn=e[t(1170)](t(806)+"d",typeof globalThis)&&(e[t(676)](e[t(1046)],globalThis[t(1251)+t(643)][t(718)])||e[t(1694)](e[t(1578)],globalThis[t(1251)+t(643)].name))&&e.Zrhqf(e.DIOLl,typeof tt),kr=(e[t(1890)](t(806)+"d",typeof globalThis)&&e[t(707)](e[t(1046)],globalThis[t(1251)+t(643)][t(718)])||e[t(688)](e.DIOLl,typeof globalThis)||e.Zrhqf(e[t(1359)],typeof globalThis)&&!!globalThis[t(822)+"Bridge"])&&e[t(1143)](e[t(1359)],typeof wx),Lr=e[t(639)](e[t(1359)],typeof globalThis)&&(e.lXHuj(e[t(1578)],globalThis.constructor.name)||e[t(1391)](e[t(1468)],globalThis[t(1251)+t(643)][t(718)])||e[t(1258)](e[t(524)],globalThis[t(1251)+t(643)][t(718)]))&&e[t(1890)]("undefined",typeof self),nh=e[t(1359)]!=typeof globalThis&&e[t(850)]("Object",globalThis[t(1251)+t(643)].name)&&e[t(1359)]!=typeof global&&e[t(1910)](e[t(1046)],global[t(1251)+"tor"][t(718)])&&e[t(1462)](e[t(1359)],typeof process)&&!!process.version;class Bo{constructor(){let n=t;this[n(1670)+"rs"]={}}emit(n,...i){let d=t,l=this[d(1670)+"rs"][n];if(l)l.slice().forEach(h=>h.fn.apply(h[d(1801)],i));else if(e.BQGHe(d(901),n)&&!this[d(1477)]){let h=i[d(1180)]&&i[0];if(e[d(1337)](h,Error))throw h;let m=new Error(e[d(837)](e[d(1229)],h?e[d(1451)](e[d(782)](" (",h[d(629)]),")"):""));throw m.context=h,h}return this}off(n,i){let d=t;if(e[d(1663)](void 0,n))this[d(1670)+"rs"]={};else if(e[d(1803)](void 0,i))this[d(1670)+"rs"][n]=null;else{let l=this[d(1670)+"rs"][n];if(l)for(let h=0;h<l[d(1180)];)e[d(1803)](l[h].fn,i)?l.splice(h,1):++h}return this}on(n,i,d){let l=t;return(this[l(1670)+"rs"][n]||(this[l(1670)+"rs"][n]=[]))[l(521)]({fn:i,ctx:d||this}),this}}class rh extends Bo{[t(1218)+t(1233)+"age"](n){let i=t,d={MHEUb:function(l,h){return e[G(1337)](l,h)}};if(e[i(1193)](i(981),i(1130)))return n[i(457)]||n[i(556)]?("message: "+(n[i(457)]||"")+i(1870)+(n.errNo||""))[i(572)]():JSON[i(479)+"y"](n);FOSTaw[i(1645)](_0x398e69,_0x5e2769)&&_0x124393[i(1411)](_0x41c569,_0x416b2d)}constructor(n,i,d){let l=t;super(),this._socket=null,kr&&wx["connectS"+l(1395)]&&(this[l(1787)]=wx[l(1013)+l(1395)]({url:n,protocols:i,header:d,fail:this[l(1936)+l(984)+l(1128)][l(1076)](this),success:this[l(1936)+l(1506)+"cessHandler"][l(1076)](this)})),mn&&tt[l(1013)+l(1395)]&&(this[l(1787)]=tt[l(1013)+l(1395)]({url:n,protocols:i,header:d,fail:this[l(1936)+"ocketFailHandler"][l(1076)](this),success:this["_createS"+l(1506)+l(510)+l(1020)][l(1076)](this)}))}[t(1936)+t(1506)+t(510)+t(1020)](){let n=t;Promise[n(1381)]()[n(612)](()=>{let i=n;this[i(533)+i(1394)]()})}[t(1936)+t(984)+"lHandler"](n){let i=t;Promise[i(1381)]()[i(612)](()=>{let d=i,l=e.veHmX(nt,e[d(864)],{message:this["_formatE"+d(1233)+d(1428)](n)});this.emit(d(901),l);let h=e[d(1664)](dt,e[d(528)],{reason:this[d(1218)+"rrorMess"+d(1428)](n)});this[d(1431)](e.WxRhZ,h)})}[t(533)+t(1394)](){let n=t,i={xUStq:e.AkyzW,sGLcz:function(d,l,h){return d(l,h)}};this[n(1787)].onOpen(d=>{let l=n;this.emit(e[l(831)],e[l(1439)](b0,l(1582),{...d,data:d[l(457)]||""}))}),this[n(1787)][n(638)](d=>{let l=n;this[l(1431)]("close",e[l(1439)](dt,e.WxRhZ,{...d}))}),this._socket[n(757)+"e"](d=>{let l=n;this[l(1431)](i[l(475)],i[l(471)](y0,i[l(475)],{...d}))}),this[n(1787)][n(873)](d=>{let l=n;this[l(1431)](e.dECWq,e[l(1847)](nt,e[l(864)],{...d,message:d[l(457)]||""}))})}send(n){let i=t,d={JPinh:"error",EGVYh:function(l,h,m){return e[G(1847)](l,h,m)},wjCjs:function(l,h){return e[G(1488)](l,h)}};if(e[i(1043)](e[i(691)],i(898))){let l=_0x4d68bb[i(1099)+"At"](_0x528e50);e.aBKye(l,55296)&&l<=56319&&e.bFVff(e[i(694)](_0x405082,1),_0x29f34d)&&(l=e.RUByE(e.vCWCn(e[i(825)](l,10),_0x2c7f46[i(1099)+"At"](++_0x6669c8)),56613888)),e[i(615)](l,128)?_0x5d1956[_0x2e86c2++]=l:(e[i(1915)](l,2048)?_0x3091a6[_0x2df100++]=e.vcahI(e[i(428)](l,6)&31,192):(l<65536?_0x2e0b10[_0x327501++]=e[i(991)](e.WLdIC(l,12),15)|224:(_0x392256[_0x532d8f++]=e[i(1160)](e[i(1293)](l,18),7)|240,_0xcffb63[_0x5c0be1++]=e.lFQWZ(e[i(1624)](e.WbchE(l,12),63),128)),_0x3043f5[_0x1356dc++]=e[i(1127)](e.xsdNy(e.gyLcp(l,6),63),128)),_0x5a02d7[_0x1b857f++]=e[i(1362)](e[i(1252)](63,l),128))}else if(n instanceof Uint8Array){let l=n[i(749)][i(560)](n[i(644)+"et"],e[i(1564)](n.byteLength,n[i(644)+"et"]));this[i(1787)]&&this[i(1787)][i(1818)]({data:l,fail:h=>{let m=i;this[m(1431)](d[m(1917)],d[m(937)](nt,d[m(1917)],{message:this[m(1218)+m(1233)+m(1428)](h)}))}})}else this[i(1787)]&&this[i(1787)][i(1818)]({data:n,fail:l=>{let h=i;if(d[h(1531)](h(636),"LAHYA"))return _0x375938[h(1381)]();this[h(1431)](d.JPinh,d[h(937)](nt,h(901),{message:this[h(1218)+h(1233)+h(1428)](l)}))}})}[t(1397)](n,i){let d=t;e.zIjWa(e[d(1516)],e[d(1596)])?(this[d(651)+d(1390)+d(664)](_0x38ab59),_0x208302.set(_0x381805,_0x40bcaf,_0x44f18e[d(629)].service)):this[d(1787)]&&this[d(1787)][d(1397)]({code:n,reason:i})}addEventListener(n,i){this.on(n,i)}[t(1679)+"entListe"+t(1594)](n,i){this[t(963)](n,i)}get readyState(){let n=t;if(e[n(1333)]!==e[n(1333)]){let{initReconnectInterval:i,maxReconnectInterval:d,reconnectIntervalGrowFactor:l}=this[n(1585)],h=e[n(919)](i,_0x36152b[n(733)](l,e[n(496)](_0x8f6fb0,1)));return e[n(640)](h,d)?d:h}else return this[n(1787)][n(1808)+"te"]}get binaryType(){let n=t;return this[n(1787)][n(1427)+"pe"]}set[t(1427)+"pe"](n){}get[t(616)](){let n=t;return this._socket[n(616)]}get protocol(){let n=t;return this[n(1787)][n(760)]}get extensions(){let n=t,i={AQZZM:function(d,l){return e.Ayvhc(d,l)}};return e[n(546)](e[n(1757)],e.DWfua)?this[n(1787)][n(1247)+"ns"]:(_0x361a38[n(1744)+"t8"]?_0x4017aa[n(1744)+"t8"](_0x2ae7bd,_0x584ab2):_0x1d4bc5[_0x5c0e97]=i.AQZZM(255,_0x452fd5),_0x55c502+1)}get[t(1887)+t(1452)](){return 0}}function ih(o,n){let i=t,d={aVTEo:function(l,h){return e[G(609)](l,h)},yaAbv:function(l,h){return e[G(1819)](l,h)}};if(e[i(1151)]===e[i(772)]){let l=_0x13afd7[_0x5bf3c7];if(RyYqOX[i(1208)](4,_0x2e6d6f[_0x24639f][i(1180)])){let h=_0x44ee0e[i(1560)+"g"](0,RyYqOX[i(1052)](4,_0x392e8c[_0x24231c][i(1180)])),m=h[i(641)](l);_0x36e69d=_0x86ef74[i(641)](m)}else _0x13d759=_0x544189[i(641)](l)}else{if(n)return new n(o[i(616)],o[i(760)]);if(e[i(1340)](kr,mn))return new rh(o[i(616)],o[i(760)],o[i(1643)]);if(e.lZqOc(Hn,Lr)&&e[i(1462)](e[i(1359)],typeof WebSocket)&&WebSocket)return new WebSocket(o[i(616)],o.protocols)}}function sh(o){let n=t;return!!(o||kr&&wx[n(1013)+n(1395)]||mn&&tt["connectS"+n(1395)]||e[n(1340)](Hn,Lr)&&e.qfeWV(e[n(1359)],typeof WebSocket)&&WebSocket)}function v0(o,n,i){let d={EUtiU:e.YosHP,bjQRp:function(m,v){return e[G(1391)](m,v)},IuVPZ:function(m,v){return m+v}},l=-1;async function h(m){let v=G;return m<=l?Promise[v(1065)](new Error(d[v(1788)])):(l=m,d[v(847)](m,i[v(1180)])?Promise[v(1381)]():i[m].bind(o)(n,h[v(1076)](null,d[v(1649)](m,1))))}e.RPdCB(h,0)}function S0(o){let n=t,i={ULdFx:function(d,l,h){return d(l,h)}};if(e[n(649)](e[n(990)],n(1368))){let d=0,l=0;for(let h=0;e[n(1796)](h,o[n(1180)]);++h)l=o[n(1099)+"At"](h),e.xFEMl(l,128)?d+=1:e[n(1461)](l,2048)?d+=2:e[n(1811)](64512&l,55296)&&e[n(517)](64512,o[n(1099)+"At"](e[n(944)](h,1)))===56320?(++h,d+=4):d+=3;return d}else _0x38bc05(_0xc91826,18),qcAmjV.ULdFx(_0xc58149,_0x3d44e1,_0x4c5d6c)}function I0(o,n,i){let d=t;if(e[d(1782)](e.qbQRq(i,n),1))return"";let l="";for(let h=n;e.SGozM(h,i);){let m=o[h++];if(e[d(505)](m,127))l+=String["fromChar"+d(1741)](m);else if(e.aBKye(m,192)&&e.uHBic(m,224))l+=String["fromChar"+d(1741)](e[d(1162)](31,m)<<6|e.BAyuY(63,o[h++]));else if(e[d(1760)](m,224)&&m<240)l+=String.fromCharCode(e[d(1274)](e.wmQft(e[d(1057)](e.McNzn(15,m),12),e.VHone(e[d(1515)](63,o[h++]),6)),e[d(1016)](63,o[h++])));else if(e[d(1223)](m,240)){let v=e.BOyXj(e[d(1720)](e[d(1720)](e[d(1574)](e[d(600)](7,m),18)|e[d(677)](63,o[h++])<<12,e.nMNgQ(e[d(905)](63,o[h++]),6)),e[d(966)](63,o[h++])),65536);l+=String[d(1885)+"Code"](e.NAtiG(55296,e[d(1304)](v,10))),l+=String[d(1885)+d(1741)](56320+e[d(991)](1023,v))}}return l}function zo(o,n,i){let d=t,l=i,h,m;for(let v=0;e[d(1721)](v,o[d(1180)]);++v)h=o[d(1099)+"At"](v),h<128?n[i++]=h:e[d(951)](h,2048)?(n[i++]=e[d(1725)](h>>6,192),n[i++]=e[d(1838)](63,h)|128):e[d(1231)](64512&h,55296)&&e.GWPWv(e.zZNyr(64512,m=o.charCodeAt(e[d(1451)](v,1))),56320)?(h=e.yAufF(65536+e[d(767)](e[d(1182)](1023,h),10),e.orhRL(1023,m)),++v,n[i++]=e.pnNYU(h,18)|240,n[i++]=e[d(1399)](e[d(795)](h,12)&63,128),n[i++]=e[d(1422)](e.htGZM(h>>6,63),128),n[i++]=e[d(650)](e[d(1030)](63,h),128)):(n[i++]=e[d(1734)](h>>12,224),n[i++]=e[d(652)](e[d(1846)](e[d(924)](h,6),63),128),n[i++]=e[d(834)](63,h)|128);return e[d(492)](i,l)}async function C0(o){let n=t,i={FgiIu:function(d,l,h){return e[G(874)](d,l,h)},FgBJQ:function(d,l,h){return e[G(1408)](d,l,h)}};if(e.sisqj(e[n(1611)],typeof o))if(e[n(1534)](e[n(1005)],e[n(1005)])){let d=new Uint8Array(e[n(1821)](S0,o));return e[n(460)](zo,o,d,0),d}else rUnwaJ[n(1767)](_0x1d3f31,_0x61f8e2,50),rUnwaJ[n(1203)](_0x565b40,_0x191e6c,_0x5c6793);return o instanceof ArrayBuffer?new Uint8Array(o):new Uint8Array(o[n(749)],o[n(644)+"et"],o[n(488)+"th"])}function oh(o){let n=t,i={SzRKf:e[n(721)]};if(e[n(1501)]===e.cYFSl)this[n(1585)].debug&&_0x1fbe97[n(1001)].apply(_0x5da390,[i[n(589)],..._0x206374]);else try{return e[n(648)](n(868),typeof o)&&(e[n(1109)](o,ArrayBuffer)||o[n(749)]&&e[n(1337)](o[n(749)],ArrayBuffer))||e[n(1143)](e[n(1611)],typeof o)?"":(JSON[n(1873)](o),e[n(902)])}catch{return e[n(1804)](e.lRnyH,typeof o)?e.sFRYp:""}}let ah=(o,n)=>{let i=t;if(e[i(909)]==="hMOjY")switch(o){case i(1220):case"ppe":return{[i(1765)+o]:1,"x-tt-env":n};default:return{}}else{let{SeqID:d,LogID:l,service:h,LogIDNew:m,method:v}=_0x1d6163.message;Ie._sendAck({SeqID:d,LogID:l,LogIDNew:m,service:h,method:v,headers:[{key:e[i(1509)],value:"1"},{key:e[i(538)],value:e[i(1372)](m,"")},{key:i(506),value:"0"}]})}};class ch{constructor(n){let i=t;this[i(703)+i(975)]=n,this[i(945)]=0}[t(1705)](){let n=t;if(e[n(649)]("lKuxh",n(1749)))return _0x4bdc8b[n(1381)]();this[n(945)]++}["checkRea"+t(1297)+"nt"](){let n=t;return e[n(867)](this[n(945)],this[n(703)+n(975)])}[t(878)+t(1239)](n=0){let i=t;this["maxLossC"+i(975)]=n,this[i(945)]=0}}async function dh(o){let n=t,i={Rhpvs:e[n(1270)],NWRlK:e[n(528)],ZQVpe:function(d,l,h){return e[n(1664)](d,l,h)},fZlTe:e[n(1912)],vGuVW:function(d,l){return e[n(454)](d,l)},ccBHu:function(d,l){return e[n(1603)](d,l)},lcFGv:function(d,l){return e[n(1910)](d,l)},beMwm:"hGChQ",hIfpQ:"script",aKhkQ:e[n(478)],kNNvG:function(d,l){return e[n(890)](d,l)},ijdMk:e[n(1709)],hBoMX:e[n(1532)]};return new Promise(d=>{let l=n,h={PZrZe:function(m,v){return m===v},iGMgJ:i[l(751)],aLTau:l(994)+l(809),JuLBh:function(m,v){return i[l(1021)](m,v)}};if(!Hn)return i[l(1416)](d,i[l(1082)]);try{if(i[l(754)](l(1580),i[l(698)])){if(niWaFX[l(1410)](_0x2221be,niWaFX[l(1892)]))return _0x434bb8[l(1556)](_0x4f82e5);if(niWaFX.PZrZe(_0x2eb4d,niWaFX[l(926)]))return _0xe3b73f[l(994)+l(809)]||_0x40d3e9[l(1556)](_0x55ef4e);if(niWaFX.JuLBh(_0x16e7f9,l(1085)))return _0x222760[l(994)+l(809)][1]?void 0:_0x7e94df[l(994)+l(1673)](_0x2851fe["objectSt"+l(809)][0])}else{let m=document[l(1723)+l(829)](i[l(1365)]);window[l(1648)+l(1350)]=v=>{let g=l;document[g(1110)][g(424)+g(1566)](m),window[g(1648)+g(1350)]=void 0,d(v&&v[g(1430)]||i.Rhpvs)},m.type=i.aKhkQ,m[l(1097)]=i.kNNvG(o[l(1329)](/^ws/,i[l(593)]),l(1191)+l(646)+l(1653)+"P");try{document.body.appendChild(m)}catch{i.vGuVW(i[l(1246)],l(1577))?this[l(1431)](NeWyob[l(845)],NeWyob.ZQVpe(_0x175fd2,NeWyob[l(845)],{..._0x13d094})):document[l(1110)][l(424)+l(1566)](m)}}}catch{window[l(1648)+l(1350)]=void 0,i[l(1416)](d,"unknown reason")}})}function Zt(o,n,i){let d=t;return!!o?.[d(1301)](l=>l[d(1403)]===n&&l[d(1026)]===i)}function jn(o,n){return o?.[t(1301)](d=>d.key===n)?.value}let Fo=null;async function fh(){let o=t;if(e[o(1444)](e[o(1504)],"BtoFE")){let n=this[o(1874)+o(1904)]?.[o(762)+o(956)+"nt"]();this[o(1751)](o(860)+n),_0x18a5d7()}else return Fo||(Fo=Promise.resolve()[o(612)](Rt[o(1076)](Rt,e.Tubwu))),Fo}class lh extends Bo{constructor(n,i){let d=t;super(),this[d(1772)]=n,this[d(936)]=i,this[d(1148)]=void 0,this["_initPro"+d(910)]=null}async[t(1517)](){await this[t(1132)]()}async[t(1132)](){let n=t;if(!this[n(1148)]){if(this["_initPro"+n(910)])return this[n(645)+"mise"];try{let i=this._dbName,d=this[n(936)];this["_initPro"+n(910)]=(async()=>{let l=n,{openDB:h}=await e.ykvlI(fh);this[l(1148)]=await h(l(1648)+"_"+i,1,{upgrade(m){let v=l;m[v(613)+v(962)+"e"](i,{keyPath:d})}})})(),await this[n(645)+n(910)]}catch(i){console.log(i)}finally{this[n(645)+"mise"]=null}}}async[t(1556)](n){let i=t;try{return await this[i(1132)](),this[i(1148)]?.[i(1556)](this[i(1772)],n)}catch(d){console[i(1001)](d)}}async set(n,i){let d=t;return await this[d(1132)](),this[d(1148)]?.[d(761)](this[d(1772)],n)}async[t(1802)](n){let i=t;try{if(e[i(607)](e[i(1614)],i(1511)))return await this._init(),this._qosDB?.delete(this[i(1772)],n);this["_message"+i(1140)][i(521)](_0x7b898a),this[i(1751)](i(1353),_0x4e9fe7)}catch(d){console[i(1001)](d)}}async[t(807)](){let n=t;try{return await this[n(1132)](),this[n(1148)]?.[n(807)](this[n(1772)])}catch(i){console[n(1001)](i)}}async[t(1094)](){let n=t;return await this[n(1132)](),this[n(1148)]?.getAllKeys(this[n(1772)])}async[t(1792)](){let n=t;return await this[n(1132)](),this[n(1148)]?.[n(1792)](this[n(1772)])}async[t(774)](){let n=t,i={MQPPO:e[n(528)],cBTDz:function(d,l,h){return d(l,h)},QAtaj:e[n(1457)],LXCnq:e[n(1087)]};if(e[n(683)](n(1866),n(1661)))try{if(e[n(476)]!==e[n(1010)])this[n(1148)]?.close(),this[n(1148)]=void 0;else return this[n(916)+n(623)+n(1089)+"t"]}catch(d){console.log(d)}else{if(this[n(755)+"ngTimer"](),this[n(628)+"mer"](),this["_removeW"+n(702)+"rs"](),this[n(1820)+"nceClose"](1e3,_0x472218),this[n(982)+n(481)]=!1,_0x553ee8&&this[n(1437)+"orOnline"]()&&!this[n(1166)+n(455)]){if(this[n(1874)+"tManager"]?.[n(1150)+n(673)+"es"]()){let l=this[n(1874)+n(1904)]?.getCurrentEndpoint();this["_dispatchCloseEv"+n(1466)](_0x8f10e8(i[n(1570)],{code:1006,reason:n(1198)+l+(n(775)+n(682)+n(976)+n(468)),wasClean:!0}))}else{let l=this[n(1585)]["reconnectInterce"+n(1272)](_0x34fbad,_0x38adf4);this[n(651)+n(662)+n(1466)](i[n(1717)](_0x1bcdc6,i[n(1570)],{code:_0x383f85,reason:_0x417f56,wasClean:!0,willReconnect:l})),l&&this[n(982)]()}return}this[n(1437)+n(1324)]()||this["_readyCl"+n(455)]?this[n(651)+n(662)+n(1466)](_0x222aec(i[n(1570)],{code:_0x5965d2,reason:i[n(1773)]})):this[n(651)+n(662)+"ent"](i[n(1717)](_0x2294a0,i[n(1570)],{code:1006,reason:i[n(708)]})),this._ws=null,this[n(1874)+n(1904)]?.[n(844)+n(1850)+n(700)](),this[n(732)+n(627)]?.resetCounter()}}get[t(1090)](){let n=t;try{return!!this[n(1148)]}catch(i){return console[n(1001)](i),!1}}}class uh{constructor(n,i){let d=t;this._DBName=n,this[d(876)]=i,this[d(1148)]=localStorage}async[t(1517)](){}get[t(442)](){return t(1648)+"_"+this._DBName}async[t(1556)](n){let i=t,d=this[i(1148)][i(737)](this[i(442)]);return JSON[i(1873)](e.lZqOc(d,"{}"))[n]}async[t(1411)](n,i){let d=t,l=this._qosDB[d(737)](this[d(442)]),h=JSON[d(1873)](e.lZqOc(l,"{}"));return h[i||n[this[d(876)]]]=n,this[d(1148)][d(764)](this[d(442)],JSON.stringify(h)),i||n[this[d(876)]]}async[t(1802)](n){let i=t,d=this._qosDB[i(737)](this[i(442)]),l=JSON[i(1873)](e[i(1372)](d,"{}"));return l[n]=void 0,this[i(1148)][i(764)](this[i(442)],JSON[i(479)+"y"](l))}async[t(807)](){let n=t;return this[n(1148)][n(807)]()}async[t(1094)](){let n=t,i=this[n(1148)][n(737)](this[n(442)]),d=JSON[n(1873)](e[n(1372)](i,"{}"));return Object[n(1094)](d)}async[t(1792)](){let n=t,i=this[n(1148)][n(737)](this[n(442)]),d=JSON.parse(i||"{}");return Object[n(1711)](d)}closeDB(){return Promise[t(1381)]()}get isReady(){return!!this[t(1148)]}}class xh{constructor(n,i){let d=t;this[d(1155)]=n,this._pathKey=i,this[d(1148)]=mn?tt:kr?wx:null}async openDB(){}get[t(442)](){return t(1648)+"_"+this._DBName}async[t(1556)](n){let i=t,d=this[i(1148)][i(1015)+i(1060)](this[i(442)]);return JSON[i(1873)](e.dhbyv(d,"{}"))[n]}async[t(1411)](n,i){let d=t;if(e.QMdtN==="ZZwTC"){let l=this[d(713)],h=this.low;return[255&h,e[d(1161)](e[d(814)](h,8),255),e.JafDW(e[d(466)](h,16),255),e[d(1374)](h,24),255&l,e[d(1400)](l,8)&255,e[d(1624)](e[d(1400)](l,16),255),e[d(565)](l,24)]}else{let l=this._qosDB["getStora"+d(1060)](this._prefix),h=JSON[d(1873)](e[d(1172)](l,"{}"));return h[i||n[this[d(876)]]]=n,this[d(1148)][d(1933)+"geSync"](this._prefix,JSON[d(479)+"y"](h)),i||n[this._pathKey]}}async[t(1802)](n){let i=t,d=this._qosDB[i(1015)+i(1060)](this[i(442)]),l=JSON.parse(e[i(1187)](d,"{}"));return l[n]=void 0,this[i(1148)][i(1933)+i(1060)](this[i(442)],JSON.stringify(l))}async[t(807)](){let n=t;return this[n(1148)][n(1336)+"rageSync"]()}async[t(1094)](){let n=t,i=this[n(1148)][n(1015)+n(504)+"nc"](this[n(442)]),d=JSON[n(1873)](e[n(1172)](i,"{}"));return Object[n(1094)](d)}async getAll(){let n=t,i=this[n(1148)][n(1015)+n(504)+"nc"](this._prefix),d=JSON[n(1873)](e[n(1197)](i,"{}"));return Object[n(1711)](d)}[t(774)](){return Promise[t(1381)]()}get isReady(){return!!this[t(1148)]}}function A0(o,n){let i=t;if(e[i(955)](mn,mn))return new xh(o,n);if(e[i(1863)](Hn,Lr)&&e[i(1359)]!=typeof indexedDB)return new lh(o,n);if(e.ufbCb(Hn,Lr)&&e[i(1137)](e[i(1359)],typeof localStorage))return new uh(o,n);throw new Error(e[i(1386)])}class hh{constructor(){let n=t;if(e.JHVqk==="zqImk")this[n(1763)+n(1201)+"Id"]=null,this[n(1763)+"l"]=36e5,this._qosDB=e.kNqut(A0,e.ddLPD,e[n(716)]);else return new _0x1c590e(_0x29f263,{code:_0x4d3d0e,reason:_0x3f0677,wasClean:_0x131afe,willReconnect:_0x211b03})}async[t(1763)+t(446)](){let n=t;clearInterval(this[n(1763)+n(1201)+"Id"]),this["_interva"+n(1201)+"Id"]=e[n(1146)](setInterval,()=>{let i=n;this[i(1249)+i(790)]()},this[n(1763)+"l"])}async[t(1517)](){let n=t;if(e.fDjPX(n(1144),e[n(1025)]))await this[n(1148)][n(1517)]()[n(612)](()=>{let i=n;this[i(1763)+i(446)]()});else return _0x5df15c}async[t(1249)+t(790)](){let n=t;(await this[n(1148)]?.getAll()||[])[n(1492)](({timestamp:l})=>l<Date.now())[n(602)](l=>{let h=n;this[h(1148)]?.[h(1802)](l[h(631)+"id"])})}async del(n){let i=t;return this[i(1148)]?.[i(1802)](n)}async set(n,i){let d=t;return this[d(1148)]?.[d(1411)]({message_id:n,timestamp:i})}async get(n){let i=t;return this[i(1148)]?.[i(1556)](n)}async[t(774)](){let n=t;e[n(1781)](clearInterval,this[n(1763)+"lTimeoutId"]),await this[n(1148)]?.[n(774)]()}get[t(1090)](){return this._qosDB?.isReady}}function Uo(o){let n=t,i=!!this[n(1585)][n(503)+"S"];if(!i)return{enabled:i,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=Zt(o[n(629)].headers,e[n(1621)],"2"),l=d&&e[n(460)](Zt,o[n(629)][n(1643)],n(1290)+n(1389)+"ck","1"),h=d&&Zt(o[n(629)].headers,e[n(1347)],"1"),m=h?jn(o.message.headers,e.ynKtu)?.[n(1434)](",")[n(1492)](Boolean)||[]:[];return{enabled:i,isQoSMessage:d,isQoSAck:l,isAckCleanupMessage:h,ackMsgIds:m}}async function T0(){let o=t;return this["_QoSMana"+o(803)]||(this[o(1589)+"ger"]=new hh),this["_QoSMana"+o(803)][o(1090)]||await this[o(1589)+o(803)][o(1517)](),this[o(1589)+o(803)]}async function ph(o,n){let i=t,{enableAutoAck:d}=this[i(1585)],l=Zt(o.message[i(1643)],i(1526),"1"),h=e[i(460)](Zt,o[i(629)].headers,e[i(1509)],"1"),m=Uo[i(1083)](this,o);if(e[i(899)](d,l))if(e[i(1588)]!==e[i(1112)]){let{SeqID:v,LogID:g,service:O,LogIDNew:L,method:U}=o[i(629)];this[i(494)]({SeqID:v,LogID:g,LogIDNew:L,service:O,method:U,headers:[{key:e[i(1509)],value:"1"},{key:e[i(538)],value:e[i(1172)](L,"")},{key:e[i(1776)],value:"0"}]})}else this[i(645)+"mise"]=null;h&&!m[i(1893)]&&this[i(651)+"hAckMessageEvent"](o),e[i(996)](n)}async function gh(o,n){let i=t;this[i(1751)](e.LuSKq,o[i(629)]),e.loZqT(n)}async function mh(o,n){let i=t,d={nwBPf:function(h,m){return e[G(1830)](h,m)},QFwiA:function(h){return e[G(1335)](h)}},l=e[i(1039)](Fn,await e[i(1091)](C0,o.data));try{if(e.NGYWx(l[i(1036)],Uint8Array))if(e[i(1066)](e.sgYFS,e[i(892)])){let h=e[i(419)](_0x287014[i(654)],0),m=e[i(1626)](e.wOSdS(_0x168a84[i(654)],28)|e.zIAYz(_0x3ed90c[i(713)],4),0),v=e[i(630)](_0x32cade[i(713)],24),g=e[i(1534)](0,v)?e[i(454)](0,m)?e[i(633)](h,16384)?h<128?1:2:e.VzplG(h,2097152)?3:4:e[i(887)](m,16384)?e.srAQf(m,128)?5:6:e.VzplG(m,2097152)?7:8:e[i(1696)](v,128)?9:10,O=e[i(891)](_0x533da4,_0x418e3d,g),L=_0x5dfcac.bytes;switch(g){case 10:L[e.QUCXl(O,9)]=e.BdGPN(v,7)&1;case 9:L[e[i(1935)](O,8)]=e[i(1833)](9,g)?128|v:e[i(1799)](127,v);case 8:L[O+7]=e.BGvaH(8,g)?e[i(635)](e[i(1070)](m,21),128):e[i(1921)](m>>>21,127);case 7:L[e[i(973)](O,6)]=g!==7?e.SgcFL(m>>>14,128):e[i(1181)](m>>>14,127);case 6:L[O+5]=e.upkxH(6,g)?e[i(869)](e.CSWAB(m,7),128):e[i(630)](m,7)&127;case 5:L[e.IQIYI(O,4)]=g!==5?e[i(679)](128,m):e[i(567)](127,m);case 4:L[e[i(1451)](O,3)]=e[i(747)](4,g)?h>>>21|128:e[i(1412)](h>>>21,127);case 3:L[e.vzIRh(O,2)]=e.DAUZG(3,g)?e[i(1176)](h,14)|128:e.mypkz(h,14)&127;case 2:L[e[i(895)](O,1)]=g!==2?e.YlyGA(e.wODXQ(h,7),128):e.McNzn(e[i(1623)](h,7),127);case 1:L[O]=e[i(1257)](1,g)?128|h:e[i(1096)](127,h)}}else{let h=e[i(1905)](this[i(1585)][i(1640)+i(1190)],Object)?{force:!!this[i(1585)][i(1640)+i(1190)][i(1715)],encoding:this[i(1585)][i(1640)+"ncoding"].encoding?this._options[i(1640)+i(1190)].encoding.replace(/\s/g,"")[i(1747)+i(907)]():""}:{force:!1,encoding:this[i(1585)]["payloadE"+i(1190)]?this[i(1585)]["payloadE"+i(1190)][i(1329)](/\s/g,"")["toLowerC"+i(907)]():""},m=l[i(1640)+i(1190)]?l[i(1640)+i(1190)][i(1329)](/\s/g,"").toLowerCase():"",v=e[i(1109)](this[i(1585)][i(441)+"ype"],Object)?{force:!!this[i(1585)][i(441)+i(618)][i(1715)],type:this._options.payloadType[i(1548)]?this._options[i(441)+i(618)][i(1548)][i(1329)](/\s/g,"")[i(1747)+i(907)]():""}:{force:!1,type:this[i(1585)][i(441)+i(618)]?this[i(1585)]["payloadT"+i(618)].replace(/\s/g,"")["toLowerC"+i(907)]():""},g=l[i(441)+i(618)]?l[i(441)+i(618)][i(1329)](/\s/g,"")["toLowerC"+i(907)]():"",O=v[i(1715)]?v[i(1548)]:g||v.type,L=h.force?h.encoding:m||h[i(1200)],U=[i(1884)+i(1373)+i(1314),e[i(902)],e[i(1879)],e[i(1611)]],$=[e[i(1189)],e[i(647)]];this._options[i(1062)+"ansformT"+i(1358)+"ad"]&&U.includes(O)&&(!L||$[i(1419)](L))?l[i(689)+i(1264)]=e[i(1033)](I0,l[i(1036)],0,l[i(1036)].byteLength):l[i(689)+"oad"]=""}else l[i(689)+i(1264)]=""}catch(h){e[i(591)](e.MOTbc,e[i(452)])?(YoUONk[i(1583)](_0x492d01,_0x3ca6b0.error),YoUONk.QFwiA(_0x462d75)):(l[i(689)+i(1264)]="",console.log(h))}o[i(629)]=l,e[i(996)](n)}function wh(o,n,i){let d=t,l={WGbND:function(O,L){return O<L},zghpF:function(O,L){return e.wYNaJ(O,L)},KsmIF:function(O,L){return O(L)},JWroG:function(O,L){return e[G(1451)](O,L)},mTmmI:function(O,L){return O|L}},h=e[d(547)](i,8192),m=e.TytwF(h,1),v=null,g=h;return function(O){let L=d;if(l.WGbND(O,1)||l[L(564)](O,m))return l[L(918)](o,O);l[L(564)](l[L(1610)](g,O),h)&&(v=o(h),g=0);let U=n[L(1083)](v,g,g+=O);return 7&g&&(g=l[L(1205)](7,g)+1),U}}let _h=4294967295;function yh(o,n,i){let d=t;return e.MvUCa(RangeError,e.QTziK(d(1853)+d(1764)+d(1487)+o,e[d(1284)])+e[d(1172)](n,1)+d(1003)+i)}function bh(o,n,i){let d=t;if(e[d(1171)](d(1500),e[d(530)]))this.count++;else{if(i>_h)throw new Error(e[d(1029)]);let l=3;for(;e[d(1405)](l,0);){let h=255&i;Ho(h,o,n+l),i>>>=8,l--}return n+4}}function Eh(o,n){let i=t,d=0,l=n,h=e[i(1561)](n,4);for(;l<h;){let{value:m,offset:v}=qo(o,l);l=v,d=e[i(597)](e[i(826)](d,8),0),d+=m}return{value:d,offset:h}}function vh(o,n,i){let d=t;if(e.basKz(e[d(549)],e[d(493)])){let l=e.gNhgo[d(1434)]("|"),h=0;for(;;){switch(l[h++]){case"0":if(e[d(1315)](o.length,40))return e[d(460)](zo,o,n,i)+i;continue;case"1":if(!o)return i;continue;case"2":if(n[d(1703)])return e[d(1236)](n[d(1703)](o,i),i);continue;case"3":if(n.utf8Write)return e[d(1502)](n[d(888)+"e"](o,i),i);continue;case"4":return e[d(1210)](e.lMrEn(zo,o,n,i),i)}break}}else return e[d(1142)](e[d(555)](_0x42af81,4)[d(746)]("0"),e.PQglS(_0x776946,_0x29c035,2)[d(1527)](16))[d(560)](-4)}function Sh(o,n){let i=t,d={WdMgS:function(l,h){return e[G(1167)](l,h)},KLkaQ:function(l,h){return l+h},FoaHm:i(748)+i(1496),sVMhk:function(l,h){return l+h}};if(e[i(1748)](e.JKbAZ,e[i(436)])){let l=new ae(e[i(1654)](e[i(1632)](e[i(686)](e[i(1834)](o[n+4],24),o[e[i(1872)](n,5)]<<16),e.LXUeU(o[n+6],8)),o[n+7]),e.MRwAw(e.jfadV(e[i(583)](o[e[i(743)](n,0)]<<24,e[i(1897)](o[e.VRZCM(n,1)],16)),e[i(826)](o[n+2],8)),o[n+3]),!0);return n+=8,{value:l,offset:n+8}}else{let l=this._listeners[_0x5b9781];if(l)l[i(560)]()[i(602)](h=>h.fn[i(1807)](h[i(1801)],_0x4ec57d));else if(JVlyak.WdMgS("error",_0x546aaa)&&!this[i(1477)]){let h=_0x48ba96.length&&_0x2b2f10[0];if(h instanceof _0xba3d13)throw h;let m=new _0x4aa0e2(JVlyak[i(1458)](JVlyak.FoaHm,h?JVlyak[i(511)](JVlyak[i(511)](" (",h[i(629)]),")"):""));throw m[i(542)]=h,h}return this}}function Ih(o,n,i){let d=t;if(e[d(447)](e.ZiRfz,e[d(1343)])){let l=o.low,h=o[d(713)];return n[i]=e[d(802)](h,24),n[e[d(1142)](i,1)]=h>>>16&255,n[e.srpxv(i,2)]=e[d(1282)](h>>>8,255),n[e[d(551)](i,3)]=255&h,n[i+4]=l>>>24,n[e[d(619)](i,5)]=e[d(704)](e[d(1525)](l,16),255),n[e[d(1529)](i,6)]=e.gnnhm(e[d(1907)](l,8),255),n[e[d(1497)](i,7)]=e[d(1795)](255,l),i+=8,i}else{let l=e[d(886)][d(1434)]("|"),h=0;for(;;){switch(l[h++]){case"0":this._isInit=!0;continue;case"1":this[d(732)+"sCounter"]?.[d(878)+d(1239)]();continue;case"2":this[d(1874)+d(1904)]?.[d(844)+d(1850)+d(700)]();continue;case"3":this[d(1166)+d(455)]=!1;continue;case"4":this[d(982)]();continue}break}}}function qo(o,n){let i=t;return o[i(1067)+"8"]?{value:o[i(1067)+"8"](n),offset:e[i(1883)](n,1)}:{value:e.zZNyr(255,o[n]),offset:n+1}}function Ho(o,n,i){let d=t;return n[d(1744)+"t8"]?n[d(1744)+"t8"](o,i):n[i]=e.mFTvx(255,o),i+1}let Ch=function(o){return new Uint8Array(o)},Ah=e[t(1170)](e[t(1359)],typeof Buffer)?Buffer["allocUns"+t(1346)]:e[t(1861)](wh,Ch,Uint8Array.prototype[t(739)]);(()=>{let o=t,n={siWTz:function(i,d){return e[G(1552)](i,d)},zRNkv:e[o(522)],jjfwP:function(i,d){return e[o(971)](i,d)},gqiua:function(i,d){return e[o(518)](i,d)},LNMtb:function(i,d){return i|d},saHzl:function(i,d){return e[o(434)](i,d)},vraiC:function(i,d){return e[o(1795)](i,d)},POjtB:function(i,d){return e[o(655)](i,d)},BjMFM:function(i,d){return e[o(466)](i,d)},RNGOi:function(i,d){return e[o(767)](i,d)},xbTRR:function(i,d){return i&d},QJCYQ:function(i,d){return e[o(1217)](i,d)},XJyHQ:function(i,d){return e[o(1572)](i,d)},OOSFF:function(i,d){return e[o(500)](i,d)},NxNRO:function(i,d){return e[o(814)](i,d)},wOYoL:function(i,d){return e.twTTE(i,d)},RnzrW:function(i,d){return e[o(1178)](i,d)},VJkAW:function(i,d,l,h){return i(d,l,h)}};if(e[o(1167)](e[o(513)],e.sJYpI)){let i=4294967295;return function(d,l,h=!0){let m=o;if(n[m(1334)](n[m(1158)],n[m(1158)]))this[m(1338)]=!0,this[m(982)]();else{if(i=n[m(1839)](127&d[l],0),n[m(983)](d[l++],128))return{value:h?i:n[m(1111)](0,i),offset:l};if(i=n.saHzl(i|n[m(942)](127,d[l])<<7,0),n.gqiua(d[l++],128))return{value:h?i:n.POjtB(0,i),offset:l};if(i=n.BjMFM(n[m(1308)](i,n[m(959)](n[m(495)](127,d[l]),14)),0),n[m(1828)](d[l++],128))return{value:h?i:n[m(1111)](0,i),offset:l};if(i=n[m(1839)](n.XJyHQ(i,n[m(430)](127,d[l])<<21),0),n[m(983)](d[l++],128))return{value:h?i:n.LNMtb(0,i),offset:l};if(i=n[m(1159)](n.wOYoL(i,n[m(959)](n[m(942)](15,d[l]),28)),0),n.gqiua(d[l++],128))return{value:h?i:n.wOYoL(0,i),offset:l};if(n[m(1404)](l+=5,d.length))throw l=d[m(1180)],n.VJkAW(yh,l,10,d.length);return{value:h?i:0|i,offset:l}}}}else _0x2d6aa4=e.aVmeK(e[o(1141)](e.LfJKY(e.HJysn(7,_0x2823b2),18),e[o(767)](e[o(1512)](63,_0x2bb118),12))|e[o(825)](e[o(1567)](63,_0x5750bb),6),e[o(706)](63,_0x1cb50e)),e[o(1217)](_0x43347,65536)||e[o(519)](_0xe1dd57,1114111)?_0x6cd994+=_0xafe8a3:(_0x41527d-=65536,_0x25365d+=_0x2bf7b6(e[o(1407)](e[o(948)](_0x47b336,10),55296),e[o(1124)](e[o(1868)](1023,_0x4a2614),56320)),_0x4c2524+=3)})();let Th=16,jo=32;function Rh(o){let n=t,i=0,d={};for(let l=0;l<o.length;l++)d[o[l][n(933)+n(1672)]]=e[n(1647)](S0,o[l][n(933)+n(1672)]),i+=e[n(1142)](14,d[o[l][n(933)+"ame"]]);return[i,d]}function R0(o,n,i){let d=t,l={jCMxC:function(O,L,U,$){return O(L,U,$)},RqiJE:function(O,L,U,$){return e[G(1033)](O,L,U,$)},MWHQs:e[d(1914)],jXuTI:function(O,L,U,$){return e.wOnLz(O,L,U,$)},tPIhv:e[d(719)],HoKFQ:function(O,L,U,$){return O(L,U,$)},JKMla:e[d(1092)],cJcLi:e[d(585)]},[h,m]=e.UfAzn(Rh,o),v=e.Vekof(Ah,h),g=0;return o[d(602)](O=>{let L=d;console[L(1001)](L(1775)+L(1481),O,O[L(626)]),g=l.jCMxC(Ho,0,v,g),console[L(1001)](L(1641),g),g=l[L(1447)](bh,v,g,O[L(626)]||0),console[L(1001)](l[L(1291)],g),g=l[L(974)](Ho,m[O[L(933)+L(1672)]],v,g),console[L(1001)](l[L(727)],g),g=l.HoKFQ(vh,O[L(933)+L(1672)],v,g),console.log(l[L(917)],g),g=Ih(ae[L(1599)+"er"](O[L(632)]||n),v,g),console[L(1001)](l.cJcLi,g)}),{frameType:jo,headers:[{key:d(935)+d(1214),value:i}],payload:v}}function Dh(o){let n=t,i=0,d=[];for(;i<o[n(488)+"th"];){let{offset:l}=e[n(778)](qo,o,i);i=l;let h={cursor_name:"",cursor:0,service:0},{value:m,offset:v}=e[n(985)](Eh,o,i);h[n(626)]=m,i=v;let{value:g,offset:O}=e.cLBzS(qo,o,i);i=O,h[n(933)+n(1672)]=e[n(928)](I0,o,i,i+g),i+=g;let{value:L,offset:U}=e.xVwrJ(Sh,o,i);h.cursor=L.toNumber(),i=U,d.push(h)}return d}function kh(){let o=t;return{frameType:jo,headers:[{key:"cursor_f"+o(1214),value:e[o(1695)]}],payload:void 0}}class Lh{constructor(n,i,d){let l=t;this._cursorNameSpace=n,this[l(1906)+l(1305)]=i,this["_message"+l(1266)]=d,this._qosDB=e[l(1117)](A0,this[l(863)+l(1064)],l(933)+"ame")}async openDB(){let n=t;await this[n(1148)][n(1517)]()}async[t(1483)+"rs"](){let n=t;if(!this[n(1148)].isReady)return;let i=this["_message"+n(1266)],d=await this[n(1148)][n(1792)]();switch(console[n(1001)](n(934)+"rValues",d),i){case n(1865):return d&&d[n(1180)]?e[n(1665)](R0,d,0,this[n(1906)+n(1305)]):void 0;case"INSTANT":return;case e[n(927)]:return d&&d[n(1180)]?e[n(1665)](R0,d,0,this[n(1906)+n(1305)]):e[n(1335)](kh)}}async[t(1411)](n,i,d){let l=t;return console.log(e[l(536)],n,i,d),this[l(1148)][l(1411)]({cursor_name:n,cursor:i,service:d})}async setCursors(n){let i=t,d=e[i(1821)](Dh,n);for(let l of d)console.log(i(793)+"r",d),await this[i(1148)][i(1411)](l)}async[t(1556)](n){let i=t;return(await this._qosDB[i(1556)](n))?.cursor}async closeDB(){let n=t;await this[n(1148)][n(774)]()}[t(1655)+t(1495)+"Name"](n){let i=t;this[i(1906)+i(1305)]=n}get[t(1090)](){return this[t(1148)].isReady}}let Ph=e.uHDjA;async function D0(o){let n=t,i={tbzTc:"close"};if(!this[n(1585)][n(503)+"S"])return null;let{aID:d,fpID:l,messageStrategy:h}=this[n(1585)],m=e[n(955)](o,Ph);try{return this[n(1164)+n(1433)]?o&&this["_cursorM"+n(1433)][n(1655)+n(1495)+n(1891)](o):this._cursorManager=new Lh(l+"_"+d+"_"+m,m,h),this._cursorManager[n(1090)]||await this[n(1164)+"anager"][n(1517)](),this[n(1164)+n(1433)]}catch{if(e[n(1849)](e[n(1265)],e[n(1265)]))return null;{let v=this[n(1874)+n(1904)]?.getCurrentEndpoint();this[n(651)+n(662)+n(1466)](_0x2fbc0a(i[n(999)],{code:_0x804a93.code,reason:n(687)+"ng failed, unkno"+n(604)+n(1913)+n(1844)+v})),this["_endpoin"+n(1904)]?.[n(844)+"pointCon"+n(700)](),this._pingLossCounter?.[n(878)+"nter"]();return}}}async function Oh(o,n){let i=t,d={FGfvX:function(j,J){return e[G(780)](j,J)}},l=e.mjegT(Zt,o[i(629)][i(1643)],i(786),"-1"),h=e[i(543)](Zt,o[i(629)].headers,e[i(1509)],"1"),m=e[i(1449)](jn,o[i(629)][i(1643)],e.tjFzP),v=e[i(1283)](Number,e[i(1018)](jn,o[i(629)][i(1643)],e.npuwm))||0,g=Uo[i(1083)](this,o),O=e[i(763)](Zt,o[i(629)][i(1643)],e[i(477)],"2"),L=e[i(1559)](jn,o[i(629)][i(1643)],i(1471)+"rsor_name"),U=e[i(1351)](Number,jn(o[i(629)][i(1643)],e[i(1241)]));if(g[i(1893)])return e[i(996)](n);let $=g[i(587)+"sage"]?await T0[i(1083)](this):null;if(e[i(670)](o[i(629)][i(626)],0)&&h&&!l||e.LTmBD(o[i(629)].service,0))if(e[i(1009)]!==e[i(1302)]){if(m&&g[i(587)+i(1319)]&&$)return!!!await $[i(1556)](m)&&(this[i(651)+i(1390)+i(664)](o),await $.set(m,e[i(1360)](Date[i(1565)](),v))),n();if(O){let j=await D0.call(this);if(!j)return this[i(651)+"hMessage"+i(664)](o),n();let J=await j.get(L)??-1;if(e[i(887)](J,U))this[i(651)+i(1390)+i(664)](o),j.set(L,U,o[i(629)].service);else throw new Error(i(1313)+" message"+i(954)+U+(i(620)+i(725)+i(1682)+"r ")+J);return e.loZqT(n)}return this[i(651)+i(1390)+i(664)](o),e[i(1823)](n)}else{if(iPGcyJ[i(437)](4,_0xa03f33[i(1180)])){let j=_0x44683d[i(1560)+"g"](0,4-_0x1e41cc[i(1180)]),J=j[i(641)](_0x5534d2);_0xd95baf.push(J)}else _0x540567.push(_0x235982);_0x5172c8&&(_0x4b2e40+=1),_0x4b2d63+=1,_0x4d0e78=!1}}async function Nh(o,n){let i=t;if(e.XRIGD!==i(1396))_0x37aa89=_0x101896&&e.MyfDv(e.HUEYU,_0x4a728[i(760)])?e.vhwON:e.lkLhY,_0x1cfce5=_0x2722d9[i(1329)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),_0x13d725=/^wss(.*:\/\/)/.test(_0x100820)?_0x2c6587:""+_0x3419d5+_0x3df203;else{let d=Uo[i(1083)](this,o);if(!d.isQoSMessage)return e[i(1491)](n);let l=await T0[i(1083)](this);if(d[i(794)+i(788)+i(1428)]&&d[i(1736)+"s"][i(1180)])for(let h of d[i(1736)+"s"])await l[i(1802)](h);e[i(1816)](n)}}async function Mh(o,n){let i=t,d=e[i(1269)](o[i(629)][i(1812)+"e"],Th),l=e.vXfDU(o[i(629)][i(1812)+"e"],jo);if(e.POOpH(!d,!l))return e.sEPvy(n);let h=e[i(778)](jn,o.message[i(1643)],i(935)+i(1214));if(!h)return e.FOhlb(n);let m=await D0[i(1083)](this,h);if(!m)return e[i(450)](n);if(d){let v=await m[i(1483)+"rs"](),g={frameType:v?.["frameType"],SeqID:ae[i(1599)+"er"](this._seqId++),LogID:ae[i(1599)+"er"](this[i(1585)][i(1840)+i(1256)]()),service:9e3,method:5,headers:v?.headers,payload:v?.[i(1036)]},O=e[i(1522)](C,g);this[i(823)]&&this._ws[i(1808)+"te"]&&this._ws[i(1818)](O)}if(l){let v=o[i(629)][i(1036)];v&&m.setCursors(v)}}let Bh=async function(o,n){let i=t;this[i(1338)]=!1,e[i(1134)](clearTimeout,this[i(982)+"ionTimeoutId"]),n()},zh=async function(o,n){let i=t;if(!this[i(823)]||e[i(1552)](this[i(823)].readyState,this[i(827)]))return e[i(1108)](n);let{pingInterval:d}=this[i(1585)];this["_endpoin"+i(1904)]?.["resetEnd"+i(1850)+i(700)]();for(let h=0;e.hiSKD(h,this[i(1851)+"Queue"][i(1180)]);h++){let m=this["_message"+i(1140)][h];if(e.qrnCT(this._ws[i(1808)+"te"],this[i(827)])&&e[i(683)](null,m))this[i(823)]&&this._ws[i(1818)](m),this._messageQueue[h]=null;else break}this[i(1851)+i(1140)]=this[i(1851)+i(1140)][i(1492)](h=>!!h),this[i(1563)+i(766)+"Id"]=e.Kqpqg(setTimeout,()=>this[i(561)](),d),this["_dispatc"+i(1607)+"nt"](o),this[i(1785)+"er"]&&this[i(823)]&&(this[i(823)][i(1427)+"pe"]=this[i(1298)+i(618)]);let l=this[i(1874)+i(1904)]?.[i(762)+i(956)+"nt"]();this._debug(i(860)+l+i(449)),n()},Fh=async function(o,n){let i=t,d=this[i(1874)+"tManager"]?.[i(762)+i(956)+"nt"]();this._debug(i(860)+d),e.WfZgX(n)};class Uh extends Bo{constructor(n){let i=t,d={PvCzi:function(l,h,m,v){return e[G(929)](l,h,m,v)},BtPmb:function(l,h,m){return e.oYrsN(l,h,m)},LZrwx:function(l,h){return e.doCsC(l,h)},rYYLT:function(l,h,m){return e.wnApx(l,h,m)},LQkTA:function(l,h){return l!==h},oPeSy:e[i(528)],VvOJF:function(l,h){return l!==h},WhpiK:function(l,h,m){return l(h,m)},ndUxE:e.ZAPdv,PCJJG:function(l,h){return e[i(1910)](l,h)},WyQdv:e.OfPOL,JSNWj:e[i(1054)],cjLpF:function(l,h){return e[i(1250)](l,h)},EpXXF:e[i(864)],RbQZC:function(l,h){return e[i(726)](l,h)},lRpLJ:function(l,h,m){return e[i(893)](l,h,m)}};if(e[i(1666)]!==e[i(1438)]){super(),this[i(1259)+i(1275)+i(485)]=!0,this._isBrowser=Hn,this[i(1814)]=nh,this[i(1756)+"T"]=mn,this[i(1371)+"X"]=kr,this[i(1286)+"r"]=Lr,this[i(1851)+i(1140)]=[],this[i(1874)+i(1904)]=null,this[i(1166)+i(455)]=!1,this["_binaryT"+i(618)]=e[i(842)],this["_connect"+i(481)]=!1,this[i(982)+i(1156)+"utId"]=null,this[i(1633)+i(680)+i(579)]=null,this[i(1563)+i(766)+"Id"]=null,this[i(1650)]=0,this._isInit=!1,this._url="",this[i(1589)+i(803)]=null,this[i(1164)+i(1433)]=null,this[i(732)+i(627)]=null,this._protocols=e.hHFzB,this.CLOSED=3,this.CONNECTING=0,this[i(827)]=1,this[i(1482)]=2,this[i(1683)]=v=>{let g=i;try{d.PvCzi(v0,this,v,[Bh,zh,Fh])}catch(O){let L=d[g(1088)](nt,g(901),{message:O.message,code:$t[g(526)+"OR"],error:O});this[g(651)+"hErrorEv"+g(1466)](L)}},this[i(461)+"ge"]=async v=>{let g=i,{pingInterval:O,pingFrequency:L}=this[g(1585)];if((e[g(1910)]("hi",v[g(1079)])&&g(1629)===L||e[g(1043)](e.kOVaY,L))&&(this[g(755)+g(1826)](),this[g(1431)](e.JXEQK,e[g(889)]),this[g(1563)+g(766)+"Id"]=setTimeout(this[g(561)][g(1076)](this),O)),!e.RpBDA("hi",v[g(1079)]))try{e[g(1886)](v0,this,v,[mh,ph,Nh,Mh,Oh,gh])}catch(U){let $=nt(g(901),{message:U[g(629)],code:$t[g(997)+g(497)],error:U});this[g(651)+g(1279)+g(1466)]($)}},this[i(736)]=v=>{let g=i;if(e.vdiTr===e[g(1909)]){let O=this[g(1874)+g(1904)]?.[g(1150)+g(673)+"es"](),L=this["_endpoin"+g(1904)]?.[g(762)+g(956)+"nt"]();if(O&&!v[g(629)]){let U=g(1198)+L+" fail, max retries reached";this[g(651)+g(1279)+g(1466)](e[g(568)](nt,e[g(864)],{message:U,code:$t["MAX_RETR"+g(1227)+"R"],error:v}));return}this[g(823)]&&e[g(1167)](this[g(823)].readyState,this[g(827)])&&this[g(1680)+g(1524)](),this["_dispatc"+g(1279)+"ent"](e[g(472)](nt,e[g(864)],{message:v.message,code:$t[g(912)+g(875)],error:v}))}else return this[g(1148)]?.[g(1090)]},this[i(1194)]=async v=>{let g=i;this[g(628)+g(913)](),this[g(755)+"ngTimer"](),this[g(720)+g(702)+"rs"](),this[g(823)]=null,this[g(982)+g(481)]=!1;let O=this._endpointManager?.[g(1150)+g(673)+"es"]();if(!O&&this[g(1437)+g(1324)]()&&!this["_readyCl"+g(455)]){let L=this[g(1874)+g(1904)]?.[g(762)+g(956)+"nt"](),U=this[g(1585)]["reconnec"+g(637)+"ptor"](v[g(786)],v.reason);this["_dispatc"+g(662)+g(1466)](dt(d[g(1832)],{code:1006,reason:v[g(515)]||g(687)+g(416)+g(811)+g(604)+g(1913)+g(1844)+L,willReconnect:U})),U&&this[g(982)]();return}if(d[g(1320)](1e3,v[g(786)])&&this[g(1166)+g(455)]){this[g(651)+g(662)+g(1466)](d[g(947)](dt,g(1397),{code:1e3,reason:d[g(1922)]})),this[g(1874)+"tManager"]?.[g(844)+g(1850)+g(700)](),this._pingLossCounter?.[g(878)+g(1239)]();return}if(d[g(1762)](1e3,v[g(786)])&&O)if(d[g(1118)](d.WyQdv,d[g(1864)])){let L=_0x283da1[g(1403)];AFNcRk[g(1622)](void 0,L)&&(AFNcRk.BtPmb(_0x401ca0,_0xc8d083,10),AFNcRk[g(1701)](_0x53cf2d,_0x1d739a,L));let U=_0x2232ff[g(1026)];AFNcRk.LQkTA(void 0,U)&&(AFNcRk[g(1088)](_0x19521e,_0x5668e7,18),AFNcRk[g(1701)](_0x4197f6,_0x17011e,U))}else{let L=this[g(1874)+g(1904)]?.[g(762)+g(956)+"nt"](),U=v[g(515)];U||(U=await d.cjLpF(dh,this[g(1173)])),U="connecting faile"+g(420)+U+(", hostna"+g(1843))+L+(g(682)+g(976)+g(468)),this[g(651)+g(662)+"ent"](d.rYYLT(dt,d[g(1832)],{code:v.code,reason:U}));let $=g(1198)+L+(g(1464)+g(1841)+g(1790)+"ed");this[g(651)+g(1279)+g(1466)](d[g(947)](nt,d[g(993)],{message:$,code:$t[g(1730)+g(1227)+"R"]})),this[g(1874)+g(1904)]?.[g(844)+g(1850)+"fig"](),this["_pingLos"+g(627)]?.[g(878)+"nter"]();return}if(d.RbQZC(1e3,v[g(786)])&&!v[g(515)]){let L=this[g(1874)+g(1904)]?.[g(762)+g(956)+"nt"]();this["_dispatc"+g(662)+"ent"](d[g(1822)](dt,d[g(1832)],{code:v[g(786)],reason:g(687)+g(416)+g(811)+"wn reaso"+g(1913)+g(1844)+L})),this[g(1874)+g(1904)]?.[g(844)+"pointConfig"](),this[g(732)+g(627)]?.[g(878)+g(1239)]();return}this[g(651)+g(662)+g(1466)](v),this[g(1874)+"tManager"]?.["resetEnd"+g(1850)+g(700)](),this[g(732)+g(627)]?.["resetCou"+g(1239)]()},this[i(1460)]=null,this[i(1477)]=null,this[i(692)+"e"]=null,this[i(1119)]=null,this[i(1829)+"econnect"]=null,this[i(486)+i(514)]=null,this[i(870)+i(1e3)+i(1435)+"ct"]=null,this["_handleO"+i(1299)]=this[i(1429)+"nLine"][i(1076)](this),this["_handleO"+i(1727)]=this[i(1429)+i(1727)].bind(this),this[i(773)+i(1441)]=this[i(773)+i(1441)][i(1076)](this),this["_handleP"+i(1581)]=this[i(773)+i(1581)].bind(this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[i(473)](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(1540)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[i(927)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:l,ws:h}=n,m=Array.isArray(l)?l:e[i(1611)]==typeof l?[l]:[];if(!m||m[i(1180)]===0)throw new Error(e.PlVpy);if(!e[i(1063)](sh,h))throw new Error(i(1479)+i(1330)+i(1793)+i(1380)+"ket cons"+i(1022)+"is undefined");Object[i(512)](this._options,n),this[i(1874)+i(1904)]=new E0(m,this._options[i(1463)+"es"]),this[i(732)+i(627)]=new ch(this._options["pingLoss"+i(1469)]),this._options[i(1470)+i(1779)]&&(this[i(1338)]=!0,this[i(982)]()),this[i(1585)][i(808)+i(1639)+"nged"]&&(this[i(1756)+"T"]||this._isMiniWX?this[i(1923)+i(1255)+i(1456)]():this._isBrowser&&this["_initGlo"+i(1278)+i(1467)]())}else{let{url:l}=_0x3b0f8b||{},h=_0x101f6b[i(1752)](l)?l:e.xbVLB(e[i(1611)],typeof l)?[l]:[];_0x3ad93f&&_0x206eea[i(512)](this._options,_0x4817b3),h&&h.length?this[i(1874)+i(1904)]=new _0x13c770(h,this[i(1585)][i(1463)+"es"]):this[i(1874)+i(1904)]?.[i(844)+i(1850)+i(700)](),this[i(732)+i(627)]?.[i(878)+i(1239)](this[i(1585)]["pingLoss"+i(1469)]),this["_readyCl"+i(455)]=!1,this[i(823)]&&e[i(1311)](this[i(823)][i(1808)+"te"],this[i(605)])?this[i(1680)+"ect"](1e3,e.aMIbB,!0):(this[i(1338)]=!0,this[i(982)]())}}["_handleO"+t(1299)](){let n=t;this._options[n(1533)+"utoReconnect"]||this[n(1166)+n(455)]||this[n(1505)+n(1543)]()}[t(1429)+t(1727)](){let n=t;this[n(943)+n(1735)+"t"]();let i=e.iJaMV(Mo,n(1925)+"t",{message:e[n(828)]});this["onStopIm"+n(1e3)+n(1435)+"ct"]&&this[n(870)+n(1e3)+n(1435)+"ct"](i)}[t(1770)+t(1278)+t(1467)](){let n=t;this[n(1785)+"er"]&&window[n(1285)+n(1467)](n(818),this[n(1429)+n(1299)]),this._isBrowser&&window[n(1285)+"Listener"](e[n(1149)],this["_handleO"+n(1727)]),this[n(1785)+"er"]&&window[n(1285)+n(1467)](n(1602),this["_handleP"+n(1441)]),this[n(1785)+"er"]&&window[n(1285)+n(1467)](e[n(1480)],this["_handleP"+n(1581)])}[t(1192)+"balEventListener"](){let n=t;this._isBrowser&&window["removeEv"+n(1895)+n(1594)](e[n(824)],this[n(1429)+n(1299)]),this[n(1785)+"er"]&&window[n(1679)+n(1895)+n(1594)](e.KzhOn,this[n(1429)+n(1727)]),this[n(1785)+"er"]&&window["removeEv"+n(1895)+n(1594)](n(1602),this["_handleP"+n(1441)]),this[n(1785)+"er"]&&window["removeEv"+n(1895)+"ner"](e.mkxAf,this[n(773)+n(1581)])}["_handleP"+t(1441)](n){let i=t;!n.persisted&&(this[i(1785)+"er"]&&window[i(1679)+"entListe"+i(1594)](i(1602),this[i(773)+i(1441)]),this[i(1785)+"er"]&&window[i(1679)+i(1895)+i(1594)](e[i(1480)],this[i(773)+i(1581)]),this[i(1397)]()),this[i(1785)+"er"]&&window[i(1679)+i(1895)+i(1594)]("online",this[i(1429)+i(1299)]),this[i(1785)+"er"]&&window[i(1679)+i(1895)+i(1594)](e.KzhOn,this[i(1429)+"ffLine"])}[t(773)+t(1581)](n){let i=t;if(n[i(1024)+"d"])if(e[i(649)]("rsMxr",e[i(1045)]))this["_navigat"+i(1324)]()&&(!this._ws||e[i(1707)](this._ws[i(1808)+"te"],this[i(827)])||e.iVVBn(this[i(823)][i(1808)+"te"],this[i(1619)+"NG"]))&&this[i(1429)+i(1299)](),this[i(1785)+"er"]&&window["addEvent"+i(1467)](e[i(824)],this[i(1429)+"nLine"]),this[i(1785)+"er"]&&window[i(1285)+"Listener"](e[i(1149)],this[i(1429)+"ffLine"]);else if(_0x1cb683=_0x40c5a4.charCodeAt(_0x2a79fd),_0xcade1<128)_0x2a8077[_0x577d8c++]=_0x40c6ef;else if(e[i(1924)](_0x47c5f6,2048))_0x579b53[_0x50a98a++]=e[i(770)](e.FQkbY(_0x50dc5f,6),192),_0x556272[_0x5d9772++]=e[i(1490)](e.kBepu(63,_0x117bde),128);else if(e[i(1748)](e[i(1154)](64512,_0x53e5ee),55296)&&e.WyqmE(64512,_0x5bd8a0=_0x50443a[i(1099)+"At"](e[i(856)](_0x59a3df,1)))===56320){let d=e[i(573)][i(1434)]("|"),l=0;for(;;){switch(d[l++]){case"0":_0x580d81[_0x3006fe++]=e[i(1260)](e[i(991)](63,_0x2b37a9),128);continue;case"1":_0x3e0864[_0x387e0b++]=e[i(650)](e.cXsMy(_0x52ca46,18),240);continue;case"2":_0x2e766b=e[i(846)](e[i(1281)](65536,e[i(826)](e[i(1827)](1023,_0x4f6990),10)),e[i(660)](1023,_0x3784db));continue;case"3":++_0x38bac2;continue;case"4":_0x52b34c[_0x204144++]=e[i(1896)](e[i(1859)](e[i(1662)](_0x500f3d,12),63),128);continue;case"5":_0x365521[_0x24d68c++]=e[i(1896)](e[i(1799)](e.xWmbv(_0x15e1d5,6),63),128);continue}break}}else _0xfc50a[_0x10afb2++]=e[i(1260)](e.zfeax(_0x58f24c,12),224),_0xb5ddfb[_0x6e920f++]=e[i(1590)](e[i(972)](e[i(1674)](_0x446690,6),63),128),_0x161ec5[_0x99c031++]=e[i(1720)](e[i(1412)](63,_0x33901d),128)}async _generateUrl(n){let i=t,{fpID:d,deviceID:l,bddID:h,ttwID:m,accessKey:v,aID:g,customParams:O={},enableAutoAck:L,enableQoS:U,QoSLevel:$,env:j}=this[i(1585)],J,ge,Q;if(this[i(1785)+"er"]||this._isMiniWX||this._isMiniTT)J=location&&e[i(1684)](e[i(433)],location[i(760)])?"wss://":i(1276),ge=n[i(1329)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Q=/^wss(.*:\/\/)/[i(1126)](n)?n:""+J+ge;else if(e[i(1498)](e[i(657)],e[i(657)]))J=i(1356),ge=n[i(1329)](/(^http)((?:[s]*:\/\/))/,""),Q=/(^ws)((?:[s]*:\/\/))/.test(ge)?ge:""+J+ge;else{let Or=e[i(431)][i(1434)]("|"),Nr=0;for(;;){switch(Or[Nr++]){case"0":_0x24a4b6=e[i(588)](_0xbeca5f|e[i(1567)](127,_0x1587d2[_0x12792b])<<7,0);continue;case"1":_0x3e45f0=e[i(1718)](e[i(785)](_0x35c6da,e[i(1115)](e[i(553)](127,_0xb5acb9[_0x434731]),21)),0);continue;case"2":if(e[i(881)](_0x1b80f6[_0x311c5a++],128))return{value:_0x197284?_0x24e70d:0|_0x231735,offset:_0x196553};continue;case"3":if(e[i(1924)](_0x591f27[_0x1a7822++],128))return{value:_0x31f166?_0x100eed:e.AcsJo(0,_0x198111),offset:_0x2de537};continue;case"4":if(e[i(1061)](_0x3e58b8[_0x375681++],128))return{value:_0x5ee5c0?_0x574d38:0|_0x18e6c5,offset:_0x3ce654};continue;case"5":return{value:_0x57f868?_0x30f3bc:e[i(594)](0,_0x50b8a6),offset:_0x46f00e};case"6":_0x472dbe=e[i(435)](_0x56ce72|e[i(1835)](127,_0x6142a3[_0x1eb0bf])<<14,0);continue;case"7":_0x124211=e[i(553)](127,_0x388dbb[_0xa74dba])>>>0;continue;case"8":if(e[i(951)](_0x1adeab[_0x474b17++],128))return{value:_0x3a3db5?_0x138344:e[i(1536)](0,_0x3c49ee),offset:_0x19f19c};continue;case"9":if(e[i(484)](_0xcbade3[_0x5a091c++],128))return{value:_0x4fd1bb?_0x88b6ce:e[i(785)](0,_0x30fc84),offset:_0x59986c};continue;case"10":_0x12e81b=e.tMdYQ(e.uYdKj(_0x3997fb,e[i(598)](e.WyqmE(15,_0x25a760[_0x3d01ce]),28)),0);continue;case"11":if((_0x5151f9+=5)>_0x206fd1[i(1180)])throw _0x58718e=_0x41a926[i(1180)],e[i(953)](_0x16d6e1,_0x3848f5,10,_0x361c31.length);continue}break}}let ue=h?i(1188):m?e[i(712)]:e.tuMgu,ft=h||m||l;if(!ft||!ue)throw new Error(e[i(611)]);let Pr=e.FxuQV==typeof O?await e[i(1335)](O):O,Go=j?ah(j[i(1445)],j[i(1493)]):{},Wo=Object[i(512)]({device_platform:e[i(552)],version_code:e.akHHj,access_key:v,fpid:d,aid:g,[ue]:ft,xsack:L?1:0,xaack:L?1:0,xsqos:U?1:0,qos_level:U?$:void 0,qos_sdk_version:2,...Go},Pr),qh=Object[i(1094)](Wo)[i(1668)]((Or,Nr)=>Wo[Nr]!==void 0?""+Or+(Or?"&":"?")+Nr+"="+Wo[Nr]:Or,"");return Q+"/ws/v2"+qh}async _connect(){let n=t,i={igHqh:function(d,l){return e[G(1642)](d,l)},rEPVs:function(d,l,h){return e.vdFZg(d,l,h)}};if(!(this["_connect"+n(481)]||this[n(1166)+n(455)])){this["_connect"+n(481)]=!0;try{let d=this[n(1874)+n(1904)]?.[n(1555)+n(1048)+n(723)+n(1646)+n(1876)](),{timeoutInterval:l}=this[n(1585)];if(d){let m=this._endpointManager?.getCurrentEndpoint(),v=this[n(1874)+"tManager"]?.[n(1769)+n(728)+n(1473)+n(1242)+n(529)](),g=this[n(1874)+n(1904)]?.["getCurrentEndpoi"+n(980)+n(975)]();if(v){let O="connect "+m+(n(775)+", max retries reached, w"+n(1761)+n(1078)+"ndpoint ")+v+(n(1918)+"y"),L=e[n(866)](nt,e[n(864)],{message:O,code:$t["MAX_RETR"+n(1227)+"R"]});this[n(1751)](O),this[n(651)+n(1279)+n(1466)](L),this._url=await this._generateUrl(v),this[n(1751)](n(1198)+v+" "+g+n(1011)),this[n(720)+n(702)+"rs"]()}else{let O="connect "+m+(n(775)+n(682)+n(976)+n(468));this[n(1751)](O),this._dispatchErrorEvent(e.vzXJg(nt,e[n(864)],{message:O,code:$t[n(1730)+n(1227)+"R"]}));return}}else if(e[n(707)](e[n(779)],e[n(1219)])){let m=this[n(1851)+n(1140)][n(1668)]((v,g)=>(v+=g&&g.byteLength||0,v),0);return e[n(742)](m,this._ws?this[n(823)][n(1887)+"Amount"]:0)}else{let m=this[n(1874)+n(1904)]?.[n(762)+"ntEndpoi"+n(1369)+"ateCount"](),v=this["_endpoin"+n(1904)]?.[n(762)+n(956)+n(980)+"ount"]();this[n(1173)]=await this[n(625)+n(534)](e[n(1187)](m,"")),this[n(1751)](n(1198)+m+" "+v+" times"),this["_removeW"+n(702)+"rs"]()}if(this[n(1338)])this[n(1338)]=!1;else if(e[n(1391)]("NSkeb",e[n(1750)])){let m=e[n(835)](Mo,"reconnect",{message:e[n(1810)]});this[n(1829)+"econnect"]&&this["onStartR"+n(1543)](m)}else{let m=new _0x246ab7(e.MavGc(_0x587373,_0x34742e));return e[n(423)](_0x35b634,_0x1e9108,m,0),m}let h=this[n(1874)+n(1904)]?.["getCurre"+n(956)+n(980)+"ount"]()||0;e[n(1222)](h,1)&&await this._wait(e[n(1177)](h,1)),this._debug(n(687)+n(1245)+this[n(1173)]+(" protoco"+n(1595))+this._protocols),this[n(823)]=e[n(1131)](ih,{url:this[n(1173)],protocols:[this[n(1268)+"ls"]],headers:this[n(1585)][n(671)+n(724)+"s"]["customHt"+n(1586)]},this[n(1585)].ws),(this._isBrowser||this[n(1286)+"r"])&&this[n(823)]&&(this[n(823)][n(1427)+"pe"]=this[n(1298)+n(618)]),this._addWsListeners(),this[n(982)+"ionTimeo"+n(771)]=e.vvgOK(setTimeout,this._onTimeout[n(1076)](this),l)}catch(d){if(e[n(1546)](e[n(1484)],e[n(783)]))throw this[n(982)+n(481)]=!1,d;return(ZTMKwN.igHqh(_0x4e60e7,8).join("0")+ZTMKwN.rEPVs(_0xebf1c3,_0x2fa1d7,10).toString(2)).slice(-8)}}}[t(628)+t(913)](){let n=t;clearTimeout(this[n(982)+"ionTimeo"+n(771)]),this[n(982)+n(1156)+n(771)]=null}[t(755)+t(1826)](){let n=t;e[n(1309)](clearTimeout,this[n(1563)+"gTimeoutId"]),e[n(1344)](clearTimeout,this[n(1633)+n(680)+n(579)]),this["_pingPon"+n(766)+"Id"]=null,this[n(1633)+"ctTimeoutId"]=null}[t(1751)](...n){let i=t;this[i(1585)][i(821)]&&console[i(1001)].apply(console,[e[i(721)],...n])}[t(1415)+t(1095)+"e"](n){let i=t,{initReconnectInterval:d,maxReconnectInterval:l,reconnectIntervalGrowFactor:h}=this._options,m=d*Math[i(733)](h,e.RUByE(n,1));return e[i(1448)](m,l)?l:m}[t(561)](){let n=t;if(this._ws&&e[n(502)](this[n(823)][n(1808)+"te"],this[n(1619)+"NG"])){if(e[n(848)](e[n(915)],n(557)))return new _0x431af3(_0x4563db,_0x3f8c6b,_0x28162f);this["_clearPi"+n(1826)](),this[n(1563)+n(766)+"Id"]=setTimeout(this[n(561)][n(1076)](this),this[n(1585)][n(1421)+n(1550)]);return}if(!this[n(823)]||e[n(1101)](this[n(823)][n(1808)+"te"],this[n(827)]))return void this["_handleR"+n(1543)]();this[n(823)]&&this._ws.send("hi"),this[n(1633)+n(680)+n(579)]=e[n(1409)](setTimeout,this[n(1505)+n(1543)+n(1361)][n(1076)](this),this[n(1585)][n(1722)+n(684)+n(1332)])}[t(1505)+t(1543)+t(1361)](){let n=t,i={sbsPP:function(d,l,h){return d(l,h)},bpcqN:function(d){return d()}};if(e[n(1660)](e[n(1113)],e[n(464)]))this[n(732)+n(627)]?.[n(1705)](),this[n(1431)](e[n(871)],e[n(820)]),this[n(732)+n(627)]?.[n(1150)+n(1297)+"nt"]()?this["_handleR"+n(1543)]():this[n(561)]();else{ZCtXhh.sbsPP(_0x23db8b,_0x5da5fe,42);let d=ZCtXhh[n(1002)](_0x197d7d);ZCtXhh[n(923)](_0x3a8448,_0x33d51f,d),_0x49f773(_0x47cde2,d[n(1221)]),ZCtXhh[n(923)](_0x29c165,_0x12e112,d),_0x19da4f(d)}}[t(1437)+"orOnline"](){let n=t,i={oaLIv:function(d,l){return e.YfSHE(d,l)},zWUZH:function(d,l){return e[G(967)](d,l)}};if(e[n(1677)]!==e.hnSGi)_0x289dca[_0x2df6f8[_0x42afb1][n(933)+n(1672)]]=YrCxbU.oaLIv(_0x2545a1,_0x44be7c[_0x32c9c5][n(933)+"ame"]),_0x345120+=YrCxbU[n(1579)](14,_0x3fb7d6[_0x150abb[_0x32a8fc].cursor_name]);else return this._isMiniTT||this._isMiniWX?this[n(1259)+"igatorOn"+n(485)]:(this[n(1785)+"er"]||this[n(1286)+"r"])&&this[n(1585)][n(808)+"tworkChanged"]?navigator[n(1295)]:!0}[t(1505)+t(1543)](){let n=t;!this[n(1437)+n(1324)]()||this[n(1166)+n(455)]||(this["_endpoin"+n(1904)]?.["resetEnd"+n(1850)+n(700)](),this[n(732)+n(627)]?.[n(878)+"nter"](),this._ws?this["_disconn"+n(1524)](1001,n(1612)+n(1805)+"reconnec"+n(1634)+n(1345),!0):this[n(982)]())}[t(1923)+t(1255)+t(1456)](){let n=t;this[n(1756)+"T"]?tt[n(425)+"kStatusC"+n(1637)](({isConnected:i})=>{let d=n;this[d(1259)+"igatorOn"+d(485)]=i,i?this[d(1429)+d(1299)]():this[d(1429)+d(1727)]()}):this._isMiniWX&&wx[n(425)+n(666)+"hange"](({isConnected:i})=>{let d=n;this["_miniNav"+d(1275)+d(485)]=i,i?this[d(1429)+"nLine"]():this[d(1429)+d(1727)]()})}_wait(n){return new Promise(i=>{e[G(1836)](setTimeout,i,this._getIntervalValue(n))})}[t(1680)+t(1524)](n=1e3,i="",d=!1){let l=t,h={aBfyq:function(m,v){return m*v}};if(e[l(1552)](e[l(1604)],e[l(1226)])){if(!this._ws)return;this[l(943)+l(1735)+"t"](n,i,d)}else{let m=new _0x5a64f2(Myaptf[l(1758)](2,_0x1516e3));m[l(1411)](_0x51cc80),_0x1585c9[l(1153)]=m}}[t(1116)+"ut"](){let n=t,i=this["_endpoin"+n(1904)]?.[n(762)+n(956)+"nt"]();this[n(1751)](n(1198)+i+" timeout"),this["_disconn"+n(1524)](1001,e[n(1635)],!0)}_sendAck(n){let i=t,d=e.yzDeO($e,n);this[i(823)]&&this[i(823)][i(1808)+"te"]===this[i(827)]&&(this[i(823)]&&this[i(823)][i(1818)](d),this._debug(e[i(965)],n))}["_removeW"+t(702)+"rs"](){let n=t,i={RoEjk:function(d,l){return d<l},EkGvc:function(d,l){return e[G(735)](d,l)},IWUpp:function(d,l){return e[G(952)](d,l)},ywGVR:function(d,l){return e[G(619)](d,l)}};if(e.xpneq!==e[n(1007)]){let d=0,l=0;for(let h=0;h<_0x4ab1f4[n(1180)];++h)l=_0x1e2101.charCodeAt(h),MQkttv[n(1920)](l,128)?d+=1:l<2048?d+=2:MQkttv[n(642)](MQkttv[n(1671)](64512,l),55296)&&MQkttv[n(642)](MQkttv[n(1671)](64512,_0x4fb763[n(1099)+"At"](MQkttv[n(1510)](h,1))),56320)?(++h,d+=4):d+=3;return d}else{let d=e.noITo[n(1434)]("|"),l=0;for(;;){switch(d[l++]){case"0":this[n(823)][n(1679)+n(1895)+n(1594)](n(1397),this._onClose);continue;case"1":this[n(823)][n(1679)+n(1895)+"ner"](n(1582),this._onOpen);continue;case"2":this[n(823)][n(1679)+n(1895)+"ner"](e[n(864)],this[n(736)]);continue;case"3":if(!this._ws)return;continue;case"4":this._ws["removeEv"+n(1895)+"ner"](n(629),this[n(461)+"ge"]);continue}break}}}["_addWsLi"+t(1394)](){let n=t,i="4|1|0|3|2".split("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(823)][n(1285)+n(1467)](e.WxRhZ,this._onClose);continue;case"1":this[n(823)][n(1285)+n(1467)](e.FEmzU,this._onOpen);continue;case"2":this[n(823)][n(1285)+n(1467)](e.dECWq,this._onError);continue;case"3":this[n(823)][n(1285)+n(1467)](e.AkyzW,this[n(461)+"ge"]);continue;case"4":if(!this[n(823)])return;continue}break}}[t(1820)+t(931)](n=1e3,i=""){let d=t;if(e[d(1123)](e[d(1737)],e[d(1737)]))return _0x3ace9c[d(1153)][e[d(778)](_0x900af5,_0x314710,1)];try{this[d(823)]&&this[d(823)][d(1397)](n,i)}catch{}}[t(943)+t(1735)+"t"](n=1e3,i="",d=!1){let l=t;if(this[l(755)+l(1826)](),this[l(628)+l(913)](),this[l(720)+"sListeners"](),this[l(1820)+"nceClose"](1e3,i),this[l(982)+"Lock"]=!1,d&&this["_navigat"+l(1324)]()&&!this._readyClosed){if(this[l(1874)+l(1904)]?.[l(1150)+l(673)+"es"]()){let m=this[l(1874)+l(1904)]?.[l(762)+l(956)+"nt"]();this["_dispatchCloseEv"+l(1466)](e[l(1131)](dt,e.WxRhZ,{code:1006,reason:l(1198)+m+(l(775)+l(682)+l(976)+l(468)),wasClean:!0}))}else{let m=this[l(1585)][l(1925)+"tInterce"+l(1272)](n,i);this["_dispatc"+l(662)+"ent"](e[l(418)](dt,e[l(528)],{code:n,reason:i,wasClean:!0,willReconnect:m})),m&&this._connect()}return}this["_navigat"+l(1324)]()||this[l(1166)+l(455)]?this[l(651)+"hCloseEv"+l(1466)](e[l(1185)](dt,l(1397),{code:n,reason:e[l(1457)]})):this["_dispatchCloseEv"+l(1466)](dt(e[l(528)],{code:1006,reason:e[l(1087)]})),this[l(823)]=null,this[l(1874)+l(1904)]?.["resetEnd"+l(1850)+l(700)](),this._pingLossCounter?.[l(878)+l(1239)]()}[t(651)+t(1607)+"nt"](n){let i=t;this[i(1431)](e[i(831)],n),this[i(1119)]&&this[i(1119)](n)}["_dispatc"+t(1390)+t(664)](n){let i=t,d={wLnxX:e[i(864)]};e[i(1686)]===e.joLbz?(this[i(1431)](d[i(1576)],_0x27c26a),this.onerror&&this[i(1477)](_0xd455d3)):(this[i(1431)](e[i(610)],n),this[i(692)+"e"]&&this.onmessage(n))}[t(651)+"hAckMessageEvent"](n){let i=t;this[i(1431)](e.JEJmy,n),this[i(486)+i(514)]&&this[i(486)+"eAck"](n)}[t(651)+t(1279)+t(1466)](n){let i=t;this.emit(e.dECWq,n),this[i(1477)]&&this.onerror(n)}[t(651)+t(662)+"ent"](n){let i=t;e[i(1253)](e[i(950)],e.REHFA)?(this[i(1431)](e.WxRhZ,n),this[i(1460)]&&this.onclose(n)):(this.endpoints=_0x99742,this[i(1463)+"es"]=_0x5e4277,this["currentI"+i(1702)]=0,this["currentE"+i(623)+i(1089)+"t"]=0)}get[t(1427)+"pe"](){let n=t;return this[n(823)]?this._ws[n(1427)+"pe"]:this[n(1298)+"ype"]}set[t(1427)+"pe"](n){let i=t;this[i(1298)+i(618)]=n,this[i(823)]&&(this[i(823)][i(1427)+"pe"]=n)}get[t(601)+"nt"](){let n=t;return this._endpointManager?.[n(762)+n(956)+n(980)+n(975)]()||0}get[t(1887)+t(1452)](){let n=t,i={dMtrl:function(l,h){return e.NGYWx(l,h)},NPwPh:function(l,h){return e[G(1497)](l,h)},ZhVib:e[n(1229)],FefAu:function(l,h){return l+h}};return this[n(1851)+n(1140)][n(1668)]((l,h)=>{let m=n;if(e[m(1552)](e[m(1406)],e[m(1406)])){let v=_0x2ef651[m(1180)]&&_0x4c32cb[0];if(dqNfAC[m(1323)](v,_0x333f90))throw v;let g=new _0x2490d1(dqNfAC[m(1520)](dqNfAC[m(740)],v?dqNfAC[m(896)](dqNfAC[m(1520)](" (",v[m(629)]),")"):""));throw g[m(542)]=v,v}else return l+=h&&h[m(488)+"th"]||0,l},0)+(this[n(823)]?this[n(823)][n(1887)+n(1452)]:0)}get extensions(){let n=t;return this[n(823)]?this[n(823)].extensions:""}get[t(760)](){let n=t;return this._ws?this[n(823)].protocol:""}get[t(1808)+"te"](){let n=t;return this[n(823)]?this[n(823)][n(1808)+"te"]:this._options[n(1470)+n(1779)]?this[n(1619)+"NG"]:this[n(605)]}get[t(616)](){let n=t;return this[n(823)]?this[n(823)][n(616)]:this[n(1173)]}close(n=1e3,i){let d=t,l={GVcVI:function(h,m){return e[G(1934)](h,m)},xtRMi:function(h,m){return h<<m},Xvfqe:function(h,m){return e[G(1689)](h,m)},FNxOn:function(h,m){return e[G(550)](h,m)},Otafd:function(h,m){return e.AwMsX(h,m)}};if(e[d(1426)](e[d(1328)],e[d(1328)]))return new _0x3f81ae(mynCqs.GVcVI(_0x5acbcc[0]|mynCqs[d(1806)](_0x13b0a1[1],8),mynCqs[d(1688)](_0x38030c[2],16))|mynCqs[d(1806)](_0x5493e8[3],24),mynCqs[d(1824)](mynCqs[d(672)](_0x14ff80[4],mynCqs.xtRMi(_0x327f51[5],8))|mynCqs[d(1688)](_0x5f06a3[6],16),mynCqs[d(830)](_0xeb6c34[7],24)),_0x4a5539);{let h=e[d(491)].split("|"),m=0;for(;;){switch(h[m++]){case"0":this[d(628)+d(913)]();continue;case"1":if(!this._ws)return void this[d(1751)](e[d(1713)]);continue;case"2":this["_dropGlobalEvent"+d(1467)]();continue;case"3":this[d(1589)+d(803)]?.[d(774)]();continue;case"4":this["_clearPi"+d(1826)]();continue;case"5":this[d(943)+d(1735)+"t"](n,i);continue;case"6":this[d(1166)+d(455)]=!0;continue;case"7":if(e[d(575)](this[d(823)][d(1808)+"te"],this[d(605)])||e[d(1910)](this[d(823)][d(1808)+"te"],this[d(1482)]))return void this[d(1751)]("close, w"+d(776)+d(532));continue}break}}}async send(n,i){let d=t,l={PRkRg:function(Q,ue,ft){return e[G(778)](Q,ue,ft)},VMQYb:function(Q,ue){return Q&ue}};if(e.JnTUU(null,n))throw new Error(e[d(535)]);e[d(487)]("number",typeof n)&&(n=JSON[d(479)+"y"](n)),e[d(1539)](d(868),typeof n)&&!(n instanceof ArrayBuffer)&&!(n[d(749)]&&n[d(749)]instanceof ArrayBuffer)&&(n=JSON.stringify(n));let h=await e.LZwRG(C0,n),m=e[d(674)](oh,n),{method:v=0,service:g=this[d(1585)].service,logID:O=this[d(1585)][d(1840)+"erator"](),headers:L=this[d(1585)].headers,payloadEncoding:U=this._options["payloadE"+d(1190)],payloadType:$=this[d(1585)][d(441)+"ype"],logIDNew:j=this._options.logIDNewConfig["enableAu"+d(1569)+d(1129)+"ew"]?e[d(458)](s,this._options["logIDNew"+d(988)][d(540)]):""}=e[d(1372)](i,{});if(!g)throw new Error("please p"+d(1690)+d(1738)+d(1481));let J={SeqID:ae[d(1599)+"er"](this[d(1650)]++),LogID:ae[d(1599)+"er"](O),service:g,method:v,headers:L,payloadEncoding:e[d(1337)](U,Object)?U[d(1200)]?U.encoding:"":U,payloadType:$ instanceof Object?$[d(1548)]?$[d(1548)]:m:$||m,payload:h,LogIDNew:j},ge=$e(J);return this[d(823)]&&this._ws.readyState===this.OPEN?(this[d(823)]&&this[d(823)][d(1818)](ge),this._debug(e[d(1554)],J)):e.LTWTm(this[d(1851)+"Queue"][d(1180)],this[d(1585)][d(1489)+d(839)+d(852)])?(this[d(1851)+"Queue"][d(521)](ge),this[d(1751)](e.HFJgW,J)):e[d(765)](e.gvWMV,e[d(1049)])?(this[d(1851)+"Queue"].shift(),this[d(1851)+d(1140)].push(ge)):(iqOGVl[d(1165)](_0x468d9c,_0x2bf969,iqOGVl[d(1425)](127,_0x11d2e3)|128),_0x1b27ca>>>=7),{seqID:this[d(1650)],logID:O,logIDNew:j}}async[t(1925)+"t"](n){let i=t;if(e[i(735)](i(1376),"ZBXfR")){let{url:d}=e[i(1300)](n,{}),l=Array[i(1752)](d)?d:e[i(1684)](e[i(1611)],typeof d)?[d]:[];n&&Object.assign(this._options,n),l&&l[i(1180)]?this[i(1874)+i(1904)]=new E0(l,this[i(1585)].maxRetries):this[i(1874)+"tManager"]?.["resetEnd"+i(1850)+i(700)](),this[i(732)+"sCounter"]?.[i(878)+"nter"](this[i(1585)][i(1037)+i(1469)]),this["_readyCl"+i(455)]=!1,this[i(823)]&&this[i(823)].readyState!==this.CLOSED?this[i(1680)+i(1524)](1e3,e[i(853)],!0):(this._isInit=!0,this[i(982)]())}else this[i(1787)]&&this[i(1787)].close({code:_0x5b024e,reason:_0x499909})}async connect(){let n=t;if(!this[n(982)+n(481)]){let i=e.iBhZU[n(1434)]("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(982)]();continue;case"1":this[n(1338)]=!0;continue;case"2":this["_pingLos"+n(627)]?.[n(878)+n(1239)]();continue;case"3":this[n(1874)+n(1904)]?.[n(844)+"pointCon"+n(700)]();continue;case"4":this[n(1166)+n(455)]=!1;continue}break}}}[t(1285)+t(1467)](n,i){this.on(n,i)}[t(1339)+t(664)](n){let i=t,{type:d}=n;this[i(1431)](d,n)}[t(1679)+t(1895)+"ner"](n,i){let d=t;if(e[d(1545)](e.NZrOs,e.NZrOs))return _0x5da558?this[d(1312)+"E"]():this[d(1712)+"E"]();this[d(963)](n,i)}[t(1120)](){let n=t,i={DLprZ:function(d,l){return e[G(777)](d,l)},McKUu:"success",WDMjH:e[n(1342)],VBEqx:e[n(871)],oucdX:function(d,l){return e[n(1258)](d,l)},VSCfB:e[n(1916)],ibIOG:e[n(1651)],Ekyju:n(1692)};return new Promise((d,l)=>{let h=n;this[h(755)+h(1826)](),this[h(1563)+h(766)+"Id"]=e.ZFWqS(setTimeout,this._ping.bind(this),this[h(1585)]["pingInte"+h(1550)]);let m=()=>{let g=h;i[g(558)](d,i[g(781)]),this[g(963)](i.WDMjH,m),this[g(963)](i[g(1472)],v)},v=()=>{let g=h;if(i.oucdX(i.VSCfB,i.ibIOG))return this[g(916)+g(623)+g(1089)+"t"]++,this.getCurrentEndpoint();i[g(558)](l,i[g(571)]),this[g(963)](i.WDMjH,m),this.off(i[g(1472)],v)};this.on(e[h(1342)],m),this.on(e.jlFWx,v),this[h(561)]()})}}})(),Ie[N(1485)+"oseEvent"]=Se[N(1485)+"oseEvent"],Ie[N(1357)+N(1575)]=Se[N(1357)+N(1575)],Ie[N(1401)+"e"]=Se.ErrorCode,Ie[N(664)]=Se[N(664)],Ie[N(1786)]=Se[N(1786)],Ie[N(469)+N(791)+N(443)]=Se[N(469)+N(791)+N(443)],Ie[N(791)+N(443)]=Se["MessageE"+N(443)],Ie.OpenEvent=Se[N(1547)+"t"],Ie[N(1794)+"tEvent"]=Se[N(1794)+N(1753)],Ie[N(1383)+N(1367)]=Se[N(1383)+N(1367)],Ie[N(1047)+N(1575)]=Se[N(1047)+"rorEvent"],Ie[N(979)+N(1514)+"nt"]=Se["createMe"+N(1514)+"nt"],Ie[N(756)+N(1931)]=Se[N(756)+N(1931)],Ie["createReconnectE"+N(443)]=Se[N(490)+N(1797)+"vent"],Ie["decodedF"+N(1364)]=Se[N(699)+N(1364)],Ie[N(582)+N(1672)]=Se[N(582)+N(1672)];for(to in Se)[N(1485)+"oseEvent",N(1357)+N(1575),N(1401)+"e",N(664),N(1786),N(469)+N(791)+N(443),N(791)+"vent","OpenEvent",N(1794)+N(1753),N(1383)+N(1367),N(1047)+N(1575),N(979)+N(1514)+"nt","createOp"+N(1931),"createRe"+N(1797)+N(443),N(699)+N(1364),N(582)+N(1672)][N(1174)](to)===-1&&(Ie[to]=Se[to]);var to;Object[N(906)+N(946)](Ie,N(1199)+"le",{value:!0})});var Ut=re((wI,gu)=>{"use strict";var hu=["nodebuffer","arraybuffer","fragments"],pu=typeof Blob<"u";pu&&hu.push("blob");gu.exports={BINARY_TYPES:hu,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:pu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ii=re((_I,co)=>{"use strict";var{EMPTY_BUFFER:xy}=Ut(),Tc=Buffer[Symbol.species];function hy(t,e){if(t.length===0)return xy;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 mu(t,e,r,s,a){for(let c=0;c<a;c++)r[s+c]=t[c]^e[c&3]}function wu(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function py(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Rc(t){if(Rc.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),Rc.readOnly=!1),e}co.exports={concat:hy,mask:mu,toArrayBuffer:py,toBuffer:Rc,unmask:wu};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ce("bufferutil");co.exports.mask=function(e,r,s,a,c){c<48?mu(e,r,s,a,c):t.mask(e,r,s,a,c)},co.exports.unmask=function(e,r){e.length<32?wu(e,r):t.unmask(e,r)}}catch{}});var bu=re((yI,yu)=>{"use strict";var _u=Symbol("kDone"),Dc=Symbol("kRun"),kc=class{constructor(e){this[_u]=()=>{this.pending--,this[Dc]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Dc]()}[Dc](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[_u])}}};yu.exports=kc});var Sr=re((bI,Iu)=>{"use strict";var Ci=ce("zlib"),Eu=Ii(),gy=bu(),{kStatusCode:vu}=Ut(),my=Buffer[Symbol.species],wy=Buffer.from([0,0,255,255]),lo=Symbol("permessage-deflate"),qt=Symbol("total-length"),Er=Symbol("callback"),pn=Symbol("buffers"),vr=Symbol("error"),fo,Lc=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,!fo){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;fo=new gy(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){fo.add(a=>{this._decompress(e,r,(c,f)=>{a(),s(c,f)})})}compress(e,r,s){fo.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[lo]=this,this._inflate[qt]=0,this._inflate[pn]=[],this._inflate.on("error",yy),this._inflate.on("data",Su)}this._inflate[Er]=s,this._inflate.write(e),r&&this._inflate.write(wy),this._inflate.flush(()=>{let c=this._inflate[vr];if(c){this._inflate.close(),this._inflate=null,s(c);return}let f=Eu.concat(this._inflate[pn],this._inflate[qt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[qt]=0,this._inflate[pn]=[],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[qt]=0,this._deflate[pn]=[],this._deflate.on("data",_y)}this._deflate[Er]=s,this._deflate.write(e),this._deflate.flush(Ci.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Eu.concat(this._deflate[pn],this._deflate[qt]);r&&(c=new my(c.buffer,c.byteOffset,c.length-4)),this._deflate[Er]=null,this._deflate[qt]=0,this._deflate[pn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),s(null,c)})}};Iu.exports=Lc;function _y(t){this[pn].push(t),this[qt]+=t.length}function Su(t){if(this[qt]+=t.length,this[lo]._maxPayload<1||this[qt]<=this[lo]._maxPayload){this[pn].push(t);return}this[vr]=new RangeError("Max payload size exceeded"),this[vr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[vr][vu]=1009,this.removeListener("data",Su),this.reset()}function yy(t){if(this[lo]._inflate=null,this[vr]){this[Er](this[vr]);return}t[vu]=1007,this[Er](t)}});var Ir=re((EI,uo)=>{"use strict";var{isUtf8:Cu}=ce("buffer"),{hasBlob:by}=Ut(),Ey=[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 vy(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 Sy(t){return by&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}uo.exports={isBlob:Sy,isValidStatusCode:vy,isValidUTF8:Pc,tokenChars:Ey};if(Cu)uo.exports.isValidUTF8=function(t){return t.length<24?Pc(t):Cu(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ce("utf-8-validate");uo.exports.isValidUTF8=function(e){return e.length<32?Pc(e):t(e)}}catch{}});var zc=re((vI,Pu)=>{"use strict";var{Writable:Iy}=ce("stream"),Au=Sr(),{BINARY_TYPES:Cy,EMPTY_BUFFER:Tu,kStatusCode:Ay,kWebSocket:Ty}=Ut(),{concat:Oc,toArrayBuffer:Ry,unmask:Dy}=Ii(),{isValidStatusCode:ky,isValidUTF8:Ru}=Ir(),xo=Buffer[Symbol.species],ot=0,Du=1,ku=2,Lu=3,Nc=4,Mc=5,ho=6,Bc=class extends Iy{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Cy[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Ty]=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=ot}_write(e,r,s){if(this._opcode===8&&this._state==ot)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 xo(s.buffer,s.byteOffset+e,s.length-e),new xo(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 xo(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 ot:this.getInfo(e);break;case Du:this.getPayloadLength16(e);break;case ku:this.getPayloadLength64(e);break;case Lu:this.getMask();break;case Nc:this.getData(e);break;case Mc:case ho: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[Au.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=Du:this._payloadLength===127?this._state=ku: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=Lu:this._state=Nc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Nc}getData(e){let r=Tu;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&&Dy(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Mc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Au.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===ot&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=ot;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=Ry(Oc(s,r)):this._binaryType==="blob"?a=new Blob(s):a=s,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=ot):(this._state=ho,setImmediate(()=>{this.emit("message",a,!0),this._state=ot,this.startLoop(e)}))}else{let a=Oc(s,r);if(!this._skipUTF8Validation&&!Ru(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Mc||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=ot):(this._state=ho,setImmediate(()=>{this.emit("message",a,!1),this._state=ot,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Tu),this.end();else{let s=e.readUInt16BE(0);if(!ky(s)){let c=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let a=new xo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ru(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=ot;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ot):(this._state=ho,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ot,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[Ay]=a,f}};Pu.exports=Bc});var qc=re((II,Mu)=>{"use strict";var{Duplex:SI}=ce("stream"),{randomFillSync:Ly}=ce("crypto"),Ou=Sr(),{EMPTY_BUFFER:Py,kWebSocket:Oy,NOOP:Ny}=Ut(),{isBlob:Cr,isValidStatusCode:My}=Ir(),{mask:Nu,toBuffer:Pn}=Ii(),at=Symbol("kByteLength"),By=Buffer.alloc(4),po=8*1024,On,Ar=po,gt=0,zy=1,Fy=2,Fc=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=gt,this.onerror=Ny,this[Oy]=void 0}static frame(e,r){let s,a=!1,c=2,f=!1;r.mask&&(s=r.maskBuffer||By,r.generateMask?r.generateMask(s):(Ar===po&&(On===void 0&&(On=Buffer.alloc(po)),Ly(On,0,po),Ar=0),s[0]=On[Ar++],s[1]=On[Ar++],s[2]=On[Ar++],s[3]=On[Ar++]),f=(s[0]|s[1]|s[2]|s[3])===0,c=6);let u;typeof e=="string"?(!r.mask||f)&&r[at]!==void 0?u=r[at]:(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 p=Buffer.allocUnsafe(a?u+c:c);return p[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(p[0]|=64),p[1]=x,x===126?p.writeUInt16BE(u,2):x===127&&(p[2]=p[3]=0,p.writeUIntBE(u,4,6)),r.mask?(p[1]|=128,p[c-4]=s[0],p[c-3]=s[1],p[c-2]=s[2],p[c-1]=s[3],f?[p,e]:a?(Nu(e,s,p,c,u),[p]):(Nu(e,s,e,0,u),[p,e])):[p,e]}close(e,r,s,a){let c;if(e===void 0)c=Py;else{if(typeof e!="number"||!My(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={[at]:c.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==gt?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=Pn(e),a=e.length,c=Pn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[at]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Cr(e)?this._state!==gt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==gt?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=Pn(e),a=e.length,c=Pn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[at]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Cr(e)?this._state!==gt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==gt?this.enqueue([this.dispatch,e,!1,f,s]):this.sendFrame(t.frame(e,f),s)}send(e,r,s){let a=this._extensions[Ou.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=Pn(e),u=e.length,x=Pn.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 p={[at]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:f};Cr(e)?this._state!==gt?this.enqueue([this.getBlobData,e,this._compress,p,s]):this.getBlobData(e,this._compress,p,s):this._state!==gt?this.enqueue([this.dispatch,e,this._compress,p,s]):this.dispatch(e,this._compress,p,s)}getBlobData(e,r,s,a){this._bufferedBytes+=s[at],this._state=Fy,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Uc,this,u,a);return}this._bufferedBytes-=s[at];let f=Pn(c);r?this.dispatch(f,r,s,a):(this._state=gt,this.sendFrame(t.frame(f,s),a),this.dequeue())}).catch(c=>{process.nextTick(Uy,this,c,a)})}dispatch(e,r,s,a){if(!r){this.sendFrame(t.frame(e,s),a);return}let c=this._extensions[Ou.extensionName];this._bufferedBytes+=s[at],this._state=zy,c.compress(e,s.fin,(f,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Uc(this,x,a);return}this._bufferedBytes-=s[at],this._state=gt,s.readOnly=!1,this.sendFrame(t.frame(u,s),a),this.dequeue()})}dequeue(){for(;this._state===gt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][at],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][at],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)}};Mu.exports=Fc;function Uc(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 Uy(t,e,r){Uc(t,e,r),t.onerror(e)}});var Wu=re((CI,Gu)=>{"use strict";var{kForOnEventAttribute:Ai,kListener:Hc}=Ut(),Bu=Symbol("kCode"),zu=Symbol("kData"),Fu=Symbol("kError"),Uu=Symbol("kMessage"),qu=Symbol("kReason"),Tr=Symbol("kTarget"),Hu=Symbol("kType"),ju=Symbol("kWasClean"),Ht=class{constructor(e){this[Tr]=null,this[Hu]=e}get target(){return this[Tr]}get type(){return this[Hu]}};Object.defineProperty(Ht.prototype,"target",{enumerable:!0});Object.defineProperty(Ht.prototype,"type",{enumerable:!0});var Nn=class extends Ht{constructor(e,r={}){super(e),this[Bu]=r.code===void 0?0:r.code,this[qu]=r.reason===void 0?"":r.reason,this[ju]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Bu]}get reason(){return this[qu]}get wasClean(){return this[ju]}};Object.defineProperty(Nn.prototype,"code",{enumerable:!0});Object.defineProperty(Nn.prototype,"reason",{enumerable:!0});Object.defineProperty(Nn.prototype,"wasClean",{enumerable:!0});var Rr=class extends Ht{constructor(e,r={}){super(e),this[Fu]=r.error===void 0?null:r.error,this[Uu]=r.message===void 0?"":r.message}get error(){return this[Fu]}get message(){return this[Uu]}};Object.defineProperty(Rr.prototype,"error",{enumerable:!0});Object.defineProperty(Rr.prototype,"message",{enumerable:!0});var Ti=class extends Ht{constructor(e,r={}){super(e),this[zu]=r.data===void 0?null:r.data}get data(){return this[zu]}};Object.defineProperty(Ti.prototype,"data",{enumerable:!0});var qy={addEventListener(t,e,r={}){for(let a of this.listeners(t))if(!r[Ai]&&a[Hc]===e&&!a[Ai])return;let s;if(t==="message")s=function(c,f){let u=new Ti("message",{data:f?c:c.toString()});u[Tr]=this,go(e,this,u)};else if(t==="close")s=function(c,f){let u=new Nn("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Tr]=this,go(e,this,u)};else if(t==="error")s=function(c){let f=new Rr("error",{error:c,message:c.message});f[Tr]=this,go(e,this,f)};else if(t==="open")s=function(){let c=new Ht("open");c[Tr]=this,go(e,this,c)};else return;s[Ai]=!!r[Ai],s[Hc]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Hc]===e&&!r[Ai]){this.removeListener(t,r);break}}};Gu.exports={CloseEvent:Nn,ErrorEvent:Rr,Event:Ht,EventTarget:qy,MessageEvent:Ti};function go(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var mo=re((AI,Ku)=>{"use strict";var{tokenChars:Ri}=Ir();function kt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Hy(t){let e=Object.create(null),r=Object.create(null),s=!1,a=!1,c=!1,f,u,x=-1,p=-1,_=-1,E=0;for(;E<t.length;E++)if(p=t.charCodeAt(E),f===void 0)if(_===-1&&Ri[p]===1)x===-1&&(x=E);else if(E!==0&&(p===32||p===9))_===-1&&x!==-1&&(_=E);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);_===-1&&(_=E);let y=t.slice(x,_);p===44?(kt(e,y,r),r=Object.create(null)):f=y,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(u===void 0)if(_===-1&&Ri[p]===1)x===-1&&(x=E);else if(p===32||p===9)_===-1&&x!==-1&&(_=E);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);_===-1&&(_=E),kt(r,t.slice(x,_),!0),p===44&&(kt(e,f,r),r=Object.create(null),f=void 0),x=_=-1}else if(p===61&&x!==-1&&_===-1)u=t.slice(x,E),x=_=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(a){if(Ri[p]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);x===-1?x=E:s||(s=!0),a=!1}else if(c)if(Ri[p]===1)x===-1&&(x=E);else if(p===34&&x!==-1)c=!1,_=E;else if(p===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(p===34&&t.charCodeAt(E-1)===61)c=!0;else if(_===-1&&Ri[p]===1)x===-1&&(x=E);else if(x!==-1&&(p===32||p===9))_===-1&&(_=E);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);_===-1&&(_=E);let y=t.slice(x,_);s&&(y=y.replace(/\\/g,""),s=!1),kt(r,u,y),p===44&&(kt(e,f,r),r=Object.create(null),f=void 0),u=void 0,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=E);let C=t.slice(x,_);return f===void 0?kt(e,C,r):(u===void 0?kt(r,C,!0):s?kt(r,u,C.replace(/\\/g,"")):kt(r,u,C),kt(e,f,r)),e}function jy(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(", ")}Ku.exports={format:jy,parse:Hy}});var bo=re((DI,ix)=>{"use strict";var Gy=ce("events"),Wy=ce("https"),Ky=ce("http"),Vu=ce("net"),$y=ce("tls"),{randomBytes:Zy,createHash:Vy}=ce("crypto"),{Duplex:TI,Readable:RI}=ce("stream"),{URL:jc}=ce("url"),gn=Sr(),Jy=zc(),Yy=qc(),{isBlob:Xy}=Ir(),{BINARY_TYPES:$u,CLOSE_TIMEOUT:Qy,EMPTY_BUFFER:wo,GUID:eb,kForOnEventAttribute:Gc,kListener:tb,kStatusCode:nb,kWebSocket:Me,NOOP:Ju}=Ut(),{EventTarget:{addEventListener:rb,removeEventListener:ib}}=Wu(),{format:sb,parse:ob}=mo(),{toBuffer:ab}=Ii(),Yu=Symbol("kAborted"),Wc=[8,13],jt=["CONNECTING","OPEN","CLOSING","CLOSED"],cb=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,fe=class t extends Gy{constructor(e,r,s){super(),this._binaryType=$u[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=wo,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]),Xu(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){$u.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 Jy({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),c=new Yy(e,this._extensions,s.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[Me]=this,c[Me]=this,e[Me]=this,a.on("conclude",lb),a.on("drain",ub),a.on("error",xb),a.on("message",hb),a.on("ping",pb),a.on("pong",gb),c.onerror=mb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",tx),e.on("data",yo),e.on("end",nx),e.on("error",rx),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[gn.extensionName]&&this._extensions[gn.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){et(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())}),ex(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){Kc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||wo,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){Kc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||wo,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){Kc(this,e,s);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[gn.extensionName]||(a.compress=!1),this._sender.send(e||wo,a,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){et(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(fe,"CONNECTING",{enumerable:!0,value:jt.indexOf("CONNECTING")});Object.defineProperty(fe.prototype,"CONNECTING",{enumerable:!0,value:jt.indexOf("CONNECTING")});Object.defineProperty(fe,"OPEN",{enumerable:!0,value:jt.indexOf("OPEN")});Object.defineProperty(fe.prototype,"OPEN",{enumerable:!0,value:jt.indexOf("OPEN")});Object.defineProperty(fe,"CLOSING",{enumerable:!0,value:jt.indexOf("CLOSING")});Object.defineProperty(fe.prototype,"CLOSING",{enumerable:!0,value:jt.indexOf("CLOSING")});Object.defineProperty(fe,"CLOSED",{enumerable:!0,value:jt.indexOf("CLOSED")});Object.defineProperty(fe.prototype,"CLOSED",{enumerable:!0,value:jt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(fe.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(fe.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Gc])return e[tb];return null},set(e){for(let r of this.listeners(t))if(r[Gc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Gc]:!0})}})});fe.prototype.addEventListener=rb;fe.prototype.removeEventListener=ib;ix.exports=fe;function Xu(t,e,r,s){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Qy,protocolVersion:Wc[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,!Wc.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${Wc.join(", ")})`);let c;if(e instanceof jc)c=e;else try{c=new jc(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 S=new SyntaxError(x);if(t._redirects===0)throw S;_o(t,S);return}let p=f?443:80,_=Zy(16).toString("base64"),E=f?Wy.request:Ky.request,C=new Set,y;if(a.createConnection=a.createConnection||(f?fb:db),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":_,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(y=new gn({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=sb({[gn.extensionName]:y.offer()})),r.length){for(let S of r){if(typeof S!="string"||!cb.test(S)||C.has(S))throw new SyntaxError("An invalid or duplicated subprotocol was specified");C.add(S)}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 S=a.path.split(":");a.socketPath=S[0],a.path=S[1]}let b;if(a.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=f,t._originalHostOrSocketPath=u?a.socketPath:c.host;let S=s&&s.headers;if(s={...s,headers:{}},S)for(let[I,R]of Object.entries(S))s.headers[I.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let S=u?t._originalIpc?a.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!S||t._originalSecure&&!f)&&(delete a.headers.authorization,delete a.headers.cookie,S||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",()=>{et(t,b,"Opening handshake has timed out")}),b.on("error",S=>{b===null||b[Yu]||(b=t._req=null,_o(t,S))}),b.on("response",S=>{let I=S.headers.location,R=S.statusCode;if(I&&a.followRedirects&&R>=300&&R<400){if(++t._redirects>a.maxRedirects){et(t,b,"Maximum redirects exceeded");return}b.abort();let P;try{P=new jc(I,e)}catch{let A=new SyntaxError(`Invalid URL: ${I}`);_o(t,A);return}Xu(t,P,r,s)}else t.emit("unexpected-response",b,S)||et(t,b,`Unexpected server response: ${S.statusCode}`)}),b.on("upgrade",(S,I,R)=>{if(t.emit("upgrade",S),t.readyState!==fe.CONNECTING)return;b=t._req=null;let P=S.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){et(t,I,"Invalid Upgrade header");return}let w=Vy("sha1").update(_+eb).digest("base64");if(S.headers["sec-websocket-accept"]!==w){et(t,I,"Invalid Sec-WebSocket-Accept header");return}let A=S.headers["sec-websocket-protocol"],D;if(A!==void 0?C.size?C.has(A)||(D="Server sent an invalid subprotocol"):D="Server sent a subprotocol but none was requested":C.size&&(D="Server sent no subprotocol"),D){et(t,I,D);return}A&&(t._protocol=A);let z=S.headers["sec-websocket-extensions"];if(z!==void 0){if(!y){et(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=ob(z)}catch{et(t,I,"Invalid Sec-WebSocket-Extensions header");return}let k=Object.keys(B);if(k.length!==1||k[0]!==gn.extensionName){et(t,I,"Server indicated an extension that was not requested");return}try{y.accept(B[gn.extensionName])}catch{et(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[gn.extensionName]=y}t.setSocket(I,R,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(b,t):b.end()}function _o(t,e){t._readyState=fe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function db(t){return t.path=t.socketPath,Vu.connect(t)}function fb(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Vu.isIP(t.host)?"":t.host),$y.connect(t)}function et(t,e,r){t._readyState=fe.CLOSING;let s=new Error(r);Error.captureStackTrace(s,et),e.setHeader?(e[Yu]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(_o,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Kc(t,e,r){if(e){let s=Xy(e)?e.size:ab(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${jt[t.readyState]})`);process.nextTick(r,s)}}function lb(t,e){let r=this[Me];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Me]!==void 0&&(r._socket.removeListener("data",yo),process.nextTick(Qu,r._socket),t===1005?r.close():r.close(t,e))}function ub(){let t=this[Me];t.isPaused||t._socket.resume()}function xb(t){let e=this[Me];e._socket[Me]!==void 0&&(e._socket.removeListener("data",yo),process.nextTick(Qu,e._socket),e.close(t[nb])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Zu(){this[Me].emitClose()}function hb(t,e){this[Me].emit("message",t,e)}function pb(t){let e=this[Me];e._autoPong&&e.pong(t,!this._isServer,Ju),e.emit("ping",t)}function gb(t){this[Me].emit("pong",t)}function Qu(t){t.resume()}function mb(t){let e=this[Me];e.readyState!==fe.CLOSED&&(e.readyState===fe.OPEN&&(e._readyState=fe.CLOSING,ex(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function ex(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function tx(){let t=this[Me];if(this.removeListener("close",tx),this.removeListener("data",yo),this.removeListener("end",nx),t._readyState=fe.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[Me]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Zu),t._receiver.on("finish",Zu))}function yo(t){this[Me]._receiver.write(t)||this.pause()}function nx(){let t=this[Me];t._readyState=fe.CLOSING,t._receiver.end(),this.end()}function rx(){let t=this[Me];this.removeListener("error",rx),this.on("error",Ju),t&&(t._readyState=fe.CLOSING,this.destroy())}});var cx=re((LI,ax)=>{"use strict";var kI=bo(),{Duplex:wb}=ce("stream");function sx(t){t.emit("close")}function _b(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ox(t){this.removeListener("error",ox),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function yb(t,e){let r=!0,s=new wb({...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(sx,s);return}let f=!1;t.once("error",function(x){f=!0,c(x)}),t.once("close",function(){f||c(a),process.nextTick(sx,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",_b),s.on("error",ox),s}ax.exports=yb});var $c=re((PI,dx)=>{"use strict";var{tokenChars:bb}=Ir();function Eb(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&&bb[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}dx.exports={parse:Eb}});var gx=re((NI,px)=>{"use strict";var vb=ce("events"),Eo=ce("http"),{Duplex:OI}=ce("stream"),{createHash:Sb}=ce("crypto"),fx=mo(),Mn=Sr(),Ib=$c(),Cb=bo(),{CLOSE_TIMEOUT:Ab,GUID:Tb,kWebSocket:Rb}=Ut(),Db=/^[+/0-9A-Za-z]{22}==$/,lx=0,ux=1,hx=2,Zc=class extends vb{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Ab,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Cb,...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=Eo.createServer((s,a)=>{let c=Eo.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=kb(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=lx}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===hx){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!==ux)if(this._state=ux,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",xx);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Bn(this,e,r,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){Bn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Db.test(c)){Bn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Bn(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"],p=new Set;if(x!==void 0)try{p=Ib.parse(x)}catch{Bn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&_!==void 0){let C=new Mn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=fx.parse(_);y[Mn.extensionName]&&(C.accept(y[Mn.extensionName]),E[Mn.extensionName]=C)}catch{Bn(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,S,I)=>{if(!y)return ki(r,b||401,S,I);this.completeUpgrade(E,c,p,e,r,s,a)});return}if(!this.options.verifyClient(C))return ki(r,401)}this.completeUpgrade(E,c,p,e,r,s,a)}completeUpgrade(e,r,s,a,c,f,u){if(!c.readable||!c.writable)return c.destroy();if(c[Rb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>lx)return ki(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Sb("sha1").update(r+Tb).digest("base64")}`],_=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&&(p.push(`Sec-WebSocket-Protocol: ${E}`),_._protocol=E)}if(e[Mn.extensionName]){let E=e[Mn.extensionName].params,C=fx.format({[Mn.extensionName]:[E]});p.push(`Sec-WebSocket-Extensions: ${C}`),_._extensions=e}this.emit("headers",p,a),c.write(p.concat(`\r
|
|
13
13
|
`).join(`\r
|
|
14
|
-
`)),c.removeListener("error",
|
|
15
|
-
`+Object.keys(
|
|
14
|
+
`)),c.removeListener("error",xx),_.setSocket(c,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(_),_.on("close",()=>{this.clients.delete(_),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Di,this)})),u(_,a)}};px.exports=Zc;function kb(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=hx,t.emit("close")}function xx(){this.destroy()}function ki(t,e,r,s){r=r||Eo.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} ${Eo.STATUS_CODES[e]}\r
|
|
15
|
+
`+Object.keys(s).map(a=>`${a}: ${s[a]}`).join(`\r
|
|
16
16
|
`)+`\r
|
|
17
17
|
\r
|
|
18
|
-
`+r)}function
|
|
18
|
+
`+r)}function Bn(t,e,r,s,a,c){if(t.listenerCount("wsClientError")){let f=new Error(a);Error.captureStackTrace(f,Bn),t.emit("wsClientError",f,r,e)}else ki(r,s,a,c)}});import{existsSync as sE,openSync as oE}from"node:fs";import{mkdir as aE}from"node:fs/promises";import{dirname as cE}from"node:path";import{fileURLToPath as dE}from"node:url";function Xc(t=ne()){return sE(t.libEntry)?t.libEntry:dE(new URL("../index.ts",import.meta.url))}async function Qc(t={}){let e=t.paths??ne(),r=t.entryOverride??Xc(e);await aE(cE(e.logFile),{recursive:!0});let s=oE(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],f=Vt(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 fE.info("daemon spawned",{pid:f.pid,entry:r}),{pid:f.pid,entry:r}}var fE,e0=rt(()=>{"use strict";Gn();te();Fe();fE=H("spawn-daemon")});import{spawn as IE}from"node:child_process";import{mkdir as CE,unlink as AE,writeFile as TE}from"node:fs/promises";import{dirname as RE,join as DE}from"node:path";function ko(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Fx(t,e){return new Promise((r,s)=>{let a=IE(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,i0,s0,Ux=rt(()=>{"use strict";te();Do=H("supervisor.launchd"),i0="ai.coze.bridge",s0={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
19
19
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
20
20
|
<plist version="1.0">
|
|
21
21
|
<dict>
|
|
22
22
|
<key>Label</key>
|
|
23
|
-
<string>${
|
|
23
|
+
<string>${i0}</string>
|
|
24
24
|
<key>ProgramArguments</key>
|
|
25
25
|
<array>
|
|
26
|
-
<string>${
|
|
27
|
-
<string>${
|
|
26
|
+
<string>${ko(t.nodeBin)}</string>
|
|
27
|
+
<string>${ko(t.entry)}</string>
|
|
28
28
|
<string>--daemon</string>
|
|
29
29
|
</array>
|
|
30
30
|
<key>RunAtLoad</key>
|
|
@@ -34,12 +34,12 @@ var qx=Object.create;var Wo=Object.defineProperty;var Gx=Object.getOwnPropertyDe
|
|
|
34
34
|
<key>ThrottleInterval</key>
|
|
35
35
|
<integer>10</integer>
|
|
36
36
|
<key>StandardOutPath</key>
|
|
37
|
-
<string>${
|
|
37
|
+
<string>${ko(t.logFile)}</string>
|
|
38
38
|
<key>StandardErrorPath</key>
|
|
39
|
-
<string>${
|
|
39
|
+
<string>${ko(t.logFile)}</string>
|
|
40
40
|
</dict>
|
|
41
41
|
</plist>
|
|
42
|
-
`},configPath(t){return
|
|
42
|
+
`},configPath(t){return DE(t.homeDir,"Library","LaunchAgents",`${i0}.plist`)},async install(t){let e=this.configPath(t);await CE(RE(e),{recursive:!0}),await TE(e,this.renderConfig(t),"utf8"),Do.info("plist written",{plistPath:e}),await Fx("launchctl",["load","-w",e]),Do.info("launchd job loaded",{label:i0})},async uninstall(t){let e=this.configPath(t);await Fx("launchctl",["unload","-w",e]).catch(r=>Do.warn("launchctl unload failed (ignored)",{err:String(r)})),await AE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Do.info("launchd job removed",{plistPath:e})}}});import{spawn as kE}from"node:child_process";import{mkdir as LE,unlink as PE,writeFile as OE}from"node:fs/promises";import{dirname as NE,join as ME}from"node:path";function Oo(t,e){return new Promise((r,s)=>{let a=kE(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 Lo,Po,o0,qx=rt(()=>{"use strict";te();Lo=H("supervisor.systemd"),Po="coze-bridge.service",o0={platform:"linux",renderConfig(t){return`[Unit]
|
|
43
43
|
Description=Coze Bridge daemon
|
|
44
44
|
After=network.target
|
|
45
45
|
|
|
@@ -53,7 +53,7 @@ StandardError=append:${t.logFile}
|
|
|
53
53
|
|
|
54
54
|
[Install]
|
|
55
55
|
WantedBy=default.target
|
|
56
|
-
`},configPath(t){return ME(t.homeDir,".config","systemd","user",
|
|
56
|
+
`},configPath(t){return ME(t.homeDir,".config","systemd","user",Po)},async install(t){let e=this.configPath(t);await LE(NE(e),{recursive:!0}),await OE(e,this.renderConfig(t),"utf8"),Lo.info("systemd unit written",{unitPath:e}),await Oo("systemctl",["--user","daemon-reload"]),await Oo("systemctl",["--user","enable","--now",Po]),Lo.info("systemd unit enabled",{unitName:Po})},async uninstall(t){let e=this.configPath(t);await Oo("systemctl",["--user","disable","--now",Po]).catch(r=>Lo.warn("systemctl disable failed (ignored)",{err:String(r)})),await PE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await Oo("systemctl",["--user","daemon-reload"]).catch(()=>{}),Lo.info("systemd unit removed",{unitPath:e})}}});import{spawn as BE}from"node:child_process";import{join as zE}from"node:path";function Hx(t,e){return new Promise((r,s)=>{let a=BE(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 a0,No,c0,jx=rt(()=>{"use strict";te();a0=H("supervisor.taskscheduler"),No="CozeBridge",c0={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
57
57
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
58
58
|
<RegistrationInfo>
|
|
59
59
|
<Description>Coze Bridge daemon</Description>
|
|
@@ -77,29 +77,29 @@ WantedBy=default.target
|
|
|
77
77
|
</Exec>
|
|
78
78
|
</Actions>
|
|
79
79
|
</Task>
|
|
80
|
-
`},configPath(t){return zE(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 Hh("schtasks",["/Create","/SC","ONLOGON","/TN",Po,"/TR",r,"/RU",t.userName,"/F"]),od.info("task scheduler entry created",{task:Po,logFile:t.logFile})},async uninstall(t){await Hh("schtasks",["/Delete","/TN",Po,"/F"]).catch(e=>od.warn("schtasks /Delete failed (ignored)",{err:String(e)})),od.info("task scheduler entry removed",{task:Po})}}});var Gh={};Ko(Gh,{buildContext:()=>qE,getSupervisor:()=>HE,launchdSupervisor:()=>id,systemdSupervisor:()=>sd,taskSchedulerSupervisor:()=>ad});import{homedir as FE,userInfo as UE}from"node:os";function HE(t=process.platform){switch(t){case"darwin":return id;case"linux":return sd;case"win32":return ad;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function qE(){let t=ee();return{nodeBin:process.execPath,entry:Yc(t),logFile:t.logFile,homeDir:FE(),userName:UE().username}}var jh=it(()=>{"use strict";Be();Qc();Fh();Uh();qh()});Q();yn();var qd=q("acp-installer-warmup"),pp=["claude-code","codex"];async function Gd(t={}){let e=t.ensure??Vn,i=(await Promise.allSettled(pp.map(async o=>{let c=await e(o);qd.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&qd.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}Zt();Q();import{readdir as Ap}from"node:fs/promises";import{mkdir as Jd,writeFile as Zd}from"node:fs/promises";import{join as Xo}from"node:path";var Ip={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Zn(t,e,r){await Jd(t,{recursive:!0});let i=Ip[e],o=Xo(t,i);return await Zd(o,r??"","utf8"),o}async function Yd(t){let e=Xo(t,".claude");await Jd(e,{recursive:!0});let r=Xo(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Zd(r,i,"utf8"),r}var Ze=q("agent-detail-sync"),Tp=6e4,Cp=5*6e4,Wi=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Ap(r)}catch(o){Ze.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Ze.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await He(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Ze.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){Ze.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),Ze.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){Ze.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Ze.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await He(e,this.opts.paths);if(!i){Ze.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){Ze.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let h=this.retryQueue.get(e),x=h?Math.min(h.currentDelay*2,Cp):Tp;this.retryQueue.set(e,{dueAt:Date.now()+x,currentDelay:x});return}if(o.agentId&&o.agentId!==e){Ze.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;if(o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,l=!0),o.deployType&&Ze.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Ze.debug("detail sync: no diff",{agentId:e});return}await Je(i,this.opts.paths),Ze.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await Zn(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var x0=mt(kl(),1);import{lstat as fc,mkdir as uc,readFile as l0,readdir as ew,rm as tw,stat as nw,writeFile as hc}from"node:fs/promises";import{dirname as rw,join as At,normalize as iw,relative as gc,resolve as xc,sep as f0}from"node:path";import{Readable as u0}from"node:stream";import{pipeline as h0}from"node:stream/promises";import Zp from"events";import $e from"fs";import{EventEmitter as Ya}from"node:events";import uf from"node:stream";import{StringDecoder as Yp}from"node:string_decoder";import pf from"node:path";import cr from"node:fs";import{dirname as lg,parse as fg}from"path";import{EventEmitter as yg}from"events";import Oa from"assert";import{Buffer as kn}from"buffer";import*as Nl from"zlib";import _g from"zlib";import{posix as tr}from"node:path";import{basename as $g}from"node:path";import vs from"fs";import Et from"fs";import ql from"path";import{win32 as im}from"node:path";import Jl from"path";import kf from"node:fs";import Em from"node:assert";import{randomBytes as Df}from"node:crypto";import Y from"node:fs";import be from"node:path";import Of from"fs";import Os from"node:fs";import ti from"node:path";import Qe from"node:fs";import Cm from"node:fs/promises";import As from"node:path";import{join as Gf}from"node:path";import Xe from"node:fs";import Kf from"node:path";var Vp=Object.defineProperty,Jp=(t,e)=>{for(var r in e)Vp(t,r,{get:e[r],enumerable:!0})},Dl=typeof process=="object"&&process?process:{stdout:null,stderr:null},Xp=t=>!!t&&typeof t=="object"&&(t instanceof Pn||t instanceof uf||Qp(t)||eg(t)),Qp=t=>!!t&&typeof t=="object"&&t instanceof Ya&&typeof t.pipe=="function"&&t.pipe!==uf.Writable.prototype.pipe,eg=t=>!!t&&typeof t=="object"&&t instanceof Ya&&typeof t.write=="function"&&typeof t.end=="function",Pt=Symbol("EOF"),Lt=Symbol("maybeEmitEnd"),Xt=Symbol("emittedEnd"),Zi=Symbol("emittingEnd"),zr=Symbol("emittedError"),Yi=Symbol("closed"),Ol=Symbol("read"),Xi=Symbol("flush"),Pl=Symbol("flushChunk"),ft=Symbol("encoding"),er=Symbol("decoder"),Te=Symbol("flowing"),Fr=Symbol("paused"),sr=Symbol("resume"),Ce=Symbol("buffer"),We=Symbol("pipes"),Re=Symbol("bufferLength"),ia=Symbol("bufferPush"),Qi=Symbol("bufferShift"),qe=Symbol("objectMode"),ge=Symbol("destroyed"),sa=Symbol("error"),oa=Symbol("emitData"),Ll=Symbol("emitEnd"),aa=Symbol("emitEnd2"),wt=Symbol("async"),ca=Symbol("abort"),es=Symbol("aborted"),Ur=Symbol("signal"),En=Symbol("dataListeners"),Ye=Symbol("discarded"),Hr=t=>Promise.resolve().then(t),tg=t=>t(),ng=t=>t==="end"||t==="finish"||t==="prefinish",rg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,ig=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),hf=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()}},sg=class extends hf{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},og=t=>!!t.objectMode,ag=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Pn=class extends Ya{[Te]=!1;[Fr]=!1;[We]=[];[Ce]=[];[qe];[ft];[wt];[er];[Pt]=!1;[Xt]=!1;[Zi]=!1;[Yi]=!1;[zr]=null;[Re]=0;[ge]=!1;[Ur];[es]=!1;[En]=0;[Ye]=!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");og(e)?(this[qe]=!0,this[ft]=null):ag(e)?(this[ft]=e.encoding,this[qe]=!1):(this[qe]=!1,this[ft]=null),this[wt]=!!e.async,this[er]=this[ft]?new Yp(this[ft]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Ce]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[We]});let{signal:r}=e;r&&(this[Ur]=r,r.aborted?this[ca]():r.addEventListener("abort",()=>this[ca]()))}get bufferLength(){return this[Re]}get encoding(){return this[ft]}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[qe]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[wt]}set async(t){this[wt]=this[wt]||!!t}[ca](){this[es]=!0,this.emit("abort",this[Ur]?.reason),this.destroy(this[Ur]?.reason)}get aborted(){return this[es]}set aborted(t){}write(t,e,r){if(this[es])return!1;if(this[Pt])throw new Error("write after end");if(this[ge])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 i=this[wt]?Hr:tg;if(!this[qe]&&!Buffer.isBuffer(t)){if(ig(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(rg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[qe]?(this[Te]&&this[Re]!==0&&this[Xi](!0),this[Te]?this.emit("data",t):this[ia](t),this[Re]!==0&&this.emit("readable"),r&&i(r),this[Te]):t.length?(typeof t=="string"&&!(e===this[ft]&&!this[er]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ft]&&(t=this[er].write(t)),this[Te]&&this[Re]!==0&&this[Xi](!0),this[Te]?this.emit("data",t):this[ia](t),this[Re]!==0&&this.emit("readable"),r&&i(r),this[Te]):(this[Re]!==0&&this.emit("readable"),r&&i(r),this[Te])}read(t){if(this[ge])return null;if(this[Ye]=!1,this[Re]===0||t===0||t&&t>this[Re])return this[Lt](),null;this[qe]&&(t=null),this[Ce].length>1&&!this[qe]&&(this[Ce]=[this[ft]?this[Ce].join(""):Buffer.concat(this[Ce],this[Re])]);let e=this[Ol](t||null,this[Ce][0]);return this[Lt](),e}[Ol](t,e){if(this[qe])this[Qi]();else{let r=e;t===r.length||t===null?this[Qi]():typeof r=="string"?(this[Ce][0]=r.slice(t),e=r.slice(0,t),this[Re]-=t):(this[Ce][0]=r.subarray(t),e=r.subarray(0,t),this[Re]-=t)}return this.emit("data",e),!this[Ce].length&&!this[Pt]&&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[Pt]=!0,this.writable=!1,(this[Te]||!this[Fr])&&this[Lt](),this}[sr](){this[ge]||(!this[En]&&!this[We].length&&(this[Ye]=!0),this[Fr]=!1,this[Te]=!0,this.emit("resume"),this[Ce].length?this[Xi]():this[Pt]?this[Lt]():this.emit("drain"))}resume(){return this[sr]()}pause(){this[Te]=!1,this[Fr]=!0,this[Ye]=!1}get destroyed(){return this[ge]}get flowing(){return this[Te]}get paused(){return this[Fr]}[ia](t){this[qe]?this[Re]+=1:this[Re]+=t.length,this[Ce].push(t)}[Qi](){return this[qe]?this[Re]-=1:this[Re]-=this[Ce][0].length,this[Ce].shift()}[Xi](t=!1){do;while(this[Pl](this[Qi]())&&this[Ce].length);!t&&!this[Ce].length&&!this[Pt]&&this.emit("drain")}[Pl](t){return this.emit("data",t),this[Te]}pipe(t,e){if(this[ge])return t;this[Ye]=!1;let r=this[Xt];return e=e||{},t===Dl.stdout||t===Dl.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[We].push(e.proxyErrors?new sg(this,t,e):new hf(this,t,e)),this[wt]?Hr(()=>this[sr]()):this[sr]()),t}unpipe(t){let e=this[We].find(r=>r.dest===t);e&&(this[We].length===1?(this[Te]&&this[En]===0&&(this[Te]=!1),this[We]=[]):this[We].splice(this[We].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[Ye]=!1,this[En]++,!this[We].length&&!this[Te]&&this[sr]();else if(t==="readable"&&this[Re]!==0)super.emit("readable");else if(ng(t)&&this[Xt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[zr]){let i=e;this[wt]?Hr(()=>i.call(this,this[zr])):i.call(this,this[zr])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[En]=this.listeners("data").length,this[En]===0&&!this[Ye]&&!this[We].length&&(this[Te]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[En]=0,!this[Ye]&&!this[We].length&&(this[Te]=!1)),e}get emittedEnd(){return this[Xt]}[Lt](){!this[Zi]&&!this[Xt]&&!this[ge]&&this[Ce].length===0&&this[Pt]&&(this[Zi]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Yi]&&this.emit("close"),this[Zi]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==ge&&this[ge])return!1;if(t==="data")return!this[qe]&&!r?!1:this[wt]?(Hr(()=>this[oa](r)),!0):this[oa](r);if(t==="end")return this[Ll]();if(t==="close"){if(this[Yi]=!0,!this[Xt]&&!this[ge])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[zr]=r,super.emit(sa,r);let o=!this[Ur]||this.listeners("error").length?super.emit("error",r):!1;return this[Lt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Lt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Lt](),i}[oa](t){for(let r of this[We])r.dest.write(t)===!1&&this.pause();let e=this[Ye]?!1:super.emit("data",t);return this[Lt](),e}[Ll](){return this[Xt]?!1:(this[Xt]=!0,this.readable=!1,this[wt]?(Hr(()=>this[aa]()),!0):this[aa]())}[aa](){if(this[er]){let e=this[er].end();if(e){for(let r of this[We])r.dest.write(e);this[Ye]||super.emit("data",e)}}for(let e of this[We])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[qe]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[qe]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[qe])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ft]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ge,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Ye]=!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[Pt])return e();let i,o,c=x=>{this.off("data",l),this.off("end",f),this.off(ge,h),e(),o(x)},l=x=>{this.off("error",c),this.off("end",f),this.off(ge,h),this.pause(),i({value:x,done:!!this[Pt]})},f=()=>{this.off("error",c),this.off("data",l),this.off(ge,h),e(),i({done:!0,value:void 0})},h=()=>c(new Error("stream destroyed"));return new Promise((x,m)=>{o=m,i=x,this.once(ge,h),this.once("error",c),this.once("end",f),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Ye]=!1;let t=!1,e=()=>(this.pause(),this.off(sa,e),this.off(ge,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(sa,e),this.once(ge,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[ge])return t?this.emit("error",t):this.emit(ge),this;this[ge]=!0,this[Ye]=!0,this[Ce].length=0,this[Re]=0;let e=this;return typeof e.close=="function"&&!this[Yi]&&e.close(),t?this.emit("error",t):this.emit(ge),this}static get isStream(){return Xp}},cg=$e.writev,dn=Symbol("_autoClose"),pt=Symbol("_close"),qr=Symbol("_ended"),re=Symbol("_fd"),da=Symbol("_finished"),zt=Symbol("_flags"),la=Symbol("_flush"),ka=Symbol("_handleChunk"),Da=Symbol("_makeBuf"),Qr=Symbol("_mode"),ts=Symbol("_needDrain"),lr=Symbol("_onerror"),fr=Symbol("_onopen"),fa=Symbol("_onread"),or=Symbol("_onwrite"),ln=Symbol("_open"),xt=Symbol("_path"),rn=Symbol("_pos"),yt=Symbol("_queue"),ar=Symbol("_read"),ua=Symbol("_readSize"),Bt=Symbol("_reading"),Gr=Symbol("_remain"),ha=Symbol("_size"),fs=Symbol("_write"),bn=Symbol("_writing"),us=Symbol("_defaultFlag"),Rn=Symbol("_errored"),Xa=class extends Pn{[Rn]=!1;[re];[xt];[ua];[Bt]=!1;[ha];[Gr];[dn];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[re]=typeof e.fd=="number"?e.fd:void 0,this[xt]=t,this[ua]=e.readSize||16*1024*1024,this[Bt]=!1,this[ha]=typeof e.size=="number"?e.size:1/0,this[Gr]=this[ha],this[dn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[re]=="number"?this[ar]():this[ln]()}get fd(){return this[re]}get path(){return this[xt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[ln](){$e.open(this[xt],"r",(t,e)=>this[fr](t,e))}[fr](t,e){t?this[lr](t):(this[re]=e,this.emit("open",e),this[ar]())}[Da](){return Buffer.allocUnsafe(Math.min(this[ua],this[Gr]))}[ar](){if(!this[Bt]){this[Bt]=!0;let t=this[Da]();if(t.length===0)return process.nextTick(()=>this[fa](null,0,t));$e.read(this[re],t,0,t.length,null,(e,r,i)=>this[fa](e,r,i))}}[fa](t,e,r){this[Bt]=!1,t?this[lr](t):this[ka](e,r)&&this[ar]()}[pt](){if(this[dn]&&typeof this[re]=="number"){let t=this[re];this[re]=void 0,$e.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[lr](t){this[Bt]=!0,this[pt](),this.emit("error",t)}[ka](t,e){let r=!1;return this[Gr]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[Gr]<=0)&&(r=!1,this[pt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[re]=="number"&&this[ar](),!1;case"error":return this[Rn]?!1:(this[Rn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},dg=class extends Xa{[ln](){let t=!0;try{this[fr](null,$e.openSync(this[xt],"r")),t=!1}finally{t&&this[pt]()}}[ar](){let t=!0;try{if(!this[Bt]){this[Bt]=!0;do{let e=this[Da](),r=e.length===0?0:$e.readSync(this[re],e,0,e.length,null);if(!this[ka](r,e))break}while(!0);this[Bt]=!1}t=!1}finally{t&&this[pt]()}}[pt](){if(this[dn]&&typeof this[re]=="number"){let t=this[re];this[re]=void 0,$e.closeSync(t),this.emit("close")}}},Ts=class extends Zp{readable=!1;writable=!0;[Rn]=!1;[bn]=!1;[qr]=!1;[yt]=[];[ts]=!1;[xt];[Qr];[dn];[re];[us];[zt];[da]=!1;[rn];constructor(t,e){e=e||{},super(e),this[xt]=t,this[re]=typeof e.fd=="number"?e.fd:void 0,this[Qr]=e.mode===void 0?438:e.mode,this[rn]=typeof e.start=="number"?e.start:void 0,this[dn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[rn]!==void 0?"r+":"w";this[us]=e.flags===void 0,this[zt]=e.flags===void 0?r:e.flags,this[re]===void 0&&this[ln]()}emit(t,...e){if(t==="error"){if(this[Rn])return!1;this[Rn]=!0}return super.emit(t,...e)}get fd(){return this[re]}get path(){return this[xt]}[lr](t){this[pt](),this[bn]=!0,this.emit("error",t)}[ln](){$e.open(this[xt],this[zt],this[Qr],(t,e)=>this[fr](t,e))}[fr](t,e){this[us]&&this[zt]==="r+"&&t&&t.code==="ENOENT"?(this[zt]="w",this[ln]()):t?this[lr](t):(this[re]=e,this.emit("open",e),this[bn]||this[la]())}end(t,e){return t&&this.write(t,e),this[qr]=!0,!this[bn]&&!this[yt].length&&typeof this[re]=="number"&&this[or](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[qr]?(this.emit("error",new Error("write() after end()")),!1):this[re]===void 0||this[bn]||this[yt].length?(this[yt].push(t),this[ts]=!0,!1):(this[bn]=!0,this[fs](t),!0)}[fs](t){$e.write(this[re],t,0,t.length,this[rn],(e,r)=>this[or](e,r))}[or](t,e){t?this[lr](t):(this[rn]!==void 0&&typeof e=="number"&&(this[rn]+=e),this[yt].length?this[la]():(this[bn]=!1,this[qr]&&!this[da]?(this[da]=!0,this[pt](),this.emit("finish")):this[ts]&&(this[ts]=!1,this.emit("drain"))))}[la](){if(this[yt].length===0)this[qr]&&this[or](null,0);else if(this[yt].length===1)this[fs](this[yt].pop());else{let t=this[yt];this[yt]=[],cg(this[re],t,this[rn],(e,r)=>this[or](e,r))}}[pt](){if(this[dn]&&typeof this[re]=="number"){let t=this[re];this[re]=void 0,$e.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},xf=class extends Ts{[ln](){let t;if(this[us]&&this[zt]==="r+")try{t=$e.openSync(this[xt],this[zt],this[Qr])}catch(e){if(e?.code==="ENOENT")return this[zt]="w",this[ln]();throw e}else t=$e.openSync(this[xt],this[zt],this[Qr]);this[fr](null,t)}[pt](){if(this[dn]&&typeof this[re]=="number"){let t=this[re];this[re]=void 0,$e.closeSync(t),this.emit("close")}}[fs](t){let e=!0;try{this[or](null,$e.writeSync(this[re],t,0,t.length,this[rn])),e=!1}finally{if(e)try{this[pt]()}catch{}}}},ug=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"]]),hg=t=>!!t.sync&&!!t.file,xg=t=>!t.sync&&!!t.file,pg=t=>!!t.sync&&!t.file,gg=t=>!t.sync&&!t.file,mg=t=>!!t.file,wg=t=>ug.get(t)||t,Qa=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=wg(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},ci=(t,e,r,i,o)=>Object.assign((c=[],l,f)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(f=l,l=void 0),l=l?Array.from(l):[];let h=Qa(c);if(o?.(h,l),hg(h)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return t(h,l)}else if(xg(h)){let x=e(h,l);return f?x.then(()=>f(),f):x}else if(pg(h)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return r(h,l)}else if(gg(h)){if(typeof f=="function")throw new TypeError("callback only supported with file option");return i(h,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),Eg=_g.constants||{ZLIB_VERNUM:4736},vt=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},Eg)),bg=kn.concat,Ml=Object.getOwnPropertyDescriptor(kn,"concat"),vg=t=>t,xa=Ml?.writable===!0||Ml?.set!==void 0?t=>{kn.concat=t?vg:bg}:t=>{},Dn=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"}},pa=Symbol("flushFlag"),ec=class extends Pn{#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 Nl[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Nl[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 Oa(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(kn.alloc(0),{[pa]: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}[Dn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=kn.from(t,e)),this.#e)return;Oa(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},xa(!0);let l;try{let h=typeof t[pa]=="number"?t[pa]:this.#r;l=this.#t._processChunk(t,h),xa(!1)}catch(h){xa(!1),this.#o(new ns(h,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",h=>this.#o(new ns(h,this.write)));let f;if(l)if(Array.isArray(l)&&l.length>0){let h=l[0];f=this[Dn](kn.from(h));for(let x=1;x<l.length;x++)f=this[Dn](l[x])}else f=this[Dn](kn.from(l));return r&&r(),f}},gf=class extends ec{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||vt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||vt.Z_FINISH,t.fullFlushFlag=vt.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(vt.Z_SYNC_FLUSH),Oa(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},Sg=class extends gf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Dn](t){return this.#e?(this.#e=!1,t[9]=255,super[Dn](t)):super[Dn](t)}},Ig=class extends gf{constructor(t){super(t,"Unzip")}},mf=class extends ec{constructor(t,e){t=t||{},t.flush=t.flush||vt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||vt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=vt.BROTLI_OPERATION_FLUSH,super(t,e)}},Ag=class extends mf{constructor(t){super(t,"BrotliCompress")}},Tg=class extends mf{constructor(t){super(t,"BrotliDecompress")}},wf=class extends ec{constructor(t,e){t=t||{},t.flush=t.flush||vt.ZSTD_e_continue,t.finishFlush=t.finishFlush||vt.ZSTD_e_end,t.fullFlushFlag=vt.ZSTD_e_flush,super(t,e)}},Cg=class extends wf{constructor(t){super(t,"ZstdCompress")}},Rg=class extends wf{constructor(t){super(t,"ZstdDecompress")}},kg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Og(t,e):Dg(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Dg=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Og=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=yf(o):o===0?e[i-1]=0:(r=!0,e[i-1]=_f(o))}},Pg=t=>{let e=t[0],r=e===128?Ng(t.subarray(1,t.length)):e===255?Lg(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},Lg=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=yf(c):c===0?l=c:(i=!0,l=_f(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},Ng=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},yf=t=>(255^t)&255,_f=t=>(255^t)+1&255,Mg={};Jp(Mg,{code:()=>tc,isCode:()=>hs,isName:()=>Bg,name:()=>Cs});var hs=t=>Cs.has(t),Bg=t=>tc.has(t),Cs=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"]]),tc=new Map(Array.from(Cs).map(t=>[t[1],t[0]])),On=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,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){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??i?.mode??sn(t,e+100,8),this.uid=r?.uid??i?.uid??sn(t,e+108,8),this.gid=r?.gid??i?.gid??sn(t,e+116,8),this.size=r?.size??i?.size??sn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??ga(t,e+136,12),this.cksum=sn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=vn(t,e+156,1);if(hs(o)&&(this.#e=o||"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??i?.uname??vn(t,e+265,32),this.gname=r?.gname??i?.gname??vn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??sn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??sn(t,e+337,8)??0,t[e+475]!==0){let l=vn(t,e+345,155);this.path=l+"/"+this.path}else{let l=vn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??ga(t,e+476,12),this.ctime=r?.ctime??i?.ctime??ga(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];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,i])=>!(i==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,i=zg(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Sn(t,e,100,o)||this.needPax,this.needPax=on(t,e+100,8,this.mode)||this.needPax,this.needPax=on(t,e+108,8,this.uid)||this.needPax,this.needPax=on(t,e+116,8,this.gid)||this.needPax,this.needPax=on(t,e+124,12,this.size)||this.needPax,this.needPax=ma(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=on(t,e+329,8,this.devmaj)||this.needPax,this.needPax=on(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=ma(t,e+476,12,this.atime)||this.needPax,this.needPax=ma(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let f=e;f<e+148;f++)l+=t[f];for(let f=e+156;f<e+512;f++)l+=t[f];return this.cksum=l,on(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Cs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(tc.get(t));if(hs(e)||e==="Unsupported")this.#e=e;else if(hs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},zg=(t,e)=>{let r=t,i="",o,c=tr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=tr.dirname(r),r=tr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(i)<=e?o=[r,i,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(i)<=e?o=[r.slice(0,99),i,!0]:(r=tr.join(tr.basename(i),r),i=tr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},vn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),ga=(t,e,r)=>Fg(sn(t,e,r)),Fg=t=>t===void 0?void 0:new Date(t*1e3),sn=(t,e,r)=>Number(t[e])&128?Pg(t.subarray(e,e+r)):Hg(t,e,r),Ug=t=>isNaN(t)?void 0:t,Hg=(t,e,r)=>Ug(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),qg={12:8589934591,8:2097151},on=(t,e,r,i)=>i===void 0?!1:i>qg[r]||i<0?(kg(i,t.subarray(e,e+r)),!0):(Gg(t,e,r,i),!1),Gg=(t,e,r,i)=>t.write(jg(i,r),e,r,"ascii"),jg=(t,e)=>Wg(Math.floor(t).toString(8),e),Wg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",ma=(t,e,r,i)=>i===void 0?!1:on(t,e,r,i.getTime()/1e3),Kg=new Array(156).join("\0"),Sn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Kg,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),bs=class Ef{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),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new On({path:("PaxHeader/"+$g(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(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}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],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
81
|
-
`,c=Buffer.byteLength(
|
|
82
|
-
`).reduce(Zg,Object.create(null)),Zg=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Yg=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,J=Yg!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),bf=class extends Pn{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=J(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?J(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,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=J(t.path)),t.linkpath&&(t.linkpath=J(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Rs=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Xg=1024*1024,Pa=Buffer.from([31,139]),La=Buffer.from([40,181,47,253]),Qg=Math.max(Pa.length,La.length),st=Symbol("state"),In=Symbol("writeEntry"),Nt=Symbol("readEntry"),wa=Symbol("nextEntry"),Bl=Symbol("processEntry"),_t=Symbol("extendedHeader"),jr=Symbol("globalExtendedHeader"),Qt=Symbol("meta"),zl=Symbol("emitMeta"),ae=Symbol("buffer"),Mt=Symbol("queue"),en=Symbol("ended"),ya=Symbol("emittedEnd"),An=Symbol("emit"),ye=Symbol("unzip"),rs=Symbol("consumeChunk"),is=Symbol("consumeChunkSub"),_a=Symbol("consumeBody"),Fl=Symbol("consumeMeta"),Ul=Symbol("consumeHeader"),Wr=Symbol("consuming"),Ea=Symbol("bufferConcat"),ss=Symbol("maybeEnd"),nr=Symbol("writing"),tn=Symbol("aborted"),os=Symbol("onDone"),Tn=Symbol("sawValidEntry"),as=Symbol("sawNullBlock"),cs=Symbol("sawEOF"),Hl=Symbol("closeStream"),em=()=>!0,ai=class extends yg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Mt]=[];[ae];[Nt];[In];[st]="begin";[Qt]="";[_t];[jr];[en]=!1;[ye];[tn]=!1;[Tn];[as]=!1;[cs]=!1;[nr]=!1;[Wr]=!1;[ya]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(os,()=>{(this[st]==="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||Xg,this.filter=typeof t.filter=="function"?t.filter:em;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[Hl]()),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)}[Ul](t,e){this[Tn]===void 0&&(this[Tn]=!1);let r;try{r=new On(t,e,this[_t],this[jr])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[as]?(this[cs]=!0,this[st]==="begin"&&(this[st]="header"),this[An]("eof")):(this[as]=!0,this[An]("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 i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[In]=new bf(r,this[_t],this[jr]);if(!this[Tn])if(o.remain){let c=()=>{o.invalid||(this[Tn]=!0)};o.on("end",c)}else this[Tn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[An]("ignoredEntry",o),this[st]="ignore",o.resume()):o.size>0&&(this[Qt]="",o.on("data",c=>this[Qt]+=c),this[st]="meta"):(this[_t]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[An]("ignoredEntry",o),this[st]=o.remain?"ignore":"header",o.resume()):(o.remain?this[st]="body":(this[st]="header",o.end()),this[Nt]?this[Mt].push(o):(this[Mt].push(o),this[wa]())))}}}[Hl](){queueMicrotask(()=>this.emit("close"))}[Bl](t){let e=!0;if(!t)this[Nt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Nt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[wa]()),e=!1);return e}[wa](){do;while(this[Bl](this[Mt].shift()));if(this[Mt].length===0){let t=this[Nt];!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 i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[st]="header",this[In]=void 0,r.end()),o.length}[Fl](t,e){let r=this[In],i=this[_a](t,e);return!this[In]&&r&&this[zl](r),i}[An](t,e,r){this[Mt].length===0&&!this[Nt]?this.emit(t,e,r):this[Mt].push([t,e,r])}[zl](t){switch(this[An]("meta",this[Qt]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[_t]=bs.parse(this[Qt],this[_t],!1);break;case"GlobalExtendedHeader":this[jr]=bs.parse(this[Qt],this[jr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[_t]??Object.create(null);this[_t]=e,e.path=this[Qt].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[_t]||Object.create(null);this[_t]=e,e.linkpath=this[Qt].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[tn]=!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[tn])return r?.(),!1;if((this[ye]===void 0||this.brotli===void 0&&this[ye]===!1)&&t){if(this[ae]&&(t=Buffer.concat([this[ae],t]),this[ae]=void 0),t.length<Qg)return this[ae]=t,r?.(),!0;for(let l=0;this[ye]===void 0&&l<Pa.length;l++)t[l]!==Pa[l]&&(this[ye]=!1);let o=!1;if(this[ye]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<La.length;l++)if(t[l]!==La[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[ye]===!1&&c)if(t.length<512)if(this[en])this.brotli=!0;else return this[ae]=t,r?.(),!0;else try{new On(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ye]===void 0||this[ye]===!1&&(this.brotli||o)){let l=this[en];this[en]=!1,this[ye]=this[ye]===void 0?new Ig({}):o?new Rg({}):new Tg({}),this[ye].on("data",h=>this[rs](h)),this[ye].on("error",h=>this.abort(h)),this[ye].on("end",()=>{this[en]=!0,this[rs]()}),this[nr]=!0;let f=!!this[ye][l?"end":"write"](t);return this[nr]=!1,r?.(),f}}this[nr]=!0,this[ye]?this[ye].write(t):this[rs](t),this[nr]=!1;let i=this[Mt].length>0?!1:this[Nt]?this[Nt].flowing:!0;return!i&&this[Mt].length===0&&this[Nt]?.once("drain",()=>this.emit("drain")),r?.(),i}[Ea](t){t&&!this[tn]&&(this[ae]=this[ae]?Buffer.concat([this[ae],t]):t)}[ss](){if(this[en]&&!this[ya]&&!this[tn]&&!this[Wr]){this[ya]=!0;let t=this[In];if(t&&t.blockRemain){let e=this[ae]?this[ae].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ae]&&t.write(this[ae]),t.end()}this[An](os)}}[rs](t){if(this[Wr]&&t)this[Ea](t);else if(!t&&!this[ae])this[ss]();else if(t){if(this[Wr]=!0,this[ae]){this[Ea](t);let e=this[ae];this[ae]=void 0,this[is](e)}else this[is](t);for(;this[ae]&&this[ae]?.length>=512&&!this[tn]&&!this[cs];){let e=this[ae];this[ae]=void 0,this[is](e)}this[Wr]=!1}(!this[ae]||this[en])&&this[ss]()}[is](t){let e=0,r=t.length;for(;e+512<=r&&!this[tn]&&!this[cs];)switch(this[st]){case"begin":case"header":this[Ul](t,e),e+=512;break;case"ignore":case"body":e+=this[_a](t,e);break;case"meta":e+=this[Fl](t,e);break;default:throw new Error("invalid state: "+this[st])}e<r&&(this[ae]=this[ae]?Buffer.concat([t.subarray(e),this[ae]]):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[tn]||(this[ye]?(t&&this[ye].write(t),this[ye].end()):(this[en]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[ss]())),this}},ei=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)},tm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},vf=(t,e)=>{let r=new Map(e.map(c=>[ei(c),!0])),i=t.filter,o=(c,l="")=>{let f=l||fg(c).root||".",h;if(c===f)h=!1;else{let x=r.get(c);h=x!==void 0?x:o(lg(c),f)}return r.set(c,h),h};t.filter=i?(c,l)=>i(c,l)&&o(ei(c)):c=>o(ei(c))},nm=t=>{let e=new ai(t),r=t.file,i;try{i=cr.openSync(r,"r");let o=cr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),f=cr.readSync(i,l,0,o.size,0);e.end(f===l.byteLength?l:l.subarray(0,f))}else{let l=0,f=Buffer.allocUnsafe(c);for(;l<o.size;){let h=cr.readSync(i,f,0,c,l);if(h===0)break;l+=h,e.write(f.subarray(0,h))}e.end()}}finally{if(typeof i=="number")try{cr.closeSync(i)}catch{}}},rm=(t,e)=>{let r=new ai(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),cr.stat(o,(f,h)=>{if(f)l(f);else{let x=new Xa(o,{readSize:i,size:h.size});x.on("error",l),x.pipe(r)}})})},ur=ci(nm,rm,t=>new ai(t),t=>new ai(t),(t,e)=>{e?.length&&vf(t,e),t.noResume||tm(t)}),Sf=(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:sm,parse:Gl}=im,nc=t=>{let e="",r=Gl(t);for(;sm(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=Gl(t)}return[e,t]},ks=["|","<",">","?",":"],rc=ks.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),om=new Map(ks.map((t,e)=>[t,rc[e]])),am=new Map(rc.map((t,e)=>[t,ks[e]])),jl=t=>ks.reduce((e,r)=>e.split(r).join(om.get(r)),t),cm=t=>rc.reduce((e,r)=>e.split(r).join(am.get(r)),t),If=(t,e)=>e?(t=J(t).replace(/^\.(\/|$)/,""),ei(e)+"/"+t):J(t),dm=16*1024*1024,Wl=Symbol("process"),Kl=Symbol("file"),$l=Symbol("directory"),Na=Symbol("symlink"),Vl=Symbol("hardlink"),Kr=Symbol("header"),xs=Symbol("read"),Ma=Symbol("lstat"),ps=Symbol("onlstat"),Ba=Symbol("onread"),za=Symbol("onreadlink"),Fa=Symbol("openfile"),Ua=Symbol("onopenfile"),an=Symbol("close"),Ss=Symbol("mode"),Ha=Symbol("awaitDrain"),ba=Symbol("ondrain"),bt=Symbol("prefix"),Af=class extends Pn{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=Qa(e);super(),this.path=J(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||dm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=J(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?J(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=nc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=cm(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=J(r.absolute||ql.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[ps](o):this[Ma]()}warn(t,e,r={}){return Rs(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Ma](){Et.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=um(t),this.emit("stat",t),this[Wl]()}[Wl](){switch(this.type){case"File":return this[Kl]();case"Directory":return this[$l]();case"SymbolicLink":return this[Na]();default:return this.end()}}[Ss](t){return Sf(t,this.type==="Directory",this.portable)}[bt](t){return If(t,this.prefix)}[Kr](){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 On({path:this[bt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bt](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 bs({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[bt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bt](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)}[$l](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Kr](),this.end()}[Na](){Et.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[za](e)})}[za](t){this.linkpath=J(t),this[Kr](),this.end()}[Vl](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=J(ql.relative(this.cwd,t)),this.stat.size=0,this[Kr](),this.end()}[Kl](){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[Vl](e);this.linkCache.set(t,this.absolute)}if(this[Kr](),this.stat.size===0)return this.end();this[Fa]()}[Fa](){Et.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Ua](e)})}[Ua](t){if(this.fd=t,this.#e)return this[an]();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[xs]()}[xs](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Et.read(t,e,r,i,o,(c,l)=>{if(c)return this[an](()=>this.emit("error",c));this[Ba](l)})}[an](t=()=>{}){this.fd!==void 0&&Et.close(this.fd,t)}[Ba](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[an](()=>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[an](()=>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[Ha](()=>this[ba]())}[Ha](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 i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}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[an](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[xs]()}},lm=class extends Af{sync=!0;[Ma](){this[ps](Et.lstatSync(this.absolute))}[Na](){this[za](Et.readlinkSync(this.absolute))}[Fa](){this[Ua](Et.openSync(this.absolute,"r"))}[xs](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let l=Et.readSync(e,r,i,o,c);this[Ba](l),t=!1}finally{if(t)try{this[an](()=>{})}catch{}}}[Ha](t){t()}[an](t=()=>{}){this.fd!==void 0&&Et.closeSync(this.fd),t()}},fm=class extends Pn{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=Qa(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:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=J(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?J(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,f]=nc(this.path);l&&typeof f=="string"&&(this.path=f,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new On({path:this[bt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bt](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}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new bs({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[bt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bt](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)}[bt](t){return If(t,this.prefix)}[Ss](t){return Sf(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 i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,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}},um=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",hm=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,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),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,i=e.length;r<i;r++)pm(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)gm(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 i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new dr;for(let o=this.head;o;)i.push(e.call(r,o.value,this)),o=o.next;return i}mapReverse(e,r){r=r||this;var i=new dr;for(let o=this.tail;o;)i.push(e.call(r,o.value,this)),o=o.prev;return i}reduce(e,r){let i,o=this.head;if(arguments.length>1)i=r;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,r){let i,o=this.tail;if(arguments.length>1)i=r;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let r=0,i=this.head;i;r++)e[r]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,i=this.tail;i;r++)e[r]=i.value,i=i.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new dr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<r;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new dr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=xm(this,o,l);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function xm(t,e,r){let i=e,o=e?e.next:t.head,c=new ic(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function pm(t,e){t.tail=new ic(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function gm(t,e){t.head=new ic(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var ic=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,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}},Zl=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Yl=Buffer.alloc(1024),gs=Symbol("onStat"),$r=Symbol("ended"),ut=Symbol("queue"),Vr=Symbol("queue"),nn=Symbol("current"),Cn=Symbol("process"),Jr=Symbol("processing"),ds=Symbol("processJob"),ht=Symbol("jobs"),va=Symbol("jobDone"),ms=Symbol("addFSEntry"),Xl=Symbol("addTarEntry"),qa=Symbol("stat"),Ga=Symbol("readdir"),ws=Symbol("onreaddir"),ys=Symbol("pipe"),Ql=Symbol("entry"),Sa=Symbol("entryOpt"),_s=Symbol("writeEntryClass"),Tf=Symbol("write"),Ia=Symbol("ondrain"),Ds=class extends Pn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[_s];onWriteEntry;[ut];[Vr]=new Map;[ht]=0;[Jr]=!1;[$r]=!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=J(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[_s]=Af,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 Sg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Ag(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Cg(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[Ia]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ia]);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[ut]=new hm,this[ht]=0,this.jobs=Number(t.jobs)||4,this[Jr]=!1,this[$r]=!1}[Tf](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[$r]=!0,this[Cn](),r&&r(),this}write(t){if(this[$r])throw new Error("write after end");return t instanceof bf?this[Xl](t):this[ms](t),this.flowing}[Xl](t){let e=J(Jl.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Zl(t.path,e);r.entry=new fm(t,this[Sa](r)),r.entry.on("end",()=>this[va](r)),this[ht]+=1,this[ut].push(r)}this[Cn]()}[ms](t){let e=J(Jl.resolve(this.cwd,t));this[ut].push(new Zl(t,e)),this[Cn]()}[qa](t){t.pending=!0,this[ht]+=1;let e=this.follow?"stat":"lstat";vs[e](t.absolute,(r,i)=>{t.pending=!1,this[ht]-=1,r?this.emit("error",r):this[gs](t,i)})}[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[nn])this[ds](t);else{let r=`${e.dev}:${e.ino}`,i=this[Vr].get(r);i?i.push(t):this[Vr].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Cn]()}[Ga](t){t.pending=!0,this[ht]+=1,vs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[ht]-=1,e)return this.emit("error",e);this[ws](t,r)})}[ws](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Cn]()}[Cn](){if(!this[Jr]){this[Jr]=!0;for(let t=this[ut].head;t&&this[ht]<this.jobs;t=t.next)if(this[ds](t.value),t.value.ignore){let e=t.next;this[ut].removeNode(t),t.next=e}this[Jr]=!1,this[$r]&&this[ut].length===0&&this[ht]===0&&(this.zip?this.zip.end(Yl):(super.write(Yl),super.end()))}}get[nn](){return this[ut]&&this[ut].head&&this[ut].head.value}[va](t){this[ut].shift(),this[ht]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[Vr].get(r);if(i){this[Vr].delete(r);for(let o of i)o.pending=!1,this[ds](o)}}this[Cn]()}[ds](t){if(t.pending&&t.pendingLink&&t===this[nn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[nn]&&!t.piped&&this[ys](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[Ga](t),!t.readdir)return}if(t.entry=this[Ql](t),!t.entry){t.ignore=!0;return}t===this[nn]&&!t.piped&&this[ys](t)}}}[Sa](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),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}}[Ql](t){this[ht]+=1;try{return new this[_s](t.path,this[Sa](t)).on("end",()=>this[va](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Ia](){this[nn]&&this[nn].entry&&this[nn].entry.resume()}[ys](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[ms](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Rs(this,t,e,r)}},sc=class extends Ds{sync=!0;constructor(t){super(t),this[_s]=lm}pause(){}resume(){}[qa](t){let e=this.follow?"statSync":"lstatSync";this[gs](t,vs[e](t.absolute))}[Ga](t){this[ws](t,vs.readdirSync(t.absolute))}[ys](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[ms](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[Tf](i)})}},mm=(t,e)=>{let r=new sc(t),i=new xf(t.file,{mode:t.mode||438});r.pipe(i),Cf(r,e)},wm=(t,e)=>{let r=new Ds(t),i=new Ts(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return Rf(r,e).catch(c=>r.emit("error",c)),o},Cf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:pf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Rf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:pf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},ym=(t,e)=>{let r=new sc(t);return Cf(r,e),r},_m=(t,e)=>{let r=new Ds(t);return Rf(r,e).catch(i=>r.emit("error",i)),r},gv=ci(mm,wm,ym,_m,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),bm=process.env.__FAKE_PLATFORM__||process.platform,Pf=bm==="win32",{O_CREAT:Lf,O_NOFOLLOW:ef,O_TRUNC:Nf,O_WRONLY:Mf}=Of.constants,Bf=Number(process.env.__FAKE_FS_O_FILENAME__)||Of.constants.UV_FS_O_FILEMAP||0,vm=Pf&&!!Bf,Sm=512*1024,Im=Bf|Nf|Lf|Mf,tf=!Pf&&typeof ef=="number"?ef|Nf|Lf|Mf:null,zf=tf!==null?()=>tf:vm?t=>t<Sm?Im:"w":()=>"w",ja=(t,e,r)=>{try{return Os.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Is=(t,e,r,i)=>{Os.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Am=(t,e,r,i,o)=>{if(e.isDirectory())Ff(ti.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=ti.resolve(t,e.name);Is(l,r,i,o)});else{let c=ti.resolve(t,e.name);Is(c,r,i,o)}},Ff=(t,e,r,i)=>{Os.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return Is(t,e,r,i);let l=c.length,f=null,h=x=>{if(!f){if(x)return i(f=x);if(--l===0)return Is(t,e,r,i)}};for(let x of c)Am(t,x,e,r,h)})},Tm=(t,e,r,i)=>{e.isDirectory()&&Uf(ti.resolve(t,e.name),r,i),ja(ti.resolve(t,e.name),r,i)},Uf=(t,e,r)=>{let i;try{i=Os.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return ja(t,e,r);throw c}for(let o of i)Tm(t,o,e,r);return ja(t,e,r)},Hf=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"}},Ps=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"}},Rm=(t,e)=>{Qe.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new Hf(t,r?.code||"ENOTDIR")),e(r)})},km=(t,e,r)=>{t=J(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,f=e.gid,h=typeof l=="number"&&typeof f=="number"&&(l!==e.processUid||f!==e.processGid),x=e.preserve,m=e.unlink,_=J(e.cwd),A=(E,S)=>{E?r(E):S&&h?Ff(S,l,f,I=>A(I)):c?Qe.chmod(t,o,r):r()};if(t===_)return Rm(t,A);if(x)return Cm.mkdir(t,{mode:o,recursive:!0}).then(E=>A(null,E??void 0),A);let y=J(As.relative(_,t)).split("/");Wa(_,y,o,m,_,void 0,A)},Wa=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let f=e.shift(),h=J(As.resolve(t+"/"+f));Qe.mkdir(h,r,qf(h,e,r,i,o,c,l))},qf=(t,e,r,i,o,c,l)=>f=>{f?Qe.lstat(t,(h,x)=>{if(h)h.path=h.path&&J(h.path),l(h);else if(x.isDirectory())Wa(t,e,r,i,o,c,l);else if(i)Qe.unlink(t,m=>{if(m)return l(m);Qe.mkdir(t,r,qf(t,e,r,i,o,c,l))});else{if(x.isSymbolicLink())return l(new Ps(t,t+"/"+e.join("/")));l(f)}}):(c=c||t,Wa(t,e,r,i,o,c,l))},Dm=t=>{let e=!1,r;try{e=Qe.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new Hf(t,r??"ENOTDIR")}},Om=(t,e)=>{t=J(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,f=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),h=e.preserve,x=e.unlink,m=J(e.cwd),_=E=>{E&&f&&Uf(E,c,l),o&&Qe.chmodSync(t,i)};if(t===m)return Dm(m),_();if(h)return _(Qe.mkdirSync(t,{mode:i,recursive:!0})??void 0);let A=J(As.relative(m,t)).split("/"),y;for(let E=A.shift(),S=m;E&&(S+="/"+E);E=A.shift()){S=J(As.resolve(S));try{Qe.mkdirSync(S,i),y=y||S}catch{let I=Qe.lstatSync(S);if(I.isDirectory())continue;if(x){Qe.unlinkSync(S),Qe.mkdirSync(S,i),y=y||S;continue}else if(I.isSymbolicLink())return new Ps(S,S+"/"+A.join("/"))}}return _(y)},Aa=Object.create(null),nf=1e4,rr=new Set,Pm=t=>{rr.has(t)?rr.delete(t):Aa[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),rr.add(t);let e=Aa[t],r=rr.size-nf;if(r>nf/10){for(let i of rr)if(rr.delete(i),delete Aa[i],--r<=0)break}return e},Lm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Nm=Lm==="win32",Mm=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=Gf(i,r)),e.push(r||"/"),e},[]),Bm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Nm?["win32 parallelization disabled"]:t.map(i=>ei(Gf(Pm(i))));let r=new Set(t.map(i=>Mm(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.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(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[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:i}=e,o=new Set;for(let c of r){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let f=l[1];if(!f){this.#e.delete(c);continue}if(l.shift(),typeof f=="function")o.add(f);else for(let h of f)o.add(h)}for(let c of i){let l=this.#e.get(c),f=l?.[0];if(!(!l||!(f instanceof Set)))if(f.size===1&&l.length===1){this.#e.delete(c);continue}else if(f.size===1){l.shift();let h=l[0];typeof h=="function"&&o.add(h)}else f.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},zm=()=>process.umask(),rf=Symbol("onEntry"),Ka=Symbol("checkFs"),sf=Symbol("checkFs2"),$a=Symbol("isReusable"),ot=Symbol("makeFs"),Va=Symbol("file"),Ja=Symbol("directory"),Es=Symbol("link"),of=Symbol("symlink"),af=Symbol("hardlink"),Xr=Symbol("ensureNoSymlink"),cf=Symbol("unsupported"),df=Symbol("checkPath"),Ta=Symbol("stripAbsolutePath"),cn=Symbol("mkdir"),ke=Symbol("onError"),ls=Symbol("pending"),lf=Symbol("pend"),ir=Symbol("unpend"),Ca=Symbol("ended"),Ra=Symbol("maybeClose"),Za=Symbol("skip"),ni=Symbol("doChown"),ri=Symbol("uid"),ii=Symbol("gid"),si=Symbol("checkedCwd"),Fm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,oi=Fm==="win32",Um=1024,Hm=(t,e)=>{if(!oi)return Y.unlink(t,e);let r=t+".DELETE."+Df(16).toString("hex");Y.rename(t,r,i=>{if(i)return e(i);Y.unlink(r,e)})},qm=t=>{if(!oi)return Y.unlinkSync(t);let e=t+".DELETE."+Df(16).toString("hex");Y.renameSync(t,e),Y.unlinkSync(e)},ff=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,oc=class extends ai{[Ca]=!1;[si]=!1;[ls]=0;reservations=new Bm;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[Ca]=!0,this[Ra]()},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:Um,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||oi,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=J(be.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:zm():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[rf](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Ra](){this[Ca]&&this[ls]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ta](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=nc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||oi&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let f=be.posix.dirname(t.path),h=be.posix.normalize(be.posix.join(f,l.join("/")));if(h.startsWith("../")||h==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[df](t){let e=J(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=J(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.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[Ta](t,"path")||!this[Ta](t,"linkpath"))return!1;if(t.absolute=be.isAbsolute(t.path)?J(be.resolve(t.path)):J(be.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:J(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:i}=be.win32.parse(String(t.absolute));t.absolute=i+jl(String(t.absolute).slice(i.length));let{root:o}=be.win32.parse(t.path);t.path=o+jl(t.path.slice(o.length))}return!0}[rf](t){if(!this[df](t))return t.resume();switch(Em.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[Ka](t);default:return this[cf](t)}}[ke](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[ir](),e.resume())}[cn](t,e,r){km(J(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)}[ni](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}[ri](t){return ff(this.uid,t.uid,this.processUid)}[ii](t){return ff(this.gid,t.gid,this.processGid)}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Ts(String(t.absolute),{flags:zf(t.size),mode:r,autoClose:!1});i.on("error",f=>{i.fd&&Y.close(i.fd,()=>{}),i.write=()=>!0,this[ke](f,t),e()});let o=1,c=f=>{if(f){i.fd&&Y.close(i.fd,()=>{}),this[ke](f,t),e();return}--o===0&&i.fd!==void 0&&Y.close(i.fd,h=>{h?this[ke](h,t):this[ir](),e()})};i.on("finish",()=>{let f=String(t.absolute),h=i.fd;if(typeof h=="number"&&t.mtime&&!this.noMtime){o++;let x=t.atime||new Date,m=t.mtime;Y.futimes(h,x,m,_=>_?Y.utimes(f,x,m,A=>c(A&&_)):c())}if(typeof h=="number"&&this[ni](t)){o++;let x=this[ri](t),m=this[ii](t);typeof x=="number"&&typeof m=="number"&&Y.fchown(h,x,m,_=>_?Y.chown(f,x,m,A=>c(A&&_)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",f=>{this[ke](f,t),e()}),t.pipe(l)),l.pipe(i)}[Ja](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[cn](String(t.absolute),r,i=>{if(i){this[ke](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[ir](),t.resume())};t.mtime&&!this.noMtime&&(o++,Y.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ni](t)&&(o++,Y.chown(String(t.absolute),Number(this[ri](t)),Number(this[ii](t)),c)),c()})}[cf](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[of](t,e){let r=J(be.relative(this.cwd,be.resolve(be.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Xr](t,this.cwd,r,()=>this[Es](t,String(t.linkpath),"symlink",e),i=>{this[ke](i,t),e()})}[af](t,e){let r=J(be.resolve(this.cwd,String(t.linkpath))),i=J(String(t.linkpath)).split("/");this[Xr](t,this.cwd,i,()=>this[Es](t,r,"link",e),o=>{this[ke](o,t),e()})}[Xr](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=be.resolve(e,c);Y.lstat(l,(f,h)=>{if(f)return i();if(h?.isSymbolicLink())return o(new Ps(l,be.resolve(l,r.join("/"))));this[Xr](t,l,r,i,o)})}[lf](){this[ls]++}[ir](){this[ls]--,this[Ra]()}[Za](t){this[ir](),t.resume()}[$a](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!oi}[Ka](t){this[lf]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[sf](t,r))}[sf](t,e){let r=l=>{e(l)},i=()=>{this[cn](this.cwd,this.dmode,l=>{if(l){this[ke](l,t),r();return}this[si]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=J(be.dirname(String(t.absolute)));if(l!==this.cwd)return this[cn](l,this.dmode,f=>{if(f){this[ke](f,t),r();return}c()})}c()},c=()=>{Y.lstat(String(t.absolute),(l,f)=>{if(f&&(this.keep||this.newer&&f.mtime>(t.mtime??f.mtime))){this[Za](t),r();return}if(l||this[$a](t,f))return this[ot](null,t,r);if(f.isDirectory()){if(t.type==="Directory"){let h=this.chmod&&t.mode&&(f.mode&4095)!==t.mode,x=m=>this[ot](m??null,t,r);return h?Y.chmod(String(t.absolute),Number(t.mode),x):x()}if(t.absolute!==this.cwd)return Y.rmdir(String(t.absolute),h=>this[ot](h??null,t,r))}if(t.absolute===this.cwd)return this[ot](null,t,r);Hm(String(t.absolute),h=>this[ot](h??null,t,r))})};this[si]?o():i()}[ot](t,e,r){if(t){this[ke](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Va](e,r);case"Link":return this[af](e,r);case"SymbolicLink":return this[of](e,r);case"Directory":case"GNUDumpDir":return this[Ja](e,r)}}[Es](t,e,r,i){Y[r](e,String(t.absolute),o=>{o?this[ke](o,t):(this[ir](),t.resume()),i()})}},Zr=t=>{try{return[null,t()]}catch(e){return[e,null]}},jf=class extends oc{sync=!0;[ot](t,e){return super[ot](t,e,()=>{})}[Ka](t){if(!this[si]){let o=this[cn](this.cwd,this.dmode);if(o)return this[ke](o,t);this[si]=!0}if(t.absolute!==this.cwd){let o=J(be.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[cn](o,this.dmode);if(c)return this[ke](c,t)}}let[e,r]=Zr(()=>Y.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Za](t);if(e||this[$a](t,r))return this[ot](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?Zr(()=>{Y.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ot](l,t)}let[o]=Zr(()=>Y.rmdirSync(String(t.absolute)));this[ot](o,t)}let[i]=t.absolute===this.cwd?[]:Zr(()=>qm(String(t.absolute)));this[ot](i,t)}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let f;try{Y.closeSync(o)}catch(h){f=h}(l||f)&&this[ke](l||f,t),e()},o;try{o=Y.openSync(String(t.absolute),zf(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[ke](l,t)),t.pipe(c)),c.on("data",l=>{try{Y.writeSync(o,l,0,l.length)}catch(f){i(f)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let f=t.atime||new Date,h=t.mtime;try{Y.futimesSync(o,f,h)}catch(x){try{Y.utimesSync(String(t.absolute),f,h)}catch{l=x}}}if(this[ni](t)){let f=this[ri](t),h=this[ii](t);try{Y.fchownSync(o,Number(f),Number(h))}catch(x){try{Y.chownSync(String(t.absolute),Number(f),Number(h))}catch{l=l||x}}}i(l)})}[Ja](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[cn](String(t.absolute),r);if(i){this[ke](i,t),e();return}if(t.mtime&&!this.noMtime)try{Y.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ni](t))try{Y.chownSync(String(t.absolute),Number(this[ri](t)),Number(this[ii](t)))}catch{}e(),t.resume()}[cn](t,e){try{return Om(J(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}}[Xr](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=be.resolve(c,l);let[f,h]=Zr(()=>Y.lstatSync(c));if(f)return i();if(h.isSymbolicLink())return o(new Ps(c,be.resolve(e,r.join("/"))))}i()}[Es](t,e,r,i){let o=`${r}Sync`;try{Y[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[ke](c,t)}}},Gm=t=>{let e=new jf(t),r=t.file,i=kf.statSync(r),o=t.maxReadSize||16*1024*1024;new dg(r,{readSize:o,size:i.size}).pipe(e)},jm=(t,e)=>{let r=new oc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),kf.stat(o,(f,h)=>{if(f)l(f);else{let x=new Xa(o,{readSize:i,size:h.size});x.on("error",l),x.pipe(r)}})})},Wf=ci(Gm,jm,t=>new jf(t),t=>new oc(t),(t,e)=>{e?.length&&vf(t,e)}),Wm=(t,e)=>{let r=new sc(t),i=!0,o,c;try{try{o=Xe.openSync(t.file,"r+")}catch(h){if(h?.code==="ENOENT")o=Xe.openSync(t.file,"w+");else throw h}let l=Xe.fstatSync(o),f=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let m=0,_=0;m<512;m+=_){if(_=Xe.readSync(o,f,m,f.length-m,c+m),c===0&&f[0]===31&&f[1]===139)throw new Error("cannot append to compressed archives");if(!_)break e}let h=new On(f);if(!h.cksumValid)break;let x=512*Math.ceil((h.size||0)/512);if(c+x+512>l.size)break;c+=x,t.mtimeCache&&h.mtime&&t.mtimeCache.set(String(h.path),h.mtime)}i=!1,Km(t,r,c,o,e)}finally{if(i)try{Xe.closeSync(o)}catch{}}},Km=(t,e,r,i,o)=>{let c=new xf(t.file,{fd:i,start:r});e.pipe(c),Vm(e,o)},$m=(t,e)=>{e=Array.from(e);let r=new Ds(t),i=(o,c,l)=>{let f=(A,y)=>{A?Xe.close(o,E=>l(A)):l(null,y)},h=0;if(c===0)return f(null,0);let x=0,m=Buffer.alloc(512),_=(A,y)=>{if(A||y===void 0)return f(A);if(x+=y,x<512&&y)return Xe.read(o,m,x,m.length-x,h+x,_);if(h===0&&m[0]===31&&m[1]===139)return f(new Error("cannot append to compressed archives"));if(x<512)return f(null,h);let E=new On(m);if(!E.cksumValid)return f(null,h);let S=512*Math.ceil((E.size??0)/512);if(h+S+512>c||(h+=S+512,h>=c))return f(null,h);t.mtimeCache&&E.mtime&&t.mtimeCache.set(String(E.path),E.mtime),x=0,Xe.read(o,m,0,512,h,_)};Xe.read(o,m,0,512,h,_)};return new Promise((o,c)=>{r.on("error",c);let l="r+",f=(h,x)=>{if(h&&h.code==="ENOENT"&&l==="r+")return l="w+",Xe.open(t.file,l,f);if(h||!x)return c(h);Xe.fstat(x,(m,_)=>{if(m)return Xe.close(x,()=>c(m));i(x,_.size,(A,y)=>{if(A)return c(A);let E=new Ts(t.file,{fd:x,start:y});r.pipe(E),E.on("error",c),E.on("close",o),Jm(r,e)})})};Xe.open(t.file,l,f)})},Vm=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:Kf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Jm=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:Kf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},Yr=ci(Wm,$m,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!mg(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")}),Dv=ci(Yr.syncFile,Yr.asyncFile,Yr.syncNoFile,Yr.asyncNoFile,(t,e=[])=>{Yr.validate?.(t,e),Zm(t)}),Zm=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};Zt();var St={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 di(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function $f(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Vf(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Jf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function hr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}je();Q();Be();je();function Ft(t,e){if(di(t)!=="cloud")throw new C("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}je();Q();var Ms="1008033",Zf="1289";var Yf="pbbp2",Xf="https://www.coze.cn",Qf="/api/coze_claw/resource/get_frontier_key",Xm="https://www.coze.cn",Qm="wss://frontier.coze.cn";function Bs(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Xm}function e0(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Qm}function xr(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function fi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var li=q("handshake");async function ac(t){let e=Bs(t.endpoint),r=t.timeoutMs??1e4,i=`${Ns(e)}${Qf}?aid=${encodeURIComponent(Ms)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...xr(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);li.info("frontier key handshake",{base:e});try{let f=await fetch(i,{method:"GET",headers:o,signal:c.signal}),h=f.headers.get("x-tt-logid")??"",x=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let E=await f.text().catch(()=>"");throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${h}: ${E.slice(0,200)}`)}let m=await f.json();if(m.code!==void 0&&m.code!==0)throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${h}`);let _=m.data??{},A=typeof _.access_key=="string"&&_.access_key||typeof _.accessKey=="string"&&_.accessKey||void 0,y=typeof _.device_id=="string"&&_.device_id||typeof _.deviceId=="string"&&_.deviceId||void 0;if(!A||!y){let E=JSON.stringify(m).slice(0,500);throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${h}: ${E}`)}return li.info("handshake ok",{remoteDeviceId:y,logid:h,traceId:x}),{accessKey:A,deviceId:y}}catch(f){if(f instanceof C)throw li.error("handshake failed (bridge error)",{base:e,message:f.message,code:f.code}),f;if(f.name==="AbortError")throw li.warn("handshake timeout",{base:e,timeoutMs:r}),new C("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:f});let h=f.cause;throw li.error("handshake error",{base:e,message:f instanceof Error?f.message:String(f),errno:h?.code,syscall:h?.syscall,cause:String(f).slice(0,300)}),new C("UPSTREAM_HANDSHAKE_FAILED",String(f),{cause:f})}finally{clearTimeout(l)}}var cc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",It="auto";function t0(t){return{model:t.model??It,...t.modelToken?{modelToken:t.modelToken}:{}}}function n0(t){return!t||t===It}function r0(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=cc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||It,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):n0(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function i0(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||It}"`):n0(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="${cc}/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 s0(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function dc(t,e){let{ttEnv:r,usePpe:i}=fi(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function o0(t,e,r){if(!t.modelToken)return{};let i=dc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
83
|
-
`)}}function lc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function a0(t,e,r){if(!t.modelToken)return null;let i=t.model||It,o=dc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${cc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,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(o).length>0&&(l.headers=o),l}function c0(t,e,r){if(!t.modelToken)return[];let i=dc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var De=q("agent-handlers"),d0=5*1024*1024,sw=1,ow=6,aw=new Set(["node_modules",".git",".coze","dist","build",".next"]),zs=class{constructor(e){this.opts=e}opts;async listSkills(e){Ft(e._meta,"_agent/listSkills");let r=hr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Ot(r).workspace,c=i?.skills??[],l=[];for(let f of c){let h=At(o,f.relPath,"SKILL.md");await nw(h).then(m=>m.isFile()).catch(()=>!1)&&l.push(uw(f))}return{skills:l}}async addSkills(e){Ft(e._meta,"_agent/addSkills");let r=hr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((h,x)=>[h.skillId,x])),f=[];for(let h of o){let x=await mc({agentId:r,workspace:i.workspace,framework:i.framework,skill:h});wc(c,l,x),f.push(h)}return await Gi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:f}}async removeSkills(e){Ft(e._meta,"_agent/removeSkills");let r=hr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let f of c){if(!o.has(f.skillId)){l.push(f);continue}let h=At(i.workspace,f.relPath);await tw(h,{recursive:!0,force:!0}),De.info("skill removed",{agentId:r,skillId:f.skillId,relPath:f.relPath})}return await Gi(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,De.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let h=c.downstream;c.downstream=void 0,De.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),h.stop(r).catch(x=>De.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(x)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return De.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await He(r);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return De.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Zn(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw De.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new C("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Je(i),De.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new C("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await He(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Je(i),De.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}):(De.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Ft(e._meta,"_agent/switchModel"),!e.agentId)throw new C("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:It,i=await He(e.agentId);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Je(i),De.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return De.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>De.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,f]of o.allSessionQueues())c.push(f.enqueue(async()=>{let h=o.sessions.get(l);h?.downstream&&(await h.downstream.stop(`switchModel: ${r}`).catch(()=>{}),h.downstream=void 0)}));return await Promise.all(c),De.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(Ft(e._meta,St.RESET),!e.agentId)throw new C("IPC_BAD_REQUEST",`${St.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,St.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Ft(e._meta,St.REPAIR),!e.agentId)throw new C("IPC_BAD_REQUEST",`${St.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new C("IPC_BAD_REQUEST",`${St.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){De.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,St.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){De.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){De.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Ft(e._meta,"_agent/getFileTree");let r=e._meta,i=hr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),f=await fc(l).catch(()=>null);if(!f)throw new C("IPC_BAD_REQUEST",`path not found: ${c}`);if(f.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Mr(l,o))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let h=vw(e.depth);return f.isDirectory()?{tree:await bw(o,l,c,h)}:{tree:[{name:Sw(c),path:g0(c||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Ft(e._meta,"_agent/getFileContent");let r=hr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new C("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await fc(o).catch(()=>null);if(!c||!c.isFile())throw new C("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Mr(o,i))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>d0)throw new C("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${d0})`);let l=await l0(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await He(e).catch(()=>null))?.workspace??Ot(e).workspace}safeJoin(e,r){let i=xc(e,r||"."),o=gc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${f0}`))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return He(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new C("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function cw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new C("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new C("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function dw(t){return t==="claude-code"?At(".claude","skills"):At(".agents","skills")}var lw=3e4,fw=50*1024*1024,pr=3e4;async function mc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new C("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new C("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let f=cw(o.skillName),h=dw(i),x=At(h,f),m=At(r,x);if(await uc(m,{recursive:!0}),c){let A=Buffer.from(o.content,"utf8");ui(A.length),await hc(At(m,"SKILL.md"),A,"utf8")}else{let A=await hw(o.downloadUrl);pw(A)?await yw(A,m):gw(A)?await mw(A,m):await hc(At(m,"SKILL.md"),A.toString("utf8"),"utf8")}let _={skillId:o.skillId,skillName:o.skillName,relPath:x,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return De.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:x,source:c?"content":"downloadUrl"}),_}function wc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function uw(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 hw(t){if(!t)throw new C("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);ui(e);let r=xw(t);return ui(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await l0(e);return ui(r.length),r}if(Ls(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),lw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new C("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return ui(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new C("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function ui(t){if(t>fw)throw new C("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function xw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new C("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function pw(t){return t.length>=2&&t[0]===31&&t[1]===139}function gw(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 pc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function mw(t,e){let r,i;try{r=new x0.default(t),i=r.getEntries()}catch(l){throw new C("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let f=l.entryName;if(!f||pc(f))continue;if(f.startsWith("/")||/^[A-Za-z]:[\\/]/.test(f))throw new C("IPC_BAD_REQUEST",`zip entry absolute path: ${f}`);if(f.split(/[/\\]/).some(x=>x===".."))throw new C("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${f}`);let h=l.header.attr>>>16&61440;if(h!==0&&h!==32768&&h!==16384)throw new C("IPC_BAD_REQUEST",`zip entry kind 0x${h.toString(16)} not allowed (symlink/hardlink/special): ${f}`)}let o=ww(i),c=xc(e);for(let l of i){if(pc(l.entryName))continue;let f=l.entryName;if(o&&f.startsWith(o)&&(f=f.slice(o.length)),!f)continue;let h=xc(e,f),x=gc(c,h);if(x.startsWith("..")||x==="..")throw new C("IPC_BAD_REQUEST",`zip entry escapes destDir: ${f}`);if(l.isDirectory){await uc(h,{recursive:!0});continue}await uc(rw(h),{recursive:!0});let m;try{m=l.getData()}catch(_){throw new C("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${_.message}`,{cause:_})}await hc(h,m)}}function ww(t){let e;for(let r of t){let i=r.entryName;if(!i||pc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function yw(t,e){await _w(t);let r=Wf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`))},pr);try{await h0(u0.from(t),r)}catch(c){throw c instanceof C?c:i?new C("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`):new C("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function _w(t){let e=[],r=ur({onReadEntry:c=>{let l=c.path,f=c.type;if(f!=="File"&&f!=="Directory"){e.push(`tar entry kind '${f}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(x=>x==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`))},pr);try{await h0(u0.from(t),r)}catch(c){throw i?new C("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`):new C("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new C("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var Ew=5e3;async function bw(t,e,r,i){return p0(t,e,r,i,{count:0})}async function p0(t,e,r,i,o){if(i<=0)return[];let c;try{c=await ew(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let f of c){if(aw.has(f.name)||f.isSymbolicLink())continue;if(o.count>=Ew){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let h=At(e,f.name),x=iw(At(r,f.name)),m=null;try{m=await fc(h)}catch{continue}if(m.isSymbolicLink())continue;o.count++;let _={name:f.name,path:g0(gc(t,h)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&i>1&&(_.children=await p0(t,h,x,i-1,o)),l.push(_)}return l.sort((f,h)=>f.isDir!==h.isDir?f.isDir?-1:1:f.name.localeCompare(h.name)),l}function vw(t){return!t||t<=0?sw:Math.min(t,ow)}function Sw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function g0(t){return t.split(f0).join("/")}Q();import{readFileSync as HS}from"node:fs";import{dirname as GS,join as jS}from"node:path";import{fileURLToPath as KS}from"node:url";var gr="0.1.83-alpha.1";var fn=q("agent-health-reporter"),Iw=1e4,hi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Iw}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()}),fn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),fn.info("heartbeat stopped"))}async tick(){if(this.inFlight){fn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){fn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let f=Aw(l);if(!f)continue;let h={agentId:l.agentId,status:f};l.patToken&&(h.patToken=l.patToken),l.accountId&&(h.accountId=l.accountId),r.push(h)}if(r.length===0)return;let i={agents:r,bridgeVersion:gr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){fn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(fn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){fn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){fn.warn("onTickEnd hook failed",{err:String(r)})}}};function Aw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Zt();import{mkdir as _c,rm as ny}from"node:fs/promises";yn();import{spawnSync as Lw}from"node:child_process";function xi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function pi(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 un(t,e){return{jsonrpc:"2.0",id:t,error:e}}je();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)}},X={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,AGENT_DEPENDENCY_INSTALL_FAILED:-32018};function m0(t){return"method"in t&&"id"in t&&t.id!==void 0}function w0(t){return"method"in t&&!("id"in t)}function Us(t){return!("method"in t)&&"id"in t}var Tw={AGENT_NOT_FOUND:X.AGENT_NOT_FOUND,AGENT_BUSY:X.AGENT_BUSY,AGENT_DISCONNECTED:X.AGENT_DISCONNECTED,AGENT_TIMEOUT:X.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:X.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:X.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:X.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:X.INTERNAL_ERROR,BRIDGE_INTERNAL:X.INTERNAL_ERROR,IPC_AUTH_FAILED:X.INTERNAL_ERROR,IPC_BAD_REQUEST:X.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:X.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:X.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:X.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:X.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:X.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:X.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:X.FILE_TOO_LARGE,UNSUPPORTED_MIME:X.UNSUPPORTED_MIME,UPLOAD_FAILED:X.UPLOAD_FAILED,UPSTREAM_NOT_READY:X.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:X.AGENT_DEPENDENCY_INSTALL_FAILED};function Cw(t){if(t!=null)return t instanceof Error?{name:t.name,message:gi(t.message)}:typeof t=="string"?gi(t):typeof t=="object"?kw(t):t}var Rw=[[/\/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 gi(t){let e=t;for(let[r,i]of Rw)e=e.replace(r,i);return e}function kw(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=gi(i):e[r]=i;return e}function mi(t){if(t instanceof C){let e=Cw(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:Tw[t.code]??X.INTERNAL_ERROR,message:gi(t.message),data:r}}return{code:X.INTERNAL_ERROR,message:gi(t instanceof Error?t.message:String(t))}}function y0(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:l,...f}=e;c=f}return new C(r,o,{retriable:e?.retriable??!1,cause:c})}function E0(t){return`${JSON.stringify(t)}
|
|
84
|
-
`}var
|
|
85
|
-
`);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(l){this.onError?.({line:c,error:l})}}return i}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 v0={"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"},r2=Object.fromEntries(Object.entries(v0).map(([t,e])=>[e,t])),Dw={"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 i=v0[e]??Ow(e),o=Dw[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(h=>b0(r?.[h]??"")),f=Pw(l).join(":");f&&c.push(f)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>b0(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function Ow(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function b0(t){return t.replace(/[:_\s]+/g,"-")}function Pw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Wn();function yr(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}je();Q();var Nw=yr("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Mw=200,Bw=yr("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),zw=yr("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),S0=500;function Fw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=S0?t:`${e.slice(0,S0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function I0(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),Lw("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var Tt=class{constructor(e){this.opts=e;this.log=q(`downstream.${this.constructor.name}`),this.decoder=new Hs({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 C("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Jt(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",i=>{try{for(let o of this.decoder.push(i))this.dispatch(o)}catch(o){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(o)})}}),r.stderr?.setEncoding("utf8"),r.stderr?.on("data",i=>{let o=i.trimEnd();this.stderrRing.push(o),this.stderrRing.length>Mw&&this.stderrRing.shift(),this.log.debug("stderr",{text:o})}),r.stdin?.on("error",i=>{this.log.warn("child stdin error",{err:String(i)})}),r.stdout?.on("error",i=>{this.log.warn("child stdout error",{err:String(i)})}),r.stderr?.on("error",i=>{this.log.warn("child stderr error",{err:String(i)})}),r.on("exit",(i,o)=>{this.stopped=!0,(i!==0||o!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:i,signal:o,recentStderr:[...this.stderrRing]});try{for(let l of this.decoder.flush())this.dispatch(l)}catch(l){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(l)})}this.failAllPending(new C("AGENT_PROTOCOL_ERROR",`agent exited (${i}/${o})`));for(let l of this.exitHandlers)l(i,o)}),r.on("error",i=>{this.log.error("child error",{err:String(i)}),this.failAllPending(new C("AGENT_SPAWN_FAILED",String(i),{cause:i}))}),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,i=new Promise(c=>r.once("exit",()=>c()));I0(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||I0(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}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=Bw,i=zw){return this.call("session/prompt",e,r,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(pi("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(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(un(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=Nw,o=0){if(!this.child||this.stopped)return Promise.reject(new C("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=xi(c,e,r),f=(()=>{if(typeof r!="object"||r===null)return;let m=r.sessionId;return typeof m=="string"?m:void 0})(),h=i>0&&Number.isFinite(i),x=o>0&&Number.isFinite(o);return new Promise((m,_)=>{let A={resolve:m,reject:_,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};h&&(A.timer=setTimeout(()=>{this.pending.delete(c),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i,...f?{sessionId:f}:{}}),_(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));let y=x?()=>{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,...f?{sessionId:f}:{}}),y?.();return}A.timer&&clearTimeout(A.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:o,...f?{sessionId:f}:{}}),_(new C("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${o}ms (no inflight agent request)`))},o)}:null;A.armFrameIdle=y,this.pending.set(c,A),y?.();try{this.writeFrame(l)}catch(E){A.timer&&clearTimeout(A.timer),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.pending.delete(c),_(E)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new C("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(E0(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(y0(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 C("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Fw(e.result)}),r.resolve(e.result));return}if(w0(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(i=>this.log.warn("update handler failed (async)",{err:String(i)}))}catch(i){this.log.warn("update handler threw sync, swallowed",{err:String(i)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(m0(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(un(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(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(un(e.id,mi(i)))}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()}};function Uw(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var qs=class extends Tt{framework="claude-code";constructor(e){let r=Nr("claude-code",e.command),i=e.args??[],o={command:r,args:i,cwd:e.cwd,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return Uw(e)}};yn();import{mkdtempSync as Hw,rmSync as qw}from"node:fs";import{tmpdir as Gw}from"node:os";import{join as jw}from"node:path";var Gs=class extends Tt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=Nr("codex",e.command),i=e.args??[],o=e.extraArgs?[...i,...e.extraArgs]:i,c=e.isolateCodexHome?Hw(jw(Gw(),"coze-bridge-codex-home-")):void 0,l=c?{...e.env??{},CODEX_HOME:c}:e.env,f={command:r,args:o,cwd:e.cwd,...l?{env:l}:{}};super(f),this.authMethodId=e.authMethodId,this.codexHomeDir=c}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 Tt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,...e.env?{env:e.env}:{}};super(o),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}};je();Q();Be();function yc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}yn();var Er=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,i)=>{this.slots.push({task:e,resolve:r,reject:i}),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 js=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 Er,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 i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)wi(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function wi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}Wn();Q();import{constants as A0,access as Kw}from"node:fs/promises";import{delimiter as $w,join as Vw}from"node:path";var hn=q("framework-detector"),T0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Jw=[".exe",".cmd",".bat",".ps1"],xn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Jt,access:e.access??Kw}}async detect(e){let r=T0[e],i=await this.which(r);if(!i)return hn.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),f={path:i,version:c};return l&&(f.defaultAgent=l),f}async detectAll(){let e=await Promise.all(Object.keys(T0).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split($w).filter(Boolean),i=this.env.platform==="win32"?["",...Jw]:[""];for(let o of r)for(let c of i){let l=Vw(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?A0.F_OK:A0.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 hn.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return hn.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return hn.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return hn.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(l=>l?.isDefault===!0);return c?!c.id||!c.workspace?(hn.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}:(hn.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return hn.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(Yw(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,f=h=>{c||(c=!0,l&&clearTimeout(l),i(h))};try{let h=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{h.kill("SIGKILL"),f(null)},15e3),h.stdout?.on("data",x=>{o+=x.toString("utf8")}),h.on("error",()=>f(null)),h.on("close",x=>f({code:x,stdout:o}))}catch{f(null)}})}},Zw=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Yw(t){return t.replace(Zw,"")}import{spawn as Xw}from"node:child_process";import{homedir as Qw}from"node:os";import{join as ey}from"node:path";je();Hi();Q();async function k0(){let t=ey(Qw(),".openclaw/openclaw.json");return(await Jn(t))?.gateway?.auth?.token??""}var C0=q("openclaw.config"),ty=[0,5e3,5e3],R0="models.providers.",Ws="agents.defaults.models",Ks=class{command;env;retryDelaysMs;queue=new Er;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??ty}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(l=>setTimeout(l,c));try{return await r()}catch(l){i=l,C0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new C("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=Xw(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`exit ${l}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){C0.warn(`${e} failed (best-effort)`,{configPath:r,err:String(i)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${R0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${R0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Ws}[${e}]`,()=>this.runCli(["config","set",Ws,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Ws}[${e}]`,`${Ws}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["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=q("agent-manager"),ry=(t,e,r,i,o,c,l,f,h)=>{switch(t){case"claude-code":{let x={...o?{...r0(o),...o0(o,l,f)}:{},...h??{},IS_SANDBOX:"1"};return new qs({cwd:r,env:x})}case"codex":{let m=[...o?[...i0(o),...c0(o,l,f)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],_={...o?s0(o):{},...h??{}},A=!!o;return new Gs({cwd:r,...m.length>0?{extraArgs:m}:{},...Object.keys(_).length>0?{env:_}:{},...A?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new _r({command:e,cwd:r,agentId:i,...c?{sessionName:yc(c)}:{}})}};function Ec(t){return t==="claude-code"||t==="codex"}var iy={path:"",version:"cloud-deployed"},sy={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},oy=6e4,$s=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??ry,this.createTimeoutMs=e.createTimeoutMs??oy,this.detectorFactory=e.detectorFactory??(()=>new xn)}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 C("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 C("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new C("IPC_BAD_REQUEST","framework required");let r=di(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let i=this.registry.get(e.agentId);if(i){if(i.framework!==e.framework)throw new C("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${i.framework})`);if(i.status==="error")Oe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await i.dispose("rebuild after error").catch(E=>Oe.warn("dispose stale agent failed (ignored)",{err:String(E)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==i.patToken){Oe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),i.setPatToken(e.patToken);let E=await He(e.agentId,this.paths).catch(()=>null);E&&(E.patToken=e.patToken,await Je(E,this.paths))}if(i.deployType==="cloud"&&e.modelInfo){Oe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),i.setModelInfo(e.modelInfo);let E=await He(e.agentId,this.paths).catch(()=>null);E&&(E.modelInfo=e.modelInfo,await Je(E,this.paths))}return Oe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:i.agentId,workspace:i.workspace,framework:i.framework}}}if(!r&&!this.config.frameworksCache?.[e.framework])throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Ot(e.agentId,this.paths),l=di(e._meta),f=e.framework==="openclaw"&&l==="local",h=f?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,x=e.workspace??h??c.workspace,m=new AbortController,_=setTimeout(()=>m.abort(new C("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,y=!1;try{r&&Ec(e.framework)&&await Vn(e.framework,m.signal);let E=()=>{if(m.signal.aborted)throw m.signal.reason instanceof Error?m.signal.reason:new C("AGENT_TIMEOUT","_agent/create aborted")};await _c(c.root,{recursive:!0}),await _c(x,{recursive:!0}),await _c(c.logs,{recursive:!0}),E(),f||await Zn(x,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await Yd(x),E();let S=await He(e.agentId,this.paths).catch(()=>null),I=t0({model:e.model??S?.model}),R=$f(e._meta)??S?.accountId,P=e.patToken??S?.patToken,w=l==="cloud"?e.modelInfo??S?.modelInfo:void 0;if(A=new js({agentId:e.agentId,framework:e.framework,workspace:x,model:I.model??It,deployType:l,...R?{accountId:R}:{},...P?{patToken:P}:{},...w?{modelInfo:w}:{}}),A.status="ok",S?.sessions){for(let[B,D]of Object.entries(S.sessions))A.sessions.set(B,{acpSessionId:D.acpSessionId,modelToken:D.modelToken,tokenGeneratedAt:D.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let z=Object.keys(S.sessions).length;z>0&&Oe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:z})}this.registry.register(A),y=!0;let T={agentId:e.agentId,framework:e.framework,workspace:x,cozeIdentity:e.cozeIdentity,createdAt:S?.createdAt??Date.now(),sessions:S?.sessions??{},model:I.model};l==="cloud"&&(T.deployType="cloud"),R&&(T.accountId=R),P&&(T.patToken=P),w&&(T.modelInfo=w),S?.skills&&(T.skills=S.skills),S?.agentName&&(T.agentName=S.agentName),S?.description&&(T.description=S.description),e.framework==="openclaw"&&l==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,x):Oe.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 z=[...T.skills??[]],B=new Map(z.map((F,j)=>[F.skillId,j])),D=await Promise.allSettled(k.map(F=>mc({agentId:e.agentId,workspace:x,framework:e.framework,skill:F}))),L=0;for(let[F,j]of D.entries()){let ie=k[F];ie&&(j.status==="fulfilled"?(wc(z,B,j.value),L++):Oe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:ie.skillId,skillName:ie.skillName,err:String(j.reason)}))}L>0&&(T.skills=z,Oe.info("initialSkills installed",{agentId:e.agentId,installed:L,requested:k.length}))}return await Je(T,this.paths),Oe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:l}),{ok:!0,agentId:e.agentId,workspace:x,framework:e.framework}}catch(E){throw Oe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(E)}),y&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ny(c.root,{recursive:!0,force:!0}).catch(S=>Oe.warn("rm agent dir failed (ignored)",{err:String(S)})),E instanceof C?E:new C("AGENT_SPAWN_FAILED",String(E),{cause:E})}finally{clearTimeout(_)}}async spawnSessionDownstream(e,r,i,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&Ec(e.framework))f=iy;else throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(Ec(e.framework)&&!Lr(e.framework)){let m=Zo(e.framework);Oe.info("spawn: ensuring acp wrapper installed",{agentId:e.agentId,framework:e.framework,reusingInFlight:!!m}),await Vn(e.framework)}let h=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,x;e.framework==="openclaw"?x=await this.buildOpenclawDownstream({session:e,modelConfig:h,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:f.path}):x=this.factory(e.framework,f.path,e.workspace,e.agentId,h,i,o,c,this.buildBinShimPathEnv());try{return await x.start(),await x.initialize(sy),x}catch(m){let _=x instanceof Tt?x.getStderrTail():[];throw _.length>0&&Oe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof C?m.code:"unknown",recentStderr:_}),await x.stop("spawnSessionDownstream failed").catch(()=>{}),m instanceof C?new C(m.code,m.message,{retriable:m.retriable,cause:m}):new C("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:m})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:f}=e,h=yc(o);if(r.deployType==="local"){let A=this.config.frameworksCache?.openclaw?.defaultAgent;if(!A?.id||!A.workspace){Oe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let E=await this.detectorFactory().detect("openclaw");if(E?.defaultAgent?.id&&E?.defaultAgent?.workspace)Oe.info("openclaw lazy re-detect success",{agentId:E.defaultAgent.id,workspace:E.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=E,A=E.defaultAgent;else throw new C("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:f,cwd:A.workspace,agentId:A.id,sessionName:h})}let x=await k0(),m=i?a0(i,c,l):null,_;if(m){let A=lc(o),E=m.models[0]?.id??It,S=`${A}/${E}`;if(!this.ensuredProviders.has(S)){let I=this.getOpenclawConfig();await I.ensureProvider(A,m),await I.addModelToAllowlist(S),this.ensuredProviders.add(S)}_=S}return new _r({command:f,cwd:r.workspace,agentId:r.agentId,sessionName:h,...x?{gatewayToken:x}:{},..._?{slashModelOnStart:_}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=lc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(f){l=!1,Oe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(f)})}try{await r.removeModelFromAllowlist(c)}catch(f){l=!1,Oe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(f)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as N0}from"node:crypto";import{promises as xy}from"node:fs";import{basename as M0}from"node:path";je();Q();import{promises as cy}from"node:fs";import{basename as dy}from"node:path";var D0=q("file-upload"),ly="/api/coze_claw/file/agent_upload",fy=6e4;async function O0(t,e={}){let i=`${Ns(Bs(e.handshakeBase))}${ly}`,o=e.timeoutMs??fy,c=await cy.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let f={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...xr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},h=new AbortController,x=setTimeout(()=>h.abort(),o);D0.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(i,{method:"POST",headers:f,body:l,signal:h.signal}),_=m.headers.get("x-tt-logid")??"";if(!m.ok){let E=await m.text().catch(()=>"");throw new C("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${_}: ${E.slice(0,200)}`)}let A=await m.json();if(A.code!==void 0&&A.code!==0)throw new C("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${_}`);let y=A.data?.file?.file_url;if(!y)throw new C("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(A).slice(0,200)}`);return D0.info("file upload ok",{uri:y,logid:_}),{uri:y}}catch(m){throw m instanceof C?m:m.name==="AbortError"?new C("UPLOAD_FAILED",`upload timeout (${o}ms) for ${dy(t.path)}`):new C("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(x)}}je();Q();import{extname as uy}from"node:path";var hy={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function P0(t){let e=uy(t).toLowerCase();return hy[e]??"application/octet-stream"}Be();var Vs=q("agent-send"),L0=50*1024*1024;function B0(t,e,r){let i=t.get(e);if(!i)throw new C("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new C("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new C("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function z0(t,e,r,i,o,c){let f;for(let h=0;h<=2;h++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(x){f=x,h<2&&(Vs.warn("sendAgentFileUpdate failed, retrying",{attempt:h+1,err:String(x)}),await new Promise(m=>setTimeout(m,5e3)))}throw new C("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(f)}`,{cause:f})}async function F0(t,e){let{session:r,runtime:i}=B0(e.core,t.agentId,t.sessionId);if(!await Mr(t.path,r.workspace))throw new C("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await xy.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new C("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>L0)throw new C("FILE_TOO_LARGE",`${o.size} bytes > limit ${L0}`);let c=await P0(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new C("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??M0(t.path),f;try{f=await O0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(x){throw Vs.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:x instanceof C?x.code:"UNKNOWN",message:x instanceof Error?x.message:String(x)}),x}let h={sessionUpdate:"agent_file",messageId:N0(),content:{type:t.kind==="image"?"image":"resource",uri:f.uri,mimeType:c,name:l,sizeBytes:o.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await z0(e,r,i,t.sessionId,h,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Vs.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:f.uri}),{ok:!0,uri:f.uri,bytes:o.size,mimeType:c,...f.fileId!==void 0?{fileId:f.fileId}:{}}}async function U0(t,e){let{session:r,runtime:i}=B0(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new C("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??M0(t.path),c={sessionUpdate:"group_file",messageId:N0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await z0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Vs.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function H0(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let l=r[c]??0,f=i[c]??0;if(l<f)return!0;if(l>f)return!1}return!1}yn();Wn();Q();var Ct=q("coze-cli-installer"),q0="@coze/cli@latest",py="coze",G0="0.1.7",gy=5e3,my=5e3,wy=9e4,j0=1e4,yi=null,Js=!1;async function bc(t,e={}){if(Js)return;if(yi)return yi;let r=e.exec??Mi;return yi=(async()=>{try{let i=await yy(py,r),o=!1;if(i){let l=await _y(r);if(l===void 0)Ct.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(H0(l,G0))Ct.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:G0}),o=!0;else{Ct.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),Js=!0;return}}let c=o?"upgrade-only":"full";Ct.info("coze-cli install start",{package:q0,mode:c});try{await r("npm",["i","-g","--prefer-online",q0],{timeout:wy,maxBuffer:10*1024*1024}),Ct.info("coze-cli install ok")}catch(l){Ct.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){Js=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:j0}),Ct.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Ct.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:j0}),Ct.info("coze auth login ok")}catch(l){Ct.warn("coze auth login failed",{err:String(l)});return}Js=!0}finally{yi=null}})(),yi}async function yy(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:gy});return Fi(i)}catch{return}}async function _y(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:my});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Hi();Be();var Ey=10*6e4;function W0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Ey:e}function Zs(t){return Jn(t??ee().configFile)}function br(t,e){return Ui(e??ee().configFile,t)}import{randomBytes as Fy}from"node:crypto";import{createReadStream as by}from"node:fs";import{mkdir as vy,readFile as Sy,realpath as Iy,stat as Ay,writeFile as Ty}from"node:fs/promises";import{basename as Cy,dirname as vc,join as Ry,relative as ky,resolve as K0,sep as Dy}from"node:path";import{createInterface as Oy}from"node:readline";je();Q();var V0=q("fs-rpc"),_i=yr("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function J0(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>_i)throw new C("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${_i} bytes`);let i=await Y0(t.path,e);return await vy(vc(i),{recursive:!0}),await Ty(i,t.content,"utf8"),V0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Z0(t,e){let r=await Y0(t.path,e),i=await Ay(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>_i&&!o)throw new C("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${_i} bytes`);let c;if(o&&i.size>_i)c=await Py(r,t.line??1,t.limit);else{let l=await Sy(r,"utf8");if(o){let f=l.split(`
|
|
86
|
-
`),
|
|
87
|
-
`)}else c=
|
|
88
|
-
`)}async function Y0(t,e){if(typeof t!="string"||t.length===0)throw new C("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([$0(K0(e)),$0(K0(t))]),o=ky(r,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Dy}`))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}async function $0(t){let e=[],r=t;for(;r!==vc(r);)try{let i=await Iy(r);return e.length?Ry(i,...e.reverse()):i}catch{e.push(Cy(r)),r=vc(r)}return t}Q();var X0=q("prompt-multimodal"),Q0=10*1024*1024,Ly=15e3,Ny=6;async function eu(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await My(l))}}let o=Array.from({length:Math.min(Ny,t.length)},()=>i());return await Promise.all(o),e}function tu(t){return t.some(e=>e.type==="image")}async function My(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:i}=await zy(e.uri),o=e.mimeType||By(i)||"application/octet-stream";return X0.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:o}),{type:"image",data:r.toString("base64"),mimeType:o}}catch(r){return X0.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function By(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function zy(t){let e=new AbortController,r=setTimeout(()=>e.abort(),Ly);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>Q0)throw new Error(`image too large: ${o.byteLength} bytes (max ${Q0})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Zt();je();Q();var V=q("core"),Uy=3e4,Hy=/^(boe|ppe)_[A-Za-z0-9_-]+$/,qy=3e4,Ys=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=W0(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(),V.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){V.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),V.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){V.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}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)&&V.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,l)=>{V.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),wi(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){V.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(un(o,{code:X.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>V.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:X.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){V.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream)try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:X.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new C("UPSTREAM_DISCONNECTED",`${i.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,i=e.params?._meta?.cozeEnv;i&&Hy.test(i)?this.currentCozeEnv=i:i&&V.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,X.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):V.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(mr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(mr(r,o));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,X.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):V.warn("drop unknown notification",{method:e.method})}catch(o){V.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(un(r,mi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new C("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new C("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new C("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new C("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);let l=Date.now(),f=!1;try{let h=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return f=!0,h}finally{V.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:f})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=Jf(i);switch(r){case"session/new":{let c=Gy();return V.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return V.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/prompt: missing sessionId");let f=await this.ensureRuntime(e,l);if(f.replySeq=0,await this.ensureDownstream(e,l,f),!f.downstream||!f.acpSessionId)throw new C("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let h=i._meta?.cozeTriggerMsgId;h?e.activeTriggers.set(f.acpSessionId,h):e.activeTriggers.delete(f.acpSessionId);let x=Vf(i._meta);if(x?e.activeGroupIds.set(f.acpSessionId,x):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&tu(c.prompt))throw new C("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await eu(c.prompt);try{let _=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:m});return f.lastActiveAt=Date.now(),_}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.reloadAfterTurn){f.reloadAfterTurn=!1;let _=f.downstream;_&&(f.downstream=void 0,V.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:f.acpSessionId}),_.stop("reload-after-turn").catch(A=>V.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(A)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,l,f)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(l);if(e.hasSessionQueue(l)){let h=e.getSessionQueue(l);h.size>0&&(V.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:h.size}),h.dispose(new C("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new C("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;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 i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(St.GEN_MODEL_TOKEN,i,qy);if(!o?.modelToken)throw new C("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof C&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new C("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(wi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new C("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,f=i.spawnFailedAt??0;if(l>=o&&Date.now()-f<c)throw new C("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-f))/1e3)}s`);let h;try{h=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(x){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(V.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),x}if(i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=h,this.attachRuntimeHooks(e,r,i),i.acpSessionId){i.loadingSession=!0;try{await h.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),V.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(x){V.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),i.acpSessionId=void 0;let m=await h.sessionNew({cwd:e.workspace});i.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let x=await h.sessionNew({cwd:e.workspace});i.acpSessionId=x.sessionId,await this.persistSessionMapping(e)}h.afterSessionEstablished&&i.acpSessionId&&await h.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(wi(i),this.isRuntimeBusy(e,i)){V.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){V.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}V.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>V.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let f=e.activeGroupIds.get(r.acpSessionId);f&&(c.cozeGroupId=f)}await this.upstream.send(pi("session/update",{sessionId:i,update:o,_meta:c}))}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){V.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){V.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(Wy(r)){V.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},f=e.activeTriggers.get(i);f&&(l.cozeTriggerMsgId=f);let h=e.activeGroupIds.get(i);h&&(l.cozeGroupId=h),this.upstream.send(pi("session/update",{...r,sessionId:o,_meta:l})).catch(x=>V.warn("forward update failed",{agentId:e.agentId,err:String(x)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}V.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:X.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await J0(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Z0(c,o);r.respondAgentRequest(i.id,l)}}catch(o){V.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,mi(o))}}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},f=c.sessionId,h=f?e.activeTriggers.get(f):void 0,x={cozeAgentId:e.agentId};h&&(x.cozeTriggerMsgId=h);let m=f?e.activeGroupIds.get(f):void 0;m&&(x.cozeGroupId=m);let _=f?this.reverseSessionId(e,f):void 0,A={...c,..._?{sessionId:_}:{},_meta:x};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method}),V.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:f,cloudSessionId:_,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(y=>({optionId:y.optionId,kind:y.kind,name:y.name}))}),this.upstream.send(xi(o,"session/request_permission",A)).catch(y=>{this.pendingUpstream.delete(o),V.error("forward permission request failed",{agentId:e.agentId,err:String(y)}),r.respondAgentRequestError(i.id,{code:X.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 o=r.value;e.error?(V.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&jy(e.result,o),V.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new Fs(e.error)):i.value.resolve(e.result);return}V.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),l=e.get(c);if(l)return V.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=Uy){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let f=setTimeout(()=>{this.pendingBridge.delete(o),l(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:f}),this.upstream.send(xi(o,e,r)).catch(h=>{let x=this.pendingBridge.get(o);x&&(clearTimeout(x.timer),this.pendingBridge.delete(o)),l(h)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await Yo(e.agentId,r,this.paths)}catch(r){V.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(un(e,{code:r,message:i,data:{bridgeVersion:gr}}))}};function Gy(){return Fy(16).toString("hex")}function jy(t,e){if(!t||typeof t!="object"){V.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){V.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){V.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&V.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function Wy(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 i=r;return i.type!=="text"||typeof i.text!="string"?!1:i.text.startsWith("Model metadata for `")}Q();Be();import{randomBytes as Ky}from"node:crypto";import{chmod as $y,mkdir as Vy,writeFile as nu}from"node:fs/promises";import{createServer as Jy}from"node:http";import{dirname as Zy}from"node:path";var Yy=1e6,Sc=q("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??ee()}async start(){this.token=Ky(32).toString("hex");let e=Jy((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});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,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await Vy(Zy(this.paths.portFile),{recursive:!0}),await nu(this.paths.portFile,String(this.port),"utf8"),await nu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await $y(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}`){Ei(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Ei(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await Xy(e)}catch(f){Ei(r,400,{error:"invalid json",detail:String(f)});return}try{let f=await c.handler(l,e);Ei(r,200,f??{ok:!0})}catch(f){Sc.error("IPC handler failed",{key:o,err:String(f)}),Ei(r,500,{error:f instanceof Error?f.message:String(f)})}}};function Ei(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function Xy(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>Yy)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var Sh=mt(hu(),1);var O1=mt(ch(),1),P1=mt(po(),1),L1=mt(Ir(),1),N1=mt(Bc(),1),M1=mt(Uc(),1),B1=mt(Kc(),1),mh=mt(yo(),1),z1=mt(gh(),1);var wh=mh.default;je();Q();var Se=q("upstream.frontier"),_h="application/json",Eh="none",U1=15e3,ki=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){Se.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Xf,...xr(this.opts.ppeOverride)};class r extends wh{constructor(E){super(E,Yf,{headers:e})}send(E,...S){if(Pd("debug"))try{let I;typeof E=="string"?I=Buffer.from(E,"utf8"):E instanceof Buffer?I=E:E instanceof ArrayBuffer?I=new Uint8Array(E):ArrayBuffer.isView(E)?I=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):I=new Uint8Array(0);let R=Buffer.from(I.slice(0,128)).toString("hex");Se.debug("WS raw frame out",{bytes:I.byteLength,headHex:R})}catch(I){Se.warn("WS raw frame dump failed",{err:String(I)})}super.send(E,...S)}}let i=e0(this.opts.urlOverride),o={url:i,ws:r,fpID:Zf,aID:Ms,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:_h,force:!0},payloadEncoding:{encoding:Eh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new Sh.FWS(o),l=!1,f=null,h,x,m=new Promise((y,E)=>{h=y,x=E}),_=y=>{l||(l=!0,f&&(clearTimeout(f),f=null),y?x(y):h())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Se.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&_();for(let E of this.connectHandlers)Promise.resolve(E({initial:y})).catch(S=>Se.warn("onConnect handler threw (ignored)",{err:String(S)}))},c.onclose=y=>{this.opened=!1,Se.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Se.warn("frontier error",{code:y.code,msg:y.message}),_(new C("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let A=this.opts.openTimeoutMs??U1;f=setTimeout(()=>{_(new C("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await m}catch(y){try{c.close(1e3,"open failed")}catch(E){Se.warn("fws close during start failure threw (ignored)",{err:String(E)})}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(i){Se.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Se.warn("frontier send refused: upstream not started",{method:i}),new C("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let f=Date.now();throw f-this.lastSendRefusedLogAt>1e3?(Se.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=f,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new C("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;bh(c)||Se.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:_h,payloadEncoding:Eh})}catch(f){throw Se.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(f)}),new C("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}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 i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Se.debug("drop non-adapter frontier frame",{service:r});return}let i=G1(e);if(!i){Se.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Se.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Se.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;bh(c)||Se.info("frontier frame in",{logid:q1(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:H1(i)}),Promise.resolve(this.handler(o)).catch(l=>Se.warn("frontier frame handler threw",{err:String(l)}))}};function bh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var vh=2e3;function H1(t){return t.length<=vh?t:`${t.slice(0,vh)}...<truncated, total ${t.length} chars>`}function q1(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function G1(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}}Q();var Vc=q("upstream.switchable"),Eo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Vc.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw Vc.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Vc.warn("previous upstream stop threw (ignored)",{err:String(o)}))}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()}};Q();var Jc=q("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)}};je();Q();Q();Be();import{promises as Zc}from"node:fs";import{dirname as j1}from"node:path";var W1=q("pat-token-store");async function Ih(t=ee()){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"&&W1.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Di(t,e=ee()){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 bo}from"node:fs";import{join as K1}from"node:path";function $1(t,e){return`#!/bin/sh
|
|
80
|
+
`},configPath(t){return zE(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 Hx("schtasks",["/Create","/SC","ONLOGON","/TN",No,"/TR",r,"/RU",t.userName,"/F"]),a0.info("task scheduler entry created",{task:No,logFile:t.logFile})},async uninstall(t){await Hx("schtasks",["/Delete","/TN",No,"/F"]).catch(e=>a0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),a0.info("task scheduler entry removed",{task:No})}}});var Gx={};$o(Gx,{buildContext:()=>HE,getSupervisor:()=>qE,launchdSupervisor:()=>s0,systemdSupervisor:()=>o0,taskSchedulerSupervisor:()=>c0});import{homedir as FE,userInfo as UE}from"node:os";function qE(t=process.platform){switch(t){case"darwin":return s0;case"linux":return o0;case"win32":return c0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function HE(){let t=ne();return{nodeBin:process.execPath,entry:Xc(t),logFile:t.logFile,homeDir:FE(),userName:UE().username}}var Wx=rt(()=>{"use strict";Fe();e0();Ux();qx();jx()});te();wn();var H0=H("acp-installer-warmup"),pp=["claude-code","codex"];async function j0(t={}){let e=t.ensure??$n,s=(await Promise.allSettled(pp.map(async a=>{let c=await e(a);H0.info("acp wrapper warmup ok",{framework:a,path:c})}))).filter(a=>a.status==="rejected");s.length>0&&H0.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:s.length,reasons:s.map(a=>a.reason instanceof Error?a.reason.message:String(a.reason))})}Jt();te();import{readdir as Cp}from"node:fs/promises";import{mkdir as V0,writeFile as J0}from"node:fs/promises";import{join as Qo}from"node:path";var Ip={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Vn(t,e,r){await V0(t,{recursive:!0});let s=Ip[e],a=Qo(t,s);return await J0(a,r??"","utf8"),a}async function Y0(t){let e=Qo(t,".claude");await V0(e,{recursive:!0});let r=Qo(e,"settings.local.json"),s=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await J0(r,s,"utf8"),r}var Je=H("agent-detail-sync"),Ap=6e4,Tp=5*6e4,$i=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,s;try{s=await Cp(r)}catch(a){Je.info("agents dir not found, skip detail sync",{root:r,err:String(a)});return}Je.info("starting detail sync",{reason:e,count:s.length}),await Promise.allSettled(s.map(async a=>{let c=await je(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Je.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(f){Je.warn("detail sync failed for agent, skipping",{agentId:a,err:String(f)})}}})),Je.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){Je.info("retrying pending detail syncs",{count:r.length});for(let s of r)try{await this.syncOne(s)}catch(a){Je.debug("detail sync retry still failing, will try again",{agentId:s,err:String(a)})}}}async syncOne(e,r){let s=r??await je(e,this.opts.paths);if(!s){Je.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){Je.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let x=this.retryQueue.get(e),p=x?Math.min(x.currentDelay*2,Tp):Ap;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(a.agentId&&a.agentId!==e){Je.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&&Je.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Je.debug("detail sync: no diff",{agentId:e});return}await Ve(s,this.opts.paths),Je.info("detail sync: config updated",{agentId:e,identityChanged:f,agentName:s.agentName}),f&&(await Vn(s.workspace,s.framework,s.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var hl=mt(Dd(),1);import{lstat as uc,mkdir as xc,readFile as fl,readdir as ew,rm as tw,stat as nw,writeFile as hc}from"node:fs/promises";import{dirname as rw,join as Ct,normalize as iw,relative as mc,resolve as pc,sep as ll}from"node:path";import{Readable as ul}from"node:stream";import{pipeline as xl}from"node:stream/promises";import Jp from"events";import Ze from"fs";import{EventEmitter as Xa}from"node:events";import uf from"node:stream";import{StringDecoder as Yp}from"node:string_decoder";import pf from"node:path";import ar from"node:fs";import{dirname as fg,parse as lg}from"path";import{EventEmitter as _g}from"events";import Pa from"assert";import{Buffer as Rn}from"buffer";import*as Nd from"zlib";import yg from"zlib";import{posix as er}from"node:path";import{basename as $g}from"node:path";import Is from"fs";import bt from"fs";import Hd from"path";import{win32 as im}from"node:path";import Vd from"path";import Df from"node:fs";import bm from"node:assert";import{randomBytes as kf}from"node:crypto";import X from"node:fs";import Ae from"node:path";import Lf from"fs";import Os from"node:fs";import ri from"node:path";import Qe from"node:fs";import Tm from"node:fs/promises";import Ts from"node:path";import{join as jf}from"node:path";import Xe from"node:fs";import Kf from"node:path";var Zp=Object.defineProperty,Vp=(t,e)=>{for(var r in e)Zp(t,r,{get:e[r],enumerable:!0})},kd=typeof process=="object"&&process?process:{stdout:null,stderr:null},Xp=t=>!!t&&typeof t=="object"&&(t instanceof Ln||t instanceof uf||Qp(t)||eg(t)),Qp=t=>!!t&&typeof t=="object"&&t instanceof Xa&&typeof t.pipe=="function"&&t.pipe!==uf.Writable.prototype.pipe,eg=t=>!!t&&typeof t=="object"&&t instanceof Xa&&typeof t.write=="function"&&typeof t.end=="function",Pt=Symbol("EOF"),Ot=Symbol("maybeEmitEnd"),Xt=Symbol("emittedEnd"),Xi=Symbol("emittingEnd"),Ur=Symbol("emittedError"),Qi=Symbol("closed"),Ld=Symbol("read"),es=Symbol("flush"),Pd=Symbol("flushChunk"),lt=Symbol("encoding"),Qn=Symbol("decoder"),De=Symbol("flowing"),qr=Symbol("paused"),ir=Symbol("resume"),ke=Symbol("buffer"),Ke=Symbol("pipes"),Le=Symbol("bufferLength"),sa=Symbol("bufferPush"),ts=Symbol("bufferShift"),Ge=Symbol("objectMode"),ye=Symbol("destroyed"),oa=Symbol("error"),aa=Symbol("emitData"),Od=Symbol("emitEnd"),ca=Symbol("emitEnd2"),wt=Symbol("async"),da=Symbol("abort"),ns=Symbol("aborted"),Hr=Symbol("signal"),yn=Symbol("dataListeners"),Ye=Symbol("discarded"),jr=t=>Promise.resolve().then(t),tg=t=>t(),ng=t=>t==="end"||t==="finish"||t==="prefinish",rg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,ig=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),xf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[ir](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},sg=class extends xf{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)}},og=t=>!!t.objectMode,ag=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Ln=class extends Xa{[De]=!1;[qr]=!1;[Ke]=[];[ke]=[];[Ge];[lt];[wt];[Qn];[Pt]=!1;[Xt]=!1;[Xi]=!1;[Qi]=!1;[Ur]=null;[Le]=0;[ye]=!1;[Hr];[ns]=!1;[yn]=0;[Ye]=!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");og(e)?(this[Ge]=!0,this[lt]=null):ag(e)?(this[lt]=e.encoding,this[Ge]=!1):(this[Ge]=!1,this[lt]=null),this[wt]=!!e.async,this[Qn]=this[lt]?new Yp(this[lt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ke]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ke]});let{signal:r}=e;r&&(this[Hr]=r,r.aborted?this[da]():r.addEventListener("abort",()=>this[da]()))}get bufferLength(){return this[Le]}get encoding(){return this[lt]}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[Ge]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[wt]}set async(t){this[wt]=this[wt]||!!t}[da](){this[ns]=!0,this.emit("abort",this[Hr]?.reason),this.destroy(this[Hr]?.reason)}get aborted(){return this[ns]}set aborted(t){}write(t,e,r){if(this[ns])return!1;if(this[Pt])throw new Error("write after end");if(this[ye])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[wt]?jr:tg;if(!this[Ge]&&!Buffer.isBuffer(t)){if(ig(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(rg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ge]?(this[De]&&this[Le]!==0&&this[es](!0),this[De]?this.emit("data",t):this[sa](t),this[Le]!==0&&this.emit("readable"),r&&s(r),this[De]):t.length?(typeof t=="string"&&!(e===this[lt]&&!this[Qn]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[lt]&&(t=this[Qn].write(t)),this[De]&&this[Le]!==0&&this[es](!0),this[De]?this.emit("data",t):this[sa](t),this[Le]!==0&&this.emit("readable"),r&&s(r),this[De]):(this[Le]!==0&&this.emit("readable"),r&&s(r),this[De])}read(t){if(this[ye])return null;if(this[Ye]=!1,this[Le]===0||t===0||t&&t>this[Le])return this[Ot](),null;this[Ge]&&(t=null),this[ke].length>1&&!this[Ge]&&(this[ke]=[this[lt]?this[ke].join(""):Buffer.concat(this[ke],this[Le])]);let e=this[Ld](t||null,this[ke][0]);return this[Ot](),e}[Ld](t,e){if(this[Ge])this[ts]();else{let r=e;t===r.length||t===null?this[ts]():typeof r=="string"?(this[ke][0]=r.slice(t),e=r.slice(0,t),this[Le]-=t):(this[ke][0]=r.subarray(t),e=r.subarray(0,t),this[Le]-=t)}return this.emit("data",e),!this[ke].length&&!this[Pt]&&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[Pt]=!0,this.writable=!1,(this[De]||!this[qr])&&this[Ot](),this}[ir](){this[ye]||(!this[yn]&&!this[Ke].length&&(this[Ye]=!0),this[qr]=!1,this[De]=!0,this.emit("resume"),this[ke].length?this[es]():this[Pt]?this[Ot]():this.emit("drain"))}resume(){return this[ir]()}pause(){this[De]=!1,this[qr]=!0,this[Ye]=!1}get destroyed(){return this[ye]}get flowing(){return this[De]}get paused(){return this[qr]}[sa](t){this[Ge]?this[Le]+=1:this[Le]+=t.length,this[ke].push(t)}[ts](){return this[Ge]?this[Le]-=1:this[Le]-=this[ke][0].length,this[ke].shift()}[es](t=!1){do;while(this[Pd](this[ts]())&&this[ke].length);!t&&!this[ke].length&&!this[Pt]&&this.emit("drain")}[Pd](t){return this.emit("data",t),this[De]}pipe(t,e){if(this[ye])return t;this[Ye]=!1;let r=this[Xt];return e=e||{},t===kd.stdout||t===kd.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ke].push(e.proxyErrors?new sg(this,t,e):new xf(this,t,e)),this[wt]?jr(()=>this[ir]()):this[ir]()),t}unpipe(t){let e=this[Ke].find(r=>r.dest===t);e&&(this[Ke].length===1?(this[De]&&this[yn]===0&&(this[De]=!1),this[Ke]=[]):this[Ke].splice(this[Ke].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[Ye]=!1,this[yn]++,!this[Ke].length&&!this[De]&&this[ir]();else if(t==="readable"&&this[Le]!==0)super.emit("readable");else if(ng(t)&&this[Xt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ur]){let s=e;this[wt]?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[yn]=this.listeners("data").length,this[yn]===0&&!this[Ye]&&!this[Ke].length&&(this[De]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[yn]=0,!this[Ye]&&!this[Ke].length&&(this[De]=!1)),e}get emittedEnd(){return this[Xt]}[Ot](){!this[Xi]&&!this[Xt]&&!this[ye]&&this[ke].length===0&&this[Pt]&&(this[Xi]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Qi]&&this.emit("close"),this[Xi]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==ye&&this[ye])return!1;if(t==="data")return!this[Ge]&&!r?!1:this[wt]?(jr(()=>this[aa](r)),!0):this[aa](r);if(t==="end")return this[Od]();if(t==="close"){if(this[Qi]=!0,!this[Xt]&&!this[ye])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[Ur]=r,super.emit(oa,r);let a=!this[Hr]||this.listeners("error").length?super.emit("error",r):!1;return this[Ot](),a}else if(t==="resume"){let a=super.emit("resume");return this[Ot](),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[Ot](),s}[aa](t){for(let r of this[Ke])r.dest.write(t)===!1&&this.pause();let e=this[Ye]?!1:super.emit("data",t);return this[Ot](),e}[Od](){return this[Xt]?!1:(this[Xt]=!0,this.readable=!1,this[wt]?(jr(()=>this[ca]()),!0):this[ca]())}[ca](){if(this[Qn]){let e=this[Qn].end();if(e){for(let r of this[Ke])r.dest.write(e);this[Ye]||super.emit("data",e)}}for(let e of this[Ke])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Ge]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Ge]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Ge])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[lt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ye,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Ye]=!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[Pt])return e();let s,a,c=p=>{this.off("data",f),this.off("end",u),this.off(ye,x),e(),a(p)},f=p=>{this.off("error",c),this.off("end",u),this.off(ye,x),this.pause(),s({value:p,done:!!this[Pt]})},u=()=>{this.off("error",c),this.off("data",f),this.off(ye,x),e(),s({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,_)=>{a=_,s=p,this.once(ye,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[Ye]=!1;let t=!1,e=()=>(this.pause(),this.off(oa,e),this.off(ye,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(oa,e),this.once(ye,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[ye])return t?this.emit("error",t):this.emit(ye),this;this[ye]=!0,this[Ye]=!0,this[ke].length=0,this[Le]=0;let e=this;return typeof e.close=="function"&&!this[Qi]&&e.close(),t?this.emit("error",t):this.emit(ye),this}static get isStream(){return Xp}},cg=Ze.writev,dn=Symbol("_autoClose"),pt=Symbol("_close"),Gr=Symbol("_ended"),se=Symbol("_fd"),fa=Symbol("_finished"),zt=Symbol("_flags"),la=Symbol("_flush"),ka=Symbol("_handleChunk"),La=Symbol("_makeBuf"),ti=Symbol("_mode"),rs=Symbol("_needDrain"),dr=Symbol("_onerror"),fr=Symbol("_onopen"),ua=Symbol("_onread"),sr=Symbol("_onwrite"),fn=Symbol("_open"),ht=Symbol("_path"),rn=Symbol("_pos"),_t=Symbol("_queue"),or=Symbol("_read"),xa=Symbol("_readSize"),Bt=Symbol("_reading"),Wr=Symbol("_remain"),ha=Symbol("_size"),xs=Symbol("_write"),bn=Symbol("_writing"),hs=Symbol("_defaultFlag"),Tn=Symbol("_errored"),Qa=class extends Ln{[Tn]=!1;[se];[ht];[xa];[Bt]=!1;[ha];[Wr];[dn];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[Tn]=!1,this[se]=typeof e.fd=="number"?e.fd:void 0,this[ht]=t,this[xa]=e.readSize||16*1024*1024,this[Bt]=!1,this[ha]=typeof e.size=="number"?e.size:1/0,this[Wr]=this[ha],this[dn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[se]=="number"?this[or]():this[fn]()}get fd(){return this[se]}get path(){return this[ht]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[fn](){Ze.open(this[ht],"r",(t,e)=>this[fr](t,e))}[fr](t,e){t?this[dr](t):(this[se]=e,this.emit("open",e),this[or]())}[La](){return Buffer.allocUnsafe(Math.min(this[xa],this[Wr]))}[or](){if(!this[Bt]){this[Bt]=!0;let t=this[La]();if(t.length===0)return process.nextTick(()=>this[ua](null,0,t));Ze.read(this[se],t,0,t.length,null,(e,r,s)=>this[ua](e,r,s))}}[ua](t,e,r){this[Bt]=!1,t?this[dr](t):this[ka](e,r)&&this[or]()}[pt](){if(this[dn]&&typeof this[se]=="number"){let t=this[se];this[se]=void 0,Ze.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[dr](t){this[Bt]=!0,this[pt](),this.emit("error",t)}[ka](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[pt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[se]=="number"&&this[or](),!1;case"error":return this[Tn]?!1:(this[Tn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},dg=class extends Qa{[fn](){let t=!0;try{this[fr](null,Ze.openSync(this[ht],"r")),t=!1}finally{t&&this[pt]()}}[or](){let t=!0;try{if(!this[Bt]){this[Bt]=!0;do{let e=this[La](),r=e.length===0?0:Ze.readSync(this[se],e,0,e.length,null);if(!this[ka](r,e))break}while(!0);this[Bt]=!1}t=!1}finally{t&&this[pt]()}}[pt](){if(this[dn]&&typeof this[se]=="number"){let t=this[se];this[se]=void 0,Ze.closeSync(t),this.emit("close")}}},Rs=class extends Jp{readable=!1;writable=!0;[Tn]=!1;[bn]=!1;[Gr]=!1;[_t]=[];[rs]=!1;[ht];[ti];[dn];[se];[hs];[zt];[fa]=!1;[rn];constructor(t,e){e=e||{},super(e),this[ht]=t,this[se]=typeof e.fd=="number"?e.fd:void 0,this[ti]=e.mode===void 0?438:e.mode,this[rn]=typeof e.start=="number"?e.start:void 0,this[dn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[rn]!==void 0?"r+":"w";this[hs]=e.flags===void 0,this[zt]=e.flags===void 0?r:e.flags,this[se]===void 0&&this[fn]()}emit(t,...e){if(t==="error"){if(this[Tn])return!1;this[Tn]=!0}return super.emit(t,...e)}get fd(){return this[se]}get path(){return this[ht]}[dr](t){this[pt](),this[bn]=!0,this.emit("error",t)}[fn](){Ze.open(this[ht],this[zt],this[ti],(t,e)=>this[fr](t,e))}[fr](t,e){this[hs]&&this[zt]==="r+"&&t&&t.code==="ENOENT"?(this[zt]="w",this[fn]()):t?this[dr](t):(this[se]=e,this.emit("open",e),this[bn]||this[la]())}end(t,e){return t&&this.write(t,e),this[Gr]=!0,!this[bn]&&!this[_t].length&&typeof this[se]=="number"&&this[sr](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[se]===void 0||this[bn]||this[_t].length?(this[_t].push(t),this[rs]=!0,!1):(this[bn]=!0,this[xs](t),!0)}[xs](t){Ze.write(this[se],t,0,t.length,this[rn],(e,r)=>this[sr](e,r))}[sr](t,e){t?this[dr](t):(this[rn]!==void 0&&typeof e=="number"&&(this[rn]+=e),this[_t].length?this[la]():(this[bn]=!1,this[Gr]&&!this[fa]?(this[fa]=!0,this[pt](),this.emit("finish")):this[rs]&&(this[rs]=!1,this.emit("drain"))))}[la](){if(this[_t].length===0)this[Gr]&&this[sr](null,0);else if(this[_t].length===1)this[xs](this[_t].pop());else{let t=this[_t];this[_t]=[],cg(this[se],t,this[rn],(e,r)=>this[sr](e,r))}}[pt](){if(this[dn]&&typeof this[se]=="number"){let t=this[se];this[se]=void 0,Ze.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},hf=class extends Rs{[fn](){let t;if(this[hs]&&this[zt]==="r+")try{t=Ze.openSync(this[ht],this[zt],this[ti])}catch(e){if(e?.code==="ENOENT")return this[zt]="w",this[fn]();throw e}else t=Ze.openSync(this[ht],this[zt],this[ti]);this[fr](null,t)}[pt](){if(this[dn]&&typeof this[se]=="number"){let t=this[se];this[se]=void 0,Ze.closeSync(t),this.emit("close")}}[xs](t){let e=!0;try{this[sr](null,Ze.writeSync(this[se],t,0,t.length,this[rn])),e=!1}finally{if(e)try{this[pt]()}catch{}}}},ug=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"]]),xg=t=>!!t.sync&&!!t.file,hg=t=>!t.sync&&!!t.file,pg=t=>!!t.sync&&!t.file,gg=t=>!t.sync&&!t.file,mg=t=>!!t.file,wg=t=>ug.get(t)||t,ec=(t={})=>{if(!t)return{};let e={};for(let[r,s]of Object.entries(t)){let a=wg(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=ec(c);if(a?.(x,f),xg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,f)}else if(hg(x)){let p=e(x,f);return u?p.then(()=>u(),u):p}else if(pg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,f)}else if(gg(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}),bg=yg.constants||{ZLIB_VERNUM:4736},vt=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},bg)),Eg=Rn.concat,Md=Object.getOwnPropertyDescriptor(Rn,"concat"),vg=t=>t,pa=Md?.writable===!0||Md?.set!==void 0?t=>{Rn.concat=t?vg:Eg}:t=>{},Dn=Symbol("_superWrite"),is=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"}},ga=Symbol("flushFlag"),tc=class extends Ln{#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 Nd[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Nd[e](t)}catch(r){throw new is(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 is(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return Pa(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Rn.alloc(0),{[ga]: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}[Dn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Rn.from(t,e)),this.#e)return;Pa(this.#t,"zlib binding closed");let s=this.#t._handle,a=s.close;s.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},pa(!0);let f;try{let x=typeof t[ga]=="number"?t[ga]:this.#r;f=this.#t._processChunk(t,x),pa(!1)}catch(x){pa(!1),this.#o(new is(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 is(x,this.write)));let u;if(f)if(Array.isArray(f)&&f.length>0){let x=f[0];u=this[Dn](Rn.from(x));for(let p=1;p<f.length;p++)u=this[Dn](f[p])}else u=this[Dn](Rn.from(f));return r&&r(),u}},gf=class extends tc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||vt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||vt.Z_FINISH,t.fullFlushFlag=vt.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(vt.Z_SYNC_FLUSH),Pa(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)}}}},Sg=class extends gf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Dn](t){return this.#e?(this.#e=!1,t[9]=255,super[Dn](t)):super[Dn](t)}},Ig=class extends gf{constructor(t){super(t,"Unzip")}},mf=class extends tc{constructor(t,e){t=t||{},t.flush=t.flush||vt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||vt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=vt.BROTLI_OPERATION_FLUSH,super(t,e)}},Cg=class extends mf{constructor(t){super(t,"BrotliCompress")}},Ag=class extends mf{constructor(t){super(t,"BrotliDecompress")}},wf=class extends tc{constructor(t,e){t=t||{},t.flush=t.flush||vt.ZSTD_e_continue,t.finishFlush=t.finishFlush||vt.ZSTD_e_end,t.fullFlushFlag=vt.ZSTD_e_flush,super(t,e)}},Tg=class extends wf{constructor(t){super(t,"ZstdCompress")}},Rg=class extends wf{constructor(t){super(t,"ZstdDecompress")}},Dg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Lg(t,e):kg(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},kg=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Lg=(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]=_f(a):a===0?e[s-1]=0:(r=!0,e[s-1]=yf(a))}},Pg=t=>{let e=t[0],r=e===128?Ng(t.subarray(1,t.length)):e===255?Og(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},Og=t=>{for(var e=t.length,r=0,s=!1,a=e-1;a>-1;a--){var c=Number(t[a]),f;s?f=_f(c):c===0?f=c:(s=!0,f=yf(c)),f!==0&&(r-=f*Math.pow(256,e-a-1))}return r},Ng=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},_f=t=>(255^t)&255,yf=t=>(255^t)+1&255,Mg={};Vp(Mg,{code:()=>nc,isCode:()=>ps,isName:()=>Bg,name:()=>Ds});var ps=t=>Ds.has(t),Bg=t=>nc.has(t),Ds=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"]]),nc=new Map(Array.from(Ds).map(t=>[t[1],t[0]])),kn=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??En(t,e,100),this.mode=r?.mode??s?.mode??sn(t,e+100,8),this.uid=r?.uid??s?.uid??sn(t,e+108,8),this.gid=r?.gid??s?.gid??sn(t,e+116,8),this.size=r?.size??s?.size??sn(t,e+124,12),this.mtime=r?.mtime??s?.mtime??ma(t,e+136,12),this.cksum=sn(t,e+148,12),s&&this.#n(s,!0),r&&this.#n(r);let a=En(t,e+156,1);if(ps(a)&&(this.#e=a||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=En(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??s?.uname??En(t,e+265,32),this.gname=r?.gname??s?.gname??En(t,e+297,32),this.devmaj=r?.devmaj??s?.devmaj??sn(t,e+329,8)??0,this.devmin=r?.devmin??s?.devmin??sn(t,e+337,8)??0,t[e+475]!==0){let f=En(t,e+345,155);this.path=f+"/"+this.path}else{let f=En(t,e+345,130);f&&(this.path=f+"/"+this.path),this.atime=r?.atime??s?.atime??ma(t,e+476,12),this.ctime=r?.ctime??s?.ctime??ma(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=zg(this.path||"",r),a=s[0],c=s[1];this.needPax=!!s[2],this.needPax=vn(t,e,100,a)||this.needPax,this.needPax=on(t,e+100,8,this.mode)||this.needPax,this.needPax=on(t,e+108,8,this.uid)||this.needPax,this.needPax=on(t,e+116,8,this.gid)||this.needPax,this.needPax=on(t,e+124,12,this.size)||this.needPax,this.needPax=wa(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=vn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=vn(t,e+265,32,this.uname)||this.needPax,this.needPax=vn(t,e+297,32,this.gname)||this.needPax,this.needPax=on(t,e+329,8,this.devmaj)||this.needPax,this.needPax=on(t,e+337,8,this.devmin)||this.needPax,this.needPax=vn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=vn(t,e+345,155,c)||this.needPax:(this.needPax=vn(t,e+345,130,c)||this.needPax,this.needPax=wa(t,e+476,12,this.atime)||this.needPax,this.needPax=wa(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,on(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Ds.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(nc.get(t));if(ps(e)||e==="Unsupported")this.#e=e;else if(ps(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},zg=(t,e)=>{let r=t,s="",a,c=er.parse(t).root||".";if(Buffer.byteLength(r)<100)a=[r,s,!1];else{s=er.dirname(r),r=er.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=er.join(er.basename(s),r),s=er.dirname(s));while(s!==c&&a===void 0);a||(a=[t.slice(0,99),"",!0])}return a},En=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),ma=(t,e,r)=>Fg(sn(t,e,r)),Fg=t=>t===void 0?void 0:new Date(t*1e3),sn=(t,e,r)=>Number(t[e])&128?Pg(t.subarray(e,e+r)):qg(t,e,r),Ug=t=>isNaN(t)?void 0:t,qg=(t,e,r)=>Ug(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Hg={12:8589934591,8:2097151},on=(t,e,r,s)=>s===void 0?!1:s>Hg[r]||s<0?(Dg(s,t.subarray(e,e+r)),!0):(jg(t,e,r,s),!1),jg=(t,e,r,s)=>t.write(Gg(s,r),e,r,"ascii"),Gg=(t,e)=>Wg(Math.floor(t).toString(8),e),Wg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",wa=(t,e,r,s)=>s===void 0?!1:on(t,e,r,s.getTime()/1e3),Kg=new Array(156).join("\0"),vn=(t,e,r,s)=>s===void 0?!1:(t.write(s+Kg,e,r,"utf8"),s.length!==Buffer.byteLength(s)||s.length>r),Ss=class bf{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 kn({path:("PaxHeader/"+$g(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+`
|
|
81
|
+
`,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 bf(Zg(Vg(e),r),s)}},Zg=(t,e)=>e?Object.assign({},e,t):t,Vg=t=>t.replace(/\n$/,"").split(`
|
|
82
|
+
`).reduce(Jg,Object.create(null)),Jg=(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,V=Yg!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Ef=class extends Ln{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=V(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?V(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=V(t.path)),t.linkpath&&(t.linkpath=V(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e))))}},ks=(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))},Xg=1024*1024,Oa=Buffer.from([31,139]),Na=Buffer.from([40,181,47,253]),Qg=Math.max(Oa.length,Na.length),it=Symbol("state"),Sn=Symbol("writeEntry"),Nt=Symbol("readEntry"),_a=Symbol("nextEntry"),Bd=Symbol("processEntry"),yt=Symbol("extendedHeader"),Kr=Symbol("globalExtendedHeader"),Qt=Symbol("meta"),zd=Symbol("emitMeta"),de=Symbol("buffer"),Mt=Symbol("queue"),en=Symbol("ended"),ya=Symbol("emittedEnd"),In=Symbol("emit"),ve=Symbol("unzip"),ss=Symbol("consumeChunk"),os=Symbol("consumeChunkSub"),ba=Symbol("consumeBody"),Fd=Symbol("consumeMeta"),Ud=Symbol("consumeHeader"),$r=Symbol("consuming"),Ea=Symbol("bufferConcat"),as=Symbol("maybeEnd"),tr=Symbol("writing"),tn=Symbol("aborted"),cs=Symbol("onDone"),Cn=Symbol("sawValidEntry"),ds=Symbol("sawNullBlock"),fs=Symbol("sawEOF"),qd=Symbol("closeStream"),em=()=>!0,di=class extends _g{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Mt]=[];[de];[Nt];[Sn];[it]="begin";[Qt]="";[yt];[Kr];[en]=!1;[ve];[tn]=!1;[Cn];[ds]=!1;[fs]=!1;[tr]=!1;[$r]=!1;[ya]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(cs,()=>{(this[it]==="begin"||this[Cn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(cs,t.ondone):this.on(cs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Xg,this.filter=typeof t.filter=="function"?t.filter:em;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[qd]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){ks(this,t,e,r)}[Ud](t,e){this[Cn]===void 0&&(this[Cn]=!1);let r;try{r=new kn(t,e,this[yt],this[Kr])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(r.nullBlock)this[ds]?(this[fs]=!0,this[it]==="begin"&&(this[it]="header"),this[In]("eof")):(this[ds]=!0,this[In]("nullBlock"));else if(this[ds]=!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[Sn]=new Ef(r,this[yt],this[Kr]);if(!this[Cn])if(a.remain){let c=()=>{a.invalid||(this[Cn]=!0)};a.on("end",c)}else this[Cn]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[In]("ignoredEntry",a),this[it]="ignore",a.resume()):a.size>0&&(this[Qt]="",a.on("data",c=>this[Qt]+=c),this[it]="meta"):(this[yt]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[In]("ignoredEntry",a),this[it]=a.remain?"ignore":"header",a.resume()):(a.remain?this[it]="body":(this[it]="header",a.end()),this[Nt]?this[Mt].push(a):(this[Mt].push(a),this[_a]())))}}}[qd](){queueMicrotask(()=>this.emit("close"))}[Bd](t){let e=!0;if(!t)this[Nt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...s]=t;this.emit(r,...s)}else this[Nt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[_a]()),e=!1);return e}[_a](){do;while(this[Bd](this[Mt].shift()));if(this[Mt].length===0){let t=this[Nt];!t||t.flowing||t.size===t.remain?this[tr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[ba](t,e){let r=this[Sn];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[it]="header",this[Sn]=void 0,r.end()),a.length}[Fd](t,e){let r=this[Sn],s=this[ba](t,e);return!this[Sn]&&r&&this[zd](r),s}[In](t,e,r){this[Mt].length===0&&!this[Nt]?this.emit(t,e,r):this[Mt].push([t,e,r])}[zd](t){switch(this[In]("meta",this[Qt]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[yt]=Ss.parse(this[Qt],this[yt],!1);break;case"GlobalExtendedHeader":this[Kr]=Ss.parse(this[Qt],this[Kr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[yt]??Object.create(null);this[yt]=e,e.path=this[Qt].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[yt]||Object.create(null);this[yt]=e,e.linkpath=this[Qt].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[tn]=!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[tn])return r?.(),!1;if((this[ve]===void 0||this.brotli===void 0&&this[ve]===!1)&&t){if(this[de]&&(t=Buffer.concat([this[de],t]),this[de]=void 0),t.length<Qg)return this[de]=t,r?.(),!0;for(let f=0;this[ve]===void 0&&f<Oa.length;f++)t[f]!==Oa[f]&&(this[ve]=!1);let a=!1;if(this[ve]===!1&&this.zstd!==!1){a=!0;for(let f=0;f<Na.length;f++)if(t[f]!==Na[f]){a=!1;break}}let c=this.brotli===void 0&&!a;if(this[ve]===!1&&c)if(t.length<512)if(this[en])this.brotli=!0;else return this[de]=t,r?.(),!0;else try{new kn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ve]===void 0||this[ve]===!1&&(this.brotli||a)){let f=this[en];this[en]=!1,this[ve]=this[ve]===void 0?new Ig({}):a?new Rg({}):new Ag({}),this[ve].on("data",x=>this[ss](x)),this[ve].on("error",x=>this.abort(x)),this[ve].on("end",()=>{this[en]=!0,this[ss]()}),this[tr]=!0;let u=!!this[ve][f?"end":"write"](t);return this[tr]=!1,r?.(),u}}this[tr]=!0,this[ve]?this[ve].write(t):this[ss](t),this[tr]=!1;let s=this[Mt].length>0?!1:this[Nt]?this[Nt].flowing:!0;return!s&&this[Mt].length===0&&this[Nt]?.once("drain",()=>this.emit("drain")),r?.(),s}[Ea](t){t&&!this[tn]&&(this[de]=this[de]?Buffer.concat([this[de],t]):t)}[as](){if(this[en]&&!this[ya]&&!this[tn]&&!this[$r]){this[ya]=!0;let t=this[Sn];if(t&&t.blockRemain){let e=this[de]?this[de].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[de]&&t.write(this[de]),t.end()}this[In](cs)}}[ss](t){if(this[$r]&&t)this[Ea](t);else if(!t&&!this[de])this[as]();else if(t){if(this[$r]=!0,this[de]){this[Ea](t);let e=this[de];this[de]=void 0,this[os](e)}else this[os](t);for(;this[de]&&this[de]?.length>=512&&!this[tn]&&!this[fs];){let e=this[de];this[de]=void 0,this[os](e)}this[$r]=!1}(!this[de]||this[en])&&this[as]()}[os](t){let e=0,r=t.length;for(;e+512<=r&&!this[tn]&&!this[fs];)switch(this[it]){case"begin":case"header":this[Ud](t,e),e+=512;break;case"ignore":case"body":e+=this[ba](t,e);break;case"meta":e+=this[Fd](t,e);break;default:throw new Error("invalid state: "+this[it])}e<r&&(this[de]=this[de]?Buffer.concat([t.subarray(e),this[de]]):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[tn]||(this[ve]?(t&&this[ve].write(t),this[ve].end()):(this[en]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[as]())),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)},tm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},vf=(t,e)=>{let r=new Map(e.map(c=>[ni(c),!0])),s=t.filter,a=(c,f="")=>{let u=f||lg(c).root||".",x;if(c===u)x=!1;else{let p=r.get(c);x=p!==void 0?p:a(fg(c),u)}return r.set(c,x),x};t.filter=s?(c,f)=>s(c,f)&&a(ni(c)):c=>a(ni(c))},nm=t=>{let e=new di(t),r=t.file,s;try{s=ar.openSync(r,"r");let a=ar.fstatSync(s),c=t.maxReadSize||16*1024*1024;if(a.size<c){let f=Buffer.allocUnsafe(a.size),u=ar.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=ar.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{ar.closeSync(s)}catch{}}},rm=(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),ar.stat(a,(u,x)=>{if(u)f(u);else{let p=new Qa(a,{readSize:s,size:x.size});p.on("error",f),p.pipe(r)}})})},lr=fi(nm,rm,t=>new di(t),t=>new di(t),(t,e)=>{e?.length&&vf(t,e),t.noResume||tm(t)}),Sf=(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:sm,parse:jd}=im,rc=t=>{let e="",r=jd(t);for(;sm(t)||r.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(s.length),e+=s,r=jd(t)}return[e,t]},Ls=["|","<",">","?",":"],ic=Ls.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),om=new Map(Ls.map((t,e)=>[t,ic[e]])),am=new Map(ic.map((t,e)=>[t,Ls[e]])),Gd=t=>Ls.reduce((e,r)=>e.split(r).join(om.get(r)),t),cm=t=>ic.reduce((e,r)=>e.split(r).join(am.get(r)),t),If=(t,e)=>e?(t=V(t).replace(/^\.(\/|$)/,""),ni(e)+"/"+t):V(t),dm=16*1024*1024,Wd=Symbol("process"),Kd=Symbol("file"),$d=Symbol("directory"),Ma=Symbol("symlink"),Zd=Symbol("hardlink"),Zr=Symbol("header"),gs=Symbol("read"),Ba=Symbol("lstat"),ms=Symbol("onlstat"),za=Symbol("onread"),Fa=Symbol("onreadlink"),Ua=Symbol("openfile"),qa=Symbol("onopenfile"),an=Symbol("close"),Cs=Symbol("mode"),Ha=Symbol("awaitDrain"),va=Symbol("ondrain"),Et=Symbol("prefix"),Cf=class extends Ln{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=ec(e);super(),this.path=V(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||dm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=V(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?V(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]=rc(this.path);c&&typeof f=="string"&&(this.path=f,s=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=cm(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=V(r.absolute||Hd.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[ms](a):this[Ba]()}warn(t,e,r={}){return ks(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Ba](){bt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ms](e)})}[ms](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=um(t),this.emit("stat",t),this[Wd]()}[Wd](){switch(this.type){case"File":return this[Kd]();case"Directory":return this[$d]();case"SymbolicLink":return this[Ma]();default:return this.end()}}[Cs](t){return Sf(t,this.type==="Directory",this.portable)}[Et](t){return If(t,this.prefix)}[Zr](){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 kn({path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,mode:this[Cs](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 Ss({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[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](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)}[$d](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Zr](),this.end()}[Ma](){bt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Fa](e)})}[Fa](t){this.linkpath=V(t),this[Zr](),this.end()}[Zd](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=V(Hd.relative(this.cwd,t)),this.stat.size=0,this[Zr](),this.end()}[Kd](){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[Zd](e);this.linkCache.set(t,this.absolute)}if(this[Zr](),this.stat.size===0)return this.end();this[Ua]()}[Ua](){bt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[qa](e)})}[qa](t){if(this.fd=t,this.#e)return this[an]();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[gs]()}[gs](){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");bt.read(t,e,r,s,a,(c,f)=>{if(c)return this[an](()=>this.emit("error",c));this[za](f)})}[an](t=()=>{}){this.fd!==void 0&&bt.close(this.fd,t)}[za](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[an](()=>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[an](()=>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[va]():this[Ha](()=>this[va]())}[Ha](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)}[va](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[an](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[gs]()}},fm=class extends Cf{sync=!0;[Ba](){this[ms](bt.lstatSync(this.absolute))}[Ma](){this[Fa](bt.readlinkSync(this.absolute))}[Ua](){this[qa](bt.openSync(this.absolute,"r"))}[gs](){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=bt.readSync(e,r,s,a,c);this[za](f),t=!1}finally{if(t)try{this[an](()=>{})}catch{}}}[Ha](t){t()}[an](t=()=>{}){this.fd!==void 0&&bt.closeSync(this.fd),t()}},lm=class extends Ln{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 ks(this,t,e,r)}constructor(t,e={}){let r=ec(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=V(t.path),this.mode=t.mode!==void 0?this[Cs](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?V(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let a=!1;if(!this.preservePaths){let[f,u]=rc(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 kn({path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](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 Ss({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[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](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)}[Et](t){return If(t,this.prefix)}[Cs](t){return Sf(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}},um=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",xm=class cr{tail;head;length=0;static create(e=[]){return new cr(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++)pm(this,e[r]);return this.length}unshift(...e){for(var r=0,s=e.length;r<s;r++)gm(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 cr;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 cr;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 cr;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 cr;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=hm(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 hm(t,e,r){let s=e,a=e?e.next:t.head,c=new sc(r,s,a,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function pm(t,e){t.tail=new sc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function gm(t,e){t.head=new sc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var sc=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}},Jd=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),ws=Symbol("onStat"),Vr=Symbol("ended"),ut=Symbol("queue"),Jr=Symbol("queue"),nn=Symbol("current"),An=Symbol("process"),Yr=Symbol("processing"),ls=Symbol("processJob"),xt=Symbol("jobs"),Sa=Symbol("jobDone"),_s=Symbol("addFSEntry"),Xd=Symbol("addTarEntry"),ja=Symbol("stat"),Ga=Symbol("readdir"),ys=Symbol("onreaddir"),bs=Symbol("pipe"),Qd=Symbol("entry"),Ia=Symbol("entryOpt"),Es=Symbol("writeEntryClass"),Af=Symbol("write"),Ca=Symbol("ondrain"),Ps=class extends Ln{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Es];onWriteEntry;[ut];[Jr]=new Map;[xt]=0;[Yr]=!1;[Vr]=!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=V(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[Es]=Cf,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 Sg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Cg(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Tg(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[Ca]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ca]);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[ut]=new xm,this[xt]=0,this.jobs=Number(t.jobs)||4,this[Yr]=!1,this[Vr]=!1}[Af](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[Vr]=!0,this[An](),r&&r(),this}write(t){if(this[Vr])throw new Error("write after end");return t instanceof Ef?this[Xd](t):this[_s](t),this.flowing}[Xd](t){let e=V(Vd.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Jd(t.path,e);r.entry=new lm(t,this[Ia](r)),r.entry.on("end",()=>this[Sa](r)),this[xt]+=1,this[ut].push(r)}this[An]()}[_s](t){let e=V(Vd.resolve(this.cwd,t));this[ut].push(new Jd(t,e)),this[An]()}[ja](t){t.pending=!0,this[xt]+=1;let e=this.follow?"stat":"lstat";Is[e](t.absolute,(r,s)=>{t.pending=!1,this[xt]-=1,r?this.emit("error",r):this[ws](t,s)})}[ws](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[nn])this[ls](t);else{let r=`${e.dev}:${e.ino}`,s=this[Jr].get(r);s?s.push(t):this[Jr].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[An]()}[Ga](t){t.pending=!0,this[xt]+=1,Is.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[xt]-=1,e)return this.emit("error",e);this[ys](t,r)})}[ys](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[An]()}[An](){if(!this[Yr]){this[Yr]=!0;for(let t=this[ut].head;t&&this[xt]<this.jobs;t=t.next)if(this[ls](t.value),t.value.ignore){let e=t.next;this[ut].removeNode(t),t.next=e}this[Yr]=!1,this[Vr]&&this[ut].length===0&&this[xt]===0&&(this.zip?this.zip.end(Yd):(super.write(Yd),super.end()))}}get[nn](){return this[ut]&&this[ut].head&&this[ut].head.value}[Sa](t){this[ut].shift(),this[xt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,s=this[Jr].get(r);if(s){this[Jr].delete(r);for(let a of s)a.pending=!1,this[ls](a)}}this[An]()}[ls](t){if(t.pending&&t.pendingLink&&t===this[nn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[nn]&&!t.piped&&this[bs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[ws](t,e):this[ja](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[ys](t,e):this[Ga](t),!t.readdir)return}if(t.entry=this[Qd](t),!t.entry){t.ignore=!0;return}t===this[nn]&&!t.piped&&this[bs](t)}}}[Ia](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}}[Qd](t){this[xt]+=1;try{return new this[Es](t.path,this[Ia](t)).on("end",()=>this[Sa](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Ca](){this[nn]&&this[nn].entry&&this[nn].entry.resume()}[bs](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[_s](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={}){ks(this,t,e,r)}},oc=class extends Ps{sync=!0;constructor(t){super(t),this[Es]=fm}pause(){}resume(){}[ja](t){let e=this.follow?"statSync":"lstatSync";this[ws](t,Is[e](t.absolute))}[Ga](t){this[ys](t,Is.readdirSync(t.absolute))}[bs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[_s](c+s)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",s=>{r.write(s)}):e.on("data",s=>{super[Af](s)})}},mm=(t,e)=>{let r=new oc(t),s=new hf(t.file,{mode:t.mode||438});r.pipe(s),Tf(r,e)},wm=(t,e)=>{let r=new Ps(t),s=new Rs(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 Rf(r,e).catch(c=>r.emit("error",c)),a},Tf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?lr({file:pf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Rf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await lr({file:pf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(r);t.end()},_m=(t,e)=>{let r=new oc(t);return Tf(r,e),r},ym=(t,e)=>{let r=new Ps(t);return Rf(r,e).catch(s=>r.emit("error",s)),r},g2=fi(mm,wm,_m,ym,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Em=process.env.__FAKE_PLATFORM__||process.platform,Pf=Em==="win32",{O_CREAT:Of,O_NOFOLLOW:ef,O_TRUNC:Nf,O_WRONLY:Mf}=Lf.constants,Bf=Number(process.env.__FAKE_FS_O_FILENAME__)||Lf.constants.UV_FS_O_FILEMAP||0,vm=Pf&&!!Bf,Sm=512*1024,Im=Bf|Nf|Of|Mf,tf=!Pf&&typeof ef=="number"?ef|Nf|Of|Mf:null,zf=tf!==null?()=>tf:vm?t=>t<Sm?Im:"w":()=>"w",Wa=(t,e,r)=>{try{return Os.lchownSync(t,e,r)}catch(s){if(s?.code!=="ENOENT")throw s}},As=(t,e,r,s)=>{Os.lchown(t,e,r,a=>{s(a&&a?.code!=="ENOENT"?a:null)})},Cm=(t,e,r,s,a)=>{if(e.isDirectory())Ff(ri.resolve(t,e.name),r,s,c=>{if(c)return a(c);let f=ri.resolve(t,e.name);As(f,r,s,a)});else{let c=ri.resolve(t,e.name);As(c,r,s,a)}},Ff=(t,e,r,s)=>{Os.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 As(t,e,r,s);let f=c.length,u=null,x=p=>{if(!u){if(p)return s(u=p);if(--f===0)return As(t,e,r,s)}};for(let p of c)Cm(t,p,e,r,x)})},Am=(t,e,r,s)=>{e.isDirectory()&&Uf(ri.resolve(t,e.name),r,s),Wa(ri.resolve(t,e.name),r,s)},Uf=(t,e,r)=>{let s;try{s=Os.readdirSync(t,{withFileTypes:!0})}catch(a){let c=a;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Wa(t,e,r);throw c}for(let a of s)Am(t,a,e,r);return Wa(t,e,r)},qf=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"}},Ns=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"}},Rm=(t,e)=>{Qe.stat(t,(r,s)=>{(r||!s.isDirectory())&&(r=new qf(t,r?.code||"ENOTDIR")),e(r)})},Dm=(t,e,r)=>{t=V(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),p=e.preserve,_=e.unlink,E=V(e.cwd),C=(b,S)=>{b?r(b):S&&x?Ff(S,f,u,I=>C(I)):c?Qe.chmod(t,a,r):r()};if(t===E)return Rm(t,C);if(p)return Tm.mkdir(t,{mode:a,recursive:!0}).then(b=>C(null,b??void 0),C);let y=V(Ts.relative(E,t)).split("/");Ka(E,y,a,_,E,void 0,C)},Ka=(t,e,r,s,a,c,f)=>{if(e.length===0)return f(null,c);let u=e.shift(),x=V(Ts.resolve(t+"/"+u));Qe.mkdir(x,r,Hf(x,e,r,s,a,c,f))},Hf=(t,e,r,s,a,c,f)=>u=>{u?Qe.lstat(t,(x,p)=>{if(x)x.path=x.path&&V(x.path),f(x);else if(p.isDirectory())Ka(t,e,r,s,a,c,f);else if(s)Qe.unlink(t,_=>{if(_)return f(_);Qe.mkdir(t,r,Hf(t,e,r,s,a,c,f))});else{if(p.isSymbolicLink())return f(new Ns(t,t+"/"+e.join("/")));f(u)}}):(c=c||t,Ka(t,e,r,s,a,c,f))},km=t=>{let e=!1,r;try{e=Qe.statSync(t).isDirectory()}catch(s){r=s?.code}finally{if(!e)throw new qf(t,r??"ENOTDIR")}},Lm=(t,e)=>{t=V(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,p=e.unlink,_=V(e.cwd),E=b=>{b&&u&&Uf(b,c,f),a&&Qe.chmodSync(t,s)};if(t===_)return km(_),E();if(x)return E(Qe.mkdirSync(t,{mode:s,recursive:!0})??void 0);let C=V(Ts.relative(_,t)).split("/"),y;for(let b=C.shift(),S=_;b&&(S+="/"+b);b=C.shift()){S=V(Ts.resolve(S));try{Qe.mkdirSync(S,s),y=y||S}catch{let I=Qe.lstatSync(S);if(I.isDirectory())continue;if(p){Qe.unlinkSync(S),Qe.mkdirSync(S,s),y=y||S;continue}else if(I.isSymbolicLink())return new Ns(S,S+"/"+C.join("/"))}}return E(y)},Aa=Object.create(null),nf=1e4,nr=new Set,Pm=t=>{nr.has(t)?nr.delete(t):Aa[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),nr.add(t);let e=Aa[t],r=nr.size-nf;if(r>nf/10){for(let s of nr)if(nr.delete(s),delete Aa[s],--r<=0)break}return e},Om=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Nm=Om==="win32",Mm=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let s=e.at(-1);return s!==void 0&&(r=jf(s,r)),e.push(r||"/"),e},[]),Bm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Nm?["win32 parallelization disabled"]:t.map(s=>ni(jf(Pm(s))));let r=new Set(t.map(s=>Mm(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}},zm=()=>process.umask(),rf=Symbol("onEntry"),$a=Symbol("checkFs"),sf=Symbol("checkFs2"),Za=Symbol("isReusable"),st=Symbol("makeFs"),Va=Symbol("file"),Ja=Symbol("directory"),vs=Symbol("link"),of=Symbol("symlink"),af=Symbol("hardlink"),ei=Symbol("ensureNoSymlink"),cf=Symbol("unsupported"),df=Symbol("checkPath"),Ta=Symbol("stripAbsolutePath"),cn=Symbol("mkdir"),Pe=Symbol("onError"),us=Symbol("pending"),ff=Symbol("pend"),rr=Symbol("unpend"),Ra=Symbol("ended"),Da=Symbol("maybeClose"),Ya=Symbol("skip"),ii=Symbol("doChown"),si=Symbol("uid"),oi=Symbol("gid"),ai=Symbol("checkedCwd"),Fm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,ci=Fm==="win32",Um=1024,qm=(t,e)=>{if(!ci)return X.unlink(t,e);let r=t+".DELETE."+kf(16).toString("hex");X.rename(t,r,s=>{if(s)return e(s);X.unlink(r,e)})},Hm=t=>{if(!ci)return X.unlinkSync(t);let e=t+".DELETE."+kf(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},lf=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,ac=class extends di{[Ra]=!1;[ai]=!1;[us]=0;reservations=new Bm;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[Ra]=!0,this[Da]()},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:Um,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=V(Ae.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:zm():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[rf](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Da](){this[Ra]&&this[us]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ta](t,e){let r=t[e],{type:s}=t;if(!r||this.preservePaths)return!0;let[a,c]=rc(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=Ae.posix.dirname(t.path),x=Ae.posix.normalize(Ae.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}[df](t){let e=V(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let s=V(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[Ta](t,"path")||!this[Ta](t,"linkpath"))return!1;if(t.absolute=Ae.isAbsolute(t.path)?V(Ae.resolve(t.path)):V(Ae.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:V(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}=Ae.win32.parse(String(t.absolute));t.absolute=s+Gd(String(t.absolute).slice(s.length));let{root:a}=Ae.win32.parse(t.path);t.path=a+Gd(t.path.slice(a.length))}return!0}[rf](t){if(!this[df](t))return t.resume();switch(bm.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[$a](t);default:return this[cf](t)}}[Pe](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[rr](),e.resume())}[cn](t,e,r){Dm(V(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 lf(this.uid,t.uid,this.processUid)}[oi](t){return lf(this.gid,t.gid,this.processGid)}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new Rs(String(t.absolute),{flags:zf(t.size),mode:r,autoClose:!1});s.on("error",u=>{s.fd&&X.close(s.fd,()=>{}),s.write=()=>!0,this[Pe](u,t),e()});let a=1,c=u=>{if(u){s.fd&&X.close(s.fd,()=>{}),this[Pe](u,t),e();return}--a===0&&s.fd!==void 0&&X.close(s.fd,x=>{x?this[Pe](x,t):this[rr](),e()})};s.on("finish",()=>{let u=String(t.absolute),x=s.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){a++;let p=t.atime||new Date,_=t.mtime;X.futimes(x,p,_,E=>E?X.utimes(u,p,_,C=>c(C&&E)):c())}if(typeof x=="number"&&this[ii](t)){a++;let p=this[si](t),_=this[oi](t);typeof p=="number"&&typeof _=="number"&&X.fchown(x,p,_,E=>E?X.chown(u,p,_,C=>c(C&&E)):c())}c()});let f=this.transform&&this.transform(t)||t;f!==t&&(f.on("error",u=>{this[Pe](u,t),e()}),t.pipe(f)),f.pipe(s)}[Ja](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[cn](String(t.absolute),r,s=>{if(s){this[Pe](s,t),e();return}let a=1,c=()=>{--a===0&&(e(),this[rr](),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()})}[cf](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[of](t,e){let r=V(Ae.relative(this.cwd,Ae.resolve(Ae.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[ei](t,this.cwd,r,()=>this[vs](t,String(t.linkpath),"symlink",e),s=>{this[Pe](s,t),e()})}[af](t,e){let r=V(Ae.resolve(this.cwd,String(t.linkpath))),s=V(String(t.linkpath)).split("/");this[ei](t,this.cwd,s,()=>this[vs](t,r,"link",e),a=>{this[Pe](a,t),e()})}[ei](t,e,r,s,a){let c=r.shift();if(this.preservePaths||c===void 0)return s();let f=Ae.resolve(e,c);X.lstat(f,(u,x)=>{if(u)return s();if(x?.isSymbolicLink())return a(new Ns(f,Ae.resolve(f,r.join("/"))));this[ei](t,f,r,s,a)})}[ff](){this[us]++}[rr](){this[us]--,this[Da]()}[Ya](t){this[rr](),t.resume()}[Za](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!ci}[$a](t){this[ff]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[sf](t,r))}[sf](t,e){let r=f=>{e(f)},s=()=>{this[cn](this.cwd,this.dmode,f=>{if(f){this[Pe](f,t),r();return}this[ai]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let f=V(Ae.dirname(String(t.absolute)));if(f!==this.cwd)return this[cn](f,this.dmode,u=>{if(u){this[Pe](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[Ya](t),r();return}if(f||this[Za](t,u))return this[st](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=_=>this[st](_??null,t,r);return x?X.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return X.rmdir(String(t.absolute),x=>this[st](x??null,t,r))}if(t.absolute===this.cwd)return this[st](null,t,r);qm(String(t.absolute),x=>this[st](x??null,t,r))})};this[ai]?a():s()}[st](t,e,r){if(t){this[Pe](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Va](e,r);case"Link":return this[af](e,r);case"SymbolicLink":return this[of](e,r);case"Directory":case"GNUDumpDir":return this[Ja](e,r)}}[vs](t,e,r,s){X[r](e,String(t.absolute),a=>{a?this[Pe](a,t):(this[rr](),t.resume()),s()})}},Xr=t=>{try{return[null,t()]}catch(e){return[e,null]}},Gf=class extends ac{sync=!0;[st](t,e){return super[st](t,e,()=>{})}[$a](t){if(!this[ai]){let a=this[cn](this.cwd,this.dmode);if(a)return this[Pe](a,t);this[ai]=!0}if(t.absolute!==this.cwd){let a=V(Ae.dirname(String(t.absolute)));if(a!==this.cwd){let c=this[cn](a,this.dmode);if(c)return this[Pe](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[Ya](t);if(e||this[Za](t,r))return this[st](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[st](f,t)}let[a]=Xr(()=>X.rmdirSync(String(t.absolute)));this[st](a,t)}let[s]=t.absolute===this.cwd?[]:Xr(()=>Hm(String(t.absolute)));this[st](s,t)}[Va](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[Pe](f||u,t),e()},a;try{a=X.openSync(String(t.absolute),zf(t.size),r)}catch(f){return s(f)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",f=>this[Pe](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(p){try{X.utimesSync(String(t.absolute),u,x)}catch{f=p}}}if(this[ii](t)){let u=this[si](t),x=this[oi](t);try{X.fchownSync(a,Number(u),Number(x))}catch(p){try{X.chownSync(String(t.absolute),Number(u),Number(x))}catch{f=f||p}}}s(f)})}[Ja](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[cn](String(t.absolute),r);if(s){this[Pe](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()}[cn](t,e){try{return Lm(V(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=Ae.resolve(c,f);let[u,x]=Xr(()=>X.lstatSync(c));if(u)return s();if(x.isSymbolicLink())return a(new Ns(c,Ae.resolve(e,r.join("/"))))}s()}[vs](t,e,r,s){let a=`${r}Sync`;try{X[a](e,String(t.absolute)),s(),t.resume()}catch(c){return this[Pe](c,t)}}},jm=t=>{let e=new Gf(t),r=t.file,s=Df.statSync(r),a=t.maxReadSize||16*1024*1024;new dg(r,{readSize:a,size:s.size}).pipe(e)},Gm=(t,e)=>{let r=new ac(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("close",c),Df.stat(a,(u,x)=>{if(u)f(u);else{let p=new Qa(a,{readSize:s,size:x.size});p.on("error",f),p.pipe(r)}})})},Wf=fi(jm,Gm,t=>new Gf(t),t=>new ac(t),(t,e)=>{e?.length&&vf(t,e)}),Wm=(t,e)=>{let r=new oc(t),s=!0,a,c;try{try{a=Xe.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")a=Xe.openSync(t.file,"w+");else throw x}let f=Xe.fstatSync(a),u=Buffer.alloc(512);e:for(c=0;c<f.size;c+=512){for(let _=0,E=0;_<512;_+=E){if(E=Xe.readSync(a,u,_,u.length-_,c+_),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let x=new kn(u);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>f.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}s=!1,Km(t,r,c,a,e)}finally{if(s)try{Xe.closeSync(a)}catch{}}},Km=(t,e,r,s,a)=>{let c=new hf(t.file,{fd:s,start:r});e.pipe(c),Zm(e,a)},$m=(t,e)=>{e=Array.from(e);let r=new Ps(t),s=(a,c,f)=>{let u=(C,y)=>{C?Xe.close(a,b=>f(C)):f(null,y)},x=0;if(c===0)return u(null,0);let p=0,_=Buffer.alloc(512),E=(C,y)=>{if(C||y===void 0)return u(C);if(p+=y,p<512&&y)return Xe.read(a,_,p,_.length-p,x+p,E);if(x===0&&_[0]===31&&_[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,x);let b=new kn(_);if(!b.cksumValid)return u(null,x);let S=512*Math.ceil((b.size??0)/512);if(x+S+512>c||(x+=S+512,x>=c))return u(null,x);t.mtimeCache&&b.mtime&&t.mtimeCache.set(String(b.path),b.mtime),p=0,Xe.read(a,_,0,512,x,E)};Xe.read(a,_,0,512,x,E)};return new Promise((a,c)=>{r.on("error",c);let f="r+",u=(x,p)=>{if(x&&x.code==="ENOENT"&&f==="r+")return f="w+",Xe.open(t.file,f,u);if(x||!p)return c(x);Xe.fstat(p,(_,E)=>{if(_)return Xe.close(p,()=>c(_));s(p,E.size,(C,y)=>{if(C)return c(C);let b=new Rs(t.file,{fd:p,start:y});r.pipe(b),b.on("error",c),b.on("close",a),Vm(r,e)})})};Xe.open(t.file,f,u)})},Zm=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?lr({file:Kf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Vm=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await lr({file:Kf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r);t.end()},Qr=fi(Wm,$m,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!mg(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")}),k2=fi(Qr.syncFile,Qr.asyncFile,Qr.syncNoFile,Qr.asyncNoFile,(t,e=[])=>{Qr.validate?.(t,e),Jm(t)}),Jm=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))};Jt();var St={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 li(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function $f(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Zf(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Vf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function ur(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}We();te();Fe();We();function Ft(t,e){if(li(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ms(t){return t.startsWith("http://")||t.startsWith("https://")}function Bs(t){return t.endsWith("/")?t.slice(0,-1):t}We();te();var zs="1008033",Jf="1289";var Yf="pbbp2",Xf="https://www.coze.cn",Qf="/api/coze_claw/resource/get_frontier_key",Xm="https://www.coze.cn",Qm="wss://frontier.coze.cn";function Fs(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Xm}function el(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Qm}function xr(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 ui=H("handshake");async function cc(t){let e=Fs(t.endpoint),r=t.timeoutMs??1e4,s=`${Bs(e)}${Qf}?aid=${encodeURIComponent(zs)}`,a={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...xr(t.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),r);ui.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")??"",p=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let b=await u.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${b.slice(0,200)}`)}let _=await u.json();if(_.code!==void 0&&_.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${_.code} msg=${_.msg??"-"} logid=${x}`);let E=_.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(_).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${b}`)}return ui.info("handshake ok",{remoteDeviceId:y,logid:x,traceId:p}),{accessKey:C,deviceId:y}}catch(u){if(u instanceof T)throw ui.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw ui.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw ui.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 T("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(f)}}var dc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",It="auto";function tl(t){return{model:t.model??It,...t.modelToken?{modelToken:t.modelToken}:{}}}function nl(t){return!t||t===It}function rl(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=dc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||It,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):nl(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function il(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||It}"`):nl(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="${dc}/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 sl(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function fc(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 ol(t,e,r){if(!t.modelToken)return{};let s=fc(e,r);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,f])=>`${c}:${f}`).join(`
|
|
83
|
+
`)}}function lc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function al(t,e,r){if(!t.modelToken)return null;let s=t.model||It,a=fc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let f={baseUrl:`${dc}/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 cl(t,e,r){if(!t.modelToken)return[];let s=fc(e,r),a=[];for(let[c,f]of Object.entries(s))a.push("-c",`model_providers.coze.http_headers.${c}="${f}"`);return a}var Oe=H("agent-handlers"),dl=5*1024*1024,sw=1,ow=6,aw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Us=class{constructor(e){this.opts=e}opts;async listSkills(e){Ft(e._meta,"_agent/listSkills");let r=ur(e._meta),s=await this.loadAgentCfg(r),a=s?.workspace??Lt(r).workspace,c=s?.skills??[],f=[];for(let u of c){let x=Ct(a,u.relPath,"SKILL.md");await nw(x).then(_=>_.isFile()).catch(()=>!1)&&f.push(uw(u))}return{skills:f}}async addSkills(e){Ft(e._meta,"_agent/addSkills");let r=ur(e._meta),s=await this.requireAgentCfg(r),a=e.skills??[],c=[...s.skills??[]],f=new Map(c.map((x,p)=>[x.skillId,p])),u=[];for(let x of a){let p=await wc({agentId:r,workspace:s.workspace,framework:s.framework,skill:x});_c(c,f,p),u.push(x)}return await Wi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Ft(e._meta,"_agent/removeSkills");let r=ur(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=Ct(s.workspace,u.relPath);await tw(x,{recursive:!0,force:!0}),Oe.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await Wi(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,Oe.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,Oe.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:f}),x.stop(r).catch(p=>Oe.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:a,err:String(p)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Oe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,s=await je(r);if(!s)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(s.cozeIdentity===e.cozeIdentity)return Oe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Vn(s.workspace,s.framework,e.cozeIdentity)}catch(a){throw Oe.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:s.framework,workspace:s.workspace,err:String(a)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(a)}`,{cause:a})}return s.cozeIdentity=e.cozeIdentity,await Ve(s),Oe.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 T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let s=await je(r);return s?(s.disconnectedAt=Date.now(),s.disconnectReason=e.reason??"",await Ve(s),Oe.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}):(Oe.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Ft(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:It,s=await je(e.agentId);if(!s)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);s.model=r,e.modelInfo&&(s.modelInfo=e.modelInfo),await Ve(s),Oe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return Oe.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=>Oe.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),Oe.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(Ft(e._meta,St.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${St.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,St.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Ft(e._meta,St.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${St.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${St.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(s){Oe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(s)})}return await this.runDetailSync(e.agentId,St.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,s){if(!this.opts.detailSyncer){Oe.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){Oe.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:s,err:String(a)})}}async getFileTree(e){Ft(e._meta,"_agent/getFileTree");let r=e._meta,s=ur(r),a=await this.resolveWorkspace(s),c=e.filePath??"",f=this.safeJoin(a,c),u=await uc(f).catch(()=>null);if(!u)throw new T("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await zr(f,a))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=vw(e.depth);return u.isDirectory()?{tree:await Ew(a,f,c,x)}:{tree:[{name:Sw(c),path:gl(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Ft(e._meta,"_agent/getFileContent");let r=ur(e._meta),s=await this.resolveWorkspace(r);if(!e.filePath)throw new T("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(s,e.filePath),c=await uc(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(!await zr(a,s))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>dl)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${dl})`);let f=await fl(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 je(e).catch(()=>null))?.workspace??Lt(e).workspace}safeJoin(e,r){let s=pc(e,r||"."),a=mc(e,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${ll}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return s}loadAgentCfg(e){return je(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new T("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function cw(t){let e=t.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: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new T("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function dw(t){return t==="claude-code"?Ct(".claude","skills"):Ct(".agents","skills")}var fw=3e4,lw=50*1024*1024,hr=3e4;async function wc(t){let{agentId:e,workspace:r,framework:s,skill:a}=t;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 u=cw(a.skillName),x=dw(s),p=Ct(x,u),_=Ct(r,p);if(await xc(_,{recursive:!0}),c){let C=Buffer.from(a.content,"utf8");hi(C.length),await hc(Ct(_,"SKILL.md"),C,"utf8")}else{let C=await xw(a.downloadUrl);pw(C)?await _w(C,_):gw(C)?await mw(C,_):await hc(Ct(_,"SKILL.md"),C.toString("utf8"),"utf8")}let E={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 Oe.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:p,source:c?"content":"downloadUrl"}),E}function _c(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 uw(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 xw(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);hi(e);let r=hw(t);return hi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await fl(e);return hi(r.length),r}if(Ms(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),fw);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new T("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 T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function hi(t){if(t>lw)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function hw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("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 pw(t){return t.length>=2&&t[0]===31&&t[1]===139}function gw(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 gc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function mw(t,e){let r,s;try{r=new hl.default(t),s=r.getEntries()}catch(f){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of s){let u=f.entryName;if(!u||gc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new T("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=f.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let a=ww(s),c=pc(e);for(let f of s){if(gc(f.entryName))continue;let u=f.entryName;if(a&&u.startsWith(a)&&(u=u.slice(a.length)),!u)continue;let x=pc(e,u),p=mc(c,x);if(p.startsWith("..")||p==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(f.isDirectory){await xc(x,{recursive:!0});continue}await xc(rw(x),{recursive:!0});let _;try{_=f.getData()}catch(E){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${E.message}`,{cause:E})}await hc(x,_)}}function ww(t){let e;for(let r of t){let s=r.entryName;if(!s||gc(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 _w(t,e){await yw(t);let r=Wf({cwd:e,strip:1}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${hr}ms)`))},hr);try{await xl(ul.from(t),r)}catch(c){throw c instanceof T?c:s?new T("IPC_BAD_REQUEST",`tar extract timeout (${hr}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}}async function yw(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(p=>p==="..")&&e.push(`tar entry contains '..': ${f}`)}}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${hr}ms)`))},hr);try{await xl(ul.from(t),r)}catch(c){throw s?new T("IPC_BAD_REQUEST",`tar list timeout (${hr}ms)`):new T("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}if(e.length>0)throw new T("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var bw=5e3;async function Ew(t,e,r,s){return pl(t,e,r,s,{count:0})}async function pl(t,e,r,s,a){if(s<=0)return[];let c;try{c=await ew(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let u of c){if(aw.has(u.name)||u.isSymbolicLink())continue;if(a.count>=bw){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Ct(e,u.name),p=iw(Ct(r,u.name)),_=null;try{_=await uc(x)}catch{continue}if(_.isSymbolicLink())continue;a.count++;let E={name:u.name,path:gl(mc(t,x)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&s>1&&(E.children=await pl(t,x,p,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 vw(t){return!t||t<=0?sw:Math.min(t,ow)}function Sw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function gl(t){return t.split(ll).join("/")}te();import{readFileSync as qS}from"node:fs";import{dirname as jS,join as GS}from"node:path";import{fileURLToPath as KS}from"node:url";var pr="0.1.83";var ln=H("agent-health-reporter"),Iw=1e4,pi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Iw}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()}),ln.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),ln.info("heartbeat stopped"))}async tick(){if(this.inFlight){ln.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){ln.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=Cw(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:pr,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",s,5e3)}catch(f){ln.warn("heartbeat batch send failed",{count:r.length,err:String(f)})}let c=a?.authFailures;if(c&&c.length>0&&(ln.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){ln.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){ln.warn("onTickEnd hook failed",{err:String(r)})}}};function Cw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Jt();import{mkdir as bc,rm as n_}from"node:fs/promises";wn();import{spawnSync as Ow}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 gr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function un(t,e){return{jsonrpc:"2.0",id:t,error:e}}We();var qs=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)}},ee={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,AGENT_DEPENDENCY_INSTALL_FAILED:-32018};function ml(t){return"method"in t&&"id"in t&&t.id!==void 0}function wl(t){return"method"in t&&!("id"in t)}function Hs(t){return!("method"in t)&&"id"in t}var Aw={AGENT_NOT_FOUND:ee.AGENT_NOT_FOUND,AGENT_BUSY:ee.AGENT_BUSY,AGENT_DISCONNECTED:ee.AGENT_DISCONNECTED,AGENT_TIMEOUT:ee.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:ee.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:ee.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:ee.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:ee.INTERNAL_ERROR,BRIDGE_INTERNAL:ee.INTERNAL_ERROR,IPC_AUTH_FAILED:ee.INTERNAL_ERROR,IPC_BAD_REQUEST:ee.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:ee.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:ee.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:ee.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:ee.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:ee.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:ee.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:ee.FILE_TOO_LARGE,UNSUPPORTED_MIME:ee.UNSUPPORTED_MIME,UPLOAD_FAILED:ee.UPLOAD_FAILED,UPSTREAM_NOT_READY:ee.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:ee.AGENT_DEPENDENCY_INSTALL_FAILED};function Tw(t){if(t!=null)return t instanceof Error?{name:t.name,message:wi(t.message)}:typeof t=="string"?wi(t):typeof t=="object"?Dw(t):t}var Rw=[[/\/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 Rw)e=e.replace(r,s);return e}function Dw(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 T){let e=Tw(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:Aw[t.code]??ee.INTERNAL_ERROR,message:wi(t.message),data:r}}return{code:ee.INTERNAL_ERROR,message:wi(t instanceof Error?t.message:String(t))}}function _l(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 T(r,a,{retriable:e?.retriable??!1,cause:c})}function bl(t){return`${JSON.stringify(t)}
|
|
84
|
+
`}var yl=10*1024*1024,js=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>yl){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${yl} bytes`)}),[]}let r=this.buffer.split(`
|
|
85
|
+
`);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 vl={"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"},r1=Object.fromEntries(Object.entries(vl).map(([t,e])=>[e,t])),kw={"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:[]},mr=class{seq=0;next(e,r){this.seq+=1;let s=vl[e]??Lw(e),a=kw[s]??[],c=[s,String(this.seq)];if(a.length>0){let f=a.map(x=>El(r?.[x]??"")),u=Pw(f).join(":");u&&c.push(u)}else r&&Object.values(r).some(f=>f)&&c.push(Object.values(r).filter(Boolean).map(f=>El(String(f))).join(":"));return c.join("_")}reset(){this.seq=0}};function Lw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function El(t){return t.replace(/[:_\s]+/g,"-")}function Pw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Gn();function wr(t,e){let r=process.env[t];if(!r)return e;let s=Number(r);return Number.isFinite(s)&&s>0?s:e}We();te();var Nw=wr("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Mw=200,Bw=wr("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),zw=wr("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),Sl=500;function Fw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Sl?t:`${e.slice(0,Sl)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Il(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),Ow("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var At=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`),this.decoder=new js({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new mr;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",r=Vt(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>Mw&&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]});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 (${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 T("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()));Il(r.pid,"SIGTERM");let a=setTimeout(()=>{r.killed||Il(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=Bw,s=zw){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(gr(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(un(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=Nw,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=gi(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let _=r.sessionId;return typeof _=="string"?_:void 0})(),x=s>0&&Number.isFinite(s),p=a>0&&Number.isFinite(a);return new Promise((_,E)=>{let C={resolve:_,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 T("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s));let y=p?()=>{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 T("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 T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(bl(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Hs(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(_l(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 T("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Fw(e.result)}),r.resolve(e.result));return}if(wl(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(ml(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(un(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(un(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()}};function Uw(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 Gs=class extends At{framework="claude-code";constructor(e){let r=Br("claude-code",e.command),s=e.args??[],a={command:r,args:s,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a)}sanitizeEnv(e){return Uw(e)}};wn();import{mkdtempSync as qw,rmSync as Hw}from"node:fs";import{tmpdir as jw}from"node:os";import{join as Gw}from"node:path";var Ws=class extends At{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=Br("codex",e.command),s=e.args??[],a=e.extraArgs?[...s,...e.extraArgs]:s,c=e.isolateCodexHome?qw(Gw(jw(),"coze-bridge-codex-home-")):void 0,f=c?{...e.env??{},CODEX_HOME:c}:e.env,u={command:r,args:a,cwd:e.cwd,...f?{env:f}:{}};super(u),this.authMethodId=e.authMethodId,this.codexHomeDir=c}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{Hw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Ww=3e4,_r=class extends At{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}};We();te();Fe();function yc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}wn();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 Ks=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)}Gn();te();import{constants as Cl,access as Kw}from"node:fs/promises";import{delimiter as $w,join as Zw}from"node:path";var xn=H("framework-detector"),Al={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Vw=[".exe",".cmd",".bat",".ps1"],hn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Vt,access:e.access??Kw}}async detect(e){let r=Al[e],s=await this.which(r);if(!s)return xn.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(Al).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"?["",...Vw]:[""];for(let a of r)for(let c of s){let f=Zw(a,e+c);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Cl.F_OK:Cl.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 xn.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return xn.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 xn.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 xn.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?(xn.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}:(xn.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:a.length}),null)}catch(a){return xn.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&&(Yw(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",p=>{a+=p.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",p=>u({code:p,stdout:a}))}catch{u(null)}})}},Jw=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Yw(t){return t.replace(Jw,"")}import{spawn as Xw}from"node:child_process";import{homedir as Qw}from"node:os";import{join as e_}from"node:path";We();ji();te();async function Dl(){let t=e_(Qw(),".openclaw/openclaw.json");return(await Zn(t))?.gateway?.auth?.token??""}var Tl=H("openclaw.config"),t_=[0,5e3,5e3],Rl="models.providers.",$s="agents.defaults.models",Zs=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,Tl.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: ${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){Tl.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",`${Rl}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Rl}${e}`)}addModelToAllowlist(e,r){let s={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${$s}[${e}]`,()=>this.runCli(["config","set",$s,JSON.stringify(s),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${$s}[${e}]`,`${$s}.${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 Ne=H("agent-manager"),r_=(t,e,r,s,a,c,f,u,x)=>{switch(t){case"claude-code":{let p={...a?{...rl(a),...ol(a,f,u)}:{},...x??{},IS_SANDBOX:"1"};return new Gs({cwd:r,env:p})}case"codex":{let _=[...a?[...il(a),...cl(a,f,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...a?sl(a):{},...x??{}},C=!!a;return new Ws({cwd:r,..._.length>0?{extraArgs:_}:{},...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:yc(c)}:{}})}};function Ec(t){return t==="claude-code"||t==="codex"}var i_={path:"",version:"cloud-deployed"},s_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},o_=6e4,Vs=class{paths;config;registry;factory;createTimeoutMs;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.detectorFactory=e.detectorFactory??(()=>new hn)}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 Zs({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 r=li(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let s=this.registry.get(e.agentId);if(s){if(s.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${s.framework})`);if(s.status==="error")Ne.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await s.dispose("rebuild after error").catch(b=>Ne.warn("dispose stale agent failed (ignored)",{err:String(b)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==s.patToken){Ne.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),s.setPatToken(e.patToken);let b=await je(e.agentId,this.paths).catch(()=>null);b&&(b.patToken=e.patToken,await Ve(b,this.paths))}if(s.deployType==="cloud"&&e.modelInfo){Ne.info("updating agent modelInfo on re-create",{agentId:e.agentId}),s.setModelInfo(e.modelInfo);let b=await je(e.agentId,this.paths).catch(()=>null);b&&(b.modelInfo=e.modelInfo,await Ve(b,this.paths))}return Ne.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 T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Lt(e.agentId,this.paths),f=li(e._meta),u=e.framework==="openclaw"&&f==="local",x=u?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??x??c.workspace,_=new AbortController,E=setTimeout(()=>_.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),C,y=!1;try{r&&Ec(e.framework)&&await $n(e.framework,_.signal);let b=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await bc(c.root,{recursive:!0}),await bc(p,{recursive:!0}),await bc(c.logs,{recursive:!0}),b(),u||await Vn(p,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await Y0(p),b();let S=await je(e.agentId,this.paths).catch(()=>null),I=tl({model:e.model??S?.model}),R=$f(e._meta)??S?.accountId,P=e.patToken??S?.patToken,w=f==="cloud"?e.modelInfo??S?.modelInfo:void 0;if(C=new Ks({agentId:e.agentId,framework:e.framework,workspace:p,model:I.model??It,deployType:f,...R?{accountId:R}:{},...P?{patToken:P}:{},...w?{modelInfo:w}:{}}),C.status="ok",S?.sessions){for(let[B,k]of Object.entries(S.sessions))C.sessions.set(B,{acpSessionId:k.acpSessionId,modelToken:k.modelToken,tokenGeneratedAt:k.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let z=Object.keys(S.sessions).length;z>0&&Ne.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:z})}this.registry.register(C),y=!0;let A={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:S?.createdAt??Date.now(),sessions:S?.sessions??{},model:I.model};f==="cloud"&&(A.deployType="cloud"),R&&(A.accountId=R),P&&(A.patToken=P),w&&(A.modelInfo=w),S?.skills&&(A.skills=S.skills),S?.agentName&&(A.agentName=S.agentName),S?.description&&(A.description=S.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,p):Ne.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let D=e.initialSkills??[];if(D.length>0){let z=[...A.skills??[]],B=new Map(z.map((F,K)=>[F.skillId,K])),k=await Promise.allSettled(D.map(F=>wc({agentId:e.agentId,workspace:p,framework:e.framework,skill:F}))),M=0;for(let[F,K]of k.entries()){let oe=D[F];oe&&(K.status==="fulfilled"?(_c(z,B,K.value),M++):Ne.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:oe.skillId,skillName:oe.skillName,err:String(K.reason)}))}M>0&&(A.skills=z,Ne.info("initialSkills installed",{agentId:e.agentId,installed:M,requested:D.length}))}return await Ve(A,this.paths),Ne.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 Ne.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(S=>Ne.warn("rm agent dir failed (ignored)",{err:String(S)})),b instanceof T?b:new T("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"&&Ec(e.framework))u=i_;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(Ec(e.framework)&&!Mr(e.framework)){let _=Yo(e.framework);Ne.info("spawn: ensuring acp wrapper installed",{agentId:e.agentId,framework:e.framework,reusingInFlight:!!_}),await $n(e.framework)}let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:s,cozeEnv:a,mockScenario:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,x,s,a,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(s_),p}catch(_){let E=p instanceof At?p.getStderrTail():[];throw E.length>0&&Ne.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:_ instanceof T?_.code:"unknown",recentStderr:E}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),_ instanceof T?new T(_.code,_.message,{retriable:_.retriable,cause:_}):new T("AGENT_SPAWN_FAILED",_ instanceof Error?_.message:String(_),{cause:_})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:s,cloudSessionId:a,cozeEnv:c,mockScenario:f,command:u}=e,x=yc(a);if(r.deployType==="local"){let C=this.config.frameworksCache?.openclaw?.defaultAgent;if(!C?.id||!C.workspace){Ne.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)Ne.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 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 _r({command:u,cwd:C.workspace,agentId:C.id,sessionName:x})}let p=await Dl(),_=s?al(s,c,f):null,E;if(_){let C=lc(a),b=_.models[0]?.id??It,S=`${C}/${b}`;if(!this.ensuredProviders.has(S)){let I=this.getOpenclawConfig();await I.ensureProvider(C,_),await I.addModelToAllowlist(S),this.ensuredProviders.add(S)}E=S}return new _r({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...p?{gatewayToken:p}:{},...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=lc(s),c=`${a}/${e.model}`,f=!0;try{await r.removeProvider(a)}catch(u){f=!1,Ne.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){f=!1,Ne.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as Nl}from"node:crypto";import{promises as h_}from"node:fs";import{basename as Ml}from"node:path";We();te();import{promises as c_}from"node:fs";import{basename as d_}from"node:path";var kl=H("file-upload"),f_="/api/coze_claw/file/agent_upload",l_=6e4;async function Ll(t,e={}){let s=`${Bs(Fs(e.handshakeBase))}${f_}`,a=e.timeoutMs??l_,c=await c_.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",...xr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),a);kl.info("file upload start",{url:s,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let _=await fetch(s,{method:"POST",headers:u,body:f,signal:x.signal}),E=_.headers.get("x-tt-logid")??"";if(!_.ok){let b=await _.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${E}: ${b.slice(0,200)}`)}let C=await _.json();if(C.code!==void 0&&C.code!==0)throw new T("UPLOAD_FAILED",`upload code=${C.code} msg=${C.msg??"-"} logid=${E}`);let y=C.data?.file?.file_url;if(!y)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(C).slice(0,200)}`);return kl.info("file upload ok",{uri:y,logid:E}),{uri:y}}catch(_){throw _ instanceof T?_:_.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${a}ms) for ${d_(t.path)}`):new T("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(p)}}We();te();import{extname as u_}from"node:path";var x_={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function Pl(t){let e=u_(t).toLowerCase();return x_[e]??"application/octet-stream"}Fe();var Js=H("agent-send"),Ol=50*1024*1024;function Bl(t,e,r){let s=t.get(e);if(!s)throw new T("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new T("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=s.sessions.get(r);if(!a)throw new T("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:s,runtime:a}}async function zl(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(p){u=p,x<2&&(Js.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(_=>setTimeout(_,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function Fl(t,e){let{session:r,runtime:s}=Bl(e.core,t.agentId,t.sessionId);if(!await zr(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let a=await h_.stat(t.path).catch(()=>null);if(!a||!a.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(a.size>Ol)throw new T("FILE_TOO_LARGE",`${a.size} bytes > limit ${Ol}`);let c=await Pl(t.path);if(t.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=t.name??Ml(t.path),u;try{u=await Ll({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(p){throw Js.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:a.size,mime:c,code:p instanceof T?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:Nl(),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 zl(e,r,s,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Js.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 Ul(t,e){let{session:r,runtime:s}=Bl(e.core,t.agentId,t.sessionId);if(!t.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=t.name??Ml(t.path),c={sessionUpdate:"group_file",messageId:Nl(),content:{uri:t.path,name:a,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await zl(e,r,s,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Js.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 ql(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}wn();Gn();te();var Tt=H("coze-cli-installer"),Hl="@coze/cli@latest",p_="coze",jl="0.1.7",g_=5e3,m_=5e3,w_=9e4,Gl=1e4,bi=null,Ys=!1;async function vc(t,e={}){if(Ys)return;if(bi)return bi;let r=e.exec??zi;return bi=(async()=>{try{let s=await __(p_,r),a=!1;if(s){let f=await y_(r);if(f===void 0)Tt.warn("coze-cli found but version unparseable, fall through to full install",{path:s});else if(ql(f,jl))Tt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:s,version:f,min:jl}),a=!0;else{Tt.info("coze-cli already on PATH with sufficient version, skip",{path:s,version:f}),Ys=!0;return}}let c=a?"upgrade-only":"full";Tt.info("coze-cli install start",{package:Hl,mode:c});try{await r("npm",["i","-g","--prefer-online",Hl],{timeout:w_,maxBuffer:10*1024*1024}),Tt.info("coze-cli install ok")}catch(f){Tt.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(a){Ys=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Gl}),Tt.info("coze config set xTTEnv ok",{env:t.env})}catch(f){Tt.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Gl}),Tt.info("coze auth login ok")}catch(f){Tt.warn("coze auth login failed",{err:String(f)});return}Ys=!0}finally{bi=null}})(),bi}async function __(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:s}=await e(r,[t],{timeout:g_});return qi(s)}catch{return}}async function y_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:m_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}ji();Fe();var b_=10*6e4;function Wl(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?b_:e}function Xs(t){return Zn(t??ne().configFile)}function br(t,e){return Hi(e??ne().configFile,t)}import{randomBytes as F_}from"node:crypto";import{createReadStream as E_}from"node:fs";import{mkdir as v_,readFile as S_,realpath as I_,stat as C_,writeFile as A_}from"node:fs/promises";import{basename as T_,dirname as Sc,join as R_,relative as D_,resolve as Kl,sep as k_}from"node:path";import{createInterface as L_}from"node:readline";We();te();var Zl=H("fs-rpc"),Ei=wr("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Vl(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Ei)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Ei} bytes`);let s=await Yl(t.path,e);return await v_(Sc(s),{recursive:!0}),await A_(s,t.content,"utf8"),Zl.info("fs/write_text_file ok",{path:s,size:t.content.length}),null}async function Jl(t,e){let r=await Yl(t.path,e),s=await C_(r),a=typeof t.line=="number"||typeof t.limit=="number";if(s.size>Ei&&!a)throw new T("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 P_(r,t.line??1,t.limit);else{let f=await S_(r,"utf8");if(a){let u=f.split(`
|
|
86
|
+
`),x=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,p).join(`
|
|
87
|
+
`)}else c=f}return Zl.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function P_(t,e,r){let s=L_({input:E_(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(`
|
|
88
|
+
`)}async function Yl(t,e){if(typeof t!="string"||t.length===0)throw new T("IPC_BAD_REQUEST","path must be a non-empty string");let[r,s]=await Promise.all([$l(Kl(e)),$l(Kl(t))]),a=D_(r,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${k_}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return s}async function $l(t){let e=[],r=t;for(;r!==Sc(r);)try{let s=await I_(r);return e.length?R_(s,...e.reverse()):s}catch{e.push(T_(r)),r=Sc(r)}return t}te();var Xl=H("prompt-multimodal"),Ql=10*1024*1024,O_=15e3,N_=6;async function eu(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 M_(f))}}let a=Array.from({length:Math.min(N_,t.length)},()=>s());return await Promise.all(a),e}function tu(t){return t.some(e=>e.type==="image")}async function M_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ms(e.uri))return t;try{let{buf:r,contentType:s}=await z_(e.uri),a=e.mimeType||B_(s)||"application/octet-stream";return Xl.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 Xl.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function B_(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function z_(t){let e=new AbortController,r=setTimeout(()=>e.abort(),O_);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>Ql)throw new Error(`image too large: ${a.byteLength} bytes (max ${Ql})`);return{buf:Buffer.from(a),contentType:s.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Jt();We();te();var Z=H("core"),U_=3e4,q_=/^(boe|ppe)_[A-Za-z0-9_-]+$/,H_=3e4,Qs=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new mr;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=Wl(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(),Z.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){Z.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),Z.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(s){Z.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)&&Z.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)=>{Z.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){Z.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(un(a,{code:ee.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(f=>Z.debug("send error response to upstream failed (ignored)",{err:String(f)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ee.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){Z.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,s]of this.pendingUpstream)try{s.downstream.respondAgentRequestError(s.agentRequestId,{code:ee.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,s]of this.pendingBridge)clearTimeout(s.timer),s.reject(new T("UPSTREAM_DISCONNECTED",`${s.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Hs(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&&q_.test(s)?this.currentCozeEnv=s:s&&Z.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,ee.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):Z.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);r!==null&&await this.upstream.send(gr(r,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(gr(r,a));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(gr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):Z.warn("drop unknown notification",{method:e.method})}catch(a){Z.error("handleFrame failed",{method:e.method,err:String(a)}),r!==null&&await this.upstream.send(un(r,_i(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,s=r._meta?.cozeAgentId;if(!s)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(s);if(!a)throw this.disconnectedAgents.has(s)?new T("AGENT_DISCONNECTED",`agent ${s} has been disconnected; cloud must _agent/create to revive`):new T("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{Z.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}=Vf(s);switch(r){case"session/new":{let c=j_();return Z.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return Z.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 u=await this.ensureRuntime(e,f);if(u.replySeq=0,await this.ensureDownstream(e,f,u),!u.downstream||!u.acpSessionId)throw new T("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 p=Zf(s._meta);if(p?e.activeGroupIds.set(u.acpSessionId,p):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&tu(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let _=await eu(c.prompt);try{let E=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:_});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,Z.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:u.acpSessionId}),E.stop("reload-after-turn").catch(C=>Z.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 T("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&&(Z.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:x.size}),x.dispose(new T("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 T("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(St.GEN_MODEL_TOKEN,s,H_);if(!a?.modelToken)throw new T("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);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,r,s){if(yi(s),s.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=s.spawnFailCount??0,u=s.spawnFailedAt??0;if(f>=a&&Date.now()-u<c)throw new T("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(p){throw s.spawnFailCount=f+1,s.spawnFailedAt=Date.now(),s.spawnFailCount>=a&&s.acpSessionId&&(Z.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:s.acpSessionId}),s.acpSessionId=void 0),p}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}),Z.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId})}catch(p){Z.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId,err:String(p)}),s.acpSessionId=void 0;let _=await x.sessionNew({cwd:e.workspace});s.acpSessionId=_.sessionId,await this.persistSessionMapping(e)}finally{s.loadingSession=!1}}else{let p=await x.sessionNew({cwd:e.workspace});s.acpSessionId=p.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)){Z.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)){Z.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,s);return}Z.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=>Z.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){Z.debug("drop update for unknown session",{agentId:e.agentId,acpId:s});return}let c=e.sessions.get(a);if(!c){Z.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(W_(r)){Z.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(p=>Z.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}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}Z.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:s.method}),r.respondAgentRequestError(s.id,{code:ee.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 Vl(c,a);r.respondAgentRequest(s.id,f)}else{let c=s.params??{},f=await Jl(c,a);r.respondAgentRequest(s.id,f)}}catch(a){Z.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,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let _=u?e.activeGroupIds.get(u):void 0;_&&(p.cozeGroupId=_);let E=u?this.reverseSessionId(e,u):void 0,C={...c,...E?{sessionId:E}:{},_meta:p};this.pendingUpstream.set(a,{agentRequestId:s.id,agentId:e.agentId,downstream:r,method:s.method}),Z.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),Z.error("forward permission request failed",{agentId:e.agentId,err:String(y)}),r.respondAgentRequestError(s.id,{code:ee.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?(Z.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"&&G_(e.result,a),Z.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 qs(e.error)):s.value.resolve(e.result);return}Z.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 Z.warn(`${s} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:f,key:c}}}sendRequest(e,r,s=U_){let a=this.upstreamIds.next(e);return new Promise((c,f)=>{let u=setTimeout(()=>{this.pendingBridge.delete(a),f(new T("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 p=this.pendingBridge.get(a);p&&(clearTimeout(p.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 Xo(e.agentId,r,this.paths)}catch(r){Z.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(un(e,{code:r,message:s,data:{bridgeVersion:pr}}))}};function j_(){return F_(16).toString("hex")}function G_(t,e){if(!t||typeof t!="object"){Z.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){Z.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"){Z.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")&&Z.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function W_(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 `")}te();Fe();import{randomBytes as K_}from"node:crypto";import{chmod as $_,mkdir as Z_,writeFile as nu}from"node:fs/promises";import{createServer as V_}from"node:http";import{dirname as J_}from"node:path";var Y_=1e6,Ic=H("ipc"),eo=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??ne()}async start(){this.token=K_(32).toString("hex");let e=V_((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(),Ic.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 Z_(J_(this.paths.portFile),{recursive:!0}),await nu(this.paths.portFile,String(this.port),"utf8"),await nu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await $_(this.paths.tokenFile,384)}catch(e){Ic.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 X_(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){Ic.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 X_(t){let e=[],r=0;for await(let a of t){let c=a;if(r+=c.length,r>Y_)throw new Error("body too large");e.push(c)}let s=Buffer.concat(e).toString("utf8");return s?JSON.parse(s):null}var Ix=mt(xu(),1);var Lb=mt(cx(),1),Pb=mt(mo(),1),Ob=mt(Sr(),1),Nb=mt(zc(),1),Mb=mt(qc(),1),Bb=mt($c(),1),mx=mt(bo(),1),zb=mt(gx(),1);var _x=mx.default;We();te();var Te=H("upstream.frontier"),bx="application/json",Ex="none",Ub=15e3,Li=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){Te.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Xf,...xr(this.opts.ppeOverride)};class r extends _x{constructor(b){super(b,Yf,{headers:e})}send(b,...S){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 R=Buffer.from(I.slice(0,128)).toString("hex");Te.debug("WS raw frame out",{bytes:I.byteLength,headHex:R})}catch(I){Te.warn("WS raw frame dump failed",{err:String(I)})}super.send(b,...S)}}let s=el(this.opts.urlOverride),a={url:s,ws:r,fpID:Jf,aID:zs,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:bx,force:!0},payloadEncoding:{encoding:Ex,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new Ix.FWS(a),f=!1,u=null,x,p,_=new Promise((y,b)=>{x=y,p=b}),E=y=>{f||(f=!0,u&&(clearTimeout(u),u=null),y?p(y):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Te.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(S=>Te.warn("onConnect handler threw (ignored)",{err:String(S)}))},c.onclose=y=>{this.opened=!1,Te.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Te.warn("frontier error",{code:y.code,msg:y.message}),E(new T("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??Ub;u=setTimeout(()=>{E(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${C}ms (handshake or upgrade slow)`))},C),await c.connect();try{await _}catch(y){try{c.close(1e3,"open failed")}catch(b){Te.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){Te.warn("frontier close threw (ignored)",{err:String(s)})}}}async send(e){let r=this.fws,s=e.method;if(!r)throw Te.warn("frontier send refused: upstream not started",{method:s}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Te.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 T("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;vx(c)||Te.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await r.send(a,{service:33555712,method:1,payloadType:bx,payloadEncoding:Ex})}catch(u){throw Te.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new T("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){Te.debug("drop non-adapter frontier frame",{service:r});return}let s=jb(e);if(!s){Te.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Te.debug("frame received but no onFrame handler",{size:s.length});return}let a;try{a=JSON.parse(s)}catch(f){Te.warn("frontier message JSON parse failed",{err:String(f),head:s.slice(0,80)});return}let c=a;vx(c)||Te.info("frontier frame in",{logid:Hb(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:qb(s)}),Promise.resolve(this.handler(a)).catch(f=>Te.warn("frontier frame handler threw",{err:String(f)}))}};function vx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Sx=2e3;function qb(t){return t.length<=Sx?t:`${t.slice(0,Sx)}...<truncated, total ${t.length} chars>`}function Hb(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function jb(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}}te();var Vc=H("upstream.switchable"),vo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Vc.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 Vc.error("swap target start failed, reverting",{err:String(a)}),this.inner=s,a}await s.stop(r??"swapped").catch(a=>Vc.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()}};te();var Jc=H("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)}};We();te();te();Fe();import{promises as Yc}from"node:fs";import{dirname as Gb}from"node:path";var Wb=H("pat-token-store");async function Cx(t=ne()){try{let r=(await Yc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Wb.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Pi(t,e=ne()){if(!t)throw new Error("writePatToken: empty patToken");await Yc.mkdir(Gb(e.patTokenFile),{recursive:!0}),await Yc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Fe();Fe();import{promises as So}from"node:fs";import{join as Kb}from"node:path";function $b(t,e){return`#!/bin/sh
|
|
89
89
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
90
|
-
`}function
|
|
90
|
+
`}function Zb(t,e){return`@echo off\r
|
|
91
91
|
"${e}" "${t}" %*\r
|
|
92
|
-
`}async function Ah(t,e=ee()){let r=e.binDir;await bo.mkdir(r,{recursive:!0});let i=K1(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?V1(t,o):$1(t,o);return await bo.readFile(i,"utf8").catch(()=>null)===c||(await bo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await bo.chmod(i,493)),r}Q();Be();import{execSync as Ch}from"node:child_process";import{readFileSync as Rh,unlinkSync as J1}from"node:fs";import{mkdir as Z1,readFile as kh,unlink as Dh,writeFile as Y1}from"node:fs/promises";import{dirname as X1}from"node:path";function Th(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var Q1=q("single-instance"),vo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??ee().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&&(Q1.warn("removing stale pid file",{stalePid:e}),await Dh(this.pidFile).catch(()=>{})),await Z1(X1(this.pidFile),{recursive:!0}),await Y1(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await kh(this.pidFile,"utf8")).trim()===String(process.pid)&&await Dh(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await kh(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 Th(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Rh(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=Ch(`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 i=Ch(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!i||/^(INFO|信息)[::]/.test(i))return!1;let o=i.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return o.includes("node")||o.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{Rh(this.pidFile,"utf8").trim()===String(process.pid)&&J1(this.pidFile)}catch{}})}};var G=q("daemon"),eE="coze-bridge-daemon";async function Ph(){let t=new vo({processTitle:eE}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Zs(),i=r??{};Ni({pid:process.pid}),G.info(r?"loaded bridge config":"initialized bridge config");try{let D=new xn;i.frameworksCache=await D.detectAll(),G.info("refreshed frameworks_cache",{detected:Object.keys(i.frameworksCache)})}catch(D){G.warn("framework detection failed",{err:String(D)})}await br(i);let o=new Eo(new Dr),c=ee(),l=null,f=new Ys({upstream:o,paths:c,bridgeConfig:i,sessionSpawner:async(D,L,F,j)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(D,L,F,j)}});await nE(c,f);let h=new $s({paths:c,config:i,registry:f});l=h;let x,m,_=null,A={},y,E=null;f.registerExtension("_agent/create",async D=>h.createAgent(D.params)),f.registerExtension("_agent/health",async()=>({ok:!0}));let S={},I=new zs({agents:f.agents,disposeAndMarkDisconnected:async(D,L)=>{let F=f.agents.get(D);if(F){await h.cleanupOpenclawSessionProviders(F).catch(ie=>G.warn("cleanup openclaw providers failed (ignored)",{agentId:D,err:String(ie)}));let j=!0;try{await F.dispose(`disconnect: ${L}`)}catch(ie){j=!1,G.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:D,err:String(ie)}),F.status="error"}j&&(F.status="disconnected",f.unregister(D),f.disconnectedAgents.add(D))}else f.disconnectedAgents.add(D)},detailSyncer:async D=>{if(!S.ref)throw new Error("agent-detail-sync not initialized yet");await S.ref.syncOne(D)},cleanupOpenclawProviders:async D=>{await h.cleanupOpenclawSessionProviders(D)},openclawRepair:async(D,L)=>{await h.openclawRepair(D,L)},isRuntimePendingPermission:D=>f.hasPendingPermissionFor(D)});f.registerExtension("_agent/listSkills",D=>I.listSkills(D.params)),f.registerExtension("_agent/addSkills",D=>I.addSkills(D.params)),f.registerExtension("_agent/removeSkills",D=>I.removeSkills(D.params)),f.registerExtension("_agent/getFileTree",D=>I.getFileTree(D.params)),f.registerExtension("_agent/getFileContent",D=>I.getFileContent(D.params)),f.registerExtension("_agent/update",D=>I.updateAgent(D.params)),f.registerExtension("_agent/disconnect",D=>I.disconnectAgent(D.params)),f.registerExtension("_agent/switchModel",D=>I.switchModel(D.params)),f.registerExtension("_agent/reset",D=>I.resetAgent(D.params)),f.registerExtension("_agent/repair",D=>I.repairAgent(D.params));let R=new Wi({paths:c,handlers:I,sendDetail:D=>f.sendRequest("_agent/detail",D)});S.ref=R;let P=async D=>{await Promise.allSettled(D.map(async L=>{try{await I.disconnectAgent({agentId:L.agentId,reason:`auth_failure: code=${L.code} ${L.message}`}),G.info("agent disconnected due to auth failure from heartbeat response",{agentId:L.agentId,code:L.code,message:L.message})}catch(F){G.warn("disconnect during authFailure handling failed (ignored)",{agentId:L.agentId,err:String(F)})}}))};o.onConnect(({initial:D})=>{G.info("frontier upstream connected, triggering detail sync",{initial:D}),R.syncAll(D?"initial-connect":"reconnect").catch(L=>G.warn("detail sync top-level error (ignored)",{err:String(L)}))});let w=new Xs({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let D=f.getMockScenario();return{running:!0,pid:process.pid,agents:[...f.agents.keys()],deviceId:_??"",frameworksCache:i.frameworksCache??{},...D?{mockScenario:D}:{}}}},{method:"POST",path:"/pair",handler:async D=>{let L=D,F=L?.privatecode,j=L?.pairing_code;if(!F||!j)throw new C("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let ie=fi(L.env),de=L.handshake_url,me=L.frontier_url,Le=Oh(L.env,de,me),dt=!!x&&x!==F,Ie=m!==void 0&&m!==Le,Wt=dt||Ie,we=await ac({privatecode:F,...de?{endpoint:de}:{},ppeOverride:ie});if(Wt){G.warn("pair config switched, resetting agents",{pcChanged:dt,envChanged:Ie,previousPc:x?So(x):"",nextPc:So(F),previousEnvKey:m??"",nextEnvKey:Le});for(let pe of[...f.agents.values()])await pe.dispose("pair config switch").catch(()=>{}),f.agents.delete(pe.agentId);f.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on pair config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await o.swap(new Dr,"pair switch").catch(()=>{})}_=we.deviceId,Ni({deviceId:_,pid:process.pid}),bc({patToken:F,env:L.env}).catch(pe=>G.warn("coze-cli setup error (ignored)",{err:String(pe)}));let Z=new ki({handshake:we,privatecode:F,...me?{urlOverride:me}:{},ppeOverride:ie,getPatTokenForAgent:pe=>f.agents.get(pe)?.patToken});await o.swap(Z,"pair");try{let pe=new xn;i.frameworksCache=await pe.detectAll(),await br(i),G.info("frameworks_cache refreshed before pair",{detected:Object.keys(i.frameworksCache)})}catch(pe){G.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(pe)})}let Fn=Object.keys(i.frameworksCache??{});try{let pe=await f.sendRequest("_agent/pair",{pairCode:j,patToken:F,frameworks:Fn,_meta:{cozeDeviceId:_}});G.info("_agent/pair ok",{pairResult:pe}),x=F,m=Le,A=ie,y=de,L.mock_scenario!==void 0&&(f.setMockScenario(L.mock_scenario),G.info("mock scenario set",{scenario:L.mock_scenario})),Di(F,c).catch(Ke=>G.warn("writePatToken after /pair failed (ignored)",{err:String(Ke)})),E||(E=new hi({core:f,getDeviceId:()=>_??"",onTickEnd:()=>R.retryPending().catch(Ke=>G.warn("detailSync.retryPending failed (ignored)",{err:String(Ke)})),onAuthFailures:P})),E.start(),Wt&&Io(c,h).catch(Ke=>G.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ke)}));let Un;return L.agent_id&&(Un=await rE(L.agent_id,c,h,Ke=>f.sendRequest("_agent/detail",Ke),F).catch(Ke=>(G.error("--agent-id ensureAgent failed",{agentId:L.agent_id,err:String(Ke)}),{ok:!1,agentId:L.agent_id??"",note:String(Ke)}))),{ok:!0,note:"paired with cloud",...Un?{agent:Un}:{}}}catch(pe){return G.error("_agent/pair failed",{err:String(pe)}),{ok:!1,note:`pair failed: ${String(pe)}`}}}},{method:"POST",path:"/connect",handler:async D=>{let L=D,F=L?.privatecode;if(!F)throw new C("IPC_BAD_REQUEST","/connect requires privatecode");let j=fi(L.env),ie=L.handshake_url,de=L.frontier_url,me=Oh(L.env,ie,de);if(x===F&&m===me){let Z=await tE(c);return f.agents.size===0&&Z?(G.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Io(c,h).catch(Fn=>G.warn("connect-noop auto-revive error (ignored)",{err:String(Fn)}))):G.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Le=!!x&&x!==F,dt=m!==void 0&&m!==me,Ie=Le||dt,Wt=await ac({privatecode:F,...ie?{endpoint:ie}:{},ppeOverride:j});if(Ie){G.warn("connect config switched, resetting agents",{pcChanged:Le,envChanged:dt,previousPc:x?So(x):"",nextPc:So(F)});for(let Z of[...f.agents.values()])await Z.dispose("connect config switch").catch(()=>{}),f.agents.delete(Z.agentId);f.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on connect config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await o.swap(new Dr,"connect switch").catch(()=>{})}_=Wt.deviceId,Ni({deviceId:_,pid:process.pid}),bc({patToken:F,env:L.env}).catch(Z=>G.warn("coze-cli setup error (ignored)",{err:String(Z)}));let we=new ki({handshake:Wt,privatecode:F,...de?{urlOverride:de}:{},ppeOverride:j,getPatTokenForAgent:Z=>f.agents.get(Z)?.patToken});return await o.swap(we,"connect"),x=F,m=me,A=j,y=ie,L.mock_scenario!==void 0&&(f.setMockScenario(L.mock_scenario),G.info("mock scenario set",{scenario:L.mock_scenario})),E||(E=new hi({core:f,getDeviceId:()=>_??"",onTickEnd:()=>R.retryPending().catch(Z=>G.warn("detailSync.retryPending failed (ignored)",{err:String(Z)})),onAuthFailures:P})),E.start(),Ie&&Io(c,h).catch(Z=>G.warn("post-connect-switch auto-revive error (ignored)",{err:String(Z)})),Di(F,c).catch(Z=>G.warn("writePatToken after /connect failed (ignored)",{err:String(Z)})),G.info("/connect: WS established",{deviceId:_}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async D=>{let L=D;return{ok:!0,result:await h.createAgent(L)}}},{method:"POST",path:"/agent/send",handler:async D=>{let L=D;if(!L?.agentId||!L?.sessionId||!L?.kind||!L?.path)throw new C("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!x)throw new C("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let F=L;return await(F.groupFile?U0:F0)(F,{core:f,patToken:x,handshakeBase:y,ppeOverride:A})}catch(F){if(F instanceof C)return{ok:!1,code:F.code,message:F.message};throw F}}},{method:"POST",path:"/refresh",handler:async()=>{G.info("IPC /refresh: re-detecting frameworks");let D=new xn;return i.frameworksCache=await D.detectAll(),await br(i),{ok:!0,frameworks:i.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(G.info("IPC /shutdown received"),setImmediate(()=>{B.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:T,token:k}=await w.start();try{await Ah(c.libEntry,c)}catch(D){G.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(D)})}await f.start(),Io(c,h).catch(D=>G.warn("auto-revive top-level error (ignored)",{err:String(D)})),Gd().then(async()=>{let{probeAcpVersion:D}=await Promise.resolve().then(()=>(yn(),Hd));for(let L of["claude-code","codex"]){let F=await D(L);F&&G.info("acp wrapper version",{framework:L,version:F})}}).catch(D=>G.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(D)}));let z=null,B={port:T,token:k,core:f,ipc:w,shutdown(D){return z||(G.info("daemon shutdown",{reason:D}),z=(async()=>{E?.stop(),await f.stop(D),await w.stop(),await t.release()})(),z)}};for(let D of["SIGTERM","SIGINT"])process.on(D,()=>{B.shutdown(D).then(()=>process.exit(0))});return process.on("unhandledRejection",D=>{G.error("unhandledRejection",{reason:D instanceof Error?D.message:String(D),stack:D instanceof Error?D.stack:void 0})}),process.on("uncaughtException",D=>{G.error("uncaughtException (will exit, supervisor will restart)",{message:D.message,stack:D.stack,name:D.name}),process.exit(1)}),G.info("daemon ready",{port:T,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(i.frameworksCache??{}),libVersion:i.libVersion??"dev"}),B}async function tE(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 Oh(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function nE(t,e){let{readdir:r}=await import("node:fs/promises"),i;try{i=await r(t.agentsRoot)}catch{return}let{loadAgentConfig:o,enforceAgentConfigMode:c}=await Promise.resolve().then(()=>(Zt(),ji));for(let l of i){await c(l,t).catch(f=>G.warn("enforceAgentConfigMode failed (ignored)",{agentId:l,err:String(f)}));try{let f=await o(l,t);f?.disconnectedAt&&(e.disconnectedAgents.add(l),G.info("agent marked disconnected on startup",{agentId:l,disconnectedAt:f.disconnectedAt,reason:f.disconnectReason??""}))}catch(f){G.warn("failed to load agent config on startup, skipping",{agentId:l,err:String(f)})}}}async function rE(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Zt(),ji)),l=await c(t,e);if(l){G.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let m={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{}};return await r.createAgent(m),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}G.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let f=await i({_meta:{cozeAgentId:t}});if(!f.framework)throw new C("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 h={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...o?{patToken:o}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await r.createAgent(h);let x=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:t,note:x?"cloud agent acknowledged":"created from cloud detail"}}async function Io(t,e){let{readdir:r}=await import("node:fs/promises"),i;try{i=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(i.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:o}=await Promise.resolve().then(()=>(Zt(),ji));G.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let f of i){let h;try{h=await o(f,t)}catch(x){G.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(x)}),l+=1;continue}if(!h){l+=1;continue}if(h.disconnectedAt){G.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:h.disconnectedAt}),l+=1;continue}try{G.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:h.framework});let x=iE(h);await e.createAgent({agentId:h.agentId,framework:h.framework,...h.cozeIdentity?{cozeIdentity:h.cozeIdentity}:{},...h.model?{model:h.model}:{},...x?{_meta:x}:{}}),c+=1}catch(x){G.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:h.framework,err:String(x)}),l+=1}}return G.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}function iE(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 Lh}from"node:fs/promises";var jt=class{paths;constructor(e){this.paths=e??ee()}async probe(e=1e3){let r=await Ao(this.paths);if(!r)return{kind:"not-running"};try{let i=await this.fetch(r,{method:"GET",path:"/status",timeoutMs:e});return i.status===200?{kind:"connected",...r}:{kind:"stale",reason:`unexpected status ${i.status}`}}catch(i){return{kind:"stale",reason:uE(i)}}}async request(e){let r=await Ao(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 i=r.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,l=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let f=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:o,body:i?JSON.stringify(r.body):void 0,signal:c.signal}),h=await f.text();return{status:f.status,body:fE(h)}}finally{clearTimeout(l)}}};async function Ao(t){try{let[e,r]=await Promise.all([Lh(t.portFile,"utf8"),Lh(t.tokenFile,"utf8")]),i=Number.parseInt(e.trim(),10),o=r.trim();return!Number.isFinite(i)||i<=0||!o?null:{port:i,token:o}}catch(e){if(e.code==="ENOENT")return null;throw e}}function fE(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function uE(t){return t instanceof Error?t.message:String(t)}Q();Be();import{copyFile as Nh,mkdir as hE,readFile as ed,writeFile as xE}from"node:fs/promises";import{homedir as WT}from"node:os";import{dirname as pE,resolve as td,sep as To}from"node:path";import{fileURLToPath as gE}from"node:url";Q();Be();var Mh=q("dist-install");function mE(t){let e=gE(t),r=pE(e),i=`${To}src${To}`;if(r.includes(i)||r.endsWith(`${To}src${To}cli`))return null;let o=td(r,"index.js"),c=td(r,"..","package.json");return{dist:o,pkgJson:c}}async function nd(t={}){let e=t.paths??ee(),r=mE(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c;try{c=JSON.parse(await ed(o,"utf8")).version??"unknown"}catch(_){return Mh.warn("cannot read source package.json,skip dist install",{err:String(_)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(_)}`}}let l=await Zs(e.configFile)??{},f=l.libVersion;if(f===c)try{return await ed(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await hE(e.libDir,{recursive:!0}),await Nh(i,e.libEntry),await Nh(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let h=td(e.libDir,"package.json"),x=`${JSON.stringify({type:"module"},null,2)}
|
|
93
|
-
`;return await
|
|
92
|
+
`}async function Ax(t,e=ne()){let r=e.binDir;await So.mkdir(r,{recursive:!0});let s=Kb(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.execPath,c=process.platform==="win32"?Zb(t,a):$b(t,a);return await So.readFile(s,"utf8").catch(()=>null)===c||(await So.writeFile(s,c,"utf8"),process.platform!=="win32"&&await So.chmod(s,493)),r}te();Fe();import{execSync as Rx}from"node:child_process";import{readFileSync as Dx,unlinkSync as Vb}from"node:fs";import{mkdir as Jb,readFile as kx,unlink as Lx,writeFile as Yb}from"node:fs/promises";import{dirname as Xb}from"node:path";function Tx(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var Qb=H("single-instance"),Io=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??ne().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&&(Qb.warn("removing stale pid file",{stalePid:e}),await Lx(this.pidFile).catch(()=>{})),await Jb(Xb(this.pidFile),{recursive:!0}),await Yb(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await kx(this.pidFile,"utf8")).trim()===String(process.pid)&&await Lx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await kx(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 Tx(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Dx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=Rx(`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=Rx(`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{Dx(this.pidFile,"utf8").trim()===String(process.pid)&&Vb(this.pidFile)}catch{}})}};var W=H("daemon"),eE="coze-bridge-daemon";async function Ox(){let t=new Io({processTitle:eE}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Xs(),s=r??{};Bi({pid:process.pid}),W.info(r?"loaded bridge config":"initialized bridge config");try{let k=new hn;s.frameworksCache=await k.detectAll(),W.info("refreshed frameworks_cache",{detected:Object.keys(s.frameworksCache)})}catch(k){W.warn("framework detection failed",{err:String(k)})}await br(s);let a=new vo(new Dr),c=ne(),f=null,u=new Qs({upstream:a,paths:c,bridgeConfig:s,sessionSpawner:async(k,M,F,K)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(k,M,F,K)}});await nE(c,u);let x=new Vs({paths:c,config:s,registry:u});f=x;let p,_,E=null,C={},y,b=null;u.registerExtension("_agent/create",async k=>x.createAgent(k.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let S={},I=new Us({agents:u.agents,disposeAndMarkDisconnected:async(k,M)=>{let F=u.agents.get(k);if(F){await x.cleanupOpenclawSessionProviders(F).catch(oe=>W.warn("cleanup openclaw providers failed (ignored)",{agentId:k,err:String(oe)}));let K=!0;try{await F.dispose(`disconnect: ${M}`)}catch(oe){K=!1,W.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:k,err:String(oe)}),F.status="error"}K&&(F.status="disconnected",u.unregister(k),u.disconnectedAgents.add(k))}else u.disconnectedAgents.add(k)},detailSyncer:async k=>{if(!S.ref)throw new Error("agent-detail-sync not initialized yet");await S.ref.syncOne(k)},cleanupOpenclawProviders:async k=>{await x.cleanupOpenclawSessionProviders(k)},openclawRepair:async(k,M)=>{await x.openclawRepair(k,M)},isRuntimePendingPermission:k=>u.hasPendingPermissionFor(k)});u.registerExtension("_agent/listSkills",k=>I.listSkills(k.params)),u.registerExtension("_agent/addSkills",k=>I.addSkills(k.params)),u.registerExtension("_agent/removeSkills",k=>I.removeSkills(k.params)),u.registerExtension("_agent/getFileTree",k=>I.getFileTree(k.params)),u.registerExtension("_agent/getFileContent",k=>I.getFileContent(k.params)),u.registerExtension("_agent/update",k=>I.updateAgent(k.params)),u.registerExtension("_agent/disconnect",k=>I.disconnectAgent(k.params)),u.registerExtension("_agent/switchModel",k=>I.switchModel(k.params)),u.registerExtension("_agent/reset",k=>I.resetAgent(k.params)),u.registerExtension("_agent/repair",k=>I.repairAgent(k.params));let R=new $i({paths:c,handlers:I,sendDetail:k=>u.sendRequest("_agent/detail",k)});S.ref=R;let P=async k=>{await Promise.allSettled(k.map(async M=>{try{await I.disconnectAgent({agentId:M.agentId,reason:`auth_failure: code=${M.code} ${M.message}`}),W.info("agent disconnected due to auth failure from heartbeat response",{agentId:M.agentId,code:M.code,message:M.message})}catch(F){W.warn("disconnect during authFailure handling failed (ignored)",{agentId:M.agentId,err:String(F)})}}))};a.onConnect(({initial:k})=>{W.info("frontier upstream connected, triggering detail sync",{initial:k}),R.syncAll(k?"initial-connect":"reconnect").catch(M=>W.warn("detail sync top-level error (ignored)",{err:String(M)}))});let w=new eo({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let k=u.getMockScenario();return{running:!0,pid:process.pid,agents:[...u.agents.keys()],deviceId:E??"",frameworksCache:s.frameworksCache??{},...k?{mockScenario:k}:{}}}},{method:"POST",path:"/pair",handler:async k=>{let M=k,F=M?.privatecode,K=M?.pairing_code;if(!F||!K)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let oe=xi(M.env),le=M.handshake_url,be=M.frontier_url,Be=Px(M.env,le,be),ct=!!p&&p!==F,Re=_!==void 0&&_!==Be,Wt=ct||Re,Ee=await cc({privatecode:F,...le?{endpoint:le}:{},ppeOverride:oe});if(Wt){W.warn("pair config switched, resetting agents",{pcChanged:ct,envChanged:Re,previousPc:p?Co(p):"",nextPc:Co(F),previousEnvKey:_??"",nextEnvKey:Be});for(let _e of[...u.agents.values()])await _e.dispose("pair config switch").catch(()=>{}),u.agents.delete(_e.agentId);u.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await a.swap(new Dr,"pair switch").catch(()=>{})}E=Ee.deviceId,Bi({deviceId:E,pid:process.pid}),vc({patToken:F,env:M.env}).catch(_e=>W.warn("coze-cli setup error (ignored)",{err:String(_e)}));let Y=new Li({handshake:Ee,privatecode:F,...be?{urlOverride:be}:{},ppeOverride:oe,getPatTokenForAgent:_e=>u.agents.get(_e)?.patToken});await a.swap(Y,"pair");try{let _e=new hn;s.frameworksCache=await _e.detectAll(),await br(s),W.info("frameworks_cache refreshed before pair",{detected:Object.keys(s.frameworksCache)})}catch(_e){W.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(_e)})}let zn=Object.keys(s.frameworksCache??{});try{let _e=await u.sendRequest("_agent/pair",{pairCode:K,patToken:F,frameworks:zn,_meta:{cozeDeviceId:E}});W.info("_agent/pair ok",{pairResult:_e}),p=F,_=Be,C=oe,y=le,M.mock_scenario!==void 0&&(u.setMockScenario(M.mock_scenario),W.info("mock scenario set",{scenario:M.mock_scenario})),Pi(F,c).catch($e=>W.warn("writePatToken after /pair failed (ignored)",{err:String($e)})),b||(b=new pi({core:u,getDeviceId:()=>E??"",onTickEnd:()=>R.retryPending().catch($e=>W.warn("detailSync.retryPending failed (ignored)",{err:String($e)})),onAuthFailures:P})),b.start(),Wt&&Ao(c,x).catch($e=>W.warn("post-pair-switch auto-revive error (ignored)",{err:String($e)}));let Fn;return M.agent_id&&(Fn=await rE(M.agent_id,c,x,$e=>u.sendRequest("_agent/detail",$e),F).catch($e=>(W.error("--agent-id ensureAgent failed",{agentId:M.agent_id,err:String($e)}),{ok:!1,agentId:M.agent_id??"",note:String($e)}))),{ok:!0,note:"paired with cloud",...Fn?{agent:Fn}:{}}}catch(_e){return W.error("_agent/pair failed",{err:String(_e)}),{ok:!1,note:`pair failed: ${String(_e)}`}}}},{method:"POST",path:"/connect",handler:async k=>{let M=k,F=M?.privatecode;if(!F)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let K=xi(M.env),oe=M.handshake_url,le=M.frontier_url,be=Px(M.env,oe,le);if(p===F&&_===be){let Y=await tE(c);return u.agents.size===0&&Y?(W.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Ao(c,x).catch(zn=>W.warn("connect-noop auto-revive error (ignored)",{err:String(zn)}))):W.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Be=!!p&&p!==F,ct=_!==void 0&&_!==be,Re=Be||ct,Wt=await cc({privatecode:F,...oe?{endpoint:oe}:{},ppeOverride:K});if(Re){W.warn("connect config switched, resetting agents",{pcChanged:Be,envChanged:ct,previousPc:p?Co(p):"",nextPc:Co(F)});for(let Y of[...u.agents.values()])await Y.dispose("connect config switch").catch(()=>{}),u.agents.delete(Y.agentId);u.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await a.swap(new Dr,"connect switch").catch(()=>{})}E=Wt.deviceId,Bi({deviceId:E,pid:process.pid}),vc({patToken:F,env:M.env}).catch(Y=>W.warn("coze-cli setup error (ignored)",{err:String(Y)}));let Ee=new Li({handshake:Wt,privatecode:F,...le?{urlOverride:le}:{},ppeOverride:K,getPatTokenForAgent:Y=>u.agents.get(Y)?.patToken});return await a.swap(Ee,"connect"),p=F,_=be,C=K,y=oe,M.mock_scenario!==void 0&&(u.setMockScenario(M.mock_scenario),W.info("mock scenario set",{scenario:M.mock_scenario})),b||(b=new pi({core:u,getDeviceId:()=>E??"",onTickEnd:()=>R.retryPending().catch(Y=>W.warn("detailSync.retryPending failed (ignored)",{err:String(Y)})),onAuthFailures:P})),b.start(),Re&&Ao(c,x).catch(Y=>W.warn("post-connect-switch auto-revive error (ignored)",{err:String(Y)})),Pi(F,c).catch(Y=>W.warn("writePatToken after /connect failed (ignored)",{err:String(Y)})),W.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async k=>{let M=k;return{ok:!0,result:await x.createAgent(M)}}},{method:"POST",path:"/agent/send",handler:async k=>{let M=k;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 F=M;return await(F.groupFile?Ul:Fl)(F,{core:u,patToken:p,handshakeBase:y,ppeOverride:C})}catch(F){if(F instanceof T)return{ok:!1,code:F.code,message:F.message};throw F}}},{method:"POST",path:"/refresh",handler:async()=>{W.info("IPC /refresh: re-detecting frameworks");let k=new hn;return s.frameworksCache=await k.detectAll(),await br(s),{ok:!0,frameworks:s.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(W.info("IPC /shutdown received"),setImmediate(()=>{B.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:A,token:D}=await w.start();try{await Ax(c.libEntry,c)}catch(k){W.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(k)})}await u.start(),Ao(c,x).catch(k=>W.warn("auto-revive top-level error (ignored)",{err:String(k)})),j0().then(async()=>{let{probeAcpVersion:k}=await Promise.resolve().then(()=>(wn(),q0));for(let M of["claude-code","codex"]){let F=await k(M);F&&W.info("acp wrapper version",{framework:M,version:F})}}).catch(k=>W.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(k)}));let z=null,B={port:A,token:D,core:u,ipc:w,shutdown(k){return z||(W.info("daemon shutdown",{reason:k}),z=(async()=>{b?.stop(),await u.stop(k),await w.stop(),await t.release()})(),z)}};for(let k of["SIGTERM","SIGINT"])process.on(k,()=>{B.shutdown(k).then(()=>process.exit(0))});return process.on("unhandledRejection",k=>{W.error("unhandledRejection",{reason:k instanceof Error?k.message:String(k),stack:k instanceof Error?k.stack:void 0})}),process.on("uncaughtException",k=>{W.error("uncaughtException (will exit, supervisor will restart)",{message:k.message,stack:k.stack,name:k.name}),process.exit(1)}),W.info("daemon ready",{port:A,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(s.frameworksCache??{}),libVersion:s.libVersion??"dev"}),B}async function tE(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function Co(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Px(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function nE(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(()=>(Jt(),Ki));for(let f of s){await c(f,t).catch(u=>W.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(u)}));try{let u=await a(f,t);u?.disconnectedAt&&(e.disconnectedAgents.add(f),W.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:u.disconnectedAt,reason:u.disconnectReason??""}))}catch(u){W.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(u)})}}}async function rE(t,e,r,s,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Jt(),Ki)),f=await c(t,e);if(f){W.info("--agent-id: local config found, reconnecting",{agentId:t,framework:f.framework,hadDisconnect:!!f.disconnectedAt});let _={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{}};return await r.createAgent(_),{ok:!0,agentId:t,note:f.disconnectedAt?"revived from local config":"connected from local config"}}W.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 T("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 p=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function Ao(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(()=>(Jt(),Ki));W.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(p){W.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(p)}),f+=1;continue}if(!x){f+=1;continue}if(x.disconnectedAt){W.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),f+=1;continue}try{W.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let p=iE(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...p?{_meta:p}:{}}),c+=1}catch(p){W.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:x.framework,err:String(p)}),f+=1}}return W.info("auto-revive: done",{revived:c,skipped:f,total:s.length}),{revived:c,skipped:f,total:s.length}}function iE(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}e0();Fe();import{readFile as Nx}from"node:fs/promises";var Gt=class{paths;constructor(e){this.paths=e??ne()}async probe(e=1e3){let r=await To(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:uE(s)}}}async request(e){let r=await To(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:lE(x)}}finally{clearTimeout(f)}}};async function To(t){try{let[e,r]=await Promise.all([Nx(t.portFile,"utf8"),Nx(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 lE(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function uE(t){return t instanceof Error?t.message:String(t)}te();Fe();import{copyFile as Mx,mkdir as xE,readFile as t0,writeFile as hE}from"node:fs/promises";import{homedir as WC}from"node:os";import{dirname as pE,resolve as n0,sep as Ro}from"node:path";import{fileURLToPath as gE}from"node:url";te();Fe();var Bx=H("dist-install");function mE(t){let e=gE(t),r=pE(e),s=`${Ro}src${Ro}`;if(r.includes(s)||r.endsWith(`${Ro}src${Ro}cli`))return null;let a=n0(r,"index.js"),c=n0(r,"..","package.json");return{dist:a,pkgJson:c}}async function r0(t={}){let e=t.paths??ne(),r=mE(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"};if(s===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c;try{c=JSON.parse(await t0(a,"utf8")).version??"unknown"}catch(E){return Bx.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 Xs(e.configFile)??{},u=f.libVersion;if(u===c)try{return await t0(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await xE(e.libDir,{recursive:!0}),await Mx(s,e.libEntry),await Mx(`${s}.map`,`${e.libEntry}.map`).catch(()=>{});let x=n0(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
|
|
93
|
+
`;return await t0(x,"utf8").catch(()=>null)!==p&&await hE(x,p),f.libVersion=c,await br(f,e.configFile),Bx.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 wE,resolve as _E}from"node:path";Fe();var yE=9e4,bE={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,AGENT_DEPENDENCY_INSTALL_FAILED:1};function EE(t){return bE[t]??1}async function zx(t,e={}){let r=e.paths??ne();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>
|
|
94
94
|
`),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.
|
|
95
|
-
`),3;let
|
|
96
|
-
`),4;let
|
|
95
|
+
`),3;let s=await To(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.
|
|
96
|
+
`),4;let a={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:_E(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 vE(s,"/agent/send",a,yE)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
|
|
97
97
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
98
|
-
`),
|
|
99
|
-
`);else{let
|
|
100
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${
|
|
101
|
-
`)}return 0}async function vE(t,e,r,
|
|
102
|
-
`)}function
|
|
98
|
+
`),EE(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
99
|
+
`);else{let f=t.name??wE(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})
|
|
100
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${f} (${SE(c.bytes)})
|
|
101
|
+
`)}return 0}async function vE(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 SE(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Kx=H("cli");function qe(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 Oi(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
102
|
+
`)}function jE(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 GE(e.slice(1));if(e[0]==="connect")return WE(e.slice(1));if(e.includes("--status"))return Oi("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return Oi("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return Oi("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return Oi("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return Oi("--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}=qe(r,"--pat-token");r=a;let{value:c,rest:f}=qe(r,"--pair-code");r=f;let{value:u,rest:x}=qe(r,"--env");r=x;let{value:p,rest:_}=qe(r,"--handshake-url");r=_;let{value:E,rest:C}=qe(r,"--frontier-url");r=C;let{value:y,rest:b}=qe(r,"--mock-scenario");r=b;let{value:S}=qe(r,"--agent-id");if(!s||!c)return{mode:"help"};let I={mode:"pair",privatecode:s,pairingCode:c};return u&&(I.env=u),p&&(I.handshakeUrl=p),E&&(I.frontierUrl=E),y&&(I.mockScenario=y),S&&(I.agentId=S),I}function GE(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}=qe(s,"--caption");s=c;let{value:f,rest:u}=qe(s,"--name");s=u;let{value:x,rest:p}=qe(s,"--agent-id");s=p;let{value:_,rest:E}=qe(s,"--session-id");s=E;let{value:C,rest:y}=qe(s,"--mime");s=y;let b=s.includes("--group-file");s=s.filter(R=>R!=="--group-file");let S=s.includes("--json"),I={mode:"send",kind:e,path:r,json:S};return a&&(I.caption=a),f&&(I.name=f),x&&(I.agentId=x),_&&(I.sessionId=_),b&&(I.groupFile=!0),C&&(I.mimeType=C),I}function WE(t){let e=t,{value:r,rest:s}=qe(e,"--pat-token");e=s;let{value:a,rest:c}=qe(e,"--env");e=c;let{value:f,rest:u}=qe(e,"--handshake-url");e=u;let{value:x,rest:p}=qe(e,"--frontier-url");e=p;let{value:_,rest:E}=qe(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),_&&(C.mockScenario=_),C}var KE=`
|
|
103
103
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
104
104
|
|
|
105
105
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -166,46 +166,46 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
166
166
|
|
|
167
167
|
Internal:
|
|
168
168
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
169
|
-
`.trimStart();async function
|
|
170
|
-
`),0;case"daemon":{try{await
|
|
171
|
-
`),1;if(
|
|
172
|
-
`),1;let
|
|
173
|
-
${JSON.stringify(
|
|
174
|
-
`),0}async function
|
|
175
|
-
`),0;if(
|
|
169
|
+
`.trimStart();async function $x(t=process.argv,e={}){let r=jE(t);switch(r.mode){case"help":return process.stdout.write(KE),0;case"version":return process.stdout.write(`${pr}
|
|
170
|
+
`),0;case"daemon":{try{await Ox()}catch(s){return Kx.error("daemon start failed",{err:String(s)}),1}return new Promise(()=>{})}case"status":return $E(e);case"stop":return ZE(e);case"refresh":return VE(e);case"purge":return JE(e);case"service-install":return YE(e);case"service-uninstall":return XE(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),QE(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),ev(r.privatecode,e,s)}case"send":return zx({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 Zx(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 $E(t){let e=t.paths??ne(),r=new Gt(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
171
|
+
`),1;if(s.kind==="stale")return await Zx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
172
|
+
`),1;let a=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
173
|
+
${JSON.stringify(a.body,null,2)}
|
|
174
|
+
`),0}async function ZE(t){let e=t.paths??ne(),r=new Gt(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
175
|
+
`),0;if(s.kind==="stale")return await Zx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
176
176
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
177
|
-
`),0}catch(
|
|
178
|
-
`),1}}async function
|
|
179
|
-
`),1;try{let
|
|
180
|
-
${JSON.stringify(
|
|
181
|
-
`),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(
|
|
182
|
-
`),1)}catch(
|
|
183
|
-
`),1}}async function
|
|
184
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
185
|
-
`)}await new Promise(
|
|
186
|
-
`)}catch(
|
|
187
|
-
`)}let
|
|
188
|
-
`)}catch(
|
|
177
|
+
`),0}catch(a){return process.stdout.write(`coze-bridge: stop failed: ${String(a)}
|
|
178
|
+
`),1}}async function VE(t){let e=new Gt(t.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
179
|
+
`),1;try{let s=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return s.status===200?(process.stdout.write(`coze-bridge: refreshed
|
|
180
|
+
${JSON.stringify(s.body,null,2)}
|
|
181
|
+
`),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(s.body)}
|
|
182
|
+
`),1)}catch(s){return process.stderr.write(`coze-bridge: refresh failed: ${String(s)}
|
|
183
|
+
`),1}}async function d0(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(()=>(Wx(),Gx)),s=e(),a=r();return{platform:s.platform,install:()=>s.install(a),uninstall:()=>s.uninstall(a)}}async function JE(t){let e=new Gt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
184
|
+
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(f){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(f)}
|
|
185
|
+
`)}await new Promise(f=>setTimeout(f,500))}let s=await d0(t);if(s)try{await s.uninstall(),process.stdout.write(`coze-bridge: ${s.platform} supervisor unregistered
|
|
186
|
+
`)}catch(f){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(f)}
|
|
187
|
+
`)}let a=t.paths??ne(),{rm:c}=await import("node:fs/promises");try{await c(a.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.bridgeRoot}
|
|
188
|
+
`)}catch(f){return process.stderr.write(`coze-bridge: remove failed: ${String(f)}
|
|
189
189
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
190
|
-
`),0}async function YE(t){let e=await
|
|
190
|
+
`),0}async function YE(t){let e=await d0(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
191
191
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
192
192
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
193
|
-
`),1}}async function XE(t){let e=await
|
|
193
|
+
`),1}}async function XE(t){let e=await d0(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
194
194
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
195
|
-
`),1}}async function QE(t,e,r,
|
|
196
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
197
|
-
`)}let
|
|
198
|
-
`),await
|
|
199
|
-
`),1;let
|
|
195
|
+
`),1}}async function QE(t,e,r,s={},a){let c=new Gt(r.paths),f=r.spawnDaemon??Qc;if(!r.skipDistInstall){let p=await r0({paths:r.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
|
|
196
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
|
|
197
|
+
`)}let u=await c.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
198
|
+
`),await f({paths:r.paths}),u=await Vx(c,r.waitTimeoutMs??1e4,r.sleep??Jx),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
|
|
199
|
+
`),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 p=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(p.status===200&&p.body?.ok){let _=p.body.agent;return _&&!_.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${_.agentId}): ${_.note}
|
|
200
200
|
`),1):(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"
|
|
201
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
202
|
-
`),1}catch(
|
|
203
|
-
`),1}}async function
|
|
204
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
205
|
-
`)}let
|
|
206
|
-
`),await
|
|
207
|
-
`),1;let
|
|
208
|
-
`),await
|
|
209
|
-
`),1)}catch(
|
|
210
|
-
`),1}}async function
|
|
201
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
|
|
202
|
+
`),1}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
|
|
203
|
+
`),1}}async function ev(t,e,r={}){let s=e.paths??ne(),a=t??await Cx(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 Gt(e.paths),f=e.spawnDaemon??Qc;if(!e.skipDistInstall){let p=await r0({paths:e.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
|
|
204
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
|
|
205
|
+
`)}let u=await c.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
206
|
+
`),await f({paths:e.paths}),u=await Vx(c,e.waitTimeoutMs??1e4,e.sleep??Jx),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
|
|
207
|
+
`),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 p=await c.request({method:"POST",path:"/connect",body:x,timeoutMs:35e3});return p.status===200&&p.body?.ok?(process.stdout.write(`coze-bridge: connected (${p.body.note??"ok"})
|
|
208
|
+
`),await Pi(a,s).catch(_=>Kx.warn("writePatToken after connect failed (ignored)",{err:String(_)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(p.body)}
|
|
209
|
+
`),1)}catch(p){return process.stderr.write(`coze-bridge: connect failed: ${String(p)}
|
|
210
|
+
`),1}}async function Vx(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 Jx(t){return new Promise(e=>setTimeout(e,t))}te();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&L0("warn");$x(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
211
211
|
`),process.exit(1)});
|