coze-bridge 0.1.82 → 0.1.83-alpha.1
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
|
-
|
|
12
|
-
`,a=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await G0(a,s,{encoding:"utf8",mode:r.mode}):await G0(a,s,"utf8"),await j0(a,t),r?.mode!==void 0&&await yp(t,r.mode)}catch(c){await j0(a,a).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(a,{force:!0}).catch(()=>{}),c}}var Ui=dt(()=>{"use strict"});import{promises as K0}from"node:fs";import{homedir as vp}from"node:os";import{sep as Ip,join as Ne,resolve as W0}from"node:path";function te(t){let e=t??vp(),r=Ne(e,".coze"),s=Ne(r,"bridge"),a=Ne(s,"lib");return{cozeRoot:r,bridgeRoot:s,libDir:a,libEntry:Ne(a,"index.js"),binDir:Ne(s,"bin"),pidFile:Ne(s,"bridge.pid"),portFile:Ne(s,"bridge.port"),tokenFile:Ne(s,"bridge.token"),patTokenFile:Ne(s,"pat-token"),logFile:Ne(s,"bridge.log"),installLock:Ne(s,"install.lock"),configFile:Ne(s,"config.json"),agentsRoot:Ne(r,"agents")}}function kt(t,e=te()){let r=Ne(e.agentsRoot,t);return{root:r,config:Ne(r,"config.json"),workspace:Ne(r,"workspace"),logs:Ne(r,"logs")}}async function Nr(t,e){let r=await K0.realpath(W0(t)).catch(()=>null);if(!r)return!1;let s=await K0.realpath(W0(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+Ip)}var Me=dt(()=>{"use strict"});var ji={};Ko(ji,{AGENT_CONFIG_FILE_MODE:()=>qi,enforceAgentConfigMode:()=>Tp,loadAgentConfig:()=>Ue,persistAgentSessions:()=>Zo,persistAgentSkills:()=>Hi,saveAgentConfig:()=>Ve});import{chmod as Ap,stat as Cp}from"node:fs/promises";function Ue(t,e){return Jn(kt(t,e).config)}function Ve(t,e){return Fi(kt(t.agentId,e).config,t,{mode:qi})}async function Tp(t,e){if(process.platform==="win32")return;let r=kt(t,e).config;try{let s=await Cp(r);if(!s.isFile())return;let a=s.mode&511;a!==qi&&(await Ap(r,qi),$0.warn("agent config mode auto-corrected to 0600",{path:r,from:a.toString(8)}))}catch(s){if(s.code==="ENOENT")return;$0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(s)})}}async function Zo(t,e,r){let s=await Ue(t,r);s&&(s.sessions=Object.fromEntries(e),await Ve(s,r))}async function Hi(t,e,r){let s=await Ue(t,r);s&&(s.skills=e,await Ve(s,r))}var $0,qi,Yt=dt(()=>{"use strict";Ui();ee();Me();$0=H("agent-config"),qi=384});var Xo=ne((K2,Y0)=>{Y0.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Ki=ne(Q0=>{var X0={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 Pp(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(X0))Q0[t]=Pp(X0[t])});var id=ne(($2,rd)=>{var Lp=ae("fs"),be=ae("path"),ed=Xo(),Np=Ki(),Mp=typeof process=="object"&&process.platform==="win32",td=t=>typeof t=="object"&&t!==null,nd=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=be.sep,this.fs=Lp,td(t)&&td(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}rd.exports=he;he.prototype.makeDir=function(t){let e=this;function r(s){let a=s.split(e.sep)[0];s.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){a+=e.sep+c;var f;try{f=e.fs.statSync(a)}catch(l){if(l.message&&l.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw l}if(f&&f.isFile())throw Np.FILE_IN_THE_WAY(`"${a}"`)}})}r(t)};he.prototype.writeFileTo=function(t,e,r,s){let a=this;if(a.fs.existsSync(t)){if(!r)return!1;var c=a.fs.statSync(t);if(c.isDirectory())return!1}var f=be.dirname(t);a.fs.existsSync(f)||a.makeDir(f);var l;try{l=a.fs.openSync(t,"w",438)}catch{a.fs.chmodSync(t,438),l=a.fs.openSync(t,"w",438)}if(l)try{a.fs.writeSync(l,e,0,e.length,0)}finally{a.fs.closeSync(l)}return a.fs.chmodSync(t,s||438),!0};he.prototype.writeFileToAsync=function(t,e,r,s,a){typeof s=="function"&&(a=s,s=void 0);let c=this;c.fs.exists(t,function(f){if(f&&!r)return a(!1);c.fs.stat(t,function(l,x){if(f&&x.isDirectory())return a(!1);var h=be.dirname(t);c.fs.exists(h,function(m){m||c.makeDir(h),c.fs.open(t,"w",438,function(E,C){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,y){c.fs.write(y,e,0,e.length,0,function(){c.fs.close(y,function(){c.fs.chmod(t,s||438,function(){a(!0)})})})})}):C?c.fs.write(C,e,0,e.length,0,function(){c.fs.close(C,function(){c.fs.chmod(t,s||438,function(){a(!0)})})}):c.fs.chmod(t,s||438,function(){a(!0)})})})})})};he.prototype.findFiles=function(t){let e=this;function r(s,a,c){typeof a=="boolean"&&(c=a,a=void 0);let f=[];return e.fs.readdirSync(s).forEach(function(l){let x=be.join(s,l),h=e.fs.statSync(x);(!a||a.test(x))&&f.push(be.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(f=f.concat(r(x,a,c)))}),f}return r(t,void 0,!0)};he.prototype.findFilesAsync=function(t,e){let r=this,s=[];r.fs.readdir(t,function(a,c){if(a)return e(a);let f=c.length;if(!f)return e(null,s);c.forEach(function(l){l=be.join(t,l),r.fs.stat(l,function(x,h){if(x)return e(x);h&&(s.push(be.normalize(l)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(l,function(m,E){if(m)return e(m);s=s.concat(E),--f||e(null,s)}):--f||e(null,s))})})})};he.prototype.getAttributes=function(){};he.prototype.setAttributes=function(){};he.crc32update=function(t,e){return nd[(t^e)&255]^t>>>8};he.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let s=0;s<e;)r=he.crc32update(r,t[s++]);return~r>>>0};he.methodToString=function(t){switch(t){case ed.STORED:return"STORED ("+t+")";case ed.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};he.canonical=function(t){if(!t)return"";let e=be.posix.normalize("/"+t.split("\\").join("/"));return be.join(".",e)};he.zipnamefix=function(t){if(!t)return"";let e=be.posix.normalize("/"+t.split("\\").join("/"));return be.posix.join(".",e)};he.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let s=r-1;s>=0;s--)if(e(t[s],s,t))return t[s]};he.sanitize=function(t,e){t=be.resolve(be.normalize(t));for(var r=e.split("/"),s=0,a=r.length;s<a;s++){var c=be.normalize(be.join(t,r.slice(s,a).join(be.sep)));if(c.indexOf(t)===0)return c}return be.normalize(be.join(t,be.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=Mp;he.crcTable=nd});var od=ne((V2,sd)=>{var Bp=ae("path");sd.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=Bp.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 cd=ne((J2,ad)=>{ad.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Xn=ne((Z2,Yn)=>{Yn.exports=id();Yn.exports.Constants=Xo();Yn.exports.Errors=Ki();Yn.exports.FileAttr=od();Yn.exports.decoder=cd()});var fd=ne((Y2,dd)=>{var Xt=Xn(),q=Xt.Constants;dd.exports=function(){var t=20,e=10,r=0,s=0,a=0,c=0,f=0,l=0,x=0,h=0,m=0,E=0,C=0,_=0,y=0;t|=Xt.isWin?2560:768,r|=q.FLG_EFS;let v={extraLen:0},I=w=>Math.max(0,w)>>>0,R=w=>Math.max(0,w)&65535,L=w=>Math.max(0,w)&255;return a=Xt.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 Xt.fromDOS2Date(this.timeval)},set time(w){w=new Date(w),this.timeval=Xt.fromDate2DOS(w)},get timeval(){return a},set timeval(w){a=I(w)},get timeHighByte(){return L(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 l},set size(w){l=I(w)},get fileNameLength(){return x},set fileNameLength(w){x=w},get extraLength(){return h},set extraLength(w){h=w},get extraLocalLength(){return v.extraLen},set extraLocalLength(w){v.extraLen=w},get commentLength(){return m},set commentLength(w){m=w},get diskNumStart(){return E},set diskNumStart(w){E=I(w)},get inAttr(){return C},set inAttr(w){C=I(w)},get attr(){return _},set attr(w){_=I(w)},get fileAttr(){return(_||0)>>16&4095},get offset(){return y},set offset(w){y=I(w)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+h+m},get realDataOffset(){return y+q.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(w){var A=w.slice(y,y+q.LOCHDR);if(A.readUInt32LE(0)!==q.LOCSIG)throw Xt.Errors.INVALID_LOC();v.version=A.readUInt16LE(q.LOCVER),v.flags=A.readUInt16LE(q.LOCFLG),v.flags_desc=(v.flags&q.FLG_DESC)>0,v.method=A.readUInt16LE(q.LOCHOW),v.time=A.readUInt32LE(q.LOCTIM),v.crc=A.readUInt32LE(q.LOCCRC),v.compressedSize=A.readUInt32LE(q.LOCSIZ),v.size=A.readUInt32LE(q.LOCLEN),v.fnameLen=A.readUInt16LE(q.LOCNAM),v.extraLen=A.readUInt16LE(q.LOCEXT);let k=y+q.LOCHDR+v.fnameLen,F=k+v.extraLen;return w.slice(k,F)},loadFromBinary:function(w){if(w.length!==q.CENHDR||w.readUInt32LE(0)!==q.CENSIG)throw Xt.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),l=w.readUInt32LE(q.CENLEN),x=w.readUInt16LE(q.CENNAM),h=w.readUInt16LE(q.CENEXT),m=w.readUInt16LE(q.CENCOM),E=w.readUInt16LE(q.CENDSK),C=w.readUInt16LE(q.CENATT),_=w.readUInt32LE(q.CENATX),y=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(l,q.LOCLEN),w.writeUInt16LE(x,q.LOCNAM),w.writeUInt16LE(v.extraLen,q.LOCEXT),w},centralHeaderToBinary:function(){var w=Buffer.alloc(q.CENHDR+x+h+m);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(l,q.CENLEN),w.writeUInt16LE(x,q.CENNAM),w.writeUInt16LE(h,q.CENEXT),w.writeUInt16LE(m,q.CENCOM),w.writeUInt16LE(E,q.CENDSK),w.writeUInt16LE(C,q.CENATT),w.writeUInt32LE(_,q.CENATX),w.writeUInt32LE(y,q.CENOFF),w},toJSON:function(){let w=function(A){return A+" bytes"};return{made:t,version:e,flags:r,method:Xt.methodToString(s),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:w(f),size:w(l),fileNameLength:w(x),extraLength:w(h),commentLength:w(m),diskNumStart:E,inAttr:C,attr:_,offset:y,centralHeaderSize:w(q.CENHDR+x+h+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ud=ne((X2,ld)=>{var Qn=Xn(),le=Qn.Constants;ld.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 le.ENDHDR+a},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),s=c.readUInt32LE(le.ENDOFF),a=c.readUInt16LE(le.ENDCOM)):(t=Qn.readBigUInt64LE(c,le.ZIP64SUB),e=Qn.readBigUInt64LE(c,le.ZIP64TOT),r=Qn.readBigUInt64LE(c,le.ZIP64SIZE),s=Qn.readBigUInt64LE(c,le.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(le.ENDHDR+a);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(s,le.ENDOFF),c.writeUInt16LE(a,le.ENDCOM),c.fill(" ",le.ENDHDR),c},toJSON:function(){let c=function(f,l){let x=f.toString(16).toUpperCase();for(;x.length<l;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(s,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ea=ne(Qo=>{Qo.EntryHeader=fd();Qo.MainHeader=ud()});var hd=ne((eS,xd)=>{xd.exports=function(t){var e=ae("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(s){var a=e.createDeflateRaw(r),c=[],f=0;a.on("data",function(l){c.push(l),f+=l.length}),a.on("end",function(){var l=Buffer.alloc(f),x=0;l.fill(0);for(var h=0;h<c.length;h++){var m=c[h];m.copy(l,x),x+=m.length}s&&s(l)}),a.end(t)}}}});var gd=ne((tS,pd)=>{var zp=+(process.versions?process.versions.node:"").split(".")[0]||0;pd.exports=function(t,e){var r=ae("zlib");let s=zp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,s)},inflateAsync:function(a){var c=r.createInflateRaw(s),f=[],l=0;c.on("data",function(x){f.push(x),l+=x.length}),c.on("end",function(){var x=Buffer.alloc(l),h=0;x.fill(0);for(var m=0;m<f.length;m++){var E=f[m];E.copy(x,h),h+=E.length}a&&a(x)}),c.end(t)}}}});var Ed=ne((nS,yd)=>{"use strict";var{randomFillSync:md}=ae("crypto"),Fp=Ki(),Up=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}),_d=(t,e)=>Math.imul(t,e)>>>0,wd=(t,e)=>Up[(t^e)&255]^t>>>8,Mr=()=>typeof md=="function"?md(Buffer.alloc(12)):Mr.node();Mr.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 Wi={genSalt:Mr};function $i(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])}$i.prototype.updateKeys=function(t){let e=this.keys;return e[0]=wd(e[0],t),e[1]+=e[0]&255,e[1]=_d(e[1],134775813)+1,e[2]=wd(e[2],e[1]>>>24),t};$i.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return _d(t,t^1)>>8&255};function qp(t){let e=new $i(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 Hp(t){let e=new $i(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 jp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let s=qp(r),a=s(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw Fp.WRONG_PASSWORD();return s(t.slice(12))}function Gp(t){Buffer.isBuffer(t)&&t.length>=12?Wi.genSalt=function(){return t.slice(0,12)}:t==="node"?Wi.genSalt=Mr.node:Wi.genSalt=Mr}function Kp(t,e,r,s=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let a=Hp(r),c=Wi.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)}yd.exports={decrypt:jp,encrypt:Kp,_salter:Gp}});var bd=ne(Vi=>{Vi.Deflater=hd();Vi.Inflater=gd();Vi.ZipCrypto=Ed()});var na=ne((iS,Sd)=>{var re=Xn(),Wp=ea(),pe=re.Constants,ta=bd();Sd.exports=function(t,e){var r=new Wp.EntryHeader,s=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,f=null,l=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let m=t,E=typeof m.decoder=="object"?m.decoder:re.decoder;h=E.hasOwnProperty("efs")?E.efs:!1;function C(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function _(w){if(!r.flags_desc&&!r.localHeader.flags_desc){if(re.crc32(w)!==r.localHeader.crc)return!1}else{let A={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==pe.LOCSIG||e.readUInt32LE(k)==pe.CENSIG)throw re.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==pe.EXTSIG)A.crc=e.readUInt32LE(k+pe.EXTCRC),A.compressedSize=e.readUInt32LE(k+pe.EXTSIZ),A.size=e.readUInt32LE(k+pe.EXTLEN);else if(e.readUInt16LE(k+12)===19280)A.crc=e.readUInt32LE(k+pe.EXTCRC-4),A.compressedSize=e.readUInt32LE(k+pe.EXTSIZ-4),A.size=e.readUInt32LE(k+pe.EXTLEN-4);else throw re.Errors.DESCRIPTOR_UNKNOWN();if(A.compressedSize!==r.compressedSize||A.size!==r.size||A.crc!==r.crc)throw re.Errors.DESCRIPTOR_FAULTY();if(re.crc32(w)!==A.crc)return!1}return!0}function y(w,A,k){if(typeof A>"u"&&typeof w=="string"&&(k=w,w=void 0),c)return w&&A&&A(Buffer.alloc(0),re.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=C();if(F.length===0)return w&&A&&A(F),F;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw re.Errors.INVALID_PASS_PARAM();F=ta.ZipCrypto.decrypt(F,r,k)}var z=Buffer.alloc(r.size);switch(r.method){case re.Constants.STORED:if(F.copy(z),_(z))return w&&A&&A(z),z;throw w&&A&&A(z,re.Errors.BAD_CRC()),re.Errors.BAD_CRC();case re.Constants.DEFLATED:var O=new ta.Inflater(F,r.size);if(w)O.inflateAsync(function(N){N.copy(N,0),A&&(_(N)?A(N):A(N,re.Errors.BAD_CRC()))});else{if(O.inflate(z).copy(z,0),!_(z))throw re.Errors.BAD_CRC(`"${E.decode(s)}"`);return z}break;default:throw w&&A&&A(Buffer.alloc(0),re.Errors.UNKNOWN_METHOD()),re.Errors.UNKNOWN_METHOD()}}function v(w,A){if((!f||!f.length)&&Buffer.isBuffer(e))return w&&A&&A(C()),C();if(f.length&&!c){var k;switch(r.method){case re.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(f.length),f.copy(k),w&&A&&A(k),k;default:case re.Constants.DEFLATED:var F=new ta.Deflater(f);if(w)F.deflateAsync(function(O){k=Buffer.alloc(O.length),r.compressedSize=O.length,O.copy(k),A&&A(k)});else{var z=F.deflate();return r.compressedSize=z.length,z}F=null;break}}else if(w&&A)A(Buffer.alloc(0));else return Buffer.alloc(0)}function I(w,A){return re.readBigUInt64LE(w,A)}function R(w){try{for(var A=0,k,F,z;A+4<w.length;)k=w.readUInt16LE(A),A+=2,F=w.readUInt16LE(A),A+=2,z=w.slice(A,A+F),A+=F,pe.ID_ZIP64===k&&L(z)}catch{throw re.Errors.EXTRA_FIELD_PARSE_ERROR()}}function L(w){var A,k,F,z;w.length>=pe.EF_ZIP64_SCOMP&&(A=I(w,pe.EF_ZIP64_SUNCOMP),r.size===pe.EF_ZIP64_OR_32&&(r.size=A)),w.length>=pe.EF_ZIP64_RHO&&(k=I(w,pe.EF_ZIP64_SCOMP),r.compressedSize===pe.EF_ZIP64_OR_32&&(r.compressedSize=k)),w.length>=pe.EF_ZIP64_DSN&&(F=I(w,pe.EF_ZIP64_RHO),r.offset===pe.EF_ZIP64_OR_32&&(r.offset=F)),w.length>=pe.EF_ZIP64_DSN+4&&(z=w.readUInt32LE(pe.EF_ZIP64_DSN),r.diskNumStart===pe.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return E.decode(s)},get rawEntryName(){return s},set entryName(w){s=re.toBuffer(w,E.encode);var A=s[s.length-1];c=A===47||A===92,r.fileNameLength=s.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return l},set extra(w){l=w,r.extraLength=w.length,R(w)},get comment(){return E.decode(a)},set comment(w){if(a=re.toBuffer(w,E.encode),r.commentLength=a.length,a.length>65535)throw re.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 v(!1,null)},getCompressedDataAsync:function(w){v(!0,w)},setData:function(w){f=re.toBuffer(w,re.decoder.encode),!c&&f.length?(r.size=f.length,r.method=re.Constants.DEFLATED,r.crc=re.crc32(w),r.changed=!0):r.method=re.Constants.STORED},getData:function(w){return r.changed?f:y(!1,null,w)},getDataAsync:function(w,A){r.changed?w(f):y(!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=l.length;var w=r.centralHeaderToBinary(),A=re.Constants.CENHDR;return s.copy(w,A),A+=s.length,l.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(),k=Buffer.alloc(A.length+s.length+r.extraLocalLength);return A.copy(k,w),w+=A.length,s.copy(k,w),w+=s.length,x.copy(k,w),w+=x.length,k},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=ne((sS,Id)=>{var vd=na(),$p=ea(),Be=Xn();Id.exports=function(t,e){var r=[],s={},a=Buffer.alloc(0),c=new $p.MainHeader,f=!1,l=null;let x=new Set,h=e,{noSort:m,decoder:E}=h;t?y(h.readEntries):f=!0;function C(){let I=new Set;for(let R of Object.keys(s)){let L=R.split("/");if(L.pop(),!!L.length)for(let w=0;w<L.length;w++){let A=L.slice(0,w+1).join("/")+"/";I.add(A)}}for(let R of I)if(!(R in s)){let L=new vd(h);L.entryName=R,L.attr=16,L.temporary=!0,r.push(L),s[L.entryName]=L,x.add(L)}}function _(){if(f=!0,s={},c.diskEntries>(t.length-c.offset)/Be.Constants.CENHDR)throw Be.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var I=c.offset,R=0;R<r.length;R++){var L=I,w=new vd(h,t);w.header=t.slice(L,L+=Be.Constants.CENHDR),w.entryName=t.slice(L,L+=w.header.fileNameLength),w.header.extraLength&&(w.extra=t.slice(L,L+=w.header.extraLength)),w.header.commentLength&&(w.comment=t.slice(L,L+w.header.commentLength)),I+=w.header.centralHeaderSize,r[R]=w,s[w.entryName]=w}x.clear(),C()}function y(I){var R=t.length-Be.Constants.ENDHDR,L=Math.max(0,R-65535),w=L,A=t.length,k=-1,F=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(L=0),R;R>=w;R--)if(t[R]===80){if(t.readUInt32LE(R)===Be.Constants.ENDSIG){k=R,F=R,A=R+Be.Constants.ENDHDR,w=R-Be.Constants.END64HDR;continue}if(t.readUInt32LE(R)===Be.Constants.END64SIG){w=L;continue}if(t.readUInt32LE(R)===Be.Constants.ZIP64SIG){k=R,A=R+Be.readBigUInt64LE(t,R+Be.Constants.ZIP64SIZE)+Be.Constants.ZIP64LEAD;break}}if(k==-1)throw Be.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,A)),c.commentLength&&(a=t.slice(F+Be.Constants.ENDHDR)),I&&_()}function v(){r.length>1&&!m&&r.sort((I,R)=>I.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return f||_(),r.filter(I=>!x.has(I))},get comment(){return E.decode(a)},set comment(I){a=Be.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||_(),s[I]||null},setEntry:function(I){f||_(),r.push(I),s[I.entryName]=I,c.totalEntries=r.length},deleteFile:function(I,R=!0){f||_();let L=s[I];this.getEntryChildren(L,R).map(A=>A.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){f||_();let R=s[I],L=r.indexOf(R);L>=0&&(r.splice(L,1),delete s[I],c.totalEntries=r.length)},getEntryChildren:function(I,R=!0){if(f||_(),typeof I=="object")if(I.isDirectory&&R){let L=[],w=I.entryName;for(let A of r)A.entryName.startsWith(w)&&L.push(A);return L}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||_(),v();let I=[],R=[],L=0,w=0;c.size=0,c.offset=0;let A=0;for(let z of this.entries){let O=z.getCompressedData();z.header.offset=w;let N=z.packLocalHeader(),U=N.length+O.length;w+=U,I.push(N),I.push(O);let W=z.packCentralHeader();R.push(W),c.size+=W.length,L+=U+W.length,A++}L+=c.mainHeaderSize,c.offset=w,c.totalEntries=A,w=0;let k=Buffer.alloc(L);for(let z of I)z.copy(k,w),w+=z.length;for(let z of R)z.copy(k,w),w+=z.length;let F=c.toBinary();return a&&a.copy(F,Be.Constants.ENDHDR),F.copy(k,w),t=k,f=!1,k},toAsyncBuffer:function(I,R,L,w){try{f||_(),v();let A=[],k=[],F=0,z=0,O=0;c.size=0,c.offset=0;let N=function(U){if(U.length>0){let W=U.shift(),se=W.entryName+W.extra.toString();L&&L(se),W.getCompressedDataAsync(function(fe){w&&w(se),W.header.offset=z;let we=W.packLocalHeader(),Le=we.length+fe.length;z+=Le,A.push(we),A.push(fe);let ot=W.packCentralHeader();k.push(ot),c.size+=ot.length,F+=Le+ot.length,O++,N(U)})}else{F+=c.mainHeaderSize,c.offset=z,c.totalEntries=O,z=0;let W=Buffer.alloc(F);A.forEach(function(fe){fe.copy(W,z),z+=fe.length}),k.forEach(function(fe){fe.copy(W,z),z+=fe.length});let se=c.toBinary();a&&a.copy(se,Be.Constants.ENDHDR),se.copy(W,z),t=W,f=!1,I(W)}};N(Array.from(this.entries))}catch(A){R(A)}}}}});var Dd=ne((oS,Td)=>{var xe=Xn(),ue=ae("path"),Vp=na(),Jp=Ad(),En=(...t)=>xe.findLast(t,e=>typeof e=="boolean"),Cd=(...t)=>xe.findLast(t,e=>typeof e=="string"),Zp=(...t)=>xe.findLast(t,e=>typeof e=="function"),Yp={noSort:!1,readEntries:!1,method:xe.Constants.NONE,fs:null};Td.exports=function(t,e){let r=null,s=Object.assign(Object.create(null),Yp);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(s,t),t=s.input?s.input:void 0,s.input&&delete s.input),Buffer.isBuffer(t)&&(r=t,s.method=xe.Constants.BUFFER,t=void 0)),Object.assign(s,e);let a=new xe(s);if((typeof s.decoder!="object"||typeof s.decoder.encode!="function"||typeof s.decoder.decode!="function")&&(s.decoder=xe.decoder),t&&typeof t=="string")if(a.fs.existsSync(t))s.method=xe.Constants.FILE,s.filename=t,r=a.fs.readFileSync(t);else throw xe.Errors.INVALID_FILENAME();let c=new Jp(r,s),{canonical:f,sanitize:l,zipnamefix:x}=xe;function h(_){if(_&&c){var y;if(typeof _=="string"&&(y=c.getEntry(ue.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(y=c.getEntry(_.entryName)),y)return y}return null}function m(_){let{join:y,normalize:v,sep:I}=ue.posix;return y(ue.isAbsolute(_)?"/":".",v(I+_.split("\\").join(I)+I))}function E(_){return _ instanceof RegExp?(function(y){return function(v){return y.test(v)}})(_):typeof _!="function"?()=>!0:_}let C=(_,y)=>{let v=y.slice(-1);return v=v===a.sep?a.sep:"",ue.relative(_,y)+v};return{readFile:function(_,y){var v=h(_);return v&&v.getData(y)||null},childCount:function(_){let y=h(_);if(y)return c.getChildCount(y)},readFileAsync:function(_,y){var v=h(_);v?v.getDataAsync(y):y(null,"getEntry failed for:"+_)},readAsText:function(_,y){var v=h(_);if(v){var I=v.getData();if(I&&I.length)return I.toString(y||"utf8")}return""},readAsTextAsync:function(_,y,v){var I=h(_);I?I.getDataAsync(function(R,L){if(L){y(R,L);return}R&&R.length?y(R.toString(v||"utf8")):y("")}):y("")},deleteFile:function(_,y=!0){var v=h(_);v&&c.deleteFile(v.entryName,y)},deleteEntry:function(_){var y=h(_);y&&c.deleteEntry(y.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,y){var v=h(_);v&&(v.comment=y)},getZipEntryComment:function(_){var y=h(_);return y&&y.comment||""},updateFile:function(_,y){var v=h(_);v&&v.setData(y)},addLocalFile:function(_,y,v,I){if(a.fs.existsSync(_)){y=y?m(y):"";let R=ue.win32.basename(ue.win32.normalize(_));y+=v||R;let L=a.fs.statSync(_),w=L.isFile()?a.fs.readFileSync(_):Buffer.alloc(0);L.isDirectory()&&(y+=a.sep),this.addFile(y,w,I,L)}else throw xe.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,y){_=typeof _=="object"?_:{localPath:_};let v=ue.resolve(_.localPath),{comment:I}=_,{zipPath:R,zipName:L}=_,w=this;a.fs.stat(v,function(A,k){if(A)return y(A,!1);R=R?m(R):"";let F=ue.win32.basename(ue.win32.normalize(v));if(R+=L||F,k.isFile())a.fs.readFile(v,function(z,O){return z?y(z,!1):(w.addFile(R,O,I,k),setImmediate(y,void 0,!0))});else if(k.isDirectory())return R+=a.sep,w.addFile(R,Buffer.alloc(0),I,k),setImmediate(y,void 0,!0)})},addLocalFolder:function(_,y,v){if(v=E(v),y=y?m(y):"",_=ue.normalize(_),a.fs.existsSync(_)){let I=a.findFiles(_),R=this;if(I.length)for(let L of I){let w=ue.join(y,C(_,L));v(w)&&R.addLocalFile(L,ue.dirname(w))}}else throw xe.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,y,v,I){I=E(I),v=v?m(v):"",_=ue.normalize(_);var R=this;a.fs.open(_,"r",function(L){if(L&&L.code==="ENOENT")y(void 0,xe.Errors.FILE_NOT_FOUND(_));else if(L)y(void 0,L);else{var w=a.findFiles(_),A=-1,k=function(){if(A+=1,A<w.length){var F=w[A],z=C(_,F).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(z)?a.fs.stat(F,function(O,N){O&&y(void 0,O),N.isFile()?a.fs.readFile(F,function(U,W){U?y(void 0,U):(R.addFile(v+z,W,"",N),k())}):(R.addFile(v+z+"/",Buffer.alloc(0),"",N),k())}):process.nextTick(()=>{k()})}else y(!0,void 0)};k()}})},addLocalFolderAsync2:function(_,y){let v=this;_=typeof _=="object"?_:{localPath:_},localPath=ue.resolve(m(_.localPath));let{zipPath:I,filter:R,namefix:L}=_;R instanceof RegExp?R=(function(k){return function(F){return k.test(F)}})(R):typeof R!="function"&&(R=function(){return!0}),I=I?m(I):"",L=="latin1"&&(L=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof L!="function"&&(L=k=>k);let w=k=>ue.join(I,L(C(localPath,k))),A=k=>ue.win32.basename(ue.win32.normalize(L(k)));a.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?y(void 0,xe.Errors.FILE_NOT_FOUND(localPath)):k?y(void 0,k):a.findFilesAsync(localPath,function(F,z){if(F)return y(F);z=z.filter(O=>R(w(O))),z.length||y(void 0,!1),setImmediate(z.reverse().reduce(function(O,N){return function(U,W){if(U||W===!1)return setImmediate(O,U,!1);v.addLocalFileAsync({localPath:N,zipPath:ue.dirname(w(N)),zipName:A(N)},O)}},y))})})},addLocalFolderPromise:function(_,y){return new Promise((v,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},y),(R,L)=>{R&&I(R),L&&v(this)})})},addFile:function(_,y,v,I){_=x(_);let R=h(_),L=R!=null;L||(R=new Vp(s),R.entryName=_),R.comment=v||"";let w=typeof I=="object"&&I instanceof a.fs.Stats;w&&(R.header.time=I.mtime);var A=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,A=(A|k<<16)>>>0,R.attr=A,R.setData(y),L||c.setEntry(R),R},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return h(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,y,v,I,R,L){I=En(!1,I),R=En(!1,R),v=En(!0,v),L=Cd(R,L);var w=h(_);if(!w)throw xe.Errors.NO_ENTRY();var A=f(w.entryName),k=l(y,L&&!w.isDirectory?L:v?A:ue.basename(A));if(w.isDirectory){var F=c.getEntryChildren(w);return F.forEach(function(N){if(N.isDirectory)return;var U=N.getData();if(!U)throw xe.Errors.CANT_EXTRACT_FILE();var W=f(N.entryName),se=l(y,v?W:ue.basename(W));let fe=R?N.header.fileAttr:void 0;a.writeFileTo(se,U,I,fe)}),!0}var z=w.getData(c.password);if(!z)throw xe.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(k)&&!I)throw xe.Errors.CANT_OVERRIDE();let O=R?_.header.fileAttr:void 0;return a.writeFileTo(k,z,I,O),!0},test:function(_){if(!c)return!1;for(var y in c.entries)try{if(y.isDirectory)continue;var v=c.entries[y].getData(_);if(!v)return!1}catch{return!1}return!0},extractAllTo:function(_,y,v,I){if(v=En(!1,v),I=Cd(v,I),y=En(!1,y),!c)throw xe.Errors.NO_ZIP();c.entries.forEach(function(R){var L=l(_,f(R.entryName));if(R.isDirectory){a.makeDir(L);return}var w=R.getData(I);if(!w)throw xe.Errors.CANT_EXTRACT_FILE();let A=v?R.header.fileAttr:void 0;a.writeFileTo(L,w,y,A);try{a.fs.utimesSync(L,R.header.time,R.header.time)}catch{throw xe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,y,v,I){if(I=Zp(y,v,I),v=En(!1,v),y=En(!1,y),!I)return new Promise((k,F)=>{this.extractAllToAsync(_,y,v,function(z){z?F(z):k(this)})});if(!c){I(xe.Errors.NO_ZIP());return}_=ue.resolve(_);let R=k=>l(_,ue.normalize(f(k.entryName))),L=(k,F)=>new Error(k+': "'+F+'"'),w=[],A=[];c.entries.forEach(k=>{k.isDirectory?w.push(k):A.push(k)});for(let k of w){let F=R(k),z=v?k.header.fileAttr:void 0;try{a.makeDir(F),z&&a.fs.chmodSync(F,z),a.fs.utimesSync(F,k.header.time,k.header.time)}catch{I(L("Unable to create folder",F))}}A.reverse().reduce(function(k,F){return function(z){if(z)k(z);else{let O=ue.normalize(f(F.entryName)),N=l(_,O);F.getDataAsync(function(U,W){if(W)k(W);else if(!U)k(xe.Errors.CANT_EXTRACT_FILE());else{let se=v?F.header.fileAttr:void 0;a.writeFileToAsync(N,U,y,se,function(fe){fe||k(L("Unable to write file",N)),a.fs.utimes(N,F.header.time,F.header.time,function(we){we?k(L("Unable to set times",N)):k()})})}})}}},I)()},writeZip:function(_,y){if(arguments.length===1&&typeof _=="function"&&(y=_,_=""),!_&&s.filename&&(_=s.filename),!!_){var v=c.compressToBuffer();if(v){var I=a.writeFileTo(_,v,!0);typeof y=="function"&&y(I?null:new Error("failed"),"")}}},writeZipPromise:function(_,y){let{overwrite:v,perm:I}=Object.assign({overwrite:!0},y);return new Promise((R,L)=>{!_&&s.filename&&(_=s.filename),_||L("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(w=>{let A=k=>k?R(k):L("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(_,w,v,I,A)},L)})},toBufferPromise:function(){return new Promise((_,y)=>{c.toAsyncBuffer(_,y)})},toBuffer:function(_,y,v,I){return typeof _=="function"?(c.toAsyncBuffer(_,y,v,I),null):c.compressToBuffer()}}}});var uu=ne(ve=>{"use strict";function to(){let t=["uxfxrvK","DfPcB3u","CxvADge","B3jRzxjhBg8","tu1Hs0u","DMfS","tKXmtM0","AKrYD2W","CM92AwrLige","wwfQzg0","yxrLq291BNq","vLvTCxi","CMfNzvn5BMm","A3f0t2e","zhPItLO","AwXSihvZzsa","s0X3rgO","ru91zwy","y2uGBM90igK","DvrozeC","v0vTAge","Dhfkq1i","t1Doveq","Dg9tDhjPBMC","Bwf4uMv0CMK","swDyrK8","AwXLx25HBwu","AK1LBhe","AhbNveq","CMvWBgfJzui","tg9JAW","yMToA0u","BeHHBMrSzxi","r1rktvi","ihzHBgLKigq","q3vZDg9Tq2W","vgzzuuC","qxDXsfK","EgLXqLy","DhjPBq","Ee9TBK4","C0jf","B3rHvMe","rNjVBNrPzxi","wK9XAMO","tgrtBuC","u21cs20","Dg9hzw5LCMe","DcbVzIbYyw4","zgvIDwC","sxv0qKO","zgvMAw5Luhi","z1n1CuO","vKTesuS","AK96s0m","zw9bA0u","tuLdBe8","zNjVBuHHC2G","wLjpy1C","DvLtuLu","B0nOr3a","suDnAei","C3vIyxjYyxK","AxjsC3O","u3fpwLK","ywzHCgu","x2rItMfTzq","q0jnBKi","Aw5N","t2X3DNC","y2zSsLm","re5RDLC","DurHsvO","q0TQtfC","D3nZoI8V","D2vI","uwrYD1G","yLPOBgC","rw1HC1i","qwHkzuy","DMvYC2LVBMm","mtbNsMrbEhi","zwXdD3C","BgrttNy","u2HSA1u","Cg9PBNrdB24","vLrWD24","s3vpA1i","z1Pev0W","CgfNzwHPzgu","ExPTCfe","tKnxsM4","zNjVBNrPzxi","r0rou1y","Cg9PBNrbBMq","zNbVse4","C2v0y3vYC28","q3DYA04","uejkAvy","ChPmEKy","yLjhufG","zNjVBu51Bwi","vw5Oyw5KBgu","AwTowLK","CgfNzxnOB3C","CMLLC0nVDw4","yLrSquC","quLTv3e","qwfWrKW","Aw5PDcbrB1m","wKTkqwq","DMvY","DhLWzq","zMvY","seLQv3i","wxD2wwy","qKjxBxG","CLbHEMO","yxv3z1a","BhP6EgC","A2LgvxK","vhPKzvu","ywXS","tgLwqum","x29Uq2XVC2u","A2vOsuC","DgvZDa","uxvLDwu","Eefrrei","BMvY","wwL4Bvm","y2DyALy","B25SAw5L","Dgv4DfbHEwW","x25HDMLNyxq","Bg9NsurozxC","vfvJC0O","D2rNCeC","BMnVzgLUzW","CMvZzxrdB3u","mJKZnhjYvgHWtW","s29xyLm","B25nzxnZywC","nhWXmhWXFdG","zw5HyMXLqxu","BLPHtwW","B1bbAMe","BfjbyLa","x2LZqNjVD3m","x3nLBMrby2S","wvruAvK","Bwf4twvZC2e","CgjNzKi","EevhC24","wM5Lyxa","zNvSBLm","rfDxEMW","zKTRB0u","B3bLBG","Dw50","wxrTqMO","x29UrxjYB3i","DeLK","BNrfBMrWB2K","y3jLyxrLt2i","tKDFrvjst1i","BxnNsuq","yxv0BW","C21muNi","Cu9RrK0","B2nRzxq","vxbKyxrLq28","B0fOELK","C3nHz2vfDMu","AMvJDfn0B3i","AwjsuwG","D0PWzxG","yuLpuMW","zunPB0C","yxfJq1y","qKjeD1i","zgvwwu4","q0Xpu0ve","suPsCwS","q2ztDhu","A0fNzgS","l3DZl3yY","qMnhq1C","mte0mJK3nNnkD01eva","ENDPr00","AgTutMe","DMvUDa","y2HLy2TdDxi","C2v0sxrLBq","B25fCNjVCG","whjXrxa","AgfZ","x21LC3nHz2u","u2DuC2C","zgrhy0i","x3nLCuLK","s3vjA3i","DK1dEgW","EeXgEMi","uKzbz0i","mxbdBuHstG","D3rHsNy","x0rctMfTzq","BNruCMLLC0m","ywjVCNq","BwvZC2fNzv8","D2fZq2XLyw4","y29UC3rYDwm","u2XnqNG","ywrKq291BNq","uxvxt1m","EfjSEhu","C0z4tM0","tMLlzhG","DMvYC2LVBG","yMfSu2nVCgu","ANb1EfG","B2P5rfO","q0XIrfi","u0XLz3C","qMrVA0O","qxfnseC","DvrLuuu","x3bPBMDmB3m","Aw5L","ru5rBgy","D0zpqve","yMrFzgLK","wuL1r3C","DeLUDgvYy2u","q29UzMLN","EK9hzuG","x29UvgLTzw8","AwLpv3q","BKnnEeu","r0r5yMK","x2LZv29YA2u","yM9KEq","D05TuxO","q1Douwm","yxbWBhK","EKP4CLC","CvjSEKC","C2nYAxb0","Avntu0K","AwXLtMfTzq","z2v0q3vYCMu","Dhj1y3rVCIa","C0nVDw50zxi","CvjTrxq","uKfVquy","qw1mvwO","D1zmsvq","CMfTugfYyw0","yKLHsMe","ywDLsgLKzq","A29Svwy","vuP3z1G","DxvVB00","zNfysM8","EsbJBg9Zzwq","qvHKuwe","sM5qzw8","yMLUyxj5","ruTyCwC","wg5oreC","BvnbDw0","x2LUDgvYDMe","ywXSzwqGBxu","v2L1sue","x3jLBw92zvC","twLZC2LUzYa","x2n1CNnVCK0","BgncEgC","B2zMBgLUzq","Dgv4Dc9Qyxy","B2LUDfjLywm","EuH0quS","svvetfa","u1DWD1m","u3rYyxrLz3K","t0rov2y","rgvKAwnHDgu","DKDHvgW","tuHPzwK","y3jLyxrLq2W","sfzhy2G","EK1PqKe","x2TLEvbHDgG","C2TVEM0","Aw5JBhvKzxm","AM9PBG","tvP2A1G","wLzuA2S","CMvTB3zLrxy","Dw5RBM93BIa","thLlDfO","zwjVwe0","qLDuEem","igzHAwWSig0","x2nYzwf0zvm","BxrzzMO","CLHfAxe","ywnOzwq","lcbOB3n0BMe","z2vtEw5J","zNjVBujPDhm","tMzJuKm","whvSAuy","u3r4EK0","rLjptLrjrvi","x29UtwvZC2e","x2rLyNvN","x2LZtwLUAvC","y3jLyxrLuMu","EfvLsxy","q0Xpu0LorW","AMXvrKu","D2zWDKS","x3bPBMC","B0DLD3q","s3vJvwG","Dfv2vMO","CgvYC2LZDgu","t0Dluu4","A1z4Bg8","ve5rwNC","vLvrAu8","ntqYmef5A1HsBW","Cgf5Bg9Hzfq","C2vYDMvYvgK","uMvJB25Uzwm","q09oveLovuu","wvniDMm","y29UBMvJDa","Dg9cExrLCW","rgTqwuC","u25LDwC","AhbNr2u","CMTLCKDSB2i","t3nwt2m","BIWGAg9ZDg4","A214sxq","CMvHzg9UBhK","ywXPzcb1CMW","Aw5Lza","AMHUuuu","q2vJsfO","wLLMAhK","zxmGCMvHy2G","x19LC01Vzhu","quXm","BM9VBuW","EvvOBfG","AgvKtwf4uMu","tLvwz0S","z2vjBMzVu3K","zMXVB3i","t0rrsgC","turTCeW","ChrVCG","Aw9UvgLTzw8","uNnTu3y","tufyx1jfvfi","Eg1ZA0y","yMX6yKW","zxH0ugf5Bg8","C2v0","rKLmrv9ot1q","s05yANO","BeDtu1q","yKnwzxq","CM92AwrLihC","B0TYAu4","yM1ytvm","zMLSDgvY","wMT3wgq","AuDlrNy","s2nJtuK","sMrAswG","zMzmAw5L","rLDt","D1jZugq","v0riD3u","tNrwsuS","uKL2uxe","y2HnyxHdB3u","q29Kzq","tgPTqLm","u2D5Ahy","BMvLzf9Hy2S","zwnVBM5Ly3q","CMvJzwL2zwq","CuPpELK","CgLUz19VBMm","qunkELi","ww5fuuu","vgXewfq","tw9Zufu","r0rbywe","CgjnD0m","vKTVu20","BeD1sLC","B3jRig9MzMW","C2vUza","zgLZCgf0y2G","B3nLza","Bwu6ia","y3vYC29Yx24","BMCGzMfPBgu","swzruNC","Aw5KzxGGB3u","y2P3vxm","mhW0Fdn8mNW","ENjYAKO","wKX1EMq","s0DVugW","rxjYB3jdB2q","t1DIwKS","Cw9Zx18","suvtx0vsuK8","DwfoBKK","D24GCMvHC28","nhWZFdf8mNW","y2XLyxi","zgLZywjSzue","BMvJDa","yw1L","yM9L","zsbHihn0CMK","AgLNAa","y3vYC29YlNm","q21qu3m","y2fSBa","rLzbEfa","q0Lvrwu","nxWX","ve1AAhi","yxKSig5LDhC","AM14CKq","DvLlvw4","BxrzCfy","qwT6vKm","EuT4v3q","wwnQB1K","ve9zDvm","uLjpuG","yKPcvgC","x2HHBMrSzu8","CMvTB3zLq2G","x2HHBMrSzva","x3bHDgHlzxK","x3fVC0rc","EgT1v0m","BMrWB2LUDfq","qKroAee","sLnptLa","zv9ZDwnJzxm","wxD4EhG","CurKALC","AgrTCgy","B2zM","t1rQELy","y1zfqMW","uMXwvK4","wgvwrgO","tLjluK8","Cujwu3a","zgvS","twLHv0q","x2rPC2nVBM4","zNjVBunOyxi","ignVzgu6ia","rxbKz1C","BwvZC2fNztO","yxvvt3i","B3bLBKrc","CM9YrxzLBNq","ExftvLm","A2v5CW","BMrWB2LUDca","Ehfiqxu","A1n0yxr1C0m","ihrVihjLDhi","BvnYtLa","Dufdzu0","y29UBMvJDca","y3vYC29Yx2y","DKvnu3e","yMXZtvi","ENnzwNe","yNLlwue","C2v0u3rVCMe","Cerds1a","Aw9Ul2PZB24","ANfxuuK","ww1buey","vfvmwxi","AMvuANu","CMvHzhLtDge","EKDfzgm","ihjLy29UBMu","r0vguvG","rgLVzNa","y2XLyxjtDg8","Bhm6ia","rxzLBNq","yw5Yq0i","yxnL","DLLMsey","BMv3vMvYC2K","t1jzr3K","v1f1te8","EMTXsg4","qxHwA3K","r21zEKy","DMLJzuLeig8","ywDLrxzLBNq","DhbizwfKzxi","Ehrbyuq","twvZC2fNzuu","qwXhDNq","Au1PrLq","EKvqyu0","t1bftG","Dej4Efq","De1gBKm","DLnHChK","v3voqLO","yKDICNK","BgLTAxq","vNvhr1a","x2DLDeLUDgu","B2zMC2v0","Ec1TC2CTy3u","v2ThAKe","DfPky0O","z1rPBwvVDxq","B25JBg9Zzq","zw1LBNq","x2HHBMrSzvi","vuXHEgO","lcbTyxGGCMu","sgPlr2W","yMrtuhe","zMLUza","x2zVCM1HDeu","D3vqAe0","y29Kzq","nJa0mfLNC0flDG","BKHotwS","s1jZEMi","wK15tLq","zxjFAxnFywm","z2v0","B25LCNjVCG","C3bSAxq","qMXPuuu","q05tDwC","mhWYFdr8m3W","zNjVBuj5Dgu","swv0ruO","y3jLyxrLrxi","uurgs0i","tNP3v2i","z2nLwK0","CgXVCeq","BgvY","BLjewgy","yMXVy2TLza","wvvyvgy","z1btBLe","sxzKBgq","DgHHBIbSB2m","zujgD3q","CwPjDNe","sxnswve","ywnRx2LK","EgvVvgW","ruDiCuW","zxjHDg9Y","zxH0zw5ZAw8","C0XPC3rLBMu","zwncwuu","C3v6ug8","y29SBM8","Bwf4tg9ZC0m","BwvKAwf0zwW","EfvZzuvUDG","CMvJB25Uzwm","uenbteK","q09otKvdveK","t0nAyu8","we5nvfy","sgvivLe","BgPNv2e","v2LUzg93","z0zkyvu","tgLZDgvUzxi","yw5ZzM9YBvq","C0PLu24","EfPHs0G","CM9tvhi","CNHRueu","vMvHuum","Ae1LC3nHz2u","C2XPy2u","sxnIBe0","qLLJswm","svH5Cg0","rg1nBwy","mxW2Fdq","yw51Ce1LC3m","C1PIuwy","zv90Aw1LB3u","y2HHCKnVzgu","AgvHzgvYCW","EePHBLK","q291BNq","z2v0qwXS","ELHvEuS","yxPUwvi","AhLHteq","mJeZnZG0rMPnvwLs","CNvcy0u","whjgtKO","twnLrw0","zK9SAhe","Cu54DMu","vgnTyKq","DhHvsei","De9jEgu","CvjrEfm","D1j6Axe","Ae5irwm","vu5esMe","qKzywwG","zfDVCMTLCKC","s1H1Bfi","DcbSAw1PDa","q2LzAgu","rMDxsfG","uvvXBLu","BM93","zxrxB3jRq2G","zxHWB3j0CW","x2XPC3rLBMu","rNjRrMm","qNDdAuW","A2v0ignVBNm","z0rluvO","yxjYyxLIDwy","BwLUAvbYB2C","uKDfBKi","B2Lzwfi","z2v0t3DUuhi","CNnVCL9Uyw0","C1LzBwC","DvfWAw0","mdaWmdaWmda","ywT3zeS","y3jLyxrLtwu","ExbL","tw13ruG","yNL0zu9MzNm","Den5BgW","ywrK","yNL0zxm","sMHdsfu","DxbKyxrLq3u","y3P0yK4","s3DcwKu","DhjPzxmGCMu","AunUrwK","rLvZtK0","CxfPALi","uNnpCNu","B25Xr2O","yxvPEgi","Cg93","CfnSCwW","AenSB3nLrxy","BezSDxnO","z2v0u3rVCMe","wfDdyNi","uu5MvLC","B01gEMi","oxWZFdb8n3W","D3jPDgu","Buf5qwm","rM1Py1C","wMzOtxu","AefJA01LC3m","BhLHENy","CKz3ugK","yxnJCMLWDa","BLfQs3G","DxrMofDYAxq","u1jsswW","ywWGy3vYC28","terwBhi","Dur0zgy","vNfJwKy","ywDL","B3DlrK4","DhjPzxm","rKfKrM0","ANHitxy","Cu5YEwe","Dg5kyvy","Ahr0Chm6","pxv0zI04","AevYCM9Yrxy","v0fzCNO","ntC0tNnAvMLO","yKLUA0S","igfYCMf5yNu","zxjFCw9Zx2e","uMLQB1q","uwPiDLq","uKfvy2m","y29UBMvJDgK","tNbbA0W","wvzfwui","BMfTzq","B3nLrxzLBNq","t3bLBKv2zw4","AvzhrLu","t0HYrfm","DxnLCKLW","zxjWA3O","wxnAtKK","rLfhtwK","x2LZtwLUAvq","ihrPBwvVDxq","Ewfkyw0","C2vYDMLJzs0","CMvHC29U","AxPns0W","BvPAy0e","wK9MEee","CgDsquK","C3z5tw4","tfzeyKu","Cgf5Bg9Hzeu","CMvQzwn0","ChD3wLq","ueXcCwG","zxq9DxrMltG","AxnszwfKEq","vxnlCMS","zMXHBNu","Dfngug8","zg9Uzq","CMvHzfvjBNq","yNL0zuXLBMC","zwPVBNa","CLrutLi","wuX5zKS","Cvj6wha","EwP3DLa","ruLHwfa","AengBwi","zvPmzNa","x3nVy2TLDa","y29UBMvJDfm","whbgvgK","wwvjy3e","u0TVwvq","C0Xf","sfjvB3C","zNDZxZeUmc4","AwXK","AgDwshK","CuH5CvC","DwDpBKS","wfDnBgK","zwziBva","BfrPBwvVDxq","CMvKDwnL","rNDSCMm","DwHtyuW","ChbL","te1HwMe","uujbBwy","BgP5BKK","Ae9Wzw5fDMu","Cg9W","vLzsueq","qNrluNu","y2nhDfe","D0Hiwxu","sKvAAgK","DvD0BKO","yvjpvK8","zMX1C2HfEha","zvbmthO","s29cDuq","yvnxzLC","B3bLCNr5","y291BNq","y3vYC29Y","BMnLq2XVC2u","CNnVCL92ywW","yMPLAe4","tKHPshq","s1LntLi","rM52tK0","BK5PweS","q2LzBK8","ENfhA0m","AgfUz2u","svfoDeW","sKXkrK4","ChbgAK8","tNLpENi","zwPJyu8","D1bKzuK","Aw5KzxHpzG","z1DhEK0","Dxrjza","qKLSqMG","CLL4yMC","wMHHuKu","EKPXtfi","m3WXFdj8mhW","uuTqELm","yNHHt20","B3LSBNe","q2L1vwC","u3ztEfG","BxvIsNK","u0rgsey","qwjVCNrfCNi","y3vZDg9Tshq","rLvmy2G","AhPPy0S","Dw5ZAwDUzwq","DxjS","t2jrrMC","yNLL","tgHPD0K","swfosw8","y29UBMvJDeu","CKXes0u","DMfSDwvZ","x2fKzfDZtgK","DxrVuMvJB24","y1HXwhy","DgLTzw91DcW","yw5Hz2vY","EMzczum","vKPUsMO","Ef9MCM9UDgK","zhrMwxu","CNzby0u","uMvHzcbWyxm","ru9QAxu","ywXty29Wzq","Cw1TtNm","zw5HyMXLuw8","x1fVu01HBMe","B25tDgfYDfi","sNLezNO","B2jQzwn0u3q","BwvyvK4","CMvZzxrfBMq","Dg9cExrLC0W","ugjSqxe","u09vq1a","C3rYAw5N","D0TsrfK","Ee1MDe0","Cfb2uMy","C2v0q3vYC28","D3LMEwK","icSG","ywnRDxbfBMq","DKXos2i","wefeveO","z2v0qwXSs2u","y2vZC0HHBMq","Aw1LCYbPBIa","rfD0CMK","y2f0y2G","qw1VDw50","qw9Htva","u3DcA2S","zhDguLe","AK93zhO","qKHkufC","CgLUz0XVC3m","AxnrB1nnzxm","EvjLy29UBMu","rfDrAhG","B0vOALy","vgD0Exe","yxv0B21HDgK","q21AB0u","ywrKt25L","Cg1iyMO","C2v0zgi","wKL2rxa","tMfTzq","vLfTDM4","Ec1TC2CTCw8","BwvZ","tercvei","ChjVDg90Exa","CNL5BfK","venNwKW","BwLtCu4","BefdEhO","zgTjvwe","wufMqwW","vxPizfq","vMfhv2u","x2nSzwfYvgK","yw5Nzq","wwjRtM4","yxfkCuK","BvLpyuG","EwfurgC","q2fYzLe","AxnmB25N","rxbwr1y","wwT5y1y","yMLUza","ru96B24","thn0vgy","BMrLEa","mZm3nZftuvHrzKC","y2XVC2veqG","vLH4rxm","sMDtEvO","zvfRtwK","tuT0BMW","zKfWEu4","CLbmv1K","CMvXDwLYzwq","t0jkDKW","CfrHwxu","B3PZzfO","CMvUDevUzha","tg9Nsuq","yMLUyxj5vhK","t1zesxC","zcWGDw5RBM8","r0j0v28","C3rVCMu","zxjYtM8","DgvmB2Djre4","CMvZB2X2zq","ywXSq3vYC28","z2HYs0O","yvnfBMG","ihn1y2nLC3m","D3r1BMG","v2vIu29JA2u","u2nhCKW","tM5ov2K","CNjVCK1LC3m","sK1nEhC","CgfYC2u","CNzHBa","r3rPsgS","DhjHBNnHy3q","Aw50zwDLCIa","C2vYDMLJzq","r1DstMW","yuXUz1K","swXJD3O","tgnnsxK","Aw5KzxG","A2v5","wu5eBLi","t2DRA0G","s2PmAg4","sfLAv0W","Bu9hEMy","y2XVC2uSihC","vvbiu1e","yxnZAwDU","zNvUy3rPB24","zLfdr1i","DMnWqM0","ihrPBwvZ","CMvZDwX0","zw50tgLZDgu","yNvMzMvY","zw50zwqGDhK","vMfoyNu","x3DZ","D2rmA28","Cgu6ia","y0nzAva","txPrwgy","A291zeq","vgLWze4","y1PdCxi","zwrPyxrLBhK","CNzHBfzHBhu","ze1iquy","CgLUz0LUDgu","zvvYBa","rMnNqwW","DgHTAxm","De1HBMfNzxi","BwLUzW","rvjst1i","svjevMi","zMLN","DMTUtge","sNbXq2i","x3DHAxq","DMfSDwu","tKrxseG","CxPLqxu","s3newg4","ysbTDxn0igi","wfbLuKm","Dg9Y","EuHptuS","A0DNEMq","D3m6lY8","DhDVCMTdAge","s0jlEKy","tKfusvzfx0u","x2n1CNnVCK4","s0zsBM0","sxrRBgW","Cun6wKG","yuPjDeq","AxjLza","AM5kDhy","vvvjAeq","EfneB2S","zgf0yq","B25TzxnZywC","C3vJy2vZCW","uxD3ANe","sfzVzKW","DK53Awi","uwrnExG","BMDuAw1LCG","weT1BKu","nde5odDWA2rvywC","AuDVv2y","AxLPq0O","vNbsDMW","rLvSAfu","yKTsq2m","yxDrqMC","EhfZwxm","v0jnAKS","D0nPzvq","veXdzK0","suDuzM4","yxrHlcbKyxq","t3PUvha","yLnQCgO","x2jPBMfYEvq","AxnbCNjHEq","vMzAwMK","DgfIyxnL","swjYquS","ChvZAa","Dg9cExrLC0i","rwD6DgC","Dg5Tze8","ig1LC3nHz2u","uwf2AvK","ANnrtgK","suzmCei","Axf2Due","x2LZsw5PDa","Efb3sMy","nhWWFdj8m3W","DMfotK0","ru5mD24","sMjere4","Efrurw52","ihzHBgLKihm","vgPrEwS","vu1lD2q","CMfUzg9T","z3vpufG","vgfN","C3rVCcbPBw0","u2vXsuq","C2HPzNq","Bw9vuwm","z3fAqMu","wfLUtvC","C2DPza","s0npt0K","CM92AwrLigi","CLHys20","A2jzsha","tuvtu0fhrv8","mta5ntC2BwXxrMj1","x2DLBMvYyxq","vevQD0G","twPguKS","CMv0CNLdB3u","zw5JB2rPBMC","AwDHDg9Yt24","y3r4","DLL5zw8","Cerhq0m","tg9NsurozxC","Bxvqwfy","uLHrAMS","z2v0sxrLBq","zw50","DhfhC3q","vgngsNu","v0zYCfe","B2nRzxrtDwm","y29UDgLUDwu","tMniEuO","DgLTzw91Da","teTuEvq","zw1PDa","ELrNDhK","BxnN","yKj4A1y","zg9fA0S","D3PSqKq","y1vVrg8","Exb2BgK","Dev2zw50","u2vYDMLJzvC","zcbLCNjVCI4","Bwv0Ag9K","x2rPC3bHDgm","BgLUzw5V","CgLUz09Uy2u","BKLwEhy","zxjFDhrS","Eu1oCLC","Exnlz0m","Ec11C2uT","x29Ut3bLBG","uhzVwNy","ihrYEsbYzwm","m3WXFdj8nhW","ywDLu2HVDW","Dg9mB3DLCKm","uef1wxq","C3vIC3rYAw4","v0riBLG","vgLTzw91Da","B2z6uhO","wevyA1e","yxbWzw5Kq2G","D3jPDgvvAw4","s1PuB3O","z29PBMCGyxC","C1bJDhO","rMDvDvi","x2rYB3bhBg8","C29YDa","BNHwEue","zxjYB3i","B25mAw5L","BKL3A1K","Eg5hBuG","tM9gwui","x21PBMLoyxy","wgT6EwO","t1bftL9fuLi","B3bLCNr5tMe","x3jLywr5q2W","EMvNyLm","yNvMzMvYzwq","EeXkveC","BMCGDxjSoIa","tgjmC2O","ug1HAei","vvHdt1u","zfLsreW","x2LUAxq","B1bRCLO","y3vYCMvUDeu","CYbPBNn0yw4","zwn0","AuD4z2e","sMnwrhm","Cgf5Bg9Hza","wfDKrLe","BgvUz3rO","CLzHBhvLCW","zfvZCNe","qwTKuMe","vxjzEe8","ufblA3e","zgvSzxrL","D1zmyMG","vxDJvfq","u3zOzg4","C291AK0","Bu5gvwu","ENbVyxC","rgDsEgm","Axnby2TdBgu","x3jLy29UBMu","Dw14q3C","y2HnyxHuCMK","A2nRq3u","Dff6Beu","EhPeBKq","AezrrNO","vePRBxC","r0zNrfO","yw1Lu3bHy2u","C2vUDa","B3vUDa","rhPUDLK","BML0AwfSAxO","zM9qt0e","Aw9U","qvPqBfm","ue9QALy","DfL0zhO","zLLZz0C","suTjveu","qKLqDwq","x29WDgLVBNm","x2LZtM9Kzq","BgLZDgvUtMu","DfnmAeq","ywnR","qKD0vu4","yKL5s1a","u3bwEfe","uhvOug4","ywnRtxnNswq","zw5fDMvUDa","zwHerwO","Bg9N","wuzdB20","B2nRzxrgywK","EgHsv2G","BM9Uzv9UB24","vK1Ure8","CYbWyxjHBxm","x3bPBMDqB24","uvbQufy","C2XbzgG","yMfSrxzLBNq","wgPgwu0","zKDIAgy","qLv6rLy","D3vHy0C","BgnOsMS","yxbWBgLJyxq","te9tq0m","tw9KDwXL","t3Lsqxe","Eg5gEuS","zM9YrwfJAa","Avzize8","qwDgvKG","u2PHqNy","z2v0q3vYC28","CMvHzhDYAxq","ywnRpwzYB24","CMvWBgfJzq","zM9Yy2u","v1ftA3a","D3nIvKG","A0jvswm","Dw5KzwzPBMu","yKfdsxi","u1b0Evq","x2LUAxrhBg8","x2nVBM5Ly3q","Bg9Nsurhzw4","B2fK","vNLruvm","qxbNC08","B3v0sw50zxi","zw5NDgG","yNLhyKS","yufLBxy","x2n1CNnVCKy","DuffA0O","D2LQzM0","BhrPCgXLihq","C1DUAfa","rfHoywq","D0HctNe","B25VCgvU","CeLwuNi","Cw9Z","ChDvzLO","y2HLy2Tszwe","B25pCgvU","yxLbAvm","yw1LoIa","y3jLyxrLt3a","B0TRAfC","ndHJqvv0DKu","Dg9iyxnO","s09SBfm","C29Tzq","BNrbBMrvCgq","C0rWy3i","zcWG","rKLIvvG","tu5yCKu","BNrLCG","z2v0s2v5","r2rSCM8","CMvZzxruCMK","BwvY","y09Wzw4","y2XVC2u","BwLZzq","sw1SwKu","Du1Squq","ywrKrxzLBNq","CwfUCvO","EuXoq2i","x2rLC3rYB3K","BwfW","CgTLv1a","C1HVwg4","DNDuzu8","B3jLtMfTzxm","igzPzwXKoIa","zMLSzw5HBwu","y3vYDMfSDwu","DgLUzYbZzxi","zufeu00","EvbWB1O","ChjVDg9JB2W","C2Trv2y","v0v4DMi","yw9ztw4","qNPowKG","qNjPzgDL","y3ruAw1LB3u","q0LduNm","AKr0yxy","o2nOyxjZzxq","A2j3EKC","zMzLCG","CM11sei","DvjxvMS","t1bzANq","sMDNwgq","zufJAW","wMHVAva","uhbZsvm","BM5Ly3q","vengrfG","BhDUuMC","CIb0DhDjra","y0PMtNO","DgHLBG","qurxBu4","y3vYCMvUDeK","qKPlt0y","zwvet1K","B25tDg9Wsw0","v3j6q0C","Dg9VigXHCMC","ANHJtMe","zw1Ozu8","qxzfr2i","CfrxEeK","yxrwvgy","Bg93","Cuzowfu","u0n4tKy","BwvZC2fNzq","B25szwnLAxy","vwf2Agu","uLPIrxG","v2r1A3a","CgXLyxnLiha","y3jLyxrLrwW","Aw1MCum","B3jL","qMnnrei","zw5KCg9PBNq","C1zwB3m","x3DZsw5ZDge","zfDty1m","D1ntCLC","vw5PBxbSzw0","zvDRDMi","x3bYB3rVy28","id4G","vfLSEM0","C0LduLi","zxjFCw9Z","AeDlyLi","x2vUzhbVAw4","ChjVy2vZCW","B3bLBIa","B2XKvMvYC2K","weHLA2e","AhrlA3y","Afv3AMC","CgX0svG","reiGzMfPBgu","x3vYBa","te5Rrei","BgLUzq","zgvJB2rLzey","DwjSBg4","z2vY","DM5fvuO","DK1vCuW","yxGGCMv0CMK","uhnoBKK","rvDiAuO","q1L4AfK","C3rLBMvYCW","rLnOB0C","zNjHBwvuExa","C3rYAw5NAwy","BKXPBMu","wKvIwKy","y05zD0e","uhjPBwfYEuS","D1zhy0S","mNWX","uNPSrwG","mdaWma","q3vZDg9Trxi","C0r4reK","sg9Qrwy","Cu9Ku2i","x3bYzwzPEa","Cu5HB2u","ExfREhC","Dhr3Awq","y29TCgXLDgu","ze9lwwu","v3vbvKW","uMrZBwO","wwPVzNu","sxbWDuy","vMrPu24","teH0zMG","BMvLEwu","Chv0","DwP1ANK","z3HdueG","t0fTsLu","qKDQtvC","zw5JB2rLrNi","DfHXv2u","tgDtuwy","qxnjDwy","x2LUAxrqCM8","zw5HyMXLvhi","zwvKzwq","s09grvO","zwj4wve","zvrOsxK","EujMDMe","B3jpBMXPBMu","u2TPCcbWyxm","zeXOzKq","D2LSBfjLy28","tfnwr20","zxj2AwnL","BezZCwm","zxjYtxnN","vMTxwxG","zgnRrfi","txvpugS","wNHkvhe","B25ozxr3B3i","qvriwuu","C2fNzq","x2nSzwfYugK","ywXSB2nvBNm","vKzpCNm","vK5SCgu","y29Uy2f0","u2HHCMvKv28","EgnZwfy"];return to=function(){return t},to()}var M=K;(function(t,e){let r=K,s=t();for(;;)try{if(parseInt(r(550))/1*(-parseInt(r(973))/2)+-parseInt(r(1281))/3+parseInt(r(1450))/4*(-parseInt(r(1919))/5)+parseInt(r(533))/6+parseInt(r(1064))/7*(-parseInt(r(899))/8)+parseInt(r(485))/9*(parseInt(r(678))/10)+-parseInt(r(1396))/11*(parseInt(r(1653))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(to,117073);var ly=Object[M(1889)+M(1149)],uy=Object[M(1005)+M(1522)+M(1256)],au=(t,e)=>function(){return t&&(e=(0,t[{pSlql:function(c,f){return c(f)}}[M(1030)](uy,t)[0]])(t=0)),e},xy=(t,e)=>{let r=M,s={xkuWC:function(c,f,l,x){return c(f,l,x)}};for(var a in e)s[r(803)](ly,t,a,{get:e[a],enumerable:!0})};function hy(){return nu||(nu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function py(){let t=M;return ru||(ru=[IDBCursor[t(1258)+"e"].advance,IDBCursor[t(1258)+"e"].continue,IDBCursor.prototype["continue"+t(1778)+"ey"]])}function K(t,e){t=t-448;let r=to(),s=r[t];if(K.ypDkYT===void 0){var a=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",E="";for(let C=0,_,y,v=0;y=x.charAt(v++);~y&&(_=C%4?_*64+y:y,C++%4)?m+=String.fromCharCode(255&_>>(-2*C&6)):0)y=h.indexOf(y);for(let C=0,_=m.length;C<_;C++)E+="%"+("00"+m.charCodeAt(C).toString(16)).slice(-2);return decodeURIComponent(E)};K.vobqiw=a,K.yrNQuf={},K.ypDkYT=!0}let c=r[0],f=t+c,l=K.yrNQuf[f];return l?s=l:(s=K.vobqiw(s),K.yrNQuf[f]=s),s}function gy(t){let e=M,r={VNlpe:function(a,c){return a(c)},FShoG:e(1514),wKRDY:e(1147),WrzCG:function(a){return a()},QDFKB:function(a,c){return a===c},MIClO:e(1644),SUjEt:"qzWuq",OuGFY:function(a,c){return a instanceof c}},s=new Promise((a,c)=>{let f=e,l={WQSkp:r[f(1772)],ejcaO:r[f(1221)],EPCNi:function(x,h){return r[f(1834)](x,h)},adBkC:function(x){return r[f(1717)](x)}};if(r[f(913)](r[f(1894)],r.SUjEt))this[f(1425)]=!0,this[f(1627)]();else{let x=()=>{let E=f;t[E(644)+E(1338)+E(474)](E(1389),h),t[E(644)+E(1338)+E(474)](l[E(1620)],m)},h=()=>{let E=f;if(l[E(1166)]===l[E(1166)])l.EPCNi(a,Dt(t.result)),l.adBkC(x);else return _0x241b98||(_0x4852e9=[_0x28fce1.prototype.advance,_0x91417b.prototype[E(1469)],_0x38de3a[E(1258)+"e"][E(1469)+E(1778)+"ey"]])},m=()=>{let E=f;r.VNlpe(c,t[E(1514)]),x()};t[f(1672)+f(948)](f(1389),h),t["addEvent"+f(948)](r[f(1772)],m)}});return s[e(1711)](a=>{let c=e;r.OuGFY(a,IDBCursor)&&Ac[c(717)](a,t)})[e(1234)](()=>{}),ro.set(s,t),s}function my(t){let e=M,r={SWpwS:function(a,c){return a(c)},rOSjF:e(1183)+"or",AapFL:function(a){return a()},TcmbD:"complete",JbDDN:e(554)};if(no[e(541)](t))return;let s=new Promise((a,c)=>{let f=e,l={pkeWP:r[f(979)],mjrhd:r[f(1430)],HBKGB:function(E){return r[f(453)](E)}},x=()=>{let E=f;t[E(644)+E(1338)+E(474)](l[E(1677)],h),t["removeEv"+E(1338)+"ner"](E(1514),m),t[E(644)+"entListe"+E(474)](l.mjrhd,m)},h=()=>{a(),l.HBKGB(x)},m=()=>{let E=f;r[E(629)](c,t[E(1514)]||new DOMException(E(1183)+"or",r.rOSjF)),r[E(453)](x)};t[f(1672)+f(948)](f(1791),h),t[f(1672)+f(948)](f(1514),m),t[f(1672)+"Listener"]("abort",m)});no[e(717)](t,s)}function wy(t){io={mBCMS:function(r,s){return r(s)}}.mBCMS(t,io)}function _y(t){let e=M,r={gPSnQ:function(s,a){return s(a)},dMHAF:function(s,a){return s!==a},VFOrs:function(s,a){return s===a},CKjLW:function(s,a){return s>>>a},FmicW:function(s,a){return s>>>a},zGEdc:function(s,a){return s===a},lzzxg:function(s,a){return s(a)},YAfAl:function(s,a){return s(a)},afape:e(1214)+e(1680),qCzZH:e(743),ZVTkk:e(1245),DNkvW:function(s){return s()}};return t===IDBDatabase.prototype[e(1316)+e(1571)]&&!(r[e(1903)]in IDBTransaction[e(1258)+"e"])?r[e(1381)]!==r[e(643)]?function(s,...a){let c=e,f=t[c(783)](r[c(921)](Ei,this),s,...a);return Ic[c(717)](f,s[c(1512)]?s[c(1512)]():[s]),r[c(921)](Dt,f)}:(_0x142100[e(1274)](_0x4f24f2)||(_0x102a00=_0x1452ce[e(1939)+"er"](_0x4eb9c4)),r[e(1352)](this.unsigned,_0x206806[e(1187)])&&r[e(1833)](r[e(1911)](this[e(780)],31),1)&&r[e(1833)](r[e(1040)](_0x1b2362[e(780)],31),1)?!1:r[e(1833)](this[e(780)],_0x4202eb.high)&&r[e(850)](this.low,_0x20aa81.low)):r[e(1909)](py)[e(640)](t)?function(...s){let a=e;return t[a(590)](r[a(921)](Ei,this),s),r[a(921)](Dt,Ac[a(904)](this))}:function(...s){let a=e;return r[a(464)](Dt,t[a(590)](r[a(1264)](Ei,this),s))}}function yy(t){let e=M,r={FgWHX:function(s,a){return s===a},ysKgC:e(1333),ADNZo:function(s,a){return s instanceof a},GtiHk:function(s,a){return s(a)},FQBZv:function(s,a,c){return s(a,c)}};return r[e(991)](typeof t,r[e(1491)])?_y(t):(r.ADNZo(t,IDBTransaction)&&r[e(1315)](my,t),r.FQBZv(cu,t,hy())?new Proxy(t,io):t)}function Dt(t){let e=M,r={oKriN:function(a,c){return a instanceof c},TYlzm:function(a,c){return a(c)},NvXKz:function(a,c){return a!==c}};if(r[e(723)](t,IDBRequest))return r[e(1746)](gy,t);if(Qs[e(541)](t))return Qs.get(t);let s=yy(t);return r.NvXKz(s,t)&&(Qs[e(717)](t,s),ro[e(717)](s,t)),s}var cu,nu,ru,Ac,no,Ic,Qs,ro,io,Ei,iu=au({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={jqWQI:function(r,s){return r||s},tBxxT:function(r,s){return r===s},SVipb:t(1441),BJKOF:function(r,s){return r instanceof s},xOmnN:t(1214)+t(1680),CwrkN:function(r,s){return r===s},CiYnO:"store",wlpzL:function(r,s){return r(s)},TjQyk:function(r,s){return r!==s},vLNKb:t(1517)};cu=(r,s)=>s[t(1656)](a=>r instanceof a),Ac=new WeakMap,no=new WeakMap,Ic=new WeakMap,Qs=new WeakMap,ro=new WeakMap,io={get(r,s,a){let c=t,f={lwnRg:function(l,x){return e[K(845)](l,x)}};if(e[c(875)]("moUQc",e.SVipb)){if(e.BJKOF(r,IDBTransaction)){if(e[c(875)](s,c(1103)))return no.get(r);if(s===e[c(1878)])return r[c(1214)+c(1680)]||Ic[c(904)](r);if(e[c(1935)](s,e[c(1159)]))return a[c(1214)+"oreNames"][1]?void 0:a["objectSt"+c(1735)](a[c(1214)+"oreNames"][0])}return e.wlpzL(Dt,r[s])}else{let l=this[c(802)].getItem(this[c(1787)]);return _0x3437a9[c(1313)](f[c(1708)](l,"{}"))[_0x3134d7]}},set(r,s,a){return r[s]=a,!0},has(r,s){let a=t;return e[a(1433)](a(1517),e[a(1228)])?this[a(1342)]?this[a(1342)][a(1188)]:this._url:e[a(1714)](r,IDBTransaction)&&(s===a(1103)||e.CwrkN(s,e[a(1159)]))?!0:s in r}},Ei=r=>ro[t(904)](r)}}),du={};xy(du,{deleteDB:()=>by,openDB:()=>Ey,unwrap:()=>Ei,wrap:()=>Dt});function Ey(t,e,{blocked:r,upgrade:s,blocking:a,terminated:c}={}){let f=M,l={rFwPi:function(m,E){return m!=E},iVHdO:f(1220),nIwkY:function(m,E){return m instanceof E},VfZZi:function(m,E){return m instanceof E},aDDkt:function(m,E,C,_,y){return m(E,C,_,y)},XYnMW:function(m,E){return m(E)},eQkMi:f(1668),ofzPz:f(1918)+"hange",TbGxJ:function(m,E){return m!==E},JLJFN:f(1215),wmioX:"upgraden"+f(1811)},x=indexedDB[f(503)](t,e),h=l[f(1443)](Dt,x);if(s){if(l.TbGxJ(l[f(1163)],l[f(1163)]))return l[f(1044)](l.iVHdO,typeof _0x1c5442)&&(l[f(1516)](_0x252908,_0x4a01e8)||_0x4a2247[f(1339)]&&l[f(1413)](_0x573647[f(1339)],_0x14ad0e))||l[f(1044)](l[f(1612)],typeof _0x567732)?"":(_0x353862[f(1313)](_0x237f95),"applicat"+f(844));x[f(1672)+f(948)](l.wmioX,m=>{let E=f;l.aDDkt(s,l[E(1443)](Dt,x[E(1337)]),m[E(1753)+"on"],m[E(860)+"on"],l[E(1443)](Dt,x["transact"+E(1571)]))})}return r&&x[f(1672)+"Listener"](f(919),()=>r()),h[f(1711)](m=>{let E=f;c&&m[E(1672)+E(948)](l[E(1285)],()=>c()),a&&m[E(1672)+E(948)](l[E(1503)],()=>a())}).catch(()=>{}),h}function by(t,{blocked:e}={}){let r=M,s={emheO:r(919)},a=indexedDB["deleteDa"+r(1414)](t);return e&&a.addEventListener(s[r(1720)],()=>e()),Dt(a)[r(1711)](()=>{})}function su(t,e){let r=M,s={pmDSo:r(1566),DuViE:r(1616)+"e",wRziq:r(693),CJdPb:function(x,h){return x instanceof h},Wdukp:function(x,h){return x in h},QcXoS:function(x,h){return x===h},qRQxS:function(x,h){return x!==h},bVpiV:"mAyAc"};if(!(s.CJdPb(t,IDBDatabase)&&!s[r(1731)](e,t)&&s.QcXoS(typeof e,r(1220))))return;if(eo.get(e))return eo.get(e);let a=e.replace(/FromIndex$/,""),c=s[r(982)](e,a),f=lu.includes(a);if(!(a in(c?IDBIndex:IDBObjectStore)[r(1258)+"e"])||!(f||fu[r(640)](a)))if(s.bVpiV!==r(1039))this[r(1342)]&&this[r(1342)][r(754)](_0x9ae654),this[r(662)](s.pmDSo,_0x391dfd);else return;let l=async function(x,...h){let m=r,E=this[m(1316)+m(1571)](x,f?s.DuViE:s[m(983)]),C=E[m(1299)];return c&&(C=C[m(1323)](h[m(1440)]())),(await Promise[m(467)]([C[a](...h),f&&E[m(1103)]]))[0]};return eo[r(717)](e,l),l}var fu,lu,eo,Sy=au({"node_modules/idb/build/index.js"(){let t=M,e={rTTNR:"getAll",UJwgX:t(1230)+"ys",jDtav:t(1150),lGuJW:function(a){return a()},SvSxX:t(1800),ahiyf:t(1547),VTpwn:t(774),qqijR:function(a,c){return a(c)}},r="4|1|0|2|5|3"[t(906)]("|"),s=0;for(;;){switch(r[s++]){case"0":fu=[t(904),t(1663),e[t(1107)],e[t(607)],e[t(1695)]];continue;case"1":e[t(752)](iu);continue;case"2":lu=[e[t(1180)],"add",e.ahiyf,e[t(1924)]];continue;case"3":e[t(1025)](wy,a=>({...a,get:(c,f,l)=>su(c,f)||a.get(c,f,l),has:(c,f)=>!!su(c,f)||a[t(541)](c,f)}));continue;case"4":e.lGuJW(iu);continue;case"5":eo=new Map;continue}break}}}),vy={idb:function(t){let e=M;t[e(995)]=Promise[e(1302)]()[e(1711)](()=>(Sy(),du))[e(1711)](function(r){return r})}},ou={};function Tt(t){let e=M,r={ODQHg:e(763)+"1"},s=r[e(708)][e(906)]("|"),a=0;for(;;){switch(s[a++]){case"0":var c=ou[t];continue;case"1":return f[e(995)];case"2":vy[t](f,f.exports,Tt);continue;case"3":var f=ou[t]={exports:{}};continue;case"4":if(c!==void 0)return c[e(995)];continue}break}}Tt.d=(t,e)=>{let r=K;for(var s in e)Tt.o(e,s)&&!Tt.o(t,s)&&Object["definePr"+r(1149)](t,s,{enumerable:!0,get:e[s]})},(()=>{let t=M;Tt.o=(e,r)=>Object.prototype["hasOwnPr"+t(1149)].call(e,r)})(),(()=>{let t=M,e={MMOoq:function(r,s){return r!=s},dtfYu:t(1623)+"d",SmBKm:t(700)+"le"};Tt.r=r=>{let s=t;e.MMOoq(e[s(1204)],typeof Symbol)&&Symbol[s(1861)+s(1437)]&&Object[s(1889)+s(1149)](r,Symbol[s(1861)+s(1437)],{value:s(1608)}),Object[s(1889)+s(1149)](r,e[s(1884)],{value:!0})}})();var Ee={};(()=>{let t=M,e={hkTNa:function(o,n){return o(n)},smLRr:function(o,n){return o+n},ShlkU:function(o,n){return o*n},Uavhe:function(o,n){return o===n},quZta:t(724),erpkz:t(1328),skQWf:function(o,n){return o(n)},rmuHB:function(o,n,i){return o(n,i)},uaNnI:t(797),Fwlrc:function(o,n){return o+n},dUsrq:t(1782),pESpz:"ffff",AkdRa:function(o,n){return o||n},CmPSs:t(1623)+"d",zrrjJ:function(o,n){return o===n},JhCHU:"eBFwt",VsnoM:t(1009)+t(1009)+t(1009)+t(1009),TUcsJ:function(o,n){return o||n},WiuIA:function(o,n){return o>=n},byGbK:function(o,n){return o===n},TCFDX:function(o,n){return o-n},YNDnR:function(o,n){return o>n},BzNZH:"hdgav",IXypm:function(o,n){return o<n},uQpim:function(o,n){return o!==n},hNHEc:t(1916),JnPeo:function(o,n){return o!==n},RlVVN:function(o,n){return o===n},oMFzb:function(o,n){return o-n},BcGCW:function(o,n){return o!==n},jeTju:function(o,n,i){return o(n,i)},ZOfxA:function(o,n){return o!==n},zegbS:function(o,n,i){return o(n,i)},VXxEs:function(o,n){return o(n)},YkycV:function(o,n,i){return o(n,i)},FAdFm:function(o,n,i){return o(n,i)},SOUCP:function(o,n){return o&n},gSuqJ:t(621)+t(1289)+t(1681)+t(1365),BIlBh:function(o){return o()},AwqHY:function(o,n){return o(n)},cJfNz:function(o,n){return o+n},tnJaV:t(1514),BBDwR:function(o,n,i){return o(n,i)},NLLNm:function(o,n,i){return o(n,i)},wdLko:function(o,n,i){return o(n,i)},OTjzV:function(o,n){return o!==n},otaVa:function(o,n,i){return o(n,i)},TcFJu:function(o,n,i){return o(n,i)},SjaBv:function(o,n){return o(n)},AXdQa:function(o,n,i){return o(n,i)},MMaKE:function(o,n,i){return o(n,i)},yUhlX:function(o,n){return o!==n},vwTeO:function(o,n,i){return o(n,i)},KjLhn:function(o,n){return o!==n},uZiOq:"laorI",qRlzG:function(o,n,i){return o(n,i)},wVGcK:function(o,n,i){return o(n,i)},awQBg:function(o,n){return o!==n},zJqLR:t(600),WBMjK:function(o,n,i){return o(n,i)},uRWVk:function(o,n,i){return o(n,i)},vNwib:function(o,n){return o(n)},AsIuf:t(1389),xAQDB:"ping_once_timeout",Yajdm:function(o,n,i){return o(n,i)},MNXrE:t(744)+t(807)+"s",xRlxu:function(o,n){return o(n)},aJItD:t(1405),VaNbu:function(o,n){return o>>>n},SUQiM:function(o,n,i){return o(n,i)},mtYfj:function(o,n){return o(n)},pgRAI:function(o,n){return o(n)},NDWHH:function(o,n){return o(n)},uuooM:function(o,n,i){return o(n,i)},xcsXV:function(o,n){return o(n)},suzPo:function(o,n,i){return o(n,i)},dYRDL:function(o,n,i){return o(n,i)},qNaoe:function(o,n){return o(n)},ZIvEp:t(621)+t(1289)+t(1681)+t(1294),DWtri:function(o,n,i){return o(n,i)},UXCOU:t(1742)+t(1340)+t(1344),ZxJTq:function(o,n){return o!==n},bACIr:t(1548),sFxNm:t(1156),fKkoE:function(o,n){return o>>n},LDVlr:function(o,n){return o>=n},aznYR:t(1052),VKDIK:"qpjDG",bkNkE:function(o,n){return o===n},ezlgA:t(1817)+t(989),Yjofu:function(o,n){return o+n},pltIX:function(o,n){return o>n},IztIf:t(1206)+t(989),vcpBm:function(o,n){return o*n},pwwZT:function(o,n){return o>n},ZkwXd:function(o,n,i){return o(n,i)},hdmpf:t(1179),CecHZ:function(o,n){return o===n},AvEGb:function(o,n){return o&n},mSrNP:function(o,n){return o(n)},RijoT:function(o,n){return o===n},bCVet:function(o,n){return o&n},deVYN:function(o,n){return o+n},QNfVW:function(o,n){return o+n},auUOr:function(o,n){return o|n},DkPYG:function(o,n){return o<<n},bSjpj:function(o,n){return o&n},guOPX:function(o,n){return o&n},WEmha:function(o,n){return o==n},TfYQG:function(o,n){return o+n},HIjWr:"owKFN",ZYfhy:function(o,n){return o+n},mtYpV:function(o,n){return o!==n},yMNrW:function(o,n){return o&n},XWdFQ:function(o,n){return o|n},sICRR:function(o,n){return o<<n},htKkv:function(o,n){return o|n},AoaMP:function(o,n){return o<<n},Zneap:function(o,n){return o<n},hgVHy:function(o,n){return o<=n},ApgsO:function(o,n){return o&n},BwCiL:function(o,n){return o+n},PAuYt:function(o,n){return o+n},PsGLr:function(o,n){return o+n},efHmP:function(o,n){return o+n},NfcRC:function(o,n){return o!==n},oChGp:function(o,n){return o&n},KBKzF:function(o,n){return o|n},xUeIv:function(o,n){return o<<n},CWNQc:function(o,n){return o|n},sDpcr:function(o,n){return o<<n},SCxNF:function(o,n){return o&n},kBUIc:function(o,n){return o<<n},LVDbE:function(o,n){return o&n},aROVO:function(o,n){return o&n},efDCY:function(o,n){return o>n},ENLwn:function(o,n,i){return o(n,i)},Xkzyj:function(o,n){return o>>n},KucUh:function(o,n){return o+n},OPYjt:function(o,n){return o&n},TULYr:function(o,n,i,d){return o(n,i,d)},qanqZ:function(o,n){return o<n},ZLuzd:function(o,n){return o>=n},yjwvP:function(o,n){return o<=n},sXoXn:function(o,n){return o<n},neeye:function(o,n){return o<<n},NLfnF:function(o,n){return o<n},ycNgR:function(o,n){return o<n},DznvY:function(o,n,i){return o(n,i)},jxcNa:function(o,n){return o+n},QPjPV:function(o,n){return o+n},WmoDp:function(o,n){return o<<n},nCMxE:function(o,n){return o<n},rYxbg:function(o,n){return o|n},dmtff:"wCwtq",eADSM:function(o,n){return o>>n},TEjwH:function(o,n){return o>>n},bjehN:function(o,n){return o&n},SKoYT:function(o,n){return o|n},SlMBx:function(o,n){return o>>n},EKXqg:function(o,n){return o&n},POjjV:function(o,n){return o(n)},iiOWt:function(o,n,i){return o(n,i)},IRDVb:"XxUOZ",YixmS:function(o,n,i){return o(n,i)},syAVu:"YLyfK",gFJaU:function(o,n){return o&n},gZDWL:function(o,n){return o<<n},eZLfp:function(o,n){return o&n},imfqC:function(o,n){return o&n},qOdSb:function(o,n){return o&n},AkzVC:function(o,n){return o&n},wJpex:function(o,n){return o|n},QehWH:function(o,n,i){return o(n,i)},WmJbU:function(o,n){return o(n)},yBfva:function(o,n){return o&n},XADTJ:function(o,n){return o<<n},KeAFt:function(o,n){return o<<n},JJKeN:function(o,n){return o&n},vMCxl:function(o,n){return o(n)},YyNeh:function(o,n){return o&n},aDSZS:"penMt",AZPlS:t(497),nHNMk:function(o,n){return o(n)},IFLpB:t(1380),dckDR:function(o,n){return o(n)},fOlhq:function(o,n){return o&n},zJxrW:function(o,n){return o&n},FULch:function(o,n){return o&n},XrqEp:function(o,n){return o&n},tOIxe:function(o,n){return o|n},wPdeI:function(o,n){return o<<n},FIbUX:function(o,n){return o>>>n},anrCB:function(o,n){return o<<n},GWRNl:function(o,n){return o<n},RGEnB:function(o,n){return o<n},cXqXv:function(o,n){return o<n},vMUqL:function(o,n){return o<n},zWhOu:function(o,n){return o&n},cgXjV:function(o,n){return o>>>n},iGxga:function(o,n){return o+n},wuacG:function(o,n){return o|n},TzdeU:function(o,n){return o>>>n},yPpoZ:function(o,n){return o>>>n},VVRPD:function(o,n){return o+n},QjHvT:function(o,n){return o!==n},MmwEH:function(o,n){return o&n},cVEBl:function(o,n){return o+n},JyDfz:function(o,n){return o!==n},plopD:function(o,n){return o&n},eeDOY:function(o,n){return o+n},aqJqI:function(o,n){return o!==n},doEkK:function(o,n){return o&n},RsmSv:function(o,n){return o>>>n},tSLhD:function(o,n){return o|n},GEFQX:function(o,n){return o>>>n},hwqXp:function(o,n){return o+n},VKoSm:function(o,n){return o!==n},JdZIh:function(o,n){return o(n)},OgkkH:function(o,n){return o|n},WuNBZ:function(o,n){return o|n},ATHYE:function(o,n){return o===n},YSHvc:function(o,n){return o<<n},uAEkJ:function(o,n){return o<<n},LFame:function(o,n){return o<<n},wtaJv:function(o,n){return o|n},YNQyA:function(o,n){return o|n},xZaKH:function(o,n){return o|n},wSvPs:function(o,n){return o<<n},BbVgM:function(o,n){return o<<n},VMnDO:function(o,n){return o|n},XDlMH:function(o,n){return o|n},KYGht:function(o,n){return o<<n},Tgtyq:t(1146),BWTxC:function(o,n){return o>>>n},gceZM:function(o,n){return o|n},CNKoZ:function(o,n){return o|n},BtKRu:function(o,n){return o>>>n},NcHyJ:function(o,n){return o|n},oPAja:function(o,n){return o|n},oGewt:function(o,n){return o&n},bTlAG:function(o,n){return o>>>n},UMKwd:function(o,n){return o&n},elCww:function(o,n){return o>>>n},OsVOc:function(o,n){return o>>>n},liQzW:function(o,n){return o>>>n},kbYHp:function(o,n){return o<=n},cjwUs:function(o,n){return o%n},AImWq:function(o,n){return o/n},KLwDj:function(o,n){return o>>>n},FrkFc:function(o,n){return o&n},SPtyT:function(o,n){return o>>>n},OfFRt:function(o,n){return o>>>n},PFQKh:function(o,n){return o+n},BHJPW:function(o,n){return o>>>n},blzbL:function(o,n){return o+n},BDNhA:function(o,n){return o|n},GDybi:function(o,n){return o!==n},HVofL:function(o,n){return o===n},wSSrW:function(o,n){return o>>>n},vEMSq:function(o,n){return o===n},NUTXs:function(o,n){return o&n},LcMIy:function(o,n){return o&n},IsRYQ:function(o,n){return o&n},Yoobm:function(o,n){return o>>>n},QqWEY:function(o,n){return o===n},TJkmw:t(548),NRKRO:"KfNCO",HMjPf:function(o,n){return o&n},ypvli:function(o,n){return o&n},VaGWe:function(o,n){return o>>>n},kehIG:function(o,n){return o&n},wfpvK:function(o,n){return o>>>n},BBWmx:"NATIVE_E"+t(796),NzwWb:t(941)+t(510),jOzKC:"MAX_RETR"+t(770)+"R",XWMli:t(1449)+t(1359),rXEiq:t(1521)+"OR",DbEVc:"0|2|5|3|"+t(961),BYcIc:function(o,n){return o<n},UPHSQ:function(o,n){return o<<n},irRsz:function(o,n){return o===n},ghrKJ:function(o,n){return o===n},NnNWi:t(990),Diofp:"opUYK",TipdN:function(o,n){return o+n},Uiyjn:function(o,n){return o(n)},VFitz:function(o,n,i){return o(n,i)},bIaJa:function(o,n){return o===n},qfMmd:"UoCmx",IUDLP:t(1609),AqMHG:"Kfmoj",Sgyhv:function(o,n){return o===n},xSDok:function(o,n){return o===n},CfStu:function(o,n){return o==n},pPvRf:function(o,n){return o===n},QUqnU:t(1309),nZaMl:function(o,n,i){return o(n,i)},oKkhW:function(o,n,i){return o(n,i)},iMiFT:function(o,n){return o!==n},LKTyT:t(1839),aARwL:function(o,n){return o===n},xzDnD:function(o,n){return o instanceof n},ZMwNk:function(o,n){return o+n},sDxDI:t(1940)+t(1483),mYOaH:function(o,n){return o+n},oWKrC:function(o,n){return o===n},CNSug:function(o,n){return o===n},cDAkc:function(o,n){return o<n},YUXTf:function(o,n){return o|n},LhiwI:t(1427)+t(786),vYyeo:function(o,n){return o&n},HQPuq:function(o,n){return o|n},MzRUL:function(o,n){return o>>n},kolUf:function(o,n){return o&n},xtAaD:function(o,n){return o+n},XEXkQ:function(o,n){return o+n},WFrpQ:function(o,n){return o>>n},KGoPl:function(o,n){return o|n},VUmqr:function(o,n){return o&n},FUlhU:function(o,n){return o|n},qHyqW:function(o,n){return o===n},zTgty:"vrdEK",ZYSij:t(482),soujM:"Qkmcz",Gdlro:t(1668),bInkK:function(o,n){return o(n)},VUQiO:t(503),OZkvX:function(o,n,i){return o(n,i)},MiaWD:function(o,n){return o!==n},LNkDB:"tiFaJ",tHZnk:function(o,n,i){return o(n,i)},fpoHN:function(o,n){return o+n},Egztg:function(o,n,i){return o(n,i)},ORYGy:t(963),GidnM:t(1845),hzicK:function(o,n){return o===n},NpAkL:t(1574),RBwqi:function(o,n){return o||n},IKITE:function(o,n){return o!=n},zqGkC:function(o,n){return o!=n},LyKtZ:"next() c"+t(618)+t(1639)+t(1232)+t(1751),oDYyR:function(o,n){return o(n)},BZeKj:function(o,n){return o<n},wyAmG:function(o,n){return o&n},LOSCC:function(o,n,i){return o(n,i)},YuoEP:function(o,n){return o===n},KUASB:"GVFjb",gDKQZ:function(o,n){return o-n},AmLUj:t(1141),DWWzl:t(1372),LMaZa:function(o,n){return o>=n},IgXFO:function(o,n){return o<<n},OGKQN:function(o,n){return o&n},rPLWY:function(o,n){return o<n},IQNtL:function(o,n){return o|n},jaFhx:function(o,n){return o<<n},ecBYE:function(o,n){return o&n},gbzHS:function(o,n){return o>=n},eoAkE:function(o,n){return o-n},UrYxO:function(o,n){return o<<n},Ilcwz:function(o,n){return o&n},gfLsu:function(o,n){return o<<n},haImq:function(o,n){return o<<n},Olwvw:function(o,n){return o&n},CICRs:function(o,n){return o>>n},lchJk:function(o,n){return o|n},ublln:function(o,n){return o|n},AoAJL:function(o,n){return o&n},HJAFy:function(o,n){return o+n},RXQjk:"4|5|3|0|"+t(1780),NyOzr:function(o,n){return o|n},ibRQh:function(o,n){return o&n},yzmpQ:function(o,n){return o>>n},wFOAQ:function(o,n){return o+n},PblAq:function(o,n){return o+n},jOqeG:function(o,n){return o&n},MceEm:function(o,n){return o|n},gqZBe:function(o,n){return o>>n},NxHNu:function(o,n){return o|n},XrFNJ:function(o,n){return o|n},tnmdO:t(1220),SLegw:function(o,n){return o(n)},IbrAK:function(o,n,i,d){return o(n,i,d)},tqJCR:function(o,n){return o instanceof n},iqvuA:function(o,n){return o instanceof n},PLBqh:t(1606)+"ion/json",VyQQS:"text/plain;chars"+t(1098),GmYzF:t(778),LDBTB:t(593),ljynI:t(625)+t(1045),hyaLD:"&jscallb"+t(1617)+"tierJSONP",ljgWa:function(o,n){return o!==n},RIvQq:t(1478),XWKoY:t(568),ojyDZ:t(455),pmHbj:function(o,n){return o+n},BliQE:"http",dzbNZ:function(o,n){return o(n)},aIORl:t(645)+t(1087),FcgAl:t(1275),XuliF:t(1203)+t(1748),PvoZv:function(o,n,i,d){return o(n,i,d)},uYSRU:t(1203)+"er_ack_m"+t(1444),IaNIo:function(o,n){return o!==n},JEZhi:t(1826),NoFYB:function(o,n){return o||n},wsbVH:t(1261),ozsdZ:function(o,n){return o||n},jOwdz:t(835),tSFPo:function(o,n){return o||n},FQGMi:function(o,n,i,d){return o(n,i,d)},oAhzY:t(1789),CBMnB:function(o,n){return o||n},Rdsmj:"pagehide",ddGcB:t(449),pYFVt:t(687),OHrDS:t(1865),lkuKv:function(o,n){return o||n},eWkvb:t(463),xqHAu:function(o,n){return o||n},CarfQ:function(o,n){return o||n},tXqWe:t(454)+t(1758)+"d",yLNCb:t(1251),fGbhf:t(787),kGgzd:function(o,n,i){return o(n,i)},ruBcE:t(1645),zEPaM:t(555)+"id",YMiJT:function(o,n,i){return o(n,i)},DWQhx:function(o,n){return o===n},dOKYe:t(1177),EWHiJ:function(o,n,i){return o(n,i)},YIoVz:function(o,n,i){return o(n,i)},XjFYM:t(1034),IGMhB:function(o,n){return o(n)},LbLsj:function(o,n,i,d){return o(n,i,d)},HeHVQ:t(1203)+"er_qos_ack",uTNdG:"x_fronti"+t(903)+"k",XNMTV:function(o,n,i){return o(n,i)},KoWbS:t(918),ehDEj:t(740),hUwjg:function(o,n,i,d){return o(n,i,d)},KsDXn:"is_ack",xJanY:function(o,n){return o&&n},WYtxM:"ack_code",NzvWa:function(o,n){return o(n)},SDFHF:function(o,n){return o<n},CYxhY:function(o,n){return o!==n},ULIcK:"EsYTj",aSHcQ:t(1131),xhfwD:t(742),aSEnh:function(o,n,i){return o(n,i)},nIVxv:t(758)+t(777),cZCqr:t(748),xMftM:function(o,n){return o(n)},ayAiS:function(o,n){return o(n)},iRcVr:function(o,n){return o===n},biwvC:t(581),onqGj:"aDWXj",fulnS:function(o,n){return o instanceof n},thmis:t(1606)+"ion/json"+t(1696)+t(1061),Ahpnl:t(1594)+"e",mSAum:t(613),IutBJ:function(o,n){return o<n},YFCom:function(o,n){return o>n},KWNDc:function(o,n){return o||n},JMMxw:function(o,n){return o>>>n},lRAbP:function(o,n){return o+n},KuOkR:function(o,n){return o+n},jmxrD:function(o,n){return o+n},ODNWf:t(761)+t(1886)+"ge: ",mubJy:t(1226),prMyg:t(1317)+t(1718)+"e",nflcG:function(o,n){return o>=n},PcgCc:function(o,n){return o&n},QuWOS:function(o,n){return o+n},CIUEe:"aVcUk",YTTiY:"aFrFf",wVLIT:function(o,n){return o<n},iyiCJ:function(o,n){return o>>>n},UwcTT:function(o,n){return o<<n},NHiHt:t(1175)+"4",vSapy:function(o,n){return o+n},ZEbZF:function(o,n,i,d){return o(n,i,d)},OCZaO:function(o,n,i,d){return o(n,i,d)},sALBB:function(o,n){return o|n},RzlEh:function(o,n){return o|n},kqtOa:function(o,n){return o<<n},cCYiP:function(o,n){return o<<n},CmZoE:function(o,n){return o+n},rxkPE:function(o,n){return o|n},KwBZE:function(o,n){return o<<n},RdPyJ:function(o,n){return o>>>n},MzQXf:function(o,n){return o&n},nngwV:function(o,n){return o+n},vnEUJ:function(o,n){return o>>>n},qmmNs:function(o,n){return o+n},IfQRw:function(o,n){return o&n},AxVky:function(o,n){return o&n},pDGCC:function(o,n){return o+n},HRUow:function(o,n){return o+n},fGJQM:function(o,n){return o===n},JcVDs:"uYkZH",mbpBb:function(o,n){return o<n},mNFUe:function(o,n){return o&n},JgSyZ:function(o,n){return o<<n},EOjiu:function(o,n){return o>>>n},RAUcc:function(o,n){return o(n)},CFYfm:"header",iCnEi:t(1683),nnLtw:function(o,n,i,d){return o(n,i,d)},rLDKE:t(781)+"ervice",iGKFv:function(o,n){return o(n)},ZhaRE:function(o,n,i,d){return o(n,i,d)},VQmvn:function(o,n){return o+n},HjKGl:function(o,n,i){return o(n,i)},vYfHF:t(837)+t(1864),GFgDZ:t(718)+"_EXIST",LgSQf:t(1582),hCFmb:t(1189),MXFxP:function(o,n){return o!==n},OWNTD:"wHNfk",rmAZk:"NamzD",mOGzf:t(1303)+t(1542),atVTf:t(701),svyMn:t(682),NtVIK:function(o,n,i,d){return o(n,i,d)},ZOqjj:function(o,n,i){return o(n,i)},BcXRc:function(o,n){return o<n},BBSXh:function(o,n){return o||n},VkWYx:t(623),xnFyK:"reconnect",WuAVL:"start",TOYuS:function(o,n,i,d){return o(n,i,d)},iqWeF:t(1203)+"er_msgid",slAdh:function(o,n){return o(n)},yKxWt:function(o,n,i){return o(n,i)},MDmpL:t(1203)+t(1489),KZToz:t(1255)+"s",PuhPn:t(884)+t(1006)+"e",tqGst:function(o,n){return o(n)},IetEJ:t(884)+t(1153)+"ue",Qwwjq:function(o,n){return o>n},LjmBS:t(1426),StxzM:t(747),SqOZY:function(o){return o()},BdokJ:t(1020),sWnhP:function(o){return o()},YVEYB:function(o){return o()},PPKkq:function(o){return o()},OVDIw:function(o){return o()},yVBYt:function(o){return o()},UTpCh:function(o,n){return o&&n},jlUFE:function(o){return o()},EGHqL:function(o,n,i){return o(n,i)},Arrti:function(o){return o()},XKunE:function(o,n){return o(n)},EIaXP:function(o,n){return o(n)},ejonp:function(o){return o()},wtunh:function(o,n){return o>=n},PTOzA:function(o,n){return o>=n},kVxlo:function(o,n){return o|n},OznTp:function(o,n){return o%n},ZMyNT:function(o,n){return o/n},OWbZK:function(o){return o()},aUMVE:function(o,n){return o<n},cNYwA:t(1164),ZhoiP:t(1272),tgEvw:function(o,n){return o===n},FVAxP:function(o,n){return o!==n},skozm:function(o,n){return o!==n},jpuxX:"Hmfig",kDzjB:t(1642),hGKbR:function(o,n){return o!==n},pTaYu:"HqGeJ",XPeRC:function(o,n,i){return o(n,i)},pwUfZ:function(o,n,i){return o(n,i)},IGTfn:t(1190),wijfm:function(o,n){return o(n)},tUvVj:function(o,n,i){return o(n,i)},fDcAx:function(o,n){return o!==n},GwIXF:t(1134),bKRCc:function(o,n,i,d){return o(n,i,d)},qOkFM:function(o,n,i){return o(n,i)},Ivdld:function(o,n){return o===n},RWgAa:"always",UUIhD:function(o,n,i,d){return o(n,i,d)},qDdjW:function(o,n){return o!==n},NiKdx:t(1001)+t(458),VpRvl:t(512),ccGtQ:t(1732)+"rovide v"+t(694),LrKoz:function(o,n){return o===n},WAYrz:t(1725),khEeF:t(1438)+t(1350)+t(851)+"ct",tMFnC:function(o,n){return o===n},vaNNM:function(o,n){return o===n},wNmQz:function(o,n,i){return o(n,i)},KRszb:t(462),fYsgG:"UnPQi",rvAcE:t(477),kiFUy:"offline",cUoDo:function(o,n){return o===n},BmKyD:t(1798),KCOOI:"WbXRK",kHkxK:function(o,n){return o!==n},sVVos:t(1060),QaviY:"wss://",JggXd:t(577),DgRxc:t(1790),bRGPX:t(1732)+t(1446)+"ddID, de"+t(866)+t(1709),kultL:function(o,n){return o==n},VuGGP:function(o,n,i){return o(n,i)},YxtWf:t(1913),WExvb:t(1121)+"0",hFQFz:"xlEnX",ujujy:function(o,n){return o===n},OCKFx:t(660)+">",UsKrk:function(o,n){return o-n},RRkOO:function(o,n){return o+n},EpdgW:function(o,n){return o(n)},YcjoY:function(o,n){return o!==n},VRsjd:t(523),yHtAK:t(749),jsQLi:function(o,n,i){return o(n,i)},KXulR:"timeout",ENQlf:function(o,n){return o>>n},muPXV:t(1508)+"ay, try reconnec"+t(1684)+t(456),jxHMv:t(1199)+t(1495)+"onnecting",WkGjA:function(o,n){return o||n},YeIcq:function(o,n){return o==n},ULaxj:function(o,n){return o!==n},DcCdL:t(815),ZROcW:t(1237),DmHcF:"send_ack",auixb:"1|0|2|4|3",tZJcJ:"message",qNrya:t(909)+"1",YbkNn:t(1278),Ywxxx:function(o,n){return o===n},nQjKx:function(o,n){return o===n},sPctz:t(1158),FnvNM:function(o,n){return o===n},bBxkV:t(1403),ACJzR:function(o,n,i){return o(n,i)},uYKUn:t(1508)+t(788)+t(753)+t(574),wRsPd:function(o,n){return o===n},OBJvL:t(1085),tftpo:function(o,n){return o+n},YtmBj:function(o,n){return o>>>n},kmxIt:function(o,n){return o>>>n},YnEQE:function(o,n){return o>>>n},gdGhG:function(o,n){return o&n},NvgkF:function(o,n){return o&n},fkxpP:function(o,n){return o>>>n},mZZcA:function(o,n){return o===n},YIuGw:t(1533),uMlAD:function(o,n){return o===n},hpgTD:function(o,n){return o===n},zpoaw:t(1330)+"s alread"+t(610),XabYa:t(1026),yTjqd:t(1363),byKYA:"please provide a"+t(1872)+t(1408)+t(1369)+t(779)+"ng or an"+t(1066)+t(1698),YsZNI:function(o,n){return o==n},ZfhMu:"number",tQzlE:function(o,n){return o!=n},MjFRK:function(o,n){return o instanceof n},Svpfh:function(o,n){return o instanceof n},wuPhM:function(o,n){return o||n},VeaQC:t(1732)+t(1846)+t(1432)+t(1821),akwdK:function(o,n){return o instanceof n},TCgZL:"enqueue",xhRWh:function(o,n){return o==n},WDHnX:"eRvtg",jnJtv:t(1550),YwvYf:function(o,n){return o+n},gWGzM:function(o,n){return o&n},WDHwu:function(o,n){return o+n},umxCw:function(o,n){return o>>>n},pTWxI:function(o,n){return o&n},aAemv:function(o,n){return o===n},iSSSI:t(720),LstTf:function(o,n){return o!==n},xmskF:t(696),eThIy:"\0\0\0\0\0\0\0\0",VJnJj:function(o,n){return o/n},ugOnK:function(o,n){return o===n},XJwSJ:t(946),oiYXR:function(o,n){return o!=n},HVGch:function(o,n){return o===n},AhJeF:function(o,n){return o!=n},PmahB:function(o,n){return o!=n},BIPud:"Object",qjIvq:function(o,n){return o===n},ImlZE:t(632)+t(987)+"lobalScope",ZUOmI:function(o,n){return o==n},KIZMt:function(o,n){return o!=n},noomL:t(1836)+t(689)+t(1208),GDNSV:function(o,n){return o!=n},aLngY:function(o,n){return o!=n}};Tt.r(Ee),Tt.d(Ee,{FWS:()=>Fh,CustomErrorEvent:()=>h0,createCloseEvent:()=>at,ReconnectEvent:()=>x0,createErrorEvent:()=>et,decodedFrame:()=>qn,createOpenEvent:()=>y0,CustomCloseEvent:()=>p0,createReconnectEvent:()=>Po,FrontierMessageEvent:()=>m0,encodeFrame:()=>Ke,createMessageEvent:()=>_0,OpenEvent:()=>w0,ErrorCode:()=>Wt,Event:()=>jn,MessageEvent:()=>g0});let r="";function s(o=""){let n=t,i="02",d=""+Date[n(993)](),u=r||(r=e[n(535)](x,o)),p=Math[n(1435)]()[n(1861)](16).slice(-6);return e[n(513)](e.smLRr(e[n(513)](i,d),u),p)}function a(){let o=t;return e[o(513)](e[o(1922)](1e4,Date[o(993)]()),Math[o(707)](e[o(1922)](1e4,Math[o(1435)]())))}function c(o){let n=t,i={MgmPj:"blocked"};if(e[n(1729)](e[n(1840)],e[n(1080)])){let d=_0x32b944["deleteDa"+n(1414)](_0x56e3e5);return _0x571e60&&d.addEventListener(xceowS.MgmPj,()=>_0x37952f()),_0x2cf25c(d)[n(1711)](()=>{})}else return e[n(513)](e[n(1688)](Array,8)[n(641)]("0"),e[n(1699)](parseInt,o,10)[n(1861)](2)).slice(-8)}function f(o){let n=t,i={eboXM:function(d,u,p){return e[K(1699)](d,u,p)}};if(e[n(1729)](e[n(771)],e.uaNnI))return e.Fwlrc(Array(4)[n(641)]("0"),parseInt(o,2).toString(16))[n(956)](-4);{let d=i[n(647)](_0x2f9e8a,"error",{message:_0x1c35b1.message,code:_0x4d91fa[n(1449)+n(1359)],error:_0x1c666b});this[n(1485)+n(1062)+"ent"](d)}}function l(o){let n=t,i=o[n(906)](/\./)[n(1676)](p=>c(p)),d=[];return d[0]=e[n(535)](f,i[0]+i[1]),d[1]=f(e[n(1130)](i[2],i[3])),[e[n(1543)],e[n(1543)],e[n(1543)],n(1782),e[n(1543)],e.pESpz,d[0],d[1]][n(641)]("")}function x(o){let n=t;if(e[n(764)](e[n(1018)],n(924))){let 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(471)](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(471)](o);return i?e[n(535)](l,o):d?h(o):e.VsnoM}else{if(_0xc18fde)return new _0x8dca22(_0xe5a02d[n(1188)],_0x350cec[n(1687)]);if(_0xc6b8f3||_0x179b7f)return new _0x4bd497(_0x3164e0[n(1188)],_0x5ee63d.protocol,_0xef69e5[n(966)]);if(e[n(1544)](_0x514764,_0x57779d)&&e[n(782)]!=typeof _0x257270&&_0x57292e)return new _0x1281b8(_0x50f8a7.url,_0x3829f9[n(1687)+"s"])}}function h(o){let n=t,i="",d=[],u=0,p=0,S=!0,b="0000";if(e.YNDnR(o[n(1168)]("::"),-1))if(e[n(1691)]!==e[n(1691)]){let g=this._qosDB[n(1033)+n(706)+"nc"](this[n(1787)]),T=_0x9c1555[n(1313)](e[n(481)](g,"{}"));return _0x33a02a[n(829)](T)}else{let g=o[n(906)]("::");for(let P=0;e[n(959)](P,g.length);P++){if(e[n(1008)](e[n(984)],e.hNHEc))return!!(e[n(619)](this[n(1713)+n(1280)],this.endpoints[n(1541)])||e[n(1634)](this[n(1713)+n(1280)],e[n(1707)](this[n(1737)+"s"][n(1541)],1))&&e[n(764)](this[n(1534)+n(804)+"riesCount"],this[n(1862)+"es"]));{let B=g[P];if(B.indexOf(":")>0){let j=B[n(906)](":");S&&(u=j[n(1541)]),p+=j.length;for(let V=0;V<j.length;V++)if(e[n(612)](4,j[V][n(1541)])){let J=b[n(1500)+"g"](0,e[n(1707)](4,j[V].length)),He=J[n(1835)](j[V]);d[n(1416)](He)}else d.push(j[V]);S=!1}else{if(e[n(1008)](4,B[n(1541)])){let j=b.substring(0,e[n(1707)](4,B[n(1541)])),V=j.concat(B);d[n(1416)](V)}else d[n(1416)](B);S&&(u+=1),p+=1,S=!1}}}let T="";for(let P=0;e.IXypm(P,e.TCFDX(8,p));P++)T=T[n(1835)](b);for(let P=0;P<d[n(1541)];P++)e[n(814)](P,u)&&(i=i[n(1835)](T)),i=i[n(1835)](d[P]);return i}{let g=o[n(906)](":");for(let T=0;e[n(959)](T,g.length);T++){let P=g[T];if(e[n(1008)](4,g[T][n(1541)])){let B=b.substring(0,e[n(1036)](4,g[T][n(1541)])),j=B[n(1835)](P);i=i[n(1835)](j)}else i=i.concat(P)}return i}}function m(o,n){let i=t,d=o[i(1324)];e[i(532)](void 0,d)&&(e.rmuHB(Y,n,10),e[i(848)](Le,n,d));let u=o.value;e[i(1090)](void 0,u)&&(e.zegbS(Y,n,18),e[i(1699)](Le,n,u))}function E(o){let n=t,i={};e:for(;!e[n(1283)](N,o);){let d=e[n(535)](_e,o);switch(d>>>3){case 0:break e;case 1:i[n(1324)]=e[n(1276)](we,o,_e(o));break;case 2:i.value=e[n(1056)](we,o,e[n(1688)](_e,o));break;default:e[n(848)](R,o,e.SOUCP(7,d))}}if(e[n(1634)](void 0,i[n(1324)]))throw new Error(n(621)+n(1289)+n(1681)+"key");if(e[n(764)](void 0,i[n(1365)]))throw new Error(e[n(1890)]);return i}function C(o){let n=t,i=e.BIlBh(A);return e.zegbS(_,o,i),e[n(1875)](z,i)}function _(o,n){let i=t,d={bdSPq:e.tnJaV,DmMmf:function($e,je,ct){return e[K(1056)]($e,je,ct)},DNAFI:function($e,je){return $e-je}},u=o[i(1439)];u!==void 0&&(e[i(525)](Y,n,8),e[i(1844)](ge,n,u));let p=o.LogID;e[i(1090)](void 0,p)&&(e.FAdFm(Y,n,16),e[i(1343)](ge,n,p));let S=o.service;S!==void 0&&(e[i(1343)](Y,n,24),ge(n,L(S)));let b=o.method;e[i(812)](void 0,b)&&(e[i(1880)](Y,n,32),e[i(1343)](ge,n,e[i(1283)](L,b)));let g=o[i(966)];if(g!==void 0)for(let $e of g){e.TcFJu(Y,n,42);let je=e[i(1171)](A);m($e,je),e[i(848)](Y,n,je[i(880)]),e[i(1844)](ot,n,je),e.SjaBv(k,je)}let T=o["payloadE"+i(483)];e.JnPeo(void 0,T)&&(e[i(611)](Y,n,50),e.jeTju(Le,n,T));let P=o[i(679)+i(1012)];e[i(612)](void 0,P)&&(Y(n,58),e[i(1842)](Le,n,P));let B=o[i(1539)];e[i(703)](void 0,B)&&(Y(n,66),e[i(1679)](Y,n,B.length),fe(n,B));let j=o[i(1460)];if(e[i(1327)](void 0,j))if(e[i(764)](i(637),e.uZiOq)){let $e=_0x54a457[i(1339)][i(956)](_0x5022a8[i(1014)+"et"],e[i(1710)](_0x1a71b3.byteLength,_0x3a6ce8.byteOffset));this[i(1114)]&&this[i(1114)][i(754)]({data:$e,fail:je=>{let ct=i;this[ct(1473)](d[ct(894)],d[ct(960)](_0x10dccc,d[ct(894)],{message:this["_formatE"+ct(1311)+ct(1053)](je)}))}})}else e[i(592)](Y,n,74),e[i(1844)](Le,n,j);let V=o["serverTi"+i(1358)];e.BcGCW(void 0,V)&&(Y(n,82),e[i(1779)](Le,n,V));let J=o[i(511)];J!==void 0&&(Y(n,90),e.jeTju(Le,n,J));let He=o[i(1773)+"e"];if(e[i(1402)](void 0,He))if(e[i(1174)]===i(600))e[i(1404)](Y,n,96),e[i(1700)](ge,n,e[i(1392)](L,He));else{let $e=_0x120859[i(1500)+"g"](0,ZsoUVf.DNAFI(4,_0x43e30.length)),je=$e[i(1835)](_0x31f209);_0x1328f4[i(1416)](je)}}function y(o){return e[t(1614)](v,e.hkTNa(F,o))}function v(o){let n=t,i={izMKL:function(d,u){return e[K(561)](d,u)},HojEf:"timeout",BcMDB:e.MNXrE,hVSWf:e.xAQDB};if(e[n(1729)](e[n(1382)],n(1405))){let d={};e:for(;!e[n(1283)](N,o);){let u=e[n(1688)](_e,o);switch(e[n(1341)](u,3)){case 0:break e;case 1:d[n(1439)]=Un(o,!0);break;case 2:d[n(1294)]=e.SUQiM(Un,o,!0);break;case 3:d[n(1318)]=e[n(651)](_e,o);break;case 4:d[n(1484)]=_e(o);break;case 5:{let p=e[n(1091)](I,o);(d[n(966)]||(d[n(966)]=[]))[n(1416)](e.NDWHH(E,o)),o[n(880)]=p;break}case 6:d[n(1094)+n(483)]=e[n(608)](we,o,e[n(1837)](_e,o));break;case 7:d[n(679)+n(1012)]=e[n(1466)](we,o,e[n(651)](_e,o));break;case 8:d.payload=e[n(934)](se,o,_e(o));break;case 9:d.LogIDNew=e[n(1531)](we,o,_e(o));break;case 10:d[n(680)+n(1358)]=e[n(1779)](we,o,e.vNwib(_e,o));break;case 11:d.msgID=we(o,e[n(561)](_e,o));break;case 12:d[n(1773)+"e"]=e[n(1788)](_e,o);break;default:e.AXdQa(R,o,e.SOUCP(7,u))}}if(e[n(1634)](void 0,d[n(1439)]))throw new Error(n(621)+n(1289)+n(1681)+n(1439));if(e.RlVVN(void 0,d[n(1294)]))throw new Error(e[n(1252)]);if(e[n(1729)](void 0,d[n(1318)]))throw new Error(n(621)+n(1289)+n(1681)+n(1318));if(e[n(764)](void 0,d[n(1484)]))throw new Error(n(621)+n(1289)+n(1681)+n(1484));return d}else{let d={oylnq:function(S,b){return S(b)},bdrjb:e[n(1808)],AgFVH:n(744)+n(807)+"s",flanu:e[n(473)]};this[n(1831)+n(1394)](),this[n(1597)+n(887)+"Id"]=e.Yajdm(_0x4d0754,this[n(669)][n(1277)](this),this[n(1578)][n(1353)+n(1314)]);let u=()=>{let S=n;d[S(1178)](_0x248951,d.bdrjb),this[S(811)](d[S(1613)],u),this[S(811)](d[S(1101)],p)},p=()=>{let S=n;i[S(1088)](_0x273ae8,i[S(1785)]),this[S(811)](i[S(1736)],u),this[S(811)](i.hVSWf,p)};this.on(e[n(1661)],u),this.on(e[n(473)],p),this[n(669)]()}}function I(o){let n=t,i=e.xRlxu(_e,o),d=o[n(880)];return o[n(880)]=e[n(513)](o[n(883)],i),d}function R(o,n){let i=t;switch(n){case 0:for(;e[i(1219)](128,Ae(o)););break;case 2:O(o,e[i(1392)](_e,o));break;case 5:e[i(1233)](O,o,4);break;case 1:e[i(848)](O,o,8);break;default:throw new Error(e[i(1530)]+n)}}function L(o){let n=t;return e[n(1827)](e[n(1624)],e[n(562)])?(o|=0,{low:o,high:e[n(502)](o,31),unsigned:e[n(1050)](o,0)}):this._ws?this[n(1342)][n(931)+"ns"]:""}let w=[];function A(){let o=t,n=w[o(1137)]();return n?(n[o(883)]=n[o(880)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(o){w.push(o)}function F(o){let n=t;return e.byGbK(e[n(971)],e[n(1891)])?!!this[n(802)]:{bytes:o,offset:0,limit:o[n(1541)]}}function z(o){let n=t,i=o[n(1017)],d=o.limit;return e[n(1869)](i[n(1541)],d)?i:i.subarray(0,d)}function O(o,n){let i=t;if(e[i(1325)](o.offset+n,o[i(880)]))throw new Error(e.ezlgA);o.offset+=n}function N(o){let n=t;return e[n(619)](o[n(883)],o.limit)}function U(o,n){let i=t,d=o[i(1017)],u=o[i(883)],p=o[i(880)],S=e[i(1795)](u,n);if(e[i(1757)](S,d[i(1541)])){let b=new Uint8Array(e[i(1922)](2,S));b.set(d),o[i(1017)]=b}return o[i(883)]=S,e[i(1325)](S,p)&&(o[i(880)]=S),u}function W(o,n){let i=t,d=o[i(883)];if(e[i(1757)](e.cJfNz(d,n),o[i(880)]))throw new Error(e.IztIf);return o[i(883)]+=n,d}function se(o,n){let i=t,d=W(o,n);return o[i(1017)].subarray(d,e[i(1795)](d,n))}function fe(o,n){let i=t,d=e[i(934)](U,o,n[i(1541)]);o[i(1017)].set(n,d)}function we(o,n){let i=t,d={MHiei:function(T,P){return e[K(513)](T,P)},KccMI:function(T,P){return T>P},KOllS:function(T,P){return e[K(1335)](T,P)},fJlbs:function(T,P){return e[K(1096)](T,P)}},u=e[i(726)](W,o,n),p=String[i(821)+i(737)],S=o[i(1017)],b="\uFFFD",g="";for(let T=0;e[i(959)](T,n);T++)if(e[i(1402)](i(1179),e[i(810)])){let P=_0x5442c4[i(1017)],B=_0x3ed492[i(883)],j=_0x3e235e.limit,V=uPrErn[i(634)](B,_0x329d64);if(uPrErn[i(728)](V,P.length)){let J=new _0x5c59ea(uPrErn[i(1655)](2,V));J[i(717)](P),_0x45581b[i(1017)]=J}return _0x123f14[i(883)]=V,uPrErn.fJlbs(V,j)&&(_0x5ef2cf[i(880)]=V),B}else{let P=S[e.cJfNz(T,u)],B,j,V,J;e[i(697)](e[i(1721)](128,P),0)?g+=e[i(834)](p,P):e[i(1068)](e[i(721)](224,P),192)?e[i(526)](T,1)>=n?g+=b:(B=S[e[i(1035)](e[i(526)](T,u),1)],e[i(1721)](192,B)!==128?g+=b:(J=e[i(825)](e[i(686)](e.bSjpj(31,P),6),e[i(1436)](63,B)),e[i(959)](J,128)?g+=b:(g+=p(J),T++))):e.WEmha(e[i(1436)](240,P),224)?e.LDVlr(e[i(1874)](T,2),n)?g+=b:i(1054)===e[i(459)]?(B=S[e[i(1795)](T,u)+1],j=S[e[i(1035)](e[i(698)](T,u),2)],e[i(791)](e[i(1490)](e[i(1540)](B,e[i(1747)](j,8)),49344),32896)?g+=b:(J=e.XWdFQ(e[i(1755)](e[i(1747)](15&P,12),e[i(1236)](63&B,6)),e[i(1219)](63,j)),e[i(499)](J,2048)||e[i(619)](J,55296)&&e.hgVHy(J,57343)?g+=b:(g+=p(J),T+=2))):this["currentE"+i(804)+"riesCount"]=0:e[i(1858)](e[i(1631)](248,P),240)?e[i(1050)](e[i(1710)](T,3),n)?g+=b:(B=S[e[i(998)](e[i(998)](T,u),1)],j=S[e[i(1499)](T,u)+2],V=S[e.PsGLr(e[i(1127)](T,u),3)],e[i(657)](e[i(1898)](e[i(1376)](B,e.xUeIv(j,8))|V<<16,12632256),8421504)?g+=b:(J=e[i(825)](e[i(589)](e.sDpcr(e[i(1726)](7,P),18),e[i(1622)](e[i(1093)](63,B),12)),e[i(686)](e[i(1144)](63,j),6))|63&V,J<65536||e.efDCY(J,1114111)?g+=b:(J-=65536,g+=e[i(1429)](p,e[i(1520)](J,10)+55296,e.KucUh(e[i(1701)](1023,J),56320)),T+=3))):g+=b}return g}function Le(o,n){let i=t,d={EOuef:function(g,T,P,B){return e[K(847)](g,T,P,B)},dLhfD:function(g,T,P){return e[K(1276)](g,T,P)},uDtdf:e[i(1059)]},u=n[i(1541)],p=0;for(let g=0;e[i(1673)](g,u);g++){let T=n[i(965)+"At"](g);e[i(765)](T,55296)&&e[i(1110)](T,56319)&&e[i(1678)](g+1,u)&&(T=e[i(1499)](e[i(1799)](T,10),n[i(965)+"At"](++g))-56613888),p+=e.NLfnF(T,128)?1:e[i(499)](T,2048)?2:e.ycNgR(T,65536)?3:4}Y(o,p);let S=e[i(1568)](U,o,p),b=o.bytes;for(let g=0;e.sXoXn(g,u);g++){let T=n.charCodeAt(g);if(e[i(619)](T,55296)&&e.yjwvP(T,56319)&&e[i(1673)](e[i(1719)](g,1),u)&&(T=e[i(1598)](e.WmoDp(T,10),n[i(965)+"At"](++g))-56613888),e.IXypm(T,128))b[S++]=T;else{if(e[i(584)](T,2048))b[S++]=e.rYxbg(e[i(1436)](e[i(1520)](T,6),31),192);else if(e[i(1008)](e.dmtff,e.dmtff))try{d[i(1855)](_0xf21916,this,_0x25b3b3,[_0x554eb3,_0xc9388c,_0x244c2e])}catch(P){let B=d[i(1818)](_0x1458fa,d[i(1051)],{message:P[i(1727)],code:_0x15ec3b.OPEN_ERROR,error:P});this[i(1485)+i(1062)+i(1464)](B)}else e.NLfnF(T,65536)?b[S++]=e.XWdFQ(e[i(1685)](T,12)&15,224):(b[S++]=e[i(1376)](e[i(1452)](T,18)&7,240),b[S++]=e.auUOr(e.bjehN(T>>12,63),128)),b[S++]=e[i(1118)](e[i(1410)](e[i(558)](T,6),63),128);b[S++]=e[i(614)](63,T)|128}}}function ot(o,n){let i=t,d=e[i(848)](U,o,n[i(880)]),u=o.bytes,p=n[i(1017)];for(let S=0,b=n.limit;e[i(1678)](S,b);S++)u[e[i(1035)](S,d)]=p[S]}function Ae(o){return o[t(1017)][e.MMaKE(W,o,1)]}function Gt(o,n){let i=t,d={FUsNM:function(u,p){return u===p},TJndd:i(1333),xEGsn:function(u,p){return u(p)},BGtUN:function(u,p){return e[i(1573)](u,p)},uWtnJ:function(u,p,S){return e[i(583)](u,p,S)},LdSmG:function(u){return u()}};if(e.awQBg(e[i(1360)],e.IRDVb))return ECijnD[i(1024)](typeof _0x16c1ad,ECijnD.TJndd)?ECijnD[i(498)](_0x43333c,_0x2f1029):(_0x42b90c instanceof _0x5e8c06&&ECijnD[i(1583)](_0x2b03b7,_0x5b6e15),ECijnD[i(1143)](_0x58df4f,_0x4a7af6,ECijnD[i(1883)](_0x5ec025))?new _0x5e5d87(_0x230036,_0x179208):_0x281d2a);{let u=e.YixmS(U,o,1);o.bytes[u]=n}}function _e(o){let n=t,i=0,d=0,u;do if(e[n(814)](n(1108),e.syAVu))u=e.xRlxu(Ae,o),e.nCMxE(i,32)&&(d|=e[n(1747)](e[n(947)](127,u),i)),i+=7;else return this[n(802)]?.[n(1099)];while(e[n(1721)](128,u));return d}function Y(o,n){let i=t;if(e[i(1729)](i(1813),"HWWLh")){let d=e[i(1707)](e[i(1755)](e.gZDWL(e[i(1113)](7,_0x2b1f95),18)|e.WmoDp(e[i(1113)](63,_0x5b941d[_0x513917++]),12),e.imfqC(63,_0x27e7ce[_0x3c7e1a++])<<6)|e[i(1786)](63,_0x1d13ec[_0x1757d4++]),65536);_0x3c2731+=_0x22cbd0["fromChar"+i(737)](e[i(671)](55296,e[i(1452)](d,10))),_0x274b9f+=_0x3b6104["fromChar"+i(737)](e[i(526)](56320,e[i(792)](1023,d)))}else{for(n>>>=0;n>=128;)Gt(o,e.wJpex(127&n,128)),n>>>=7;e.QehWH(Gt,o,n)}}function Un(o,n){let i=t,d={PCALI:function(g,T){return e.hkTNa(g,T)}},u=0,p=0,S=0,b;return b=e.WmJbU(Ae,o),u=e.SOUCP(127,b),e[i(1815)](128,b)&&(b=e[i(1091)](Ae,o),u|=e[i(1229)](127&b,7),e[i(1734)](128,b)&&(b=Ae(o),u|=e.KeAFt(127&b,14),e.JJKeN(128,b)&&(b=e[i(547)](Ae,o),u|=e.YyNeh(127,b)<<21,e.AvEGb(128,b)&&(e.aDSZS!==e[i(1572)]?(b=e[i(900)](Ae,o),p=e.AkzVC(127,b),128&b&&(e[i(764)](e[i(1423)],e[i(1423)])?(b=e[i(1825)](Ae,o),p|=e[i(977)](127,b)<<7,e.zJxrW(128,b)&&(b=Ae(o),p|=e[i(1185)](127,b)<<14,e[i(540)](128,b)&&(b=e[i(561)](Ae,o),p|=e[i(686)](127&b,21),128&b&&(b=Ae(o),S=e.SOUCP(127,b),e[i(614)](128,b)&&(b=e[i(1366)](Ae,o),S|=e[i(1786)](127,b)<<7))))):(this[i(936)+i(1567)]=_0x47a13f,this[i(1150)]=0))):_0x36868b(_0xd2cd5(_0xb3350b[i(1337)]),_0x42e88f[i(1753)+"on"],_0xf1a10d.newVersion,vsjSLt[i(940)](_0x39bf29,_0x35c9c1[i(1316)+i(1571)])))))),{low:e.tOIxe(u,e[i(1926)](p,28)),high:e[i(589)](p>>>4,e[i(1167)](S,24)),unsigned:n}}function ge(o,n){let i=t,d=e[i(1341)](n.low,0),u=e[i(1660)](e[i(1376)](n.low>>>28,e[i(857)](n.high,4)),0),p=n[i(780)]>>>24,S=e.CecHZ(0,p)?u===0?e[i(959)](d,16384)?e[i(1319)](d,128)?1:2:e[i(1003)](d,2097152)?3:4:u<16384?e[i(584)](u,128)?5:6:e[i(1198)](u,2097152)?7:8:e[i(1766)](p,128)?9:10,b=U(o,S),g=o[i(1017)];switch(S){case 10:g[e[i(671)](b,9)]=e.zWhOu(e[i(476)](p,7),1);case 9:g[e[i(1537)](b,8)]=e[i(1008)](9,S)?e[i(1604)](128,p):127&p;case 8:g[e.QPjPV(b,7)]=S!==8?e[i(1540)](e[i(466)](u,21),128):e[i(614)](e[i(1686)](u,21),127);case 7:g[e[i(1138)](b,6)]=e[i(1069)](7,S)?e.VaNbu(u,14)|128:e[i(1013)](e.VaNbu(u,14),127);case 6:g[e[i(813)](b,5)]=e.QjHvT(6,S)?e.wJpex(e[i(1341)](u,7),128):e[i(1410)](u>>>7,127);case 5:g[e.cVEBl(b,4)]=e.JyDfz(5,S)?128|u:e[i(916)](127,u);case 4:g[e[i(1715)](b,3)]=e[i(1270)](4,S)?e[i(1540)](e[i(476)](d,21),128):e[i(1477)](e.RsmSv(d,21),127);case 3:g[e[i(1537)](b,2)]=S!==3?e[i(1581)](e[i(852)](d,14),128):e[i(1219)](d>>>14,127);case 2:g[e.hwqXp(b,1)]=S!==2?e[i(1581)](e[i(1341)](d,7),128):e[i(1898)](e[i(466)](d,7),127);case 1:g[b]=e[i(751)](1,S)?e[i(1755)](128,d):e[i(1477)](127,d)}}function qn(o){return e.xcsXV(y,o)}function Ke(o){return e[t(729)](C,o)}let d0=65536,Zx=e[t(1814)],Hn=e[t(1335)](d0,d0),f0=Hn*Hn,l0=e[t(1202)](f0,2),Kt=String.prototype[t(965)+"At"];class oe{constructor(n,i,d){let u=t;this[u(1274)]=!0,this[u(1724)]=e[u(1326)](0,n),this[u(780)]=e.WuNBZ(0,i),this[u(1187)]=!!d}static[t(1274)](n){return n&&e.ATHYE(!0,n.isLong)}static[t(656)](n,i,d){return new oe(n,i,d)}static fromBytes(n,i,d){let u=t;return d?oe[u(910)+u(1119)](n,i):oe[u(910)+u(1879)](n,i)}static[t(910)+t(1119)](n,i){let d=t;return new oe(e[d(521)](e[d(981)](n[0],e[d(683)](n[1],8))|e[d(1637)](n[2],16),e[d(665)](n[3],24)),n[4]|e.LFame(n[5],8)|e[d(1229)](n[6],16)|e[d(857)](n[7],24),i)}static[t(910)+"sBE"](n,i){let d=t;return new oe(e[d(551)](e.YNQyA(e[d(951)](e.wSvPs(n[4],24),n[5]<<16),e.BbVgM(n[6],8)),n[7]),e[d(1595)](e.XDlMH(e[d(1540)](n[0]<<24,n[1]<<16),e.KYGht(n[2],8)),n[3]),i)}static[t(1895)](n){let i=t;return e[i(791)]("BbzNl",e[i(1246)])?e[i(1729)](n,Zx)?u0:new oe(e[i(648)](e[i(1581)](e[i(915)](e.CNKoZ(Kt[i(783)](n,0),Kt.call(n,1)<<8),e[i(665)](Kt[i(783)](n,2),16)),e[i(1658)](Kt[i(783)](n,3),24)),0),e[i(1139)](e[i(1470)](e[i(491)](Kt[i(783)](n,4),Kt[i(783)](n,5)<<8)|e[i(1236)](Kt[i(783)](n,6),16),e.KYGht(Kt[i(783)](n,7),24)),0),!0):new _0x206070(d=>{let u=i;_0x3cd1de(d,this["_getInte"+u(1351)+"e"](_0x2f4a28))})}[t(1654)](){let n=t;return String["fromChar"+n(737)](e.LVDbE(255,this[n(1724)]),e[n(1093)](e[n(1341)](this[n(1724)],8),255),e[n(670)](e.bTlAG(this[n(1724)],16),255),e.cgXjV(this[n(1724)],24),e[n(1434)](255,this.high),e[n(1154)](e[n(1920)](this[n(780)],8),255),e[n(1093)](e[n(690)](this[n(780)],16),255),e.liQzW(this[n(780)],24))}static[t(1939)+"er"](n,i=!0){let d=t;if(e[d(561)](isNaN,n))return i?Yx:u0;if(i){if(e[d(619)](n,f0))return Qx}else{if(e[d(1448)](n,-l0))return eh;if(e.efHmP(n,1)>=l0)return Xx}return oe[d(656)](e[d(1470)](e[d(762)](n,Hn),0),e[d(878)](e.AImWq(n,Hn),0),i)}toNumber(){let n=t;return this[n(1187)]?e.PsGLr(e[n(1922)](e[n(451)](this.high,0),Hn),this.low>>>0):e[n(1795)](e[n(1335)](this.high,Hn),e[n(712)](this[n(1724)],0))}isZero(){let n=t;return this[n(780)]===0&&this[n(1724)]===0}[t(1016)](n){let i=t;oe.isLong(n)||(n=oe.fromNumber(n));let d=e[i(1854)](this.high,16),u=65535&this.high,p=e.BWTxC(this[i(1724)],16),S=e[i(721)](65535,this.low),b=n.high>>>16,g=e[i(997)](65535,n[i(780)]),T=e[i(1625)](n[i(1724)],16),P=65535&n[i(1724)],B=0,j=0,V=0,J=0;return J+=S+P,V+=J>>>16,J&=65535,V+=e[i(1598)](p,T),j+=e.OfFRt(V,16),V&=65535,j+=e.PFQKh(u,g),B+=e[i(1240)](j,16),j&=65535,B+=e[i(715)](d,b),B&=65535,oe.fromBits(e[i(1172)](e[i(686)](V,16),J),e[i(805)](e.wPdeI(B,16),j),this[i(1187)])}equals(n){let i=t;return oe[i(1274)](n)||(n=oe.fromNumber(n)),e[i(585)](this.unsigned,n[i(1187)])&&e[i(1391)](e[i(852)](this[i(780)],31),1)&&e[i(814)](e[i(1741)](n[i(780)],31),1)?!1:this.high===n.high&&this[i(1724)]===n.low}[t(1249)](){let n=t;return this[n(1724)]===-1&&e[n(1869)](-1,this[n(780)])?oe[n(656)](0,0,this.unsigned):e[n(838)](-1,this[n(1724)])?oe[n(656)](0,this[n(780)]+1,this.unsigned):oe.fromBits(e[n(1710)](this[n(1724)],1),this[n(780)],this[n(1187)])}[t(685)](n){let i=t;return n?this[i(1217)+"E"]():this[i(1417)+"E"]()}[t(1217)+"E"](){let n=t,i=this[n(780)],d=this[n(1724)];return[e.NUTXs(255,d),e[n(1322)](e[n(451)](d,8),255),e[n(977)](e.BtKRu(d,16),255),e[n(466)](d,24),e[n(926)](255,i),e[n(1240)](i,8)&255,e.Yoobm(i,16)&255,e[n(1625)](i,24)]}toBytesBE(){let n=t;if(e[n(1838)](e[n(1563)],e[n(816)]))this._listeners={};else{let i=this[n(780)],d=this.low;return[e[n(1920)](i,24),e.HMjPf(e[n(712)](i,16),255),e[n(1480)](i>>>8,255),e[n(947)](255,i),e[n(1625)](d,24),e[n(1266)](d,16)&255,e[n(470)](e[n(668)](d,8),255),e[n(1185)](255,d)]}}}let u0=new oe(0,0,!1),Yx=new oe(0,0,!0),Xx=oe[t(656)](-1,2147483647,!1),Qx=oe[t(656)](-1,-1,!0),eh=oe.fromBits(0,-2147483648,!1);var Wt=(function(o){let n=t;return o[o[e[n(461)]]=5001]=e[n(461)],o[o[e[n(914)]]=5002]=e[n(914)],o[o[e[n(1892)]]=5003]=e[n(1892)],o[o["MESSAGE_"+n(1359)]=5004]=e[n(1126)],o[o[e[n(652)]]=5005]="OPEN_ERROR",o})({});class jn{constructor(n){this.type=n,this.target=null}}class x0 extends jn{constructor(n,i){let d=t;super(n),this[d(1727)]=i&&i.message||null}}class h0 extends jn{constructor(n,i){let d=t,u=e.DbEVc[d(906)]("|"),p=0;for(;;){switch(u[p++]){case"0":super(n);continue;case"1":this[d(1486)]=i&&i[d(1486)]||0;continue;case"2":this[d(1514)]=i&&i[d(1514)]||null;continue;case"3":this[d(1682)]=i&&i.filename||"";continue;case"4":this[d(898)]=i&&i[d(898)]||5001;continue;case"5":this[d(935)]=i&&i[d(935)]||0;continue;case"6":this[d(1727)]=i&&i[d(1727)]||"";continue}break}}}class p0 extends jn{constructor(n,i){let d=t;super(n),this[d(898)]=i&&i[d(898)]||0,this[d(1087)]=i&&i[d(1087)]||"",this[d(556)]=i&&i[d(556)]||!1,this[d(1819)+d(1706)]=i&&i["willReco"+d(1706)]||!1}}class g0 extends jn{constructor(n,i){let d=t;super(n),this[d(1387)]=i&&i[d(1387)]||null}}class m0 extends g0{constructor(n,i){let d=t;super(n),this[d(1387)]=i&&i.data||null,this[d(1727)]=i&&i[d(1727)]||null}}class w0 extends jn{constructor(n,i){let d=t;super(n),this[d(1387)]=i&&i.data||null}}function et(o,{message:n,code:i,error:d}){return new h0(o,{message:n,code:i,error:d})}function at(o,{code:n,reason:i,wasClean:d,willReconnect:u}){return new p0(o,{code:n,reason:i,wasClean:d,willReconnect:u})}function _0(o,{data:n,message:i}){let d=t,u={vknLa:function(p,S){return e[K(1123)](p,S)},FgUuR:function(p,S){return e[K(958)](p,S)},nxVyA:function(p,S){return p+S},vGaTl:function(p,S){return p-S},qBVSp:function(p,S){return e[K(1331)](p,S)}};if(e[d(1901)]("NCWJn",d(1929)))return new m0(o,{data:n,message:i});{let p=_0x3717f3[d(965)+"At"](_0x43a373);p>=55296&&BTkDKA[d(1362)](p,56319)&&BTkDKA[d(1510)](BTkDKA[d(1513)](_0x4c31f,1),_0x564409)&&(p=BTkDKA[d(633)](BTkDKA[d(1513)](BTkDKA[d(817)](p,10),_0x68f0da[d(965)+"At"](++_0x4672d6)),56613888)),_0x4f1dac+=p<128?1:BTkDKA[d(1510)](p,2048)?2:p<65536?3:4}}function y0(o,{data:n}){return new w0(o,{data:n})}function Po(o,{message:n}){return new x0(o,{message:n})}class E0{constructor(n,i){let d=t;this[d(1737)+"s"]=n,this[d(1862)+"es"]=i,this[d(1713)+d(1280)]=0,this[d(1534)+"ndpointT"+d(450)+"t"]=0}[t(1216)+"pointConfig"](){let n=t;this[n(1713)+"ndex"]=0,this[n(1534)+n(804)+n(450)+"t"]=0}[t(1665)+"es"](){let n=t;if(e[n(1304)](e[n(1310)],e[n(853)])){if(this[n(1578)]["disableA"+n(1197)+n(776)]||this[n(1523)+n(756)])return;this[n(890)+n(741)]()}else this["currentE"+n(804)+n(450)+"t"]=0}["getCurre"+t(508)+"nt"](){let n=t,i={qRmEt:function(d,u){return e[K(1348)](d,u)},SgTsg:function(d,u){return e.Uiyjn(d,u)},AqARN:function(d,u,p){return e.VFitz(d,u,p)}};return e[n(604)](e.qfMmd,e[n(628)])?LoPBWP[n(599)](LoPBWP[n(543)](_0x63bb13,8).join("0"),LoPBWP.AqARN(_0x30c8c8,_0x3f3f59,10)[n(1861)](2))[n(956)](-8):this[n(1737)+"s"][this["currentI"+n(1280)]]}[t(596)+t(508)+t(553)+t(1567)](){let n=t,i={lACxz:n(1668)};if(e[n(571)]!==n(1225))return this[n(1534)+n(804)+"riesCount"];if(this[n(1750)+n(1357)]?.[n(1647)+n(1558)+"es"]()){let u=this["_endpoin"+n(1357)]?.["getCurre"+n(508)+"nt"]();this[n(1485)+"hCloseEv"+n(1464)](_0x41f3ab("close",{code:1006,reason:n(836)+u+(" timeout"+n(892)+n(1022)+n(653)),wasClean:!0}))}else{let u=this[n(1578)][n(939)+n(579)+n(710)](_0x20e5f7,_0x15ccb0);this[n(1485)+n(1031)+n(1464)](_0x7b04ef(i[n(1262)],{code:_0x48aeec,reason:_0x35a4e4,wasClean:!0,willReconnect:u})),u&&this[n(1627)]()}}[t(1647)+"chMaxTries"](){let n=t;return!!(this["currentI"+n(1280)]>=this[n(1737)+"s"][n(1541)]||e[n(739)](this["currentI"+n(1280)],e[n(1707)](this[n(1737)+"s"][n(1541)],1))&&e[n(1386)](this["currentE"+n(804)+n(450)+"t"],this[n(1862)+"es"]))}[t(537)+t(1293)+t(626)+t(704)+"tries"](){let n=t;return e.CfStu(this[n(1713)+n(1280)],this[n(1737)+"s"][n(1541)])?!0:e[n(1096)](this[n(1534)+n(804)+"riesCount"],this[n(1862)+"es"])}["replaceB"+t(1227)+"pointAnd"+t(516)+t(504)](){let n=t;return this[n(1534)+n(804)+n(450)+"t"]=1,this[n(1713)+n(1280)]++,this[n(1737)+"s"][this.currentIndex]}[t(596)+t(508)+t(1657)+t(1848)](){let n=t;if(e[n(1223)](e[n(992)],e[n(992)]))return this[n(1534)+n(804)+n(450)+"t"]++,this[n(596)+n(508)+"nt"]();this["_miniNav"+n(1456)+n(1761)]=_0x5f3413,_0x3eaa0b?this["_handleO"+n(1775)]():this[n(798)+n(730)]()}}let Gn=(e[t(1160)](e[t(782)],typeof globalThis)&&e[t(1125)](e.XJwSJ,globalThis[t(557)+t(1371)][t(1074)])||e[t(1004)](e[t(782)],typeof window)&&e[t(636)](t(946),window[t(557)+t(1371)][t(1074)]))&&e[t(1917)](e.CmPSs,typeof document),_n=e[t(1529)](e.CmPSs,typeof globalThis)&&(e[t(1577)]===globalThis[t(557)+t(1371)][t(1074)]||e[t(925)](e[t(1670)],globalThis[t(557)+t(1371)][t(1074)]))&&e[t(1576)](e[t(782)],typeof tt),kr=(t(1623)+"d"!=typeof globalThis&&e[t(1577)]===globalThis[t(557)+t(1371)][t(1074)]||e.ZUOmI(e[t(782)],typeof globalThis)||e.KIZMt(e[t(782)],typeof globalThis)&&!!globalThis["WeixinJS"+t(1692)])&&e[t(1004)](e[t(782)],typeof wx),Or=typeof globalThis<"u"&&(e.ImlZE===globalThis["construc"+t(1371)][t(1074)]||e[t(702)]===globalThis[t(557)+"tor"][t(1074)]||e[t(1671)](t(1482)+t(1841)+t(565),globalThis[t(557)+"tor"][t(1074)]))&&e[t(1931)](e[t(782)],typeof self),th=e[t(782)]!=typeof globalThis&&e[t(1386)](e[t(1577)],globalThis[t(557)+t(1371)][t(1074)])&&e[t(782)]!=typeof global&&e[t(764)](e[t(1577)],global[t(557)+"tor"].name)&&e.CmPSs!=typeof process&&!!process[t(564)];class Lo{constructor(){let n=t;if(e[n(872)]("tZBou",e[n(1472)])){e[n(490)](_0x1f02da,_0x113e99,42);let i=e[n(1171)](_0x54c081);_0x2b16e1(_0x506b0c,i),e[n(1652)](_0x1050dd,_0x4aad30,i.limit),e[n(1844)](_0x4e68e1,_0x543257,i),_0x1beae6(i)}else this[n(996)+"rs"]={}}[t(1473)](n,...i){let d=t,u=this[d(996)+"rs"][n];if(u)u[d(956)]()[d(1611)](p=>p.fn[d(590)](p[d(1457)],i));else if(e.aARwL(e[d(1059)],n)&&!this.onerror){let p=i[d(1541)]&&i[0];if(e[d(1561)](p,Error))throw p;let S=new Error(e.ZMwNk(e[d(1784)],p?e[d(1271)](" ("+p[d(1727)],")"):""));throw S.context=p,p}return this}off(n,i){let d=t;if(e.oWKrC(void 0,n))this._listeners={};else if(e[d(908)](void 0,i))this._listeners[n]=null;else{let u=this[d(996)+"rs"][n];if(u)for(let p=0;e.nCMxE(p,u[d(1541)]);)u[p].fn===i?u.splice(p,1):++p}return this}on(n,i,d){let u=t;return(this._listeners[n]||(this[u(996)+"rs"][n]=[]))[u(1416)]({fn:i,ctx:d||this}),this}}class nh extends Lo{["_formatErrorMess"+t(1053)](n){let i=t;if(e[i(1124)](e[i(1474)],"vrdEK"))return n[i(1823)]||n[i(1300)]?(i(824)+" "+(n.errMsg||"")+i(822)+(n[i(1300)]||""))[i(1877)]():JSON.stringify(n);if(_0x5d9bdd=_0x23d787[i(965)+"At"](_0x830aaf),e.cDAkc(_0x4df9e8,128))_0x4d4293[_0x98f504++]=_0x31d2d8;else if(e.cXqXv(_0x35e65b,2048))_0x465dac[_0x16b0fb++]=e[i(981)](e.TEjwH(_0x2e64a2,6),192),_0x312548[_0x5c907d++]=e[i(920)](63&_0x1624e3,128);else if(e[i(1869)](e.fOlhq(64512,_0x29cd15),55296)&&e[i(838)](e.OPYjt(64512,_0x550787=_0xc41d28.charCodeAt(e.VVRPD(_0x53adfc,1))),56320)){let d=e[i(1191)][i(906)]("|"),u=0;for(;;){switch(d[u++]){case"0":++_0x5915c6;continue;case"1":_0x566fe8[_0x23ca52++]=e[i(1172)](e[i(1458)](63,_0x1e6489),128);continue;case"2":_0x3dcb3d[_0x1005ca++]=e.HQPuq(e.MzRUL(_0x5358ca,18),240);continue;case"3":_0x789bf8[_0xa86d13++]=e[i(551)](e[i(606)](_0x3f4f5d>>12,63),128);continue;case"4":_0x4d1261=e[i(869)](e[i(1504)](65536,(1023&_0x3f23b1)<<10),e.vYyeo(1023,_0x22ffa6));continue;case"5":_0x2e81d0[_0xdb2f3c++]=e.IsRYQ(e[i(1467)](_0x55a12f,6),63)|128;continue}break}}else _0x2bb314[_0x1ee605++]=e[i(502)](_0x550865,12)|224,_0xb7d8e[_0x5caceb++]=e[i(766)](e[i(1849)](_0x39ef4a>>6,63),128),_0x14521b[_0x257449++]=e[i(1400)](63&_0x3d7c6b,128)}constructor(n,i,d){let u=t;super(),this[u(1114)]=null,kr&&wx[u(1115)+u(515)]&&(this[u(1114)]=wx.connectSocket({url:n,protocols:i,header:d,fail:this[u(650)+u(1592)+u(1870)][u(1277)](this),success:this[u(650)+u(1468)+u(1231)+u(917)][u(1277)](this)})),_n&&tt["connectS"+u(515)]&&(this[u(1114)]=tt[u(1115)+u(515)]({url:n,protocols:i,header:d,fail:this[u(650)+u(1592)+u(1870)][u(1277)](this),success:this[u(650)+u(1468)+u(1231)+u(917)][u(1277)](this)}))}[t(650)+t(1468)+t(1231)+t(917)](){let n=t;Promise[n(1302)]().then(()=>{this["_addWsLi"+n(1771)]()})}[t(650)+t(1592)+t(1870)](n){let i=t,d={MKtnl:function(u,p){return u<<p},SZsex:function(u,p){return u<p},txUHB:function(u,p){return e[K(1065)](u,p)}};Promise[i(1302)]().then(()=>{let u=i;if(e[u(764)](e.ZYSij,e[u(1551)]))_0x848f1d=EVMSOm[u(1286)](31&_0x3d0d21,6)|63&_0x560db1,EVMSOm.SZsex(_0x3ade50,128)?_0x5945b1+=_0x38b315:(_0x2eec67+=EVMSOm[u(980)](_0x1fffa6,_0x593334),_0x1a0225++);else{let p=e[u(1699)](et,e[u(1059)],{message:this[u(896)+u(1311)+u(1053)](n)});this[u(1473)]("error",p);let S=at(e[u(1664)],{reason:this[u(896)+u(1311)+"age"](n)});this[u(1473)](e.Gdlro,S)}})}[t(1196)+t(1771)](){let n=t,i={WQuLO:function(d,u,p){return d(u,p)}};this[n(1114)][n(1648)](d=>{let u=n;this.emit(e.VUQiO,e.OZkvX(y0,e.VUQiO,{...d,data:d[u(1823)]||""}))}),this._socket.onClose(d=>{let u=n;e[u(819)](e.LNkDB,e[u(1760)])?(this[u(1713)+u(1280)]=0,this[u(1534)+"ndpointT"+u(450)+"t"]=0):this[u(1473)](e[u(1664)],e[u(1652)](at,e.Gdlro,{...d}))}),this[n(1114)][n(487)+"e"](d=>{let u=n;this[u(1473)](u(1727),i[u(862)](_0,u(1727),{...d}))}),this[n(1114)][n(539)](d=>{let u=n;this[u(1473)](e[u(1059)],et(e[u(1059)],{...d,message:d[u(1823)]||""}))})}[t(754)](n){let i=t,d={aoYMn:e.tnJaV};if(e[i(1561)](n,Uint8Array)){let u=n[i(1339)][i(956)](n.byteOffset,e.fpoHN(n[i(1105)+"th"],n[i(1014)+"et"]));this[i(1114)]&&this[i(1114)][i(754)]({data:u,fail:p=>{let S=i;this[S(1473)](e[S(1059)],e.tHZnk(et,e[S(1059)],{message:this[S(896)+"rrorMess"+S(1053)](p)}))}})}else this[i(1114)]&&this[i(1114)][i(754)]({data:n,fail:u=>{let p=i;this[p(1473)](d[p(1690)],et(d[p(1690)],{message:this["_formatE"+p(1311)+p(1053)](u)}))}})}[t(1668)](n,i){this[t(1114)]&&this._socket.close({code:n,reason:i})}[t(1672)+t(948)](n,i){this.on(n,i)}[t(644)+t(1338)+t(474)](n,i){this[t(811)](n,i)}get[t(849)+"te"](){let n=t,i={bZhlg:e[n(1661)],aqcCV:e[n(1808)],TNGFP:function(d,u,p){return e[n(1418)](d,u,p)}};if(e[n(1223)](n(963),e[n(861)]))return this[n(1114)][n(849)+"te"];this[n(1831)+n(1394)](),this.emit(i[n(1915)],i[n(524)]),this[n(1597)+n(887)+"Id"]=i.TNGFP(_0x264fdc,this[n(669)][n(1277)](this),_0x11d47e)}get[t(1295)+"pe"](){let n=t;return e.GidnM!==n(1845)?{bytes:_0x21b85d,offset:0,limit:_0x3ab7e0[n(1541)]}:this[n(1114)][n(1295)+"pe"]}set[t(1295)+"pe"](n){}get[t(1188)](){let n=t;return this[n(1114)][n(1188)]}get[t(1687)](){return this[t(1114)].protocol}get extensions(){let n=t;return this[n(1114)][n(931)+"ns"]}get[t(1525)+t(1235)](){let n=t;return e[n(1186)](n(978),e[n(1072)])?this[n(1114)][n(931)+"ns"]:0}}function rh(o,n){let i=t;if(n)return new n(o.url,o[i(1687)]);if(kr||_n)return new nh(o[i(1188)],o[i(1687)],o.headers);if(e.RBwqi(Gn,Or)&&e.IKITE(e[i(782)],typeof WebSocket)&&WebSocket)return new WebSocket(o[i(1188)],o[i(1687)+"s"])}function ih(o){let n=t,i=(n(1496)+"0")[n(906)]("|"),d=0;for(;;){switch(i[d++]){case"0":return!1;case"1":if(kr&&wx["connectS"+n(515)])return!0;continue;case"2":if(_n&&tt[n(1115)+n(515)])return!0;continue;case"3":if(o)return!0;continue;case"4":if(e.RBwqi(Gn,Or)&&e[n(1160)](e[n(782)],typeof WebSocket)&&WebSocket)return!0;continue}break}}function b0(o,n,i){let d=t,u={zsYZq:function(b,g){return b<=g},dkIUa:e[d(646)],KNXjz:function(b,g){return e[d(1869)](b,g)}},p=-1;async function S(b){let g=d;return u[g(840)](b,p)?Promise[g(1095)](new Error(u[g(1263)])):(p=b,u[g(719)](b,i[g(1541)])?Promise[g(1302)]():i[b][g(1277)](o)(n,S.bind(null,b+1)))}e.oDYyR(S,0)}function S0(o){let n=t,i=0,d=0;for(let u=0;e[n(959)](u,o[n(1541)]);++u)d=o[n(965)+"At"](u),e[n(959)](d,128)?i+=1:e.BZeKj(d,2048)?i+=2:(64512&d)===55296&&e.wyAmG(64512,o[n(965)+"At"](e[n(671)](u,1)))===56320?(++u,i+=4):i+=3;return i}function v0(o,n,i){let d=t;if(e.YuoEP(e.KUASB,d(1298))){let u=e[d(1607)](_0x29d5d9,_0x2ca510,1);_0x162051[d(1017)][u]=_0x377a3c}else{if(e[d(1673)](e[d(1e3)](i,n),1))return"";let u="";for(let p=n;p<i;)if(e[d(601)]===e[d(501)])_0x4d8baf(_0x387456,82),_0x1e4535(_0x265fdb,_0x273578);else{let S=o[p++];if(S<=127)u+=String.fromCharCode(S);else if(e[d(1133)](S,192)&&e[d(1003)](S,224))u+=String[d(821)+d(737)](e.NcHyJ(e[d(1863)](e[d(1734)](31,S),6),e[d(674)](63,o[p++])));else if(e[d(1133)](S,224)&&e[d(1288)](S,240))u+=String[d(821)+d(737)](e[d(1162)](e[d(1540)](e.jaFhx(e[d(933)](15,S),12),e[d(1631)](63,o[p++])<<6),e[d(591)](63,o[p++])));else if(e.gbzHS(S,240)){let b=e[d(1893)](e[d(825)](e[d(1470)](e[d(1545)](e[d(1321)](7,S),18),e.gfLsu(e[d(1113)](63,o[p++]),12)),e.haImq(e[d(1907)](63,o[p++]),6))|e[d(1721)](63,o[p++]),65536);u+=String[d(821)+d(737)](e.ZYfhy(55296,e[d(1694)](b,10))),u+=String[d(821)+"Code"](e.QPjPV(56320,e[d(1786)](1023,b)))}}return u}}function No(o,n,i){let d=t,u=i,p,S;for(let b=0;e[d(958)](b,o[d(1541)]);++b)if(p=o[d(965)+"At"](b),e[d(959)](p,128))n[i++]=p;else if(e[d(584)](p,2048))n[i++]=e[d(1605)](e[d(1467)](p,6),192),n[i++]=e[d(1763)](e[d(1898)](63,p),128);else if((64512&p)===55296&&e.vEMSq(e.AoAJL(64512,S=o.charCodeAt(e.HJAFy(b,1))),56320)){let g=e[d(1462)][d(906)]("|"),T=0;for(;;){switch(g[T++]){case"0":n[i++]=e[d(1165)](e[d(520)](p>>12,63),128);continue;case"1":n[i++]=e[d(589)](63&p,128);continue;case"2":n[i++]=e[d(1726)](e[d(1928)](p,6),63)|128;continue;case"3":n[i++]=p>>18|240;continue;case"4":p=e[d(576)](e[d(1218)](65536,e.IgXFO(e.jOqeG(1023,p),10)),1023&S);continue;case"5":++b;continue}break}}else n[i++]=e[d(976)](e[d(1442)](p,12),224),n[i++]=e.NxHNu(e.AvEGb(p>>6,63),128),n[i++]=e[d(975)](e[d(1815)](63,p),128);return e[d(1707)](i,u)}async function I0(o){let n=t;if(e[n(1858)](e[n(1419)],typeof o)){let i=new Uint8Array(e.SLegw(S0,o));return e[n(1415)](No,o,i,0),i}return e.tqJCR(o,ArrayBuffer)?new Uint8Array(o):new Uint8Array(o[n(1339)],o[n(1014)+"et"],o.byteLength)}function sh(o){let n=t;try{return e[n(1419)]!=typeof o&&(e[n(1859)](o,ArrayBuffer)||o[n(1339)]&&e[n(1424)](o[n(1339)],ArrayBuffer))||n(1220)!=typeof o?"":(JSON.parse(o),e[n(1097)])}catch{return e.CfStu(e[n(1419)],typeof o)?e[n(1630)]:""}}let oh=(o,n)=>{let i=t;switch(o){case e[i(865)]:case i(1132):return{[i(1492)+o]:1,"x-tt-env":n};default:return{}}};class ah{constructor(n){let i=t;this["maxLossC"+i(1567)]=n,this.count=0}addCount(){let n=t;this[n(1150)]++}[t(1647)+t(736)+"nt"](){let n=t;return e[n(765)](this[n(1150)],this[n(936)+n(1567)])}[t(484)+t(1662)](n=0){let i=t;this[i(936)+"ount"]=n,this.count=0}}async function ch(o){let n=t,i={koudD:function(d,u){return e[K(651)](d,u)},bIyKP:n(645)+n(1087),XHeka:e[n(1257)],sJeSn:e.ljynI,RWMFQ:function(d,u){return e[n(1933)](d,u)},pzLzF:e[n(972)],FACFk:function(d,u){return e[n(945)](d,u)},BUzFV:e[n(735)],ADWmN:n(1803),zwiGM:function(d,u){return e[n(569)](d,u)}};return new Promise(d=>{let u=n;if(!Gn)return d(i[u(1584)]);try{let p=document[u(1733)+u(889)](i[u(1754)]);window[u(1930)+u(806)]=S=>{let b=u;document[b(587)][b(799)+b(1122)](p),window[b(1930)+"JSONP"]=void 0,i[b(1347)](d,S&&S[b(1475)]||i[b(1584)])},p[u(457)]=i[u(950)],p.src=i.RWMFQ(o.replace(/^ws/,"http"),i[u(1937)]);try{if(i.FACFk(i[u(1603)],i[u(1712)]))document[u(587)][u(1505)+u(1122)](p);else{let S=(u(773)+"0")[u(906)]("|"),b=0;for(;;){switch(S[b++]){case"0":this[u(1627)]();continue;case"1":this[u(1523)+"osed"]=!1;continue;case"2":this[u(1425)]=!0;continue;case"3":this[u(573)+u(598)]?.[u(484)+u(1662)]();continue;case"4":this[u(1750)+u(1357)]?.[u(1216)+u(1923)+u(1361)]();continue}break}}}catch{document[u(587)][u(799)+u(1122)](p)}}catch{window["frontier"+u(806)]=void 0,i[u(534)](d,i[u(1584)])}})}function $t(o,n,i){let d=t;return!!o?.[d(895)](u=>u.key===n&&u[d(1365)]===i)}function Kn(o,n){let i=t;if(e[i(1223)](e.XWKoY,e[i(567)])){let d=_0x1c3189[i(1500)+"g"](0,4-_0x1b67be[_0x36a995][i(1541)]),u=d[i(1835)](_0x4507ab[_0x24ae02]);_0x21fbcc[i(1416)](u)}else return o?.[i(895)](d=>d[i(1324)]===n)?.[i(1365)]}let Mo=null;async function dh(){let o=t;return Mo||(Mo=Promise[o(1302)]()[o(1711)](Tt[o(1277)](Tt,"idb"))),Mo}class fh extends Lo{constructor(n,i){let d=t;super(),this[d(1904)]=n,this[d(638)]=i,this[d(802)]=void 0,this._initPromise=null}async openDB(){await this[t(1532)]()}async[t(1532)](){let n=t,i={qRzXp:function(d){return e[K(1171)](d)},iGoWf:function(d,u,p,S){return e[K(847)](d,u,p,S)}};if(!this[n(802)]){if(this[n(1809)+n(1669)])return this[n(1809)+n(1669)];try{let d=this[n(1904)],u=this._keyPath;this[n(1809)+n(1669)]=(async()=>{let p=n,{openDB:S}=await i[p(1109)](dh);this._qosDB=await i[p(1397)](S,"frontier_"+d,1,{upgrade(b){let g=p;b[g(509)+g(519)+"e"](d,{keyPath:u})}})})(),await this[n(1809)+"mise"]}catch(d){console[n(1590)](d)}finally{this["_initPro"+n(1669)]=null}}}async[t(904)](n){let i=t,d={yqSVS:function(u,p){return e[K(1852)](u,p)},fqXJo:e[i(522)]};try{return await this[i(1532)](),this[i(802)]?.get(this[i(1904)],n)}catch(u){if(e.pPvRf(e[i(1355)],"EpVGV"))console[i(1590)](u);else{let p=_0x551eb0[i(1733)+i(889)](e[i(1257)]);_0x3c474c[i(1930)+i(806)]=S=>{let b=i;_0x22ab97[b(587)].removeChild(p),_0x13086e[b(1930)+b(806)]=void 0,ZrDjCn[b(828)](_0x757dd,S&&S.msg||ZrDjCn[b(609)])},p.type=e[i(1135)],p.src=e[i(1250)](_0x138152.replace(/^ws/,e[i(907)]),e[i(972)]);try{_0x37e0dd.body["appendCh"+i(1122)](p)}catch{_0x16152d.body[i(799)+"ild"](p)}}}}async[t(717)](n,i){return await this._init(),this._qosDB?.put(this._dbName,n)}async[t(818)](n){let i=t;try{return await this[i(1532)](),this[i(802)]?.[i(1547)](this._dbName,n)}catch(d){console[i(1590)](d)}}async[t(774)](){let n=t,i={LSVGm:e[n(658)],rXXKm:"x_fronti"+n(1067)+"ck",zfBeC:function(d,u,p,S){return e[n(1494)](d,u,p,S)},foPOA:e[n(1897)]};if(e[n(1192)](n(1826),e[n(1142)])){let d=!!this[n(1578)][n(1210)+"S"];if(!d)return{enabled:d,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let u=_0x5de3db(_0x44bf0f[n(1727)][n(966)],i[n(1820)],"2"),p=u&&_0x7b1b7(_0x1e27bf[n(1727)][n(966)],i[n(1447)],"1"),S=u&&i[n(1201)](_0x468f39,_0x309276[n(1727)][n(966)],n(1203)+n(903)+"k","1"),b=S?_0xe98eb4(_0x55e8be.message[n(966)],i[n(1570)])?.split(",").filter(_0x497ce1)||[]:[];return{enabled:d,isQoSMessage:u,isQoSAck:p,isAckCleanupMessage:S,ackMsgIds:b}}else try{return await this._init(),this._qosDB?.clear(this._dbName)}catch(d){console[n(1590)](d)}}async[t(829)](){let n=t;return await this[n(1532)](),this._qosDB?.getAllKeys(this[n(1904)])}async[t(969)](){let n=t;return await this[n(1532)](),this[n(802)]?.[n(969)](this[n(1904)])}async closeDB(){let n=t;try{if(n(1740)===e[n(1621)]){let i=this._qosDB[n(1463)](this[n(1787)]),d=_0x45b72a.parse(e[n(1518)](i,"{}"));return _0x14f109.values(d)}else this[n(802)]?.[n(1668)](),this[n(802)]=void 0}catch(i){console[n(1590)](i)}}get isReady(){try{return!!this._qosDB}catch(n){return console.log(n),!1}}}class lh{constructor(n,i){let d=t;this._DBName=n,this._pathKey=i,this[d(802)]=localStorage}async[t(826)](){}get[t(1787)](){return t(1930)+"_"+this._DBName}async[t(904)](n){let i=t,d=this[i(802)][i(1463)](this._prefix);return JSON[i(1313)](e[i(1292)](d,"{}"))[n]}async[t(717)](n,i){let d=t;if(d(835)===e[d(1239)]){let u=this._qosDB[d(1463)](this[d(1787)]),p=JSON[d(1313)](e.tSFPo(u,"{}"));return p[i||n[this._pathKey]]=n,this[d(802)][d(538)](this[d(1787)],JSON[d(1774)+"y"](p)),i||n[this[d(801)]]}else this[d(1473)](d(503),e[d(1847)](_0x5523be,d(503),{..._0x1b704d,data:_0x2cefd9[d(1823)]||""}))}async[t(818)](n){let i=t;if(e[i(697)](e[i(517)],e[i(517)])){let d=this[i(802)][i(1463)](this[i(1787)]),u=JSON[i(1313)](e[i(1905)](d,"{}"));return u[n]=void 0,this[i(802)][i(538)](this._prefix,JSON[i(1774)+"y"](u))}else e[i(1082)](_0x3392d4,this,_0x4c6a8c,[_0x2dd927,_0x126581,_0x114cf7])}async[t(774)](){return this[t(802)].clear()}async[t(829)](){let n=t,i=this._qosDB.getItem(this._prefix),d=JSON[n(1313)](i||"{}");return Object[n(829)](d)}async[t(969)](){let n=t,i=this[n(802)][n(1463)](this._prefix),d=JSON[n(1313)](e[n(1102)](i,"{}"));return Object[n(1195)](d)}[t(1282)](){return Promise[t(1302)]()}get isReady(){return!!this[t(802)]}}class uh{constructor(n,i){let d=t;e[d(1386)](e.pYFVt,"Sneug")?(this[d(552)]=n,this._pathKey=i,this._qosDB=_n?tt:kr?wx:null):(this[d(493)+"er"]&&_0x3108a6[d(644)+"entListe"+d(474)](e[d(1794)],this[d(800)+d(605)]),this[d(493)+"er"]&&_0x14a0ae[d(644)+d(1338)+d(474)](e[d(544)],this["_handleP"+d(1497)]),this[d(1668)]())}async[t(826)](){}get[t(1787)](){let n=t;return n(1930)+"_"+this[n(552)]}async[t(904)](n){let i=t;if(e[i(1078)]===e[i(1078)]){let d=this[i(802)].getStorageSync(this[i(1787)]);return JSON[i(1313)](d||"{}")[n]}else return _0x358ba5[i(1302)]()}async set(n,i){let d=t,u=this[d(802)][d(1033)+d(655)](this[d(1787)]),p=JSON[d(1313)](e.RBwqi(u,"{}"));return p[i||n[this[d(801)]]]=n,this._qosDB[d(842)+d(655)](this[d(1787)],JSON[d(1774)+"y"](p)),i||n[this[d(801)]]}async[t(818)](n){let i=t,d=this._qosDB[i(1033)+i(655)](this._prefix),u=JSON.parse(d||"{}");return u[n]=void 0,this[i(802)][i(842)+i(655)](this[i(1787)],JSON.stringify(u))}async[t(774)](){let n=t;return this._qosDB[n(854)+n(1850)]()}async keys(){let n=t,i=this[n(802)]["getStora"+n(706)+"nc"](this[n(1787)]),d=JSON[n(1313)](e.lkuKv(i,"{}"));return Object[n(829)](d)}async[t(969)](){let n=t;if(e[n(1213)]("auwgP",e[n(1743)]))this._qosDB?.[n(818)](_0x5bb160.message_id);else{let i=this[n(802)]["getStora"+n(706)+"nc"](this[n(1787)]),d=JSON.parse(i||"{}");return Object[n(1195)](d)}}closeDB(){return Promise[t(1302)]()}get[t(1099)](){return!!this[t(802)]}}function A0(o,n){let i=t;if(e[i(481)](_n,_n))return new uh(o,n);if(e[i(831)](Gn,Or)&&typeof indexedDB<"u")return new fh(o,n);if(e.CarfQ(Gn,Or)&&e[i(1576)]("undefined",typeof localStorage))return new lh(o,n);throw new Error(e[i(1806)])}class xh{constructor(){let n=t;if(n(1871)!==e[n(1602)])this[n(617)+n(1128)+"Id"]=null,this._interval=36e5,this[n(802)]=e[n(1373)](A0,e[n(974)],e[n(873)]);else return _0xa12055[n(1590)](e[n(1674)],_0x387b85,_0x20ed28,_0xabe5f7),this[n(802)][n(717)]({cursor_name:_0x1f3bc4,cursor:_0x304eb0,service:_0x597173})}async[t(617)+t(1032)](){let n=t;clearInterval(this[n(617)+n(1128)+"Id"]),this[n(617)+"lTimeoutId"]=e.YMiJT(setInterval,()=>{this["flushExp"+n(1383)]()},this._interval)}async[t(826)](){let n=t,i={fCZLA:n(530)};await this[n(802)][n(826)]()[n(1711)](()=>{let d=n;if(d(530)!==i.fCZLA){let{type:u}=_0x55c255;this[d(1473)](u,_0x4e8155)}else this[d(617)+d(1032)]()})}async[t(1145)+t(1383)](){let n=t;(await this._qosDB?.getAll()||[]).filter(({timestamp:u})=>u<Date[n(993)]()).forEach(u=>{let p=n,S={lyazv:function(b,g){return b||g}};if(e[p(1244)](e[p(1792)],"NuNDs")){let b=this[p(802)][p(1463)](this[p(1787)]),g=_0x5655e5[p(1313)](LmQzpm[p(1043)](b,"{}"));return g[_0x32b273||_0x4b15fc[this[p(801)]]]=_0x50665b,this[p(802)][p(538)](this._prefix,_0x365677[p(1774)+"y"](g)),_0x575158||_0x257883[this[p(801)]]}else this[p(802)]?.[p(818)](u[p(555)+"id"])})}async[t(818)](n){let i=t;return this[i(802)]?.[i(818)](n)}async[t(717)](n,i){let d=t;if(e.XjFYM!==e[d(1601)]){if(this[d(1831)+d(1394)](),this[d(1267)+"mer"](),this[d(620)+d(932)+"rs"](),this[d(1739)+"nceClose"](1e3,_0x2e11b7),this[d(1627)+d(1868)]=!1,_0x17018b&&this[d(479)+"orOnline"]()&&!this[d(1523)+d(756)]){if(this[d(1750)+d(1357)]?.[d(1647)+d(1558)+"es"]()){let p=this["_endpoin"+d(1357)]?.[d(596)+d(508)+"nt"]();this["_dispatc"+d(1031)+d(1464)](e[d(1769)](_0x1eacc5,e.Gdlro,{code:1006,reason:d(836)+p+(d(1084)+d(892)+d(1022)+d(653)),wasClean:!0}))}else{let p=this[d(1578)][d(939)+d(579)+d(710)](_0x11adc6,_0x8e3c75);this["_dispatc"+d(1031)+"ent"](e.YIoVz(_0x5b9113,e[d(1664)],{code:_0x5c2dc5,reason:_0xaa0dbf,wasClean:!0,willReconnect:p})),p&&this[d(1627)]()}return}this[d(479)+d(1816)]()||this[d(1523)+d(756)]?this[d(1485)+d(1031)+d(1464)](e[d(525)](_0x47f4a4,d(1668),{code:_0x221431,reason:"bye"})):this[d(1485)+"hCloseEv"+d(1464)](e.dYRDL(_0x95fd73,d(1668),{code:1006,reason:d(1508)+d(788)+d(753)+d(574)})),this._ws=null,this[d(1750)+d(1357)]?.[d(1216)+d(1923)+d(1361)](),this[d(573)+"sCounter"]?.[d(484)+d(1662)]()}else return this[d(802)]?.[d(717)]({message_id:n,timestamp:i})}async[t(904)](n){return this[t(802)]?.get(n)}async[t(1282)](){let n=t;e[n(1899)](clearInterval,this["_interva"+n(1128)+"Id"]),await this[n(802)]?.[n(1282)]()}get isReady(){let n=t;return this._qosDB?.[n(1099)]}}function Bo(o){let n=t,i=!!this[n(1578)][n(1210)+"S"];if(!i)return{enabled:i,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1082)]($t,o[n(1727)].headers,e[n(658)],"2"),u=d&&e[n(1528)]($t,o[n(1727)].headers,e[n(944)],"1"),p=d&&e[n(847)]($t,o.message[n(966)],e[n(1857)],"1"),S=p?e[n(943)](Kn,o[n(1727)][n(966)],e.uYSRU)?.[n(906)](",")[n(725)](Boolean)||[]:[];return{enabled:i,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:p,ackMsgIds:S}}async function C0(){let o=t;return this[o(1211)+o(1764)]||(this[o(1211)+o(1764)]=new xh),this[o(1211)+o(1764)].isReady||await this["_QoSMana"+o(1764)][o(826)](),this[o(1211)+"ger"]}async function hh(o,n){let i=t;if(e[i(1838)](i(918),e[i(486)])){let{enableAutoAck:d}=this._options,u=e[i(847)]($t,o[i(1727)].headers,e[i(1589)],"1"),p=e[i(1756)]($t,o[i(1727)][i(966)],e[i(1368)],"1"),S=Bo[i(783)](this,o);if(e[i(967)](d,u)){let{SeqID:b,LogID:g,service:T,LogIDNew:P,method:B}=o[i(1727)];this[i(494)]({SeqID:b,LogID:g,LogIDNew:P,service:T,method:B,headers:[{key:e[i(1368)],value:"1"},{key:i(927),value:P||""},{key:e.WYtxM,value:"0"}]})}p&&!S.isQoSAck&&this["_dispatc"+i(1042)+i(867)](o),e[i(1171)](n)}else return _0x42a20e?.find(d=>d[i(1324)]===_0x96d614)?.[i(1365)]}async function ph(o,n){let i=t;if(e[i(1770)](e.ULIcK,e.aSHcQ))this._debug(e.xhfwD,o.message),e[i(1171)](n);else{let d=0,u=0,p;do p=e.NzvWa(_0x451087,_0x31957b),e[i(1182)](d,32)&&(u|=(127&p)<<d),d+=7;while(128&p);return u}}async function gh(o,n){let i=t;if(e.ghrKJ(e[i(1349)],e[i(1349)])){let d=e[i(1222)](qn,await e[i(1649)](I0,o[i(1387)]));try{if(e.iRcVr(e.biwvC,e[i(1027)]))this[i(1378)+"ameSpace"]=_0x3a97e1,this[i(1636)+i(595)]=_0x1217b1,this[i(542)+i(630)]=_0x2af883,this._qosDB=e[i(1305)](_0x1fa512,this[i(1378)+i(1565)],e[i(1488)]);else if(e[i(500)](d[i(1539)],Uint8Array)){let u=this[i(1578)][i(1094)+i(483)]instanceof Object?{force:!!this._options[i(1094)+i(483)][i(1619)],encoding:this[i(1578)][i(1094)+i(483)][i(1455)]?this[i(1578)]["payloadE"+i(483)][i(1455)][i(1618)](/\s/g,"")[i(1498)+"ase"]():""}:{force:!1,encoding:this[i(1578)][i(1094)+"ncoding"]?this[i(1578)].payloadEncoding[i(1618)](/\s/g,"")["toLowerC"+i(858)]():""},p=d["payloadE"+i(483)]?d[i(1094)+i(483)][i(1618)](/\s/g,"")["toLowerC"+i(858)]():"",S=e[i(1561)](this[i(1578)]["payloadT"+i(1012)],Object)?{force:!!this[i(1578)]["payloadT"+i(1012)][i(1619)],type:this[i(1578)][i(679)+i(1012)][i(457)]?this._options[i(679)+i(1012)][i(457)][i(1618)](/\s/g,"")[i(1498)+i(858)]():""}:{force:!1,type:this[i(1578)]["payloadT"+i(1012)]?this[i(1578)][i(679)+i(1012)].replace(/\s/g,"")[i(1498)+i(858)]():""},b=d[i(679)+i(1012)]?d["payloadT"+i(1012)][i(1618)](/\s/g,"")["toLowerC"+i(858)]():"",g=S[i(1619)]?S[i(457)]:b||S[i(457)],T=u[i(1619)]?u[i(1455)]:p||u.encoding,P=[e.VyQQS,e.PLBqh,e[i(1356)],i(1220)],B=[e.Ahpnl,e[i(616)]];this[i(1578)][i(1810)+i(949)+i(716)+"ad"]&&P[i(640)](g)&&(!T||B[i(640)](T))?d[i(478)+i(1629)]=e.IbrAK(v0,d.payload,0,d[i(1539)].byteLength):d[i(478)+i(1629)]=""}else d[i(478)+i(1629)]=""}catch(u){d[i(478)+"oad"]="",console[i(1590)](u)}o[i(1727)]=d,n()}else _0x1743e=e[i(1788)](_0x5008a3,_0xc10e73),_0x54492f=0}function mh(o,n,i){let d=t,u={KOFEZ:function(T,P){return e[K(1888)](T,P)},JJygr:function(T,P){return e[K(1591)](T,P)},LiVAC:function(T,P){return e[K(526)](T,P)},vsLRn:function(T,P){return T(P)},cflJS:function(T,P){return T&P}},p=e.KWNDc(i,8192),S=e[d(1312)](p,1),b=null,g=p;return function(T){let P=d;if(u[P(1812)](T,1)||u.JJygr(T,S))return o(T);u.JJygr(u[P(468)](g,T),p)&&(b=u.vsLRn(o,p),g=0);let B=n.call(b,g,g+=T);return u[P(1908)](7,g)&&(g=(7|g)+1),B}}let wh=4294967295;function _h(o,n,i){let d=t,u={KuIkr:function(p,S){return e[K(492)](p,S)}};return e[d(1222)](RangeError,e[d(1348)](e[d(869)](e.KuOkR(e[d(1348)](e[d(789)](e[d(631)],o),e[d(1181)]),e.RBwqi(n,1)),d(1745)),i))}function yh(o,n,i){let d=t;if(e[d(1757)](i,wh))throw new Error(e.prMyg);let u=3;for(;e.nflcG(u,0);){let p=e.PcgCc(255,i);e[d(847)](Fo,p,o,e[d(560)](n,u)),i>>>=8,u--}return n+4}function Eh(o,n){let i=t,d={UzHdT:function(u,p,S){return u(p,S)}};if(e[i(612)](e[i(785)],e[i(495)])){let u=0,p=n,S=n+4;for(;e[i(602)](p,S);){let{value:b,offset:g}=e.WBMjK(zo,o,p);p=g,u=e[i(1398)](e[i(1549)](u,8),0),u+=b}return{value:u,offset:S}}else{let u=this[i(1750)+i(1357)]?.[i(596)+i(508)+"nt"]();this[i(1485)+i(1031)+i(1464)](d[i(1265)](_0x45a2f6,i(1668),{code:_0xa64268[i(898)],reason:i(1071)+i(759)+"d, unknown reason, hostn"+i(1650)+u})),this[i(1750)+i(1357)]?.["resetEnd"+i(1923)+i(1361)](),this[i(573)+i(598)]?.["resetCou"+i(1662)]();return}}function bh(o,n,i){let d=t,u=e[d(1155)][d(906)]("|"),p=0;for(;;){switch(u[p++]){case"0":if(n[d(1038)])return e[d(492)](n[d(1038)](o,i),i);continue;case"1":if(e[d(1319)](o[d(1541)],40))return e[d(877)](e[d(1776)](No,o,n,i),i);continue;case"2":if(n[d(1047)+"e"])return e.jmxrD(n[d(1047)+"e"](o,i),i);continue;case"3":if(!o)return i;continue;case"4":return e[d(942)](No,o,n,i)+i}break}}function Sh(o,n){let i=t,d=new oe(e.sALBB(e[i(1781)](e.gceZM(o[e[i(1499)](n,4)]<<24,e.kqtOa(o[n+5],16)),e[i(1345)](o[n+6],8)),o[e[i(1248)](n,7)]),e[i(953)](e[i(1021)](o[e[i(1925)](n,0)],24),o[n+1]<<16)|e[i(1851)](o[n+2],8)|o[e[i(1504)](n,3)],!0);return n+=8,{value:d,offset:n+8}}function vh(o,n,i){let d=t,u=o[d(1724)],p=o[d(780)];return n[i]=e.RdPyJ(p,24),n[e[d(526)](i,1)]=e[d(1346)](p>>>16,255),n[i+2]=e[d(916)](e[d(712)](p,8),255),n[i+3]=e[d(1113)](255,p),n[e.nngwV(i,4)]=e.vnEUJ(u,24),n[e[d(1209)](i,5)]=e[d(760)](e.BHJPW(u,16),255),n[i+6]=e[d(1765)](u,8)&255,n[i+7]=e[d(864)](255,u),i+=8,i}function zo(o,n){let i=t;return o[i(1104)+"8"]?{value:o[i(1104)+"8"](n),offset:e[i(1459)](n,1)}:{value:e[i(540)](255,o[n]),offset:e[i(1120)](n,1)}}function Fo(o,n,i){let d=t;return n.writeUint8?n[d(1506)+"t8"](o,i):n[i]=255&o,i+1}let Ih=function(o){let n=t;return e.fGJQM(e[n(1538)],"uYkZH")?new Uint8Array(o):new _0x3a5ad3(_0x502af1,_0x4ba9a5,_0x44249b)},Ah=e[t(1320)](e[t(782)],typeof Buffer)?Buffer[t(1832)+"afe"]:e.vwTeO(mh,Ih,Uint8Array[t(1258)+"e"][t(1900)]),Ch=16,Uo=32;function Th(o){let n=t,i=0,d={};for(let u=0;u<o[n(1541)];u++)d[o[u]["cursor_n"+n(777)]]=e[n(1070)](S0,o[u].cursor_name),i+=14+d[o[u]["cursor_n"+n(777)]];return[i,d]}function T0(o,n,i){let d=t,u={xeJOm:d(1037)+d(488)+"|5|2|6",Ysesq:e.CFYfm,kbwzG:function(T,P,B,j){return e.FQGMi(T,P,B,j)},lFsqc:d(1074),kckCu:e[d(1023)],gxCPH:function(T,P,B,j){return e.nnLtw(T,P,B,j)},dwFRQ:function(T,P,B,j){return T(P,B,j)},NUVgK:e[d(1194)],xeoTl:function(T,P,B,j){return e.FQGMi(T,P,B,j)}},[p,S]=Th(o),b=e[d(727)](Ah,p),g=0;return o[d(1611)](T=>{let P=d,B=u.xeJOm.split("|"),j=0;for(;;){switch(B[j++]){case"0":console[P(1590)](u.Ysesq,g);continue;case"1":console[P(1590)](P(1086)+P(1074),g);continue;case"2":g=u[P(1697)](vh,oe[P(1939)+"er"](T[P(1151)]||n),b,g);continue;case"3":g=u[P(1697)](Fo,0,b,g);continue;case"4":console[P(1590)](P(1318),g);continue;case"5":console[P(1590)](u[P(1822)],g);continue;case"6":console[P(1590)](u[P(1559)],g);continue;case"7":g=u[P(1802)](yh,b,g,T.service||0);continue;case"8":g=u[P(1238)](bh,T[P(758)+P(777)],b,g);continue;case"9":console.log(u[P(705)],T,T[P(1318)]);continue;case"10":g=u[P(928)](Fo,S[T[P(758)+P(777)]],b,g);continue}break}}),{frameType:Uo,headers:[{key:"cursor_f"+d(1864),value:i}],payload:b}}function Dh(o){let n=t,i=0,d=[];for(;i<o[n(1105)+"th"];){let{offset:u}=e.nZaMl(zo,o,i);i=u;let p={cursor_name:"",cursor:0,service:0},{value:S,offset:b}=e.MMaKE(Eh,o,i);p.service=S,i=b;let{value:g,offset:T}=e.MMaKE(zo,o,i);i=T,p[n(758)+n(777)]=e[n(1173)](v0,o,i,e[n(1254)](i,g)),i+=g;let{value:P,offset:B}=e[n(893)](Sh,o,i);p.cursor=P.toNumber(),i=B,d[n(1416)](p)}return d}function Rh(){let o=t;return{frameType:Uo,headers:[{key:e[o(859)],value:e[o(1564)]}],payload:void 0}}class kh{constructor(n,i,d){let u=t,p={RFAgB:e[u(1807)]};e[u(1112)]!==e.hCFmb?(this[u(1473)](p[u(549)],_0x31bcfc),this[u(1728)+"eAck"]&&this[u(1728)+u(1703)](_0x5832f1)):(this[u(1378)+u(1565)]=n,this[u(1636)+u(595)]=i,this[u(542)+u(630)]=d,this[u(802)]=e[u(1679)](A0,this[u(1378)+u(1565)],"cursor_name"))}async[t(826)](){let n=t;if(e.MXFxP(e.OWNTD,e[n(1860)]))return this[n(1114)][n(1188)];await this[n(802)][n(826)]()}async getCursors(){let n=t;if(e.zrrjJ("hQdfq",e.rmAZk))this[n(552)]=_0x3c8600,this._pathKey=_0x5ae70e,this[n(802)]=_0x364f70;else{if(!this[n(802)].isReady)return;let i=this["_message"+n(630)],d=await this._qosDB[n(969)]();switch(console[n(1590)](e[n(1329)],d),i){case e[n(1723)]:return d&&d.length?e[n(1494)](T0,d,0,this[n(1636)+n(595)]):void 0;case"INSTANT":return;case e[n(1092)]:return d&&d[n(1541)]?e[n(734)](T0,d,0,this[n(1636)+n(595)]):e[n(1171)](Rh)}}}async[t(717)](n,i,d){let u=t;return console[u(1590)](e[u(1674)],n,i,d),this[u(802)][u(717)]({cursor_name:n,cursor:i,service:d})}async[t(1224)+"rs"](n){let i=t,d=Dh(n);for(let u of d)console[i(1590)](i(1934)+"r",d),await this[i(802)].set(u)}async get(n){let i=t;return(await this[i(802)][i(904)](n))?.[i(1151)]}async[t(1282)](){let n=t;await this[n(802)][n(1282)]()}updateCursorFileName(n){let i=t;this[i(1636)+"ileName"]=n}get[t(1099)](){let n=t;return this[n(802)][n(1099)]}}let Oh="__x_msg_"+t(769);async function D0(o){let n=t,i={BGjMW:function(b,g,T){return e[K(1882)](b,g,T)},VdiSn:function(b,g){return e.BcXRc(b,g)},diXNq:function(b,g){return b+g}};if(!this[n(1578)][n(1210)+"S"])return null;let{aID:d,fpID:u,messageStrategy:p}=this._options,S=e.BBSXh(o,Oh);try{if(e[n(532)](e[n(1824)],e[n(1824)])){let b=gWQzow[n(1804)](_0x406ecc,_0xf5f422,_0x547717.limit),g=_0x4d07b6[n(1017)],T=_0x535c65[n(1017)];for(let P=0,B=_0x221881[n(880)];gWQzow[n(1797)](P,B);P++)g[gWQzow.diXNq(P,b)]=T[P]}else return this["_cursorM"+n(1200)]?o&&this[n(622)+n(1200)][n(1019)+"rsorFile"+n(1253)](o):this[n(622)+n(1200)]=new kh(u+"_"+d+"_"+S,S,p),this[n(622)+n(1200)][n(1099)]||await this[n(622)+n(1200)][n(826)](),this[n(622)+"anager"]}catch{return null}}async function Ph(o,n){let i=t,d=e[i(847)]($t,o[i(1727)].headers,i(898),"-1"),u=e[i(795)]($t,o[i(1727)][i(966)],e[i(1368)],"1"),p=e.YkycV(Kn,o[i(1727)][i(966)],e.iqWeF),S=e.slAdh(Number,e[i(793)](Kn,o[i(1727)][i(966)],e[i(709)]))||0,b=Bo[i(783)](this,o),g=$t(o[i(1727)][i(966)],e[i(1507)],"2"),T=Kn(o[i(1727)][i(966)],e[i(1586)]),P=e[i(1465)](Number,Kn(o[i(1727)][i(966)],e[i(911)]));if(b.isQoSAck)return e[i(1171)](n);let B=b.isQoSMessage?await C0[i(783)](this):null;if(e[i(1325)](o[i(1727)][i(1318)],0)&&u&&!d||e[i(1390)](o[i(1727)].service,0)){if(p&&b["isQoSMes"+i(1830)]&&B)if(e[i(738)]===e[i(659)]){let j=_0x217be2(e[i(1610)],{message:e[i(1793)]});this[i(1212)+"econnect"]&&this[i(1212)+i(741)](j)}else return!!!await B[i(904)](p)&&(this["_dispatc"+i(955)+"Event"](o),await B[i(717)](p,Date[i(993)]()+S)),e.SqOZY(n);if(g){let j=await D0[i(783)](this);if(!j)return e[i(570)]!==e[i(570)]?!!_0x53b0e4?.[i(895)](J=>J[i(1324)]===_0x38dff2&&J[i(1365)]===_0x3679e4):(this[i(1485)+"hMessage"+i(856)](o),e[i(1640)](n));let V=await j[i(904)](T)??-1;if(e[i(1678)](V,P))this[i(1485)+"hMessage"+i(856)](o),j[i(717)](T,P,o[i(1727)][i(1318)]);else throw new Error("recevied"+i(1420)+" cursor "+P+(" larger "+i(923)+i(1049)+"r ")+V);return e[i(1073)](n)}return this[i(1485)+i(955)+i(856)](o),e[i(1546)](n)}}async function Lh(o,n){let i=t,d=Bo[i(783)](this,o);if(!d[i(1242)+"sage"])return e[i(1296)](n);let u=await C0[i(783)](this);if(d[i(1555)+i(962)+"age"]&&d[i(1587)+"s"][i(1541)])for(let p of d.ackMsgIds)await u[i(818)](p);e.yVBYt(n)}async function Nh(o,n){let i=t,d=o[i(1727)][i(1773)+"e"]===Ch,u=e.zrrjJ(o[i(1727)][i(1773)+"e"],Uo);if(e.UTpCh(!d,!u))return e[i(667)](n);let p=e[i(929)](Kn,o[i(1727)][i(966)],e.vYfHF);if(!p)return e.Arrti(n);let S=await D0[i(783)](this,p);if(!S)return n();if(d){let b=await S[i(1615)+"rs"](),g={frameType:b?.["frameType"],SeqID:oe[i(1939)+"er"](this[i(545)]++),LogID:oe[i(1939)+"er"](this[i(1578)][i(1628)+i(930)]()),service:9e3,method:5,headers:b?.headers,payload:b?.[i(1539)]},T=e[i(1395)](C,g);this[i(1342)]&&this[i(1342)][i(849)+"te"]&&this._ws[i(754)](T)}if(u){let b=o[i(1727)][i(1539)];b&&S[i(1224)+"rs"](b)}}let Mh=async function(o,n){let i=t;this[i(1425)]=!1,e[i(1111)](clearTimeout,this["_connect"+i(711)+i(1170)]),e[i(1106)](n)},Bh=async function(o,n){let i=t;if(!this[i(1342)]||this[i(1342)][i(849)+"te"]!==this[i(874)])return e[i(768)](n);let{pingInterval:d}=this[i(1578)];this[i(1750)+i(1357)]?.[i(1216)+"pointCon"+i(1361)]();for(let p=0;e.aUMVE(p,this[i(542)+i(472)][i(1541)]);p++){if(e[i(1777)]===e[i(1704)])return this[i(802)]?.[i(818)](_0x5f47ca);{let S=this["_message"+i(472)][p];if(e.tgEvw(this._ws.readyState,this[i(874)])&&e[i(784)](null,S))if(e[i(639)](e[i(566)],e.kDzjB))this[i(1342)]&&this[i(1342)][i(754)](S),this[i(542)+i(472)][p]=null;else{if(e.iGKFv(_0x336678,_0x146a1e))return _0x7ed275?_0x5267dc:_0x10c16b;if(_0x4ed83c){if(e[i(1307)](_0x3f7901,_0x374ae0))return _0x3e3bfb}else{if(e[i(1123)](_0x3c92ff,-_0x29cba3))return _0xf8f0a4;if(e.PTOzA(_0x93cb0d+1,_0x44bc62))return _0x1bb7b7}return _0x5e8ffd[i(656)](e[i(675)](e[i(1409)](_0x52e66a,_0x1503ca),0),e[i(976)](e[i(902)](_0x39b79c,_0x435712),0),_0x403291)}else break}}this[i(542)+i(472)]=this[i(542)+i(472)][i(725)](p=>!!p),this[i(1597)+i(887)+"Id"]=setTimeout(()=>this[i(669)](),d),this[i(1485)+i(1136)+"nt"](o),this[i(493)+"er"]&&this[i(1342)]&&(this._ws[i(1295)+"pe"]=this["_binaryT"+i(1012)]);let u=this["_endpoin"+i(1357)]?.[i(596)+"ntEndpoint"]();this[i(662)](i(1752)+u+i(1306)),e[i(667)](n)},zh=async function(o,n){let i=t,d=this["_endpoin"+i(1357)]?.[i(596)+"ntEndpoint"]();this[i(662)](i(1752)+d),e[i(1902)](n)};class Fh extends Lo{constructor(n){let i=t,d={pmnVD:function(u,p,S,b){return e[K(1401)](u,p,S,b)},fApyN:function(u,p,S){return e[K(514)](u,p,S)},roSTr:e[i(1059)],vIMct:e[i(1664)],YKTlc:"versionc"+i(1161),xLJTG:function(u,p){return e[i(922)](u,p)},ekOQJ:e.RWgAa,CZXUn:i(512),zkqHn:function(u,p,S){return u(p,S)},xiqBV:function(u,p,S,b){return e[i(1385)](u,p,S,b)}};if(e[i(809)]("qzeAu",i(1367)))return _0x561524||(_0x1fa538=[_0x247215,_0x46c648,_0x4b7c10,_0x3838d9,_0x51c2c0]);{super(),this[i(1519)+i(1456)+i(1761)]=!0,this[i(493)+"er"]=Gn,this[i(1579)]=th,this[i(1083)+"T"]=_n,this[i(663)+"X"]=kr,this[i(586)+"r"]=Or,this[i(542)+i(472)]=[],this[i(1750)+"tManager"]=null,this["_readyCl"+i(756)]=!1,this["_binaryT"+i(1012)]=e[i(563)],this[i(1627)+"Lock"]=!1,this._connectionTimeoutId=null,this["_reconne"+i(1693)+i(507)]=null,this["_pingPon"+i(887)+"Id"]=null,this[i(545)]=0,this[i(1425)]=!1,this[i(1759)]="",this[i(1211)+"ger"]=null,this[i(622)+i(1200)]=null,this[i(573)+i(598)]=null,this[i(1744)+"ls"]="pbbp2",this[i(527)]=3,this[i(941)+"NG"]=0,this[i(874)]=1,this[i(666)]=2,this[i(1493)]=b=>{let g=i;try{d.pmnVD(b0,this,b,[Mh,Bh,zh])}catch(T){let P=d[g(1287)](et,d[g(952)],{message:T[g(1727)],code:Wt[g(1521)+"OR"],error:T});this["_dispatc"+g(1062)+"ent"](P)}},this[i(661)+"ge"]=async b=>{let g=i,T={ldSNv:d.vIMct,pbMwC:d.YKTlc},{pingInterval:P,pingFrequency:B}=this[g(1578)];if((b[g(1387)]==="hi"&&d.xLJTG(d.ekOQJ,B)||d[g(1526)](d.CZXUn,B))&&(this[g(1831)+"ngTimer"](),this[g(1473)](g(744)+"e_success",g(1389)),this[g(1597)+g(887)+"Id"]=d.zkqHn(setTimeout,this[g(669)][g(1277)](this),P)),b[g(1387)]!=="hi")try{d.xLJTG("tRxir",g(1705))?(_0x261624&&_0x4315a0[g(1672)+"Listener"](mGEkEo[g(1921)],()=>_0x214512()),_0x319f6b&&_0x13b53e[g(1672)+g(948)](mGEkEo[g(750)],()=>_0xa43e7f())):d[g(1876)](b0,this,b,[gh,hh,Lh,Nh,Ph,ph])}catch(j){let V=d[g(863)](et,d[g(952)],{message:j[g(1727)],code:Wt[g(1449)+g(1359)],error:j});this[g(1485)+g(1062)+g(1464)](V)}},this[i(506)]=b=>{let g=i,T=this[g(1750)+g(1357)]?.["checkRea"+g(1558)+"es"](),P=this[g(1750)+g(1357)]?.[g(596)+"ntEndpoint"]();if(T&&!b[g(1727)])if(e[g(1749)](e.pTaYu,e[g(1291)]))_0x58f32e[g(1302)]()[g(1711)](()=>{this._addWsListeners()});else{let B=g(836)+P+(g(649)+g(1767)+g(699)+"ed");this[g(1485)+g(1062)+g(1464)](e[g(1370)](et,e[g(1059)],{message:B,code:Wt[g(713)+g(770)+"R"],error:b}));return}this._ws&&this[g(1342)][g(849)+"te"]===this.OPEN&&this["_disconn"+g(1536)](),this[g(1485)+g(1062)+g(1464)](et(e[g(1059)],{message:b[g(1727)],code:Wt[g(1377)+g(796)],error:b}))},this[i(469)]=async b=>{let g=i;this[g(1267)+g(1666)](),this[g(1831)+g(1394)](),this["_removeW"+g(932)+"rs"](),this[g(1342)]=null,this[g(1627)+g(1868)]=!1;let T=this["_endpoin"+g(1357)]?.[g(1647)+g(1558)+"es"]();if(!T&&this[g(479)+"orOnline"]()&&!this[g(1523)+g(756)]){let P=this["_endpoin"+g(1357)]?.[g(596)+g(508)+"nt"](),B=this[g(1578)][g(939)+g(579)+"ptor"](b[g(898)],b.reason);this._dispatchCloseEvent(e[g(1652)](at,"close",{code:1006,reason:b[g(1087)]||g(1071)+g(759)+g(1297)+g(772)+g(691)+"ame: "+P,willReconnect:B})),B&&this[g(1627)]();return}if(b.code!==1e3&&this[g(1523)+g(756)]){this[g(1485)+g(1031)+g(1464)](e[g(1646)](at,e[g(1664)],{code:1e3,reason:e[g(1407)]})),this["_endpoin"+g(1357)]?.[g(1216)+g(1923)+g(1361)](),this["_pingLos"+g(598)]?.[g(484)+"nter"]();return}if(b[g(898)]!==1e3&&T){let P=this[g(1750)+g(1357)]?.[g(596)+g(508)+"nt"](),B=b.reason;B||(B=await e[g(1638)](ch,this[g(1759)])),B=g(1071)+g(759)+g(1659)+B+(g(654)+g(757))+P+(", max re"+g(1022)+g(653)),this[g(1485)+g(1031)+g(1464)](e.tUvVj(at,e[g(1664)],{code:b[g(898)],reason:B}));let j=g(836)+P+(g(649)+"ax retries reached");this[g(1485)+"hErrorEv"+g(1464)](et(e[g(1059)],{message:j,code:Wt[g(713)+g(770)+"R"]})),this[g(1750)+g(1357)]?.[g(1216)+g(1923)+g(1361)](),this[g(573)+"sCounter"]?.[g(484)+g(1662)]();return}if(e.uQpim(1e3,b.code)&&!b.reason)if(e.fDcAx(g(1134),e.GwIXF))this._initPromise=null;else{let P=this[g(1750)+"tManager"]?.[g(596)+"ntEndpoint"]();this[g(1485)+g(1031)+g(1464)](at(g(1668),{code:b[g(898)],reason:g(1071)+g(759)+"d, unkno"+g(772)+"n, hostn"+g(1650)+P})),this[g(1750)+g(1357)]?.[g(1216)+g(1923)+"fig"](),this[g(573)+g(598)]?.[g(484)+g(1662)]();return}this[g(1485)+g(1031)+g(1464)](b),this["_endpoin"+g(1357)]?.[g(1216)+"pointConfig"](),this[g(573)+g(598)]?.resetCounter()},this[i(888)]=null,this[i(905)]=null,this[i(1388)+"e"]=null,this[i(1643)]=null,this[i(1212)+i(741)]=null,this[i(1728)+i(1703)]=null,this[i(1716)+"mediatel"+i(1243)+"ct"]=null,this[i(798)+i(1775)]=this[i(798)+i(1775)].bind(this),this[i(798)+"ffLine"]=this[i(798)+i(730)][i(1277)](this),this[i(800)+i(605)]=this[i(800)+i(605)][i(1277)](this),this[i(800)+"ageShow"]=this[i(800)+i(1497)][i(1277)](this),this[i(1578)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[i(452)](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(1399)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[i(1092)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:p}=n,S=Array[i(1412)](u)?u:e[i(529)](e.tnmdO,typeof u)?[u]:[];if(!S||S[i(1541)]===0)throw new Error(e[i(1140)]);if(!e[i(1599)](ih,p))throw new Error(i(1732)+i(722)+i(1596)+", WebSoc"+i(999)+i(597)+"is undef"+i(695));Object[i(1332)](this[i(1578)],n),this[i(1750)+"tManager"]=new E0(S,this[i(1578)][i(1862)+"es"]),this[i(573)+i(598)]=new ah(this[i(1578)][i(1241)+i(968)]),this[i(1578)][i(1247)+"cOpen"]&&(this[i(1425)]=!0,this[i(1627)]()),this[i(1578)][i(1580)+i(1375)+"nged"]&&(this[i(1083)+"T"]||this[i(663)+"X"]?this["_onPageN"+i(994)+i(1268)]():this[i(493)+"er"]&&this["_initGlo"+i(1600)+i(948)]())}}["_handleO"+t(1775)](){let n=t;this[n(1578)][n(775)+n(1197)+n(776)]||this[n(1523)+"osed"]||this[n(890)+n(741)]()}[t(798)+t(730)](){let n=t;if(e.LrKoz(e.WAYrz,e[n(1063)])){this[n(1675)+"WebSocket"]();let i=Po(e[n(1610)],{message:e.khEeF});this[n(1716)+n(937)+n(1243)+"ct"]&&this[n(1716)+"mediatel"+n(1243)+"ct"](i)}else return this[n(1342)]?this[n(1342)].binaryType:this[n(1411)+n(1012)]}[t(1626)+t(1600)+t(948)](){let n=t,i={bGbry:function(d,u){return e[K(1729)](d,u)},gyoLc:function(d,u){return e[K(876)](d,u)},XnNDG:"always",TLCfM:function(d,u){return e[K(1428)](d,u)},PsNnI:e[n(1661)],TNQZw:e[n(1808)],ikNZY:function(d,u,p){return e[n(588)](d,u,p)},QKPzS:function(d,u){return d===u},WnOEk:function(d,u,p,S){return e[n(847)](d,u,p,S)},IOaCg:e[n(1059)]};if(e.KjLhn(e[n(901)],e[n(1575)]))this._isBrowser&&window[n(1672)+n(948)](e[n(1205)],this[n(798)+n(1775)]),this[n(493)+"er"]&&window[n(1672)+n(948)](e[n(465)],this[n(798)+n(730)]),this[n(493)+"er"]&&window[n(1672)+n(948)](n(1927),this["_handleP"+n(605)]),this[n(493)+"er"]&&window[n(1672)+n(948)](n(449),this[n(800)+n(1497)]);else{let{pingInterval:d,pingFrequency:u}=this._options;if((JQBzcA[n(879)]("hi",_0x4a156[n(1387)])&&JQBzcA.gyoLc(JQBzcA[n(615)],u)||JQBzcA[n(1406)](n(512),u))&&(this[n(1831)+"ngTimer"](),this[n(1473)](JQBzcA[n(1768)],JQBzcA[n(676)]),this[n(1597)+n(887)+"Id"]=JQBzcA[n(448)](_0x2a1f61,this[n(669)][n(1277)](this),d)),JQBzcA[n(1176)]("hi",_0x426663[n(1387)]))return;try{JQBzcA.WnOEk(_0x5c5016,this,_0x2dc108,[_0x5c9e72,_0x3994f9,_0x1c3ffc,_0x2e935e,_0x461b8e,_0xf077b4])}catch(p){let S=_0x126a21(JQBzcA.IOaCg,{message:p[n(1727)],code:_0x11d1a6["MESSAGE_"+n(1359)],error:p});this[n(1485)+n(1062)+"ent"](S)}}}[t(1511)+t(1600)+t(948)](){let n=t;this._isBrowser&&window[n(644)+n(1338)+n(474)](e[n(1205)],this[n(798)+n(1775)]),this._isBrowser&&window[n(644)+n(1338)+"ner"](n(624),this[n(798)+n(730)]),this[n(493)+"er"]&&window["removeEv"+n(1338)+"ner"](e[n(1794)],this["_handleP"+n(605)]),this[n(493)+"er"]&&window["removeEv"+n(1338)+n(474)](e[n(544)],this[n(800)+n(1497)])}[t(800)+t(605)](n){let i=t;if(!n[i(673)+"d"]){if(e[i(1479)](e.BmKyD,e[i(1445)]))return;this[i(493)+"er"]&&window[i(644)+i(1338)+"ner"](e[i(1794)],this[i(800)+"ageHide"]),this[i(493)+"er"]&&window[i(644)+i(1338)+i(474)](e.ddGcB,this[i(800)+i(1497)]),this[i(1668)]()}this._isBrowser&&window[i(644)+"entListener"](e[i(1205)],this[i(798)+i(1775)]),this[i(493)+"er"]&&window["removeEv"+i(1338)+"ner"](i(624),this[i(798)+"ffLine"])}[t(800)+t(1497)](n){let i=t;n[i(673)+"d"]&&(this[i(479)+i(1816)]()&&(!this[i(1342)]||this[i(1342)][i(849)+"te"]!==this.OPEN||e.kHkxK(this[i(1342)][i(849)+"te"],this[i(941)+"NG"]))&&this[i(798)+i(1775)](),this[i(493)+"er"]&&window[i(1672)+i(948)](e.rvAcE,this[i(798)+i(1775)]),this[i(493)+"er"]&&window[i(1672)+i(948)](e[i(465)],this[i(798)+i(730)]))}async["_generat"+t(1354)](n){let i=t,{fpID:d,deviceID:u,bddID:p,ttwID:S,accessKey:b,aID:g,customParams:T={},enableAutoAck:P,enableQoS:B,QoSLevel:j,env:V}=this[i(1578)],J,He,$e;this[i(493)+"er"]||this[i(663)+"X"]||this[i(1083)+"T"]?(J=location&&e.WEmha(e[i(1738)],location.protocol)?i(1912):i(1374),He=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),$e=/^wss(.*:\/\/)/[i(471)](n)?n:""+J+He):(J=e[i(1421)],He=n.replace(/(^http)((?:[s]*:\/\/))/,""),$e=/(^ws)((?:[s]*:\/\/))/[i(471)](He)?He:""+J+He);let je=p?e[i(1702)]:S?e[i(1554)]:"device_id",ct=p||S||u;if(e[i(831)](!ct,!je))throw new Error(e[i(1938)]);let R0=e.kultL(i(1333),typeof T)?await T():T,Uh=V?e[i(881)](oh,V[i(938)],V[i(1431)]):{},qo=Object.assign({device_platform:e.YxtWf,version_code:e[i(1689)],access_key:b,fpid:d,aid:g,[je]:ct,xsack:P?1:0,xaack:P?1:0,xsqos:B?1:0,qos_level:B?j:void 0,qos_sdk_version:2,...Uh},R0),qh=Object[i(829)](qo).reduce((Ho,jo)=>qo[jo]!==void 0?""+Ho+(Ho?"&":"?")+jo+"="+qo[jo]:Ho,"");return $e+i(531)+qh}async[t(1627)](){let n=t;if(!(this[n(1627)+n(1868)]||this[n(1523)+n(756)])){this["_connect"+n(1868)]=!0;try{let i=this[n(1750)+n(1357)]?.["checkCur"+n(1293)+n(626)+n(704)+n(1055)](),{timeoutInterval:d}=this._options;if(i){let p=this[n(1750)+n(1357)]?.[n(596)+n(508)+"nt"](),S=this[n(1750)+n(1357)]?.[n(1867)+n(1227)+n(1932)+"UpdateCo"+n(504)](),b=this[n(1750)+"tManager"]?.["getCurre"+n(508)+n(553)+"ount"]();if(S)if(e[n(1634)](n(1730),e[n(1562)])){let g=this[n(802)][n(1463)](this[n(1787)]),T=_0x39fe4a[n(1313)](e[n(1905)](g,"{}"));return _0x175be5[n(829)](T)}else{let g="connect "+p+(n(1084)+n(892)+n(1022)+"ached, w"+n(1853)+"backup e"+n(830))+S+(n(833)+"y"),T=e[n(608)](et,"error",{message:g,code:Wt[n(713)+n(770)+"R"]});this[n(662)](g),this[n(1485)+n(1062)+"ent"](T),this[n(1759)]=await this[n(1451)+n(1354)](S),this[n(662)]("connect "+S+" "+b+n(1336)),this[n(620)+"sListeners"]()}else if(e[n(1801)](n(1259),"ryylY")){let g=n(836)+p+(n(1084)+n(892)+n(1022)+"ached");this[n(662)](g),this[n(1485)+n(1062)+n(1464)](et(e[n(1059)],{message:g,code:Wt[n(713)+n(770)+"R"]}));return}else return this[n(1114)][n(1295)+"pe"]}else{let p=this["_endpoin"+n(1357)]?.[n(596)+n(508)+"ntAndUpdateCount"](),S=this[n(1750)+n(1357)]?.["getCurrentEndpoi"+n(553)+n(1567)]();this[n(1759)]=await this[n(1451)+n(1354)](e[n(1273)](p,"")),this[n(662)](n(836)+p+" "+S+n(1336)),this[n(620)+n(932)+"rs"]()}if(this._isInit)this[n(1425)]=!1;else{let p=e[n(1524)](Po,e[n(1610)],{message:e.WuAVL});this["onStartR"+n(741)]&&this.onStartReconnect(p)}let u=this["_endpoin"+n(1357)]?.[n(596)+n(508)+n(553)+n(1567)]()||0;u>1&&await this[n(1364)](e[n(1707)](u,1)),this[n(662)](n(1071)+n(1527)+this[n(1759)]+(" protoco"+n(855))+this._protocols),this._ws=e[n(881)](rh,{url:this._url,protocols:[this._protocols],headers:this._options[n(1002)+n(603)+"s"][n(1184)+n(868)]},this[n(1578)].ws),(this[n(493)+"er"]||this._isWorker)&&this._ws&&(this[n(1342)][n(1295)+"pe"]=this[n(1411)+n(1012)]),this["_addWsLi"+n(1771)](),this[n(1627)+"ionTimeo"+n(1170)]=e.SUQiM(setTimeout,this._onTimeout[n(1277)](this),d)}catch(i){throw this[n(1627)+"Lock"]=!1,i}}}[t(1267)+"mer"](){let n=t;e[n(1465)](clearTimeout,this["_connect"+n(711)+"utId"]),this[n(1627)+n(711)+n(1170)]=null}[t(1831)+t(1394)](){let n=t;e[n(727)](clearTimeout,this._pingPongTimeoutId),clearTimeout(this[n(1556)+"ctTimeoutId"]),this[n(1597)+n(887)+"Id"]=null,this[n(1556)+n(1693)+n(507)]=null}[t(662)](...n){let i=t;this[i(1578)][i(1887)]&&console[i(1590)][i(590)](console,[e.OCKFx,...n])}[t(882)+t(1351)+"e"](n){let i=t,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:p}=this[i(1578)],S=d*Math[i(1029)](p,e[i(1100)](n,1));return e[i(1757)](S,u)?u:S}[t(669)](){let n=t;if(e[n(794)](e.VRsjd,"eCioG")){let i=_0x2e337f(_0x1ffc32),d=_0x32c287[n(880)];return _0x282bc2[n(880)]=e.RRkOO(_0x4c128b[n(883)],i),d}else{if(this[n(1342)]&&e.tgEvw(this[n(1342)].readyState,this[n(941)+"NG"]))if(e[n(627)]===n(749)){this[n(1831)+n(1394)](),this["_pingPon"+n(887)+"Id"]=e[n(475)](setTimeout,this._ping[n(1277)](this),this[n(1578)]["pingInte"+n(1314)]);return}else e[n(823)](_0x123378,this[n(1627)+"ionTimeo"+n(1170)]),this[n(1627)+n(711)+n(1170)]=null;if(!this[n(1342)]||e[n(657)](this[n(1342)][n(849)+"te"],this.OPEN))return void this[n(890)+n(741)]();this[n(1342)]&&this[n(1342)][n(754)]("hi"),this["_reconne"+n(1693)+n(507)]=e[n(1422)](setTimeout,this[n(890)+n(741)+n(1502)][n(1277)](this),this[n(1578)]["pingTime"+n(1632)+n(1843)])}}["_handleR"+t(741)+"Timeout"](){let n=t;this[n(573)+n(598)]?.[n(559)](),this.emit(n(744)+n(964)+"t",e[n(988)]),this[n(573)+n(598)]?.["checkRea"+n(736)+"nt"]()?this[n(890)+"econnect"]():this[n(669)]()}[t(479)+"orOnline"](){let n=t,i={UMhAN:function(d,u){return e[K(575)](d,u)},blsMR:function(d,u){return d>=u}};return e[n(1090)](n(528),n(985))?this[n(1083)+"T"]||this[n(663)+"X"]?this[n(1519)+n(1456)+n(1761)]:(this._isBrowser||this[n(586)+"r"])&&this._options[n(1580)+n(1375)+"nged"]?navigator[n(1515)]:!0:(_0xa3bd89|=0,{low:_0x54edf3,high:XRFjAJ.UMhAN(_0x2c2232,31),unsigned:XRFjAJ[n(839)](_0x12327b,0)})}[t(890)+t(741)](){let n=t;!this[n(479)+n(1816)]()||this[n(1523)+n(756)]||(this["_endpoin"+n(1357)]?.[n(1216)+n(1923)+n(1361)](),this[n(573)+n(598)]?.[n(484)+n(1662)](),this._ws?this[n(820)+n(1536)](1001,e[n(1461)],!0):this[n(1627)]())}["_onPageN"+t(994)+t(1268)](){let n=t;this[n(1083)+"T"]?tt["onNetwor"+n(832)+n(1161)](({isConnected:i})=>{let d=n;this[d(1519)+"igatorOn"+d(1761)]=i,i?this[d(798)+d(1775)]():this["_handleO"+d(730)]()}):this._isMiniWX&&wx[n(1828)+n(832)+n(1161)](({isConnected:i})=>{let d=n;this[d(1519)+d(1456)+d(1761)]=i,i?this[d(798)+d(1775)]():this[d(798)+d(730)]()})}[t(1364)](n){return new Promise(i=>{setTimeout(i,this[K(882)+"rvalValue"](n))})}[t(820)+t(1536)](n=1e3,i="",d=!1){let u=t;this[u(1342)]&&this[u(1675)+u(1308)+"t"](n,i,d)}[t(582)+"ut"](){let n=t,i=this[n(1750)+"tManager"]?.[n(596)+n(508)+"nt"]();this._debug("connect "+i+n(1084)),this["_disconn"+n(1536)](1001,e[n(1057)],!0)}[t(494)](n){let i=t,d={QdMyx:function(p,S){return e[K(885)](p,S)},sBneB:function(p,S){return e[K(1117)](p,S)},hpgGe:function(p,S){return e.ULaxj(p,S)}},u=Ke(n);if(this[i(1342)]&&this[i(1342)][i(849)+"te"]===this[i(874)])if(e.DcCdL!==e[i(1896)])this[i(1342)]&&this[i(1342)][i(754)](u),this._debug(e.DmHcF,n);else{let{url:p}=d[i(1393)](_0x40f4c5,{}),S=_0x342ff4[i(1412)](p)?p:d.sBneB(i(1220),typeof p)?[p]:[];_0xe48250&&_0x4dd1aa[i(1332)](this[i(1578)],_0x2aae33),S&&S[i(1541)]?this[i(1750)+"tManager"]=new _0x14e4d7(S,this._options.maxRetries):this[i(1750)+i(1357)]?.[i(1216)+i(1923)+i(1361)](),this[i(573)+i(598)]?.resetCounter(this[i(1578)][i(1241)+i(968)]),this[i(1523)+i(756)]=!1,this._ws&&d[i(688)](this[i(1342)][i(849)+"te"],this.CLOSED)?this[i(820)+"ect"](1e3,"manual r"+i(741)+i(1906),!0):(this[i(1425)]=!0,this[i(1627)]())}}["_removeW"+t(932)+"rs"](){let n=t,i=e[n(1028)].split("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(1342)][n(644)+"entListe"+n(474)](e.VUQiO,this._onOpen);continue;case"1":if(!this[n(1342)])return;continue;case"2":this._ws[n(644)+"entListe"+n(474)](e.Gdlro,this[n(469)]);continue;case"3":this._ws[n(644)+n(1338)+n(474)](e.tnJaV,this._onError);continue;case"4":this[n(1342)][n(644)+n(1338)+n(474)](e[n(886)],this._onMessage);continue}break}}[t(1196)+t(1771)](){let n=t,i=e[n(1058)][n(906)]("|"),d=0;for(;;){switch(i[d++]){case"0":if(!this[n(1342)])return;continue;case"1":this[n(1342)]["addEvent"+n(948)](e[n(1059)],this[n(506)]);continue;case"2":this[n(1342)][n(1672)+"Listener"](e[n(677)],this[n(1493)]);continue;case"3":this._ws[n(1672)+n(948)](e[n(886)],this[n(661)+"ge"]);continue;case"4":this[n(1342)][n(1672)+n(948)](e[n(1664)],this._onClose);continue}break}}["_wsInsta"+t(1152)](n=1e3,i=""){let d=t;if(e[d(1269)]!==e[d(1269)])this[d(1150)]++;else try{if(e[d(808)](d(846),"fiDtR"))return this[d(1114)].protocol;this[d(1342)]&&this[d(1342)][d(1668)](n,i)}catch{}}[t(1675)+"WebSocket"](n=1e3,i="",d=!1){let u=t,p={KRdrX:function(S,b){return e[K(891)](S,b)},QdrwX:function(S,b){return S-b}};if(e[u(1046)](e[u(1509)],e[u(1509)])){if(this["_clearPi"+u(1394)](),this[u(1267)+u(1666)](),this[u(620)+u(932)+"rs"](),this[u(1739)+u(1152)](1e3,i),this["_connect"+u(1868)]=!1,d&&this[u(479)+u(1816)]()&&!this[u(1523)+u(756)])if(e[u(1157)](e[u(1476)],e[u(1476)])){if(this["_endpoin"+u(1357)]?.[u(1647)+u(1558)+"es"]()){let b=this["_endpoin"+u(1357)]?.[u(596)+"ntEndpoint"]();this[u(1485)+u(1031)+u(1464)](e[u(672)](at,e.Gdlro,{code:1006,reason:u(836)+b+(u(1084)+u(892)+u(1022)+u(653)),wasClean:!0}))}else{let b=this[u(1578)][u(939)+"tInterce"+u(710)](n,i);this["_dispatc"+u(1031)+u(1464)](e[u(745)](at,u(1668),{code:n,reason:i,wasClean:!0,willReconnect:b})),b&&this[u(1627)]()}return}else this.emit(e[u(1664)],_0xb94019(e[u(1664)],{..._0x581450}));this[u(479)+u(1816)]()||this[u(1523)+u(756)]?this[u(1485)+u(1031)+u(1464)](at(e[u(1664)],{code:n,reason:e[u(1407)]})):this[u(1485)+u(1031)+"ent"](e[u(1305)](at,e[u(1664)],{code:1006,reason:e[u(790)]})),this._ws=null,this._endpointManager?.[u(1216)+u(1923)+u(1361)](),this[u(573)+u(598)]?.[u(484)+"nter"]()}else{if(jMULre.KRdrX(4,_0x263b4f[u(1541)])){let S=_0x2a45c3[u(1500)+"g"](0,jMULre[u(1914)](4,_0x1a3824[u(1541)])),b=S[u(1835)](_0x1714fb);_0x3926df[u(1416)](b)}else _0x2253e9[u(1416)](_0x441c07);_0xcc9be9&&(_0x2e77f0+=1),_0x3abcce+=1,_0x494d8c=!1}}[t(1485)+"hOpenEvent"](n){let i=t;this[i(1473)](e[i(677)],n),this[i(1643)]&&this.onopen(n)}[t(1485)+t(955)+t(856)](n){let i=t;this[i(1473)](i(1727),n),this[i(1388)+"e"]&&this[i(1388)+"e"](n)}[t(1485)+t(1042)+t(867)](n){let i=t;if(e[i(732)](e[i(1290)],"yaJam"))this[i(1473)](e[i(1807)],n),this[i(1728)+i(1703)]&&this[i(1728)+i(1703)](n);else return this[i(1737)+"s"][this[i(1713)+i(1280)]]}[t(1485)+t(1062)+t(1464)](n){let i=t;this.emit(e[i(1059)],n),this[i(905)]&&this[i(905)](n)}[t(1485)+"hCloseEv"+t(1464)](n){let i=t;this[i(1473)](e[i(1664)],n),this[i(888)]&&this.onclose(n)}get[t(1295)+"pe"](){let n=t;return this[n(1342)]?this[n(1342)][n(1295)+"pe"]:this[n(1411)+n(1012)]}set[t(1295)+"pe"](n){let i=t;this["_binaryT"+i(1012)]=n,this[i(1342)]&&(this._ws[i(1295)+"pe"]=n)}get[t(1454)+"nt"](){let n=t;return this[n(1750)+n(1357)]?.[n(596)+n(508)+"ntTriesC"+n(1567)]()||0}get["buffered"+t(1235)](){let n=t;return this[n(542)+"Queue"].reduce((d,u)=>(d+=u&&u[n(1105)+"th"]||0,d),0)+(this._ws?this._ws[n(1525)+n(1235)]:0)}get extensions(){let n=t;return e.ULaxj(n(1048),n(1910))?this[n(1342)]?this[n(1342)][n(931)+"ns"]:"":this[n(1187)]?e.tftpo(e[n(1922)](e[n(505)](this.high,0),_0x239245),e[n(451)](this.low,0)):e.vcpBm(this[n(780)],_0x564c53)+e[n(692)](this.low,0)}get[t(1687)](){let n=t;return this._ws?this[n(1342)][n(1687)]:""}get readyState(){let n=t;return this[n(1342)]?this[n(1342)][n(849)+"te"]:this[n(1578)]["automati"+n(1667)]?this[n(941)+"NG"]:this[n(527)]}get[t(1188)](){let n=t;return this._ws?this[n(1342)][n(1188)]:this[n(1759)]}[t(1668)](n=1e3,i){let d=t;if(e[d(1089)](d(1007),e[d(578)])){let u=this[d(780)],p=this.low;return[255&p,e[d(746)](p,8)&255,e.gdGhG(e.JMMxw(p,16),255),p>>>24,e.NvgkF(255,u),e[d(1477)](e[d(712)](u,8),255),e.fkxpP(u,16)&255,e[d(712)](u,24)]}else{if(this[d(1523)+"osed"]=!0,this[d(1267)+d(1666)](),this["_clearPi"+d(1394)](),this["_dropGlo"+d(1600)+d(948)](),this[d(1211)+d(1764)]?.closeDB(),!this._ws)return void this._debug(d(1330)+d(1535)+d(1856)+d(1569)+"ed");if(e.uMlAD(this[d(1342)][d(849)+"te"],this[d(527)])||e[d(1866)](this[d(1342)].readyState,this.CLOSING))return void this[d(662)](e[d(1553)]);this[d(1675)+"WebSocket"](n,i)}}async[t(754)](n,i){let d=t,u={XpFTi:e.AsIuf,JkCZC:d(1514)};if(e[d(1829)](e.XabYa,e.yTjqd))_0x2b57b7[d(644)+d(1338)+"ner"](PyTOKT[d(1116)],_0x25985b),_0x2d56d4["removeEventListe"+d(474)](PyTOKT.JkCZC,_0x3375fd);else{if(n==null)throw new Error(e[d(841)]);e[d(1081)](e[d(1041)],typeof n)&&(n=JSON[d(1774)+"y"](n)),e[d(1560)](e[d(1419)],typeof n)&&!e[d(1453)](n,ArrayBuffer)&&!(n[d(1339)]&&e.Svpfh(n.buffer,ArrayBuffer))&&(n=JSON.stringify(n));let p=await I0(n),S=sh(n),{method:b=0,service:g=this._options[d(1318)],logID:T=this[d(1578)][d(1628)+d(930)](),headers:P=this._options[d(966)],payloadEncoding:B=this[d(1578)][d(1094)+"ncoding"],payloadType:j=this._options[d(679)+d(1012)],logIDNew:V=this[d(1578)].logIDNewConfig[d(489)+d(1885)+d(1301)+"ew"]?e.mSrNP(s,this[d(1578)][d(480)+d(580)][d(1079)]):""}=e[d(897)](i,{});if(!g)throw new Error(e[d(954)]);let J={SeqID:oe[d(1939)+"er"](this[d(545)]++),LogID:oe[d(1939)+"er"](T),service:g,method:b,headers:P,payloadEncoding:e[d(1010)](B,Object)?B[d(1455)]?B[d(1455)]:"":B,payloadType:j instanceof Object?j[d(457)]?j.type:S:j||S,payload:p,LogIDNew:V},He=Ke(J);return this[d(1342)]&&e[d(604)](this._ws.readyState,this[d(874)])?(this[d(1342)]&&this[d(1342)][d(754)](He),this[d(662)]("sent",J)):e[d(1182)](this._messageQueue.length,this[d(1578)][d(496)+"geQueueL"+d(1633)])?(this["_message"+d(472)][d(1416)](He),this[d(662)](e[d(1260)],J)):(this[d(542)+d(472)][d(1440)](),this[d(542)+d(472)][d(1416)](He)),{seqID:this[d(545)],logID:T,logIDNew:V}}}async[t(939)+"t"](n){let i=t,{url:d}=e[i(1292)](n,{}),u=Array.isArray(d)?d:e[i(1593)](e.tnmdO,typeof d)?[d]:[];n&&Object[i(1332)](this._options,n),u&&u[i(1541)]?this[i(1750)+i(1357)]=new E0(u,this[i(1578)][i(1862)+"es"]):this[i(1750)+i(1357)]?.[i(1216)+i(1923)+i(1361)](),this[i(573)+"sCounter"]?.[i(484)+i(1662)](this[i(1578)][i(1241)+i(968)]),this[i(1523)+i(756)]=!1,this[i(1342)]&&this[i(1342)].readyState!==this[i(527)]?this[i(820)+i(1536)](1e3,"manual r"+i(741)+i(1906),!0):e[i(1501)]===e[i(1384)]?_0x3bfb00.o=(p,S)=>_0x349d9e[i(1258)+"e"]["hasOwnPr"+i(1149)][i(783)](p,S):(this._isInit=!0,this._connect())}async[t(684)](){let n=t;!this["_connect"+n(1868)]&&(this["_endpoin"+n(1357)]?.[n(1216)+n(1923)+n(1361)](),this[n(573)+n(598)]?.[n(484)+n(1662)](),this[n(1523)+n(756)]=!1,this[n(1425)]=!0,this[n(1627)]())}[t(1672)+t(948)](n,i){let d=t;if(e[d(1635)](d(720),e[d(594)]))this.on(n,i);else{let u=_0x2f4f24[d(1724)],p=_0xedb2e7[d(780)];return _0x9b7d3e[_0xdf360e]=e[d(712)](p,24),_0x1a2b05[e[d(460)](_0x5de187,1)]=e[d(1169)](e.RsmSv(p,16),255),_0x507d2d[e[d(733)](_0x5bd5dc,2)]=e[d(1557)](p,8)&255,_0x2ccd24[_0x16860a+3]=255&p,_0xa6c626[e.CmZoE(_0x4a4d19,4)]=u>>>24,_0x2ad15b[e[d(1499)](_0x59688c,5)]=e[d(1722)](e[d(1686)](u,16),255),_0x38c4f6[_0x40a903+6]=e[d(947)](e[d(668)](u,8),255),_0x591328[_0x55f1f0+7]=e[d(1477)](255,u),_0x17e930+=8,_0x4a14e0}}[t(755)+t(856)](n){let i=t,{type:d}=n;this[i(1473)](d,n)}[t(644)+"entListe"+t(474)](n,i){this[t(811)](n,i)}[t(1487)](){let n=t,i={tdDze:e[n(1661)],uTeQE:e[n(473)]};return new Promise((d,u)=>{let p=n,S={uKwyt:function(b,g){return e[K(500)](b,g)},AlGvt:function(b,g){return e[K(729)](b,g)},IppuF:function(b,g){return b!==g},iVGFU:p(1389),IsblM:p(744)+p(807)+"s",SpVxQ:p(744)+p(964)+"t"};if(e[p(1279)](e.xmskF,e[p(714)])){if(XLksxp.uKwyt(_0x41d93a,_0x35b3c8))return _0x23b0cd(_0xc3fe1c);if(_0x1162e1[p(541)](_0x439b88))return _0x33f935[p(904)](_0x1fcd49);let b=XLksxp[p(871)](_0x2f3f03,_0xc7dc55);return XLksxp[p(1796)](b,_0x180fa1)&&(_0x29c26d[p(717)](_0x1101b9,b),_0x33a891[p(717)](b,_0x2da1c1)),b}else{this[p(1831)+p(1394)](),this[p(1597)+p(887)+"Id"]=setTimeout(this._ping[p(1277)](this),this._options.pingInterval);let b=()=>{let T=p;d(S[T(1077)]),this[T(811)](S[T(957)],b),this.off(S[T(1585)],g)},g=()=>{let T=p;u(T(1471)),this[T(811)](i.tdDze,b),this.off(i[T(572)],g)};this.on(p(744)+p(807)+"s",b),this.on(e.xAQDB,g),this[p(669)]()}})}}})(),ve[M(1873)+"oseEvent"]=Ee["CustomCl"+M(1075)],ve["CustomEr"+M(827)]=Ee[M(1783)+M(827)],ve.ErrorCode=Ee[M(767)+"e"],ve[M(856)]=Ee[M(856)],ve[M(731)]=Ee[M(731)],ve.FrontierMessageEvent=Ee[M(1881)+"MessageE"+M(536)],ve[M(870)+M(536)]=Ee[M(870)+"vent"],ve[M(1076)+"t"]=Ee[M(1076)+"t"],ve[M(681)+"tEvent"]=Ee[M(681)+M(1481)],ve[M(635)+"oseEvent"]=Ee[M(635)+M(1075)],ve[M(912)+"rorEvent"]=Ee["createEr"+M(827)],ve[M(1011)+M(518)+"nt"]=Ee["createMe"+M(518)+"nt"],ve[M(1651)+M(1588)]=Ee[M(1651)+M(1588)],ve["createRe"+M(1193)+M(536)]=Ee[M(664)+M(1193)+M(536)],ve[M(1762)+"rame"]=Ee[M(1762)+"rame"],ve[M(1805)+"ame"]=Ee[M(1805)+M(777)];for(Xs in Ee)[M(1873)+M(1075),M(1783)+M(827),M(767)+"e",M(856),M(731),M(1881)+M(870)+M(536),M(870)+M(536),M(1076)+"t",M(681)+M(1481),"createCl"+M(1075),M(912)+M(827),"createMessageEvent",M(1651)+M(1588),M(664)+M(1193)+M(536),"decodedFrame",M(1805)+M(777)][M(1168)](Xs)===-1&&(ve[Xs]=Ee[Xs]);var Xs;Object[M(1889)+M(1149)](ve,M(700)+"le",{value:!0})});var Ft=ne((OI,pu)=>{"use strict";var xu=["nodebuffer","arraybuffer","fragments"],hu=typeof Blob<"u";hu&&xu.push("blob");pu.exports={BINARY_TYPES:xu,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:hu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var bi=ne((PI,so)=>{"use strict";var{EMPTY_BUFFER:Iy}=Ft(),Cc=Buffer[Symbol.species];function Ay(t,e){if(t.length===0)return Iy;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 Cc(r.buffer,r.byteOffset,s):r}function gu(t,e,r,s,a){for(let c=0;c<a;c++)r[s+c]=t[c]^e[c&3]}function mu(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Cy(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Tc(t){if(Tc.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Cc(t):ArrayBuffer.isView(t)?e=new Cc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Tc.readOnly=!1),e}so.exports={concat:Ay,mask:gu,toArrayBuffer:Cy,toBuffer:Tc,unmask:mu};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ae("bufferutil");so.exports.mask=function(e,r,s,a,c){c<48?gu(e,r,s,a,c):t.mask(e,r,s,a,c)},so.exports.unmask=function(e,r){e.length<32?mu(e,r):t.unmask(e,r)}}catch{}});var yu=ne((LI,_u)=>{"use strict";var wu=Symbol("kDone"),Dc=Symbol("kRun"),Rc=class{constructor(e){this[wu]=()=>{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[wu])}}};_u.exports=Rc});var vr=ne((NI,vu)=>{"use strict";var Si=ae("zlib"),Eu=bi(),Ty=yu(),{kStatusCode:bu}=Ft(),Dy=Buffer[Symbol.species],Ry=Buffer.from([0,0,255,255]),ao=Symbol("permessage-deflate"),Ut=Symbol("total-length"),br=Symbol("callback"),mn=Symbol("buffers"),Sr=Symbol("error"),oo,kc=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!oo){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;oo=new Ty(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[br];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){oo.add(a=>{this._decompress(e,r,(c,f)=>{a(),s(c,f)})})}compress(e,r,s){oo.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"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Si.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[ao]=this,this._inflate[Ut]=0,this._inflate[mn]=[],this._inflate.on("error",Oy),this._inflate.on("data",Su)}this._inflate[br]=s,this._inflate.write(e),r&&this._inflate.write(Ry),this._inflate.flush(()=>{let c=this._inflate[Sr];if(c){this._inflate.close(),this._inflate=null,s(c);return}let f=Eu.concat(this._inflate[mn],this._inflate[Ut]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ut]=0,this._inflate[mn]=[],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"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Si.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Ut]=0,this._deflate[mn]=[],this._deflate.on("data",ky)}this._deflate[br]=s,this._deflate.write(e),this._deflate.flush(Si.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Eu.concat(this._deflate[mn],this._deflate[Ut]);r&&(c=new Dy(c.buffer,c.byteOffset,c.length-4)),this._deflate[br]=null,this._deflate[Ut]=0,this._deflate[mn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),s(null,c)})}};vu.exports=kc;function ky(t){this[mn].push(t),this[Ut]+=t.length}function Su(t){if(this[Ut]+=t.length,this[ao]._maxPayload<1||this[Ut]<=this[ao]._maxPayload){this[mn].push(t);return}this[Sr]=new RangeError("Max payload size exceeded"),this[Sr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Sr][bu]=1009,this.removeListener("data",Su),this.reset()}function Oy(t){if(this[ao]._inflate=null,this[Sr]){this[br](this[Sr]);return}t[bu]=1007,this[br](t)}});var Ir=ne((MI,co)=>{"use strict";var{isUtf8:Iu}=ae("buffer"),{hasBlob:Py}=Ft(),Ly=[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 Ny(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 My(t){return Py&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}co.exports={isBlob:My,isValidStatusCode:Ny,isValidUTF8:Oc,tokenChars:Ly};if(Iu)co.exports.isValidUTF8=function(t){return t.length<24?Oc(t):Iu(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ae("utf-8-validate");co.exports.isValidUTF8=function(e){return e.length<32?Oc(e):t(e)}}catch{}});var Bc=ne((BI,Ou)=>{"use strict";var{Writable:By}=ae("stream"),Au=vr(),{BINARY_TYPES:zy,EMPTY_BUFFER:Cu,kStatusCode:Fy,kWebSocket:Uy}=Ft(),{concat:Pc,toArrayBuffer:qy,unmask:Hy}=bi(),{isValidStatusCode:jy,isValidUTF8:Tu}=Ir(),fo=Buffer[Symbol.species],it=0,Du=1,Ru=2,ku=3,Lc=4,Nc=5,lo=6,Mc=class extends By{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||zy[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Uy]=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=it}_write(e,r,s){if(this._opcode===8&&this._state==it)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 fo(s.buffer,s.byteOffset+e,s.length-e),new fo(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 fo(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 it:this.getInfo(e);break;case Du:this.getPayloadLength16(e);break;case Ru:this.getPayloadLength64(e);break;case ku:this.getMask();break;case Lc:this.getData(e);break;case Nc:case lo:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let s=(r[0]&64)===64;if(s&&!this._extensions[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=Ru: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=ku: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&&Hy(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[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===it&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=it;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=Pc(s,r):this._binaryType==="arraybuffer"?a=qy(Pc(s,r)):this._binaryType==="blob"?a=new Blob(s):a=s,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=it):(this._state=lo,setImmediate(()=>{this.emit("message",a,!0),this._state=it,this.startLoop(e)}))}else{let a=Pc(s,r);if(!this._skipUTF8Validation&&!Tu(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Nc||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=it):(this._state=lo,setImmediate(()=>{this.emit("message",a,!1),this._state=it,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 s=e.readUInt16BE(0);if(!jy(s)){let c=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let a=new fo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Tu(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=it;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=it):(this._state=lo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=it,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[Fy]=a,f}};Ou.exports=Mc});var Uc=ne((FI,Nu)=>{"use strict";var{Duplex:zI}=ae("stream"),{randomFillSync:Gy}=ae("crypto"),Pu=vr(),{EMPTY_BUFFER:Ky,kWebSocket:Wy,NOOP:$y}=Ft(),{isBlob:Ar,isValidStatusCode:Vy}=Ir(),{mask:Lu,toBuffer:Nn}=bi(),st=Symbol("kByteLength"),Jy=Buffer.alloc(4),uo=8*1024,Mn,Cr=uo,pt=0,Zy=1,Yy=2,zc=class t{constructor(e,r,s){this._extensions=r||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=pt,this.onerror=$y,this[Wy]=void 0}static frame(e,r){let s,a=!1,c=2,f=!1;r.mask&&(s=r.maskBuffer||Jy,r.generateMask?r.generateMask(s):(Cr===uo&&(Mn===void 0&&(Mn=Buffer.alloc(uo)),Gy(Mn,0,uo),Cr=0),s[0]=Mn[Cr++],s[1]=Mn[Cr++],s[2]=Mn[Cr++],s[3]=Mn[Cr++]),f=(s[0]|s[1]|s[2]|s[3])===0,c=6);let l;typeof e=="string"?(!r.mask||f)&&r[st]!==void 0?l=r[st]:(e=Buffer.from(e),l=e.length):(l=e.length,a=r.mask&&r.readOnly&&!f);let x=l;l>=65536?(c+=8,x=127):l>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(a?l+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(l,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(l,4,6)),r.mask?(h[1]|=128,h[c-4]=s[0],h[c-3]=s[1],h[c-2]=s[2],h[c-1]=s[3],f?[h,e]:a?(Lu(e,s,h,c,l),[h]):(Lu(e,s,e,0,l),[h,e])):[h,e]}close(e,r,s,a){let c;if(e===void 0)c=Ky;else{if(typeof e!="number"||!Vy(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 l=Buffer.byteLength(r);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+l),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let f={[st]:c.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==pt?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):Ar(e)?(a=e.size,c=!1):(e=Nn(e),a=e.length,c=Nn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[st]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Ar(e)?this._state!==pt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==pt?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):Ar(e)?(a=e.size,c=!1):(e=Nn(e),a=e.length,c=Nn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[st]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Ar(e)?this._state!==pt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==pt?this.enqueue([this.dispatch,e,!1,f,s]):this.sendFrame(t.frame(e,f),s)}send(e,r,s){let a=this._extensions[Pu.extensionName],c=r.binary?2:1,f=r.compress,l,x;typeof e=="string"?(l=Buffer.byteLength(e),x=!1):Ar(e)?(l=e.size,x=!1):(e=Nn(e),l=e.length,x=Nn.readOnly),this._firstFragment?(this._firstFragment=!1,f&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=l>=a._threshold),this._compress=f):(f=!1,c=0),r.fin&&(this._firstFragment=!0);let h={[st]:l,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:f};Ar(e)?this._state!==pt?this.enqueue([this.getBlobData,e,this._compress,h,s]):this.getBlobData(e,this._compress,h,s):this._state!==pt?this.enqueue([this.dispatch,e,this._compress,h,s]):this.dispatch(e,this._compress,h,s)}getBlobData(e,r,s,a){this._bufferedBytes+=s[st],this._state=Yy,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(Fc,this,l,a);return}this._bufferedBytes-=s[st];let f=Nn(c);r?this.dispatch(f,r,s,a):(this._state=pt,this.sendFrame(t.frame(f,s),a),this.dequeue())}).catch(c=>{process.nextTick(Xy,this,c,a)})}dispatch(e,r,s,a){if(!r){this.sendFrame(t.frame(e,s),a);return}let c=this._extensions[Pu.extensionName];this._bufferedBytes+=s[st],this._state=Zy,c.compress(e,s.fin,(f,l)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Fc(this,x,a);return}this._bufferedBytes-=s[st],this._state=pt,s.readOnly=!1,this.sendFrame(t.frame(l,s),a),this.dequeue()})}dequeue(){for(;this._state===pt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][st],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][st],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)}};Nu.exports=zc;function Fc(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let a=t._queue[s],c=a[a.length-1];typeof c=="function"&&c(e)}}function Xy(t,e,r){Fc(t,e,r),t.onerror(e)}});var Gu=ne((UI,ju)=>{"use strict";var{kForOnEventAttribute:vi,kListener:qc}=Ft(),Mu=Symbol("kCode"),Bu=Symbol("kData"),zu=Symbol("kError"),Fu=Symbol("kMessage"),Uu=Symbol("kReason"),Tr=Symbol("kTarget"),qu=Symbol("kType"),Hu=Symbol("kWasClean"),qt=class{constructor(e){this[Tr]=null,this[qu]=e}get target(){return this[Tr]}get type(){return this[qu]}};Object.defineProperty(qt.prototype,"target",{enumerable:!0});Object.defineProperty(qt.prototype,"type",{enumerable:!0});var Bn=class extends qt{constructor(e,r={}){super(e),this[Mu]=r.code===void 0?0:r.code,this[Uu]=r.reason===void 0?"":r.reason,this[Hu]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Mu]}get reason(){return this[Uu]}get wasClean(){return this[Hu]}};Object.defineProperty(Bn.prototype,"code",{enumerable:!0});Object.defineProperty(Bn.prototype,"reason",{enumerable:!0});Object.defineProperty(Bn.prototype,"wasClean",{enumerable:!0});var Dr=class extends qt{constructor(e,r={}){super(e),this[zu]=r.error===void 0?null:r.error,this[Fu]=r.message===void 0?"":r.message}get error(){return this[zu]}get message(){return this[Fu]}};Object.defineProperty(Dr.prototype,"error",{enumerable:!0});Object.defineProperty(Dr.prototype,"message",{enumerable:!0});var Ii=class extends qt{constructor(e,r={}){super(e),this[Bu]=r.data===void 0?null:r.data}get data(){return this[Bu]}};Object.defineProperty(Ii.prototype,"data",{enumerable:!0});var Qy={addEventListener(t,e,r={}){for(let a of this.listeners(t))if(!r[vi]&&a[qc]===e&&!a[vi])return;let s;if(t==="message")s=function(c,f){let l=new Ii("message",{data:f?c:c.toString()});l[Tr]=this,xo(e,this,l)};else if(t==="close")s=function(c,f){let l=new Bn("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Tr]=this,xo(e,this,l)};else if(t==="error")s=function(c){let f=new Dr("error",{error:c,message:c.message});f[Tr]=this,xo(e,this,f)};else if(t==="open")s=function(){let c=new qt("open");c[Tr]=this,xo(e,this,c)};else return;s[vi]=!!r[vi],s[qc]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[qc]===e&&!r[vi]){this.removeListener(t,r);break}}};ju.exports={CloseEvent:Bn,ErrorEvent:Dr,Event:qt,EventTarget:Qy,MessageEvent:Ii};function xo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ho=ne((qI,Ku)=>{"use strict";var{tokenChars:Ai}=Ir();function Rt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function eE(t){let e=Object.create(null),r=Object.create(null),s=!1,a=!1,c=!1,f,l,x=-1,h=-1,m=-1,E=0;for(;E<t.length;E++)if(h=t.charCodeAt(E),f===void 0)if(m===-1&&Ai[h]===1)x===-1&&(x=E);else if(E!==0&&(h===32||h===9))m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(x,m);h===44?(Rt(e,_,r),r=Object.create(null)):f=_,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(l===void 0)if(m===-1&&Ai[h]===1)x===-1&&(x=E);else if(h===32||h===9)m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E),Rt(r,t.slice(x,m),!0),h===44&&(Rt(e,f,r),r=Object.create(null),f=void 0),x=m=-1}else if(h===61&&x!==-1&&m===-1)l=t.slice(x,E),x=m=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(a){if(Ai[h]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);x===-1?x=E:s||(s=!0),a=!1}else if(c)if(Ai[h]===1)x===-1&&(x=E);else if(h===34&&x!==-1)c=!1,m=E;else if(h===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(h===34&&t.charCodeAt(E-1)===61)c=!0;else if(m===-1&&Ai[h]===1)x===-1&&(x=E);else if(x!==-1&&(h===32||h===9))m===-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(x,m);s&&(_=_.replace(/\\/g,""),s=!1),Rt(r,l,_),h===44&&(Rt(e,f,r),r=Object.create(null),f=void 0),l=void 0,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=E);let C=t.slice(x,m);return f===void 0?Rt(e,C,r):(l===void 0?Rt(r,C,!0):s?Rt(r,l,C.replace(/\\/g,"")):Rt(r,l,C),Rt(e,f,r)),e}function tE(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:tE,parse:eE}});var wo=ne((GI,rx)=>{"use strict";var nE=ae("events"),rE=ae("https"),iE=ae("http"),Vu=ae("net"),sE=ae("tls"),{randomBytes:oE,createHash:aE}=ae("crypto"),{Duplex:HI,Readable:jI}=ae("stream"),{URL:Hc}=ae("url"),wn=vr(),cE=Bc(),dE=Uc(),{isBlob:fE}=Ir(),{BINARY_TYPES:Wu,CLOSE_TIMEOUT:lE,EMPTY_BUFFER:po,GUID:uE,kForOnEventAttribute:jc,kListener:xE,kStatusCode:hE,kWebSocket:Pe,NOOP:Ju}=Ft(),{EventTarget:{addEventListener:pE,removeEventListener:gE}}=Gu(),{format:mE,parse:wE}=ho(),{toBuffer:_E}=bi(),Zu=Symbol("kAborted"),Gc=[8,13],Ht=["CONNECTING","OPEN","CLOSING","CLOSED"],yE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,de=class t extends nE{constructor(e,r,s){super(),this._binaryType=Wu[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=po,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]),Yu(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Wu.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 cE({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),c=new dE(e,this._extensions,s.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[Pe]=this,c[Pe]=this,e[Pe]=this,a.on("conclude",SE),a.on("drain",vE),a.on("error",IE),a.on("message",AE),a.on("ping",CE),a.on("pong",TE),c.onerror=DE,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",ex),e.on("data",mo),e.on("end",tx),e.on("error",nx),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[wn.extensionName]&&this._extensions[wn.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){Qe(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())}),Qu(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||po,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||po,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[wn.extensionName]||(a.compress=!1),this._sender.send(e||po,a,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Qe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(de,"CONNECTING",{enumerable:!0,value:Ht.indexOf("CONNECTING")});Object.defineProperty(de.prototype,"CONNECTING",{enumerable:!0,value:Ht.indexOf("CONNECTING")});Object.defineProperty(de,"OPEN",{enumerable:!0,value:Ht.indexOf("OPEN")});Object.defineProperty(de.prototype,"OPEN",{enumerable:!0,value:Ht.indexOf("OPEN")});Object.defineProperty(de,"CLOSING",{enumerable:!0,value:Ht.indexOf("CLOSING")});Object.defineProperty(de.prototype,"CLOSING",{enumerable:!0,value:Ht.indexOf("CLOSING")});Object.defineProperty(de,"CLOSED",{enumerable:!0,value:Ht.indexOf("CLOSED")});Object.defineProperty(de.prototype,"CLOSED",{enumerable:!0,value:Ht.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(de.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(de.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[jc])return e[xE];return null},set(e){for(let r of this.listeners(t))if(r[jc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[jc]:!0})}})});de.prototype.addEventListener=pE;de.prototype.removeEventListener=gE;rx.exports=de;function Yu(t,e,r,s){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:lE,protocolVersion:Gc[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=a.autoPong,t._closeTimeout=a.closeTimeout,!Gc.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${Gc.join(", ")})`);let c;if(e instanceof Hc)c=e;else try{c=new Hc(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let f=c.protocol==="wss:",l=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!f&&!l?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let v=new SyntaxError(x);if(t._redirects===0)throw v;go(t,v);return}let h=f?443:80,m=oE(16).toString("base64"),E=f?rE.request:iE.request,C=new Set,_;if(a.createConnection=a.createConnection||(f?bE:EE),a.defaultPort=a.defaultPort||h,a.port=c.port||h,a.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(_=new wn({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=mE({[wn.extensionName]:_.offer()})),r.length){for(let v of r){if(typeof v!="string"||!yE.test(v)||C.has(v))throw new SyntaxError("An invalid or duplicated subprotocol was specified");C.add(v)}a.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(c.username||c.password)&&(a.auth=`${c.username}:${c.password}`),l){let v=a.path.split(":");a.socketPath=v[0],a.path=v[1]}let y;if(a.followRedirects){if(t._redirects===0){t._originalIpc=l,t._originalSecure=f,t._originalHostOrSocketPath=l?a.socketPath:c.host;let v=s&&s.headers;if(s={...s,headers:{}},v)for(let[I,R]of Object.entries(v))s.headers[I.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let v=l?t._originalIpc?a.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!v||t._originalSecure&&!f)&&(delete a.headers.authorization,delete a.headers.cookie,v||delete a.headers.host,a.auth=void 0)}a.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),y=t._req=E(a),t._redirects&&t.emit("redirect",t.url,y)}else y=t._req=E(a);a.timeout&&y.on("timeout",()=>{Qe(t,y,"Opening handshake has timed out")}),y.on("error",v=>{y===null||y[Zu]||(y=t._req=null,go(t,v))}),y.on("response",v=>{let I=v.headers.location,R=v.statusCode;if(I&&a.followRedirects&&R>=300&&R<400){if(++t._redirects>a.maxRedirects){Qe(t,y,"Maximum redirects exceeded");return}y.abort();let L;try{L=new Hc(I,e)}catch{let A=new SyntaxError(`Invalid URL: ${I}`);go(t,A);return}Yu(t,L,r,s)}else t.emit("unexpected-response",y,v)||Qe(t,y,`Unexpected server response: ${v.statusCode}`)}),y.on("upgrade",(v,I,R)=>{if(t.emit("upgrade",v),t.readyState!==de.CONNECTING)return;y=t._req=null;let L=v.headers.upgrade;if(L===void 0||L.toLowerCase()!=="websocket"){Qe(t,I,"Invalid Upgrade header");return}let w=aE("sha1").update(m+uE).digest("base64");if(v.headers["sec-websocket-accept"]!==w){Qe(t,I,"Invalid Sec-WebSocket-Accept header");return}let A=v.headers["sec-websocket-protocol"],k;if(A!==void 0?C.size?C.has(A)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":C.size&&(k="Server sent no subprotocol"),k){Qe(t,I,k);return}A&&(t._protocol=A);let F=v.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){Qe(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=wE(F)}catch{Qe(t,I,"Invalid Sec-WebSocket-Extensions header");return}let O=Object.keys(z);if(O.length!==1||O[0]!==wn.extensionName){Qe(t,I,"Server indicated an extension that was not requested");return}try{_.accept(z[wn.extensionName])}catch{Qe(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[wn.extensionName]=_}t.setSocket(I,R,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(y,t):y.end()}function go(t,e){t._readyState=de.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function EE(t){return t.path=t.socketPath,Vu.connect(t)}function bE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Vu.isIP(t.host)?"":t.host),sE.connect(t)}function Qe(t,e,r){t._readyState=de.CLOSING;let s=new Error(r);Error.captureStackTrace(s,Qe),e.setHeader?(e[Zu]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(go,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=fE(e)?e.size:_E(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ht[t.readyState]})`);process.nextTick(r,s)}}function SE(t,e){let r=this[Pe];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Pe]!==void 0&&(r._socket.removeListener("data",mo),process.nextTick(Xu,r._socket),t===1005?r.close():r.close(t,e))}function vE(){let t=this[Pe];t.isPaused||t._socket.resume()}function IE(t){let e=this[Pe];e._socket[Pe]!==void 0&&(e._socket.removeListener("data",mo),process.nextTick(Xu,e._socket),e.close(t[hE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function $u(){this[Pe].emitClose()}function AE(t,e){this[Pe].emit("message",t,e)}function CE(t){let e=this[Pe];e._autoPong&&e.pong(t,!this._isServer,Ju),e.emit("ping",t)}function TE(t){this[Pe].emit("pong",t)}function Xu(t){t.resume()}function DE(t){let e=this[Pe];e.readyState!==de.CLOSED&&(e.readyState===de.OPEN&&(e._readyState=de.CLOSING,Qu(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Qu(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function ex(){let t=this[Pe];if(this.removeListener("close",ex),this.removeListener("data",mo),this.removeListener("end",tx),t._readyState=de.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Pe]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",$u),t._receiver.on("finish",$u))}function mo(t){this[Pe]._receiver.write(t)||this.pause()}function tx(){let t=this[Pe];t._readyState=de.CLOSING,t._receiver.end(),this.end()}function nx(){let t=this[Pe];this.removeListener("error",nx),this.on("error",Ju),t&&(t._readyState=de.CLOSING,this.destroy())}});var ax=ne((WI,ox)=>{"use strict";var KI=wo(),{Duplex:RE}=ae("stream");function ix(t){t.emit("close")}function kE(){!this.destroyed&&this._writableState.finished&&this.destroy()}function sx(t){this.removeListener("error",sx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function OE(t,e){let r=!0,s=new RE({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,f){let l=!f&&s._readableState.objectMode?c.toString():c;s.push(l)||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(ix,s);return}let f=!1;t.once("error",function(x){f=!0,c(x)}),t.once("close",function(){f||c(a),process.nextTick(ix,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",kE),s.on("error",sx),s}ox.exports=OE});var Wc=ne(($I,cx)=>{"use strict";var{tokenChars:PE}=Ir();function LE(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&&PE[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 l=t.slice(r,s);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),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}cx.exports={parse:LE}});var px=ne((JI,hx)=>{"use strict";var NE=ae("events"),_o=ae("http"),{Duplex:VI}=ae("stream"),{createHash:ME}=ae("crypto"),dx=ho(),zn=vr(),BE=Wc(),zE=wo(),{CLOSE_TIMEOUT:FE,GUID:UE,kWebSocket:qE}=Ft(),HE=/^[+/0-9A-Za-z]{22}==$/,fx=0,lx=1,xx=2,$c=class extends NE{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:FE,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:zE,...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((s,a)=>{let c=_o.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=jE(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=fx}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===xx){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!==lx)if(this._state=lx,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,s,a){r.on("error",ux);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Fn(this,e,r,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){Fn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!HE.test(c)){Fn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){Fn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ti(r,400);return}let x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=BE.parse(x)}catch{Fn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&m!==void 0){let C=new zn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=dx.parse(m);_[zn.extensionName]&&(C.accept(_[zn.extensionName]),E[zn.extensionName]=C)}catch{Fn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let C={origin:e.headers[`${l===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,v,I)=>{if(!_)return Ti(r,y||401,v,I);this.completeUpgrade(E,c,h,e,r,s,a)});return}if(!this.options.verifyClient(C))return Ti(r,401)}this.completeUpgrade(E,c,h,e,r,s,a)}completeUpgrade(e,r,s,a,c,f,l){if(!c.readable||!c.writable)return c.destroy();if(c[qE])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>fx)return Ti(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ME("sha1").update(r+UE).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(s.size){let E=this.options.handleProtocols?this.options.handleProtocols(s,a):s.values().next().value;E&&(h.push(`Sec-WebSocket-Protocol: ${E}`),m._protocol=E)}if(e[zn.extensionName]){let E=e[zn.extensionName].params,C=dx.format({[zn.extensionName]:[E]});h.push(`Sec-WebSocket-Extensions: ${C}`),m._extensions=e}this.emit("headers",h,a),c.write(h.concat(`\r
|
|
8
|
+
var qx=Object.create;var Wo=Object.defineProperty;var Gx=Object.getOwnPropertyDescriptor;var jx=Object.getOwnPropertyNames;var Wx=Object.getPrototypeOf,Kx=Object.prototype.hasOwnProperty;var oe=(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 it=(t,e)=>()=>(t&&(e=t(t=0)),e);var te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ko=(t,e)=>{for(var r in e)Wo(t,r,{get:e[r],enumerable:!0})},$x=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of jx(e))!Kx.call(t,o)&&o!==r&&Wo(t,o,{get:()=>e[o],enumerable:!(i=Gx(e,o))||i.enumerable});return t};var mt=(t,e,r)=>(r=t!=null?qx(Wx(t)):{},$x(e||!t||!t.__esModule?Wo(r,"default",{value:t,enumerable:!0}):r,t));function Od(t){$o=t}function Pd(t){return Li[$o]<=Li[t]}function Ni(t){Dd={...t}}function Zx(t){let e=(f,h=2)=>String(f).padStart(h,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),l=e(o%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)}${i}${c}:${l}`}function Pi(t,e,r,i){if(Li[t]<Li[$o])return;let o=JSON.stringify({ts:Zx(new Date),level:t,module:e,msg:r,...Dd,...i});t==="error"||t==="warn"?Jx.write(`${o}
|
|
9
|
+
`):Vx.write(`${o}
|
|
10
|
+
`)}function q(t){return{debug:(e,r)=>Pi("debug",t,e,r),info:(e,r)=>Pi("info",t,e,r),warn:(e,r)=>Pi("warn",t,e,r),error:(e,r)=>Pi("error",t,e,r),child:e=>q(`${t}.${e}`)}}var Li,$o,Vx,Jx,Dd,Q=it(()=>{"use strict";Li={debug:10,info:20,warn:30,error:40},$o=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Vx=process.stdout,Jx=process.stderr,Dd={}});import{execFile as Yx,spawn as Xx,spawnSync as ib}from"node:child_process";import{promisify as Qx}from"node:util";function tp(t){if(process.platform!=="win32")return!1;if(Ld.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Ld,"").toLowerCase();return ep.has(r)}function Nd(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 Jt(t,e=[],r={}){return Xx(t,e,Nd(t,r))}function Mi(t,e=[],r={}){return np(t,e,Nd(t,r))}var ep,Ld,np,Wn=it(()=>{"use strict";ep=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp"]),Ld=/\.(cmd|bat|ps1)$/i;np=Qx(Yx)});var C,je=it(()=>{"use strict";C=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var Hd={};Ko(Hd,{_resetAcpInstallerForTests:()=>up,_resetInstallTimeoutsForTests:()=>lp,_setBinaryPathCacheForTests:()=>xp,_setInFlightForTests:()=>hp,_setInstallTimeoutsForTests:()=>dp,buildInstallFailureMessage:()=>Ud,ensureAcpInstalled:()=>Vn,formatExecError:()=>zd,getAcpBinaryPath:()=>Lr,getAcpPackageSpec:()=>ap,getInFlightInstall:()=>Zo,npmInstallGlobal:()=>Fd,pickWhichLine:()=>Fi,probeAcpVersion:()=>fp,resolveAcpCommand:()=>Nr});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){Bi=t,zi=e}function lp(){Bi=5e4,zi=5e3}function zd(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 i=e.stderr?.toString().trim();i&&r.push(`stderr=${i.slice(0,2e3)}`);let o=e.stdout?.toString().trim();return o&&r.push(`stdout=${o.slice(0,2e3)}`),r.length>0?r.join(" | "):String(t)}async function Md(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await Mi(e,[t],{timeout:cp});return Fi(r)}catch{return}}function Fi(t){let e=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=i=>e.find(o=>o.toLowerCase().endsWith(i));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}async function fp(t){let e=Jo[t];if(!e)return;let r=Lr(t);if(!r){Ue.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 i;try{i=await ip(r)}catch(c){Ue.warn("acp wrapper probe: realpath failed (symlink target \u4E0D\u5B58\u5728?)",{framework:t,binaryPath:r,err:String(c)});return}let o=Vo(i);for(let c=0;c<Bd;c++){let l=op(o,"package.json");try{if(!(await sp(l)).isFile()){o=Vo(o);continue}let x=await rp(l,"utf8"),m=JSON.parse(x);if(m.name===e.npmPackage){if(typeof m.version=="string"&&m.version.length>0)return m.version;Ue.warn("acp wrapper probe: package.json \u627E\u5230\u4F46 version \u5B57\u6BB5\u7F3A",{framework:t,packageJsonPath:l});return}}catch(h){let x=h;x.code!=="ENOENT"&&Ue.warn("acp wrapper probe: package.json \u8BFB\u53D6\u5F02\u5E38",{framework:t,candidate:l,errCode:x?.code,err:String(h)})}let f=Vo(o);if(f===o)break;o=f}Ue.warn("acp wrapper probe: \u627E\u4E0D\u5230\u5339\u914D name \u7684 package.json (\u4E0A\u6EAF\u5230 max depth)",{framework:t,binaryPath:r,realBinary:i,expectedName:e.npmPackage,maxDepth:Bd})}async function Fd(t,e,r){let i=`${t}@${e}`;Ue.info("npm install -g start",{npmPackage:t,versionSpec:e});let o=Date.now(),c=process.platform==="win32";return new Promise((l,f)=>{let h=Jt("npm",["install","-g",i],{stdio:["ignore","pipe","pipe"],...c?{}:{detached:!0}});if(!h.pid){f(new Error(`failed to spawn npm: no pid (npmPackage=${t})`));return}let x=h.pid,m=10*1024*1024,_=[],A=[],y=0,E=0;h.stdout?.on("data",T=>{y+=T.length,y<m&&_.push(T)}),h.stderr?.on("data",T=>{E+=T.length,E<m&&A.push(T)});let S="running",I,R=T=>{try{return c?h.kill(T):process.kill(-x,T),!0}catch(k){return Ue.warn("npm install: kill failed (process already dead?)",{npmPackage:t,pid:x,sig:T,err:String(k)}),!1}},P=setTimeout(()=>{S="terminating",Ue.warn("npm install timeout, sending SIGTERM to process group",{npmPackage:t,versionSpec:e,pid:x,elapsedMs:Date.now()-o,timeoutMs:Bi,graceMs:zi,stdoutBytes:y,stderrBytes:E}),R("SIGTERM"),I=setTimeout(()=>{S="killing",Ue.warn("npm install SIGTERM grace expired, escalating to SIGKILL",{npmPackage:t,versionSpec:e,pid:x,elapsedMs:Date.now()-o,stdoutBytes:y,stderrBytes:E}),R("SIGKILL")},zi)},Bi),w=()=>{S="aborted",Ue.warn("npm install externally aborted, sending SIGKILL to process group",{npmPackage:t,versionSpec:e,pid:x,elapsedMs:Date.now()-o}),R("SIGKILL")};r&&(r.aborted?w():r.addEventListener("abort",w,{once:!0})),h.on("error",T=>{clearTimeout(P),I&&clearTimeout(I),r?.removeEventListener("abort",w),Ue.warn("npm install spawn error",{npmPackage:t,versionSpec:e,pid:x,err:String(T)}),f(new Error(`spawn npm failed: ${String(T)}`))}),h.on("close",(T,k)=>{clearTimeout(P),I&&clearTimeout(I),r?.removeEventListener("abort",w);let z=Buffer.concat(_).toString("utf8"),B=Buffer.concat(A).toString("utf8"),D=Date.now()-o;if(T===0&&S==="running"){Ue.info("npm install -g done",{npmPackage:t,versionSpec:e,elapsedMs:D}),l();return}Ue.warn("npm install -g exited non-success",{npmPackage:t,versionSpec:e,pid:x,phase:S,exitCode:T,signal:k,elapsedMs:D,stdoutBytes:y,stderrBytes:E});let L=Object.assign(new Error(`Command failed: npm install -g ${i}`+(k?` (killed by ${k})`:"")+(T!==null?` (exit ${T})`:"")+(S!=="running"?` (phase=${S})`:"")),{code:T,signal:k,stderr:B,stdout:z});f(L)})})}function Ud(t){let{framework:e,npmPackage:r,versionSpec:i,command:o,reason:c,elapsedMs:l}=t;return["ACP wrapper \u5B89\u88C5\u5931\u8D25",`Framework: ${e}`,`Package: ${r}@${i}`,`\u6267\u884C\u547D\u4EE4: ${o}`,`\u5931\u8D25\u539F\u56E0: ${c}`,`\u8017\u65F6: ${l}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 Vn(t,e){let r=Jo[t];if(!r)throw new C("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Kn.get(t);if(i)return i;let o=$n.get(t);if(o)return o;let c=`npm install -g ${r.npmPackage}@${r.versionSpec}`,l=(h,x,m)=>new C("AGENT_DEPENDENCY_INSTALL_FAILED",Ud({framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,command:c,reason:h,elapsedMs:x}),m!==void 0?{cause:m}:{}),f=(async()=>{let h=await Md(r.binary);if(h)return Kn.set(t,h),Ue.info("acp wrapper found on PATH",{binary:r.binary,path:h}),h;let x=Date.now();try{await Fd(r.npmPackage,r.versionSpec,e)}catch(_){let A=zd(_);throw Ue.warn("acp wrapper install failed",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary,err:A}),l(A,Date.now()-x,_)}let m=await Md(r.binary);if(!m)throw Ue.warn("acp wrapper installed but binary not found on PATH",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary}),l(`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()-x);return Kn.set(t,m),m})().finally(()=>{$n.delete(t)});return $n.set(t,f),f}function Lr(t){return Kn.get(t)}function Nr(t,e){if(e)return e;let r=Lr(t);if(!r)throw new C("BRIDGE_INTERNAL",`${t} ACP wrapper binary path cache miss (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function Zo(t){return $n.get(t)}function up(){Kn.clear(),$n.clear()}function hp(t,e){$n.set(t,e)}function xp(t,e){Kn.set(t,e)}var Ue,Jo,Bi,zi,cp,Kn,$n,Bd,yn=it(()=>{"use strict";Wn();je();Q();Ue=q("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"}};Bi=5e4,zi=5e3,cp=5e3;Kn=new Map,$n=new Map;Bd=6});import{chmod as gp,mkdir as mp,readFile as wp,rename as jd,writeFile as Wd}from"node:fs/promises";import{dirname as yp}from"node:path";async function Jn(t){try{let e=await wp(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Ui(t,e,r){await mp(yp(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
|
|
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
|
|
13
13
|
`).join(`\r
|
|
14
|
-
`)),c.removeListener("error",
|
|
15
|
-
`+Object.keys(
|
|
14
|
+
`)),c.removeListener("error",hh),m.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ci,this)})),f(m,o)}};ph.exports=$c;function D1(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function Ci(t){t._state=xh,t.emit("close")}function hh(){this.destroy()}function Ri(t,e,r,i){r=r||_o.STATUS_CODES[e],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...i},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${_o.STATUS_CODES[e]}\r
|
|
15
|
+
`+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
|
|
16
16
|
`)+`\r
|
|
17
17
|
\r
|
|
18
|
-
`+r)}function
|
|
18
|
+
`+r)}function zn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,zn),t.emit("wsClientError",l,r,e)}else Ri(r,i,o,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 Yc(t=ee()){return sE(t.libEntry)?t.libEntry:dE(new URL("../index.ts",import.meta.url))}async function Xc(t={}){let e=t.paths??ee(),r=t.entryOverride??Yc(e);await aE(cE(e.logFile),{recursive:!0});let i=oE(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],l=Jt(process.execPath,c,{detached:!0,stdio:["ignore",i,i],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(l.unref(),typeof l.pid!="number")throw new Error("failed to spawn daemon (no pid)");return lE.info("daemon spawned",{pid:l.pid,entry:r}),{pid:l.pid,entry:r}}var lE,Qc=it(()=>{"use strict";Wn();Q();Be();lE=q("spawn-daemon")});import{spawn as IE}from"node:child_process";import{mkdir as AE,unlink as TE,writeFile as CE}from"node:fs/promises";import{dirname as RE,join as kE}from"node:path";function Ro(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function zh(t,e){return new Promise((r,i)=>{let o=IE(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Co,rd,id,Fh=it(()=>{"use strict";Q();Co=q("supervisor.launchd"),rd="ai.coze.bridge",id={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>${rd}</string>
|
|
24
24
|
<key>ProgramArguments</key>
|
|
25
25
|
<array>
|
|
26
|
-
<string>${
|
|
27
|
-
<string>${
|
|
26
|
+
<string>${Ro(t.nodeBin)}</string>
|
|
27
|
+
<string>${Ro(t.entry)}</string>
|
|
28
28
|
<string>--daemon</string>
|
|
29
29
|
</array>
|
|
30
30
|
<key>RunAtLoad</key>
|
|
@@ -34,12 +34,12 @@ ${t.stack??""}`:String(t);return up.test(r)||xp.test(r)}function z0(t){if(t==nul
|
|
|
34
34
|
<key>ThrottleInterval</key>
|
|
35
35
|
<integer>10</integer>
|
|
36
36
|
<key>StandardOutPath</key>
|
|
37
|
-
<string>${
|
|
37
|
+
<string>${Ro(t.logFile)}</string>
|
|
38
38
|
<key>StandardErrorPath</key>
|
|
39
|
-
<string>${
|
|
39
|
+
<string>${Ro(t.logFile)}</string>
|
|
40
40
|
</dict>
|
|
41
41
|
</plist>
|
|
42
|
-
`},configPath(t){return
|
|
42
|
+
`},configPath(t){return kE(t.homeDir,"Library","LaunchAgents",`${rd}.plist`)},async install(t){let e=this.configPath(t);await AE(RE(e),{recursive:!0}),await CE(e,this.renderConfig(t),"utf8"),Co.info("plist written",{plistPath:e}),await zh("launchctl",["load","-w",e]),Co.info("launchd job loaded",{label:rd})},async uninstall(t){let e=this.configPath(t);await zh("launchctl",["unload","-w",e]).catch(r=>Co.warn("launchctl unload failed (ignored)",{err:String(r)})),await TE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Co.info("launchd job removed",{plistPath:e})}}});import{spawn as DE}from"node:child_process";import{mkdir as OE,unlink as PE,writeFile as LE}from"node:fs/promises";import{dirname as NE,join as ME}from"node:path";function Oo(t,e){return new Promise((r,i)=>{let o=DE(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var ko,Do,sd,Uh=it(()=>{"use strict";Q();ko=q("supervisor.systemd"),Do="coze-bridge.service",sd={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
|
|
56
|
+
`},configPath(t){return ME(t.homeDir,".config","systemd","user",Do)},async install(t){let e=this.configPath(t);await OE(NE(e),{recursive:!0}),await LE(e,this.renderConfig(t),"utf8"),ko.info("systemd unit written",{unitPath:e}),await Oo("systemctl",["--user","daemon-reload"]),await Oo("systemctl",["--user","enable","--now",Do]),ko.info("systemd unit enabled",{unitName:Do})},async uninstall(t){let e=this.configPath(t);await Oo("systemctl",["--user","disable","--now",Do]).catch(r=>ko.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(()=>{}),ko.info("systemd unit removed",{unitPath:e})}}});import{spawn as BE}from"node:child_process";import{join as zE}from"node:path";function Hh(t,e){return new Promise((r,i)=>{let o=BE(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var od,Po,ad,qh=it(()=>{"use strict";Q();od=q("supervisor.taskscheduler"),Po="CozeBridge",ad={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 Zb(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 qx("schtasks",["/Create","/SC","ONLOGON","/TN",Oo,"/TR",r,"/RU",t.userName,"/F"]),o0.info("task scheduler entry created",{task:Oo,logFile:t.logFile})},async uninstall(t){await qx("schtasks",["/Delete","/TN",Oo,"/F"]).catch(e=>o0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),o0.info("task scheduler entry removed",{task:Oo})}}});var jx={};Ko(jx,{buildContext:()=>e2,getSupervisor:()=>Qb,launchdSupervisor:()=>i0,systemdSupervisor:()=>s0,taskSchedulerSupervisor:()=>a0});import{homedir as Yb,userInfo as Xb}from"node:os";function Qb(t=process.platform){switch(t){case"darwin":return i0;case"linux":return s0;case"win32":return a0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function e2(){let t=te();return{nodeBin:process.execPath,entry:Yc(t),logFile:t.logFile,homeDir:Yb(),userName:Xb().username}}var Gx=dt(()=>{"use strict";Me();Qc();Fx();Ux();Hx()});ee();Zt();var q0=H("acp-installer-warmup"),_p=["claude-code","codex"];async function H0(t={}){let e=t.ensure??yn,s=(await Promise.allSettled(_p.map(async a=>{let c=await e(a);q0.info("acp wrapper warmup ok",{framework:a,installed:!!c,path:c??""})}))).filter(a=>a.status==="rejected");s.length>0&&q0.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:s.length,reasons:s.map(a=>String(a.reason))})}Yt();ee();import{readdir as Rp}from"node:fs/promises";import{mkdir as V0,writeFile as J0}from"node:fs/promises";import{join as Yo}from"node:path";var Dp={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Zn(t,e,r){await V0(t,{recursive:!0});let s=Dp[e],a=Yo(t,s);return await J0(a,r??"","utf8"),a}async function Z0(t){let e=Yo(t,".claude");await V0(e,{recursive:!0});let r=Yo(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"),kp=6e4,Op=5*6e4,Gi=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,s;try{s=await Rp(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 Ue(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 Ue(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(l){Je.warn("detail RPC failed, using local data",{agentId:e,err:String(l)});let x=this.retryQueue.get(e),h=x?Math.min(x.currentDelay*2,Op):kp;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});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 Zn(s.workspace,s.framework,s.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var xl=gt(Dd(),1);import{lstat as fc,mkdir as lc,readFile as dl,readdir as iw,rm as sw,stat as ow,writeFile as uc}from"node:fs/promises";import{dirname as aw,join as It,normalize as cw,relative as pc,resolve as xc,sep as fl}from"node:path";import{Readable as ll}from"node:stream";import{pipeline as ul}from"node:stream/promises";import eg from"events";import We from"fs";import{EventEmitter as Za}from"node:events";import lf from"node:stream";import{StringDecoder as tg}from"node:string_decoder";import hf from"node:path";import cr from"node:fs";import{dirname as hg,parse as pg}from"path";import{EventEmitter as Sg}from"events";import ka from"assert";import{Buffer as kn}from"buffer";import*as Ld from"zlib";import vg from"zlib";import{posix as tr}from"node:path";import{basename as Yg}from"node:path";import bs from"fs";import yt from"fs";import qd from"path";import{win32 as cm}from"node:path";import Vd from"path";import Df from"node:fs";import Im from"node:assert";import{randomBytes as Rf}from"node:crypto";import X from"node:fs";import Se from"node:path";import kf from"fs";import ks from"node:fs";import ei from"node:path";import Xe from"node:fs";import Om from"node:fs/promises";import Is from"node:path";import{join as Hf}from"node:path";import Ye from"node:fs";import Kf from"node:path";var Xp=Object.defineProperty,Qp=(t,e)=>{for(var r in e)Xp(t,r,{get:e[r],enumerable:!0})},Rd=typeof process=="object"&&process?process:{stdout:null,stderr:null},ng=t=>!!t&&typeof t=="object"&&(t instanceof Ln||t instanceof lf||rg(t)||ig(t)),rg=t=>!!t&&typeof t=="object"&&t instanceof Za&&typeof t.pipe=="function"&&t.pipe!==lf.Writable.prototype.pipe,ig=t=>!!t&&typeof t=="object"&&t instanceof Za&&typeof t.write=="function"&&typeof t.end=="function",Ot=Symbol("EOF"),Pt=Symbol("maybeEmitEnd"),Qt=Symbol("emittedEnd"),Ji=Symbol("emittingEnd"),Br=Symbol("emittedError"),Zi=Symbol("closed"),kd=Symbol("read"),Yi=Symbol("flush"),Od=Symbol("flushChunk"),ft=Symbol("encoding"),er=Symbol("decoder"),Ce=Symbol("flowing"),zr=Symbol("paused"),sr=Symbol("resume"),Te=Symbol("buffer"),Ge=Symbol("pipes"),De=Symbol("bufferLength"),ra=Symbol("bufferPush"),Xi=Symbol("bufferShift"),qe=Symbol("objectMode"),me=Symbol("destroyed"),ia=Symbol("error"),sa=Symbol("emitData"),Pd=Symbol("emitEnd"),oa=Symbol("emitEnd2"),mt=Symbol("async"),aa=Symbol("abort"),Qi=Symbol("aborted"),Fr=Symbol("signal"),bn=Symbol("dataListeners"),Ze=Symbol("discarded"),Ur=t=>Promise.resolve().then(t),sg=t=>t(),og=t=>t==="end"||t==="finish"||t==="prefinish",ag=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,cg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),uf=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()}},dg=class extends uf{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)}},fg=t=>!!t.objectMode,lg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Ln=class extends Za{[Ce]=!1;[zr]=!1;[Ge]=[];[Te]=[];[qe];[ft];[mt];[er];[Ot]=!1;[Qt]=!1;[Ji]=!1;[Zi]=!1;[Br]=null;[De]=0;[me]=!1;[Fr];[Qi]=!1;[bn]=0;[Ze]=!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");fg(e)?(this[qe]=!0,this[ft]=null):lg(e)?(this[ft]=e.encoding,this[qe]=!1):(this[qe]=!1,this[ft]=null),this[mt]=!!e.async,this[er]=this[ft]?new tg(this[ft]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Te]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ge]});let{signal:r}=e;r&&(this[Fr]=r,r.aborted?this[aa]():r.addEventListener("abort",()=>this[aa]()))}get bufferLength(){return this[De]}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[mt]}set async(t){this[mt]=this[mt]||!!t}[aa](){this[Qi]=!0,this.emit("abort",this[Fr]?.reason),this.destroy(this[Fr]?.reason)}get aborted(){return this[Qi]}set aborted(t){}write(t,e,r){if(this[Qi])return!1;if(this[Ot])throw new Error("write after end");if(this[me])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let s=this[mt]?Ur:sg;if(!this[qe]&&!Buffer.isBuffer(t)){if(cg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(ag(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[Ce]&&this[De]!==0&&this[Yi](!0),this[Ce]?this.emit("data",t):this[ra](t),this[De]!==0&&this.emit("readable"),r&&s(r),this[Ce]):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[Ce]&&this[De]!==0&&this[Yi](!0),this[Ce]?this.emit("data",t):this[ra](t),this[De]!==0&&this.emit("readable"),r&&s(r),this[Ce]):(this[De]!==0&&this.emit("readable"),r&&s(r),this[Ce])}read(t){if(this[me])return null;if(this[Ze]=!1,this[De]===0||t===0||t&&t>this[De])return this[Pt](),null;this[qe]&&(t=null),this[Te].length>1&&!this[qe]&&(this[Te]=[this[ft]?this[Te].join(""):Buffer.concat(this[Te],this[De])]);let e=this[kd](t||null,this[Te][0]);return this[Pt](),e}[kd](t,e){if(this[qe])this[Xi]();else{let r=e;t===r.length||t===null?this[Xi]():typeof r=="string"?(this[Te][0]=r.slice(t),e=r.slice(0,t),this[De]-=t):(this[Te][0]=r.subarray(t),e=r.subarray(0,t),this[De]-=t)}return this.emit("data",e),!this[Te].length&&!this[Ot]&&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[Ot]=!0,this.writable=!1,(this[Ce]||!this[zr])&&this[Pt](),this}[sr](){this[me]||(!this[bn]&&!this[Ge].length&&(this[Ze]=!0),this[zr]=!1,this[Ce]=!0,this.emit("resume"),this[Te].length?this[Yi]():this[Ot]?this[Pt]():this.emit("drain"))}resume(){return this[sr]()}pause(){this[Ce]=!1,this[zr]=!0,this[Ze]=!1}get destroyed(){return this[me]}get flowing(){return this[Ce]}get paused(){return this[zr]}[ra](t){this[qe]?this[De]+=1:this[De]+=t.length,this[Te].push(t)}[Xi](){return this[qe]?this[De]-=1:this[De]-=this[Te][0].length,this[Te].shift()}[Yi](t=!1){do;while(this[Od](this[Xi]())&&this[Te].length);!t&&!this[Te].length&&!this[Ot]&&this.emit("drain")}[Od](t){return this.emit("data",t),this[Ce]}pipe(t,e){if(this[me])return t;this[Ze]=!1;let r=this[Qt];return e=e||{},t===Rd.stdout||t===Rd.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ge].push(e.proxyErrors?new dg(this,t,e):new uf(this,t,e)),this[mt]?Ur(()=>this[sr]()):this[sr]()),t}unpipe(t){let e=this[Ge].find(r=>r.dest===t);e&&(this[Ge].length===1?(this[Ce]&&this[bn]===0&&(this[Ce]=!1),this[Ge]=[]):this[Ge].splice(this[Ge].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[Ze]=!1,this[bn]++,!this[Ge].length&&!this[Ce]&&this[sr]();else if(t==="readable"&&this[De]!==0)super.emit("readable");else if(og(t)&&this[Qt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Br]){let s=e;this[mt]?Ur(()=>s.call(this,this[Br])):s.call(this,this[Br])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[bn]=this.listeners("data").length,this[bn]===0&&!this[Ze]&&!this[Ge].length&&(this[Ce]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[bn]=0,!this[Ze]&&!this[Ge].length&&(this[Ce]=!1)),e}get emittedEnd(){return this[Qt]}[Pt](){!this[Ji]&&!this[Qt]&&!this[me]&&this[Te].length===0&&this[Ot]&&(this[Ji]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Zi]&&this.emit("close"),this[Ji]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==me&&this[me])return!1;if(t==="data")return!this[qe]&&!r?!1:this[mt]?(Ur(()=>this[sa](r)),!0):this[sa](r);if(t==="end")return this[Pd]();if(t==="close"){if(this[Zi]=!0,!this[Qt]&&!this[me])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[Br]=r,super.emit(ia,r);let a=!this[Fr]||this.listeners("error").length?super.emit("error",r):!1;return this[Pt](),a}else if(t==="resume"){let a=super.emit("resume");return this[Pt](),a}else if(t==="finish"||t==="prefinish"){let a=super.emit(t);return this.removeAllListeners(t),a}let s=super.emit(t,...e);return this[Pt](),s}[sa](t){for(let r of this[Ge])r.dest.write(t)===!1&&this.pause();let e=this[Ze]?!1:super.emit("data",t);return this[Pt](),e}[Pd](){return this[Qt]?!1:(this[Qt]=!0,this.readable=!1,this[mt]?(Ur(()=>this[oa]()),!0):this[oa]())}[oa](){if(this[er]){let e=this[er].end();if(e){for(let r of this[Ge])r.dest.write(e);this[Ze]||super.emit("data",e)}}for(let e of this[Ge])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[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(me,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Ze]=!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[Ot])return e();let s,a,c=h=>{this.off("data",f),this.off("end",l),this.off(me,x),e(),a(h)},f=h=>{this.off("error",c),this.off("end",l),this.off(me,x),this.pause(),s({value:h,done:!!this[Ot]})},l=()=>{this.off("error",c),this.off("data",f),this.off(me,x),e(),s({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,m)=>{a=m,s=h,this.once(me,x),this.once("error",c),this.once("end",l),this.once("data",f)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Ze]=!1;let t=!1,e=()=>(this.pause(),this.off(ia,e),this.off(me,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let s=this.read();return s===null?e():{done:!1,value:s}};return this.once("end",e),this.once(ia,e),this.once(me,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[me])return t?this.emit("error",t):this.emit(me),this;this[me]=!0,this[Ze]=!0,this[Te].length=0,this[De]=0;let e=this;return typeof e.close=="function"&&!this[Zi]&&e.close(),t?this.emit("error",t):this.emit(me),this}static get isStream(){return ng}},ug=We.writev,fn=Symbol("_autoClose"),ht=Symbol("_close"),qr=Symbol("_ended"),ie=Symbol("_fd"),ca=Symbol("_finished"),Bt=Symbol("_flags"),da=Symbol("_flush"),Da=Symbol("_handleChunk"),Ra=Symbol("_makeBuf"),Xr=Symbol("_mode"),es=Symbol("_needDrain"),fr=Symbol("_onerror"),lr=Symbol("_onopen"),fa=Symbol("_onread"),or=Symbol("_onwrite"),ln=Symbol("_open"),xt=Symbol("_path"),sn=Symbol("_pos"),wt=Symbol("_queue"),ar=Symbol("_read"),la=Symbol("_readSize"),Mt=Symbol("_reading"),Hr=Symbol("_remain"),ua=Symbol("_size"),fs=Symbol("_write"),Sn=Symbol("_writing"),ls=Symbol("_defaultFlag"),Rn=Symbol("_errored"),Ya=class extends Ln{[Rn]=!1;[ie];[xt];[la];[Mt]=!1;[ua];[Hr];[fn];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Rn]=!1,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[xt]=t,this[la]=e.readSize||16*1024*1024,this[Mt]=!1,this[ua]=typeof e.size=="number"?e.size:1/0,this[Hr]=this[ua],this[fn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ie]=="number"?this[ar]():this[ln]()}get fd(){return this[ie]}get path(){return this[xt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[ln](){We.open(this[xt],"r",(t,e)=>this[lr](t,e))}[lr](t,e){t?this[fr](t):(this[ie]=e,this.emit("open",e),this[ar]())}[Ra](){return Buffer.allocUnsafe(Math.min(this[la],this[Hr]))}[ar](){if(!this[Mt]){this[Mt]=!0;let t=this[Ra]();if(t.length===0)return process.nextTick(()=>this[fa](null,0,t));We.read(this[ie],t,0,t.length,null,(e,r,s)=>this[fa](e,r,s))}}[fa](t,e,r){this[Mt]=!1,t?this[fr](t):this[Da](e,r)&&this[ar]()}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[fr](t){this[Mt]=!0,this[ht](),this.emit("error",t)}[Da](t,e){let r=!1;return this[Hr]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[Hr]<=0)&&(r=!1,this[ht](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ie]=="number"&&this[ar](),!1;case"error":return this[Rn]?!1:(this[Rn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},xg=class extends Ya{[ln](){let t=!0;try{this[lr](null,We.openSync(this[xt],"r")),t=!1}finally{t&&this[ht]()}}[ar](){let t=!0;try{if(!this[Mt]){this[Mt]=!0;do{let e=this[Ra](),r=e.length===0?0:We.readSync(this[ie],e,0,e.length,null);if(!this[Da](r,e))break}while(!0);this[Mt]=!1}t=!1}finally{t&&this[ht]()}}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.closeSync(t),this.emit("close")}}},As=class extends eg{readable=!1;writable=!0;[Rn]=!1;[Sn]=!1;[qr]=!1;[wt]=[];[es]=!1;[xt];[Xr];[fn];[ie];[ls];[Bt];[ca]=!1;[sn];constructor(t,e){e=e||{},super(e),this[xt]=t,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[Xr]=e.mode===void 0?438:e.mode,this[sn]=typeof e.start=="number"?e.start:void 0,this[fn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[sn]!==void 0?"r+":"w";this[ls]=e.flags===void 0,this[Bt]=e.flags===void 0?r:e.flags,this[ie]===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[ie]}get path(){return this[xt]}[fr](t){this[ht](),this[Sn]=!0,this.emit("error",t)}[ln](){We.open(this[xt],this[Bt],this[Xr],(t,e)=>this[lr](t,e))}[lr](t,e){this[ls]&&this[Bt]==="r+"&&t&&t.code==="ENOENT"?(this[Bt]="w",this[ln]()):t?this[fr](t):(this[ie]=e,this.emit("open",e),this[Sn]||this[da]())}end(t,e){return t&&this.write(t,e),this[qr]=!0,!this[Sn]&&!this[wt].length&&typeof this[ie]=="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[ie]===void 0||this[Sn]||this[wt].length?(this[wt].push(t),this[es]=!0,!1):(this[Sn]=!0,this[fs](t),!0)}[fs](t){We.write(this[ie],t,0,t.length,this[sn],(e,r)=>this[or](e,r))}[or](t,e){t?this[fr](t):(this[sn]!==void 0&&typeof e=="number"&&(this[sn]+=e),this[wt].length?this[da]():(this[Sn]=!1,this[qr]&&!this[ca]?(this[ca]=!0,this[ht](),this.emit("finish")):this[es]&&(this[es]=!1,this.emit("drain"))))}[da](){if(this[wt].length===0)this[qr]&&this[or](null,0);else if(this[wt].length===1)this[fs](this[wt].pop());else{let t=this[wt];this[wt]=[],ug(this[ie],t,this[sn],(e,r)=>this[or](e,r))}}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},xf=class extends As{[ln](){let t;if(this[ls]&&this[Bt]==="r+")try{t=We.openSync(this[xt],this[Bt],this[Xr])}catch(e){if(e?.code==="ENOENT")return this[Bt]="w",this[ln]();throw e}else t=We.openSync(this[xt],this[Bt],this[Xr]);this[lr](null,t)}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.closeSync(t),this.emit("close")}}[fs](t){let e=!0;try{this[or](null,We.writeSync(this[ie],t,0,t.length,this[sn])),e=!1}finally{if(e)try{this[ht]()}catch{}}}},gg=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"]]),mg=t=>!!t.sync&&!!t.file,wg=t=>!t.sync&&!!t.file,_g=t=>!!t.sync&&!t.file,yg=t=>!t.sync&&!t.file,Eg=t=>!!t.file,bg=t=>gg.get(t)||t,Xa=(t={})=>{if(!t)return{};let e={};for(let[r,s]of Object.entries(t)){let a=bg(r);e[a]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},ai=(t,e,r,s,a)=>Object.assign((c=[],f,l)=>{Array.isArray(c)&&(f=c,c={}),typeof f=="function"&&(l=f,f=void 0),f=f?Array.from(f):[];let x=Xa(c);if(a?.(x,f),mg(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,f)}else if(wg(x)){let h=e(x,f);return l?h.then(()=>l(),l):h}else if(_g(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,f)}else if(yg(x)){if(typeof l=="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}),Ig=vg.constants||{ZLIB_VERNUM:4736},bt=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},Ig)),Ag=kn.concat,Nd=Object.getOwnPropertyDescriptor(kn,"concat"),Cg=t=>t,xa=Nd?.writable===!0||Nd?.set!==void 0?t=>{kn.concat=t?Cg:Ag}:t=>{},On=Symbol("_superWrite"),ts=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ha=Symbol("flushFlag"),Qa=class extends 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 Ld[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Ld[e](t)}catch(r){throw new ts(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 ts(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ka(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(kn.alloc(0),{[ha]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[On](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;ka(this.#t,"zlib binding closed");let s=this.#t._handle,a=s.close;s.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},xa(!0);let f;try{let x=typeof t[ha]=="number"?t[ha]:this.#r;f=this.#t._processChunk(t,x),xa(!1)}catch(x){xa(!1),this.#o(new ts(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 ts(x,this.write)));let l;if(f)if(Array.isArray(f)&&f.length>0){let x=f[0];l=this[On](kn.from(x));for(let h=1;h<f.length;h++)l=this[On](f[h])}else l=this[On](kn.from(f));return r&&r(),l}},pf=class extends Qa{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||bt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||bt.Z_FINISH,t.fullFlushFlag=bt.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(bt.Z_SYNC_FLUSH),ka(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(s,a)=>{typeof s=="function"&&(a=s,s=this.flushFlag),this.flush(s),a?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},Tg=class extends pf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[On](t){return this.#e?(this.#e=!1,t[9]=255,super[On](t)):super[On](t)}},Dg=class extends pf{constructor(t){super(t,"Unzip")}},gf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||bt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||bt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=bt.BROTLI_OPERATION_FLUSH,super(t,e)}},Rg=class extends gf{constructor(t){super(t,"BrotliCompress")}},kg=class extends gf{constructor(t){super(t,"BrotliDecompress")}},mf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||bt.ZSTD_e_continue,t.finishFlush=t.finishFlush||bt.ZSTD_e_end,t.fullFlushFlag=bt.ZSTD_e_flush,super(t,e)}},Og=class extends mf{constructor(t){super(t,"ZstdCompress")}},Pg=class extends mf{constructor(t){super(t,"ZstdDecompress")}},Lg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Mg(t,e):Ng(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Ng=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Mg=(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]=wf(a):a===0?e[s-1]=0:(r=!0,e[s-1]=_f(a))}},Bg=t=>{let e=t[0],r=e===128?Fg(t.subarray(1,t.length)):e===255?zg(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},zg=t=>{for(var e=t.length,r=0,s=!1,a=e-1;a>-1;a--){var c=Number(t[a]),f;s?f=wf(c):c===0?f=c:(s=!0,f=_f(c)),f!==0&&(r-=f*Math.pow(256,e-a-1))}return r},Fg=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},wf=t=>(255^t)&255,_f=t=>(255^t)+1&255,Ug={};Qp(Ug,{code:()=>ec,isCode:()=>us,isName:()=>qg,name:()=>Cs});var us=t=>Cs.has(t),qg=t=>ec.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"]]),ec=new Map(Array.from(Cs).map(t=>[t[1],t[0]])),Pn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,s){Buffer.isBuffer(t)?this.decode(t,e||0,r,s):t&&this.#n(t)}decode(t,e,r,s){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??vn(t,e,100),this.mode=r?.mode??s?.mode??on(t,e+100,8),this.uid=r?.uid??s?.uid??on(t,e+108,8),this.gid=r?.gid??s?.gid??on(t,e+116,8),this.size=r?.size??s?.size??on(t,e+124,12),this.mtime=r?.mtime??s?.mtime??pa(t,e+136,12),this.cksum=on(t,e+148,12),s&&this.#n(s,!0),r&&this.#n(r);let a=vn(t,e+156,1);if(us(a)&&(this.#e=a||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=vn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??s?.uname??vn(t,e+265,32),this.gname=r?.gname??s?.gname??vn(t,e+297,32),this.devmaj=r?.devmaj??s?.devmaj??on(t,e+329,8)??0,this.devmin=r?.devmin??s?.devmin??on(t,e+337,8)??0,t[e+475]!==0){let f=vn(t,e+345,155);this.path=f+"/"+this.path}else{let f=vn(t,e+345,130);f&&(this.path=f+"/"+this.path),this.atime=r?.atime??s?.atime??pa(t,e+476,12),this.ctime=r?.ctime??s?.ctime??pa(t,e+488,12)}let c=256;for(let f=e;f<e+148;f++)c+=t[f];for(let f=e+156;f<e+512;f++)c+=t[f];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,s=Hg(this.path||"",r),a=s[0],c=s[1];this.needPax=!!s[2],this.needPax=In(t,e,100,a)||this.needPax,this.needPax=an(t,e+100,8,this.mode)||this.needPax,this.needPax=an(t,e+108,8,this.uid)||this.needPax,this.needPax=an(t,e+116,8,this.gid)||this.needPax,this.needPax=an(t,e+124,12,this.size)||this.needPax,this.needPax=ga(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=In(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=In(t,e+265,32,this.uname)||this.needPax,this.needPax=In(t,e+297,32,this.gname)||this.needPax,this.needPax=an(t,e+329,8,this.devmaj)||this.needPax,this.needPax=an(t,e+337,8,this.devmin)||this.needPax,this.needPax=In(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=In(t,e+345,155,c)||this.needPax:(this.needPax=In(t,e+345,130,c)||this.needPax,this.needPax=ga(t,e+476,12,this.atime)||this.needPax,this.needPax=ga(t,e+488,12,this.ctime)||this.needPax);let f=256;for(let l=e;l<e+148;l++)f+=t[l];for(let l=e+156;l<e+512;l++)f+=t[l];return this.cksum=f,an(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(ec.get(t));if(us(e)||e==="Unsupported")this.#e=e;else if(us(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Hg=(t,e)=>{let r=t,s="",a,c=tr.parse(t).root||".";if(Buffer.byteLength(r)<100)a=[r,s,!1];else{s=tr.dirname(r),r=tr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(s)<=e?a=[r,s,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(s)<=e?a=[r.slice(0,99),s,!0]:(r=tr.join(tr.basename(s),r),s=tr.dirname(s));while(s!==c&&a===void 0);a||(a=[t.slice(0,99),"",!0])}return a},vn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),pa=(t,e,r)=>jg(on(t,e,r)),jg=t=>t===void 0?void 0:new Date(t*1e3),on=(t,e,r)=>Number(t[e])&128?Bg(t.subarray(e,e+r)):Kg(t,e,r),Gg=t=>isNaN(t)?void 0:t,Kg=(t,e,r)=>Gg(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Wg={12:8589934591,8:2097151},an=(t,e,r,s)=>s===void 0?!1:s>Wg[r]||s<0?(Lg(s,t.subarray(e,e+r)),!0):($g(t,e,r,s),!1),$g=(t,e,r,s)=>t.write(Vg(s,r),e,r,"ascii"),Vg=(t,e)=>Jg(Math.floor(t).toString(8),e),Jg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",ga=(t,e,r,s)=>s===void 0?!1:an(t,e,r,s.getTime()/1e3),Zg=new Array(156).join("\0"),In=(t,e,r,s)=>s===void 0?!1:(t.write(s+Zg,e,r,"utf8"),s.length!==Buffer.byteLength(s)||s.length>r),Es=class yf{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),s=512*Math.ceil(1+r/512),a=Buffer.allocUnsafe(s);for(let c=0;c<512;c++)a[c]=0;new Pn({path:("PaxHeader/"+Yg(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(
|
|
82
|
-
`).reduce(em,Object.create(null)),em=(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},tm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=tm!=="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=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,s=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,s-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e))))}},Ts=(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))},nm=1024*1024,Oa=Buffer.from([31,139]),Pa=Buffer.from([40,181,47,253]),rm=Math.max(Oa.length,Pa.length),nt=Symbol("state"),An=Symbol("writeEntry"),Lt=Symbol("readEntry"),ma=Symbol("nextEntry"),Md=Symbol("processEntry"),_t=Symbol("extendedHeader"),jr=Symbol("globalExtendedHeader"),en=Symbol("meta"),Bd=Symbol("emitMeta"),ce=Symbol("buffer"),Nt=Symbol("queue"),tn=Symbol("ended"),wa=Symbol("emittedEnd"),Cn=Symbol("emit"),ye=Symbol("unzip"),ns=Symbol("consumeChunk"),rs=Symbol("consumeChunkSub"),_a=Symbol("consumeBody"),zd=Symbol("consumeMeta"),Fd=Symbol("consumeHeader"),Gr=Symbol("consuming"),ya=Symbol("bufferConcat"),is=Symbol("maybeEnd"),nr=Symbol("writing"),nn=Symbol("aborted"),ss=Symbol("onDone"),Tn=Symbol("sawValidEntry"),os=Symbol("sawNullBlock"),as=Symbol("sawEOF"),Ud=Symbol("closeStream"),im=()=>!0,oi=class extends Sg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Nt]=[];[ce];[Lt];[An];[nt]="begin";[en]="";[_t];[jr];[tn]=!1;[ye];[nn]=!1;[Tn];[os]=!1;[as]=!1;[nr]=!1;[Gr]=!1;[wa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(ss,()=>{(this[nt]==="begin"||this[Tn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(ss,t.ondone):this.on(ss,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||nm,this.filter=typeof t.filter=="function"?t.filter:im;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[Ud]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ts(this,t,e,r)}[Fd](t,e){this[Tn]===void 0&&(this[Tn]=!1);let r;try{r=new Pn(t,e,this[_t],this[jr])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(r.nullBlock)this[os]?(this[as]=!0,this[nt]==="begin"&&(this[nt]="header"),this[Cn]("eof")):(this[os]=!0,this[Cn]("nullBlock"));else if(this[os]=!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[An]=new Ef(r,this[_t],this[jr]);if(!this[Tn])if(a.remain){let c=()=>{a.invalid||(this[Tn]=!0)};a.on("end",c)}else this[Tn]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[Cn]("ignoredEntry",a),this[nt]="ignore",a.resume()):a.size>0&&(this[en]="",a.on("data",c=>this[en]+=c),this[nt]="meta"):(this[_t]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[Cn]("ignoredEntry",a),this[nt]=a.remain?"ignore":"header",a.resume()):(a.remain?this[nt]="body":(this[nt]="header",a.end()),this[Lt]?this[Nt].push(a):(this[Nt].push(a),this[ma]())))}}}[Ud](){queueMicrotask(()=>this.emit("close"))}[Md](t){let e=!0;if(!t)this[Lt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...s]=t;this.emit(r,...s)}else this[Lt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ma]()),e=!1);return e}[ma](){do;while(this[Md](this[Nt].shift()));if(this[Nt].length===0){let t=this[Lt];!t||t.flowing||t.size===t.remain?this[nr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[_a](t,e){let r=this[An];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[nt]="header",this[An]=void 0,r.end()),a.length}[zd](t,e){let r=this[An],s=this[_a](t,e);return!this[An]&&r&&this[Bd](r),s}[Cn](t,e,r){this[Nt].length===0&&!this[Lt]?this.emit(t,e,r):this[Nt].push([t,e,r])}[Bd](t){switch(this[Cn]("meta",this[en]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[_t]=Es.parse(this[en],this[_t],!1);break;case"GlobalExtendedHeader":this[jr]=Es.parse(this[en],this[jr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[_t]??Object.create(null);this[_t]=e,e.path=this[en].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[_t]||Object.create(null);this[_t]=e,e.linkpath=this[en].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[nn]=!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[nn])return r?.(),!1;if((this[ye]===void 0||this.brotli===void 0&&this[ye]===!1)&&t){if(this[ce]&&(t=Buffer.concat([this[ce],t]),this[ce]=void 0),t.length<rm)return this[ce]=t,r?.(),!0;for(let f=0;this[ye]===void 0&&f<Oa.length;f++)t[f]!==Oa[f]&&(this[ye]=!1);let a=!1;if(this[ye]===!1&&this.zstd!==!1){a=!0;for(let f=0;f<Pa.length;f++)if(t[f]!==Pa[f]){a=!1;break}}let c=this.brotli===void 0&&!a;if(this[ye]===!1&&c)if(t.length<512)if(this[tn])this.brotli=!0;else return this[ce]=t,r?.(),!0;else try{new Pn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ye]===void 0||this[ye]===!1&&(this.brotli||a)){let f=this[tn];this[tn]=!1,this[ye]=this[ye]===void 0?new Dg({}):a?new Pg({}):new kg({}),this[ye].on("data",x=>this[ns](x)),this[ye].on("error",x=>this.abort(x)),this[ye].on("end",()=>{this[tn]=!0,this[ns]()}),this[nr]=!0;let l=!!this[ye][f?"end":"write"](t);return this[nr]=!1,r?.(),l}}this[nr]=!0,this[ye]?this[ye].write(t):this[ns](t),this[nr]=!1;let s=this[Nt].length>0?!1:this[Lt]?this[Lt].flowing:!0;return!s&&this[Nt].length===0&&this[Lt]?.once("drain",()=>this.emit("drain")),r?.(),s}[ya](t){t&&!this[nn]&&(this[ce]=this[ce]?Buffer.concat([this[ce],t]):t)}[is](){if(this[tn]&&!this[wa]&&!this[nn]&&!this[Gr]){this[wa]=!0;let t=this[An];if(t&&t.blockRemain){let e=this[ce]?this[ce].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ce]&&t.write(this[ce]),t.end()}this[Cn](ss)}}[ns](t){if(this[Gr]&&t)this[ya](t);else if(!t&&!this[ce])this[is]();else if(t){if(this[Gr]=!0,this[ce]){this[ya](t);let e=this[ce];this[ce]=void 0,this[rs](e)}else this[rs](t);for(;this[ce]&&this[ce]?.length>=512&&!this[nn]&&!this[as];){let e=this[ce];this[ce]=void 0,this[rs](e)}this[Gr]=!1}(!this[ce]||this[tn])&&this[is]()}[rs](t){let e=0,r=t.length;for(;e+512<=r&&!this[nn]&&!this[as];)switch(this[nt]){case"begin":case"header":this[Fd](t,e),e+=512;break;case"ignore":case"body":e+=this[_a](t,e);break;case"meta":e+=this[zd](t,e);break;default:throw new Error("invalid state: "+this[nt])}e<r&&(this[ce]=this[ce]?Buffer.concat([t.subarray(e),this[ce]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[nn]||(this[ye]?(t&&this[ye].write(t),this[ye].end()):(this[tn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[is]())),this}},Qr=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)},sm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},bf=(t,e)=>{let r=new Map(e.map(c=>[Qr(c),!0])),s=t.filter,a=(c,f="")=>{let l=f||pg(c).root||".",x;if(c===l)x=!1;else{let h=r.get(c);x=h!==void 0?h:a(hg(c),l)}return r.set(c,x),x};t.filter=s?(c,f)=>s(c,f)&&a(Qr(c)):c=>a(Qr(c))},om=t=>{let e=new oi(t),r=t.file,s;try{s=cr.openSync(r,"r");let a=cr.fstatSync(s),c=t.maxReadSize||16*1024*1024;if(a.size<c){let f=Buffer.allocUnsafe(a.size),l=cr.readSync(s,f,0,a.size,0);e.end(l===f.byteLength?f:f.subarray(0,l))}else{let f=0,l=Buffer.allocUnsafe(c);for(;f<a.size;){let x=cr.readSync(s,l,0,c,f);if(x===0)break;f+=x,e.write(l.subarray(0,x))}e.end()}}finally{if(typeof s=="number")try{cr.closeSync(s)}catch{}}},am=(t,e)=>{let r=new oi(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("end",c),cr.stat(a,(l,x)=>{if(l)f(l);else{let h=new Ya(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},ur=ai(om,am,t=>new oi(t),t=>new oi(t),(t,e)=>{e?.length&&bf(t,e),t.noResume||sm(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:dm,parse:Hd}=cm,tc=t=>{let e="",r=Hd(t);for(;dm(t)||r.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(s.length),e+=s,r=Hd(t)}return[e,t]},Ds=["|","<",">","?",":"],nc=Ds.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),fm=new Map(Ds.map((t,e)=>[t,nc[e]])),lm=new Map(nc.map((t,e)=>[t,Ds[e]])),jd=t=>Ds.reduce((e,r)=>e.split(r).join(fm.get(r)),t),um=t=>nc.reduce((e,r)=>e.split(r).join(lm.get(r)),t),vf=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),Qr(e)+"/"+t):Z(t),xm=16*1024*1024,Gd=Symbol("process"),Kd=Symbol("file"),Wd=Symbol("directory"),La=Symbol("symlink"),$d=Symbol("hardlink"),Kr=Symbol("header"),xs=Symbol("read"),Na=Symbol("lstat"),hs=Symbol("onlstat"),Ma=Symbol("onread"),Ba=Symbol("onreadlink"),za=Symbol("openfile"),Fa=Symbol("onopenfile"),cn=Symbol("close"),Ss=Symbol("mode"),Ua=Symbol("awaitDrain"),Ea=Symbol("ondrain"),Et=Symbol("prefix"),If=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=Xa(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||xm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let s=!1;if(!this.preservePaths){let[c,f]=tc(this.path);c&&typeof f=="string"&&(this.path=f,s=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=um(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||qd.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[hs](a):this[Na]()}warn(t,e,r={}){return Ts(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Na](){yt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[hs](e)})}[hs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=gm(t),this.emit("stat",t),this[Gd]()}[Gd](){switch(this.type){case"File":return this[Kd]();case"Directory":return this[Wd]();case"SymbolicLink":return this[La]();default:return this.end()}}[Ss](t){return Sf(t,this.type==="Directory",this.portable)}[Et](t){return vf(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 Pn({path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,mode:this[Ss](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Es({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[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)}[Wd](){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()}[La](){yt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ba](e)})}[Ba](t){this.linkpath=Z(t),this[Kr](),this.end()}[$d](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(qd.relative(this.cwd,t)),this.stat.size=0,this[Kr](),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[$d](e);this.linkCache.set(t,this.absolute)}if(this[Kr](),this.stat.size===0)return this.end();this[za]()}[za](){yt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Fa](e)})}[Fa](t){if(this.fd=t,this.#e)return this[cn]();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:s,pos:a}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");yt.read(t,e,r,s,a,(c,f)=>{if(c)return this[cn](()=>this.emit("error",c));this[Ma](f)})}[cn](t=()=>{}){this.fd!==void 0&&yt.close(this.fd,t)}[Ma](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[cn](()=>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[cn](()=>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[Ea]():this[Ua](()=>this[Ea]())}[Ua](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let s=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Ea](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[cn](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]()}},hm=class extends If{sync=!0;[Na](){this[hs](yt.lstatSync(this.absolute))}[La](){this[Ba](yt.readlinkSync(this.absolute))}[za](){this[Fa](yt.openSync(this.absolute,"r"))}[xs](){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=yt.readSync(e,r,s,a,c);this[Ma](f),t=!1}finally{if(t)try{this[cn](()=>{})}catch{}}}[Ua](t){t()}[cn](t=()=>{}){this.fd!==void 0&&yt.closeSync(this.fd),t()}},pm=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 Ts(this,t,e,r)}constructor(t,e={}){let r=Xa(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:s}=t;if(s==="Unsupported")throw new Error("writing entry that should be ignored");this.type=s,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Z(t.path),this.mode=t.mode!==void 0?this[Ss](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let a=!1;if(!this.preservePaths){let[f,l]=tc(this.path);f&&typeof l=="string"&&(this.path=l,a=f)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Pn({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 Es({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[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 vf(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 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}},gm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",mm=class dr{tail;head;length=0;static create(e=[]){return new dr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,s=e.prev;return r&&(r.prev=s),s&&(s.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=s),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,s=e.length;r<s;r++)_m(this,e[r]);return this.length}unshift(...e){for(var r=0,s=e.length;r<s;r++)ym(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let s=this.head,a=0;s;a++)e.call(r,s.value,a,this),s=s.next}forEachReverse(e,r){r=r||this;for(let s=this.tail,a=this.length-1;s;a--)e.call(r,s.value,a,this),s=s.prev}get(e){let r=0,s=this.head;for(;s&&r<e;r++)s=s.next;if(r===e&&s)return s.value}getReverse(e){let r=0,s=this.tail;for(;s&&r<e;r++)s=s.prev;if(r===e&&s)return s.value}map(e,r){r=r||this;let s=new dr;for(let a=this.head;a;)s.push(e.call(r,a.value,this)),a=a.next;return s}mapReverse(e,r){r=r||this;var s=new dr;for(let a=this.tail;a;)s.push(e.call(r,a.value,this)),a=a.prev;return s}reduce(e,r){let s,a=this.head;if(arguments.length>1)s=r;else if(this.head)a=this.head.next,s=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;a;c++)s=e(s,a.value,c),a=a.next;return s}reduceReverse(e,r){let s,a=this.tail;if(arguments.length>1)s=r;else if(this.tail)a=this.tail.prev,s=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;a;c--)s=e(s,a.value,c),a=a.prev;return s}toArray(){let e=new Array(this.length);for(let r=0,s=this.head;s;r++)e[r]=s.value,s=s.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,s=this.tail;s;r++)e[r]=s.value,s=s.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.head,c=0;for(c=0;a&&c<e;c++)a=a.next;for(;a&&c<r;c++,a=a.next)s.push(a.value);return s}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.length,c=this.tail;for(;c&&a>r;a--)c=c.prev;for(;c&&a>e;a--,c=c.prev)s.push(c.value);return s}splice(e,r=0,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let a=this.head;for(let f=0;a&&f<e;f++)a=a.next;let c=[];for(let f=0;a&&f<r;f++)c.push(a.value),a=this.removeNode(a);a?a!==this.tail&&(a=a.prev):a=this.tail;for(let f of s)a=wm(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 wm(t,e,r){let s=e,a=e?e.next:t.head,c=new rc(r,s,a,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function _m(t,e){t.tail=new rc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function ym(t,e){t.head=new rc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var rc=class{list;next;prev;value;constructor(t,e,r,s){this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},Jd=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Zd=Buffer.alloc(1024),ps=Symbol("onStat"),Wr=Symbol("ended"),lt=Symbol("queue"),$r=Symbol("queue"),rn=Symbol("current"),Dn=Symbol("process"),Vr=Symbol("processing"),cs=Symbol("processJob"),ut=Symbol("jobs"),ba=Symbol("jobDone"),gs=Symbol("addFSEntry"),Yd=Symbol("addTarEntry"),qa=Symbol("stat"),Ha=Symbol("readdir"),ms=Symbol("onreaddir"),ws=Symbol("pipe"),Xd=Symbol("entry"),Sa=Symbol("entryOpt"),_s=Symbol("writeEntryClass"),Af=Symbol("write"),va=Symbol("ondrain"),Rs=class extends Ln{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[_s];onWriteEntry;[lt];[$r]=new Map;[ut]=0;[Vr]=!1;[Wr]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[_s]=If,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 Tg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Rg(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Og(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[va]()),this.on("resume",()=>e.resume())}else this.on("drain",this[va]);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[lt]=new mm,this[ut]=0,this.jobs=Number(t.jobs)||4,this[Vr]=!1,this[Wr]=!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[Wr]=!0,this[Dn](),r&&r(),this}write(t){if(this[Wr])throw new Error("write after end");return t instanceof Ef?this[Yd](t):this[gs](t),this.flowing}[Yd](t){let e=Z(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 pm(t,this[Sa](r)),r.entry.on("end",()=>this[ba](r)),this[ut]+=1,this[lt].push(r)}this[Dn]()}[gs](t){let e=Z(Vd.resolve(this.cwd,t));this[lt].push(new Jd(t,e)),this[Dn]()}[qa](t){t.pending=!0,this[ut]+=1;let e=this.follow?"stat":"lstat";bs[e](t.absolute,(r,s)=>{t.pending=!1,this[ut]-=1,r?this.emit("error",r):this[ps](t,s)})}[ps](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[rn])this[cs](t);else{let r=`${e.dev}:${e.ino}`,s=this[$r].get(r);s?s.push(t):this[$r].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Dn]()}[Ha](t){t.pending=!0,this[ut]+=1,bs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[ut]-=1,e)return this.emit("error",e);this[ms](t,r)})}[ms](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Dn]()}[Dn](){if(!this[Vr]){this[Vr]=!0;for(let t=this[lt].head;t&&this[ut]<this.jobs;t=t.next)if(this[cs](t.value),t.value.ignore){let e=t.next;this[lt].removeNode(t),t.next=e}this[Vr]=!1,this[Wr]&&this[lt].length===0&&this[ut]===0&&(this.zip?this.zip.end(Zd):(super.write(Zd),super.end()))}}get[rn](){return this[lt]&&this[lt].head&&this[lt].head.value}[ba](t){this[lt].shift(),this[ut]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,s=this[$r].get(r);if(s){this[$r].delete(r);for(let a of s)a.pending=!1,this[cs](a)}}this[Dn]()}[cs](t){if(t.pending&&t.pendingLink&&t===this[rn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[rn]&&!t.piped&&this[ws](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[ps](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[ms](t,e):this[Ha](t),!t.readdir)return}if(t.entry=this[Xd](t),!t.entry){t.ignore=!0;return}t===this[rn]&&!t.piped&&this[ws](t)}}}[Sa](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}}[Xd](t){this[ut]+=1;try{return new this[_s](t.path,this[Sa](t)).on("end",()=>this[ba](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[va](){this[rn]&&this[rn].entry&&this[rn].entry.resume()}[ws](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[gs](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={}){Ts(this,t,e,r)}},ic=class extends Rs{sync=!0;constructor(t){super(t),this[_s]=hm}pause(){}resume(){}[qa](t){let e=this.follow?"statSync":"lstatSync";this[ps](t,bs[e](t.absolute))}[Ha](t){this[ms](t,bs.readdirSync(t.absolute))}[ws](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[gs](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)})}},Em=(t,e)=>{let r=new ic(t),s=new xf(t.file,{mode:t.mode||438});r.pipe(s),Cf(r,e)},bm=(t,e)=>{let r=new Rs(t),s=new As(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 Tf(r,e).catch(c=>r.emit("error",c)),a},Cf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:hf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Tf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:hf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(r);t.end()},Sm=(t,e)=>{let r=new ic(t);return Cf(r,e),r},vm=(t,e)=>{let r=new Rs(t);return Tf(r,e).catch(s=>r.emit("error",s)),r},AS=ai(Em,bm,Sm,vm,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Am=process.env.__FAKE_PLATFORM__||process.platform,Of=Am==="win32",{O_CREAT:Pf,O_NOFOLLOW:Qd,O_TRUNC:Lf,O_WRONLY:Nf}=kf.constants,Mf=Number(process.env.__FAKE_FS_O_FILENAME__)||kf.constants.UV_FS_O_FILEMAP||0,Cm=Of&&!!Mf,Tm=512*1024,Dm=Mf|Lf|Pf|Nf,ef=!Of&&typeof Qd=="number"?Qd|Lf|Pf|Nf:null,Bf=ef!==null?()=>ef:Cm?t=>t<Tm?Dm:"w":()=>"w",ja=(t,e,r)=>{try{return ks.lchownSync(t,e,r)}catch(s){if(s?.code!=="ENOENT")throw s}},vs=(t,e,r,s)=>{ks.lchown(t,e,r,a=>{s(a&&a?.code!=="ENOENT"?a:null)})},Rm=(t,e,r,s,a)=>{if(e.isDirectory())zf(ei.resolve(t,e.name),r,s,c=>{if(c)return a(c);let f=ei.resolve(t,e.name);vs(f,r,s,a)});else{let c=ei.resolve(t,e.name);vs(c,r,s,a)}},zf=(t,e,r,s)=>{ks.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 vs(t,e,r,s);let f=c.length,l=null,x=h=>{if(!l){if(h)return s(l=h);if(--f===0)return vs(t,e,r,s)}};for(let h of c)Rm(t,h,e,r,x)})},km=(t,e,r,s)=>{e.isDirectory()&&Ff(ei.resolve(t,e.name),r,s),ja(ei.resolve(t,e.name),r,s)},Ff=(t,e,r)=>{let s;try{s=ks.readdirSync(t,{withFileTypes:!0})}catch(a){let c=a;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return ja(t,e,r);throw c}for(let a of s)km(t,a,e,r);return ja(t,e,r)},Uf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Os=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Pm=(t,e)=>{Xe.stat(t,(r,s)=>{(r||!s.isDirectory())&&(r=new Uf(t,r?.code||"ENOTDIR")),e(r)})},Lm=(t,e,r)=>{t=Z(t);let s=e.umask??18,a=e.mode|448,c=(a&s)!==0,f=e.uid,l=e.gid,x=typeof f=="number"&&typeof l=="number"&&(f!==e.processUid||l!==e.processGid),h=e.preserve,m=e.unlink,E=Z(e.cwd),C=(y,v)=>{y?r(y):v&&x?zf(v,f,l,I=>C(I)):c?Xe.chmod(t,a,r):r()};if(t===E)return Pm(t,C);if(h)return Om.mkdir(t,{mode:a,recursive:!0}).then(y=>C(null,y??void 0),C);let _=Z(Is.relative(E,t)).split("/");Ga(E,_,a,m,E,void 0,C)},Ga=(t,e,r,s,a,c,f)=>{if(e.length===0)return f(null,c);let l=e.shift(),x=Z(Is.resolve(t+"/"+l));Xe.mkdir(x,r,qf(x,e,r,s,a,c,f))},qf=(t,e,r,s,a,c,f)=>l=>{l?Xe.lstat(t,(x,h)=>{if(x)x.path=x.path&&Z(x.path),f(x);else if(h.isDirectory())Ga(t,e,r,s,a,c,f);else if(s)Xe.unlink(t,m=>{if(m)return f(m);Xe.mkdir(t,r,qf(t,e,r,s,a,c,f))});else{if(h.isSymbolicLink())return f(new Os(t,t+"/"+e.join("/")));f(l)}}):(c=c||t,Ga(t,e,r,s,a,c,f))},Nm=t=>{let e=!1,r;try{e=Xe.statSync(t).isDirectory()}catch(s){r=s?.code}finally{if(!e)throw new Uf(t,r??"ENOTDIR")}},Mm=(t,e)=>{t=Z(t);let r=e.umask??18,s=e.mode|448,a=(s&r)!==0,c=e.uid,f=e.gid,l=typeof c=="number"&&typeof f=="number"&&(c!==e.processUid||f!==e.processGid),x=e.preserve,h=e.unlink,m=Z(e.cwd),E=y=>{y&&l&&Ff(y,c,f),a&&Xe.chmodSync(t,s)};if(t===m)return Nm(m),E();if(x)return E(Xe.mkdirSync(t,{mode:s,recursive:!0})??void 0);let C=Z(Is.relative(m,t)).split("/"),_;for(let y=C.shift(),v=m;y&&(v+="/"+y);y=C.shift()){v=Z(Is.resolve(v));try{Xe.mkdirSync(v,s),_=_||v}catch{let I=Xe.lstatSync(v);if(I.isDirectory())continue;if(h){Xe.unlinkSync(v),Xe.mkdirSync(v,s),_=_||v;continue}else if(I.isSymbolicLink())return new Os(v,v+"/"+C.join("/"))}}return E(_)},Ia=Object.create(null),tf=1e4,rr=new Set,Bm=t=>{rr.has(t)?rr.delete(t):Ia[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),rr.add(t);let e=Ia[t],r=rr.size-tf;if(r>tf/10){for(let s of rr)if(rr.delete(s),delete Ia[s],--r<=0)break}return e},zm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Fm=zm==="win32",Um=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let s=e.at(-1);return s!==void 0&&(r=Hf(s,r)),e.push(r||"/"),e},[]),qm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Fm?["win32 parallelization disabled"]:t.map(s=>Qr(Hf(Bm(s))));let r=new Set(t.map(s=>Um(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 l=f[1];if(!l){this.#e.delete(c);continue}if(f.shift(),typeof l=="function")a.add(l);else for(let x of l)a.add(x)}for(let c of s){let f=this.#e.get(c),l=f?.[0];if(!(!f||!(l instanceof Set)))if(l.size===1&&f.length===1){this.#e.delete(c);continue}else if(l.size===1){f.shift();let x=f[0];typeof x=="function"&&a.add(x)}else l.delete(t)}return this.#r.delete(t),a.forEach(c=>this.#i(c)),!0}},Hm=()=>process.umask(),nf=Symbol("onEntry"),Ka=Symbol("checkFs"),rf=Symbol("checkFs2"),Wa=Symbol("isReusable"),rt=Symbol("makeFs"),$a=Symbol("file"),Va=Symbol("directory"),ys=Symbol("link"),sf=Symbol("symlink"),of=Symbol("hardlink"),Yr=Symbol("ensureNoSymlink"),af=Symbol("unsupported"),cf=Symbol("checkPath"),Aa=Symbol("stripAbsolutePath"),dn=Symbol("mkdir"),Re=Symbol("onError"),ds=Symbol("pending"),df=Symbol("pend"),ir=Symbol("unpend"),Ca=Symbol("ended"),Ta=Symbol("maybeClose"),Ja=Symbol("skip"),ti=Symbol("doChown"),ni=Symbol("uid"),ri=Symbol("gid"),ii=Symbol("checkedCwd"),jm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,si=jm==="win32",Gm=1024,Km=(t,e)=>{if(!si)return X.unlink(t,e);let r=t+".DELETE."+Rf(16).toString("hex");X.rename(t,r,s=>{if(s)return e(s);X.unlink(r,e)})},Wm=t=>{if(!si)return X.unlinkSync(t);let e=t+".DELETE."+Rf(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},ff=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,sc=class extends oi{[Ca]=!1;[ii]=!1;[ds]=0;reservations=new qm;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[Ta]()},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:Gm,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||si,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Se.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Hm():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[nf](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Ta](){this[Ca]&&this[ds]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Aa](t,e){let r=t[e],{type:s}=t;if(!r||this.preservePaths)return!0;let[a,c]=tc(r),f=c.replaceAll(/\\/g,"/").split("/");if(f.includes("..")||si&&/^[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 l=Se.posix.dirname(t.path),x=Se.posix.normalize(Se.posix.join(l,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}[cf](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let s=Z(String(t.linkpath)).split("/");if(s.length>=this.strip)t.linkpath=s.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Aa](t,"path")||!this[Aa](t,"linkpath"))return!1;if(t.absolute=Se.isAbsolute(t.path)?Z(Se.resolve(t.path)):Z(Se.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:s}=Se.win32.parse(String(t.absolute));t.absolute=s+jd(String(t.absolute).slice(s.length));let{root:a}=Se.win32.parse(t.path);t.path=a+jd(t.path.slice(a.length))}return!0}[nf](t){if(!this[cf](t))return t.resume();switch(Im.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[af](t)}}[Re](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[ir](),e.resume())}[dn](t,e,r){Lm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[ti](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}[ni](t){return ff(this.uid,t.uid,this.processUid)}[ri](t){return ff(this.gid,t.gid,this.processGid)}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new As(String(t.absolute),{flags:Bf(t.size),mode:r,autoClose:!1});s.on("error",l=>{s.fd&&X.close(s.fd,()=>{}),s.write=()=>!0,this[Re](l,t),e()});let a=1,c=l=>{if(l){s.fd&&X.close(s.fd,()=>{}),this[Re](l,t),e();return}--a===0&&s.fd!==void 0&&X.close(s.fd,x=>{x?this[Re](x,t):this[ir](),e()})};s.on("finish",()=>{let l=String(t.absolute),x=s.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){a++;let h=t.atime||new Date,m=t.mtime;X.futimes(x,h,m,E=>E?X.utimes(l,h,m,C=>c(C&&E)):c())}if(typeof x=="number"&&this[ti](t)){a++;let h=this[ni](t),m=this[ri](t);typeof h=="number"&&typeof m=="number"&&X.fchown(x,h,m,E=>E?X.chown(l,h,m,C=>c(C&&E)):c())}c()});let f=this.transform&&this.transform(t)||t;f!==t&&(f.on("error",l=>{this[Re](l,t),e()}),t.pipe(f)),f.pipe(s)}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[dn](String(t.absolute),r,s=>{if(s){this[Re](s,t),e();return}let a=1,c=()=>{--a===0&&(e(),this[ir](),t.resume())};t.mtime&&!this.noMtime&&(a++,X.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ti](t)&&(a++,X.chown(String(t.absolute),Number(this[ni](t)),Number(this[ri](t)),c)),c()})}[af](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[sf](t,e){let r=Z(Se.relative(this.cwd,Se.resolve(Se.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Yr](t,this.cwd,r,()=>this[ys](t,String(t.linkpath),"symlink",e),s=>{this[Re](s,t),e()})}[of](t,e){let r=Z(Se.resolve(this.cwd,String(t.linkpath))),s=Z(String(t.linkpath)).split("/");this[Yr](t,this.cwd,s,()=>this[ys](t,r,"link",e),a=>{this[Re](a,t),e()})}[Yr](t,e,r,s,a){let c=r.shift();if(this.preservePaths||c===void 0)return s();let f=Se.resolve(e,c);X.lstat(f,(l,x)=>{if(l)return s();if(x?.isSymbolicLink())return a(new Os(f,Se.resolve(f,r.join("/"))));this[Yr](t,f,r,s,a)})}[df](){this[ds]++}[ir](){this[ds]--,this[Ta]()}[Ja](t){this[ir](),t.resume()}[Wa](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!si}[Ka](t){this[df]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[rf](t,r))}[rf](t,e){let r=f=>{e(f)},s=()=>{this[dn](this.cwd,this.dmode,f=>{if(f){this[Re](f,t),r();return}this[ii]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let f=Z(Se.dirname(String(t.absolute)));if(f!==this.cwd)return this[dn](f,this.dmode,l=>{if(l){this[Re](l,t),r();return}c()})}c()},c=()=>{X.lstat(String(t.absolute),(f,l)=>{if(l&&(this.keep||this.newer&&l.mtime>(t.mtime??l.mtime))){this[Ja](t),r();return}if(f||this[Wa](t,l))return this[rt](null,t,r);if(l.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(l.mode&4095)!==t.mode,h=m=>this[rt](m??null,t,r);return x?X.chmod(String(t.absolute),Number(t.mode),h):h()}if(t.absolute!==this.cwd)return X.rmdir(String(t.absolute),x=>this[rt](x??null,t,r))}if(t.absolute===this.cwd)return this[rt](null,t,r);Km(String(t.absolute),x=>this[rt](x??null,t,r))})};this[ii]?a():s()}[rt](t,e,r){if(t){this[Re](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[$a](e,r);case"Link":return this[of](e,r);case"SymbolicLink":return this[sf](e,r);case"Directory":case"GNUDumpDir":return this[Va](e,r)}}[ys](t,e,r,s){X[r](e,String(t.absolute),a=>{a?this[Re](a,t):(this[ir](),t.resume()),s()})}},Jr=t=>{try{return[null,t()]}catch(e){return[e,null]}},jf=class extends sc{sync=!0;[rt](t,e){return super[rt](t,e,()=>{})}[Ka](t){if(!this[ii]){let a=this[dn](this.cwd,this.dmode);if(a)return this[Re](a,t);this[ii]=!0}if(t.absolute!==this.cwd){let a=Z(Se.dirname(String(t.absolute)));if(a!==this.cwd){let c=this[dn](a,this.dmode);if(c)return this[Re](c,t)}}let[e,r]=Jr(()=>X.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ja](t);if(e||this[Wa](t,r))return this[rt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[f]=c?Jr(()=>{X.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[rt](f,t)}let[a]=Jr(()=>X.rmdirSync(String(t.absolute)));this[rt](a,t)}let[s]=t.absolute===this.cwd?[]:Jr(()=>Wm(String(t.absolute)));this[rt](s,t)}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=f=>{let l;try{X.closeSync(a)}catch(x){l=x}(f||l)&&this[Re](f||l,t),e()},a;try{a=X.openSync(String(t.absolute),Bf(t.size),r)}catch(f){return s(f)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",f=>this[Re](f,t)),t.pipe(c)),c.on("data",f=>{try{X.writeSync(a,f,0,f.length)}catch(l){s(l)}}),c.on("end",()=>{let f=null;if(t.mtime&&!this.noMtime){let l=t.atime||new Date,x=t.mtime;try{X.futimesSync(a,l,x)}catch(h){try{X.utimesSync(String(t.absolute),l,x)}catch{f=h}}}if(this[ti](t)){let l=this[ni](t),x=this[ri](t);try{X.fchownSync(a,Number(l),Number(x))}catch(h){try{X.chownSync(String(t.absolute),Number(l),Number(x))}catch{f=f||h}}}s(f)})}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[dn](String(t.absolute),r);if(s){this[Re](s,t),e();return}if(t.mtime&&!this.noMtime)try{X.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ti](t))try{X.chownSync(String(t.absolute),Number(this[ni](t)),Number(this[ri](t)))}catch{}e(),t.resume()}[dn](t,e){try{return Mm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[Yr](t,e,r,s,a){if(this.preservePaths||r.length===0)return s();let c=e;for(let f of r){c=Se.resolve(c,f);let[l,x]=Jr(()=>X.lstatSync(c));if(l)return s();if(x.isSymbolicLink())return a(new Os(c,Se.resolve(e,r.join("/"))))}s()}[ys](t,e,r,s){let a=`${r}Sync`;try{X[a](e,String(t.absolute)),s(),t.resume()}catch(c){return this[Re](c,t)}}},$m=t=>{let e=new jf(t),r=t.file,s=Df.statSync(r),a=t.maxReadSize||16*1024*1024;new xg(r,{readSize:a,size:s.size}).pipe(e)},Vm=(t,e)=>{let r=new sc(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("close",c),Df.stat(a,(l,x)=>{if(l)f(l);else{let h=new Ya(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},Gf=ai($m,Vm,t=>new jf(t),t=>new sc(t),(t,e)=>{e?.length&&bf(t,e)}),Jm=(t,e)=>{let r=new ic(t),s=!0,a,c;try{try{a=Ye.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")a=Ye.openSync(t.file,"w+");else throw x}let f=Ye.fstatSync(a),l=Buffer.alloc(512);e:for(c=0;c<f.size;c+=512){for(let m=0,E=0;m<512;m+=E){if(E=Ye.readSync(a,l,m,l.length-m,c+m),c===0&&l[0]===31&&l[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let x=new Pn(l);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>f.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}s=!1,Zm(t,r,c,a,e)}finally{if(s)try{Ye.closeSync(a)}catch{}}},Zm=(t,e,r,s,a)=>{let c=new xf(t.file,{fd:s,start:r});e.pipe(c),Xm(e,a)},Ym=(t,e)=>{e=Array.from(e);let r=new Rs(t),s=(a,c,f)=>{let l=(C,_)=>{C?Ye.close(a,y=>f(C)):f(null,_)},x=0;if(c===0)return l(null,0);let h=0,m=Buffer.alloc(512),E=(C,_)=>{if(C||_===void 0)return l(C);if(h+=_,h<512&&_)return Ye.read(a,m,h,m.length-h,x+h,E);if(x===0&&m[0]===31&&m[1]===139)return l(new Error("cannot append to compressed archives"));if(h<512)return l(null,x);let y=new Pn(m);if(!y.cksumValid)return l(null,x);let v=512*Math.ceil((y.size??0)/512);if(x+v+512>c||(x+=v+512,x>=c))return l(null,x);t.mtimeCache&&y.mtime&&t.mtimeCache.set(String(y.path),y.mtime),h=0,Ye.read(a,m,0,512,x,E)};Ye.read(a,m,0,512,x,E)};return new Promise((a,c)=>{r.on("error",c);let f="r+",l=(x,h)=>{if(x&&x.code==="ENOENT"&&f==="r+")return f="w+",Ye.open(t.file,f,l);if(x||!h)return c(x);Ye.fstat(h,(m,E)=>{if(m)return Ye.close(h,()=>c(m));s(h,E.size,(C,_)=>{if(C)return c(C);let y=new As(t.file,{fd:h,start:_});r.pipe(y),y.on("error",c),y.on("close",a),Qm(r,e)})})};Ye.open(t.file,f,l)})},Xm=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:Kf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Qm=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:s=>t.add(s)}):t.add(r);t.end()},Zr=ai(Jm,Ym,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Eg(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")}),qS=ai(Zr.syncFile,Zr.asyncFile,Zr.syncNoFile,Zr.asyncNoFile,(t,e=[])=>{Zr.validate?.(t,e),ew(t)}),ew=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))};Yt();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 ci(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Wf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function $f(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 xr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}var D=class extends Error{code;retriable;cause;constructor(e,r,s){super(r),this.name="BridgeError",this.code=e,this.retriable=s?.retriable??!1,s?.cause!==void 0&&(this.cause=s.cause)}};ee();Me();function zt(t,e){if(ci(t)!=="cloud")throw new D("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ps(t){return t.startsWith("http://")||t.startsWith("https://")}function Ls(t){return t.endsWith("/")?t.slice(0,-1):t}ee();var Ns="1008033",Jf="1289";var Zf="pbbp2",Yf="https://www.coze.cn",Xf="/api/coze_claw/resource/get_frontier_key",nw="https://www.coze.cn",rw="wss://frontier.coze.cn";function Ms(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??nw}function Qf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??rw}function hr(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,s=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),s&&(e["x-use-ppe"]=s),e}function fi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var di=H("handshake");async function oc(t){let e=Ms(t.endpoint),r=t.timeoutMs??1e4,s=`${Ls(e)}${Xf}?aid=${encodeURIComponent(Ns)}`,a={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...hr(t.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),r);di.info("frontier key handshake",{base:e});try{let l=await fetch(s,{method:"GET",headers:a,signal:c.signal}),x=l.headers.get("x-tt-logid")??"",h=l.headers.get("x-tt-trace-id")??"";if(!l.ok){let y=await l.text().catch(()=>"");throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${l.status} logid=${x}: ${y.slice(0,200)}`)}let m=await l.json();if(m.code!==void 0&&m.code!==0)throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${x}`);let E=m.data??{},C=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,_=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!C||!_){let y=JSON.stringify(m).slice(0,500);throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${y}`)}return di.info("handshake ok",{remoteDeviceId:_,logid:x,traceId:h}),{accessKey:C,deviceId:_}}catch(l){if(l instanceof D)throw di.error("handshake failed (bridge error)",{base:e,message:l.message,code:l.code}),l;if(l.name==="AbortError")throw di.warn("handshake timeout",{base:e,timeoutMs:r}),new D("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:l});let x=l.cause;throw di.error("handshake error",{base:e,message:l instanceof Error?l.message:String(l),errno:x?.code,syscall:x?.syscall,cause:String(l).slice(0,300)}),new D("UPSTREAM_HANDSHAKE_FAILED",String(l),{cause:l})}finally{clearTimeout(f)}}var ac=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",vt="auto";function el(t){return{model:t.model??vt,...t.modelToken?{modelToken:t.modelToken}:{}}}function tl(t){return!t||t===vt}function nl(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=ac,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||vt,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):tl(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function rl(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||vt}"`):tl(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${ac}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"'),t.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${t.modelInfo.contextWindow}`)),e}function il(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function cc(t,e){let{ttEnv:r,usePpe:s}=fi(t),a={};return r&&(a["x-tt-env"]=r),s&&(a["x-use-ppe"]=s),e&&(a["x-mock-scenario"]=e),a}function sl(t,e,r){if(!t.modelToken)return{};let s=cc(e,r);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,f])=>`${c}:${f}`).join(`
|
|
83
|
-
`)}}function dc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function ol(t,e,r){if(!t.modelToken)return null;let s=t.model||vt,a=cc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let f={baseUrl:`${ac}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:s,name:s,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(a).length>0&&(f.headers=a),f}function al(t,e,r){if(!t.modelToken)return[];let s=cc(e,r),a=[];for(let[c,f]of Object.entries(s))a.push("-c",`model_providers.coze.http_headers.${c}="${f}"`);return a}var ke=H("agent-handlers"),cl=5*1024*1024,dw=1,fw=6,lw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Bs=class{constructor(e){this.opts=e}opts;async listSkills(e){zt(e._meta,"_agent/listSkills");let r=xr(e._meta),s=await this.loadAgentCfg(r),a=s?.workspace??kt(r).workspace,c=s?.skills??[],f=[];for(let l of c){let x=It(a,l.relPath,"SKILL.md");await ow(x).then(m=>m.isFile()).catch(()=>!1)&&f.push(gw(l))}return{skills:f}}async addSkills(e){zt(e._meta,"_agent/addSkills");let r=xr(e._meta),s=await this.requireAgentCfg(r),a=e.skills??[],c=[...s.skills??[]],f=new Map(c.map((x,h)=>[x.skillId,h])),l=[];for(let x of a){let h=await gc({agentId:r,workspace:s.workspace,framework:s.framework,skill:x});mc(c,f,h),l.push(x)}return await Hi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:l}}async removeSkills(e){zt(e._meta,"_agent/removeSkills");let r=xr(e._meta),s=await this.requireAgentCfg(r),a=new Set(e.skillIds??[]),c=s.skills??[],f=[];for(let l of c){if(!a.has(l.skillId)){f.push(l);continue}let x=It(s.workspace,l.relPath);await sw(x,{recursive:!0,force:!0}),ke.info("skill removed",{agentId:r,skillId:l.skillId,relPath:l.relPath})}return await Hi(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,ke.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,ke.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:f}),x.stop(r).catch(h=>ke.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:a,err:String(h)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ke.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,s=await Ue(r);if(!s)throw new D("AGENT_NOT_FOUND",`agent not found: ${r}`);if(s.cozeIdentity===e.cozeIdentity)return ke.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Zn(s.workspace,s.framework,e.cozeIdentity)}catch(a){throw ke.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:s.framework,workspace:s.workspace,err:String(a)}),new D("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(a)}`,{cause:a})}return s.cozeIdentity=e.cozeIdentity,await Ve(s),ke.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 D("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let s=await Ue(r);return s?(s.disconnectedAt=Date.now(),s.disconnectReason=e.reason??"",await Ve(s),ke.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}):(ke.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(zt(e._meta,"_agent/switchModel"),!e.agentId)throw new D("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:vt,s=await Ue(e.agentId);if(!s)throw new D("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);s.model=r,e.modelInfo&&(s.modelInfo=e.modelInfo),await Ve(s),ke.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return ke.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=>ke.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(f)}));let c=[];for(let[f,l]of a.allSessionQueues())c.push(l.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),ke.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(zt(e._meta,St.RESET),!e.agentId)throw new D("IPC_BAD_REQUEST",`${St.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,St.RESET,e.reason),{ok:!0}}async repairAgent(e){if(zt(e._meta,St.REPAIR),!e.agentId)throw new D("IPC_BAD_REQUEST",`${St.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new D("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){ke.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){ke.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){ke.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:s,err:String(a)})}}async getFileTree(e){zt(e._meta,"_agent/getFileTree");let r=e._meta,s=xr(r),a=await this.resolveWorkspace(s),c=e.filePath??"",f=this.safeJoin(a,c),l=await fc(f).catch(()=>null);if(!l)throw new D("IPC_BAD_REQUEST",`path not found: ${c}`);if(l.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Nr(f,a))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=Cw(e.depth);return l.isDirectory()?{tree:await Aw(a,f,c,x)}:{tree:[{name:Tw(c),path:pl(c||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){zt(e._meta,"_agent/getFileContent");let r=xr(e._meta),s=await this.resolveWorkspace(r);if(!e.filePath)throw new D("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(s,e.filePath),c=await fc(a).catch(()=>null);if(!c||!c.isFile())throw new D("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Nr(a,s))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>cl)throw new D("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${cl})`);let f=await dl(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 Ue(e).catch(()=>null))?.workspace??kt(e).workspace}safeJoin(e,r){let s=xc(e,r||"."),a=pc(e,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${fl}`))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return s}loadAgentCfg(e){return Ue(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new D("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function uw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new D("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new D("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function xw(t){return t==="claude-code"?It(".claude","skills"):It(".agents","skills")}var hw=3e4,pw=50*1024*1024,pr=3e4;async function gc(t){let{agentId:e,workspace:r,framework:s,skill:a}=t;if(!a.skillName)throw new D("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 D("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let l=uw(a.skillName),x=xw(s),h=It(x,l),m=It(r,h);if(await lc(m,{recursive:!0}),c){let C=Buffer.from(a.content,"utf8");li(C.length),await uc(It(m,"SKILL.md"),C,"utf8")}else{let C=await mw(a.downloadUrl);_w(C)?await Sw(C,m):yw(C)?await Ew(C,m):await uc(It(m,"SKILL.md"),C.toString("utf8"),"utf8")}let E={skillId:a.skillId,skillName:a.skillName,relPath:h,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return ke.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:h,source:c?"content":"downloadUrl"}),E}function mc(t,e,r){let s=e.get(r.skillId);if(s!==void 0){t[s]=r;return}e.set(r.skillId,t.length),t.push(r)}function gw(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 mw(t){if(!t)throw new D("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);li(e);let r=ww(t);return li(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await dl(e);return li(r.length),r}if(Ps(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),hw);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new D("IPC_BAD_REQUEST",`fetch skill failed HTTP ${s.status} ${t}`);let a=await s.arrayBuffer();return li(a.byteLength),Buffer.from(a)}finally{clearTimeout(r)}}throw new D("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function li(t){if(t>pw)throw new D("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function ww(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new D("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 _w(t){return t.length>=2&&t[0]===31&&t[1]===139}function yw(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function hc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function Ew(t,e){let r,s;try{r=new xl.default(t),s=r.getEntries()}catch(f){throw new D("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of s){let l=f.entryName;if(!l||hc(l))continue;if(l.startsWith("/")||/^[A-Za-z]:[\\/]/.test(l))throw new D("IPC_BAD_REQUEST",`zip entry absolute path: ${l}`);if(l.split(/[/\\]/).some(h=>h===".."))throw new D("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${l}`);let x=f.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new D("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${l}`)}let a=bw(s),c=xc(e);for(let f of s){if(hc(f.entryName))continue;let l=f.entryName;if(a&&l.startsWith(a)&&(l=l.slice(a.length)),!l)continue;let x=xc(e,l),h=pc(c,x);if(h.startsWith("..")||h==="..")throw new D("IPC_BAD_REQUEST",`zip entry escapes destDir: ${l}`);if(f.isDirectory){await lc(x,{recursive:!0});continue}await lc(aw(x),{recursive:!0});let m;try{m=f.getData()}catch(E){throw new D("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${E.message}`,{cause:E})}await uc(x,m)}}function bw(t){let e;for(let r of t){let s=r.entryName;if(!s||hc(s))continue;let a=s.indexOf("/");if(a<=0)return;let c=s.slice(0,a+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function Sw(t,e){await vw(t);let r=Gf({cwd:e,strip:1}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`))},pr);try{await ul(ll.from(t),r)}catch(c){throw c instanceof D?c:s?new D("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`):new D("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}}async function vw(t){let e=[],r=ur({onReadEntry:c=>{let f=c.path,l=c.type;if(l!=="File"&&l!=="Directory"){e.push(`tar entry kind '${l}' not allowed (symlink/hardlink/special): ${f.slice(0,100)}`);return}if(f.startsWith("/")||f.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(f)){e.push(`tar entry absolute path: ${f}`);return}f.split(/[/\\]/).some(h=>h==="..")&&e.push(`tar entry contains '..': ${f}`)}}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`))},pr);try{await ul(ll.from(t),r)}catch(c){throw s?new D("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`):new D("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}if(e.length>0)throw new D("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var Iw=5e3;async function Aw(t,e,r,s){return hl(t,e,r,s,{count:0})}async function hl(t,e,r,s,a){if(s<=0)return[];let c;try{c=await iw(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let l of c){if(lw.has(l.name)||l.isSymbolicLink())continue;if(a.count>=Iw){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=It(e,l.name),h=cw(It(r,l.name)),m=null;try{m=await fc(x)}catch{continue}if(m.isSymbolicLink())continue;a.count++;let E={name:l.name,path:pl(pc(t,x)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&s>1&&(E.children=await hl(t,x,h,s-1,a)),f.push(E)}return f.sort((l,x)=>l.isDir!==x.isDir?l.isDir?-1:1:l.name.localeCompare(x.name)),f}function Cw(t){return!t||t<=0?dw:Math.min(t,fw)}function Tw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function pl(t){return t.split(fl).join("/")}ee();import{readFileSync as Xv}from"node:fs";import{dirname as e1,join as t1}from"node:path";import{fileURLToPath as r1}from"node:url";var gr="0.1.82";var un=H("agent-health-reporter"),Dw=1e4,ui=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Dw}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()}),un.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),un.info("heartbeat stopped"))}async tick(){if(this.inFlight){un.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){un.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 l=Rw(f);if(!l)continue;let x={agentId:f.agentId,status:l};f.patToken&&(x.patToken=f.patToken),f.accountId&&(x.accountId=f.accountId),r.push(x)}if(r.length===0)return;let s={agents:r,bridgeVersion:gr,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",s,5e3)}catch(f){un.warn("heartbeat batch send failed",{count:r.length,err:String(f)})}let c=a?.authFailures;if(c&&c.length>0&&(un.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){un.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){un.warn("onTickEnd hook failed",{err:String(r)})}}};function Rw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Yt();import{mkdir as yc,rm as d_}from"node:fs/promises";Zt();Zt();import{spawnSync as zw}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 hi(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 xn(t,e){return{jsonrpc:"2.0",id:t,error:e}}var zs=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Q={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function gl(t){return"method"in t&&"id"in t&&t.id!==void 0}function ml(t){return"method"in t&&!("id"in t)}function Fs(t){return!("method"in t)&&"id"in t}var kw={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,NPX_CACHE_CORRUPT:Q.INTERNAL_ERROR};function Ow(t){if(t!=null)return t instanceof Error?{name:t.name,message:pi(t.message)}:typeof t=="string"?pi(t):typeof t=="object"?Lw(t):t}var Pw=[[/\/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 pi(t){let e=t;for(let[r,s]of Pw)e=e.replace(r,s);return e}function Lw(t){let e={};for(let[r,s]of Object.entries(t))typeof s=="string"?e[r]=pi(s):e[r]=s;return e}function gi(t){if(t instanceof D){let e=Ow(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:kw[t.code]??Q.INTERNAL_ERROR,message:pi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:pi(t instanceof Error?t.message:String(t))}}function wl(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,...l}=e;c=l}return new D(r,a,{retriable:e?.retriable??!1,cause:c})}function yl(t){return`${JSON.stringify(t)}
|
|
84
|
-
`}var
|
|
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 bl={"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"},h1=Object.fromEntries(Object.entries(bl).map(([t,e])=>[e,t])),Nw={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},wr=class{seq=0;next(e,r){this.seq+=1;let s=bl[e]??Mw(e),a=Nw[s]??[],c=[s,String(this.seq)];if(a.length>0){let f=a.map(x=>El(r?.[x]??"")),l=Bw(f).join(":");l&&c.push(l)}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 Mw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function El(t){return t.replace(/[:_\s]+/g,"-")}function Bw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Wn();function hn(t,e){let r=process.env[t];if(!r)return e;let s=Number(r);return Number.isFinite(s)&&s>0?s:e}ee();var Fw=hn("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Uw=200,qw=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function wc(t){return t.some(e=>qw.test(e))}var Hw=hn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),jw=hn("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),Sl=500;function Gw(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 vl(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),zw("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 Us({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 D("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>Uw&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),r.stdin?.on("error",s=>{this.log.warn("child stdin error",{err:String(s)})}),r.stdout?.on("error",s=>{this.log.warn("child stdout error",{err:String(s)})}),r.stderr?.on("error",s=>{this.log.warn("child stderr error",{err:String(s)})}),r.on("exit",(s,a)=>{this.stopped=!0,(s!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:s,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&wc(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),yn(this.framework).catch(l=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(l)})})));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 D("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 D("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()));vl(r.pid,"SIGTERM");let a=setTimeout(()=>{r.killed||vl(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=Hw,s=jw){return this.call("session/prompt",e,r,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(hi("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(mr(e,r))}catch(s){this.log.warn("respondAgentRequest write failed",{id:e,err:String(s)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(xn(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=Fw,a=0){if(!this.child||this.stopped)return Promise.reject(new D("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),f=xi(c,e,r),l=(()=>{if(typeof r!="object"||r===null)return;let m=r.sessionId;return typeof m=="string"?m:void 0})(),x=s>0&&Number.isFinite(s),h=a>0&&Number.isFinite(a);return new Promise((m,E)=>{let C={resolve:m,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,...l?{sessionId:l}:{}}),E(new D("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s));let _=h?()=>{C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),C.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...l?{sessionId:l}:{}}),_?.();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,...l?{sessionId:l}:{}}),E(new D("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;C.armFrameIdle=_,this.pending.set(c,C),_?.();try{this.writeFrame(f)}catch(y){C.timer&&clearTimeout(C.timer),C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),this.pending.delete(c),E(y)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new D("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(yl(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Fs(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(wl(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 D("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Gw(e.result)}),r.resolve(e.result));return}if(ml(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(gl(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(xn(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(xn(e.id,gi(s)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var Kw=Lr("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function Ww(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 qs=class extends At{framework="claude-code";constructor(e){let r=Jt("claude-code"),[s,a]=r?[r,[]]:["npx",["-y",Kw]],c=e.command??s,f=e.args??a,l={command:c,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(l)}sanitizeEnv(e){return Ww(e)}};Zt();import{mkdtempSync as $w,rmSync as Vw}from"node:fs";import{tmpdir as Jw}from"node:os";import{join as Zw}from"node:path";var Yw=Lr("codex")??"@zed-industries/codex-acp@^0.15",Hs=class extends At{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=Jt("codex"),[s,a]=r?[r,[]]:["npx",["-y",Yw]],c=e.command??s,f=e.args??a,l=e.extraArgs?[...f,...e.extraArgs]:f,x=e.isolateCodexHome?$w(Zw(Jw(),"coze-bridge-codex-home-")):void 0,h=x?{...e.env??{},CODEX_HOME:x}:e.env,m={command:c,args:l,cwd:e.cwd,...h?{env:h}:{}};super(m),this.authMethodId=e.authMethodId,this.codexHomeDir=x}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Vw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Xw=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}`}]},Xw))}get acpSessionName(){return this.sessionName}};ee();Me();function _c(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}Zt();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 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 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)mi(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 mi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}Wn();ee();import{constants as Il,access as Qw}from"node:fs/promises";import{delimiter as e_,join as t_}from"node:path";var pn=H("framework-detector"),Al={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},n_=[".exe",".cmd",".bat",".ps1"],gn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Vt,access:e.access??Qw}}async detect(e){let r=Al[e],s=await this.which(r);if(!s)return pn.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)]),l={path:s,version:c};return f&&(l.defaultAgent=f),l}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(e_).filter(Boolean),s=this.env.platform==="win32"?["",...n_]:[""];for(let a of r)for(let c of s){let f=t_(a,e+c);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Il.F_OK:Il.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 pn.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return pn.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 pn.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 pn.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?(pn.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}:(pn.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:a.length}),null)}catch(a){return pn.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&&(i_(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(s=>{let a="",c=!1,f,l=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"),l(null)},15e3),x.stdout?.on("data",h=>{a+=h.toString("utf8")}),x.on("error",()=>l(null)),x.on("close",h=>l({code:h,stdout:a}))}catch{l(null)}})}},r_=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function i_(t){return t.replace(r_,"")}import{spawn as s_}from"node:child_process";import{homedir as o_}from"node:os";import{join as a_}from"node:path";Ui();ee();async function Dl(){let t=a_(o_(),".openclaw/openclaw.json");return(await Jn(t))?.gateway?.auth?.token??""}var Cl=H("openclaw.config"),c_=[0,5e3,5e3],Tl="models.providers.",Gs="agents.defaults.models",Ks=class{command;env;retryDelaysMs;queue=new yr;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??c_}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,Cl.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(f)})}}throw new D("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${s?.message??"unknown"}`)}runCli(e){return new Promise((r,s)=>{let a=s_(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){Cl.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",`${Tl}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Tl}${e}`)}addModelToAllowlist(e,r){let s={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Gs}[${e}]`,()=>this.runCli(["config","set",Gs,JSON.stringify(s),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Gs}[${e}]`,`${Gs}.${e}`)}ensureAgent(e,r,s){let a=["agents","add",e,"--workspace",r,"--non-interactive"];return s&&a.push("--model",s),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Oe=H("agent-manager"),f_=(t,e,r,s,a,c,f,l,x)=>{switch(t){case"claude-code":{let h={...a?{...nl(a),...sl(a,f,l)}:{},...x??{},IS_SANDBOX:"1"};return new qs({cwd:r,env:h})}case"codex":{let m=[...a?[...rl(a),...al(a,f,l)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...a?il(a):{},...x??{}},C=!!a;return new Hs({cwd:r,...m.length>0?{extraArgs:m}:{},...Object.keys(E).length>0?{env:E}:{},...C?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new _r({command:e,cwd:r,agentId:s,...c?{sessionName:_c(c)}:{}})}};function Ec(t){return t==="claude-code"||t==="codex"}var l_={path:"",version:"cloud-deployed"},u_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},x_=6e4,h_=hn("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),Ws=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??f_,this.createTimeoutMs=e.createTimeoutMs??x_,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??h_,this.detectorFactory=e.detectorFactory??(()=>new gn)}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 D("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 D("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new D("IPC_BAD_REQUEST","framework required");let r=ci(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let s=this.registry.get(e.agentId);if(s){if(s.framework!==e.framework)throw new D("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${s.framework})`);if(s.status==="error")Oe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await s.dispose("rebuild after error").catch(y=>Oe.warn("dispose stale agent failed (ignored)",{err:String(y)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==s.patToken){Oe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),s.setPatToken(e.patToken);let y=await Ue(e.agentId,this.paths).catch(()=>null);y&&(y.patToken=e.patToken,await Ve(y,this.paths))}if(s.deployType==="cloud"&&e.modelInfo){Oe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),s.setModelInfo(e.modelInfo);let y=await Ue(e.agentId,this.paths).catch(()=>null);y&&(y.modelInfo=e.modelInfo,await Ve(y,this.paths))}return Oe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:s.agentId,workspace:s.workspace,framework:s.framework}}}if(!r&&!this.config.frameworksCache?.[e.framework])throw new D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=kt(e.agentId,this.paths),f=ci(e._meta),l=e.framework==="openclaw"&&f==="local",x=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,h=e.workspace??x??c.workspace,m=new AbortController,E=setTimeout(()=>m.abort(new D("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),C,_=!1;try{r&&Ec(e.framework)&&await yn(e.framework,m.signal);let y=()=>{if(m.signal.aborted)throw m.signal.reason instanceof Error?m.signal.reason:new D("AGENT_TIMEOUT","_agent/create aborted")};await yc(c.root,{recursive:!0}),await yc(h,{recursive:!0}),await yc(c.logs,{recursive:!0}),y(),l||await Zn(h,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await Z0(h),y();let v=await Ue(e.agentId,this.paths).catch(()=>null),I=el({model:e.model??v?.model}),R=Wf(e._meta)??v?.accountId,L=e.patToken??v?.patToken,w=f==="cloud"?e.modelInfo??v?.modelInfo:void 0;if(C=new js({agentId:e.agentId,framework:e.framework,workspace:h,model:I.model??vt,deployType:f,...R?{accountId:R}:{},...L?{patToken:L}:{},...w?{modelInfo:w}:{}}),C.status="ok",v?.sessions){for(let[z,O]of Object.entries(v.sessions))C.sessions.set(z,{acpSessionId:O.acpSessionId,modelToken:O.modelToken,tokenGeneratedAt:O.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(v.sessions).length;F>0&&Oe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(C),_=!0;let A={agentId:e.agentId,framework:e.framework,workspace:h,cozeIdentity:e.cozeIdentity,createdAt:v?.createdAt??Date.now(),sessions:v?.sessions??{},model:I.model};f==="cloud"&&(A.deployType="cloud"),R&&(A.accountId=R),L&&(A.patToken=L),w&&(A.modelInfo=w),v?.skills&&(A.skills=v.skills),v?.agentName&&(A.agentName=v.agentName),v?.description&&(A.description=v.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,h):Oe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let k=e.initialSkills??[];if(k.length>0){let F=[...A.skills??[]],z=new Map(F.map((U,W)=>[U.skillId,W])),O=await Promise.allSettled(k.map(U=>gc({agentId:e.agentId,workspace:h,framework:e.framework,skill:U}))),N=0;for(let[U,W]of O.entries()){let se=k[U];se&&(W.status==="fulfilled"?(mc(F,z,W.value),N++):Oe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:se.skillId,skillName:se.skillName,err:String(W.reason)}))}N>0&&(A.skills=F,Oe.info("initialSkills installed",{agentId:e.agentId,installed:N,requested:k.length}))}return await Ve(A,this.paths),Oe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:h,framework:e.framework}}catch(y){throw Oe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(y)}),_&&C&&(await C.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await d_(c.root,{recursive:!0,force:!0}).catch(v=>Oe.warn("rm agent dir failed (ignored)",{err:String(v)})),y instanceof D?y:new D("AGENT_SPAWN_FAILED",String(y),{cause:y})}finally{clearTimeout(E)}}async spawnSessionDownstream(e,r,s,a,c){let l=this.config.frameworksCache?.[e.framework];if(!l)if(e.deployType==="cloud"&&Ec(e.framework))l=l_;else throw new D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(Ec(e.framework)&&!Jt(e.framework)){let m=Jo(e.framework);m&&(Oe.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([m.catch(()=>{}),new Promise(E=>setTimeout(E,this.spawnAwaitInstallMs))]))}let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;e.framework==="openclaw"?h=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:s,cozeEnv:a,mockScenario:c,command:l.path}):h=this.factory(e.framework,l.path,e.workspace,e.agentId,x,s,a,c,this.buildBinShimPathEnv());try{return await h.start(),await h.initialize(u_),h}catch(m){let E=h instanceof At?h.getStderrTail():[];E.length>0&&Oe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof D?m.code:"unknown",recentStderr:E});let C=wc(E);await h.stop("spawnSessionDownstream failed").catch(()=>{});let _=C?new D("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:m}):m;throw m instanceof D?new D(m.code,m.message,{retriable:m.retriable,cause:_}):new D("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:_})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:s,cloudSessionId:a,cozeEnv:c,mockScenario:f,command:l}=e,x=_c(a);if(r.deployType==="local"){let C=this.config.frameworksCache?.openclaw?.defaultAgent;if(!C?.id||!C.workspace){Oe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let y=await this.detectorFactory().detect("openclaw");if(y?.defaultAgent?.id&&y?.defaultAgent?.workspace)Oe.info("openclaw lazy re-detect success",{agentId:y.defaultAgent.id,workspace:y.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=y,C=y.defaultAgent;else throw new D("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:l,cwd:C.workspace,agentId:C.id,sessionName:x})}let h=await Dl(),m=s?ol(s,c,f):null,E;if(m){let C=dc(a),y=m.models[0]?.id??vt,v=`${C}/${y}`;if(!this.ensuredProviders.has(v)){let I=this.getOpenclawConfig();await I.ensureProvider(C,m),await I.addModelToAllowlist(v),this.ensuredProviders.add(v)}E=v}return new _r({command:l,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let s=this.getOpenclawConfig();await s.deleteAgent(e),await s.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let s of e.sessions.keys()){let a=dc(s),c=`${a}/${e.model}`,f=!0;try{await r.removeProvider(a)}catch(l){f=!1,Oe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(l)})}try{await r.removeModelFromAllowlist(c)}catch(l){f=!1,Oe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(l)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as Ll}from"node:crypto";import{promises as I_}from"node:fs";import{basename as Nl}from"node:path";import{promises as g_}from"node:fs";import{basename as m_}from"node:path";ee();var Rl=H("file-upload"),w_="/api/coze_claw/file/agent_upload",__=6e4;async function kl(t,e={}){let s=`${Ls(Ms(e.handshakeBase))}${w_}`,a=e.timeoutMs??__,c=await g_.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 l={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...hr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),a);Rl.info("file upload start",{url:s,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(s,{method:"POST",headers:l,body:f,signal:x.signal}),E=m.headers.get("x-tt-logid")??"";if(!m.ok){let y=await m.text().catch(()=>"");throw new D("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${E}: ${y.slice(0,200)}`)}let C=await m.json();if(C.code!==void 0&&C.code!==0)throw new D("UPLOAD_FAILED",`upload code=${C.code} msg=${C.msg??"-"} logid=${E}`);let _=C.data?.file?.file_url;if(!_)throw new D("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(C).slice(0,200)}`);return Rl.info("file upload ok",{uri:_,logid:E}),{uri:_}}catch(m){throw m instanceof D?m:m.name==="AbortError"?new D("UPLOAD_FAILED",`upload timeout (${a}ms) for ${m_(t.path)}`):new D("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(h)}}ee();import{promises as y_}from"node:fs";import{extname as E_}from"node:path";var b_=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function S_(t){return t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}var v_={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Ol(t){let e=await y_.open(t,"r");try{let r=Buffer.alloc(16);if(await e.read(r,0,16,0),S_(r))return"image/webp";for(let s of b_)if(s.prefix.every((a,c)=>r[c]===a))return s.mime}finally{await e.close()}return v_[E_(t).toLowerCase()]??"application/octet-stream"}Me();var $s=H("agent-send"),Pl=50*1024*1024,A_=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Ml(t,e,r){let s=t.get(e);if(!s)throw new D("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new D("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=s.sessions.get(r);if(!a)throw new D("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:s,runtime:a}}async function Bl(t,e,r,s,a,c){let l;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,s,a);return}catch(h){l=h,x<2&&($s.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(m=>setTimeout(m,5e3)))}throw new D("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(l)}`,{cause:l})}async function zl(t,e){let{session:r,runtime:s}=Ml(e.core,t.agentId,t.sessionId);if(!await Nr(t.path,r.workspace))throw new D("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let a=await I_.stat(t.path).catch(()=>null);if(!a||!a.isFile())throw new D("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(a.size>Pl)throw new D("FILE_TOO_LARGE",`${a.size} bytes > limit ${Pl}`);let c=await Ol(t.path);if(!A_.has(c))throw new D("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(t.kind==="image"&&!c.startsWith("image/"))throw new D("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let f=t.name??Nl(t.path),l;try{l=await kl({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:f,sizeBytes:a.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(h){throw $s.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:a.size,mime:c,code:h instanceof D?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId:Ll(),content:{type:t.kind==="image"?"image":"resource",uri:l.uri,mimeType:c,name:f,sizeBytes:a.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Bl(e,r,s,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),$s.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:f,bytes:a.size,mime:c,uri:l.uri}),{ok:!0,uri:l.uri,bytes:a.size,mimeType:c,...l.fileId!==void 0?{fileId:l.fileId}:{}}}async function Fl(t,e){let{session:r,runtime:s}=Ml(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new D("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let a=t.name??Nl(t.path),c={sessionUpdate:"group_file",messageId:Ll(),content:{uri:t.path,name:a,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Bl(e,r,s,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),$s.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 Ul(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,l=s[c]??0;if(f<l)return!0;if(f>l)return!1}return!1}Zt();Wn();ee();var Ct=H("coze-cli-installer"),ql="@coze/cli@latest",C_="coze",Hl="0.1.7",T_=5e3,D_=5e3,R_=9e4,jl=1e4,wi=null,Vs=!1;async function bc(t,e={}){if(Vs)return;if(wi)return wi;let r=e.exec??Ni;return wi=(async()=>{try{let s=await k_(C_,r),a=!1;if(s){let f=await O_(r);if(f===void 0)Ct.warn("coze-cli found but version unparseable, fall through to full install",{path:s});else if(Ul(f,Hl))Ct.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:s,version:f,min:Hl}),a=!0;else{Ct.info("coze-cli already on PATH with sufficient version, skip",{path:s,version:f}),Vs=!0;return}}let c=a?"upgrade-only":"full";Ct.info("coze-cli install start",{package:ql,mode:c});try{await r("npm",["i","-g","--prefer-online",ql],{timeout:R_,maxBuffer:10*1024*1024}),Ct.info("coze-cli install ok")}catch(f){Ct.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(a){Vs=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:jl}),Ct.info("coze config set xTTEnv ok",{env:t.env})}catch(f){Ct.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:jl}),Ct.info("coze auth login ok")}catch(f){Ct.warn("coze auth login failed",{err:String(f)});return}Vs=!0}finally{wi=null}})(),wi}async function k_(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:s}=await e(r,[t],{timeout:T_});return zi(s)}catch{return}}async function O_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:D_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Ui();Me();var P_=10*6e4;function Gl(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?P_:e}function Js(t){return Jn(t??te().configFile)}function Er(t,e){return Fi(e??te().configFile,t)}import{randomBytes as Y_}from"node:crypto";import{createReadStream as L_}from"node:fs";import{mkdir as N_,readFile as M_,realpath as B_,stat as z_,writeFile as F_}from"node:fs/promises";import{basename as U_,dirname as Sc,join as q_,relative as H_,resolve as Kl,sep as j_}from"node:path";import{createInterface as G_}from"node:readline";ee();var $l=H("fs-rpc"),_i=hn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Vl(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>_i)throw new D("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${_i} bytes`);let s=await Zl(t.path,e);return await N_(Sc(s),{recursive:!0}),await F_(s,t.content,"utf8"),$l.info("fs/write_text_file ok",{path:s,size:t.content.length}),null}async function Jl(t,e){let r=await Zl(t.path,e),s=await z_(r),a=typeof t.line=="number"||typeof t.limit=="number";if(s.size>_i&&!a)throw new D("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${s.size} bytes > ${_i} bytes`);let c;if(a&&s.size>_i)c=await K_(r,t.line??1,t.limit);else{let f=await M_(r,"utf8");if(a){let l=f.split(`
|
|
86
|
-
`),
|
|
87
|
-
`)}else c=
|
|
88
|
-
`)}async function Zl(t,e){if(typeof t!="string"||t.length===0)throw new D("IPC_BAD_REQUEST","path must be a non-empty string");let[r,s]=await Promise.all([Wl(Kl(e)),Wl(Kl(t))]),a=H_(r,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${j_}`))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return s}async function Wl(t){let e=[],r=t;for(;r!==Sc(r);)try{let s=await B_(r);return e.length?q_(s,...e.reverse()):s}catch{e.push(U_(r)),r=Sc(r)}return t}ee();var Yl=H("prompt-multimodal"),Xl=10*1024*1024,W_=15e3,$_=6;async function Ql(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 V_(f))}}let a=Array.from({length:Math.min($_,t.length)},()=>s());return await Promise.all(a),e}function eu(t){return t.some(e=>e.type==="image")}async function V_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ps(e.uri))return t;try{let{buf:r,contentType:s}=await Z_(e.uri),a=e.mimeType||J_(s)||"application/octet-stream";return Yl.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 Yl.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function J_(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(),W_);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>Xl)throw new Error(`image too large: ${a.byteLength} bytes (max ${Xl})`);return{buf:Buffer.from(a),contentType:s.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Yt();ee();var $=H("core"),X_=3e4,Q_=/^(boe|ppe)_[A-Za-z0-9_-]+$/,ey=3e4,Zs=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=Gl(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(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.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),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(s){$.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)&&$.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)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:f}),mi(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){$.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(xn(a,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(f=>$.debug("send error response to upstream failed (ignored)",{err:String(f)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Q.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,s]of this.pendingUpstream)try{s.downstream.respondAgentRequestError(s.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,s]of this.pendingBridge)clearTimeout(s.timer),s.reject(new D("UPSTREAM_DISCONNECTED",`${s.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Fs(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&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:s});try{if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);r!==null&&await this.upstream.send(mr(r,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(mr(r,a));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(mr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(a){$.error("handleFrame failed",{method:e.method,err:String(a)}),r!==null&&await this.upstream.send(xn(r,gi(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new D("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,s=r._meta?.cozeAgentId;if(!s)throw new D("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(s);if(!a)throw this.disconnectedAgents.has(s)?new D("AGENT_DISCONNECTED",`agent ${s} has been disconnected; cloud must _agent/create to revive`):new D("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(),l=!1;try{let x=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,r));return l=!0,x}finally{$.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-f,ok:l})}}async dispatchSessionCall(e,r,s){e.lastActiveAt=Date.now();let{stripped:a}=Vf(s);switch(r){case"session/new":{let c=ty();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,f=c.sessionId;if(!f)throw new D("IPC_BAD_REQUEST","session/prompt: missing sessionId");let l=await this.ensureRuntime(e,f);if(l.replySeq=0,await this.ensureDownstream(e,f,l),!l.downstream||!l.acpSessionId)throw new D("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=s._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(l.acpSessionId,x):e.activeTriggers.delete(l.acpSessionId);let h=$f(s._meta);if(h?e.activeGroupIds.set(l.acpSessionId,h):e.activeGroupIds.delete(l.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&eu(c.prompt))throw new D("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await Ql(c.prompt);try{let E=await l.downstream.sessionPrompt({...c,sessionId:l.acpSessionId,prompt:m});return l.lastActiveAt=Date.now(),E}finally{if(e.activeTriggers.delete(l.acpSessionId),e.activeGroupIds.delete(l.acpSessionId),l.reloadAfterTurn){l.reloadAfterTurn=!1;let E=l.downstream;E&&(l.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:l.acpSessionId}),E.stop("reload-after-turn").catch(C=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:f,err:String(C)})))}else l.downstream?.isAlive()&&this.armIdleTimer(e,f,l)}}case"session/cancel":{let f=a.sessionId;if(!f)throw new D("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(f);if(e.hasSessionQueue(f)){let x=e.getSessionQueue(f);x.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:x.size}),x.dispose(new D("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${f}`)))}return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new D("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,ey);if(!a?.modelToken)throw new D("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return a.modelToken}catch(a){throw a instanceof D&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new D("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,r,s){if(mi(s),s.downstream?.isAlive())return;if(!this.sessionSpawner)throw new D("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,f=s.spawnFailCount??0,l=s.spawnFailedAt??0;if(f>=a&&Date.now()-l<c)throw new D("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()-l))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,s.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(h){throw s.spawnFailCount=f+1,s.spawnFailedAt=Date.now(),s.spawnFailCount>=a&&s.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:s.acpSessionId}),s.acpSessionId=void 0),h}if(s.spawnFailCount=0,s.spawnFailedAt=void 0,s.downstream=x,this.attachRuntimeHooks(e,r,s),s.acpSessionId){s.loadingSession=!0;try{await x.sessionLoad({sessionId:s.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId})}catch(h){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId,err:String(h)}),s.acpSessionId=void 0;let m=await x.sessionNew({cwd:e.workspace});s.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{s.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});s.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&s.acpSessionId&&await x.afterSessionEstablished(s.acpSessionId)}armIdleTimer(e,r,s){if(mi(s),this.isRuntimeBusy(e,s)){$.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)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,s);return}$.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=>$.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 l=e.activeGroupIds.get(r.acpSessionId);l&&(c.cozeGroupId=l)}await this.upstream.send(hi("session/update",{sessionId:s,update:a,_meta:c}))}forwardUpdate(e,r){let s=r.sessionId,a=this.reverseSessionId(e,s);if(!a){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:s});return}let c=e.sessions.get(a);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(ry(r)){$.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:s});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},l=e.activeTriggers.get(s);l&&(f.cozeTriggerMsgId=l);let x=e.activeGroupIds.get(s);x&&(f.cozeGroupId=x),this.upstream.send(hi("session/update",{...r,sessionId:a,_meta:f})).catch(h=>$.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}handleAgentRequest(e,r,s){if(s.method==="session/request_permission"){this.forwardPermissionRequest(e,r,s);return}if(s.method==="fs/write_text_file"||s.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,s);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:s.method}),r.respondAgentRequestError(s.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${s.method}`})}async handleFsRpcRequest(e,r,s){try{let a=e.workspace;if(s.method==="fs/write_text_file"){let c=s.params??{},f=await 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){$.warn("fs rpc handler failed",{agentId:e.agentId,method:s.method,err:String(a)}),r.respondAgentRequestError(s.id,gi(a))}}forwardPermissionRequest(e,r,s){let a=this.upstreamIds.next("session/request_permission"),c=s.params??{},l=c.sessionId,x=l?e.activeTriggers.get(l):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let m=l?e.activeGroupIds.get(l):void 0;m&&(h.cozeGroupId=m);let E=l?this.reverseSessionId(e,l):void 0,C={...c,...E?{sessionId:E}:{},_meta:h};this.pendingUpstream.set(a,{agentRequestId:s.id,agentId:e.agentId,downstream:r,method:s.method}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:l,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(_=>({optionId:_.optionId,kind:_.kind,name:_.name}))}),this.upstream.send(xi(a,"session/request_permission",C)).catch(_=>{this.pendingUpstream.delete(a),$.error("forward permission request failed",{agentId:e.agentId,err:String(_)}),r.respondAgentRequestError(s.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(_)}`})})}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?($.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"&&ny(e.result,a),$.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.agentRequestId,e.result));return}let 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 zs(e.error)):s.value.resolve(e.result);return}$.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 $.warn(`${s} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:f,key:c}}}sendRequest(e,r,s=X_){let a=this.upstreamIds.next(e);return new Promise((c,f)=>{let l=setTimeout(()=>{this.pendingBridge.delete(a),f(new D("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s);this.pendingBridge.set(a,{method:e,resolve:c,reject:f,timer:l}),this.upstream.send(xi(a,e,r)).catch(x=>{let h=this.pendingBridge.get(a);h&&(clearTimeout(h.timer),this.pendingBridge.delete(a)),f(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[s,a]of e.sessions){let c={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(c.acpSessionId=a.acpSessionId),r.set(s,c)}await Zo(e.agentId,r,this.paths)}catch(r){$.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(xn(e,{code:r,message:s,data:{bridgeVersion:gr}}))}};function ty(){return Y_(16).toString("hex")}function ny(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.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"){$.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")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function ry(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let s=r;return s.type!=="text"||typeof s.text!="string"?!1:s.text.startsWith("Model metadata for `")}ee();Me();import{randomBytes as iy}from"node:crypto";import{chmod as sy,mkdir as oy,writeFile as tu}from"node:fs/promises";import{createServer as ay}from"node:http";import{dirname as cy}from"node:path";var dy=1e6,vc=H("ipc"),Ys=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??te()}async start(){this.token=iy(32).toString("hex");let e=ay((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(),vc.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 oy(cy(this.paths.portFile),{recursive:!0}),await tu(this.paths.portFile,String(this.port),"utf8"),await tu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await sy(this.paths.tokenFile,384)}catch(e){vc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){yi(r,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(a);if(!c){yi(r,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await fy(e)}catch(l){yi(r,400,{error:"invalid json",detail:String(l)});return}try{let l=await c.handler(f,e);yi(r,200,l??{ok:!0})}catch(l){vc.error("IPC handler failed",{key:a,err:String(l)}),yi(r,500,{error:l instanceof Error?l.message:String(l)})}}};function yi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function fy(t){let e=[],r=0;for await(let a of t){let c=a;if(r+=c.length,r>dy)throw new Error("body too large");e.push(c)}let s=Buffer.concat(e).toString("utf8");return s?JSON.parse(s):null}var vx=gt(uu(),1);var GE=gt(ax(),1),KE=gt(ho(),1),WE=gt(vr(),1),$E=gt(Bc(),1),VE=gt(Uc(),1),JE=gt(Wc(),1),gx=gt(wo(),1),ZE=gt(px(),1);var mx=gx.default;ee();var Ie=H("upstream.frontier"),yx="application/json",Ex="none",XE=15e3,Di=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){Ie.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Yf,...hr(this.opts.ppeOverride)};class r extends mx{constructor(y){super(y,Zf,{headers:e})}send(y,...v){if(P0("debug"))try{let I;typeof y=="string"?I=Buffer.from(y,"utf8"):y instanceof Buffer?I=y:y instanceof ArrayBuffer?I=new Uint8Array(y):ArrayBuffer.isView(y)?I=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):I=new Uint8Array(0);let R=Buffer.from(I.slice(0,128)).toString("hex");Ie.debug("WS raw frame out",{bytes:I.byteLength,headHex:R})}catch(I){Ie.warn("WS raw frame dump failed",{err:String(I)})}super.send(y,...v)}}let s=Qf(this.opts.urlOverride),a={url:s,ws:r,fpID:Jf,aID:Ns,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:yx,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 vx.FWS(a),f=!1,l=null,x,h,m=new Promise((_,y)=>{x=_,h=y}),E=_=>{f||(f=!0,l&&(clearTimeout(l),l=null),_?h(_):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;Ie.info("frontier opened",{url:s,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&E();for(let y of this.connectHandlers)Promise.resolve(y({initial:_})).catch(v=>Ie.warn("onConnect handler threw (ignored)",{err:String(v)}))},c.onclose=_=>{this.opened=!1,Ie.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{Ie.warn("frontier error",{code:_.code,msg:_.message}),E(new D("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let C=this.opts.openTimeoutMs??XE;l=setTimeout(()=>{E(new D("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${C}ms (handshake or upgrade slow)`))},C),await c.connect();try{await m}catch(_){try{c.close(1e3,"open failed")}catch(y){Ie.warn("fws close during start failure threw (ignored)",{err:String(y)})}throw this.fws=null,this.opened=!1,_}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(s){Ie.warn("frontier close threw (ignored)",{err:String(s)})}}}async send(e){let r=this.fws,s=e.method;if(!r)throw Ie.warn("frontier send refused: upstream not started",{method:s}),new D("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let l=Date.now();throw l-this.lastSendRefusedLogAt>1e3?(Ie.warn("frontier send refused: ws not open",{method:s,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=l,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new D("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;bx(c)||Ie.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await r.send(a,{service:33555712,method:1,payloadType:yx,payloadEncoding:Ex})}catch(l){throw Ie.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(l)}),new D("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(l)}`,{cause:l})}}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){Ie.debug("drop non-adapter frontier frame",{service:r});return}let s=tb(e);if(!s){Ie.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ie.debug("frame received but no onFrame handler",{size:s.length});return}let a;try{a=JSON.parse(s)}catch(f){Ie.warn("frontier message JSON parse failed",{err:String(f),head:s.slice(0,80)});return}let c=a;bx(c)||Ie.info("frontier frame in",{logid:eb(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:QE(s)}),Promise.resolve(this.handler(a)).catch(f=>Ie.warn("frontier frame handler threw",{err:String(f)}))}};function bx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Sx=2e3;function QE(t){return t.length<=Sx?t:`${t.slice(0,Sx)}...<truncated, total ${t.length} chars>`}function eb(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function tb(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ee();var Vc=H("upstream.switchable"),yo=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()}};ee();var Jc=H("upstream"),Rr=class{handler=null;async start(){Jc.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Jc.info("NoopUpstream stopped",{reason:e})}async send(e){Jc.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};ee();ee();Me();import{promises as Zc}from"node:fs";import{dirname as nb}from"node:path";var rb=H("pat-token-store");async function Ix(t=te()){try{let r=(await Zc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&rb.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ri(t,e=te()){if(!t)throw new Error("writePatToken: empty patToken");await Zc.mkdir(nb(e.patTokenFile),{recursive:!0}),await Zc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Me();Me();import{promises as Eo}from"node:fs";import{join as ib}from"node:path";function sb(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 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(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new Ef(Vg(Jg(e),r),i)}},Vg=(t,e)=>e?Object.assign({},e,t):t,Jg=t=>t.replace(/\n$/,"").split(`
|
|
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 _0=10*1024*1024,Hs=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>_0){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${_0} bytes`)}),[]}let r=this.buffer.split(`
|
|
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
|
+
`),h=Math.max(0,(t.line??1)-1),x=typeof t.limit=="number"?h+t.limit:void 0;c=f.slice(h,x).join(`
|
|
87
|
+
`)}else c=l}return V0.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function Py(t,e,r){let i=Oy({input:by(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,l=[],f=0;try{for await(let h of i)if(f>=o&&f<c&&l.push(h),f++,f>=c)break}finally{i.close()}return l.join(`
|
|
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
|
|
89
89
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
90
|
-
`}function
|
|
90
|
+
`}function V1(t,e){return`@echo off\r
|
|
91
91
|
"${e}" "${t}" %*\r
|
|
92
|
-
`}async function Ax(t,e=te()){let r=e.binDir;await Eo.mkdir(r,{recursive:!0});let s=ib(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.execPath,c=process.platform==="win32"?ob(t,a):sb(t,a);return await Eo.readFile(s,"utf8").catch(()=>null)===c||(await Eo.writeFile(s,c,"utf8"),process.platform!=="win32"&&await Eo.chmod(s,493)),r}ee();Me();import{execSync as Tx}from"node:child_process";import{readFileSync as Dx,unlinkSync as ab}from"node:fs";import{mkdir as cb,readFile as Rx,unlink as kx,writeFile as db}from"node:fs/promises";import{dirname as fb}from"node:path";function Cx(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var lb=H("single-instance"),bo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??te().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(lb.warn("removing stale pid file",{stalePid:e}),await kx(this.pidFile).catch(()=>{})),await cb(fb(this.pidFile),{recursive:!0}),await db(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Rx(this.pidFile,"utf8")).trim()===String(process.pid)&&await kx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Rx(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 Cx(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=Tx(`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=Tx(`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)&&ab(this.pidFile)}catch{}})}};var G=H("daemon"),ub="coze-bridge-daemon";async function Px(){let t=new bo({processTitle:ub}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Js(),s=r??{};Li({pid:process.pid}),G.info(r?"loaded bridge config":"initialized bridge config");try{let O=new gn;s.frameworksCache=await O.detectAll(),G.info("refreshed frameworks_cache",{detected:Object.keys(s.frameworksCache)})}catch(O){G.warn("framework detection failed",{err:String(O)})}await Er(s);let a=new yo(new Rr),c=te(),f=null,l=new Zs({upstream:a,paths:c,bridgeConfig:s,sessionSpawner:async(O,N,U,W)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(O,N,U,W)}});await hb(c,l);let x=new Ws({paths:c,config:s,registry:l});f=x;let h,m,E=null,C={},_,y=null;l.registerExtension("_agent/create",async O=>x.createAgent(O.params)),l.registerExtension("_agent/health",async()=>({ok:!0}));let v={},I=new Bs({agents:l.agents,disposeAndMarkDisconnected:async(O,N)=>{let U=l.agents.get(O);if(U){await x.cleanupOpenclawSessionProviders(U).catch(se=>G.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(se)}));let W=!0;try{await U.dispose(`disconnect: ${N}`)}catch(se){W=!1,G.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(se)}),U.status="error"}W&&(U.status="disconnected",l.unregister(O),l.disconnectedAgents.add(O))}else l.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!v.ref)throw new Error("agent-detail-sync not initialized yet");await v.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,N)=>{await x.openclawRepair(O,N)},isRuntimePendingPermission:O=>l.hasPendingPermissionFor(O)});l.registerExtension("_agent/listSkills",O=>I.listSkills(O.params)),l.registerExtension("_agent/addSkills",O=>I.addSkills(O.params)),l.registerExtension("_agent/removeSkills",O=>I.removeSkills(O.params)),l.registerExtension("_agent/getFileTree",O=>I.getFileTree(O.params)),l.registerExtension("_agent/getFileContent",O=>I.getFileContent(O.params)),l.registerExtension("_agent/update",O=>I.updateAgent(O.params)),l.registerExtension("_agent/disconnect",O=>I.disconnectAgent(O.params)),l.registerExtension("_agent/switchModel",O=>I.switchModel(O.params)),l.registerExtension("_agent/reset",O=>I.resetAgent(O.params)),l.registerExtension("_agent/repair",O=>I.repairAgent(O.params));let R=new Gi({paths:c,handlers:I,sendDetail:O=>l.sendRequest("_agent/detail",O)});v.ref=R;let L=async O=>{await Promise.allSettled(O.map(async N=>{try{await I.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),G.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(U){G.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(U)})}}))};a.onConnect(({initial:O})=>{G.info("frontier upstream connected, triggering detail sync",{initial:O}),R.syncAll(O?"initial-connect":"reconnect").catch(N=>G.warn("detail sync top-level error (ignored)",{err:String(N)}))});let w=new Ys({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let O=l.getMockScenario();return{running:!0,pid:process.pid,agents:[...l.agents.keys()],deviceId:E??"",frameworksCache:s.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let N=O,U=N?.privatecode,W=N?.pairing_code;if(!U||!W)throw new D("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let se=fi(N.env),fe=N.handshake_url,we=N.frontier_url,Le=Ox(N.env,fe,we),ot=!!h&&h!==U,Ae=m!==void 0&&m!==Le,Gt=ot||Ae,_e=await oc({privatecode:U,...fe?{endpoint:fe}:{},ppeOverride:se});if(Gt){G.warn("pair config switched, resetting agents",{pcChanged:ot,envChanged:Ae,previousPc:h?So(h):"",nextPc:So(U),previousEnvKey:m??"",nextEnvKey:Le});for(let ge of[...l.agents.values()])await ge.dispose("pair config switch").catch(()=>{}),l.agents.delete(ge.agentId);l.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on pair config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new Rr,"pair switch").catch(()=>{})}E=_e.deviceId,Li({deviceId:E,pid:process.pid}),bc({patToken:U,env:N.env}).catch(ge=>G.warn("coze-cli setup error (ignored)",{err:String(ge)}));let Y=new Di({handshake:_e,privatecode:U,...we?{urlOverride:we}:{},ppeOverride:se,getPatTokenForAgent:ge=>l.agents.get(ge)?.patToken});await a.swap(Y,"pair");try{let ge=new gn;s.frameworksCache=await ge.detectAll(),await Er(s),G.info("frameworks_cache refreshed before pair",{detected:Object.keys(s.frameworksCache)})}catch(ge){G.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ge)})}let Un=Object.keys(s.frameworksCache??{});try{let ge=await l.sendRequest("_agent/pair",{pairCode:W,patToken:U,frameworks:Un,_meta:{cozeDeviceId:E}});G.info("_agent/pair ok",{pairResult:ge}),h=U,m=Le,C=se,_=fe,N.mock_scenario!==void 0&&(l.setMockScenario(N.mock_scenario),G.info("mock scenario set",{scenario:N.mock_scenario})),Ri(U,c).catch(Ke=>G.warn("writePatToken after /pair failed (ignored)",{err:String(Ke)})),y||(y=new ui({core:l,getDeviceId:()=>E??"",onTickEnd:()=>R.retryPending().catch(Ke=>G.warn("detailSync.retryPending failed (ignored)",{err:String(Ke)})),onAuthFailures:L})),y.start(),Gt&&vo(c,x).catch(Ke=>G.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ke)}));let qn;return N.agent_id&&(qn=await pb(N.agent_id,c,x,Ke=>l.sendRequest("_agent/detail",Ke),U).catch(Ke=>(G.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(Ke)}),{ok:!1,agentId:N.agent_id??"",note:String(Ke)}))),{ok:!0,note:"paired with cloud",...qn?{agent:qn}:{}}}catch(ge){return G.error("_agent/pair failed",{err:String(ge)}),{ok:!1,note:`pair failed: ${String(ge)}`}}}},{method:"POST",path:"/connect",handler:async O=>{let N=O,U=N?.privatecode;if(!U)throw new D("IPC_BAD_REQUEST","/connect requires privatecode");let W=fi(N.env),se=N.handshake_url,fe=N.frontier_url,we=Ox(N.env,se,fe);if(h===U&&m===we){let Y=await xb(c);return l.agents.size===0&&Y?(G.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),vo(c,x).catch(Un=>G.warn("connect-noop auto-revive error (ignored)",{err:String(Un)}))):G.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Le=!!h&&h!==U,ot=m!==void 0&&m!==we,Ae=Le||ot,Gt=await oc({privatecode:U,...se?{endpoint:se}:{},ppeOverride:W});if(Ae){G.warn("connect config switched, resetting agents",{pcChanged:Le,envChanged:ot,previousPc:h?So(h):"",nextPc:So(U)});for(let Y of[...l.agents.values()])await Y.dispose("connect config switch").catch(()=>{}),l.agents.delete(Y.agentId);l.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on connect config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new Rr,"connect switch").catch(()=>{})}E=Gt.deviceId,Li({deviceId:E,pid:process.pid}),bc({patToken:U,env:N.env}).catch(Y=>G.warn("coze-cli setup error (ignored)",{err:String(Y)}));let _e=new Di({handshake:Gt,privatecode:U,...fe?{urlOverride:fe}:{},ppeOverride:W,getPatTokenForAgent:Y=>l.agents.get(Y)?.patToken});return await a.swap(_e,"connect"),h=U,m=we,C=W,_=se,N.mock_scenario!==void 0&&(l.setMockScenario(N.mock_scenario),G.info("mock scenario set",{scenario:N.mock_scenario})),y||(y=new ui({core:l,getDeviceId:()=>E??"",onTickEnd:()=>R.retryPending().catch(Y=>G.warn("detailSync.retryPending failed (ignored)",{err:String(Y)})),onAuthFailures:L})),y.start(),Ae&&vo(c,x).catch(Y=>G.warn("post-connect-switch auto-revive error (ignored)",{err:String(Y)})),Ri(U,c).catch(Y=>G.warn("writePatToken after /connect failed (ignored)",{err:String(Y)})),G.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async O=>{let N=O;return{ok:!0,result:await x.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async O=>{let N=O;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new D("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new D("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let U=N;return await(U.groupFile?Fl:zl)(U,{core:l,patToken:h,handshakeBase:_,ppeOverride:C})}catch(U){if(U instanceof D)return{ok:!1,code:U.code,message:U.message};throw U}}},{method:"POST",path:"/refresh",handler:async()=>{G.info("IPC /refresh: re-detecting frameworks");let O=new gn;return s.frameworksCache=await O.detectAll(),await Er(s),{ok:!0,frameworks:s.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(G.info("IPC /shutdown received"),setImmediate(()=>{z.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:A,token:k}=await w.start();try{await Ax(c.libEntry,c)}catch(O){G.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await l.start(),vo(c,x).catch(O=>G.warn("auto-revive top-level error (ignored)",{err:String(O)})),H0().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(Zt(),U0));for(let N of["claude-code","codex"]){let U=await O(N);U&&G.info("acp wrapper version",{framework:N,version:U})}}).catch(O=>G.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let F=null,z={port:A,token:k,core:l,ipc:w,shutdown(O){return F||(G.info("daemon shutdown",{reason:O}),F=(async()=>{y?.stop(),await l.stop(O),await w.stop(),await t.release()})(),F)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{z.shutdown(O).then(()=>process.exit(0))});return process.on("unhandledRejection",O=>{G.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{G.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name}),process.exit(1)}),G.info("daemon ready",{port:A,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(s.frameworksCache??{}),libVersion:s.libVersion??"dev"}),z}async function xb(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 Ox(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function hb(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(()=>(Yt(),ji));for(let f of s){await c(f,t).catch(l=>G.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(l)}));try{let l=await a(f,t);l?.disconnectedAt&&(e.disconnectedAgents.add(f),G.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){G.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(l)})}}}async function pb(t,e,r,s,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Yt(),ji)),f=await c(t,e);if(f){G.info("--agent-id: local config found, reconnecting",{agentId:t,framework:f.framework,hadDisconnect:!!f.disconnectedAt});let m={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{}};return await r.createAgent(m),{ok:!0,agentId:t,note:f.disconnectedAt?"revived from local config":"connected from local config"}}G.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let l=await s({_meta:{cozeAgentId:t}});if(!l.framework)throw new D("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:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...a?{patToken:a}:{},...l.deployType?{_meta:{cozeDeployType:l.deployType}}:{}};await r.createAgent(x);let h=l.deployType==="cloud"&&l.framework==="openclaw";return{ok:!0,agentId:t,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function vo(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(()=>(Yt(),ji));G.info("auto-revive: scanning local agents on startup",{count:s.length});let c=0,f=0;for(let l of s){let x;try{x=await a(l,t)}catch(h){G.warn("auto-revive: load config failed (skipping)",{agentId:l,err:String(h)}),f+=1;continue}if(!x){f+=1;continue}if(x.disconnectedAt){G.info("auto-revive: skip disconnected agent",{agentId:l,disconnectedAt:x.disconnectedAt}),f+=1;continue}try{G.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:l,framework:x.framework});let h=gb(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...h?{_meta:h}:{}}),c+=1}catch(h){G.warn("auto-revive: createAgent failed (skipping)",{agentId:l,framework:x.framework,err:String(h)}),f+=1}}return G.info("auto-revive: done",{revived:c,skipped:f,total:s.length}),{revived:c,skipped:f,total:s.length}}function gb(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();Me();import{readFile as Lx}from"node:fs/promises";var jt=class{paths;constructor(e){this.paths=e??te()}async probe(e=1e3){let r=await Io(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:vb(s)}}}async request(e){let r=await Io(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 l=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 l.text();return{status:l.status,body:Sb(x)}}finally{clearTimeout(f)}}};async function Io(t){try{let[e,r]=await Promise.all([Lx(t.portFile,"utf8"),Lx(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 Sb(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function vb(t){return t instanceof Error?t.message:String(t)}ee();Me();import{copyFile as Nx,mkdir as Ib,readFile as e0,writeFile as Ab}from"node:fs/promises";import{homedir as s5}from"node:os";import{dirname as Cb,resolve as t0,sep as Ao}from"node:path";import{fileURLToPath as Tb}from"node:url";ee();Me();var Mx=H("dist-install");function Db(t){let e=Tb(t),r=Cb(e),s=`${Ao}src${Ao}`;if(r.includes(s)||r.endsWith(`${Ao}src${Ao}cli`))return null;let a=t0(r,"index.js"),c=t0(r,"..","package.json");return{dist:a,pkgJson:c}}async function n0(t={}){let e=t.paths??te(),r=Db(import.meta.url),s=t.sourceDist??r?.dist,a=t.sourcePackageJson??r?.pkgJson;if(!s||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let c;try{c=JSON.parse(await e0(a,"utf8")).version??"unknown"}catch(E){return Mx.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 Js(e.configFile)??{},l=f.libVersion;if(l===c)try{return await e0(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await Ib(e.libDir,{recursive:!0}),await Nx(s,e.libEntry),await Nx(`${s}.map`,`${e.libEntry}.map`).catch(()=>{});let x=t0(e.libDir,"package.json"),h=`${JSON.stringify({type:"module"},null,2)}
|
|
93
|
-
`;return await
|
|
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 ed(h,"utf8").catch(()=>null)!==x&&await xE(h,x),l.libVersion=c,await br(l,e.configFile),Mh.info("dist installed",{libEntry:e.libEntry,fromVersion:f,toVersion:c}),f?{kind:"version-changed",fromVersion:f,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}import{basename as wE,resolve as yE}from"node:path";Be();var _E=9e4,EE={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 bE(t){return EE[t]??1}async function Bh(t,e={}){let r=e.paths??ee();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 i=await Ao(r).catch(()=>null);if(!i)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 o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:yE(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(i,"/agent/send",o,_E)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
|
|
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
|
|
102
|
-
`)}function
|
|
98
|
+
`),bE(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
99
|
+
`);else{let l=t.name??wE(o.path);if(t.groupFile){let f=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${l} (uri=${f})
|
|
100
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${SE(c.bytes)})
|
|
101
|
+
`)}return 0}async function vE(t,e,r,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let l=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:o.signal}),f=await l.text(),h=f?JSON.parse(f):null;return h&&typeof h=="object"&&"ok"in h?h:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${l.status}): ${f.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 Wh=q("cli");function Fe(t,e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o];if(c===e){i=t[o+1],o+=1;continue}if(c.startsWith(`${e}=`)){i=c.slice(e.length+1);continue}r.push(c)}return{value:i,rest:r}}function Oi(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
102
|
+
`)}function GE(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 jE(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:i,rest:o}=Fe(r,"--pat-token");r=o;let{value:c,rest:l}=Fe(r,"--pair-code");r=l;let{value:f,rest:h}=Fe(r,"--env");r=h;let{value:x,rest:m}=Fe(r,"--handshake-url");r=m;let{value:_,rest:A}=Fe(r,"--frontier-url");r=A;let{value:y,rest:E}=Fe(r,"--mock-scenario");r=E;let{value:S}=Fe(r,"--agent-id");if(!i||!c)return{mode:"help"};let I={mode:"pair",privatecode:i,pairingCode:c};return f&&(I.env=f),x&&(I.handshakeUrl=x),_&&(I.frontierUrl=_),y&&(I.mockScenario=y),S&&(I.agentId=S),I}function jE(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.startsWith("--"))return{mode:"help"};let i=t.slice(2),{value:o,rest:c}=Fe(i,"--caption");i=c;let{value:l,rest:f}=Fe(i,"--name");i=f;let{value:h,rest:x}=Fe(i,"--agent-id");i=x;let{value:m,rest:_}=Fe(i,"--session-id");i=_;let{value:A,rest:y}=Fe(i,"--mime");i=y;let E=i.includes("--group-file");i=i.filter(R=>R!=="--group-file");let S=i.includes("--json"),I={mode:"send",kind:e,path:r,json:S};return o&&(I.caption=o),l&&(I.name=l),h&&(I.agentId=h),m&&(I.sessionId=m),E&&(I.groupFile=!0),A&&(I.mimeType=A),I}function WE(t){let e=t,{value:r,rest:i}=Fe(e,"--pat-token");e=i;let{value:o,rest:c}=Fe(e,"--env");e=c;let{value:l,rest:f}=Fe(e,"--handshake-url");e=f;let{value:h,rest:x}=Fe(e,"--frontier-url");e=x;let{value:m,rest:_}=Fe(e,"--mock-scenario");e=_;let A={mode:"connect"};return r&&(A.privatecode=r),o&&(A.env=o),l&&(A.handshakeUrl=l),h&&(A.frontierUrl=h),m&&(A.mockScenario=m),A}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 Kh(t=process.argv,e={}){let r=GE(t);switch(r.mode){case"help":return process.stdout.write(KE),0;case"version":return process.stdout.write(`${gr}
|
|
170
|
+
`),0;case"daemon":{try{await Ph()}catch(i){return Wh.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return $E(e);case"stop":return VE(e);case"refresh":return JE(e);case"purge":return ZE(e);case"service-install":return YE(e);case"service-uninstall":return XE(e);case"pair":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),QE(r.privatecode,r.pairingCode,e,i,r.agentId)}case"connect":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),eb(r.privatecode,e,i)}case"send":return Bh({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 $h(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??ee(),r=new jt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
171
|
+
`),1;if(i.kind==="stale")return await $h(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
172
|
+
`),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
173
|
+
${JSON.stringify(o.body,null,2)}
|
|
174
|
+
`),0}async function VE(t){let e=t.paths??ee(),r=new jt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
175
|
+
`),0;if(i.kind==="stale")return await $h(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(o){return process.stdout.write(`coze-bridge: stop failed: ${String(o)}
|
|
178
|
+
`),1}}async function JE(t){let e=new jt(t.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
179
|
+
`),1;try{let i=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return i.status===200?(process.stdout.write(`coze-bridge: refreshed
|
|
180
|
+
${JSON.stringify(i.body,null,2)}
|
|
181
|
+
`),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(i.body)}
|
|
182
|
+
`),1)}catch(i){return process.stderr.write(`coze-bridge: refresh failed: ${String(i)}
|
|
183
|
+
`),1}}async function cd(t){if(t.supervisor){let c=t.supervisor,l={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:()=>c.install(l),uninstall:()=>c.uninstall(l)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(jh(),Gh)),i=e(),o=r();return{platform:i.platform,install:()=>i.install(o),uninstall:()=>i.uninstall(o)}}async function ZE(t){let e=new jt(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(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
|
|
185
|
+
`)}await new Promise(l=>setTimeout(l,500))}let i=await cd(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
186
|
+
`)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
187
|
+
`)}let o=t.paths??ee(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
|
|
188
|
+
`)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
|
|
189
189
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
190
|
-
`),0}async function
|
|
190
|
+
`),0}async function YE(t){let e=await cd(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
|
|
193
|
+
`),1}}async function XE(t){let e=await cd(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
|
|
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,i={},o){let c=new jt(r.paths),l=r.spawnDaemon??Xc;if(!r.skipDistInstall){let x=await nd({paths:r.paths});x.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${x.fromVersion} \u2192 ${x.toVersion}
|
|
196
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):x.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${x.libVersion}
|
|
197
|
+
`)}let f=await c.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
198
|
+
`),await l({paths:r.paths}),f=await Vh(c,r.waitTimeoutMs??1e4,r.sleep??Jh),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
|
|
199
|
+
`),1;let h={privatecode:t,pairing_code:e};i.env&&(h.env=i.env),i.handshakeUrl&&(h.handshake_url=i.handshakeUrl),i.frontierUrl&&(h.frontier_url=i.frontierUrl),i.mockScenario&&(h.mock_scenario=i.mockScenario),o&&(h.agent_id=o);try{let x=await c.request({method:"POST",path:"/pair",body:h,timeoutMs:35e3});if(x.status===200&&x.body?.ok){let m=x.body.agent;return m&&!m.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${m.agentId}): ${m.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(x.body)}
|
|
202
|
+
`),1}catch(x){return process.stderr.write(`coze-bridge: pair failed: ${String(x)}
|
|
203
|
+
`),1}}async function eb(t,e,r={}){let i=e.paths??ee(),o=t??await Ih(i);if(!o)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 jt(e.paths),l=e.spawnDaemon??Xc;if(!e.skipDistInstall){let x=await nd({paths:e.paths});x.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${x.fromVersion} \u2192 ${x.toVersion}
|
|
204
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):x.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${x.libVersion}
|
|
205
|
+
`)}let f=await c.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
206
|
+
`),await l({paths:e.paths}),f=await Vh(c,e.waitTimeoutMs??1e4,e.sleep??Jh),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
|
|
207
|
+
`),1;let h={privatecode:o};r.env&&(h.env=r.env),r.handshakeUrl&&(h.handshake_url=r.handshakeUrl),r.frontierUrl&&(h.frontier_url=r.frontierUrl),r.mockScenario&&(h.mock_scenario=r.mockScenario);try{let x=await c.request({method:"POST",path:"/connect",body:h,timeoutMs:35e3});return x.status===200&&x.body?.ok?(process.stdout.write(`coze-bridge: connected (${x.body.note??"ok"})
|
|
208
|
+
`),await Di(o,i).catch(m=>Wh.warn("writePatToken after connect failed (ignored)",{err:String(m)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(x.body)}
|
|
209
|
+
`),1)}catch(x){return process.stderr.write(`coze-bridge: connect failed: ${String(x)}
|
|
210
|
+
`),1}}async function Vh(t,e,r){let i=Date.now()+e;for(;Date.now()<i;){let o=await t.probe(500);if(o.kind==="connected")return o;await r(200)}return t.probe(500)}function Jh(t){return new Promise(e=>setTimeout(e,t))}Q();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&Od("warn");Kh(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)});
|