coze-bridge 0.1.77 → 0.1.78

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.
Files changed (2) hide show
  1. package/dist/index.js +73 -73
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,27 +5,27 @@ 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 zx=Object.create;var jo=Object.defineProperty;var Fx=Object.getOwnPropertyDescriptor;var Ux=Object.getOwnPropertyNames;var Hx=Object.getPrototypeOf,qx=Object.prototype.hasOwnProperty;var ce=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var ct=(t,e)=>()=>(t&&(e=t(t=0)),e);var ne=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Go=(t,e)=>{for(var r in e)jo(t,r,{get:e[r],enumerable:!0})},jx=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ux(e))!qx.call(t,o)&&o!==r&&jo(t,o,{get:()=>e[o],enumerable:!(i=Fx(e,o))||i.enumerable});return t};var pt=(t,e,r)=>(r=t!=null?zx(Hx(t)):{},jx(e||!t||!t.__esModule?jo(r,"default",{value:t,enumerable:!0}):r,t));function Rd(t){Wo=t}function Dd(t){return Ni[Wo]<=Ni[t]}function Mi(t){Cd={...t}}function Kx(t){let e=(u,h=2)=>String(u).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 Oi(t,e,r,i){if(Ni[t]<Ni[Wo])return;let o=JSON.stringify({ts:Kx(new Date),level:t,module:e,msg:r,...Cd,...i});t==="error"||t==="warn"?Wx.write(`${o}
9
- `):Gx.write(`${o}
10
- `)}function q(t){return{debug:(e,r)=>Oi("debug",t,e,r),info:(e,r)=>Oi("info",t,e,r),warn:(e,r)=>Oi("warn",t,e,r),error:(e,r)=>Oi("error",t,e,r),child:e=>q(`${t}.${e}`)}}var Ni,Wo,Gx,Wx,Cd,ee=ct(()=>{"use strict";Ni={debug:10,info:20,warn:30,error:40},Wo=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Gx=process.stdout,Wx=process.stderr,Cd={}});import{execFile as $x,spawn as Vx,spawnSync as d1}from"node:child_process";import{promisify as Jx}from"node:util";function Yx(t){if(process.platform!=="win32")return!1;if(kd.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(kd,"").toLowerCase();return Zx.has(r)}function Pd(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return Yx(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function Gn(t,e=[],r={}){return Vx(t,e,Pd(t,r))}function Wn(t,e=[],r={}){return Xx(t,e,Pd(t,r))}var Zx,kd,Xx,Kn=ct(()=>{"use strict";Zx=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp"]),kd=/\.(cmd|bat|ps1)$/i;Xx=Jx($x)});var Md={};Go(Md,{_resetAcpInstallerForTests:()=>ap,_setInFlightForTests:()=>cp,ensureAcpInstalled:()=>mn,formatExecError:()=>Nd,getAcpBinaryPath:()=>wn,getAcpPackageSpec:()=>Nr,getInFlightInstall:()=>$o,pickWhichLine:()=>Bi,probeAcpVersion:()=>sp});function Nr(t){let e=Ko[t];if(e)return`${e.npmPackage}@${e.versionSpec}`}function ip(t){let e=t?.code;if(e&&tp.has(e))return!0;let r=t instanceof Error?`${t.message}
11
- ${t.stack??""}`:String(t);return np.test(r)||rp.test(r)}function Nd(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 Ld(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await Wn(e,[t],{timeout:Od});return Bi(r)}catch{return}}function Bi(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 sp(t){let e=Ko[t];if(e)try{let{stdout:r}=await Wn(e.binary,["--version"],{timeout:Od});return r.split(`
12
- `)[0]?.trim()||void 0}catch{return}}async function op(t,e,r){Lr.info("npm install -g start",{npmPackage:t,versionSpec:e}),await Wn("npm",["install","-g",`${t}@${e}`],{timeout:Qx,maxBuffer:10*1024*1024,...r?{signal:r}:{}}),Lr.info("npm install -g done",{npmPackage:t,versionSpec:e})}async function mn(t,e){let r=Ko[t];if(!r)return;let i=Or.get(t);if(i)return i;let o=Pr.get(t);if(o&&Date.now()-o<ep)return;let c=$n.get(t);if(c)return c;let l=(async()=>{let u=await Ld(r.binary);if(u)return Or.set(t,u),Lr.info("acp wrapper found on PATH",{binary:r.binary,path:u}),u;try{await op(r.npmPackage,r.versionSpec,e)}catch(p){let w=ip(p);Lr.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:r.npmPackage,transient:w,err:Nd(p)}),w||Pr.set(t,Date.now());return}let h=await Ld(r.binary);if(!h){Lr.warn("acp wrapper installed but binary not found on PATH",{binary:r.binary}),Pr.set(t,Date.now());return}return Or.set(t,h),Pr.delete(t),h})().finally(()=>{$n.delete(t)});return $n.set(t,l),l}function wn(t){return Or.get(t)}function $o(t){return $n.get(t)}function ap(){Or.clear(),Pr.clear(),$n.clear()}function cp(t,e){$n.set(t,e)}var Lr,Ko,Qx,Od,ep,tp,np,rp,Or,Pr,$n,$t=ct(()=>{"use strict";Kn();ee();Lr=q("agents.acp-installer"),Ko={"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"}};Qx=5e4,Od=5e3,ep=5*6e4,tp=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),np=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,rp=/fetch failed|request timed out|socket hang up|network timeout/i;Or=new Map,Pr=new Map,$n=new Map});import{chmod as lp,mkdir as fp,readFile as up,rename as Fd,writeFile as Ud}from"node:fs/promises";import{dirname as hp}from"node:path";async function Vn(t){try{let e=await up(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function zi(t,e,r){await fp(hp(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
13
- `,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await Ud(o,i,{encoding:"utf8",mode:r.mode}):await Ud(o,i,"utf8"),await Fd(o,t),r?.mode!==void 0&&await lp(t,r.mode)}catch(c){await Fd(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Fi=ct(()=>{"use strict"});import{promises as Hd}from"node:fs";import{homedir as xp}from"node:os";import{sep as pp,join as ze,resolve as qd}from"node:path";function te(t){let e=t??xp(),r=ze(e,".coze"),i=ze(r,"bridge"),o=ze(i,"lib");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:ze(o,"index.js"),binDir:ze(i,"bin"),pidFile:ze(i,"bridge.pid"),portFile:ze(i,"bridge.port"),tokenFile:ze(i,"bridge.token"),patTokenFile:ze(i,"pat-token"),logFile:ze(i,"bridge.log"),installLock:ze(i,"install.lock"),configFile:ze(i,"config.json"),agentsRoot:ze(r,"agents")}}function Dt(t,e=te()){let r=ze(e.agentsRoot,t);return{root:r,config:ze(r,"config.json"),workspace:ze(r,"workspace"),logs:ze(r,"logs")}}async function Mr(t,e){let r=await Hd.realpath(qd(t)).catch(()=>null);if(!r)return!1;let i=await Hd.realpath(qd(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+pp)}var Fe=ct(()=>{"use strict"});var qi={};Go(qi,{AGENT_CONFIG_FILE_MODE:()=>Ui,enforceAgentConfigMode:()=>wp,loadAgentConfig:()=>qe,persistAgentSessions:()=>Vo,persistAgentSkills:()=>Hi,saveAgentConfig:()=>$e});import{chmod as gp,stat as mp}from"node:fs/promises";function qe(t,e){return Vn(Dt(t,e).config)}function $e(t,e){return zi(Dt(t.agentId,e).config,t,{mode:Ui})}async function wp(t,e){if(process.platform==="win32")return;let r=Dt(t,e).config;try{let i=await mp(r);if(!i.isFile())return;let o=i.mode&511;o!==Ui&&(await gp(r,Ui),jd.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;jd.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Vo(t,e,r){let i=await qe(t,r);i&&(i.sessions=Object.fromEntries(e),await $e(i,r))}async function Hi(t,e,r){let i=await qe(t,r);i&&(i.skills=e,await $e(i,r))}var jd,Ui,Vt=ct(()=>{"use strict";Fi();ee();Fe();jd=q("agent-config"),Ui=384});var Zo=ne((M1,$d)=>{$d.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 Gi=ne(Jd=>{var Vd={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 Ap(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(Vd))Jd[t]=Ap(Vd[t])});var e0=ne((z1,Qd)=>{var Tp=ce("fs"),Ie=ce("path"),Zd=Zo(),Cp=Gi(),Rp=typeof process=="object"&&process.platform==="win32",Yd=t=>typeof t=="object"&&t!==null,Xd=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function me(t){this.sep=Ie.sep,this.fs=Tp,Yd(t)&&Yd(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Qd.exports=me;me.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(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(l&&l.isFile())throw Cp.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};me.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=Ie.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var u;try{u=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),u=o.fs.openSync(t,"w",438)}if(u)try{o.fs.writeSync(u,e,0,e.length,0)}finally{o.fs.closeSync(u)}return o.fs.chmodSync(t,i||438),!0};me.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(u,h){if(l&&h.isDirectory())return o(!1);var p=Ie.dirname(t);c.fs.exists(p,function(w){w||c.makeDir(p),c.fs.open(t,"w",438,function(b,A){b?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,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)})})})})})};me.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(u){let h=Ie.join(i,u),p=e.fs.statSync(h);(!o||o.test(h))&&l.push(Ie.normalize(h)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(l=l.concat(r(h,o,c)))}),l}return r(t,void 0,!0)};me.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(u){u=Ie.join(t,u),r.fs.stat(u,function(h,p){if(h)return e(h);p&&(i.push(Ie.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(w,b){if(w)return e(w);i=i.concat(b),--l||e(null,i)}):--l||e(null,i))})})})};me.prototype.getAttributes=function(){};me.prototype.setAttributes=function(){};me.crc32update=function(t,e){return Xd[(t^e)&255]^t>>>8};me.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=me.crc32update(r,t[i++]);return~r>>>0};me.methodToString=function(t){switch(t){case Zd.STORED:return"STORED ("+t+")";case Zd.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};me.canonical=function(t){if(!t)return"";let e=Ie.posix.normalize("/"+t.split("\\").join("/"));return Ie.join(".",e)};me.zipnamefix=function(t){if(!t)return"";let e=Ie.posix.normalize("/"+t.split("\\").join("/"));return Ie.posix.join(".",e)};me.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};me.sanitize=function(t,e){t=Ie.resolve(Ie.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Ie.normalize(Ie.join(t,r.slice(i,o).join(Ie.sep)));if(c.indexOf(t)===0)return c}return Ie.normalize(Ie.join(t,Ie.basename(e)))};me.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};me.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};me.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};me.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};me.isWin=Rp;me.crcTable=Xd});var n0=ne((F1,t0)=>{var Dp=ce("path");t0.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=Dp.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 i0=ne((U1,r0)=>{r0.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Yn=ne((H1,Zn)=>{Zn.exports=e0();Zn.exports.Constants=Zo();Zn.exports.Errors=Gi();Zn.exports.FileAttr=n0();Zn.exports.decoder=i0()});var o0=ne((q1,s0)=>{var Jt=Yn(),H=Jt.Constants;s0.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,h=0,p=0,w=0,b=0,A=0,_=0,E=0;t|=Jt.isWin?2560:768,r|=H.FLG_EFS;let v={extraLen:0},I=y=>Math.max(0,y)>>>0,k=y=>Math.max(0,y)&65535,O=y=>Math.max(0,y)&255;return o=Jt.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&H.FLG_EFS)>0},set flags_efs(y){y?r|=H.FLG_EFS:r&=~H.FLG_EFS},get flags_desc(){return(r&H.FLG_DESC)>0},set flags_desc(y){y?r|=H.FLG_DESC:r&=~H.FLG_DESC},get method(){return i},set method(y){switch(y){case H.STORED:this.version=10;case H.DEFLATED:default:this.version=20}i=y},get time(){return Jt.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=Jt.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=I(y)},get timeHighByte(){return O(o>>>8)},get crc(){return c},set crc(y){c=I(y)},get compressedSize(){return l},set compressedSize(y){l=I(y)},get size(){return u},set size(y){u=I(y)},get fileNameLength(){return h},set fileNameLength(y){h=y},get extraLength(){return p},set extraLength(y){p=y},get extraLocalLength(){return v.extraLen},set extraLocalLength(y){v.extraLen=y},get commentLength(){return w},set commentLength(y){w=y},get diskNumStart(){return b},set diskNumStart(y){b=I(y)},get inAttr(){return A},set inAttr(y){A=I(y)},get attr(){return _},set attr(y){_=I(y)},get fileAttr(){return(_||0)>>16&4095},get offset(){return E},set offset(y){E=I(y)},get encrypted(){return(r&H.FLG_ENC)===H.FLG_ENC},get centralHeaderSize(){return H.CENHDR+h+p+w},get realDataOffset(){return E+H.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(y){var C=y.slice(E,E+H.LOCHDR);if(C.readUInt32LE(0)!==H.LOCSIG)throw Jt.Errors.INVALID_LOC();v.version=C.readUInt16LE(H.LOCVER),v.flags=C.readUInt16LE(H.LOCFLG),v.flags_desc=(v.flags&H.FLG_DESC)>0,v.method=C.readUInt16LE(H.LOCHOW),v.time=C.readUInt32LE(H.LOCTIM),v.crc=C.readUInt32LE(H.LOCCRC),v.compressedSize=C.readUInt32LE(H.LOCSIZ),v.size=C.readUInt32LE(H.LOCLEN),v.fnameLen=C.readUInt16LE(H.LOCNAM),v.extraLen=C.readUInt16LE(H.LOCEXT);let L=E+H.LOCHDR+v.fnameLen,F=L+v.extraLen;return y.slice(L,F)},loadFromBinary:function(y){if(y.length!==H.CENHDR||y.readUInt32LE(0)!==H.CENSIG)throw Jt.Errors.INVALID_CEN();t=y.readUInt16LE(H.CENVEM),e=y.readUInt16LE(H.CENVER),r=y.readUInt16LE(H.CENFLG),i=y.readUInt16LE(H.CENHOW),o=y.readUInt32LE(H.CENTIM),c=y.readUInt32LE(H.CENCRC),l=y.readUInt32LE(H.CENSIZ),u=y.readUInt32LE(H.CENLEN),h=y.readUInt16LE(H.CENNAM),p=y.readUInt16LE(H.CENEXT),w=y.readUInt16LE(H.CENCOM),b=y.readUInt16LE(H.CENDSK),A=y.readUInt16LE(H.CENATT),_=y.readUInt32LE(H.CENATX),E=y.readUInt32LE(H.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(H.LOCHDR);return y.writeUInt32LE(H.LOCSIG,0),y.writeUInt16LE(e,H.LOCVER),y.writeUInt16LE(r,H.LOCFLG),y.writeUInt16LE(i,H.LOCHOW),y.writeUInt32LE(o,H.LOCTIM),y.writeUInt32LE(c,H.LOCCRC),y.writeUInt32LE(l,H.LOCSIZ),y.writeUInt32LE(u,H.LOCLEN),y.writeUInt16LE(h,H.LOCNAM),y.writeUInt16LE(v.extraLen,H.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(H.CENHDR+h+p+w);return y.writeUInt32LE(H.CENSIG,0),y.writeUInt16LE(t,H.CENVEM),y.writeUInt16LE(e,H.CENVER),y.writeUInt16LE(r,H.CENFLG),y.writeUInt16LE(i,H.CENHOW),y.writeUInt32LE(o,H.CENTIM),y.writeUInt32LE(c,H.CENCRC),y.writeUInt32LE(l,H.CENSIZ),y.writeUInt32LE(u,H.CENLEN),y.writeUInt16LE(h,H.CENNAM),y.writeUInt16LE(p,H.CENEXT),y.writeUInt16LE(w,H.CENCOM),y.writeUInt16LE(b,H.CENDSK),y.writeUInt16LE(A,H.CENATT),y.writeUInt32LE(_,H.CENATX),y.writeUInt32LE(E,H.CENOFF),y},toJSON:function(){let y=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:Jt.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(l),size:y(u),fileNameLength:y(h),extraLength:y(p),commentLength:y(w),diskNumStart:b,inAttr:A,attr:_,offset:E,centralHeaderSize:y(H.CENHDR+h+p+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var c0=ne((j1,a0)=>{var Xn=Yn(),he=Xn.Constants;a0.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 he.ENDHDR+o},loadFromBinary:function(c){if((c.length!==he.ENDHDR||c.readUInt32LE(0)!==he.ENDSIG)&&(c.length<he.ZIP64HDR||c.readUInt32LE(0)!==he.ZIP64SIG))throw Xn.Errors.INVALID_END();c.readUInt32LE(0)===he.ENDSIG?(t=c.readUInt16LE(he.ENDSUB),e=c.readUInt16LE(he.ENDTOT),r=c.readUInt32LE(he.ENDSIZ),i=c.readUInt32LE(he.ENDOFF),o=c.readUInt16LE(he.ENDCOM)):(t=Xn.readBigUInt64LE(c,he.ZIP64SUB),e=Xn.readBigUInt64LE(c,he.ZIP64TOT),r=Xn.readBigUInt64LE(c,he.ZIP64SIZE),i=Xn.readBigUInt64LE(c,he.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(he.ENDHDR+o);return c.writeUInt32LE(he.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,he.ENDSUB),c.writeUInt16LE(e,he.ENDTOT),c.writeUInt32LE(r,he.ENDSIZ),c.writeUInt32LE(i,he.ENDOFF),c.writeUInt16LE(o,he.ENDCOM),c.fill(" ",he.ENDHDR),c},toJSON:function(){let c=function(l,u){let h=l.toString(16).toUpperCase();for(;h.length<u;)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 Xo=ne(Yo=>{Yo.EntryHeader=o0();Yo.MainHeader=c0()});var l0=ne((W1,d0)=>{d0.exports=function(t){var e=ce("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(u){c.push(u),l+=u.length}),o.on("end",function(){var u=Buffer.alloc(l),h=0;u.fill(0);for(var p=0;p<c.length;p++){var w=c[p];w.copy(u,h),h+=w.length}i&&i(u)}),o.end(t)}}}});var u0=ne((K1,f0)=>{var kp=+(process.versions?process.versions.node:"").split(".")[0]||0;f0.exports=function(t,e){var r=ce("zlib");let i=kp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],u=0;c.on("data",function(h){l.push(h),u+=h.length}),c.on("end",function(){var h=Buffer.alloc(u),p=0;h.fill(0);for(var w=0;w<l.length;w++){var b=l[w];b.copy(h,p),p+=b.length}o&&o(h)}),c.end(t)}}}});var m0=ne(($1,g0)=>{"use strict";var{randomFillSync:h0}=ce("crypto"),Pp=Gi(),Lp=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}),p0=(t,e)=>Math.imul(t,e)>>>0,x0=(t,e)=>Lp[(t^e)&255]^t>>>8,Br=()=>typeof h0=="function"?h0(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 Wi={genSalt:Br};function Ki(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])}Ki.prototype.updateKeys=function(t){let e=this.keys;return e[0]=x0(e[0],t),e[1]+=e[0]&255,e[1]=p0(e[1],134775813)+1,e[2]=x0(e[2],e[1]>>>24),t};Ki.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return p0(t,t^1)>>8&255};function Op(t){let e=new Ki(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 Np(t){let e=new Ki(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 Mp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Op(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Pp.WRONG_PASSWORD();return i(t.slice(12))}function Bp(t){Buffer.isBuffer(t)&&t.length>=12?Wi.genSalt=function(){return t.slice(0,12)}:t==="node"?Wi.genSalt=Br.node:Wi.genSalt=Br}function zp(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Np(r),c=Wi.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)}g0.exports={decrypt:Mp,encrypt:zp,_salter:Bp}});var w0=ne($i=>{$i.Deflater=l0();$i.Inflater=u0();$i.ZipCrypto=m0()});var ea=ne((J1,y0)=>{var re=Yn(),Fp=Xo(),we=re.Constants,Qo=w0();y0.exports=function(t,e){var r=new Fp.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),h=Buffer.alloc(0),p=!0;let w=t,b=typeof w.decoder=="object"?w.decoder:re.decoder;p=b.hasOwnProperty("efs")?b.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){if(!r.flags_desc&&!r.localHeader.flags_desc){if(re.crc32(y)!==r.localHeader.crc)return!1}else{let C={},L=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(L)==we.LOCSIG||e.readUInt32LE(L)==we.CENSIG)throw re.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(L)==we.EXTSIG)C.crc=e.readUInt32LE(L+we.EXTCRC),C.compressedSize=e.readUInt32LE(L+we.EXTSIZ),C.size=e.readUInt32LE(L+we.EXTLEN);else if(e.readUInt16LE(L+12)===19280)C.crc=e.readUInt32LE(L+we.EXTCRC-4),C.compressedSize=e.readUInt32LE(L+we.EXTSIZ-4),C.size=e.readUInt32LE(L+we.EXTLEN-4);else throw re.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==r.compressedSize||C.size!==r.size||C.crc!==r.crc)throw re.Errors.DESCRIPTOR_FAULTY();if(re.crc32(y)!==C.crc)return!1}return!0}function E(y,C,L){if(typeof C>"u"&&typeof y=="string"&&(L=y,y=void 0),c)return y&&C&&C(Buffer.alloc(0),re.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=A();if(F.length===0)return y&&C&&C(F),F;if(r.encrypted){if(typeof L!="string"&&!Buffer.isBuffer(L))throw re.Errors.INVALID_PASS_PARAM();F=Qo.ZipCrypto.decrypt(F,r,L)}var z=Buffer.alloc(r.size);switch(r.method){case re.Constants.STORED:if(F.copy(z),_(z))return y&&C&&C(z),z;throw y&&C&&C(z,re.Errors.BAD_CRC()),re.Errors.BAD_CRC();case re.Constants.DEFLATED:var P=new Qo.Inflater(F,r.size);if(y)P.inflateAsync(function(N){N.copy(N,0),C&&(_(N)?C(N):C(N,re.Errors.BAD_CRC()))});else{if(P.inflate(z).copy(z,0),!_(z))throw re.Errors.BAD_CRC(`"${b.decode(i)}"`);return z}break;default:throw y&&C&&C(Buffer.alloc(0),re.Errors.UNKNOWN_METHOD()),re.Errors.UNKNOWN_METHOD()}}function v(y,C){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&C&&C(A()),A();if(l.length&&!c){var L;switch(r.method){case re.Constants.STORED:return r.compressedSize=r.size,L=Buffer.alloc(l.length),l.copy(L),y&&C&&C(L),L;default:case re.Constants.DEFLATED:var F=new Qo.Deflater(l);if(y)F.deflateAsync(function(P){L=Buffer.alloc(P.length),r.compressedSize=P.length,P.copy(L),C&&C(L)});else{var z=F.deflate();return r.compressedSize=z.length,z}F=null;break}}else if(y&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function I(y,C){return re.readBigUInt64LE(y,C)}function k(y){try{for(var C=0,L,F,z;C+4<y.length;)L=y.readUInt16LE(C),C+=2,F=y.readUInt16LE(C),C+=2,z=y.slice(C,C+F),C+=F,we.ID_ZIP64===L&&O(z)}catch{throw re.Errors.EXTRA_FIELD_PARSE_ERROR()}}function O(y){var C,L,F,z;y.length>=we.EF_ZIP64_SCOMP&&(C=I(y,we.EF_ZIP64_SUNCOMP),r.size===we.EF_ZIP64_OR_32&&(r.size=C)),y.length>=we.EF_ZIP64_RHO&&(L=I(y,we.EF_ZIP64_SCOMP),r.compressedSize===we.EF_ZIP64_OR_32&&(r.compressedSize=L)),y.length>=we.EF_ZIP64_DSN&&(F=I(y,we.EF_ZIP64_RHO),r.offset===we.EF_ZIP64_OR_32&&(r.offset=F)),y.length>=we.EF_ZIP64_DSN+4&&(z=y.readUInt32LE(we.EF_ZIP64_DSN),r.diskNumStart===we.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return b.decode(i)},get rawEntryName(){return i},set entryName(y){i=re.toBuffer(y,b.encode);var C=i[i.length-1];c=C===47||C===92,r.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return u},set extra(y){u=y,r.extraLength=y.length,k(y)},get comment(){return b.decode(o)},set comment(y){if(o=re.toBuffer(y,b.encode),r.commentLength=o.length,o.length>65535)throw re.Errors.COMMENT_TOO_LONG()},get name(){var y=b.decode(i);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return v(!1,null)},getCompressedDataAsync:function(y){v(!0,y)},setData:function(y){l=re.toBuffer(y,re.decoder.encode),!c&&l.length?(r.size=l.length,r.method=re.Constants.DEFLATED,r.crc=re.crc32(y),r.changed=!0):r.method=re.Constants.STORED},getData:function(y){return r.changed?l:E(!1,null,y)},getDataAsync:function(y,C){r.changed?y(l):E(!0,y,C)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var y=r.centralHeaderToBinary(),C=re.Constants.CENHDR;return i.copy(y,C),C+=i.length,u.copy(y,C),C+=r.extraLength,o.copy(y,C),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=h.length;let C=r.localHeaderToBinary(),L=Buffer.alloc(C.length+i.length+r.extraLocalLength);return C.copy(L,y),y+=C.length,i.copy(L,y),y+=i.length,h.copy(L,y),y+=h.length,L},toJSON:function(){let y=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var E0=ne((Z1,b0)=>{var _0=ea(),Up=Xo(),Ue=Yn();b0.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Up.MainHeader,l=!1,u=null;let h=new Set,p=e,{noSort:w,decoder:b}=p;t?E(p.readEntries):l=!0;function A(){let I=new Set;for(let k of Object.keys(i)){let O=k.split("/");if(O.pop(),!!O.length)for(let y=0;y<O.length;y++){let C=O.slice(0,y+1).join("/")+"/";I.add(C)}}for(let k of I)if(!(k in i)){let O=new _0(p);O.entryName=k,O.attr=16,O.temporary=!0,r.push(O),i[O.entryName]=O,h.add(O)}}function _(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/Ue.Constants.CENHDR)throw Ue.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var I=c.offset,k=0;k<r.length;k++){var O=I,y=new _0(p,t);y.header=t.slice(O,O+=Ue.Constants.CENHDR),y.entryName=t.slice(O,O+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(O,O+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(O,O+y.header.commentLength)),I+=y.header.centralHeaderSize,r[k]=y,i[y.entryName]=y}h.clear(),A()}function E(I){var k=t.length-Ue.Constants.ENDHDR,O=Math.max(0,k-65535),y=O,C=t.length,L=-1,F=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(O=0),k;k>=y;k--)if(t[k]===80){if(t.readUInt32LE(k)===Ue.Constants.ENDSIG){L=k,F=k,C=k+Ue.Constants.ENDHDR,y=k-Ue.Constants.END64HDR;continue}if(t.readUInt32LE(k)===Ue.Constants.END64SIG){y=O;continue}if(t.readUInt32LE(k)===Ue.Constants.ZIP64SIG){L=k,C=k+Ue.readBigUInt64LE(t,k+Ue.Constants.ZIP64SIZE)+Ue.Constants.ZIP64LEAD;break}}if(L==-1)throw Ue.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(L,C)),c.commentLength&&(o=t.slice(F+Ue.Constants.ENDHDR)),I&&_()}function v(){r.length>1&&!w&&r.sort((I,k)=>I.entryName.toLowerCase().localeCompare(k.entryName.toLowerCase()))}return{get entries(){return l||_(),r.filter(I=>!h.has(I))},get comment(){return b.decode(o)},set comment(I){o=Ue.toBuffer(I,b.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||_(),i[I]||null},setEntry:function(I){l||_(),r.push(I),i[I.entryName]=I,c.totalEntries=r.length},deleteFile:function(I,k=!0){l||_();let O=i[I];this.getEntryChildren(O,k).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){l||_();let k=i[I],O=r.indexOf(k);O>=0&&(r.splice(O,1),delete i[I],c.totalEntries=r.length)},getEntryChildren:function(I,k=!0){if(l||_(),typeof I=="object")if(I.isDirectory&&k){let O=[],y=I.entryName;for(let C of r)C.entryName.startsWith(y)&&O.push(C);return O}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let k=this.getEntryChildren(I);return k.includes(I)?k.length-1:k.length}return 0},compressToBuffer:function(){l||_(),v();let I=[],k=[],O=0,y=0;c.size=0,c.offset=0;let C=0;for(let z of this.entries){let P=z.getCompressedData();z.header.offset=y;let N=z.packLocalHeader(),U=N.length+P.length;y+=U,I.push(N),I.push(P);let W=z.packCentralHeader();k.push(W),c.size+=W.length,O+=U+W.length,C++}O+=c.mainHeaderSize,c.offset=y,c.totalEntries=C,y=0;let L=Buffer.alloc(O);for(let z of I)z.copy(L,y),y+=z.length;for(let z of k)z.copy(L,y),y+=z.length;let F=c.toBinary();return o&&o.copy(F,Ue.Constants.ENDHDR),F.copy(L,y),t=L,l=!1,L},toAsyncBuffer:function(I,k,O,y){try{l||_(),v();let C=[],L=[],F=0,z=0,P=0;c.size=0,c.offset=0;let N=function(U){if(U.length>0){let W=U.shift(),oe=W.entryName+W.extra.toString();O&&O(oe),W.getCompressedDataAsync(function(ue){y&&y(oe),W.header.offset=z;let be=W.packLocalHeader(),Be=be.length+ue.length;z+=Be,C.push(be),C.push(ue);let ot=W.packCentralHeader();L.push(ot),c.size+=ot.length,F+=Be+ot.length,P++,N(U)})}else{F+=c.mainHeaderSize,c.offset=z,c.totalEntries=P,z=0;let W=Buffer.alloc(F);C.forEach(function(ue){ue.copy(W,z),z+=ue.length}),L.forEach(function(ue){ue.copy(W,z),z+=ue.length});let oe=c.toBinary();o&&o.copy(oe,Ue.Constants.ENDHDR),oe.copy(W,z),t=W,l=!1,I(W)}};N(Array.from(this.entries))}catch(C){k(C)}}}}});var I0=ne((Y1,S0)=>{var pe=Yn(),xe=ce("path"),Hp=ea(),qp=E0(),yn=(...t)=>pe.findLast(t,e=>typeof e=="boolean"),v0=(...t)=>pe.findLast(t,e=>typeof e=="string"),jp=(...t)=>pe.findLast(t,e=>typeof e=="function"),Gp={noSort:!1,readEntries:!1,method:pe.Constants.NONE,fs:null};S0.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Gp);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=pe.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new pe(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=pe.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=pe.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw pe.Errors.INVALID_FILENAME();let c=new qp(r,i),{canonical:l,sanitize:u,zipnamefix:h}=pe;function p(_){if(_&&c){var E;if(typeof _=="string"&&(E=c.getEntry(xe.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(E=c.getEntry(_.entryName)),E)return E}return null}function w(_){let{join:E,normalize:v,sep:I}=xe.posix;return E(xe.isAbsolute(_)?"/":".",v(I+_.split("\\").join(I)+I))}function b(_){return _ instanceof RegExp?(function(E){return function(v){return E.test(v)}})(_):typeof _!="function"?()=>!0:_}let A=(_,E)=>{let v=E.slice(-1);return v=v===o.sep?o.sep:"",xe.relative(_,E)+v};return{readFile:function(_,E){var v=p(_);return v&&v.getData(E)||null},childCount:function(_){let E=p(_);if(E)return c.getChildCount(E)},readFileAsync:function(_,E){var v=p(_);v?v.getDataAsync(E):E(null,"getEntry failed for:"+_)},readAsText:function(_,E){var v=p(_);if(v){var I=v.getData();if(I&&I.length)return I.toString(E||"utf8")}return""},readAsTextAsync:function(_,E,v){var I=p(_);I?I.getDataAsync(function(k,O){if(O){E(k,O);return}k&&k.length?E(k.toString(v||"utf8")):E("")}):E("")},deleteFile:function(_,E=!0){var v=p(_);v&&c.deleteFile(v.entryName,E)},deleteEntry:function(_){var E=p(_);E&&c.deleteEntry(E.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,E){var v=p(_);v&&(v.comment=E)},getZipEntryComment:function(_){var E=p(_);return E&&E.comment||""},updateFile:function(_,E){var v=p(_);v&&v.setData(E)},addLocalFile:function(_,E,v,I){if(o.fs.existsSync(_)){E=E?w(E):"";let k=xe.win32.basename(xe.win32.normalize(_));E+=v||k;let O=o.fs.statSync(_),y=O.isFile()?o.fs.readFileSync(_):Buffer.alloc(0);O.isDirectory()&&(E+=o.sep),this.addFile(E,y,I,O)}else throw pe.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,E){_=typeof _=="object"?_:{localPath:_};let v=xe.resolve(_.localPath),{comment:I}=_,{zipPath:k,zipName:O}=_,y=this;o.fs.stat(v,function(C,L){if(C)return E(C,!1);k=k?w(k):"";let F=xe.win32.basename(xe.win32.normalize(v));if(k+=O||F,L.isFile())o.fs.readFile(v,function(z,P){return z?E(z,!1):(y.addFile(k,P,I,L),setImmediate(E,void 0,!0))});else if(L.isDirectory())return k+=o.sep,y.addFile(k,Buffer.alloc(0),I,L),setImmediate(E,void 0,!0)})},addLocalFolder:function(_,E,v){if(v=b(v),E=E?w(E):"",_=xe.normalize(_),o.fs.existsSync(_)){let I=o.findFiles(_),k=this;if(I.length)for(let O of I){let y=xe.join(E,A(_,O));v(y)&&k.addLocalFile(O,xe.dirname(y))}}else throw pe.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,E,v,I){I=b(I),v=v?w(v):"",_=xe.normalize(_);var k=this;o.fs.open(_,"r",function(O){if(O&&O.code==="ENOENT")E(void 0,pe.Errors.FILE_NOT_FOUND(_));else if(O)E(void 0,O);else{var y=o.findFiles(_),C=-1,L=function(){if(C+=1,C<y.length){var F=y[C],z=A(_,F).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(z)?o.fs.stat(F,function(P,N){P&&E(void 0,P),N.isFile()?o.fs.readFile(F,function(U,W){U?E(void 0,U):(k.addFile(v+z,W,"",N),L())}):(k.addFile(v+z+"/",Buffer.alloc(0),"",N),L())}):process.nextTick(()=>{L()})}else E(!0,void 0)};L()}})},addLocalFolderAsync2:function(_,E){let v=this;_=typeof _=="object"?_:{localPath:_},localPath=xe.resolve(w(_.localPath));let{zipPath:I,filter:k,namefix:O}=_;k instanceof RegExp?k=(function(L){return function(F){return L.test(F)}})(k):typeof k!="function"&&(k=function(){return!0}),I=I?w(I):"",O=="latin1"&&(O=L=>L.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof O!="function"&&(O=L=>L);let y=L=>xe.join(I,O(A(localPath,L))),C=L=>xe.win32.basename(xe.win32.normalize(O(L)));o.fs.open(localPath,"r",function(L){L&&L.code==="ENOENT"?E(void 0,pe.Errors.FILE_NOT_FOUND(localPath)):L?E(void 0,L):o.findFilesAsync(localPath,function(F,z){if(F)return E(F);z=z.filter(P=>k(y(P))),z.length||E(void 0,!1),setImmediate(z.reverse().reduce(function(P,N){return function(U,W){if(U||W===!1)return setImmediate(P,U,!1);v.addLocalFileAsync({localPath:N,zipPath:xe.dirname(y(N)),zipName:C(N)},P)}},E))})})},addLocalFolderPromise:function(_,E){return new Promise((v,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},E),(k,O)=>{k&&I(k),O&&v(this)})})},addFile:function(_,E,v,I){_=h(_);let k=p(_),O=k!=null;O||(k=new Hp(i),k.entryName=_),k.comment=v||"";let y=typeof I=="object"&&I instanceof o.fs.Stats;y&&(k.header.time=I.mtime);var C=k.isDirectory?16:0;let L=k.isDirectory?16384:32768;return y?L|=4095&I.mode:typeof I=="number"?L|=4095&I:L|=k.isDirectory?493:420,C=(C|L<<16)>>>0,k.attr=C,k.setData(E),O||c.setEntry(k),k},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return p(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,E,v,I,k,O){I=yn(!1,I),k=yn(!1,k),v=yn(!0,v),O=v0(k,O);var y=p(_);if(!y)throw pe.Errors.NO_ENTRY();var C=l(y.entryName),L=u(E,O&&!y.isDirectory?O:v?C:xe.basename(C));if(y.isDirectory){var F=c.getEntryChildren(y);return F.forEach(function(N){if(N.isDirectory)return;var U=N.getData();if(!U)throw pe.Errors.CANT_EXTRACT_FILE();var W=l(N.entryName),oe=u(E,v?W:xe.basename(W));let ue=k?N.header.fileAttr:void 0;o.writeFileTo(oe,U,I,ue)}),!0}var z=y.getData(c.password);if(!z)throw pe.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(L)&&!I)throw pe.Errors.CANT_OVERRIDE();let P=k?_.header.fileAttr:void 0;return o.writeFileTo(L,z,I,P),!0},test:function(_){if(!c)return!1;for(var E in c.entries)try{if(E.isDirectory)continue;var v=c.entries[E].getData(_);if(!v)return!1}catch{return!1}return!0},extractAllTo:function(_,E,v,I){if(v=yn(!1,v),I=v0(v,I),E=yn(!1,E),!c)throw pe.Errors.NO_ZIP();c.entries.forEach(function(k){var O=u(_,l(k.entryName));if(k.isDirectory){o.makeDir(O);return}var y=k.getData(I);if(!y)throw pe.Errors.CANT_EXTRACT_FILE();let C=v?k.header.fileAttr:void 0;o.writeFileTo(O,y,E,C);try{o.fs.utimesSync(O,k.header.time,k.header.time)}catch{throw pe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,E,v,I){if(I=jp(E,v,I),v=yn(!1,v),E=yn(!1,E),!I)return new Promise((L,F)=>{this.extractAllToAsync(_,E,v,function(z){z?F(z):L(this)})});if(!c){I(pe.Errors.NO_ZIP());return}_=xe.resolve(_);let k=L=>u(_,xe.normalize(l(L.entryName))),O=(L,F)=>new Error(L+': "'+F+'"'),y=[],C=[];c.entries.forEach(L=>{L.isDirectory?y.push(L):C.push(L)});for(let L of y){let F=k(L),z=v?L.header.fileAttr:void 0;try{o.makeDir(F),z&&o.fs.chmodSync(F,z),o.fs.utimesSync(F,L.header.time,L.header.time)}catch{I(O("Unable to create folder",F))}}C.reverse().reduce(function(L,F){return function(z){if(z)L(z);else{let P=xe.normalize(l(F.entryName)),N=u(_,P);F.getDataAsync(function(U,W){if(W)L(W);else if(!U)L(pe.Errors.CANT_EXTRACT_FILE());else{let oe=v?F.header.fileAttr:void 0;o.writeFileToAsync(N,U,E,oe,function(ue){ue||L(O("Unable to write file",N)),o.fs.utimes(N,F.header.time,F.header.time,function(be){be?L(O("Unable to set times",N)):L()})})}})}}},I)()},writeZip:function(_,E){if(arguments.length===1&&typeof _=="function"&&(E=_,_=""),!_&&i.filename&&(_=i.filename),!!_){var v=c.compressToBuffer();if(v){var I=o.writeFileTo(_,v,!0);typeof E=="function"&&E(I?null:new Error("failed"),"")}}},writeZipPromise:function(_,E){let{overwrite:v,perm:I}=Object.assign({overwrite:!0},E);return new Promise((k,O)=>{!_&&i.filename&&(_=i.filename),_||O("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let C=L=>L?k(L):O("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(_,y,v,I,C)},O)})},toBufferPromise:function(){return new Promise((_,E)=>{c.toAsyncBuffer(_,E)})},toBuffer:function(_,E,v,I){return typeof _=="function"?(c.toAsyncBuffer(_,E,v,I),null):c.compressToBuffer()}}}});var cu=ne(Te=>{"use strict";var M=J;function eo(){let t=["q0fjCeO","AMTezM4","s01zA3K","D05Zt2G","zw5HyMXLqxu","CYbWyxjHBxm","t1fLzhi","tufyx1jfvfi","x29Uq2XVC2u","ywvwsLG","ren6zMS","C2vUDa","t1DlAeq","zurVBKy","Dgv4Dc9WBge","y21du0q","yu5wq1q","BMrWB2LUDfq","B3LLyMy","CMvJB25Uzwm","C1POD2K","BLruwxG","u3viA3m","DeXKq3u","C2nYAxb0","y3jLyxrLrxi","quDTzMm","uxvPuue","zMzmAw5L","vg9rAvO","y2Hbt1a","DhbizwfKzxi","zw5XDwv1zq","sLnptLa","wMHhtey","weXSr3q","qxzcrxu","DxjS","uu5urK8","ywnRx2LK","u2DLzLK","AenSB3nLrxy","qxPXDNO","CNjVCK1LC3m","x2HHBMrSzvi","Dg9tDhjPBMC","B25LCNjVCG","tvPotxC","ExPLse4","C3rMELi","yvzTq3G","CMvHC29U","Dw5ZAwDUzwq","CKHcDMi","yu5QAMW","AxnbCNjHEq","wuf2B3K","qM1lD0W","BgvUz3rO","rMrTBhe","thn4yKO","yw5XqLq","uKjnBM4","uhLWzhy","twHUDfm","rfPxrwq","y3vYC29Yx24","txP2svm","uLrUzMK","ALPsu24","y3jLyxrLt3a","tLLSsLK","z2vjBMzVu3K","zvD4AuW","CgLUz1rPBwu","CMvQzwn0","tu1myNa","BhHQvw4","rvzvyuO","DgLTzw91DcW","B25mAw5L","zw5JB2rLrNi","Eer1wKu","B3bmCxC","EePqDxK","weHYDgy","r0XlywW","ywrKt25L","Bxzcz00","y2HHCKnVzgu","zM9YrwfJAa","Aw9U","Efrurw52","B25pCgvU","zNjHBwvuExa","quTxrei","EvHfz0e","mhW1Fdn8mNW","CIb0DhDjra","zxjHDg9Y","EMH4u1i","CM92AwrLihC","swHbuum","CMjTqMe","u0vbDg4","r3jet0G","yNLL","CgLUz0XVC3m","zcWG","uezdzKC","yNL0zu9MzNm","vw1KqNK","AxmGDw5Kzwy","CgLUz09Uy2u","y2HnyxHdB3u","EurUAeC","C3rLBMvYCW","EvLssxm","Cg9PBNrdB24","ExbL","mNWX","CKnPExm","ywnRtxnNswq","BfjyDNa","Axnby2TdBgu","yMfSrxzLBNq","u3n2EKK","zwrPyxrLBhK","tfLlve4","EKf4Dw4","B2zMC2v0","ywnRx2nVzgu","v0XorwG","rgjfzLu","D2n6DeC","x2HHBMrSzva","B2zMBgLUzq","rxztuwO","y2DpALi","uwXgC2O","sxLRy00","v3bfsfa","t1PZzNu","DLzuv2O","teXLz0q","BMP4sKK","swX4ChK","vffLuuC","tg9NsurozxC","x2rLyNvN","zgvJB2rLzey","q01tAvC","veDVEgG","DgLTzw91Da","CNzHBfzHBhu","DhbZtge","t0DIB0u","rgrrDK8","vKr3Dhy","y29UBMvJDa","vuDlr2m","swnuAvq","ue50tK8","Awzhsxe","u2TPCcbWyxm","B25SAw5L","DMvYC2LVBG","D0X0t2K","uK1msMu","Ahr0Ca","yMfRuMy","AKrPz3O","z2v0u3rVCMe","rejQvei","ug9TB2C","CwfeuLi","uhnLvgS","AMzbt0m","D2TjEKu","C2rHCwK","zw5NDgG","ChnHzLe","z2vY","r2DxteK","BLjjueG","CgvYC2LZDgu","D2LSBfjLy28","y3PdyuW","teXZEhC","yxnuvu0","ywrKq291BNq","C3rVCcbPBw0","B3jLtMfTzxm","uKfKDK0","Bg9NsurozxC","swvwsu0","D0jmu1O","y3vYCMvUDeu","wgnltxK","t09KAMy","vuzhtei","wMjRqwW","x0rctMfTzq","tvPWzKu","zxj2AwnL","uwXpC1y","yNvMzMvYzwq","u3Lsu1G","Cu9MCvK","m3W0Fdf8mNW","zg9Uzq","zw5KCg9PBNq","A0Hutva","vffctem","rgjJzNu","zwn0","twLZC2LUzYa","yLPqtgW","Cgf5Bg9Hzfq","ALvjv0W","rxrKruu","CMvZB2X2zq","y3vYC29Yx2y","zLjysLi","Dg1TDKq","ruHcwee","BNznvfO","zw5JB2rPBMC","CMvZDwX0","A2v5","AuDqCgC","DgLLCKPtt04","B1bOv2m","C3bSAwnL","DujtBe4","r3PSC2K","BIWGAg9ZDg4","ufngDwK","wfzKBge","yuHsuxK","sgLVy1C","CvP1rKC","AKDLyKq","uej4zvK","Cg1nC2i","vNLvzNi","r1PyAwO","BNruCMLLC0m","x29WDgLVBNm","CwD6EgG","DxrMofDYAxq","z2v0q3vYC28","revQu1C","zgzdEgm","Dev2zw50","rffQD0u","rwfAs0W","qNjPzgDL","x2rItMfTzq","CgfNzxnOB3C","yNL0zxm","A2XRyuO","yvzrr00","AKr6zw8","sK9wv0q","te1qvuW","y2jduMK","zu94vvq","BvjRv0S","DLfssgC","CMvJzwL2zwq","tvbNCKi","q291BNq","C2DPza","qu5Qvge","DMfSDwvZ","zMLN","zfbfBfe","yxKSihrYEsa","wLHQvuu","CMniwvK","zfrqrNi","y291BNq","DwTIBuW","BgLUzw5V","q29SCwG","CvvHz2C","DgvZDa","D1jSswu","C2vUzf9Hy2S","ANvbuMq","Dg9oDw1Izxi","CNnVCKzPBgu","EhzzuMi","Bwf4uMv0CMK","vLzeA1y","DLrmDw4","q0zfugK","mNWXFdr8m3W","Dg9iyxnO","BxbzEvG","EMTvrLm","rxHKtMK","D3m6lY8","D1zywvO","x29UrxjYB3i","BMDLza","qKrLsgG","CMvXDwLYzwq","yw5Tz0W","x2LZtM9Kzq","qwXgy1G","sNDSuKm","B2jQzwn0u3q","y29UBMvJDgK","tMrUu1q","CeTWuee","zMLSDgvY","x2LZqNjVD3m","AvDAD3G","jMPZy2fSBgi","yw5Hz2vY","C3bque4","CMvZzxruCMK","zfPjzKG","ihn1y2nLC3m","u3jhzvO","DcbSAw1PDa","Dw5KzwzPBMu","BhDYAMS","wxHbAKm","s0PnD24","CM92AwrLigi","ve5sB2e","C2v0sxrLBq","s0fWveW","EhbIEMi","v0TuEeC","sgXwvwm","B2nRzxrtDwm","ihrPBwvVDxq","qK9RC2q","uvb6wwq","A2v0ignVBNm","DgDPwLy","r3zVwKy","x3bYzwzPEa","ysbTDxn0igi","mta3ndq3mwvLCfbLqq","Bu9PtMW","x2nYzwf0zvm","DKjNAw0","B3bLCNr5tMe","AwLctfm","we1hB3C","AxnMAfi","CMTLCKDSB2i","qwnbDhm","tev5vwy","AKj1C0m","BKXPBMu","BvL2yMO","A0Pfv3m","y2vZC0HHBMq","z2v0qwXS","CMLgCxi","yw1LoIa","BMCGzMfPBgu","x2LZtwLUAvq","vvnyvhu","z2z0v0C","zNvUy3rPB24","q0Xpu0ve","zMn6qLy","txfutLa","u3rYyxrLz3K","B3nLrxzLBNq","CMfTzq","z2v0s2v5","mJGYndu2ANDIEhLW","zvvYBa","EfbYzem","qML4qNq","q2nOyxe","C3Dmu3C","tNr0twW","Euvsu0S","zwP4sKi","z3zYwuW","AwXLx25HBwu","sfD0CNa","AgDmrNe","z3buyLG","suTODfm","t2PJzfm","svffzNy","uMvJB25Uzwm","Dgnqz1G","ugfVChC","EM5NsNy","DfDtzgK","rKn1sMG","BvbLs1u","BwfW","A2v5CW","AwPVB3C","C2vUza","BxnNsuq","wxfdBeK","ihzHBgLKihm","y2XVC2u","CNnkv3a","yMnjveq","tuzvzNa","su5tvefova","z0nfwLy","EunoBKK","vvr0Bxy","Cgf5Bg9Hzeu","zxq9DxrMltG","uuLmqwy","x2rPC2nVBM4","tfH1Ce4","r0vtq2C","s3vzEeW","EMrRExi","CgLUz0LUDgu","BhHRqMq","yMLUyxj5vhK","D2HNrwW","vw5Tvfy","DeLUwhq","mtq0mdyXnfPKEfL3sa","y01lA2y","DhjPzxm","Cfrrqum","yxbWBgLJyxq","y3jLyxrLrwW","u3Hor2S","s3DIsuK","uNvQy2y","CMvHzfvjBNq","y0Pxquu","yMLUza","BwLZzq","CMfNzvn5BMm","AxnFywnR","ruTWCKG","DNLWueG","rLvcz2W","rePivLa","Bg93","x21LC3nHz2u","DMvUDa","Dgnwv1G","D2nKEvy","vxryAMi","zgLZywjSzue","revkCg4","tKTYyw8","x2LZv29YA2u","x3jLBw92zvC","EvjLy29UBMu","u2vXsuq","zM9Yy2u","tenOEwu","C2vYDMvYvgK","CfvVD3K","x3bHDgHlzxK","AxbwEuS","r3jws2W","Eg5tDM0","EfvZzuvUDG","B3jpBMXPBMu","tKDFrvjst1i","ChjPBvC","CwDKBfa","CgfNzwHPzgu","zwf6v04","vw5Oyw5KBgu","BunMEeK","DgPzEhm","rgrADhe","odi1mZzUzuzHBvO","x0vysvnu","ChbL","ru5ir2e","thLywLC","yMP5vKu","rwLoyNy","wLr1D0e","quTiwKK","txjot0e","qwnZshu","vfnXrgy","vfbuuNu","x2LUAxrqCM8","CuvHAeK","C2v0","ChvZAa","BwvZC2fNzv8","y2uGBM90igK","s3H0Dxe","q0HMAgC","sNHus2y","CMfUzg9T","DwLtC3G","z2v0","Aw5PDcbrB1m","ChPvC3K","zxjYB3i","qLfYsg0","z29PBMCGyxC","y05byMK","z0TjsgS","D0fbz00","AwXSihvZzsa","DgfIyMm","mJG4nJzrrLb3wu0","AxjLza","v2DMuKK","qLLUC0W","zxrxB3jRq2G","x2DLBMvYyxq","q29Kzq","suvtx0vsuK8","ig1LC3nHz2u","sM1nAwy","ywX3yxLZ","AwXK","wxznr04","u0fLBhe","zMLktw8","x2rYB3bhBg8","DNPUuLi","ChjVDg90Exa","ELzyA1G","Dg9mB3DLCKm","DgHHBIbSB2m","AwDHDg9Yt24","qu5Rqu8","BKD1AuW","x2n1CNnVCK0","C3vJy2vZCW","rKnrvgm","tg9Nsuq","BwvY","AgvHzgvYCW","r1fivg8","qxD5D00","BNzTDuu","C3bSAxq","Devfwu0","DhjHBNnHy3q","x2XPC3rLBMu","qMfTDgS","EeXXrMK","Eurcuva","zgvSzxrL","AxnAzxjV","x2rLC3rYB3K","x21PBMLoyxy","CKzryKm","zw5HyMXLuw8","y0vSChq","B1zwte8","u2DrDxm","D3jqBMO","tKHTsvG","q1LUr0m","zw50zwqGDhK","z1fbs3O","y0XUCKO","wvziChC","ALPQCeu","C0nVDw50zxi","zxjFywnRx20","r3jesuK","BMzsCe4","svzOAKm","C2XPy2u","EMPRuMG","teHyCwO","yvrXAKy","BM93","Dgv4Dc9Qyxy","D1vZEwq","DcbVzIbYyw4","v3byDxG","B25tDgfYDfi","EKzruNG","C2HPzNq","x2DLDeLUDgu","yxKSig5LDhC","BwfUDwfSihi","y3jLyxrLq2W","r3nsywi","rxjYB3jdB2q","zgr4vNC","y09Wzw4","y29UDgv4Da","Aw1MENO","zxmGCMvHy2G","De5bALG","tvvMvKO","sgrbEee","C2v0u3rVCMe","q0fksKy","sLPWsgi","BujvCu8","CefqweC","BMrWB2LUDca","CxzwtM4","yxv0B21HDgK","C3jJ","BgXvy1m","tu9KCgS","DKTPzMW","tKHPBuy","y3P3wem","y3jLyxrLuMu","A3jkvve","vezVEhu","wwHtCMS","Aw1LCYbPBIa","mxW0Fdj8m3W","tMjnDLu","ywXS","qwjVCNrfCNi","CMv0CNLdB3u","q2fAt2W","CgfYC2u","AevYCM9Yrxy","Cur5y3q","DxnLCKLW","zw50tgLZDgu","quPuCMq","C0D6B0i","DhDTC0i","s1f5wMS","Be5WD2G","BgvY","CMvKDwnL","DgrtALu","ywDLu2HVDW","rNjVBNrPzxi","v1zVCwW","ChL3tKS","A0Hurgu","BMjoELG","mJqXmti0nxvQzxrrEq","tefOsLO","uLjpuG","AM9PBG","rNnqBhG","rMfRD2W","zLPhzvu","u29ftw4","z2H2u2i","AMvJDfn0B3i","zMvY","EvDHBgG","swzkuNq","AgfZ","B3nLza","zNLjBLu","t1fuuKS","sej3wLq","zxf1ywXZ","verYq0W","tefAB2W","x19LC01Vzhu","zMX1C2HfEha","C2v0zgi","ihjLy29UBMu","t3rzALC","BMCGB3iGyw4","zxHWB3j0CW","yMXVy2TLza","DvHAtKy","rfPoAM0","qMvZDvu","y3jLyxrLt2i","BNrbBMrvCgq","sgLqt3e","CMvZzxrdB3u","wef6vLm","z0PfuKu","CM92AwrLige","DM9dEhG","v2jYr0O","EfnZCgS","vMfzA2C","o2nOyxjZzxq","D3z5ANe","DNbSsgK","x3bPBMDqB24","yKDbvue","zNryCg0","Dg9cExrLC0W","A1jKDhG","BwLUAvbYB2C","ywjVCNq","Ef9MCM9UDgK","yNvMzMvY","zxH0zw5ZAw8","vK1Tvxy","rKn4BKm","vxP1vva","De1HBMfNzxi","ywnRpwzYB24","rK5vANy","DMfS","x2LUAxq","y29UBMvJDeu","zu9MCgK","zxjYtM8","sgrJseK","D1bWBum","C0jf","wfnkCeK","vuTOCLy","C2fNzq","t2Devg4","x29UugfNzu4","t29ZCM4","tuvtu0fhrv8","CMvHzhLtDge","Cwzqv04","lcbTyxGGCMu","uM9krNO","q09oveLovuu","v2vIu29JA2u","s3nIv3C","ChjVDg9JB2W","s1PWu3y","C3L4t1C","B3jRzxjhBg8","x2n1CNnVCKy","yvrvwgS","AxrODwe","ueXAtfK","x2jPBMfYEvq","BMrLEa","D2zkCLG","ihzHBgLKigq","CKz3ELi","u21yt2C","y2f0y2G","Ae1IzNm","BNrfBMrWB2K","AfnsEMS","DeLUDgvYy2u","x3nVy2TLDa","r0jSs0u","s1viq0y","BgPvBuO","CYbHBhjLywq","Ce9swwu","BwHKvva","CMvTB3zLq2G","DerWzKW","u2Pgr1e","CM9YrxzLBNq","EhPKuhG","zxjFAxnFywm","Ee14C0S","igzPzwXKoIa","wgzHBMO","EsbJBg9Zzwq","D2vzzuO","AMDdCKS","zhfrtLO","tuDMqMW","wM9jvvy","x1fVu01HBMe","AgvKtwf4uMu","Bwf4twvZC2e","AvLpBu4","ywzL","BNflu2W","tMfMrM0","uuriDvu","uwzeree","y096Dvq","D3jPDgvvAw4","rLLzAwS","x2HHBMrSzu8","y2XVC2veqG","sLPKD0e","y3vYC29Y","wwXHrwe","we94r24","AwrI","vw5PBxbSzw0","B25szwnLAxy","EwPpvKG","s2nsz0O","yu9rDLm","x2nVBM5Ly3q","qujhrNq","zeXLwhu","Egz6A3O","tfnuu0i","yw1L","Cgu6ia","mdaWma","zhH2teK","y2XLyxi","B2nRzxq","vxPmy2e","zw1LBNq","y2HnyxHuCMK","BNzZrhO","vef6z3e","x3bPBMDmB3m","AuLrzfm","tenZy2y","uNPQC3q","ugvnDuy","zv9ZDwnJzxm","x3bYB3rVy28","CMvZzxrfBMq","vufyq3G","Dvfys0S","AKDwuKG","rxzLBNq","r1P5Efe","A2fUtvu","t1bftL9fuLi","yKnyq2G","EvnLz1G","x29UvgLTzw8","B25VCgvU","Bxv5twG","DMX1Afq","nxWX","y29UC3rYDwm","Bg9IywXty28","yxbWzw5Kq2G","ywXSq3vYC28","EMn4Cxu","swXUtwK","v0nivhG","yNnhDwC","z2v0q3vYCMu","y2XLyxjtDg8","BgLTAxq","y29UDgLUDwu","uKPPuhu","DhjPzxmGCMu","BMvY","AxnrB1nnzxm","B3bLBG","DgP3vMO","t1bftG","tg9MAvm","BNfVzKu","rgvKAwnHDgu","Cwrqs20","ugP2DwW","B3DHqu4","CKXYt3C","vgLTzw91Da","s0rNwfe","AvLzvLm","rNf4y2y","qLvXzfy","yLbjtNi","Bwv0Ag9K","C3vIyxjYyxK","Dgv4DfbHEwW","AMvoz1K","C3rYAw5NAwy","sNftALq","B25JBg9Zzq","sMvIzxm","wLDrq08","DeLK","x3nLCuLK","ywHouu8","vNfuEfa","Bg1ZsfC","BgLUzq","EwPqthq","ywDLsgLKzq","BMnVzgLUzW","tgT6Eem","Eg5dAMq","zvvAzNi","Aw5Lza","zvrJEfe","DvrsALq","zNbzy1C","z0rMvu0","DNPJENm","zfnrC2C","CgXLyxnLiha","su5du20","ChrVCG","A3vvAvG","C3nHz2vfDMu","uxvLDwu","Ahv2DNi","y1j6uMq","A21xAey","t25yDLm","yMLUyxj5","uLHVB0S","r0zRCM0","D1vqCxm","rxnYEe4","EfjvBKK","C0XpC1y","wwrqAKS","Cgf5Bg9Hza","mdaWmdaWmda","r0zluxa","BgLZDgvUtMu","yxrLq291BNq","BMCGDxjSoIa","lcbxzwjtB2m","t2LeDuy","tNDlANe","s0DdBva","uuXKweK","vhP1vgO","DunUBNm","yxbWBhK","CNnVCL92ywW","z251DNu","rLrIvKW","z0rqu2K","yM9KEq","Ae1Wv3q","DfPzCum","DhLWzq","se5dzxm","ugLTyMi","r1rNqNe","y3vYC29YlNm","yxjoC2u","zcbLCNjVCI4","yxGGCMv0CMK","ze96Bfy","B25ozxr3B3i","BwLUzW","BM5Ly3q","x3DZ","y1D2sNO","wgrPCeS","x2rPC3bHDgm","C3vIC3rYAw4","x2fKzfDZtgK","BwvZC2fNzq","x2n1CNnVCK4","rvf0CNy","s2zqtKO","rKTMqLu","B0jkCuu","y3ruAw1LB3u","ywnOzwq","zNjVBuj5Dgu","C0Herue","Cg9PBNrbBMq","A0fbD2K","rvfgENq","sLDYzvO","vevrwNO","sLj5wwK","C2v0q3vYC28","zgLbsum","zw1htfe","AgLNAa","nhW1","Aw9Ul2PZB24","C3rVCMu","y29UBMvJDca","EMTQugi","AwTOEgC","x2LZsw5PDa","CgLUz19VBMm","vNLzCgu","Ahr0Chm6","yLj6se8","sNrWyKi","BNrLCG","rhzVtuu","zgf0yq","y2XVC2uSihC","wMzHzu4","x3jLy29UBMu","A050wKm","yw5ZzM9YBvq","ign1CNnVCIa","BMfTzq","x3vYBa","u1Pey0q","qNPMDw4","B09PCvC","BLn2u3i","x2TLEvbHDgG","AefJA01LC3m","BeHmwfe","z2vtEw5J","A0vyB1y","CLzHBhvLCW","DLbYCw0","ALzktNu","t3P1zLi","BfrPBwvVDxq","v2LUzg93","vgjlwLi","DujOA2u","wgDyC0W","CNvWyKO","ueDxBu0","zfDPy3G","tfbiwhm","D24GCMvHC28","Aw9VvNK","zv90Aw1LB3u","CMvWBgfJzq","BeHHBMrSzxi","Bwf4tg9ZC0m","DxbNCMfKzw4","zNjVBu51Bwi","q3vZDg9Trxi","zKjwvwe","AgfZt3DUuhi","Dgngq3i","x3jLywr5q2W","C1HTsvi","tg9JAW","q29UzMLN","rvjxsMy","qvHQywy","qu94CLu","tez0yue","Dxrjza","tvPLrMm","AxnszwfKEq","q3PoD2O","DKHwBMO","t0DHruy","BMDuAw1LCG","vNHdD1u","uNPREfm","mxWYFdb8m3W","C01ozfq","odi2CMLjDunK","zgTTD20","BeXHC3m","B25nzxnZywC","C0Xf","y1rSy2q","A2TJDeW","BgvPD1u","B3bLBKrc","zgvMAw5Luhi","qNLyz3a","Axb1q00","shbrtwW","x3DZsw5ZDge","seD0A1y","CNzHBa","EhPiCwO","EenpvKe","x3DHAxq","zwrNz1y","DKrxzK8","EePIt04","rejWEwG","zMLSzw5HBwu","shHODLu","y1zcwvq","z2PJwuC","BLjbEKy","EwnpCLa","BvzftNG","vefnENq","B3jRig9MzMW","t3bLBKv2zw4","Cw9Zx18","D3nZoI8V","AgvUvLy","Dhr3Awq","B2zM","q09otKvdveK","BeDOzeC","BMvJDa","CLrrq0u","B2zrEuW","uNHNsuK","BNrcue4","B3bLBIa","yLLYqwy","CKTRzfm","ywrK","qLzkDw0","t01pzeG","CgjICdi","q0vMAfm","BKfpqNG","vNrRtwC","zxfQAhK","Aw5KzxGGB3u","tLzTqLe","qvHLB0y","yMfJA3vWigu","otiWtLbyugHy","DxjuvuG","uK55zLi","Ae1LC3nHz2u","zw5fDMvUDa","BMvLzf9Hy2S","z1D2yKy","CMvTB3zLrxy","y29SBM8","wxDPDKi","zu1xs3G","vvrHDfK","B2fK","yw1Lu3bHy2u","D2jKB2O","s0zeDMC","zMXVB3i","thzrDg4","uMHUsgG","y3r4","x3nLBMrby2S","CKj4C1q","vKHvsfy","nNWXFdr8nq","AunUAfa","uxjyAwO","Ehflwuu","z2v0t3DUuhi","v3H6ANG","AhnIAMS","uwnmruK","Cw9Z","Ec1TC2CTy3u","rwDKr24","t3rHDfu","lcbOB3n0BMe","x3fVC0rc","zgvS","x2LUDgvYDMe","BNvTyMvY","C2XbAu0","v2Ptq2K","Aw5KzxHpzG","x29UtwvZC2e","quXm","C1LOzg8","ihrPBwvZ","yxnZAwDU","tNzmChi","wxrlqwO","AgfUz2u","zg5RtvG","y2HLy2Tszwe","n3WWFdn8mNW","rvjst1i","Cxr6u0i","CxvutLa","wxfdsxa","AxP2sMW","x29Ut3bLBG","CNnVCL9Uyw0","BwvZC2fNztO","ALjdvem","Dg9Y","s2zQDM0","ywDL","zw50","DvfTzgm","z1Pdv1G","twvZC2fNzuu","q0Xpu0LorW","A2jvAuO","ELjvtwe","r2r0Evq","t25XAfi","Cw9xu2C","se1Iz1u","ywXSzwqGBxu","BgDMrKi","sNbgBxa","zufJAW","v3bhELy","vfnAyMK","suXsBgC","Ec11C2uT","DuvXEgO","B3vUDa","zgrjrcWGzgu","tvf2qK4","AuTbzvG","DgrNCgq","uKn4Ewi","s09Rvwi","uMrSBMW","DxjMswu","vvzVvw4","C3Pxt2q","t2jQzwn0","z0nYAge","x3bPBMC","C2Xjruu","zxjYtxnN","C2vYDMLJzq","qwHQAwW","zfDVCMTLCKC","Ae16r2u","Aw9UvgLTzw8","seXLAwS","vwf1DeK","sufzq2e","y29TCgXLDgu","zwnVBM5Ly3q","z1rPBwvVDxq","AvzHqwm","AeXxv1K","tefxu2y","y2fSBa","y0DLue0","wLn4A00","odaYmZe4qLzhChn0","D2fZq2XLyw4","yM9Js1O","zhHjzhm","zxjFCw9Z","zNjVBunOyxi","zNzHDfu","rMnOr0G","z2v0qwXSs2u","C29YDa","CMLLC0nVDw4","igXHCMDLCIa","y29hrMG","C1bXtNy","zvfnEfy","rvf2zNG","AxnrB1nby2S","y29Uy2f0","D2vI","tLLZsgy","qNL0uNu","A1Dlrha","mNWZFdf8nhW","wgHeB1e","s1r6z0y","yxnL","seT6rfO","ywDLrxzLBNq","A3znDeG","DenlwuW","Be54v1C","wMzNzwy","Aw50zwDLCIa","y2HLy2TdDxi","Chv0","x2LZtwLUAvC","BgTeBw4","AxnmB25N","zhruEeu","D3jPDgu","zxjFDhrS","zvbOv3G","tMfTzq","Ae9Wzw5fDMu","B3HhCgC","CKD5zNO","uhjPBwfYEuS","yw5Nzq","shfXDhi","rhLWAeW","B3nnBu0","yvj6ELu","y3vZDg9Tshq","BwvZ","CMvHzg9UBhK","vgj0Dw4","D0Pwv0e","s2jWtMG","qw1VDw50","sLjhA1q","FdH8mxWWFde","y3jLyxrLtwu","l3DZl3yY","Dg9VigXHCMC","zNjVBujPDhm","DNzrzeS","x2nSzwfYvgK","yM5pBgm","Du1krvq","y29Kzq","sNnZBNe","Efrhs04","ywrKrxzLBNq","Bwu6ia","ywnR","x2vUzhbVAw4","DMvYC2LVBMm","ExDfqKO","svnQtwG","zMzLCG","yNL0zuXLBMC","DgHLBG","t29YrMm","ALb3ChG","A09yzwS","tKfusvzfx0u","AhnOte8","rKzeqMe","wuPgv1K","DezlDM4","BMfzsvq","B2Pgzge","DgfIyxnL","y2vqDfy","ywHoANq","BMnLq2XVC2u","uvnhDu4","uw5fq1K","igzHAwWSig0","B25tDg9Wsw0","DMLJzuLeig8","q3vZDg9Tq2W","vKfxrxO","vgfN","seDAExe","uu55Dvy","ExbHBeK","DMvY","CM92AwrLihy","CMvHzhDYAxq","s1H4zhy","DxbKyxrLq3u","CgDJsuy","EK54Cvu","y3vYCMvUDeK","x2nSzwfYugK","DvnwsLq","y2vXz1a","BKrlALi","BgPTELm","yujuwMC","tMDLzgC","B0T4vNe","tufdCe0","A1jrDM4","Dw50","ugPUBuS","yxv0BW","BMTfqvK","zMzMzG","Dg9cExrLCW","AwXLtMfTzq","ihrYEsbYzwm","tKHoBfG","BwvKAwf0zwW","Bg9N","zMjNA1m","AMXZDg4","vgXjtNu","wvPbv2C","B2zKs20","ihrVihjLDhi","qLLLA3C","tNr5uvi","zuTwDLe","mxWYFdr8mhW","tM1vs2G","B25fCNjVCG","q3HqteK","BxnN","EM5xwfO","A1n0yxr1C0m","BezSDxnO","zwvKzwq","txvXD0m","vKjotvm","B25TzxnZywC","DvbMyLu","EKfNs1y","C3rYAw5N","uvPLC3i","DML3z0G","zgLZCgf0y2G","zgvSzxrLrge","zuDyB3y","svz1CMC","C2Pvuve","zNjVBNrPzxi","qLb0uMu","x25HDMLNyxq","B2LUDfjLywm","wxHNyLK","tKz5D0W","wwLls1q","yvv3wvK","qwf5AvK","B3v0sw50zxi","wwLdAwm","Aw5N","wu92Avq","swXhy3e","B2nRzxrgywK","CM9VqvC","D3fIDwO","rLDt","AxfnCxO","reHqs2K","zw1PDa","yvPyuKu","zgPtt1m","Bw9jqK0","Aw5JBhvKzxm","tgLZDgvUzxi","CMvUDevUzha","Cg93","CMnkuMS","wKPRqM8","yMTfuhO","BMzkDem","Aw47y2HHCNm","BwzXDxC","qunVBLO","z2v0sxrLBq","v3ntEue","yKDMB2e","x2zVCM1HDeu","BeLTBuW","v2f2yNe","Dg9cExrLC0i","D3fSrvK","BvvyDu4","s1bOEK4","t01itwi","Bg1Lq1a","BMv4DcGPigm","ALbsCuy","C0XPC3rLBMu","B3bLCNr5","y29UBMvJDfm","ignVzgu6ia","AMPXy2W","vMXcqLK","tgfqzfG","Afb2rwK","vxbKyxrLq28","DMfSDwu","x2LUAxrhBg8","zNjVBuHHC2G","tLHryMe"];return eo=function(){return t},eo()}(function(t,e){let r=J,i=t();for(;;)try{if(-parseInt(r(1035))/1+-parseInt(r(1696))/2+-parseInt(r(1612))/3+parseInt(r(289))/4+-parseInt(r(456))/5+-parseInt(r(324))/6*(parseInt(r(856))/7)+-parseInt(r(916))/8*(-parseInt(r(1643))/9)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(eo,699065);var i_=Object[M(865)+M(1252)],s_=Object[M(943)+M(1616)+M(1088)],ru=(t,e)=>function(){return t&&(e=(0,t[{gftWG:function(c,l){return c(l)}}[M(1634)](s_,t)[0]])(t=0)),e},o_=(t,e)=>{let r=M,i={vplHi:function(c,l,u,h){return c(l,u,h)}};for(var o in e)i[r(501)](i_,t,o,{get:e[o],enumerable:!0})};function a_(){return Xf||(Xf=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function c_(){let t=M;return Qf||(Qf=[IDBCursor.prototype.advance,IDBCursor[t(341)+"e"][t(654)],IDBCursor[t(341)+"e"][t(654)+t(1081)+"ey"]])}function d_(t){let e=M,r={LYKTN:function(o,c){return o(c)},kbUiJ:function(o){return o()},rHBvb:"error",UautI:function(o,c){return o(c)},DEJpn:e(349),GFKQp:"message",FFDBa:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,u={szWOd:l(349),UtXjb:r[l(1317)],tInXt:function(b,A){return r[l(1024)](b,A)},jGebD:function(b){return r[l(987)](b)}},h=()=>{let b=l;t[b(923)+b(441)+"ner"](u[b(1012)],p),t["removeEv"+b(441)+b(657)](u[b(1720)],w)},p=()=>{let b=l;r[b(1392)](o,r[b(1392)](Ct,t[b(1492)])),r[b(987)](h)},w=()=>{let b=l;u[b(1695)](c,t[b(316)]),u[b(1506)](h)};t[l(1107)+l(1227)](r[l(264)],p),t[l(1107)+l(1227)](r[l(1317)],w)});return i[e(1116)](o=>{let c=e;c(1621)==="KXrkj"?(this[c(1222)](r[c(723)],_0x167b2a),this.onmessage&&this[c(1191)+"e"](_0x311efc)):r[c(1122)](o,IDBCursor)&&Sc[c(304)](o,t)})[e(554)](()=>{}),no[e(304)](i,t),i}function l_(t){let e=M,r={QNTFO:e(1026),ySegX:function(o){return o()},XUNow:function(o,c){return o(c)},KQyZk:e(434)+"or",oPhWc:"error"};if(to[e(469)](t))return;let i=new Promise((o,c)=>{let l=e,u={WpGzV:r[l(1302)],lHLXQ:function(b){return r[l(637)](b)},eazWN:function(b,A){return r.XUNow(b,A)},jBusC:r[l(445)]},h=()=>{let b=l;t[b(923)+b(441)+b(657)](u[b(997)],p),t[b(923)+b(441)+"ner"](b(316),w),t[b(923)+b(441)+b(657)](b(508),w)},p=()=>{let b=l;u[b(809)](o),u[b(809)](h)},w=()=>{let b=l;u[b(284)](c,t[b(316)]||new DOMException(b(434)+"or",u[b(1623)])),h()};t[l(1107)+l(1227)](r[l(1302)],p),t[l(1107)+l(1227)](r[l(1496)],w),t[l(1107)+l(1227)]("abort",w)});to[e(304)](t,i)}function f_(t){ro={gJeyR:function(r,i){return r(i)}}.gJeyR(t,ro)}function u_(t){let e=M,r={PNtNO:function(i){return i()},Ilxpy:function(i,o){return i!==o},NHimF:e(704),Fqxcf:e(1453),eKVvQ:function(i,o){return i(o)},ErKTk:function(i,o,c,l){return i(o,c,l)},zNMzZ:function(i,o){return i+o},bCXCh:function(i,o){return i!==o},PFCfG:e(1535),TFoxu:function(i,o){return i(o)},kGaxa:function(i,o){return i===o},zhrnx:function(i,o){return i in o},bVjRH:e(1577)+e(1456),GFkrm:function(i,o){return i!==o},LSTSB:e(1490)};return r.kGaxa(t,IDBDatabase[e(341)+"e"][e(359)+e(1355)])&&!r.zhrnx(r.bVjRH,IDBTransaction[e(341)+"e"])?r[e(715)](r[e(609)],e(323))?function(i,...o){let c=e,l={AXeoF:function(u){return r.PNtNO(u)}};if(r[c(1410)](r[c(424)],r[c(672)])){let u=t.call(r.eKVvQ(Ei,this),i,...o);return vc[c(304)](u,i[c(1044)]?i[c(1044)]():[i]),Ct(u)}else aPJKky[c(914)](_0x2d8ae),_0x16e05e()}:(this._dispatchMessageEvent(_0x368730),r[e(1426)](_0x5b0646)):r[e(1426)](c_).includes(t)?function(...i){let o=e,c={BUqdV:function(l,u,h){return l(u,h)},vluhT:function(l,u,h,p){return r.ErKTk(l,u,h,p)},OtatU:function(l,u){return r.zNMzZ(l,u)}};if(r[o(636)](r[o(1373)],r.PFCfG)){let{offset:l}=c[o(673)](_0x5006aa,_0x26aad8,_0x354c03);_0x357072=l;let u={cursor_name:"",cursor:0,service:0},{value:h,offset:p}=c[o(673)](_0x6de8bd,_0x1f6e70,_0x39bf23);u.service=h,_0x32200e=p;let{value:w,offset:b}=c[o(673)](_0x2c131d,_0x1ae71a,_0x46c7b7);_0x46f61c=b,u[o(1330)+o(610)]=c[o(641)](_0x70148b,_0x320707,_0x23c678,c[o(950)](_0x40749d,w)),_0x45dec7+=w;let{value:A,offset:_}=_0x565662(_0x5d4c1a,_0x53c683);u[o(596)]=A[o(1555)](),_0x29df41=_,_0x50336d[o(305)](u)}else return t[o(734)](r[o(428)](Ei,this),i),r[o(1179)](Ct,Sc.get(this))}:function(...i){let o=e;return r[o(428)](Ct,t[o(734)](r[o(428)](Ei,this),i))}}function h_(t){let e=M,r={DCzfk:function(i,o){return i===o},XAzVS:e(1635),SmXOg:function(i,o){return i(o)},Rzjst:function(i,o,c){return i(o,c)},LMPdk:function(i){return i()}};return r[e(1274)](typeof t,r[e(492)])?r[e(553)](u_,t):(t instanceof IDBTransaction&&r[e(553)](l_,t),r[e(624)](iu,t,r.LMPdk(a_))?new Proxy(t,ro):t)}function Ct(t){let e=M,r={TEQZz:function(o,c){return o instanceof c},YYgXm:function(o,c){return o(c)},YUNPD:function(o,c){return o!==c}};if(r[e(774)](t,IDBRequest))return d_(t);if(Xs[e(469)](t))return Xs[e(313)](t);let i=r.YYgXm(h_,t);return r.YUNPD(i,t)&&(Xs.set(t,i),no[e(304)](i,t)),i}var iu,Xf,Qf,Sc,to,vc,Xs,no,ro,Ei,eu=ru({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={lLass:function(r,i){return r instanceof i},RJiPu:t(1201),OorFc:"pBwMQ",Pimbb:function(r,i){return r===i},yYRIs:"done",pmMsb:function(r,i){return r(i)},dTPFr:function(r,i){return r===i},nGuiL:t(782),llUcS:function(r,i){return r in i}};iu=(r,i)=>i.some(o=>r instanceof o),Sc=new WeakMap,to=new WeakMap,vc=new WeakMap,Xs=new WeakMap,no=new WeakMap,ro={get(r,i,o){let c=t;if(e[c(858)](r,IDBTransaction))if(e[c(655)]===e[c(1117)])_0x266473[c(1170)](_0x351e01);else{if(e[c(744)](i,e[c(1381)]))return to[c(313)](r);if(e[c(744)](i,c(1577)+"oreNames"))return r["objectSt"+c(1456)]||vc[c(313)](r);if(e[c(744)](i,c(782)))return o["objectSt"+c(1456)][1]?void 0:o.objectStore(o[c(1577)+"oreNames"][0])}return e[c(1508)](Ct,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return r instanceof IDBTransaction&&(i===e[o(1381)]||e[o(1545)](i,e[o(347)]))?!0:e[o(421)](i,r)}},Ei=r=>no[t(313)](r)}}),su={};o_(su,{deleteDB:()=>p_,openDB:()=>x_,unwrap:()=>Ei,wrap:()=>Ct});function x_(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=M,u={nbNzX:function(w,b,A,_,E){return w(b,A,_,E)},henVV:function(w,b){return w(b)},zngJv:function(w,b){return w(b)},NdnST:l(1674),DvoME:l(1111)+l(966),xnvZx:l(831)+l(1188)},h=indexedDB[l(659)](t,e),p=u[l(1663)](Ct,h);return i&&h[l(1107)+l(1227)](u.xnvZx,w=>{let b=l;u[b(455)](i,u[b(891)](Ct,h.result),w.oldVersion,w.newVersion,u.zngJv(Ct,h["transact"+b(1355)]))}),r&&h[l(1107)+l(1227)](l(484),()=>r()),p[l(1116)](w=>{let b=l;c&&w[b(1107)+b(1227)](u[b(1579)],()=>c()),o&&w[b(1107)+b(1227)](u[b(793)],()=>o())})[l(554)](()=>{}),p}function p_(t,{blocked:e}={}){let r=M,i={YdPjK:r(484),SsvzI:function(c,l){return c(l)}},o=indexedDB[r(1198)+r(1127)](t);return e&&o["addEvent"+r(1227)](i[r(720)],()=>e()),i[r(1390)](Ct,o)[r(1116)](()=>{})}function tu(t,e){let r=M,i={AKHZI:r(1144)+"e",EHBXA:function(h,p){return h instanceof p},PBxeY:function(h,p){return h in p},AOxrU:r(1194)};if(!(i[r(1489)](t,IDBDatabase)&&!i[r(1507)](e,t)&&typeof e===i[r(843)]))return;if(Qs[r(313)](e))return Qs.get(e);let o=e.replace(/FromIndex$/,""),c=e!==o,l=au.includes(o);if(!i[r(1507)](o,(c?IDBIndex:IDBObjectStore)[r(341)+"e"])||!(l||ou.includes(o)))return;let u=async function(h,...p){let w=r,b=this[w(359)+w(1355)](h,l?i[w(297)]:w(1089)),A=b.store;return c&&(A=A.index(p[w(397)]())),(await Promise[w(433)]([A[o](...p),l&&b[w(1474)]]))[0]};return Qs[r(304)](e,u),u}var ou,au,Qs,g_=ru({"node_modules/idb/build/index.js"(){let t=M,e={RBMnn:"0|4|2|3|"+t(642),LsxbJ:function(o){return o()},PGWmM:t(1642),IlGcq:t(1628),opLqw:"getAllKeys",UzuUP:"delete"},r=e[t(1326)].split("|"),i=0;for(;;){switch(r[i++]){case"0":e[t(1324)](eu);continue;case"1":f_(o=>({...o,get:(c,l,u)=>tu(c,l)||o[t(313)](c,l,u),has:(c,l)=>!!tu(c,l)||o[t(469)](c,l)}));continue;case"2":ou=[t(313),e[t(822)],e[t(1215)],e[t(1347)],t(1546)];continue;case"3":au=[t(1069),t(904),e[t(514)],"clear"];continue;case"4":e[t(1324)](eu);continue;case"5":Qs=new Map;continue}break}}}),m_={idb:function(t){let e=M;t[e(483)]=Promise.resolve().then(()=>(g_(),su))[e(1116)](function(r){return r})}},nu={};function Tt(t){let e=M,r={IeVIM:e(1180)+"3",xzHqj:function(u,h){return u!==h}},i=r[e(1459)][e(357)]("|"),o=0;for(;;){switch(i[o++]){case"0":m_[t](l,l[e(483)],Tt);continue;case"1":var c=nu[t];continue;case"2":if(r[e(872)](void 0,c))return c[e(483)];continue;case"3":return l[e(483)];case"4":var l=nu[t]={exports:{}};continue}break}}function J(t,e){t=t-263;let r=eo(),i=r[t];if(J.aqGZDz===void 0){var o=function(h){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",b="";for(let A=0,_,E,v=0;E=h.charAt(v++);~E&&(_=A%4?_*64+E:E,A++%4)?w+=String.fromCharCode(255&_>>(-2*A&6)):0)E=p.indexOf(E);for(let A=0,_=w.length;A<_;A++)b+="%"+("00"+w.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(b)};J.kkrdWL=o,J.lfJWGb={},J.aqGZDz=!0}let c=r[0],l=t+c,u=J.lfJWGb[l];return u?i=u:(i=J.kkrdWL(i),J.lfJWGb[l]=i),i}(()=>{let t=M,e={XKFOL:function(r,i){return r>=i},cGePM:function(r,i){return r===i},uexyD:t(683)};Tt.d=(r,i)=>{let o=t;if(e[o(1033)](e.uexyD,o(683)))for(var c in i)Tt.o(i,c)&&!Tt.o(r,c)&&Object[o(865)+o(1252)](r,c,{enumerable:!0,get:i[c]});else return e.XKFOL(_0x5dc135[o(1394)],_0xa52722[o(653)])}})(),(()=>{let t=M;Tt.o=(e,r)=>Object[t(341)+"e"][t(835)+"operty"].call(e,r)})(),(()=>{let t=M,e={wJVWA:function(r,i){return r!=i},CAIpJ:"Module",NHNlX:t(477)+"le"};Tt.r=r=>{let i=t;e[i(1091)](i(1592)+"d",typeof Symbol)&&Symbol[i(1309)+"Tag"]&&Object[i(865)+i(1252)](r,Symbol[i(1309)+i(1138)],{value:e[i(1264)]}),Object["definePr"+i(1252)](r,e[i(1168)],{value:!0})}})();var Se={};(()=>{let t=M,e={tdgpd:function(a,n){return a!==n},sXmIR:t(1294),tFKvn:function(a,n){return a+n},spPPN:function(a,n){return a+n},LAWSf:function(a,n){return a+n},JRGkT:function(a,n){return a*n},izvJl:function(a,n){return a*n},djSOS:function(a,n){return a===n},cmCSD:function(a,n){return a>>>n},TDrCL:function(a,n){return a|n},wBLSZ:function(a,n){return a|n},jlstn:function(a,n){return a|n},FUBgl:function(a,n){return a<<n},ceqgP:t(1531),QcLEI:function(a,n){return a+n},AwywM:function(a,n,s){return a(n,s)},rcJRk:function(a,n){return a+n},UAXCx:function(a,n){return a(n)},YZAWg:function(a,n){return a+n},JOVWD:t(612),bVqEz:t(1164),QLdXI:function(a,n){return a(n)},PSFui:function(a,n){return a>n},KFDvg:function(a,n){return a<n},pUowy:function(a,n){return a!==n},jZRSn:function(a,n){return a-n},qEahI:function(a,n){return a<n},nfRpN:function(a,n){return a===n},wvyjq:function(a,n){return a!==n},XHrtf:t(1421),zRUMa:"FyQrc",LFtaA:function(a,n){return a<n},cgOjR:t(1001),hPvEi:function(a,n){return a!==n},NKrao:function(a,n){return a===n},aMDav:t(524),QqYEN:t(481),TAMzt:function(a,n){return a===n},plHlI:"orGqF",ANjTa:"JjIxE",FchGH:function(a,n,s){return a(n,s)},oKxVq:function(a,n){return a(n)},MUfVJ:function(a,n){return a(n)},eOfpi:function(a,n,s){return a(n,s)},IlnMi:function(a,n,s){return a(n,s)},KfPNJ:function(a,n){return a&n},VHUHV:function(a,n){return a===n},tLdCu:t(1480)+t(1572)+t(573)+t(1493),DQjwE:function(a,n){return a===n},sVJiN:t(1480)+t(1572)+" field: "+t(1260),hshLO:function(a){return a()},Wxzjx:t(1026),pORYe:t(316),rooAW:t(508),eUZfr:function(a,n,s){return a(n,s)},naYIT:function(a,n,s){return a(n,s)},NtyQR:function(a,n){return a!==n},SjFGQ:t(310),KDgXQ:function(a,n,s){return a(n,s)},ePhWx:function(a,n){return a!==n},isfhR:function(a,n){return a===n},bakRf:t(1369),MZpfE:function(a,n){return a!==n},GdtyT:function(a,n,s){return a(n,s)},gnuvu:function(a){return a()},ftXpm:function(a,n,s){return a(n,s)},ljmzS:function(a,n,s){return a(n,s)},mvBgM:function(a,n,s){return a(n,s)},wUPqs:function(a,n){return a!==n},xMxsK:function(a,n,s){return a(n,s)},wUsyd:function(a,n){return a!==n},llnBg:function(a,n,s){return a(n,s)},JqSjT:function(a,n,s){return a(n,s)},primW:function(a,n,s){return a(n,s)},IcTiT:function(a,n,s){return a(n,s)},LCscf:function(a,n){return a(n)},bGAUA:function(a,n){return a(n)},EgdGn:function(a,n,s){return a(n,s)},TSZbi:function(a,n,s){return a(n,s)},EJwZq:function(a,n,s){return a(n,s)},oVVLO:function(a,n){return a(n)},WiFhB:function(a,n){return a===n},xqKYE:t(1480)+t(1572)+t(573)+t(269),YqCIp:t(1480)+t(1572)+t(573)+t(351),jDzeo:function(a,n){return a===n},ojFda:"Missing "+t(1572)+t(573)+t(1018),XOxGn:t(1480)+t(1572)+" field: "+t(675),dfCxc:function(a,n,s){return a(n,s)},GrDII:t(600)+t(376)+t(611),FNUjv:t(1299),Xfanj:function(a,n){return a>=n},UmdBy:"nAnVy",yWalh:function(a,n){return a===n},MZNMw:function(a,n){return a>n},BPtRe:function(a,n){return a>=n},ABGFt:function(a,n){return a*n},hMzGe:t(1534),CzNwj:function(a,n,s){return a(n,s)},hMbfs:function(a,n){return a===n},xlqSe:t(1427),CFNQo:t(898),KbpNh:function(a,n){return a+n},WgfRI:function(a,n){return a===n},slIEE:function(a,n){return a&n},mfquw:function(a,n){return a(n)},NVmBQ:function(a,n){return a+n},JmMif:function(a,n){return a+n},dkmwm:function(a,n){return a!==n},nAOBx:function(a,n){return a<<n},fVoVb:function(a,n){return a(n)},pdiDP:function(a,n){return a&n},kvMtH:function(a,n){return a+n},aNVCT:function(a,n){return a+n},VtkMg:function(a,n){return a+n},mVENx:function(a,n){return a|n},bPINr:function(a,n){return a<<n},MZeFc:function(a,n){return a&n},VMmUv:function(a,n){return a<=n},CNkAw:function(a,n){return a!==n},iiBLS:"uBbTo",eQMxV:function(a,n){return a==n},zFQRx:function(a,n){return a&n},JtpbB:function(a,n){return a+n},QSGuN:function(a,n){return a|n},uBhke:function(a,n){return a<<n},nkEAY:function(a,n){return a|n},XSJpI:function(a,n){return a|n},WbrGJ:function(a,n){return a&n},VyYpe:function(a,n,s){return a(n,s)},zkUFS:function(a,n){return a+n},XMGow:function(a,n){return a>>n},Jebes:function(a,n){return a&n},ukbmL:function(a,n){return a<n},MGfBl:function(a,n){return a<=n},TAzgq:function(a,n){return a-n},xSspk:function(a,n){return a<n},anqBT:function(a,n){return a>=n},AayiY:function(a,n){return a<=n},kWKDp:function(a,n){return a<n},iLVPJ:function(a,n){return a+n},GZyxQ:function(a,n){return a+n},vzczs:function(a,n){return a<n},MQvBN:function(a,n){return a&n},moIBM:function(a,n){return a!==n},RzkxS:t(743),xzdPx:t(1407),aTUXk:function(a,n){return a>>n},uHNhD:function(a,n){return a|n},CEfhS:function(a,n){return a>>n},aeVJX:function(a,n){return a|n},GQHTo:function(a,n){return a&n},owaAN:function(a,n){return a|n},fczBV:function(a,n,s){return a(n,s)},tZYqC:function(a,n){return a||n},OgDTn:t(1221),wcztG:function(a,n,s){return a(n,s)},WjSCi:function(a,n){return a(n)},gCEZV:function(a,n){return a&n},dqQNZ:function(a,n,s){return a(n,s)},ZbkAl:function(a,n){return a|n},AKWDB:function(a,n){return a&n},yjOVH:function(a,n,s){return a(n,s)},KOkUb:function(a,n){return a&n},DJHVP:function(a,n){return a&n},aUwYY:function(a,n){return a(n)},fyInU:function(a,n){return a&n},lxjUn:function(a,n){return a<<n},JRyYi:function(a,n){return a(n)},sdaqi:function(a,n){return a<<n},Paopw:function(a,n){return a(n)},ShrUH:function(a,n){return a<<n},XsBzQ:function(a,n){return a&n},tjYxs:function(a,n){return a&n},SEAtn:function(a,n){return a!==n},bjyVE:t(1085),NYlJY:"UwtZX",YXEmT:function(a,n){return a&n},ZGxFz:function(a,n){return a&n},sMNdT:function(a,n){return a<<n},BEoNk:function(a,n){return a<<n},VAWEz:function(a,n){return a>>>n},ithua:function(a,n){return a===n},ywEBJ:function(a,n){return a===n},KXxdv:function(a,n){return a<n},uMJET:function(a,n){return a<n},ipVyK:function(a,n,s){return a(n,s)},JpFmp:function(a,n){return a+n},uTRjT:function(a,n){return a>>>n},fovMF:function(a,n){return a|n},czwXC:function(a,n){return a&n},iYOmN:function(a,n){return a|n},dOzlV:function(a,n){return a&n},yERSK:function(a,n){return a+n},LXupN:function(a,n){return a>>>n},XgXsL:function(a,n){return a&n},fpYcW:function(a,n){return a!==n},zkjPb:function(a,n){return a|n},NafFm:function(a,n){return a>>>n},cNAbi:function(a,n){return a&n},Ahjil:function(a,n){return a>>>n},vKifl:function(a,n){return a|n},vvQdK:function(a,n){return a|n},BVJum:function(a,n){return a&n},bEmxH:function(a,n){return a>>>n},ILRlg:function(a,n){return a|n},hsbjk:function(a,n){return a(n)},yDnhG:function(a,n){return a|n},jGVRH:function(a,n){return a|n},OyMjM:function(a,n){return a|n},qUagg:function(a,n){return a<<n},xCOVA:function(a,n){return a|n},cePtV:function(a,n){return a|n},muyMh:function(a,n){return a<<n},KuYxL:function(a,n){return a<<n},jRCTC:function(a,n){return a|n},jjqcl:function(a,n){return a<<n},ypalI:function(a,n){return a===n},DZNjm:function(a,n){return a>>>n},xJbON:function(a,n){return a<<n},NXQba:function(a,n){return a>>>n},gclvN:function(a,n){return a|n},vypPH:function(a,n){return a<<n},bYrAf:function(a,n){return a&n},IQEfv:function(a,n){return a>>>n},NttMl:function(a,n){return a>>>n},FKbje:function(a,n){return a>>>n},NHmIX:function(a,n){return a>>>n},jPRqF:"DKrDO",vPrqm:t(1298),qfPWN:function(a,n){return a<=n},AJTrd:function(a,n){return a>=n},HGtkV:function(a,n){return a+n},PmmmX:function(a,n){return a%n},TQBLC:function(a,n){return a/n},fbgkS:function(a,n){return a*n},WpXux:function(a,n){return a>>>n},tpsLa:function(a,n){return a+n},USXTu:function(a,n){return a*n},uQXKK:function(a,n){return a===n},stfzR:function(a,n){return a!==n},sZhwi:"zWsii",GZXij:function(a,n){return a===n},xvYRb:function(a,n){return a>>>n},aRzzU:function(a,n){return a>>>n},TQeQG:function(a,n){return a|n},arNse:function(a,n){return a|n},sHDEA:function(a,n){return a<<n},ikhxg:function(a,n){return a!==n},YlaEa:function(a,n){return a>>>n},UTtmv:function(a,n){return a===n},cLnrJ:function(a,n){return a===n},dnkMX:function(a,n){return a+n},Tbtun:function(a,n){return a+n},yCNnI:function(a,n){return a===n},aworu:t(1494),lRXvp:function(a,n){return a&n},bZPLl:function(a,n){return a&n},tjwVj:function(a,n){return a&n},VlBBY:function(a,n){return a>>>n},EQvfx:function(a,n){return a>>>n},oBJqE:function(a,n){return a&n},RAdvM:"5|3|0|4|"+t(1384),LAZol:t(1271)+t(331)+"R",cgNXT:t(635)+"OR",mPeKU:"CONNECTI"+t(280),kHTDe:t(532)+"ERROR",klkaJ:"NATIVE_E"+t(458),MrNOA:t(1057)+"0",LAhJZ:t(1194),jZPVF:function(a,n){return a instanceof n},yXEgA:t(1700)+t(781),kkctL:t(1278)+t(1234)+t(1683),lgfFB:"rkDCU",JWreZ:function(a,n){return a(n)},JwlRC:function(a,n){return a&n},VVDkV:function(a,n){return a&n},mFQPw:t(415),nfJtC:t(965),AlFcX:t(659),bhWmw:function(a,n){return a!==n},ipuCM:"DBjTB",kanMU:function(a,n){return a===n},HdcHI:function(a,n){return a>n},MTZdZ:function(a,n){return a===n},BvQbV:function(a,n){return a instanceof n},yjPLt:function(a,n){return a+n},QrXij:t(285)+t(748),TNRoa:function(a,n){return a+n},gAJzI:t(1646),KApTL:function(a,n){return a===n},AcsHu:function(a,n){return a<n},fvatU:function(a,n){return a===n},viwgH:t(409),fQqCg:function(a,n,s){return a(n,s)},ZoIUV:t(1674),syxOW:function(a,n,s){return a(n,s)},mOiNl:"NZwTV",zlamf:function(a,n,s){return a(n,s)},LaPdX:t(760),wVXYZ:function(a,n,s){return a(n,s)},HdAxA:function(a,n){return a instanceof n},HKzDZ:function(a,n){return a+n},ByXgp:t(1553),zVXkX:t(1238),wNsOh:"IacTp",cMKkf:"online",UVoUn:t(1400),Ngedg:t(283),zcxqu:t(1523),tCKYL:t(805),LMPUL:function(a,n){return a||n},qaDRR:"2|0|3|4|1",hMpWt:"undefined",FCuJh:t(1249)+t(993)+"ltiple t"+t(430)+"process",QDHuU:function(a,n){return a<n},bAWby:function(a,n){return a<n},eWxiL:function(a,n){return a<n},YwivB:function(a,n){return a<n},ESAcz:function(a,n){return a<=n},xRUnI:function(a,n){return a>=n},LLegD:function(a,n){return a<n},oyebf:function(a,n){return a|n},yzeHN:function(a,n){return a|n},IfJRt:function(a,n){return a<<n},rBxsT:function(a,n){return a&n},UljID:function(a,n){return a&n},GBlKE:function(a,n){return a&n},rupbJ:function(a,n){return a>=n},mpYyX:function(a,n){return a|n},DbEfU:function(a,n){return a<<n},IkzXz:function(a,n){return a&n},aHLJE:function(a,n){return a>>n},LwCDE:t(1647),czCaL:function(a,n){return a|n},sYwzA:function(a,n){return a>>n},qoWSg:function(a,n){return a&n},iVaAc:function(a,n){return a===n},CAJJF:function(a,n){return a|n},mYvbj:function(a,n){return a+n},VqTxP:function(a,n){return a+n},wfJrX:function(a,n){return a<<n},BHaIv:function(a,n){return a&n},dLeXu:function(a,n){return a&n},tmmvD:function(a,n){return a>>n},EaZKL:function(a,n){return a>>n},vShoL:function(a,n){return a&n},TzuTj:function(a,n){return a>>n},gpTbX:function(a,n){return a-n},xnCjd:function(a,n,s,d){return a(n,s,d)},Rujcf:function(a,n){return a!=n},quTNP:function(a,n){return a!=n},bnOlc:function(a,n){return a==n},qtzSB:t(291),YxgbY:t(334),wRlIe:t(787)+t(626)+"s",nvmuE:t(349),UGKGc:function(a,n,s){return a(n,s)},RxgII:function(a,n){return a===n},EEiPa:t(1248),cElpt:function(a,n){return a>=n},XRlIm:t(854)+t(780),RCxyb:t(1642),wqlEY:t(1043)+"ys",tdSjU:t(1546),RTnfi:t(1069),bHmgj:t(904),YhSrk:t(364),kRQvn:"clear",TSqDf:t(1499),gZCWX:"unknown "+t(1315),XdipK:function(a,n){return a(n)},mUXuN:t(1288),zhxSR:t(391)+"ascript",OQedr:t(1433),uXZNF:t(1079),UnmTV:t(1703),OnXvS:"XkdpA",dWwen:t(1438),EQFzt:t(815),eqjhy:t(1462),IAYCa:function(a,n){return a===n},emGLQ:"pWfxZ",mqnHM:t(1580),eGXov:function(a,n){return a||n},dzqWU:function(a,n){return a||n},qgzxh:t(1672),dxIds:function(a,n){return a||n},wqbuj:"9|2|5|10|6|7|3|4"+t(1095)+"1",rFwzR:function(a,n){return a<n},OZsfu:function(a,n){return a&n},Bamtk:function(a,n){return a<<n},aZXRE:t(622),QDsGa:t(1675),QZesr:function(a,n){return a||n},AXjaf:function(a,n){return a!=n},gjcYG:function(a,n,s){return a(n,s)},kAAwi:t(306)+"id",cbCRi:function(a,n){return a(n)},aBTZg:function(a){return a()},CHfhg:"hivOr",wrPnj:t(702),SyRSX:t(446),uiSsx:function(a,n){return a(n)},SZDcD:function(a,n,s,d){return a(n,s,d)},MFUfp:t(509)+t(1039),ztsSu:t(509)+t(571)+"k",swLSw:t(509)+t(382)+t(1537),kmWhF:function(a,n){return a|n},LofiS:function(a,n){return a|n},TPTRu:function(a,n){return a<<n},KsbWw:function(a,n){return a|n},WPJNO:function(a,n){return a!==n},DEjSW:"gAwHB",RhnHh:t(346),jDigz:t(1710),DjazC:t(1303),FCxnC:function(a,n){return a||n},tcVWX:function(a,n){return a(n)},eDonF:function(a,n){return a instanceof n},WRpVW:t(713),LHXqj:function(a){return a()},WCHTx:t(1504),gKIHk:t(1684),jkDfn:function(a,n){return a|n},OMHMb:function(a,n){return a+n},JZpHb:function(a,n){return a+n},BQrHm:t(912)+t(393)+"ge: ",KswdN:function(a,n){return a||n},tgiZV:" > ",bleQm:function(a,n){return a&n},dPElQ:t(1067)+t(1098)+"e",imfzz:function(a,n){return a>=n},kNtZC:t(1113),twmsB:function(a,n){return a+n},hgLFq:function(a,n,s){return a(n,s)},GTgBq:function(a,n){return a+n},LPHXs:function(a,n){return a===n},iWZwx:t(1241),HiPOq:function(a,n,s){return a(n,s)},uPfbU:function(a,n){return a>>>n},ahNjt:function(a,n,s,d){return a(n,s,d)},zdkyr:function(a,n){return a+n},zAxun:function(a,n){return a(n)},vQRHg:t(880),vzzRf:function(a,n){return a|n},nRAzF:function(a,n){return a|n},fiJMo:function(a,n){return a<<n},kgLRN:function(a,n){return a+n},YvMGN:function(a,n){return a+n},FTbVL:function(a,n){return a|n},GrVKl:function(a,n){return a|n},ljUmJ:function(a,n){return a<<n},rrpII:function(a,n){return a<<n},SgefY:function(a,n){return a+n},jZjpE:function(a,n){return a<<n},iCnhP:function(a,n){return a+n},iooVy:function(a,n){return a&n},kuUiX:function(a,n){return a>>>n},nqofE:function(a,n){return a&n},UFGLB:function(a,n){return a>>>n},QPzYd:function(a,n){return a>>>n},aVQGM:function(a,n){return a&n},KIbKK:function(a,n){return a&n},SxNGk:function(a,n){return a+n},SAelq:t(277),gvrYL:t(1422),FCQTc:function(a,n){return a>>>n},IhAQC:function(a,n){return a>>>n},Kxtuq:function(a,n){return a&n},Fdmlq:function(a,n){return a<<n},ppWcK:function(a,n){return a&n},mhdUP:function(a,n){return a<n},KJMwn:function(a,n){return a|n},wcdyV:function(a,n){return a<<n},sYhdo:function(a,n){return a<n},lxkBd:function(a,n){return a<n},MqTNP:function(a,n){return a>n},CtuEu:function(a,n){return a+n},UzLca:"godmy",xpbzb:t(746)+t(1468),sLOsV:"header",YiKKT:function(a,n,s,d){return a(n,s,d)},qgdlP:function(a,n,s,d){return a(n,s,d)},oHWDI:"curvalue",MOdpk:t(1486)+t(1653),SoEMn:function(a,n){return a<n},gfsGK:"FILE_NOT"+t(290),Kfjvm:function(a,n,s){return a(n,s)},WrJTP:t(1330)+"ame",rcHYY:t(1678),Zfgef:t(537),Pypdv:function(a,n){return a(n)},xxIZG:"setcursor",HeQUd:function(a,n){return a!==n},gqQLx:t(288),koxDd:function(a,n){return a!==n},HMbgU:"lzxsW",jeNgY:function(a,n){return a(n)},CxPLI:t(1543),zjkRh:t(1084),sQKBL:t(1361)+"4|1",lENUU:function(a,n,s,d){return a(n,s,d)},KcRgJ:t(509)+"er_msgid",cWvJz:function(a,n,s){return a(n,s)},TbKZR:t(509)+t(1075),NvLpr:function(a,n,s,d){return a(n,s,d)},Oosrn:"x-msg-qos",kJEWs:"x-msg-cu"+t(976)+"e",gQAKz:t(948)+t(735)+"ue",BYekw:function(a,n){return a>n},xPrdC:function(a,n){return a>n},BDeHh:function(a,n){return a!==n},voCxx:"eTcxQ",tXMUb:t(1403),xfzkz:"qmRNt",DZWEd:function(a,n){return a<n},dZIfH:function(a){return a()},xDuZE:function(a){return a()},xLqFi:function(a,n){return a===n},YrjBC:function(a,n){return a&&n},KMYky:function(a){return a()},nRIPH:function(a,n){return a(n)},Fakwl:function(a,n){return a!==n},kXYnm:function(a){return a()},iYYVS:"tNzUk",uBSlN:function(a,n,s){return a(n,s)},OGboE:t(315),ycOrP:t(1370),urfIe:function(a,n){return a!==n},wAAgM:function(a,n){return a===n},bocKZ:t(1483),NmUKh:t(804),LvQtn:function(a,n,s){return a(n,s)},uHksZ:function(a,n){return a!==n},CFEPi:function(a,n){return a===n},sGzoB:"arraybuf"+t(466),hLWWY:t(907),eMWKx:t(1162),MzvIS:function(a,n){return a==n},QRSfQ:t(703)+t(1143)+"alid url",EpOQX:t(703)+t(1365)+t(1269)+t(727)+t(1607)+"tructor "+t(1376)+t(696),NFywL:t(1350),bcITD:t(1283)+"t",fRXJR:t(1615),QKjHi:t(863),WkyBl:function(a,n){return a!==n},nvsDz:t(730),Hqqtr:function(a,n){return a!==n},Dbcfu:function(a,n){return a!==n},bWaYU:t(890),QNyuV:t(892),xsOzv:"device_id",nDKjR:"please p"+t(1596)+t(1003)+t(1135)+t(1362),eomZV:t(1635),bGfoa:function(a){return a()},RNyfR:t(1053),ExdNi:function(a,n,s){return a(n,s)},IDFef:"start",SMAzf:function(a,n){return a>n},xTGKN:function(a,n){return a-n},EkJtN:function(a,n,s){return a(n,s)},zlNgs:t(1502),qvVNn:function(a,n){return a>n},HlVUc:t(567),RPdHo:function(a,n,s){return a(n,s)},UKhrV:function(a,n,s){return a(n,s)},njxJI:t(787)+t(827)+"t",EiNbv:t(1417),BYnsL:function(a,n){return a>=n},nCshm:t(814),DtJFK:function(a,n){return a+n},Colqh:function(a,n){return a<n},iKAeX:t(895),ZfaeN:t(460),mRkWK:t(1343)+t(1167)+"onnecting",anmgL:function(a,n,s){return a(n,s)},mEUYz:function(a,n){return a(n)},lNxWW:t(983),PnMkw:"4|2|3|0|1",gCrha:t(1473)+"0",MMLbp:function(a,n,s){return a(n,s)},rbmBa:function(a,n,s){return a(n,s)},DIytD:function(a,n,s){return a(n,s)},YJFWY:t(1109),cRzRd:function(a,n){return a===n},LChye:"Azqvz",dSfLj:function(a,n){return a(n)},JZdwA:function(a,n){return a!==n},znWXZ:"LWwyt",ZJkBo:t(487),fxFVj:"ycRSb",uPUsR:t(969)+t(939),XhDoQ:t(795)+"s instan"+t(307)+"nitialized",RgVjz:t(795)+t(563)+t(575),ahNQO:function(a,n){return a>>n},ddxVw:function(a,n){return a+n},OWKhD:function(a,n){return a<<n},CXaaI:function(a,n){return a|n},MuqwC:function(a,n){return a==n},EEAHo:t(955),lkDmn:function(a,n){return a!=n},iqMqz:function(a,n){return a instanceof n},VBNMS:function(a,n){return a(n)},zNxqU:function(a,n){return a(n)},yMdoz:function(a,n){return a instanceof n},DYXeX:function(a,n){return a===n},HLeik:t(1275),SgQus:function(a,n){return a<n},rKkdS:"xUHrl",NBsJY:t(1296),uLpGb:function(a,n){return a==n},rFQbC:function(a,n){return a!==n},YAvoy:t(400)+"econnect"+t(1213),urTUH:function(a,n){return a!==n},BytRu:t(1328),rGyfz:"\0\0\0\0\0\0\0\0",LEyUf:function(a,n){return a*n},cOzuT:function(a,n){return a/n},WVoql:function(a,n){return a!=n},edggV:function(a,n){return a===n},vHVnj:function(a,n){return a!=n},jPwpx:t(1013),gWvbF:function(a,n){return a===n},pTQAC:function(a,n){return a==n},riFqr:function(a,n){return a!=n},AtPFF:"SharedWo"+t(1620)+"alScope",pywNK:"ServiceW"+t(543)+"balScope",bkEPz:function(a,n){return a!=n},vDWfO:function(a,n){return a===n},jfAOC:"__x_msg_"+t(889)};Tt.r(Se),Tt.d(Se,{FWS:()=>Nx,CustomErrorEvent:()=>ud,createCloseEvent:()=>at,ReconnectEvent:()=>fd,createErrorEvent:()=>Qe,decodedFrame:()=>Fn,createOpenEvent:()=>wd,CustomCloseEvent:()=>hd,createReconnectEvent:()=>Po,FrontierMessageEvent:()=>pd,encodeFrame:()=>We,createMessageEvent:()=>md,OpenEvent:()=>gd,ErrorCode:()=>Wt,Event:()=>Hn,MessageEvent:()=>xd});let r="";function i(a=""){let n=t;if(e[n(1006)](e[n(838)],n(1294))){let s=_0x539c07[n(760)][n(721)];s&&_0x41eaa2[n(776)+"rs"](s)}else{let d=""+Date[n(390)](),f=r||(r=h(a)),x=Math[n(311)]()[n(1309)](16).slice(-6);return e[n(1124)](e[n(1586)]("02",d)+f,x)}}function o(){let a=t;return e[a(1031)](e.JRGkT(1e4,Date[a(390)]()),Math[a(932)](e[a(974)](1e4,Math[a(311)]())))}function c(a){let n=t;return e[n(1006)](e[n(1152)],"eOxUT")?e[n(1224)](_0x4f06a0,_0x4a979a)?_0x4cea2e:new _0xd0acc9(e[n(1279)](e[n(475)](e[n(1460)](e[n(1172)](_0x29e562.call(_0x151fc7,0),e[n(1713)](_0x36ba89[n(1032)](_0x47ad29,1),8)),e[n(1713)](_0x4310ab.call(_0x3629e5,2),16)),e[n(1713)](_0x28975c.call(_0x149dbc,3),24)),0),(e[n(1172)](_0xc91090[n(1032)](_0x275d45,4),_0xa2a25a.call(_0x27edf3,5)<<8)|_0x294fef[n(1032)](_0x3c9a49,6)<<16|e[n(1713)](_0x3d923a[n(1032)](_0x5c928c,7),24))>>>0,!0):e[n(946)](Array(8)[n(459)]("0"),parseInt(a,10)[n(1309)](2))[n(386)](-8)}function l(a){let n=t;return(Array(4).join("0")+e.AwywM(parseInt,a,2)[n(1309)](16))[n(386)](-4)}function u(a){let n=t,s=a[n(357)](/\./)[n(1667)](x=>c(x)),d=[];return d[0]=l(e[n(1230)](s[0],s[1])),d[1]=e[n(629)](l,e[n(1174)](s[2],s[3])),[n(612),e[n(1528)],n(612),n(612),e[n(1528)],e.bVqEz,d[0],d[1]][n(459)]("")}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}/.test(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]))/[n(1551)](a);return s?e[n(629)](u,a):d?p(a):n(722)+n(722)+n(722)+n(722)}function p(a){let n=t,s={juARd:function(T,D){return T===D}},d="",f=[],x=0,m=0,S=!0,g="0000";if(a.indexOf("::")>-1){let T=a[n(357)]("::");for(let B=0;B<T[n(1322)];B++){let G=T[B];if(e[n(1501)](G[n(958)](":"),0)){let $=G[n(357)](":");S&&(x=$[n(1322)]),m+=$[n(1322)];for(let K=0;e[n(931)](K,$.length);K++)if(e[n(1006)](4,$[K][n(1322)])){let ge=g[n(758)+"g"](0,4-$[K].length),se=ge[n(1052)]($[K]);f[n(305)](se)}else f[n(305)]($[K]);S=!1}else{if(e[n(273)](4,G[n(1322)])){let $=g[n(758)+"g"](0,e[n(1333)](4,G[n(1322)])),K=$[n(1052)](G);f[n(305)](K)}else f[n(305)](G);S&&(x+=1),m+=1,S=!1}}let D="";for(let B=0;e.qEahI(B,e[n(1333)](8,m));B++)D=D[n(1052)](g);for(let B=0;B<f[n(1322)];B++)e[n(384)](B,x)&&(d=d[n(1052)](D)),d=d[n(1052)](f[B]);return d}if(e.wvyjq(e[n(1349)],e[n(988)])){let T=a[n(357)](":");for(let D=0;e[n(844)](D,T.length);D++)if(e.cgOjR!==e[n(1402)]){let B=/(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(1551)](_0x35b008),G=/(([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(1551)](_0x426bbb);return B?e[n(731)](_0x444899,_0xe31f98):G?e[n(629)](_0x504f03,_0xd92bdc):n(722)+n(722)+n(722)+"00000000"}else{let B=T[D];if(e[n(1258)](4,T[D][n(1322)]))if(e[n(265)](e.aMDav,e.QqYEN)){let G=_0x195ede[n(1524)],$=_0x1ebc6b[n(653)];return s[n(1554)](G[n(1322)],$)?G:G[n(676)](0,$)}else{let G=g[n(758)+"g"](0,4-T[D][n(1322)]),$=G.concat(B);d=d[n(1052)]($)}else d=d[n(1052)](B)}return d}else e.AwywM(_0x39a094,_0x2d8a85,82),e[n(355)](_0x17b0a7,_0x232aca,_0xd506da)}function w(a,n){let s=t,d=a[s(1493)];e[s(500)](void 0,d)&&(e.TAMzt(e.plHlI,e[s(1538)])?(this[s(952)]?.[s(1674)](),this[s(952)]=void 0):(e[s(355)](Y,n,10),e[s(355)](Be,n,d)));let f=a[s(1260)];e.wvyjq(void 0,f)&&(Y(n,18),e[s(1042)](Be,n,f))}function b(a){let n=t,s={};e:for(;!e[n(1157)](N,a);){let d=e.QLdXI(Ee,a);switch(d>>>3){case 0:break e;case 1:s[n(1493)]=e.FchGH(be,a,e[n(410)](Ee,a));break;case 2:s[n(1260)]=e[n(521)](be,a,e[n(629)](Ee,a));break;default:e[n(648)](k,a,e[n(763)](7,d))}}if(e[n(938)](void 0,s[n(1493)]))throw new Error(e[n(1287)]);if(e[n(1519)](void 0,s[n(1260)]))throw new Error(e.sVJiN);return s}function A(a){let n=t,s=e.hshLO(C);return e[n(648)](_,a,s),e[n(629)](z,s)}function _(a,n){let s=t,d={PBBKr:e[s(944)],Wavbq:e[s(564)],bgLmv:e[s(1217)]},f=a[s(269)];f!==void 0&&(e[s(695)](Y,n,8),e.naYIT(ye,n,f));let x=a[s(351)];if(e[s(1178)](void 0,x)){if(e.pUowy(s(310),e[s(568)]))return!0;e[s(670)](Y,n,16),ye(n,x)}let m=a[s(1018)];e[s(1076)](void 0,m)&&(e[s(1619)](s(1369),e[s(1434)])?(Y(n,24),e.FchGH(ye,n,O(m))):(_0x28b21d[s(923)+s(441)+"ner"](UIeerx.PBBKr,_0x56a63c),_0x2a4aa9[s(923)+"entListe"+s(657)](UIeerx[s(1242)],_0x1e336f),_0x36ecaf["removeEv"+s(441)+s(657)](UIeerx.bgLmv,_0x4df471)));let S=a[s(675)];e[s(1467)](void 0,S)&&(e[s(695)](Y,n,32),ye(n,O(S)));let g=a[s(353)];if(g!==void 0)for(let se of g){e[s(989)](Y,n,42);let de=e.gnuvu(C);e.ftXpm(w,se,de),e[s(1042)](Y,n,de[s(653)]),e[s(1042)](ot,n,de),L(de)}let T=a.payloadEncoding;e[s(1178)](void 0,T)&&(e.eUZfr(Y,n,50),Be(n,T));let D=a[s(1482)+s(1383)];D!==void 0&&(e[s(989)](Y,n,58),Be(n,D));let B=a.payload;e[s(500)](void 0,B)&&(Y(n,66),e[s(1154)](Y,n,B[s(1322)]),e[s(1352)](ue,n,B));let G=a.LogIDNew;e[s(1178)](void 0,G)&&(Y(n,74),Be(n,G));let $=a["serverTi"+s(752)];e[s(716)](void 0,$)&&(e[s(572)](Y,n,82),Be(n,$));let K=a[s(1671)];e.wUsyd(void 0,K)&&(e[s(521)](Y,n,90),Be(n,K));let ge=a[s(1358)+"e"];e[s(1467)](void 0,ge)&&(e.llnBg(Y,n,96),e[s(680)](ye,n,O(ge)))}function E(a){return v(F(a))}function v(a){let n=t,s={};e:for(;!e[n(410)](N,a);){let d=e.MUfVJ(Ee,a);switch(e[n(1279)](d,3)){case 0:break e;case 1:s[n(269)]=e[n(281)](zn,a,!0);break;case 2:s[n(351)]=e.IcTiT(zn,a,!0);break;case 3:s[n(1018)]=e[n(623)](Ee,a);break;case 4:s[n(675)]=e[n(410)](Ee,a);break;case 5:{let f=e.bGAUA(I,a);(s[n(353)]||(s[n(353)]=[]))[n(305)](e[n(731)](b,a)),a.limit=f;break}case 6:s[n(1682)+n(692)]=e.JqSjT(be,a,e[n(731)](Ee,a));break;case 7:s[n(1482)+n(1383)]=be(a,e.LCscf(Ee,a));break;case 8:s[n(721)]=oe(a,Ee(a));break;case 9:s[n(1412)]=e[n(949)](be,a,e[n(623)](Ee,a));break;case 10:s[n(272)+"ming"]=e[n(998)](be,a,e[n(629)](Ee,a));break;case 11:s[n(1671)]=e.EJwZq(be,a,e[n(371)](Ee,a));break;case 12:s[n(1358)+"e"]=e[n(731)](Ee,a);break;default:k(a,e[n(763)](7,d))}}if(e.WiFhB(void 0,s.SeqID))throw new Error(e[n(942)]);if(e.nfRpN(void 0,s[n(351)]))throw new Error(e[n(973)]);if(e[n(1527)](void 0,s[n(1018)]))throw new Error(e[n(1126)]);if(e[n(384)](void 0,s[n(675)]))throw new Error(e[n(598)]);return s}function I(a){let n=t,s=e[n(410)](Ee,a),d=a[n(653)];return a.limit=e[n(1031)](a[n(1394)],s),d}function k(a,n){let s=t;switch(n){case 0:for(;e[s(763)](128,e.UAXCx(Re,a)););break;case 2:e[s(989)](P,a,e[s(629)](Ee,a));break;case 5:P(a,4);break;case 1:e[s(1517)](P,a,8);break;default:throw new Error(e[s(1586)](e[s(383)],n))}}function O(a){let n=t;if(n(868)!==e[n(517)])return a|=0,{low:a,high:a>>31,unsigned:e[n(574)](a,0)};this[n(1222)](n(316),_0x6a5a5f(e.pORYe,{..._0xb62d31,message:_0x59857a[n(1017)]||""}))}let y=[];function C(){let a=t,n=y.pop();return n?(n.offset=n[a(653)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function L(a){y[t(305)](a)}function F(a){return{bytes:a,offset:0,limit:a.length}}function z(a){let n=t;if(n(1300)===e[n(1375)]){let s=n(783)+_0xcd9673+(" fail, m"+n(749)+n(408)+"ed");this[n(757)+n(438)+n(982)](e[n(504)](_0x3d3b61,n(316),{message:s,code:_0x2a9b8e[n(1271)+n(331)+"R"],error:_0x2246dc}));return}else{let s=a[n(1524)],d=a[n(653)];return e[n(467)](s[n(1322)],d)?s:s[n(676)](0,d)}}function P(a,n){let s=t;if(e.MZNMw(e[s(1124)](a[s(1394)],n),a.limit))throw new Error(s(1428)+"t limit");a[s(1394)]+=n}function N(a){let n=t;return e.BPtRe(a[n(1394)],a[n(653)])}function U(a,n){let s=t,d=a.bytes,f=a[s(1394)],x=a[s(653)],m=e.QcLEI(f,n);if(e[s(1311)](m,d[s(1322)])){let S=new Uint8Array(e[s(606)](2,m));S[s(304)](d),a[s(1524)]=S}return a[s(1394)]=m,m>x&&(a[s(653)]=m),f}function W(a,n){let s=t,d=a[s(1394)];if(e[s(1311)](d+n,a[s(653)]))throw new Error("Read past limit");return a.offset+=n,d}function oe(a,n){let s=t,d=W(a,n);return a[s(1524)][s(676)](d,d+n)}function ue(a,n){let s=t,d=e[s(281)](U,a,n[s(1322)]);a.bytes.set(n,d)}function be(a,n){let s=t,d={BOksd:function(T,D){return e[J(1230)](T,D)}},f=e.CzNwj(W,a,n),x=String[s(1040)+s(330)],m=a[s(1524)],S="\uFFFD",g="";for(let T=0;e[s(931)](T,n);T++)if(e[s(555)](e.xlqSe,e.CFNQo))this[s(1413)](e.hMzGe,_0x40967b[s(760)]),e[s(1121)](_0x1fea21);else{let D=m[e[s(1092)](T,f)],B,G,$,K;if(e[s(326)](e[s(1016)](128,D),0))g+=e[s(1235)](x,D);else if(e[s(326)](224&D,192))e[s(574)](T+1,n)?g+=S:(B=m[e[s(913)](e.JmMif(T,f),1)],e.dkmwm(192&B,128)?g+=S:(K=e[s(475)](e[s(909)](e[s(763)](31,D),6),63&B),K<128?g+=S:(g+=e.fVoVb(x,K),T++)));else if(e.pdiDP(240,D)==224)if(e[s(1230)](T,2)>=n)g+=S;else if(B=m[e[s(1063)](e[s(1280)](T,f),1)],G=m[e.tFKvn(e[s(910)](T,f),2)],e[s(1467)](e[s(885)](B,e[s(909)](G,8))&49344,32896))g+=S;else if(K=e[s(885)](e.slIEE(15,D)<<12|e[s(674)](e[s(846)](63,B),6),e.KfPNJ(63,G)),K<2048||e[s(1203)](K,55296)&&e[s(512)](K,57343))g+=S;else if(e.CNkAw(e[s(1617)],s(1059)))g+=x(K),T+=2;else{let ge=_0x8fb948[s(1524)],se=_0x5b4d41[s(1394)],de=_0x197964[s(653)],et=KppRbB[s(1605)](se,_0x452f62);if(et>ge[s(1322)]){let Li=new _0x5127bf(2*et);Li.set(ge),_0x8e317.bytes=Li}return _0x5c2808.offset=et,et>de&&(_0x32b90b[s(653)]=et),se}else e.eQMxV(e[s(396)](248,D),240)?e[s(1203)](T+3,n)?g+=S:(B=m[e[s(1031)](e[s(791)](T,f),1)],G=m[e[s(333)](e[s(1586)](T,f),2)],$=m[e[s(1092)](T,f)+3],e[s(1016)](e[s(1131)](e.TDrCL(B,e.uBhke(G,8)),e.nAOBx($,16)),12632256)!==8421504?g+=S:(K=e[s(1163)](e[s(526)](e[s(496)](7,D)<<18|e[s(909)](63&B,12),e[s(1016)](63,G)<<6),e.slIEE(63,$)),K<65536||K>1114111?g+=S:(K-=65536,g+=e[s(788)](x,e[s(1565)](e[s(1618)](K,10),55296),e[s(1230)](e[s(682)](1023,K),56320)),T+=3))):g+=S}return g}function Be(a,n){let s=t,d=n.length,f=0;for(let S=0;e.ukbmL(S,d);S++){let g=n[s(1353)+"At"](S);g>=55296&&e[s(579)](g,56319)&&e[s(844)](e[s(1586)](S,1),d)&&(g=e[s(620)]((g<<10)+n.charCodeAt(++S),56613888)),f+=e[s(931)](g,128)?1:g<2048?2:e[s(1547)](g,65536)?3:4}e[s(788)](Y,a,f);let x=U(a,f),m=a[s(1524)];for(let S=0;e[s(497)](S,d);S++){let g=n[s(1353)+"At"](S);if(e[s(1325)](g,55296)&&e[s(1210)](g,56319)&&e[s(1056)](e.iLVPJ(S,1),d)&&(g=e[s(633)](e.nAOBx(g,10),n.charCodeAt(++S))-56613888),e[s(701)](g,128))m[x++]=g;else{if(g<2048)m[x++]=e[s(1172)](e[s(1004)](e.XMGow(g,6),31),192);else if(e[s(1225)](e[s(853)],e[s(570)]))g<65536?m[x++]=e[s(846)](e[s(545)](g,12),15)|224:(m[x++]=e[s(885)](e[s(846)](e[s(545)](g,18),7),240),m[x++]=e.uHNhD(e[s(908)](g,12)&63,128)),m[x++]=e[s(1273)](e[s(354)](g>>6,63),128);else return new _0x44054b(_0x3c1277,{data:_0x7917db});m[x++]=e[s(667)](e[s(1004)](63,g),128)}}}function ot(a,n){let s=t,d=e.IlnMi(U,a,n[s(653)]),f=a[s(1524)],x=n[s(1524)];for(let m=0,S=n[s(653)];m<S;m++)f[e.KbpNh(m,d)]=x[m]}function Re(a){return a[t(1524)][e.fczBV(W,a,1)]}function jt(a,n){let s=t,d={ZTuwA:function(f,x){return e[J(741)](f,x)}};if(e[s(529)]!==e[s(529)]){let f=this[s(952)][s(1237)](this[s(1610)]),x=_0x1f79f9.parse(d[s(296)](f,"{}"));return _0x467e3c[s(1668)](x)}else{let f=e[s(1398)](U,a,1);a[s(1524)][f]=n}}function Ee(a){let n=t,s=0,d=0,f;do f=e[n(957)](Re,a),s<32&&(d|=e[n(909)](e[n(1679)](127,f),s)),s+=7;while(e[n(682)](128,f));return d}function Y(a,n){let s=t;for(n>>>=0;e[s(1203)](n,128);)e[s(578)](jt,a,e[s(1465)](e[s(1359)](127,n),128)),n>>>=7;jt(a,n)}function zn(a,n){let s=t,d=0,f=0,x=0,m;if(m=e[s(503)](Re,a),d=e[s(1008)](127,m),e[s(1714)](128,m)&&(m=e.aUwYY(Re,a),d|=(127&m)<<7,e[s(471)](128,m)&&(m=Re(a),d|=e[s(1341)](127&m,14),128&m&&(m=e[s(775)](Re,a),d|=e[s(1443)](e[s(496)](127,m),21),128&m&&(m=e[s(1662)](Re,a),f=e[s(496)](127,m),128&m&&(m=e[s(1209)](Re,a),f|=e.ShrUH(e.XsBzQ(127,m),7),e[s(287)](128,m)))))))if(e[s(1368)](e[s(294)],e[s(1335)]))m=Re(a),f|=(127&m)<<14,e.YXEmT(128,m)&&(m=e[s(775)](Re,a),f|=(127&m)<<21,128&m&&(m=Re(a),x=e[s(1359)](127,m),e.ZGxFz(128,m)&&(m=Re(a),x|=e[s(855)](e[s(396)](127,m),7))));else{let S=e[s(602)](_0x46c17b,_0x223e46,1);_0x53f368[s(1524)][S]=_0x20cd38}return{low:e[s(1460)](d,e.BEoNk(f,28)),high:e[s(1172)](e.cmCSD(f,4),x<<24),unsigned:n}}function ye(a,n){let s=t,d=e[s(1279)](n[s(1715)],0),f=e[s(1137)](e[s(1273)](e[s(1279)](n.low,28),e[s(1443)](n[s(779)],4)),0),x=n[s(779)]>>>24,m=e[s(546)](0,x)?e.ywEBJ(0,f)?e[s(844)](d,16384)?e.xSspk(d,128)?1:2:e[s(1145)](d,2097152)?3:4:f<16384?f<128?5:6:e[s(1103)](f,2097152)?7:8:x<128?9:10,S=e[s(275)](U,a,m),g=a[s(1524)];switch(m){case 10:g[e[s(995)](S,9)]=e[s(698)](x,7)&1;case 9:g[e.JtpbB(S,8)]=m!==9?e.owaAN(128,x):e[s(287)](127,x);case 8:g[S+7]=m!==8?e.fovMF(e[s(1279)](f,21),128):e.czwXC(e.VAWEz(f,21),127);case 7:g[S+6]=e[s(716)](7,m)?e[s(584)](f>>>14,128):e[s(750)](f>>>14,127);case 6:g[e.yERSK(S,5)]=m!==6?e[s(475)](e[s(1686)](f,7),128):e[s(820)](e[s(698)](f,7),127);case 5:g[S+4]=e[s(699)](5,m)?128|f:e[s(763)](127,f);case 4:g[S+3]=m!==4?e[s(784)](e[s(587)](d,21),128):e[s(319)](e[s(1019)](d,21),127);case 3:g[S+2]=m!==3?e[s(423)](d>>>14,128):e[s(319)](e.Ahjil(d,14),127);case 2:g[S+1]=e[s(857)](2,m)?e[s(1100)](d>>>7,128):e[s(905)](e.bEmxH(d,7),127);case 1:g[S]=m!==1?e.ILRlg(128,d):e[s(496)](127,d)}}function Fn(a){return e[t(945)](E,a)}function We(a){return e.UAXCx(A,a)}let ad=65536,Wh=e[t(1080)],Un=e[t(1622)](ad,ad),cd=Un*Un,dd=e[t(590)](cd,2),Gt=String.prototype.charCodeAt;class ae{constructor(n,s,d){let f=t;this[f(1072)]=!0,this[f(1715)]=e[f(1379)](0,n),this[f(779)]=e[f(631)](0,s),this[f(1316)]=!!d}static[t(1072)](n){let s=t;return n&&e[s(384)](!0,n[s(1072)])}static[t(1099)](n,s,d){return new ae(n,s,d)}static[t(768)+"s"](n,s,d){return d?ae["fromByte"+t(860)](n,s):ae.fromBytesBE(n,s)}static[t(768)+"sLE"](n,s){let d=t;return new ae(e.OyMjM(e[d(667)](n[0],e[d(1341)](n[1],8))|e[d(909)](n[2],16),e[d(1550)](n[3],24)),e.xCOVA(e[d(1379)](n[4],e[d(1341)](n[5],8))|e[d(1443)](n[6],16),n[7]<<24),s)}static["fromByte"+t(525)](n,s){let d=t;return new ae(e[d(1128)](e[d(423)](e[d(1163)](e.nAOBx(n[4],24),e[d(640)](n[5],16)),e[d(1688)](n[6],8)),n[7]),e[d(1128)](e[d(423)](e[d(978)](e.BEoNk(n[0],24),n[1]<<16),e[d(1255)](n[2],8)),n[3]),s)}static[t(1262)](n){let s=t;return e[s(1141)](n,Wh)?ld:new ae(e[s(486)](e[s(1172)](e.ZbkAl(e[s(526)](Gt[s(1032)](n,0),e[s(877)](Gt[s(1032)](n,1),8)),Gt.call(n,2)<<16),e[s(1688)](Gt[s(1032)](n,3),24)),0),e[s(1263)](e.gclvN(e.wBLSZ(e.jRCTC(Gt[s(1032)](n,4),e[s(1712)](Gt[s(1032)](n,5),8)),Gt.call(n,6)<<16),Gt[s(1032)](n,7)<<24),0),!0)}[t(1563)](){let n=t;return String["fromChar"+n(330)](e[n(820)](255,this[n(1715)]),e[n(902)](e[n(1659)](this[n(1715)],8),255),e[n(396)](this[n(1715)]>>>16,255),e[n(1649)](this[n(1715)],24),255&this[n(779)],e[n(1016)](e.FKbje(this[n(779)],8),255),e[n(396)](e.NHmIX(this[n(779)],16),255),e.NttMl(this[n(779)],24))}static[t(832)+"er"](n,s=!0){let d=t,f={Jssnq:function(x,m){return x+m},wLtOi:d(1428)+d(1591)};if(isNaN(n))return s?Kh:ld;if(s)if(e[d(392)](e[d(1250)],e[d(813)])){if(e[d(574)](n,cd))return Vh}else{if(IJpwZH[d(1105)](_0x229d60[d(1394)],_0x2ea5ec)>_0x155269[d(653)])throw new _0x529529(IJpwZH[d(1431)]);_0x1b1ecf[d(1394)]+=_0x190771}else{if(e[d(534)](n,-dd))return Jh;if(e[d(442)](e[d(870)](n,1),dd))return $h}return ae[d(1099)](e.nkEAY(e.PmmmX(n,Un),0),e.TQBLC(n,Un)|0,s)}[t(1555)](){let n=t;return this[n(1316)]?e[n(791)](e[n(1171)](e[n(394)](this[n(779)],0),Un),e.FKbje(this[n(1715)],0)):e[n(1419)](e[n(1633)](this[n(779)],Un),e.bEmxH(this[n(1715)],0))}[t(365)](){let n=t,s={ZSAYc:function(d,f){return e[J(630)](d,f)},GgWLI:function(d,f){return e.yWalh(d,f)}};return e[n(1313)](e[n(1284)],e[n(1284)])?s.ZSAYc(0,this[n(779)])&&s[n(1447)](0,this[n(1715)]):this[n(779)]===0&&e[n(1510)](0,this[n(1715)])}add(n){let s=t;ae[s(1072)](n)||(n=ae[s(832)+"er"](n));let d=e[s(1137)](this.high,16),f=65535&this[s(779)],x=e[s(587)](this.low,16),m=e[s(905)](65535,this[s(1715)]),S=e[s(698)](n[s(779)],16),g=65535&n[s(779)],T=e.xvYRb(n[s(1715)],16),D=e[s(396)](65535,n[s(1715)]),B=0,G=0,$=0,K=0;return K+=m+D,$+=e[s(1086)](K,16),K&=65535,$+=x+T,G+=$>>>16,$&=65535,G+=f+g,B+=e[s(1557)](G,16),G&=65535,B+=e[s(913)](d,S),B&=65535,ae.fromBits(e[s(1411)](e[s(1712)]($,16),K),e.arNse(e[s(769)](B,16),G),this[s(1316)])}[t(474)](n){let s=t;return ae[s(1072)](n)||(n=ae[s(832)+"er"](n)),e.ikhxg(this[s(1316)],n[s(1316)])&&e[s(597)](this[s(779)],31)===1&&e[s(938)](n[s(779)]>>>31,1)?!1:e[s(1681)](this.high,n[s(779)])&&this[s(1715)]===n[s(1715)]}[t(1351)](){let n=t;return e[n(1681)](-1,this[n(1715)])&&e[n(326)](-1,this.high)?ae[n(1099)](0,0,this[n(1316)]):e[n(378)](-1,this[n(1715)])?ae[n(1099)](0,e[n(967)](this[n(779)],1),this[n(1316)]):ae[n(1099)](e[n(1090)](this[n(1715)],1),this[n(779)],this[n(1316)])}[t(1165)](n){let s=t;if(e[s(1680)](e.aworu,s(811))){let d=_0x40e4be(_0x34ff25,_0x46c735);return _0x34951c[s(1524)].subarray(d,d+_0xf52642)}else return n?this.toBytesLE():this[s(1243)+"E"]()}[t(505)+"E"](){let n=t,s=this[n(779)],d=this[n(1715)];return[e[n(750)](255,d),e.IQEfv(d,8)&255,e[n(1387)](e[n(1137)](d,16),255),d>>>24,e[n(1481)](255,s),e[n(1714)](e[n(374)](s,8),255),e[n(660)](e[n(1256)](s,16),255),s>>>24]}[t(1243)+"E"](){let n=t,s=this[n(779)],d=this[n(1715)];return[s>>>24,e[n(763)](e[n(1050)](s,16),255),e[n(765)](e.NttMl(s,8),255),e.GQHTo(255,s),e[n(1050)](d,24),e[n(1481)](d>>>16,255),e[n(1557)](d,8)&255,255&d]}}let ld=new ae(0,0,!1),Kh=new ae(0,0,!0),$h=ae[t(1099)](-1,2147483647,!1),Vh=ae[t(1099)](-1,-1,!0),Jh=ae.fromBits(0,-2147483648,!1);var Wt=(function(a){let n=t,s=e[n(1457)][n(357)]("|"),d=0;for(;;){switch(s[d++]){case"0":a[a["MAX_RETR"+n(331)+"R"]=5003]=e[n(476)];continue;case"1":return a;case"2":a[a[n(635)+"OR"]=5005]=e.cgNXT;continue;case"3":a[a[e[n(1666)]]=5002]=e[n(1666)];continue;case"4":a[a[e[n(454)]]=5004]=n(532)+"ERROR";continue;case"5":a[a[e[n(1525)]]=5001]=e.klkaJ;continue}break}})({});class Hn{constructor(n){let s=t;this[s(742)]=n,this.target=null}}class fd extends Hn{constructor(n,s){let d=t;super(n),this[d(760)]=s&&s.message||null}}class ud extends Hn{constructor(n,s){let d=t;super(n),this[d(316)]=s&&s.error||null,this[d(924)]=s&&s[d(924)]||0,this[d(879)]=s&&s[d(879)]||"",this[d(1548)]=s&&s[d(1548)]||0,this[d(760)]=s&&s[d(760)]||"",this.code=s&&s[d(1104)]||5001}}class hd extends Hn{constructor(n,s){let d=t,f=e[d(298)][d(357)]("|"),x=0;for(;;){switch(f[x++]){case"0":this[d(1450)+d(753)]=s&&s[d(1450)+"nnect"]||!1;continue;case"1":this[d(1315)]=s&&s[d(1315)]||"";continue;case"2":super(n);continue;case"3":this[d(1104)]=s&&s[d(1104)]||0;continue;case"4":this[d(1036)]=s&&s[d(1036)]||!1;continue}break}}}class xd extends Hn{constructor(n,s){let d=t;super(n),this[d(794)]=s&&s[d(794)]||null}}class pd extends xd{constructor(n,s){let d=t;super(n),this[d(794)]=s&&s[d(794)]||null,this[d(760)]=s&&s[d(760)]||null}}class gd extends Hn{constructor(n,s){let d=t;super(n),this[d(794)]=s&&s[d(794)]||null}}function Qe(a,{message:n,code:s,error:d}){return new ud(a,{message:n,code:s,error:d})}function at(a,{code:n,reason:s,wasClean:d,willReconnect:f}){let x=t,m={EVUaJ:e[x(457)],FYYik:function(S,g){return e.jZPVF(S,g)},vTLun:function(S,g){return S!=g},IKhtS:e[x(1360)],GZjXD:function(S,g){return S==g},tWSdi:e[x(862)]};if(e[x(716)](e[x(994)],e[x(994)]))try{return m.EVUaJ!=typeof _0x7f4d4d&&(m.FYYik(_0x1c15a8,_0x148f67)||_0x23cf21[x(510)]&&m[x(592)](_0x4df3f7[x(510)],_0x12d35e))||m[x(1560)](m[x(1342)],typeof _0xb106d5)?"":(_0x2706d5[x(437)](_0x32a21a),m[x(1657)])}catch{return m.GZjXD("string",typeof _0x55f54d)?m[x(1664)]:""}else return new hd(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function md(a,{data:n,message:s}){return new pd(a,{data:n,message:s})}function wd(a,{data:n}){return new gd(a,{data:n})}function Po(a,{message:n}){return new fd(a,{message:n})}class yd{constructor(n,s){let d=t;this[d(1475)+"s"]=n,this[d(1558)+"es"]=s,this[d(1149)+d(549)]=0,this[d(1461)+d(1281)+d(1045)+"t"]=0}[t(628)+t(1382)+"fig"](){let n=t;this[n(1149)+n(549)]=0,this.currentEndpointTriesCount=0}[t(1587)+"es"](){let n=t;this[n(1461)+n(1281)+n(1045)+"t"]=0}[t(651)+t(556)+"nt"](){let n=t;return this[n(1475)+"s"][this[n(1149)+"ndex"]]}[t(651)+t(556)+t(1511)+"ount"](){let n=t,s={ijoow:function(d,f){return e[J(773)](d,f)},sGZST:function(d,f){return e.WbrGJ(d,f)},rCiys:function(d,f){return e[J(1679)](d,f)},EQtrv:function(d,f){return e[J(1576)](d,f)},imSHQ:function(d,f){return e[J(1559)](d,f)}};if(e.mFQPw===e[n(1233)])_0x3da63a=amoPYq[n(1669)](_0xf3f575,_0x1e01f8),_0x4b58a8|=amoPYq.sGZST(127,_0x2e2d12)<<21,128&_0x606d17&&(_0x477504=_0x12ef3d(_0x34ee1a),_0x112c62=amoPYq[n(1385)](127,_0x54664f),amoPYq[n(762)](128,_0x32fa5c)&&(_0x4d1c65=amoPYq[n(1669)](_0x52755c,_0x13c1cf),_0x4dbc4e|=amoPYq.imSHQ(127,_0x5b7387)<<7));else return this[n(1461)+"ndpointTriesCount"]}[t(968)+t(618)+"es"](){let n=t,s={cVBYT:function(d,f,x){return e[J(521)](d,f,x)},GESCg:e[n(1575)]};if(e.bhWmw(e[n(867)],n(1437)))this[n(1222)](n(659),s[n(881)](_0xe06b45,s[n(1687)],{..._0x3b6343,data:_0x4e9787[n(1017)]||""}));else return!!(e[n(1203)](this["currentI"+n(549)],this.endpoints[n(1322)])||this[n(1149)+"ndex"]===this[n(1475)+"s"][n(1322)]-1&&e[n(634)](this[n(1461)+"ndpointTriesCount"],this.maxRetries))}["checkCurrentEndp"+t(1205)+t(582)+t(1698)](){let n=t;return e[n(1049)](this.currentIndex,this[n(1475)+"s"].length)?!0:e[n(523)](this["currentEndpointT"+n(1045)+"t"],this[n(1558)+"es"])}["replaceBackupEnd"+t(770)+t(1259)+t(1160)](){let n=t;return this[n(1461)+"ndpointT"+n(1045)+"t"]=1,this[n(1149)+n(549)]++,this[n(1475)+"s"][this[n(1149)+n(549)]]}[t(651)+"ntEndpoi"+t(489)+"ateCount"](){let n=t;return this[n(1461)+n(1281)+n(1045)+"t"]++,this[n(651)+"ntEndpoint"]()}}let qn=(e[t(452)](e.hMpWt,typeof globalThis)&&t(817)===globalThis[t(643)+t(979)][t(801)]||e.hMpWt!=typeof window&&e[t(875)](t(817),window["construc"+t(979)].name))&&e[t(740)]!=typeof document,gn=e[t(849)](e[t(740)],typeof globalThis)&&(e.nfRpN(e[t(1118)],globalThis["construc"+t(979)][t(801)])||e[t(326)]("Dedicate"+t(1020)+t(644)+"pe",globalThis[t(643)+"tor"].name))&&e.Rujcf(e.hMpWt,typeof tt),Dr=(e[t(740)]!=typeof globalThis&&e[t(922)](e[t(1118)],globalThis["construc"+t(979)][t(801)])||e[t(1699)](e.hMpWt,typeof globalThis)||e[t(1629)](e[t(740)],typeof globalThis)&&!!globalThis["WeixinJS"+t(1521)])&&e[t(1704)](e[t(740)],typeof wx),kr=e[t(1071)](e[t(740)],typeof globalThis)&&(t(664)+t(1020)+t(644)+"pe"===globalThis[t(643)+t(979)][t(801)]||e.AtPFF===globalThis["construc"+t(979)].name||e[t(453)]===globalThis.constructor.name)&&e[t(740)]!=typeof self,Zh=typeof globalThis<"u"&&e[t(630)](e[t(1118)],globalThis[t(643)+t(979)].name)&&e[t(1232)](e[t(740)],typeof global)&&e[t(876)](e[t(1118)],global[t(643)+t(979)].name)&&e[t(740)]!=typeof process&&!!process[t(1430)];class Lo{constructor(){let n=t;this[n(360)+"rs"]={}}[t(1222)](n,...s){let d=t,f=this[d(360)+"rs"][n];if(f)f[d(386)]()[d(1354)](x=>x.fn[d(734)](x[d(935)],s));else if(e.MTZdZ(d(316),n)&&!this[d(1310)]){let x=s[d(1322)]&&s[0];if(e.BvQbV(x,Error))throw x;let m=new Error(e[d(690)](e[d(941)],x?e[d(1597)](e.GZyxQ(" (",x[d(760)]),")"):""));throw m[d(406)]=x,x}return this}[t(893)](n,s){let d=t;if(e.wUsyd(e.gAJzI,e.gAJzI)){let{type:f}=_0x3063ce;this[d(1222)](f,_0x35c651)}else{if(n===void 0)this[d(360)+"rs"]={};else if(e.KApTL(void 0,s))this._listeners[n]=null;else{let f=this._listeners[n];if(f)for(let x=0;e[d(299)](x,f.length);)e[d(1041)](f[x].fn,s)?f[d(1497)](x,1):++x}return this}}on(n,s,d){let f=t;return e[f(1680)](e[f(1196)],f(472))?e[f(1049)](e[f(457)],typeof _0x1dca61)?e[f(862)]:"":((this[f(360)+"rs"][n]||(this._listeners[n]=[]))[f(305)]({fn:s,ctx:d||this}),this)}}class Yh extends Lo{[t(1240)+t(1307)+t(981)](n){let s=t;return n[s(1017)]||n.errNo?(s(977)+" "+(n.errMsg||"")+s(1254)+(n[s(522)]||"")).trim():JSON[s(679)+"y"](n)}constructor(n,s,d){let f=t;super(),this[f(559)]=null,Dr&&wx[f(1253)+"ocket"]&&(this[f(559)]=wx[f(1253)+f(615)]({url:n,protocols:s,header:d,fail:this[f(1614)+"ocketFailHandler"][f(1707)](this),success:this[f(1614)+f(1603)+f(1627)+f(447)].bind(this)})),gn&&tt["connectS"+f(615)]&&(this[f(559)]=tt[f(1253)+"ocket"]({url:n,protocols:s,header:d,fail:this[f(1614)+f(1216)+f(829)][f(1707)](this),success:this["_createS"+f(1603)+"cessHandler"][f(1707)](this)}))}["_createS"+t(1603)+t(1627)+"ler"](){let n=t;Promise[n(1485)]()[n(1116)](()=>{this[n(759)+"steners"]()})}[t(1614)+"ocketFai"+t(829)](n){let s=t,d={KPhzN:function(f,x,m){return e.fQqCg(f,x,m)},aHRQy:s(316),IVurg:e[s(580)]};Promise[s(1485)]().then(()=>{let f=s,x=d[f(1246)](Qe,d[f(1503)],{message:this["_formatErrorMess"+f(981)](n)});this.emit(d[f(1503)],x);let m=at(d[f(1200)],{reason:this[f(1240)+f(1307)+f(981)](n)});this[f(1222)](d[f(1200)],m)})}[t(759)+"steners"](){let n=t,s={MACpM:n(283),VaYkg:e.pORYe,pgcIF:function(d,f,x){return e[n(275)](d,f,x)}};this[n(559)][n(1357)](d=>{let f=n;this[f(1222)](e[f(1575)],e[f(542)](wd,"open",{...d,data:d[f(1017)]||""}))}),this[n(559)].onClose(d=>{let f=n;e[f(857)](e[f(1613)],e[f(1613)])?(this[f(1582)+"er"]&&_0x4fc0cd["removeEv"+f(441)+"ner"](s[f(1158)],this[f(1399)+"ageHide"]),this[f(1582)+"er"]&&_0x2dba83[f(923)+f(441)+"ner"]("pageshow",this["_handleP"+f(450)]),this[f(1674)]()):this.emit(e[f(580)],e.zlamf(at,f(1674),{...d}))}),this[n(559)][n(859)+"e"](d=>{let f=n;this.emit(e[f(1257)],md(e[f(1257)],{...d}))}),this[n(559)][n(1182)](d=>{let f=n;this[f(1222)](s[f(498)],s[f(1147)](Qe,s[f(498)],{...d,message:d.errMsg||""}))})}[t(1670)](n){let s=t,d={kHTMP:function(f,x,m){return e.primW(f,x,m)},HGZyq:s(316)};if(e[s(411)](n,Uint8Array)){let f=n[s(510)].slice(n[s(1374)+"et"],e[s(1061)](n[s(1115)+"th"],n[s(1374)+"et"]));this[s(559)]&&this[s(559)][s(1670)]({data:f,fail:x=>{let m=s;this[m(1222)](e.pORYe,e[m(1568)](Qe,m(316),{message:this["_formatE"+m(1307)+m(981)](x)}))}})}else this[s(559)]&&this[s(559)][s(1670)]({data:n,fail:f=>{let x=s;this.emit(x(316),d[x(1476)](Qe,d[x(1139)],{message:this[x(1240)+x(1307)+x(981)](f)}))}})}[t(1674)](n,s){let d=t;this._socket&&this[d(559)][d(1674)]({code:n,reason:s})}[t(1107)+t(1227)](n,s){this.on(n,s)}[t(923)+t(441)+"ner"](n,s){let d=t,f={OMOdH:e[d(866)]};e[d(1313)](e[d(342)],e[d(1267)])?this[d(893)](n,s):(this[d(754)]&&this[d(754)][d(1670)](_0x4e706b),this[d(1413)](f[d(906)],_0x2c5904))}get[t(533)+"te"](){let n=t;return this._socket[n(533)+"te"]}get[t(1692)+"pe"](){let n=t;if(e[n(1064)]===n(1661))this[n(1582)+"er"]&&_0x21caef[n(923)+n(441)+n(657)](e[n(1697)],this[n(593)+n(1624)]),this[n(1582)+"er"]&&_0x242b51["removeEventListe"+n(657)](e[n(1011)],this[n(593)+n(1292)]),this[n(1582)+"er"]&&_0x417267[n(923)+n(441)+"ner"](e[n(1156)],this["_handleP"+n(691)]),this[n(1582)+"er"]&&_0x1f11ed[n(923)+n(441)+n(657)](e[n(647)],this[n(1399)+n(450)]);else return this[n(559)][n(1692)+"pe"]}set[t(1692)+"pe"](n){}get[t(1301)](){let n=t;return this[n(559)][n(1301)]}get[t(540)](){let n=t;return this[n(559)][n(540)]}get[t(511)+"ns"](){return this[t(559)].extensions}get[t(1470)+t(1093)](){return 0}}function Xh(a,n){let s=t;if(n)return new n(a[s(1301)],a[s(540)]);if(e.tZYqC(Dr,gn))return new Yh(a[s(1301)],a.protocol,a.headers);if(e[s(1529)](qn,kr)&&s(1592)+"d"!=typeof WebSocket&&WebSocket)return new WebSocket(a.url,a[s(540)+"s"])}function Qh(a){let n=t,s=e[n(1439)][n(357)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(Dr&&wx["connectS"+n(615)])return!0;continue;case"1":return!1;case"2":if(a)return!0;continue;case"3":if(gn&&tt[n(1253)+"ocket"])return!0;continue;case"4":if((qn||kr)&&e[n(740)]!=typeof WebSocket&&WebSocket)return!0;continue}break}}function _d(a,n,s){let d=-1;async function f(x){let m=J;return e.qfPWN(x,d)?Promise[m(1339)](new Error(e[m(1665)])):(d=x,e[m(938)](x,s.length)?Promise.resolve():s[x][m(1707)](a)(n,f[m(1707)](null,e.kvMtH(x,1))))}f(0)}function bd(a){let n=t,s=0,d=0;for(let f=0;e[n(588)](f,a[n(1322)]);++f)d=a[n(1353)+"At"](f),e.bAWby(d,128)?s+=1:e[n(1145)](d,2048)?s+=2:(64512&d)===55296&&e[n(1141)](e[n(750)](64512,a[n(1353)+"At"](f+1)),56320)?(++f,s+=4):s+=3;return s}function Ed(a,n,s){let d=t;if(e[d(1337)](e[d(1333)](s,n),1))return"";let f="";for(let x=n;e[d(925)](x,s);){let m=a[x++];if(e.ESAcz(m,127))f+=String[d(1040)+d(330)](m);else if(e[d(718)](m,192)&&e.LLegD(m,224))f+=String[d(1040)+d(330)](e.oyebf(e[d(1688)](31&m,6),63&a[x++]));else if(e[d(1203)](m,224)&&e.xSspk(m,240))f+=String[d(1040)+d(330)](e.ILRlg(e.yzeHN(e.IfJRt(e[d(937)](15,m),12),e.uBhke(e.UljID(63,a[x++]),6)),e[d(560)](63,a[x++])));else if(e[d(821)](m,240)){let S=(e[d(1564)](e[d(1397)](e.GBlKE(7,m),18),e[d(560)](63,a[x++])<<12)|(63&a[x++])<<6|e.IkzXz(63,a[x++]))-65536;f+=String["fromChar"+d(330)](e[d(1419)](55296,e.aHLJE(S,10))),f+=String[d(1040)+d(330)](e[d(1230)](56320,e[d(682)](1023,S)))}}return f}function Oo(a,n,s){let d=t;if(e[d(378)](e.LwCDE,"KszgL"))return _0x3d497a?_0x2488d2[d(768)+d(860)](_0x2e8ecb,_0x2b5c46):_0x5ded0a[d(768)+"sBE"](_0x468c3a,_0x4726c0);{let f=s,x,m;for(let S=0;e[d(925)](S,a[d(1322)]);++S)if(x=a[d(1353)+"At"](S),x<128)n[s++]=x;else if(x<2048)n[s++]=e[d(1451)](e.sYwzA(x,6),192),n[s++]=e[d(873)](e.qoWSg(63,x),128);else if(e.iVaAc(64512&x,55296)&&e[d(1041)](64512&(m=a[d(1353)+"At"](e.aNVCT(S,1))),56320)){let g=(d(1562)+"5|0")[d(357)]("|"),T=0;for(;;){switch(g[T++]){case"0":n[s++]=e.CAJJF(e[d(991)](63,x),128);continue;case"1":++S;continue;case"2":x=e[d(1625)](e[d(687)](65536,e[d(550)](e.BHaIv(1023,x),10)),e[d(991)](1023,m));continue;case"3":n[s++]=e[d(607)](e[d(908)](x,12),63)|128;continue;case"4":n[s++]=e[d(747)](e[d(908)](x,18),240);continue;case"5":n[s++]=e[d(999)](e[d(425)](e[d(1488)](x,6),63),128);continue}break}}else n[s++]=e[d(1379)](e[d(1520)](x,12),224),n[s++]=e.vShoL(e[d(732)](x,6),63)|128,n[s++]=63&x|128;return e[d(1656)](s,f)}}async function vd(a){let n=t;if(e.LAhJZ==typeof a){let s=new Uint8Array(e[n(945)](bd,a));return e[n(694)](Oo,a,s,0),s}return e.jZPVF(a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(510)],a.byteOffset,a[n(1115)+"th"])}function ex(a){let n=t;try{return e[n(1704)](n(1194),typeof a)&&(a instanceof ArrayBuffer||a[n(510)]&&e.HdAxA(a[n(510)],ArrayBuffer))||e[n(972)](e[n(457)],typeof a)?"":(JSON[n(437)](a),e[n(1360)])}catch{return e[n(1102)](e[n(457)],typeof a)?e[n(862)]:""}}let tx=(a,n)=>{let s=t;switch(a){case"boe":case e[s(971)]:return{["x-use-"+a]:1,"x-tt-env":n};default:return{}}};class nx{constructor(n){let s=t;this["maxLossC"+s(1002)]=n,this.count=0}addCount(){this.count++}[t(968)+t(1378)+"nt"](){let n=t,s={SrGeZ:function(d,f){return d===f},GsRab:function(d,f){return d===f},oaZmd:e[n(1206)],WLNEh:e[n(1552)],aVmCx:e[n(356)],vIfKG:function(d,f,x){return e[n(1424)](d,f,x)},fhLFH:function(d,f,x,m){return e[n(694)](d,f,x,m)},fZGeU:function(d,f,x){return d(f,x)},slAiM:e.pORYe};if(e[n(899)](e.EEiPa,"Qgrlk")){let{pingInterval:d,pingFrequency:f}=this[n(1512)];if((s[n(1590)]("hi",_0x14fdf1[n(794)])&&s[n(402)](s.oaZmd,f)||f==="auto")&&(this[n(1150)+n(851)](),this.emit(s[n(1396)],s[n(1314)]),this[n(502)+n(1028)+"Id"]=s.vIfKG(_0x264e47,this[n(1015)][n(1707)](this),d)),s[n(1590)]("hi",_0x10755f[n(794)]))return;try{s.fhLFH(_0xb17e09,this,_0x382d91,[_0x449f03,_0x38a549,_0x455f93,_0x1c7322,_0x3142e9,_0x145981])}catch(x){let m=s[n(462)](_0x5bb999,s[n(956)],{message:x[n(760)],code:_0x1195d9["MESSAGE_"+n(970)],error:x});this[n(757)+n(438)+n(982)](m)}}else return e[n(370)](this[n(1546)],this[n(830)+"ount"])}["resetCou"+t(792)](n=0){let s=t;if(e.VHUHV(s(464),e[s(300)])){let d=e.XRlIm[s(357)]("|"),f=0;for(;;){switch(d[f++]){case"0":_0x151d32=[s(313),laGflA[s(1007)],s(1628),laGflA[s(1244)],laGflA[s(449)]];continue;case"1":laGflA[s(736)](_0x156849);continue;case"2":laGflA[s(1121)](_0x4bbd0d);continue;case"3":_0x3a7c2a=[laGflA[s(1332)],laGflA.bHmgj,laGflA[s(429)],laGflA[s(1159)]];continue;case"4":_0x49c5c8=new _0x416fd1;continue;case"5":laGflA[s(957)](_0x53c98e,x=>({...x,get:(m,S,g)=>_0x158fa0(m,S)||x[s(313)](m,S,g),has:(m,S)=>!!_0x374916(m,S)||x.has(m,S)}));continue}break}}else this[s(830)+"ount"]=n,this[s(1546)]=0}}async function rx(a){let n=t,s={weYeJ:e[n(984)],nTTYx:function(d,f){return e.XdipK(d,f)},NbMvU:e[n(1245)],krJUQ:e[n(1364)],xaaIg:function(d,f){return d+f},rTQCE:e.OQedr};return new Promise(d=>{let f=n;if(!qn)return s.nTTYx(d,s[f(576)]);try{let x=document["createEl"+f(617)](s[f(432)]);window[f(1202)+f(1297)]=m=>{let S=f;document[S(739)]["removeCh"+S(335)](x),window[S(1202)+S(1297)]=void 0,d(m&&m[S(1184)]||s.weYeJ)},x[f(742)]=s[f(427)],x[f(420)]=s.xaaIg(a[f(828)](/^ws/,s[f(897)]),f(1584)+f(516)+f(1495)+"P");try{document[f(739)][f(645)+"ild"](x)}catch{document.body[f(566)+f(335)](x)}}catch{window["frontier"+f(1297)]=void 0,s[f(1285)](d,s[f(576)])}})}function Kt(a,n,s){let d=t;return!!a?.find(f=>f[d(1493)]===n&&f[d(1260)]===s)}function jn(a,n){let s=t;return a?.find(d=>d[s(1493)]===n)?.[s(1260)]}let No=null;async function ix(){let a=t;return No||(No=Promise[a(1485)]().then(Tt[a(1707)](Tt,a(599)))),No}class sx extends Lo{constructor(n,s){let d=t;super(),this[d(1522)]=n,this[d(807)]=s,this[d(952)]=void 0,this[d(302)+d(1708)]=null}async[t(864)](){await this[t(519)]()}async[t(519)](){let n=t;if(!this._qosDB){if(this["_initPro"+n(1708)])return this["_initPro"+n(1708)];try{let s=this[n(1522)],d=this._keyPath;this[n(302)+n(1708)]=(async()=>{let f=n,{openDB:x}=await ix();this[f(952)]=await e[f(694)](x,f(1202)+"_"+s,1,{upgrade(m){let S=f;m[S(488)+S(465)+"e"](s,{keyPath:d})}})})(),await this[n(302)+n(1708)]}catch(s){console.log(s)}finally{this[n(302)+n(1708)]=null}}}async[t(313)](n){let s=t;if(e[s(485)]!==e[s(1694)])try{return await this[s(519)](),this[s(952)]?.[s(313)](this[s(1522)],n)}catch(d){console[s(1170)](d)}else return this[s(559)][s(1692)+"pe"]}async[t(304)](n,s){let d=t;return await this[d(519)](),this[d(952)]?.[d(1069)](this._dbName,n)}async[t(953)](n){let s=t;try{return await this[s(519)](),this._qosDB?.delete(this[s(1522)],n)}catch(d){if(e.NKrao(e[s(712)],e.dWwen))switch(_0x44f7f5){case"boe":case s(291):return{[s(1e3)+_0x5d0c10]:1,"x-tt-env":_0xb51b05};default:return{}}else console[s(1170)](d)}}async[t(614)](){let n=t,s={CaZOl:function(d,f){return e.mfquw(d,f)},YnOrb:function(d,f){return e[J(957)](d,f)}};try{return e[n(1258)](n(815),e[n(772)])?(_0x3ca8ed[n(734)](IsyQpj[n(436)](_0x4738c7,this),_0x1bc5a3),IsyQpj.YnOrb(_0x459164,_0x1e4e33.get(this))):(await this._init(),this._qosDB?.[n(614)](this._dbName))}catch(d){console[n(1170)](d)}}async[t(1668)](){let n=t;return await this[n(519)](),this[n(952)]?.[n(1043)+"ys"](this[n(1522)])}async getAll(){let n=t,s={YVHpw:function(d,f){return e[J(273)](d,f)},BmKwL:function(d,f){return e[J(500)](d,f)},FKfBU:e.cMKkf,ERWJf:e[n(1011)]};if(e.djSOS("XcKMy",e[n(911)]))return await this._init(),this[n(952)]?.[n(1628)](this._dbName);_0x23cca8[n(1449)+"d"]&&(this[n(1204)+n(279)]()&&(!this._ws||s[n(379)](this[n(754)].readyState,this[n(661)])||s[n(1321)](this._ws[n(533)+"te"],this.CONNECTING))&&this._handleOnLine(),this[n(1582)+"er"]&&_0x47f766["addEvent"+n(1227)](s[n(764)],this[n(593)+n(1624)]),this._isBrowser&&_0x37fbc4[n(1107)+n(1227)](s[n(841)],this[n(593)+n(1292)]))}async[t(594)](){let n=t;try{this[n(952)]?.[n(1674)](),this[n(952)]=void 0}catch(s){if(e.IAYCa(e[n(778)],e.mqnHM))return new _0x3b1a01(_0x7f60ac);console[n(1170)](s)}}get[t(847)](){let n=t;try{return!!this[n(952)]}catch(s){return console[n(1170)](s),!1}}}class ox{constructor(n,s){let d=t;this[d(1466)]=n,this[d(274)]=s,this[d(952)]=localStorage}async[t(864)](){}get[t(1610)](){let n=t;return n(1202)+"_"+this[n(1466)]}async[t(313)](n){let s=t,d=this[s(952)].getItem(this._prefix);return JSON[s(437)](d||"{}")[n]}async[t(304)](n,s){let d=t,f=this._qosDB[d(1237)](this[d(1610)]),x=JSON[d(437)](e[d(1529)](f,"{}"));return x[s||n[this._pathKey]]=n,this[d(952)][d(1598)](this[d(1610)],JSON[d(679)+"y"](x)),s||n[this[d(274)]]}async del(n){let s=t,d=this._qosDB[s(1237)](this[s(1610)]),f=JSON.parse(d||"{}");return f[n]=void 0,this._qosDB.setItem(this[s(1610)],JSON[s(679)+"y"](f))}async[t(614)](){let n=t;return this[n(952)][n(614)]()}async[t(1668)](){let n=t,s=this[n(952)][n(1237)](this._prefix),d=JSON[n(437)](e[n(1199)](s,"{}"));return Object.keys(d)}async getAll(){let n=t,s={kRdtx:function(d,f){return e.dzqWU(d,f)}};if(e[n(886)](e[n(1513)],n(1175))){let d=this[n(952)][n(1237)](this[n(1610)]);return _0x201c81[n(437)](VuPOPT[n(506)](d,"{}"))[_0x4ea85c]}else{let d=this._qosDB[n(1237)](this[n(1610)]),f=JSON[n(437)](e[n(1199)](d,"{}"));return Object[n(1539)](f)}}[t(594)](){return Promise[t(1485)]()}get[t(847)](){return!!this[t(952)]}}class ax{constructor(n,s){let d=t;this[d(1466)]=n,this[d(274)]=s,this[d(952)]=gn?tt:Dr?wx:null}async[t(864)](){}get[t(1610)](){let n=t;return n(1202)+"_"+this[n(1466)]}async[t(313)](n){let s=t,d=this[s(952)][s(1436)+s(810)](this._prefix);return JSON[s(437)](e[s(1038)](d,"{}"))[n]}async set(n,s){let d=t,f=this[d(952)][d(1436)+d(810)](this[d(1610)]),x=JSON[d(437)](e[d(1038)](f,"{}"));return x[s||n[this[d(274)]]]=n,this[d(952)][d(412)+d(810)](this[d(1610)],JSON[d(679)+"y"](x)),s||n[this[d(274)]]}async[t(953)](n){let s=t,d=this[s(952)][s(1436)+"geSync"](this[s(1610)]),f=JSON[s(437)](e[s(741)](d,"{}"));return f[n]=void 0,this[s(952)]["setStora"+s(810)](this._prefix,JSON.stringify(f))}async[t(614)](){let n=t;return this[n(952)][n(652)+n(1709)]()}async[t(1668)](){let n=t,s=this[n(952)][n(1436)+"geInfoSync"](this[n(1610)]),d=JSON[n(437)](s||"{}");return Object.keys(d)}async[t(1628)](){let n=t,s=this[n(952)][n(1436)+n(1336)+"nc"](this[n(1610)]),d=JSON[n(437)](s||"{}");return Object[n(1539)](d)}[t(594)](){return Promise.resolve()}get[t(847)](){return!!this[t(952)]}}function Sd(a,n){let s=t,d={EKprH:e[s(1218)],iWtoK:function(f,x){return f>x},aTqjF:function(f,x,m,S){return f(x,m,S)},DTCIf:function(f,x){return e[s(931)](f,x)},AGmfc:function(f,x){return e.aeVJX(f,x)},nqKSl:function(f,x){return e[s(552)](f,x)},RMLJe:function(f,x){return f|x},EsrxN:function(f,x){return f|x},CMSiW:function(f,x){return e[s(909)](f,x)},WpEHP:function(f,x){return e[s(1406)](f,x)},gJERE:function(f,x){return f>>>x},HBwZT:function(f,x){return e[s(1172)](f,x)},qDyct:function(f,x){return f<<x},ZpUVq:function(f,x){return f>>>x},IVhjC:function(f,x){return e[s(550)](f,x)},KUHCF:function(f,x){return f|x},cTlcd:function(f,x){return e[s(361)](f,x)},cJWAE:function(f,x){return e[s(319)](f,x)},WKTxG:function(f,x){return f<x}};if(e.KApTL(e[s(1223)],e.QDsGa)){let f=4294967295;return function(x,m,S=!0){let g=s,T=d[g(1711)][g(357)]("|"),D=0;for(;;){switch(T[D++]){case"0":if(d.iWtoK(m+=5,x[g(1322)]))throw m=x[g(1322)],d[g(389)](_0x592f97,m,10,x[g(1322)]);continue;case"1":if(d.DTCIf(x[m++],128))return{value:S?f:d[g(1290)](0,f),offset:m};continue;case"2":if(d[g(586)](x[m++],128))return{value:S?f:d[g(1432)](0,f),offset:m};continue;case"3":f=d[g(717)](f,d[g(1415)](d[g(1405)](127,x[m]),21))>>>0;continue;case"4":if(x[m++]<128)return{value:S?f:0|f,offset:m};continue;case"5":f=d[g(493)](d[g(473)](f,d[g(439)](d[g(1405)](127,x[m]),7)),0);continue;case"6":f=d.ZpUVq(d.RMLJe(f,d[g(385)](127&x[m],14)),0);continue;case"7":if(x[m++]<128)return{value:S?f:d.EsrxN(0,f),offset:m};continue;case"8":f=d[g(561)](f,d[g(861)](d[g(1706)](15,x[m]),28))>>>0;continue;case"9":f=(127&x[m])>>>0;continue;case"10":if(d[g(1601)](x[m++],128))return{value:S?f:0|f,offset:m};continue;case"11":return{value:S?f:d[g(1290)](0,f),offset:m}}break}}}else{if(gn||gn)return new ax(a,n);if((qn||kr)&&e[s(972)](e[s(740)],typeof indexedDB))return new sx(a,n);if(e[s(1195)](qn,kr)&&e[s(842)](e[s(740)],typeof localStorage))return new ox(a,n);throw new Error(s(314)+"DB failed")}}class cx{constructor(){let n=t;this["_interva"+n(816)+"Id"]=null,this[n(954)+"l"]=36e5,this[n(952)]=e[n(882)](Sd,n(947),e[n(771)])}async[t(954)+t(1187)](){let n=t;e[n(629)](clearInterval,this[n(954)+n(816)+"Id"]),this[n(954)+n(816)+"Id"]=e[n(1125)](setInterval,()=>{this["flushExp"+n(325)]()},this[n(954)+"l"])}async openDB(){let n=t,s={YxAjC:function(d,f){return e[J(1530)](d,f)},PseTk:function(d){return e[J(1155)](d)}};if(e[n(326)](e[n(309)],e[n(373)])){let d={iJeiL:laGflA.nvmuE,YOviT:function(S,g){return S(g)}},f=()=>{let S=n;_0x315f7a["removeEv"+S(441)+"ner"](d.iJeiL,x),_0x108a17["removeEv"+S(441)+S(657)]("error",m)},x=()=>{let S=n;d[S(1214)](_0x5ef9a0,d[S(1214)](_0x32e2d8,_0x5da863[S(1492)])),f()},m=()=>{let S=n;QXCADt[S(1594)](_0x482f79,_0x4cc04a.error),QXCADt[S(1440)](f)};_0x4c499a[n(1107)+"Listener"](laGflA[n(356)],x),_0x25fd0e["addEvent"+n(1227)](laGflA[n(564)],m)}else await this._qosDB[n(864)]()[n(1116)](()=>{let d=n;this[d(954)+d(1187)]()})}async[t(478)+t(325)](){let n=t;(await this[n(952)]?.[n(1628)]()||[])[n(1581)](({timestamp:f})=>f<Date[n(390)]())[n(1354)](f=>{let x=n;this[x(952)]?.[x(953)](f[x(306)+"id"])})}async[t(953)](n){let s=t,d={wkIzE:e[s(1156)],dxvLI:e.zcxqu};if(e[s(1619)](e[s(1471)],e[s(1471)]))return this[s(952)]?.[s(953)](n);this[s(1582)+"er"]&&_0x26bdc5[s(1107)+s(1227)](s(1429),this[s(593)+s(1624)]),this[s(1582)+"er"]&&_0x3ab48c[s(1107)+s(1227)](s(1400),this[s(593)+s(1292)]),this[s(1582)+"er"]&&_0x2285b3[s(1107)+s(1227)](d[s(1442)],this[s(1399)+s(691)]),this._isBrowser&&_0x989873[s(1107)+"Listener"](d[s(613)],this[s(1399)+s(450)])}async[t(304)](n,s){let d=t;return this._qosDB?.[d(304)]({message_id:n,timestamp:s})}async[t(313)](n){let s=t;return this[s(952)]?.[s(313)](n)}async[t(594)](){let n=t;e[n(312)](clearInterval,this[n(954)+n(816)+"Id"]),await this[n(952)]?.[n(594)]()}get[t(847)](){let n=t;return this[n(952)]?.[n(847)]}}function Mo(a){let n=t,s=!!this[n(1512)].enableQoS;if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e.SZDcD(Kt,a.message.headers,e[n(1677)],"2"),f=d&&e[n(803)](Kt,a[n(760)][n(353)],n(509)+"er_qos_ack","1"),x=d&&Kt(a[n(760)][n(353)],e.ztsSu,"1"),m=x?jn(a.message.headers,e[n(1648)])?.split(",")[n(1581)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:x,ackMsgIds:m}}async function Id(){let a=t;return this[a(581)+a(1446)]||(this[a(581)+"ger"]=new cx),this["_QoSMana"+a(1446)][a(847)]||await this["_QoSMana"+a(1446)][a(864)](),this[a(581)+"ger"]}async function dx(a,n){let s=t;if(e.WPJNO(e[s(1516)],e[s(934)])){let{enableAutoAck:d}=this._options,f=e[s(694)](Kt,a[s(760)][s(353)],s(921),"1"),x=e[s(694)](Kt,a[s(760)][s(353)],e[s(1435)],"1"),m=Mo.call(this,a);if(d&&f){let{SeqID:S,LogID:g,service:T,LogIDNew:D,method:B}=a[s(760)];this[s(936)]({SeqID:S,LogID:g,LogIDNew:D,service:T,method:B,headers:[{key:e[s(1435)],value:"1"},{key:e.DjazC,value:e[s(513)](D,"")},{key:s(1395),value:"0"}]})}x&&!m[s(1051)]&&this[s(757)+s(808)+s(1062)](a),n()}else return new _0x354d46(e[s(711)](e[s(662)](e[s(747)](_0x5eb0d6[0],e[s(468)](_0x4ea590[1],8)),e[s(301)](_0xcb02f9[2],16)),e[s(855)](_0x11ecfd[3],24)),e[s(539)](e.CAJJF(_0x2ad752[4]|_0x2abd21[5]<<8,_0x3c179b[6]<<16),e[s(819)](_0x4ba3e7[7],24)),_0x1e8baa)}async function lx(a,n){let s=t;this[s(1413)](e[s(1021)],a[s(760)]),e.gnuvu(n)}async function fx(a,n){let s=t,d=e[s(1718)](Fn,await vd(a[s(794)]));try{if(d.payload instanceof Uint8Array){let f=e[s(1277)](this[s(1512)][s(1682)+s(692)],Object)?{force:!!this[s(1512)][s(1682)+s(692)][s(270)],encoding:this[s(1512)][s(1682)+s(692)][s(1491)]?this._options[s(1682)+s(692)].encoding[s(828)](/\s/g,"")["toLowerC"+s(1060)]():""}:{force:!1,encoding:this[s(1512)][s(1682)+s(692)]?this[s(1512)][s(1682)+"ncoding"][s(828)](/\s/g,"")[s(343)+s(1060)]():""},x=d[s(1682)+"ncoding"]?d[s(1682)+s(692)][s(828)](/\s/g,"")[s(343)+"ase"]():"",m=e.HdAxA(this[s(1512)]["payloadT"+s(1383)],Object)?{force:!!this._options[s(1482)+s(1383)][s(270)],type:this[s(1512)]["payloadT"+s(1383)].type?this._options.payloadType.type[s(828)](/\s/g,"").toLowerCase():""}:{force:!1,type:this[s(1512)][s(1482)+s(1383)]?this[s(1512)][s(1482)+s(1383)][s(828)](/\s/g,"")[s(343)+s(1060)]():""},S=d[s(1482)+"ype"]?d[s(1482)+s(1383)].replace(/\s/g,"")[s(343)+s(1060)]():"",g=m.force?m[s(742)]:S||m.type,T=f[s(270)]?f[s(1491)]:x||f[s(1491)],D=[s(1278)+s(1234)+s(1683),e[s(1360)],s(1700)+s(781)+s(499)+"=utf-8",e[s(457)]],B=["none_none",e.WRpVW];this._options["enableTr"+s(799)+"extPayload"]&&D[s(1226)](g)&&(!T||B[s(1226)](T))?d[s(677)+s(928)]=Ed(d[s(721)],0,d[s(721)][s(1115)+"th"]):d["textPayl"+s(928)]=""}else d[s(677)+s(928)]=""}catch(f){d[s(677)+s(928)]="",console.log(f)}a[s(760)]=d,e[s(388)](n)}function ux(a,n,s){let d=t,f={jgCrK:function(T,D){return T(D)},wbdoj:function(T,D){return e.eWxiL(T,D)},mCfxI:function(T,D){return T>D},bRzHO:function(T,D){return e.HdcHI(T,D)},PonoE:function(T,D){return e.VqTxP(T,D)},OGaEF:function(T,D){return T!==D},PGdui:e[d(649)],CYnGC:e[d(320)],LkzxC:function(T,D){return e[d(1265)](T,D)}},x=s||8192,m=x>>>1,S=null,g=x;return function(T){let D=d;if(f[D(930)](T,1)||f[D(286)](T,m))return a(T);f[D(790)](f.PonoE(g,T),x)&&(f[D(850)](f.PGdui,f[D(375)])?(S=f[D(577)](a,x),g=0):(f[D(577)](_0x1f94f7,this[D(502)+"gTimeoutId"]),f[D(577)](_0x19995,this[D(797)+D(766)+"tId"]),this[D(502)+D(1028)+"Id"]=null,this[D(797)+"ctTimeou"+D(684)]=null));let B=n[D(1032)](S,g,g+=T);return 7&g&&(g=f[D(693)](7,g)+1),B}}let hx=4294967295;function xx(a,n,s){let d=t;return RangeError(e[d(1247)](e[d(690)](e[d(870)](e[d(414)](e[d(317)],a)+" + ",e.KswdN(n,1)),e[d(1608)]),s))}function px(a,n,s){let d=t,f={uSVJT:function(x,m){return e.bleQm(x,m)},GvoZF:function(x,m){return x+m}};if(d(878)==="jFivx")return _0x5828e2[d(591)+"t8"]?_0x2c845f[d(591)+"t8"](_0x1b1bb0,_0x5ad719):_0x38e2b5[_0x2ceb89]=f[d(1151)](255,_0x608e2b),f[d(1609)](_0x27bdfc,1);{if(e[d(1311)](s,hx))throw new Error(e[d(1541)]);let x=3;for(;e[d(407)](x,0);)if(e[d(1178)](e[d(798)],e[d(798)]))this[d(302)+d(1708)]=null;else{let m=e[d(354)](255,s);e[d(803)](zo,m,a,n+x),s>>>=8,x--}return e[d(444)](n,4)}}function gx(a,n){let s=t,d={OnqhR:function(S,g,T){return e[J(1655)](S,g,T)},dWicx:function(S,g){return e[J(1662)](S,g)}},f=0,x=n,m=e[s(745)](n,4);for(;e[s(1408)](x,m);)if(e[s(824)](e[s(1583)],s(1241))){let{value:S,offset:g}=e[s(490)](Bo,a,x);x=g,f=e[s(1192)](f<<8,0),f+=S}else VHpQuF[s(990)](_0x1b0228,_0x17b29b,96),VHpQuF[s(990)](_0x2dcb82,_0x53b59e,VHpQuF[s(823)](_0x3af953,_0xb0d4a5));return{value:f,offset:m}}function mx(a,n,s){let d=t;return a?e[d(1056)](a[d(1322)],40)?e[d(1124)](e[d(1129)](Oo,a,n,s),s):n[d(1514)+"e"]?e[d(1092)](n[d(1514)+"e"](a,s),s):n[d(1074)]?n[d(1074)](a,s)+s:e[d(1689)](e[d(694)](Oo,a,n,s),s):s}function yx(a,n){let s=t;if(e.vQRHg!==e[s(1533)])e[s(1393)](_0x1f2c30,s(1417)),this[s(893)](s(787)+s(626)+"s",_0xd299d3),this[s(893)](s(787)+s(827)+"t",_0x44023d);else{let d=new ae(e.vzzRf(e[s(883)](e.Bamtk(a[e[s(1650)](n,4)],24)|e.sHDEA(a[e[s(913)](n,5)],16),e[s(338)](a[e.kgLRN(n,6)],8)),a[e[s(336)](n,7)]),e[s(737)](e[s(276)](e[s(1312)](e[s(562)](a[n+0],24),e.rrpII(a[e[s(1304)](n,1)],16)),e[s(380)](a[e[s(940)](n,2)],8)),a[e[s(1092)](n,3)]),!0);return n+=8,{value:d,offset:e[s(791)](n,8)}}}function _x(a,n,s){let d=t,f=a[d(1715)],x=a.high;return n[s]=x>>>24,n[s+1]=e[d(826)](e[d(706)](x,16),255),n[e[d(414)](s,2)]=e[d(663)](e[d(1464)](x,8),255),n[e[d(940)](s,3)]=255&x,n[s+4]=f>>>24,n[s+5]=e.dOzlV(e[d(1606)](f,16),255),n[s+6]=e[d(1526)](e[d(1557)](f,8),255),n[e[d(1174)](s,7)]=e[d(750)](255,f),s+=8,s}function Bo(a,n){let s=t;return a.readUInt8?{value:a[s(1705)+"8"](n),offset:e[s(1230)](n,1)}:{value:e.KIbKK(255,a[n]),offset:e[s(1702)](n,1)}}function zo(a,n,s){let d=t;return n[d(591)+"t8"]?n.writeUint8(a,s):n[s]=e[d(682)](255,a),e[d(633)](s,1)}let bx=function(a){return new Uint8Array(a)},Ex=e[t(740)]!=typeof Buffer?Buffer["allocUns"+t(585)]:ux(bx,Uint8Array[t(341)+"e"].subarray),vx=16,Fo=32;function Sx(a){let n=t,s=0,d={};for(let f=0;f<a[n(1322)];f++)d[a[f][n(1330)+n(610)]]=bd(a[f]["cursor_n"+n(610)]),s+=e.CtuEu(14,d[a[f][n(1330)+"ame"]]);return[s,d]}function Ad(a,n,s){let d=t,f={qjBDn:d(688),AdzYr:e[d(616)],hlMiJ:e[d(1600)],SuHks:e[d(719)],KZpSv:function(T,D,B,G){return e[d(1208)](T,D,B,G)},dUcfN:"service-name",tcFCr:function(T,D,B,G){return e[d(282)](T,D,B,G)},ntBPN:d(801),EURVN:e.oHWDI},[x,m]=e[d(1235)](Sx,a),S=e[d(371)](Ex,x),g=0;return a[d(1354)](T=>{let D=d;f.qjBDn===f.AdzYr?this._qosDB?.[D(953)](_0xc62c7[D(306)+"id"]):(console[D(1170)](f.hlMiJ,T,T[D(1018)]),g=zo(0,S,g),console[D(1170)](f[D(1286)],g),g=f[D(541)](px,S,g,T[D(1018)]||0),console[D(1170)](D(1018),g),g=zo(m[T["cursor_n"+D(610)]],S,g),console[D(1170)](f.dUcfN,g),g=f.tcFCr(mx,T[D(1330)+"ame"],S,g),console[D(1170)](f[D(900)],g),g=f[D(836)](_x,ae.fromNumber(T[D(596)]||n),S,g),console[D(1170)](f.EURVN,g))}),{frameType:Fo,headers:[{key:e.MOdpk,value:s}],payload:S}}function Ix(a){let n=t,s=0,d=[];for(;e[n(463)](s,a[n(1115)+"th"]);){let{offset:f}=e[n(355)](Bo,a,s);s=f;let x={cursor_name:"",cursor:0,service:0},{value:m,offset:S}=gx(a,s);x[n(1018)]=m,s=S;let{value:g,offset:T}=e[n(1517)](Bo,a,s);s=T,x["cursor_n"+n(610)]=e[n(694)](Ed,a,s,s+g),s+=g;let{value:D,offset:B}=yx(a,s);x[n(596)]=D[n(1555)](),s=B,d[n(305)](x)}return d}function Ax(){return{frameType:Fo,headers:[{key:e[t(422)],value:e.gfsGK}],payload:void 0}}class Tx{constructor(n,s,d){let f=t;this[f(761)+f(929)]=n,this["_cursorF"+f(1166)]=s,this._messageStrategy=d,this[f(952)]=e.Kfjvm(Sd,this[f(761)+f(929)],e.WrJTP)}async[t(864)](){let n=t;await this._qosDB[n(864)]()}async[t(1515)+"rs"](){let n=t;if(!this._qosDB.isReady)return;let s=this[n(1716)+n(1639)],d=await this._qosDB.getAll();switch(console[n(1170)](n(646)+n(812),d),s){case n(960):return d&&d[n(1322)]?Ad(d,0,this[n(544)+n(1166)]):void 0;case e[n(1544)]:return;case e[n(1066)]:return d&&d[n(1322)]?e[n(1129)](Ad,d,0,this[n(544)+n(1166)]):e[n(736)](Ax)}}async set(n,s,d){let f=t;return console[f(1170)](f(479),n,s,d),this._qosDB.set({cursor_name:n,cursor:s,service:d})}async setCursors(n){let s=t,d=e[s(1327)](Ix,n);for(let f of d)console[s(1170)](e.xxIZG,d),await this[s(952)].set(f)}async[t(313)](n){let s=t;if(e.HeQUd(e.gqQLx,"DdZtq")){if(!this._ws)return;this[s(754)][s(1107)+s(1227)](e[s(1575)],this[s(975)]),this[s(754)][s(1107)+s(1227)](s(1674),this[s(1272)]),this._ws[s(1107)+s(1227)](e[s(1257)],this[s(959)+"ge"]),this[s(754)][s(1107)+s(1227)](e[s(564)],this[s(1569)])}else return(await this._qosDB.get(n))?.cursor}async[t(594)](){let n=t;e.koxDd(e[n(992)],"lzxsW")?(this[n(1466)]=_0x35ebfc,this[n(274)]=_0x97425a,this[n(952)]=_0x29d7e7?_0xd3ccb8:_0x4c4279?_0xbccf7f:null):await this[n(952)][n(594)]()}["updateCursorFile"+t(1077)](n){let s=t;this["_cursorF"+s(1166)]=n}get[t(847)](){let n=t,s={Rdlnl:e[n(944)],xJPuy:e[n(564)],OiDuF:e.rooAW,LyXZW:function(d,f){return e[n(678)](d,f)},diAIC:n(434)+"or",QlOsV:function(d){return e.LHXqj(d)}};if(e[n(546)](e[n(1183)],e[n(1183)]))return this[n(952)][n(847)];{let d=()=>{let m=n;_0x17ca22["removeEventListe"+m(657)](cAtrYR[m(1009)],f),_0xbb3167["removeEv"+m(441)+m(657)](cAtrYR[m(1348)],x),_0x10c23b[m(923)+m(441)+m(657)](cAtrYR[m(728)],x)},f=()=>{_0x240772(),d()},x=()=>{let m=n;cAtrYR[m(293)](_0x5c6ed3,_0x31ab6c[m(316)]||new _0x2e3261(cAtrYR.diAIC,cAtrYR[m(777)])),cAtrYR[m(1469)](d)};_0x4e8120.addEventListener(cAtrYR[n(1009)],f),_0x116268[n(1107)+"Listener"](cAtrYR.xJPuy,x),_0xf43523[n(1107)+n(1227)](cAtrYR[n(728)],x)}}}let Cx=e[t(1441)];async function Td(a){let n=t;if(!this[n(1512)][n(369)+"S"])return null;let{aID:s,fpID:d,messageStrategy:f}=this[n(1512)],x=e[n(1529)](a,Cx);try{if(this["_cursorM"+n(1585)])if(e[n(273)](e[n(387)],e[n(387)])){let m=_0x3c27ef(e[n(564)],{message:_0x2c823c.message,code:_0x58fdb4[n(635)+"OR"],error:_0x344e88});this[n(757)+n(438)+n(982)](m)}else a&&this[n(348)+"anager"][n(1146)+n(1556)+n(1077)](a);else this._cursorManager=new Tx(d+"_"+s+"_"+x,x,f);return this[n(348)+n(1585)][n(847)]||await this[n(348)+"anager"][n(864)](),this[n(348)+"anager"]}catch{return null}}async function Rx(a,n){let s=t,d={AConZ:function($,K,ge){return e[J(1568)]($,K,ge)},qdPKm:e.sQKBL,vznRR:"NATIVE_E"+s(458),nSvSr:e[s(454)],hSRzk:e[s(476)],psafQ:"OPEN_ERROR",RXooK:e[s(1666)]},f=e[s(282)](Kt,a.message[s(353)],s(1104),"-1"),x=e.lENUU(Kt,a[s(760)].headers,e.jDigz,"1"),m=jn(a[s(760)][s(353)],e[s(603)]),S=e[s(1327)](Number,e[s(755)](jn,a.message[s(353)],e[s(818)]))||0,g=Mo[s(1032)](this,a),T=e[s(964)](Kt,a[s(760)][s(353)],e[s(531)],"2"),D=e[s(1125)](jn,a[s(760)][s(353)],e[s(1626)]),B=Number(jn(a[s(760)][s(353)],e[s(377)]));if(g[s(1051)])return e[s(1121)](n);let G=g[s(658)+s(528)]?await Id.call(this):null;if(e[s(1177)](a.message[s(1018)],0)&&x&&!f||e[s(1645)](a[s(760)].service,0)){if(m&&g["isQoSMes"+s(528)]&&G)return!!!await G[s(313)](m)&&(e[s(1571)](s(697),e[s(495)])?(wtipcW[s(1236)](_0x54a932,_0x310686,50),_0x526537(_0x582d12,_0x168a9a)):(this[s(757)+"hMessage"+s(632)](a),await G[s(304)](m,Date[s(390)]()+S))),e[s(736)](n);if(T){let $=await Td.call(this);if(!$)if(e[s(1224)](e.tXMUb,e[s(608)])){let ge=d[s(665)][s(357)]("|"),se=0;for(;;){switch(ge[se++]){case"0":_0x5ccf4b[_0x5a243[wtipcW[s(340)]]=5001]=wtipcW[s(340)];continue;case"1":return _0x36d24d;case"2":_0x3fadc5[_0x345b12[wtipcW[s(806)]]=5004]="MESSAGE_"+s(970);continue;case"3":_0x1b8cca[_0x422929[s(1271)+s(331)+"R"]=5003]=wtipcW[s(557)];continue;case"4":_0x200b37[_0x522eb3[wtipcW.psafQ]=5005]=wtipcW[s(1445)];continue;case"5":_0x4b2876[_0x51a820[wtipcW[s(714)]]=5002]="CONNECTI"+s(280);continue}break}}else return this["_dispatchMessage"+s(632)](a),e[s(736)](n);let K=await $.get(D)??-1;if(e[s(1329)](K,B))this["_dispatchMessage"+s(632)](a),$[s(304)](D,B,a[s(760)][s(1018)]);else throw new Error("recevied"+s(332)+s(800)+B+(s(1046)+s(344)+"al cursor ")+K);return e[s(1588)](n)}return this[s(757)+s(919)+"Event"](a),e[s(1588)](n)}}async function Dx(a,n){let s=t,d=Mo[s(1032)](this,a);if(!d[s(658)+s(528)])return e[s(1346)](n);let f=await Id[s(1032)](this);if(d[s(1388)+"anupMess"+s(981)]&&d[s(1386)+"s"][s(1322)])for(let x of d[s(1386)+"s"])await f[s(953)](x);e[s(1155)](n)}async function kx(a,n){let s=t,d=e[s(1025)](a[s(760)][s(1358)+"e"],vx),f=e[s(362)](a.message[s(1358)+"e"],Fo);if(e.YrjBC(!d,!f))return e[s(736)](n);let x=e.AwywM(jn,a[s(760)][s(353)],s(1486)+s(1653));if(!x)return e[s(1266)](n);let m=await Td[s(1032)](this,x);if(!m)return e[s(388)](n);if(d){let S=await m[s(1515)+"rs"](),g={frameType:S?.[s(1358)+"e"],SeqID:ae[s(832)+"er"](this[s(685)]++),LogID:ae[s(832)+"er"](this[s(1512)]["logIDGen"+s(1363)]()),service:9e3,method:5,headers:S?.[s(353)],payload:S?.[s(721)]},T=e[s(1448)](A,g);this[s(754)]&&this[s(754)][s(533)+"te"]&&this[s(754)][s(1670)](T)}if(f){let S=a[s(760)][s(721)];S&&m[s(776)+"rs"](S)}}let Px=async function(a,n){let s=t;this[s(786)]=!1,clearTimeout(this["_connect"+s(1022)+s(845)]),e.dZIfH(n)},Lx=async function(a,n){let s=t;if(!this[s(754)]||this[s(754)][s(533)+"te"]!==this[s(661)])return n();let{pingInterval:d}=this[s(1512)];this[s(1110)+"tManager"]?.["resetEnd"+s(1382)+s(1540)]();for(let x=0;e[s(925)](x,this["_message"+s(708)].length);x++){let m=this[s(1716)+s(708)][x];if(e[s(899)](this[s(754)][s(533)+"te"],this[s(661)])&&e[s(461)](null,m))this[s(754)]&&this[s(754)][s(1670)](m),this[s(1716)+s(708)][x]=null;else break}this[s(1716)+"Queue"]=this[s(1716)+s(708)][s(1581)](x=>!!x),this[s(502)+"gTimeoutId"]=e[s(648)](setTimeout,()=>this._ping(),d),this["_dispatc"+s(1078)+"nt"](a),this[s(1582)+"er"]&&this._ws&&(this[s(754)].binaryType=this[s(548)+s(1383)]);let f=this["_endpoin"+s(515)]?.[s(651)+s(556)+"nt"]();this[s(1413)]("open "+f+s(1589)),e[s(1588)](n)},Ox=async function(a,n){let s=t,d=this._endpointManager?.["getCurre"+s(556)+"nt"]();this[s(1413)](s(901)+d),e.kXYnm(n)};class Nx extends Lo{constructor(n){let s=t,d={gDPSi:e.zhxSR,EtdEE:e[s(1270)],pAPXG:function(S,g,T){return e[s(848)](S,g,T)},TlINu:function(S,g){return e[s(1561)](S,g)},IykcM:function(S,g,T){return e[s(281)](S,g,T)},kOXek:e[s(564)]};super(),this["_miniNav"+s(345)+s(689)]=!0,this[s(1582)+"er"]=qn,this[s(1574)]=Zh,this[s(1632)+"T"]=gn,this[s(1070)+"X"]=Dr,this[s(266)+"r"]=kr,this["_message"+s(708)]=[],this[s(1110)+s(515)]=null,this[s(837)+s(470)]=!1,this[s(548)+s(1383)]=e[s(443)],this[s(605)+s(839)]=!1,this[s(605)+s(1022)+s(845)]=null,this[s(797)+s(766)+"tId"]=null,this[s(502)+s(1028)+"Id"]=null,this[s(685)]=0,this[s(786)]=!1,this[s(802)]="",this[s(581)+"ger"]=null,this._cursorManager=null,this[s(621)+s(381)]=null,this[s(627)+"ls"]=e[s(1030)],this.CLOSED=3,this.CONNECTING=0,this.OPEN=1,this[s(986)]=2,this[s(975)]=S=>{let g=s;try{if(e[g(785)](e[g(671)],"tNzUk")){let T=_0x3ed057[g(1701)+g(617)](g(1288));_0x36f713[g(1202)+g(1297)]=D=>{let B=g;_0x2e8c43[B(739)].removeChild(T),_0x439418[B(1202)+B(1297)]=void 0,_0x14167b(D&&D[B(1184)]||"unknown "+B(1315))},T[g(742)]=MyOyQu[g(738)],T[g(420)]=_0x4ee57a[g(828)](/^ws/,MyOyQu[g(1484)])+("&jscallb"+g(516)+g(1495)+"P");try{_0x5b8467[g(739)][g(645)+"ild"](T)}catch{_0x35e4fd[g(739)][g(566)+g(335)](T)}}else e[g(964)](_d,this,S,[Px,Lx,Ox])}catch(T){let D=e[g(542)](Qe,"error",{message:T.message,code:Wt.OPEN_ERROR,error:T});this["_dispatc"+g(438)+g(982)](D)}},this[s(959)+"ge"]=async S=>{let g=s,{pingInterval:T,pingFrequency:D}=this[g(1512)];if((e[g(1681)]("hi",S[g(794)])&&e[g(1206)]===D||e.ypalI(g(1162),D))&&(this[g(1150)+"ngTimer"](),this.emit(e.wRlIe,e[g(356)]),this[g(502)+"gTimeoutId"]=e[g(1498)](setTimeout,this[g(1015)][g(1707)](this),T)),!e[g(1112)]("hi",S[g(794)]))try{if(e[g(467)](e[g(1420)],e[g(1420)]))e.YiKKT(_d,this,S,[fx,dx,Dx,kx,Rx,lx]);else return _0x449c59[g(1485)]()}catch(B){let G=Qe(e[g(564)],{message:B[g(760)],code:Wt[g(532)+g(970)],error:B});this["_dispatchErrorEv"+g(982)](G)}},this._onError=S=>{let g=s,T=this["_endpoin"+g(515)]?.checkReachMaxTries(),D=this[g(1110)+g(515)]?.["getCurre"+g(556)+"nt"]();if(T&&!S.message){let B=g(783)+D+(g(1133)+g(749)+"es reached");this[g(757)+g(438)+g(982)](d[g(416)](Qe,g(316),{message:B,code:Wt[g(1271)+g(331)+"R"],error:S}));return}this._ws&&d[g(1173)](this[g(754)][g(533)+"te"],this[g(661)])&&this[g(1685)+"ect"](),this[g(757)+"hErrorEv"+g(982)](d[g(1404)](Qe,d[g(1119)],{message:S[g(760)],code:Wt[g(1120)+g(458)],error:S}))},this[s(1272)]=async S=>{let g=s;this[g(1101)+g(352)](),this[g(1150)+g(851)](),this["_removeW"+g(1251)+"rs"](),this._ws=null,this[g(605)+g(839)]=!1;let T=this["_endpoin"+g(515)]?.[g(968)+g(618)+"es"]();if(!T&&this["_navigat"+g(279)]()&&!this[g(837)+g(470)]){let D=this["_endpoin"+g(515)]?.[g(651)+g(556)+"nt"](),B=this[g(1512)][g(1283)+g(558)+g(705)](S[g(1104)],S[g(1315)]);this["_dispatc"+g(1305)+g(982)](e.IlnMi(at,e[g(580)],{code:1006,reason:S.reason||g(1578)+"ng failed, unknown reaso"+g(1500)+"ame: "+D,willReconnect:B})),B&&this._connect();return}if(e.HeQUd(1e3,S.code)&&this[g(837)+g(470)]){this["_dispatc"+g(1305)+"ent"](at(e[g(580)],{code:1e3,reason:e.ycOrP})),this[g(1110)+g(515)]?.["resetEnd"+g(1382)+g(1540)](),this["_pingLos"+g(381)]?.[g(491)+g(792)]();return}if(e[g(1010)](1e3,S[g(1104)])&&T)if(e[g(321)](e[g(1037)],e[g(1181)]))this["currentI"+g(549)]=0,this[g(1461)+"ndpointT"+g(1045)+"t"]=0;else{let D=this["_endpoin"+g(515)]?.[g(651)+g(556)+"nt"](),B=S[g(1315)];B||(B=await rx(this[g(802)])),B=g(1578)+"ng faile"+g(1372)+B+(g(951)+g(1108))+D+(g(535)+g(656)+g(767)),this[g(757)+g(1305)+g(982)](e[g(572)](at,e[g(580)],{code:S[g(1104)],reason:B}));let G=g(783)+D+(g(1133)+g(749)+g(408)+"ed");this[g(757)+"hErrorEv"+g(982)](e[g(933)](Qe,g(316),{message:G,code:Wt[g(1271)+g(331)+"R"]})),this._endpointManager?.[g(628)+g(1382)+g(1540)](),this[g(621)+g(381)]?.[g(491)+g(792)]();return}if(e.uHksZ(1e3,S[g(1104)])&&!S[g(1315)]){let D=this[g(1110)+"tManager"]?.["getCurre"+g(556)+"nt"]();this[g(757)+"hCloseEv"+g(982)](e[g(1637)](at,"close",{code:S[g(1104)],reason:"connecti"+g(1631)+"d, unkno"+g(825)+"n, hostn"+g(1630)+D})),this["_endpoin"+g(515)]?.[g(628)+g(1382)+g(1540)](),this._pingLossCounter?.resetCounter();return}this._dispatchCloseEvent(S),this[g(1110)+g(515)]?.[g(628)+"pointCon"+g(1540)](),this[g(621)+g(381)]?.[g(491)+g(792)]()},this[s(681)]=null,this[s(1310)]=null,this.onmessage=null,this.onopen=null,this["onStartR"+s(1027)]=null,this[s(601)+s(996)]=null,this[s(1134)+s(1169)+"yReconnect"]=null,this[s(593)+"nLine"]=this["_handleO"+s(1624)].bind(this),this[s(593)+s(1292)]=this["_handleO"+s(1292)].bind(this),this[s(1399)+s(691)]=this[s(1399)+s(691)].bind(this),this[s(1399)+s(450)]=this[s(1399)+"ageShow"][s(1707)](this),this[s(1512)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1477)](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(926)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(1066)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:x}=n,m=Array[s(1319)](f)?f:e[s(1331)](e[s(457)],typeof f)?[f]:[];if(!m||e[s(1519)](0,m[s(1322)]))throw new Error(e.QRSfQ);if(!Qh(x))throw new Error(e.EpOQX);if(Object.assign(this[s(1512)],n),this[s(1110)+"tManager"]=new yd(m,this[s(1512)][s(1558)+"es"]),this[s(621)+s(381)]=new nx(this[s(1512)]["pingLoss"+s(1536)]),this[s(1512)][s(419)+s(405)])if(e[s(1207)]===s(1350))this[s(786)]=!0,this._connect();else return"frontier_"+this[s(1466)];this._options[s(724)+"tworkCha"+s(1570)]&&(this[s(1632)+"T"]||this[s(1070)+"X"]?this[s(530)+s(328)+s(1082)]():this._isBrowser&&this["_initGlo"+s(1389)+s(1227)]())}_handleOnLine(){let n=t;this[n(1512)][n(263)+"utoRecon"+n(896)]||this[n(837)+n(470)]||this[n(1308)+n(1027)]()}[t(593)+t(1292)](){let n=t;this[n(366)+n(538)+"t"]();let s=e[n(1425)](Po,e[n(1676)],{message:n(1455)+n(1391)+n(480)+"ct"});this["onStopIm"+n(1169)+n(268)+"ct"]&&this[n(1134)+n(1169)+n(268)+"ct"](s)}[t(1261)+t(1389)+t(1227)](){let n=t;this[n(1582)+"er"]&&window[n(1107)+n(1227)](n(1429),this[n(593)+n(1624)]),this._isBrowser&&window[n(1107)+"Listener"](e[n(1011)],this[n(593)+n(1292)]),this[n(1582)+"er"]&&window["addEvent"+n(1227)](e.Ngedg,this[n(1399)+"ageHide"]),this._isBrowser&&window[n(1107)+"Listener"](e[n(647)],this[n(1399)+"ageShow"])}[t(339)+"balEvent"+t(1227)](){let n=t;this[n(1582)+"er"]&&window["removeEv"+n(441)+n(657)](e[n(1697)],this[n(593)+n(1624)]),this[n(1582)+"er"]&&window["removeEv"+n(441)+n(657)](e[n(1011)],this[n(593)+n(1292)]),this[n(1582)+"er"]&&window[n(923)+n(441)+"ner"](e[n(1156)],this[n(1399)+n(691)]),this[n(1582)+"er"]&&window[n(923)+n(441)+n(657)](e[n(647)],this[n(1399)+n(450)])}["_handleP"+t(691)](n){let s=t,d={uCnns:e[s(580)]};if(e[s(699)](e[s(1487)],e.QKjHi)){if(!n[s(1449)+"d"]){if(e.WkyBl(e[s(619)],e[s(619)]))return _0x584be9;this._isBrowser&&window[s(923)+s(441)+s(657)]("pagehide",this[s(1399)+"ageHide"]),this[s(1582)+"er"]&&window["removeEv"+s(441)+s(657)](e[s(647)],this._handlePageShow),this.close()}this._isBrowser&&window[s(923)+"entListe"+s(657)](e[s(1697)],this[s(593)+"nLine"]),this._isBrowser&&window[s(923)+"entListe"+s(657)](s(1400),this[s(593)+s(1292)])}else this[s(1222)](d[s(733)],_0x57c41c),this[s(681)]&&this[s(681)](_0x585b4e)}[t(1399)+t(450)](n){let s=t;n[s(1449)+"d"]&&(this[s(1204)+s(279)]()&&(!this[s(754)]||e[s(1083)](this._ws.readyState,this[s(661)])||e[s(1478)](this._ws[s(533)+"te"],this[s(894)+"NG"]))&&this[s(593)+"nLine"](),this._isBrowser&&window["addEvent"+s(1227)](e[s(1697)],this._handleOnLine),this[s(1582)+"er"]&&window.addEventListener(e[s(1011)],this[s(593)+s(1292)]))}async[t(329)+t(1644)](n){let s=t,{fpID:d,deviceID:f,bddID:x,ttwID:m,accessKey:S,aID:g,customParams:T={},enableAutoAck:D,enableQoS:B,QoSLevel:G,env:$}=this[s(1512)],K,ge,se;this[s(1582)+"er"]||this[s(1070)+"X"]||this[s(1632)+"T"]?(K=location&&s(789)==location[s(540)]?e.bWaYU:s(1567),ge=n[s(828)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),se=/^wss(.*:\/\/)/.test(n)?n:""+K+ge):(K=e.bWaYU,ge=n[s(828)](/(^http)((?:[s]*:\/\/))/,""),se=/(^ws)((?:[s]*:\/\/))/[s(1551)](ge)?ge:""+K+ge);let de=x?"bd_did":m?e[s(1140)]:e.xsOzv,et=x||m||f;if(!et||!de)throw new Error(e[s(1153)]);let Li=e[s(1331)](e.eomZV,typeof T)?await e[s(1239)](T):T,Mx=$?tx($[s(278)],$[s(1356)]):{},Uo=Object[s(963)]({device_platform:e[s(918)],version_code:"fws_1.0.0",access_key:S,fpid:d,aid:g,[de]:et,xsack:D?1:0,xaack:D?1:0,xsqos:B?1:0,qos_level:B?G:void 0,qos_sdk_version:2,...Mx},Li),Bx=Object[s(1668)](Uo)[s(448)]((Ho,qo)=>Uo[qo]!==void 0?""+Ho+(Ho?"&":"?")+qo+"="+Uo[qo]:Ho,"");return se+s(1097)+Bx}async[t(605)](){let n=t;if(!(this[n(605)+n(839)]||this[n(837)+n(470)])){this[n(605)+n(839)]=!0;try{let s=this["_endpoin"+n(515)]?.[n(1068)+n(1228)+n(1205)+n(582)+"tries"](),{timeoutInterval:d}=this[n(1512)];if(s){let x=this[n(1110)+n(515)]?.[n(651)+n(556)+"nt"](),m=this[n(1110)+n(515)]?.["replaceBackupEnd"+n(770)+"UpdateCount"](),S=this[n(1110)+n(515)]?.[n(651)+n(556)+"ntTriesCount"]();if(m){let g=n(783)+x+(n(1604)+n(535)+n(656)+"ached, w"+n(322)+n(915)+n(417))+m+(n(1176)+"y"),T=e[n(1566)](Qe,n(316),{message:g,code:Wt["MAX_RETR"+n(331)+"R"]});this[n(1413)](g),this[n(757)+n(438)+"ent"](T),this._url=await this[n(329)+n(1644)](m),this._debug("connect "+m+" "+S+" times"),this[n(267)+n(1251)+"rs"]()}else{let g=n(783)+x+(n(1604)+n(535)+"tries reached");this[n(1413)](g),this[n(757)+n(438)+n(982)](e[n(980)](Qe,e[n(564)],{message:g,code:Wt.MAX_RETRIES_ERROR}));return}}else{let x=this["_endpoin"+n(515)]?.["getCurre"+n(556)+"ntAndUpd"+n(725)](),m=this[n(1110)+"tManager"]?.["getCurrentEndpointTriesC"+n(1002)]();this[n(802)]=await this[n(329)+"eUrl"](e[n(1038)](x,"")),this._debug(n(783)+x+" "+m+n(962)),this[n(267)+n(1251)+"rs"]()}if(this[n(786)])this[n(786)]=!1;else{let x=Po(n(1283)+"t",{message:e.IDFef});this[n(395)+n(1027)]&&this[n(395)+n(1027)](x)}let f=this[n(1110)+n(515)]?.[n(651)+n(556)+n(1511)+"ount"]()||0;e.SMAzf(f,1)&&await this._wait(e[n(1106)](f,1)),this[n(1413)]("connecti"+n(726)+this._url+" protocols: "+this._protocols),this[n(754)]=e.EkJtN(Xh,{url:this[n(802)],protocols:[this[n(627)+"ls"]],headers:this[n(1512)][n(507)+"ramParams"][n(1087)+n(1295)]},this[n(1512)].ws),(this[n(1582)+"er"]||this[n(266)+"r"])&&this[n(754)]&&(this[n(754)][n(1692)+"pe"]=this[n(548)+n(1383)]),this[n(759)+n(1380)](),this[n(605)+n(1022)+n(845)]=e[n(542)](setTimeout,this[n(638)+"ut"][n(1707)](this),d)}catch(s){throw this["_connect"+n(839)]=!1,s}}}["_clearTi"+t(352)](){let n=t;clearTimeout(this[n(605)+"ionTimeo"+n(845)]),this["_connect"+n(1022)+"utId"]=null}[t(1150)+"ngTimer"](){let n=t,s={QfDDA:function(d,f,x){return e[J(490)](d,f,x)}};n(1502)===e.zlNgs?(e[n(756)](clearTimeout,this["_pingPon"+n(1028)+"Id"]),e[n(756)](clearTimeout,this["_reconne"+n(766)+"tId"]),this[n(502)+n(1028)+"Id"]=null,this[n(797)+n(766)+n(684)]=null):(jgLhFy[n(589)](_0x5ad4d4,_0x1e5f60,16),jgLhFy.QfDDA(_0x4ce552,_0x517743,_0x2a5ce9))}[t(1413)](...n){this[t(1512)].debug&&console.log.apply(console,["FRONTIER>",...n])}[t(398)+t(1418)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:x}=this[s(1512)],m=e[s(1094)](d,Math[s(1229)](x,e[s(1333)](n,1)));return e[s(418)](m,f)?f:m}[t(1015)](){let n=t;if(this[n(754)]&&e.ywEBJ(this[n(754)].readyState,this.CONNECTING))if(e[n(1602)]===e[n(1602)]){this[n(1150)+n(851)](),this._pingPongTimeoutId=e.RPdHo(setTimeout,this[n(1015)][n(1707)](this),this[n(1512)][n(1690)+n(871)]);return}else this[n(1461)+n(1281)+n(1045)+"t"]=0;if(!this._ws||this._ws[n(533)+"te"]!==this[n(661)])return void this[n(1308)+n(1027)]();this[n(754)]&&this[n(754)][n(1670)]("hi"),this["_reconnectTimeou"+n(684)]=e[n(527)](setTimeout,this[n(1308)+"econnectTimeout"][n(1707)](this),this[n(1512)][n(1338)+n(1211)+n(518)])}[t(1308)+t(1027)+t(669)](){let n=t;this["_pingLos"+n(381)]?.[n(1454)](),this[n(1222)](e[n(1409)],e[n(295)]),this[n(621)+"sCounter"]?.["checkRea"+n(1378)+"nt"]()?this[n(1308)+n(1027)]():this[n(1015)]()}[t(1204)+t(279)](){let n=t;return this._isMiniTT||this._isMiniWX?this["_miniNavigatorOn"+n(689)]:(this._isBrowser||this[n(266)+"r"])&&this[n(1512)][n(724)+"tworkCha"+n(1570)]?navigator[n(1344)]:!0}[t(1308)+"econnect"](){let n=t;!this[n(1204)+"orOnline"]()||this[n(837)+n(470)]||(this[n(1110)+n(515)]?.[n(628)+n(1382)+n(1540)](),this[n(621)+n(381)]?.[n(491)+n(792)](),this[n(754)]?this[n(1685)+"ect"](1001,n(318)+n(1542)+n(1283)+"ting ser"+n(1142),!0):this[n(605)]())}["_onPageN"+t(328)+t(1082)](){let n=t,s={KuFtn:function(d,f){return e[J(327)](d,f)},YiCic:function(d,f){return d===f},OOdjf:e.nCshm};this[n(1632)+"T"]?tt[n(751)+n(1186)+n(966)](({isConnected:d})=>{let f=n,x={LzfXA:function(m,S){return s.KuFtn(m,S)},AIwzm:function(m,S){return s[J(1212)](m,S)},QnECY:function(m,S){return m-S},coGFh:function(m,S){return s[J(1212)](m,S)}};if(f(668)===s[f(1463)])return!!(SQBlTE.LzfXA(this[f(1149)+f(549)],this[f(1475)+"s"][f(1322)])||SQBlTE.AIwzm(this[f(1149)+"ndex"],SQBlTE[f(1132)](this[f(1475)+"s"][f(1322)],1))&&SQBlTE[f(1047)](this["currentE"+f(1281)+f(1045)+"t"],this.maxRetries));this["_miniNav"+f(345)+f(689)]=d,d?this[f(593)+"nLine"]():this[f(593)+f(1292)]()}):this[n(1070)+"X"]&&wx[n(751)+n(1186)+n(966)](({isConnected:d})=>{let f=n;this[f(367)+f(345)+f(689)]=d,d?this[f(593)+"nLine"]():this["_handleO"+f(1292)]()})}[t(874)](n){let s=t,d={HWtrp:function(f,x){return e.DtJFK(f,x)},DHAuQ:function(f,x){return e[J(1549)](f,x)},VxCwU:function(f,x,m){return e[J(1125)](f,x,m)},ejxJB:function(f,x){return e[J(1050)](f,x)},qZuFG:function(f,x){return f<<x},ZOSln:e[s(1005)],ENHGa:function(f,x,m){return f(x,m)}};return new Promise(f=>{let x=s;if(x(650)!==d.ZOSln)d[x(292)](setTimeout,f,this[x(398)+x(1418)+"e"](n));else{let m=0,S=_0xff978e,g=ThAJVl[x(1654)](_0x4b600e,4);for(;ThAJVl.DHAuQ(S,g);){let{value:T,offset:D}=ThAJVl[x(852)](_0x1d42a7,_0x4152ac,S);S=D,m=ThAJVl[x(1651)](ThAJVl[x(1505)](m,8),0),m+=T}return{value:m,offset:g}}})}[t(1685)+t(1479)](n=1e3,s="",d=!1){let f=t;if(e[f(796)]===e.ZfaeN){if(!this[f(754)])return;this[f(366)+"WebSocket"](n,s,d)}else{this[f(757)+f(1305)+f(982)](_0x5cce10(e[f(580)],{code:1e3,reason:f(1370)})),this[f(1110)+"tManager"]?.[f(628)+"pointCon"+f(1540)](),this["_pingLos"+f(381)]?.["resetCou"+f(792)]();return}}[t(638)+"ut"](){let n=t,s=this[n(1110)+n(515)]?.[n(651)+"ntEndpoint"]();this[n(1413)]("connect "+s+n(1604)),this[n(1685)+"ect"](1001,e[n(1532)],!0)}[t(936)](n){let s=t,d=e.mEUYz(We,n);if(this._ws&&this[s(754)][s(533)+"te"]===this[s(661)])if(e[s(1065)]!==e[s(1065)]){let f=s(783)+_0x17f491+(s(1604)+s(535)+s(656)+"ached");this[s(1413)](f),this[s(757)+s(438)+s(982)](e[s(1573)](_0x571438,s(316),{message:f,code:_0x5ab048[s(1271)+"IES_ERROR"]}));return}else this[s(754)]&&this[s(754)][s(1670)](d),this._debug(e[s(866)],n)}[t(267)+t(1251)+"rs"](){let n=t,s=e.PnMkw[n(357)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(754)][n(923)+"entListe"+n(657)](n(760),this[n(959)+"ge"]);continue;case"1":this._ws.removeEventListener("error",this[n(1569)]);continue;case"2":this[n(754)][n(923)+"entListe"+n(657)](e[n(1575)],this[n(975)]);continue;case"3":this[n(754)].removeEventListener(e.ZoIUV,this._onClose);continue;case"4":if(!this._ws)return;continue}break}}[t(759)+"steners"](){let n=t,s=e[n(1014)][n(357)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(754)][n(1107)+"Listener"](e[n(564)],this[n(1569)]);continue;case"1":this._ws[n(1107)+n(1227)]("close",this._onClose);continue;case"2":this._ws[n(1107)+n(1227)](e[n(1257)],this[n(959)+"ge"]);continue;case"3":if(!this._ws)return;continue;case"4":this[n(754)][n(1107)+n(1227)](n(659),this._onOpen);continue}break}}[t(869)+t(1130)](n=1e3,s=""){let d=t,f={zAgKV:function(x,m,S){return e[J(1340)](x,m,S)}};try{e[d(699)](d(1693),d(1693))?QwXkAc[d(1193)](_0x1c2554,_0x42885e,this._getIntervalValue(_0x2c27b7)):this[d(754)]&&this[d(754)][d(1674)](n,s)}catch{}}[t(366)+t(538)+"t"](n=1e3,s="",d=!1){let f=t;if(this[f(1150)+f(851)](),this[f(1101)+"mer"](),this[f(267)+"sListeners"](),this[f(869)+f(1130)](1e3,s),this[f(605)+"Lock"]=!1,d&&this[f(1204)+f(279)]()&&!this[f(837)+f(470)]){if(this[f(1110)+f(515)]?.["checkRea"+f(618)+"es"]()){let m=this[f(1110)+f(515)]?.[f(651)+"ntEndpoint"]();this[f(757)+"hCloseEv"+f(982)](e[f(1367)](at,e.ZoIUV,{code:1006,reason:"connect "+m+(f(1604)+", max re"+f(656)+f(767)),wasClean:!0}))}else{let m=this[f(1512)]["reconnec"+f(558)+"ptor"](n,s);this[f(757)+f(1305)+f(982)](e[f(848)](at,e[f(580)],{code:n,reason:s,wasClean:!0,willReconnect:m})),m&&this._connect()}return}this["_navigat"+f(279)]()||this[f(837)+"osed"]?this[f(757)+f(1305)+f(982)](e.DIytD(at,f(1674),{code:n,reason:e[f(884)]})):this._dispatchCloseEvent(at(e[f(580)],{code:1006,reason:f(318)+f(399)+f(887)+"ine"})),this[f(754)]=null,this[f(1110)+f(515)]?.["resetEnd"+f(1382)+f(1540)](),this[f(621)+f(381)]?.[f(491)+f(792)]()}[t(757)+"hOpenEvent"](n){let s=t;this.emit(s(659),n),this[s(639)]&&this[s(639)](n)}[t(757)+t(919)+t(632)](n){let s=t;this[s(1222)](e[s(1257)],n),this[s(1191)+"e"]&&this[s(1191)+"e"](n)}[t(757)+"hAckMess"+t(1062)](n){let s=t;this[s(1222)](e[s(1123)],n),this["onReceiv"+s(996)]&&this[s(601)+s(996)](n)}[t(757)+"hErrorEv"+t(982)](n){let s=t;this[s(1222)](s(316),n),this.onerror&&this[s(1310)](n)}[t(757)+t(1305)+t(982)](n){let s=t;this[s(1222)](e[s(580)],n),this.onclose&&this[s(681)](n)}get[t(1692)+"pe"](){let n=t;return this[n(754)]?this._ws.binaryType:this[n(548)+"ype"]}set[t(1692)+"pe"](n){let s=t;this[s(548)+s(1383)]=n,this[s(754)]&&(this[s(754)][s(1692)+"pe"]=n)}get[t(435)+"nt"](){let n=t;return this[n(1110)+n(515)]?.[n(651)+"ntEndpointTriesC"+n(1002)]()||0}get[t(1470)+"Amount"](){let n=t;return this[n(1716)+n(708)][n(448)]((d,f)=>(d+=f&&f[n(1115)+"th"]||0,d),0)+(this[n(754)]?this[n(754)].bufferedAmount:0)}get[t(511)+"ns"](){let n=t;return e[n(710)](e[n(271)],n(1306))?this[n(754)]?this[n(754)][n(511)+"ns"]:"":_0x3b69f5<=_0x49a701?_0x1fe8d3[n(1339)](new _0x1f185f(e[n(1665)])):(_0x2f95b7=_0xd8110e,_0x246152===_0x44346a[n(1322)]?_0x46b8cc[n(1485)]():_0x1df2c7[_0x1abcd7][n(1707)](_0x3cfa14)(_0x7044ae,_0x3b4961[n(1707)](null,e.JZpHb(_0x1fdda0,1))))}get[t(540)](){let n=t;if(e[n(595)](e[n(1185)],e[n(1185)])){let s={EvSQj:function(d,f){return laGflA.dSfLj(d,f)}};return function(d,...f){let x=n,m=_0x39cf4d[x(1032)](s.EvSQj(_0x5d9200,this),d,...f);return _0x6071eb[x(304)](m,d.sort?d[x(1044)]():[d]),s[x(1401)](_0xca015c,m)}}else return this._ws?this[n(754)][n(540)]:""}get[t(533)+"te"](){let n=t;return this[n(754)]?this[n(754)][n(533)+"te"]:this[n(1512)][n(419)+n(405)]?this[n(894)+"NG"]:this.CLOSED}get[t(1301)](){let n=t;if(e[n(362)](e[n(1231)],e.fxFVj))_0x4c8595[n(483)]=_0x358ee1[n(1485)]()[n(1116)](()=>(_0x45312a(),_0x4ab114)).then(function(s){return s});else return this[n(754)]?this[n(754)][n(1301)]:this._url}[t(1674)](n=1e3,s){let d=t,f=e.uPUsR[d(357)]("|"),x=0;for(;;){switch(f[x++]){case"0":this[d(1101)+d(352)]();continue;case"1":if(!this._ws)return void this._debug(e[d(1058)]);continue;case"2":this[d(339)+"balEventListener"]();continue;case"3":this[d(1150)+d(851)]();continue;case"4":if(e[d(362)](this[d(754)].readyState,this.CLOSED)||e[d(1029)](this[d(754)][d(533)+"te"],this[d(986)]))return void this[d(1413)](e.RgVjz);continue;case"5":this[d(366)+"WebSocket"](n,s);continue;case"6":this[d(581)+d(1446)]?.closeDB();continue;case"7":this[d(837)+d(470)]=!0;continue}break}}async[t(1670)](n,s){let d=t,f={aOQvS:d(431)+"0|5",LLsxw:function(se,de){return e[d(686)](se,de)},OjcdS:function(se,de){return e[d(404)](se,de)},gDfUM:function(se,de){return e[d(1276)](se,de)},NwKjq:function(se,de){return se&de},ZSxkM:function(se,de){return e.CXaaI(se,de)},PLZLY:function(se,de){return e[d(902)](se,de)},UTatY:function(se,de){return e.xCOVA(se,de)}};if(e[d(1189)](null,n))throw new Error(d(703)+d(494)+d(551)+"ata, dat"+d(1611)+"e a stri"+d(482)+" arraybu"+d(1114));e.EEAHo==typeof n&&(n=JSON[d(679)+"y"](n)),e[d(1071)](d(1194),typeof n)&&!e[d(1220)](n,ArrayBuffer)&&!(n[d(510)]&&n.buffer instanceof ArrayBuffer)&&(n=JSON[d(679)+"y"](n));let x=await e[d(1190)](vd,n),m=e[d(1148)](ex,n),{method:S=0,service:g=this[d(1512)][d(1018)],logID:T=this[d(1512)]["logIDGen"+d(1363)](),headers:D=this[d(1512)][d(353)],payloadEncoding:B=this[d(1512)]["payloadE"+d(692)],payloadType:G=this[d(1512)][d(1482)+d(1383)],logIDNew:$=this[d(1512)]["logIDNew"+d(840)][d(1268)+"toGenerateLogIDNew"]?e[d(1148)](i,this[d(1512)][d(1458)+d(840)][d(440)]):""}=s||{};if(!g)throw new Error(d(703)+d(494)+d(1673)+d(1468));let K={SeqID:ae[d(832)+"er"](this[d(685)]++),LogID:ae.fromNumber(T),service:g,method:S,headers:D,payloadEncoding:e.yMdoz(B,Object)?B[d(1491)]?B[d(1491)]:"":B,payloadType:G instanceof Object?G[d(742)]?G.type:m:G||m,payload:x,LogIDNew:$},ge=e[d(629)](We,K);if(this[d(754)]&&e.DYXeX(this[d(754)][d(533)+"te"],this[d(661)]))this[d(754)]&&this[d(754)][d(1670)](ge),this[d(1413)](e[d(1023)],K);else if(e[d(372)](this[d(1716)+d(708)][d(1322)],this[d(1512)][d(583)+"geQueueL"+d(1444)]))if(e[d(500)](e[d(903)],e[d(903)])){let se=f[d(604)].split("|"),de=0;for(;;){switch(se[de++]){case"0":_0x23187e[_0x5568e9++]=sDTQNW[d(1452)](_0x422080,6)&63|128;continue;case"1":_0x5aa2b1=sDTQNW[d(1658)](65536+sDTQNW[d(700)](1023&_0x3519ac,10),sDTQNW[d(729)](1023,_0x264db8));continue;case"2":_0x5a9161[_0x24d001++]=_0x421947>>18|240;continue;case"3":_0x320c79[_0x245164++]=sDTQNW[d(1034)](sDTQNW[d(547)](sDTQNW[d(1452)](_0x57b52a,12),63),128);continue;case"4":++_0x8463e9;continue;case"5":_0x1dc74d[_0x28e7b6++]=sDTQNW[d(927)](sDTQNW[d(729)](63,_0x474dea),128);continue}break}}else this[d(1716)+d(708)][d(305)](ge),this[d(1413)](e.NBsJY,K);else this[d(1716)+"Queue"][d(397)](),this[d(1716)+d(708)][d(305)](ge);return{seqID:this[d(685)],logID:T,logIDNew:$}}async[t(1283)+"t"](n){let s=t,{url:d}=n||{},f=Array[s(1319)](d)?d:e.uLpGb(e[s(457)],typeof d)?[d]:[];n&&Object[s(963)](this[s(1512)],n),f&&f.length?this["_endpoin"+s(515)]=new yd(f,this._options.maxRetries):this[s(1110)+s(515)]?.[s(628)+s(1382)+s(1540)](),this[s(621)+s(381)]?.[s(491)+s(792)](this._options[s(1371)+"Count"]),this._readyClosed=!1,this[s(754)]&&e[s(368)](this[s(754)].readyState,this[s(1636)])?this[s(1685)+"ect"](1e3,e[s(1320)],!0):(this[s(786)]=!0,this._connect())}async[t(1423)](){let n=t;!this[n(605)+"Lock"]&&(this[n(1110)+n(515)]?.["resetEnd"+n(1382)+n(1540)](),this["_pingLos"+n(381)]?.["resetCou"+n(792)](),this[n(837)+n(470)]=!1,this[n(786)]=!0,this[n(605)]())}addEventListener(n,s){this.on(n,s)}[t(1197)+t(632)](n){let{type:s}=n;this.emit(s,n)}["removeEv"+t(441)+"ner"](n,s){this[t(893)](n,s)}[t(1377)](){let n=t,s={QuiQA:function(d,f){return e.MzvIS(d,f)},TGoxh:function(d,f){return e[J(917)](d,f)},fGFzk:e.YAvoy,sPqNv:function(d,f){return e[J(1599)](d,f)},huvvr:n(363),PjnmK:e.wRlIe,RoJFz:e.njxJI};if(e[n(1368)](e.BytRu,e[n(1055)]))_0x4c0a69[n(1170)](_0x204d89);else return new Promise((d,f)=>{let x=n,m={qOfqY:function(T,D){return T||D},gelUe:function(T,D){return s[J(1291)](T,D)},GTIXz:"string",fBVUa:function(T,D){return s[J(1416)](T,D)},dtTxE:s.fGFzk,Pjvul:function(T,D){return s[J(1048)](T,D)},lwrjk:s[x(709)],VyUfr:s[x(1161)],PeMuF:function(T,D){return T(D)},NYsHf:x(1417),gYdcL:s[x(536)]};this[x(1150)+x(851)](),this[x(502)+x(1028)+"Id"]=setTimeout(this[x(1015)][x(1707)](this),this[x(1512)][x(1690)+x(871)]);let S=()=>{let T=x;if(m[T(666)](m.lwrjk,m[T(1593)]))d("success"),this[T(893)](m[T(1509)],S),this[T(893)](T(787)+T(827)+"t",g);else{let{url:D}=LLXaRs[T(1472)](_0x5e4c8f,{}),B=_0x108df5[T(1319)](D)?D:LLXaRs.gelUe(LLXaRs.GTIXz,typeof D)?[D]:[];_0x2c3377&&_0x40a7ac[T(963)](this[T(1512)],_0x638c6c),B&&B[T(1322)]?this[T(1110)+T(515)]=new _0x39e217(B,this[T(1512)].maxRetries):this[T(1110)+"tManager"]?.["resetEnd"+T(1382)+"fig"](),this[T(621)+"sCounter"]?.[T(491)+T(792)](this._options[T(1371)+T(1536)]),this[T(837)+"osed"]=!1,this[T(754)]&&LLXaRs[T(834)](this[T(754)][T(533)+"te"],this[T(1636)])?this[T(1685)+T(1479)](1e3,LLXaRs[T(1073)],!0):(this[T(786)]=!0,this[T(605)]())}},g=()=>{let T=x;m[T(625)](f,m[T(1054)]),this[T(893)](m[T(1509)],S),this[T(893)](m.gYdcL,g)};this.on(x(787)+x(626)+"s",S),this.on(x(787)+"e_timeout",g),this[x(1015)]()})}}})(),Te[M(1136)+"oseEvent"]=Se[M(1136)+"oseEvent"],Te[M(833)+M(569)]=Se.CustomErrorEvent,Te[M(403)+"e"]=Se[M(403)+"e"],Te.Event=Se.Event,Te.FWS=Se[M(1219)],Te[M(451)+"MessageEvent"]=Se[M(451)+"MessageE"+M(1717)],Te[M(985)+M(1717)]=Se[M(985)+M(1717)],Te[M(888)+"t"]=Se[M(888)+"t"],Te[M(1660)+M(1518)]=Se[M(1660)+M(1518)],Te[M(401)+M(1640)]=Se[M(401)+M(1640)],Te.createErrorEvent=Se[M(1289)+"rorEvent"],Te[M(1096)+M(707)+"nt"]=Se["createMe"+M(707)+"nt"],Te[M(1334)+M(920)]=Se.createOpenEvent,Te[M(426)+M(520)+M(1717)]=Se["createRe"+M(520)+M(1717)],Te[M(1414)+M(1641)]=Se["decodedF"+M(1641)],Te[M(1345)+"ame"]=Se[M(1345)+M(610)];for(Ys in Se)["CustomCl"+M(1640),M(833)+"rorEvent","ErrorCode",M(632),M(1219),M(451)+M(985)+M(1717),"MessageE"+M(1717),"OpenEvent",M(1660)+M(1518),M(401)+M(1640),"createEr"+M(569),M(1096)+M(707)+"nt",M(1334)+"enEvent",M(426)+M(520)+M(1717),"decodedFrame",M(1345)+M(610)][M(958)](Ys)===-1&&(Te[Ys]=Se[Ys]);var Ys;Object[M(865)+M(1252)](Te,M(477)+"le",{value:!0})});var zt=ne((vA,fu)=>{"use strict";var du=["nodebuffer","arraybuffer","fragments"],lu=typeof Blob<"u";lu&&du.push("blob");fu.exports={BINARY_TYPES:du,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:lu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var vi=ne((SA,io)=>{"use strict";var{EMPTY_BUFFER:w_}=zt(),Ic=Buffer[Symbol.species];function y_(t,e){if(t.length===0)return w_;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 Ic(r.buffer,r.byteOffset,i):r}function uu(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function hu(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function __(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Ac(t){if(Ac.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Ic(t):ArrayBuffer.isView(t)?e=new Ic(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Ac.readOnly=!1),e}io.exports={concat:y_,mask:uu,toArrayBuffer:__,toBuffer:Ac,unmask:hu};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ce("bufferutil");io.exports.mask=function(e,r,i,o,c){c<48?uu(e,r,i,o,c):t.mask(e,r,i,o,c)},io.exports.unmask=function(e,r){e.length<32?hu(e,r):t.unmask(e,r)}}catch{}});var gu=ne((IA,pu)=>{"use strict";var xu=Symbol("kDone"),Tc=Symbol("kRun"),Cc=class{constructor(e){this[xu]=()=>{this.pending--,this[Tc]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Tc]()}[Tc](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[xu])}}};pu.exports=Cc});var vr=ne((AA,_u)=>{"use strict";var Si=ce("zlib"),mu=vi(),b_=gu(),{kStatusCode:wu}=zt(),E_=Buffer[Symbol.species],v_=Buffer.from([0,0,255,255]),oo=Symbol("permessage-deflate"),Ft=Symbol("total-length"),br=Symbol("callback"),xn=Symbol("buffers"),Er=Symbol("error"),so,Rc=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,!so){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;so=new b_(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,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){so.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){so.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[oo]=this,this._inflate[Ft]=0,this._inflate[xn]=[],this._inflate.on("error",I_),this._inflate.on("data",yu)}this._inflate[br]=i,this._inflate.write(e),r&&this._inflate.write(v_),this._inflate.flush(()=>{let c=this._inflate[Er];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=mu.concat(this._inflate[xn],this._inflate[Ft]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ft]=0,this._inflate[xn]=[],r&&this.params[`${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[Ft]=0,this._deflate[xn]=[],this._deflate.on("data",S_)}this._deflate[br]=i,this._deflate.write(e),this._deflate.flush(Si.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=mu.concat(this._deflate[xn],this._deflate[Ft]);r&&(c=new E_(c.buffer,c.byteOffset,c.length-4)),this._deflate[br]=null,this._deflate[Ft]=0,this._deflate[xn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};_u.exports=Rc;function S_(t){this[xn].push(t),this[Ft]+=t.length}function yu(t){if(this[Ft]+=t.length,this[oo]._maxPayload<1||this[Ft]<=this[oo]._maxPayload){this[xn].push(t);return}this[Er]=new RangeError("Max payload size exceeded"),this[Er].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Er][wu]=1009,this.removeListener("data",yu),this.reset()}function I_(t){if(this[oo]._inflate=null,this[Er]){this[br](this[Er]);return}t[wu]=1007,this[br](t)}});var Sr=ne((TA,ao)=>{"use strict";var{isUtf8:bu}=ce("buffer"),{hasBlob:A_}=zt(),T_=[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 C_(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Dc(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 R_(t){return A_&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}ao.exports={isBlob:R_,isValidStatusCode:C_,isValidUTF8:Dc,tokenChars:T_};if(bu)ao.exports.isValidUTF8=function(t){return t.length<24?Dc(t):bu(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ce("utf-8-validate");ao.exports.isValidUTF8=function(e){return e.length<32?Dc(e):t(e)}}catch{}});var Nc=ne((CA,Cu)=>{"use strict";var{Writable:D_}=ce("stream"),Eu=vr(),{BINARY_TYPES:k_,EMPTY_BUFFER:vu,kStatusCode:P_,kWebSocket:L_}=zt(),{concat:kc,toArrayBuffer:O_,unmask:N_}=vi(),{isValidStatusCode:M_,isValidUTF8:Su}=Sr(),co=Buffer[Symbol.species],it=0,Iu=1,Au=2,Tu=3,Pc=4,Lc=5,lo=6,Oc=class extends D_{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||k_[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[L_]=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,i){if(this._opcode===8&&this._state==it)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 co(i.buffer,i.byteOffset+e,i.length-e),new co(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 co(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 it:this.getInfo(e);break;case Iu:this.getPayloadLength16(e);break;case Au:this.getPayloadLength64(e);break;case Tu:this.getMask();break;case Pc:this.getData(e);break;case Lc: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 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[Eu.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=Iu:this._payloadLength===127?this._state=Au: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=Tu:this._state=Pc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Pc}getData(e){let r=vu;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&&N_(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Lc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Eu.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===it&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=it;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=kc(i,r):this._binaryType==="arraybuffer"?o=O_(kc(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=it):(this._state=lo,setImmediate(()=>{this.emit("message",o,!0),this._state=it,this.startLoop(e)}))}else{let o=kc(i,r);if(!this._skipUTF8Validation&&!Su(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Lc||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=it):(this._state=lo,setImmediate(()=>{this.emit("message",o,!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,vu),this.end();else{let i=e.readUInt16BE(0);if(!M_(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new co(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Su(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=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,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[P_]=o,l}};Cu.exports=Oc});var zc=ne((DA,ku)=>{"use strict";var{Duplex:RA}=ce("stream"),{randomFillSync:B_}=ce("crypto"),Ru=vr(),{EMPTY_BUFFER:z_,kWebSocket:F_,NOOP:U_}=zt(),{isBlob:Ir,isValidStatusCode:H_}=Sr(),{mask:Du,toBuffer:Ln}=vi(),st=Symbol("kByteLength"),q_=Buffer.alloc(4),fo=8*1024,On,Ar=fo,xt=0,j_=1,G_=2,Mc=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=xt,this.onerror=U_,this[F_]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||q_,r.generateMask?r.generateMask(i):(Ar===fo&&(On===void 0&&(On=Buffer.alloc(fo)),B_(On,0,fo),Ar=0),i[0]=On[Ar++],i[1]=On[Ar++],i[2]=On[Ar++],i[3]=On[Ar++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[st]!==void 0?u=r[st]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);let h=u;u>=65536?(c+=8,h=127):u>125&&(c+=2,h=126);let p=Buffer.allocUnsafe(o?u+c:c);return p[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(p[0]|=64),p[1]=h,h===126?p.writeUInt16BE(u,2):h===127&&(p[2]=p[3]=0,p.writeUIntBE(u,4,6)),r.mask?(p[1]|=128,p[c-4]=i[0],p[c-3]=i[1],p[c-2]=i[2],p[c-1]=i[3],l?[p,e]:o?(Du(e,i,p,c,u),[p]):(Du(e,i,e,0,u),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=z_;else{if(typeof e!="number"||!H_(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let l={[st]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==xt?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):Ir(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={[st]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Ir(e)?this._state!==xt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==xt?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):Ir(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={[st]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Ir(e)?this._state!==xt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==xt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[Ru.extensionName],c=r.binary?2:1,l=r.compress,u,h;typeof e=="string"?(u=Buffer.byteLength(e),h=!1):Ir(e)?(u=e.size,h=!1):(e=Ln(e),u=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=u>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[st]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:h,rsv1:l};Ir(e)?this._state!==xt?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==xt?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[st],this._state=G_,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Bc,this,u,o);return}this._bufferedBytes-=i[st];let l=Ln(c);r?this.dispatch(l,r,i,o):(this._state=xt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(W_,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Ru.extensionName];this._bufferedBytes+=i[st],this._state=j_,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");Bc(this,h,o);return}this._bufferedBytes-=i[st],this._state=xt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===xt&&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)}};ku.exports=Mc;function Bc(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 W_(t,e,r){Bc(t,e,r),t.onerror(e)}});var Uu=ne((kA,Fu)=>{"use strict";var{kForOnEventAttribute:Ii,kListener:Fc}=zt(),Pu=Symbol("kCode"),Lu=Symbol("kData"),Ou=Symbol("kError"),Nu=Symbol("kMessage"),Mu=Symbol("kReason"),Tr=Symbol("kTarget"),Bu=Symbol("kType"),zu=Symbol("kWasClean"),Ut=class{constructor(e){this[Tr]=null,this[Bu]=e}get target(){return this[Tr]}get type(){return this[Bu]}};Object.defineProperty(Ut.prototype,"target",{enumerable:!0});Object.defineProperty(Ut.prototype,"type",{enumerable:!0});var Nn=class extends Ut{constructor(e,r={}){super(e),this[Pu]=r.code===void 0?0:r.code,this[Mu]=r.reason===void 0?"":r.reason,this[zu]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Pu]}get reason(){return this[Mu]}get wasClean(){return this[zu]}};Object.defineProperty(Nn.prototype,"code",{enumerable:!0});Object.defineProperty(Nn.prototype,"reason",{enumerable:!0});Object.defineProperty(Nn.prototype,"wasClean",{enumerable:!0});var Cr=class extends Ut{constructor(e,r={}){super(e),this[Ou]=r.error===void 0?null:r.error,this[Nu]=r.message===void 0?"":r.message}get error(){return this[Ou]}get message(){return this[Nu]}};Object.defineProperty(Cr.prototype,"error",{enumerable:!0});Object.defineProperty(Cr.prototype,"message",{enumerable:!0});var Ai=class extends Ut{constructor(e,r={}){super(e),this[Lu]=r.data===void 0?null:r.data}get data(){return this[Lu]}};Object.defineProperty(Ai.prototype,"data",{enumerable:!0});var K_={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Ii]&&o[Fc]===e&&!o[Ii])return;let i;if(t==="message")i=function(c,l){let u=new Ai("message",{data:l?c:c.toString()});u[Tr]=this,uo(e,this,u)};else if(t==="close")i=function(c,l){let u=new Nn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Tr]=this,uo(e,this,u)};else if(t==="error")i=function(c){let l=new Cr("error",{error:c,message:c.message});l[Tr]=this,uo(e,this,l)};else if(t==="open")i=function(){let c=new Ut("open");c[Tr]=this,uo(e,this,c)};else return;i[Ii]=!!r[Ii],i[Fc]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Fc]===e&&!r[Ii]){this.removeListener(t,r);break}}};Fu.exports={CloseEvent:Nn,ErrorEvent:Cr,Event:Ut,EventTarget:K_,MessageEvent:Ai};function uo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ho=ne((PA,Hu)=>{"use strict";var{tokenChars:Ti}=Sr();function Rt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function $_(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,h=-1,p=-1,w=-1,b=0;for(;b<t.length;b++)if(p=t.charCodeAt(b),l===void 0)if(w===-1&&Ti[p]===1)h===-1&&(h=b);else if(b!==0&&(p===32||p===9))w===-1&&h!==-1&&(w=b);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b);let _=t.slice(h,w);p===44?(Rt(e,_,r),r=Object.create(null)):l=_,h=w=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);else if(u===void 0)if(w===-1&&Ti[p]===1)h===-1&&(h=b);else if(p===32||p===9)w===-1&&h!==-1&&(w=b);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b),Rt(r,t.slice(h,w),!0),p===44&&(Rt(e,l,r),r=Object.create(null),l=void 0),h=w=-1}else if(p===61&&h!==-1&&w===-1)u=t.slice(h,b),h=w=-1;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(o){if(Ti[p]!==1)throw new SyntaxError(`Unexpected character at index ${b}`);h===-1?h=b:i||(i=!0),o=!1}else if(c)if(Ti[p]===1)h===-1&&(h=b);else if(p===34&&h!==-1)c=!1,w=b;else if(p===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(p===34&&t.charCodeAt(b-1)===61)c=!0;else if(w===-1&&Ti[p]===1)h===-1&&(h=b);else if(h!==-1&&(p===32||p===9))w===-1&&(w=b);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b);let _=t.slice(h,w);i&&(_=_.replace(/\\/g,""),i=!1),Rt(r,u,_),p===44&&(Rt(e,l,r),r=Object.create(null),l=void 0),u=void 0,h=w=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);if(h===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=b);let A=t.slice(h,w);return l===void 0?Rt(e,A,r):(u===void 0?Rt(r,A,!0):i?Rt(r,u,A.replace(/\\/g,"")):Rt(r,u,A),Rt(e,l,r)),e}function V_(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(", ")}Hu.exports={format:V_,parse:$_}});var mo=ne((NA,Qu)=>{"use strict";var J_=ce("events"),Z_=ce("https"),Y_=ce("http"),Gu=ce("net"),X_=ce("tls"),{randomBytes:Q_,createHash:eb}=ce("crypto"),{Duplex:LA,Readable:OA}=ce("stream"),{URL:Uc}=ce("url"),pn=vr(),tb=Nc(),nb=zc(),{isBlob:rb}=Sr(),{BINARY_TYPES:qu,CLOSE_TIMEOUT:ib,EMPTY_BUFFER:xo,GUID:sb,kForOnEventAttribute:Hc,kListener:ob,kStatusCode:ab,kWebSocket:Me,NOOP:Wu}=zt(),{EventTarget:{addEventListener:cb,removeEventListener:db}}=Uu(),{format:lb,parse:fb}=ho(),{toBuffer:ub}=vi(),Ku=Symbol("kAborted"),qc=[8,13],Ht=["CONNECTING","OPEN","CLOSING","CLOSED"],hb=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,fe=class t extends J_{constructor(e,r,i){super(),this._binaryType=qu[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=xo,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]),$u(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){qu.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 tb({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new nb(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Me]=this,c[Me]=this,e[Me]=this,o.on("conclude",gb),o.on("drain",mb),o.on("error",wb),o.on("message",yb),o.on("ping",_b),o.on("pong",bb),c.onerror=Eb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Zu),e.on("data",go),e.on("end",Yu),e.on("error",Xu),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[pn.extensionName]&&this._extensions[pn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Xe(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Ju(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){jc(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||xo,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){jc(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||xo,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){jc(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[pn.extensionName]||(o.compress=!1),this._sender.send(e||xo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Xe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(fe,"CONNECTING",{enumerable:!0,value:Ht.indexOf("CONNECTING")});Object.defineProperty(fe.prototype,"CONNECTING",{enumerable:!0,value:Ht.indexOf("CONNECTING")});Object.defineProperty(fe,"OPEN",{enumerable:!0,value:Ht.indexOf("OPEN")});Object.defineProperty(fe.prototype,"OPEN",{enumerable:!0,value:Ht.indexOf("OPEN")});Object.defineProperty(fe,"CLOSING",{enumerable:!0,value:Ht.indexOf("CLOSING")});Object.defineProperty(fe.prototype,"CLOSING",{enumerable:!0,value:Ht.indexOf("CLOSING")});Object.defineProperty(fe,"CLOSED",{enumerable:!0,value:Ht.indexOf("CLOSED")});Object.defineProperty(fe.prototype,"CLOSED",{enumerable:!0,value:Ht.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(fe.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(fe.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Hc])return e[ob];return null},set(e){for(let r of this.listeners(t))if(r[Hc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Hc]:!0})}})});fe.prototype.addEventListener=cb;fe.prototype.removeEventListener=db;Qu.exports=fe;function $u(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:ib,protocolVersion:qc[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,!qc.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${qc.join(", ")})`);let c;if(e instanceof Uc)c=e;else try{c=new Uc(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:",u=c.protocol==="ws+unix:",h;if(c.protocol!=="ws:"&&!l&&!u?h=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?h="The URL's pathname is empty":c.hash&&(h="The URL contains a fragment identifier"),h){let v=new SyntaxError(h);if(t._redirects===0)throw v;po(t,v);return}let p=l?443:80,w=Q_(16).toString("base64"),b=l?Z_.request:Y_.request,A=new Set,_;if(o.createConnection=o.createConnection||(l?pb:xb),o.defaultPort=o.defaultPort||p,o.port=c.port||p,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":w,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(_=new pn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=lb({[pn.extensionName]:_.offer()})),r.length){for(let v of r){if(typeof v!="string"||!hb.test(v)||A.has(v))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(v)}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}`),u){let v=o.path.split(":");o.socketPath=v[0],o.path=v[1]}let E;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let v=i&&i.headers;if(i={...i,headers:{}},v)for(let[I,k]of Object.entries(v))i.headers[I.toLowerCase()]=k}else if(t.listenerCount("redirect")===0){let v=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!v||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,v||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=b(o),t._redirects&&t.emit("redirect",t.url,E)}else E=t._req=b(o);o.timeout&&E.on("timeout",()=>{Xe(t,E,"Opening handshake has timed out")}),E.on("error",v=>{E===null||E[Ku]||(E=t._req=null,po(t,v))}),E.on("response",v=>{let I=v.headers.location,k=v.statusCode;if(I&&o.followRedirects&&k>=300&&k<400){if(++t._redirects>o.maxRedirects){Xe(t,E,"Maximum redirects exceeded");return}E.abort();let O;try{O=new Uc(I,e)}catch{let C=new SyntaxError(`Invalid URL: ${I}`);po(t,C);return}$u(t,O,r,i)}else t.emit("unexpected-response",E,v)||Xe(t,E,`Unexpected server response: ${v.statusCode}`)}),E.on("upgrade",(v,I,k)=>{if(t.emit("upgrade",v),t.readyState!==fe.CONNECTING)return;E=t._req=null;let O=v.headers.upgrade;if(O===void 0||O.toLowerCase()!=="websocket"){Xe(t,I,"Invalid Upgrade header");return}let y=eb("sha1").update(w+sb).digest("base64");if(v.headers["sec-websocket-accept"]!==y){Xe(t,I,"Invalid Sec-WebSocket-Accept header");return}let C=v.headers["sec-websocket-protocol"],L;if(C!==void 0?A.size?A.has(C)||(L="Server sent an invalid subprotocol"):L="Server sent a subprotocol but none was requested":A.size&&(L="Server sent no subprotocol"),L){Xe(t,I,L);return}C&&(t._protocol=C);let F=v.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){Xe(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=fb(F)}catch{Xe(t,I,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(z);if(P.length!==1||P[0]!==pn.extensionName){Xe(t,I,"Server indicated an extension that was not requested");return}try{_.accept(z[pn.extensionName])}catch{Xe(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[pn.extensionName]=_}t.setSocket(I,k,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(E,t):E.end()}function po(t,e){t._readyState=fe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function xb(t){return t.path=t.socketPath,Gu.connect(t)}function pb(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Gu.isIP(t.host)?"":t.host),X_.connect(t)}function Xe(t,e,r){t._readyState=fe.CLOSING;let i=new Error(r);Error.captureStackTrace(i,Xe),e.setHeader?(e[Ku]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(po,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function jc(t,e,r){if(e){let i=rb(e)?e.size:ub(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ht[t.readyState]})`);process.nextTick(r,i)}}function gb(t,e){let r=this[Me];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Me]!==void 0&&(r._socket.removeListener("data",go),process.nextTick(Vu,r._socket),t===1005?r.close():r.close(t,e))}function mb(){let t=this[Me];t.isPaused||t._socket.resume()}function wb(t){let e=this[Me];e._socket[Me]!==void 0&&(e._socket.removeListener("data",go),process.nextTick(Vu,e._socket),e.close(t[ab])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function ju(){this[Me].emitClose()}function yb(t,e){this[Me].emit("message",t,e)}function _b(t){let e=this[Me];e._autoPong&&e.pong(t,!this._isServer,Wu),e.emit("ping",t)}function bb(t){this[Me].emit("pong",t)}function Vu(t){t.resume()}function Eb(t){let e=this[Me];e.readyState!==fe.CLOSED&&(e.readyState===fe.OPEN&&(e._readyState=fe.CLOSING,Ju(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Ju(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Zu(){let t=this[Me];if(this.removeListener("close",Zu),this.removeListener("data",go),this.removeListener("end",Yu),t._readyState=fe.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Me]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",ju),t._receiver.on("finish",ju))}function go(t){this[Me]._receiver.write(t)||this.pause()}function Yu(){let t=this[Me];t._readyState=fe.CLOSING,t._receiver.end(),this.end()}function Xu(){let t=this[Me];this.removeListener("error",Xu),this.on("error",Wu),t&&(t._readyState=fe.CLOSING,this.destroy())}});var rh=ne((BA,nh)=>{"use strict";var MA=mo(),{Duplex:vb}=ce("stream");function eh(t){t.emit("close")}function Sb(){!this.destroyed&&this._writableState.finished&&this.destroy()}function th(t){this.removeListener("error",th),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Ib(t,e){let r=!0,i=new vb({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let u=!l&&i._readableState.objectMode?c.toString():c;i.push(u)||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(eh,i);return}let l=!1;t.once("error",function(h){l=!0,c(h)}),t.once("close",function(){l||c(o),process.nextTick(eh,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",Sb),i.on("error",th),i}nh.exports=Ib});var Gc=ne((zA,ih)=>{"use strict";var{tokenChars:Ab}=Sr();function Tb(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&&Ab[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 u=t.slice(r,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),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}ih.exports={parse:Tb}});var fh=ne((UA,lh)=>{"use strict";var Cb=ce("events"),wo=ce("http"),{Duplex:FA}=ce("stream"),{createHash:Rb}=ce("crypto"),sh=ho(),Mn=vr(),Db=Gc(),kb=mo(),{CLOSE_TIMEOUT:Pb,GUID:Lb,kWebSocket:Ob}=zt(),Nb=/^[+/0-9A-Za-z]{22}==$/,oh=0,ah=1,dh=2,Wc=class extends Cb{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Pb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:kb,...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=wo.createServer((i,o)=>{let c=wo.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=Mb(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=oh}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===dh){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!==ah)if(this._state=ah,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",ch);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Bn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Bn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Nb.test(c)){Bn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Bn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ri(r,400);return}let h=e.headers["sec-websocket-protocol"],p=new Set;if(h!==void 0)try{p=Db.parse(h)}catch{Bn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],b={};if(this.options.perMessageDeflate&&w!==void 0){let A=new Mn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=sh.parse(w);_[Mn.extensionName]&&(A.accept(_[Mn.extensionName]),b[Mn.extensionName]=A)}catch{Bn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(_,E,v,I)=>{if(!_)return Ri(r,E||401,v,I);this.completeUpgrade(b,c,p,e,r,i,o)});return}if(!this.options.verifyClient(A))return Ri(r,401)}this.completeUpgrade(b,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[Ob])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>oh)return Ri(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Rb("sha1").update(r+Lb).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(i.size){let b=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;b&&(p.push(`Sec-WebSocket-Protocol: ${b}`),w._protocol=b)}if(e[Mn.extensionName]){let b=e[Mn.extensionName].params,A=sh.format({[Mn.extensionName]:[b]});p.push(`Sec-WebSocket-Extensions: ${A}`),w._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
8
+ var Fh=Object.create;var qo=Object.defineProperty;var Uh=Object.getOwnPropertyDescriptor;var qh=Object.getOwnPropertyNames;var Hh=Object.getPrototypeOf,jh=Object.prototype.hasOwnProperty;var ae=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var st=(t,e)=>()=>(t&&(e=t(t=0)),e);var ne=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ho=(t,e)=>{for(var r in e)qo(t,r,{get:e[r],enumerable:!0})},Gh=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of qh(e))!jh.call(t,a)&&a!==r&&qo(t,a,{get:()=>e[a],enumerable:!(s=Uh(e,a))||s.enumerable});return t};var lt=(t,e,r)=>(r=t!=null?Fh(Hh(t)):{},Gh(e||!t||!t.__esModule?qo(r,"default",{value:t,enumerable:!0}):r,t));function D0(t){jo=t}function k0(t){return Li[jo]<=Li[t]}function Oi(t){R0={...t}}function Vh(t){let e=(u,x=2)=>String(u).padStart(x,"0"),r=-t.getTimezoneOffset(),s=r>=0?"+":"-",a=Math.abs(r),c=e(Math.floor(a/60)),f=e(a%60);return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${s}${c}:${f}`}function Pi(t,e,r,s){if(Li[t]<Li[jo])return;let a=JSON.stringify({ts:Vh(new Date),level:t,module:e,msg:r,...R0,...s});t==="error"||t==="warn"?Kh.write(`${a}
9
+ `):Wh.write(`${a}
10
+ `)}function j(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=>j(`${t}.${e}`)}}var Li,jo,Wh,Kh,R0,ee=st(()=>{"use strict";Li={debug:10,info:20,warn:30,error:40},jo=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Wh=process.stdout,Kh=process.stderr,R0={}});import{execFile as $h,spawn as Jh,spawnSync as f2}from"node:child_process";import{promisify as Zh}from"node:util";function Xh(t){if(process.platform!=="win32")return!1;if(P0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(P0,"").toLowerCase();return Yh.has(r)}function L0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return Xh(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function Gn(t,e=[],r={}){return Jh(t,e,L0(t,r))}function Wn(t,e=[],r={}){return Qh(t,e,L0(t,r))}var Yh,P0,Qh,Kn=st(()=>{"use strict";Yh=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp"]),P0=/\.(cmd|bat|ps1)$/i;Qh=Zh($h)});var M0={};Ho(M0,{_resetAcpInstallerForTests:()=>cp,_setInFlightForTests:()=>dp,ensureAcpInstalled:()=>mn,formatExecError:()=>N0,getAcpBinaryPath:()=>wn,getAcpPackageSpec:()=>Or,getInFlightInstall:()=>Ko,pickWhichLine:()=>Ni,probeAcpVersion:()=>op});function Or(t){let e=Wo[t];if(e)return`${e.npmPackage}@${e.versionSpec}`}function sp(t){let e=t?.code;if(e&&np.has(e))return!0;let r=t instanceof Error?`${t.message}
11
+ ${t.stack??""}`:String(t);return rp.test(r)||ip.test(r)}function N0(t){if(t==null||typeof t!="object")return String(t);let e=t,r=[];e.message&&r.push(e.message),e.code!==void 0&&e.code!==null&&r.push(`code=${e.code}`),e.signal&&r.push(`signal=${e.signal}`);let s=e.stderr?.toString().trim();s&&r.push(`stderr=${s.slice(0,2e3)}`);let a=e.stdout?.toString().trim();return a&&r.push(`stdout=${a.slice(0,2e3)}`),r.length>0?r.join(" | "):String(t)}async function O0(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await Wn(e,[t],{timeout:Go});return Ni(r)}catch{return}}function Ni(t){let e=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=s=>e.find(a=>a.toLowerCase().endsWith(s));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}async function op(t){let e=Wo[t];if(e)try{let{stdout:r}=await Wn(e.binary,["--version"],{timeout:Go}),s=r.split(`
12
+ `)[0]?.trim();if(!s){gn.warn("acp wrapper --version stdout empty (wrapper outputs noise first line?)",{framework:t,binary:e.binary,stdoutHead:r.slice(0,200)});return}return s}catch(r){let s=r;gn.warn("acp wrapper --version probe failed",{framework:t,binary:e.binary,errCode:s?.code,signal:s?.signal,timeoutMs:Go,message:r instanceof Error?r.message:String(r),stderrHead:s?.stderr?String(s.stderr).slice(0,500):void 0});return}}async function ap(t,e,r){gn.info("npm install -g start",{npmPackage:t,versionSpec:e}),await Wn("npm",["install","-g",`${t}@${e}`],{timeout:ep,maxBuffer:10*1024*1024,...r?{signal:r}:{}}),gn.info("npm install -g done",{npmPackage:t,versionSpec:e})}async function mn(t,e){let r=Wo[t];if(!r)return;let s=Lr.get(t);if(s)return s;let a=Pr.get(t);if(a&&Date.now()-a<tp)return;let c=Vn.get(t);if(c)return c;let f=(async()=>{let u=await O0(r.binary);if(u)return Lr.set(t,u),gn.info("acp wrapper found on PATH",{binary:r.binary,path:u}),u;try{await ap(r.npmPackage,r.versionSpec,e)}catch(h){let m=sp(h);gn.warn("acp wrapper install failed (will fallback to npx)",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary,transient:m,err:N0(h)}),m||Pr.set(t,Date.now());return}let x=await O0(r.binary);if(!x){gn.warn("acp wrapper installed but binary not found on PATH",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary}),Pr.set(t,Date.now());return}return Lr.set(t,x),Pr.delete(t),x})().finally(()=>{Vn.delete(t)});return Vn.set(t,f),f}function wn(t){return Lr.get(t)}function Ko(t){return Vn.get(t)}function cp(){Lr.clear(),Pr.clear(),Vn.clear()}function dp(t,e){Vn.set(t,e)}var gn,Wo,ep,Go,tp,np,rp,ip,Lr,Pr,Vn,Kt=st(()=>{"use strict";Kn();ee();gn=j("agents.acp-installer"),Wo={"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"}};ep=5e4,Go=5e3,tp=5*6e4,np=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),rp=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,ip=/fetch failed|request timed out|socket hang up|network timeout/i;Lr=new Map,Pr=new Map,Vn=new Map});import{chmod as up,mkdir as lp,readFile as xp,rename as F0,writeFile as U0}from"node:fs/promises";import{dirname as hp}from"node:path";async function $n(t){try{let e=await xp(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Mi(t,e,r){await lp(hp(t),{recursive:!0});let s=`${JSON.stringify(e,null,2)}
13
+ `,a=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await U0(a,s,{encoding:"utf8",mode:r.mode}):await U0(a,s,"utf8"),await F0(a,t),r?.mode!==void 0&&await up(t,r.mode)}catch(c){await F0(a,a).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(a,{force:!0}).catch(()=>{}),c}}var Bi=st(()=>{"use strict"});import{promises as q0}from"node:fs";import{homedir as pp}from"node:os";import{sep as gp,join as Ne,resolve as H0}from"node:path";function te(t){let e=t??pp(),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 Tt(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 q0.realpath(H0(t)).catch(()=>null);if(!r)return!1;let s=await q0.realpath(H0(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+gp)}var Me=st(()=>{"use strict"});var Ui={};Ho(Ui,{AGENT_CONFIG_FILE_MODE:()=>zi,enforceAgentConfigMode:()=>_p,loadAgentConfig:()=>Fe,persistAgentSessions:()=>Vo,persistAgentSkills:()=>Fi,saveAgentConfig:()=>Ge});import{chmod as mp,stat as wp}from"node:fs/promises";function Fe(t,e){return $n(Tt(t,e).config)}function Ge(t,e){return Mi(Tt(t.agentId,e).config,t,{mode:zi})}async function _p(t,e){if(process.platform==="win32")return;let r=Tt(t,e).config;try{let s=await wp(r);if(!s.isFile())return;let a=s.mode&511;a!==zi&&(await mp(r,zi),j0.warn("agent config mode auto-corrected to 0600",{path:r,from:a.toString(8)}))}catch(s){if(s.code==="ENOENT")return;j0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(s)})}}async function Vo(t,e,r){let s=await Fe(t,r);s&&(s.sessions=Object.fromEntries(e),await Ge(s,r))}async function Fi(t,e,r){let s=await Fe(t,r);s&&(s.skills=e,await Ge(s,r))}var j0,zi,Vt=st(()=>{"use strict";Bi();ee();Me();j0=j("agent-config"),zi=384});var Jo=ne((B2,V0)=>{V0.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 Hi=ne(J0=>{var $0={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Cp(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,s)=>e[s]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys($0))J0[t]=Cp($0[t])});var ed=ne((F2,Q0)=>{var Tp=ae("fs"),Ee=ae("path"),Z0=Jo(),Rp=Hi(),Dp=typeof process=="object"&&process.platform==="win32",Y0=t=>typeof t=="object"&&t!==null,X0=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=Tp,Y0(t)&&Y0(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Q0.exports=he;he.prototype.makeDir=function(t){let e=this;function r(s){let a=s.split(e.sep)[0];s.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){a+=e.sep+c;var f;try{f=e.fs.statSync(a)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw u}if(f&&f.isFile())throw Rp.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=Ee.dirname(t);a.fs.existsSync(f)||a.makeDir(f);var u;try{u=a.fs.openSync(t,"w",438)}catch{a.fs.chmodSync(t,438),u=a.fs.openSync(t,"w",438)}if(u)try{a.fs.writeSync(u,e,0,e.length,0)}finally{a.fs.closeSync(u)}return a.fs.chmodSync(t,s||438),!0};he.prototype.writeFileToAsync=function(t,e,r,s,a){typeof s=="function"&&(a=s,s=void 0);let c=this;c.fs.exists(t,function(f){if(f&&!r)return a(!1);c.fs.stat(t,function(u,x){if(f&&x.isDirectory())return a(!1);var h=Ee.dirname(t);c.fs.exists(h,function(m){m||c.makeDir(h),c.fs.open(t,"w",438,function(v,A){v?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,b){c.fs.write(b,e,0,e.length,0,function(){c.fs.close(b,function(){c.fs.chmod(t,s||438,function(){a(!0)})})})})}):A?c.fs.write(A,e,0,e.length,0,function(){c.fs.close(A,function(){c.fs.chmod(t,s||438,function(){a(!0)})})}):c.fs.chmod(t,s||438,function(){a(!0)})})})})})};he.prototype.findFiles=function(t){let e=this;function r(s,a,c){typeof a=="boolean"&&(c=a,a=void 0);let f=[];return e.fs.readdirSync(s).forEach(function(u){let x=Ee.join(s,u),h=e.fs.statSync(x);(!a||a.test(x))&&f.push(Ee.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(f=f.concat(r(x,a,c)))}),f}return r(t,void 0,!0)};he.prototype.findFilesAsync=function(t,e){let r=this,s=[];r.fs.readdir(t,function(a,c){if(a)return e(a);let f=c.length;if(!f)return e(null,s);c.forEach(function(u){u=Ee.join(t,u),r.fs.stat(u,function(x,h){if(x)return e(x);h&&(s.push(Ee.normalize(u)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(u,function(m,v){if(m)return e(m);s=s.concat(v),--f||e(null,s)}):--f||e(null,s))})})})};he.prototype.getAttributes=function(){};he.prototype.setAttributes=function(){};he.crc32update=function(t,e){return X0[(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 Z0.STORED:return"STORED ("+t+")";case Z0.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 s=r-1;s>=0;s--)if(e(t[s],s,t))return t[s]};he.sanitize=function(t,e){t=Ee.resolve(Ee.normalize(t));for(var r=e.split("/"),s=0,a=r.length;s<a;s++){var c=Ee.normalize(Ee.join(t,r.slice(s,a).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=Dp;he.crcTable=X0});var nd=ne((U2,td)=>{var kp=ae("path");td.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=kp.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 id=ne((q2,rd)=>{rd.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Yn=ne((H2,Zn)=>{Zn.exports=ed();Zn.exports.Constants=Jo();Zn.exports.Errors=Hi();Zn.exports.FileAttr=nd();Zn.exports.decoder=id()});var od=ne((j2,sd)=>{var $t=Yn(),H=$t.Constants;sd.exports=function(){var t=20,e=10,r=0,s=0,a=0,c=0,f=0,u=0,x=0,h=0,m=0,v=0,A=0,_=0,b=0;t|=$t.isWin?2560:768,r|=H.FLG_EFS;let S={extraLen:0},I=w=>Math.max(0,w)>>>0,D=w=>Math.max(0,w)&65535,O=w=>Math.max(0,w)&255;return a=$t.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&H.FLG_EFS)>0},set flags_efs(w){w?r|=H.FLG_EFS:r&=~H.FLG_EFS},get flags_desc(){return(r&H.FLG_DESC)>0},set flags_desc(w){w?r|=H.FLG_DESC:r&=~H.FLG_DESC},get method(){return s},set method(w){switch(w){case H.STORED:this.version=10;case H.DEFLATED:default:this.version=20}s=w},get time(){return $t.fromDOS2Date(this.timeval)},set time(w){w=new Date(w),this.timeval=$t.fromDate2DOS(w)},get timeval(){return a},set timeval(w){a=I(w)},get timeHighByte(){return O(a>>>8)},get crc(){return c},set crc(w){c=I(w)},get compressedSize(){return f},set compressedSize(w){f=I(w)},get size(){return u},set size(w){u=I(w)},get fileNameLength(){return x},set fileNameLength(w){x=w},get extraLength(){return h},set extraLength(w){h=w},get extraLocalLength(){return S.extraLen},set extraLocalLength(w){S.extraLen=w},get commentLength(){return m},set commentLength(w){m=w},get diskNumStart(){return v},set diskNumStart(w){v=I(w)},get inAttr(){return A},set inAttr(w){A=I(w)},get attr(){return _},set attr(w){_=I(w)},get fileAttr(){return(_||0)>>16&4095},get offset(){return b},set offset(w){b=I(w)},get encrypted(){return(r&H.FLG_ENC)===H.FLG_ENC},get centralHeaderSize(){return H.CENHDR+x+h+m},get realDataOffset(){return b+H.LOCHDR+S.fnameLen+S.extraLen},get localHeader(){return S},loadLocalHeaderFromBinary:function(w){var C=w.slice(b,b+H.LOCHDR);if(C.readUInt32LE(0)!==H.LOCSIG)throw $t.Errors.INVALID_LOC();S.version=C.readUInt16LE(H.LOCVER),S.flags=C.readUInt16LE(H.LOCFLG),S.flags_desc=(S.flags&H.FLG_DESC)>0,S.method=C.readUInt16LE(H.LOCHOW),S.time=C.readUInt32LE(H.LOCTIM),S.crc=C.readUInt32LE(H.LOCCRC),S.compressedSize=C.readUInt32LE(H.LOCSIZ),S.size=C.readUInt32LE(H.LOCLEN),S.fnameLen=C.readUInt16LE(H.LOCNAM),S.extraLen=C.readUInt16LE(H.LOCEXT);let L=b+H.LOCHDR+S.fnameLen,F=L+S.extraLen;return w.slice(L,F)},loadFromBinary:function(w){if(w.length!==H.CENHDR||w.readUInt32LE(0)!==H.CENSIG)throw $t.Errors.INVALID_CEN();t=w.readUInt16LE(H.CENVEM),e=w.readUInt16LE(H.CENVER),r=w.readUInt16LE(H.CENFLG),s=w.readUInt16LE(H.CENHOW),a=w.readUInt32LE(H.CENTIM),c=w.readUInt32LE(H.CENCRC),f=w.readUInt32LE(H.CENSIZ),u=w.readUInt32LE(H.CENLEN),x=w.readUInt16LE(H.CENNAM),h=w.readUInt16LE(H.CENEXT),m=w.readUInt16LE(H.CENCOM),v=w.readUInt16LE(H.CENDSK),A=w.readUInt16LE(H.CENATT),_=w.readUInt32LE(H.CENATX),b=w.readUInt32LE(H.CENOFF)},localHeaderToBinary:function(){var w=Buffer.alloc(H.LOCHDR);return w.writeUInt32LE(H.LOCSIG,0),w.writeUInt16LE(e,H.LOCVER),w.writeUInt16LE(r,H.LOCFLG),w.writeUInt16LE(s,H.LOCHOW),w.writeUInt32LE(a,H.LOCTIM),w.writeUInt32LE(c,H.LOCCRC),w.writeUInt32LE(f,H.LOCSIZ),w.writeUInt32LE(u,H.LOCLEN),w.writeUInt16LE(x,H.LOCNAM),w.writeUInt16LE(S.extraLen,H.LOCEXT),w},centralHeaderToBinary:function(){var w=Buffer.alloc(H.CENHDR+x+h+m);return w.writeUInt32LE(H.CENSIG,0),w.writeUInt16LE(t,H.CENVEM),w.writeUInt16LE(e,H.CENVER),w.writeUInt16LE(r,H.CENFLG),w.writeUInt16LE(s,H.CENHOW),w.writeUInt32LE(a,H.CENTIM),w.writeUInt32LE(c,H.CENCRC),w.writeUInt32LE(f,H.CENSIZ),w.writeUInt32LE(u,H.CENLEN),w.writeUInt16LE(x,H.CENNAM),w.writeUInt16LE(h,H.CENEXT),w.writeUInt16LE(m,H.CENCOM),w.writeUInt16LE(v,H.CENDSK),w.writeUInt16LE(A,H.CENATT),w.writeUInt32LE(_,H.CENATX),w.writeUInt32LE(b,H.CENOFF),w},toJSON:function(){let w=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:$t.methodToString(s),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:w(f),size:w(u),fileNameLength:w(x),extraLength:w(h),commentLength:w(m),diskNumStart:v,inAttr:A,attr:_,offset:b,centralHeaderSize:w(H.CENHDR+x+h+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var cd=ne((G2,ad)=>{var Xn=Yn(),ue=Xn.Constants;ad.exports=function(){var t=0,e=0,r=0,s=0,a=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return s},set offset(c){s=c},get commentLength(){return a},set commentLength(c){a=c},get mainHeaderSize(){return ue.ENDHDR+a},loadFromBinary:function(c){if((c.length!==ue.ENDHDR||c.readUInt32LE(0)!==ue.ENDSIG)&&(c.length<ue.ZIP64HDR||c.readUInt32LE(0)!==ue.ZIP64SIG))throw Xn.Errors.INVALID_END();c.readUInt32LE(0)===ue.ENDSIG?(t=c.readUInt16LE(ue.ENDSUB),e=c.readUInt16LE(ue.ENDTOT),r=c.readUInt32LE(ue.ENDSIZ),s=c.readUInt32LE(ue.ENDOFF),a=c.readUInt16LE(ue.ENDCOM)):(t=Xn.readBigUInt64LE(c,ue.ZIP64SUB),e=Xn.readBigUInt64LE(c,ue.ZIP64TOT),r=Xn.readBigUInt64LE(c,ue.ZIP64SIZE),s=Xn.readBigUInt64LE(c,ue.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(ue.ENDHDR+a);return c.writeUInt32LE(ue.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,ue.ENDSUB),c.writeUInt16LE(e,ue.ENDTOT),c.writeUInt32LE(r,ue.ENDSIZ),c.writeUInt32LE(s,ue.ENDOFF),c.writeUInt16LE(a,ue.ENDCOM),c.fill(" ",ue.ENDHDR),c},toJSON:function(){let c=function(f,u){let x=f.toString(16).toUpperCase();for(;x.length<u;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(s,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Yo=ne(Zo=>{Zo.EntryHeader=od();Zo.MainHeader=cd()});var fd=ne((K2,dd)=>{dd.exports=function(t){var e=ae("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(s){var a=e.createDeflateRaw(r),c=[],f=0;a.on("data",function(u){c.push(u),f+=u.length}),a.on("end",function(){var u=Buffer.alloc(f),x=0;u.fill(0);for(var h=0;h<c.length;h++){var m=c[h];m.copy(u,x),x+=m.length}s&&s(u)}),a.end(t)}}}});var ld=ne((V2,ud)=>{var Pp=+(process.versions?process.versions.node:"").split(".")[0]||0;ud.exports=function(t,e){var r=ae("zlib");let s=Pp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,s)},inflateAsync:function(a){var c=r.createInflateRaw(s),f=[],u=0;c.on("data",function(x){f.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),h=0;x.fill(0);for(var m=0;m<f.length;m++){var v=f[m];v.copy(x,h),h+=v.length}a&&a(x)}),c.end(t)}}}});var md=ne(($2,gd)=>{"use strict";var{randomFillSync:xd}=ae("crypto"),Lp=Hi(),Op=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),pd=(t,e)=>Math.imul(t,e)>>>0,hd=(t,e)=>Op[(t^e)&255]^t>>>8,Mr=()=>typeof xd=="function"?xd(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 ji={genSalt:Mr};function Gi(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])}Gi.prototype.updateKeys=function(t){let e=this.keys;return e[0]=hd(e[0],t),e[1]+=e[0]&255,e[1]=pd(e[1],134775813)+1,e[2]=hd(e[2],e[1]>>>24),t};Gi.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return pd(t,t^1)>>8&255};function Np(t){let e=new Gi(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 Mp(t){let e=new Gi(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 Bp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let s=Np(r),a=s(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw Lp.WRONG_PASSWORD();return s(t.slice(12))}function zp(t){Buffer.isBuffer(t)&&t.length>=12?ji.genSalt=function(){return t.slice(0,12)}:t==="node"?ji.genSalt=Mr.node:ji.genSalt=Mr}function Fp(t,e,r,s=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let a=Mp(r),c=ji.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)}gd.exports={decrypt:Bp,encrypt:Fp,_salter:zp}});var wd=ne(Wi=>{Wi.Deflater=fd();Wi.Inflater=ld();Wi.ZipCrypto=md()});var Qo=ne((Z2,_d)=>{var re=Yn(),Up=Yo(),pe=re.Constants,Xo=wd();_d.exports=function(t,e){var r=new Up.EntryHeader,s=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,f=null,u=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let m=t,v=typeof m.decoder=="object"?m.decoder:re.decoder;h=v.hasOwnProperty("efs")?v.efs:!1;function A(){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 C={},L=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(L)==pe.LOCSIG||e.readUInt32LE(L)==pe.CENSIG)throw re.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(L)==pe.EXTSIG)C.crc=e.readUInt32LE(L+pe.EXTCRC),C.compressedSize=e.readUInt32LE(L+pe.EXTSIZ),C.size=e.readUInt32LE(L+pe.EXTLEN);else if(e.readUInt16LE(L+12)===19280)C.crc=e.readUInt32LE(L+pe.EXTCRC-4),C.compressedSize=e.readUInt32LE(L+pe.EXTSIZ-4),C.size=e.readUInt32LE(L+pe.EXTLEN-4);else throw re.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==r.compressedSize||C.size!==r.size||C.crc!==r.crc)throw re.Errors.DESCRIPTOR_FAULTY();if(re.crc32(w)!==C.crc)return!1}return!0}function b(w,C,L){if(typeof C>"u"&&typeof w=="string"&&(L=w,w=void 0),c)return w&&C&&C(Buffer.alloc(0),re.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=A();if(F.length===0)return w&&C&&C(F),F;if(r.encrypted){if(typeof L!="string"&&!Buffer.isBuffer(L))throw re.Errors.INVALID_PASS_PARAM();F=Xo.ZipCrypto.decrypt(F,r,L)}var z=Buffer.alloc(r.size);switch(r.method){case re.Constants.STORED:if(F.copy(z),_(z))return w&&C&&C(z),z;throw w&&C&&C(z,re.Errors.BAD_CRC()),re.Errors.BAD_CRC();case re.Constants.DEFLATED:var k=new Xo.Inflater(F,r.size);if(w)k.inflateAsync(function(N){N.copy(N,0),C&&(_(N)?C(N):C(N,re.Errors.BAD_CRC()))});else{if(k.inflate(z).copy(z,0),!_(z))throw re.Errors.BAD_CRC(`"${v.decode(s)}"`);return z}break;default:throw w&&C&&C(Buffer.alloc(0),re.Errors.UNKNOWN_METHOD()),re.Errors.UNKNOWN_METHOD()}}function S(w,C){if((!f||!f.length)&&Buffer.isBuffer(e))return w&&C&&C(A()),A();if(f.length&&!c){var L;switch(r.method){case re.Constants.STORED:return r.compressedSize=r.size,L=Buffer.alloc(f.length),f.copy(L),w&&C&&C(L),L;default:case re.Constants.DEFLATED:var F=new Xo.Deflater(f);if(w)F.deflateAsync(function(k){L=Buffer.alloc(k.length),r.compressedSize=k.length,k.copy(L),C&&C(L)});else{var z=F.deflate();return r.compressedSize=z.length,z}F=null;break}}else if(w&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function I(w,C){return re.readBigUInt64LE(w,C)}function D(w){try{for(var C=0,L,F,z;C+4<w.length;)L=w.readUInt16LE(C),C+=2,F=w.readUInt16LE(C),C+=2,z=w.slice(C,C+F),C+=F,pe.ID_ZIP64===L&&O(z)}catch{throw re.Errors.EXTRA_FIELD_PARSE_ERROR()}}function O(w){var C,L,F,z;w.length>=pe.EF_ZIP64_SCOMP&&(C=I(w,pe.EF_ZIP64_SUNCOMP),r.size===pe.EF_ZIP64_OR_32&&(r.size=C)),w.length>=pe.EF_ZIP64_RHO&&(L=I(w,pe.EF_ZIP64_SCOMP),r.compressedSize===pe.EF_ZIP64_OR_32&&(r.compressedSize=L)),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 v.decode(s)},get rawEntryName(){return s},set entryName(w){s=re.toBuffer(w,v.encode);var C=s[s.length-1];c=C===47||C===92,r.fileNameLength=s.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return u},set extra(w){u=w,r.extraLength=w.length,D(w)},get comment(){return v.decode(a)},set comment(w){if(a=re.toBuffer(w,v.encode),r.commentLength=a.length,a.length>65535)throw re.Errors.COMMENT_TOO_LONG()},get name(){var w=v.decode(s);return c?w.substr(w.length-1).split("/").pop():w.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return S(!1,null)},getCompressedDataAsync:function(w){S(!0,w)},setData:function(w){f=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:b(!1,null,w)},getDataAsync:function(w,C){r.changed?w(f):b(!0,w,C)},set attr(w){r.attr=w},get attr(){return r.attr},set header(w){r.loadFromBinary(w)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var w=r.centralHeaderToBinary(),C=re.Constants.CENHDR;return s.copy(w,C),C+=s.length,u.copy(w,C),C+=r.extraLength,a.copy(w,C),w},packLocalHeader:function(){let w=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let C=r.localHeaderToBinary(),L=Buffer.alloc(C.length+s.length+r.extraLocalLength);return C.copy(L,w),w+=C.length,s.copy(L,w),w+=s.length,x.copy(L,w),w+=x.length,L},toJSON:function(){let w=function(C){return"<"+(C&&C.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 Ed=ne((Y2,bd)=>{var yd=Qo(),qp=Yo(),Be=Yn();bd.exports=function(t,e){var r=[],s={},a=Buffer.alloc(0),c=new qp.MainHeader,f=!1,u=null;let x=new Set,h=e,{noSort:m,decoder:v}=h;t?b(h.readEntries):f=!0;function A(){let I=new Set;for(let D of Object.keys(s)){let O=D.split("/");if(O.pop(),!!O.length)for(let w=0;w<O.length;w++){let C=O.slice(0,w+1).join("/")+"/";I.add(C)}}for(let D of I)if(!(D in s)){let O=new yd(h);O.entryName=D,O.attr=16,O.temporary=!0,r.push(O),s[O.entryName]=O,x.add(O)}}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,D=0;D<r.length;D++){var O=I,w=new yd(h,t);w.header=t.slice(O,O+=Be.Constants.CENHDR),w.entryName=t.slice(O,O+=w.header.fileNameLength),w.header.extraLength&&(w.extra=t.slice(O,O+=w.header.extraLength)),w.header.commentLength&&(w.comment=t.slice(O,O+w.header.commentLength)),I+=w.header.centralHeaderSize,r[D]=w,s[w.entryName]=w}x.clear(),A()}function b(I){var D=t.length-Be.Constants.ENDHDR,O=Math.max(0,D-65535),w=O,C=t.length,L=-1,F=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(O=0),D;D>=w;D--)if(t[D]===80){if(t.readUInt32LE(D)===Be.Constants.ENDSIG){L=D,F=D,C=D+Be.Constants.ENDHDR,w=D-Be.Constants.END64HDR;continue}if(t.readUInt32LE(D)===Be.Constants.END64SIG){w=O;continue}if(t.readUInt32LE(D)===Be.Constants.ZIP64SIG){L=D,C=D+Be.readBigUInt64LE(t,D+Be.Constants.ZIP64SIZE)+Be.Constants.ZIP64LEAD;break}}if(L==-1)throw Be.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(L,C)),c.commentLength&&(a=t.slice(F+Be.Constants.ENDHDR)),I&&_()}function S(){r.length>1&&!m&&r.sort((I,D)=>I.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return f||_(),r.filter(I=>!x.has(I))},get comment(){return v.decode(a)},set comment(I){a=Be.toBuffer(I,v.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,D=!0){f||_();let O=s[I];this.getEntryChildren(O,D).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){f||_();let D=s[I],O=r.indexOf(D);O>=0&&(r.splice(O,1),delete s[I],c.totalEntries=r.length)},getEntryChildren:function(I,D=!0){if(f||_(),typeof I=="object")if(I.isDirectory&&D){let O=[],w=I.entryName;for(let C of r)C.entryName.startsWith(w)&&O.push(C);return O}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let D=this.getEntryChildren(I);return D.includes(I)?D.length-1:D.length}return 0},compressToBuffer:function(){f||_(),S();let I=[],D=[],O=0,w=0;c.size=0,c.offset=0;let C=0;for(let z of this.entries){let k=z.getCompressedData();z.header.offset=w;let N=z.packLocalHeader(),U=N.length+k.length;w+=U,I.push(N),I.push(k);let W=z.packCentralHeader();D.push(W),c.size+=W.length,O+=U+W.length,C++}O+=c.mainHeaderSize,c.offset=w,c.totalEntries=C,w=0;let L=Buffer.alloc(O);for(let z of I)z.copy(L,w),w+=z.length;for(let z of D)z.copy(L,w),w+=z.length;let F=c.toBinary();return a&&a.copy(F,Be.Constants.ENDHDR),F.copy(L,w),t=L,f=!1,L},toAsyncBuffer:function(I,D,O,w){try{f||_(),S();let C=[],L=[],F=0,z=0,k=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();O&&O(se),W.getCompressedDataAsync(function(fe){w&&w(se),W.header.offset=z;let we=W.packLocalHeader(),Oe=we.length+fe.length;z+=Oe,C.push(we),C.push(fe);let nt=W.packCentralHeader();L.push(nt),c.size+=nt.length,F+=Oe+nt.length,k++,N(U)})}else{F+=c.mainHeaderSize,c.offset=z,c.totalEntries=k,z=0;let W=Buffer.alloc(F);C.forEach(function(fe){fe.copy(W,z),z+=fe.length}),L.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(C){D(C)}}}}});var Id=ne((X2,Sd)=>{var xe=Yn(),le=ae("path"),Hp=Qo(),jp=Ed(),_n=(...t)=>xe.findLast(t,e=>typeof e=="boolean"),vd=(...t)=>xe.findLast(t,e=>typeof e=="string"),Gp=(...t)=>xe.findLast(t,e=>typeof e=="function"),Wp={noSort:!1,readEntries:!1,method:xe.Constants.NONE,fs:null};Sd.exports=function(t,e){let r=null,s=Object.assign(Object.create(null),Wp);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:u,zipnamefix:x}=xe;function h(_){if(_&&c){var b;if(typeof _=="string"&&(b=c.getEntry(le.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(b=c.getEntry(_.entryName)),b)return b}return null}function m(_){let{join:b,normalize:S,sep:I}=le.posix;return b(le.isAbsolute(_)?"/":".",S(I+_.split("\\").join(I)+I))}function v(_){return _ instanceof RegExp?(function(b){return function(S){return b.test(S)}})(_):typeof _!="function"?()=>!0:_}let A=(_,b)=>{let S=b.slice(-1);return S=S===a.sep?a.sep:"",le.relative(_,b)+S};return{readFile:function(_,b){var S=h(_);return S&&S.getData(b)||null},childCount:function(_){let b=h(_);if(b)return c.getChildCount(b)},readFileAsync:function(_,b){var S=h(_);S?S.getDataAsync(b):b(null,"getEntry failed for:"+_)},readAsText:function(_,b){var S=h(_);if(S){var I=S.getData();if(I&&I.length)return I.toString(b||"utf8")}return""},readAsTextAsync:function(_,b,S){var I=h(_);I?I.getDataAsync(function(D,O){if(O){b(D,O);return}D&&D.length?b(D.toString(S||"utf8")):b("")}):b("")},deleteFile:function(_,b=!0){var S=h(_);S&&c.deleteFile(S.entryName,b)},deleteEntry:function(_){var b=h(_);b&&c.deleteEntry(b.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,b){var S=h(_);S&&(S.comment=b)},getZipEntryComment:function(_){var b=h(_);return b&&b.comment||""},updateFile:function(_,b){var S=h(_);S&&S.setData(b)},addLocalFile:function(_,b,S,I){if(a.fs.existsSync(_)){b=b?m(b):"";let D=le.win32.basename(le.win32.normalize(_));b+=S||D;let O=a.fs.statSync(_),w=O.isFile()?a.fs.readFileSync(_):Buffer.alloc(0);O.isDirectory()&&(b+=a.sep),this.addFile(b,w,I,O)}else throw xe.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,b){_=typeof _=="object"?_:{localPath:_};let S=le.resolve(_.localPath),{comment:I}=_,{zipPath:D,zipName:O}=_,w=this;a.fs.stat(S,function(C,L){if(C)return b(C,!1);D=D?m(D):"";let F=le.win32.basename(le.win32.normalize(S));if(D+=O||F,L.isFile())a.fs.readFile(S,function(z,k){return z?b(z,!1):(w.addFile(D,k,I,L),setImmediate(b,void 0,!0))});else if(L.isDirectory())return D+=a.sep,w.addFile(D,Buffer.alloc(0),I,L),setImmediate(b,void 0,!0)})},addLocalFolder:function(_,b,S){if(S=v(S),b=b?m(b):"",_=le.normalize(_),a.fs.existsSync(_)){let I=a.findFiles(_),D=this;if(I.length)for(let O of I){let w=le.join(b,A(_,O));S(w)&&D.addLocalFile(O,le.dirname(w))}}else throw xe.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,b,S,I){I=v(I),S=S?m(S):"",_=le.normalize(_);var D=this;a.fs.open(_,"r",function(O){if(O&&O.code==="ENOENT")b(void 0,xe.Errors.FILE_NOT_FOUND(_));else if(O)b(void 0,O);else{var w=a.findFiles(_),C=-1,L=function(){if(C+=1,C<w.length){var F=w[C],z=A(_,F).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(z)?a.fs.stat(F,function(k,N){k&&b(void 0,k),N.isFile()?a.fs.readFile(F,function(U,W){U?b(void 0,U):(D.addFile(S+z,W,"",N),L())}):(D.addFile(S+z+"/",Buffer.alloc(0),"",N),L())}):process.nextTick(()=>{L()})}else b(!0,void 0)};L()}})},addLocalFolderAsync2:function(_,b){let S=this;_=typeof _=="object"?_:{localPath:_},localPath=le.resolve(m(_.localPath));let{zipPath:I,filter:D,namefix:O}=_;D instanceof RegExp?D=(function(L){return function(F){return L.test(F)}})(D):typeof D!="function"&&(D=function(){return!0}),I=I?m(I):"",O=="latin1"&&(O=L=>L.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof O!="function"&&(O=L=>L);let w=L=>le.join(I,O(A(localPath,L))),C=L=>le.win32.basename(le.win32.normalize(O(L)));a.fs.open(localPath,"r",function(L){L&&L.code==="ENOENT"?b(void 0,xe.Errors.FILE_NOT_FOUND(localPath)):L?b(void 0,L):a.findFilesAsync(localPath,function(F,z){if(F)return b(F);z=z.filter(k=>D(w(k))),z.length||b(void 0,!1),setImmediate(z.reverse().reduce(function(k,N){return function(U,W){if(U||W===!1)return setImmediate(k,U,!1);S.addLocalFileAsync({localPath:N,zipPath:le.dirname(w(N)),zipName:C(N)},k)}},b))})})},addLocalFolderPromise:function(_,b){return new Promise((S,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},b),(D,O)=>{D&&I(D),O&&S(this)})})},addFile:function(_,b,S,I){_=x(_);let D=h(_),O=D!=null;O||(D=new Hp(s),D.entryName=_),D.comment=S||"";let w=typeof I=="object"&&I instanceof a.fs.Stats;w&&(D.header.time=I.mtime);var C=D.isDirectory?16:0;let L=D.isDirectory?16384:32768;return w?L|=4095&I.mode:typeof I=="number"?L|=4095&I:L|=D.isDirectory?493:420,C=(C|L<<16)>>>0,D.attr=C,D.setData(b),O||c.setEntry(D),D},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return h(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,b,S,I,D,O){I=_n(!1,I),D=_n(!1,D),S=_n(!0,S),O=vd(D,O);var w=h(_);if(!w)throw xe.Errors.NO_ENTRY();var C=f(w.entryName),L=u(b,O&&!w.isDirectory?O:S?C:le.basename(C));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=u(b,S?W:le.basename(W));let fe=D?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(L)&&!I)throw xe.Errors.CANT_OVERRIDE();let k=D?_.header.fileAttr:void 0;return a.writeFileTo(L,z,I,k),!0},test:function(_){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var S=c.entries[b].getData(_);if(!S)return!1}catch{return!1}return!0},extractAllTo:function(_,b,S,I){if(S=_n(!1,S),I=vd(S,I),b=_n(!1,b),!c)throw xe.Errors.NO_ZIP();c.entries.forEach(function(D){var O=u(_,f(D.entryName));if(D.isDirectory){a.makeDir(O);return}var w=D.getData(I);if(!w)throw xe.Errors.CANT_EXTRACT_FILE();let C=S?D.header.fileAttr:void 0;a.writeFileTo(O,w,b,C);try{a.fs.utimesSync(O,D.header.time,D.header.time)}catch{throw xe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,b,S,I){if(I=Gp(b,S,I),S=_n(!1,S),b=_n(!1,b),!I)return new Promise((L,F)=>{this.extractAllToAsync(_,b,S,function(z){z?F(z):L(this)})});if(!c){I(xe.Errors.NO_ZIP());return}_=le.resolve(_);let D=L=>u(_,le.normalize(f(L.entryName))),O=(L,F)=>new Error(L+': "'+F+'"'),w=[],C=[];c.entries.forEach(L=>{L.isDirectory?w.push(L):C.push(L)});for(let L of w){let F=D(L),z=S?L.header.fileAttr:void 0;try{a.makeDir(F),z&&a.fs.chmodSync(F,z),a.fs.utimesSync(F,L.header.time,L.header.time)}catch{I(O("Unable to create folder",F))}}C.reverse().reduce(function(L,F){return function(z){if(z)L(z);else{let k=le.normalize(f(F.entryName)),N=u(_,k);F.getDataAsync(function(U,W){if(W)L(W);else if(!U)L(xe.Errors.CANT_EXTRACT_FILE());else{let se=S?F.header.fileAttr:void 0;a.writeFileToAsync(N,U,b,se,function(fe){fe||L(O("Unable to write file",N)),a.fs.utimes(N,F.header.time,F.header.time,function(we){we?L(O("Unable to set times",N)):L()})})}})}}},I)()},writeZip:function(_,b){if(arguments.length===1&&typeof _=="function"&&(b=_,_=""),!_&&s.filename&&(_=s.filename),!!_){var S=c.compressToBuffer();if(S){var I=a.writeFileTo(_,S,!0);typeof b=="function"&&b(I?null:new Error("failed"),"")}}},writeZipPromise:function(_,b){let{overwrite:S,perm:I}=Object.assign({overwrite:!0},b);return new Promise((D,O)=>{!_&&s.filename&&(_=s.filename),_||O("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(w=>{let C=L=>L?D(L):O("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(_,w,S,I,C)},O)})},toBufferPromise:function(){return new Promise((_,b)=>{c.toAsyncBuffer(_,b)})},toBuffer:function(_,b,S,I){return typeof _=="function"?(c.toAsyncBuffer(_,b,S,I),null):c.compressToBuffer()}}}});var cl=ne(Se=>{"use strict";var M=K;(function(t,e){let r=K,s=t();for(;;)try{if(-parseInt(r(506))/1+-parseInt(r(1802))/2*(-parseInt(r(1331))/3)+-parseInt(r(1445))/4+-parseInt(r(1607))/5+parseInt(r(464))/6+parseInt(r(2018))/7*(parseInt(r(1442))/8)+-parseInt(r(710))/9===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Xs,545221);var sy=Object[M(871)+M(668)],oy=Object[M(1301)+M(1438)+M(1702)],rl=(t,e)=>function(){return t&&(e=(0,t[{RDSuI:function(c,f){return c(f)}}[M(905)](oy,t)[0]])(t=0)),e},ay=(t,e)=>{let r=M,s={KGSJX:function(c,f,u,x){return c(f,u,x)}};for(var a in e)s[r(702)](sy,t,a,{get:e[a],enumerable:!0})};function cy(){return Xu||(Xu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function K(t,e){t=t-455;let r=Xs(),s=r[t];if(K.LVIRlO===void 0){var a=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",v="";for(let A=0,_,b,S=0;b=x.charAt(S++);~b&&(_=A%4?_*64+b:b,A++%4)?m+=String.fromCharCode(255&_>>(-2*A&6)):0)b=h.indexOf(b);for(let A=0,_=m.length;A<_;A++)v+="%"+("00"+m.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(v)};K.WApeJF=a,K.wVSHYV={},K.LVIRlO=!0}let c=r[0],f=t+c,u=K.wVSHYV[f];return u?s=u:(s=K.WApeJF(s),K.wVSHYV[f]=s),s}function dy(){let t=M;return Qu||(Qu=[IDBCursor.prototype[t(1160)],IDBCursor[t(1157)+"e"][t(877)],IDBCursor.prototype[t(877)+"PrimaryKey"]])}function fy(t){let e=M,r={mYBnb:"error",qyCOU:function(a,c){return a(c)},emYqd:e(1736),NUzol:function(a,c){return a instanceof c}},s=new Promise((a,c)=>{let f=e,u={EHkdT:f(1736),dKPBi:r[f(566)],YJtAe:function(v,A){return r.qyCOU(v,A)},MAEad:function(v){return v()}},x=()=>{let v=f;t["removeEventListe"+v(567)](u[v(1744)],h),t[v(1248)+"entListe"+v(567)](u[v(1161)],m)},h=()=>{let v=f;a(u[v(1439)](It,t[v(542)])),u.MAEad(x)},m=()=>{c(t[f(796)]),x()};t[f(1920)+f(2007)](r[f(1145)],h),t[f(1920)+f(2007)](r[f(566)],m)});return s[e(684)](a=>{let c=e;r[c(1497)](a,IDBCursor)&&vc[c(472)](a,t)})[e(1545)](()=>{}),eo[e(472)](s,t),s}function uy(t){let e=M,r={SKQGI:"complete",aIwKk:e(796),UYoRc:e(1148),cVbIE:function(a){return a()},qvOcu:function(a){return a()},etdZO:function(a,c){return a(c)},HRSQF:"AbortError",EoXhg:function(a,c){return a===c},FCpvG:e(1500),XkvNN:e(1437)};if(Qs.has(t))return;let s=new Promise((a,c)=>{let f=e;if(r[f(1995)](r.FCpvG,r[f(1408)]))return this._socket[f(903)+"pe"];{let u=()=>{let m=f;t[m(1248)+m(563)+"ner"](r.SKQGI,x),t[m(1248)+m(563)+m(567)](r[m(844)],h),t[m(1248)+m(563)+m(567)](r.UYoRc,h)},x=()=>{let m=f;r[m(1732)](a),r[m(961)](u)},h=()=>{let m=f;r.etdZO(c,t[m(796)]||new DOMException(r[m(1495)],r.HRSQF)),r.qvOcu(u)};t[f(1920)+"Listener"](r.SKQGI,x),t[f(1920)+f(2007)](r.aIwKk,h),t.addEventListener("abort",h)}});Qs[e(472)](t,s)}function ly(t){to={zSBRo:function(s,a){return s(a)}}[M(2011)](t,to)}function xy(t){let e=M,r={iOXYm:function(s,a){return s(a)},RMVHY:function(s,a){return s||a},LBxAJ:function(s,a){return s(a)},AEtkT:function(s,a){return s(a)},sFIgk:function(s){return s()},bLZQU:function(s,a){return s!==a},gqIxS:"mQQQy",HBVxh:e(948)};if(t===IDBDatabase[e(1157)+"e"]["transact"+e(477)]&&!(e(1918)+e(1971)in IDBTransaction.prototype))return function(s,...a){let c=e,f=t.call(bi(this),s,...a);return Ec[c(472)](f,s[c(1897)]?s.sort():[s]),r[c(1929)](It,f)};if(r[e(1847)](dy).includes(t)){if(r[e(1135)](r[e(1008)],r[e(1357)]))return function(...s){let a=e;return t[a(1235)](bi(this),s),It(vc[a(1656)](this))};{let s=this[e(1113)][e(1244)+e(1499)+"nc"](this[e(546)]),a=_0x557825[e(1196)](r[e(1441)](s,"{}"));return _0x35d118[e(1997)](a)}}return function(...s){let a=e;return r[a(548)](It,t[a(1235)](r.AEtkT(bi,this),s))}}function Xs(){let t=["vLvvBKq","Bg93","C3jytgu","z2v0","zhjpC1G","DgfYz2v0","suf1vwe","Aw1LCYbPBIa","ANzMsvy","AxnmB25N","r3LfCNm","q21MB2W","thLYv0K","ANnsquG","DLzfBxu","x2LZqNjVD3m","CxPPtvC","tfDjAe4","yvbIu04","D2zTzxa","ywnOzwqSihC","vwn2A0O","quXnu00","yuzYzvq","Cg5Qt3K","CgLvue4","ugnrA20","EeLsCeC","vxDQCvi","r0XxAhi","yNL0zxm","nhWWFdf8mNW","s2nyEeC","Bhm6ia","zNvUy3rPB24","z3vLDLa","seHnq0u","thD4y1O","tuvtu0fhrv8","vwDmzeq","q0DNtg4","t0ncv1i","seXqz1C","ywXSq3vYC28","y3r4","y29UBMvJDca","z2u6ia","vuvbthi","sfjAwfm","BwvZ","yMP3wfK","ywDLrxzLBNq","sMjAwwq","BfPKAKm","t2zyvLK","D1zSruS","C2v0q3vYC28","x2XPC3rLBMu","A3zPyKm","zcWGDw5RBM8","whPLtve","D3m6lY8","ihn1y2nLC3m","Eg9cvvi","mxWZFdL8n3W","y21rt3i","EKXXDMW","B3jRzxjhBg8","rxjYB3jdB2q","D0Tru2O","yw1L","C3rHCNq","wNPMweS","pxv0zI04","r1DqEwS","yxGGCMv0CMK","zLboAha","rKjzqu0","vxbKyxrLq28","y1zIsuu","u2vYDMLJzvC","Dg9cExrLC0W","BxnNsuq","C3vJy2vZCW","Ec1TC2CTy3u","C2rMug8","CMXnyxO","Dw9LB20","AxnbCNjHEq","ywrKq291BNq","vwTlqLu","ruHRzfq","AwDHDg9Yt24","s2Pvzuu","rwHjyKK","s3jdCfa","q0TQCMq","zujOwMy","BgDisNO","sxP3uei","Bg1isuO","Ahjrs1a","ihrVihjLDhi","Aw52Cxy","CMvJzwL2zwq","A1n0yxr1C0m","yMDjDMS","qxPsEfu","EwXIu3u","Bwv0Ag9K","Ee5Nu1q","yxv0B21HDgK","wffkAeC","Bwf4tg9ZC0m","BeHHBMrSzxi","BfPgzw4","x3bPBMDqB24","uNLeAva","AwnLB3m","B25mAw5L","CLHYA1C","sNbUteS","zNjHBwvuExa","DgvZDa","x29Uq2XVC2u","B3jpBMXPBMu","AwXSihvZzsa","DxnLCKLW","qKjQy2O","zxmGCMvHy2G","yMfSu2nVCgu","BgzQvuu","wwL6t2S","BMnhBvi","x2DLBMvYyxq","EfjyzLC","z0r4s1u","Au5TyKq","CLzHBhvLCW","z3LRsNC","ywDL","y1PIu2e","Dg9oDw1Izxi","CfztrNG","x2n1CNnVCK4","v3n4u3a","mxW0Fdz8mNW","Aw5N","wxHWq0S","ohHRvLfYrG","q29Syxq","y2XLyxjtDg8","Dgv4Dc9Qyxy","Aw5KzxHpzG","q1bpwKC","Ewf0ugi","q29Kzq","z2Xfqve","vgfN","v0vJseq","zxq9DxrMltG","ywXPzcb1CMW","AMD6rNO","CvPUEgS","t3bLBKv2zw4","rKLmrv9ot1q","DK9kEgu","Dxv6uLa","zw5XDwv1zq","Cg93","DxnWBuK","suvtx0vsuK8","y3jLyxrLq2W","Ew1yzMO","shzhyMW","x3vYBa","z2HUswu","v3jgwgG","BM9Uzv9UB24","rNLAzwK","qLfdAuS","tgXbuhq","yvf0wwq","v3vouhi","s3D6zvu","t2Xfthu","weD4vey","vLLJt3m","EgTwBLO","sfzvthe","q0PIC1m","qKPYy2m","AKz4EgO","s0TdAue","C0zjz2S","BKXVrxm","zxDMyu8","z2nPs2G","zgvSzxrLrge","wwDutLy","zNbXrMi","qxjAs0S","yMDny2q","C3zergS","tuvsAwO","CwjcqMi","yNnAEw4","wxn5shO","BxLHwxO","tgTJy1K","C2vUzf9Hy2S","Dg9cExrLC0i","uhjPBwfYEuS","x21PBMLoyxy","B25pCgvU","ufLzz0i","qxHduLy","u0nMq1C","De1HBMfNzxi","y2HLy2Tszwe","BM5iAey","BgLIvfC","B09PAKK","BMTfB1i","vw5PBxbSzw0","x2LZv29YA2u","DMvY","zvjny2i","rMvAugO","Avjcsg0","CwjzEKu","CMfNzvn5BMm","vevrDgG","sLD1uKm","ELrtq3O","CgXLyxnLiha","y2HnyxHdB3u","AgLNAa","BgvY","B1DzCKK","nhWYFdeWFdy","vLLsrem","x2LUAxq","DwD1t3i","C29YDa","zgvIDwC","zxzwBMO","Cg9W","zgf0yq","yNbSqxG","DMvYC2LVBG","Cfv6zfq","AeHWAKS","zK5dqwK","D2Pnr20","zw1LBNq","z1rPBwvVDxq","B25tDg9Wsw0","B25fCNjVCG","t1rqwwi","AMzXvNO","AgfZ","tfDUB0m","EvjLy29UBMu","uxDYt1e","B2jQzwn0u3q","zw50zwqGDhK","ywrKrxzLBNq","vxvLuNG","C25nExm","BfzQwg4","tLLmuhK","x2LUDgvYDMe","r2zWCgG","q01xuwO","tg9JAW","Au9yww0","ugDezK8","C05iD0q","y3jLyxrLrwW","tNPHB0e","EK5jrxa","BMfTzq","DejSAKK","tMTwyvi","q29UzMLN","uNjdvgi","wvzwAum","t1bLvxi","u2HHCMvKv28","v2vIu29JA2u","C2vYDMLJzq","C2fNzq","quvfCNq","AwXK","BLrfyNq","q0HQsLi","CNnVCKzPBgu","EvHyA20","Axnby2TdBgu","tKH4qKe","EM50EfC","BgvUz3rO","DMvUDa","zMXVB3i","AMn6rKG","BwP1Ae0","EMTfufa","werUENC","zwnVBM5Ly3q","yNDQv0e","uvLUv3u","BM5Ly3q","vLfYq2e","sgrkqMm","zejMD3i","qMjsv1O","tMrJDKG","B3jLtMfTzxm","x2DLDeLUDgu","AuPvBgK","BwvKAwf0zwW","tg9Nsuq","igXHCMDLCIa","DKHzu0e","svP2wvu","wgLYuK8","C0nVDw50zxi","Ahr0Chm6","zxrxB3jRq2G","D0vtD2u","q1rfq1e","D2PWB00","zM1zBhC","z2v0qwXSs2u","C2v0sxrLBq","qu5gv1C","Cwj0tNy","B25SAw5L","ywnRx2nVzgu","z2DNsNO","z3zSDNe","rw9yAgC","x2LZtM9Kzq","DMfSDwvZ","u3LeB0y","Dw5ZAwDUzwq","qwnqq1e","EfvZzuvUDG","AMftEvO","B3jL","zxH0ugf5Bg8","D2vI","EwretvK","tgLZDgvUzxi","rfHLsvi","C3bSAwnL","v21eELG","ELncuM8","Dg9cExrLCW","B2zbz3O","v1zIuue","qw1VDw50","x3bPBMDmB3m","uNLICwG","nJKYnti0D3vAC0DQ","D1jXCgq","t25xB2i","EfD6tw4","qKDhDvq","Dw9QDve","D1zsv0K","yNnLteu","tKDlrMy","x2nSzwfYugK","zNjVBuj5Dgu","r0fpCeG","CMvQzwn0","m3WWFdf8nhW","BwXhtxi","DMfSDwu","BKX1CgW","rNLABw4","BgLZDgvUtMu","wLvntwS","x2zVCM1HDeu","BKXPBMu","A1DJEha","qMPTBwe","AxHotwO","zxjHDg9Y","AenSB3nLrxy","z0rWtfe","vw9MCgy","mta1mZC4t0XMuu1i","yMLUyxj5","AePUDLO","DxDUsNa","yxnJCMLWDa","EM9TrLy","CNjVCK1LC3m","ELrmq0e","C2v0","z1vzwg4","y3vYC29Y","AM9QrwG","CuDJuw4","Aw9U","AxjLza","x2LZsw5PDa","q1DmwMy","qLvqyum","BefLrw4","x2LZtwLUAvC","v2LUzg93","B2zMC2v0","sKHAt0q","zePrDKG","nxWX","yNnRDue","ENLOrK4","BNrLCG","AwnMzMG","CgLUz0XVC3m","z2vMBLe","zw50","quzQrgK","zMzLCG","rNLSuxO","BMnVzgLUzW","q0rZy00","yuv5tNu","AgTSBKK","teDMr1y","zgvSzxrL","yw5Nzq","oda0mZy2C0DrsunO","z2nmDvy","wLz5Cg8","y3zHuMC","zwDJr1G","B25szwnLAxy","Dw50","Cg9PBNrbBMq","ihzHBgLKigq","sw9uBve","uMvHzcbWyxm","Bg9IywXty28","CM5UyMq","B3bLBG","BwfW","qLPiBwO","uNDIALK","wuLYwNu","wu1wzLy","wfPbq00","y0roChu","svz4ywq","v2jvwwq","tKPyr1m","z2v0q3vYC28","A2Trvuq","zNjVBunOyxi","rgDgt1C","uxngwvy","rwHJChC","AwXLx25HBwu","y29UBMvJDa","DffXr1e","AxjftLi","x19LC01Vzhu","zfDVCMTLCKC","CMvZDwX0","D2fZq2XLyw4","CMLSwuy","rvnzENG","x3bYzwzPEa","BIWGAg9ZDg4","tej4quO","t1jsDM8","DMvYC2LVBMm","BwTdtge","x25HDMLNyxq","tNvmwNO","s1P0DvK","t3rgwNO","q3fPtKC","z0DnAKG","y2HHCKnVzgu","q1PxDNu","tuvsr0u","v3LWtfK","rxzLBNq","zw50tgLZDgu","C2v0u3rVCMe","mdaWmdaWmda","BvLcBMi","BMvY","Aejoz1u","z3PguhO","BuXbDwW","D2XsDfa","BeHIDuS","uNHnzwe","te54rui","BhfbsMO","AhfJvva","y3vYC29YlNm","q1nZAKK","C3nPt20","EuTLtgm","CgLUz19VBMm","EMfAs0y","C0vWBee","y29UDgv4Da","quLpwwG","B3nLrxzLBNq","ELrcChC","CxnbDuy","q0zUsK0","C29Tzq","r2rLqvi","ueXvsgC","x2rYB3bhBg8","CffSC08","y3jLyxrLt2i","qxz6D04","CLHOEMC","v2jYugi","vgLTzw91Da","CNzfAei","DcbSAw1PDa","A01jCgO","tKfusvzfx0u","BNruCMLLC0m","DMXwDvm","BgLTAxq","ELDLC04","BKrgELO","t1DosKy","zxjFCw9Z","Dxrjza","ve1kuwS","C2v0zgi","D1bACw0","zgLZywjSzue","tNrgwLa","yM9KEq","rLjptLrjrvi","BMvJDa","C2PrDM4","r3PPzwK","EgHVvKS","C0H1v0O","x2HHBMrSzu8","Ewj6DKq","zM9Yy2u","u016EMW","zwn0","zNPKzuG","Bg9N","zvvYBa","BMDVteW","zw5HyMXLuw8","Ahj3zNa","Afrzs2K","qLnmBMe","ven2B2W","yw1Lu3bHy2u","B2fK","BM93","B25LCNjVCG","yNL0zuXLBMC","yNvMzMvY","zM9YrwfJAa","uvzIz2W","EKzyqKK","tM10qwu","q1Prywu","yxrLq291BNq","B2XpBMS","BwnvtNi","B3vUDa","B0XIuKK","C3vIyxjYyxK","t0PVDLa","Cgf5Bg9Hzeu","A2v5","CMvJB25Uzwm","AKXYEeC","DLbwBxy","BwXvtuu","CeDrAxe","y29Uy2f0","DLjJuM4","Eg9hq0y","q2PguNu","qwzJCeC","B3bLCNr5","rLDt","qLHyAeu","y09Wzw4","s1D1q28","y2jtENa","AMTNuMC","qLL1Axu","B25tDgfYDfi","B05Wv0O","yvnpDeW","EhDoAfC","yuvhD04","EuLWzNq","CMvZB2X2zq","DxrVuMvJB24","DgHLBG","De5AB3u","txfsDu4","C29bs2K","AgT3sey","BLnzD3i","BezSDxnO","CMvUDevUzha","CKHLDxi","CYbHBhjLywq","BwvY","y2XVC2uSihC","y2fSBa","CNnVCL92ywW","uwDyvLm","EeXht2G","y3vYC29Yx24","tgPwyNC","s0DtsLG","Dhb6ugq","sMH2ywm","yNzXt0C","r1fczvK","tMPLt2e","uLDbDKy","yMrFzgLK","mJeYnZi0mePxtfv4vq","ignVzgu6ia","yKLfsvq","CvL2twm","ENrkB2u","mNW0Fdf8m3W","CMfTzq","ExbL","t3HhwMu","x29UvgLTzw8","rgrvwLi","AhnqAK0","Dhj1y3rVCIa","y0vkq3u","uxbwBMC","tvvbvei","u2vXsuq","BwvZC2fNztO","rwLmuhi","vwPvzgC","ANj5suG","CMvXDwLYzwq","q1zhzfm","Cg9PBNrdB24","tfzkrgK","svbnzem","AKPLquy","EePTEM0","C3rYAw5N","ueT4twG","DhDVCMTdAge","wvvytwq","Bg9Nsurhzw4","vu9NB3K","tgnAyuG","yu1Aveu","s2nitNC","sNzKtgW","zw5HyMXLqxu","q3vZDg9Tq2W","zv90Aw1LB3u","C2nYAxb0","z05mBLC","yMTlAuC","DhjPzxm","CMfUzg9T","q0Xpu0ve","zxjYtM8","yKTvvvC","B1DOzMC","CMvZzxrdB3u","Exbntxy","uhrcAeG","Bg1fqvu","zwTTrfC","zxf1ywXZ","zv9ZDwnJzxm","v29kAuO","zNzqDLy","wfPfzgu","ChHIBhm","y3jLyxrLt3a","B25TzxnZywC","yvnhy1e","C3nHz2vfDMu","uxHqrKe","EKDIz20","BgLUzq","q1rkr0G","DLLewxi","x3nLBMrby2S","CevXuuS","zMfdAg0","AwLoELG","Dgv4DfbHEwW","rvn0u20","x3jLy29UBMu","y3LIDhK","uuvKDMK","CLbysLa","zMzmAw5L","x3jLywr5q2W","qKzYt1K","ChvZAa","z0rmrLy","y2HnyxHuCMK","zxjYB3i","C3rVCcbPBw0","BNrfBMrWB2K","z1Pgsfy","tfPcu2m","yxnZAwDU","q0PfAfi","zxjFDhrS","B0XZvem","icSG","D09dEg0","CgLUz1rPBwu","BevRA24","wxvPC1G","CMLLC0nVDw4","x2nSzwfYvgK","x3jLBw92zvC","ywvZy28","rvfvsMW","veTNA0e","BuXSvLO","qvPbrwC","DhjPzxmGCMu","ufrAqxO","sgzjAwO","x1fVu01HBMe","AfrUquq","z0HvBwe","x2rPC3bHDgm","AvziBLO","CvzTq3y","BMCGB3iGyw4","rvH0C2S","AxnrB1nby2S","quToqvK","s1zJDuu","Dg9tDhjPBMC","m3WXFdr8mNW","s2PwqKy","vu5qEeS","rNzJBuu","tgPkCgG","B2nRzxrgywK","zMLSzw5HBwu","whDvz2e","ihrPBwvVDxq","mNWZFdf8mhW","BLvAEwi","yuL3s2S","B3PXwwC","ue5LB2C","yxKSihrYEsa","EfvWt2u","yxbWBgLJyxq","CKXws3K","y21ZBxe","Bencq1K","Cw9Z","AwrI","y3bkvKy","C0jf","CgjICdi","rhv6vuq","s1ztD3u","Bxv0wfe","B2nRzxrtDwm","ChjVDg9JB2W","BKfJuNe","yvDVyMW","BuPqzgW","tfPArKC","EgvMrvu","DMLJzuLeig8","ELH6vKi","AuLttMy","zgvMAw5Luhi","Bwf4uMv0CMK","uwrIvK8","vxvMBeO","DvPgtgK","DxbNCMfKzw4","y29UDgLUDwu","tMXzAwq","zMLXzui","zxjYtxnN","z2vrDwv1zuW","C2Plufy","x3nVy2TLDa","qwLuAxi","rxn6shu","CwXVzgy","uhb6A3O","A1bdAK4","y0P1Eee","D01XA2q","uxDVrMy","uu1RvLK","B3LwCMy","DxrMofDYAxq","rNjVBNrPzxi","C3vIC3rYAw4","CKrnq3e","x2fKzfDZtgK","Dgv4Dc9WBge","C3rkqMC","CMTLCKDSB2i","y29UBMvJDgK","yMLUyxj5vhK","ywnRtxnNswq","uKrtDuK","uwPtAfe","Eu55zvm","C3bor2u","AfjXzNC","vKzQDfy","CKP1zw8","ww1gzK4","zeHJANO","zeHWv2C","ExvZsgu","BuDQz2W","vM1ICwq","BwLUzW","sLHIu1a","B2nRzxq","vw5Oyw5KBgu","BxDfy3i","yMLUza","AgXTq3i","zvryAhe","zvr2DKS","uffdsgK","y29Kzq","q05PCKy","s1nmsM0","AuzNALm","z2jLzgy","y291BNq","vgXttKW","sNDUwg8","CwLwC2i","u3HPvLu","DhbizwfKzxi","rgnqs1O","t1bftG","wvvUrfC","vgHMDuO","igzPzwXKoIa","BujRBwG","DLPyC3a","zvzttwW","tKXbCKm","wLLbrha","Cgf5Bg9Hza","ChbL","o2nOyxjZzxq","wvjzDMq","x3DZ","z1vjBe4","qMPTELq","D1jADxu","rePSvLy","CMvZzxrfBMq","CgDmDwe","BMDLza","Cxzpy3u","AuvNwe8","twnYChC","AK1YsMK","wwj2zNC","nhWZFdf8mhW","CfLMt2W","C2DPza","wu56zNe","BLjgsKi","wNfhzvu","zNDly1q","txDqA2q","q291BNq","uu91Bwu","Dev2zw50","u2HjzvG","zxH0zw5ZAw8","EhvcD0G","D2DuqLy","qNvQCu0","BKTkr0u","x3DHAxq","x2rLyNvN","uKPbAfq","x2nVBM5Ly3q","yNL0zu9MzNm","q3vZDg9Trxi","CfDZtve","uxrwAMS","wuHmzMK","zKjpww8","yKjxt00","zhz2AwO","zw5NDgG","AgvHzgvYCW","C2vUDa","C0XPC3rLBMu","z2v0qwXS","zxjFBxnNAwq","uvPuyMu","y0T3Evq","lcbxzwjtB2m","rw9YAKq","v0nwALa","t1bftL9fuLi","ywrKt25L","z3fjEfm","AxjUv1G","rgz1shm","zgrjrcWGzgu","EwLNAwq","zxjFCw9Zx2e","vLfgvxa","AgXIsKe","vvHrtum","zgvJB2rLzey","igfYCMf5yNu","BMvLzf9Hy2S","Eg90uMq","x2jPBMfYEvq","sMHNsMu","DLLJAKC","yw5ZzM9YBvq","wxDWqNi","Dg9Y","yMXZBvy","z0LrEKS","z0zzvfa","wgDkzLy","Bgjyy28","zxjFywnRx20","y3ruAw1LB3u","x3nLCuLK","BKLIuMu","wfLLq0S","EuzTDxC","zNjVBNrPzxi","DMvmzgu","EKLND2W","AM9PBG","rM9zC2O","AgfZt3DUuhi","x21LC3nHz2u","BwPmthe","AgvHzgvY","zK1HzNu","CLbIDgi","A2v5CW","wwHOvum","DvbqBNG","y3jLyxrLuMu","DhnIAvu","EgXHqxK","s1DND0q","tKHtv3K","D0f6v0y","BMDuAw1LCG","D2LSBfjLy28","uNzXAKG","sKz5vg4","C0Dlv0e","Bg9NsurozxC","shnhvxu","ihrYEsbYzwm","y29UBMvJDeu","DMTXDNu","BurgrMy","zNjVBujPDhm","DNDcDLG","y05otxO","EhLws3G","veLVv0G","A2nkrM0","CM9YrxzLBNq","AxPVywm","AeD6txe","yuresLm","BKfLufa","ve5VsfK","qxDqDvO","y0HTBhu","uLPyBw0","EM5tEMm","uLjpuG","zMzMzG","CIb0DhDjra","y29SBM8","Cgf5Bg9Hzfq","AuvNwKq","BwvZC2fNzv8","yxv0BW","wu1rC1q","BMCGzMfPBgu","C0nOuKO","zg9Uzq","B3vTvNG","Dw5KzwzPBMu","x29UrxjYB3i","CYbPBNn0yw4","rhPdzhy","tNrJvwS","uxvLDwu","D1vlAuy","wvH4B1m","Ae1LC3nHz2u","wufRCKW","zMznr20","AxnrB1nnzxm","Bejpzxm","serytgy","zgvS","x3fVC0rc","Efrurw52","BMv3vMvYC2K","vwTbA2S","wMDzAuK","reXYB2i","wgLiBfu","B3nLza","AgzLwK0","CMvZzxruCMK","x0rctMfTzq","rLLmqNO","rgrHBLm","vgH6EKG","svHOCvq","ug9bsLK","uhzWAMS","v2LcrwO","x29Ut3bLBG","EuHLsuS","DNvizw8","vfLmtwO","yKXAuvu","u1z3quy","yNvMzMvYzwq","zw5fDMvUDa","DeLK","tNHUCeW","tgr2AwS","BLDeqwy","Ce5rtw0","y0v5rha","zw1zCwq","wxjxs0i","A0PZtMK","ywjVCNq","uMjyyKu","zw1PDa","thntAKW","qu1HveG","wxDbzxq","BgTpq0O","AxnAzxjV","AKv3rge","ChjVDg90Exa","yvDhC3i","vgr0uMS","ywr2yw5Jzq","zeTqqMK","Cuv3B08","terfy3G","BwjmDhG","vKrYCwu","CMvHC29U","CM92AwrLihC","yNviEvK","tgTxzfq","CgXTBgW","sfvWEuK","D3jPDgvvAw4","tgLPtxq","Exf3zMi","zufJAW","EefTA3u","D24GCMvHC28","ywDLu2HVDW","y29UC3rYDwm","C3rYAw5NAwy","z1n2rLy","mNWZFdb8nhW","D3jPDgu","s2z6qMO","C0Xf","qNjPzgDL","DgXfAeq","s1jJy3G","B3v0sw50zxi","DfrODLq","CMvKDwnL","qw9Tr1q","rw9yy3q","yxKSig5LDhC","sfnhChm","CgfYC2u","tufyx1jfvfi","BKPdywu","Bwf4twvZC2e","BhrYr0W","Dw5RBM93BIa","yLH5veC","qwHAENO","Eu9wzwq","x2rLC3rYB3K","tuDWBMq","BfrPBwvVDxq","x2nYzwf0zvm","sNL6DvC","AwvrA2m","CMrlEeS","DMDdAuC","C3rLBMvYCW","BNrbBMrvCgq","qxrrsvC","ANjjwxi","sMr0B1m","CgLUz0LUDgu","yMjiBwO","sLb0DhG","su5pDeK","tKTJA0O","yMTSt0q","tuPLtwW","qxH6yxq","vxLpy3e","CgvYC2LZDgu","D3j2y00","DMLLy3a","ihzHBgLKihm","zw5JB2rPBMC","C3bSAxq","reiGzMfPBgu","yw1LoIa","yxbWBhK","thvStK0","wuzfqK8","D1L1q3K","sMrlAg8","sgLcBNy","B2zMBgLUzq","C2HPzNq","mNWZ","z2v0u3rVCMe","nxWXmhWWFde","CvjKtMy","sLnptLa","CMvTB3zLrxy","z2v0q3vYCMu","ywnR","EwXOu0i","swfQwwu","B1PVvLK","vu9RuNq","DhjHBNnHy3q","EMnHDuG","tMfTzq","BejWs04","BLvNveO","AevYCM9Yrxy","zwTqyvm","uuXjBNi","nNWZFdi","y3jLyxrLrxi","seLSD0S","CwPVDgu","rwjzAw0","Aw5KzxGGB3u","Bwu6ia","CwzRqu4","vKPouLa","ywnRx2LK","BwfUDwfSihi","uMvJB25Uzwm","x0vysvnu","v0j1Ew0","Dg9mB3DLCKm","DxbKyxrLq3u","u2nzwfK","sM1ftxe","q0Xpu0LorW","ALLPyu8","A2v0ignVBNm","BhrPCgXLihq","rxfjCuC","rfjqBMC","wMrmEMm","C3rVCMu","EKz6yKq","u2XkBfq","CMvWBgfJzq","AxPSvNm","x3bYB3rVy28","DxvPrM0","AxPNwNG","jMPZy2fSBgi","CNnVCL9Uyw0","Cg5huuW","y2PpDKC","BgLUzw5V","z2v0t3DUuhi","sMjOs2G","sK13z1q","zMvZrum","uwDPvei","s0PwCg4","Aw50zwDLCIa","vLvRy3G","BMnLq2XVC2u","AMDLq2S","AvDdDhe","Burwwwu","AhDmExi","wLnRAvi","zxHWB3j0CW","qwr3Cfa","zLHfu2y","DxjS","x2n1CNnVCK0","ENLWC1y","zwvKzwq","Aw9UvgLTzw8","uLbVy1K","nhWYFdf8m3W","D3nZoI8V","yNvIAhm","B2L5vLG","AMHXEgq","zMLSDgvY","C2vUza","odaZnZG3CvPWwuHs","z2Lqv00","vejrqMG","yMfJA3vWigu","BvLeA2q","AwXLtMfTzq","CMvJzxzPzwq","y3vYCMvUDeu","veLlB2y","EKPHwNK","ufjssMm","zw5JB2rLrNi","yxnL","rgvKAwnHDgu","CM92AwrLige","zsbHihn0CMK","igzHAwWSig0","CwjwDxa","yNLL","CMvWBgfJzui","x2rPC2nVBM4","DwrJt0e","u0ris3O","wwfiChe","wxvdt2G","AgvKtwf4uMu","sejwEgG","A0HWCxe","weDTtMS","x2LUAxrhBg8","x2HHBMrSzvi","sfnvr28","CgfNzwHPzgu","r3bxqNm","AxHXuKW","tfvdywW","ywWGy3vYC28","zMLUza","DuDLAuq","sNzzrMu","B3bLBKrc","Cw9Zx18","sxH3CKW","Ag5NB1y","AxnFywnR","tKHsqNa","Aw9Ul2PZB24","ChrVCG","rgv5ruy","x2LUAxrqCM8","DhLWzq","zLzsyNq","vLPvz2e","B1rIqMi","AefJA01LC3m","y2XVC2veqG","wu1Irxm","rwD5tuu","CfrdBLG","lcbTyxGGCMu","z1rUCMW","Duz3ExC","DK1swhC","BufhB0S","EKfUzvK","y2XVC2u","zLr0Bei","ELLXu1i","ANnUCvO","rw90B3e","y2XLyxi","C25vq3m","AMvJDfn0B3i","FdH8nxWZ","uuj5t2q","vgLNuLa","DgLZvhi","wgT2tK4","x2n1CNnVCKy","yLb5y3m","AejcvMm","vhvivfm","ruHWDgC","AwHxrui","zgzLzuS","r2Dcu0e","qM9rEMq","z0PptNK","CYbWyxjHBxm","ufrZuey","EvPXuu8","y29UBMvJDfm","whzAALa","zvH1vgO","AwjZA1a","rvjst1i","q09otKvdveK","zunwEeu","vgX1uNy","tg9NsurozxC","ywnOzwq","wLL3AM4","BMrLEa","yw5Hz2vY","se1vA2S","uKLTy3q","rfH0A2C","B3bLCNr5tMe","wuP0qwu","y3L2Dwm","uK1wsfK","odHPEfjHzum","zw5KCg9PBNq","su5tvefova","mty4mJi3mKfbq0fMsG","EMHeveq","zMLN","y3jLyxrLtwu","AK5RExm","Ae9Wzw5fDMu","tMDOtwW","z3rsBvm","z29PBMCGyxC","DeLUDgvYy2u","Effbt2q","txzetMW","AgfUz2u","A3LdEfu","uKjsB1e","t3L3u04","ywnRpwzYB24","B2zM","zu1YqLa","ExL5EgG","DNvMv0m","EwP5wve","ysbTDxn0igi","ywXty29Wzq","EMfUuNm","tvnbv0C","z0f1Afi","C2v0y3vYC28","ywHMAgu","x2LZtwLUAvq","z2v0sxrLBq","uxPjvuK","x3bPBMC","q09oveLovuu","u21ItuK","D2Xpzw8","yw51Ce1LC3m","A29jDwC","u1beuha","CNzHBa","CgLUz09Uy2u","zgLZCgf0y2G","z2vtEw5J","Ef9MCM9UDgK","s1bktuy","y3vYC29Yx2y","z2LAAgy","vwDMq2m","B25VCgvU","ALvyuLO","sfjtuuy","Bwfwz2e","tLv6B2W","t3DuB1i","z2vjBMzVu3K","ENj4yxO","ChPzDNK","C3jJ","C2XPy2u","y09TCLG","Aw5KzxG","wwnyqvG","s29quxG","BhHMqMq","AxLssLe","r3LLBve","yKD4tNi","ENvzzKe","D3D4qKq","y3vZDg9Tshq","CgfNzxnOB3C","rw5VCLG","quDTCfO","A0v4Dwi","x29WDgLVBNm","CMfcBxG","DgLLCKPtt04","BMv4DcGPigm","qNnAvva","CMvHzfvjBNq","DujJu3a","wNr3v1u","C3rJrLa","reHrq2G","B2LUDfjLywm","z3bwwKy","DvfVAeG","uMHZBg8","uND1Cxy","suPzywO","DKLHC0u","rwfYwfC","y3rkB1m","BvvoDLa","AhHUD2W","uvjVBNO","CNzHBfzHBhu","ChL2q2S","rvPmAfq","B3fJDvu","y2f0y2G","vNLetLy","Aw5JBhvKzxm","Ahr0Ca","yLDTD2K","DhjPBq","x3bHDgHlzxK","ChnWrMK","BK5Sv0q","BwvZC2fNzq","x2rItMfTzq","zxjFAxnFywm","y3vYCMvUDeK","Ag9VsNa","x29UtwvZC2e","DhjZz0i","yMXVy2TLza","DgvmB2Djre4","CKzAs3u","nxWWFdf8nhW","tw9KDwXL","wM9huuu","ign1CNnVCIa","CMvHzhLtDge","AxnszwfKEq","AgTpv1C","CgPHwha","B25ozxr3B3i","wuTyqLK","x2vUzhbVAw4","ywrK","tKjZrLG","rwnmt3u","CK54te8","uMrLzNa","yMfSrxzLBNq","yxbWzw5Kq2G","shHyyvC","s1beEKu","s0PZrLO","r2vosvq","EfHjs20","zfjuEhG","r05eywi","u3fkDuS","D3reCMC","zNjVBu51Bwi","yu5hDe0","B0PbAeW","y1bMy1u","v2v2uLu","zMX1C2HfEha","DMfS","x29UugfNzu4","yM1PDNm","BwLZzq","EvDpvwi","vKXMDwy","vw9rDKe","y0Ppzw4","Cu1lEui","rNz2CM8","odu1mdGWAe5drMTq","ExzJA2e","zKnwENa","z2vY","uxniAgW","wwT3rfi","DhnWsvG","CwrSr0K","yLvhuwW","zw5HyMXLvhi","we9duNe","BNvTyMvY","B3bLBIa","qunAAhq","tKDFrvjst1i","AuLfvwK","twvZC2fNzuu","uerYz3u","t0XjANm","x2HHBMrSzva","nhWZFdj8mhW","C09tsva","BMrWB2LUDfq","uMTNBK4","Du9Sv1a","twLZC2LUzYa","BMCGDxjSoIa","AufsrMW","ywDLsgLKzq","z2XoAeS","DgLTzw91DcW","sKn6r0y","ExjXwuK","rwTLuhu","y2vZC0HHBMq","B2XKvMvYC2K","AKHZsvC","BNLjzhm","s2Tszw8","s29AB2u","q1bfDva","vNvHqwy","y2HLy2TdDxi","EsbJBg9Zzwq","EeL3Bfu","zNbstfi"];return Xs=function(){return t},Xs()}function hy(t){let e=M,r={qTHoW:function(s,a){return s===a},LDYyF:e(1687),iNmbD:function(s,a){return s instanceof a},apsIA:function(s,a,c){return s(a,c)}};return r.qTHoW(typeof t,r.LDYyF)?xy(t):(r[e(1790)](t,IDBTransaction)&&uy(t),r.apsIA(il,t,cy())?new Proxy(t,to):t)}function It(t){let e=M,r={JbZYd:function(a,c){return a instanceof c},udcOA:function(a,c){return a(c)},nAcRq:function(a,c){return a!==c}};if(r[e(1705)](t,IDBRequest))return r[e(1352)](fy,t);if(Zs[e(1914)](t))return Zs[e(1656)](t);let s=r[e(1352)](hy,t);return r[e(863)](s,t)&&(Zs[e(472)](t,s),eo[e(472)](s,t)),s}var il,Xu,Qu,vc,Qs,Ec,Zs,eo,to,bi,el=rl({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={xefEU:function(r,s){return r===s},srXLe:t(1918)+t(1971),mUNvP:function(r,s){return r===s},QtVjk:function(r,s){return r(s)},ZUMMk:function(r,s){return r||s},ZdDCy:function(r,s){return r instanceof s},JCzGF:function(r,s){return r===s},lqAJj:t(1096),Fvvro:function(r,s){return r!==s},xUpOe:t(930)};il=(r,s)=>s[t(590)](a=>r instanceof a),vc=new WeakMap,Qs=new WeakMap,Ec=new WeakMap,Zs=new WeakMap,eo=new WeakMap,to={get(r,s,a){let c=t;if(r instanceof IDBTransaction){if(e[c(867)](s,c(1096)))return Qs[c(1656)](r);if(e[c(867)](s,e[c(1655)]))return r[c(1918)+c(1971)]||Ec[c(1656)](r);if(e[c(1538)](s,c(1288)))return a[c(1918)+c(1971)][1]?void 0:a[c(1918)+c(2003)](a[c(1918)+c(1971)][0])}return e[c(990)](It,r[s])},set(r,s,a){return r[s]=a,!0},has(r,s){let a=t,c={lZFen:function(f,u){return e[K(2037)](f,u)},Sgloo:function(f,u){return e[K(2037)](f,u)},TIoWH:function(f,u){return f!=u},MwPkd:a(1098)+"d"};if(e.ZdDCy(r,IDBTransaction)&&(e[a(1638)](s,e[a(575)])||e.JCzGF(s,a(1288))))if(e[a(1606)](e[a(848)],e.xUpOe)){if(_0x480792)return new _0x5d3118(_0x2cf1b1[a(1318)],_0x352ccf[a(862)]);if(c[a(1768)](_0x4359a7,_0x4a7bc7))return new _0x1dd233(_0x41e604[a(1318)],_0x42b4a7.protocol,_0xdd11c7[a(996)]);if(c.Sgloo(_0x5bbf55,_0xdc7813)&&c[a(1073)](c[a(973)],typeof _0x370fd2)&&_0x12b730)return new _0x2221de(_0x297819.url,_0x7477f0[a(862)+"s"])}else return!0;return s in r}},bi=r=>eo[t(1656)](r)}}),sl={};ay(sl,{deleteDB:()=>gy,openDB:()=>py,unwrap:()=>bi,wrap:()=>It});function py(t,e,{blocked:r,upgrade:s,blocking:a,terminated:c}={}){let f=M,u={bKUUW:function(m,v,A,_,b){return m(v,A,_,b)},wJVdk:function(m,v){return m(v)},oVSgU:function(m,v){return m===v},OGpkk:f(1716),SVwAF:"IXhZf",fBOYo:f(1396),bXyTG:"versionc"+f(1457),DgFOW:function(m,v){return m(v)},ySsEB:f(1561)},x=indexedDB[f(519)](t,e),h=u[f(533)](It,x);return s&&x[f(1920)+f(2007)](f(876)+f(1321),m=>{let v=f;u[v(758)](s,u.wJVdk(It,x[v(542)]),m[v(1642)+"on"],m[v(1115)+"on"],It(x["transact"+v(477)]))}),r&&x[f(1920)+"Listener"](u.ySsEB,()=>r()),h.then(m=>{let v=f;if(u.oVSgU(u.OGpkk,u[v(1136)]))return this._socket[v(1568)+"te"];c&&m[v(1920)+"Listener"](u[v(992)],()=>c()),a&&m["addEvent"+v(2007)](u[v(1202)],()=>a())})[f(1545)](()=>{}),h}function gy(t,{blocked:e}={}){let r=M,s={oLsTC:"blocked",JyzuW:function(c,f){return c(f)}},a=indexedDB[r(1851)+"tabase"](t);return e&&a.addEventListener(s[r(804)],()=>e()),s[r(1209)](It,a)[r(684)](()=>{})}function tl(t,e){let r=M,s={KVcuE:"readwrite",BzOUK:function(x,h){return x instanceof h},BuLOj:function(x,h){return x in h},WEcHD:function(x,h){return x===h},HIOIc:function(x,h){return x!==h},gIQzK:function(x,h){return x in h}};if(!(s.BzOUK(t,IDBDatabase)&&!s.BuLOj(e,t)&&s[r(1812)](typeof e,"string")))return;if(Ys[r(1656)](e))return Ys[r(1656)](e);let a=e[r(1291)](/FromIndex$/,""),c=s.HIOIc(e,a),f=al[r(1547)](a);if(!s[r(1028)](a,(c?IDBIndex:IDBObjectStore)[r(1157)+"e"])||!(f||ol[r(1547)](a)))return;let u=async function(x,...h){let m=r,v=this[m(1255)+m(477)](x,f?s[m(831)]:"readonly"),A=v[m(1288)];return c&&(A=A[m(1505)](h[m(1242)]())),(await Promise.all([A[a](...h),f&&v[m(1096)]]))[0]};return Ys.set(e,u),u}var ol,al,Ys,my=rl({"node_modules/idb/build/index.js"(){let t=M,e={EXtsk:"4|0|2|5|3|1",Mcrpw:function(a){return a()},CZWvu:function(a,c){return a(c)},HHMCE:t(1656),BTfvg:"getKey",jMrJi:t(999),gggJz:t(933),ArZKK:t(1575),bIEIT:"delete",oqcuU:t(1401)},r=e[t(828)][t(1232)]("|"),s=0;for(;;){switch(r[s++]){case"0":e[t(963)](el);continue;case"1":e[t(559)](ly,a=>({...a,get:(c,f,u)=>tl(c,f)||a[t(1656)](c,f,u),has:(c,f)=>!!tl(c,f)||a[t(1914)](c,f)}));continue;case"2":ol=[e[t(1689)],e.BTfvg,e[t(964)],t(1987)+"ys",e[t(1993)]];continue;case"3":Ys=new Map;continue;case"4":e[t(963)](el);continue;case"5":al=["put",e[t(1854)],e[t(712)],e[t(1544)]];continue}break}}}),wy={idb:function(t){let e=M;t[e(1315)]=Promise[e(682)]()[e(684)](()=>(my(),sl))[e(684)](function(r){return r})}},nl={};function St(t){let e=M,r={CJbsS:e(1684)+"3"},s=r[e(1843)][e(1232)]("|"),a=0;for(;;){switch(s[a++]){case"0":if(f!==void 0)return f[e(1315)];continue;case"1":var c=nl[t]={exports:{}};continue;case"2":wy[t](c,c[e(1315)],St);continue;case"3":return c.exports;case"4":var f=nl[t];continue}break}}St.d=(t,e)=>{let r=K;for(var s in e)St.o(e,s)&&!St.o(t,s)&&Object[r(871)+r(668)](t,s,{enumerable:!0,get:e[s]})},(()=>{let t=M;St.o=(e,r)=>Object[t(1157)+"e"][t(1043)+t(668)][t(696)](e,r)})(),(()=>{let t=M,e={efdOV:function(r,s){return r!=s},uFwyw:t(1098)+"d"};St.r=r=>{let s=t;e.efdOV(e[s(1392)],typeof Symbol)&&Symbol["toString"+s(1811)]&&Object[s(871)+"operty"](r,Symbol[s(832)+"Tag"],{value:s(1565)}),Object["definePr"+s(668)](r,s(540)+"le",{value:!0})}})();var be={};(()=>{let t=M,e={FylQz:function(o,n){return o+n},AEErt:function(o,n){return o+n},jYiaO:function(o,n){return o*n},qZnxk:function(o,n){return o(n)},qdlGI:function(o,n,i){return o(n,i)},wAzWF:function(o,n){return o(n)},CHjJR:"0000",pgLua:t(1086),cNBLv:function(o,n){return o(n)},bPycs:t(565)+t(565)+t(565)+t(565),VUkcx:function(o,n){return o||n},oyVrf:function(o,n){return o>n},OTPYb:function(o,n){return o<n},giPWM:function(o,n){return o>n},YuCOh:function(o,n){return o<n},snMys:function(o,n){return o!==n},gAuhR:function(o,n){return o===n},CPEuP:t(1921),nLupl:function(o,n){return o!==n},zGbgm:function(o,n){return o-n},pTCnX:function(o,n){return o===n},mYDkd:t(1563),opLhl:t(1251),vYDYr:function(o,n){return o!==n},Cmfol:t(509),lHbuK:t(1203),PtBhH:function(o,n,i){return o(n,i)},mJPdl:function(o,n){return o!==n},AKNAY:function(o,n,i){return o(n,i)},fTtlB:function(o,n,i){return o(n,i)},ltrGL:function(o,n,i){return o(n,i)},GWPyk:function(o,n){return o(n)},ghnIe:function(o,n){return o!==n},xotRd:t(937),wPZqm:function(o,n){return o>>>n},vkqvu:function(o,n){return o(n)},iIEUi:function(o,n,i){return o(n,i)},Gfpph:function(o,n){return o(n)},zuYfA:t(1632)+t(731)+t(943)+t(657),fwKcT:function(o){return o()},EHptg:function(o,n,i){return o(n,i)},qRzNr:t(581)+"e_timeout",myaYz:"timeout",yXXkm:function(o,n){return o!==n},CTJGH:function(o,n){return o!==n},qbtNv:t(1738),eVSMl:function(o,n){return o!==n},PTsPF:function(o,n,i){return o(n,i)},AFjDi:function(o,n,i){return o(n,i)},XirRO:function(o){return o()},fesEC:function(o,n,i){return o(n,i)},tThvT:function(o,n,i){return o(n,i)},LVJDi:function(o,n){return o!==n},jryIH:t(955),GyemQ:function(o,n,i){return o(n,i)},gTnrl:function(o,n){return o!==n},HdJBc:function(o,n,i){return o(n,i)},CPOZG:function(o,n){return o!==n},nIbRe:t(715)+"0",hqcUP:t(796),vVEmu:t(519),EkePu:function(o,n){return o===n},LWIhN:"aFyDC",mKonY:t(1820),bbHmj:function(o,n){return o(n)},LjJph:function(o,n,i){return o(n,i)},sjQvn:function(o,n){return o(n)},drOsX:function(o,n){return o===n},eRMcb:t(1312),egcGX:function(o,n){return o(n)},iRBHm:function(o,n){return o(n)},mAGoK:function(o,n){return o===n},icffh:t(1632)+t(731)+" field: "+t(726),BoQzd:t(1632)+t(731)+t(943)+t(1944),plmll:t(1632)+t(731)+t(943)+t(1762),blsmV:function(o,n){return o(n)},aWobl:function(o,n){return o&n},NuLZz:function(o,n,i){return o(n,i)},kExub:function(o,n){return o+n},cDNpu:t(1877)+t(1919)+"pe: ",hooJp:function(o,n){return o>>n},xkVnZ:function(o,n){return o>=n},BYuiu:t(1016),sFMhs:t(1068),aDDJS:t(1554),YUXMd:t(1323),UhmrT:function(o,n){return o>n},XzeMQ:function(o,n){return o+n},OJovP:"Skip pas"+t(601),BFrOY:function(o,n){return o>n},KjVBF:function(o,n){return o*n},cKwyT:function(o,n){return o>n},QdbVO:function(o,n){return o>n},YMVfV:function(o,n){return o+n},gHUma:t(516)+t(601),cNNMz:function(o,n){return o>>>n},ztJoe:function(o,n){return o===n},zNIEp:t(1659),YkwDR:function(o,n,i){return o(n,i)},hJnvZ:"close",SlJlT:function(o,n){return o||n},JpnLK:function(o,n){return o!=n},OfXVY:t(1098)+"d",WuNPr:"init QoS"+t(1233)+"d",VUUnD:function(o,n){return o<n},cZbSa:t(989),QOume:function(o,n){return o===n},pNQMm:function(o,n){return o===n},tisTr:function(o,n){return o+n},HiBnv:function(o,n){return o!==n},DzCdv:function(o,n){return o&n},cmQOr:function(o,n){return o|n},zcauH:function(o,n){return o<<n},tBljI:function(o,n){return o<n},Gziei:t(743),fvPvV:function(o,n){return o==n},RBRoQ:function(o,n){return o&n},EQaAL:function(o,n){return o!==n},sHuWJ:"MxWmr",Vmbqd:function(o,n){return o+n},Rwuqv:function(o,n){return o&n},bwjWA:function(o,n){return o|n},oumVx:function(o,n){return o&n},ybzvD:function(o,n){return o&n},rGOov:function(o,n){return o<=n},BBjcj:function(o,n){return o(n)},LyrWI:t(1740),JpRkb:"gbqGc",oWhfg:function(o,n){return o+n},yrqYI:function(o,n){return o+n},YxpCK:function(o,n){return o+n},RyDiP:function(o,n){return o!==n},DLrob:function(o,n){return o|n},YVViC:function(o,n){return o<<n},UwjqR:function(o,n){return o&n},WypLY:function(o,n){return o<n},ESYzx:function(o,n){return o>n},sNHwD:function(o,n,i){return o(n,i)},bmivs:function(o,n){return o+n},pLmON:function(o,n){return o+n},TBQBh:function(o,n){return o&n},mDcMP:function(o,n){return o>>n},glNhK:function(o,n){return o&n},JHZOD:function(o,n){return o>>n},zXzVB:t(997),yyyxh:function(o,n){return o<n},iJbvm:function(o,n){return o+n},uOlWP:function(o,n){return o+n},AIOYh:function(o,n){return o<<n},hBNgU:function(o,n){return o<n},NGKFf:function(o,n){return o<n},QByOd:function(o,n){return o|n},uZFLi:function(o,n){return o&n},mbLtx:function(o,n){return o>>n},ieQkc:function(o,n){return o|n},nkEoR:function(o,n){return o&n},qsAuF:function(o,n){return o|n},rDMCq:function(o,n){return o>>n},UyOcq:function(o,n){return o|n},gtRmS:function(o,n){return o&n},QRonz:function(o,n){return o>>n},NtcUk:t(980),vRcRn:t(1384),hpyWJ:function(o,n){return o<n},yigid:function(o,n){return o-n},YHLfi:function(o,n){return o<<n},RkgnN:function(o,n){return o<n},qbYzE:function(o,n,i){return o(n,i)},iwBrG:t(2017),wjMGm:"KAtLH",mkegE:function(o,n){return o>=n},MMdnb:function(o,n){return o<=n},nRFJB:function(o,n){return o+n},fMafu:function(o,n){return o-n},UjUdg:function(o,n){return o+n},SCfCW:function(o,n){return o<n},iARFl:function(o,n){return o>>n},hlmCr:function(o,n){return o===n},WsxSp:t(816),bplAx:function(o,n){return o<n},YFEBO:function(o,n){return o>>n},gmUms:function(o,n){return o>>n},MqRuN:function(o,n){return o|n},invqv:function(o,n){return o&n},FyZmn:function(o,n){return o>>n},RvqjH:function(o,n){return o|n},DJlVV:function(o,n){return o&n},rdKxK:function(o,n){return o>>n},VSKxj:function(o,n,i){return o(n,i)},aSOtL:function(o,n){return o<n},qVmCv:t(858),lmEAU:t(1252),qZvfJ:function(o,n){return o<n},AdwpP:function(o,n){return o<<n},WbrPb:function(o,n){return o>=n},hxnwl:function(o,n,i){return o(n,i)},bgIvk:function(o,n){return o|n},dfeeK:function(o,n,i){return o(n,i)},YcXAX:function(o,n){return o===n},LcZaH:function(o,n){return o===n},YAkrL:function(o,n){return o(n)},PVteq:function(o,n){return o&n},kJsNi:"AByCR",zaZKF:function(o,n){return o(n)},nLoEs:function(o,n){return o<<n},xNgST:function(o,n){return o&n},KWgwD:function(o,n){return o&n},LUCal:t(1905),iEgZD:function(o,n){return o(n)},EStSm:function(o,n){return o&n},XGmNk:function(o,n){return o(n)},gbedf:function(o,n){return o&n},DZwOk:function(o,n){return o&n},nJCae:function(o,n){return o(n)},PYYgB:function(o,n){return o&n},TEQth:t(925),fCVzp:function(o,n){return o<<n},qbVup:function(o,n){return o&n},AfcpG:function(o,n){return o<<n},BKKCl:function(o,n){return o&n},XgJfV:function(o,n){return o&n},YizOk:function(o,n){return o|n},JmEMq:function(o,n){return o|n},PTZAz:t(1132),ahfhe:function(o,n){return o>>>n},xIRpG:function(o,n){return o>>>n},aesco:function(o,n){return o<<n},QYnWu:function(o,n){return o>>>n},wUKiF:function(o,n){return o===n},OywSN:function(o,n){return o<n},AtQIW:function(o,n){return o<n},jkgRg:function(o,n){return o<n},snUCs:function(o,n){return o<n},fVRbt:function(o,n){return o<n},KoPQx:function(o,n){return o<n},zYqSR:function(o,n){return o!==n},NHRBp:function(o,n){return o|n},NBsFX:function(o,n){return o&n},QsHhl:function(o,n){return o+n},QOsEz:function(o,n){return o!==n},UNPxK:function(o,n){return o|n},jJeAF:function(o,n){return o&n},MvDNl:function(o,n){return o!==n},EoXct:function(o,n){return o|n},jfqVz:function(o,n){return o>>>n},TigRP:function(o,n){return o&n},PLUHg:function(o,n){return o>>>n},ngoLL:function(o,n){return o|n},dvvij:function(o,n){return o&n},cEJCu:function(o,n){return o!==n},gvlvq:function(o,n){return o>>>n},WZShx:function(o,n){return o>>>n},NdcvH:function(o,n){return o&n},cJuxA:function(o,n){return o>>>n},yZqQO:function(o,n){return o|n},pQlsO:function(o,n){return o|n},YwAet:function(o,n){return o!==n},yKeLc:t(1725),NayiF:function(o,n){return o<<n},zyhFN:function(o,n){return o<<n},CGgLn:function(o,n){return o<<n},hGzMq:function(o,n){return o|n},RJAhT:function(o,n){return o<<n},YMbEs:function(o,n){return o<<n},qCmvs:function(o,n){return o|n},yWOUb:function(o,n){return o|n},viecp:function(o,n){return o<<n},fmYlw:function(o,n){return o|n},KrCpP:function(o,n){return o<<n},rHeur:function(o,n){return o===n},HSUGo:function(o,n){return o|n},jgzFz:function(o,n){return o<<n},vOJxe:function(o,n){return o|n},PRRJc:function(o,n){return o<<n},zLqvl:function(o,n){return o<<n},lRsKm:function(o,n){return o===n},GAOpH:t(1353),VJNRP:function(o,n){return o&n},kWcxp:function(o,n){return o>>>n},DCFwq:function(o,n){return o&n},hkwHF:function(o,n){return o>>>n},TuHTS:function(o,n){return o&n},nYoNr:function(o,n){return o&n},iiNzX:function(o,n){return o>>>n},SmbMI:function(o,n){return o>=n},qFYIp:function(o,n){return o+n},ZtwWU:function(o,n){return o%n},wqyDA:function(o,n){return o|n},gZFHV:function(o,n){return o/n},jsRAH:function(o,n){return o+n},DRfvY:function(o,n){return o>>>n},wVRWI:function(o,n){return o===n},oLbRI:function(o,n){return o!==n},YIrZu:t(1578),nNlWD:t(1133),wRqpd:function(o,n){return o>>>n},gefnQ:function(o,n){return o>>>n},faChm:function(o,n){return o&n},HFWkh:function(o,n){return o&n},vMRXw:function(o,n){return o&n},bjwXY:function(o,n){return o+n},hRqfw:function(o,n){return o>>>n},HsGUu:function(o,n){return o+n},Myxcz:function(o,n){return o|n},Ppzkz:function(o,n){return o<<n},BXXhE:function(o,n){return o!==n},NJXGS:function(o,n){return o===n},AxCRV:function(o,n){return o===n},GdeAR:"online",nTEbt:t(1241),LkWdT:"pagehide",pGQiq:t(1515),CVGdS:t(1279),nyIds:function(o,n){return o&n},CDscM:function(o,n){return o&n},aFreT:function(o,n){return o>>>n},ZoGQE:function(o,n){return o&n},XYeCK:function(o,n){return o&n},lxfBd:function(o,n){return o&n},dBfwr:function(o,n){return o>>>n},piUPN:"3|2|5|1|4|0",YRYvd:t(1427)+t(1621),dJQvH:t(603)+t(1085),irENR:t(1006)+"OR",uuiFm:t(1197)+"IES_ERROR",bskuA:t(1250),Ldvik:function(o,n){return o!==n},jgeCk:t(1588),PzrEX:t(822),PviYu:"4|1|5|0|"+t(1263),CTECQ:t(2031)+"2",KJVpn:"hvofY",lgHJz:t(845),JXbSP:function(o,n){return o!==n},veLde:"QTRCz",TCCvu:function(o,n){return o|n},ykoEv:function(o,n){return o<<n},OwToR:function(o,n){return o>n},AMaTH:function(o,n){return o>>n},TNoHY:t(971),xLGOh:function(o,n){return o===n},BUPaC:t(775),iyRJQ:function(o,n){return o!==n},XwUga:"mvgIk",wVlEK:function(o,n,i){return o(n,i)},vlFwr:function(o,n){return o!==n},pYfOl:t(1181),GQBeY:t(913),PoAJY:function(o,n){return o-n},gFYTP:function(o,n){return o==n},WbUYd:function(o,n){return o>n},bgMcd:function(o,n){return o instanceof n},rLVKy:t(921)+"d error.",DfuHs:function(o,n){return o*n},Bjmma:function(o,n){return o>n},QgiTB:function(o,n){return o===n},WmDzX:t(685),koIug:function(o,n){return o<n},lbXco:function(o,n){return o>>>n},xoAJr:t(1838),bubhs:t(1873),MUATB:function(o,n){return o===n},IZvYU:t(1370),dqUFO:function(o,n){return o===n},RxMea:"bVlHI",SSbLZ:t(1253),KFFjN:function(o,n,i){return o(n,i)},fPNhp:t(1492),YaHpq:"bYnrO",MERij:t(1894),glEAQ:t(1117),DHQCh:function(o,n){return o!==n},aPbSN:t(1771),cybty:t(1349),jsnqZ:function(o,n){return o(n)},cEyDp:t(1863),buHyY:t(1765),uBcSp:t(1154),JwnXo:function(o,n){return o===n},RJpqz:t(1266),bkKiG:t(1754),YuisX:function(o,n){return o instanceof n},RrCTb:"kvibC",gfysj:t(2006),LphAZ:t(1221),aMZTE:function(o,n){return o||n},RbXbE:function(o,n){return o||n},wVRth:t(1225),TVwZl:t(1522)+"alled mu"+t(1284)+t(1660)+"process",wfmep:function(o,n){return o(n)},cOmrX:function(o,n){return o<n},pVSFx:function(o,n){return o===n},bsZyn:function(o,n){return o&n},aSGcQ:function(o,n){return o===n},yatPb:function(o,n){return o+n},SyDoF:t(551),zFXBI:function(o,n){return o&n},ekmDW:function(o,n){return o<<n},fNCAi:function(o,n){return o&n},iYubC:function(o,n){return o&n},izoac:function(o,n){return o&n},DdUZR:function(o,n){return o>=n},fiqeB:function(o,n){return o!==n},IQMWB:t(589),IPMdC:function(o,n){return o-n},CWLZf:function(o,n){return o|n},MPNrT:function(o,n){return o|n},GpWBs:function(o,n){return o&n},xhoVK:function(o,n){return o<<n},xlaAy:function(o,n){return o&n},XiHlU:function(o,n){return o+n},NNdMq:function(o,n){return o!==n},yJVLr:t(1074),Rhslo:t(2e3),LWnoC:function(o,n){return o<n},HLPgW:function(o,n){return o|n},ORRvo:function(o,n){return o>>n},cPfcU:function(o,n){return o&n},ofAgz:function(o,n){return o>>n},VrhnB:function(o,n){return o|n},rilYF:function(o,n){return o&n},CqiNG:function(o,n){return o+n},VFjtV:function(o,n){return o&n},pzYvy:function(o,n){return o|n},vIasE:function(o,n){return o|n},iWCtq:function(o,n){return o&n},LZBSc:function(o,n){return o|n},vlVuS:function(o,n){return o>>n},WrFXh:function(o,n){return o|n},sChRJ:function(o,n){return o&n},jFxxj:function(o,n){return o>>n},FyZei:function(o,n){return o-n},LQcEa:function(o,n){return o(n)},IxwrL:function(o,n,i,d){return o(n,i,d)},wlOeo:function(o,n){return o!=n},OWNJF:t(1663),IzwPB:"string",mlGMr:t(849)+t(1377),VpRdV:t(739),uojuQ:"netaK",vHYSA:"text/plain;charset=utf-8",JWuRC:"boe",uguOr:t(950),EbYim:"KZgUs",nUgTJ:t(1201)+t(1166),zIgwl:t(751),eBhZf:t(1805)+t(468),TDynb:t(1548),UvskQ:t(1296)+t(1461)+t(1521)+"P",OCBWR:function(o,n){return o===n},ctJoS:t(718),ZCfEs:t(1691)+t(1426),DHdlU:t(854),PgDfO:function(o,n,i){return o(n,i)},bWmwi:t(1593),tUDgx:"aEEFe",xPKjy:function(o){return o()},xJmzm:function(o,n,i,d){return o(n,i,d)},KVSwu:function(o,n){return o===n},YNzfq:t(1543),qMKyB:t(1079),BbRWZ:function(o,n){return o||n},QgXVS:function(o,n){return o||n},mjuhM:function(o,n){return o||n},oJUWX:function(o,n){return o||n},vwBvX:function(o,n){return o!==n},WVbQA:t(1941),LDEcx:"fbgdi",KcXxG:function(o,n){return o(n)},DUjHd:"FQeQK",BQCiK:t(1536),AomGT:function(o,n){return o||n},raBmx:function(o,n){return o===n},pnjOy:function(o,n){return o|n},kMIpj:function(o,n){return o<<n},JvdLl:function(o,n){return o<<n},LwxcZ:t(1082),BZHmj:function(o,n){return o||n},iEgXO:function(o,n){return o!=n},pUzdT:function(o,n){return o||n},AGmpZ:t(853),nZRFP:t(1091)+"id",gGMjH:function(o,n,i){return o(n,i)},gpVZF:function(o,n){return o(n)},EiLPr:t(637),UOkRt:"x_fronti"+t(610),VZUga:function(o,n,i,d){return o(n,i,d)},VyDNV:t(1488)+t(1556)+"k",zTBpw:function(o,n,i){return o(n,i)},ffMGm:t(616),hkOWW:t(1019),fihaD:function(o,n){return o&&n},AZAEg:t(1375),Ybvfw:t(1272),HMUkk:t(1992),WBuym:t(1757),zhDTD:function(o){return o()},QpVng:t(1187),tQqGQ:function(o,n){return o instanceof n},aqyPZ:t(459),MmASF:t(1831)+"e",QEdvi:t(465),HVULq:function(o,n){return o(n)},rPXJP:function(o,n){return o(n)},aNGtM:function(o,n){return o&n},PcQkm:function(o,n){return o|n},olOnk:function(o,n){return o+n},uZKgb:function(o,n){return o+n},fpRLR:" > ",YrWKB:t(1307)+"too large",hBBVc:function(o,n){return o>=n},gzFPz:function(o,n){return o&n},qiVsb:function(o,n){return o+n},lCBCY:function(o,n){return o+n},ylbSu:function(o,n){return o<n},hTYKi:function(o,n){return o<<n},iISNf:function(o,n){return o+n},MSAWG:function(o,n){return o!==n},pEqQK:t(1222),GtGos:"3|2|4|0|1",lVjXn:function(o,n){return o<n},UoQvA:function(o,n,i,d){return o(n,i,d)},WDsTn:function(o,n){return o|n},BJrcc:function(o,n){return o<<n},NHSWy:function(o,n){return o+n},lEkkn:function(o,n){return o+n},brpwg:function(o,n){return o<<n},KoZoe:function(o,n){return o+n},CfmEz:function(o,n){return o|n},lfjUE:function(o,n){return o<<n},cKXNw:function(o,n){return o+n},guevP:function(o,n){return o+n},jUXRZ:t(926),AwPuZ:function(o,n){return o&n},Colat:function(o,n){return o+n},zTLCA:function(o,n){return o&n},nKJGE:function(o,n){return o>n},mwEcr:function(o,n){return o*n},aEyNu:function(o,n){return o===n},CKjrd:"OwcZl",OnWob:function(o,n){return o+n},bGxNr:function(o,n){return o>>>n},yjyYQ:function(o,n){return o>>>n},lBpKN:function(o,n){return o|n},YwpBr:function(o,n){return o>>>n},LiiMt:function(o,n){return o|n},XZEde:function(o,n){return o|n},oiyVX:function(o,n){return o<<n},LsSjL:function(o,n){return o<<n},yusHe:function(o,n){return o&n},cpJVF:function(o,n,i,d){return o(n,i,d)},Slkjl:function(o,n){return o|n},LulNM:function(o,n){return o<n},MJwrU:function(o,n){return o|n},gUIlN:function(o,n){return o+n},ABHtn:function(o,n){return o!==n},SyIsn:t(1893)+"|1|9|0|7"+t(1404),jczFH:t(1944),yvcka:function(o,n,i,d){return o(n,i,d)},vcdiL:"curvalue",JPttx:t(1935),qYvMc:t(2025),yOVed:t(1490)+t(536),QjShQ:function(o,n){return o>>>n},jvfIV:function(o,n){return o&n},AoKGZ:function(o,n){return o&n},QzIUI:t(473),mLAul:function(o,n){return o<n},cDbcb:function(o,n,i){return o(n,i)},irnWX:t(700)+t(1723),GfCvb:t(1696)+t(1791),dHpWg:"ALL",hlbJA:function(o,n,i,d){return o(n,i,d)},hwLyr:t(1444),RwbjY:function(o,n,i,d){return o(n,i,d)},pspFi:function(o){return o()},IKWzz:function(o,n){return o===n},szxIk:t(761),DXeIR:"HjvDJ",nUZyb:t(613),TdtRk:function(o,n){return o(n)},FBYAM:t(1472)+"r",jaSyZ:function(o,n){return o+n},QZTbe:function(o,n){return o<<n},YhhUC:function(o,n){return o===n},HUpyI:t(1303),rPbtb:function(o){return o()},zFzbD:function(o,n){return o||n},ucwwm:t(1786),UoCqW:"joaBX",wYuCy:function(o,n){return o(n)},ZdLzc:function(o,n){return o!==n},SDvmP:t(928),ewfaO:function(o,n,i,d){return o(n,i,d)},DeyEF:t(1488)+t(1e3),oNpWJ:function(o,n){return o(n)},GctiA:t(1488)+t(803),wOCxm:t(1737)+t(1297)+"e",ibskP:function(o,n){return o(n)},kyCxU:function(o,n,i){return o(n,i)},qGcQn:"x-msg-cu"+t(697)+"ue",OLIjs:t(1682),yNyeS:function(o,n){return o!==n},QLInr:t(1983),IXJLx:function(o,n,i){return o(n,i)},RImct:t(1989),cbSzp:function(o,n){return o===n},HvGbl:function(o,n){return o===n},JAuMb:function(o){return o()},Rdefp:function(o){return o()},ESIhN:function(o,n){return o===n},qRdNf:t(1792),JGbAU:"KUdth",cyvuc:function(o){return o()},HIlwK:function(o){return o()},LNxEB:function(o){return o()},uGeiD:function(o,n){return o===n},NLArC:function(o,n){return o===n},fzdeH:"always",eXuTj:t(1092),UkKBU:function(o,n){return o===n},qVRzx:t(944),izgZx:t(581)+t(766)+"s",AzRxU:t(1736),GeNIT:function(o,n,i){return o(n,i)},WoJiJ:function(o,n,i,d){return o(n,i,d)},maVga:function(o,n,i){return o(n,i)},eMrBP:function(o,n){return o(n)},vYcjG:function(o,n,i){return o(n,i)},rJueo:t(1643),JhgJe:t(1701),giVCJ:function(o,n,i){return o(n,i)},lAeEn:function(o,n,i,d){return o(n,i,d)},QwoFf:function(o,n,i){return o(n,i)},IoTmQ:"arraybuffer",rJLFs:t(857),ssiOm:function(o,n){return o/n},xAmku:t(1478),wFRig:function(o,n){return o==n},nDFzZ:"please provide v"+t(1814),pxbls:function(o,n){return o(n)},hklnI:function(o,n){return o===n},EorjD:"ADyjs",fpqFb:t(849)+t(1377)+t(951)+t(1726),zomFV:function(o,n,i,d){return o(n,i,d)},NkVaR:t(892),HSGps:"reconnect",RWAvF:t(882),mlUME:function(o,n){return o!==n},xyVKx:t(1488)+t(1013)+"ck",KjTzR:"x_fronti"+t(1032)+t(968),TluRv:function(o,n){return o!==n},YXxoS:t(687),bBWOM:function(o,n){return o==n},nWDAf:t(1325),CZQae:t(1714),rXhzg:function(o,n){return o===n},GEOBp:"TjVXc",svDDk:t(885),DdanS:t(709),EjVaE:"ttwid",zTSCz:"device_id",TlSNL:t(1888)+"rovide b"+t(1011)+t(868)+t(1087),kMtKK:t(1687),crHdT:function(o,n,i){return o(n,i)},HxXaW:"fws_1.0.0",Jhvac:t(1724),FYLBz:function(o,n,i){return o(n,i)},FvcmE:function(o,n){return o(n)},UEALr:function(o,n){return o!==n},KKCiA:t(1374),jEwDa:function(o,n){return o(n)},spNGe:t(618)+">",uhcdr:function(o,n){return o-n},uSntj:function(o,n){return o!==n},hggsz:t(1400),zJaZy:t(1826),VQFUp:function(o,n,i){return o(n,i)},KRccx:function(o,n,i){return o(n,i)},sGKWA:function(o,n){return o!==n},MJeMl:t(554),JCjfc:t(1453)+t(847)+t(658)+"ting ser"+t(1879),xXIKm:t(1096),LjVbw:function(o,n){return o===n},wrvcM:function(o,n){return o===n},JdKho:"store",cRKnS:function(o,n){return o!==n},wlRtP:"FTLbI",Uofpf:t(1637)+t(1065)+"onnecting",xoGCF:function(o,n){return o(n)},KPJMF:t(1324)+"0",KWuCo:t(842)+"4",BGGuT:function(o,n){return o+n},mfUiH:function(o,n){return o|n},gNLnW:t(746),TKgkA:function(o,n,i){return o(n,i)},vZXsp:"ZDAIH",izlVs:t(1973),NzaoA:t(916),XSLNM:function(o,n){return o+n},exlpU:function(o,n){return o+n},Dghfk:function(o,n){return o!==n},PQCHi:t(1862),NlYid:function(o,n){return o==n},AkXkS:function(o,n){return o(n)},WiBEj:t(1789),XOCRq:function(o,n){return o===n},dlmBU:t(802),evVnj:function(o,n){return o===n},qbBBb:"VSFMn",hfeZM:function(o,n){return o===n},NYLPy:function(o,n){return o===n},cmsmq:function(o,n){return o===n},aWGsr:function(o,n){return o===n},Pvpjk:function(o,n,i,d){return o(n,i,d)},xwNhW:function(o,n){return o===n},pyvCk:"Bvvyw",MGpnd:t(647),KwzeU:function(o,n){return o==n},VQrCa:t(1888)+t(1345)+t(514)+"ata, dat"+t(1467)+t(1346)+t(827)+t(1018)+t(497),stcFP:t(1618),sEplA:function(o,n){return o!=n},JdtoS:function(o,n){return o instanceof n},hsPjM:function(o,n){return o instanceof n},omUdm:function(o,n){return o(n)},EAnPN:t(1888)+t(1345)+t(1230)+"ervice",AiTir:function(o,n){return o instanceof n},kkQUD:function(o,n){return o instanceof n},BsZUP:function(o,n){return o(n)},lTYqs:function(o,n){return o===n},vPVmv:function(o,n){return o<n},wjpoM:t(1821),KJsFZ:function(o,n){return o!==n},QsFYV:t(2021),bUGQl:t(607),mjLLq:function(o,n){return o==n},nSYwr:t(1273)+t(1962)+t(1800),LGfGV:"4|2|3|1|0",SMzzl:function(o,n){return o<<n},znSzc:function(o,n){return o&n},IJYaj:function(o,n){return o&n},YmFfN:function(o,n){return o<<n},iGKXQ:t(977),RiWre:function(o,n){return o(n)},iVHnZ:function(o,n){return o===n},EnorX:t(1620),RSIfO:"\0\0\0\0\0\0\0\0",jLrxG:function(o,n){return o*n},qlodf:function(o,n){return o!=n},aQtYd:function(o,n){return o===n},PDrgu:t(484),tpzPd:function(o,n){return o!=n},rlMaz:function(o,n){return o!=n},ekPaS:function(o,n){return o!=n},sOSIP:"Object",trsgB:t(1344)+t(541)+t(517)+"pe",gciKh:function(o,n){return o!=n},YgTNV:function(o,n){return o!=n},NzjWC:function(o,n){return o!=n},hrwfp:t(1942)+t(901)+t(1468),WCVjP:function(o,n){return o===n},yqwfb:function(o,n){return o!=n}};St.r(be),St.d(be,{FWS:()=>Nh,CustomErrorEvent:()=>u0,createCloseEvent:()=>rt,ReconnectEvent:()=>f0,createErrorEvent:()=>Ze,decodedFrame:()=>Fn,createOpenEvent:()=>m0,CustomCloseEvent:()=>l0,createReconnectEvent:()=>Do,FrontierMessageEvent:()=>h0,encodeFrame:()=>He,createMessageEvent:()=>g0,OpenEvent:()=>p0,ErrorCode:()=>jt,Event:()=>qn,MessageEvent:()=>x0});let r="";function s(o=""){let n=t,i="02",d=""+Date[n(640)](),l=r||(r=x(o)),g=Math.random().toString(16)[n(1503)](-6);return e[n(498)](e[n(498)](e[n(1946)](i,d),l),g)}function a(){let o=t;return e.AEErt(1e4*Date[o(640)](),Math[o(1957)](e[o(1282)](1e4,Math[o(755)]())))}function c(o){let n=t;return(e.qZnxk(Array,8).join("0")+e[n(1614)](parseInt,o,10).toString(2)).slice(-8)}function f(o){let n=t;return(e[n(1057)](Array,4)[n(1041)]("0")+parseInt(o,2)[n(832)](16)).slice(-4)}function u(o){let n=t,i=o[n(1232)](/\./)[n(520)](g=>c(g)),d=[];return d[0]=e[n(1816)](f,e.AEErt(i[0],i[1])),d[1]=e[n(1816)](f,e[n(498)](i[2],i[3])),[e[n(1949)],e[n(1949)],e[n(1949)],e[n(1949)],e[n(1949)],e[n(959)],d[0],d[1]][n(1041)]("")}function x(o){let n=t,i=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(1776)](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]))/.test(o);return i?e.cNBLv(u,o):d?h(o):e[n(1410)]}function h(o){let n=t,i="",d=[],l=0,g=0,y=!0,E=e[n(1949)];if(e[n(893)](o[n(1806)]("::"),-1)){let p=o[n(1232)]("::");for(let T=0;e[n(1912)](T,p[n(1955)]);T++){let B=p[T];if(e[n(1332)](B[n(1806)](":"),0)){let q=B[n(1232)](":");y&&(l=q[n(1955)]),g+=q.length;for(let $=0;e[n(1355)]($,q[n(1955)]);$++)if(e[n(1922)](4,q[$][n(1955)])){let Y=E.substring(0,4-q[$][n(1955)]),it=Y.concat(q[$]);d[n(793)](it)}else d.push(q[$]);y=!1}else if(e[n(1471)](e[n(1647)],e.CPEuP)){if(e[n(2034)](4,B[n(1955)])){let q=E[n(896)+"g"](0,4-B[n(1955)]),$=q[n(663)](B);d[n(793)]($)}else d[n(793)](B);y&&(l+=1),g+=1,y=!1}else _0x2ae628[n(630)](_0x2381ed)}let P="";for(let T=0;e.YuCOh(T,e[n(776)](8,g));T++)P=P.concat(E);for(let T=0;T<d.length;T++)e[n(1389)](T,l)?e[n(1335)]===e[n(1335)]?(i=i[n(663)](P),i=i[n(663)](d[T])):this[n(898)+n(1213)]():i=i[n(663)](d[T]);return i}if(e.opLhl!==n(1573)){let p=o[n(1232)](":");for(let P=0;e[n(1912)](P,p[n(1955)]);P++){let T=p[P];if(e[n(1922)](4,p[P][n(1955)]))if(e[n(779)](e[n(1664)],e[n(572)])){let B=E[n(896)+"g"](0,e.zGbgm(4,p[P][n(1955)])),q=B.concat(T);i=i.concat(q)}else{let B=this[n(1113)][n(1475)](this[n(546)]);return _0x285889[n(1196)](e[n(1308)](B,"{}"))[_0x57dbae]}else i=i.concat(T)}return i}else this["maxLossC"+n(652)]=_0x16af28,this.count=0}function m(o,n){let i=t,d=o.key;e[i(779)](void 0,d)&&(e.PtBhH(Z,n,10),e[i(762)](Oe,n,d));let l=o[i(2033)];e[i(865)](void 0,l)&&(e[i(830)](Z,n,18),Oe(n,l))}function v(o){let n=t,i={};e:for(;!e[n(1727)](N,o);)if(e.ghnIe(n(937),e[n(1020)]))e[n(1397)](_0x4d4bb3,_0x65d85a,32),e[n(1200)](_0x5bb51e,_0x44c14d,_0xa7277f(_0x2ba7aa));else{let d=_e(o);switch(e[n(614)](d,3)){case 0:break e;case 1:i[n(657)]=we(o,e[n(1067)](_e,o));break;case 2:i[n(2033)]=e.iIEUi(we,o,e[n(1926)](_e,o));break;default:e.PtBhH(D,o,7&d)}}if(i.key===void 0)throw new Error(e[n(1512)]);if(e.gAuhR(void 0,i[n(2033)]))throw new Error(n(1632)+n(731)+n(943)+n(2033));return i}function A(o){let n=t,i=e.fwKcT(C);return e[n(1413)](_,o,i),e[n(1727)](z,i)}function _(o,n){let i=t,d={wtDrg:e.qRzNr,UcvkJ:e[i(1861)]},l=o[i(726)];e[i(1829)](void 0,l)&&(Z(n,8),ge(n,l));let g=o[i(1975)];e[i(1951)](void 0,g)&&(Z(n,16),ge(n,g));let y=o[i(1944)];e[i(778)](void 0,y)&&(i(1747)===e[i(1990)]?(this[i(2016)+i(1980)]?.[i(1742)](),this[i(1150)](d[i(1590)],d[i(1674)]),this["_pingLos"+i(1980)]?.[i(1872)+i(1889)+"nt"]()?this["_handleR"+i(1962)]():this[i(1477)]()):(e.iIEUi(Z,n,24),ge(n,O(y))));let E=o[i(1762)];e[i(946)](void 0,E)&&(e[i(1622)](Z,n,32),e[i(1420)](ge,n,O(E)));let p=o[i(996)];if(e[i(865)](void 0,p))for(let Ct of p){e[i(496)](Z,n,42);let Wt=e[i(1979)](C);e[i(1304)](m,Ct,Wt),e.tThvT(Z,n,Wt.limit),nt(n,Wt),L(Wt)}let P=o.payloadEncoding;e[i(734)](void 0,P)&&(e[i(762)](Z,n,50),e.EHptg(Oe,n,P));let T=o[i(1089)+i(717)];T!==void 0&&(e[i(1614)](Z,n,58),Oe(n,T));let B=o[i(949)];B!==void 0&&(Z(n,66),e[i(830)](Z,n,B[i(1955)]),fe(n,B));let q=o.LogIDNew;if(e[i(1951)](void 0,q)){if(e[i(730)]==="XHSGR")return _0x32d83c(_0x251984);e[i(496)](Z,n,74),e[i(1510)](Oe,n,q)}let $=o["serverTi"+i(918)];e[i(1391)](void 0,$)&&(Z(n,82),e[i(1510)](Oe,n,$));let Y=o[i(1735)];Y!==void 0&&(Z(n,90),e.HdJBc(Oe,n,Y));let it=o[i(1775)+"e"];e[i(1807)](void 0,it)&&(Z(n,96),e[i(1614)](ge,n,O(it)))}function b(o){let n=t;if(e[n(1640)](e[n(1670)],e.mKonY)){let i=e[n(1035)][n(1232)]("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(953)][n(1920)+n(2007)](e[n(576)],this[n(1099)]);continue;case"1":this[n(953)][n(1920)+n(2007)](n(1396),this[n(1777)]);continue;case"2":if(!this[n(953)])return;continue;case"3":this[n(953)][n(1920)+n(2007)](n(1554),this._onMessage);continue;case"4":this[n(953)][n(1920)+"Listener"](e[n(1667)],this._onOpen);continue}break}}else return e[n(1219)](S,F(o))}function S(o){let n=t,i={UuflJ:function(l,g,y){return e[K(837)](l,g,y)}},d={};e:for(;!e[n(620)](N,o);)if(e[n(1657)](e[n(1880)],n(1881)))zpipKr[n(874)](_0x46c072,_0x47fb64,50),zpipKr[n(874)](_0x45355e,_0x16cdcb,_0x56300d);else{let l=e[n(1067)](_e,o);switch(l>>>3){case 0:break e;case 1:d[n(726)]=e[n(837)](zn,o,!0);break;case 2:d.LogID=e[n(1397)](zn,o,!0);break;case 3:d[n(1944)]=e[n(620)](_e,o);break;case 4:d.method=e[n(1727)](_e,o);break;case 5:{let g=e.vkqvu(I,o);(d.headers||(d[n(996)]=[]))[n(793)](e.Gfpph(v,o)),o[n(606)]=g;break}case 6:d[n(656)+n(499)]=we(o,e[n(510)](_e,o));break;case 7:d[n(1089)+n(717)]=e[n(1397)](we,o,e.wAzWF(_e,o));break;case 8:d[n(949)]=e[n(1967)](se,o,_e(o));break;case 9:d[n(1430)]=we(o,e.sjQvn(_e,o));break;case 10:d.serverTiming=we(o,e[n(1882)](_e,o));break;case 11:d[n(1735)]=e.PtBhH(we,o,_e(o));break;case 12:d[n(1775)+"e"]=e[n(510)](_e,o);break;default:e.PTsPF(D,o,7&l)}}if(e[n(1394)](void 0,d.SeqID))throw new Error(e[n(492)]);if(d[n(1975)]===void 0)throw new Error(n(1632)+n(731)+n(943)+"LogID");if(d[n(1944)]===void 0)throw new Error(e[n(1417)]);if(d[n(1762)]===void 0)throw new Error(e[n(1170)]);return d}function I(o){let n=t,i=e[n(1027)](_e,o),d=o[n(606)];return o[n(606)]=e.FylQz(o.offset,i),d}function D(o,n){let i=t;switch(n){case 0:for(;e[i(864)](128,Ae(o)););break;case 2:e[i(1967)](k,o,e[i(620)](_e,o));break;case 5:e[i(553)](k,o,4);break;case 1:k(o,8);break;default:throw new Error(e.kExub(e[i(526)],n))}}function O(o){let n=t;return o|=0,{low:o,high:e[n(1558)](o,31),unsigned:e[n(1841)](o,0)}}let w=[];function C(){let o=t,n=w[o(1900)]();return n?(n.offset=n[o(606)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function L(o){let n=t;e[n(1829)](e[n(675)],e.sFMhs)?w[n(793)](o):this.on(_0x78d906,_0x3a7caf)}function F(o){let n=t,i={zAneY:e[n(1078)]};if(e[n(734)](e[n(741)],n(578)))return{bytes:o,offset:0,limit:o.length};this[n(1150)](i[n(1395)],_0x384e82),this[n(772)+"e"]&&this[n(772)+"e"](_0x2bc707)}function z(o){let n=t,i=o[n(1683)],d=o.limit;return i[n(1955)]===d?i:i.subarray(0,d)}function k(o,n){let i=t;if(e.UhmrT(e.XzeMQ(o.offset,n),o[i(606)]))throw new Error(e.OJovP);o.offset+=n}function N(o){let n=t;return e[n(1841)](o[n(485)],o[n(606)])}function U(o,n){let i=t,d=o[i(1683)],l=o.offset,g=o[i(606)],y=l+n;if(e[i(792)](y,d[i(1955)])){let E=new Uint8Array(e[i(834)](2,y));E[i(472)](d),o[i(1683)]=E}return o[i(485)]=y,e[i(1002)](y,g)&&(o[i(606)]=y),l}function W(o,n){let i=t,d=o[i(485)];if(e[i(873)](e.YMVfV(d,n),o.limit))throw new Error(e[i(823)]);return o[i(485)]+=n,d}function se(o,n){let i=t,d={ALMSM:function(l,g){return e[K(1071)](l,g)},ZYwjn:function(l,g){return e[K(614)](l,g)},VuaAf:function(l,g){return l&g},jidEX:function(l,g){return l&g},uwnJp:function(l,g){return e[K(1071)](l,g)}};if(e[i(714)](e[i(1934)],e[i(1934)])){let l=e[i(830)](W,o,n);return o[i(1683)].subarray(l,e[i(1518)](l,n))}else return _0x7a2766[i(532)+i(1809)](255&this[i(1654)],d[i(1675)](this[i(1654)],8)&255,d.ALMSM(this[i(1654)],16)&255,d[i(1432)](this[i(1654)],24),d[i(1648)](255,this[i(1890)]),d.VuaAf(d[i(1675)](this[i(1890)],8),255),d.jidEX(d[i(467)](this[i(1890)],16),255),d[i(1432)](this[i(1890)],24))}function fe(o,n){let i=t,d=e[i(1612)](U,o,n[i(1955)]);o[i(1683)][i(472)](n,d)}function we(o,n){let i=t,d={MFGlM:function(P,T){return e[K(873)](P,T)},bvqOG:function(P,T){return P+T},DcPKZ:e[i(655)]},l=W(o,n),g=String[i(532)+i(1809)],y=o[i(1683)],E="\uFFFD",p="";for(let P=0;e[i(1653)](P,n);P++)if(e[i(778)](i(989),e[i(1794)]))this[i(1113)]?.[i(1112)](_0x1e9b73[i(1091)+"id"]);else{let T=y[P+l],B,q,$,Y;if(e[i(975)](128&T,0))p+=e[i(1057)](g,T);else if(e[i(1143)](e[i(864)](224,T),192))if(e[i(498)](P,1)>=n)p+=E;else if(B=y[e[i(1407)](P,l)+1],e[i(1240)](e[i(1101)](192,B),128))p+=E;else if(Y=e[i(1718)](e[i(1256)](e[i(1101)](31,T),6),e[i(864)](63,B)),e[i(1936)](Y,128))p+=E;else if(e[i(621)]===e[i(621)])p+=g(Y),P++;else{if(RgehRH.MFGlM(RgehRH[i(705)](_0x384484[i(485)],_0x442232),_0xfcbd7e.limit))throw new _0x16a79b(RgehRH[i(939)]);_0x45adb5[i(485)]+=_0x139686}else if(e[i(768)](e[i(1459)](240,T),224))e.XzeMQ(P,2)>=n?p+=E:e.EQaAL(e[i(623)],e[i(623)])?this[i(1150)](e[i(466)],e.GyemQ(_0x3eaade,e.hJnvZ,{..._0x467478})):(B=y[e.XzeMQ(P+l,1)],q=y[e.Vmbqd(P+l,2)],e[i(1533)](e[i(1963)](B,e[i(1256)](q,8)),49344)!==32896?p+=E:(Y=e[i(1963)](e[i(1097)](15,T)<<12,(63&B)<<6)|e[i(625)](63,q),e[i(1653)](Y,2048)||e[i(1841)](Y,55296)&&e.rGOov(Y,57343)?p+=E:(p+=e.BBjcj(g,Y),P+=2)));else if((248&T)==240)if(e[i(1841)](P+3,n))p+=E;else if(e[i(975)](e[i(1665)],e.JpRkb)){if(e[i(1290)](_0x427e00,_0x584794))return new _0x23cc0d(_0x30e37b,_0x4ac561);if((_0x38b551||_0x342b97)&&e[i(1774)](e[i(1707)],typeof _0xb98ad8))return new _0x1a6a68(_0x3fa33f,_0x16aced);if(e[i(1290)](_0x3ecf67,_0x1cd66b)&&e[i(1774)](e[i(1707)],typeof _0x5c5aff))return new _0x3dbf8a(_0x3deee7,_0x40cc45);throw new _0x1480bc(e[i(1836)])}else B=y[e[i(1946)](e[i(917)](P,l),1)],q=y[e[i(759)](P+l,2)],$=y[e[i(1639)](e[i(1801)](P,l),3)],e.RyDiP(e[i(864)](e[i(1718)](e.DLrob(B,e[i(1940)](q,8)),$<<16),12632256),8421504)?p+=E:(Y=e[i(1963)](e[i(1681)](7,T)<<18|e.Rwuqv(63,B)<<12,e[i(1533)](63,q)<<6)|e.RBRoQ(63,$),e[i(561)](Y,65536)||e[i(545)](Y,1114111)?p+=E:(Y-=65536,p+=e.sNHwD(g,e[i(1599)](Y>>10,55296),e.pLmON(1023&Y,56320)),P+=3));else p+=E}return p}function Oe(o,n){let i=t;if(e.yXXkm(e[i(1102)],e[i(664)])){let d=n[i(1955)],l=0;for(let E=0;e.hpyWJ(E,d);E++){let p=n[i(558)+"At"](E);e[i(1841)](p,55296)&&p<=56319&&E+1<d&&(p=e.yigid(e[i(1713)](e[i(991)](p,10),n[i(558)+"At"](++E)),56613888)),l+=e[i(1653)](p,128)?1:p<2048?2:e[i(1630)](p,65536)?3:4}e[i(1420)](Z,o,l);let g=e[i(1883)](U,o,l),y=o.bytes;for(let E=0;E<d;E++)if(e.iwBrG!==e[i(1907)]){let p=n[i(558)+"At"](E);e.mkegE(p,55296)&&e.MMdnb(p,56319)&&e[i(1355)](e[i(970)](E,1),d)&&(p=e[i(1047)](e.UjUdg(e.YVViC(p,10),n[i(558)+"At"](++E)),56613888)),e[i(1870)](p,128)?y[g++]=p:(e[i(1653)](p,2048)?y[g++]=e[i(1210)](e[i(1452)](e[i(1634)](p,6),31),192):e.hlmCr(e[i(1798)],i(816))?(e.bplAx(p,65536)?y[g++]=e[i(588)](e[i(1681)](e[i(1237)](p,12),15),224):(y[g++]=e.DLrob(e[i(1452)](e.gmUms(p,18),7),240),y[g++]=e[i(686)](e[i(1756)](e[i(2035)](p,12),63),128)),y[g++]=e[i(1060)](e[i(957)](e[i(1211)](p,6),63),128)):(_0x40fc41[_0x13bb16++]=e[i(1718)](e[i(1333)](e.mDcMP(_0x4e69d4,18),7),240),_0x498059[_0x185f75++]=e[i(1636)](e[i(486)](_0x497d1a,12),63)|128),y[g++]=63&p|128)}else this[i(953)]&&this[i(953)][i(1330)](_0x49767c),this[i(984)](e.zXzVB,_0x7fa963)}else{let d=_0x1ad16b.charCodeAt(_0x55c3ae);d>=55296&&e.rGOov(d,56319)&&e[i(1464)](e.iJbvm(_0xf158f1,1),_0x2cfac5)&&(d=e[i(776)](e[i(1631)](e[i(585)](d,10),_0x5b22cc[i(558)+"At"](++_0x3a84ad)),56613888)),e[i(568)](d,128)?_0x1ee499[_0x401a81++]=d:(e.NGKFf(d,2048)?_0xcc6008[_0x262e6d++]=e[i(1405)](e[i(875)](e[i(1164)](d,6),31),192):(e[i(1355)](d,65536)?_0x138689[_0x4797f0++]=e[i(1210)](e[i(864)](d>>12,15),224):(_0x3b7305[_0x3cfb62++]=e[i(1963)](e[i(1876)](d>>18,7),240),_0x300f6c[_0x3070d3++]=e[i(588)](e[i(897)](d,12)&63,128)),_0x3ddbb9[_0x205f5b++]=e[i(1226)](e[i(1452)](e[i(1540)](d,6),63),128)),_0x241250[_0x3817f5++]=e.gtRmS(63,d)|128)}}function nt(o,n){let i=t,d=e.VSKxj(U,o,n[i(606)]),l=o[i(1683)],g=n[i(1683)];for(let y=0,E=n.limit;e[i(678)](y,E);y++)l[e.yrqYI(y,d)]=g[y]}function Ae(o){let n=t;if(e[n(1240)](e[n(826)],e[n(763)]))return o[n(1683)][e[n(1510)](W,o,1)];this[n(953)]&&this[n(953)].send(_0x4908c4),this[n(984)](n(1863),_0x37b9e9)}function qt(o,n){let i=t,d=e.LjJph(U,o,1);o[i(1683)][d]=n}function _e(o){let n=t,i=0,d=0,l;do l=e[n(1057)](Ae,o),e.qZvfJ(i,32)&&(d|=e.AdwpP(e.ybzvD(127,l),i)),i+=7;while(e[n(1097)](128,l));return d}function Z(o,n){let i=t;for(n>>>=0;e[i(598)](n,128);)e.hxnwl(qt,o,e[i(1759)](127&n,128)),n>>>=7;e[i(1415)](qt,o,n)}function zn(o,n){let i=t,d={XDnzw:function(p,P){return e[K(1506)](p,P)},aEGwN:function(p,P){return e.DzCdv(p,P)},LZZFG:function(p,P){return e[K(744)](p,P)},iVMBc:function(p,P){return e[K(1946)](p,P)}},l=0,g=0,y=0,E;if(E=e[i(1107)](Ae,o),l=e.RBRoQ(127,E),e.PVteq(128,E))if(e[i(1394)](i(1162),e[i(1147)])){let p=e[i(1397)](_0x14b3ad,_0x897f59,_0x5ad494[i(1955)]);_0x5d7cd1[i(1683)][i(472)](_0x2af532,p)}else E=e[i(582)](Ae,o),l|=e[i(1848)](e[i(1763)](127,E),7),e[i(1055)](128,E)&&(e[i(1366)]!=="hHpjK"?(_0x497fce=_0x48c4da[i(558)+"At"](_0x556006),_0x72526f<128?_0x3c7c31+=1:_0x135f8c<2048?_0x3330a8+=2:d[i(1961)](d[i(680)](64512,_0x536b2f),55296)&&d[i(866)](64512&_0x5d129e[i(558)+"At"](d.iVMBc(_0x1ec73f,1)),56320)?(++_0x2c6915,_0x324551+=4):_0x239ab6+=3):(E=e[i(1090)](Ae,o),l|=e[i(785)](127,E)<<14,128&E&&(E=e[i(1359)](Ae,o),l|=e[i(932)](127,E)<<21,e.DZwOk(128,E)&&(E=e[i(1198)](Ae,o),g=e[i(1681)](127,E),e[i(1868)](128,E)&&(E=Ae(o),g|=e[i(957)](127,E)<<7,128&E&&(i(555)!==e[i(1885)]?(E=e[i(1057)](Ae,o),g|=e[i(1609)](e[i(1348)](127,E),14),e[i(1348)](128,E)&&(E=e[i(1107)](Ae,o),g|=e[i(667)](e.BKKCl(127,E),21),e[i(1333)](128,E)&&(E=e[i(1057)](Ae,o),y=e[i(932)](127,E),e[i(625)](128,E)&&(E=e[i(1781)](Ae,o),y|=e[i(991)](e[i(1030)](127,E),7))))):_0xf48878.log(_0x68fdc8)))))));return{low:e[i(1785)](l,g<<28),high:e[i(1280)](e[i(614)](g,4),e[i(1940)](y,24)),unsigned:n}}function ge(o,n){let i=t;if(e[i(1770)](i(1132),e[i(819)]))this[i(1044)+i(1103)][i(1242)](),this[i(1044)+i(1103)][i(793)](_0x970805);else{let d=e.ahfhe(n[i(1654)],0),l=e.cNNMz(e.xIRpG(n[i(1654)],28)|e[i(813)](n[i(1890)],4),0),g=e[i(1964)](n[i(1890)],24),y=e.gAuhR(0,g)?e[i(1104)](0,l)?e.OywSN(d,16384)?e[i(1215)](d,128)?1:2:d<2097152?3:4:e[i(674)](l,16384)?e[i(1402)](l,128)?5:6:e[i(1382)](l,2097152)?7:8:e[i(1507)](g,128)?9:10,E=U(o,y),p=o[i(1683)];switch(y){case 10:p[e[i(1599)](E,9)]=e[i(875)](g>>>7,1);case 9:p[E+8]=e[i(1398)](9,y)?e[i(1376)](128,g):e[i(1576)](127,g);case 8:p[e[i(1611)](E,7)]=e.QOsEz(8,y)?e[i(835)](e[i(614)](l,21),128):e[i(736)](l>>>21,127);case 7:p[e[i(1407)](E,6)]=e[i(1456)](7,y)?e[i(1193)](e[i(1913)](l,14),128):e[i(1406)](e[i(592)](l,14),127);case 6:p[e[i(1946)](E,5)]=y!==6?l>>>7|128:e[i(1030)](e[i(1913)](l,7),127);case 5:p[e[i(1407)](E,4)]=e[i(1391)](5,y)?e[i(632)](128,l):e[i(994)](127,l);case 4:p[e[i(1407)](E,3)]=e[i(723)](4,y)?d>>>21|128:e.gvlvq(d,21)&127;case 3:p[E+2]=e[i(1770)](3,y)?e[i(1963)](e.WZShx(d,14),128):e[i(1970)](e.cJuxA(d,14),127);case 2:p[e.Vmbqd(E,1)]=y!==2?e.QByOd(e[i(1994)](d,7),128):e[i(1868)](d>>>7,127);case 1:p[E]=e[i(778)](1,y)?e[i(1421)](128,d):e[i(1876)](127,d)}}}function Fn(o){return b(o)}function He(o){return e[t(1067)](A,o)}let o0=65536,Kx=e.RSIfO,Un=e[t(659)](o0,o0),a0=e[t(1010)](Un,Un),c0=a0/2,Ht=String[t(1157)+"e"][t(558)+"At"];class oe{constructor(n,i,d){let l=t;this[l(1662)]=!0,this[l(1654)]=0|n,this[l(1890)]=e[l(594)](0,i),this.unsigned=!!d}static[t(1662)](n){let i=t,d={gDLFV:function(l,g){return l===g},YUnDW:function(l,g){return e[K(1104)](l,g)},pnGQL:function(l,g){return l+g}};return e[i(1153)](e[i(580)],e.yKeLc)?d[i(794)](-1,this[i(1654)])&&this[i(1890)]===-1?_0x56cf8b[i(1069)](0,0,this[i(1999)]):d[i(941)](-1,this[i(1654)])?_0x26c560.fromBits(0,d[i(1298)](this[i(1890)],1),this[i(1999)]):_0x55fb0a[i(1069)](this[i(1654)]+1,this[i(1890)],this[i(1999)]):n&&e[i(1506)](!0,n[i(1662)])}static fromBits(n,i,d){return new oe(n,i,d)}static[t(2028)+"s"](n,i,d){let l=t;return d?oe[l(2028)+"sLE"](n,i):oe[l(2028)+l(856)](n,i)}static[t(2028)+t(1185)](n,i){let d=t;return new oe(e[d(1118)](e[d(588)](e.DLrob(n[0],e.NayiF(n[1],8)),e[d(490)](n[2],16)),e[d(1693)](n[3],24)),e[d(1077)](n[4]|e[d(985)](n[5],8),e[d(1387)](n[6],16))|e[d(985)](n[7],24),i)}static[t(2028)+t(856)](n,i){let d=t;return new oe(e[d(1226)](e.qCmvs(e[d(1601)](n[4]<<24,e[d(1229)](n[5],16)),n[6]<<8),n[7]),e[d(1986)](e[d(1060)](e[d(1748)](n[0],24),e[d(490)](n[1],16))|e[d(667)](n[2],8),n[3]),i)}static fromHash(n){let i=t;return e[i(692)](n,Kx)?d0:new oe(e[i(1680)](e[i(1362)](Ht[i(696)](n,0)|Ht[i(696)](n,1)<<8,e[i(1815)](Ht[i(696)](n,2),16))|Ht[i(696)](n,3)<<24,0),e[i(592)](e[i(1376)](e[i(1819)](e[i(594)](Ht.call(n,4),e.RJAhT(Ht[i(696)](n,5),8)),e[i(1341)](Ht.call(n,6),16)),e.zLqvl(Ht.call(n,7),24)),0),!0)}toHash(){let n=t;return n(1110)!==e[n(2029)]?String[n(532)+n(1809)](e[n(1271)](255,this[n(1654)]),e.kWcxp(this[n(1654)],8)&255,e.DCFwq(e[n(688)](this[n(1654)],16),255),e[n(592)](this.low,24),e[n(625)](255,this[n(1890)]),e[n(1412)](e[n(1680)](this[n(1890)],8),255),e.nYoNr(e[n(783)](this.high,16),255),e[n(457)](this[n(1890)],24)):_0x508db1&&e.lRsKm(!0,_0x380e8f[n(1662)])}static[t(1591)+"er"](n,i=!0){let d=t;if(isNaN(n))return i?Vx:d0;if(i){if(e.mkegE(n,a0))return Jx}else{if(n<=-c0)return Zx;if(e[d(1479)](e.qFYIp(n,1),c0))return $x}return oe[d(1069)](e[d(1526)](n,Un)|0,e.wqyDA(e[d(799)](n,Un),0),i)}[t(1795)](){let n=t;return this[n(1999)]?e[n(1407)](e[n(1282)](e[n(1994)](this[n(1890)],0),Un),this[n(1654)]>>>0):e[n(1666)](e[n(834)](this[n(1890)],Un),e.DRfvY(this.low,0))}[t(1155)](){let n=t;return this.high===0&&e[n(2024)](0,this.low)}add(n){let i=t;if(e.oLbRI(e[i(523)],e[i(1553)])){oe.isLong(n)||(n=oe[i(1591)+"er"](n));let d=e[i(2019)](this[i(1890)],16),l=65535&this[i(1890)],g=e[i(494)](this[i(1654)],16),y=e[i(782)](65535,this.low),E=e[i(494)](n[i(1890)],16),p=e.HFWkh(65535,n[i(1890)]),P=e[i(494)](n[i(1654)],16),T=e.vMRXw(65535,n[i(1654)]),B=0,q=0,$=0,Y=0;return Y+=e[i(1703)](y,T),$+=e[i(909)](Y,16),Y&=65535,$+=g+P,q+=e.iiNzX($,16),$&=65535,q+=e[i(1064)](l,p),B+=e[i(1964)](q,16),q&=65535,B+=e[i(498)](d,E),B&=65535,oe[i(1069)](e.Myxcz(e[i(887)]($,16),Y),e.cmQOr(e[i(667)](B,16),q),this[i(1999)])}else{let d=this[i(1113)][i(1475)](this._prefix),l=_0x14081f[i(1196)](e[i(1308)](d,"{}"));return l[_0x30aea4||_0x457953[this[i(1551)]]]=_0x4e9f38,this[i(1113)][i(1988)](this[i(546)],_0x2a2aa3[i(1180)+"y"](l)),_0x1b963d||_0x62bf1e[this[i(1551)]]}}[t(765)](n){let i=t;return oe[i(1662)](n)||(n=oe[i(1591)+"er"](n)),e[i(670)](this[i(1999)],n[i(1999)])&&e.NJXGS(this[i(1890)]>>>31,1)&&e.EkePu(e[i(1680)](n[i(1890)],31),1)?!1:this[i(1890)]===n.high&&e[i(714)](this[i(1654)],n[i(1654)])}[t(1007)](){let n=t;return e[n(1506)](-1,this[n(1654)])&&e[n(1869)](-1,this[n(1890)])?oe[n(1069)](0,0,this[n(1999)]):e[n(1471)](-1,this.low)?oe[n(1069)](0,e[n(1946)](this.high,1),this[n(1999)]):oe.fromBits(e[n(1611)](this[n(1654)],1),this[n(1890)],this[n(1999)])}[t(2012)](n){let i=t;return n?this[i(1734)+"E"]():this[i(1864)+"E"]()}[t(1734)+"E"](){let n=t;if(e.lRsKm(e[n(732)],e[n(732)])){let i=this.high,d=this[n(1654)];return[e[n(785)](255,d),e[n(1644)](e[n(889)](d,8),255),e[n(500)](e[n(592)](d,16),255),e[n(2019)](d,24),e.PYYgB(255,i),e[n(1101)](e[n(1676)](i,8),255),i>>>16&255,e[n(1473)](i,24)]}else this[n(1668)+"er"]&&_0x5025c0[n(1248)+n(563)+n(567)](e.GdeAR,this[n(624)+n(456)]),this[n(1668)+"er"]&&_0x1056d3[n(1248)+n(563)+n(567)](e[n(1948)],this[n(624)+n(790)]),this[n(1668)+"er"]&&_0x5e4b19["removeEventListe"+n(567)](e[n(1169)],this[n(1626)+n(1635)]),this[n(1668)+"er"]&&_0x55cbe8[n(1248)+"entListe"+n(567)](e[n(662)],this["_handleP"+n(1178)])}[t(1864)+"E"](){let n=t,i=this[n(1890)],d=this[n(1654)];return[e.hRqfw(i,24),e[n(1566)](e[n(1680)](i,16),255),e[n(1036)](e[n(592)](i,8),255),e[n(1508)](255,i),d>>>24,e.nkEoR(e[n(1968)](d,16),255),e.gtRmS(e.iiNzX(d,8),255),e[n(1644)](255,d)]}}let d0=new oe(0,0,!1),Vx=new oe(0,0,!0),$x=oe[t(1069)](-1,2147483647,!1),Jx=oe[t(1069)](-1,-1,!0),Zx=oe.fromBits(0,-2147483648,!1);var jt=(function(o){let n=t,i=e[n(1678)][n(1232)]("|"),d=0;for(;;){switch(i[d++]){case"0":return o;case"1":o[o[n(1691)+"ERROR"]=5004]=n(1691)+n(1426);continue;case"2":o[o[n(1427)+n(1621)]=5002]=e[n(952)];continue;case"3":o[o[e[n(487)]]=5001]=e[n(487)];continue;case"4":o[o[e[n(539)]]=5005]=e[n(539)];continue;case"5":o[o[n(1197)+n(1824)+"R"]=5003]=e[n(1294)];continue}break}})({});class qn{constructor(n){let i=t;this[i(1381)]=n,this[i(1658)]=null}}class f0 extends qn{constructor(n,i){let d=t;e[d(1141)](e[d(1310)],e.PzrEX)?(super(n),this[d(1554)]=i&&i.message||null):(this[d(1150)](e[d(489)],_0x1d6dee),this[d(511)+d(1175)]&&this["onReceiv"+d(1175)](_0x251a29))}}class u0 extends qn{constructor(n,i){let d=t,l=e.PviYu[d(1232)]("|"),g=0;for(;;){switch(l[g++]){case"0":this[d(839)]=i&&i[d(839)]||"";continue;case"1":this[d(796)]=i&&i[d(796)]||null;continue;case"2":this[d(928)]=i&&i[d(928)]||5001;continue;case"3":this.message=i&&i[d(1554)]||"";continue;case"4":super(n);continue;case"5":this.colno=i&&i[d(1088)]||0;continue;case"6":this.lineno=i&&i[d(1300)]||0;continue}break}}}class l0 extends qn{constructor(n,i){let d=t,l=e[d(1984)][d(1232)]("|"),g=0;for(;;){switch(l[g++]){case"0":this[d(928)]=i&&i[d(928)]||0;continue;case"1":this[d(1166)]=i&&i.reason||"";continue;case"2":this[d(1059)+d(1965)]=i&&i.willReconnect||!1;continue;case"3":super(n);continue;case"4":this.wasClean=i&&i[d(543)]||!1;continue}break}}}class x0 extends qn{constructor(n,i){let d=t;e[d(734)](e[d(1306)],e[d(1751)])?(super(n),this[d(1901)]=i&&i.data||null):this[d(1710)+"rs"]={}}}class h0 extends x0{constructor(n,i){let d=t,l={YhEUb:function(g,y){return e[K(1781)](g,y)},HfIij:function(g,y){return e.pLmON(g,y)},kHpqq:function(g,y){return g(y)},CNirF:"0000"};if(e[d(919)](e[d(1039)],e.veLde)){let g=_0x59da86[d(1232)](/\./)[d(520)](p=>_0xaf849e(p)),y=[];return y[0]=RyrxqV.YhEUb(_0x1437e7,RyrxqV.HfIij(g[0],g[1])),y[1]=RyrxqV[d(1358)](_0x15c1b2,RyrxqV[d(820)](g[2],g[3])),["0000",RyrxqV[d(929)],RyrxqV[d(929)],"0000",RyrxqV[d(929)],"ffff",y[0],y[1]][d(1041)]("")}else super(n),this[d(1901)]=i&&i.data||null,this[d(1554)]=i&&i[d(1554)]||null}}class p0 extends qn{constructor(n,i){let d=t;super(n),this.data=i&&i[d(1901)]||null}}function Ze(o,{message:n,code:i,error:d}){let l=t;if(e[l(1471)](l(971),e[l(1080)]))return new u0(o,{message:n,code:i,error:d});_0x170871=e.TCCvu(e[l(1077)](e.ngoLL((7&_0x5b8712)<<18,e.ykoEv(e[l(1101)](63,_0x59db4f),12)),e[l(1748)](e[l(1393)](63,_0x45e0dd),6)),63&_0x3ebafe),e[l(1902)](_0x43b72c,65536)||e[l(1498)](_0x64ce68,1114111)?_0x1d39f5+=_0x30b7e9:(_0x24626e-=65536,_0x51c85a+=e[l(1415)](_0x182394,e[l(970)](e[l(1152)](_0x3ee923,10),55296),e[l(736)](1023,_0x2ff059)+56320),_0x209015+=3)}function rt(o,{code:n,reason:i,wasClean:d,willReconnect:l}){return new l0(o,{code:n,reason:i,wasClean:d,willReconnect:l})}function g0(o,{data:n,message:i}){let d=t;if(e[d(699)](e[d(481)],e[d(481)]))return new h0(o,{data:n,message:i});this[d(1866)+"igatorOn"+d(777)]=_0x4761a1,_0x1c3d07?this[d(624)+"nLine"]():this[d(624)+d(790)]()}function m0(o,{data:n}){let i=t;return e[i(1509)](e.XwUga,e[i(840)])?this[i(1113)]?.[i(1112)](_0x4318e3):new p0(o,{data:n})}function Do(o,{message:n}){return new f0(o,{message:n})}class w0{constructor(n,i){let d=t;this[d(1443)+"s"]=n,this[d(872)+"es"]=i,this["currentI"+d(1433)]=0,this[d(1338)+d(1629)+"riesCount"]=0}[t(958)+t(733)+t(1447)](){let n=t;this[n(1557)+n(1433)]=0,this[n(1338)+n(1629)+"riesCount"]=0}[t(1122)+"es"](){let n=t;this[n(1338)+n(1629)+n(810)+"t"]=0}[t(1249)+t(798)+"nt"](){let n=t;if(e.vlFwr(e[n(967)],e[n(706)]))return this.endpoints[this[n(1557)+n(1433)]];e[n(1708)](_0x33d249,_0x4e2b89,this[n(1972)+n(1541)+"e"](_0x2b7e1e))}[t(1249)+t(798)+t(604)+t(652)](){let n=t;return this[n(1338)+n(1629)+n(810)+"t"]}["checkRea"+t(795)+"es"](){let n=t;return!!(this["currentI"+n(1433)]>=this[n(1443)+"s"].length||e[n(744)](this[n(1557)+n(1433)],e[n(1128)](this[n(1443)+"s"].length,1))&&e[n(1869)](this[n(1338)+n(1629)+n(810)+"t"],this[n(872)+"es"]))}[t(1649)+t(691)+t(1529)+t(1356)+t(754)](){let n=t;return e[n(1029)](this[n(1557)+n(1433)],this.endpoints[n(1955)])?!0:e[n(528)](this["currentEndpointT"+n(810)+"t"],this.maxRetries)}[t(1350)+"ackupEnd"+t(513)+"UpdateCo"+t(512)](){let n=t;return this[n(1338)+n(1629)+n(810)+"t"]=1,this[n(1557)+n(1433)]++,this[n(1443)+"s"][this[n(1557)+"ndex"]]}[t(1249)+t(798)+t(1214)+t(649)](){let n=t;return this[n(1338)+n(1629)+n(810)+"t"]++,this[n(1249)+"ntEndpoint"]()}}let Hn=(e[t(886)](e.OfXVY,typeof globalThis)&&e[t(1835)](e[t(1624)],globalThis["construc"+t(1026)].name)||e[t(703)](e[t(1707)],typeof window)&&e[t(692)](e[t(1624)],window.constructor[t(1935)]))&&e[t(1739)](e[t(1707)],typeof document),pn=e[t(1261)](e[t(1707)],typeof globalThis)&&(e[t(502)](e[t(1628)],globalThis[t(1179)+t(1026)][t(1935)])||e.pTCnX(e.trsgB,globalThis["construc"+t(1026)].name))&&e[t(1480)]("undefined",typeof tt),Dr=(e[t(1850)](t(1098)+"d",typeof globalThis)&&e.wUKiF(e[t(1628)],globalThis[t(1179)+t(1026)][t(1935)])||e[t(1707)]==typeof globalThis||e[t(1774)](e[t(1707)],typeof globalThis)&&!!globalThis["WeixinJS"+t(1186)])&&e[t(1852)](e.OfXVY,typeof wx),kr=e.NzjWC(e[t(1707)],typeof globalThis)&&(e.hlmCr(e[t(1560)],globalThis.constructor.name)||e[t(1369)](e[t(634)],globalThis[t(1179)+"tor"][t(1935)])||e[t(1005)](t(1733)+t(1720)+t(1783),globalThis[t(1179)+t(1026)][t(1935)]))&&e[t(1850)](e.OfXVY,typeof self),Yx=e[t(1774)](e.OfXVY,typeof globalThis)&&e[t(1694)](e[t(1628)],globalThis["construc"+t(1026)][t(1935)])&&e.NzjWC(e[t(1707)],typeof global)&&e[t(1628)]===global[t(1179)+"tor"][t(1935)]&&e[t(583)](e[t(1707)],typeof process)&&!!process[t(1903)];class ko{constructor(){this._listeners={}}[t(1150)](n,...i){let d=t,l=this[d(1710)+"rs"][n];if(l)l.slice()[d(644)](g=>g.fn.apply(g[d(1697)],i));else if(d(796)===n&&!this[d(641)]){let g=i[d(1955)]&&i[0];if(e[d(1855)](g,Error))throw g;let y=new Error(e.rLVKy+(g?e.bjwXY(" (",g[d(1554)])+")":""));throw y.context=g,g}return this}off(n,i){let d=t;if(e[d(1305)](void 0,n))this[d(1710)+"rs"]={};else if(i===void 0)this._listeners[n]=null;else if(e[d(865)](e.WmDzX,e[d(2010)])){let{initReconnectInterval:l,maxReconnectInterval:g,reconnectIntervalGrowFactor:y}=this[d(1519)],E=e[d(1010)](l,_0x11afae[d(1822)](y,e[d(776)](_0x162893,1)));return e[d(458)](E,g)?g:E}else{let l=this[d(1710)+"rs"][n];if(l)for(let g=0;e[d(1482)](g,l.length);)l[g].fn===i?l[d(2009)](g,1):++g}return this}on(n,i,d){let l=t;return(this[l(1710)+"rs"][n]||(this[l(1710)+"rs"][n]=[]))[l(793)]({fn:i,ctx:d||this}),this}}class Xx extends ko{[t(455)+t(470)+"age"](n){let i=t,d={zanRs:function(l,g){return e[K(1452)](l,g)},VDrqe:function(l,g){return l&g},wMqkd:function(l,g){return e[K(592)](l,g)},RZXmm:function(l,g){return e.DRfvY(l,g)},xQAOd:function(l,g){return e.lbXco(l,g)}};if(e.EkePu(e.xoAJr,e[i(1326)])){let l=this[i(1890)],g=this[i(1654)];return[tCVqQA[i(1469)](255,g),tCVqQA[i(1165)](tCVqQA[i(890)](g,8),255),tCVqQA[i(890)](g,16)&255,g>>>24,255&l,tCVqQA[i(1083)](l,8)&255,l>>>16&255,tCVqQA[i(1455)](l,24)]}else return n[i(880)]||n[i(757)]?(i(727)+" "+(n[i(880)]||"")+i(711)+(n.errNo||""))[i(1550)]():JSON[i(1180)+"y"](n)}constructor(n,i,d){let l=t;if(e.MUATB(l(1370),e[l(1978)]))super(),this[l(883)]=null,Dr&&wx[l(1422)+"ocket"]&&(this[l(883)]=wx[l(1422)+l(920)]({url:n,protocols:i,header:d,fail:this[l(1208)+l(838)+"lHandler"][l(923)](this),success:this[l(1208)+l(861)+l(1641)+l(1891)][l(923)](this)})),pn&&tt[l(1422)+l(920)]&&(this[l(883)]=tt[l(1422)+"ocket"]({url:n,protocols:i,header:d,fail:this[l(1208)+l(838)+l(1767)][l(923)](this),success:this[l(1208)+"ocketSuc"+l(1641)+l(1891)][l(923)](this)}));else return _0xa868e|=0,{low:_0x1aa425,high:_0x2af1e2>>31,unsigned:e.mkegE(_0x20f0c2,0)}}[t(1208)+t(861)+t(1641)+t(1891)](){let n=t;Promise[n(682)]()[n(684)](()=>{this._addWsListeners()})}[t(1208)+t(838)+t(1767)](n){let i=t,d={QVbgl:function(l,g){return e.dqUFO(l,g)},tsbiU:e[i(573)],gDpLQ:e.SSbLZ,NeEUt:function(l,g,y){return l(g,y)},qfkAN:e[i(576)],NHxBA:e[i(466)]};Promise[i(682)]()[i(684)](()=>{let l=i,g={KfzBj:function(y,E){return y|E}};if(d[l(645)](d[l(1053)],d[l(462)]))this[l(1662)]=!0,this[l(1654)]=dyhzBh.KfzBj(0,_0x4a2d32),this.high=dyhzBh[l(1184)](0,_0x22db59),this.unsigned=!!_0x110de3;else{let y=d.NeEUt(Ze,d[l(1270)],{message:this["_formatE"+l(470)+"age"](n)});this.emit(l(796),y);let E=d.NeEUt(rt,d[l(1953)],{reason:this["_formatE"+l(470)+l(1793)](n)});this[l(1150)](d[l(1953)],E)}})}[t(898)+t(1213)](){let n=t;if(e[n(1657)](e[n(1857)],e[n(1810)]))return _0x5eea77?.[n(1368)](i=>i[n(657)]===_0xa5a02)?.[n(2033)];this[n(883)][n(1867)](i=>{let d=n;this[d(1150)](e[d(1667)],e[d(1708)](m0,d(519),{...i,data:i[d(880)]||""}))}),this[n(883)].onClose(i=>{this[n(1150)](e.hJnvZ,rt("close",{...i}))}),this[n(883)].onMessage(i=>{let d=n;this[d(1150)](d(1554),e.KFFjN(g0,"message",{...i}))}),this[n(883)][n(1911)](i=>{let d=n,l={EcLOu:e[d(662)]};e.HiBnv(e[d(1729)],e[d(1354)])?this[d(1150)](d(796),Ze("error",{...i,message:i[d(880)]||""})):(this[d(1668)+"er"]&&_0x42bc8e[d(1248)+d(563)+"ner"](d(1363),this[d(1626)+d(1635)]),this[d(1668)+"er"]&&_0x4dd0eb[d(1248)+d(563)+d(567)](l[d(1577)],this[d(1626)+d(1178)]),this[d(1396)]())})}[t(1330)](n){let i=t,d={rvEhB:function(l,g,y){return e.wVlEK(l,g,y)},bklOD:e[i(466)],XZACM:e.cybty,YMQsT:function(l,g){return e[i(1399)](l,g)},zubiO:function(l,g){return l===g},EqIqG:e[i(1144)],JFyTn:function(l,g){return l===g},UkAkk:e[i(1168)],NafBw:e[i(1525)],fXESf:e.hqcUP};if(e[i(935)](e.RJpqz,e[i(753)])){this["_dispatc"+i(461)+i(495)](d[i(600)](_0x5d65b2,d[i(1223)],{code:1e3,reason:d[i(525)]})),this[i(1574)+i(1871)]?.[i(958)+i(733)+i(1447)](),this[i(2016)+i(1980)]?.[i(760)+i(491)]();return}else if(e[i(809)](n,Uint8Array))if(e[i(924)](e[i(1939)],i(1711))){let l=n.buffer[i(1503)](n[i(987)+"et"],e[i(1631)](n[i(642)+"th"],n[i(987)+"et"]));this._socket&&this[i(883)][i(1330)]({data:l,fail:g=>{let y=i;if(e[y(1528)](e[y(1671)],e[y(1671)])){let E=d[y(1093)](_0x12eb6b,_0xd94870);this[y(953)]&&d.zubiO(this[y(953)][y(1568)+"te"],this[y(940)])&&(this[y(953)]&&this._ws[y(1330)](E),this[y(984)](d[y(1285)],_0x16923e))}else this[y(1150)](y(796),e[y(1614)](Ze,y(796),{message:this[y(455)+y(470)+y(1793)](g)}))}})}else _0x382e77 instanceof _0x1c214c&&_0x20821a[i(472)](_0x196e71,_0x106786);else this[i(883)]&&this._socket[i(1330)]({data:n,fail:l=>{let g=i;if(d[g(1061)](d[g(1116)],d.NafBw))return this[g(883)].protocol;this[g(1150)](d[g(1317)],Ze(g(796),{message:this[g(455)+"rrorMess"+g(1793)](l)}))}})}[t(1396)](n,i){let d=t;this._socket&&this[d(883)][d(1396)]({code:n,reason:i})}[t(1920)+"Listener"](n,i){this.on(n,i)}[t(1248)+"entListe"+t(567)](n,i){let d=t;if(e.oLbRI(e.gfysj,e.LphAZ))this.off(n,i);else{let l=_0x1a7f51[d(896)+"g"](0,4-_0x4def4d[_0x14dc49][d(1955)]),g=l.concat(_0x5b336f[_0x54710b]);_0x5909a4[d(793)](g)}}get[t(1568)+"te"](){let n=t;return this[n(883)][n(1568)+"te"]}get[t(903)+"pe"](){let n=t;return this._socket[n(903)+"pe"]}set binaryType(n){}get[t(1318)](){return this[t(883)].url}get[t(862)](){return this._socket.protocol}get[t(978)+"ns"](){let n=t;return this[n(883)][n(978)+"ns"]}get["buffered"+t(2015)](){return 0}}function Qx(o,n){let i=t;if(n)return new n(o.url,o[i(862)]);if(e[i(745)](Dr,pn))return new Xx(o[i(1318)],o[i(862)],o[i(996)]);if(e[i(1149)](Hn,kr)&&e[i(1707)]!=typeof WebSocket&&WebSocket)return new WebSocket(o[i(1318)],o[i(862)+"s"])}function eh(o){let n=t;if(e.wVRth===e.wVRth){let d=(n(966)+"2").split("|"),l=0;for(;;){switch(d[l++]){case"0":if(e[n(745)](Hn,kr)&&e.OfXVY!=typeof WebSocket&&WebSocket)return!0;continue;case"1":if(pn&&tt[n(1422)+"ocket"])return!0;continue;case"2":return!1;case"3":if(Dr&&wx[n(1422)+n(920)])return!0;continue;case"4":if(o)return!0;continue}break}}else for(var i in _0x73ec2a)_0x558dfb.o(_0x1e2bcb,i)&&!_0x3431d3.o(_0x4dc61d,i)&&_0x1a5507[n(871)+n(668)](_0x3179c9,i,{enumerable:!0,get:_0x1b2a57[i]})}function _0(o,n,i){let d=t,l=-1;async function g(y){let E=K;return y<=l?Promise[E(2030)](new Error(e.TVwZl)):(l=y,e[E(725)](y,i.length)?Promise[E(682)]():i[y].bind(o)(n,g[E(923)](null,e[E(1064)](y,1))))}e[d(1672)](g,0)}function y0(o){let n=t,i=0,d=0;for(let l=0;e[n(1504)](l,o.length);++l)d=o.charCodeAt(l),e[n(1460)](d,128)?i+=1:e[n(1912)](d,2048)?i+=2:e.pVSFx(e[n(1859)](64512,d),55296)&&e[n(773)](64512&o.charCodeAt(e[n(1808)](l,1)),56320)?(++l,i+=4):i+=3;return i}function b0(o,n,i){let d=t;if(e.oLbRI(e[d(1998)],d(1874))){if(e[d(1012)](i,n)<1)return"";let l="";for(let g=n;e[d(2026)](g,i);){let y=o[g++];if(y<=127)l+=String[d(532)+"Code"](y);else if(e[d(598)](y,192)&&e.tBljI(y,224))l+=String["fromChar"+d(1809)](e.wqyDA(e[d(646)](31,y)<<6,63&o[g++]));else if(y>=224&&y<240)l+=String["fromChar"+d(1809)](e.MqRuN(e[d(632)](e[d(764)](e[d(1906)](15,y),12),e.iYubC(63,o[g++])<<6),e[d(1076)](63,o[g++])));else if(e[d(720)](y,240))if(e[d(879)](e.IQMWB,e.IQMWB))this[d(1380)+d(1600)]=null;else{let E=e[d(735)](e[d(686)](e[d(480)](e.MPNrT(e[d(764)](e[d(1364)](7,y),18),e[d(622)](e[d(1533)](63,o[g++]),12)),(63&o[g++])<<6),e[d(1054)](63,o[g++])),65536);l+=String[d(532)+d(1809)](e[d(1119)](55296,E>>10)),l+=String[d(532)+"Code"](e[d(729)](56320,1023&E))}}return l}else return _0xb6049c+=_0x51bff4&&_0x3aab47[d(642)+"th"]||0,_0x4ebb18}function Po(o,n,i){let d=t;if(e.yJVLr===e[d(1532)]){if(e.NNdMq(4,_0x21e975[d(1955)])){let l=_0x17c5c8.substring(0,e.IPMdC(4,_0x5afb70[d(1955)])),g=l[d(663)](_0x264b05);_0xe715a1[d(793)](g)}else _0x1cc29f[d(793)](_0xc08567);_0x3914c0&&(_0x17ea52+=1),_0x2a6d8f+=1,_0x129f6a=!1}else{let l=i,g,y;for(let E=0;E<o[d(1955)];++E)if(g=o[d(558)+"At"](E),e.aSOtL(g,128))n[i++]=g;else if(e.LWnoC(g,2048))n[i++]=e[d(1695)](e[d(549)](g,6),192),n[i++]=63&g|128;else if(e[d(1506)](64512&g,55296)&&e[d(1594)](64512,y=o.charCodeAt(e[d(1946)](E,1)))===56320){let p=(d(1182)+d(488)).split("|"),P=0;for(;;){switch(p[P++]){case"0":n[i++]=e[d(1280)](e[d(2013)](g,18),240);continue;case"1":n[i++]=e.VrhnB(e[d(544)](63,g),128);continue;case"2":g=e[d(556)](65536+(e[d(864)](1023,g)<<10),e[d(910)](1023,y));continue;case"3":++E;continue;case"4":n[i++]=e[d(1501)](e[d(1406)](e[d(1540)](g,12),63),128);continue;case"5":n[i++]=e[d(1535)](e[d(1311)](g>>6,63),128);continue}break}}else n[i++]=e.LZBSc(e[d(605)](g,12),224),n[i++]=e[d(1830)](e[d(1095)](e[d(1845)](g,6),63),128),n[i++]=e.qsAuF(e[d(1054)](63,g),128);return e[d(1832)](i,l)}}async function E0(o){let n=t;if(n(738)==typeof o){let i=new Uint8Array(e.LQcEa(y0,o));return e.IxwrL(Po,o,i,0),i}return o instanceof ArrayBuffer?new Uint8Array(o):new Uint8Array(o[n(643)],o.byteOffset,o.byteLength)}function th(o){let n=t;try{return e[n(1796)](e[n(609)],e.OWNJF)?e[n(1480)](e[n(1752)],typeof o)&&(e[n(1855)](o,ArrayBuffer)||o[n(643)]&&e[n(809)](o[n(643)],ArrayBuffer))||e[n(1774)](e.IzwPB,typeof o)?"":(JSON[n(1196)](o),e[n(2032)]):n(1038)+"_"+this[n(1123)]}catch{if(e.VpRdV!==e[n(2023)])return e[n(1752)]==typeof o?e[n(1977)]:"";{let i=(n(1627)+"1").split("|"),d=0;for(;;){switch(i[d++]){case"0":if(e[n(1149)](_0x578857,_0x68c124)&&e.wlOeo(e[n(1707)],typeof _0x2756f7)&&_0x33db9b)return!0;continue;case"1":return!1;case"2":if(_0x59d0f1&&_0xb4568e.connectSocket)return!0;continue;case"3":if(_0x556385&&_0x2c4dab.connectSocket)return!0;continue;case"4":if(_0x3eb8f4)return!0;continue}break}}}}let nh=(o,n)=>{let i=t;switch(o){case e[i(1886)]:case e[i(1896)]:return{["x-use-"+o]:1,"x-tt-env":n};default:return{}}};class rh{constructor(n){let i=t;this[i(1766)+i(652)]=n,this[i(933)]=0}[t(1742)](){let n=t;this[n(933)]++}[t(1872)+t(1889)+"nt"](){let n=t;return e[n(1841)](this[n(933)],this[n(1766)+n(652)])}[t(760)+t(491)](n=0){let i=t;this[i(1766)+i(652)]=n,this[i(933)]=0}}async function ih(o){let n=t,i={NjeOa:n(1564)+n(1243),KkReo:e.YRYvd,GgBSA:e.uuiFm,rXrkW:e[n(539)],ihWEB:e.ZCfEs,NxnpL:n(603)+n(1085),JbhKh:function(d,l){return d(l)},IXhqT:e[n(1259)]};return new Promise(d=>{let l=n;if(e[l(529)](e[l(1267)],l(1126))){let g=i[l(707)][l(1232)]("|"),y=0;for(;;){switch(g[y++]){case"0":_0x5cd21f[_0x488464[llPXOb[l(1645)]]=5002]=llPXOb.KkReo;continue;case"1":_0x35dbb1[_0x4e01c9[l(1197)+l(1824)+"R"]=5003]=llPXOb[l(1416)];continue;case"2":_0x30b1dd[_0x4a3464[llPXOb[l(1773)]]=5005]=llPXOb[l(1773)];continue;case"3":return _0x2789de;case"4":_0x2fb193[_0x28185a[l(1691)+l(1426)]=5004]=llPXOb[l(1414)];continue;case"5":_0x3866bf[_0x4b6a17[llPXOb[l(1140)]]=5001]=llPXOb[l(1140)];continue}break}}else{if(!Hn)return d(e[l(1259)]);try{let g=document[l(1932)+l(1908)](e[l(1040)]);window[l(1038)+l(1247)]=y=>{let E=l;document[E(617)].removeChild(g),window["frontier"+E(1247)]=void 0,i[E(1302)](d,y&&y.msg||i[E(1127)])},g.type=e[l(1750)],g[l(1502)]=e.FylQz(o.replace(/^ws/,e.TDynb),e.UvskQ);try{if(e.OCBWR(e[l(1537)],l(718)))document.body[l(1581)+"ild"](g);else return this["currentE"+l(1629)+l(810)+"t"]}catch{document[l(617)]["removeCh"+l(1947)](g)}}catch{window[l(1038)+l(1247)]=void 0,d(e[l(1259)])}}})}function Gt(o,n,i){let d=t;return!!o?.[d(1368)](l=>l[d(657)]===n&&l[d(2033)]===i)}function jn(o,n){let i=t;return o?.find(d=>d.key===n)?.[i(2033)]}let Lo=null;async function sh(){let o=t;return Lo||(Lo=Promise[o(682)]()[o(684)](St[o(923)](St,e.DHdlU))),Lo}class oh extends ko{constructor(n,i){let d=t;super(),this[d(1555)]=n,this._keyPath=i,this[d(1113)]=void 0,this["_initPro"+d(1600)]=null}async openDB(){let n=t,i={zypsV:function(d,l,g){return e[K(1930)](d,l,g)},TYLMj:e[n(466)]};if(e.JwnXo(e[n(1549)],e.tUDgx)){let d=this[n(1574)+n(1871)]?.[n(1249)+n(798)+"nt"]();this["_dispatc"+n(461)+n(495)](i[n(1320)](_0x1261d8,i[n(1134)],{code:_0x73e522[n(928)],reason:n(902)+n(1094)+n(1712)+n(1177)+n(547)+n(1234)+d})),this["_endpoin"+n(1871)]?.[n(958)+n(733)+n(1447)](),this[n(2016)+"sCounter"]?.[n(760)+n(491)]();return}else await this[n(1895)]()}async[t(1895)](){let n=t;if(!this[n(1113)]){if(this["_initPro"+n(1600)])return this["_initPro"+n(1600)];try{if(e[n(859)](e[n(969)],e[n(1605)]))return _0x32abda[n(630)](n(613),_0x30bf7b,_0x1e6026,_0x2dbf30),this[n(1113)].set({cursor_name:_0x50a5fb,cursor:_0x66c17c,service:_0x59a4bb});{let i=this[n(1555)],d=this._keyPath;this["_initPro"+n(1600)]=(async()=>{let l=n,{openDB:g}=await e.xPKjy(sh);this._qosDB=await e[l(737)](g,l(1038)+"_"+i,1,{upgrade(y){let E=l;y[E(595)+E(1403)+"e"](i,{keyPath:d})}})})(),await this[n(1380)+n(1600)]}}catch(i){console[n(630)](i)}finally{this[n(1380)+"mise"]=null}}}async[t(1656)](n){let i=t;try{return await this._init(),this[i(1113)]?.[i(1656)](this[i(1555)],n)}catch(d){console.log(d)}}async[t(472)](n,i){let d=t;return await this[d(1895)](),this[d(1113)]?.put(this[d(1555)],n)}async[t(1112)](n){let i=t;try{return await this[i(1895)](),this[i(1113)]?.[i(504)](this[i(1555)],n)}catch(d){console[i(630)](d)}}async[t(1401)](){let n=t;try{return await this[n(1895)](),this._qosDB?.[n(1401)](this[n(1555)])}catch(i){console[n(630)](i)}}async keys(){let n=t;return await this._init(),this._qosDB?.[n(1987)+"ys"](this._dbName)}async[t(999)](){let n=t;return await this[n(1895)](),this[n(1113)]?.[n(999)](this[n(1555)])}async[t(1386)](){let n=t;try{this[n(1113)]?.[n(1396)](),this[n(1113)]=void 0}catch(i){console[n(630)](i)}}get isReady(){let n=t;try{return!!this[n(1113)]}catch(i){return console[n(630)](i),!1}}}class ah{constructor(n,i){let d=t;this[d(1123)]=n,this[d(1551)]=i,this[d(1113)]=localStorage}async[t(1371)](){}get[t(546)](){return"frontier_"+this[t(1123)]}async get(n){let i=t,d=this[i(1113)][i(1475)](this[i(546)]);return JSON[i(1196)](d||"{}")[n]}async set(n,i){let d=t,l=this[d(1113)][d(1475)](this[d(546)]),g=JSON[d(1196)](e[d(1969)](l,"{}"));return g[i||n[this[d(1551)]]]=n,this[d(1113)][d(1988)](this[d(546)],JSON.stringify(g)),i||n[this[d(1551)]]}async del(n){let i=t,d=this[i(1113)].getItem(this._prefix),l=JSON.parse(e[i(698)](d,"{}"));return l[n]=void 0,this[i(1113)][i(1988)](this._prefix,JSON.stringify(l))}async clear(){let n=t;return this[n(1113)][n(1401)]()}async[t(1049)](){let n=t,i=this[n(1113)][n(1475)](this[n(546)]),d=JSON[n(1196)](e.aMZTE(i,"{}"));return Object[n(1049)](d)}async[t(999)](){let n=t,i=this[n(1113)][n(1475)](this[n(546)]),d=JSON[n(1196)](e[n(1959)](i,"{}"));return Object[n(1997)](d)}[t(1386)](){return Promise[t(682)]()}get[t(1569)](){return!!this._qosDB}}class ch{constructor(n,i){let d=t;this._DBName=n,this[d(1551)]=i,this[d(1113)]=pn?tt:Dr?wx:null}async[t(1371)](){}get[t(546)](){return t(1038)+"_"+this._DBName}async[t(1656)](n){let i=t,d=this[i(1113)][i(1244)+i(1487)](this._prefix);return JSON.parse(d||"{}")[n]}async[t(472)](n,i){let d=t,l=this[d(1113)][d(1244)+d(1487)](this[d(546)]),g=JSON[d(1196)](l||"{}");return g[i||n[this._pathKey]]=n,this[d(1113)][d(564)+d(1487)](this._prefix,JSON[d(1180)+"y"](g)),i||n[this[d(1551)]]}async[t(1112)](n){let i=t,d=this._qosDB.getStorageSync(this._prefix),l=JSON[i(1196)](e.oJUWX(d,"{}"));return l[n]=void 0,this[i(1113)].setStorageSync(this[i(546)],JSON.stringify(l))}async[t(1401)](){let n=t;if(e[n(1070)](e[n(2014)],e[n(1163)]))return this[n(1113)][n(1804)+n(1884)]();_0x472540&&_0x2662a0[n(1920)+n(2007)](JEbeYT[n(466)],()=>_0x1cc26d()),_0x6097c9&&_0xb926e3[n(1920)+"Listener"](n(550)+n(1457),()=>_0x3e11b5())}async keys(){let n=t,i={eCVxE:function(d,l){return e[K(1685)](d,l)}};if(e.DUjHd===e[n(1833)])this[n(479)]=!1,i[n(1428)](_0x5b8737,this[n(986)+n(1322)+n(611)]),_0x27ba4e();else{let d=this[n(1113)][n(1244)+n(1499)+"nc"](this[n(546)]),l=JSON[n(1196)](e[n(1192)](d,"{}"));return Object[n(1049)](l)}}async[t(999)](){let n=t,i=this[n(1113)].getStorageInfoSync(this._prefix),d=JSON[n(1196)](i||"{}");return Object.values(d)}closeDB(){let n=t;return e[n(529)](e[n(1690)],e[n(1690)])?Promise.resolve():e[n(1520)](_0x28784e,_0x35310d)?_0xc69759:new _0xfdfa31(e[n(457)](e[n(1677)](e[n(800)](_0x1c8277[n(696)](_0x49ec05,0),_0x252a80[n(696)](_0x5654dc,1)<<8),e[n(602)](_0x185e3f[n(696)](_0x36a251,2),16))|_0x255bac.call(_0x1f75dc,3)<<24,0),e.hRqfw(e[n(1986)](e[n(1421)](_0x222e20[n(696)](_0x53de49,4),_0x4864f7.call(_0x4236ea,5)<<8),e[n(1748)](_0x3f243b[n(696)](_0x2beb0e,6),16))|e[n(747)](_0x50868f.call(_0xb4885c,7),24),0),!0)}get[t(1569)](){return!!this[t(1113)]}}function v0(o,n){let i=t;if(pn||pn)return new ch(o,n);if(e[i(521)](Hn,kr)&&e[i(962)](e[i(1707)],typeof indexedDB))return new oh(o,n);if(e[i(1904)](Hn,kr)&&typeof localStorage<"u")return new ah(o,n);throw new Error(e[i(1836)])}class dh{constructor(){let n=t;this[n(1925)+n(1207)+"Id"]=null,this._interval=36e5,this[n(1113)]=e.GyemQ(v0,e[n(1517)],e.nZRFP)}async[t(1925)+"lFlush"](){let n=t;e[n(1067)](clearInterval,this[n(1925)+n(1207)+"Id"]),this[n(1925)+"lTimeoutId"]=e[n(557)](setInterval,()=>{this["flushExp"+n(478)]()},this._interval)}async openDB(){let n=t;await this[n(1113)].openDB().then(()=>{let i=n;this[i(1925)+i(690)]()})}async[t(1596)+"ired"](){let n=t;(await this[n(1113)]?.[n(999)]()||[]).filter(({timestamp:l})=>l<Date.now())[n(644)](l=>{let g=n;this[g(1113)]?.[g(1112)](l.message_id)})}async del(n){return this[t(1113)]?.del(n)}async[t(472)](n,i){let d=t;return this._qosDB?.[d(472)]({message_id:n,timestamp:i})}async[t(1656)](n){let i=t;return this[i(1113)]?.[i(1656)](n)}async[t(1386)](){let n=t,i={jojEh:function(d,l){return e[K(1530)](d,l)},mcUNr:function(d,l){return e.fCVzp(d,l)}};e.EiLPr===e[n(728)]?(clearInterval(this[n(1925)+n(1207)+"Id"]),await this._qosDB?.closeDB()):(_0x2f3312=LoIhKP[n(475)](_0x5459d5,_0xd9a6d0),_0x29b7c4|=LoIhKP[n(651)](127&_0x22c902,7))}get isReady(){return this[t(1113)]?.isReady}}function Oo(o){let n=t,i=!!this[n(1519)][n(633)+"S"];if(!i)return{enabled:i,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1373)](Gt,o.message[n(996)],e[n(1254)],"2"),l=d&&e[n(1383)](Gt,o[n(1554)][n(996)],"x_frontier_qos_ack","1"),g=d&&Gt(o[n(1554)][n(996)],e[n(1546)],"1"),y=g?e[n(587)](jn,o.message[n(996)],n(1488)+"er_ack_m"+n(968))?.split(",")[n(1329)](Boolean)||[]:[];return{enabled:i,isQoSMessage:d,isQoSAck:l,isAckCleanupMessage:g,ackMsgIds:y}}async function S0(){let o=t;if(e[o(1104)](o(681),e[o(1108)]))this[o(1596)+"ired"]();else return this["_QoSMana"+o(1610)]||(this[o(821)+"ger"]=new dh),this[o(821)+o(1610)][o(1569)]||await this["_QoSMana"+o(1610)][o(1371)](),this[o(821)+o(1610)]}async function fh(o,n){let i=t,{enableAutoAck:d}=this._options,l=e[i(1373)](Gt,o.message.headers,e[i(1570)],"1"),g=Gt(o[i(1554)][i(996)],i(1375),"1"),y=Oo[i(696)](this,o);if(e.fihaD(d,l)){let{SeqID:E,LogID:p,service:P,LogIDNew:T,method:B}=o.message;this[i(780)]({SeqID:E,LogID:p,LogIDNew:T,service:P,method:B,headers:[{key:e.AZAEg,value:"1"},{key:e[i(965)],value:T||""},{key:e[i(1435)],value:"0"}]})}g&&!y[i(829)]&&this[i(824)+i(1385)+i(1704)](o),e.xPKjy(n)}async function uh(o,n){let i=t;this[i(984)](e[i(1276)],o.message),e[i(1446)](n)}async function lh(o,n){let i=t;if(e[i(653)](e[i(724)],i(1187)))return this["_endpoin"+i(1871)]?.[i(1249)+i(798)+"ntTriesC"+i(652)]()||0;{let d=Fn(await E0(o[i(1901)]));try{if(e[i(538)](d[i(949)],Uint8Array)){if(e[i(935)](e.aqyPZ,"oTrFI"))return _0x98c9cd[_0xa31082]=_0x57a3b1,!0;{let l=e[i(1855)](this[i(1519)][i(656)+"ncoding"],Object)?{force:!!this._options[i(656)+"ncoding"][i(626)],encoding:this[i(1519)][i(656)+i(499)][i(1231)]?this[i(1519)][i(656)+i(499)][i(1231)][i(1291)](/\s/g,"")["toLowerC"+i(1343)]():""}:{force:!1,encoding:this._options[i(656)+i(499)]?this[i(1519)][i(656)+i(499)][i(1291)](/\s/g,"").toLowerCase():""},g=d[i(656)+"ncoding"]?d["payloadE"+i(499)][i(1291)](/\s/g,"")[i(1277)+"ase"]():"",y=e[i(809)](this._options[i(1089)+"ype"],Object)?{force:!!this[i(1519)][i(1089)+i(717)][i(626)],type:this[i(1519)][i(1089)+i(717)].type?this[i(1519)][i(1089)+i(717)][i(1381)].replace(/\s/g,"")["toLowerC"+i(1343)]():""}:{force:!1,type:this._options[i(1089)+i(717)]?this[i(1519)][i(1089)+i(717)][i(1291)](/\s/g,"")["toLowerC"+i(1343)]():""},E=d[i(1089)+i(717)]?d.payloadType.replace(/\s/g,"")[i(1277)+i(1343)]():"",p=y[i(626)]?y[i(1381)]:E||y[i(1381)],P=l.force?l[i(1231)]:g||l[i(1231)],T=[e[i(1977)],e.mlGMr,i(849)+i(1377)+i(951)+i(1726),e.IzwPB],B=[e.MmASF,e[i(788)]];this[i(1519)][i(1616)+"ansformTextPayload"]&&T.includes(p)&&(!P||B[i(1547)](P))?d["textPayl"+i(639)]=e[i(1373)](b0,d.payload,0,d[i(949)][i(642)+"th"]):d[i(784)+i(639)]=""}}else d[i(784)+i(639)]=""}catch(l){d[i(784)+i(639)]="",console[i(630)](l)}o[i(1554)]=d,e[i(1979)](n)}}function xh(o,n,i){let d=t,l={kPCjN:e[d(576)],bQiil:e[d(1667)],Meeym:d(1554),jNkys:e[d(466)],zntxW:d(1834),uspmI:function(P,T){return e.qZvfJ(P,T)},vufWC:function(P,T){return e.BFrOY(P,T)},mutXQ:function(P,T){return e[d(1842)](P,T)},nZEJp:function(P,T){return e[d(789)](P,T)},rnnbd:function(P,T){return e[d(1592)](P,T)},MERGE:function(P,T){return e[d(1679)](P,T)}},g=i||8192,y=g>>>1,E=null,p=g;return function(P){let T=d;if(l.zntxW!==l[T(1954)]){let B=(T(833)+"0")[T(1232)]("|"),q=0;for(;;){switch(B[q++]){case"0":this[T(953)]["removeEventListe"+T(567)](l[T(888)],this._onError);continue;case"1":this[T(953)][T(1248)+"entListe"+T(567)](l.bQiil,this[T(1131)]);continue;case"2":this[T(953)][T(1248)+T(563)+"ner"](l.Meeym,this._onMessage);continue;case"3":if(!this[T(953)])return;continue;case"4":this[T(953)]["removeEv"+T(563)+T(567)](l[T(1449)],this._onClose);continue}break}}else{if(l[T(1823)](P,1)||l[T(1465)](P,y))return l[T(860)](o,P);l[T(1465)](p+P,g)&&(E=l.nZEJp(o,g),p=0);let B=n[T(696)](E,p,p+=P);return l[T(518)](7,p)&&(p=l[T(560)](7,p)+1),B}}}let hh=4294967295;function ph(o,n,i){let d=t;return RangeError(e[d(650)](e.uZKgb(d(1268)+"t of ran"+d(1699)+o+d(805),e[d(1308)](n,1))+e[d(1652)],i))}function gh(o,n,i){let d=t;if(e[d(1332)](i,hh))throw new Error(e[d(1146)]);let l=3;for(;e[d(1411)](l,0);){let g=e[d(569)](255,i);e[d(1383)](Mo,g,o,e[d(936)](n,l)),i>>>=8,l--}return e[d(1713)](n,4)}function mh(o,n){let i=t,d=0,l=n,g=e[i(852)](n,4);for(;e[i(1761)](l,g);){let{value:y,offset:E}=No(o,l);l=E,d=e[i(635)](d,8)>>>0,d+=y}return{value:d,offset:g}}function wh(o,n,i){let d=t,l={stJBg:function(g,y,E){return e[K(1967)](g,y,E)},vgCiG:function(g,y){return e[K(870)](g,y)},EgyME:function(g,y,E){return e[K(1190)](g,y,E)}};if(e[d(1470)](e[d(781)],d(1722))){let g=e.GtGos[d(1232)]("|"),y=0;for(;;){switch(g[y++]){case"0":if(n.write)return e[d(1946)](n[d(1183)](o,i),i);continue;case"1":return e.YMVfV(e[d(1373)](Po,o,n,i),i);case"2":if(e[d(1923)](o[d(1955)],40))return e[d(1603)](Po,o,n,i)+i;continue;case"3":if(!o)return i;continue;case"4":if(n.utf8Write)return n[d(894)+"e"](o,i)+i;continue}break}}else{let{offset:g}=_0x11931d(_0x16469b,_0x3f0917);_0x37f276=g;let y={cursor_name:"",cursor:0,service:0},{value:E,offset:p}=l[d(900)](_0xa980c5,_0x1710a2,_0x1815ca);y[d(1944)]=E,_0x348249=p;let{value:P,offset:T}=l[d(900)](_0x427a42,_0xdb1c79,_0x351593);_0x543ee1=T,y[d(700)+d(1723)]=_0x7f219e(_0x233b0e,_0x1375f1,l[d(1212)](_0x3d1a1c,P)),_0x1e0f2d+=P;let{value:B,offset:q}=l[d(1388)](_0x155118,_0x332a72,_0x10ff7a);y.cursor=B[d(1795)](),_0x3a0ea9=q,_0x46d5bd.push(y)}}function _h(o,n){let i=t,d=new oe(e[i(1193)](e.WDsTn(e.RvqjH(e[i(1844)](o[e[i(1056)](n,4)],24),e[i(667)](o[e[i(808)](n,5)],16)),e.brpwg(o[e[i(1646)](n,6)],8)),o[e[i(1801)](n,7)]),e.vOJxe(e.CfmEz(e.MqRuN(e[i(1784)](o[e[i(1518)](n,0)],24),o[e.cKXNw(n,1)]<<16),e[i(1316)](o[e[i(1688)](n,2)],8)),o[e[i(524)](n,3)]),!0);return n+=8,{value:d,offset:n+8}}function yh(o,n,i){let d=t;if(e.oLbRI(e[d(1494)],e[d(1494)]))return _0x4c8c8f||(_0x13ee8f=[_0x1fa4e3[d(1157)+"e"].advance,_0x5dd9af[d(1157)+"e"].continue,_0x4f458e.prototype[d(877)+d(1865)+"ey"]]);{let l=o.low,g=o[d(1890)];return n[i]=e[d(592)](g,24),n[e[d(936)](i,1)]=e[d(1081)](e[d(1964)](g,16),255),n[e[d(498)](i,2)]=e.nyIds(g>>>8,255),n[e[d(1803)](i,3)]=e[d(471)](255,g),n[e[d(498)](i,4)]=e[d(1964)](l,24),n[e[d(1064)](i,5)]=l>>>16&255,n[e.iISNf(i,6)]=e[d(592)](l,8)&255,n[e[d(1803)](i,7)]=e[d(1055)](255,l),i+=8,i}}function No(o,n){let i=t,d={ixqRL:function(l,g){return e[K(982)](l,g)},NbUsE:function(l,g){return e[K(922)](l,g)},wwxBD:function(l,g){return l>g}};if(e[i(501)](e[i(1749)],e[i(1749)]))return o.readUInt8?{value:o[i(1524)+"8"](n),offset:e[i(2020)](n,1)}:{value:e[i(1756)](255,o[n]),offset:e[i(1639)](n,1)};{let l=_0x8ed8f0.bytes,g=_0x1ef6b5[i(485)],y=_0x920293[i(606)],E=g+_0x4af942;if(GFBIqe[i(1365)](E,l[i(1955)])){let p=new _0x52a7bc(GFBIqe.NbUsE(2,E));p.set(l),_0x5972f6[i(1683)]=p}return _0x310263[i(485)]=E,GFBIqe[i(1513)](E,y)&&(_0x208d2b[i(606)]=E),g}}function Mo(o,n,i){let d=t;return n[d(1172)+"t8"]?n[d(1172)+"t8"](o,i):n[i]=e.GpWBs(255,o),e[d(1946)](i,1)}let bh=function(o){return new Uint8Array(o)},Eh=e[t(1174)](e[t(1707)],typeof Buffer)?Buffer.allocUnsafe:xh(bh,Uint8Array[t(1157)+"e"][t(654)]),vh=16,Bo=32;function Sh(o){let n=t,i=0,d={};for(let l=0;e.KoPQx(l,o[n(1955)]);l++)d[o[l][n(700)+n(1723)]]=e[n(1685)](y0,o[l][n(700)+"ame"]),i+=e[n(954)](14,d[o[l][n(700)+n(1723)]]);return[i,d]}function I0(o,n,i){let d=t,l={ImvyL:function(g,y){return e.ABHtn(g,y)},uPPnx:"JLlcA",QwrOQ:e.SyIsn,XvZjP:e[d(1958)],HDXLf:function(g,y,E,p){return e[d(1608)](g,y,E,p)},KkVBN:e.vcdiL,yFmuw:function(g,y,E,p){return g(y,E,p)},xuBwH:function(g,y,E,p){return e[d(855)](g,y,E,p)},fBNGA:e[d(1220)],SPDPp:d(1046)};if(e[d(1528)]("ahIGm",e[d(713)])){let[g,y]=e.GWPyk(Sh,o),E=e[d(1781)](Eh,g),p=0;return o[d(644)](P=>{let T=d;if(l.ImvyL(l[T(1051)],l[T(1051)]))_0x1c57d6[T(595)+T(1403)+"e"](_0x45b9ce,{keyPath:_0x450be6});else{let B=l[T(1917)][T(1232)]("|"),q=0;for(;;){switch(B[q++]){case"0":console[T(630)]("service-"+T(1935),p);continue;case"1":console[T(630)](l[T(1423)],p);continue;case"2":p=l[T(1111)](Mo,0,E,p);continue;case"3":console[T(630)](l.KkVBN,p);continue;case"4":console[T(630)](T(577)+"ervice",P,P[T(1944)]);continue;case"5":p=yh(oe[T(1591)+"er"](P[T(474)]||n),E,p);continue;case"6":p=l.yFmuw(gh,E,p,P[T(1944)]||0);continue;case"7":p=l[T(979)](wh,P[T(700)+T(1723)],E,p);continue;case"8":console[T(630)](l.fBNGA,p);continue;case"9":p=l[T(1037)](Mo,y[P[T(700)+T(1723)]],E,p);continue;case"10":console[T(630)](l[T(1483)],p);continue}break}}}),{frameType:Bo,headers:[{key:e.yOVed,value:i}],payload:E}}else JEbeYT[d(1727)](_0x50e071,_0x1b3d0d.error),JEbeYT[d(972)](_0x2cf9d7)}function Ih(o){let n=t,i={ZVypo:function(d,l){return e[K(906)](d,l)},jhqxd:function(d,l){return e[K(1661)](d,l)},nqzFy:function(d,l){return e[K(1964)](d,l)},FoYsj:function(d,l){return e.AoKGZ(d,l)},LSiRW:function(d,l){return d>>>l},eFPgv:function(d,l){return d&l},giZhf:function(d,l){return d&l}};if(e[n(1476)]!==n(473)){let d=this[n(1890)],l=this[n(1654)];return[TVDXmI[n(508)](d,24),TVDXmI[n(508)](d,16)&255,TVDXmI[n(1328)](TVDXmI.nqzFy(d,8),255),TVDXmI[n(1042)](255,d),TVDXmI.nqzFy(l,24),TVDXmI.LSiRW(l,16)&255,TVDXmI.eFPgv(l>>>8,255),TVDXmI[n(1491)](255,l)]}else{let d=0,l=[];for(;e[n(570)](d,o.byteLength);){let{offset:g}=e.AKNAY(No,o,d);d=g;let y={cursor_name:"",cursor:0,service:0},{value:E,offset:p}=e[n(1304)](mh,o,d);y[n(1944)]=E,d=p;let{value:P,offset:T}=e[n(1622)](No,o,d);d=T,y[n(700)+"ame"]=b0(o,d,e.Colat(d,P)),d+=P;let{value:B,offset:q}=_h(o,d);y[n(474)]=B[n(1795)](),d=q,l[n(793)](y)}return l}}function Ah(){let o=t;return{frameType:Bo,headers:[{key:e.yOVed,value:o(1818)+o(1275)}],payload:void 0}}class Ch{constructor(n,i,d){let l=t;this["_cursorN"+l(638)]=n,this[l(1409)+l(1336)]=i,this[l(1044)+"Strategy"]=d,this[l(1113)]=e.cDbcb(v0,this[l(1797)+l(638)],e[l(1009)])}async[t(1371)](){let n=t;await this[n(1113)][n(1371)]()}async getCursors(){let n=t;if(!this._qosDB[n(1569)])return;let i=this._messageStrategy,d=await this[n(1113)].getAll();switch(console[n(630)](e.GfCvb,d),i){case e[n(914)]:return d&&d.length?e[n(1015)](I0,d,0,this["_cursorF"+n(1336)]):void 0;case e[n(1313)]:return;case n(1478):return d&&d[n(1955)]?e[n(522)](I0,d,0,this[n(1409)+n(1336)]):e[n(1552)](Ah)}}async set(n,i,d){let l=t;if(e.IKWzz(e.szxIk,e[l(2008)]))_0x122236(_0x24baa2,10),e[l(1539)](_0x38c7cb,_0x1a176a,_0x99620f);else return console[l(630)](e[l(843)],n,i,d),this._qosDB.set({cursor_name:n,cursor:i,service:d})}async[t(1709)+"rs"](n){let i=t,d=e[i(1159)](Ih,n);for(let l of d)console.log(e[i(1730)],d),await this._qosDB[i(472)](l)}async[t(1656)](n){let i=t;return(await this._qosDB[i(1656)](n))?.[i(474)]}async closeDB(){let n=t;if(e.YhhUC(e[n(1171)],e[n(1171)]))await this[n(1113)][n(1386)]();else{let i=0,d=_0x368405,l=e[n(2002)](_0x2df1ee,4);for(;e[n(1460)](d,l);){let{value:g,offset:y}=e.GyemQ(_0x1968a9,_0x71cc06,d);d=y,i=e.cNNMz(e[n(1001)](i,8),0),i+=g}return{value:i,offset:l}}}[t(1278)+t(1950)+t(1257)](n){let i=t;this["_cursorF"+i(1336)]=n}get[t(1569)](){let n=t;return this[n(1113)][n(1569)]}}let Th="__x_msg_"+t(1372);async function A0(o){let n=t,i={deorb:function(E){return e[K(1048)](E)},CGsGO:function(E){return E()}};if(!this[n(1519)][n(633)+"S"])return null;let{aID:d,fpID:l,messageStrategy:g}=this[n(1519)],y=e[n(1289)](o,Th);try{if(e.KVSwu(e.ucwwm,n(636)))_0x33df18[n(617)][n(1581)+n(1947)](_0x42b2a7);else return this[n(1319)+n(1434)]?e[n(1471)]("joaBX",e.UoCqW)?o&&this[n(1319)+n(1434)]["updateCu"+n(1950)+n(1257)](o):(vHFQgX.deorb(_0x2f929d),vHFQgX.CGsGO(_0x99d6ae)):this[n(1319)+n(1434)]=new Ch(l+"_"+d+"_"+y,y,g),this["_cursorM"+n(1434)][n(1569)]||await this[n(1319)+n(1434)][n(1371)](),this._cursorManager}catch{return null}}async function Rh(o,n){let i=t,d=e.hlbJA(Gt,o[i(1554)][i(996)],e.SDvmP,"-1"),l=e[i(1849)](Gt,o[i(1554)][i(996)],e[i(817)],"1"),g=e.ltrGL(jn,o[i(1554)][i(996)],e[i(1379)]),y=e[i(677)](Number,e[i(837)](jn,o.message[i(996)],e.GctiA))||0,E=Oo[i(696)](this,o),p=Gt(o[i(1554)][i(996)],"x-msg-qos","2"),P=e[i(1614)](jn,o.message[i(996)],e[i(806)]),T=e[i(1425)](Number,e[i(1458)](jn,o.message[i(996)],e[i(476)]));if(E.isQoSAck)return n();let B=E[i(1109)+i(1945)]?await S0.call(this):null;if(e[i(1002)](o[i(1554)].service,0)&&l&&!d||e[i(873)](o[i(1554)][i(1944)],0)){if(g&&E[i(1109)+i(1945)]&&B)if(i(931)===e[i(1625)])e.wYuCy(_0x3a32ae,this[i(1925)+i(1207)+"Id"]),this[i(1925)+i(1207)+"Id"]=_0x3895bd(()=>{let q=i;this[q(1596)+q(478)]()},this[i(1925)+"l"]);else return!!!await B.get(g)&&(this[i(824)+i(1106)+i(562)](o),await B.set(g,e[i(1803)](Date[i(640)](),y))),e.XirRO(n);if(p){let q=await A0.call(this);if(!q){if(e[i(907)](i(1788),e[i(1262)]))return this[i(824)+i(1106)+i(562)](o),n();this[i(552)+i(1778)]()&&(!this[i(953)]||e.nLupl(this[i(953)][i(1568)+"te"],this[i(940)])||e[i(1287)](this[i(953)].readyState,this[i(1427)+"NG"]))&&this[i(624)+i(456)](),this[i(1668)+"er"]&&_0x567319["addEvent"+i(2007)](i(1991),this[i(624)+i(456)]),this[i(1668)+"er"]&&_0x12999a["addEvent"+i(2007)](e.nTEbt,this[i(624)+i(790)])}let $=await q[i(1656)](P)??-1;if(e[i(1504)]($,T))this[i(824)+i(1106)+i(562)](o),q.set(P,T,o[i(1554)][i(1944)]);else throw new Error(i(1337)+" message"+i(1567)+T+(i(1976)+"than loc"+i(1367)+"r ")+$);return n()}return this[i(824)+i(1106)+i(562)](o),n()}}async function Dh(o,n){let i=t;if(i(1989)===e[i(1436)]){let d=Oo[i(696)](this,o);if(!d.isQoSMessage)return e.xPKjy(n);let l=await S0.call(this);if(d[i(1952)+i(1481)+"age"]&&d[i(904)+"s"][i(1955)])for(let g of d[i(904)+"s"])await l.del(g);n()}else{let d=i(1698)+_0x673192+(i(1347)+i(1728)+i(1782)+"ed");this[i(824)+i(1260)+"ent"](e.IXJLx(_0x149d3f,e[i(576)],{message:d,code:_0x569b56[i(1197)+i(1824)+"R"],error:_0x365118}));return}}async function kh(o,n){let i=t,d=e[i(673)](o[i(1554)][i(1775)+"e"],vh),l=e[i(1827)](o[i(1554)].frameType,Bo);if(!d&&!l)return e.JAuMb(n);let g=e[i(1397)](jn,o[i(1554)][i(996)],e[i(1204)]);if(!g)return e[i(1552)](n);let y=await A0[i(696)](this,g);if(!y)return e[i(1579)](n);if(d){if(e.ESIhN(e[i(1246)],e.JGbAU))return!!_0x41e7e1?.[i(1368)](E=>E[i(657)]===_0x380c14&&E.value===_0x219628);{let E=await y[i(530)+"rs"](),p={frameType:E?.["frameType"],SeqID:oe[i(1591)+"er"](this[i(1034)]++),LogID:oe.fromNumber(this[i(1519)][i(742)+i(460)]()),service:9e3,method:5,headers:E?.[i(996)],payload:E?.payload},P=e[i(1425)](A,p);this._ws&&this[i(953)][i(1568)+"te"]&&this._ws.send(P)}}if(l){let E=o[i(1554)][i(949)];E&&y[i(1709)+"rs"](E)}}let Ph=async function(o,n){let i=t;this[i(479)]=!1,e[i(1107)](clearTimeout,this[i(986)+i(1322)+i(611)]),e[i(1440)](n)},Lh=async function(o,n){let i=t;if(!this[i(953)]||this[i(953)][i(1568)+"te"]!==this[i(940)])return e[i(1265)](n);let{pingInterval:d}=this[i(1519)];this[i(1574)+i(1871)]?.["resetEndpointCon"+i(1447)]();for(let g=0;g<this["_message"+i(1103)][i(1955)];g++){let y=this[i(1044)+"Queue"][g];if(e[i(1050)](this[i(953)][i(1568)+"te"],this.OPEN)&&y!==null)this._ws&&this[i(953)][i(1330)](y),this[i(1044)+i(1103)][g]=null;else break}this[i(1044)+i(1103)]=this[i(1044)+"Queue"][i(1329)](g=>!!g),this[i(1769)+i(1909)+"Id"]=setTimeout(()=>this._ping(),d),this["_dispatc"+i(1450)+"nt"](o),this[i(1668)+"er"]&&this[i(953)]&&(this[i(953)][i(903)+"pe"]=this[i(1021)+i(717)]);let l=this["_endpoin"+i(1871)]?.[i(1249)+i(798)+"nt"]();this[i(984)](i(1619)+l+i(1715)),e.HIlwK(n)},Oh=async function(o,n){let i=t,d=this[i(1574)+"tManager"]?.[i(1249)+i(798)+"nt"]();this[i(984)](i(1619)+d),e[i(574)](n)};class Nh extends ko{constructor(n){let i=t,d={BujqM:function(E,p,P,T){return e[K(482)](E,p,P,T)},CjFRu:e[i(576)],CMWQj:function(E,p,P){return e[i(891)](E,p,P)}};super(),this[i(1866)+i(1745)+i(777)]=!0,this[i(1668)+"er"]=Hn,this[i(1996)]=Yx,this[i(1474)+"T"]=pn,this[i(483)+"X"]=Dr,this[i(1878)+"r"]=kr,this[i(1044)+i(1103)]=[],this["_endpoin"+i(1871)]=null,this[i(791)+i(1120)]=!1,this[i(1021)+i(717)]=e[i(515)],this[i(986)+"Lock"]=!1,this[i(986)+"ionTimeoutId"]=null,this[i(786)+"ctTimeou"+i(1139)]=null,this["_pingPon"+i(1909)+"Id"]=null,this[i(1034)]=0,this[i(479)]=!1,this._url="",this[i(821)+i(1610)]=null,this[i(1319)+i(1434)]=null,this["_pingLos"+i(1980)]=null,this._protocols=e.rJLFs,this[i(756)]=3,this[i(1427)+"NG"]=0,this.OPEN=1,this[i(1281)]=2,this._onOpen=E=>{let p=i;try{d[p(981)](_0,this,E,[Ph,Lh,Oh])}catch(P){let T=Ze(d[p(666)],{message:P[p(1554)],code:jt[p(1006)+"OR"],error:P});this[p(824)+p(1260)+p(495)](T)}},this[i(1559)+"ge"]=async E=>{let p=i,P={gLlEj:function(q,$,Y,it){return e[K(1015)](q,$,Y,it)}},{pingInterval:T,pingFrequency:B}=this[p(1519)];if(e[p(1369)]("hi",E[p(1901)])&&e[p(947)](e.fzdeH,B)||e[p(1143)](e[p(1424)],B)){if(e[p(1743)](e.qVRzx,p(1531)))throw _0x6c5abf=_0xa00536[p(1955)],bGSwPg.gLlEj(_0x2047d6,_0x9108a1,10,_0x44944d[p(1955)]);this[p(2027)+p(1058)](),this[p(1150)](e[p(1295)],e[p(1760)]),this[p(1769)+p(1909)+"Id"]=e[p(1585)](setTimeout,this._ping[p(923)](this),T)}if(!e[p(1471)]("hi",E[p(1901)]))try{e[p(767)](_0,this,E,[lh,fh,Dh,kh,Rh,uh])}catch(q){let $=Ze(p(796),{message:q.message,code:jt[p(1691)+p(1426)],error:q});this["_dispatc"+p(1260)+p(495)]($)}},this[i(1099)]=E=>{let p=i,P=this[p(1574)+p(1871)]?.[p(1872)+p(795)+"es"](),T=this["_endpoin"+p(1871)]?.[p(1249)+p(798)+"nt"]();if(P&&!E[p(1554)]){let B=p(1698)+T+(" fail, max retri"+p(1782)+"ed");this[p(824)+"hErrorEv"+p(495)](d.CMWQj(Ze,d[p(666)],{message:B,code:jt[p(1197)+p(1824)+"R"],error:E}));return}this._ws&&this[p(953)][p(1568)+"te"]===this[p(940)]&&this["_disconn"+p(628)](),this["_dispatc"+p(1260)+p(495)](d[p(1927)](Ze,d[p(666)],{message:E[p(1554)],code:jt[p(603)+"RROR"],error:E}))},this[i(1777)]=async E=>{let p=i,P={pjaXp:function(B,q,$){return B(q,$)},VLfuf:function(B,q){return e[K(620)](B,q)}};this[p(811)+p(694)](),this[p(2027)+p(1058)](),this[p(812)+p(998)+"rs"](),this[p(953)]=null,this[p(986)+p(1928)]=!1;let T=this["_endpoin"+p(1871)]?.[p(1872)+"chMaxTries"]();if(!T&&this["_navigat"+p(1778)]()&&!this[p(791)+p(1120)]){let B=this["_endpoin"+p(1871)]?.[p(1249)+p(798)+"nt"](),q=this._options[p(658)+p(1454)+p(1378)](E[p(928)],E[p(1166)]);this[p(824)+"hCloseEv"+p(495)](e[p(1496)](rt,"close",{code:1006,reason:E[p(1166)]||p(902)+p(1094)+p(1712)+"wn reaso"+p(547)+"ame: "+B,willReconnect:q})),q&&this[p(986)]();return}if(e[p(653)](1e3,E[p(928)])&&this[p(791)+p(1120)]){this[p(824)+"hCloseEv"+p(495)](rt(e[p(466)],{code:1e3,reason:e[p(787)]})),this[p(1574)+p(1871)]?.[p(958)+p(733)+p(1447)](),this[p(2016)+p(1980)]?.[p(760)+p(491)]();return}if(e.vYDYr(1e3,E[p(928)])&&T){let B=this["_endpoin"+p(1871)]?.[p(1249)+p(798)+"nt"](),q=E.reason;q||(q=await e[p(1463)](ih,this[p(1828)])),q="connecti"+p(1094)+"d, "+q+(", hostna"+p(1269))+B+(", max retries re"+p(1431)),this[p(824)+"hCloseEv"+p(495)](e[p(1415)](rt,p(1396),{code:E[p(928)],reason:q}));let $=p(1698)+B+(p(1347)+"ax retri"+p(1782)+"ed");this[p(824)+p(1260)+"ent"](e[p(1023)](Ze,e.hqcUP,{message:$,code:jt[p(1197)+p(1824)+"R"]})),this[p(1574)+p(1871)]?.[p(958)+p(733)+p(1447)](),this[p(2016)+p(1980)]?.["resetCou"+p(491)]();return}if(E.code!==1e3&&!E[p(1166)])if(e[p(911)]===e[p(1022)])gPCrYe[p(1571)](_0x2be104,_0x600fce,24),gPCrYe[p(1571)](_0x50a8e4,_0x3414bd,gPCrYe[p(1602)](_0x164afd,_0x97441e));else{let B=this[p(1574)+"tManager"]?.[p(1249)+p(798)+"nt"]();this[p(824)+p(461)+p(495)](e.giVCJ(rt,e.hJnvZ,{code:E[p(928)],reason:"connecting faile"+p(1712)+p(1177)+p(547)+p(1234)+B})),this[p(1574)+"tManager"]?.[p(958)+p(733)+p(1447)](),this[p(2016)+p(1980)]?.["resetCou"+p(491)]();return}this[p(824)+p(461)+p(495)](E),this[p(1574)+p(1871)]?.[p(958)+p(733)+p(1447)](),this[p(2016)+"sCounter"]?.[p(760)+"nter"]()},this.onclose=null,this[i(641)]=null,this[i(772)+"e"]=null,this.onopen=null,this[i(676)+i(1962)]=null,this[i(511)+i(1175)]=null,this[i(1910)+i(1974)+i(1916)+"ct"]=null,this[i(624)+"nLine"]=this[i(624)+i(456)][i(923)](this),this[i(624)+i(790)]=this[i(624)+"ffLine"][i(923)](this),this[i(1626)+i(1635)]=this["_handleP"+i(1635)][i(923)](this),this[i(1626)+i(1178)]=this[i(1626)+"ageShow"][i(923)](this),this[i(1519)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[i(579)](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(1424)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[i(1176)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:l,ws:g}=n,y=Array[i(1741)](l)?l:e.wFRig(e[i(1752)],typeof l)?[l]:[];if(!y||e.OCBWR(0,y[i(1955)]))throw new Error(e[i(608)]);if(!e[i(770)](eh,g))throw new Error(i(1888)+i(1167)+i(1419)+i(1003)+i(1283)+i(722)+"is undefined");Object[i(801)](this._options,n),this["_endpoin"+i(1871)]=new w0(y,this[i(1519)][i(872)+"es"]),this[i(2016)+i(1980)]=new rh(this[i(1519)][i(493)+i(974)]),this[i(1519)][i(1764)+i(671)]&&(e[i(502)](i(1587),e[i(1004)])?_0x55c42d=JEbeYT.GWPyk(_0x3a4cee,_0x3dc899):(this[i(479)]=!0,this[i(986)]())),this[i(1519)][i(2036)+i(740)+i(960)]&&(this._isMiniTT||this[i(483)+"X"]?this[i(1598)+i(1982)+i(505)]():this[i(1668)+"er"]&&this["_initGlo"+i(1580)+i(2007)]())}["_handleO"+t(456)](){let n=t;if(e[n(692)](n(1314),e[n(1937)])){let i=e[n(809)](this._options[n(656)+n(499)],_0xbe7714)?{force:!!this[n(1519)]["payloadE"+n(499)].force,encoding:this[n(1519)].payloadEncoding[n(1231)]?this[n(1519)].payloadEncoding[n(1231)][n(1291)](/\s/g,"")[n(1277)+"ase"]():""}:{force:!1,encoding:this[n(1519)][n(656)+"ncoding"]?this[n(1519)][n(656)+"ncoding"][n(1291)](/\s/g,"")["toLowerC"+n(1343)]():""},d=_0x2bce8a[n(656)+n(499)]?_0x57df85[n(656)+n(499)].replace(/\s/g,"")[n(1277)+n(1343)]():"",l=e[n(538)](this[n(1519)][n(1089)+"ype"],_0x2dc415)?{force:!!this[n(1519)][n(1089)+n(717)][n(626)],type:this[n(1519)][n(1089)+n(717)].type?this[n(1519)][n(1089)+n(717)].type[n(1291)](/\s/g,"").toLowerCase():""}:{force:!1,type:this._options[n(1089)+"ype"]?this._options[n(1089)+"ype"][n(1291)](/\s/g,"")[n(1277)+"ase"]():""},g=_0x365545[n(1089)+"ype"]?_0xf8b317[n(1089)+"ype"][n(1291)](/\s/g,"")[n(1277)+"ase"]():"",y=l[n(626)]?l[n(1381)]:g||l[n(1381)],E=i.force?i[n(1231)]:d||i.encoding,p=[n(899)+"in;chars"+n(1813),e[n(2032)],e[n(1853)],"string"],P=[n(1831)+"e",n(465)];this[n(1519)][n(1616)+n(1024)+n(2004)+"ad"]&&p[n(1547)](y)&&(!E||P[n(1547)](E))?_0x41a107["textPayl"+n(639)]=e[n(469)](_0x331864,_0x5d771a.payload,0,_0x5803a5[n(949)][n(642)+"th"]):_0x4166e5[n(784)+n(639)]=""}else{if(this[n(1519)][n(615)+n(683)+n(619)]||this[n(791)+n(1120)])return;this[n(1361)+n(1962)]()}}_handleOffLine(){let n=t;this[n(1205)+"WebSocket"]();let i=Do(e[n(1195)],{message:n(797)+"ediately reconnect"});this[n(1910)+n(1974)+"yReconnect"]&&this[n(1910)+n(1974)+n(1916)+"ct"](i)}[t(1360)+t(1580)+t(2007)](){let n=t;e[n(907)](e[n(708)],n(882))?(_0x493586(e[n(1760)]),this[n(1462)](e[n(1295)],_0x29b0a5),this[n(1462)](n(581)+n(750)+"t",_0x2dbed9)):(this[n(1668)+"er"]&&window[n(1920)+n(2007)](e[n(591)],this[n(624)+n(456)]),this[n(1668)+"er"]&&window[n(1920)+n(2007)](e[n(1948)],this[n(624)+"ffLine"]),this[n(1668)+"er"]&&window[n(1920)+n(2007)](e.LkWdT,this[n(1626)+n(1635)]),this[n(1668)+"er"]&&window.addEventListener(e.pGQiq,this[n(1626)+n(1178)]))}[t(593)+t(1580)+"Listener"](){let n=t;this[n(1668)+"er"]&&window[n(1248)+n(563)+n(567)](e[n(591)],this[n(624)+n(456)]),this[n(1668)+"er"]&&window[n(1248)+n(563)+n(567)](e[n(1948)],this["_handleO"+n(790)]),this._isBrowser&&window[n(1248)+n(563)+"ner"](e[n(1169)],this[n(1626)+n(1635)]),this[n(1668)+"er"]&&window[n(1248)+"entListe"+n(567)](e[n(662)],this[n(1626)+n(1178)])}[t(1626)+t(1635)](n){let i=t;!n[i(1227)+"d"]&&(this[i(1668)+"er"]&&window["removeEv"+i(563)+"ner"](e[i(1169)],this._handlePageHide),this[i(1668)+"er"]&&window[i(1248)+i(563)+"ner"](e[i(662)],this["_handleP"+i(1178)]),this[i(1396)]()),this[i(1668)+"er"]&&window["removeEv"+i(563)+i(567)](e[i(591)],this["_handleO"+i(456)]),this._isBrowser&&window["removeEv"+i(563)+"ner"](i(1241),this[i(624)+i(790)])}_handlePageShow(n){let i=t;n[i(1227)+"d"]&&(this[i(552)+i(1778)]()&&(!this._ws||e[i(661)](this[i(953)][i(1568)+"te"],this[i(940)])||this[i(953)][i(1568)+"te"]!==this[i(1427)+"NG"])&&this[i(624)+i(456)](),this[i(1668)+"er"]&&window["addEvent"+i(2007)](e.GdeAR,this[i(624)+i(456)]),this[i(1668)+"er"]&&window[i(1920)+"Listener"](e[i(1948)],this[i(624)+"ffLine"]))}async[t(1787)+t(631)](n){let i=t,d={SqJuK:function(l,g,y,E){return l(g,y,E)},NghMl:e[i(1072)],kHlFN:e.VyDNV,cJOen:function(l,g,y){return e.wVlEK(l,g,y)},oWYrI:e.KjTzR};if(e[i(1429)](i(687),e[i(1105)])){let l=!!this[i(1519)][i(633)+"S"];if(!l)return{enabled:l,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let g=_0x178a0e(_0x20e222[i(1554)][i(996)],i(1488)+i(610),"2"),y=g&&aLwzDy.SqJuK(_0x4f9e67,_0x5264a2[i(1554)][i(996)],aLwzDy[i(1451)],"1"),E=g&&aLwzDy[i(1589)](_0x643250,_0x282468[i(1554)][i(996)],aLwzDy.kHlFN,"1"),p=E?aLwzDy[i(1604)](_0xe0ea4e,_0x2b4eec[i(1554)].headers,aLwzDy[i(1892)])?.[i(1232)](",").filter(_0x2eb297)||[]:[];return{enabled:l,isQoSMessage:g,isQoSAck:y,isAckCleanupMessage:E,ackMsgIds:p}}else{let{fpID:l,deviceID:g,bddID:y,ttwID:E,accessKey:p,aID:P,customParams:T={},enableAutoAck:B,enableQoS:q,QoSLevel:$,env:Y}=this[i(1519)],it,Ct,Wt;if(this[i(1668)+"er"]||this[i(483)+"X"]||this._isMiniTT)it=location&&e[i(993)](i(1981),location[i(862)])?e.nWDAf:e[i(648)],Ct=n[i(1291)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Wt=/^wss(.*:\/\/)/[i(1776)](n)?n:""+it+Ct;else{if(e[i(597)](e.GEOBp,e[i(1856)]))return this[i(953)]?this[i(953)].binaryType:this[i(1021)+i(717)];it=e[i(1142)],Ct=n[i(1291)](/(^http)((?:[s]*:\/\/))/,""),Wt=/(^ws)((?:[s]*:\/\/))/[i(1776)](Ct)?Ct:""+it+Ct}let C0=y?e[i(1125)]:E?e.EjVaE:e[i(1887)],T0=y||E||g;if(!T0||!C0)throw new Error(e[i(934)]);let Mh=e[i(768)](e.kMtKK,typeof T)?await T():T,Bh=Y?e.crHdT(nh,Y[i(2001)],Y[i(1114)]):{},zo=Object[i(801)]({device_platform:i(2005),version_code:e[i(1582)],access_key:p,fpid:l,aid:P,[C0]:T0,xsack:B?1:0,xaack:B?1:0,xsqos:q?1:0,qos_level:q?$:void 0,qos_sdk_version:2,...Bh},Mh),zh=Object.keys(zo).reduce((Fo,Uo)=>zo[Uo]!==void 0?""+Fo+(Fo?"&":"?")+Uo+"="+zo[Uo]:Fo,"");return Wt+"/ws/v2"+zh}}async _connect(){let n=t;if(!(this["_connect"+n(1928)]||this[n(791)+"osed"])){this._connectLock=!0;try{let i=this[n(1574)+n(1871)]?.[n(1649)+n(691)+n(1529)+n(1356)+"tries"](),{timeoutInterval:d}=this[n(1519)];if(i){let g=this[n(1574)+n(1871)]?.["getCurre"+n(798)+"nt"](),y=this[n(1574)+n(1871)]?.[n(1350)+"ackupEnd"+n(513)+n(1731)+n(512)](),E=this[n(1574)+n(1871)]?.[n(1249)+"ntEndpointTriesC"+n(652)]();if(y){let p="connect "+g+(n(841)+n(1390)+n(818)+n(1673)+n(1779)+n(1334)+"ndpoint ")+y+(n(1755)+"y"),P=e[n(1708)](Ze,e.hqcUP,{message:p,code:jt["MAX_RETR"+n(1824)+"R"]});this[n(984)](p),this["_dispatc"+n(1260)+n(495)](P),this[n(1828)]=await this[n(1787)+n(631)](y),this[n(984)](n(1698)+y+" "+E+" times"),this[n(812)+n(998)+"rs"]()}else{let p="connect "+g+(n(841)+n(1390)+"tries re"+n(1431));this[n(984)](p),this[n(824)+"hErrorEv"+n(495)](e.PtBhH(Ze,e[n(576)],{message:p,code:jt[n(1197)+n(1824)+"R"]}));return}}else{let g=this[n(1574)+"tManager"]?.[n(1249)+n(798)+n(1214)+"ateCount"](),y=this[n(1574)+n(1871)]?.[n(1249)+n(798)+n(604)+n(652)]();this[n(1828)]=await this[n(1787)+"eUrl"](g||""),this._debug(n(1698)+g+" "+y+" times"),this[n(812)+n(998)+"rs"]()}if(this[n(479)])this[n(479)]=!1;else{let g=Do(e[n(1195)],{message:e[n(704)]});this[n(676)+"econnect"]&&this[n(676)+n(1962)](g)}let l=this[n(1574)+"tManager"]?.["getCurre"+n(798)+"ntTriesC"+n(652)]()||0;e[n(873)](l,1)&&await this[n(983)](e[n(776)](l,1)),this[n(984)]("connecti"+n(1633)+this[n(1828)]+(" protoco"+n(1686))+this[n(1293)+"ls"]),this[n(953)]=e[n(1124)](Qx,{url:this[n(1828)],protocols:[this._protocols],headers:this[n(1519)].miniProgramParams[n(1514)+n(938)]},this[n(1519)].ws),(this._isBrowser||this[n(1878)+"r"])&&this[n(953)]&&(this[n(953)][n(903)+"pe"]=this["_binaryT"+n(717)]),this[n(898)+n(1213)](),this[n(986)+"ionTimeo"+n(611)]=setTimeout(this._onTimeout.bind(this),d)}catch(i){throw this[n(986)+"Lock"]=!1,i}}}[t(811)+t(694)](){let n=t;e[n(1727)](clearTimeout,this[n(986)+n(1322)+n(611)]),this[n(986)+"ionTimeo"+n(611)]=null}[t(2027)+t(1058)](){let n=t,i={KPDzE:function(d,l){return e[K(836)](d,l)},TIKof:function(d,l,g){return e[K(1510)](d,l,g)}};if(e[n(1700)](n(1374),e[n(1846)]))return(XBbQZT[n(1583)](_0x37aa58,8)[n(1041)]("0")+XBbQZT[n(1339)](_0x1a5e76,_0x4f701f,10)[n(832)](2))[n(1503)](-8);e[n(1156)](clearTimeout,this["_pingPon"+n(1909)+"Id"]),clearTimeout(this["_reconne"+n(1033)+n(1139)]),this[n(1769)+n(1909)+"Id"]=null,this[n(786)+n(1033)+n(1139)]=null}[t(984)](...n){let i=t;this[i(1519)][i(1898)]&&console[i(630)][i(1235)](console,[e[i(908)],...n])}[t(1972)+"rvalValue"](n){let i=t,{initReconnectInterval:d,maxReconnectInterval:l,reconnectIntervalGrowFactor:g}=this[i(1519)],y=e[i(922)](d,Math.pow(g,e.uhcdr(n,1)));return y>l?l:y}[t(1477)](){let n=t;if(this[n(953)]&&this[n(953)].readyState===this[n(1427)+"NG"])if(e.uSntj(e.hggsz,e[n(1340)])){this._clearPingTimer(),this[n(1769)+n(1909)+"Id"]=e[n(1014)](setTimeout,this[n(1477)][n(923)](this),this[n(1519)][n(1218)+n(1484)]);return}else _0x197675[n(682)]()[n(684)](()=>{this[n(898)+"steners"]()});if(!this[n(953)]||e.ABHtn(this[n(953)][n(1568)+"te"],this[n(940)]))return void this[n(1361)+n(1962)]();this[n(953)]&&this._ws.send("hi"),this[n(786)+n(1033)+n(1139)]=e[n(1188)](setTimeout,this[n(1361)+n(1962)+n(599)][n(923)](this),this[n(1519)][n(807)+n(1189)+n(1597)])}[t(1361)+t(1962)+"Timeout"](){let n=t;if(e[n(1062)](n(814),e[n(1224)]))this[n(2016)+n(1980)]?.[n(1742)](),this[n(1150)](n(581)+n(750)+"t","timeout"),this[n(2016)+n(1980)]?.[n(1872)+n(1889)+"nt"]()?this["_handleR"+n(1962)]():this[n(1477)]();else return new _0x5b889c(_0x522ec4,{code:_0x4ebd72,reason:_0x1176d4,wasClean:_0x13c7b3,willReconnect:_0x1a7ef3})}[t(552)+t(1778)](){let n=t;return this[n(1474)+"T"]||this._isMiniWX?this[n(1866)+n(1745)+n(777)]:(this[n(1668)+"er"]||this._isWorker)&&this[n(1519)]["listenNe"+n(740)+n(960)]?navigator[n(1772)]:!0}[t(1361)+t(1962)](){let n=t;!this["_navigat"+n(1778)]()||this[n(791)+n(1120)]||(this[n(1574)+n(1871)]?.[n(958)+n(733)+n(1447)](),this[n(2016)+n(1980)]?.[n(760)+n(491)](),this[n(953)]?this[n(1351)+n(628)](1001,e.JCjfc,!0):this[n(986)]())}["_onPageN"+t(1982)+t(505)](){let n=t;this._isMiniTT?tt[n(1572)+"kStatusC"+n(1457)](({isConnected:i})=>{let d=n;this[d(1866)+d(1745)+d(777)]=i,i?this["_handleO"+d(456)]():this[d(624)+"ffLine"]()}):this[n(483)+"X"]&&wx["onNetwor"+n(1758)+"hange"](({isConnected:i})=>{let d=n;this[d(1866)+d(1745)+d(777)]=i,i?this[d(624)+d(456)]():this["_handleO"+d(790)]()})}[t(983)](n){return new Promise(i=>{let d=K;setTimeout(i,this[d(1972)+d(1541)+"e"](n))})}[t(1351)+t(628)](n=1e3,i="",d=!1){let l=t;if(e.cRKnS(e[l(571)],"FTLbI")){if(JEbeYT.NLArC(_0x2d0c52,JEbeYT[l(1586)]))return _0x31d001[l(1656)](_0x5e2401);if(JEbeYT[l(701)](_0x59a47f,l(1918)+l(1971)))return _0x29de15[l(1918)+l(1971)]||_0x5e2522[l(1656)](_0x32b9ba);if(JEbeYT[l(1228)](_0x5c44c6,JEbeYT[l(1239)]))return _0x2e7ce8[l(1918)+l(1971)][1]?void 0:_0x5da71b[l(1918)+l(2003)](_0x22ff62[l(1918)+l(1971)][0])}else{if(!this[l(953)])return;this["_destroy"+l(1943)+"t"](n,i,d)}}[t(719)+"ut"](){let n=t,i=this[n(1574)+n(1871)]?.[n(1249)+n(798)+"nt"]();this[n(984)](n(1698)+i+n(841)),this[n(1351)+n(628)](1001,e[n(463)],!0)}[t(780)](n){let i=t,d=e[i(665)](He,n);this._ws&&this._ws[i(1568)+"te"]===this[i(940)]&&(this._ws&&this[i(953)].send(d),this[i(984)](e[i(1144)],n))}[t(812)+"sListeners"](){let n=t,i=e[n(1489)].split("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(953)][n(1248)+n(563)+"ner"](e[n(576)],this._onError);continue;case"1":this._ws[n(1248)+n(563)+n(567)](e.hJnvZ,this._onClose);continue;case"2":this._ws["removeEventListe"+n(567)](e[n(1667)],this[n(1131)]);continue;case"3":this[n(953)][n(1248)+"entListe"+n(567)](e[n(1078)],this[n(1559)+"ge"]);continue;case"4":if(!this._ws)return;continue}break}}[t(898)+t(1213)](){let n=t,i=e[n(672)].split("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(953)][n(1920)+n(2007)](e[n(1078)],this._onMessage);continue;case"1":this[n(953)][n(1920)+n(2007)](e[n(466)],this[n(1777)]);continue;case"2":if(!this._ws)return;continue;case"3":this[n(953)]["addEvent"+n(2007)](n(519),this[n(1131)]);continue;case"4":this[n(953)][n(1920)+n(2007)](e[n(576)],this[n(1099)]);continue}break}}_wsInstanceClose(n=1e3,i=""){let d=t;try{this[d(953)]&&this._ws.close(n,i)}catch{}}[t(1205)+"WebSocket"](n=1e3,i="",d=!1){let l=t,g={PFTQr:function(y,E){return e[K(2022)](y,E)},IVxad:function(y,E){return e.mfUiH(y,E)},wRZuu:function(y,E){return e[K(1915)](y,E)}};if(this[l(2027)+l(1058)](),this[l(811)+l(694)](),this[l(812)+l(998)+"rs"](),this["_wsInsta"+l(1309)](1e3,i),this["_connect"+l(1928)]=!1,d&&this["_navigat"+l(1778)]()&&!this[l(791)+l(1120)]){if(this["_endpoin"+l(1871)]?.[l(1872)+l(795)+"es"]())if(e[l(752)]!==e[l(752)])_0x24e039=_0x5e53f2[pyDueB.PFTQr(_0x1d4c49,_0x434ec1)+1],(192&_0x23f181)!==128?_0x27aefa+=_0x177638:(_0x362342=pyDueB[l(527)]((31&_0x44f68d)<<6,63&_0x17c6ea),pyDueB[l(956)](_0x4ff53f,128)?_0x515a4b+=_0x2c2475:(_0x4d45f3+=_0x438403(_0x46a064),_0x1cb904++));else{let E=this[l(1574)+"tManager"]?.["getCurre"+l(798)+"nt"]();this[l(824)+"hCloseEv"+l(495)](e[l(1931)](rt,l(1396),{code:1006,reason:"connect "+E+(l(841)+", max re"+l(818)+"ached"),wasClean:!0}))}else{let E=this._options[l(658)+l(1454)+"ptor"](n,i);this[l(824)+l(461)+"ent"](e[l(815)](rt,e[l(466)],{code:n,reason:i,wasClean:!0,willReconnect:E})),E&&this[l(986)]()}return}this[l(552)+l(1778)]()||this[l(791)+l(1120)]?this["_dispatc"+l(461)+l(495)](e[l(1510)](rt,e[l(466)],{code:n,reason:e[l(787)]})):this[l(824)+l(461)+l(495)](rt(e[l(466)],{code:1006,reason:l(1453)+l(1194)+"ork offline"})),this[l(953)]=null,this[l(1574)+"tManager"]?.[l(958)+l(733)+l(1447)](),this["_pingLos"+l(1980)]?.[l(760)+l(491)]()}[t(824)+t(1450)+"nt"](n){let i=t;if(e.pTCnX(e[i(945)],i(1669))){let d=new _0x5586a8(2*_0x3b8114);d[i(472)](_0x3009ab),_0x3dbf61[i(1683)]=d}else this[i(1150)](e[i(1667)],n),this[i(1493)]&&this[i(1493)](n)}[t(824)+t(1106)+t(562)](n){let i=t;this.emit("message",n),this[i(772)+"e"]&&this.onmessage(n)}[t(824)+t(1385)+"ageEvent"](n){let i=t;this[i(1150)](e[i(489)],n),this["onReceiv"+i(1175)]&&this[i(511)+i(1175)](n)}[t(824)+t(1260)+t(495)](n){let i=t;e[i(1292)]===e[i(1933)]?_0x1b97db[i(617)]["removeCh"+i(1947)](_0x5c2b38):(this[i(1150)](e[i(576)],n),this[i(641)]&&this.onerror(n))}[t(824)+"hCloseEv"+t(495)](n){let i=t;this.emit(i(1396),n),this.onclose&&this.onclose(n)}get[t(903)+"pe"](){let n=t;if(e.Dghfk(e[n(927)],n(1286)))return this._ws?this._ws[n(903)+"pe"]:this[n(1021)+n(717)];{let i=this[n(1710)+"rs"][_0x2c1314];if(i)i.slice()[n(644)](d=>d.fn.apply(d.ctx,_0x18214f));else if(e[n(1471)](n(796),_0x35c67d)&&!this[n(641)]){let d=_0x46ede8[n(1955)]&&_0xe95dc[0];if(e[n(538)](d,_0x40ea6e))throw d;let l=new _0x5367a2(e[n(556)](e[n(850)],d?e.XSLNM(e.exlpU(" (",d[n(1554)]),")"):""));throw l[n(584)]=d,d}return this}}set[t(903)+"pe"](n){let i=t;this[i(1021)+i(717)]=n,this[i(953)]&&(this[i(953)].binaryType=n)}get retryCount(){let n=t;if(e[n(1520)](n(1789),e[n(1130)]))return this[n(1574)+n(1871)]?.[n(1249)+n(798)+n(604)+n(652)]()||0;if(e[n(878)](e[n(1752)],typeof _0x256aa9)){let i=new _0x28bcf8(e.AkXkS(_0x1eba7a,_0x10baed));return e.IxwrL(_0x3a2081,_0x1249e4,i,0),i}return e.YuisX(_0x454a2,_0x2ae492)?new _0x534b21(_0x3d0ff5):new _0x54dba3(_0x5e3578.buffer,_0x527861[n(987)+"et"],_0xba1095[n(642)+"th"])}get[t(1137)+"Amount"](){let n=t;return e[n(1617)](e.dlmBU,n(1753))?_0x36f43f.objectStoreNames||_0x240fbd.get(_0x40f089):this[n(1044)+n(1103)][n(1191)]((d,l)=>(d+=l&&l[n(642)+"th"]||0,d),0)+(this[n(953)]?this._ws[n(1137)+n(2015)]:0)}get[t(978)+"ns"](){let n=t;return e[n(778)](n(1299),n(942))?this._ws?this[n(953)][n(978)+"ns"]:"":e[n(1899)](0,this[n(1890)])&&this[n(1654)]===0}get protocol(){let n=t;return this[n(953)]?this[n(953)][n(862)]:""}get[t(1568)+"te"](){let n=t,i={gcLuV:"pagehide",tspIX:n(1515),AvzwN:n(1241)};if(e.aSGcQ(e[n(1858)],e[n(1858)]))return this[n(953)]?this[n(953)][n(1568)+"te"]:this[n(1519)][n(1764)+n(671)]?this.CONNECTING:this[n(756)];!_0x37912a[n(1227)+"d"]&&(this[n(1668)+"er"]&&_0x56be05[n(1248)+"entListe"+n(567)](QOwIhG[n(507)],this[n(1626)+n(1635)]),this._isBrowser&&_0x1f0280[n(1248)+n(563)+n(567)](QOwIhG[n(1613)],this[n(1626)+"ageShow"]),this[n(1396)]()),this[n(1668)+"er"]&&_0x1d812d[n(1248)+n(563)+n(567)](n(1991),this[n(624)+n(456)]),this[n(1668)+"er"]&&_0x1b28ab[n(1248)+n(563)+n(567)](QOwIhG[n(596)],this[n(624)+n(790)])}get[t(1318)](){let n=t;return this[n(953)]?this[n(953)][n(1318)]:this._url}[t(1396)](n=1e3,i){let d=t;if(this[d(791)+"osed"]=!0,this[d(811)+d(694)](),this._clearPingTimer(),this[d(593)+d(1580)+d(2007)](),this[d(821)+d(1610)]?.[d(1386)](),!this[d(953)])return void this[d(984)]("close, w"+d(1100)+"ce not initialized");if(e[d(1121)](this[d(953)][d(1568)+"te"],this[d(756)])||e[d(1924)](this[d(953)][d(1568)+"te"],this[d(1281)]))return void this[d(984)](d(695)+d(693)+d(1650));this["_destroy"+d(1943)+"t"](n,i)}async[t(1330)](n,i){let d=t;if(e[d(679)](e[d(1542)],e[d(1206)])){let{pingInterval:l,pingFrequency:g}=this._options;if((_0x2f4aa6[d(1901)]==="hi"&&e[d(851)](e[d(629)],g)||e[d(1424)]===g)&&(this[d(2027)+d(1058)](),this[d(1150)](e.izgZx,e[d(1760)]),this[d(1769)+"gTimeoutId"]=_0x582a28(this[d(1477)].bind(this),l)),e[d(1158)]("hi",_0x2c56b2.data))return;try{e[d(1129)](_0x4f4fe0,this,_0x26ebc1,[_0x194ec5,_0x33177d,_0x4580f7,_0x5b02ba,_0x2320b9,_0x233834])}catch(y){let E=_0x2f94a7(d(796),{message:y[d(1554)],code:_0x2b9708["MESSAGE_"+d(1426)],error:y});this["_dispatc"+d(1260)+d(495)](E)}}else{if(e[d(1837)](null,n))throw new Error(e[d(1966)]);e[d(1837)](e[d(1527)],typeof n)&&(n=JSON[d(1180)+"y"](n)),e[d(583)](e[d(1752)],typeof n)&&!e[d(1217)](n,ArrayBuffer)&&!(n.buffer&&e[d(721)](n[d(643)],ArrayBuffer))&&(n=JSON[d(1180)+"y"](n));let l=await e.omUdm(E0,n),g=e[d(1238)](th,n),{method:y=0,service:E=this._options[d(1944)],logID:p=this._options[d(742)+d(460)](),headers:P=this._options.headers,payloadEncoding:T=this[d(1519)][d(656)+d(499)],payloadType:B=this[d(1519)][d(1089)+"ype"],logIDNew:q=this[d(1519)][d(1063)+"Config"][d(748)+"toGenera"+d(1562)+"ew"]?s(this[d(1519)][d(1063)+d(1938)][d(1780)]):""}=e[d(1289)](i,{});if(!E)throw new Error(e.EAnPN);let $={SeqID:oe[d(1591)+"er"](this[d(1034)]++),LogID:oe.fromNumber(p),service:E,method:y,headers:P,payloadEncoding:e[d(884)](T,Object)?T.encoding?T[d(1231)]:"":T,payloadType:e[d(531)](B,Object)?B[d(1381)]?B[d(1381)]:g:B||g,payload:l,LogIDNew:q},Y=e[d(1523)](He,$);return this._ws&&e.lTYqs(this[d(953)][d(1568)+"te"],this[d(940)])?(this._ws&&this._ws[d(1330)](Y),this[d(984)](e[d(869)],$)):e[d(660)](this[d(1044)+"Queue"][d(1955)],this[d(1519)][d(1199)+d(881)+d(995)])?(this[d(1044)+d(1103)][d(793)](Y),this[d(984)](e[d(1985)],$)):(this[d(1044)+d(1103)][d(1242)](),this[d(1044)+d(1103)][d(793)](Y)),{seqID:this[d(1034)],logID:p,logIDNew:q}}}async[t(658)+"t"](n){let i=t;if(e[i(1584)](e[i(534)],e[i(1615)])){let{url:d}=n||{},l=Array[i(1741)](d)?d:e[i(1045)](i(738),typeof d)?[d]:[];n&&Object[i(801)](this[i(1519)],n),l&&l[i(1955)]?this[i(1574)+"tManager"]=new w0(l,this[i(1519)][i(872)+"es"]):this[i(1574)+i(1871)]?.[i(958)+"pointCon"+i(1447)](),this[i(2016)+i(1980)]?.resetCounter(this[i(1519)][i(493)+i(974)]),this[i(791)+i(1120)]=!1,this._ws&&this._ws[i(1568)+"te"]!==this[i(756)]?this[i(1351)+i(628)](1e3,e[i(689)],!0):(this[i(479)]=!0,this._connect())}else{let d=this[i(1113)][i(1475)](this[i(546)]),l=_0x309ace[i(1196)](e[i(1149)](d,"{}"));return l[_0x61502e]=void 0,this._qosDB[i(1988)](this[i(546)],_0x41aa71.stringify(l))}}async[t(537)](){let n=t;if(!this[n(986)+"Lock"]){let i=e[n(503)][n(1232)]("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(986)]();continue;case"1":this[n(479)]=!0;continue;case"2":this[n(2016)+n(1980)]?.[n(760)+n(491)]();continue;case"3":this[n(791)+"osed"]=!1;continue;case"4":this[n(1574)+n(1871)]?.["resetEnd"+n(733)+"fig"]();continue}break}}}[t(1920)+t(2007)](n,i){this.on(n,i)}[t(1486)+"Event"](n){let i=t,{type:d}=n;this[i(1150)](d,n)}["removeEv"+t(563)+"ner"](n,i){this[t(1462)](n,i)}[t(1485)](){let n=t,i={cmNfW:e.AzRxU,UWkOp:e.iGKXQ,msDuA:n(846),KjUeE:function(d,l){return e.RiWre(d,l)},zkEPP:e.myaYz,VYcOs:e.qRzNr,gJONy:e[n(1295)]};if(e[n(825)](n(1839),e[n(1516)]))_0x21ce51=e.egcGX(_0x2e73bc,_0x587359),_0x122a21|=e[n(1719)](127&_0x589f0d,14),e.vMRXw(128,_0x1afd59)&&(_0x339d22=_0x1a7789(_0x2c2284),_0x1eed85|=e[n(627)](e[n(1452)](127,_0x23125e),21),e[n(1084)](128,_0x359386)&&(_0xb828c8=e[n(836)](_0x5487a8,_0x29ab3c),_0x41030d=e[n(1534)](127,_0x3fe0a4),128&_0x1b1027&&(_0x440cb0=_0x3f30ea(_0x360b94),_0x529ef3|=e[n(912)](e[n(569)](127,_0xdfdfb4),7))));else return new Promise((d,l)=>{let g=n,y={xIwlU:function(P,T){return P(T)},WevRU:i.cmNfW,UgLdD:g(581)+g(766)+"s",Ehcpw:function(P,T){return P!==T},TMJQk:i.UWkOp,lZdjC:i.msDuA,YsyHz:function(P,T){return i[g(1746)](P,T)},oOijI:i[g(1960)],jrIYr:i[g(1840)]};this[g(2027)+"ngTimer"](),this["_pingPon"+g(1909)+"Id"]=setTimeout(this[g(1477)][g(923)](this),this[g(1519)][g(1218)+"rval"]);let E=()=>{let P=g;y[P(1651)](d,y[P(1595)]),this[P(1462)](y[P(1692)],E),this.off("ping_onc"+P(750)+"t",p)},p=()=>{let P=g;y[P(535)](y[P(612)],y[P(1706)])?(y[P(1860)](l,y[P(1875)]),this[P(1462)](y[P(1692)],E),this[P(1462)](y[P(1216)],p)):_0x101789.d=(T,B)=>{for(var q in B)_0x32e863.o(B,q)&&!_0x330451.o(T,q)&&_0x272ea8.defineProperty(T,q,{enumerable:!0,get:B[q]})}};this.on(i[g(1418)],E),this.on("ping_onc"+g(750)+"t",p),this._ping()})}}})(),Se[M(749)+M(586)]=be[M(749)+M(586)],Se[M(988)+M(1075)]=be["CustomEr"+M(1075)],Se.ErrorCode=be[M(1721)+"e"],Se[M(562)]=be[M(562)],Se[M(669)]=be[M(669)],Se[M(895)+M(1623)+"vent"]=be[M(895)+M(1623)+"vent"],Se.MessageEvent=be[M(1623)+M(1956)],Se[M(1817)+"t"]=be[M(1817)+"t"],Se[M(1274)+M(976)]=be["Reconnec"+M(976)],Se[M(1825)+M(586)]=be[M(1825)+"oseEvent"],Se[M(1264)+M(1075)]=be["createEr"+M(1075)],Se[M(1448)+M(774)+"nt"]=be["createMe"+M(774)+"nt"],Se[M(771)+"enEvent"]=be[M(771)+M(1138)],Se[M(1052)+"connectE"+M(1956)]=be[M(1052)+"connectE"+M(1956)],Se[M(1017)+M(716)]=be["decodedF"+M(716)],Se["encodeFr"+M(1723)]=be["encodeFr"+M(1723)];for(Js in be)[M(749)+"oseEvent","CustomEr"+M(1075),M(1721)+"e",M(562),M(669),M(895)+M(1623)+M(1956),"MessageE"+M(1956),M(1817)+"t",M(1274)+"tEvent","createCl"+M(586),"createEr"+M(1075),M(1448)+M(774)+"nt",M(771)+M(1138),"createRe"+M(1066)+"vent",M(1017)+M(716),M(1342)+M(1723)][M(1806)](Js)===-1&&(Se[Js]=be[Js]);var Js;Object[M(871)+"operty"](Se,M(540)+"le",{value:!0})});var Mt=ne((SI,ul)=>{"use strict";var dl=["nodebuffer","arraybuffer","fragments"],fl=typeof Blob<"u";fl&&dl.push("blob");ul.exports={BINARY_TYPES:dl,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:fl,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ei=ne((II,no)=>{"use strict";var{EMPTY_BUFFER:_y}=Mt(),Sc=Buffer[Symbol.species];function yy(t,e){if(t.length===0)return _y;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 Sc(r.buffer,r.byteOffset,s):r}function ll(t,e,r,s,a){for(let c=0;c<a;c++)r[s+c]=t[c]^e[c&3]}function xl(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function by(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Ic(t){if(Ic.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Sc(t):ArrayBuffer.isView(t)?e=new Sc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Ic.readOnly=!1),e}no.exports={concat:yy,mask:ll,toArrayBuffer:by,toBuffer:Ic,unmask:xl};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ae("bufferutil");no.exports.mask=function(e,r,s,a,c){c<48?ll(e,r,s,a,c):t.mask(e,r,s,a,c)},no.exports.unmask=function(e,r){e.length<32?xl(e,r):t.unmask(e,r)}}catch{}});var gl=ne((AI,pl)=>{"use strict";var hl=Symbol("kDone"),Ac=Symbol("kRun"),Cc=class{constructor(e){this[hl]=()=>{this.pending--,this[Ac]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ac]()}[Ac](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[hl])}}};pl.exports=Cc});var vr=ne((CI,yl)=>{"use strict";var vi=ae("zlib"),ml=Ei(),Ey=gl(),{kStatusCode:wl}=Mt(),vy=Buffer[Symbol.species],Sy=Buffer.from([0,0,255,255]),io=Symbol("permessage-deflate"),Bt=Symbol("total-length"),br=Symbol("callback"),xn=Symbol("buffers"),Er=Symbol("error"),ro,Tc=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,!ro){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ro=new Ey(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){ro.add(a=>{this._decompress(e,r,(c,f)=>{a(),s(c,f)})})}compress(e,r,s){ro.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"?vi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=vi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[io]=this,this._inflate[Bt]=0,this._inflate[xn]=[],this._inflate.on("error",Ay),this._inflate.on("data",_l)}this._inflate[br]=s,this._inflate.write(e),r&&this._inflate.write(Sy),this._inflate.flush(()=>{let c=this._inflate[Er];if(c){this._inflate.close(),this._inflate=null,s(c);return}let f=ml.concat(this._inflate[xn],this._inflate[Bt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Bt]=0,this._inflate[xn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),s(null,f)})}_compress(e,r,s){let a=this._isServer?"server":"client";if(!this._deflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?vi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=vi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Bt]=0,this._deflate[xn]=[],this._deflate.on("data",Iy)}this._deflate[br]=s,this._deflate.write(e),this._deflate.flush(vi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=ml.concat(this._deflate[xn],this._deflate[Bt]);r&&(c=new vy(c.buffer,c.byteOffset,c.length-4)),this._deflate[br]=null,this._deflate[Bt]=0,this._deflate[xn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),s(null,c)})}};yl.exports=Tc;function Iy(t){this[xn].push(t),this[Bt]+=t.length}function _l(t){if(this[Bt]+=t.length,this[io]._maxPayload<1||this[Bt]<=this[io]._maxPayload){this[xn].push(t);return}this[Er]=new RangeError("Max payload size exceeded"),this[Er].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Er][wl]=1009,this.removeListener("data",_l),this.reset()}function Ay(t){if(this[io]._inflate=null,this[Er]){this[br](this[Er]);return}t[wl]=1007,this[br](t)}});var Sr=ne((TI,so)=>{"use strict";var{isUtf8:bl}=ae("buffer"),{hasBlob:Cy}=Mt(),Ty=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Ry(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Rc(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 Dy(t){return Cy&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}so.exports={isBlob:Dy,isValidStatusCode:Ry,isValidUTF8:Rc,tokenChars:Ty};if(bl)so.exports.isValidUTF8=function(t){return t.length<24?Rc(t):bl(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ae("utf-8-validate");so.exports.isValidUTF8=function(e){return e.length<32?Rc(e):t(e)}}catch{}});var Oc=ne((RI,Tl)=>{"use strict";var{Writable:ky}=ae("stream"),El=vr(),{BINARY_TYPES:Py,EMPTY_BUFFER:vl,kStatusCode:Ly,kWebSocket:Oy}=Mt(),{concat:Dc,toArrayBuffer:Ny,unmask:My}=Ei(),{isValidStatusCode:By,isValidUTF8:Sl}=Sr(),oo=Buffer[Symbol.species],Qe=0,Il=1,Al=2,Cl=3,kc=4,Pc=5,ao=6,Lc=class extends ky{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Py[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Oy]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=Qe}_write(e,r,s){if(this._opcode===8&&this._state==Qe)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 oo(s.buffer,s.byteOffset+e,s.length-e),new oo(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 oo(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 Qe:this.getInfo(e);break;case Il:this.getPayloadLength16(e);break;case Al:this.getPayloadLength64(e);break;case Cl:this.getMask();break;case kc:this.getData(e);break;case Pc:case ao: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[El.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=Il:this._payloadLength===127?this._state=Al:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),s=r.readUInt32BE(0);if(s>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=s*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Cl:this._state=kc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=kc}getData(e){let r=vl;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&&My(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Pc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[El.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===Qe&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=Qe;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=Dc(s,r):this._binaryType==="arraybuffer"?a=Ny(Dc(s,r)):this._binaryType==="blob"?a=new Blob(s):a=s,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=Qe):(this._state=ao,setImmediate(()=>{this.emit("message",a,!0),this._state=Qe,this.startLoop(e)}))}else{let a=Dc(s,r);if(!this._skipUTF8Validation&&!Sl(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Pc||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=Qe):(this._state=ao,setImmediate(()=>{this.emit("message",a,!1),this._state=Qe,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,vl),this.end();else{let s=e.readUInt16BE(0);if(!By(s)){let c=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let a=new oo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Sl(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=Qe;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Qe):(this._state=ao,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Qe,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[Ly]=a,f}};Tl.exports=Lc});var Bc=ne((kI,kl)=>{"use strict";var{Duplex:DI}=ae("stream"),{randomFillSync:zy}=ae("crypto"),Rl=vr(),{EMPTY_BUFFER:Fy,kWebSocket:Uy,NOOP:qy}=Mt(),{isBlob:Ir,isValidStatusCode:Hy}=Sr(),{mask:Dl,toBuffer:Ln}=Ei(),et=Symbol("kByteLength"),jy=Buffer.alloc(4),co=8*1024,On,Ar=co,ut=0,Gy=1,Wy=2,Nc=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=ut,this.onerror=qy,this[Uy]=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):(Ar===co&&(On===void 0&&(On=Buffer.alloc(co)),zy(On,0,co),Ar=0),s[0]=On[Ar++],s[1]=On[Ar++],s[2]=On[Ar++],s[3]=On[Ar++]),f=(s[0]|s[1]|s[2]|s[3])===0,c=6);let u;typeof e=="string"?(!r.mask||f)&&r[et]!==void 0?u=r[et]:(e=Buffer.from(e),u=e.length):(u=e.length,a=r.mask&&r.readOnly&&!f);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(a?u+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(u,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(u,4,6)),r.mask?(h[1]|=128,h[c-4]=s[0],h[c-3]=s[1],h[c-2]=s[2],h[c-1]=s[3],f?[h,e]:a?(Dl(e,s,h,c,u),[h]):(Dl(e,s,e,0,u),[h,e])):[h,e]}close(e,r,s,a){let c;if(e===void 0)c=Fy;else{if(typeof e!="number"||!Hy(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let f={[et]:c.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==ut?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):Ir(e)?(a=e.size,c=!1):(e=Ln(e),a=e.length,c=Ln.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[et]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Ir(e)?this._state!==ut?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==ut?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):Ir(e)?(a=e.size,c=!1):(e=Ln(e),a=e.length,c=Ln.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[et]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Ir(e)?this._state!==ut?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==ut?this.enqueue([this.dispatch,e,!1,f,s]):this.sendFrame(t.frame(e,f),s)}send(e,r,s){let a=this._extensions[Rl.extensionName],c=r.binary?2:1,f=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):Ir(e)?(u=e.size,x=!1):(e=Ln(e),u=e.length,x=Ln.readOnly),this._firstFragment?(this._firstFragment=!1,f&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=u>=a._threshold),this._compress=f):(f=!1,c=0),r.fin&&(this._firstFragment=!0);let h={[et]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:f};Ir(e)?this._state!==ut?this.enqueue([this.getBlobData,e,this._compress,h,s]):this.getBlobData(e,this._compress,h,s):this._state!==ut?this.enqueue([this.dispatch,e,this._compress,h,s]):this.dispatch(e,this._compress,h,s)}getBlobData(e,r,s,a){this._bufferedBytes+=s[et],this._state=Wy,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Mc,this,u,a);return}this._bufferedBytes-=s[et];let f=Ln(c);r?this.dispatch(f,r,s,a):(this._state=ut,this.sendFrame(t.frame(f,s),a),this.dequeue())}).catch(c=>{process.nextTick(Ky,this,c,a)})}dispatch(e,r,s,a){if(!r){this.sendFrame(t.frame(e,s),a);return}let c=this._extensions[Rl.extensionName];this._bufferedBytes+=s[et],this._state=Gy,c.compress(e,s.fin,(f,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Mc(this,x,a);return}this._bufferedBytes-=s[et],this._state=ut,s.readOnly=!1,this.sendFrame(t.frame(u,s),a),this.dequeue()})}dequeue(){for(;this._state===ut&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][et],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][et],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)}};kl.exports=Nc;function Mc(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 Ky(t,e,r){Mc(t,e,r),t.onerror(e)}});var Ul=ne((PI,Fl)=>{"use strict";var{kForOnEventAttribute:Si,kListener:zc}=Mt(),Pl=Symbol("kCode"),Ll=Symbol("kData"),Ol=Symbol("kError"),Nl=Symbol("kMessage"),Ml=Symbol("kReason"),Cr=Symbol("kTarget"),Bl=Symbol("kType"),zl=Symbol("kWasClean"),zt=class{constructor(e){this[Cr]=null,this[Bl]=e}get target(){return this[Cr]}get type(){return this[Bl]}};Object.defineProperty(zt.prototype,"target",{enumerable:!0});Object.defineProperty(zt.prototype,"type",{enumerable:!0});var Nn=class extends zt{constructor(e,r={}){super(e),this[Pl]=r.code===void 0?0:r.code,this[Ml]=r.reason===void 0?"":r.reason,this[zl]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Pl]}get reason(){return this[Ml]}get wasClean(){return this[zl]}};Object.defineProperty(Nn.prototype,"code",{enumerable:!0});Object.defineProperty(Nn.prototype,"reason",{enumerable:!0});Object.defineProperty(Nn.prototype,"wasClean",{enumerable:!0});var Tr=class extends zt{constructor(e,r={}){super(e),this[Ol]=r.error===void 0?null:r.error,this[Nl]=r.message===void 0?"":r.message}get error(){return this[Ol]}get message(){return this[Nl]}};Object.defineProperty(Tr.prototype,"error",{enumerable:!0});Object.defineProperty(Tr.prototype,"message",{enumerable:!0});var Ii=class extends zt{constructor(e,r={}){super(e),this[Ll]=r.data===void 0?null:r.data}get data(){return this[Ll]}};Object.defineProperty(Ii.prototype,"data",{enumerable:!0});var Vy={addEventListener(t,e,r={}){for(let a of this.listeners(t))if(!r[Si]&&a[zc]===e&&!a[Si])return;let s;if(t==="message")s=function(c,f){let u=new Ii("message",{data:f?c:c.toString()});u[Cr]=this,fo(e,this,u)};else if(t==="close")s=function(c,f){let u=new Nn("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Cr]=this,fo(e,this,u)};else if(t==="error")s=function(c){let f=new Tr("error",{error:c,message:c.message});f[Cr]=this,fo(e,this,f)};else if(t==="open")s=function(){let c=new zt("open");c[Cr]=this,fo(e,this,c)};else return;s[Si]=!!r[Si],s[zc]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[zc]===e&&!r[Si]){this.removeListener(t,r);break}}};Fl.exports={CloseEvent:Nn,ErrorEvent:Tr,Event:zt,EventTarget:Vy,MessageEvent:Ii};function fo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var uo=ne((LI,ql)=>{"use strict";var{tokenChars:Ai}=Sr();function At(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function $y(t){let e=Object.create(null),r=Object.create(null),s=!1,a=!1,c=!1,f,u,x=-1,h=-1,m=-1,v=0;for(;v<t.length;v++)if(h=t.charCodeAt(v),f===void 0)if(m===-1&&Ai[h]===1)x===-1&&(x=v);else if(v!==0&&(h===32||h===9))m===-1&&x!==-1&&(m=v);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${v}`);m===-1&&(m=v);let _=t.slice(x,m);h===44?(At(e,_,r),r=Object.create(null)):f=_,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${v}`);else if(u===void 0)if(m===-1&&Ai[h]===1)x===-1&&(x=v);else if(h===32||h===9)m===-1&&x!==-1&&(m=v);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${v}`);m===-1&&(m=v),At(r,t.slice(x,m),!0),h===44&&(At(e,f,r),r=Object.create(null),f=void 0),x=m=-1}else if(h===61&&x!==-1&&m===-1)u=t.slice(x,v),x=m=-1;else throw new SyntaxError(`Unexpected character at index ${v}`);else if(a){if(Ai[h]!==1)throw new SyntaxError(`Unexpected character at index ${v}`);x===-1?x=v:s||(s=!0),a=!1}else if(c)if(Ai[h]===1)x===-1&&(x=v);else if(h===34&&x!==-1)c=!1,m=v;else if(h===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${v}`);else if(h===34&&t.charCodeAt(v-1)===61)c=!0;else if(m===-1&&Ai[h]===1)x===-1&&(x=v);else if(x!==-1&&(h===32||h===9))m===-1&&(m=v);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${v}`);m===-1&&(m=v);let _=t.slice(x,m);s&&(_=_.replace(/\\/g,""),s=!1),At(r,u,_),h===44&&(At(e,f,r),r=Object.create(null),f=void 0),u=void 0,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${v}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=v);let A=t.slice(x,m);return f===void 0?At(e,A,r):(u===void 0?At(r,A,!0):s?At(r,u,A.replace(/\\/g,"")):At(r,u,A),At(e,f,r)),e}function Jy(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(a=>{let c=s[a];return Array.isArray(c)||(c=[c]),c.map(f=>f===!0?a:`${a}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}ql.exports={format:Jy,parse:$y}});var po=ne((MI,Ql)=>{"use strict";var Zy=ae("events"),Yy=ae("https"),Xy=ae("http"),Gl=ae("net"),Qy=ae("tls"),{randomBytes:eb,createHash:tb}=ae("crypto"),{Duplex:OI,Readable:NI}=ae("stream"),{URL:Fc}=ae("url"),hn=vr(),nb=Oc(),rb=Bc(),{isBlob:ib}=Sr(),{BINARY_TYPES:Hl,CLOSE_TIMEOUT:sb,EMPTY_BUFFER:lo,GUID:ob,kForOnEventAttribute:Uc,kListener:ab,kStatusCode:cb,kWebSocket:Le,NOOP:Wl}=Mt(),{EventTarget:{addEventListener:db,removeEventListener:fb}}=Ul(),{format:ub,parse:lb}=uo(),{toBuffer:xb}=Ei(),Kl=Symbol("kAborted"),qc=[8,13],Ft=["CONNECTING","OPEN","CLOSING","CLOSED"],hb=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,de=class t extends Zy{constructor(e,r,s){super(),this._binaryType=Hl[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=lo,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]),Vl(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Hl.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 nb({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),c=new rb(e,this._extensions,s.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[Le]=this,c[Le]=this,e[Le]=this,a.on("conclude",mb),a.on("drain",wb),a.on("error",_b),a.on("message",yb),a.on("ping",bb),a.on("pong",Eb),c.onerror=vb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Zl),e.on("data",ho),e.on("end",Yl),e.on("error",Xl),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[hn.extensionName]&&this._extensions[hn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Je(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())}),Jl(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){Hc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||lo,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){Hc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||lo,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){Hc(this,e,s);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[hn.extensionName]||(a.compress=!1),this._sender.send(e||lo,a,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Je(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:Ft.indexOf("CONNECTING")});Object.defineProperty(de.prototype,"CONNECTING",{enumerable:!0,value:Ft.indexOf("CONNECTING")});Object.defineProperty(de,"OPEN",{enumerable:!0,value:Ft.indexOf("OPEN")});Object.defineProperty(de.prototype,"OPEN",{enumerable:!0,value:Ft.indexOf("OPEN")});Object.defineProperty(de,"CLOSING",{enumerable:!0,value:Ft.indexOf("CLOSING")});Object.defineProperty(de.prototype,"CLOSING",{enumerable:!0,value:Ft.indexOf("CLOSING")});Object.defineProperty(de,"CLOSED",{enumerable:!0,value:Ft.indexOf("CLOSED")});Object.defineProperty(de.prototype,"CLOSED",{enumerable:!0,value:Ft.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[Uc])return e[ab];return null},set(e){for(let r of this.listeners(t))if(r[Uc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Uc]:!0})}})});de.prototype.addEventListener=db;de.prototype.removeEventListener=fb;Ql.exports=de;function Vl(t,e,r,s){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:sb,protocolVersion:qc[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,!qc.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${qc.join(", ")})`);let c;if(e instanceof Fc)c=e;else try{c=new Fc(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let f=c.protocol==="wss:",u=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!f&&!u?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let S=new SyntaxError(x);if(t._redirects===0)throw S;xo(t,S);return}let h=f?443:80,m=eb(16).toString("base64"),v=f?Yy.request:Xy.request,A=new Set,_;if(a.createConnection=a.createConnection||(f?gb:pb),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 hn({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=ub({[hn.extensionName]:_.offer()})),r.length){for(let S of r){if(typeof S!="string"||!hb.test(S)||A.has(S))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(S)}a.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(c.username||c.password)&&(a.auth=`${c.username}:${c.password}`),u){let S=a.path.split(":");a.socketPath=S[0],a.path=S[1]}let b;if(a.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=f,t._originalHostOrSocketPath=u?a.socketPath:c.host;let S=s&&s.headers;if(s={...s,headers:{}},S)for(let[I,D]of Object.entries(S))s.headers[I.toLowerCase()]=D}else if(t.listenerCount("redirect")===0){let S=u?t._originalIpc?a.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!S||t._originalSecure&&!f)&&(delete a.headers.authorization,delete a.headers.cookie,S||delete a.headers.host,a.auth=void 0)}a.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),b=t._req=v(a),t._redirects&&t.emit("redirect",t.url,b)}else b=t._req=v(a);a.timeout&&b.on("timeout",()=>{Je(t,b,"Opening handshake has timed out")}),b.on("error",S=>{b===null||b[Kl]||(b=t._req=null,xo(t,S))}),b.on("response",S=>{let I=S.headers.location,D=S.statusCode;if(I&&a.followRedirects&&D>=300&&D<400){if(++t._redirects>a.maxRedirects){Je(t,b,"Maximum redirects exceeded");return}b.abort();let O;try{O=new Fc(I,e)}catch{let C=new SyntaxError(`Invalid URL: ${I}`);xo(t,C);return}Vl(t,O,r,s)}else t.emit("unexpected-response",b,S)||Je(t,b,`Unexpected server response: ${S.statusCode}`)}),b.on("upgrade",(S,I,D)=>{if(t.emit("upgrade",S),t.readyState!==de.CONNECTING)return;b=t._req=null;let O=S.headers.upgrade;if(O===void 0||O.toLowerCase()!=="websocket"){Je(t,I,"Invalid Upgrade header");return}let w=tb("sha1").update(m+ob).digest("base64");if(S.headers["sec-websocket-accept"]!==w){Je(t,I,"Invalid Sec-WebSocket-Accept header");return}let C=S.headers["sec-websocket-protocol"],L;if(C!==void 0?A.size?A.has(C)||(L="Server sent an invalid subprotocol"):L="Server sent a subprotocol but none was requested":A.size&&(L="Server sent no subprotocol"),L){Je(t,I,L);return}C&&(t._protocol=C);let F=S.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){Je(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=lb(F)}catch{Je(t,I,"Invalid Sec-WebSocket-Extensions header");return}let k=Object.keys(z);if(k.length!==1||k[0]!==hn.extensionName){Je(t,I,"Server indicated an extension that was not requested");return}try{_.accept(z[hn.extensionName])}catch{Je(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[hn.extensionName]=_}t.setSocket(I,D,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(b,t):b.end()}function xo(t,e){t._readyState=de.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function pb(t){return t.path=t.socketPath,Gl.connect(t)}function gb(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Gl.isIP(t.host)?"":t.host),Qy.connect(t)}function Je(t,e,r){t._readyState=de.CLOSING;let s=new Error(r);Error.captureStackTrace(s,Je),e.setHeader?(e[Kl]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(xo,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Hc(t,e,r){if(e){let s=ib(e)?e.size:xb(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ft[t.readyState]})`);process.nextTick(r,s)}}function mb(t,e){let r=this[Le];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Le]!==void 0&&(r._socket.removeListener("data",ho),process.nextTick($l,r._socket),t===1005?r.close():r.close(t,e))}function wb(){let t=this[Le];t.isPaused||t._socket.resume()}function _b(t){let e=this[Le];e._socket[Le]!==void 0&&(e._socket.removeListener("data",ho),process.nextTick($l,e._socket),e.close(t[cb])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function jl(){this[Le].emitClose()}function yb(t,e){this[Le].emit("message",t,e)}function bb(t){let e=this[Le];e._autoPong&&e.pong(t,!this._isServer,Wl),e.emit("ping",t)}function Eb(t){this[Le].emit("pong",t)}function $l(t){t.resume()}function vb(t){let e=this[Le];e.readyState!==de.CLOSED&&(e.readyState===de.OPEN&&(e._readyState=de.CLOSING,Jl(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Jl(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Zl(){let t=this[Le];if(this.removeListener("close",Zl),this.removeListener("data",ho),this.removeListener("end",Yl),t._readyState=de.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Le]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",jl),t._receiver.on("finish",jl))}function ho(t){this[Le]._receiver.write(t)||this.pause()}function Yl(){let t=this[Le];t._readyState=de.CLOSING,t._receiver.end(),this.end()}function Xl(){let t=this[Le];this.removeListener("error",Xl),this.on("error",Wl),t&&(t._readyState=de.CLOSING,this.destroy())}});var rx=ne((zI,nx)=>{"use strict";var BI=po(),{Duplex:Sb}=ae("stream");function ex(t){t.emit("close")}function Ib(){!this.destroyed&&this._writableState.finished&&this.destroy()}function tx(t){this.removeListener("error",tx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Ab(t,e){let r=!0,s=new Sb({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,f){let u=!f&&s._readableState.objectMode?c.toString():c;s.push(u)||t.pause()}),t.once("error",function(c){s.destroyed||(r=!1,s.destroy(c))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(a,c){if(t.readyState===t.CLOSED){c(a),process.nextTick(ex,s);return}let f=!1;t.once("error",function(x){f=!0,c(x)}),t.once("close",function(){f||c(a),process.nextTick(ex,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",Ib),s.on("error",tx),s}nx.exports=Ab});var jc=ne((FI,ix)=>{"use strict";var{tokenChars:Cb}=Sr();function Tb(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&&Cb[f]===1)r===-1&&(r=a);else if(a!==0&&(f===32||f===9))s===-1&&r!==-1&&(s=a);else if(f===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${a}`);s===-1&&(s=a);let u=t.slice(r,s);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,a);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}ix.exports={parse:Tb}});var ux=ne((qI,fx)=>{"use strict";var Rb=ae("events"),go=ae("http"),{Duplex:UI}=ae("stream"),{createHash:Db}=ae("crypto"),sx=uo(),Mn=vr(),kb=jc(),Pb=po(),{CLOSE_TIMEOUT:Lb,GUID:Ob,kWebSocket:Nb}=Mt(),Mb=/^[+/0-9A-Za-z]{22}==$/,ox=0,ax=1,dx=2,Gc=class extends Rb{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Lb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Pb,...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=go.createServer((s,a)=>{let c=go.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=Bb(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=ox}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===dx){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!==ax)if(this._state=ax,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",cx);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Bn(this,e,r,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){Bn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Mb.test(c)){Bn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Bn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ti(r,400);return}let x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=kb.parse(x)}catch{Bn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],v={};if(this.options.perMessageDeflate&&m!==void 0){let A=new Mn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=sx.parse(m);_[Mn.extensionName]&&(A.accept(_[Mn.extensionName]),v[Mn.extensionName]=A)}catch{Bn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(_,b,S,I)=>{if(!_)return Ti(r,b||401,S,I);this.completeUpgrade(v,c,h,e,r,s,a)});return}if(!this.options.verifyClient(A))return Ti(r,401)}this.completeUpgrade(v,c,h,e,r,s,a)}completeUpgrade(e,r,s,a,c,f,u){if(!c.readable||!c.writable)return c.destroy();if(c[Nb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ox)return Ti(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Db("sha1").update(r+Ob).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(s.size){let v=this.options.handleProtocols?this.options.handleProtocols(s,a):s.values().next().value;v&&(h.push(`Sec-WebSocket-Protocol: ${v}`),m._protocol=v)}if(e[Mn.extensionName]){let v=e[Mn.extensionName].params,A=sx.format({[Mn.extensionName]:[v]});h.push(`Sec-WebSocket-Extensions: ${A}`),m._extensions=e}this.emit("headers",h,a),c.write(h.concat(`\r
14
14
  `).join(`\r
15
- `)),c.removeListener("error",ch),w.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(w),w.on("close",()=>{this.clients.delete(w),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ci,this)})),u(w,o)}};lh.exports=Wc;function Mb(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=dh,t.emit("close")}function ch(){this.destroy()}function Ri(t,e,r,i){r=r||wo.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} ${wo.STATUS_CODES[e]}\r
16
- `+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
15
+ `)),c.removeListener("error",cx),m.setSocket(c,f,{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)})),u(m,a)}};fx.exports=Gc;function Bb(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let s of Object.keys(e))t.removeListener(s,e[s])}}function Ci(t){t._state=dx,t.emit("close")}function cx(){this.destroy()}function Ti(t,e,r,s){r=r||go.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${go.STATUS_CODES[e]}\r
16
+ `+Object.keys(s).map(a=>`${a}: ${s[a]}`).join(`\r
17
17
  `)+`\r
18
18
  \r
19
- `+r)}function Bn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Bn),t.emit("wsClientError",l,r,e)}else Ri(r,i,o,c)}});import{existsSync as lE,openSync as fE}from"node:fs";import{mkdir as uE}from"node:fs/promises";import{dirname as hE}from"node:path";import{fileURLToPath as xE}from"node:url";function Jc(t=te()){return lE(t.libEntry)?t.libEntry:xE(new URL("../index.ts",import.meta.url))}async function Zc(t={}){let e=t.paths??te(),r=t.entryOverride??Jc(e);await uE(hE(e.logFile),{recursive:!0});let i=fE(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],l=Gn(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 pE.info("daemon spawned",{pid:l.pid,entry:r}),{pid:l.pid,entry:r}}var pE,Yc=ct(()=>{"use strict";Kn();ee();Fe();pE=q("spawn-daemon")});import{spawn as DE}from"node:child_process";import{mkdir as kE,unlink as PE,writeFile as LE}from"node:fs/promises";import{dirname as OE,join as NE}from"node:path";function To(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Lh(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 Ao,td,nd,Oh=ct(()=>{"use strict";ee();Ao=q("supervisor.launchd"),td="ai.coze.bridge",nd={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
19
+ `+r)}function Bn(t,e,r,s,a,c){if(t.listenerCount("wsClientError")){let f=new Error(a);Error.captureStackTrace(f,Bn),t.emit("wsClientError",f,r,e)}else Ti(r,s,a,c)}});import{existsSync as uE,openSync as lE}from"node:fs";import{mkdir as xE}from"node:fs/promises";import{dirname as hE}from"node:path";import{fileURLToPath as pE}from"node:url";function $c(t=te()){return uE(t.libEntry)?t.libEntry:pE(new URL("../index.ts",import.meta.url))}async function Jc(t={}){let e=t.paths??te(),r=t.entryOverride??$c(e);await xE(hE(e.logFile),{recursive:!0});let s=lE(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],f=Gn(process.execPath,c,{detached:!0,stdio:["ignore",s,s],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return gE.info("daemon spawned",{pid:f.pid,entry:r}),{pid:f.pid,entry:r}}var gE,Zc=st(()=>{"use strict";Kn();ee();Me();gE=j("spawn-daemon")});import{spawn as kE}from"node:child_process";import{mkdir as PE,unlink as LE,writeFile as OE}from"node:fs/promises";import{dirname as NE,join as ME}from"node:path";function Io(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ox(t,e){return new Promise((r,s)=>{let a=kE(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var So,e0,t0,Nx=st(()=>{"use strict";ee();So=j("supervisor.launchd"),e0="ai.coze.bridge",t0={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
20
20
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
21
21
  <plist version="1.0">
22
22
  <dict>
23
23
  <key>Label</key>
24
- <string>${td}</string>
24
+ <string>${e0}</string>
25
25
  <key>ProgramArguments</key>
26
26
  <array>
27
- <string>${To(t.nodeBin)}</string>
28
- <string>${To(t.entry)}</string>
27
+ <string>${Io(t.nodeBin)}</string>
28
+ <string>${Io(t.entry)}</string>
29
29
  <string>--daemon</string>
30
30
  </array>
31
31
  <key>RunAtLoad</key>
@@ -35,12 +35,12 @@ ${t.stack??""}`:String(t);return np.test(r)||rp.test(r)}function Nd(t){if(t==nul
35
35
  <key>ThrottleInterval</key>
36
36
  <integer>10</integer>
37
37
  <key>StandardOutPath</key>
38
- <string>${To(t.logFile)}</string>
38
+ <string>${Io(t.logFile)}</string>
39
39
  <key>StandardErrorPath</key>
40
- <string>${To(t.logFile)}</string>
40
+ <string>${Io(t.logFile)}</string>
41
41
  </dict>
42
42
  </plist>
43
- `},configPath(t){return NE(t.homeDir,"Library","LaunchAgents",`${td}.plist`)},async install(t){let e=this.configPath(t);await kE(OE(e),{recursive:!0}),await LE(e,this.renderConfig(t),"utf8"),Ao.info("plist written",{plistPath:e}),await Lh("launchctl",["load","-w",e]),Ao.info("launchd job loaded",{label:td})},async uninstall(t){let e=this.configPath(t);await Lh("launchctl",["unload","-w",e]).catch(r=>Ao.warn("launchctl unload failed (ignored)",{err:String(r)})),await PE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Ao.info("launchd job removed",{plistPath:e})}}});import{spawn as ME}from"node:child_process";import{mkdir as BE,unlink as zE,writeFile as FE}from"node:fs/promises";import{dirname as UE,join as HE}from"node:path";function Do(t,e){return new Promise((r,i)=>{let o=ME(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,Ro,rd,Nh=ct(()=>{"use strict";ee();Co=q("supervisor.systemd"),Ro="coze-bridge.service",rd={platform:"linux",renderConfig(t){return`[Unit]
43
+ `},configPath(t){return ME(t.homeDir,"Library","LaunchAgents",`${e0}.plist`)},async install(t){let e=this.configPath(t);await PE(NE(e),{recursive:!0}),await OE(e,this.renderConfig(t),"utf8"),So.info("plist written",{plistPath:e}),await Ox("launchctl",["load","-w",e]),So.info("launchd job loaded",{label:e0})},async uninstall(t){let e=this.configPath(t);await Ox("launchctl",["unload","-w",e]).catch(r=>So.warn("launchctl unload failed (ignored)",{err:String(r)})),await LE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),So.info("launchd job removed",{plistPath:e})}}});import{spawn as BE}from"node:child_process";import{mkdir as zE,unlink as FE,writeFile as UE}from"node:fs/promises";import{dirname as qE,join as HE}from"node:path";function To(t,e){return new Promise((r,s)=>{let a=BE(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Ao,Co,n0,Mx=st(()=>{"use strict";ee();Ao=j("supervisor.systemd"),Co="coze-bridge.service",n0={platform:"linux",renderConfig(t){return`[Unit]
44
44
  Description=Coze Bridge daemon
45
45
  After=network.target
46
46
 
@@ -54,7 +54,7 @@ StandardError=append:${t.logFile}
54
54
 
55
55
  [Install]
56
56
  WantedBy=default.target
57
- `},configPath(t){return HE(t.homeDir,".config","systemd","user",Ro)},async install(t){let e=this.configPath(t);await BE(UE(e),{recursive:!0}),await FE(e,this.renderConfig(t),"utf8"),Co.info("systemd unit written",{unitPath:e}),await Do("systemctl",["--user","daemon-reload"]),await Do("systemctl",["--user","enable","--now",Ro]),Co.info("systemd unit enabled",{unitName:Ro})},async uninstall(t){let e=this.configPath(t);await Do("systemctl",["--user","disable","--now",Ro]).catch(r=>Co.warn("systemctl disable failed (ignored)",{err:String(r)})),await zE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await Do("systemctl",["--user","daemon-reload"]).catch(()=>{}),Co.info("systemd unit removed",{unitPath:e})}}});import{spawn as qE}from"node:child_process";import{join as jE}from"node:path";function Mh(t,e){return new Promise((r,i)=>{let o=qE(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 id,ko,sd,Bh=ct(()=>{"use strict";ee();id=q("supervisor.taskscheduler"),ko="CozeBridge",sd={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
57
+ `},configPath(t){return HE(t.homeDir,".config","systemd","user",Co)},async install(t){let e=this.configPath(t);await zE(qE(e),{recursive:!0}),await UE(e,this.renderConfig(t),"utf8"),Ao.info("systemd unit written",{unitPath:e}),await To("systemctl",["--user","daemon-reload"]),await To("systemctl",["--user","enable","--now",Co]),Ao.info("systemd unit enabled",{unitName:Co})},async uninstall(t){let e=this.configPath(t);await To("systemctl",["--user","disable","--now",Co]).catch(r=>Ao.warn("systemctl disable failed (ignored)",{err:String(r)})),await FE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await To("systemctl",["--user","daemon-reload"]).catch(()=>{}),Ao.info("systemd unit removed",{unitPath:e})}}});import{spawn as jE}from"node:child_process";import{join as GE}from"node:path";function Bx(t,e){return new Promise((r,s)=>{let a=jE(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var r0,Ro,i0,zx=st(()=>{"use strict";ee();r0=j("supervisor.taskscheduler"),Ro="CozeBridge",i0={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
58
58
  <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
59
59
  <RegistrationInfo>
60
60
  <Description>Coze Bridge daemon</Description>
@@ -78,17 +78,17 @@ WantedBy=default.target
78
78
  </Exec>
79
79
  </Actions>
80
80
  </Task>
81
- `},configPath(t){return jE(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 Mh("schtasks",["/Create","/SC","ONLOGON","/TN",ko,"/TR",r,"/RU",t.userName,"/F"]),id.info("task scheduler entry created",{task:ko,logFile:t.logFile})},async uninstall(t){await Mh("schtasks",["/Delete","/TN",ko,"/F"]).catch(e=>id.warn("schtasks /Delete failed (ignored)",{err:String(e)})),id.info("task scheduler entry removed",{task:ko})}}});var zh={};Go(zh,{buildContext:()=>$E,getSupervisor:()=>KE,launchdSupervisor:()=>nd,systemdSupervisor:()=>rd,taskSchedulerSupervisor:()=>sd});import{homedir as GE,userInfo as WE}from"node:os";function KE(t=process.platform){switch(t){case"darwin":return nd;case"linux":return rd;case"win32":return sd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function $E(){let t=te();return{nodeBin:process.execPath,entry:Jc(t),logFile:t.logFile,homeDir:GE(),userName:WE().username}}var Fh=ct(()=>{"use strict";Fe();Yc();Oh();Nh();Bh()});ee();$t();var Bd=q("acp-installer-warmup"),dp=["claude-code","codex"];async function zd(t={}){let e=t.ensure??mn,i=(await Promise.allSettled(dp.map(async o=>{let c=await e(o);Bd.info("acp wrapper warmup ok",{framework:o,installed:!!c,path:c??""})}))).filter(o=>o.status==="rejected");i.length>0&&Bd.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:i.length,reasons:i.map(o=>String(o.reason))})}Vt();ee();import{readdir as vp}from"node:fs/promises";import{mkdir as Gd,writeFile as Wd}from"node:fs/promises";import{join as Jo}from"node:path";var yp={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Jn(t,e,r,i){await Gd(t,{recursive:!0});let o=yp[e],c=Jo(t,o),l=_p(e,r,i);return await Wd(c,l,"utf8"),c}async function Kd(t){let e=Jo(t,".claude");await Gd(e,{recursive:!0});let r=Jo(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Wd(r,i,"utf8"),r}function _p(t,e,r){let i=`# Coze Agent: ${e}
81
+ `},configPath(t){return GE(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 Bx("schtasks",["/Create","/SC","ONLOGON","/TN",Ro,"/TR",r,"/RU",t.userName,"/F"]),r0.info("task scheduler entry created",{task:Ro,logFile:t.logFile})},async uninstall(t){await Bx("schtasks",["/Delete","/TN",Ro,"/F"]).catch(e=>r0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),r0.info("task scheduler entry removed",{task:Ro})}}});var Fx={};Ho(Fx,{buildContext:()=>$E,getSupervisor:()=>VE,launchdSupervisor:()=>t0,systemdSupervisor:()=>n0,taskSchedulerSupervisor:()=>i0});import{homedir as WE,userInfo as KE}from"node:os";function VE(t=process.platform){switch(t){case"darwin":return t0;case"linux":return n0;case"win32":return i0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function $E(){let t=te();return{nodeBin:process.execPath,entry:$c(t),logFile:t.logFile,homeDir:WE(),userName:KE().username}}var Ux=st(()=>{"use strict";Me();Zc();Nx();Mx();zx()});ee();Kt();var B0=j("acp-installer-warmup"),fp=["claude-code","codex"];async function z0(t={}){let e=t.ensure??mn,s=(await Promise.allSettled(fp.map(async a=>{let c=await e(a);B0.info("acp wrapper warmup ok",{framework:a,installed:!!c,path:c??""})}))).filter(a=>a.status==="rejected");s.length>0&&B0.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))})}Vt();ee();import{readdir as Sp}from"node:fs/promises";import{mkdir as G0,writeFile as W0}from"node:fs/promises";import{join as $o}from"node:path";var yp={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Jn(t,e,r,s){await G0(t,{recursive:!0});let a=yp[e],c=$o(t,a),f=bp(e,r,s);return await W0(c,f,"utf8"),c}async function K0(t){let e=$o(t,".claude");await G0(e,{recursive:!0});let r=$o(e,"settings.local.json"),s=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await W0(r,s,"utf8"),r}function bp(t,e,r){let s=`# Coze Agent: ${e}
82
82
 
83
83
  > framework: \`${t}\`
84
84
 
85
- `,o=r?.trim()?r.endsWith(`
85
+ `,a=r?.trim()?r.endsWith(`
86
86
  `)?r:`${r}
87
87
  `:`_No instructions provided._
88
- `;return`${i}---
88
+ `;return`${s}---
89
89
 
90
- ${o}
91
- ${bp()}`}function bp(){let t=process.platform==="win32"?"coze-bridge.cmd":"coze-bridge";return Ep.replace(/\bcoze-bridge\b(?!\.cmd)/g,t)}var Ep=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
90
+ ${a}
91
+ ${Ep()}`}function Ep(){let t=process.platform==="win32"?"coze-bridge.cmd":"coze-bridge";return vp.replace(/\bcoze-bridge\b(?!\.cmd)/g,t)}var vp=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
92
92
 
93
93
  \u6BCF\u6761\u7528\u6237\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u4E91\u7AEF\u6CE8\u5165\u7684 \`<coze-context>\` \u5757, \u5F62\u5982:
94
94
 
@@ -112,29 +112,29 @@ ${bp()}`}function bp(){let t=process.platform==="win32"?"coze-bridge.cmd":"coze-
112
112
  - \`sessionId\` \u5FC5\u987B\u7528\u4E91\u7AEF \`<coze-context>\` \u7ED9\u7684 ID, **\u4E0D\u8981**\u81EA\u5DF1\u7F16\u6216\u8005\u7528\u5176\u5B83\u6765\u6E90
113
113
 
114
114
  \u26A0\uFE0F \u751F\u6210\u6587\u4EF6\u540E\u8BF7**\u7B49\u6587\u4EF6\u5B8C\u6574\u5199\u76D8**\u518D send (\u7528 \`&&\` \u4E32\u884C, \u4E0D\u8981 \`&\` \u540E\u53F0)\u3002
115
- `;var Ve=q("agent-detail-sync"),Sp=6e4,Ip=5*6e4,ji=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await vp(r)}catch(o){Ve.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Ve.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await qe(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Ve.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){Ve.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),Ve.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){Ve.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Ve.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await qe(e,this.opts.paths);if(!i){Ve.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(u){Ve.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let h=this.retryQueue.get(e),p=h?Math.min(h.currentDelay*2,Ip):Sp;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){Ve.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&&Ve.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Ve.debug("detail sync: no diff",{agentId:e});return}await $e(i,this.opts.paths),Ve.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await Jn(i.workspace,i.framework,e,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var df=pt(I0(),1);import{lstat as cc,mkdir as dc,readFile as sf,readdir as Ym,rm as Xm,stat as Qm,writeFile as lc}from"node:fs/promises";import{dirname as ew,join as St,normalize as tw,relative as hc,resolve as fc,sep as of}from"node:path";import{Readable as af}from"node:stream";import{pipeline as cf}from"node:stream/promises";import $p from"events";import Ke from"fs";import{EventEmitter as Va}from"node:events";import ol from"node:stream";import{StringDecoder as Vp}from"node:string_decoder";import dl from"node:path";import ar from"node:fs";import{dirname as ag,parse as cg}from"path";import{EventEmitter as gg}from"events";import Ra from"assert";import{Buffer as Rn}from"buffer";import*as D0 from"zlib";import mg from"zlib";import{posix as er}from"node:path";import{basename as Gg}from"node:path";import bs from"fs";import yt from"fs";import B0 from"path";import{win32 as tm}from"node:path";import G0 from"path";import Sl from"node:fs";import wm from"node:assert";import{randomBytes as Il}from"node:crypto";import X from"node:fs";import Ae from"node:path";import Al from"fs";import Ds from"node:fs";import ti from"node:path";import Ye from"node:fs";import Im from"node:fs/promises";import Ss from"node:path";import{join as Bl}from"node:path";import Ze from"node:fs";import Ul from"node:path";var Wp=Object.defineProperty,Kp=(t,e)=>{for(var r in e)Wp(t,r,{get:e[r],enumerable:!0})},A0=typeof process=="object"&&process?process:{stdout:null,stderr:null},Jp=t=>!!t&&typeof t=="object"&&(t instanceof Pn||t instanceof ol||Zp(t)||Yp(t)),Zp=t=>!!t&&typeof t=="object"&&t instanceof Va&&typeof t.pipe=="function"&&t.pipe!==ol.Writable.prototype.pipe,Yp=t=>!!t&&typeof t=="object"&&t instanceof Va&&typeof t.write=="function"&&typeof t.end=="function",kt=Symbol("EOF"),Pt=Symbol("maybeEmitEnd"),Zt=Symbol("emittedEnd"),Vi=Symbol("emittingEnd"),zr=Symbol("emittedError"),Ji=Symbol("closed"),T0=Symbol("read"),Zi=Symbol("flush"),C0=Symbol("flushChunk"),dt=Symbol("encoding"),Qn=Symbol("decoder"),De=Symbol("flowing"),Fr=Symbol("paused"),ir=Symbol("resume"),ke=Symbol("buffer"),Ge=Symbol("pipes"),Pe=Symbol("bufferLength"),ta=Symbol("bufferPush"),Yi=Symbol("bufferShift"),je=Symbol("objectMode"),_e=Symbol("destroyed"),na=Symbol("error"),ra=Symbol("emitData"),R0=Symbol("emitEnd"),ia=Symbol("emitEnd2"),gt=Symbol("async"),sa=Symbol("abort"),Xi=Symbol("aborted"),Ur=Symbol("signal"),_n=Symbol("dataListeners"),Je=Symbol("discarded"),Hr=t=>Promise.resolve().then(t),Xp=t=>t(),Qp=t=>t==="end"||t==="finish"||t==="prefinish",eg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,tg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),al=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[ir](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ng=class extends al{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)}},rg=t=>!!t.objectMode,ig=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Pn=class extends Va{[De]=!1;[Fr]=!1;[Ge]=[];[ke]=[];[je];[dt];[gt];[Qn];[kt]=!1;[Zt]=!1;[Vi]=!1;[Ji]=!1;[zr]=null;[Pe]=0;[_e]=!1;[Ur];[Xi]=!1;[_n]=0;[Je]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");rg(e)?(this[je]=!0,this[dt]=null):ig(e)?(this[dt]=e.encoding,this[je]=!1):(this[je]=!1,this[dt]=null),this[gt]=!!e.async,this[Qn]=this[dt]?new Vp(this[dt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ke]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ge]});let{signal:r}=e;r&&(this[Ur]=r,r.aborted?this[sa]():r.addEventListener("abort",()=>this[sa]()))}get bufferLength(){return this[Pe]}get encoding(){return this[dt]}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[je]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[gt]}set async(t){this[gt]=this[gt]||!!t}[sa](){this[Xi]=!0,this.emit("abort",this[Ur]?.reason),this.destroy(this[Ur]?.reason)}get aborted(){return this[Xi]}set aborted(t){}write(t,e,r){if(this[Xi])return!1;if(this[kt])throw new Error("write after end");if(this[_e])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[gt]?Hr:Xp;if(!this[je]&&!Buffer.isBuffer(t)){if(tg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(eg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[je]?(this[De]&&this[Pe]!==0&&this[Zi](!0),this[De]?this.emit("data",t):this[ta](t),this[Pe]!==0&&this.emit("readable"),r&&i(r),this[De]):t.length?(typeof t=="string"&&!(e===this[dt]&&!this[Qn]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[dt]&&(t=this[Qn].write(t)),this[De]&&this[Pe]!==0&&this[Zi](!0),this[De]?this.emit("data",t):this[ta](t),this[Pe]!==0&&this.emit("readable"),r&&i(r),this[De]):(this[Pe]!==0&&this.emit("readable"),r&&i(r),this[De])}read(t){if(this[_e])return null;if(this[Je]=!1,this[Pe]===0||t===0||t&&t>this[Pe])return this[Pt](),null;this[je]&&(t=null),this[ke].length>1&&!this[je]&&(this[ke]=[this[dt]?this[ke].join(""):Buffer.concat(this[ke],this[Pe])]);let e=this[T0](t||null,this[ke][0]);return this[Pt](),e}[T0](t,e){if(this[je])this[Yi]();else{let r=e;t===r.length||t===null?this[Yi]():typeof r=="string"?(this[ke][0]=r.slice(t),e=r.slice(0,t),this[Pe]-=t):(this[ke][0]=r.subarray(t),e=r.subarray(0,t),this[Pe]-=t)}return this.emit("data",e),!this[ke].length&&!this[kt]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[kt]=!0,this.writable=!1,(this[De]||!this[Fr])&&this[Pt](),this}[ir](){this[_e]||(!this[_n]&&!this[Ge].length&&(this[Je]=!0),this[Fr]=!1,this[De]=!0,this.emit("resume"),this[ke].length?this[Zi]():this[kt]?this[Pt]():this.emit("drain"))}resume(){return this[ir]()}pause(){this[De]=!1,this[Fr]=!0,this[Je]=!1}get destroyed(){return this[_e]}get flowing(){return this[De]}get paused(){return this[Fr]}[ta](t){this[je]?this[Pe]+=1:this[Pe]+=t.length,this[ke].push(t)}[Yi](){return this[je]?this[Pe]-=1:this[Pe]-=this[ke][0].length,this[ke].shift()}[Zi](t=!1){do;while(this[C0](this[Yi]())&&this[ke].length);!t&&!this[ke].length&&!this[kt]&&this.emit("drain")}[C0](t){return this.emit("data",t),this[De]}pipe(t,e){if(this[_e])return t;this[Je]=!1;let r=this[Zt];return e=e||{},t===A0.stdout||t===A0.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ge].push(e.proxyErrors?new ng(this,t,e):new al(this,t,e)),this[gt]?Hr(()=>this[ir]()):this[ir]()),t}unpipe(t){let e=this[Ge].find(r=>r.dest===t);e&&(this[Ge].length===1?(this[De]&&this[_n]===0&&(this[De]=!1),this[Ge]=[]):this[Ge].splice(this[Ge].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[Je]=!1,this[_n]++,!this[Ge].length&&!this[De]&&this[ir]();else if(t==="readable"&&this[Pe]!==0)super.emit("readable");else if(Qp(t)&&this[Zt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[zr]){let i=e;this[gt]?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[_n]=this.listeners("data").length,this[_n]===0&&!this[Je]&&!this[Ge].length&&(this[De]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[_n]=0,!this[Je]&&!this[Ge].length&&(this[De]=!1)),e}get emittedEnd(){return this[Zt]}[Pt](){!this[Vi]&&!this[Zt]&&!this[_e]&&this[ke].length===0&&this[kt]&&(this[Vi]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ji]&&this.emit("close"),this[Vi]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==_e&&this[_e])return!1;if(t==="data")return!this[je]&&!r?!1:this[gt]?(Hr(()=>this[ra](r)),!0):this[ra](r);if(t==="end")return this[R0]();if(t==="close"){if(this[Ji]=!0,!this[Zt]&&!this[_e])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[zr]=r,super.emit(na,r);let o=!this[Ur]||this.listeners("error").length?super.emit("error",r):!1;return this[Pt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Pt](),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[Pt](),i}[ra](t){for(let r of this[Ge])r.dest.write(t)===!1&&this.pause();let e=this[Je]?!1:super.emit("data",t);return this[Pt](),e}[R0](){return this[Zt]?!1:(this[Zt]=!0,this.readable=!1,this[gt]?(Hr(()=>this[ia]()),!0):this[ia]())}[ia](){if(this[Qn]){let e=this[Qn].end();if(e){for(let r of this[Ge])r.dest.write(e);this[Je]||super.emit("data",e)}}for(let e of this[Ge])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[je]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[je]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[je])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[dt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(_e,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Je]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[kt])return e();let i,o,c=p=>{this.off("data",l),this.off("end",u),this.off(_e,h),e(),o(p)},l=p=>{this.off("error",c),this.off("end",u),this.off(_e,h),this.pause(),i({value:p,done:!!this[kt]})},u=()=>{this.off("error",c),this.off("data",l),this.off(_e,h),e(),i({done:!0,value:void 0})},h=()=>c(new Error("stream destroyed"));return new Promise((p,w)=>{o=w,i=p,this.once(_e,h),this.once("error",c),this.once("end",u),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Je]=!1;let t=!1,e=()=>(this.pause(),this.off(na,e),this.off(_e,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(na,e),this.once(_e,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[_e])return t?this.emit("error",t):this.emit(_e),this;this[_e]=!0,this[Je]=!0,this[ke].length=0,this[Pe]=0;let e=this;return typeof e.close=="function"&&!this[Ji]&&e.close(),t?this.emit("error",t):this.emit(_e),this}static get isStream(){return Jp}},sg=Ke.writev,an=Symbol("_autoClose"),ht=Symbol("_close"),qr=Symbol("_ended"),ie=Symbol("_fd"),oa=Symbol("_finished"),Mt=Symbol("_flags"),aa=Symbol("_flush"),Ta=Symbol("_handleChunk"),Ca=Symbol("_makeBuf"),Qr=Symbol("_mode"),Qi=Symbol("_needDrain"),dr=Symbol("_onerror"),lr=Symbol("_onopen"),ca=Symbol("_onread"),sr=Symbol("_onwrite"),cn=Symbol("_open"),ut=Symbol("_path"),tn=Symbol("_pos"),mt=Symbol("_queue"),or=Symbol("_read"),da=Symbol("_readSize"),Nt=Symbol("_reading"),jr=Symbol("_remain"),la=Symbol("_size"),ds=Symbol("_write"),bn=Symbol("_writing"),ls=Symbol("_defaultFlag"),Cn=Symbol("_errored"),Ja=class extends Pn{[Cn]=!1;[ie];[ut];[da];[Nt]=!1;[la];[jr];[an];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[Cn]=!1,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[ut]=t,this[da]=e.readSize||16*1024*1024,this[Nt]=!1,this[la]=typeof e.size=="number"?e.size:1/0,this[jr]=this[la],this[an]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ie]=="number"?this[or]():this[cn]()}get fd(){return this[ie]}get path(){return this[ut]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[cn](){Ke.open(this[ut],"r",(t,e)=>this[lr](t,e))}[lr](t,e){t?this[dr](t):(this[ie]=e,this.emit("open",e),this[or]())}[Ca](){return Buffer.allocUnsafe(Math.min(this[da],this[jr]))}[or](){if(!this[Nt]){this[Nt]=!0;let t=this[Ca]();if(t.length===0)return process.nextTick(()=>this[ca](null,0,t));Ke.read(this[ie],t,0,t.length,null,(e,r,i)=>this[ca](e,r,i))}}[ca](t,e,r){this[Nt]=!1,t?this[dr](t):this[Ta](e,r)&&this[or]()}[ht](){if(this[an]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[dr](t){this[Nt]=!0,this[ht](),this.emit("error",t)}[Ta](t,e){let r=!1;return this[jr]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[jr]<=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[or](),!1;case"error":return this[Cn]?!1:(this[Cn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},og=class extends Ja{[cn](){let t=!0;try{this[lr](null,Ke.openSync(this[ut],"r")),t=!1}finally{t&&this[ht]()}}[or](){let t=!0;try{if(!this[Nt]){this[Nt]=!0;do{let e=this[Ca](),r=e.length===0?0:Ke.readSync(this[ie],e,0,e.length,null);if(!this[Ta](r,e))break}while(!0);this[Nt]=!1}t=!1}finally{t&&this[ht]()}}[ht](){if(this[an]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.closeSync(t),this.emit("close")}}},Is=class extends $p{readable=!1;writable=!0;[Cn]=!1;[bn]=!1;[qr]=!1;[mt]=[];[Qi]=!1;[ut];[Qr];[an];[ie];[ls];[Mt];[oa]=!1;[tn];constructor(t,e){e=e||{},super(e),this[ut]=t,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[Qr]=e.mode===void 0?438:e.mode,this[tn]=typeof e.start=="number"?e.start:void 0,this[an]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[tn]!==void 0?"r+":"w";this[ls]=e.flags===void 0,this[Mt]=e.flags===void 0?r:e.flags,this[ie]===void 0&&this[cn]()}emit(t,...e){if(t==="error"){if(this[Cn])return!1;this[Cn]=!0}return super.emit(t,...e)}get fd(){return this[ie]}get path(){return this[ut]}[dr](t){this[ht](),this[bn]=!0,this.emit("error",t)}[cn](){Ke.open(this[ut],this[Mt],this[Qr],(t,e)=>this[lr](t,e))}[lr](t,e){this[ls]&&this[Mt]==="r+"&&t&&t.code==="ENOENT"?(this[Mt]="w",this[cn]()):t?this[dr](t):(this[ie]=e,this.emit("open",e),this[bn]||this[aa]())}end(t,e){return t&&this.write(t,e),this[qr]=!0,!this[bn]&&!this[mt].length&&typeof this[ie]=="number"&&this[sr](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[bn]||this[mt].length?(this[mt].push(t),this[Qi]=!0,!1):(this[bn]=!0,this[ds](t),!0)}[ds](t){Ke.write(this[ie],t,0,t.length,this[tn],(e,r)=>this[sr](e,r))}[sr](t,e){t?this[dr](t):(this[tn]!==void 0&&typeof e=="number"&&(this[tn]+=e),this[mt].length?this[aa]():(this[bn]=!1,this[qr]&&!this[oa]?(this[oa]=!0,this[ht](),this.emit("finish")):this[Qi]&&(this[Qi]=!1,this.emit("drain"))))}[aa](){if(this[mt].length===0)this[qr]&&this[sr](null,0);else if(this[mt].length===1)this[ds](this[mt].pop());else{let t=this[mt];this[mt]=[],sg(this[ie],t,this[tn],(e,r)=>this[sr](e,r))}}[ht](){if(this[an]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},cl=class extends Is{[cn](){let t;if(this[ls]&&this[Mt]==="r+")try{t=Ke.openSync(this[ut],this[Mt],this[Qr])}catch(e){if(e?.code==="ENOENT")return this[Mt]="w",this[cn]();throw e}else t=Ke.openSync(this[ut],this[Mt],this[Qr]);this[lr](null,t)}[ht](){if(this[an]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.closeSync(t),this.emit("close")}}[ds](t){let e=!0;try{this[sr](null,Ke.writeSync(this[ie],t,0,t.length,this[tn])),e=!1}finally{if(e)try{this[ht]()}catch{}}}},dg=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),lg=t=>!!t.sync&&!!t.file,fg=t=>!t.sync&&!!t.file,ug=t=>!!t.sync&&!t.file,hg=t=>!t.sync&&!t.file,xg=t=>!!t.file,pg=t=>dg.get(t)||t,Za=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=pg(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,u)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(u=l,l=void 0),l=l?Array.from(l):[];let h=Za(c);if(o?.(h,l),lg(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(h,l)}else if(fg(h)){let p=e(h,l);return u?p.then(()=>u(),u):p}else if(ug(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(h,l)}else if(hg(h)){if(typeof u=="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}),wg=mg.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},wg)),yg=Rn.concat,k0=Object.getOwnPropertyDescriptor(Rn,"concat"),_g=t=>t,fa=k0?.writable===!0||k0?.set!==void 0?t=>{Rn.concat=t?_g:yg}:t=>{},Dn=Symbol("_superWrite"),es=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"}},ua=Symbol("flushFlag"),Ya=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 D0[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new D0[e](t)}catch(r){throw new es(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 es(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return Ra(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Rn.alloc(0),{[ua]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[Dn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Rn.from(t,e)),this.#e)return;Ra(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},fa(!0);let l;try{let h=typeof t[ua]=="number"?t[ua]:this.#r;l=this.#t._processChunk(t,h),fa(!1)}catch(h){fa(!1),this.#o(new es(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 es(h,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let h=l[0];u=this[Dn](Rn.from(h));for(let p=1;p<l.length;p++)u=this[Dn](l[p])}else u=this[Dn](Rn.from(l));return r&&r(),u}},ll=class extends Ya{#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),Ra(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)}}}},bg=class extends ll{#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)}},Eg=class extends ll{constructor(t){super(t,"Unzip")}},fl=class extends Ya{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)}},vg=class extends fl{constructor(t){super(t,"BrotliCompress")}},Sg=class extends fl{constructor(t){super(t,"BrotliDecompress")}},ul=class extends Ya{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)}},Ig=class extends ul{constructor(t){super(t,"ZstdCompress")}},Ag=class extends ul{constructor(t){super(t,"ZstdDecompress")}},Tg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Rg(t,e):Cg(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Cg=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Rg=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=hl(o):o===0?e[i-1]=0:(r=!0,e[i-1]=xl(o))}},Dg=t=>{let e=t[0],r=e===128?Pg(t.subarray(1,t.length)):e===255?kg(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},kg=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=hl(c):c===0?l=c:(i=!0,l=xl(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},Pg=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},hl=t=>(255^t)&255,xl=t=>(255^t)+1&255,Lg={};Kp(Lg,{code:()=>Xa,isCode:()=>fs,isName:()=>Og,name:()=>As});var fs=t=>As.has(t),Og=t=>Xa.has(t),As=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Xa=new Map(Array.from(As).map(t=>[t[1],t[0]])),kn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,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??En(t,e,100),this.mode=r?.mode??i?.mode??nn(t,e+100,8),this.uid=r?.uid??i?.uid??nn(t,e+108,8),this.gid=r?.gid??i?.gid??nn(t,e+116,8),this.size=r?.size??i?.size??nn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??ha(t,e+136,12),this.cksum=nn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=En(t,e+156,1);if(fs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=En(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??En(t,e+265,32),this.gname=r?.gname??i?.gname??En(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??nn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??nn(t,e+337,8)??0,t[e+475]!==0){let l=En(t,e+345,155);this.path=l+"/"+this.path}else{let l=En(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??ha(t,e+476,12),this.ctime=r?.ctime??i?.ctime??ha(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=Ng(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=vn(t,e,100,o)||this.needPax,this.needPax=rn(t,e+100,8,this.mode)||this.needPax,this.needPax=rn(t,e+108,8,this.uid)||this.needPax,this.needPax=rn(t,e+116,8,this.gid)||this.needPax,this.needPax=rn(t,e+124,12,this.size)||this.needPax,this.needPax=xa(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=vn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=vn(t,e+265,32,this.uname)||this.needPax,this.needPax=vn(t,e+297,32,this.gname)||this.needPax,this.needPax=rn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=rn(t,e+337,8,this.devmin)||this.needPax,this.needPax=vn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=vn(t,e+345,155,c)||this.needPax:(this.needPax=vn(t,e+345,130,c)||this.needPax,this.needPax=xa(t,e+476,12,this.atime)||this.needPax,this.needPax=xa(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let u=e;u<e+148;u++)l+=t[u];for(let u=e+156;u<e+512;u++)l+=t[u];return this.cksum=l,rn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:As.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Xa.get(t));if(fs(e)||e==="Unsupported")this.#e=e;else if(fs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Ng=(t,e)=>{let r=t,i="",o,c=er.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=er.dirname(r),r=er.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=er.join(er.basename(i),r),i=er.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},En=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),ha=(t,e,r)=>Mg(nn(t,e,r)),Mg=t=>t===void 0?void 0:new Date(t*1e3),nn=(t,e,r)=>Number(t[e])&128?Dg(t.subarray(e,e+r)):zg(t,e,r),Bg=t=>isNaN(t)?void 0:t,zg=(t,e,r)=>Bg(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Fg={12:8589934591,8:2097151},rn=(t,e,r,i)=>i===void 0?!1:i>Fg[r]||i<0?(Tg(i,t.subarray(e,e+r)),!0):(Ug(t,e,r,i),!1),Ug=(t,e,r,i)=>t.write(Hg(i,r),e,r,"ascii"),Hg=(t,e)=>qg(Math.floor(t).toString(8),e),qg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",xa=(t,e,r,i)=>i===void 0?!1:rn(t,e,r,i.getTime()/1e3),jg=new Array(156).join("\0"),vn=(t,e,r,i)=>i===void 0?!1:(t.write(i+jg,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),_s=class pl{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 kn({path:("PaxHeader/"+Gg(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(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+`
116
- `,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 pl(Wg(Kg(e),r),i)}},Wg=(t,e)=>e?Object.assign({},e,t):t,Kg=t=>t.replace(/\n$/,"").split(`
117
- `).reduce($g,Object.create(null)),$g=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let 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},Vg=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=Vg!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),gl=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=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,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=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Ts=(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))},Jg=1024*1024,Da=Buffer.from([31,139]),ka=Buffer.from([40,181,47,253]),Zg=Math.max(Da.length,ka.length),nt=Symbol("state"),Sn=Symbol("writeEntry"),Lt=Symbol("readEntry"),pa=Symbol("nextEntry"),P0=Symbol("processEntry"),wt=Symbol("extendedHeader"),Gr=Symbol("globalExtendedHeader"),Yt=Symbol("meta"),L0=Symbol("emitMeta"),le=Symbol("buffer"),Ot=Symbol("queue"),Xt=Symbol("ended"),ga=Symbol("emittedEnd"),In=Symbol("emit"),ve=Symbol("unzip"),ts=Symbol("consumeChunk"),ns=Symbol("consumeChunkSub"),ma=Symbol("consumeBody"),O0=Symbol("consumeMeta"),N0=Symbol("consumeHeader"),Wr=Symbol("consuming"),wa=Symbol("bufferConcat"),rs=Symbol("maybeEnd"),tr=Symbol("writing"),Qt=Symbol("aborted"),is=Symbol("onDone"),An=Symbol("sawValidEntry"),ss=Symbol("sawNullBlock"),os=Symbol("sawEOF"),M0=Symbol("closeStream"),Yg=()=>!0,ai=class extends gg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ot]=[];[le];[Lt];[Sn];[nt]="begin";[Yt]="";[wt];[Gr];[Xt]=!1;[ve];[Qt]=!1;[An];[ss]=!1;[os]=!1;[tr]=!1;[Wr]=!1;[ga]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(is,()=>{(this[nt]==="begin"||this[An]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(is,t.ondone):this.on(is,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Jg,this.filter=typeof t.filter=="function"?t.filter:Yg;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[M0]()),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)}[N0](t,e){this[An]===void 0&&(this[An]=!1);let r;try{r=new kn(t,e,this[wt],this[Gr])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[ss]?(this[os]=!0,this[nt]==="begin"&&(this[nt]="header"),this[In]("eof")):(this[ss]=!0,this[In]("nullBlock"));else if(this[ss]=!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[Sn]=new gl(r,this[wt],this[Gr]);if(!this[An])if(o.remain){let c=()=>{o.invalid||(this[An]=!0)};o.on("end",c)}else this[An]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[In]("ignoredEntry",o),this[nt]="ignore",o.resume()):o.size>0&&(this[Yt]="",o.on("data",c=>this[Yt]+=c),this[nt]="meta"):(this[wt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[In]("ignoredEntry",o),this[nt]=o.remain?"ignore":"header",o.resume()):(o.remain?this[nt]="body":(this[nt]="header",o.end()),this[Lt]?this[Ot].push(o):(this[Ot].push(o),this[pa]())))}}}[M0](){queueMicrotask(()=>this.emit("close"))}[P0](t){let e=!0;if(!t)this[Lt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Lt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[pa]()),e=!1);return e}[pa](){do;while(this[P0](this[Ot].shift()));if(this[Ot].length===0){let t=this[Lt];!t||t.flowing||t.size===t.remain?this[tr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[ma](t,e){let r=this[Sn];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[nt]="header",this[Sn]=void 0,r.end()),o.length}[O0](t,e){let r=this[Sn],i=this[ma](t,e);return!this[Sn]&&r&&this[L0](r),i}[In](t,e,r){this[Ot].length===0&&!this[Lt]?this.emit(t,e,r):this[Ot].push([t,e,r])}[L0](t){switch(this[In]("meta",this[Yt]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[wt]=_s.parse(this[Yt],this[wt],!1);break;case"GlobalExtendedHeader":this[Gr]=_s.parse(this[Yt],this[Gr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[wt]??Object.create(null);this[wt]=e,e.path=this[Yt].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[wt]||Object.create(null);this[wt]=e,e.linkpath=this[Yt].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[Qt]=!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[Qt])return r?.(),!1;if((this[ve]===void 0||this.brotli===void 0&&this[ve]===!1)&&t){if(this[le]&&(t=Buffer.concat([this[le],t]),this[le]=void 0),t.length<Zg)return this[le]=t,r?.(),!0;for(let l=0;this[ve]===void 0&&l<Da.length;l++)t[l]!==Da[l]&&(this[ve]=!1);let o=!1;if(this[ve]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<ka.length;l++)if(t[l]!==ka[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[ve]===!1&&c)if(t.length<512)if(this[Xt])this.brotli=!0;else return this[le]=t,r?.(),!0;else try{new kn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ve]===void 0||this[ve]===!1&&(this.brotli||o)){let l=this[Xt];this[Xt]=!1,this[ve]=this[ve]===void 0?new Eg({}):o?new Ag({}):new Sg({}),this[ve].on("data",h=>this[ts](h)),this[ve].on("error",h=>this.abort(h)),this[ve].on("end",()=>{this[Xt]=!0,this[ts]()}),this[tr]=!0;let u=!!this[ve][l?"end":"write"](t);return this[tr]=!1,r?.(),u}}this[tr]=!0,this[ve]?this[ve].write(t):this[ts](t),this[tr]=!1;let i=this[Ot].length>0?!1:this[Lt]?this[Lt].flowing:!0;return!i&&this[Ot].length===0&&this[Lt]?.once("drain",()=>this.emit("drain")),r?.(),i}[wa](t){t&&!this[Qt]&&(this[le]=this[le]?Buffer.concat([this[le],t]):t)}[rs](){if(this[Xt]&&!this[ga]&&!this[Qt]&&!this[Wr]){this[ga]=!0;let t=this[Sn];if(t&&t.blockRemain){let e=this[le]?this[le].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[le]&&t.write(this[le]),t.end()}this[In](is)}}[ts](t){if(this[Wr]&&t)this[wa](t);else if(!t&&!this[le])this[rs]();else if(t){if(this[Wr]=!0,this[le]){this[wa](t);let e=this[le];this[le]=void 0,this[ns](e)}else this[ns](t);for(;this[le]&&this[le]?.length>=512&&!this[Qt]&&!this[os];){let e=this[le];this[le]=void 0,this[ns](e)}this[Wr]=!1}(!this[le]||this[Xt])&&this[rs]()}[ns](t){let e=0,r=t.length;for(;e+512<=r&&!this[Qt]&&!this[os];)switch(this[nt]){case"begin":case"header":this[N0](t,e),e+=512;break;case"ignore":case"body":e+=this[ma](t,e);break;case"meta":e+=this[O0](t,e);break;default:throw new Error("invalid state: "+this[nt])}e<r&&(this[le]=this[le]?Buffer.concat([t.subarray(e),this[le]]):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[Qt]||(this[ve]?(t&&this[ve].write(t),this[ve].end()):(this[Xt]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[rs]())),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)},Xg=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},ml=(t,e)=>{let r=new Map(e.map(c=>[ei(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||cg(c).root||".",h;if(c===u)h=!1;else{let p=r.get(c);h=p!==void 0?p:o(ag(c),u)}return r.set(c,h),h};t.filter=i?(c,l)=>i(c,l)&&o(ei(c)):c=>o(ei(c))},Qg=t=>{let e=new ai(t),r=t.file,i;try{i=ar.openSync(r,"r");let o=ar.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=ar.readSync(i,l,0,o.size,0);e.end(u===l.byteLength?l:l.subarray(0,u))}else{let l=0,u=Buffer.allocUnsafe(c);for(;l<o.size;){let h=ar.readSync(i,u,0,c,l);if(h===0)break;l+=h,e.write(u.subarray(0,h))}e.end()}}finally{if(typeof i=="number")try{ar.closeSync(i)}catch{}}},em=(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),ar.stat(o,(u,h)=>{if(u)l(u);else{let p=new Ja(o,{readSize:i,size:h.size});p.on("error",l),p.pipe(r)}})})},fr=ci(Qg,em,t=>new ai(t),t=>new ai(t),(t,e)=>{e?.length&&ml(t,e),t.noResume||Xg(t)}),wl=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:nm,parse:z0}=tm,Qa=t=>{let e="",r=z0(t);for(;nm(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=z0(t)}return[e,t]},Cs=["|","<",">","?",":"],ec=Cs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),rm=new Map(Cs.map((t,e)=>[t,ec[e]])),im=new Map(ec.map((t,e)=>[t,Cs[e]])),F0=t=>Cs.reduce((e,r)=>e.split(r).join(rm.get(r)),t),sm=t=>ec.reduce((e,r)=>e.split(r).join(im.get(r)),t),yl=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),ei(e)+"/"+t):Z(t),om=16*1024*1024,U0=Symbol("process"),H0=Symbol("file"),q0=Symbol("directory"),Pa=Symbol("symlink"),j0=Symbol("hardlink"),Kr=Symbol("header"),us=Symbol("read"),La=Symbol("lstat"),hs=Symbol("onlstat"),Oa=Symbol("onread"),Na=Symbol("onreadlink"),Ma=Symbol("openfile"),Ba=Symbol("onopenfile"),sn=Symbol("close"),Es=Symbol("mode"),za=Symbol("awaitDrain"),ya=Symbol("ondrain"),_t=Symbol("prefix"),_l=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=Za(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||om,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Qa(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=sm(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||B0.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[hs](o):this[La]()}warn(t,e,r={}){return Ts(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[La](){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=dm(t),this.emit("stat",t),this[U0]()}[U0](){switch(this.type){case"File":return this[H0]();case"Directory":return this[q0]();case"SymbolicLink":return this[Pa]();default:return this.end()}}[Es](t){return wl(t,this.type==="Directory",this.portable)}[_t](t){return yl(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 kn({path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](this.linkpath):this.linkpath,mode:this[Es](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 _s({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[q0](){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()}[Pa](){yt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Na](e)})}[Na](t){this.linkpath=Z(t),this[Kr](),this.end()}[j0](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(B0.relative(this.cwd,t)),this.stat.size=0,this[Kr](),this.end()}[H0](){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[j0](e);this.linkCache.set(t,this.absolute)}if(this[Kr](),this.stat.size===0)return this.end();this[Ma]()}[Ma](){yt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Ba](e)})}[Ba](t){if(this.fd=t,this.#e)return this[sn]();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[us]()}[us](){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");yt.read(t,e,r,i,o,(c,l)=>{if(c)return this[sn](()=>this.emit("error",c));this[Oa](l)})}[sn](t=()=>{}){this.fd!==void 0&&yt.close(this.fd,t)}[Oa](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[sn](()=>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[sn](()=>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[ya]():this[za](()=>this[ya]())}[za](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)}[ya](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[sn](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[us]()}},am=class extends _l{sync=!0;[La](){this[hs](yt.lstatSync(this.absolute))}[Pa](){this[Na](yt.readlinkSync(this.absolute))}[Ma](){this[Ba](yt.openSync(this.absolute,"r"))}[us](){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=yt.readSync(e,r,i,o,c);this[Oa](l),t=!1}finally{if(t)try{this[sn](()=>{})}catch{}}}[za](t){t()}[sn](t=()=>{}){this.fd!==void 0&&yt.closeSync(this.fd),t()}},cm=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 Ts(this,t,e,r)}constructor(t,e={}){let r=Za(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=Z(t.path),this.mode=t.mode!==void 0?this[Es](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 o=!1;if(!this.preservePaths){let[l,u]=Qa(this.path);l&&typeof u=="string"&&(this.path=u,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new kn({path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),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 _s({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[_t](t){return yl(t,this.prefix)}[Es](t){return wl(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}},dm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",lm=class cr{tail;head;length=0;static create(e=[]){return new cr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,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++)um(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)hm(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 cr;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 cr;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 cr;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 cr;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=fm(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 fm(t,e,r){let i=e,o=e?e.next:t.head,c=new tc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function um(t,e){t.tail=new tc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function hm(t,e){t.head=new tc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var tc=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}},W0=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},K0=Buffer.alloc(1024),xs=Symbol("onStat"),$r=Symbol("ended"),lt=Symbol("queue"),Vr=Symbol("queue"),en=Symbol("current"),Tn=Symbol("process"),Jr=Symbol("processing"),as=Symbol("processJob"),ft=Symbol("jobs"),_a=Symbol("jobDone"),ps=Symbol("addFSEntry"),$0=Symbol("addTarEntry"),Fa=Symbol("stat"),Ua=Symbol("readdir"),gs=Symbol("onreaddir"),ms=Symbol("pipe"),V0=Symbol("entry"),ba=Symbol("entryOpt"),ws=Symbol("writeEntryClass"),bl=Symbol("write"),Ea=Symbol("ondrain"),Rs=class extends Pn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[ws];onWriteEntry;[lt];[Vr]=new Map;[ft]=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=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[ws]=_l,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new bg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new vg(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Ig(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[Ea]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ea]);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 lm,this[ft]=0,this.jobs=Number(t.jobs)||4,this[Jr]=!1,this[$r]=!1}[bl](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[Tn](),r&&r(),this}write(t){if(this[$r])throw new Error("write after end");return t instanceof gl?this[$0](t):this[ps](t),this.flowing}[$0](t){let e=Z(G0.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new W0(t.path,e);r.entry=new cm(t,this[ba](r)),r.entry.on("end",()=>this[_a](r)),this[ft]+=1,this[lt].push(r)}this[Tn]()}[ps](t){let e=Z(G0.resolve(this.cwd,t));this[lt].push(new W0(t,e)),this[Tn]()}[Fa](t){t.pending=!0,this[ft]+=1;let e=this.follow?"stat":"lstat";bs[e](t.absolute,(r,i)=>{t.pending=!1,this[ft]-=1,r?this.emit("error",r):this[xs](t,i)})}[xs](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[en])this[as](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[Tn]()}[Ua](t){t.pending=!0,this[ft]+=1,bs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[ft]-=1,e)return this.emit("error",e);this[gs](t,r)})}[gs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Tn]()}[Tn](){if(!this[Jr]){this[Jr]=!0;for(let t=this[lt].head;t&&this[ft]<this.jobs;t=t.next)if(this[as](t.value),t.value.ignore){let e=t.next;this[lt].removeNode(t),t.next=e}this[Jr]=!1,this[$r]&&this[lt].length===0&&this[ft]===0&&(this.zip?this.zip.end(K0):(super.write(K0),super.end()))}}get[en](){return this[lt]&&this[lt].head&&this[lt].head.value}[_a](t){this[lt].shift(),this[ft]-=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[as](o)}}this[Tn]()}[as](t){if(t.pending&&t.pendingLink&&t===this[en]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[en]&&!t.piped&&this[ms](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[xs](t,e):this[Fa](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[gs](t,e):this[Ua](t),!t.readdir)return}if(t.entry=this[V0](t),!t.entry){t.ignore=!0;return}t===this[en]&&!t.piped&&this[ms](t)}}}[ba](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}}[V0](t){this[ft]+=1;try{return new this[ws](t.path,this[ba](t)).on("end",()=>this[_a](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Ea](){this[en]&&this[en].entry&&this[en].entry.resume()}[ms](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[ps](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={}){Ts(this,t,e,r)}},nc=class extends Rs{sync=!0;constructor(t){super(t),this[ws]=am}pause(){}resume(){}[Fa](t){let e=this.follow?"statSync":"lstatSync";this[xs](t,bs[e](t.absolute))}[Ua](t){this[gs](t,bs.readdirSync(t.absolute))}[ms](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[ps](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[bl](i)})}},xm=(t,e)=>{let r=new nc(t),i=new cl(t.file,{mode:t.mode||438});r.pipe(i),El(r,e)},pm=(t,e)=>{let r=new Rs(t),i=new Is(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 vl(r,e).catch(c=>r.emit("error",c)),o},El=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?fr({file:dl.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},vl=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await fr({file:dl.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},gm=(t,e)=>{let r=new nc(t);return El(r,e),r},mm=(t,e)=>{let r=new Rs(t);return vl(r,e).catch(i=>r.emit("error",i)),r},m2=ci(xm,pm,gm,mm,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),ym=process.env.__FAKE_PLATFORM__||process.platform,Tl=ym==="win32",{O_CREAT:Cl,O_NOFOLLOW:J0,O_TRUNC:Rl,O_WRONLY:Dl}=Al.constants,kl=Number(process.env.__FAKE_FS_O_FILENAME__)||Al.constants.UV_FS_O_FILEMAP||0,_m=Tl&&!!kl,bm=512*1024,Em=kl|Rl|Cl|Dl,Z0=!Tl&&typeof J0=="number"?J0|Rl|Cl|Dl:null,Pl=Z0!==null?()=>Z0:_m?t=>t<bm?Em:"w":()=>"w",Ha=(t,e,r)=>{try{return Ds.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},vs=(t,e,r,i)=>{Ds.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},vm=(t,e,r,i,o)=>{if(e.isDirectory())Ll(ti.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=ti.resolve(t,e.name);vs(l,r,i,o)});else{let c=ti.resolve(t,e.name);vs(c,r,i,o)}},Ll=(t,e,r,i)=>{Ds.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 vs(t,e,r,i);let l=c.length,u=null,h=p=>{if(!u){if(p)return i(u=p);if(--l===0)return vs(t,e,r,i)}};for(let p of c)vm(t,p,e,r,h)})},Sm=(t,e,r,i)=>{e.isDirectory()&&Ol(ti.resolve(t,e.name),r,i),Ha(ti.resolve(t,e.name),r,i)},Ol=(t,e,r)=>{let i;try{i=Ds.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Ha(t,e,r);throw c}for(let o of i)Sm(t,o,e,r);return Ha(t,e,r)},Nl=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"}},ks=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"}},Am=(t,e)=>{Ye.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new Nl(t,r?.code||"ENOTDIR")),e(r)})},Tm=(t,e,r)=>{t=Z(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,u=e.gid,h=typeof l=="number"&&typeof u=="number"&&(l!==e.processUid||u!==e.processGid),p=e.preserve,w=e.unlink,b=Z(e.cwd),A=(E,v)=>{E?r(E):v&&h?Ll(v,l,u,I=>A(I)):c?Ye.chmod(t,o,r):r()};if(t===b)return Am(t,A);if(p)return Im.mkdir(t,{mode:o,recursive:!0}).then(E=>A(null,E??void 0),A);let _=Z(Ss.relative(b,t)).split("/");qa(b,_,o,w,b,void 0,A)},qa=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),h=Z(Ss.resolve(t+"/"+u));Ye.mkdir(h,r,Ml(h,e,r,i,o,c,l))},Ml=(t,e,r,i,o,c,l)=>u=>{u?Ye.lstat(t,(h,p)=>{if(h)h.path=h.path&&Z(h.path),l(h);else if(p.isDirectory())qa(t,e,r,i,o,c,l);else if(i)Ye.unlink(t,w=>{if(w)return l(w);Ye.mkdir(t,r,Ml(t,e,r,i,o,c,l))});else{if(p.isSymbolicLink())return l(new ks(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,qa(t,e,r,i,o,c,l))},Cm=t=>{let e=!1,r;try{e=Ye.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new Nl(t,r??"ENOTDIR")}},Rm=(t,e)=>{t=Z(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,u=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),h=e.preserve,p=e.unlink,w=Z(e.cwd),b=E=>{E&&u&&Ol(E,c,l),o&&Ye.chmodSync(t,i)};if(t===w)return Cm(w),b();if(h)return b(Ye.mkdirSync(t,{mode:i,recursive:!0})??void 0);let A=Z(Ss.relative(w,t)).split("/"),_;for(let E=A.shift(),v=w;E&&(v+="/"+E);E=A.shift()){v=Z(Ss.resolve(v));try{Ye.mkdirSync(v,i),_=_||v}catch{let I=Ye.lstatSync(v);if(I.isDirectory())continue;if(p){Ye.unlinkSync(v),Ye.mkdirSync(v,i),_=_||v;continue}else if(I.isSymbolicLink())return new ks(v,v+"/"+A.join("/"))}}return b(_)},va=Object.create(null),Y0=1e4,nr=new Set,Dm=t=>{nr.has(t)?nr.delete(t):va[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),nr.add(t);let e=va[t],r=nr.size-Y0;if(r>Y0/10){for(let i of nr)if(nr.delete(i),delete va[i],--r<=0)break}return e},km=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Pm=km==="win32",Lm=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=Bl(i,r)),e.push(r||"/"),e},[]),Om=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Pm?["win32 parallelization disabled"]:t.map(i=>ei(Bl(Dm(i))));let r=new Set(t.map(i=>Lm(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 u=l[1];if(!u){this.#e.delete(c);continue}if(l.shift(),typeof u=="function")o.add(u);else for(let h of u)o.add(h)}for(let c of i){let l=this.#e.get(c),u=l?.[0];if(!(!l||!(u instanceof Set)))if(u.size===1&&l.length===1){this.#e.delete(c);continue}else if(u.size===1){l.shift();let h=l[0];typeof h=="function"&&o.add(h)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Nm=()=>process.umask(),X0=Symbol("onEntry"),ja=Symbol("checkFs"),Q0=Symbol("checkFs2"),Ga=Symbol("isReusable"),rt=Symbol("makeFs"),Wa=Symbol("file"),Ka=Symbol("directory"),ys=Symbol("link"),el=Symbol("symlink"),tl=Symbol("hardlink"),Xr=Symbol("ensureNoSymlink"),nl=Symbol("unsupported"),rl=Symbol("checkPath"),Sa=Symbol("stripAbsolutePath"),on=Symbol("mkdir"),Le=Symbol("onError"),cs=Symbol("pending"),il=Symbol("pend"),rr=Symbol("unpend"),Ia=Symbol("ended"),Aa=Symbol("maybeClose"),$a=Symbol("skip"),ni=Symbol("doChown"),ri=Symbol("uid"),ii=Symbol("gid"),si=Symbol("checkedCwd"),Mm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,oi=Mm==="win32",Bm=1024,zm=(t,e)=>{if(!oi)return X.unlink(t,e);let r=t+".DELETE."+Il(16).toString("hex");X.rename(t,r,i=>{if(i)return e(i);X.unlink(r,e)})},Fm=t=>{if(!oi)return X.unlinkSync(t);let e=t+".DELETE."+Il(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},sl=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,rc=class extends ai{[Ia]=!1;[si]=!1;[cs]=0;reservations=new Om;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[Ia]=!0,this[Aa]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Bm,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||oi,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Ae.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Nm():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[X0](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Aa](){this[Ia]&&this[cs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Sa](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Qa(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 u=Ae.posix.dirname(t.path),h=Ae.posix.normalize(Ae.posix.join(u,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}[rl](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Z(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[Sa](t,"path")||!this[Sa](t,"linkpath"))return!1;if(t.absolute=Ae.isAbsolute(t.path)?Z(Ae.resolve(t.path)):Z(Ae.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path: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:i}=Ae.win32.parse(String(t.absolute));t.absolute=i+F0(String(t.absolute).slice(i.length));let{root:o}=Ae.win32.parse(t.path);t.path=o+F0(t.path.slice(o.length))}return!0}[X0](t){if(!this[rl](t))return t.resume();switch(wm.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[ja](t);default:return this[nl](t)}}[Le](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[rr](),e.resume())}[on](t,e,r){Tm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[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 sl(this.uid,t.uid,this.processUid)}[ii](t){return sl(this.gid,t.gid,this.processGid)}[Wa](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Is(String(t.absolute),{flags:Pl(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&X.close(i.fd,()=>{}),i.write=()=>!0,this[Le](u,t),e()});let o=1,c=u=>{if(u){i.fd&&X.close(i.fd,()=>{}),this[Le](u,t),e();return}--o===0&&i.fd!==void 0&&X.close(i.fd,h=>{h?this[Le](h,t):this[rr](),e()})};i.on("finish",()=>{let u=String(t.absolute),h=i.fd;if(typeof h=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,w=t.mtime;X.futimes(h,p,w,b=>b?X.utimes(u,p,w,A=>c(A&&b)):c())}if(typeof h=="number"&&this[ni](t)){o++;let p=this[ri](t),w=this[ii](t);typeof p=="number"&&typeof w=="number"&&X.fchown(h,p,w,b=>b?X.chown(u,p,w,A=>c(A&&b)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[Le](u,t),e()}),t.pipe(l)),l.pipe(i)}[Ka](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[on](String(t.absolute),r,i=>{if(i){this[Le](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[rr](),t.resume())};t.mtime&&!this.noMtime&&(o++,X.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ni](t)&&(o++,X.chown(String(t.absolute),Number(this[ri](t)),Number(this[ii](t)),c)),c()})}[nl](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[el](t,e){let r=Z(Ae.relative(this.cwd,Ae.resolve(Ae.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Xr](t,this.cwd,r,()=>this[ys](t,String(t.linkpath),"symlink",e),i=>{this[Le](i,t),e()})}[tl](t,e){let r=Z(Ae.resolve(this.cwd,String(t.linkpath))),i=Z(String(t.linkpath)).split("/");this[Xr](t,this.cwd,i,()=>this[ys](t,r,"link",e),o=>{this[Le](o,t),e()})}[Xr](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Ae.resolve(e,c);X.lstat(l,(u,h)=>{if(u)return i();if(h?.isSymbolicLink())return o(new ks(l,Ae.resolve(l,r.join("/"))));this[Xr](t,l,r,i,o)})}[il](){this[cs]++}[rr](){this[cs]--,this[Aa]()}[$a](t){this[rr](),t.resume()}[Ga](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!oi}[ja](t){this[il]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Q0](t,r))}[Q0](t,e){let r=l=>{e(l)},i=()=>{this[on](this.cwd,this.dmode,l=>{if(l){this[Le](l,t),r();return}this[si]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Z(Ae.dirname(String(t.absolute)));if(l!==this.cwd)return this[on](l,this.dmode,u=>{if(u){this[Le](u,t),r();return}c()})}c()},c=()=>{X.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[$a](t),r();return}if(l||this[Ga](t,u))return this[rt](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let h=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=w=>this[rt](w??null,t,r);return h?X.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return X.rmdir(String(t.absolute),h=>this[rt](h??null,t,r))}if(t.absolute===this.cwd)return this[rt](null,t,r);zm(String(t.absolute),h=>this[rt](h??null,t,r))})};this[si]?o():i()}[rt](t,e,r){if(t){this[Le](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Wa](e,r);case"Link":return this[tl](e,r);case"SymbolicLink":return this[el](e,r);case"Directory":case"GNUDumpDir":return this[Ka](e,r)}}[ys](t,e,r,i){X[r](e,String(t.absolute),o=>{o?this[Le](o,t):(this[rr](),t.resume()),i()})}},Zr=t=>{try{return[null,t()]}catch(e){return[e,null]}},zl=class extends rc{sync=!0;[rt](t,e){return super[rt](t,e,()=>{})}[ja](t){if(!this[si]){let o=this[on](this.cwd,this.dmode);if(o)return this[Le](o,t);this[si]=!0}if(t.absolute!==this.cwd){let o=Z(Ae.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[on](o,this.dmode);if(c)return this[Le](c,t)}}let[e,r]=Zr(()=>X.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[$a](t);if(e||this[Ga](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,[l]=c?Zr(()=>{X.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[rt](l,t)}let[o]=Zr(()=>X.rmdirSync(String(t.absolute)));this[rt](o,t)}let[i]=t.absolute===this.cwd?[]:Zr(()=>Fm(String(t.absolute)));this[rt](i,t)}[Wa](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{X.closeSync(o)}catch(h){u=h}(l||u)&&this[Le](l||u,t),e()},o;try{o=X.openSync(String(t.absolute),Pl(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[Le](l,t)),t.pipe(c)),c.on("data",l=>{try{X.writeSync(o,l,0,l.length)}catch(u){i(u)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,h=t.mtime;try{X.futimesSync(o,u,h)}catch(p){try{X.utimesSync(String(t.absolute),u,h)}catch{l=p}}}if(this[ni](t)){let u=this[ri](t),h=this[ii](t);try{X.fchownSync(o,Number(u),Number(h))}catch(p){try{X.chownSync(String(t.absolute),Number(u),Number(h))}catch{l=l||p}}}i(l)})}[Ka](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[on](String(t.absolute),r);if(i){this[Le](i,t),e();return}if(t.mtime&&!this.noMtime)try{X.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ni](t))try{X.chownSync(String(t.absolute),Number(this[ri](t)),Number(this[ii](t)))}catch{}e(),t.resume()}[on](t,e){try{return Rm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[Xr](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Ae.resolve(c,l);let[u,h]=Zr(()=>X.lstatSync(c));if(u)return i();if(h.isSymbolicLink())return o(new ks(c,Ae.resolve(e,r.join("/"))))}i()}[ys](t,e,r,i){let o=`${r}Sync`;try{X[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[Le](c,t)}}},Um=t=>{let e=new zl(t),r=t.file,i=Sl.statSync(r),o=t.maxReadSize||16*1024*1024;new og(r,{readSize:o,size:i.size}).pipe(e)},Hm=(t,e)=>{let r=new rc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),Sl.stat(o,(u,h)=>{if(u)l(u);else{let p=new Ja(o,{readSize:i,size:h.size});p.on("error",l),p.pipe(r)}})})},Fl=ci(Um,Hm,t=>new zl(t),t=>new rc(t),(t,e)=>{e?.length&&ml(t,e)}),qm=(t,e)=>{let r=new nc(t),i=!0,o,c;try{try{o=Ze.openSync(t.file,"r+")}catch(h){if(h?.code==="ENOENT")o=Ze.openSync(t.file,"w+");else throw h}let l=Ze.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let w=0,b=0;w<512;w+=b){if(b=Ze.readSync(o,u,w,u.length-w,c+w),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!b)break e}let h=new kn(u);if(!h.cksumValid)break;let p=512*Math.ceil((h.size||0)/512);if(c+p+512>l.size)break;c+=p,t.mtimeCache&&h.mtime&&t.mtimeCache.set(String(h.path),h.mtime)}i=!1,jm(t,r,c,o,e)}finally{if(i)try{Ze.closeSync(o)}catch{}}},jm=(t,e,r,i,o)=>{let c=new cl(t.file,{fd:i,start:r});e.pipe(c),Wm(e,o)},Gm=(t,e)=>{e=Array.from(e);let r=new Rs(t),i=(o,c,l)=>{let u=(A,_)=>{A?Ze.close(o,E=>l(A)):l(null,_)},h=0;if(c===0)return u(null,0);let p=0,w=Buffer.alloc(512),b=(A,_)=>{if(A||_===void 0)return u(A);if(p+=_,p<512&&_)return Ze.read(o,w,p,w.length-p,h+p,b);if(h===0&&w[0]===31&&w[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,h);let E=new kn(w);if(!E.cksumValid)return u(null,h);let v=512*Math.ceil((E.size??0)/512);if(h+v+512>c||(h+=v+512,h>=c))return u(null,h);t.mtimeCache&&E.mtime&&t.mtimeCache.set(String(E.path),E.mtime),p=0,Ze.read(o,w,0,512,h,b)};Ze.read(o,w,0,512,h,b)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(h,p)=>{if(h&&h.code==="ENOENT"&&l==="r+")return l="w+",Ze.open(t.file,l,u);if(h||!p)return c(h);Ze.fstat(p,(w,b)=>{if(w)return Ze.close(p,()=>c(w));i(p,b.size,(A,_)=>{if(A)return c(A);let E=new Is(t.file,{fd:p,start:_});r.pipe(E),E.on("error",c),E.on("close",o),Km(r,e)})})};Ze.open(t.file,l,u)})},Wm=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?fr({file:Ul.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Km=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await fr({file:Ul.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},Yr=ci(qm,Gm,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!xg(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")}),P2=ci(Yr.syncFile,Yr.asyncFile,Yr.syncNoFile,Yr.asyncNoFile,(t,e=[])=>{Yr.validate?.(t,e),$m(t)}),$m=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))};Vt();var Et={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 Hl(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function ql(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function jl(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function ur(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}var R=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)}};ee();Fe();function Bt(t,e){if(di(t)!=="cloud")throw new R("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 Os="1008033",Gl="1289";var Wl="pbbp2",Kl="https://www.coze.cn",$l="/api/coze_claw/resource/get_frontier_key",Jm="https://www.coze.cn",Zm="wss://frontier.coze.cn";function Ns(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Jm}function Vl(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Zm}function hr(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 ic(t){let e=Ns(t.endpoint),r=t.timeoutMs??1e4,i=`${Ls(e)}${$l}?aid=${encodeURIComponent(Os)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...hr(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);li.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),h=u.headers.get("x-tt-logid")??"",p=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let E=await u.text().catch(()=>"");throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${h}: ${E.slice(0,200)}`)}let w=await u.json();if(w.code!==void 0&&w.code!==0)throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${h}`);let b=w.data??{},A=typeof b.access_key=="string"&&b.access_key||typeof b.accessKey=="string"&&b.accessKey||void 0,_=typeof b.device_id=="string"&&b.device_id||typeof b.deviceId=="string"&&b.deviceId||void 0;if(!A||!_){let E=JSON.stringify(w).slice(0,500);throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${h}: ${E}`)}return li.info("handshake ok",{remoteDeviceId:_,logid:h,traceId:p}),{accessKey:A,deviceId:_}}catch(u){if(u instanceof R)throw li.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw li.warn("handshake timeout",{base:e,timeoutMs:r}),new R("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let h=u.cause;throw li.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:h?.code,syscall:h?.syscall,cause:String(u).slice(0,300)}),new R("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(l)}}var sc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",vt="auto";function Jl(t){return{model:t.model??vt,...t.modelToken?{modelToken:t.modelToken}:{}}}function Zl(t){return!t||t===vt}function Yl(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=sc,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))):Zl(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function Xl(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||vt}"`):Zl(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="${sc}/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 Ql(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function oc(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 ef(t,e,r){if(!t.modelToken)return{};let i=oc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
118
- `)}}function ac(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function tf(t,e,r){if(!t.modelToken)return null;let i=t.model||vt,o=oc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${sc}/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 nf(t,e,r){if(!t.modelToken)return[];let i=oc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Oe=q("agent-handlers"),rf=5*1024*1024,nw=1,rw=6,iw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Ms=class{constructor(e){this.opts=e}opts;async listSkills(e){Bt(e._meta,"_agent/listSkills");let r=ur(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Dt(r).workspace,c=i?.skills??[],l=[];for(let u of c){let h=St(o,u.relPath,"SKILL.md");await Qm(h).then(w=>w.isFile()).catch(()=>!1)&&l.push(dw(u))}return{skills:l}}async addSkills(e){Bt(e._meta,"_agent/addSkills");let r=ur(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((h,p)=>[h.skillId,p])),u=[];for(let h of o){let p=await xc({agentId:r,workspace:i.workspace,framework:i.framework,skill:h});pc(c,l,p),u.push(h)}return await Hi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Bt(e._meta,"_agent/removeSkills");let r=ur(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let u of c){if(!o.has(u.skillId)){l.push(u);continue}let h=St(i.workspace,u.relPath);await Xm(h,{recursive:!0,force:!0}),Oe.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await Hi(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,Oe.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,Oe.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),h.stop(r).catch(p=>Oe.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(p)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Oe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await qe(r);if(!i)throw new R("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Oe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Jn(i.workspace,i.framework,r,e.cozeIdentity)}catch(o){throw Oe.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new R("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await $e(i),Oe.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 R("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await qe(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await $e(i),Oe.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(Oe.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Bt(e._meta,"_agent/switchModel"),!e.agentId)throw new R("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:vt,i=await qe(e.agentId);if(!i)throw new R("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await $e(i),Oe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Oe.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=>Oe.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,u]of o.allSessionQueues())c.push(u.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),Oe.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Bt(e._meta,Et.RESET),!e.agentId)throw new R("IPC_BAD_REQUEST",`${Et.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Et.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Bt(e._meta,Et.REPAIR),!e.agentId)throw new R("IPC_BAD_REQUEST",`${Et.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new R("IPC_BAD_REQUEST",`${Et.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Oe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,Et.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Oe.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Oe.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Bt(e._meta,"_agent/getFileTree");let r=e._meta,i=ur(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await cc(l).catch(()=>null);if(!u)throw new R("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Mr(l,o))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let h=_w(e.depth);return u.isDirectory()?{tree:await yw(o,l,c,h)}:{tree:[{name:bw(c),path:ff(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Bt(e._meta,"_agent/getFileContent");let r=ur(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new R("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await cc(o).catch(()=>null);if(!c||!c.isFile())throw new R("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Mr(o,i))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>rf)throw new R("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${rf})`);let l=await sf(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 qe(e).catch(()=>null))?.workspace??Dt(e).workspace}safeJoin(e,r){let i=fc(e,r||"."),o=hc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${of}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return qe(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new R("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function sw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new R("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new R("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function ow(t){return t==="claude-code"?St(".claude","skills"):St(".agents","skills")}var aw=3e4,cw=50*1024*1024,xr=3e4;async function xc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new R("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 R("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=sw(o.skillName),h=ow(i),p=St(h,u),w=St(r,p);if(await dc(w,{recursive:!0}),c){let A=Buffer.from(o.content,"utf8");ui(A.length),await lc(St(w,"SKILL.md"),A,"utf8")}else{let A=await lw(o.downloadUrl);uw(A)?await gw(A,w):hw(A)?await xw(A,w):await lc(St(w,"SKILL.md"),A.toString("utf8"),"utf8")}let b={skillId:o.skillId,skillName:o.skillName,relPath:p,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 Oe.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),b}function pc(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 dw(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function lw(t){if(!t)throw new R("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);ui(e);let r=fw(t);return ui(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await sf(e);return ui(r.length),r}if(Ps(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),aw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new R("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 R("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function ui(t){if(t>cw)throw new R("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function fw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new R("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 uw(t){return t.length>=2&&t[0]===31&&t[1]===139}function hw(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 uc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function xw(t,e){let r,i;try{r=new df.default(t),i=r.getEntries()}catch(l){throw new R("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||uc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new R("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new R("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let h=l.header.attr>>>16&61440;if(h!==0&&h!==32768&&h!==16384)throw new R("IPC_BAD_REQUEST",`zip entry kind 0x${h.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=pw(i),c=fc(e);for(let l of i){if(uc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let h=fc(e,u),p=hc(c,h);if(p.startsWith("..")||p==="..")throw new R("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await dc(h,{recursive:!0});continue}await dc(ew(h),{recursive:!0});let w;try{w=l.getData()}catch(b){throw new R("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${b.message}`,{cause:b})}await lc(h,w)}}function pw(t){let e;for(let r of t){let i=r.entryName;if(!i||uc(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 gw(t,e){await mw(t);let r=Fl({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar extract timeout (${xr}ms)`))},xr);try{await cf(af.from(t),r)}catch(c){throw c instanceof R?c:i?new R("IPC_BAD_REQUEST",`tar extract timeout (${xr}ms)`):new R("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function mw(t){let e=[],r=fr({onReadEntry:c=>{let l=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' 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(p=>p==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar list timeout (${xr}ms)`))},xr);try{await cf(af.from(t),r)}catch(c){throw i?new R("IPC_BAD_REQUEST",`tar list timeout (${xr}ms)`):new R("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new R("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var ww=5e3;async function yw(t,e,r,i){return lf(t,e,r,i,{count:0})}async function lf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await Ym(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(iw.has(u.name)||u.isSymbolicLink())continue;if(o.count>=ww){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let h=St(e,u.name),p=tw(St(r,u.name)),w=null;try{w=await cc(h)}catch{continue}if(w.isSymbolicLink())continue;o.count++;let b={name:u.name,path:ff(hc(t,h)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&i>1&&(b.children=await lf(t,h,p,i-1,o)),l.push(b)}return l.sort((u,h)=>u.isDir!==h.isDir?u.isDir?-1:1:u.name.localeCompare(h.name)),l}function _w(t){return!t||t<=0?nw:Math.min(t,rw)}function bw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function ff(t){return t.split(of).join("/")}ee();import{readFileSync as jv}from"node:fs";import{dirname as Wv,join as Kv}from"node:path";import{fileURLToPath as Vv}from"node:url";var pr="0.1.77";var dn=q("agent-health-reporter"),Ew=1e4,hi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Ew}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),dn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),dn.info("heartbeat stopped"))}async tick(){if(this.inFlight){dn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){dn.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 u=vw(l);if(!u)continue;let h={agentId:l.agentId,status:u};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:pr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){dn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(dn.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){dn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){dn.warn("onTickEnd hook failed",{err:String(r)})}}};function vw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Vt();import{mkdir as wc,rm as ny}from"node:fs/promises";$t();$t();import{spawnSync as kw}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 gr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function ln(t,e){return{jsonrpc:"2.0",id:t,error:e}}var Bs=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 uf(t){return"method"in t&&"id"in t&&t.id!==void 0}function hf(t){return"method"in t&&!("id"in t)}function zs(t){return!("method"in t)&&"id"in t}var Sw={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,NPX_CACHE_CORRUPT:Q.INTERNAL_ERROR};function Iw(t){if(t!=null)return t instanceof Error?{name:t.name,message:gi(t.message)}:typeof t=="string"?gi(t):typeof t=="object"?Tw(t):t}var Aw=[[/\/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 Aw)e=e.replace(r,i);return e}function Tw(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 R){let e=Iw(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:Sw[t.code]??Q.INTERNAL_ERROR,message:gi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:gi(t instanceof Error?t.message:String(t))}}function xf(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,...u}=e;c=u}return new R(r,o,{retriable:e?.retriable??!1,cause:c})}function gf(t){return`${JSON.stringify(t)}
119
- `}var pf=10*1024*1024,Fs=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>pf){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${pf} bytes`)}),[]}let r=this.buffer.split(`
120
- `);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 wf={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},sS=Object.fromEntries(Object.entries(wf).map(([t,e])=>[e,t])),Cw={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},mr=class{seq=0;next(e,r){this.seq+=1;let i=wf[e]??Rw(e),o=Cw[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(h=>mf(r?.[h]??"")),u=Dw(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>mf(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function Rw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function mf(t){return t.replace(/[:_\s]+/g,"-")}function Dw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Kn();function fn(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}ee();var Pw=fn("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Lw=200,Ow=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function gc(t){return t.some(e=>Ow.test(e))}var Nw=fn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Mw=fn("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),yf=500;function Bw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=yf?t:`${e.slice(0,yf)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function _f(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),kw("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var It=class{constructor(e){this.opts=e;this.log=q(`downstream.${this.constructor.name}`),this.decoder=new Fs({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new mr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new R("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Gn(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>Lw&&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]}),(this.framework==="claude-code"||this.framework==="codex")&&gc(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),mn(this.framework).catch(u=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(u)})})));try{for(let 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 R("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 R("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()));_f(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||_f(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=Nw,i=Mw){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(gr(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(ln(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=Pw,o=0){if(!this.child||this.stopped)return Promise.reject(new R("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=xi(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let w=r.sessionId;return typeof w=="string"?w:void 0})(),h=i>0&&Number.isFinite(i),p=o>0&&Number.isFinite(o);return new Promise((w,b)=>{let A={resolve:w,reject:b,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,...u?{sessionId:u}:{}}),b(new R("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));let _=p?()=>{A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),A.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...u?{sessionId:u}:{}}),_?.();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,...u?{sessionId:u}:{}}),b(new R("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${o}ms (no inflight agent request)`))},o)}:null;A.armFrameIdle=_,this.pending.set(c,A),_?.();try{this.writeFrame(l)}catch(E){A.timer&&clearTimeout(A.timer),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.pending.delete(c),b(E)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new R("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(gf(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(zs(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(xf(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new R("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Bw(e.result)}),r.resolve(e.result));return}if(hf(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(uf(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(ln(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(ln(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()}};var zw=Nr("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function Fw(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 Us=class extends It{framework="claude-code";constructor(e){let r=wn("claude-code"),[i,o]=r?[r,[]]:["npx",["-y",zw]],c=e.command??i,l=e.args??o,u={command:c,args:l,cwd:e.cwd,...e.env?{env:e.env}:{}};super(u)}sanitizeEnv(e){return Fw(e)}};$t();import{mkdtempSync as Uw,rmSync as Hw}from"node:fs";import{tmpdir as qw}from"node:os";import{join as jw}from"node:path";var Gw=Nr("codex")??"@zed-industries/codex-acp@^0.15",Hs=class extends It{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=wn("codex"),[i,o]=r?[r,[]]:["npx",["-y",Gw]],c=e.command??i,l=e.args??o,u=e.extraArgs?[...l,...e.extraArgs]:l,h=e.isolateCodexHome?Uw(jw(qw(),"coze-bridge-codex-home-")):void 0,p=h?{...e.env??{},CODEX_HOME:h}:e.env,w={command:c,args:u,cwd:e.cwd,...p?{env:p}:{}};super(w),this.authMethodId=e.authMethodId,this.codexHomeDir=h}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Hw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Ww=3e4,wr=class extends It{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}};ee();Fe();function mc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}$t();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,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 qs=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 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)}Kn();ee();import{constants as bf,access as Kw}from"node:fs/promises";import{delimiter as $w,join as Vw}from"node:path";var un=q("framework-detector"),Ef={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Jw=[".exe",".cmd",".bat",".ps1"],hn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Gn,access:e.access??Kw}}async detect(e){let r=Ef[e],i=await this.which(r);if(!i)return un.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)]),u={path:i,version:c};return l&&(u.defaultAgent=l),u}async detectAll(){let e=await Promise.all(Object.keys(Ef).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"?bf.F_OK:bf.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return un.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return un.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return un.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return un.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?(un.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(un.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return un.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,u=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"),u(null)},15e3),h.stdout?.on("data",p=>{o+=p.toString("utf8")}),h.on("error",()=>u(null)),h.on("close",p=>u({code:p,stdout:o}))}catch{u(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";Fi();ee();async function If(){let t=ey(Qw(),".openclaw/openclaw.json");return(await Vn(t))?.gateway?.auth?.token??""}var vf=q("openclaw.config"),ty=[0,5e3,5e3],Sf="models.providers.",js="agents.defaults.models",Gs=class{command;env;retryDelaysMs;queue=new yr;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,vf.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new R("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){vf.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",`${Sf}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Sf}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${js}[${e}]`,()=>this.runCli(["config","set",js,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${js}[${e}]`,`${js}.${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 Ne=q("agent-manager"),ry=(t,e,r,i,o,c,l,u,h)=>{switch(t){case"claude-code":{let p={...o?{...Yl(o),...ef(o,l,u)}:{},...h??{},IS_SANDBOX:"1"};return new Us({cwd:r,env:p})}case"codex":{let w=[...o?[...Xl(o),...nf(o,l,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],b={...o?Ql(o):{},...h??{}},A=!!o;return new Hs({cwd:r,...w.length>0?{extraArgs:w}:{},...Object.keys(b).length>0?{env:b}:{},...A?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new wr({command:e,cwd:r,agentId:i,...c?{sessionName:mc(c)}:{}})}};function yc(t){return t==="claude-code"||t==="codex"}var iy={path:"",version:"cloud-deployed"},sy={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},oy=6e4,ay=fn("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??ry,this.createTimeoutMs=e.createTimeoutMs??oy,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??ay,this.detectorFactory=e.detectorFactory??(()=>new hn)}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new R("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Gs({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new R("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new R("IPC_BAD_REQUEST","framework required");let r=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 R("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${i.framework})`);if(i.status==="error")Ne.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await i.dispose("rebuild after error").catch(E=>Ne.warn("dispose stale agent failed (ignored)",{err:String(E)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==i.patToken){Ne.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),i.setPatToken(e.patToken);let E=await qe(e.agentId,this.paths).catch(()=>null);E&&(E.patToken=e.patToken,await $e(E,this.paths))}if(i.deployType==="cloud"&&e.modelInfo){Ne.info("updating agent modelInfo on re-create",{agentId:e.agentId}),i.setModelInfo(e.modelInfo);let E=await qe(e.agentId,this.paths).catch(()=>null);E&&(E.modelInfo=e.modelInfo,await $e(E,this.paths))}return Ne.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 R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Dt(e.agentId,this.paths),l=di(e._meta),u=e.framework==="openclaw"&&l==="local",h=u?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??h??c.workspace,w=new AbortController,b=setTimeout(()=>w.abort(new R("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,_=!1;try{r&&yc(e.framework)&&await mn(e.framework,w.signal);let E=()=>{if(w.signal.aborted)throw w.signal.reason instanceof Error?w.signal.reason:new R("AGENT_TIMEOUT","_agent/create aborted")};await wc(c.root,{recursive:!0}),await wc(p,{recursive:!0}),await wc(c.logs,{recursive:!0}),E(),u||await Jn(p,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Kd(p),E();let v=await qe(e.agentId,this.paths).catch(()=>null),I=Jl({model:e.model??v?.model}),k=Hl(e._meta)??v?.accountId,O=e.patToken??v?.patToken,y=l==="cloud"?e.modelInfo??v?.modelInfo:void 0;if(A=new qs({agentId:e.agentId,framework:e.framework,workspace:p,model:I.model??vt,deployType:l,...k?{accountId:k}:{},...O?{patToken:O}:{},...y?{modelInfo:y}:{}}),A.status="ok",v?.sessions){for(let[z,P]of Object.entries(v.sessions))A.sessions.set(z,{acpSessionId:P.acpSessionId,modelToken:P.modelToken,tokenGeneratedAt:P.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(v.sessions).length;F>0&&Ne.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(A),_=!0;let C={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:v?.createdAt??Date.now(),sessions:v?.sessions??{},model:I.model};l==="cloud"&&(C.deployType="cloud"),k&&(C.accountId=k),O&&(C.patToken=O),y&&(C.modelInfo=y),v?.skills&&(C.skills=v.skills),v?.agentName&&(C.agentName=v.agentName),v?.description&&(C.description=v.description),e.framework==="openclaw"&&l==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,p):Ne.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let L=e.initialSkills??[];if(L.length>0){let F=[...C.skills??[]],z=new Map(F.map((U,W)=>[U.skillId,W])),P=await Promise.allSettled(L.map(U=>xc({agentId:e.agentId,workspace:p,framework:e.framework,skill:U}))),N=0;for(let[U,W]of P.entries()){let oe=L[U];oe&&(W.status==="fulfilled"?(pc(F,z,W.value),N++):Ne.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:oe.skillId,skillName:oe.skillName,err:String(W.reason)}))}N>0&&(C.skills=F,Ne.info("initialSkills installed",{agentId:e.agentId,installed:N,requested:L.length}))}return await $e(C,this.paths),Ne.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:l}),{ok:!0,agentId:e.agentId,workspace:p,framework:e.framework}}catch(E){throw Ne.error("agent create failed, rolling back",{agentId:e.agentId,err:String(E)}),_&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ny(c.root,{recursive:!0,force:!0}).catch(v=>Ne.warn("rm agent dir failed (ignored)",{err:String(v)})),E instanceof R?E:new R("AGENT_SPAWN_FAILED",String(E),{cause:E})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&yc(e.framework))u=iy;else throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(yc(e.framework)&&!wn(e.framework)){let w=$o(e.framework);w&&(Ne.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([w.catch(()=>{}),new Promise(b=>setTimeout(b,this.spawnAwaitInstallMs))]))}let h=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:h,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,h,i,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(sy),p}catch(w){let b=p instanceof It?p.getStderrTail():[];b.length>0&&Ne.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof R?w.code:"unknown",recentStderr:b});let A=gc(b);await p.stop("spawnSessionDownstream failed").catch(()=>{});let _=A?new R("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:w}):w;throw w instanceof R?new R(w.code,w.message,{retriable:w.retriable,cause:_}):new R("AGENT_SPAWN_FAILED",w instanceof Error?w.message:String(w),{cause:_})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,h=mc(o);if(r.deployType==="local"){let A=this.config.frameworksCache?.openclaw?.defaultAgent;if(!A?.id||!A.workspace){Ne.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)Ne.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 R("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent")}return new wr({command:u,cwd:A.workspace,agentId:A.id,sessionName:h})}let p=await If(),w=i?tf(i,c,l):null,b;if(w){let A=ac(o),E=w.models[0]?.id??vt,v=`${A}/${E}`;if(!this.ensuredProviders.has(v)){let I=this.getOpenclawConfig();await I.ensureProvider(A,w),await I.addModelToAllowlist(v),this.ensuredProviders.add(v)}b=v}return new wr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:h,...p?{gatewayToken:p}:{},...b?{slashModelOnStart:b}:{}})}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=ac(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,Ne.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,Ne.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as Df}from"node:crypto";import{promises as wy}from"node:fs";import{basename as kf}from"node:path";import{promises as dy}from"node:fs";import{basename as ly}from"node:path";ee();var Af=q("file-upload"),fy="/api/coze_claw/file/agent_upload",uy=6e4;async function Tf(t,e={}){let i=`${Ls(Ns(e.handshakeBase))}${fy}`,o=e.timeoutMs??uy,c=await dy.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 u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...hr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},h=new AbortController,p=setTimeout(()=>h.abort(),o);Af.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let w=await fetch(i,{method:"POST",headers:u,body:l,signal:h.signal}),b=w.headers.get("x-tt-logid")??"";if(!w.ok){let E=await w.text().catch(()=>"");throw new R("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${b}: ${E.slice(0,200)}`)}let A=await w.json();if(A.code!==void 0&&A.code!==0)throw new R("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${b}`);let _=A.data?.file?.file_url;if(!_)throw new R("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${b}: ${JSON.stringify(A).slice(0,200)}`);return Af.info("file upload ok",{uri:_,logid:b}),{uri:_}}catch(w){throw w instanceof R?w:w.name==="AbortError"?new R("UPLOAD_FAILED",`upload timeout (${o}ms) for ${ly(t.path)}`):new R("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(p)}}ee();import{promises as hy}from"node:fs";import{extname as xy}from"node:path";var py=[{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 gy(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 my={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Cf(t){let e=await hy.open(t,"r");try{let r=Buffer.alloc(16);if(await e.read(r,0,16,0),gy(r))return"image/webp";for(let i of py)if(i.prefix.every((o,c)=>r[c]===o))return i.mime}finally{await e.close()}return my[xy(t).toLowerCase()]??"application/octet-stream"}Fe();var Ks=q("agent-send"),Rf=50*1024*1024,yy=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Pf(t,e,r){let i=t.get(e);if(!i)throw new R("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new R("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new R("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function Lf(t,e,r,i,o,c){let u;for(let h=0;h<=2;h++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(p){u=p,h<2&&(Ks.warn("sendAgentFileUpdate failed, retrying",{attempt:h+1,err:String(p)}),await new Promise(w=>setTimeout(w,5e3)))}throw new R("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function Of(t,e){let{session:r,runtime:i}=Pf(e.core,t.agentId,t.sessionId);if(!await Mr(t.path,r.workspace))throw new R("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await wy.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new R("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>Rf)throw new R("FILE_TOO_LARGE",`${o.size} bytes > limit ${Rf}`);let c=await Cf(t.path);if(!yy.has(c))throw new R("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(t.kind==="image"&&!c.startsWith("image/"))throw new R("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??kf(t.path),u;try{u=await Tf({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(p){throw Ks.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof R?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let h={sessionUpdate:"agent_file",messageId:Df(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:l,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Lf(e,r,i,t.sessionId,h,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Ks.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function Nf(t,e){let{session:r,runtime:i}=Pf(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new R("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??kf(t.path),c={sessionUpdate:"group_file",messageId:Df(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Lf(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Ks.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 Mf(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,u=i[c]??0;if(l<u)return!0;if(l>u)return!1}return!1}$t();Kn();ee();var At=q("coze-cli-installer"),Bf="@coze/cli@latest",_y="coze",zf="0.1.7",by=5e3,Ey=5e3,vy=9e4,Ff=1e4,yi=null,$s=!1;async function _c(t,e={}){if($s)return;if(yi)return yi;let r=e.exec??Wn;return yi=(async()=>{try{let i=await Sy(_y,r),o=!1;if(i){let l=await Iy(r);if(l===void 0)At.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(Mf(l,zf))At.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:zf}),o=!0;else{At.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),$s=!0;return}}let c=o?"upgrade-only":"full";At.info("coze-cli install start",{package:Bf,mode:c});try{await r("npm",["i","-g","--prefer-online",Bf],{timeout:vy,maxBuffer:10*1024*1024}),At.info("coze-cli install ok")}catch(l){At.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){$s=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Ff}),At.info("coze config set xTTEnv ok",{env:t.env})}catch(l){At.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Ff}),At.info("coze auth login ok")}catch(l){At.warn("coze auth login failed",{err:String(l)});return}$s=!0}finally{yi=null}})(),yi}async function Sy(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:by});return Bi(i)}catch{return}}async function Iy(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Ey});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Fi();Fe();var Ay=10*6e4;function Uf(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Ay:e}function Vs(t){return Vn(t??te().configFile)}function _r(t,e){return zi(e??te().configFile,t)}import{randomBytes as Gy}from"node:crypto";import{createReadStream as Ty}from"node:fs";import{mkdir as Cy,readFile as Ry,realpath as Dy,stat as ky,writeFile as Py}from"node:fs/promises";import{basename as Ly,dirname as bc,join as Oy,relative as Ny,resolve as Hf,sep as My}from"node:path";import{createInterface as By}from"node:readline";ee();var jf=q("fs-rpc"),_i=fn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Gf(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>_i)throw new R("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${_i} bytes`);let i=await Kf(t.path,e);return await Cy(bc(i),{recursive:!0}),await Py(i,t.content,"utf8"),jf.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Wf(t,e){let r=await Kf(t.path,e),i=await ky(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>_i&&!o)throw new R("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 zy(r,t.line??1,t.limit);else{let l=await Ry(r,"utf8");if(o){let u=l.split(`
121
- `),h=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?h+t.limit:void 0;c=u.slice(h,p).join(`
122
- `)}else c=l}return jf.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function zy(t,e,r){let i=By({input:Ty(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,l=[],u=0;try{for await(let h of i)if(u>=o&&u<c&&l.push(h),u++,u>=c)break}finally{i.close()}return l.join(`
123
- `)}async function Kf(t,e){if(typeof t!="string"||t.length===0)throw new R("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([qf(Hf(e)),qf(Hf(t))]),o=Ny(r,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${My}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}async function qf(t){let e=[],r=t;for(;r!==bc(r);)try{let i=await Dy(r);return e.length?Oy(i,...e.reverse()):i}catch{e.push(Ly(r)),r=bc(r)}return t}ee();var $f=q("prompt-multimodal"),Vf=10*1024*1024,Fy=15e3,Uy=6;async function Jf(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 Hy(l))}}let o=Array.from({length:Math.min(Uy,t.length)},()=>i());return await Promise.all(o),e}function Zf(t){return t.some(e=>e.type==="image")}async function Hy(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:i}=await jy(e.uri),o=e.mimeType||qy(i)||"application/octet-stream";return $f.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 $f.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function qy(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function jy(t){let e=new AbortController,r=setTimeout(()=>e.abort(),Fy);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>Vf)throw new Error(`image too large: ${o.byteLength} bytes (max ${Vf})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Vt();ee();var V=q("core"),Wy=3e4,Ky=/^(boe|ppe)_[A-Za-z0-9_-]+$/,$y=3e4,Js=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new mr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Uf(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(ln(o,{code:Q.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:Q.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:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new R("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(zs(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&&Ky.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,Q.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(gr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(gr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(gr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.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(ln(r,mi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new R("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new R("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new R("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new R("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(),u=!1;try{let h=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,h}finally{V.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=jl(i);switch(r){case"session/new":{let c=Vy();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 R("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,l);if(u.replySeq=0,await this.ensureDownstream(e,l,u),!u.downstream||!u.acpSessionId)throw new R("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let h=i._meta?.cozeTriggerMsgId;h?e.activeTriggers.set(u.acpSessionId,h):e.activeTriggers.delete(u.acpSessionId);let p=ql(i._meta);if(p?e.activeGroupIds.set(u.acpSessionId,p):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Zf(c.prompt))throw new R("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await Jf(c.prompt);try{let b=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:w});return u.lastActiveAt=Date.now(),b}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.reloadAfterTurn){u.reloadAfterTurn=!1;let b=u.downstream;b&&(u.downstream=void 0,V.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:u.acpSessionId}),b.stop("reload-after-turn").catch(A=>V.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(A)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,l,u)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new R("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=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 R("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new R("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let 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(Et.GEN_MODEL_TOKEN,i,$y);if(!o?.modelToken)throw new R("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof R&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new R("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 R("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new R("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()-u))/1e3)}s`);let h;try{h=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(p){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),p}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(p){V.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let w=await h.sessionNew({cwd:e.workspace});i.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let p=await h.sessionNew({cwd:e.workspace});i.acpSessionId=p.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 u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}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(Zy(r)){V.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(i);u&&(l.cozeTriggerMsgId=u);let h=e.activeGroupIds.get(i);h&&(l.cozeGroupId=h),this.upstream.send(pi("session/update",{...r,sessionId:o,_meta:l})).catch(p=>V.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}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:Q.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 Gf(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Wf(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??{},u=c.sessionId,h=u?e.activeTriggers.get(u):void 0,p={cozeAgentId:e.agentId};h&&(p.cozeTriggerMsgId=h);let w=u?e.activeGroupIds.get(u):void 0;w&&(p.cozeGroupId=w);let b=u?this.reverseSessionId(e,u):void 0,A={...c,...b?{sessionId:b}:{},_meta:p};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:u,cloudSessionId:b,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(_=>({optionId:_.optionId,kind:_.kind,name:_.name}))}),this.upstream.send(xi(o,"session/request_permission",A)).catch(_=>{this.pendingUpstream.delete(o),V.error("forward permission request failed",{agentId:e.agentId,err:String(_)}),r.respondAgentRequestError(i.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 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 Bs(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=Wy){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new R("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(xi(o,e,r)).catch(h=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.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 Vo(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(ln(e,{code:r,message:i,data:{bridgeVersion:pr}}))}};function Vy(){return Gy(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 Zy(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 `")}ee();Fe();import{randomBytes as Yy}from"node:crypto";import{chmod as Xy,mkdir as Qy,writeFile as Yf}from"node:fs/promises";import{createServer as e_}from"node:http";import{dirname as t_}from"node:path";var n_=1e6,Ec=q("ipc"),Zs=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=Yy(32).toString("hex");let e=e_((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(),Ec.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 Qy(t_(this.paths.portFile),{recursive:!0}),await Yf(this.paths.portFile,String(this.port),"utf8"),await Yf(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Xy(this.paths.tokenFile,384)}catch(e){Ec.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){bi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){bi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await r_(e)}catch(u){bi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);bi(r,200,u??{ok:!0})}catch(u){Ec.error("IPC handler failed",{key:o,err:String(u)}),bi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function bi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function r_(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>n_)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var yh=pt(cu(),1);var Bb=pt(rh(),1),zb=pt(ho(),1),Fb=pt(vr(),1),Ub=pt(Nc(),1),Hb=pt(zc(),1),qb=pt(Gc(),1),uh=pt(mo(),1),jb=pt(fh(),1);var hh=uh.default;ee();var Ce=q("upstream.frontier"),ph="application/json",gh="none",Wb=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){Ce.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Kl,...hr(this.opts.ppeOverride)};class r extends hh{constructor(E){super(E,Wl,{headers:e})}send(E,...v){if(Dd("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 k=Buffer.from(I.slice(0,128)).toString("hex");Ce.debug("WS raw frame out",{bytes:I.byteLength,headHex:k})}catch(I){Ce.warn("WS raw frame dump failed",{err:String(I)})}super.send(E,...v)}}let i=Vl(this.opts.urlOverride),o={url:i,ws:r,fpID:Gl,aID:Os,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:ph,force:!0},payloadEncoding:{encoding:gh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new yh.FWS(o),l=!1,u=null,h,p,w=new Promise((_,E)=>{h=_,p=E}),b=_=>{l||(l=!0,u&&(clearTimeout(u),u=null),_?p(_):h())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;Ce.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&b();for(let E of this.connectHandlers)Promise.resolve(E({initial:_})).catch(v=>Ce.warn("onConnect handler threw (ignored)",{err:String(v)}))},c.onclose=_=>{this.opened=!1,Ce.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{Ce.warn("frontier error",{code:_.code,msg:_.message}),b(new R("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let A=this.opts.openTimeoutMs??Wb;u=setTimeout(()=>{b(new R("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await w}catch(_){try{c.close(1e3,"open failed")}catch(E){Ce.warn("fws close during start failure threw (ignored)",{err:String(E)})}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(i){Ce.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Ce.warn("frontier send refused: upstream not started",{method:i}),new R("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Ce.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new R("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;mh(c)||Ce.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:ph,payloadEncoding:gh})}catch(u){throw Ce.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new R("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let 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){Ce.debug("drop non-adapter frontier frame",{service:r});return}let i=Vb(e);if(!i){Ce.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ce.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Ce.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;mh(c)||Ce.info("frontier frame in",{logid:$b(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:Kb(i)}),Promise.resolve(this.handler(o)).catch(l=>Ce.warn("frontier frame handler threw",{err:String(l)}))}};function mh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var wh=2e3;function Kb(t){return t.length<=wh?t:`${t.slice(0,wh)}...<truncated, total ${t.length} chars>`}function $b(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function Vb(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 Kc=q("upstream.switchable"),yo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Kc.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 Kc.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Kc.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()}};ee();var $c=q("upstream"),Rr=class{handler=null;async start(){$c.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){$c.info("NoopUpstream stopped",{reason:e})}async send(e){$c.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();Fe();import{promises as Vc}from"node:fs";import{dirname as Jb}from"node:path";var Zb=q("pat-token-store");async function _h(t=te()){try{let r=(await Vc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Zb.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function ki(t,e=te()){if(!t)throw new Error("writePatToken: empty patToken");await Vc.mkdir(Jb(e.patTokenFile),{recursive:!0}),await Vc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Fe();Fe();import{promises as _o}from"node:fs";import{join as Yb}from"node:path";function Xb(t,e){return`#!/bin/sh
115
+ `;var We=j("agent-detail-sync"),Ip=6e4,Ap=5*6e4,qi=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,s;try{s=await Sp(r)}catch(a){We.info("agents dir not found, skip detail sync",{root:r,err:String(a)});return}We.info("starting detail sync",{reason:e,count:s.length}),await Promise.allSettled(s.map(async a=>{let c=await Fe(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){We.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(f){We.warn("detail sync failed for agent, skipping",{agentId:a,err:String(f)})}}})),We.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){We.info("retrying pending detail syncs",{count:r.length});for(let s of r)try{await this.syncOne(s)}catch(a){We.debug("detail sync retry still failing, will try again",{agentId:s,err:String(a)})}}}async syncOne(e,r){let s=r??await Fe(e,this.opts.paths);if(!s){We.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(u){We.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let x=this.retryQueue.get(e),h=x?Math.min(x.currentDelay*2,Ap):Ip;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(a.agentId&&a.agentId!==e){We.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&&We.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){We.debug("detail sync: no diff",{agentId:e});return}await Ge(s,this.opts.paths),We.info("detail sync: config updated",{agentId:e,identityChanged:f,agentName:s.agentName}),f&&(await Jn(s.workspace,s.framework,e,s.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var du=lt(Id(),1);import{lstat as ac,mkdir as cc,readFile as su,readdir as Xm,rm as Qm,stat as ew,writeFile as dc}from"node:fs/promises";import{dirname as tw,join as bt,normalize as nw,relative as lc,resolve as fc,sep as ou}from"node:path";import{Readable as au}from"node:stream";import{pipeline as cu}from"node:stream/promises";import $p from"events";import je from"fs";import{EventEmitter as Va}from"node:events";import af from"node:stream";import{StringDecoder as Jp}from"node:string_decoder";import ff from"node:path";import ar from"node:fs";import{dirname as cg,parse as dg}from"path";import{EventEmitter as mg}from"events";import Ta from"assert";import{Buffer as Rn}from"buffer";import*as Dd from"zlib";import wg from"zlib";import{posix as er}from"node:path";import{basename as Wg}from"node:path";import _s from"fs";import gt from"fs";import Bd from"path";import{win32 as nm}from"node:path";import Gd from"path";import If from"node:fs";import _m from"node:assert";import{randomBytes as Af}from"node:crypto";import X from"node:fs";import ve from"node:path";import Cf from"fs";import Ts from"node:fs";import ei from"node:path";import $e from"node:fs";import Am from"node:fs/promises";import Es from"node:path";import{join as zf}from"node:path";import Ve from"node:fs";import qf from"node:path";var Kp=Object.defineProperty,Vp=(t,e)=>{for(var r in e)Kp(t,r,{get:e[r],enumerable:!0})},Ad=typeof process=="object"&&process?process:{stdout:null,stderr:null},Zp=t=>!!t&&typeof t=="object"&&(t instanceof Pn||t instanceof af||Yp(t)||Xp(t)),Yp=t=>!!t&&typeof t=="object"&&t instanceof Va&&typeof t.pipe=="function"&&t.pipe!==af.Writable.prototype.pipe,Xp=t=>!!t&&typeof t=="object"&&t instanceof Va&&typeof t.write=="function"&&typeof t.end=="function",Rt=Symbol("EOF"),Dt=Symbol("maybeEmitEnd"),Jt=Symbol("emittedEnd"),Ki=Symbol("emittingEnd"),Br=Symbol("emittedError"),Vi=Symbol("closed"),Cd=Symbol("read"),$i=Symbol("flush"),Td=Symbol("flushChunk"),ot=Symbol("encoding"),Qn=Symbol("decoder"),Ce=Symbol("flowing"),zr=Symbol("paused"),ir=Symbol("resume"),Te=Symbol("buffer"),qe=Symbol("pipes"),Re=Symbol("bufferLength"),ea=Symbol("bufferPush"),Ji=Symbol("bufferShift"),Ue=Symbol("objectMode"),me=Symbol("destroyed"),ta=Symbol("error"),na=Symbol("emitData"),Rd=Symbol("emitEnd"),ra=Symbol("emitEnd2"),xt=Symbol("async"),ia=Symbol("abort"),Zi=Symbol("aborted"),Fr=Symbol("signal"),yn=Symbol("dataListeners"),Ke=Symbol("discarded"),Ur=t=>Promise.resolve().then(t),Qp=t=>t(),eg=t=>t==="end"||t==="finish"||t==="prefinish",tg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,ng=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),cf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[ir](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},rg=class extends cf{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)}},ig=t=>!!t.objectMode,sg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Pn=class extends Va{[Ce]=!1;[zr]=!1;[qe]=[];[Te]=[];[Ue];[ot];[xt];[Qn];[Rt]=!1;[Jt]=!1;[Ki]=!1;[Vi]=!1;[Br]=null;[Re]=0;[me]=!1;[Fr];[Zi]=!1;[yn]=0;[Ke]=!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");ig(e)?(this[Ue]=!0,this[ot]=null):sg(e)?(this[ot]=e.encoding,this[Ue]=!1):(this[Ue]=!1,this[ot]=null),this[xt]=!!e.async,this[Qn]=this[ot]?new Jp(this[ot]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Te]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[qe]});let{signal:r}=e;r&&(this[Fr]=r,r.aborted?this[ia]():r.addEventListener("abort",()=>this[ia]()))}get bufferLength(){return this[Re]}get encoding(){return this[ot]}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[Ue]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[xt]}set async(t){this[xt]=this[xt]||!!t}[ia](){this[Zi]=!0,this.emit("abort",this[Fr]?.reason),this.destroy(this[Fr]?.reason)}get aborted(){return this[Zi]}set aborted(t){}write(t,e,r){if(this[Zi])return!1;if(this[Rt])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[xt]?Ur:Qp;if(!this[Ue]&&!Buffer.isBuffer(t)){if(ng(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(tg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ue]?(this[Ce]&&this[Re]!==0&&this[$i](!0),this[Ce]?this.emit("data",t):this[ea](t),this[Re]!==0&&this.emit("readable"),r&&s(r),this[Ce]):t.length?(typeof t=="string"&&!(e===this[ot]&&!this[Qn]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ot]&&(t=this[Qn].write(t)),this[Ce]&&this[Re]!==0&&this[$i](!0),this[Ce]?this.emit("data",t):this[ea](t),this[Re]!==0&&this.emit("readable"),r&&s(r),this[Ce]):(this[Re]!==0&&this.emit("readable"),r&&s(r),this[Ce])}read(t){if(this[me])return null;if(this[Ke]=!1,this[Re]===0||t===0||t&&t>this[Re])return this[Dt](),null;this[Ue]&&(t=null),this[Te].length>1&&!this[Ue]&&(this[Te]=[this[ot]?this[Te].join(""):Buffer.concat(this[Te],this[Re])]);let e=this[Cd](t||null,this[Te][0]);return this[Dt](),e}[Cd](t,e){if(this[Ue])this[Ji]();else{let r=e;t===r.length||t===null?this[Ji]():typeof r=="string"?(this[Te][0]=r.slice(t),e=r.slice(0,t),this[Re]-=t):(this[Te][0]=r.subarray(t),e=r.subarray(0,t),this[Re]-=t)}return this.emit("data",e),!this[Te].length&&!this[Rt]&&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[Rt]=!0,this.writable=!1,(this[Ce]||!this[zr])&&this[Dt](),this}[ir](){this[me]||(!this[yn]&&!this[qe].length&&(this[Ke]=!0),this[zr]=!1,this[Ce]=!0,this.emit("resume"),this[Te].length?this[$i]():this[Rt]?this[Dt]():this.emit("drain"))}resume(){return this[ir]()}pause(){this[Ce]=!1,this[zr]=!0,this[Ke]=!1}get destroyed(){return this[me]}get flowing(){return this[Ce]}get paused(){return this[zr]}[ea](t){this[Ue]?this[Re]+=1:this[Re]+=t.length,this[Te].push(t)}[Ji](){return this[Ue]?this[Re]-=1:this[Re]-=this[Te][0].length,this[Te].shift()}[$i](t=!1){do;while(this[Td](this[Ji]())&&this[Te].length);!t&&!this[Te].length&&!this[Rt]&&this.emit("drain")}[Td](t){return this.emit("data",t),this[Ce]}pipe(t,e){if(this[me])return t;this[Ke]=!1;let r=this[Jt];return e=e||{},t===Ad.stdout||t===Ad.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[qe].push(e.proxyErrors?new rg(this,t,e):new cf(this,t,e)),this[xt]?Ur(()=>this[ir]()):this[ir]()),t}unpipe(t){let e=this[qe].find(r=>r.dest===t);e&&(this[qe].length===1?(this[Ce]&&this[yn]===0&&(this[Ce]=!1),this[qe]=[]):this[qe].splice(this[qe].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[Ke]=!1,this[yn]++,!this[qe].length&&!this[Ce]&&this[ir]();else if(t==="readable"&&this[Re]!==0)super.emit("readable");else if(eg(t)&&this[Jt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Br]){let s=e;this[xt]?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[yn]=this.listeners("data").length,this[yn]===0&&!this[Ke]&&!this[qe].length&&(this[Ce]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[yn]=0,!this[Ke]&&!this[qe].length&&(this[Ce]=!1)),e}get emittedEnd(){return this[Jt]}[Dt](){!this[Ki]&&!this[Jt]&&!this[me]&&this[Te].length===0&&this[Rt]&&(this[Ki]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Vi]&&this.emit("close"),this[Ki]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==me&&this[me])return!1;if(t==="data")return!this[Ue]&&!r?!1:this[xt]?(Ur(()=>this[na](r)),!0):this[na](r);if(t==="end")return this[Rd]();if(t==="close"){if(this[Vi]=!0,!this[Jt]&&!this[me])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[Br]=r,super.emit(ta,r);let a=!this[Fr]||this.listeners("error").length?super.emit("error",r):!1;return this[Dt](),a}else if(t==="resume"){let a=super.emit("resume");return this[Dt](),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[Dt](),s}[na](t){for(let r of this[qe])r.dest.write(t)===!1&&this.pause();let e=this[Ke]?!1:super.emit("data",t);return this[Dt](),e}[Rd](){return this[Jt]?!1:(this[Jt]=!0,this.readable=!1,this[xt]?(Ur(()=>this[ra]()),!0):this[ra]())}[ra](){if(this[Qn]){let e=this[Qn].end();if(e){for(let r of this[qe])r.dest.write(e);this[Ke]||super.emit("data",e)}}for(let e of this[qe])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Ue]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Ue]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Ue])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ot]?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[Ke]=!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[Rt])return e();let s,a,c=h=>{this.off("data",f),this.off("end",u),this.off(me,x),e(),a(h)},f=h=>{this.off("error",c),this.off("end",u),this.off(me,x),this.pause(),s({value:h,done:!!this[Rt]})},u=()=>{this.off("error",c),this.off("data",f),this.off(me,x),e(),s({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,m)=>{a=m,s=h,this.once(me,x),this.once("error",c),this.once("end",u),this.once("data",f)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Ke]=!1;let t=!1,e=()=>(this.pause(),this.off(ta,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(ta,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[Ke]=!0,this[Te].length=0,this[Re]=0;let e=this;return typeof e.close=="function"&&!this[Vi]&&e.close(),t?this.emit("error",t):this.emit(me),this}static get isStream(){return Zp}},og=je.writev,on=Symbol("_autoClose"),ft=Symbol("_close"),qr=Symbol("_ended"),ie=Symbol("_fd"),sa=Symbol("_finished"),Ot=Symbol("_flags"),oa=Symbol("_flush"),Aa=Symbol("_handleChunk"),Ca=Symbol("_makeBuf"),Xr=Symbol("_mode"),Yi=Symbol("_needDrain"),dr=Symbol("_onerror"),fr=Symbol("_onopen"),aa=Symbol("_onread"),sr=Symbol("_onwrite"),an=Symbol("_open"),dt=Symbol("_path"),en=Symbol("_pos"),ht=Symbol("_queue"),or=Symbol("_read"),ca=Symbol("_readSize"),Lt=Symbol("_reading"),Hr=Symbol("_remain"),da=Symbol("_size"),as=Symbol("_write"),bn=Symbol("_writing"),cs=Symbol("_defaultFlag"),Tn=Symbol("_errored"),$a=class extends Pn{[Tn]=!1;[ie];[dt];[ca];[Lt]=!1;[da];[Hr];[on];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Tn]=!1,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[dt]=t,this[ca]=e.readSize||16*1024*1024,this[Lt]=!1,this[da]=typeof e.size=="number"?e.size:1/0,this[Hr]=this[da],this[on]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ie]=="number"?this[or]():this[an]()}get fd(){return this[ie]}get path(){return this[dt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[an](){je.open(this[dt],"r",(t,e)=>this[fr](t,e))}[fr](t,e){t?this[dr](t):(this[ie]=e,this.emit("open",e),this[or]())}[Ca](){return Buffer.allocUnsafe(Math.min(this[ca],this[Hr]))}[or](){if(!this[Lt]){this[Lt]=!0;let t=this[Ca]();if(t.length===0)return process.nextTick(()=>this[aa](null,0,t));je.read(this[ie],t,0,t.length,null,(e,r,s)=>this[aa](e,r,s))}}[aa](t,e,r){this[Lt]=!1,t?this[dr](t):this[Aa](e,r)&&this[or]()}[ft](){if(this[on]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,je.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[dr](t){this[Lt]=!0,this[ft](),this.emit("error",t)}[Aa](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[ft](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ie]=="number"&&this[or](),!1;case"error":return this[Tn]?!1:(this[Tn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},ag=class extends $a{[an](){let t=!0;try{this[fr](null,je.openSync(this[dt],"r")),t=!1}finally{t&&this[ft]()}}[or](){let t=!0;try{if(!this[Lt]){this[Lt]=!0;do{let e=this[Ca](),r=e.length===0?0:je.readSync(this[ie],e,0,e.length,null);if(!this[Aa](r,e))break}while(!0);this[Lt]=!1}t=!1}finally{t&&this[ft]()}}[ft](){if(this[on]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,je.closeSync(t),this.emit("close")}}},vs=class extends $p{readable=!1;writable=!0;[Tn]=!1;[bn]=!1;[qr]=!1;[ht]=[];[Yi]=!1;[dt];[Xr];[on];[ie];[cs];[Ot];[sa]=!1;[en];constructor(t,e){e=e||{},super(e),this[dt]=t,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[Xr]=e.mode===void 0?438:e.mode,this[en]=typeof e.start=="number"?e.start:void 0,this[on]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[en]!==void 0?"r+":"w";this[cs]=e.flags===void 0,this[Ot]=e.flags===void 0?r:e.flags,this[ie]===void 0&&this[an]()}emit(t,...e){if(t==="error"){if(this[Tn])return!1;this[Tn]=!0}return super.emit(t,...e)}get fd(){return this[ie]}get path(){return this[dt]}[dr](t){this[ft](),this[bn]=!0,this.emit("error",t)}[an](){je.open(this[dt],this[Ot],this[Xr],(t,e)=>this[fr](t,e))}[fr](t,e){this[cs]&&this[Ot]==="r+"&&t&&t.code==="ENOENT"?(this[Ot]="w",this[an]()):t?this[dr](t):(this[ie]=e,this.emit("open",e),this[bn]||this[oa]())}end(t,e){return t&&this.write(t,e),this[qr]=!0,!this[bn]&&!this[ht].length&&typeof this[ie]=="number"&&this[sr](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[bn]||this[ht].length?(this[ht].push(t),this[Yi]=!0,!1):(this[bn]=!0,this[as](t),!0)}[as](t){je.write(this[ie],t,0,t.length,this[en],(e,r)=>this[sr](e,r))}[sr](t,e){t?this[dr](t):(this[en]!==void 0&&typeof e=="number"&&(this[en]+=e),this[ht].length?this[oa]():(this[bn]=!1,this[qr]&&!this[sa]?(this[sa]=!0,this[ft](),this.emit("finish")):this[Yi]&&(this[Yi]=!1,this.emit("drain"))))}[oa](){if(this[ht].length===0)this[qr]&&this[sr](null,0);else if(this[ht].length===1)this[as](this[ht].pop());else{let t=this[ht];this[ht]=[],og(this[ie],t,this[en],(e,r)=>this[sr](e,r))}}[ft](){if(this[on]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,je.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},df=class extends vs{[an](){let t;if(this[cs]&&this[Ot]==="r+")try{t=je.openSync(this[dt],this[Ot],this[Xr])}catch(e){if(e?.code==="ENOENT")return this[Ot]="w",this[an]();throw e}else t=je.openSync(this[dt],this[Ot],this[Xr]);this[fr](null,t)}[ft](){if(this[on]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,je.closeSync(t),this.emit("close")}}[as](t){let e=!0;try{this[sr](null,je.writeSync(this[ie],t,0,t.length,this[en])),e=!1}finally{if(e)try{this[ft]()}catch{}}}},fg=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"]]),ug=t=>!!t.sync&&!!t.file,lg=t=>!t.sync&&!!t.file,xg=t=>!!t.sync&&!t.file,hg=t=>!t.sync&&!t.file,pg=t=>!!t.file,gg=t=>fg.get(t)||t,Ja=(t={})=>{if(!t)return{};let e={};for(let[r,s]of Object.entries(t)){let a=gg(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,u)=>{Array.isArray(c)&&(f=c,c={}),typeof f=="function"&&(u=f,f=void 0),f=f?Array.from(f):[];let x=Ja(c);if(a?.(x,f),ug(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,f)}else if(lg(x)){let h=e(x,f);return u?h.then(()=>u(),u):h}else if(xg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,f)}else if(hg(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return s(x,f)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:s,validate:a}),_g=wg.constants||{ZLIB_VERNUM:4736},wt=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},_g)),yg=Rn.concat,kd=Object.getOwnPropertyDescriptor(Rn,"concat"),bg=t=>t,fa=kd?.writable===!0||kd?.set!==void 0?t=>{Rn.concat=t?bg:yg}:t=>{},Dn=Symbol("_superWrite"),Xi=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"}},ua=Symbol("flushFlag"),Za=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 Dd[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Dd[e](t)}catch(r){throw new Xi(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 Xi(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return Ta(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Rn.alloc(0),{[ua]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[Dn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Rn.from(t,e)),this.#e)return;Ta(this.#t,"zlib binding closed");let s=this.#t._handle,a=s.close;s.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},fa(!0);let f;try{let x=typeof t[ua]=="number"?t[ua]:this.#r;f=this.#t._processChunk(t,x),fa(!1)}catch(x){fa(!1),this.#o(new Xi(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 Xi(x,this.write)));let u;if(f)if(Array.isArray(f)&&f.length>0){let x=f[0];u=this[Dn](Rn.from(x));for(let h=1;h<f.length;h++)u=this[Dn](f[h])}else u=this[Dn](Rn.from(f));return r&&r(),u}},uf=class extends Za{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||wt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||wt.Z_FINISH,t.fullFlushFlag=wt.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(wt.Z_SYNC_FLUSH),Ta(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)}}}},Eg=class extends uf{#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)}},vg=class extends uf{constructor(t){super(t,"Unzip")}},lf=class extends Za{constructor(t,e){t=t||{},t.flush=t.flush||wt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||wt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=wt.BROTLI_OPERATION_FLUSH,super(t,e)}},Sg=class extends lf{constructor(t){super(t,"BrotliCompress")}},Ig=class extends lf{constructor(t){super(t,"BrotliDecompress")}},xf=class extends Za{constructor(t,e){t=t||{},t.flush=t.flush||wt.ZSTD_e_continue,t.finishFlush=t.finishFlush||wt.ZSTD_e_end,t.fullFlushFlag=wt.ZSTD_e_flush,super(t,e)}},Ag=class extends xf{constructor(t){super(t,"ZstdCompress")}},Cg=class extends xf{constructor(t){super(t,"ZstdDecompress")}},Tg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Dg(t,e):Rg(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Rg=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Dg=(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]=hf(a):a===0?e[s-1]=0:(r=!0,e[s-1]=pf(a))}},kg=t=>{let e=t[0],r=e===128?Lg(t.subarray(1,t.length)):e===255?Pg(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},Pg=t=>{for(var e=t.length,r=0,s=!1,a=e-1;a>-1;a--){var c=Number(t[a]),f;s?f=hf(c):c===0?f=c:(s=!0,f=pf(c)),f!==0&&(r-=f*Math.pow(256,e-a-1))}return r},Lg=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},hf=t=>(255^t)&255,pf=t=>(255^t)+1&255,Og={};Vp(Og,{code:()=>Ya,isCode:()=>ds,isName:()=>Ng,name:()=>Ss});var ds=t=>Ss.has(t),Ng=t=>Ya.has(t),Ss=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"]]),Ya=new Map(Array.from(Ss).map(t=>[t[1],t[0]])),kn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,s){Buffer.isBuffer(t)?this.decode(t,e||0,r,s):t&&this.#n(t)}decode(t,e,r,s){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??En(t,e,100),this.mode=r?.mode??s?.mode??tn(t,e+100,8),this.uid=r?.uid??s?.uid??tn(t,e+108,8),this.gid=r?.gid??s?.gid??tn(t,e+116,8),this.size=r?.size??s?.size??tn(t,e+124,12),this.mtime=r?.mtime??s?.mtime??la(t,e+136,12),this.cksum=tn(t,e+148,12),s&&this.#n(s,!0),r&&this.#n(r);let a=En(t,e+156,1);if(ds(a)&&(this.#e=a||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=En(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??s?.uname??En(t,e+265,32),this.gname=r?.gname??s?.gname??En(t,e+297,32),this.devmaj=r?.devmaj??s?.devmaj??tn(t,e+329,8)??0,this.devmin=r?.devmin??s?.devmin??tn(t,e+337,8)??0,t[e+475]!==0){let f=En(t,e+345,155);this.path=f+"/"+this.path}else{let f=En(t,e+345,130);f&&(this.path=f+"/"+this.path),this.atime=r?.atime??s?.atime??la(t,e+476,12),this.ctime=r?.ctime??s?.ctime??la(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=Mg(this.path||"",r),a=s[0],c=s[1];this.needPax=!!s[2],this.needPax=vn(t,e,100,a)||this.needPax,this.needPax=nn(t,e+100,8,this.mode)||this.needPax,this.needPax=nn(t,e+108,8,this.uid)||this.needPax,this.needPax=nn(t,e+116,8,this.gid)||this.needPax,this.needPax=nn(t,e+124,12,this.size)||this.needPax,this.needPax=xa(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=vn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=vn(t,e+265,32,this.uname)||this.needPax,this.needPax=vn(t,e+297,32,this.gname)||this.needPax,this.needPax=nn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=nn(t,e+337,8,this.devmin)||this.needPax,this.needPax=vn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=vn(t,e+345,155,c)||this.needPax:(this.needPax=vn(t,e+345,130,c)||this.needPax,this.needPax=xa(t,e+476,12,this.atime)||this.needPax,this.needPax=xa(t,e+488,12,this.ctime)||this.needPax);let f=256;for(let u=e;u<e+148;u++)f+=t[u];for(let u=e+156;u<e+512;u++)f+=t[u];return this.cksum=f,nn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Ss.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Ya.get(t));if(ds(e)||e==="Unsupported")this.#e=e;else if(ds(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Mg=(t,e)=>{let r=t,s="",a,c=er.parse(t).root||".";if(Buffer.byteLength(r)<100)a=[r,s,!1];else{s=er.dirname(r),r=er.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(s)<=e?a=[r,s,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(s)<=e?a=[r.slice(0,99),s,!0]:(r=er.join(er.basename(s),r),s=er.dirname(s));while(s!==c&&a===void 0);a||(a=[t.slice(0,99),"",!0])}return a},En=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),la=(t,e,r)=>Bg(tn(t,e,r)),Bg=t=>t===void 0?void 0:new Date(t*1e3),tn=(t,e,r)=>Number(t[e])&128?kg(t.subarray(e,e+r)):Fg(t,e,r),zg=t=>isNaN(t)?void 0:t,Fg=(t,e,r)=>zg(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Ug={12:8589934591,8:2097151},nn=(t,e,r,s)=>s===void 0?!1:s>Ug[r]||s<0?(Tg(s,t.subarray(e,e+r)),!0):(qg(t,e,r,s),!1),qg=(t,e,r,s)=>t.write(Hg(s,r),e,r,"ascii"),Hg=(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",xa=(t,e,r,s)=>s===void 0?!1:nn(t,e,r,s.getTime()/1e3),Gg=new Array(156).join("\0"),vn=(t,e,r,s)=>s===void 0?!1:(t.write(s+Gg,e,r,"utf8"),s.length!==Buffer.byteLength(s)||s.length>r),ws=class gf{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),s=512*Math.ceil(1+r/512),a=Buffer.allocUnsafe(s);for(let c=0;c<512;c++)a[c]=0;new kn({path:("PaxHeader/"+Wg(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+`
116
+ `,c=Buffer.byteLength(a),f=Math.floor(Math.log(c)/Math.log(10))+1;return c+f>=Math.pow(10,f)&&(f+=1),f+c+a}static parse(e,r,s=!1){return new gf(Kg(Vg(e),r),s)}},Kg=(t,e)=>e?Object.assign({},e,t):t,Vg=t=>t.replace(/\n$/,"").split(`
117
+ `).reduce($g,Object.create(null)),$g=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let s=e.split("="),a=s.shift();if(!a)return t;let c=a.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),f=s.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(f)*1e3):/^[0-9]+$/.test(f)?+f:f,t},Jg=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,J=Jg!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),mf=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,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=J(t.path)),t.linkpath&&(t.linkpath=J(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e))))}},Is=(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))},Zg=1024*1024,Ra=Buffer.from([31,139]),Da=Buffer.from([40,181,47,253]),Yg=Math.max(Ra.length,Da.length),Ye=Symbol("state"),Sn=Symbol("writeEntry"),kt=Symbol("readEntry"),ha=Symbol("nextEntry"),Pd=Symbol("processEntry"),pt=Symbol("extendedHeader"),jr=Symbol("globalExtendedHeader"),Zt=Symbol("meta"),Ld=Symbol("emitMeta"),ce=Symbol("buffer"),Pt=Symbol("queue"),Yt=Symbol("ended"),pa=Symbol("emittedEnd"),In=Symbol("emit"),ye=Symbol("unzip"),Qi=Symbol("consumeChunk"),es=Symbol("consumeChunkSub"),ga=Symbol("consumeBody"),Od=Symbol("consumeMeta"),Nd=Symbol("consumeHeader"),Gr=Symbol("consuming"),ma=Symbol("bufferConcat"),ts=Symbol("maybeEnd"),tr=Symbol("writing"),Xt=Symbol("aborted"),ns=Symbol("onDone"),An=Symbol("sawValidEntry"),rs=Symbol("sawNullBlock"),is=Symbol("sawEOF"),Md=Symbol("closeStream"),Xg=()=>!0,oi=class extends mg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Pt]=[];[ce];[kt];[Sn];[Ye]="begin";[Zt]="";[pt];[jr];[Yt]=!1;[ye];[Xt]=!1;[An];[rs]=!1;[is]=!1;[tr]=!1;[Gr]=!1;[pa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(ns,()=>{(this[Ye]==="begin"||this[An]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(ns,t.ondone):this.on(ns,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Zg,this.filter=typeof t.filter=="function"?t.filter:Xg;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[Md]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Is(this,t,e,r)}[Nd](t,e){this[An]===void 0&&(this[An]=!1);let r;try{r=new kn(t,e,this[pt],this[jr])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(r.nullBlock)this[rs]?(this[is]=!0,this[Ye]==="begin"&&(this[Ye]="header"),this[In]("eof")):(this[rs]=!0,this[In]("nullBlock"));else if(this[rs]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let s=r.type;if(/^(Symbolic)?Link$/.test(s)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(s)&&!/^(Global)?ExtendedHeader$/.test(s)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let a=this[Sn]=new mf(r,this[pt],this[jr]);if(!this[An])if(a.remain){let c=()=>{a.invalid||(this[An]=!0)};a.on("end",c)}else this[An]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[In]("ignoredEntry",a),this[Ye]="ignore",a.resume()):a.size>0&&(this[Zt]="",a.on("data",c=>this[Zt]+=c),this[Ye]="meta"):(this[pt]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[In]("ignoredEntry",a),this[Ye]=a.remain?"ignore":"header",a.resume()):(a.remain?this[Ye]="body":(this[Ye]="header",a.end()),this[kt]?this[Pt].push(a):(this[Pt].push(a),this[ha]())))}}}[Md](){queueMicrotask(()=>this.emit("close"))}[Pd](t){let e=!0;if(!t)this[kt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...s]=t;this.emit(r,...s)}else this[kt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ha]()),e=!1);return e}[ha](){do;while(this[Pd](this[Pt].shift()));if(this[Pt].length===0){let t=this[kt];!t||t.flowing||t.size===t.remain?this[tr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[ga](t,e){let r=this[Sn];if(!r)throw new Error("attempt to consume body without entry??");let s=r.blockRemain??0,a=s>=t.length&&e===0?t:t.subarray(e,e+s);return r.write(a),r.blockRemain||(this[Ye]="header",this[Sn]=void 0,r.end()),a.length}[Od](t,e){let r=this[Sn],s=this[ga](t,e);return!this[Sn]&&r&&this[Ld](r),s}[In](t,e,r){this[Pt].length===0&&!this[kt]?this.emit(t,e,r):this[Pt].push([t,e,r])}[Ld](t){switch(this[In]("meta",this[Zt]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[pt]=ws.parse(this[Zt],this[pt],!1);break;case"GlobalExtendedHeader":this[jr]=ws.parse(this[Zt],this[jr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[pt]??Object.create(null);this[pt]=e,e.path=this[Zt].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[pt]||Object.create(null);this[pt]=e,e.linkpath=this[Zt].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[Xt]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[Xt])return r?.(),!1;if((this[ye]===void 0||this.brotli===void 0&&this[ye]===!1)&&t){if(this[ce]&&(t=Buffer.concat([this[ce],t]),this[ce]=void 0),t.length<Yg)return this[ce]=t,r?.(),!0;for(let f=0;this[ye]===void 0&&f<Ra.length;f++)t[f]!==Ra[f]&&(this[ye]=!1);let a=!1;if(this[ye]===!1&&this.zstd!==!1){a=!0;for(let f=0;f<Da.length;f++)if(t[f]!==Da[f]){a=!1;break}}let c=this.brotli===void 0&&!a;if(this[ye]===!1&&c)if(t.length<512)if(this[Yt])this.brotli=!0;else return this[ce]=t,r?.(),!0;else try{new kn(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[Yt];this[Yt]=!1,this[ye]=this[ye]===void 0?new vg({}):a?new Cg({}):new Ig({}),this[ye].on("data",x=>this[Qi](x)),this[ye].on("error",x=>this.abort(x)),this[ye].on("end",()=>{this[Yt]=!0,this[Qi]()}),this[tr]=!0;let u=!!this[ye][f?"end":"write"](t);return this[tr]=!1,r?.(),u}}this[tr]=!0,this[ye]?this[ye].write(t):this[Qi](t),this[tr]=!1;let s=this[Pt].length>0?!1:this[kt]?this[kt].flowing:!0;return!s&&this[Pt].length===0&&this[kt]?.once("drain",()=>this.emit("drain")),r?.(),s}[ma](t){t&&!this[Xt]&&(this[ce]=this[ce]?Buffer.concat([this[ce],t]):t)}[ts](){if(this[Yt]&&!this[pa]&&!this[Xt]&&!this[Gr]){this[pa]=!0;let t=this[Sn];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[In](ns)}}[Qi](t){if(this[Gr]&&t)this[ma](t);else if(!t&&!this[ce])this[ts]();else if(t){if(this[Gr]=!0,this[ce]){this[ma](t);let e=this[ce];this[ce]=void 0,this[es](e)}else this[es](t);for(;this[ce]&&this[ce]?.length>=512&&!this[Xt]&&!this[is];){let e=this[ce];this[ce]=void 0,this[es](e)}this[Gr]=!1}(!this[ce]||this[Yt])&&this[ts]()}[es](t){let e=0,r=t.length;for(;e+512<=r&&!this[Xt]&&!this[is];)switch(this[Ye]){case"begin":case"header":this[Nd](t,e),e+=512;break;case"ignore":case"body":e+=this[ga](t,e);break;case"meta":e+=this[Od](t,e);break;default:throw new Error("invalid state: "+this[Ye])}e<r&&(this[ce]=this[ce]?Buffer.concat([t.subarray(e),this[ce]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[Xt]||(this[ye]?(t&&this[ye].write(t),this[ye].end()):(this[Yt]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[ts]())),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)},Qg=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},wf=(t,e)=>{let r=new Map(e.map(c=>[Qr(c),!0])),s=t.filter,a=(c,f="")=>{let u=f||dg(c).root||".",x;if(c===u)x=!1;else{let h=r.get(c);x=h!==void 0?h:a(cg(c),u)}return r.set(c,x),x};t.filter=s?(c,f)=>s(c,f)&&a(Qr(c)):c=>a(Qr(c))},em=t=>{let e=new oi(t),r=t.file,s;try{s=ar.openSync(r,"r");let a=ar.fstatSync(s),c=t.maxReadSize||16*1024*1024;if(a.size<c){let f=Buffer.allocUnsafe(a.size),u=ar.readSync(s,f,0,a.size,0);e.end(u===f.byteLength?f:f.subarray(0,u))}else{let f=0,u=Buffer.allocUnsafe(c);for(;f<a.size;){let x=ar.readSync(s,u,0,c,f);if(x===0)break;f+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof s=="number")try{ar.closeSync(s)}catch{}}},tm=(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),ar.stat(a,(u,x)=>{if(u)f(u);else{let h=new $a(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},ur=ai(em,tm,t=>new oi(t),t=>new oi(t),(t,e)=>{e?.length&&wf(t,e),t.noResume||Qg(t)}),_f=(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:rm,parse:zd}=nm,Xa=t=>{let e="",r=zd(t);for(;rm(t)||r.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(s.length),e+=s,r=zd(t)}return[e,t]},As=["|","<",">","?",":"],Qa=As.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),im=new Map(As.map((t,e)=>[t,Qa[e]])),sm=new Map(Qa.map((t,e)=>[t,As[e]])),Fd=t=>As.reduce((e,r)=>e.split(r).join(im.get(r)),t),om=t=>Qa.reduce((e,r)=>e.split(r).join(sm.get(r)),t),yf=(t,e)=>e?(t=J(t).replace(/^\.(\/|$)/,""),Qr(e)+"/"+t):J(t),am=16*1024*1024,Ud=Symbol("process"),qd=Symbol("file"),Hd=Symbol("directory"),ka=Symbol("symlink"),jd=Symbol("hardlink"),Wr=Symbol("header"),fs=Symbol("read"),Pa=Symbol("lstat"),us=Symbol("onlstat"),La=Symbol("onread"),Oa=Symbol("onreadlink"),Na=Symbol("openfile"),Ma=Symbol("onopenfile"),rn=Symbol("close"),ys=Symbol("mode"),Ba=Symbol("awaitDrain"),wa=Symbol("ondrain"),mt=Symbol("prefix"),bf=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=Ja(e);super(),this.path=J(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||am,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 s=!1;if(!this.preservePaths){let[c,f]=Xa(this.path);c&&typeof f=="string"&&(this.path=f,s=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=om(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=J(r.absolute||Bd.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[us](a):this[Pa]()}warn(t,e,r={}){return Is(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Pa](){gt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[us](e)})}[us](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=fm(t),this.emit("stat",t),this[Ud]()}[Ud](){switch(this.type){case"File":return this[qd]();case"Directory":return this[Hd]();case"SymbolicLink":return this[ka]();default:return this.end()}}[ys](t){return _f(t,this.type==="Directory",this.portable)}[mt](t){return yf(t,this.prefix)}[Wr](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new kn({path:this[mt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[mt](this.linkpath):this.linkpath,mode:this[ys](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 ws({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[mt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[mt](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)}[Hd](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Wr](),this.end()}[ka](){gt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Oa](e)})}[Oa](t){this.linkpath=J(t),this[Wr](),this.end()}[jd](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=J(Bd.relative(this.cwd,t)),this.stat.size=0,this[Wr](),this.end()}[qd](){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[jd](e);this.linkCache.set(t,this.absolute)}if(this[Wr](),this.stat.size===0)return this.end();this[Na]()}[Na](){gt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Ma](e)})}[Ma](t){if(this.fd=t,this.#e)return this[rn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[fs]()}[fs](){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");gt.read(t,e,r,s,a,(c,f)=>{if(c)return this[rn](()=>this.emit("error",c));this[La](f)})}[rn](t=()=>{}){this.fd!==void 0&&gt.close(this.fd,t)}[La](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[wa]():this[Ba](()=>this[wa]())}[Ba](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)}[wa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[rn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[fs]()}},cm=class extends bf{sync=!0;[Pa](){this[us](gt.lstatSync(this.absolute))}[ka](){this[Oa](gt.readlinkSync(this.absolute))}[Na](){this[Ma](gt.openSync(this.absolute,"r"))}[fs](){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=gt.readSync(e,r,s,a,c);this[La](f),t=!1}finally{if(t)try{this[rn](()=>{})}catch{}}}[Ba](t){t()}[rn](t=()=>{}){this.fd!==void 0&&gt.closeSync(this.fd),t()}},dm=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 Is(this,t,e,r)}constructor(t,e={}){let r=Ja(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=J(t.path),this.mode=t.mode!==void 0?this[ys](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 a=!1;if(!this.preservePaths){let[f,u]=Xa(this.path);f&&typeof u=="string"&&(this.path=u,a=f)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new kn({path:this[mt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[mt](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 ws({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[mt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[mt](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)}[mt](t){return yf(t,this.prefix)}[ys](t){return _f(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}},fm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",um=class cr{tail;head;length=0;static create(e=[]){return new cr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,s=e.prev;return r&&(r.prev=s),s&&(s.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=s),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,s=e.length;r<s;r++)xm(this,e[r]);return this.length}unshift(...e){for(var r=0,s=e.length;r<s;r++)hm(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let s=this.head,a=0;s;a++)e.call(r,s.value,a,this),s=s.next}forEachReverse(e,r){r=r||this;for(let s=this.tail,a=this.length-1;s;a--)e.call(r,s.value,a,this),s=s.prev}get(e){let r=0,s=this.head;for(;s&&r<e;r++)s=s.next;if(r===e&&s)return s.value}getReverse(e){let r=0,s=this.tail;for(;s&&r<e;r++)s=s.prev;if(r===e&&s)return s.value}map(e,r){r=r||this;let s=new cr;for(let a=this.head;a;)s.push(e.call(r,a.value,this)),a=a.next;return s}mapReverse(e,r){r=r||this;var s=new cr;for(let a=this.tail;a;)s.push(e.call(r,a.value,this)),a=a.prev;return s}reduce(e,r){let s,a=this.head;if(arguments.length>1)s=r;else if(this.head)a=this.head.next,s=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;a;c++)s=e(s,a.value,c),a=a.next;return s}reduceReverse(e,r){let s,a=this.tail;if(arguments.length>1)s=r;else if(this.tail)a=this.tail.prev,s=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;a;c--)s=e(s,a.value,c),a=a.prev;return s}toArray(){let e=new Array(this.length);for(let r=0,s=this.head;s;r++)e[r]=s.value,s=s.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,s=this.tail;s;r++)e[r]=s.value,s=s.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new cr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.head,c=0;for(c=0;a&&c<e;c++)a=a.next;for(;a&&c<r;c++,a=a.next)s.push(a.value);return s}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new cr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.length,c=this.tail;for(;c&&a>r;a--)c=c.prev;for(;c&&a>e;a--,c=c.prev)s.push(c.value);return s}splice(e,r=0,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let a=this.head;for(let f=0;a&&f<e;f++)a=a.next;let c=[];for(let f=0;a&&f<r;f++)c.push(a.value),a=this.removeNode(a);a?a!==this.tail&&(a=a.prev):a=this.tail;for(let f of s)a=lm(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 lm(t,e,r){let s=e,a=e?e.next:t.head,c=new ec(r,s,a,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function xm(t,e){t.tail=new ec(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function hm(t,e){t.head=new ec(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var ec=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}},Wd=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Kd=Buffer.alloc(1024),ls=Symbol("onStat"),Kr=Symbol("ended"),at=Symbol("queue"),Vr=Symbol("queue"),Qt=Symbol("current"),Cn=Symbol("process"),$r=Symbol("processing"),ss=Symbol("processJob"),ct=Symbol("jobs"),_a=Symbol("jobDone"),xs=Symbol("addFSEntry"),Vd=Symbol("addTarEntry"),za=Symbol("stat"),Fa=Symbol("readdir"),hs=Symbol("onreaddir"),ps=Symbol("pipe"),$d=Symbol("entry"),ya=Symbol("entryOpt"),gs=Symbol("writeEntryClass"),Ef=Symbol("write"),ba=Symbol("ondrain"),Cs=class extends Pn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[gs];onWriteEntry;[at];[Vr]=new Map;[ct]=0;[$r]=!1;[Kr]=!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[gs]=bf,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 Eg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Sg(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Ag(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[ba]()),this.on("resume",()=>e.resume())}else this.on("drain",this[ba]);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[at]=new um,this[ct]=0,this.jobs=Number(t.jobs)||4,this[$r]=!1,this[Kr]=!1}[Ef](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[Kr]=!0,this[Cn](),r&&r(),this}write(t){if(this[Kr])throw new Error("write after end");return t instanceof mf?this[Vd](t):this[xs](t),this.flowing}[Vd](t){let e=J(Gd.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Wd(t.path,e);r.entry=new dm(t,this[ya](r)),r.entry.on("end",()=>this[_a](r)),this[ct]+=1,this[at].push(r)}this[Cn]()}[xs](t){let e=J(Gd.resolve(this.cwd,t));this[at].push(new Wd(t,e)),this[Cn]()}[za](t){t.pending=!0,this[ct]+=1;let e=this.follow?"stat":"lstat";_s[e](t.absolute,(r,s)=>{t.pending=!1,this[ct]-=1,r?this.emit("error",r):this[ls](t,s)})}[ls](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[Qt])this[ss](t);else{let r=`${e.dev}:${e.ino}`,s=this[Vr].get(r);s?s.push(t):this[Vr].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Cn]()}[Fa](t){t.pending=!0,this[ct]+=1,_s.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[ct]-=1,e)return this.emit("error",e);this[hs](t,r)})}[hs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Cn]()}[Cn](){if(!this[$r]){this[$r]=!0;for(let t=this[at].head;t&&this[ct]<this.jobs;t=t.next)if(this[ss](t.value),t.value.ignore){let e=t.next;this[at].removeNode(t),t.next=e}this[$r]=!1,this[Kr]&&this[at].length===0&&this[ct]===0&&(this.zip?this.zip.end(Kd):(super.write(Kd),super.end()))}}get[Qt](){return this[at]&&this[at].head&&this[at].head.value}[_a](t){this[at].shift(),this[ct]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,s=this[Vr].get(r);if(s){this[Vr].delete(r);for(let a of s)a.pending=!1,this[ss](a)}}this[Cn]()}[ss](t){if(t.pending&&t.pendingLink&&t===this[Qt]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[Qt]&&!t.piped&&this[ps](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[ls](t,e):this[za](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[hs](t,e):this[Fa](t),!t.readdir)return}if(t.entry=this[$d](t),!t.entry){t.ignore=!0;return}t===this[Qt]&&!t.piped&&this[ps](t)}}}[ya](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}}[$d](t){this[ct]+=1;try{return new this[gs](t.path,this[ya](t)).on("end",()=>this[_a](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[ba](){this[Qt]&&this[Qt].entry&&this[Qt].entry.resume()}[ps](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[xs](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={}){Is(this,t,e,r)}},tc=class extends Cs{sync=!0;constructor(t){super(t),this[gs]=cm}pause(){}resume(){}[za](t){let e=this.follow?"statSync":"lstatSync";this[ls](t,_s[e](t.absolute))}[Fa](t){this[hs](t,_s.readdirSync(t.absolute))}[ps](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[xs](c+s)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",s=>{r.write(s)}):e.on("data",s=>{super[Ef](s)})}},pm=(t,e)=>{let r=new tc(t),s=new df(t.file,{mode:t.mode||438});r.pipe(s),vf(r,e)},gm=(t,e)=>{let r=new Cs(t),s=new vs(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 Sf(r,e).catch(c=>r.emit("error",c)),a},vf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:ff.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Sf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:ff.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(r);t.end()},mm=(t,e)=>{let r=new tc(t);return vf(r,e),r},wm=(t,e)=>{let r=new Cs(t);return Sf(r,e).catch(s=>r.emit("error",s)),r},wv=ai(pm,gm,mm,wm,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),ym=process.env.__FAKE_PLATFORM__||process.platform,Tf=ym==="win32",{O_CREAT:Rf,O_NOFOLLOW:Jd,O_TRUNC:Df,O_WRONLY:kf}=Cf.constants,Pf=Number(process.env.__FAKE_FS_O_FILENAME__)||Cf.constants.UV_FS_O_FILEMAP||0,bm=Tf&&!!Pf,Em=512*1024,vm=Pf|Df|Rf|kf,Zd=!Tf&&typeof Jd=="number"?Jd|Df|Rf|kf:null,Lf=Zd!==null?()=>Zd:bm?t=>t<Em?vm:"w":()=>"w",Ua=(t,e,r)=>{try{return Ts.lchownSync(t,e,r)}catch(s){if(s?.code!=="ENOENT")throw s}},bs=(t,e,r,s)=>{Ts.lchown(t,e,r,a=>{s(a&&a?.code!=="ENOENT"?a:null)})},Sm=(t,e,r,s,a)=>{if(e.isDirectory())Of(ei.resolve(t,e.name),r,s,c=>{if(c)return a(c);let f=ei.resolve(t,e.name);bs(f,r,s,a)});else{let c=ei.resolve(t,e.name);bs(c,r,s,a)}},Of=(t,e,r,s)=>{Ts.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 bs(t,e,r,s);let f=c.length,u=null,x=h=>{if(!u){if(h)return s(u=h);if(--f===0)return bs(t,e,r,s)}};for(let h of c)Sm(t,h,e,r,x)})},Im=(t,e,r,s)=>{e.isDirectory()&&Nf(ei.resolve(t,e.name),r,s),Ua(ei.resolve(t,e.name),r,s)},Nf=(t,e,r)=>{let s;try{s=Ts.readdirSync(t,{withFileTypes:!0})}catch(a){let c=a;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Ua(t,e,r);throw c}for(let a of s)Im(t,a,e,r);return Ua(t,e,r)},Mf=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"}},Rs=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Cm=(t,e)=>{$e.stat(t,(r,s)=>{(r||!s.isDirectory())&&(r=new Mf(t,r?.code||"ENOTDIR")),e(r)})},Tm=(t,e,r)=>{t=J(t);let s=e.umask??18,a=e.mode|448,c=(a&s)!==0,f=e.uid,u=e.gid,x=typeof f=="number"&&typeof u=="number"&&(f!==e.processUid||u!==e.processGid),h=e.preserve,m=e.unlink,v=J(e.cwd),A=(b,S)=>{b?r(b):S&&x?Of(S,f,u,I=>A(I)):c?$e.chmod(t,a,r):r()};if(t===v)return Cm(t,A);if(h)return Am.mkdir(t,{mode:a,recursive:!0}).then(b=>A(null,b??void 0),A);let _=J(Es.relative(v,t)).split("/");qa(v,_,a,m,v,void 0,A)},qa=(t,e,r,s,a,c,f)=>{if(e.length===0)return f(null,c);let u=e.shift(),x=J(Es.resolve(t+"/"+u));$e.mkdir(x,r,Bf(x,e,r,s,a,c,f))},Bf=(t,e,r,s,a,c,f)=>u=>{u?$e.lstat(t,(x,h)=>{if(x)x.path=x.path&&J(x.path),f(x);else if(h.isDirectory())qa(t,e,r,s,a,c,f);else if(s)$e.unlink(t,m=>{if(m)return f(m);$e.mkdir(t,r,Bf(t,e,r,s,a,c,f))});else{if(h.isSymbolicLink())return f(new Rs(t,t+"/"+e.join("/")));f(u)}}):(c=c||t,qa(t,e,r,s,a,c,f))},Rm=t=>{let e=!1,r;try{e=$e.statSync(t).isDirectory()}catch(s){r=s?.code}finally{if(!e)throw new Mf(t,r??"ENOTDIR")}},Dm=(t,e)=>{t=J(t);let r=e.umask??18,s=e.mode|448,a=(s&r)!==0,c=e.uid,f=e.gid,u=typeof c=="number"&&typeof f=="number"&&(c!==e.processUid||f!==e.processGid),x=e.preserve,h=e.unlink,m=J(e.cwd),v=b=>{b&&u&&Nf(b,c,f),a&&$e.chmodSync(t,s)};if(t===m)return Rm(m),v();if(x)return v($e.mkdirSync(t,{mode:s,recursive:!0})??void 0);let A=J(Es.relative(m,t)).split("/"),_;for(let b=A.shift(),S=m;b&&(S+="/"+b);b=A.shift()){S=J(Es.resolve(S));try{$e.mkdirSync(S,s),_=_||S}catch{let I=$e.lstatSync(S);if(I.isDirectory())continue;if(h){$e.unlinkSync(S),$e.mkdirSync(S,s),_=_||S;continue}else if(I.isSymbolicLink())return new Rs(S,S+"/"+A.join("/"))}}return v(_)},Ea=Object.create(null),Yd=1e4,nr=new Set,km=t=>{nr.has(t)?nr.delete(t):Ea[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),nr.add(t);let e=Ea[t],r=nr.size-Yd;if(r>Yd/10){for(let s of nr)if(nr.delete(s),delete Ea[s],--r<=0)break}return e},Pm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Lm=Pm==="win32",Om=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let s=e.at(-1);return s!==void 0&&(r=zf(s,r)),e.push(r||"/"),e},[]),Nm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Lm?["win32 parallelization disabled"]:t.map(s=>Qr(zf(km(s))));let r=new Set(t.map(s=>Om(s)).reduce((s,a)=>s.concat(a)));this.#n.set(e,{dirs:r,paths:t});for(let s of t){let a=this.#e.get(s);a?a.push(e):this.#e.set(s,[e])}for(let s of r){let a=this.#e.get(s);if(!a)this.#e.set(s,[new Set([e])]);else{let c=a.at(-1);c instanceof Set?c.add(e):a.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(s=>s&&s[0]===t)&&r.every(s=>s&&s[0]instanceof Set&&s[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:s}=e,a=new Set;for(let c of r){let f=this.#e.get(c);if(!f||f?.[0]!==t)continue;let u=f[1];if(!u){this.#e.delete(c);continue}if(f.shift(),typeof u=="function")a.add(u);else for(let x of u)a.add(x)}for(let c of s){let f=this.#e.get(c),u=f?.[0];if(!(!f||!(u instanceof Set)))if(u.size===1&&f.length===1){this.#e.delete(c);continue}else if(u.size===1){f.shift();let x=f[0];typeof x=="function"&&a.add(x)}else u.delete(t)}return this.#r.delete(t),a.forEach(c=>this.#i(c)),!0}},Mm=()=>process.umask(),Xd=Symbol("onEntry"),Ha=Symbol("checkFs"),Qd=Symbol("checkFs2"),ja=Symbol("isReusable"),Xe=Symbol("makeFs"),Ga=Symbol("file"),Wa=Symbol("directory"),ms=Symbol("link"),ef=Symbol("symlink"),tf=Symbol("hardlink"),Yr=Symbol("ensureNoSymlink"),nf=Symbol("unsupported"),rf=Symbol("checkPath"),va=Symbol("stripAbsolutePath"),sn=Symbol("mkdir"),De=Symbol("onError"),os=Symbol("pending"),sf=Symbol("pend"),rr=Symbol("unpend"),Sa=Symbol("ended"),Ia=Symbol("maybeClose"),Ka=Symbol("skip"),ti=Symbol("doChown"),ni=Symbol("uid"),ri=Symbol("gid"),ii=Symbol("checkedCwd"),Bm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,si=Bm==="win32",zm=1024,Fm=(t,e)=>{if(!si)return X.unlink(t,e);let r=t+".DELETE."+Af(16).toString("hex");X.rename(t,r,s=>{if(s)return e(s);X.unlink(r,e)})},Um=t=>{if(!si)return X.unlinkSync(t);let e=t+".DELETE."+Af(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},of=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,nc=class extends oi{[Sa]=!1;[ii]=!1;[os]=0;reservations=new Nm;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[Sa]=!0,this[Ia]()},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:zm,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=J(ve.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Mm():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[Xd](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Ia](){this[Sa]&&this[os]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[va](t,e){let r=t[e],{type:s}=t;if(!r||this.preservePaths)return!0;let[a,c]=Xa(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 u=ve.posix.dirname(t.path),x=ve.posix.normalize(ve.posix.join(u,f.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return a&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute ${e}`,{entry:t,[e]:r})),!0}[rf](t){let e=J(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let s=J(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[va](t,"path")||!this[va](t,"linkpath"))return!1;if(t.absolute=ve.isAbsolute(t.path)?J(ve.resolve(t.path)):J(ve.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:s}=ve.win32.parse(String(t.absolute));t.absolute=s+Fd(String(t.absolute).slice(s.length));let{root:a}=ve.win32.parse(t.path);t.path=a+Fd(t.path.slice(a.length))}return!0}[Xd](t){if(!this[rf](t))return t.resume();switch(_m.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[Ha](t);default:return this[nf](t)}}[De](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[rr](),e.resume())}[sn](t,e,r){Tm(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)}[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 of(this.uid,t.uid,this.processUid)}[ri](t){return of(this.gid,t.gid,this.processGid)}[Ga](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new vs(String(t.absolute),{flags:Lf(t.size),mode:r,autoClose:!1});s.on("error",u=>{s.fd&&X.close(s.fd,()=>{}),s.write=()=>!0,this[De](u,t),e()});let a=1,c=u=>{if(u){s.fd&&X.close(s.fd,()=>{}),this[De](u,t),e();return}--a===0&&s.fd!==void 0&&X.close(s.fd,x=>{x?this[De](x,t):this[rr](),e()})};s.on("finish",()=>{let u=String(t.absolute),x=s.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){a++;let h=t.atime||new Date,m=t.mtime;X.futimes(x,h,m,v=>v?X.utimes(u,h,m,A=>c(A&&v)):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,v=>v?X.chown(u,h,m,A=>c(A&&v)):c())}c()});let f=this.transform&&this.transform(t)||t;f!==t&&(f.on("error",u=>{this[De](u,t),e()}),t.pipe(f)),f.pipe(s)}[Wa](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[sn](String(t.absolute),r,s=>{if(s){this[De](s,t),e();return}let a=1,c=()=>{--a===0&&(e(),this[rr](),t.resume())};t.mtime&&!this.noMtime&&(a++,X.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ti](t)&&(a++,X.chown(String(t.absolute),Number(this[ni](t)),Number(this[ri](t)),c)),c()})}[nf](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[ef](t,e){let r=J(ve.relative(this.cwd,ve.resolve(ve.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Yr](t,this.cwd,r,()=>this[ms](t,String(t.linkpath),"symlink",e),s=>{this[De](s,t),e()})}[tf](t,e){let r=J(ve.resolve(this.cwd,String(t.linkpath))),s=J(String(t.linkpath)).split("/");this[Yr](t,this.cwd,s,()=>this[ms](t,r,"link",e),a=>{this[De](a,t),e()})}[Yr](t,e,r,s,a){let c=r.shift();if(this.preservePaths||c===void 0)return s();let f=ve.resolve(e,c);X.lstat(f,(u,x)=>{if(u)return s();if(x?.isSymbolicLink())return a(new Rs(f,ve.resolve(f,r.join("/"))));this[Yr](t,f,r,s,a)})}[sf](){this[os]++}[rr](){this[os]--,this[Ia]()}[Ka](t){this[rr](),t.resume()}[ja](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!si}[Ha](t){this[sf]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Qd](t,r))}[Qd](t,e){let r=f=>{e(f)},s=()=>{this[sn](this.cwd,this.dmode,f=>{if(f){this[De](f,t),r();return}this[ii]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let f=J(ve.dirname(String(t.absolute)));if(f!==this.cwd)return this[sn](f,this.dmode,u=>{if(u){this[De](u,t),r();return}c()})}c()},c=()=>{X.lstat(String(t.absolute),(f,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Ka](t),r();return}if(f||this[ja](t,u))return this[Xe](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,h=m=>this[Xe](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[Xe](x??null,t,r))}if(t.absolute===this.cwd)return this[Xe](null,t,r);Fm(String(t.absolute),x=>this[Xe](x??null,t,r))})};this[ii]?a():s()}[Xe](t,e,r){if(t){this[De](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Ga](e,r);case"Link":return this[tf](e,r);case"SymbolicLink":return this[ef](e,r);case"Directory":case"GNUDumpDir":return this[Wa](e,r)}}[ms](t,e,r,s){X[r](e,String(t.absolute),a=>{a?this[De](a,t):(this[rr](),t.resume()),s()})}},Jr=t=>{try{return[null,t()]}catch(e){return[e,null]}},Ff=class extends nc{sync=!0;[Xe](t,e){return super[Xe](t,e,()=>{})}[Ha](t){if(!this[ii]){let a=this[sn](this.cwd,this.dmode);if(a)return this[De](a,t);this[ii]=!0}if(t.absolute!==this.cwd){let a=J(ve.dirname(String(t.absolute)));if(a!==this.cwd){let c=this[sn](a,this.dmode);if(c)return this[De](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[Ka](t);if(e||this[ja](t,r))return this[Xe](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[Xe](f,t)}let[a]=Jr(()=>X.rmdirSync(String(t.absolute)));this[Xe](a,t)}let[s]=t.absolute===this.cwd?[]:Jr(()=>Um(String(t.absolute)));this[Xe](s,t)}[Ga](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=f=>{let u;try{X.closeSync(a)}catch(x){u=x}(f||u)&&this[De](f||u,t),e()},a;try{a=X.openSync(String(t.absolute),Lf(t.size),r)}catch(f){return s(f)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",f=>this[De](f,t)),t.pipe(c)),c.on("data",f=>{try{X.writeSync(a,f,0,f.length)}catch(u){s(u)}}),c.on("end",()=>{let f=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,x=t.mtime;try{X.futimesSync(a,u,x)}catch(h){try{X.utimesSync(String(t.absolute),u,x)}catch{f=h}}}if(this[ti](t)){let u=this[ni](t),x=this[ri](t);try{X.fchownSync(a,Number(u),Number(x))}catch(h){try{X.chownSync(String(t.absolute),Number(u),Number(x))}catch{f=f||h}}}s(f)})}[Wa](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[sn](String(t.absolute),r);if(s){this[De](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()}[sn](t,e){try{return Dm(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}}[Yr](t,e,r,s,a){if(this.preservePaths||r.length===0)return s();let c=e;for(let f of r){c=ve.resolve(c,f);let[u,x]=Jr(()=>X.lstatSync(c));if(u)return s();if(x.isSymbolicLink())return a(new Rs(c,ve.resolve(e,r.join("/"))))}s()}[ms](t,e,r,s){let a=`${r}Sync`;try{X[a](e,String(t.absolute)),s(),t.resume()}catch(c){return this[De](c,t)}}},qm=t=>{let e=new Ff(t),r=t.file,s=If.statSync(r),a=t.maxReadSize||16*1024*1024;new ag(r,{readSize:a,size:s.size}).pipe(e)},Hm=(t,e)=>{let r=new nc(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("close",c),If.stat(a,(u,x)=>{if(u)f(u);else{let h=new $a(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},Uf=ai(qm,Hm,t=>new Ff(t),t=>new nc(t),(t,e)=>{e?.length&&wf(t,e)}),jm=(t,e)=>{let r=new tc(t),s=!0,a,c;try{try{a=Ve.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")a=Ve.openSync(t.file,"w+");else throw x}let f=Ve.fstatSync(a),u=Buffer.alloc(512);e:for(c=0;c<f.size;c+=512){for(let m=0,v=0;m<512;m+=v){if(v=Ve.readSync(a,u,m,u.length-m,c+m),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!v)break e}let x=new kn(u);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>f.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}s=!1,Gm(t,r,c,a,e)}finally{if(s)try{Ve.closeSync(a)}catch{}}},Gm=(t,e,r,s,a)=>{let c=new df(t.file,{fd:s,start:r});e.pipe(c),Km(e,a)},Wm=(t,e)=>{e=Array.from(e);let r=new Cs(t),s=(a,c,f)=>{let u=(A,_)=>{A?Ve.close(a,b=>f(A)):f(null,_)},x=0;if(c===0)return u(null,0);let h=0,m=Buffer.alloc(512),v=(A,_)=>{if(A||_===void 0)return u(A);if(h+=_,h<512&&_)return Ve.read(a,m,h,m.length-h,x+h,v);if(x===0&&m[0]===31&&m[1]===139)return u(new Error("cannot append to compressed archives"));if(h<512)return u(null,x);let b=new kn(m);if(!b.cksumValid)return u(null,x);let S=512*Math.ceil((b.size??0)/512);if(x+S+512>c||(x+=S+512,x>=c))return u(null,x);t.mtimeCache&&b.mtime&&t.mtimeCache.set(String(b.path),b.mtime),h=0,Ve.read(a,m,0,512,x,v)};Ve.read(a,m,0,512,x,v)};return new Promise((a,c)=>{r.on("error",c);let f="r+",u=(x,h)=>{if(x&&x.code==="ENOENT"&&f==="r+")return f="w+",Ve.open(t.file,f,u);if(x||!h)return c(x);Ve.fstat(h,(m,v)=>{if(m)return Ve.close(h,()=>c(m));s(h,v.size,(A,_)=>{if(A)return c(A);let b=new vs(t.file,{fd:h,start:_});r.pipe(b),b.on("error",c),b.on("close",a),Vm(r,e)})})};Ve.open(t.file,f,u)})},Km=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:qf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Vm=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:qf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r);t.end()},Zr=ai(jm,Wm,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!pg(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")}),Lv=ai(Zr.syncFile,Zr.asyncFile,Zr.syncNoFile,Zr.asyncNoFile,(t,e=[])=>{Zr.validate?.(t,e),$m(t)}),$m=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,s)=>e(r,s)&&!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0)):(r,s)=>!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0))};Vt();var _t={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 Hf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function jf(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Gf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function lr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}var R=class extends Error{code;retriable;cause;constructor(e,r,s){super(r),this.name="BridgeError",this.code=e,this.retriable=s?.retriable??!1,s?.cause!==void 0&&(this.cause=s.cause)}};ee();Me();function Nt(t,e){if(ci(t)!=="cloud")throw new R("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ds(t){return t.startsWith("http://")||t.startsWith("https://")}function ks(t){return t.endsWith("/")?t.slice(0,-1):t}ee();var Ps="1008033",Wf="1289";var Kf="pbbp2",Vf="https://www.coze.cn",$f="/api/coze_claw/resource/get_frontier_key",Zm="https://www.coze.cn",Ym="wss://frontier.coze.cn";function Ls(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Zm}function Jf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Ym}function xr(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,s=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),s&&(e["x-use-ppe"]=s),e}function fi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var di=j("handshake");async function rc(t){let e=Ls(t.endpoint),r=t.timeoutMs??1e4,s=`${ks(e)}${$f}?aid=${encodeURIComponent(Ps)}`,a={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...xr(t.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),r);di.info("frontier key handshake",{base:e});try{let u=await fetch(s,{method:"GET",headers:a,signal:c.signal}),x=u.headers.get("x-tt-logid")??"",h=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let b=await u.text().catch(()=>"");throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${b.slice(0,200)}`)}let m=await u.json();if(m.code!==void 0&&m.code!==0)throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${x}`);let v=m.data??{},A=typeof v.access_key=="string"&&v.access_key||typeof v.accessKey=="string"&&v.accessKey||void 0,_=typeof v.device_id=="string"&&v.device_id||typeof v.deviceId=="string"&&v.deviceId||void 0;if(!A||!_){let b=JSON.stringify(m).slice(0,500);throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${b}`)}return di.info("handshake ok",{remoteDeviceId:_,logid:x,traceId:h}),{accessKey:A,deviceId:_}}catch(u){if(u instanceof R)throw di.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw di.warn("handshake timeout",{base:e,timeoutMs:r}),new R("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw di.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:x?.code,syscall:x?.syscall,cause:String(u).slice(0,300)}),new R("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(f)}}var ic=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",yt="auto";function Zf(t){return{model:t.model??yt,...t.modelToken?{modelToken:t.modelToken}:{}}}function Yf(t){return!t||t===yt}function Xf(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=ic,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||yt,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):Yf(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function Qf(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||yt}"`):Yf(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="${ic}/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 eu(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function sc(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 tu(t,e,r){if(!t.modelToken)return{};let s=sc(e,r);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,f])=>`${c}:${f}`).join(`
118
+ `)}}function oc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function nu(t,e,r){if(!t.modelToken)return null;let s=t.model||yt,a=sc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let f={baseUrl:`${ic}/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 ru(t,e,r){if(!t.modelToken)return[];let s=sc(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=j("agent-handlers"),iu=5*1024*1024,rw=1,iw=6,sw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Os=class{constructor(e){this.opts=e}opts;async listSkills(e){Nt(e._meta,"_agent/listSkills");let r=lr(e._meta),s=await this.loadAgentCfg(r),a=s?.workspace??Tt(r).workspace,c=s?.skills??[],f=[];for(let u of c){let x=bt(a,u.relPath,"SKILL.md");await ew(x).then(m=>m.isFile()).catch(()=>!1)&&f.push(fw(u))}return{skills:f}}async addSkills(e){Nt(e._meta,"_agent/addSkills");let r=lr(e._meta),s=await this.requireAgentCfg(r),a=e.skills??[],c=[...s.skills??[]],f=new Map(c.map((x,h)=>[x.skillId,h])),u=[];for(let x of a){let h=await xc({agentId:r,workspace:s.workspace,framework:s.framework,skill:x});hc(c,f,h),u.push(x)}return await Fi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Nt(e._meta,"_agent/removeSkills");let r=lr(e._meta),s=await this.requireAgentCfg(r),a=new Set(e.skillIds??[]),c=s.skills??[],f=[];for(let u of c){if(!a.has(u.skillId)){f.push(u);continue}let x=bt(s.workspace,u.relPath);await Qm(x,{recursive:!0,force:!0}),ke.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await Fi(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 Fe(r);if(!s)throw new R("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 Jn(s.workspace,s.framework,r,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 R("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(a)}`,{cause:a})}return s.cozeIdentity=e.cozeIdentity,await Ge(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 R("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let s=await Fe(r);return s?(s.disconnectedAt=Date.now(),s.disconnectReason=e.reason??"",await Ge(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(Nt(e._meta,"_agent/switchModel"),!e.agentId)throw new R("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:yt,s=await Fe(e.agentId);if(!s)throw new R("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);s.model=r,e.modelInfo&&(s.modelInfo=e.modelInfo),await Ge(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,u]of a.allSessionQueues())c.push(u.enqueue(async()=>{let x=a.sessions.get(f);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),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(Nt(e._meta,_t.RESET),!e.agentId)throw new R("IPC_BAD_REQUEST",`${_t.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,_t.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Nt(e._meta,_t.REPAIR),!e.agentId)throw new R("IPC_BAD_REQUEST",`${_t.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new R("IPC_BAD_REQUEST",`${_t.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,_t.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){Nt(e._meta,"_agent/getFileTree");let r=e._meta,s=lr(r),a=await this.resolveWorkspace(s),c=e.filePath??"",f=this.safeJoin(a,c),u=await ac(f).catch(()=>null);if(!u)throw new R("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Nr(f,a))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=bw(e.depth);return u.isDirectory()?{tree:await yw(a,f,c,x)}:{tree:[{name:Ew(c),path:uu(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Nt(e._meta,"_agent/getFileContent");let r=lr(e._meta),s=await this.resolveWorkspace(r);if(!e.filePath)throw new R("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(s,e.filePath),c=await ac(a).catch(()=>null);if(!c||!c.isFile())throw new R("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Nr(a,s))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>iu)throw new R("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${iu})`);let f=await su(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 Fe(e).catch(()=>null))?.workspace??Tt(e).workspace}safeJoin(e,r){let s=fc(e,r||"."),a=lc(e,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${ou}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return s}loadAgentCfg(e){return Fe(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new R("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function ow(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new R("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new R("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function aw(t){return t==="claude-code"?bt(".claude","skills"):bt(".agents","skills")}var cw=3e4,dw=50*1024*1024,hr=3e4;async function xc(t){let{agentId:e,workspace:r,framework:s,skill:a}=t;if(!a.skillName)throw new R("IPC_BAD_REQUEST","skill missing skillName");let c=typeof a.content=="string"&&a.content.length>0,f=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!c&&!f)throw new R("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let u=ow(a.skillName),x=aw(s),h=bt(x,u),m=bt(r,h);if(await cc(m,{recursive:!0}),c){let A=Buffer.from(a.content,"utf8");ui(A.length),await dc(bt(m,"SKILL.md"),A,"utf8")}else{let A=await uw(a.downloadUrl);xw(A)?await mw(A,m):hw(A)?await pw(A,m):await dc(bt(m,"SKILL.md"),A.toString("utf8"),"utf8")}let v={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"}),v}function hc(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 fw(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 uw(t){if(!t)throw new R("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);ui(e);let r=lw(t);return ui(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await su(e);return ui(r.length),r}if(Ds(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),cw);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new R("IPC_BAD_REQUEST",`fetch skill failed HTTP ${s.status} ${t}`);let a=await s.arrayBuffer();return ui(a.byteLength),Buffer.from(a)}finally{clearTimeout(r)}}throw new R("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function ui(t){if(t>dw)throw new R("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function lw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new R("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],s=e[3]??"";return r?Buffer.from(s,"base64"):Buffer.from(decodeURIComponent(s),"utf8")}function xw(t){return t.length>=2&&t[0]===31&&t[1]===139}function hw(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 uc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function pw(t,e){let r,s;try{r=new du.default(t),s=r.getEntries()}catch(f){throw new R("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of s){let u=f.entryName;if(!u||uc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new R("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(h=>h===".."))throw new R("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=f.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new R("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let a=gw(s),c=fc(e);for(let f of s){if(uc(f.entryName))continue;let u=f.entryName;if(a&&u.startsWith(a)&&(u=u.slice(a.length)),!u)continue;let x=fc(e,u),h=lc(c,x);if(h.startsWith("..")||h==="..")throw new R("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(f.isDirectory){await cc(x,{recursive:!0});continue}await cc(tw(x),{recursive:!0});let m;try{m=f.getData()}catch(v){throw new R("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${v.message}`,{cause:v})}await dc(x,m)}}function gw(t){let e;for(let r of t){let s=r.entryName;if(!s||uc(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 mw(t,e){await ww(t);let r=Uf({cwd:e,strip:1}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar extract timeout (${hr}ms)`))},hr);try{await cu(au.from(t),r)}catch(c){throw c instanceof R?c:s?new R("IPC_BAD_REQUEST",`tar extract timeout (${hr}ms)`):new R("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}}async function ww(t){let e=[],r=ur({onReadEntry:c=>{let f=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${f.slice(0,100)}`);return}if(f.startsWith("/")||f.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(f)){e.push(`tar entry absolute path: ${f}`);return}f.split(/[/\\]/).some(h=>h==="..")&&e.push(`tar entry contains '..': ${f}`)}}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar list timeout (${hr}ms)`))},hr);try{await cu(au.from(t),r)}catch(c){throw s?new R("IPC_BAD_REQUEST",`tar list timeout (${hr}ms)`):new R("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}if(e.length>0)throw new R("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var _w=5e3;async function yw(t,e,r,s){return fu(t,e,r,s,{count:0})}async function fu(t,e,r,s,a){if(s<=0)return[];let c;try{c=await Xm(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let u of c){if(sw.has(u.name)||u.isSymbolicLink())continue;if(a.count>=_w){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=bt(e,u.name),h=nw(bt(r,u.name)),m=null;try{m=await ac(x)}catch{continue}if(m.isSymbolicLink())continue;a.count++;let v={name:u.name,path:uu(lc(t,x)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&s>1&&(v.children=await fu(t,x,h,s-1,a)),f.push(v)}return f.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),f}function bw(t){return!t||t<=0?rw:Math.min(t,iw)}function Ew(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function uu(t){return t.split(ou).join("/")}ee();import{readFileSync as GS}from"node:fs";import{dirname as KS,join as VS}from"node:path";import{fileURLToPath as JS}from"node:url";var pr="0.1.78";var cn=j("agent-health-reporter"),vw=1e4,li=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??vw}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),cn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),cn.info("heartbeat stopped"))}async tick(){if(this.inFlight){cn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){cn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let f of this.opts.core.agents.values()){let u=Sw(f);if(!u)continue;let x={agentId:f.agentId,status:u};f.patToken&&(x.patToken=f.patToken),f.accountId&&(x.accountId=f.accountId),r.push(x)}if(r.length===0)return;let s={agents:r,bridgeVersion:pr,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",s,5e3)}catch(f){cn.warn("heartbeat batch send failed",{count:r.length,err:String(f)})}let c=a?.authFailures;if(c&&c.length>0&&(cn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(f){cn.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){cn.warn("onTickEnd hook failed",{err:String(r)})}}};function Sw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Vt();import{mkdir as mc,rm as r_}from"node:fs/promises";Kt();Kt();import{spawnSync as Pw}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 gr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function dn(t,e){return{jsonrpc:"2.0",id:t,error:e}}var Ns=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 lu(t){return"method"in t&&"id"in t&&t.id!==void 0}function xu(t){return"method"in t&&!("id"in t)}function Ms(t){return!("method"in t)&&"id"in t}var Iw={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 Aw(t){if(t!=null)return t instanceof Error?{name:t.name,message:pi(t.message)}:typeof t=="string"?pi(t):typeof t=="object"?Tw(t):t}var Cw=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function pi(t){let e=t;for(let[r,s]of Cw)e=e.replace(r,s);return e}function Tw(t){let e={};for(let[r,s]of Object.entries(t))typeof s=="string"?e[r]=pi(s):e[r]=s;return e}function gi(t){if(t instanceof R){let e=Aw(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:Iw[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 hu(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",s=!!e&&typeof e.message=="string"&&!!e.message,a=s?e?.message:t.message,c=t.data;if(s&&e){let{message:f,...u}=e;c=u}return new R(r,a,{retriable:e?.retriable??!1,cause:c})}function gu(t){return`${JSON.stringify(t)}
119
+ `}var pu=10*1024*1024,Bs=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>pu){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${pu} bytes`)}),[]}let r=this.buffer.split(`
120
+ `);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 wu={"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"},o1=Object.fromEntries(Object.entries(wu).map(([t,e])=>[e,t])),Rw={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},mr=class{seq=0;next(e,r){this.seq+=1;let s=wu[e]??Dw(e),a=Rw[s]??[],c=[s,String(this.seq)];if(a.length>0){let f=a.map(x=>mu(r?.[x]??"")),u=kw(f).join(":");u&&c.push(u)}else r&&Object.values(r).some(f=>f)&&c.push(Object.values(r).filter(Boolean).map(f=>mu(String(f))).join(":"));return c.join("_")}reset(){this.seq=0}};function Dw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function mu(t){return t.replace(/[:_\s]+/g,"-")}function kw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Kn();function fn(t,e){let r=process.env[t];if(!r)return e;let s=Number(r);return Number.isFinite(s)&&s>0?s:e}ee();var Lw=fn("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Ow=200,Nw=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function pc(t){return t.some(e=>Nw.test(e))}var Mw=fn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Bw=fn("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),_u=500;function zw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=_u?t:`${e.slice(0,_u)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function yu(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),Pw("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var Et=class{constructor(e){this.opts=e;this.log=j(`downstream.${this.constructor.name}`),this.decoder=new Bs({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new mr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new R("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Gn(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=r,r.stdout?.setEncoding("utf8"),r.stdout?.on("data",s=>{try{for(let a of this.decoder.push(s))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),r.stderr?.setEncoding("utf8"),r.stderr?.on("data",s=>{let a=s.trimEnd();this.stderrRing.push(a),this.stderrRing.length>Ow&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),r.stdin?.on("error",s=>{this.log.warn("child stdin error",{err:String(s)})}),r.stdout?.on("error",s=>{this.log.warn("child stdout error",{err:String(s)})}),r.stderr?.on("error",s=>{this.log.warn("child stderr error",{err:String(s)})}),r.on("exit",(s,a)=>{this.stopped=!0,(s!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:s,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&pc(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),mn(this.framework).catch(u=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(u)})})));try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(new R("AGENT_PROTOCOL_ERROR",`agent exited (${s}/${a})`));for(let f of this.exitHandlers)f(s,a)}),r.on("error",s=>{this.log.error("child error",{err:String(s)}),this.failAllPending(new R("AGENT_SPAWN_FAILED",String(s),{cause:s}))}),this.log.info("downstream started",{command:this.opts.command,pid:r.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let r=this.child,s=new Promise(c=>r.once("exit",()=>c()));yu(r.pid,"SIGTERM");let a=setTimeout(()=>{r.killed||yu(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=Mw,s=Bw){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(gr(e,r))}catch(s){this.log.warn("respondAgentRequest write failed",{id:e,err:String(s)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(dn(e,r))}catch(s){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(s)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,s=Lw,a=0){if(!this.child||this.stopped)return Promise.reject(new R("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),f=xi(c,e,r),u=(()=>{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,v)=>{let A={resolve:m,reject:v,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};x&&(A.timer=setTimeout(()=>{this.pending.delete(c),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:s,...u?{sessionId:u}:{}}),v(new R("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s));let _=h?()=>{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,...u?{sessionId:u}:{}}),_?.();return}A.timer&&clearTimeout(A.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:a,...u?{sessionId:u}:{}}),v(new R("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;A.armFrameIdle=_,this.pending.set(c,A),_?.();try{this.writeFrame(f)}catch(b){A.timer&&clearTimeout(A.timer),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.pending.delete(c),v(b)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new R("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(gu(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Ms(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(hu(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new R("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:zw(e.result)}),r.resolve(e.result));return}if(xu(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(lu(e)){let r=e;try{this.handleAgentRequest(r).catch(s=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(s)}))}catch(s){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(s)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(dn(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(s){this.log.error("agentRequestHandler threw",{method:e.method,err:String(s)});try{this.writeFrame(dn(e.id,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 Fw=Or("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function Uw(t){let e={};for(let[r,s]of Object.entries(t))s!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=s));return e}var zs=class extends Et{framework="claude-code";constructor(e){let r=wn("claude-code"),[s,a]=r?[r,[]]:["npx",["-y",Fw]],c=e.command??s,f=e.args??a,u={command:c,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(u)}sanitizeEnv(e){return Uw(e)}};Kt();import{mkdtempSync as qw,rmSync as Hw}from"node:fs";import{tmpdir as jw}from"node:os";import{join as Gw}from"node:path";var Ww=Or("codex")??"@zed-industries/codex-acp@^0.15",Fs=class extends Et{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=wn("codex"),[s,a]=r?[r,[]]:["npx",["-y",Ww]],c=e.command??s,f=e.args??a,u=e.extraArgs?[...f,...e.extraArgs]:f,x=e.isolateCodexHome?qw(Gw(jw(),"coze-bridge-codex-home-")):void 0,h=x?{...e.env??{},CODEX_HOME:x}:e.env,m={command:c,args:u,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{Hw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Kw=3e4,wr=class extends Et{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}`}]},Kw))}get acpSessionName(){return this.sessionName}};ee();Me();function gc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}Kt();var _r=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 Us=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 _r,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)}Kn();ee();import{constants as bu,access as Vw}from"node:fs/promises";import{delimiter as $w,join as Jw}from"node:path";var un=j("framework-detector"),Eu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Zw=[".exe",".cmd",".bat",".ps1"],ln=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Gn,access:e.access??Vw}}async detect(e){let r=Eu[e],s=await this.which(r);if(!s)return un.debug("framework binary not found",{framework:e,bin:r}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[c,f]=await Promise.all([this.probeVersion(s,a),e==="openclaw"?this.probeOpenclawDefaultAgent(s):Promise.resolve(null)]),u={path:s,version:c};return f&&(u.defaultAgent=f),u}async detectAll(){let e=await Promise.all(Object.keys(Eu).map(async s=>[s,await this.detect(s)])),r={};for(let[s,a]of e)a&&(r[s]=a);return r}async which(e){let r=this.env.pathEnv.split($w).filter(Boolean),s=this.env.platform==="win32"?["",...Zw]:[""];for(let a of r)for(let c of s){let f=Jw(a,e+c);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?bu.F_OK:bu.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return un.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return un.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let s=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!s)return un.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let a=JSON.parse(s[0]);if(!Array.isArray(a))return un.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=a.find(f=>f?.isDefault===!0);return c?!c.id||!c.workspace?(un.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(un.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:a.length}),null)}catch(a){return un.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(a),matchHead:s[0].slice(0,200)}),null}}async probeVersion(e,r=[]){let s=await this.runProbe(e,[...r,"--version"]);return s&&(Xw(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(s=>{let a="",c=!1,f,u=x=>{c||(c=!0,f&&clearTimeout(f),s(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{x.kill("SIGKILL"),u(null)},15e3),x.stdout?.on("data",h=>{a+=h.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",h=>u({code:h,stdout:a}))}catch{u(null)}})}},Yw=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Xw(t){return t.replace(Yw,"")}import{spawn as Qw}from"node:child_process";import{homedir as e_}from"node:os";import{join as t_}from"node:path";Bi();ee();async function Iu(){let t=t_(e_(),".openclaw/openclaw.json");return(await $n(t))?.gateway?.auth?.token??""}var vu=j("openclaw.config"),n_=[0,5e3,5e3],Su="models.providers.",qs="agents.defaults.models",Hs=class{command;env;retryDelaysMs;queue=new _r;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??n_}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,vu.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(f)})}}throw new R("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${s?.message??"unknown"}`)}runCli(e){return new Promise((r,s)=>{let a=Qw(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){vu.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",`${Su}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Su}${e}`)}addModelToAllowlist(e,r){let s={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${qs}[${e}]`,()=>this.runCli(["config","set",qs,JSON.stringify(s),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${qs}[${e}]`,`${qs}.${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 Pe=j("agent-manager"),i_=(t,e,r,s,a,c,f,u,x)=>{switch(t){case"claude-code":{let h={...a?{...Xf(a),...tu(a,f,u)}:{},...x??{},IS_SANDBOX:"1"};return new zs({cwd:r,env:h})}case"codex":{let m=[...a?[...Qf(a),...ru(a,f,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],v={...a?eu(a):{},...x??{}},A=!!a;return new Fs({cwd:r,...m.length>0?{extraArgs:m}:{},...Object.keys(v).length>0?{env:v}:{},...A?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new wr({command:e,cwd:r,agentId:s,...c?{sessionName:gc(c)}:{}})}};function wc(t){return t==="claude-code"||t==="codex"}var s_={path:"",version:"cloud-deployed"},o_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},a_=6e4,c_=fn("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),js=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??i_,this.createTimeoutMs=e.createTimeoutMs??a_,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??c_,this.detectorFactory=e.detectorFactory??(()=>new ln)}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new R("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Hs({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new R("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new R("IPC_BAD_REQUEST","framework required");let r=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 R("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${s.framework})`);if(s.status==="error")Pe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await s.dispose("rebuild after error").catch(b=>Pe.warn("dispose stale agent failed (ignored)",{err:String(b)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==s.patToken){Pe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),s.setPatToken(e.patToken);let b=await Fe(e.agentId,this.paths).catch(()=>null);b&&(b.patToken=e.patToken,await Ge(b,this.paths))}if(s.deployType==="cloud"&&e.modelInfo){Pe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),s.setModelInfo(e.modelInfo);let b=await Fe(e.agentId,this.paths).catch(()=>null);b&&(b.modelInfo=e.modelInfo,await Ge(b,this.paths))}return Pe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:s.agentId,workspace:s.workspace,framework:s.framework}}}if(!r&&!this.config.frameworksCache?.[e.framework])throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Tt(e.agentId,this.paths),f=ci(e._meta),u=e.framework==="openclaw"&&f==="local",x=u?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,h=e.workspace??x??c.workspace,m=new AbortController,v=setTimeout(()=>m.abort(new R("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,_=!1;try{r&&wc(e.framework)&&await mn(e.framework,m.signal);let b=()=>{if(m.signal.aborted)throw m.signal.reason instanceof Error?m.signal.reason:new R("AGENT_TIMEOUT","_agent/create aborted")};await mc(c.root,{recursive:!0}),await mc(h,{recursive:!0}),await mc(c.logs,{recursive:!0}),b(),u||await Jn(h,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await K0(h),b();let S=await Fe(e.agentId,this.paths).catch(()=>null),I=Zf({model:e.model??S?.model}),D=Hf(e._meta)??S?.accountId,O=e.patToken??S?.patToken,w=f==="cloud"?e.modelInfo??S?.modelInfo:void 0;if(A=new Us({agentId:e.agentId,framework:e.framework,workspace:h,model:I.model??yt,deployType:f,...D?{accountId:D}:{},...O?{patToken:O}:{},...w?{modelInfo:w}:{}}),A.status="ok",S?.sessions){for(let[z,k]of Object.entries(S.sessions))A.sessions.set(z,{acpSessionId:k.acpSessionId,modelToken:k.modelToken,tokenGeneratedAt:k.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(S.sessions).length;F>0&&Pe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(A),_=!0;let C={agentId:e.agentId,framework:e.framework,workspace:h,cozeIdentity:e.cozeIdentity,createdAt:S?.createdAt??Date.now(),sessions:S?.sessions??{},model:I.model};f==="cloud"&&(C.deployType="cloud"),D&&(C.accountId=D),O&&(C.patToken=O),w&&(C.modelInfo=w),S?.skills&&(C.skills=S.skills),S?.agentName&&(C.agentName=S.agentName),S?.description&&(C.description=S.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,h):Pe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let L=e.initialSkills??[];if(L.length>0){let F=[...C.skills??[]],z=new Map(F.map((U,W)=>[U.skillId,W])),k=await Promise.allSettled(L.map(U=>xc({agentId:e.agentId,workspace:h,framework:e.framework,skill:U}))),N=0;for(let[U,W]of k.entries()){let se=L[U];se&&(W.status==="fulfilled"?(hc(F,z,W.value),N++):Pe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:se.skillId,skillName:se.skillName,err:String(W.reason)}))}N>0&&(C.skills=F,Pe.info("initialSkills installed",{agentId:e.agentId,installed:N,requested:L.length}))}return await Ge(C,this.paths),Pe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:h,framework:e.framework}}catch(b){throw Pe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(b)}),_&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await r_(c.root,{recursive:!0,force:!0}).catch(S=>Pe.warn("rm agent dir failed (ignored)",{err:String(S)})),b instanceof R?b:new R("AGENT_SPAWN_FAILED",String(b),{cause:b})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,r,s,a,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&wc(e.framework))u=s_;else throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(wc(e.framework)&&!wn(e.framework)){let m=Ko(e.framework);m&&(Pe.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([m.catch(()=>{}),new Promise(v=>setTimeout(v,this.spawnAwaitInstallMs))]))}let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;e.framework==="openclaw"?h=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:s,cozeEnv:a,mockScenario:c,command:u.path}):h=this.factory(e.framework,u.path,e.workspace,e.agentId,x,s,a,c,this.buildBinShimPathEnv());try{return await h.start(),await h.initialize(o_),h}catch(m){let v=h instanceof Et?h.getStderrTail():[];v.length>0&&Pe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof R?m.code:"unknown",recentStderr:v});let A=pc(v);await h.stop("spawnSessionDownstream failed").catch(()=>{});let _=A?new R("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:m}):m;throw m instanceof R?new R(m.code,m.message,{retriable:m.retriable,cause:_}):new R("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:u}=e,x=gc(a);if(r.deployType==="local"){let A=this.config.frameworksCache?.openclaw?.defaultAgent;if(!A?.id||!A.workspace){Pe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let b=await this.detectorFactory().detect("openclaw");if(b?.defaultAgent?.id&&b?.defaultAgent?.workspace)Pe.info("openclaw lazy re-detect success",{agentId:b.defaultAgent.id,workspace:b.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=b,A=b.defaultAgent;else throw new R("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent")}return new wr({command:u,cwd:A.workspace,agentId:A.id,sessionName:x})}let h=await Iu(),m=s?nu(s,c,f):null,v;if(m){let A=oc(a),b=m.models[0]?.id??yt,S=`${A}/${b}`;if(!this.ensuredProviders.has(S)){let I=this.getOpenclawConfig();await I.ensureProvider(A,m),await I.addModelToAllowlist(S),this.ensuredProviders.add(S)}v=S}return new wr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...v?{slashModelOnStart:v}:{}})}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=oc(s),c=`${a}/${e.model}`,f=!0;try{await r.removeProvider(a)}catch(u){f=!1,Pe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){f=!1,Pe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as Du}from"node:crypto";import{promises as __}from"node:fs";import{basename as ku}from"node:path";import{promises as f_}from"node:fs";import{basename as u_}from"node:path";ee();var Au=j("file-upload"),l_="/api/coze_claw/file/agent_upload",x_=6e4;async function Cu(t,e={}){let s=`${ks(Ls(e.handshakeBase))}${l_}`,a=e.timeoutMs??x_,c=await f_.readFile(t.path),f=new FormData;f.append("agent_id",t.agentId),f.append("session_id",t.sessionId),f.append("file_name",t.name),f.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...xr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),a);Au.info("file upload start",{url:s,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(s,{method:"POST",headers:u,body:f,signal:x.signal}),v=m.headers.get("x-tt-logid")??"";if(!m.ok){let b=await m.text().catch(()=>"");throw new R("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${v}: ${b.slice(0,200)}`)}let A=await m.json();if(A.code!==void 0&&A.code!==0)throw new R("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${v}`);let _=A.data?.file?.file_url;if(!_)throw new R("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${v}: ${JSON.stringify(A).slice(0,200)}`);return Au.info("file upload ok",{uri:_,logid:v}),{uri:_}}catch(m){throw m instanceof R?m:m.name==="AbortError"?new R("UPLOAD_FAILED",`upload timeout (${a}ms) for ${u_(t.path)}`):new R("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(h)}}ee();import{promises as h_}from"node:fs";import{extname as p_}from"node:path";var g_=[{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 m_(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 w_={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Tu(t){let e=await h_.open(t,"r");try{let r=Buffer.alloc(16);if(await e.read(r,0,16,0),m_(r))return"image/webp";for(let s of g_)if(s.prefix.every((a,c)=>r[c]===a))return s.mime}finally{await e.close()}return w_[p_(t).toLowerCase()]??"application/octet-stream"}Me();var Gs=j("agent-send"),Ru=50*1024*1024,y_=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Pu(t,e,r){let s=t.get(e);if(!s)throw new R("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new R("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=s.sessions.get(r);if(!a)throw new R("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:s,runtime:a}}async function Lu(t,e,r,s,a,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,s,a);return}catch(h){u=h,x<2&&(Gs.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(m=>setTimeout(m,5e3)))}throw new R("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function Ou(t,e){let{session:r,runtime:s}=Pu(e.core,t.agentId,t.sessionId);if(!await Nr(t.path,r.workspace))throw new R("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let a=await __.stat(t.path).catch(()=>null);if(!a||!a.isFile())throw new R("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(a.size>Ru)throw new R("FILE_TOO_LARGE",`${a.size} bytes > limit ${Ru}`);let c=await Tu(t.path);if(!y_.has(c))throw new R("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(t.kind==="image"&&!c.startsWith("image/"))throw new R("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let f=t.name??ku(t.path),u;try{u=await Cu({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 Gs.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:a.size,mime:c,code:h instanceof R?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId:Du(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:f,sizeBytes:a.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Lu(e,r,s,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Gs.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:f,bytes:a.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:a.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function Nu(t,e){let{session:r,runtime:s}=Pu(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new R("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let a=t.name??ku(t.path),c={sessionUpdate:"group_file",messageId:Du(),content:{uri:t.path,name:a,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Lu(e,r,s,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Gs.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 Mu(t,e){let r=t.split(".").map(Number),s=e.split(".").map(Number),a=Math.max(r.length,s.length);for(let c=0;c<a;c++){let f=r[c]??0,u=s[c]??0;if(f<u)return!0;if(f>u)return!1}return!1}Kt();Kn();ee();var vt=j("coze-cli-installer"),Bu="@coze/cli@latest",b_="coze",zu="0.1.7",E_=5e3,v_=5e3,S_=9e4,Fu=1e4,wi=null,Ws=!1;async function _c(t,e={}){if(Ws)return;if(wi)return wi;let r=e.exec??Wn;return wi=(async()=>{try{let s=await I_(b_,r),a=!1;if(s){let f=await A_(r);if(f===void 0)vt.warn("coze-cli found but version unparseable, fall through to full install",{path:s});else if(Mu(f,zu))vt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:s,version:f,min:zu}),a=!0;else{vt.info("coze-cli already on PATH with sufficient version, skip",{path:s,version:f}),Ws=!0;return}}let c=a?"upgrade-only":"full";vt.info("coze-cli install start",{package:Bu,mode:c});try{await r("npm",["i","-g","--prefer-online",Bu],{timeout:S_,maxBuffer:10*1024*1024}),vt.info("coze-cli install ok")}catch(f){vt.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(a){Ws=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Fu}),vt.info("coze config set xTTEnv ok",{env:t.env})}catch(f){vt.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Fu}),vt.info("coze auth login ok")}catch(f){vt.warn("coze auth login failed",{err:String(f)});return}Ws=!0}finally{wi=null}})(),wi}async function I_(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:s}=await e(r,[t],{timeout:E_});return Ni(s)}catch{return}}async function A_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:v_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Bi();Me();var C_=10*6e4;function Uu(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?C_:e}function Ks(t){return $n(t??te().configFile)}function yr(t,e){return Mi(e??te().configFile,t)}import{randomBytes as W_}from"node:crypto";import{createReadStream as T_}from"node:fs";import{mkdir as R_,readFile as D_,realpath as k_,stat as P_,writeFile as L_}from"node:fs/promises";import{basename as O_,dirname as yc,join as N_,relative as M_,resolve as qu,sep as B_}from"node:path";import{createInterface as z_}from"node:readline";ee();var ju=j("fs-rpc"),_i=fn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Gu(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>_i)throw new R("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${_i} bytes`);let s=await Ku(t.path,e);return await R_(yc(s),{recursive:!0}),await L_(s,t.content,"utf8"),ju.info("fs/write_text_file ok",{path:s,size:t.content.length}),null}async function Wu(t,e){let r=await Ku(t.path,e),s=await P_(r),a=typeof t.line=="number"||typeof t.limit=="number";if(s.size>_i&&!a)throw new R("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 F_(r,t.line??1,t.limit);else{let f=await D_(r,"utf8");if(a){let u=f.split(`
121
+ `),x=Math.max(0,(t.line??1)-1),h=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,h).join(`
122
+ `)}else c=f}return ju.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function F_(t,e,r){let s=z_({input:T_(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),c=typeof r=="number"?a+r:Number.POSITIVE_INFINITY,f=[],u=0;try{for await(let x of s)if(u>=a&&u<c&&f.push(x),u++,u>=c)break}finally{s.close()}return f.join(`
123
+ `)}async function Ku(t,e){if(typeof t!="string"||t.length===0)throw new R("IPC_BAD_REQUEST","path must be a non-empty string");let[r,s]=await Promise.all([Hu(qu(e)),Hu(qu(t))]),a=M_(r,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${B_}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return s}async function Hu(t){let e=[],r=t;for(;r!==yc(r);)try{let s=await k_(r);return e.length?N_(s,...e.reverse()):s}catch{e.push(O_(r)),r=yc(r)}return t}ee();var Vu=j("prompt-multimodal"),$u=10*1024*1024,U_=15e3,q_=6;async function Ju(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 H_(f))}}let a=Array.from({length:Math.min(q_,t.length)},()=>s());return await Promise.all(a),e}function Zu(t){return t.some(e=>e.type==="image")}async function H_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ds(e.uri))return t;try{let{buf:r,contentType:s}=await G_(e.uri),a=e.mimeType||j_(s)||"application/octet-stream";return Vu.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 Vu.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 G_(t){let e=new AbortController,r=setTimeout(()=>e.abort(),U_);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>$u)throw new Error(`image too large: ${a.byteLength} bytes (max ${$u})`);return{buf:Buffer.from(a),contentType:s.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Vt();ee();var V=j("core"),K_=3e4,V_=/^(boe|ppe)_[A-Za-z0-9_-]+$/,$_=3e4,Vs=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new mr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Uu(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(s){V.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)&&V.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)=>{V.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){V.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:s.length});for(let a of s){let c=this.pendingUpstream.get(a);if(c){this.pendingUpstream.delete(a),this.upstream.send(dn(a,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(f=>V.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)){V.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,s]of this.pendingUpstream)try{s.downstream.respondAgentRequestError(s.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,s]of this.pendingBridge)clearTimeout(s.timer),s.reject(new R("UPSTREAM_DISCONNECTED",`${s.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Ms(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&&V_.test(s)?this.currentCozeEnv=s:s&&V.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}`):V.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);r!==null&&await this.upstream.send(gr(r,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(gr(r,a));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(gr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):V.warn("drop unknown notification",{method:e.method})}catch(a){V.error("handleFrame failed",{method:e.method,err:String(a)}),r!==null&&await this.upstream.send(dn(r,gi(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new R("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,s=r._meta?.cozeAgentId;if(!s)throw new R("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(s);if(!a)throw this.disconnectedAgents.has(s)?new R("AGENT_DISCONNECTED",`agent ${s} has been disconnected; cloud must _agent/create to revive`):new R("AGENT_NOT_FOUND",`agent not found: ${s}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(a,e.method,r);let f=Date.now(),u=!1;try{let x=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,r));return u=!0,x}finally{V.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-f,ok:u})}}async dispatchSessionCall(e,r,s){e.lastActiveAt=Date.now();let{stripped:a}=Gf(s);switch(r){case"session/new":{let c=J_();return V.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return V.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,f=c.sessionId;if(!f)throw new R("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,f);if(u.replySeq=0,await this.ensureDownstream(e,f,u),!u.downstream||!u.acpSessionId)throw new R("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=s._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(u.acpSessionId,x):e.activeTriggers.delete(u.acpSessionId);let h=jf(s._meta);if(h?e.activeGroupIds.set(u.acpSessionId,h):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Zu(c.prompt))throw new R("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await Ju(c.prompt);try{let v=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:m});return u.lastActiveAt=Date.now(),v}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.reloadAfterTurn){u.reloadAfterTurn=!1;let v=u.downstream;v&&(u.downstream=void 0,V.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:u.acpSessionId}),v.stop("reload-after-turn").catch(A=>V.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:f,err:String(A)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,f,u)}}case"session/cancel":{let f=a.sessionId;if(!f)throw new R("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(f);if(e.hasSessionQueue(f)){let x=e.getSessionQueue(f);x.size>0&&(V.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:x.size}),x.dispose(new R("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${f}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new R("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let s=e.sessions.get(r);if(s)return s;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let s={sessionId:r,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(_t.GEN_MODEL_TOKEN,s,$_);if(!a?.modelToken)throw new R("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return a.modelToken}catch(a){throw a instanceof R&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new R("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,r,s){if(mi(s),s.downstream?.isAlive())return;if(!this.sessionSpawner)throw new R("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,f=s.spawnFailCount??0,u=s.spawnFailedAt??0;if(f>=a&&Date.now()-u<c)throw new R("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${f} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,s.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(h){throw s.spawnFailCount=f+1,s.spawnFailedAt=Date.now(),s.spawnFailCount>=a&&s.acpSessionId&&(V.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}),V.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId})}catch(h){V.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)){V.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)){V.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,s);return}V.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=>V.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),s.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let s=r.downstream;if(!s)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===s)return!0;return!1}async sendAgentFileUpdate(e,r,s,a){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let f=e.activeTriggers.get(r.acpSessionId);f&&(c.cozeTriggerMsgId=f);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(hi("session/update",{sessionId:s,update:a,_meta:c}))}forwardUpdate(e,r){let s=r.sessionId,a=this.reverseSessionId(e,s);if(!a){V.debug("drop update for unknown session",{agentId:e.agentId,acpId:s});return}let c=e.sessions.get(a);if(!c){V.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(Y_(r)){V.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:s});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(s);u&&(f.cozeTriggerMsgId=u);let x=e.activeGroupIds.get(s);x&&(f.cozeGroupId=x),this.upstream.send(hi("session/update",{...r,sessionId:a,_meta:f})).catch(h=>V.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}V.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 Gu(c,a);r.respondAgentRequest(s.id,f)}else{let c=s.params??{},f=await Wu(c,a);r.respondAgentRequest(s.id,f)}}catch(a){V.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??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let m=u?e.activeGroupIds.get(u):void 0;m&&(h.cozeGroupId=m);let v=u?this.reverseSessionId(e,u):void 0,A={...c,...v?{sessionId:v}:{},_meta:h};this.pendingUpstream.set(a,{agentRequestId:s.id,agentId:e.agentId,downstream:r,method:s.method}),V.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:u,cloudSessionId:v,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(_=>({optionId:_.optionId,kind:_.kind,name:_.name}))}),this.upstream.send(xi(a,"session/request_permission",A)).catch(_=>{this.pendingUpstream.delete(a),V.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?(V.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"&&Z_(e.result,a),V.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 Ns(e.error)):s.value.resolve(e.result);return}V.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 V.warn(`${s} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:f,key:c}}}sendRequest(e,r,s=K_){let a=this.upstreamIds.next(e);return new Promise((c,f)=>{let u=setTimeout(()=>{this.pendingBridge.delete(a),f(new R("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s);this.pendingBridge.set(a,{method:e,resolve:c,reject:f,timer:u}),this.upstream.send(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 Vo(e.agentId,r,this.paths)}catch(r){V.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[s,a]of e.sessions.entries())if(a.acpSessionId===r)return s}sendError(e,r,s){return this.upstream.send(dn(e,{code:r,message:s,data:{bridgeVersion:pr}}))}};function J_(){return W_(16).toString("hex")}function Z_(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 s=r.outcome;if(!s||typeof s!="object"){V.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")&&V.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function Y_(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 X_}from"node:crypto";import{chmod as Q_,mkdir as ey,writeFile as Yu}from"node:fs/promises";import{createServer as ty}from"node:http";import{dirname as ny}from"node:path";var ry=1e6,bc=j("ipc"),$s=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=X_(32).toString("hex");let e=ty((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(),bc.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 ey(ny(this.paths.portFile),{recursive:!0}),await Yu(this.paths.portFile,String(this.port),"utf8"),await Yu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Q_(this.paths.tokenFile,384)}catch(e){bc.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 iy(e)}catch(u){yi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(f,e);yi(r,200,u??{ok:!0})}catch(u){bc.error("IPC handler failed",{key:a,err:String(u)}),yi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function yi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function iy(t){let e=[],r=0;for await(let a of t){let c=a;if(r+=c.length,r>ry)throw new Error("body too large");e.push(c)}let s=Buffer.concat(e).toString("utf8");return s?JSON.parse(s):null}var yx=lt(cl(),1);var zb=lt(rx(),1),Fb=lt(uo(),1),Ub=lt(vr(),1),qb=lt(Oc(),1),Hb=lt(Bc(),1),jb=lt(jc(),1),lx=lt(po(),1),Gb=lt(ux(),1);var xx=lx.default;ee();var Ie=j("upstream.frontier"),px="application/json",gx="none",Kb=15e3,Ri=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:Vf,...xr(this.opts.ppeOverride)};class r extends xx{constructor(b){super(b,Kf,{headers:e})}send(b,...S){if(k0("debug"))try{let I;typeof b=="string"?I=Buffer.from(b,"utf8"):b instanceof Buffer?I=b:b instanceof ArrayBuffer?I=new Uint8Array(b):ArrayBuffer.isView(b)?I=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):I=new Uint8Array(0);let D=Buffer.from(I.slice(0,128)).toString("hex");Ie.debug("WS raw frame out",{bytes:I.byteLength,headHex:D})}catch(I){Ie.warn("WS raw frame dump failed",{err:String(I)})}super.send(b,...S)}}let s=Jf(this.opts.urlOverride),a={url:s,ws:r,fpID:Wf,aID:Ps,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:px,force:!0},payloadEncoding:{encoding:gx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new yx.FWS(a),f=!1,u=null,x,h,m=new Promise((_,b)=>{x=_,h=b}),v=_=>{f||(f=!0,u&&(clearTimeout(u),u=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}),_&&v();for(let b of this.connectHandlers)Promise.resolve(b({initial:_})).catch(S=>Ie.warn("onConnect handler threw (ignored)",{err:String(S)}))},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}),v(new R("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let A=this.opts.openTimeoutMs??Kb;u=setTimeout(()=>{v(new R("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await m}catch(_){try{c.close(1e3,"open failed")}catch(b){Ie.warn("fws close during start failure threw (ignored)",{err:String(b)})}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 R("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-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=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new R("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let a=JSON.stringify(e),c=e;mx(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:px,payloadEncoding:gx})}catch(u){throw Ie.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new R("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let s=e.params?._meta;if(!s?.cozeAgentId)return;let a=r(s.cozeAgentId);a&&(s.cozePatToken=a)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Ie.debug("drop non-adapter frontier frame",{service:r});return}let s=Jb(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;mx(c)||Ie.info("frontier frame in",{logid:$b(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:Vb(s)}),Promise.resolve(this.handler(a)).catch(f=>Ie.warn("frontier frame handler threw",{err:String(f)}))}};function mx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var _x=2e3;function Vb(t){return t.length<=_x?t:`${t.slice(0,_x)}...<truncated, total ${t.length} chars>`}function $b(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function Jb(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ee();var Wc=j("upstream.switchable"),mo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Wc.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 Wc.error("swap target start failed, reverting",{err:String(a)}),this.inner=s,a}await s.stop(r??"swapped").catch(a=>Wc.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 Kc=j("upstream"),Rr=class{handler=null;async start(){Kc.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Kc.info("NoopUpstream stopped",{reason:e})}async send(e){Kc.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 Vc}from"node:fs";import{dirname as Zb}from"node:path";var Yb=j("pat-token-store");async function bx(t=te()){try{let r=(await Vc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Yb.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Di(t,e=te()){if(!t)throw new Error("writePatToken: empty patToken");await Vc.mkdir(Zb(e.patTokenFile),{recursive:!0}),await Vc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Me();Me();import{promises as wo}from"node:fs";import{join as Xb}from"node:path";function Qb(t,e){return`#!/bin/sh
124
124
  exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
125
- `}function Qb(t,e){return`@echo off\r
125
+ `}function eE(t,e){return`@echo off\r
126
126
  "${e}" "${t}" %*\r
127
- `}async function bh(t,e=te()){let r=e.binDir;await _o.mkdir(r,{recursive:!0});let i=Yb(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?Qb(t,o):Xb(t,o);return await _o.readFile(i,"utf8").catch(()=>null)===c||(await _o.writeFile(i,c,"utf8"),process.platform!=="win32"&&await _o.chmod(i,493)),r}ee();Fe();import{execSync as vh}from"node:child_process";import{readFileSync as Sh,unlinkSync as eE}from"node:fs";import{mkdir as tE,readFile as Ih,unlink as Ah,writeFile as nE}from"node:fs/promises";import{dirname as rE}from"node:path";function Eh(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var iE=q("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&&(iE.warn("removing stale pid file",{stalePid:e}),await Ah(this.pidFile).catch(()=>{})),await tE(rE(this.pidFile),{recursive:!0}),await nE(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ih(this.pidFile,"utf8")).trim()===String(process.pid)&&await Ah(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ih(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 Eh(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Sh(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=vh(`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=vh(`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{Sh(this.pidFile,"utf8").trim()===String(process.pid)&&eE(this.pidFile)}catch{}})}};var j=q("daemon"),sE="coze-bridge-daemon";async function Ch(){let t=new bo({processTitle:sE}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Vs(),i=r??{};Mi({pid:process.pid}),j.info(r?"loaded bridge config":"initialized bridge config");try{let P=new hn;i.frameworksCache=await P.detectAll(),j.info("refreshed frameworks_cache",{detected:Object.keys(i.frameworksCache)})}catch(P){j.warn("framework detection failed",{err:String(P)})}await _r(i);let o=new yo(new Rr),c=te(),l=null,u=new Js({upstream:o,paths:c,bridgeConfig:i,sessionSpawner:async(P,N,U,W)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(P,N,U,W)}});await aE(c,u);let h=new Ws({paths:c,config:i,registry:u});l=h;let p,w,b=null,A={},_,E=null;u.registerExtension("_agent/create",async P=>h.createAgent(P.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let v={},I=new Ms({agents:u.agents,disposeAndMarkDisconnected:async(P,N)=>{let U=u.agents.get(P);if(U){await h.cleanupOpenclawSessionProviders(U).catch(oe=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(oe)}));let W=!0;try{await U.dispose(`disconnect: ${N}`)}catch(oe){W=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(oe)}),U.status="error"}W&&(U.status="disconnected",u.unregister(P),u.disconnectedAgents.add(P))}else u.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!v.ref)throw new Error("agent-detail-sync not initialized yet");await v.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await h.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,N)=>{await h.openclawRepair(P,N)},isRuntimePendingPermission:P=>u.hasPendingPermissionFor(P)});u.registerExtension("_agent/listSkills",P=>I.listSkills(P.params)),u.registerExtension("_agent/addSkills",P=>I.addSkills(P.params)),u.registerExtension("_agent/removeSkills",P=>I.removeSkills(P.params)),u.registerExtension("_agent/getFileTree",P=>I.getFileTree(P.params)),u.registerExtension("_agent/getFileContent",P=>I.getFileContent(P.params)),u.registerExtension("_agent/update",P=>I.updateAgent(P.params)),u.registerExtension("_agent/disconnect",P=>I.disconnectAgent(P.params)),u.registerExtension("_agent/switchModel",P=>I.switchModel(P.params)),u.registerExtension("_agent/reset",P=>I.resetAgent(P.params)),u.registerExtension("_agent/repair",P=>I.repairAgent(P.params));let k=new ji({paths:c,handlers:I,sendDetail:P=>u.sendRequest("_agent/detail",P)});v.ref=k;let O=async P=>{await Promise.allSettled(P.map(async N=>{try{await I.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(U){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(U)})}}))};o.onConnect(({initial:P})=>{j.info("frontier upstream connected, triggering detail sync",{initial:P}),k.syncAll(P?"initial-connect":"reconnect").catch(N=>j.warn("detail sync top-level error (ignored)",{err:String(N)}))});let y=new Zs({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let P=u.getMockScenario();return{running:!0,pid:process.pid,agents:[...u.agents.keys()],deviceId:b??"",frameworksCache:i.frameworksCache??{},...P?{mockScenario:P}:{}}}},{method:"POST",path:"/pair",handler:async P=>{let N=P,U=N?.privatecode,W=N?.pairing_code;if(!U||!W)throw new R("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let oe=fi(N.env),ue=N.handshake_url,be=N.frontier_url,Be=Th(N.env,ue,be),ot=!!p&&p!==U,Re=w!==void 0&&w!==Be,jt=ot||Re,Ee=await ic({privatecode:U,...ue?{endpoint:ue}:{},ppeOverride:oe});if(jt){j.warn("pair config switched, resetting agents",{pcChanged:ot,envChanged:Re,previousPc:p?Eo(p):"",nextPc:Eo(U),previousEnvKey:w??"",nextEnvKey:Be});for(let ye of[...u.agents.values()])await ye.dispose("pair config switch").catch(()=>{}),u.agents.delete(ye.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await o.swap(new Rr,"pair switch").catch(()=>{})}b=Ee.deviceId,Mi({deviceId:b,pid:process.pid}),_c({patToken:U,env:N.env}).catch(ye=>j.warn("coze-cli setup error (ignored)",{err:String(ye)}));let Y=new Di({handshake:Ee,privatecode:U,...be?{urlOverride:be}:{},ppeOverride:oe,getPatTokenForAgent:ye=>u.agents.get(ye)?.patToken});await o.swap(Y,"pair");try{let ye=new hn;i.frameworksCache=await ye.detectAll(),await _r(i),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(i.frameworksCache)})}catch(ye){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ye)})}let zn=Object.keys(i.frameworksCache??{});try{let ye=await u.sendRequest("_agent/pair",{pairCode:W,patToken:U,frameworks:zn,_meta:{cozeDeviceId:b}});j.info("_agent/pair ok",{pairResult:ye}),p=U,w=Be,A=oe,_=ue,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),j.info("mock scenario set",{scenario:N.mock_scenario})),ki(U,c).catch(We=>j.warn("writePatToken after /pair failed (ignored)",{err:String(We)})),E||(E=new hi({core:u,getDeviceId:()=>b??"",onTickEnd:()=>k.retryPending().catch(We=>j.warn("detailSync.retryPending failed (ignored)",{err:String(We)})),onAuthFailures:O})),E.start(),jt&&vo(c,h).catch(We=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(We)}));let Fn;return N.agent_id&&(Fn=await cE(N.agent_id,c,h,We=>u.sendRequest("_agent/detail",We),U).catch(We=>(j.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(We)}),{ok:!1,agentId:N.agent_id??"",note:String(We)}))),{ok:!0,note:"paired with cloud",...Fn?{agent:Fn}:{}}}catch(ye){return j.error("_agent/pair failed",{err:String(ye)}),{ok:!1,note:`pair failed: ${String(ye)}`}}}},{method:"POST",path:"/connect",handler:async P=>{let N=P,U=N?.privatecode;if(!U)throw new R("IPC_BAD_REQUEST","/connect requires privatecode");let W=fi(N.env),oe=N.handshake_url,ue=N.frontier_url,be=Th(N.env,oe,ue);if(p===U&&w===be){let Y=await oE(c);return u.agents.size===0&&Y?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),vo(c,h).catch(zn=>j.warn("connect-noop auto-revive error (ignored)",{err:String(zn)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Be=!!p&&p!==U,ot=w!==void 0&&w!==be,Re=Be||ot,jt=await ic({privatecode:U,...oe?{endpoint:oe}:{},ppeOverride:W});if(Re){j.warn("connect config switched, resetting agents",{pcChanged:Be,envChanged:ot,previousPc:p?Eo(p):"",nextPc:Eo(U)});for(let Y of[...u.agents.values()])await Y.dispose("connect config switch").catch(()=>{}),u.agents.delete(Y.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await o.swap(new Rr,"connect switch").catch(()=>{})}b=jt.deviceId,Mi({deviceId:b,pid:process.pid}),_c({patToken:U,env:N.env}).catch(Y=>j.warn("coze-cli setup error (ignored)",{err:String(Y)}));let Ee=new Di({handshake:jt,privatecode:U,...ue?{urlOverride:ue}:{},ppeOverride:W,getPatTokenForAgent:Y=>u.agents.get(Y)?.patToken});return await o.swap(Ee,"connect"),p=U,w=be,A=W,_=oe,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),j.info("mock scenario set",{scenario:N.mock_scenario})),E||(E=new hi({core:u,getDeviceId:()=>b??"",onTickEnd:()=>k.retryPending().catch(Y=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Y)})),onAuthFailures:O})),E.start(),Re&&vo(c,h).catch(Y=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(Y)})),ki(U,c).catch(Y=>j.warn("writePatToken after /connect failed (ignored)",{err:String(Y)})),j.info("/connect: WS established",{deviceId:b}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async P=>{let N=P;return{ok:!0,result:await h.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async P=>{let N=P;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new R("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new R("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let U=N;return await(U.groupFile?Nf:Of)(U,{core:u,patToken:p,handshakeBase:_,ppeOverride:A})}catch(U){if(U instanceof R)return{ok:!1,code:U.code,message:U.message};throw U}}},{method:"POST",path:"/refresh",handler:async()=>{j.info("IPC /refresh: re-detecting frameworks");let P=new hn;return i.frameworksCache=await P.detectAll(),await _r(i),{ok:!0,frameworks:i.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{z.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:C,token:L}=await y.start();try{await bh(c.libEntry,c)}catch(P){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(P)})}await u.start(),vo(c,h).catch(P=>j.warn("auto-revive top-level error (ignored)",{err:String(P)})),zd().then(async()=>{let{probeAcpVersion:P}=await Promise.resolve().then(()=>($t(),Md));for(let N of["claude-code","codex"]){let U=await P(N);U?j.info("acp wrapper version",{framework:N,version:U}):j.warn("acp wrapper version probe failed (binary not on PATH?)",{framework:N})}}).catch(P=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(P)}));let F=null,z={port:C,token:L,core:u,ipc:y,shutdown(P){return F||(j.info("daemon shutdown",{reason:P}),F=(async()=>{E?.stop(),await u.stop(P),await y.stop(),await t.release()})(),F)}};for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{z.shutdown(P).then(()=>process.exit(0))});return process.on("unhandledRejection",P=>{j.error("unhandledRejection",{reason:P instanceof Error?P.message:String(P),stack:P instanceof Error?P.stack:void 0})}),process.on("uncaughtException",P=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:P.message,stack:P.stack,name:P.name}),process.exit(1)}),j.info("daemon ready",{port:C,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(i.frameworksCache??{}),libVersion:i.libVersion??"dev"}),z}async function oE(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function Eo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Th(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function aE(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(()=>(Vt(),qi));for(let l of i){await c(l,t).catch(u=>j.warn("enforceAgentConfigMode failed (ignored)",{agentId:l,err:String(u)}));try{let u=await o(l,t);u?.disconnectedAt&&(e.disconnectedAgents.add(l),j.info("agent marked disconnected on startup",{agentId:l,disconnectedAt:u.disconnectedAt,reason:u.disconnectReason??""}))}catch(u){j.warn("failed to load agent config on startup, skipping",{agentId:l,err:String(u)})}}}async function cE(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Vt(),qi)),l=await c(t,e);if(l){j.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let w={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{}};return await r.createAgent(w),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}j.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await i({_meta:{cozeAgentId:t}});if(!u.framework)throw new R("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let h={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...o?{patToken:o}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(h);let p=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function vo(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(()=>(Vt(),qi));j.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let u of i){let h;try{h=await o(u,t)}catch(p){j.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(p)}),l+=1;continue}if(!h){l+=1;continue}if(h.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:h.disconnectedAt}),l+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:h.framework});let p=dE(h);await e.createAgent({agentId:h.agentId,framework:h.framework,...h.cozeIdentity?{cozeIdentity:h.cozeIdentity}:{},...h.model?{model:h.model}:{},...p?{_meta:p}:{}}),c+=1}catch(p){j.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:h.framework,err:String(p)}),l+=1}}return j.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}function dE(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Yc();Fe();import{readFile as Rh}from"node:fs/promises";var qt=class{paths;constructor(e){this.paths=e??te()}async probe(e=1e3){let r=await So(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:mE(i)}}}async request(e){let r=await So(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 u=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 u.text();return{status:u.status,body:gE(h)}}finally{clearTimeout(l)}}};async function So(t){try{let[e,r]=await Promise.all([Rh(t.portFile,"utf8"),Rh(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 gE(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function mE(t){return t instanceof Error?t.message:String(t)}ee();Fe();import{copyFile as Dh,mkdir as wE,readFile as Xc,writeFile as yE}from"node:fs/promises";import{homedir as ZT}from"node:os";import{dirname as _E,resolve as Qc,sep as Io}from"node:path";import{fileURLToPath as bE}from"node:url";ee();Fe();var kh=q("dist-install");function EE(t){let e=bE(t),r=_E(e),i=`${Io}src${Io}`;if(r.includes(i)||r.endsWith(`${Io}src${Io}cli`))return null;let o=Qc(r,"index.js"),c=Qc(r,"..","package.json");return{dist:o,pkgJson:c}}async function ed(t={}){let e=t.paths??te(),r=EE(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"};let c;try{c=JSON.parse(await Xc(o,"utf8")).version??"unknown"}catch(b){return kh.warn("cannot read source package.json,skip dist install",{err:String(b)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(b)}`}}let l=await Vs(e.configFile)??{},u=l.libVersion;if(u===c)try{return await Xc(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await wE(e.libDir,{recursive:!0}),await Dh(i,e.libEntry),await Dh(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let h=Qc(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
128
- `;return await Xc(h,"utf8").catch(()=>null)!==p&&await yE(h,p),l.libVersion=c,await _r(l,e.configFile),kh.info("dist installed",{libEntry:e.libEntry,fromVersion:u,toVersion:c}),u?{kind:"version-changed",fromVersion:u,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}import{basename as vE,resolve as SE}from"node:path";Fe();var IE=9e4,AE={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,NPX_CACHE_CORRUPT:1};function TE(t){return AE[t]??1}async function Ph(t,e={}){let r=e.paths??te();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
127
+ `}async function Ex(t,e=te()){let r=e.binDir;await wo.mkdir(r,{recursive:!0});let s=Xb(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.execPath,c=process.platform==="win32"?eE(t,a):Qb(t,a);return await wo.readFile(s,"utf8").catch(()=>null)===c||(await wo.writeFile(s,c,"utf8"),process.platform!=="win32"&&await wo.chmod(s,493)),r}ee();Me();import{execSync as Sx}from"node:child_process";import{readFileSync as Ix,unlinkSync as tE}from"node:fs";import{mkdir as nE,readFile as Ax,unlink as Cx,writeFile as rE}from"node:fs/promises";import{dirname as iE}from"node:path";function vx(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var sE=j("single-instance"),_o=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&&(sE.warn("removing stale pid file",{stalePid:e}),await Cx(this.pidFile).catch(()=>{})),await nE(iE(this.pidFile),{recursive:!0}),await rE(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ax(this.pidFile,"utf8")).trim()===String(process.pid)&&await Cx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ax(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return vx(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Ix(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=Sx(`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=Sx(`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{Ix(this.pidFile,"utf8").trim()===String(process.pid)&&tE(this.pidFile)}catch{}})}};var G=j("daemon"),oE="coze-bridge-daemon";async function Rx(){let t=new _o({processTitle:oE}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Ks(),s=r??{};Oi({pid:process.pid}),G.info(r?"loaded bridge config":"initialized bridge config");try{let k=new ln;s.frameworksCache=await k.detectAll(),G.info("refreshed frameworks_cache",{detected:Object.keys(s.frameworksCache)})}catch(k){G.warn("framework detection failed",{err:String(k)})}await yr(s);let a=new mo(new Rr),c=te(),f=null,u=new Vs({upstream:a,paths:c,bridgeConfig:s,sessionSpawner:async(k,N,U,W)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(k,N,U,W)}});await cE(c,u);let x=new js({paths:c,config:s,registry:u});f=x;let h,m,v=null,A={},_,b=null;u.registerExtension("_agent/create",async k=>x.createAgent(k.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let S={},I=new Os({agents:u.agents,disposeAndMarkDisconnected:async(k,N)=>{let U=u.agents.get(k);if(U){await x.cleanupOpenclawSessionProviders(U).catch(se=>G.warn("cleanup openclaw providers failed (ignored)",{agentId:k,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:k,err:String(se)}),U.status="error"}W&&(U.status="disconnected",u.unregister(k),u.disconnectedAgents.add(k))}else u.disconnectedAgents.add(k)},detailSyncer:async k=>{if(!S.ref)throw new Error("agent-detail-sync not initialized yet");await S.ref.syncOne(k)},cleanupOpenclawProviders:async k=>{await x.cleanupOpenclawSessionProviders(k)},openclawRepair:async(k,N)=>{await x.openclawRepair(k,N)},isRuntimePendingPermission:k=>u.hasPendingPermissionFor(k)});u.registerExtension("_agent/listSkills",k=>I.listSkills(k.params)),u.registerExtension("_agent/addSkills",k=>I.addSkills(k.params)),u.registerExtension("_agent/removeSkills",k=>I.removeSkills(k.params)),u.registerExtension("_agent/getFileTree",k=>I.getFileTree(k.params)),u.registerExtension("_agent/getFileContent",k=>I.getFileContent(k.params)),u.registerExtension("_agent/update",k=>I.updateAgent(k.params)),u.registerExtension("_agent/disconnect",k=>I.disconnectAgent(k.params)),u.registerExtension("_agent/switchModel",k=>I.switchModel(k.params)),u.registerExtension("_agent/reset",k=>I.resetAgent(k.params)),u.registerExtension("_agent/repair",k=>I.repairAgent(k.params));let D=new qi({paths:c,handlers:I,sendDetail:k=>u.sendRequest("_agent/detail",k)});S.ref=D;let O=async k=>{await Promise.allSettled(k.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:k})=>{G.info("frontier upstream connected, triggering detail sync",{initial:k}),D.syncAll(k?"initial-connect":"reconnect").catch(N=>G.warn("detail sync top-level error (ignored)",{err:String(N)}))});let w=new $s({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let k=u.getMockScenario();return{running:!0,pid:process.pid,agents:[...u.agents.keys()],deviceId:v??"",frameworksCache:s.frameworksCache??{},...k?{mockScenario:k}:{}}}},{method:"POST",path:"/pair",handler:async k=>{let N=k,U=N?.privatecode,W=N?.pairing_code;if(!U||!W)throw new R("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let se=fi(N.env),fe=N.handshake_url,we=N.frontier_url,Oe=Tx(N.env,fe,we),nt=!!h&&h!==U,Ae=m!==void 0&&m!==Oe,qt=nt||Ae,_e=await rc({privatecode:U,...fe?{endpoint:fe}:{},ppeOverride:se});if(qt){G.warn("pair config switched, resetting agents",{pcChanged:nt,envChanged:Ae,previousPc:h?yo(h):"",nextPc:yo(U),previousEnvKey:m??"",nextEnvKey:Oe});for(let ge of[...u.agents.values()])await ge.dispose("pair config switch").catch(()=>{}),u.agents.delete(ge.agentId);u.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await a.swap(new Rr,"pair switch").catch(()=>{})}v=_e.deviceId,Oi({deviceId:v,pid:process.pid}),_c({patToken:U,env:N.env}).catch(ge=>G.warn("coze-cli setup error (ignored)",{err:String(ge)}));let Z=new Ri({handshake:_e,privatecode:U,...we?{urlOverride:we}:{},ppeOverride:se,getPatTokenForAgent:ge=>u.agents.get(ge)?.patToken});await a.swap(Z,"pair");try{let ge=new ln;s.frameworksCache=await ge.detectAll(),await yr(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 zn=Object.keys(s.frameworksCache??{});try{let ge=await u.sendRequest("_agent/pair",{pairCode:W,patToken:U,frameworks:zn,_meta:{cozeDeviceId:v}});G.info("_agent/pair ok",{pairResult:ge}),h=U,m=Oe,A=se,_=fe,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),G.info("mock scenario set",{scenario:N.mock_scenario})),Di(U,c).catch(He=>G.warn("writePatToken after /pair failed (ignored)",{err:String(He)})),b||(b=new li({core:u,getDeviceId:()=>v??"",onTickEnd:()=>D.retryPending().catch(He=>G.warn("detailSync.retryPending failed (ignored)",{err:String(He)})),onAuthFailures:O})),b.start(),qt&&bo(c,x).catch(He=>G.warn("post-pair-switch auto-revive error (ignored)",{err:String(He)}));let Fn;return N.agent_id&&(Fn=await dE(N.agent_id,c,x,He=>u.sendRequest("_agent/detail",He),U).catch(He=>(G.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(He)}),{ok:!1,agentId:N.agent_id??"",note:String(He)}))),{ok:!0,note:"paired with cloud",...Fn?{agent:Fn}:{}}}catch(ge){return G.error("_agent/pair failed",{err:String(ge)}),{ok:!1,note:`pair failed: ${String(ge)}`}}}},{method:"POST",path:"/connect",handler:async k=>{let N=k,U=N?.privatecode;if(!U)throw new R("IPC_BAD_REQUEST","/connect requires privatecode");let W=fi(N.env),se=N.handshake_url,fe=N.frontier_url,we=Tx(N.env,se,fe);if(h===U&&m===we){let Z=await aE(c);return u.agents.size===0&&Z?(G.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),bo(c,x).catch(zn=>G.warn("connect-noop auto-revive error (ignored)",{err:String(zn)}))):G.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Oe=!!h&&h!==U,nt=m!==void 0&&m!==we,Ae=Oe||nt,qt=await rc({privatecode:U,...se?{endpoint:se}:{},ppeOverride:W});if(Ae){G.warn("connect config switched, resetting agents",{pcChanged:Oe,envChanged:nt,previousPc:h?yo(h):"",nextPc:yo(U)});for(let Z of[...u.agents.values()])await Z.dispose("connect config switch").catch(()=>{}),u.agents.delete(Z.agentId);u.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await a.swap(new Rr,"connect switch").catch(()=>{})}v=qt.deviceId,Oi({deviceId:v,pid:process.pid}),_c({patToken:U,env:N.env}).catch(Z=>G.warn("coze-cli setup error (ignored)",{err:String(Z)}));let _e=new Ri({handshake:qt,privatecode:U,...fe?{urlOverride:fe}:{},ppeOverride:W,getPatTokenForAgent:Z=>u.agents.get(Z)?.patToken});return await a.swap(_e,"connect"),h=U,m=we,A=W,_=se,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),G.info("mock scenario set",{scenario:N.mock_scenario})),b||(b=new li({core:u,getDeviceId:()=>v??"",onTickEnd:()=>D.retryPending().catch(Z=>G.warn("detailSync.retryPending failed (ignored)",{err:String(Z)})),onAuthFailures:O})),b.start(),Ae&&bo(c,x).catch(Z=>G.warn("post-connect-switch auto-revive error (ignored)",{err:String(Z)})),Di(U,c).catch(Z=>G.warn("writePatToken after /connect failed (ignored)",{err:String(Z)})),G.info("/connect: WS established",{deviceId:v}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async k=>{let N=k;return{ok:!0,result:await x.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async k=>{let N=k;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new R("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new R("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let U=N;return await(U.groupFile?Nu:Ou)(U,{core:u,patToken:h,handshakeBase:_,ppeOverride:A})}catch(U){if(U instanceof R)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 k=new ln;return s.frameworksCache=await k.detectAll(),await yr(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:C,token:L}=await w.start();try{await Ex(c.libEntry,c)}catch(k){G.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(k)})}await u.start(),bo(c,x).catch(k=>G.warn("auto-revive top-level error (ignored)",{err:String(k)})),z0().then(async()=>{let{probeAcpVersion:k}=await Promise.resolve().then(()=>(Kt(),M0));for(let N of["claude-code","codex"]){let U=await k(N);U&&G.info("acp wrapper version",{framework:N,version:U})}}).catch(k=>G.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(k)}));let F=null,z={port:C,token:L,core:u,ipc:w,shutdown(k){return F||(G.info("daemon shutdown",{reason:k}),F=(async()=>{b?.stop(),await u.stop(k),await w.stop(),await t.release()})(),F)}};for(let k of["SIGTERM","SIGINT"])process.on(k,()=>{z.shutdown(k).then(()=>process.exit(0))});return process.on("unhandledRejection",k=>{G.error("unhandledRejection",{reason:k instanceof Error?k.message:String(k),stack:k instanceof Error?k.stack:void 0})}),process.on("uncaughtException",k=>{G.error("uncaughtException (will exit, supervisor will restart)",{message:k.message,stack:k.stack,name:k.name}),process.exit(1)}),G.info("daemon ready",{port:C,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(s.frameworksCache??{}),libVersion:s.libVersion??"dev"}),z}async function aE(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function yo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Tx(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function cE(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(()=>(Vt(),Ui));for(let f of s){await c(f,t).catch(u=>G.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(u)}));try{let u=await a(f,t);u?.disconnectedAt&&(e.disconnectedAgents.add(f),G.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:u.disconnectedAt,reason:u.disconnectReason??""}))}catch(u){G.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(u)})}}}async function dE(t,e,r,s,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Vt(),Ui)),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 u=await s({_meta:{cozeAgentId:t}});if(!u.framework)throw new R("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let x={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...a?{patToken:a}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(x);let h=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function bo(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(()=>(Vt(),Ui));G.info("auto-revive: scanning local agents on startup",{count:s.length});let c=0,f=0;for(let u of s){let x;try{x=await a(u,t)}catch(h){G.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(h)}),f+=1;continue}if(!x){f+=1;continue}if(x.disconnectedAt){G.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),f+=1;continue}try{G.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let h=fE(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:u,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 fE(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Zc();Me();import{readFile as Dx}from"node:fs/promises";var Ut=class{paths;constructor(e){this.paths=e??te()}async probe(e=1e3){let r=await Eo(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:wE(s)}}}async request(e){let r=await Eo(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let s=r.body!==void 0,a={Authorization:`Bearer ${e.token}`};s&&(a["content-type"]="application/json");let c=new AbortController,f=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:a,body:s?JSON.stringify(r.body):void 0,signal:c.signal}),x=await u.text();return{status:u.status,body:mE(x)}}finally{clearTimeout(f)}}};async function Eo(t){try{let[e,r]=await Promise.all([Dx(t.portFile,"utf8"),Dx(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 mE(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function wE(t){return t instanceof Error?t.message:String(t)}ee();Me();import{copyFile as kx,mkdir as _E,readFile as Yc,writeFile as yE}from"node:fs/promises";import{homedir as YA}from"node:os";import{dirname as bE,resolve as Xc,sep as vo}from"node:path";import{fileURLToPath as EE}from"node:url";ee();Me();var Px=j("dist-install");function vE(t){let e=EE(t),r=bE(e),s=`${vo}src${vo}`;if(r.includes(s)||r.endsWith(`${vo}src${vo}cli`))return null;let a=Xc(r,"index.js"),c=Xc(r,"..","package.json");return{dist:a,pkgJson:c}}async function Qc(t={}){let e=t.paths??te(),r=vE(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 Yc(a,"utf8")).version??"unknown"}catch(v){return Px.warn("cannot read source package.json,skip dist install",{err:String(v)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(v)}`}}let f=await Ks(e.configFile)??{},u=f.libVersion;if(u===c)try{return await Yc(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await _E(e.libDir,{recursive:!0}),await kx(s,e.libEntry),await kx(`${s}.map`,`${e.libEntry}.map`).catch(()=>{});let x=Xc(e.libDir,"package.json"),h=`${JSON.stringify({type:"module"},null,2)}
128
+ `;return await Yc(x,"utf8").catch(()=>null)!==h&&await yE(x,h),f.libVersion=c,await yr(f,e.configFile),Px.info("dist installed",{libEntry:e.libEntry,fromVersion:u,toVersion:c}),u?{kind:"version-changed",fromVersion:u,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}import{basename as SE,resolve as IE}from"node:path";Me();var AE=9e4,CE={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,NPX_CACHE_CORRUPT:1};function TE(t){return CE[t]??1}async function Lx(t,e={}){let r=e.paths??te();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
129
129
  `),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.
130
- `),3;let i=await So(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.
131
- `),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:SE(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 CE(i,"/agent/send",o,IE)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
130
+ `),3;let s=await Eo(r).catch(()=>null);if(!s)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
131
+ `),4;let a={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:IE(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 RE(s,"/agent/send",a,AE)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
132
132
  `),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
133
133
  `),TE(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
134
- `);else{let l=t.name??vE(o.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${l} (uri=${u})
135
- `)}else process.stdout.write(`Sent ${t.kind} ${l} (${RE(c.bytes)})
136
- `)}return 0}async function CE(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}),u=await l.text(),h=u?JSON.parse(u):null;return h&&typeof h=="object"&&"ok"in h?h:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${l.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function RE(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Uh=q("cli");function He(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 Pi(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
137
- `)}function VE(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 ZE(e.slice(1));if(e.includes("--status"))return Pi("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return Pi("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return Pi("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return Pi("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return Pi("--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}=He(r,"--pat-token");r=o;let{value:c,rest:l}=He(r,"--pair-code");r=l;let{value:u,rest:h}=He(r,"--env");r=h;let{value:p,rest:w}=He(r,"--handshake-url");r=w;let{value:b,rest:A}=He(r,"--frontier-url");r=A;let{value:_,rest:E}=He(r,"--mock-scenario");r=E;let{value:v}=He(r,"--agent-id");if(!i||!c)return{mode:"help"};let I={mode:"pair",privatecode:i,pairingCode:c};return u&&(I.env=u),p&&(I.handshakeUrl=p),b&&(I.frontierUrl=b),_&&(I.mockScenario=_),v&&(I.agentId=v),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}=He(i,"--caption");i=c;let{value:l,rest:u}=He(i,"--name");i=u;let{value:h,rest:p}=He(i,"--agent-id");i=p;let{value:w,rest:b}=He(i,"--session-id");i=b;let{value:A,rest:_}=He(i,"--mime");i=_;let E=i.includes("--group-file");i=i.filter(k=>k!=="--group-file");let v=i.includes("--json"),I={mode:"send",kind:e,path:r,json:v};return o&&(I.caption=o),l&&(I.name=l),h&&(I.agentId=h),w&&(I.sessionId=w),E&&(I.groupFile=!0),A&&(I.mimeType=A),I}function ZE(t){let e=t,{value:r,rest:i}=He(e,"--pat-token");e=i;let{value:o,rest:c}=He(e,"--env");e=c;let{value:l,rest:u}=He(e,"--handshake-url");e=u;let{value:h,rest:p}=He(e,"--frontier-url");e=p;let{value:w,rest:b}=He(e,"--mock-scenario");e=b;let A={mode:"connect"};return r&&(A.privatecode=r),o&&(A.env=o),l&&(A.handshakeUrl=l),h&&(A.frontierUrl=h),w&&(A.mockScenario=w),A}var YE=`
134
+ `);else{let f=t.name??SE(a.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${f} (uri=${u})
135
+ `)}else process.stdout.write(`Sent ${t.kind} ${f} (${DE(c.bytes)})
136
+ `)}return 0}async function RE(t,e,r,s){let a=new AbortController,c=setTimeout(()=>a.abort(),s);try{let f=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:a.signal}),u=await f.text(),x=u?JSON.parse(u):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function DE(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var qx=j("cli");function ze(t,e){let r=[],s;for(let a=0;a<t.length;a++){let c=t[a];if(c===e){s=t[a+1],a+=1;continue}if(c.startsWith(`${e}=`)){s=c.slice(e.length+1);continue}r.push(c)}return{value:s,rest:r}}function ki(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
137
+ `)}function JE(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="refresh")return{mode:"refresh"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return ZE(e.slice(1));if(e[0]==="connect")return YE(e.slice(1));if(e.includes("--status"))return ki("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return ki("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return ki("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return ki("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return ki("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:s,rest:a}=ze(r,"--pat-token");r=a;let{value:c,rest:f}=ze(r,"--pair-code");r=f;let{value:u,rest:x}=ze(r,"--env");r=x;let{value:h,rest:m}=ze(r,"--handshake-url");r=m;let{value:v,rest:A}=ze(r,"--frontier-url");r=A;let{value:_,rest:b}=ze(r,"--mock-scenario");r=b;let{value:S}=ze(r,"--agent-id");if(!s||!c)return{mode:"help"};let I={mode:"pair",privatecode:s,pairingCode:c};return u&&(I.env=u),h&&(I.handshakeUrl=h),v&&(I.frontierUrl=v),_&&(I.mockScenario=_),S&&(I.agentId=S),I}function ZE(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.startsWith("--"))return{mode:"help"};let s=t.slice(2),{value:a,rest:c}=ze(s,"--caption");s=c;let{value:f,rest:u}=ze(s,"--name");s=u;let{value:x,rest:h}=ze(s,"--agent-id");s=h;let{value:m,rest:v}=ze(s,"--session-id");s=v;let{value:A,rest:_}=ze(s,"--mime");s=_;let b=s.includes("--group-file");s=s.filter(D=>D!=="--group-file");let S=s.includes("--json"),I={mode:"send",kind:e,path:r,json:S};return a&&(I.caption=a),f&&(I.name=f),x&&(I.agentId=x),m&&(I.sessionId=m),b&&(I.groupFile=!0),A&&(I.mimeType=A),I}function YE(t){let e=t,{value:r,rest:s}=ze(e,"--pat-token");e=s;let{value:a,rest:c}=ze(e,"--env");e=c;let{value:f,rest:u}=ze(e,"--handshake-url");e=u;let{value:x,rest:h}=ze(e,"--frontier-url");e=h;let{value:m,rest:v}=ze(e,"--mock-scenario");e=v;let A={mode:"connect"};return r&&(A.privatecode=r),a&&(A.env=a),f&&(A.handshakeUrl=f),x&&(A.frontierUrl=x),m&&(A.mockScenario=m),A}var XE=`
138
138
  coze-bridge - local bridge daemon for cloud Agent Service
139
139
 
140
140
  Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
@@ -201,46 +201,46 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
201
201
 
202
202
  Internal:
203
203
  <node> <entry> --daemon daemon mode (OS supervisor only)
204
- `.trimStart();async function Hh(t=process.argv,e={}){let r=VE(t);switch(r.mode){case"help":return process.stdout.write(YE),0;case"version":return process.stdout.write(`${pr}
205
- `),0;case"daemon":{try{await Ch()}catch(i){return Uh.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return XE(e);case"stop":return QE(e);case"refresh":return e1(e);case"purge":return t1(e);case"service-install":return n1(e);case"service-uninstall":return r1(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),i1(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),s1(r.privatecode,e,i)}case"send":return Ph({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 qh(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 XE(t){let e=t.paths??te(),r=new qt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
206
- `),1;if(i.kind==="stale")return await qh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
207
- `),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
208
- ${JSON.stringify(o.body,null,2)}
209
- `),0}async function QE(t){let e=t.paths??te(),r=new qt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
210
- `),0;if(i.kind==="stale")return await qh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
204
+ `.trimStart();async function Hx(t=process.argv,e={}){let r=JE(t);switch(r.mode){case"help":return process.stdout.write(XE),0;case"version":return process.stdout.write(`${pr}
205
+ `),0;case"daemon":{try{await Rx()}catch(s){return qx.error("daemon start failed",{err:String(s)}),1}return new Promise(()=>{})}case"status":return QE(e);case"stop":return e2(e);case"refresh":return t2(e);case"purge":return n2(e);case"service-install":return r2(e);case"service-uninstall":return i2(e);case"pair":{let s={};return r.env&&(s.env=r.env),r.handshakeUrl&&(s.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(s.frontierUrl=r.frontierUrl),r.mockScenario&&(s.mockScenario=r.mockScenario),s2(r.privatecode,r.pairingCode,e,s,r.agentId)}case"connect":{let s={};return r.env&&(s.env=r.env),r.handshakeUrl&&(s.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(s.frontierUrl=r.frontierUrl),r.mockScenario&&(s.mockScenario=r.mockScenario),o2(r.privatecode,e,s)}case"send":return Lx({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 jx(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 QE(t){let e=t.paths??te(),r=new Ut(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
206
+ `),1;if(s.kind==="stale")return await jx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
207
+ `),1;let a=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
208
+ ${JSON.stringify(a.body,null,2)}
209
+ `),0}async function e2(t){let e=t.paths??te(),r=new Ut(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
210
+ `),0;if(s.kind==="stale")return await jx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
211
211
  `),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
212
- `),0}catch(o){return process.stdout.write(`coze-bridge: stop failed: ${String(o)}
213
- `),1}}async function e1(t){let e=new qt(t.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
214
- `),1;try{let i=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return i.status===200?(process.stdout.write(`coze-bridge: refreshed
215
- ${JSON.stringify(i.body,null,2)}
216
- `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(i.body)}
217
- `),1)}catch(i){return process.stderr.write(`coze-bridge: refresh failed: ${String(i)}
218
- `),1}}async function od(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(()=>(Fh(),zh)),i=e(),o=r();return{platform:i.platform,install:()=>i.install(o),uninstall:()=>i.uninstall(o)}}async function t1(t){let e=new qt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
219
- `);try{await e.request({method:"POST",path:"/shutdown"})}catch(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
220
- `)}await new Promise(l=>setTimeout(l,500))}let i=await od(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
221
- `)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
222
- `)}let o=t.paths??te(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
223
- `)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
212
+ `),0}catch(a){return process.stdout.write(`coze-bridge: stop failed: ${String(a)}
213
+ `),1}}async function t2(t){let e=new Ut(t.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
214
+ `),1;try{let s=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return s.status===200?(process.stdout.write(`coze-bridge: refreshed
215
+ ${JSON.stringify(s.body,null,2)}
216
+ `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(s.body)}
217
+ `),1)}catch(s){return process.stderr.write(`coze-bridge: refresh failed: ${String(s)}
218
+ `),1}}async function s0(t){if(t.supervisor){let c=t.supervisor,f={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:()=>c.install(f),uninstall:()=>c.uninstall(f)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Ux(),Fx)),s=e(),a=r();return{platform:s.platform,install:()=>s.install(a),uninstall:()=>s.uninstall(a)}}async function n2(t){let e=new Ut(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
219
+ `);try{await e.request({method:"POST",path:"/shutdown"})}catch(f){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(f)}
220
+ `)}await new Promise(f=>setTimeout(f,500))}let s=await s0(t);if(s)try{await s.uninstall(),process.stdout.write(`coze-bridge: ${s.platform} supervisor unregistered
221
+ `)}catch(f){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(f)}
222
+ `)}let a=t.paths??te(),{rm:c}=await import("node:fs/promises");try{await c(a.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.bridgeRoot}
223
+ `)}catch(f){return process.stderr.write(`coze-bridge: remove failed: ${String(f)}
224
224
  `),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
225
- `),0}async function n1(t){let e=await od(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
225
+ `),0}async function r2(t){let e=await s0(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
226
226
  `),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
227
227
  `),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
228
- `),1}}async function r1(t){let e=await od(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
228
+ `),1}}async function i2(t){let e=await s0(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
229
229
  `),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
230
- `),1}}async function i1(t,e,r,i={},o){let c=new qt(r.paths),l=r.spawnDaemon??Zc;if(!r.skipDistInstall){let p=await ed({paths:r.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
231
- `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(b=>setTimeout(b,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
230
+ `),1}}async function s2(t,e,r,s={},a){let c=new Ut(r.paths),f=r.spawnDaemon??Jc;if(!r.skipDistInstall){let h=await Qc({paths:r.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
231
+ `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(v=>setTimeout(v,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
232
232
  `)}let u=await c.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
233
- `),await l({paths:r.paths}),u=await jh(c,r.waitTimeoutMs??1e4,r.sleep??Gh),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
234
- `),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 p=await c.request({method:"POST",path:"/pair",body:h,timeoutMs:35e3});if(p.status===200&&p.body?.ok){let w=p.body.agent;return w&&!w.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${w.agentId}): ${w.note}
233
+ `),await f({paths:r.paths}),u=await Gx(c,r.waitTimeoutMs??1e4,r.sleep??Wx),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
234
+ `),1;let x={privatecode:t,pairing_code:e};s.env&&(x.env=s.env),s.handshakeUrl&&(x.handshake_url=s.handshakeUrl),s.frontierUrl&&(x.frontier_url=s.frontierUrl),s.mockScenario&&(x.mock_scenario=s.mockScenario),a&&(x.agent_id=a);try{let h=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(h.status===200&&h.body?.ok){let m=h.body.agent;return m&&!m.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${m.agentId}): ${m.note}
235
235
  `),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"
236
- `),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
237
- `),1}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
238
- `),1}}async function s1(t,e,r={}){let i=e.paths??te(),o=t??await _h(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 qt(e.paths),l=e.spawnDaemon??Zc;if(!e.skipDistInstall){let p=await ed({paths:e.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
239
- `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(b=>setTimeout(b,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
236
+ `),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(h.body)}
237
+ `),1}catch(h){return process.stderr.write(`coze-bridge: pair failed: ${String(h)}
238
+ `),1}}async function o2(t,e,r={}){let s=e.paths??te(),a=t??await bx(s);if(!a)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new Ut(e.paths),f=e.spawnDaemon??Jc;if(!e.skipDistInstall){let h=await Qc({paths:e.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
239
+ `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(v=>setTimeout(v,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
240
240
  `)}let u=await c.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
241
- `),await l({paths:e.paths}),u=await jh(c,e.waitTimeoutMs??1e4,e.sleep??Gh),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
242
- `),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 p=await c.request({method:"POST",path:"/connect",body:h,timeoutMs:35e3});return p.status===200&&p.body?.ok?(process.stdout.write(`coze-bridge: connected (${p.body.note??"ok"})
243
- `),await ki(o,i).catch(w=>Uh.warn("writePatToken after connect failed (ignored)",{err:String(w)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(p.body)}
244
- `),1)}catch(p){return process.stderr.write(`coze-bridge: connect failed: ${String(p)}
245
- `),1}}async function jh(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 Gh(t){return new Promise(e=>setTimeout(e,t))}ee();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&Rd("warn");Hh(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
241
+ `),await f({paths:e.paths}),u=await Gx(c,e.waitTimeoutMs??1e4,e.sleep??Wx),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
242
+ `),1;let x={privatecode:a};r.env&&(x.env=r.env),r.handshakeUrl&&(x.handshake_url=r.handshakeUrl),r.frontierUrl&&(x.frontier_url=r.frontierUrl),r.mockScenario&&(x.mock_scenario=r.mockScenario);try{let h=await c.request({method:"POST",path:"/connect",body:x,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: connected (${h.body.note??"ok"})
243
+ `),await Di(a,s).catch(m=>qx.warn("writePatToken after connect failed (ignored)",{err:String(m)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(h.body)}
244
+ `),1)}catch(h){return process.stderr.write(`coze-bridge: connect failed: ${String(h)}
245
+ `),1}}async function Gx(t,e,r){let s=Date.now()+e;for(;Date.now()<s;){let a=await t.probe(500);if(a.kind==="connected")return a;await r(200)}return t.probe(500)}function Wx(t){return new Promise(e=>setTimeout(e,t))}ee();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&D0("warn");Hx(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
246
246
  `),process.exit(1)});