coze-bridge 0.1.103 → 0.1.104-beta.0

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 +81 -78
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -5,34 +5,34 @@ 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 Kp=Object.create;var _a=Object.defineProperty;var $p=Object.getOwnPropertyDescriptor;var Vp=Object.getOwnPropertyNames;var Jp=Object.getPrototypeOf,Zp=Object.prototype.hasOwnProperty;var le=(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 Ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var se=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ya=(t,e)=>{for(var r in e)_a(t,r,{get:e[r],enumerable:!0})},Xp=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vp(e))!Zp.call(t,o)&&o!==r&&_a(t,o,{get:()=>e[o],enumerable:!(i=$p(e,o))||i.enumerable});return t};var It=(t,e,r)=>(r=t!=null?Kp(Jp(t)):{},Xp(e||!t||!t.__esModule?_a(r,"default",{value:t,enumerable:!0}):r,t));function Ke(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var ir=Ye(()=>{"use strict"});import{createWriteStream as Yp,mkdirSync as Qp,readdirSync as eg,unlinkSync as tg}from"node:fs";import{join as al}from"node:path";function Pn(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function sr(t,e){return`${t}-${e}.log`}function ba(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function ng(t,e,r){let i=c=>{let[l,u,x]=c.split("-").map(Number);return Date.UTC(l??0,(u??1)-1,x??1)};return Math.floor((i(e)-i(t))/864e5)>r}function ss(t,e,r,i){let o;try{o=eg(t)}catch{return}for(let c of o){let l=ba(c,e);if(l&&ng(l,r,i))try{tg(al(t,c))}catch{}}}var Qr,Ea=Ye(()=>{"use strict";Qr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>Pn(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let r=this.clock();r!==this.currentDate&&this.rotate(r),this.stream?.write(e)}rotate(e){this.stream?.end();try{Qp(this.dir,{recursive:!0});let r=Yp(al(this.dir,sr(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
8
+ var eg=Object.create;var ya=Object.defineProperty;var tg=Object.getOwnPropertyDescriptor;var ng=Object.getOwnPropertyNames;var rg=Object.getPrototypeOf,ig=Object.prototype.hasOwnProperty;var fe=(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 Ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var ce=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ea=(t,e)=>{for(var r in e)ya(t,r,{get:e[r],enumerable:!0})},sg=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ng(e))!ig.call(t,o)&&o!==r&&ya(t,o,{get:()=>e[o],enumerable:!(i=tg(e,o))||i.enumerable});return t};var Ft=(t,e,r)=>(r=t!=null?eg(rg(t)):{},sg(e||!t||!t.__esModule?ya(r,"default",{value:t,enumerable:!0}):r,t));function We(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var nr=Ye(()=>{"use strict"});import{createWriteStream as og,mkdirSync as ag,readdirSync as cg,unlinkSync as dg}from"node:fs";import{join as ll}from"node:path";function kn(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function rr(t,e){return`${t}-${e}.log`}function ba(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function lg(t,e,r){let i=c=>{let[l,u,x]=c.split("-").map(Number);return Date.UTC(l??0,(u??1)-1,x??1)};return Math.floor((i(e)-i(t))/864e5)>r}function os(t,e,r,i){let o;try{o=cg(t)}catch{return}for(let c of o){let l=ba(c,e);if(l&&lg(l,r,i))try{dg(ll(t,c))}catch{}}}var Yr,va=Ye(()=>{"use strict";Yr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>kn(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let r=this.clock();r!==this.currentDate&&this.rotate(r),this.stream?.write(e)}rotate(e){this.stream?.end();try{ag(this.dir,{recursive:!0});let r=og(ll(this.dir,rr(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
9
9
  `)),this.stream=r}catch(r){process.stderr.write(`[log-sink] rotate failed: ${String(r)}
10
- `),this.stream=void 0;return}this.currentDate!==void 0&&ss(this.dir,this.prefix,e,this.opts.retentionDays),this.currentDate=e}close(){this.stream?.end(),this.stream=void 0,this.currentDate=void 0}}});import{appendFileSync as rg,mkdirSync as ig}from"node:fs";import{join as sg}from"node:path";function dl(t){let e=t.retentionDays??cg,r=t.clock??(()=>Pn(new Date));as={bridgeSink:new Qr(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new Qr(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();ss(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])ss(t.agentLogsDir(o),"agent",i,e)}function dg(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function ll(t){va=t}function ul(t){return or[va]<=or[t]}function fl(t,e){let r=or[t];return r===void 0?!0:r>=or[e]}function cs(t){cl={...t}}function xl(t){let e=(u,x=2)=>String(u).padStart(x,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),l=e(o%60);return`${Pn(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${l}`}function Tt(t,e,r,i,o){try{let c=`${JSON.stringify({ts:xl(new Date),level:e,module:r,msg:i,...o})}
11
- `;ig(t,{recursive:!0}),rg(sg(t,sr("bridge",Pn(new Date))),c)}catch{}}function lg(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function os(t,e,r,i,o){if(or[t]<or[va])return;let c=`${JSON.stringify({ts:xl(new Date),level:t,module:e,msg:r,...cl,...i})}
12
- `;if(as){let l=lg(o,i),u=l?dg(as,l):as.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?ag.write(c):og.write(c)}function q(t,e){return{debug:(r,i)=>os("debug",t,r,i,e),info:(r,i)=>os("info",t,r,i,e),warn:(r,i)=>os("warn",t,r,i,e),error:(r,i)=>os("error",t,r,i,e),child:r=>q(`${t}.${r}`,e),forAgent:r=>q(t,r)}}var or,va,og,ag,cl,cg,as,te=Ye(()=>{"use strict";ir();Ea();or={debug:10,info:20,warn:30,error:40},va=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),og=process.stdout,ag=process.stderr,cl={},cg=Ke("COZE_BRIDGE_LOG_RETENTION_DAYS",30),as=null});var C,Ve=Ye(()=>{"use strict";C=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var ml={};ya(ml,{ACP_WRAPPER_NPM_PACKAGES:()=>ti,_resetAcpInstallerForTests:()=>gg,_setBinaryPathCacheForTests:()=>mg,buildAcpSpawn:()=>ni,ensureAcpInstalled:()=>ar,getAcpBinaryPath:()=>ds,pickWhichLine:()=>Ia,probeAcpVersion:()=>pg,resolveAcpCommand:()=>gl});import{readFileSync as hl}from"node:fs";import{createRequire as ug}from"node:module";import{dirname as fg,resolve as xg}from"node:path";function Ia(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]}function hg(t){let e=pl.resolve(`${t.npmPackage}/package.json`),r=fg(e),i=JSON.parse(hl(e,"utf8")),o=typeof i.bin=="string"?i.bin:i.bin?.[t.binary];if(!o)throw new Error(`${t.npmPackage} package.json \u7F3A bin[${t.binary}]`);return xg(r,o)}async function ar(t,e){let r=Aa[t];if(!r)throw new C("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=ei.get(t);if(i)return i;try{let o=hg(r);return ei.set(t,o),Sa.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw Sa.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:r.npmPackage,err:String(o)}),new C("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${r.npmPackage} (framework=${t})`,"\u8BE5 wrapper \u968F coze-bridge \u4E00\u8D77\u5B89\u88C5 (\u56FA\u5316\u5230 ~/.coze/bridge/lib/node_modules)\u3002","\u8BF7\u91CD\u8DD1 `coze-bridge pair` / `connect` \u89E6\u53D1\u56FA\u5316\u5B89\u88C5; \u82E5\u4ECD\u5931\u8D25, \u68C0\u67E5\u7F51\u7EDC / npm \u7F13\u5B58\u3002"].join(`
13
- `),{cause:o})}}async function pg(t){let e=Aa[t];if(e)try{let r=pl.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(hl(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){Sa.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function ds(t){return ei.get(t)}function gl(t,e){if(e)return e;let r=ds(t);if(!r)throw new C("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function ni(t,e,r){if(e)return{command:e,args:[...r]};let i=gl(t);return{command:process.execPath,args:[i,...r]}}function gg(){ei.clear()}function mg(t,e){ei.set(t,e)}var Sa,Aa,ti,pl,ei,on=Ye(()=>{"use strict";Ve();te();Sa=q("agents.acp-installer"),Aa={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},ti=Object.values(Aa).filter(t=>t!==void 0).map(t=>t.npmPackage),pl=ug(import.meta.url),ei=new Map});import{chmod as _g,mkdir as yg,readFile as bg,rename as Eg,rm as vg,writeFile as Sg}from"node:fs/promises";import{dirname as Ag}from"node:path";async function cr(t){try{let e=await bg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function an(t,e,r){await yg(Ag(t),{recursive:!0});let i=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{await Sg(i,e,{encoding:"utf8",mode:r?.mode}),await Eg(i,t),r?.mode!==void 0&&await _g(t,r.mode)}catch(o){throw await vg(i,{force:!0}).catch(()=>{}),o}}async function dr(t,e,r){await an(t,`${JSON.stringify(e,null,2)}
14
- `,r)}var cn=Ye(()=>{"use strict"});import{promises as yl,readdirSync as Ig}from"node:fs";import{homedir as Tg}from"node:os";import{sep as Dg,join as De,resolve as bl}from"node:path";function Y(t){let e=t??Tg(),r=De(e,".coze"),i=De(r,"bridge"),o=De(i,"lib"),c=De(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:De(o,"index.js"),binDir:De(i,"bin"),pidFile:De(i,"bridge.pid"),portFile:De(i,"bridge.port"),tokenFile:De(i,"bridge.token"),patTokenFile:De(i,"pat-token"),agentEnvFile:De(i,"agent-env.json"),logFile:De(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:De(c,"daemon-stdio.log"),installLock:De(i,"install.lock"),configFile:De(i,"config.json"),agentsRoot:De(r,"agents")}}function Qe(t,e=Y()){let r=De(e.agentsRoot,t);return{root:r,config:De(r,"config.json"),workspace:De(r,"workspace"),logs:De(r,"logs")}}function ls(t=Y()){try{return Ig(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function ri(t,e){let r=await yl.realpath(bl(t)).catch(()=>null);if(!r)return!1;let i=await yl.realpath(bl(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+Dg)}var Oe=Ye(()=>{"use strict"});var xs={};ya(xs,{AGENT_CONFIG_FILE_MODE:()=>us,enforceAgentConfigMode:()=>kg,loadAgentConfig:()=>He,persistAgentSessions:()=>ii,persistAgentSkills:()=>fs,saveAgentConfig:()=>et});import{chmod as Cg,stat as Rg}from"node:fs/promises";function He(t,e){return cr(Qe(t,e).config)}function et(t,e){return dr(Qe(t.agentId,e).config,t,{mode:us})}async function kg(t,e){if(process.platform==="win32")return;let r=Qe(t,e).config;try{let i=await Rg(r);if(!i.isFile())return;let o=i.mode&511;o!==us&&(await Cg(r,us),El.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;El.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ii(t,e,r){let i=await He(t,r);i&&(i.sessions=Object.fromEntries(e),await et(i,r))}async function fs(t,e,r){let i=await He(t,r);i&&(i.skills=e,await et(i,r))}var El,us,dn=Ye(()=>{"use strict";cn();te();Oe();El=q("agent-config"),us=384});var Da=se((o2,Il)=>{Il.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 ps=se(Dl=>{var Tl={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 Mg(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(Tl))Dl[t]=Mg(Tl[t])});var Ol=se((c2,Pl)=>{var Bg=le("fs"),Le=le("path"),Cl=Da(),zg=ps(),Fg=typeof process=="object"&&process.platform==="win32",Rl=t=>typeof t=="object"&&t!==null,kl=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 be(t){this.sep=Le.sep,this.fs=Bg,Rl(t)&&Rl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Pl.exports=be;be.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 zg.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};be.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=Le.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};be.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,x){if(l&&x.isDirectory())return o(!1);var g=Le.dirname(t);c.fs.exists(g,function(w){w||c.makeDir(g),c.fs.open(t,"w",438,function(E,S){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):S?c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};be.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 x=Le.join(i,u),g=e.fs.statSync(x);(!o||o.test(x))&&l.push(Le.normalize(x)+(g.isDirectory()?e.sep:"")),g.isDirectory()&&c&&(l=l.concat(r(x,o,c)))}),l}return r(t,void 0,!0)};be.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=Le.join(t,u),r.fs.stat(u,function(x,g){if(x)return e(x);g&&(i.push(Le.normalize(u)+(g.isDirectory()?r.sep:"")),g.isDirectory()?r.findFilesAsync(u,function(w,E){if(w)return e(w);i=i.concat(E),--l||e(null,i)}):--l||e(null,i))})})})};be.prototype.getAttributes=function(){};be.prototype.setAttributes=function(){};be.crc32update=function(t,e){return kl[(t^e)&255]^t>>>8};be.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=be.crc32update(r,t[i++]);return~r>>>0};be.methodToString=function(t){switch(t){case Cl.STORED:return"STORED ("+t+")";case Cl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};be.canonical=function(t){if(!t)return"";let e=Le.posix.normalize("/"+t.split("\\").join("/"));return Le.join(".",e)};be.zipnamefix=function(t){if(!t)return"";let e=Le.posix.normalize("/"+t.split("\\").join("/"));return Le.posix.join(".",e)};be.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]};be.sanitize=function(t,e){t=Le.resolve(Le.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Le.normalize(Le.join(t,r.slice(i,o).join(Le.sep)));if(c.indexOf(t)===0)return c}return Le.normalize(Le.join(t,Le.basename(e)))};be.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};be.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};be.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)};be.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};be.isWin=Fg;be.crcTable=kl});var Nl=se((d2,Ll)=>{var Ug=le("path");Ll.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=Ug.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 Bl=se((l2,Ml)=>{Ml.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var fr=se((u2,ur)=>{ur.exports=Ol();ur.exports.Constants=Da();ur.exports.Errors=ps();ur.exports.FileAttr=Nl();ur.exports.decoder=Bl()});var Fl=se((f2,zl)=>{var ln=fr(),G=ln.Constants;zl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,x=0,g=0,w=0,E=0,S=0,y=0,v=0;t|=ln.isWin?2560:768,r|=G.FLG_EFS;let A={extraLen:0},T=b=>Math.max(0,b)>>>0,D=b=>Math.max(0,b)&65535,P=b=>Math.max(0,b)&255;return o=ln.fromDate2DOS(new Date),{get made(){return t},set made(b){t=b},get version(){return e},set version(b){e=b},get flags(){return r},set flags(b){r=b},get flags_efs(){return(r&G.FLG_EFS)>0},set flags_efs(b){b?r|=G.FLG_EFS:r&=~G.FLG_EFS},get flags_desc(){return(r&G.FLG_DESC)>0},set flags_desc(b){b?r|=G.FLG_DESC:r&=~G.FLG_DESC},get method(){return i},set method(b){switch(b){case G.STORED:this.version=10;case G.DEFLATED:default:this.version=20}i=b},get time(){return ln.fromDOS2Date(this.timeval)},set time(b){b=new Date(b),this.timeval=ln.fromDate2DOS(b)},get timeval(){return o},set timeval(b){o=T(b)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(b){c=T(b)},get compressedSize(){return l},set compressedSize(b){l=T(b)},get size(){return u},set size(b){u=T(b)},get fileNameLength(){return x},set fileNameLength(b){x=b},get extraLength(){return g},set extraLength(b){g=b},get extraLocalLength(){return A.extraLen},set extraLocalLength(b){A.extraLen=b},get commentLength(){return w},set commentLength(b){w=b},get diskNumStart(){return E},set diskNumStart(b){E=T(b)},get inAttr(){return S},set inAttr(b){S=T(b)},get attr(){return y},set attr(b){y=T(b)},get fileAttr(){return(y||0)>>16&4095},get offset(){return v},set offset(b){v=T(b)},get encrypted(){return(r&G.FLG_ENC)===G.FLG_ENC},get centralHeaderSize(){return G.CENHDR+x+g+w},get realDataOffset(){return v+G.LOCHDR+A.fnameLen+A.extraLen},get localHeader(){return A},loadLocalHeaderFromBinary:function(b){var k=b.slice(v,v+G.LOCHDR);if(k.readUInt32LE(0)!==G.LOCSIG)throw ln.Errors.INVALID_LOC();A.version=k.readUInt16LE(G.LOCVER),A.flags=k.readUInt16LE(G.LOCFLG),A.flags_desc=(A.flags&G.FLG_DESC)>0,A.method=k.readUInt16LE(G.LOCHOW),A.time=k.readUInt32LE(G.LOCTIM),A.crc=k.readUInt32LE(G.LOCCRC),A.compressedSize=k.readUInt32LE(G.LOCSIZ),A.size=k.readUInt32LE(G.LOCLEN),A.fnameLen=k.readUInt16LE(G.LOCNAM),A.extraLen=k.readUInt16LE(G.LOCEXT);let O=v+G.LOCHDR+A.fnameLen,U=O+A.extraLen;return b.slice(O,U)},loadFromBinary:function(b){if(b.length!==G.CENHDR||b.readUInt32LE(0)!==G.CENSIG)throw ln.Errors.INVALID_CEN();t=b.readUInt16LE(G.CENVEM),e=b.readUInt16LE(G.CENVER),r=b.readUInt16LE(G.CENFLG),i=b.readUInt16LE(G.CENHOW),o=b.readUInt32LE(G.CENTIM),c=b.readUInt32LE(G.CENCRC),l=b.readUInt32LE(G.CENSIZ),u=b.readUInt32LE(G.CENLEN),x=b.readUInt16LE(G.CENNAM),g=b.readUInt16LE(G.CENEXT),w=b.readUInt16LE(G.CENCOM),E=b.readUInt16LE(G.CENDSK),S=b.readUInt16LE(G.CENATT),y=b.readUInt32LE(G.CENATX),v=b.readUInt32LE(G.CENOFF)},localHeaderToBinary:function(){var b=Buffer.alloc(G.LOCHDR);return b.writeUInt32LE(G.LOCSIG,0),b.writeUInt16LE(e,G.LOCVER),b.writeUInt16LE(r,G.LOCFLG),b.writeUInt16LE(i,G.LOCHOW),b.writeUInt32LE(o,G.LOCTIM),b.writeUInt32LE(c,G.LOCCRC),b.writeUInt32LE(l,G.LOCSIZ),b.writeUInt32LE(u,G.LOCLEN),b.writeUInt16LE(x,G.LOCNAM),b.writeUInt16LE(A.extraLen,G.LOCEXT),b},centralHeaderToBinary:function(){var b=Buffer.alloc(G.CENHDR+x+g+w);return b.writeUInt32LE(G.CENSIG,0),b.writeUInt16LE(t,G.CENVEM),b.writeUInt16LE(e,G.CENVER),b.writeUInt16LE(r,G.CENFLG),b.writeUInt16LE(i,G.CENHOW),b.writeUInt32LE(o,G.CENTIM),b.writeUInt32LE(c,G.CENCRC),b.writeUInt32LE(l,G.CENSIZ),b.writeUInt32LE(u,G.CENLEN),b.writeUInt16LE(x,G.CENNAM),b.writeUInt16LE(g,G.CENEXT),b.writeUInt16LE(w,G.CENCOM),b.writeUInt16LE(E,G.CENDSK),b.writeUInt16LE(S,G.CENATT),b.writeUInt32LE(y,G.CENATX),b.writeUInt32LE(v,G.CENOFF),b},toJSON:function(){let b=function(k){return k+" bytes"};return{made:t,version:e,flags:r,method:ln.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:b(l),size:b(u),fileNameLength:b(x),extraLength:b(g),commentLength:b(w),diskNumStart:E,inAttr:S,attr:y,offset:v,centralHeaderSize:b(G.CENHDR+x+g+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Gl=se((x2,Ul)=>{var xr=fr(),we=xr.Constants;Ul.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return we.ENDHDR+o},loadFromBinary:function(c){if((c.length!==we.ENDHDR||c.readUInt32LE(0)!==we.ENDSIG)&&(c.length<we.ZIP64HDR||c.readUInt32LE(0)!==we.ZIP64SIG))throw xr.Errors.INVALID_END();c.readUInt32LE(0)===we.ENDSIG?(t=c.readUInt16LE(we.ENDSUB),e=c.readUInt16LE(we.ENDTOT),r=c.readUInt32LE(we.ENDSIZ),i=c.readUInt32LE(we.ENDOFF),o=c.readUInt16LE(we.ENDCOM)):(t=xr.readBigUInt64LE(c,we.ZIP64SUB),e=xr.readBigUInt64LE(c,we.ZIP64TOT),r=xr.readBigUInt64LE(c,we.ZIP64SIZE),i=xr.readBigUInt64LE(c,we.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(we.ENDHDR+o);return c.writeUInt32LE(we.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,we.ENDSUB),c.writeUInt16LE(e,we.ENDTOT),c.writeUInt32LE(r,we.ENDSIZ),c.writeUInt32LE(i,we.ENDOFF),c.writeUInt16LE(o,we.ENDCOM),c.fill(" ",we.ENDHDR),c},toJSON:function(){let c=function(l,u){let x=l.toString(16).toUpperCase();for(;x.length<u;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ra=se(Ca=>{Ca.EntryHeader=Fl();Ca.MainHeader=Gl()});var jl=se((p2,ql)=>{ql.exports=function(t){var e=le("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),x=0;u.fill(0);for(var g=0;g<c.length;g++){var w=c[g];w.copy(u,x),x+=w.length}i&&i(u)}),o.end(t)}}}});var Wl=se((g2,Hl)=>{var Gg=+(process.versions?process.versions.node:"").split(".")[0]||0;Hl.exports=function(t,e){var r=le("zlib");let i=Gg>=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(x){l.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),g=0;x.fill(0);for(var w=0;w<l.length;w++){var E=l[w];E.copy(x,g),g+=E.length}o&&o(x)}),c.end(t)}}}});var Zl=se((m2,Jl)=>{"use strict";var{randomFillSync:Kl}=le("crypto"),qg=ps(),jg=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}),Vl=(t,e)=>Math.imul(t,e)>>>0,$l=(t,e)=>jg[(t^e)&255]^t>>>8,si=()=>typeof Kl=="function"?Kl(Buffer.alloc(12)):si.node();si.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 gs={genSalt:si};function ms(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])}ms.prototype.updateKeys=function(t){let e=this.keys;return e[0]=$l(e[0],t),e[1]+=e[0]&255,e[1]=Vl(e[1],134775813)+1,e[2]=$l(e[2],e[1]>>>24),t};ms.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Vl(t,t^1)>>8&255};function Hg(t){let e=new ms(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 Wg(t){let e=new ms(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 Kg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Hg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw qg.WRONG_PASSWORD();return i(t.slice(12))}function $g(t){Buffer.isBuffer(t)&&t.length>=12?gs.genSalt=function(){return t.slice(0,12)}:t==="node"?gs.genSalt=si.node:gs.genSalt=si}function Vg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Wg(r),c=gs.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)}Jl.exports={decrypt:Kg,encrypt:Vg,_salter:$g}});var Xl=se(ws=>{ws.Deflater=jl();ws.Inflater=Wl();ws.ZipCrypto=Zl()});var Pa=se((_2,Yl)=>{var oe=fr(),Jg=Ra(),Ee=oe.Constants,ka=Xl();Yl.exports=function(t,e){var r=new Jg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),x=Buffer.alloc(0),g=!0;let w=t,E=typeof w.decoder=="object"?w.decoder:oe.decoder;g=E.hasOwnProperty("efs")?E.efs:!1;function S(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function y(b){if(!r.flags_desc&&!r.localHeader.flags_desc){if(oe.crc32(b)!==r.localHeader.crc)return!1}else{let k={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==Ee.LOCSIG||e.readUInt32LE(O)==Ee.CENSIG)throw oe.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==Ee.EXTSIG)k.crc=e.readUInt32LE(O+Ee.EXTCRC),k.compressedSize=e.readUInt32LE(O+Ee.EXTSIZ),k.size=e.readUInt32LE(O+Ee.EXTLEN);else if(e.readUInt16LE(O+12)===19280)k.crc=e.readUInt32LE(O+Ee.EXTCRC-4),k.compressedSize=e.readUInt32LE(O+Ee.EXTSIZ-4),k.size=e.readUInt32LE(O+Ee.EXTLEN-4);else throw oe.Errors.DESCRIPTOR_UNKNOWN();if(k.compressedSize!==r.compressedSize||k.size!==r.size||k.crc!==r.crc)throw oe.Errors.DESCRIPTOR_FAULTY();if(oe.crc32(b)!==k.crc)return!1}return!0}function v(b,k,O){if(typeof k>"u"&&typeof b=="string"&&(O=b,b=void 0),c)return b&&k&&k(Buffer.alloc(0),oe.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var U=S();if(U.length===0)return b&&k&&k(U),U;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw oe.Errors.INVALID_PASS_PARAM();U=ka.ZipCrypto.decrypt(U,r,O)}var B=Buffer.alloc(r.size);switch(r.method){case oe.Constants.STORED:if(U.copy(B),y(B))return b&&k&&k(B),B;throw b&&k&&k(B,oe.Errors.BAD_CRC()),oe.Errors.BAD_CRC();case oe.Constants.DEFLATED:var J=new ka.Inflater(U,r.size);if(b)J.inflateAsync(function($){$.copy($,0),k&&(y($)?k($):k($,oe.Errors.BAD_CRC()))});else{if(J.inflate(B).copy(B,0),!y(B))throw oe.Errors.BAD_CRC(`"${E.decode(i)}"`);return B}break;default:throw b&&k&&k(Buffer.alloc(0),oe.Errors.UNKNOWN_METHOD()),oe.Errors.UNKNOWN_METHOD()}}function A(b,k){if((!l||!l.length)&&Buffer.isBuffer(e))return b&&k&&k(S()),S();if(l.length&&!c){var O;switch(r.method){case oe.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(l.length),l.copy(O),b&&k&&k(O),O;default:case oe.Constants.DEFLATED:var U=new ka.Deflater(l);if(b)U.deflateAsync(function(J){O=Buffer.alloc(J.length),r.compressedSize=J.length,J.copy(O),k&&k(O)});else{var B=U.deflate();return r.compressedSize=B.length,B}U=null;break}}else if(b&&k)k(Buffer.alloc(0));else return Buffer.alloc(0)}function T(b,k){return oe.readBigUInt64LE(b,k)}function D(b){try{for(var k=0,O,U,B;k+4<b.length;)O=b.readUInt16LE(k),k+=2,U=b.readUInt16LE(k),k+=2,B=b.slice(k,k+U),k+=U,Ee.ID_ZIP64===O&&P(B)}catch{throw oe.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(b){var k,O,U,B;b.length>=Ee.EF_ZIP64_SCOMP&&(k=T(b,Ee.EF_ZIP64_SUNCOMP),r.size===Ee.EF_ZIP64_OR_32&&(r.size=k)),b.length>=Ee.EF_ZIP64_RHO&&(O=T(b,Ee.EF_ZIP64_SCOMP),r.compressedSize===Ee.EF_ZIP64_OR_32&&(r.compressedSize=O)),b.length>=Ee.EF_ZIP64_DSN&&(U=T(b,Ee.EF_ZIP64_RHO),r.offset===Ee.EF_ZIP64_OR_32&&(r.offset=U)),b.length>=Ee.EF_ZIP64_DSN+4&&(B=b.readUInt32LE(Ee.EF_ZIP64_DSN),r.diskNumStart===Ee.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return E.decode(i)},get rawEntryName(){return i},set entryName(b){i=oe.toBuffer(b,E.encode);var k=i[i.length-1];c=k===47||k===92,r.fileNameLength=i.length},get efs(){return typeof g=="function"?g(this.entryName):g},get extra(){return u},set extra(b){u=b,r.extraLength=b.length,D(b)},get comment(){return E.decode(o)},set comment(b){if(o=oe.toBuffer(b,E.encode),r.commentLength=o.length,o.length>65535)throw oe.Errors.COMMENT_TOO_LONG()},get name(){var b=E.decode(i);return c?b.substr(b.length-1).split("/").pop():b.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return A(!1,null)},getCompressedDataAsync:function(b){A(!0,b)},setData:function(b){l=oe.toBuffer(b,oe.decoder.encode),!c&&l.length?(r.size=l.length,r.method=oe.Constants.DEFLATED,r.crc=oe.crc32(b),r.changed=!0):r.method=oe.Constants.STORED},getData:function(b){return r.changed?l:v(!1,null,b)},getDataAsync:function(b,k){r.changed?b(l):v(!0,b,k)},set attr(b){r.attr=b},get attr(){return r.attr},set header(b){r.loadFromBinary(b)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var b=r.centralHeaderToBinary(),k=oe.Constants.CENHDR;return i.copy(b,k),k+=i.length,u.copy(b,k),k+=r.extraLength,o.copy(b,k),b},packLocalHeader:function(){let b=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let k=r.localHeaderToBinary(),O=Buffer.alloc(k.length+i.length+r.extraLocalLength);return k.copy(O,b),b+=k.length,i.copy(O,b),b+=i.length,x.copy(O,b),b+=x.length,O},toJSON:function(){let b=function(k){return"<"+(k&&k.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:b(e),data:b(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var tu=se((y2,eu)=>{var Ql=Pa(),Zg=Ra(),We=fr();eu.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Zg.MainHeader,l=!1,u=null;let x=new Set,g=e,{noSort:w,decoder:E}=g;t?v(g.readEntries):l=!0;function S(){let T=new Set;for(let D of Object.keys(i)){let P=D.split("/");if(P.pop(),!!P.length)for(let b=0;b<P.length;b++){let k=P.slice(0,b+1).join("/")+"/";T.add(k)}}for(let D of T)if(!(D in i)){let P=new Ql(g);P.entryName=D,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,x.add(P)}}function y(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/We.Constants.CENHDR)throw We.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var T=c.offset,D=0;D<r.length;D++){var P=T,b=new Ql(g,t);b.header=t.slice(P,P+=We.Constants.CENHDR),b.entryName=t.slice(P,P+=b.header.fileNameLength),b.header.extraLength&&(b.extra=t.slice(P,P+=b.header.extraLength)),b.header.commentLength&&(b.comment=t.slice(P,P+b.header.commentLength)),T+=b.header.centralHeaderSize,r[D]=b,i[b.entryName]=b}x.clear(),S()}function v(T){var D=t.length-We.Constants.ENDHDR,P=Math.max(0,D-65535),b=P,k=t.length,O=-1,U=0;for(typeof g.trailingSpace=="boolean"&&g.trailingSpace&&(P=0),D;D>=b;D--)if(t[D]===80){if(t.readUInt32LE(D)===We.Constants.ENDSIG){O=D,U=D,k=D+We.Constants.ENDHDR,b=D-We.Constants.END64HDR;continue}if(t.readUInt32LE(D)===We.Constants.END64SIG){b=P;continue}if(t.readUInt32LE(D)===We.Constants.ZIP64SIG){O=D,k=D+We.readBigUInt64LE(t,D+We.Constants.ZIP64SIZE)+We.Constants.ZIP64LEAD;break}}if(O==-1)throw We.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,k)),c.commentLength&&(o=t.slice(U+We.Constants.ENDHDR)),T&&y()}function A(){r.length>1&&!w&&r.sort((T,D)=>T.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return l||y(),r.filter(T=>!x.has(T))},get comment(){return E.decode(o)},set comment(T){o=We.toBuffer(T,E.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(T){this.entries.forEach(T)},getEntry:function(T){return l||y(),i[T]||null},setEntry:function(T){l||y(),r.push(T),i[T.entryName]=T,c.totalEntries=r.length},deleteFile:function(T,D=!0){l||y();let P=i[T];this.getEntryChildren(P,D).map(k=>k.entryName).forEach(this.deleteEntry)},deleteEntry:function(T){l||y();let D=i[T],P=r.indexOf(D);P>=0&&(r.splice(P,1),delete i[T],c.totalEntries=r.length)},getEntryChildren:function(T,D=!0){if(l||y(),typeof T=="object")if(T.isDirectory&&D){let P=[],b=T.entryName;for(let k of r)k.entryName.startsWith(b)&&P.push(k);return P}else return[T];return[]},getChildCount:function(T){if(T&&T.isDirectory){let D=this.getEntryChildren(T);return D.includes(T)?D.length-1:D.length}return 0},compressToBuffer:function(){l||y(),A();let T=[],D=[],P=0,b=0;c.size=0,c.offset=0;let k=0;for(let B of this.entries){let J=B.getCompressedData();B.header.offset=b;let $=B.packLocalHeader(),re=$.length+J.length;b+=re,T.push($),T.push(J);let X=B.packCentralHeader();D.push(X),c.size+=X.length,P+=re+X.length,k++}P+=c.mainHeaderSize,c.offset=b,c.totalEntries=k,b=0;let O=Buffer.alloc(P);for(let B of T)B.copy(O,b),b+=B.length;for(let B of D)B.copy(O,b),b+=B.length;let U=c.toBinary();return o&&o.copy(U,We.Constants.ENDHDR),U.copy(O,b),t=O,l=!1,O},toAsyncBuffer:function(T,D,P,b){try{l||y(),A();let k=[],O=[],U=0,B=0,J=0;c.size=0,c.offset=0;let $=function(re){if(re.length>0){let X=re.shift(),Se=X.entryName+X.extra.toString();P&&P(Se),X.getCompressedDataAsync(function(pe){b&&b(Se),X.header.offset=B;let L=X.packLocalHeader(),j=L.length+pe.length;B+=j,k.push(L),k.push(pe);let K=X.packCentralHeader();O.push(K),c.size+=K.length,U+=j+K.length,J++,$(re)})}else{U+=c.mainHeaderSize,c.offset=B,c.totalEntries=J,B=0;let X=Buffer.alloc(U);k.forEach(function(pe){pe.copy(X,B),B+=pe.length}),O.forEach(function(pe){pe.copy(X,B),B+=pe.length});let Se=c.toBinary();o&&o.copy(Se,We.Constants.ENDHDR),Se.copy(X,B),t=X,l=!1,T(X)}};$(Array.from(this.entries))}catch(k){D(k)}}}}});var iu=se((b2,ru)=>{var ye=fr(),_e=le("path"),Xg=Pa(),Yg=tu(),On=(...t)=>ye.findLast(t,e=>typeof e=="boolean"),nu=(...t)=>ye.findLast(t,e=>typeof e=="string"),Qg=(...t)=>ye.findLast(t,e=>typeof e=="function"),em={noSort:!1,readEntries:!1,method:ye.Constants.NONE,fs:null};ru.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),em);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=ye.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new ye(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=ye.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=ye.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw ye.Errors.INVALID_FILENAME();let c=new Yg(r,i),{canonical:l,sanitize:u,zipnamefix:x}=ye;function g(y){if(y&&c){var v;if(typeof y=="string"&&(v=c.getEntry(_e.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(v=c.getEntry(y.entryName)),v)return v}return null}function w(y){let{join:v,normalize:A,sep:T}=_e.posix;return v(_e.isAbsolute(y)?"/":".",A(T+y.split("\\").join(T)+T))}function E(y){return y instanceof RegExp?(function(v){return function(A){return v.test(A)}})(y):typeof y!="function"?()=>!0:y}let S=(y,v)=>{let A=v.slice(-1);return A=A===o.sep?o.sep:"",_e.relative(y,v)+A};return{readFile:function(y,v){var A=g(y);return A&&A.getData(v)||null},childCount:function(y){let v=g(y);if(v)return c.getChildCount(v)},readFileAsync:function(y,v){var A=g(y);A?A.getDataAsync(v):v(null,"getEntry failed for:"+y)},readAsText:function(y,v){var A=g(y);if(A){var T=A.getData();if(T&&T.length)return T.toString(v||"utf8")}return""},readAsTextAsync:function(y,v,A){var T=g(y);T?T.getDataAsync(function(D,P){if(P){v(D,P);return}D&&D.length?v(D.toString(A||"utf8")):v("")}):v("")},deleteFile:function(y,v=!0){var A=g(y);A&&c.deleteFile(A.entryName,v)},deleteEntry:function(y){var v=g(y);v&&c.deleteEntry(v.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,v){var A=g(y);A&&(A.comment=v)},getZipEntryComment:function(y){var v=g(y);return v&&v.comment||""},updateFile:function(y,v){var A=g(y);A&&A.setData(v)},addLocalFile:function(y,v,A,T){if(o.fs.existsSync(y)){v=v?w(v):"";let D=_e.win32.basename(_e.win32.normalize(y));v+=A||D;let P=o.fs.statSync(y),b=P.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);P.isDirectory()&&(v+=o.sep),this.addFile(v,b,T,P)}else throw ye.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,v){y=typeof y=="object"?y:{localPath:y};let A=_e.resolve(y.localPath),{comment:T}=y,{zipPath:D,zipName:P}=y,b=this;o.fs.stat(A,function(k,O){if(k)return v(k,!1);D=D?w(D):"";let U=_e.win32.basename(_e.win32.normalize(A));if(D+=P||U,O.isFile())o.fs.readFile(A,function(B,J){return B?v(B,!1):(b.addFile(D,J,T,O),setImmediate(v,void 0,!0))});else if(O.isDirectory())return D+=o.sep,b.addFile(D,Buffer.alloc(0),T,O),setImmediate(v,void 0,!0)})},addLocalFolder:function(y,v,A){if(A=E(A),v=v?w(v):"",y=_e.normalize(y),o.fs.existsSync(y)){let T=o.findFiles(y),D=this;if(T.length)for(let P of T){let b=_e.join(v,S(y,P));A(b)&&D.addLocalFile(P,_e.dirname(b))}}else throw ye.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,v,A,T){T=E(T),A=A?w(A):"",y=_e.normalize(y);var D=this;o.fs.open(y,"r",function(P){if(P&&P.code==="ENOENT")v(void 0,ye.Errors.FILE_NOT_FOUND(y));else if(P)v(void 0,P);else{var b=o.findFiles(y),k=-1,O=function(){if(k+=1,k<b.length){var U=b[k],B=S(y,U).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),T(B)?o.fs.stat(U,function(J,$){J&&v(void 0,J),$.isFile()?o.fs.readFile(U,function(re,X){re?v(void 0,re):(D.addFile(A+B,X,"",$),O())}):(D.addFile(A+B+"/",Buffer.alloc(0),"",$),O())}):process.nextTick(()=>{O()})}else v(!0,void 0)};O()}})},addLocalFolderAsync2:function(y,v){let A=this;y=typeof y=="object"?y:{localPath:y},localPath=_e.resolve(w(y.localPath));let{zipPath:T,filter:D,namefix:P}=y;D instanceof RegExp?D=(function(O){return function(U){return O.test(U)}})(D):typeof D!="function"&&(D=function(){return!0}),T=T?w(T):"",P=="latin1"&&(P=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=O=>O);let b=O=>_e.join(T,P(S(localPath,O))),k=O=>_e.win32.basename(_e.win32.normalize(P(O)));o.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?v(void 0,ye.Errors.FILE_NOT_FOUND(localPath)):O?v(void 0,O):o.findFilesAsync(localPath,function(U,B){if(U)return v(U);B=B.filter(J=>D(b(J))),B.length||v(void 0,!1),setImmediate(B.reverse().reduce(function(J,$){return function(re,X){if(re||X===!1)return setImmediate(J,re,!1);A.addLocalFileAsync({localPath:$,zipPath:_e.dirname(b($)),zipName:k($)},J)}},v))})})},addLocalFolderPromise:function(y,v){return new Promise((A,T)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},v),(D,P)=>{D&&T(D),P&&A(this)})})},addFile:function(y,v,A,T){y=x(y);let D=g(y),P=D!=null;P||(D=new Xg(i),D.entryName=y),D.comment=A||"";let b=typeof T=="object"&&T instanceof o.fs.Stats;b&&(D.header.time=T.mtime);var k=D.isDirectory?16:0;let O=D.isDirectory?16384:32768;return b?O|=4095&T.mode:typeof T=="number"?O|=4095&T:O|=D.isDirectory?493:420,k=(k|O<<16)>>>0,D.attr=k,D.setData(v),P||c.setEntry(D),D},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return g(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,v,A,T,D,P){T=On(!1,T),D=On(!1,D),A=On(!0,A),P=nu(D,P);var b=g(y);if(!b)throw ye.Errors.NO_ENTRY();var k=l(b.entryName),O=u(v,P&&!b.isDirectory?P:A?k:_e.basename(k));if(b.isDirectory){var U=c.getEntryChildren(b);return U.forEach(function($){if($.isDirectory)return;var re=$.getData();if(!re)throw ye.Errors.CANT_EXTRACT_FILE();var X=l($.entryName),Se=u(v,A?X:_e.basename(X));let pe=D?$.header.fileAttr:void 0;o.writeFileTo(Se,re,T,pe)}),!0}var B=b.getData(c.password);if(!B)throw ye.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(O)&&!T)throw ye.Errors.CANT_OVERRIDE();let J=D?y.header.fileAttr:void 0;return o.writeFileTo(O,B,T,J),!0},test:function(y){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var A=c.entries[v].getData(y);if(!A)return!1}catch{return!1}return!0},extractAllTo:function(y,v,A,T){if(A=On(!1,A),T=nu(A,T),v=On(!1,v),!c)throw ye.Errors.NO_ZIP();c.entries.forEach(function(D){var P=u(y,l(D.entryName));if(D.isDirectory){o.makeDir(P);return}var b=D.getData(T);if(!b)throw ye.Errors.CANT_EXTRACT_FILE();let k=A?D.header.fileAttr:void 0;o.writeFileTo(P,b,v,k);try{o.fs.utimesSync(P,D.header.time,D.header.time)}catch{throw ye.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,v,A,T){if(T=Qg(v,A,T),A=On(!1,A),v=On(!1,v),!T)return new Promise((O,U)=>{this.extractAllToAsync(y,v,A,function(B){B?U(B):O(this)})});if(!c){T(ye.Errors.NO_ZIP());return}y=_e.resolve(y);let D=O=>u(y,_e.normalize(l(O.entryName))),P=(O,U)=>new Error(O+': "'+U+'"'),b=[],k=[];c.entries.forEach(O=>{O.isDirectory?b.push(O):k.push(O)});for(let O of b){let U=D(O),B=A?O.header.fileAttr:void 0;try{o.makeDir(U),B&&o.fs.chmodSync(U,B),o.fs.utimesSync(U,O.header.time,O.header.time)}catch{T(P("Unable to create folder",U))}}k.reverse().reduce(function(O,U){return function(B){if(B)O(B);else{let J=_e.normalize(l(U.entryName)),$=u(y,J);U.getDataAsync(function(re,X){if(X)O(X);else if(!re)O(ye.Errors.CANT_EXTRACT_FILE());else{let Se=A?U.header.fileAttr:void 0;o.writeFileToAsync($,re,v,Se,function(pe){pe||O(P("Unable to write file",$)),o.fs.utimes($,U.header.time,U.header.time,function(L){L?O(P("Unable to set times",$)):O()})})}})}}},T)()},writeZip:function(y,v){if(arguments.length===1&&typeof y=="function"&&(v=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var A=c.compressToBuffer();if(A){var T=o.writeFileTo(y,A,!0);typeof v=="function"&&v(T?null:new Error("failed"),"")}}},writeZipPromise:function(y,v){let{overwrite:A,perm:T}=Object.assign({overwrite:!0},v);return new Promise((D,P)=>{!y&&i.filename&&(y=i.filename),y||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(b=>{let k=O=>O?D(O):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,b,A,T,k)},P)})},toBufferPromise:function(){return new Promise((y,v)=>{c.toAsyncBuffer(y,v)})},toBuffer:function(y,v,A,T){return typeof y=="function"?(c.toAsyncBuffer(y,v,A,T),null):c.compressToBuffer()}}}});import{execFile as H_,spawn as W_,spawnSync as L3}from"node:child_process";import{promisify as K_}from"node:util";function V_(t){if(process.platform!=="win32")return!1;if(Y0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Y0,"").toLowerCase();return $_.has(r)}function Q0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return V_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function lt(t,e=[],r={}){return W_(t,e,Q0(t,r))}function ef(t,e=[],r={}){return J_(t,e,Q0(t,r))}var $_,Y0,J_,An=Ye(()=>{"use strict";$_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Y0=/\.(cmd|bat|ps1)$/i;J_=K_(H_)});var ix=se(Be=>{"use strict";var z=N;(function(t,e){let r=N,i=t();for(;;)try{if(-parseInt(r(1390))/1*(parseInt(r(397))/2)+-parseInt(r(551))/3*(parseInt(r(713))/4)+parseInt(r(837))/5+-parseInt(r(1179))/6+-parseInt(r(1506))/7*(-parseInt(r(426))/8)+-parseInt(r(1733))/9+parseInt(r(512))/10*(parseInt(r(1822))/11)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Ro,299298);var Nb=Object[z(802)+z(1566)],Mb=Object[z(380)+z(970)+"mes"],Qf=(t,e)=>function(){return t&&(e=(0,t[Mb(t)[0]])(t=0)),e},Bb=(t,e)=>{let r={cEXiH:function(o,c,l,u){return o(c,l,u)}};for(var i in e)r.cEXiH(Nb,t,i,{get:e[i],enumerable:!0})};function zb(){return Vf||(Vf=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Fb(){let t=z;return Jf||(Jf=[IDBCursor[t(974)+"e"].advance,IDBCursor[t(974)+"e"][t(406)],IDBCursor[t(974)+"e"][t(406)+t(520)+"ey"]])}function Ub(t){let e=z,r={HoiII:e(1112),Sgsso:e(1135),vkOEu:function(o,c){return o(c)},ITEPd:function(o){return o()},woHYs:function(o,c){return o(c)},flQMi:function(o,c){return o===c},eWxSL:e(1640),VIMnf:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,u={nCwhl:function(x,g){return r[N(1722)](x,g)},DsFMq:function(x){return r[N(1414)](x)},AWZVZ:function(x,g){return r[N(1447)](x,g)}};if(r[l(1824)](r[l(504)],r[l(504)])){let x=()=>{let E=l;t[E(256)+E(1431)+E(564)](r[E(849)],g),t[E(256)+"entListe"+E(564)](r[E(1419)],w)},g=()=>{let E=l;o(u[E(1334)](zt,t.result)),u[E(820)](x)},w=()=>{let E=l;u[E(443)](c,t[E(1135)]),u[E(820)](x)};t[l(1512)+l(724)](r[l(849)],g),t[l(1512)+"Listener"](r[l(1419)],w)}else return this[l(1430)].protocol});return i.then(o=>{let c=e;r[c(1809)](o,IDBCursor)&&sd[c(839)](o,t)})[e(449)](()=>{}),Do[e(839)](i,t),i}function Gb(t){let e=z,r={nqJuz:e(636),mnmmp:function(o,c){return o+c},IbdIo:function(o,c){return o!==c},Hunoa:e(486),wbTjm:e(364),kwGLk:function(o){return o()},dKPQR:e(1591),bRMPJ:function(o,c){return o(c)},QSEOn:e(260)+"or",pQiwZ:function(o){return o()},aMaGF:"complete",wGtKq:"error"};if(To.has(t))return;let i=new Promise((o,c)=>{let l=e,u=()=>{let w=N;t[w(256)+w(1431)+"ner"](w(850),x),t[w(256)+w(1431)+w(564)]("error",g),t[w(256)+w(1431)+"ner"](r[w(578)],g)},x=()=>{let w=N,E={fCPZa:function(S,y){return r.mnmmp(S,y)}};if(r[w(922)](r[w(1748)],r[w(1377)]))o(),r[w(1045)](u);else{let y=""+_0x44682f.now(),v=_0x160dc6||(_0x3d4886=_0x22c4af(_0x2c3ce0)),A=_0x8941b6.random()[w(1063)](16)[w(1651)](-6);return E[w(1728)]("02"+y+v,A)}},g=()=>{let w=N;r[w(922)](r[w(665)],r[w(665)])?(_0x3b069e[w(839)](_0x5097da,_0x1c6c16),_0x474d7d[w(839)](_0x29ae5a,_0x1efd29)):(r.bRMPJ(c,t[w(1135)]||new DOMException(r.QSEOn,r[w(346)])),r[w(1662)](u))};t[l(1512)+l(724)](r[l(1319)],x),t[l(1512)+l(724)](r[l(748)],g),t[l(1512)+"Listener"](r.nqJuz,g)});To[e(839)](t,i)}function qb(t){Co={ebtJg:function(i,o){return i(o)}}[z(533)](t,Co)}function jb(t){let e=z,r={aXFDn:function(i,o){return i(o)},cpunC:function(i,o){return i(o)},aNhsT:function(i,o){return i instanceof o},jCOnA:"text/pla"+e(1253)+e(1017),xBQQG:e(1019)+e(1087),BvzFf:e(1019)+"ion/json;charset=utf-8",OOXNK:e(434),giCJs:e(907)+"e",RSjRZ:e(874),iscmW:function(i,o,c,l){return i(o,c,l)},TvcSw:function(i,o){return i(o)},PUGBG:function(i,o){return i(o)},nioxr:function(i,o){return i===o},ihjvY:function(i,o){return i in o},dDUpZ:"objectSt"+e(1752),qCCjz:function(i){return i()},nJdPX:e(1663)};if(r[e(394)](t,IDBDatabase.prototype[e(1537)+e(855)])&&!r[e(1585)](r[e(1501)],IDBTransaction.prototype))return function(i,...o){let c=e,l=t[c(1214)](r[c(674)](Wi,this),i,...o);return id[c(839)](l,i[c(1268)]?i.sort():[i]),r.cpunC(zt,l)};if(r.qCCjz(Fb).includes(t))if(r[e(1571)]!==r[e(1571)])if(r[e(1528)](_0x50d3ff.payload,_0x5cffee)){let i=r[e(1528)](this[e(1564)][e(1613)+"ncoding"],_0x1fface)?{force:!!this[e(1564)][e(1613)+e(1423)][e(360)],encoding:this[e(1564)][e(1613)+e(1423)][e(869)]?this[e(1564)][e(1613)+"ncoding"][e(869)][e(467)](/\s/g,"")[e(363)+e(1242)]():""}:{force:!1,encoding:this[e(1564)][e(1613)+e(1423)]?this[e(1564)].payloadEncoding[e(467)](/\s/g,"")["toLowerC"+e(1242)]():""},o=_0xebe228[e(1613)+e(1423)]?_0x8b9252["payloadE"+e(1423)][e(467)](/\s/g,"")[e(363)+e(1242)]():"",c=r[e(1528)](this._options[e(710)+e(1316)],_0x3c11d4)?{force:!!this[e(1564)][e(710)+e(1316)][e(360)],type:this[e(1564)][e(710)+e(1316)][e(430)]?this._options["payloadT"+e(1316)][e(430)][e(467)](/\s/g,"")[e(363)+"ase"]():""}:{force:!1,type:this._options[e(710)+"ype"]?this[e(1564)][e(710)+"ype"].replace(/\s/g,"")[e(363)+e(1242)]():""},l=_0x14786f[e(710)+e(1316)]?_0x4c23e4["payloadT"+e(1316)][e(467)](/\s/g,"")[e(363)+e(1242)]():"",u=c[e(360)]?c.type:l||c[e(430)],x=i[e(360)]?i.encoding:o||i.encoding,g=[r[e(705)],r.xBQQG,r[e(336)],r[e(1819)]],w=[r[e(676)],r.RSjRZ];this[e(1564)].enableTransformTextPayload&&g[e(670)](u)&&(!x||w[e(670)](x))?_0x4d802e[e(1552)+e(387)]=r[e(1618)](_0x552e93,_0x1f4b1f[e(691)],0,_0x105f12[e(691)].byteLength):_0x1570fc["textPayl"+e(387)]=""}else _0x5dc1ce[e(1552)+"oad"]="";else return function(...i){let o=e;return t[o(332)](r[o(674)](Wi,this),i),r[o(317)](zt,sd.get(this))};return function(...i){let o=e;return r[o(317)](zt,t[o(332)](r.PUGBG(Wi,this),i))}}function Hb(t){let e=z,r={sdTHp:e(1232),WHrWB:function(i,o){return i instanceof o},MYPnS:function(i,o){return i(o)},jaKZY:function(i){return i()}};return typeof t===r[e(421)]?jb(t):(r[e(590)](t,IDBTransaction)&&r[e(286)](Gb,t),ex(t,r[e(476)](zb))?new Proxy(t,Co):t)}function zt(t){let e=z,r={Uyxrb:function(o,c){return o(c)},AXkWa:function(o,c){return o!==c}};if(t instanceof IDBRequest)return r[e(1529)](Ub,t);if(Ao[e(847)](t))return Ao.get(t);let i=Hb(t);return r.AXkWa(i,t)&&(Ao[e(839)](t,i),Do[e(839)](i,t)),i}var ex,Vf,Jf,sd,To,id,Ao,Do,Co,Wi,Zf=Qf({"node_modules/idb/build/wrap-idb-value.js"(){let t=z,e={uhaZq:function(r,i){return r instanceof i},HmMiH:function(r,i){return r===i},JYMYD:t(396),gFxFz:t(1490),fOKdG:function(r,i){return r>=i},JctOL:function(r,i,o){return r(i,o)},wMQdI:t(901),uohBY:function(r,i){return r instanceof i},fFlnU:function(r,i){return r===i},AIZeg:function(r,i){return r===i},MCmxr:function(r,i){return r in i}};ex=(r,i)=>i[t(1256)](o=>r instanceof o),sd=new WeakMap,To=new WeakMap,id=new WeakMap,Ao=new WeakMap,Do=new WeakMap,Co={get(r,i,o){let c=t;if(e.uhaZq(r,IDBTransaction)){if(e[c(416)](i,e[c(1088)]))return To[c(1336)](r);if(e[c(416)](i,c(966)+c(1752)))return r[c(966)+c(1752)]||id.get(r);if(i===e[c(918)])return o[c(966)+c(1752)][1]?void 0:o[c(966)+c(1648)](o[c(966)+"oreNames"][0])}return zt(r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t,c={BuVDI:function(l,u){return e[N(1460)](l,u)},pRXkw:function(l,u,x){return e[N(646)](l,u,x)},wlMZi:function(l,u){return l|u}};if(e[o(489)]===o(1541)){for(_0x2fb150>>>=0;c[o(1382)](_0x5c4ea6,128);)c[o(873)](_0x3cec94,_0x424d2e,c[o(341)](127&_0x1aa3c1,128)),_0x28908b>>>=7;_0x48768e(_0x3d6bf8,_0x23c622)}else return e[o(1615)](r,IDBTransaction)&&(e[o(381)](i,e[o(1088)])||e.AIZeg(i,e.gFxFz))?!0:e[o(1619)](i,r)}},Wi=r=>Do[t(1336)](r)}}),tx={};Bb(tx,{deleteDB:()=>Kb,openDB:()=>Wb,unwrap:()=>Wi,wrap:()=>zt});function Wb(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=z,u={TeiCT:function(w,E){return w(E)},UvLuQ:l(1081),cMUQe:l(1169)+l(994),FnIwY:l(1210)+l(800)},x=indexedDB[l(470)](t,e),g=u[l(1700)](zt,x);return i&&x["addEvent"+l(724)](u[l(983)],w=>{let E=l;i(u.TeiCT(zt,x[E(579)]),w[E(493)+"on"],w.newVersion,u[E(1700)](zt,x[E(1537)+E(855)]))}),r&&x[l(1512)+l(724)](l(1805),()=>r()),g[l(980)](w=>{let E=l;c&&w["addEvent"+E(724)](u.UvLuQ,()=>c()),o&&w[E(1512)+E(724)](u.cMUQe,()=>o())})[l(449)](()=>{}),g}function Kb(t,{blocked:e}={}){let r=z,i={nGwyG:r(1805),lemmj:function(c,l){return c(l)}},o=indexedDB["deleteDa"+r(536)](t);return e&&o["addEvent"+r(724)](i[r(1366)],()=>e()),i[r(544)](zt,o)[r(980)](()=>{})}function Xf(t,e){let r=z,i={SMlAD:r(1081),fMVKy:function(x,g,w){return x(g,w)},FqZLQ:function(x,g){return x!==g},VkUOx:r(1557)+"e",Cxpsi:function(x,g){return x instanceof g},obiBZ:function(x,g){return x===g},diweW:"string",VVgUE:function(x,g){return x!==g},JjJgh:function(x,g){return x in g}};if(!(i[r(1356)](t,IDBDatabase)&&!(e in t)&&i[r(928)](typeof e,i.diweW)))return;if(Io[r(1336)](e))return Io[r(1336)](e);let o=e[r(467)](/FromIndex$/,""),c=i[r(1798)](e,o),l=rx[r(670)](o);if(!i[r(338)](o,(c?IDBIndex:IDBObjectStore)[r(974)+"e"])||!(l||nx.includes(o)))return;let u=async function(x,...g){let w=r,E={fOfhO:i[w(1418)],TgcKF:function(S,y,v){return i[w(651)](S,y,v)}};if(i[w(514)](w(277),w(708))){let S=this[w(1537)+w(855)](x,l?i[w(309)]:"readonly"),y=S[w(1490)];return c&&(y=y[w(248)](g[w(1638)]())),(await Promise.all([y[o](...g),l&&S[w(396)]]))[0]}else this[w(866)](E[w(1491)],E[w(1102)](_0x350fb2,E[w(1491)],{..._0x4170c1}))};return Io[r(839)](e,u),u}var nx,rx,Io,$b=Qf({"node_modules/idb/build/index.js"(){let t=z,e={LfuBo:function(o){return o()},RBFfM:function(o,c){return o(c)},fiEaR:function(o){return o()},hDpqS:t(1555),jelwJ:t(1580),leFcB:"get",Bakak:t(1520),quJXw:t(852),PxQtl:t(1273)},r=(t(252)+"1|2")[t(702)]("|"),i=0;for(;;){switch(r[i++]){case"0":e[t(981)](Zf);continue;case"1":Io=new Map;continue;case"2":e.RBFfM(qb,o=>({...o,get:(c,l,u)=>Xf(c,l)||o.get(c,l,u),has:(c,l)=>!!Xf(c,l)||o[t(847)](c,l)}));continue;case"3":e[t(1742)](Zf);continue;case"4":rx=[e[t(401)],e[t(437)],t(543),t(232)];continue;case"5":nx=[e[t(1474)],e.Bakak,e[t(251)],t(862)+"ys",e.PxQtl];continue}break}}}),Vb={idb:function(t){let e=z;t[e(609)]=Promise[e(429)]().then(()=>($b(),tx)).then(function(r){return r})}},Yf={};function Bt(t){let e=z,r={uyXKG:e(334)+"0",MPGfn:function(u,x){return u!==x}},i=r[e(1623)][e(702)]("|"),o=0;for(;;){switch(i[o++]){case"0":return l[e(609)];case"1":var c=Yf[t];continue;case"2":var l=Yf[t]={exports:{}};continue;case"3":Vb[t](l,l[e(609)],Bt);continue;case"4":if(r[e(565)](void 0,c))return c.exports;continue}break}}function N(t,e){t=t-220;let r=Ro(),i=r[t];if(N.TkkeCH===void 0){var o=function(x){let g="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",E="";for(let S=0,y,v,A=0;v=x.charAt(A++);~v&&(y=S%4?y*64+v:v,S++%4)?w+=String.fromCharCode(255&y>>(-2*S&6)):0)v=g.indexOf(v);for(let S=0,y=w.length;S<y;S++)E+="%"+("00"+w.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(E)};N.ZjHxVj=o,N.aPOopY={},N.TkkeCH=!0}let c=r[0],l=t+c,u=N.aPOopY[l];return u?i=u:(i=N.ZjHxVj(i),N.aPOopY[l]=i),i}Bt.d=(t,e)=>{let r=N;for(var i in e)Bt.o(e,i)&&!Bt.o(t,i)&&Object[r(802)+r(1566)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=z;Bt.o=(e,r)=>Object[t(974)+"e"][t(1274)+"operty"].call(e,r)})(),(()=>{let t=z,e={rdWmZ:t(771)+"d",sPtkY:t(1813)+"le"};Bt.r=r=>{let i=t;e[i(455)]!=typeof Symbol&&Symbol[i(1063)+"Tag"]&&Object[i(802)+i(1566)](r,Symbol[i(1063)+"Tag"],{value:i(1236)}),Object[i(802)+i(1566)](r,e[i(640)],{value:!0})}})();var Re={};function Ro(){let t=["B2PusuC","AwHQDLK","uxfvue4","y29UBMvJDgK","C2vUzf9Hy2S","v2LUzg93","CxDoAwq","DMrRuNa","BwLUzW","y29UBMvJDeu","rM54CKi","ug9us3O","zw50","AvzYr2K","Afr0tg0","zv90Aw1LB3u","BM1Xvvu","ELDMu1u","sMTvDvK","rLjptLrjrvi","ywr2yw5Jzq","v1L4t0u","zfnwufu","ufryANm","B1bZBe4","rKPRv0C","DKDvsKe","Ahr0Chm6","B3nLrxzLBNq","Cgf5Bg9Hzeu","B2zMC2v0","Dw9OqLK","tg9NsurozxC","AwrI","AxnJBvC","tunTEhi","x2XPC3rLBMu","yLHTqwq","rwTWz0y","DxLys0C","EMr1qKW","q0DfDNm","DuPRy0G","x2LZv29YA2u","vxDzu2u","AxnmB25N","q3vZDg9Tq2W","qNjPzgDL","q3LNy2e","x2LUAxrqCM8","D2z4zxy","wufttLm","sNPXELC","B01etKu","C2HPzNq","t1bftL9fuLi","BuXSwwq","BNruCMLLC0m","vNjwq2O","CwnvvvK","zxLcD3K","AwDHDg9Yt24","vu5HwMO","ChbyAum","B3jL","DuHbEvm","tufXs3G","C2XPy2u","wuPIEK0","y1vxsu0","BM5Ly3q","qw1VDw50","A1zwBhe","AK9mwha","Cwvstfm","ugreve4","CMvXDwLYzwq","zNnOyKe","CffPD1O","seH5EMm","DvPoBeS","CgTNyMC","zwrPyxrLBhK","tNLvyxe","wwPZrhO","uuDcz3C","r1vwDNK","AxnrB1nby2S","x2LZqNjVD3m","zMX1C2HfEha","zu9qAwy","C2v0u3rVCMe","q291BNq","ufDTEg0","r1rZDNa","t2LTBMO","DMLJzuLeig8","Dgv4Dc9Qyxy","AvztELO","yMLUyxj5vhK","DLfowgW","zNjVBujPDhm","rvvvtfq","uuPfwhC","Ag55Bwy","q29UzMLN","CMjkyxC","twXUq2q","v0DtBeW","CgLUz1rPBwu","uuTUs0C","BMrWB2LUDca","u3rYyxrLz3K","r2PZthe","rKjRtgy","C0nVDw50zxi","vgvPq1q","uNjUCeW","A3LKA0G","nNWZFdv8n3W","C3jJ","CNzHBfzHBhu","mhWXFdr8nxW","zw5KCg9PBNq","BwvZC2fNzq","y2jTAei","vw5Oyw5KBgu","t1b5twu","Dxrjza","ExrAu3G","D3m6lY8","s1bZqNi","AvDkuMm","C2vYDMvYvgK","D3rHALa","yxKSig5LDhC","C2vYDMLJzs0","ignVzgu6ia","DMTprxu","Cw9Z","BK5UAxq","r2LUvNa","ExDXqMy","y3r6DgK","zKnqwMe","Efrurw52","DhDVCMTdAge","DgLUzYbZzxi","wvbywKO","nti0ndK1n3HWz01mDG","q0HnuvG","zNjVBu51Bwi","ruz4y28","x2LZtwLUAvC","D3rHD3K","Bg9NsurozxC","uwHiuuW","CNDmwu8","zMLfyvi","ysbTDxn0igi","s2f0EvG","D2LSBfjLy28","tufyx1jfvfi","zM5Nq3m","shvUB2e","y3jLyxrLrxi","D21dsMe","uKfhsva","B3jLtMfTzxm","r1bpDxi","tvjlwM8","t3HHvuK","yw1kEMK","CuXmwue","tKr4Buy","B25VCgvU","yNL0zxm","AhvLALq","ywTsAwe","BMrWB2LUDfq","tMjoELC","CIb0DhDjra","BMrLEa","y3LdzMy","uK55uKW","x2LUAxq","r3rls2S","DxrMofDYAxq","ign1CNnVCIa","x29UrxjYB3i","D3HbyKi","vwT2Cfy","x2LUDgvYDMe","wfHVvvi","x2rLC3rYB3K","CKLgwxi","z1HrBwS","ig1LC3nHz2u","ExbHq0m","y1bVtLC","sKLIy2e","DKzKsLC","yNDXEfG","C3nHz2vfDMu","zvvYBa","Dgv4Dc9WBge","tuD1rfm","u2TPCcbWyxm","DM5yCNy","swfPDvG","zgLZCgf0y2G","DNfqBu8","x2rYB3bhBg8","z3HYsve","vLzNvuu","Ec1TC2CTy3u","DKDzALO","s1HPq2O","AMDrwKq","A3fACwC","whLjBvy","yMXVy2TLza","wKHxvfm","CMvZzxrdB3u","tKnTt3a","vKLnBMy","swvprKi","l3DZl3yY","mNWWFdr8m3W","x19LC01Vzhu","z1zzzxy","zgvIDwC","wKzru0q","yw1L","y3jLyxrLrwW","t09ytKS","AvHSB2e","DvzeEge","mZa4yNP4r3nf","Cw1ZvxG","zMXrtwK","y3r4","A1bNswK","DMvUDa","B3jRig9MzMW","reH3tfa","t0vWqM0","terotMC","BwzczwK","D2fZq2XLyw4","BKTbvuO","suvtx0vsuK8","AwXK","t3nMtwq","CLvTEuy","zgvJB2rLzey","C3rYAw5NAwy","DuTirwq","y2XLyxi","B05cthi","BwzQEee","wMfhBvm","CxbWyLO","BhLXwMm","EfHWAhe","thvYy0u","DcbSAw1PDa","CMvZzxruCMK","x2fKzfDZtgK","tg9JAW","suL4A1u","ugj5Chi","zunUuhe","zhr3Ewi","Aw5KzxG","rhPxte8","rezXzKC","CxvkwhC","m3WWFdv8nhW","yNL0zuXLBMC","wM1kveS","EvjLy29UBMu","CMvTB3zLrxy","t1vSEKK","wfz5reK","EfPzvhu","qwjVCNrfCNi","q2DbwLq","q0XJy0i","x3nLCuLK","x3jLywr5q2W","ANryEw0","Ehrbww4","BLrWC1m","x2DLDeLUDgu","svDMsuG","yu1dEuC","EvrNtxG","Ae1LC3nHz2u","Dg9oDw1Izxi","x3DZsw5ZDge","x2n1CNnVCKy","y29UC3rYDwm","z1P0BNG","zgHsBfu","zxjHDg9Y","y2HHCKnVzgu","uNvxuMO","ENn0s3O","uwHyEw4","CMvHzhLtDge","DgvmB2Djre4","tvLqBLm","rfHlBgW","mtb8m3W3","zNjHBwvuExa","BxfoBNC","CeHXtgi","wvrTzwK","yNjkBfK","zgvS","B25JBg9Zzq","ywnRpwzYB24","zNDZxZeUmc4","sgr6C2q","uwnAvNK","tgv4zK0","vKzWuwW","s0rwqxC","vwTstg4","CM9YrxzLBNq","x1fVu01HBMe","Dwv4zMi","wxHvrMu","D3nZoI8V","vMTvt3G","DeLK","twHKy1i","sLvSDMe","uxvLDwu","ihrVihjLDhi","sNHgBK4","x29UtwvZC2e","vhzJu3C","u214z2G","CuzACuS","EMvtr3O","ywXSB2nvBNm","CgXLyxnLiha","vwHUBxm","tMTWsM0","vNzxt2q","AgvHzgvYCW","yNvMzMvYzwq","CuXhwvi","x3vYBa","ChLTs2y","yMDtrgu","yxbWBhK","s0Tgz3i","mxW0Fdj8m3W","CgzsuLm","qNz6rMy","qNDcCK0","sMPkz2G","Ewrusfe","ALjyDhe","D2XnwMK","z29itgO","sersEwS","t25KBg4","rg5Vyuq","uvnft24","CMvdufi","vxvNyxy","EhrqsxO","seTrt0m","s1ftCvy","zLjhwvG","BNvTyMvY","BLvkAgy","qvzRsLy","vfPSCuy","s0D5twe","x2rPC3bHDgm","x3bYzwzPEa","zM9Yy2u","quXm","DcbVzIbYyw4","Dg9mB3DLCKm","vNLwDwq","s2TQwMm","B25tDgfYDfi","z2v0q3vYC28","rxjmy3q","u1LyExu","qxfZzxm","zw9rB2O","q01nre4","DgvZDa","AxmGDw5Kzwy","zw9OBgq","A0Lkswi","AgvKtwf4uMu","CLrIqMm","AwXLtMfTzq","z2v0t3DUuhi","zKzSBLu","zw50zwqGDhK","zufLq2u","z1zpzwm","vgn4t24","EgHHBgS","B2fK","r2fuuei","rwTrt2u","zMvpveC","wuHnCxO","wvnHshG","qKL1yMm","BMLVEhi","rgfuwe4","zg9Uzq","nZG3nZC0uNb1AwXh","shzVs2G","qNjgBfu","AxnrB1nnzxm","AerWCvm","DMfSDwvZ","rLDt","yxGGCMv0CMK","y01itha","y29UDgLUDwu","ENjvBeS","vNrvqLe","A2v5CW","Aw5PDcbrB1m","ChvZAa","tuTqqLu","u3LMCxm","rwzKrMi","B3zgAfK","sg1nAuG","CgLUz19VBMm","zMv0Cg0","nhWXFdb8mG","A2jdq1q","C2rusha","Axjusem","Cgu6ia","ww9jCNu","yxjYyxLIDwy","odyZmdq4y2fkrMvk","x3bHDgHlzxK","u0HUuvO","CMvZB2X2zq","DhLWzq","CM92AwrLihy","AK5mCgG","AevYCM9Yrxy","C3rYAw5N","tKrXs0q","ALbTv2i","AMvSD0O","rw9VCey","x29UvgLTzw8","quzcz04","ugfer0C","AxjLza","qvDAvLO","C1jOuhm","DunVtw4","r0PJy1q","wgzvB3a","Aer6sM8","y2f0y2G","s3zhAMG","Efv1wKi","tfznt0m","yvrPtu0","u0vWuwe","CMrxBvO","rKfSCu4","yNnPD2W","ufPNDfu","sMveuu8","x2LZsw5PDa","t0fjsee","B3Detgq","se9Owhm","uLjpuG","BMfmsNO","x2TLEvbHDgG","CMvWBgfJzq","zfnnuuG","Dev2zw50","B3bLBG","s3HysvG","wNbNEg4","sgjMsve","AMnyCwO","vejVwuu","AMflwLK","Ec1TC2CTCw8","EgTTAgG","BNrbBMrvCgq","CK5cAxe","EhPXANu","u2vXsuq","ywWGy3vYC28","BNf3uNi","y2XVC2uSihC","Bwj3qKW","tffpALu","v3HzEhC","D01rzeK","AMDOy2W","yMfPtge","u3jsBeC","B2XKvMvYC2K","qwXhzei","C2v0y3vYC28","sNrbAva","AMjLrM4","CujvtvO","tMPIuKC","EgH1AgO","zvjREw8","C0jf","o2nOyxjZzxq","zvD4u0W","x3jLBw92zvC","CKrvs2G","yxnZAwDU","EwnAtxK","v1HYzhG","DMvY","zufJAW","ntyXmdeWreTIt0LV","ExDeAMe","rNfAtfe","rhrjruC","ywDL","yw5ZzM9YBvq","EfzABuG","EKTbEhy","uhjPBwfYEuS","mxWZFdb8mNW","yM9KEq","B1nYBfC","y3vYCMvUDeu","vxbKyxrLq28","rKfszfa","ywnOzwqSihC","zxPyswS","BeLAALe","ANrTzum","y0nyDvu","BNrLCG","zwj0sMC","DeXRB0O","DMfS","DgfIyxnL","yuvKCfe","B25szwnLAxy","D2HMvxq","Bhnwvgu","B2vWqwK","ywTwDha","zgvSzxrL","BgvTBwO","Dhj1y3rVCIa","x3jLy29UBMu","ywXSzwqGBxu","wgncCLq","reTQsLy","Bwv0Ag9K","nde3ndvjC2Hgq08","Ahrsr3G","sMT6DMO","DuLirvm","yKXXD0q","CunyqxK","C0LsDgG","ywX3yxLZ","CgLUz0XVC3m","ChrVCG","suz3Bhq","C1PNs0e","v1bKBhm","BMvY","tvbhzM4","ChjVDg9JB2W","EMHSDem","BxfWwKO","Cef3Cvi","zxjYtM8","s3r6DMC","vfblvKG","x2n1CNnVCK4","rM56sem","q2zZtve","u2DLDhq","z3nWsva","BNfkDxO","CMvZDwX0","wwDpAeC","rhP6v1u","qLD1yue","quj2zxO","rNLsD2W","BeDktwC","yvzkEhC","y29SBM8","z29REhO","u3nuEee","v0HYv0i","Dw5RBM93BIa","mNW0Fdv8mhW","CNnVCL92ywW","Defmtvi","ywX1tfC","ywXSq3vYC28","uxj4EfO","DxrVuMvJB24","BgvUz3rO","BgLUzw5V","zu5iAe4","AxD4A2u","C0Xf","AxnAzxjV","EeLRDvm","uurHANK","tunTtNe","C2vUza","zxHWB3j0CW","BgvY","zxjFBxnNAwq","CMvUDevUzha","AgvHzgvY","uwDcrLO","svfRs1a","Cezhzwe","D24GCMvHC28","suDYDM4","y0Tmrum","qwfuEgm","BMDLza","yLftteu","seLnCwi","D29YrK0","CMvWBgfJzui","v2fwB3m","thP5uK8","DhjPzxm","A2vUC08","ywnRx2nVzgu","AenSB3nLrxy","BMCGDxjSoIa","s2DiEKS","vLfAs0e","CMvJzxzPzwq","ywjVCNq","zv9ZDwnJzxm","uKPjA0S","CeT1rxK","C1b0A1K","B3PbruC","qxvHyKm","CKrOv0S","CgDKwuu","v1jpBM8","sMn0t0W","vw9RA2O","wMjABNi","q0jkCeS","zxjYtxnN","zK1ws3K","z2jYC1m","s2Dnz08","ugLSse8","yNL0zu9MzNm","D3ncvhm","ihbYB3rVy28","wvrdvM0","x29Uq2XVC2u","D1v5u3i","CM92AwrLigi","BgLUzq","zfLyBxm","sLHjDu8","zeTquvi","CKLbDfm","CKrpvwW","EMjdzwi","rvjst1i","Aw5JBhvKzxm","vxHOs1q","yMLUza","s0nODwK","yvHgrg4","BMCGB3iGyw4","z2LdsNm","wwfoyvO","Bg1Iv2K","BNvQr2W","BLnWDue","A29zyKm","z2nzzeq","sKrXrgW","B25ozxr3B3i","DhDUDgu","y2XVC2veqG","D3L1Eem","sgvQvxe","uxz5BLC","y3vYC29Y","Cgf5Bg9Hza","B3vKrfO","Dg9cExrLCW","CMXPvgC","x0rctMfTzq","C3vIyxjYyxK","yuPyqLm","DeLUDgvYy2u","DgLTzw91Da","yMDUu0u","Berqvwy","C3bSAxq","B3jpBMXPBMu","vhfmtLK","AKnpBKe","y2Lovxu","wvrjAuG","ufPAuNO","Efb3CK4","Cgf5Bg9Hzfq","tMjwve4","tgDXAeq","otzit0XQwxi","uLPdz00","uxDeAw8","tvfTvgu","BwLZzq","uNHVCNu","wgHXEgW","vNHyv3O","rvPusg8","y3vYC29Yx24","vND6r3C","tgLZDgvUzxi","BMHYyMO","zKrkrK4","sfHpr24","BMCGzMfPBgu","DKHNBfm","CgLUz0LUDgu","DxjS","B2rmru8","ugPvBeS","thzhrMm","Aw5Lza","t1P6sLq","u3Dlz0m","ChvUEvK","v2vIu29JA2u","Cg9W","x25HDMLNyxq","reiGzMfPBgu","AM11DeS","uvnnuue","B3bLBIa","Bwf4uMv0CMK","qxzUy0e","D0D0s3e","ywfRyKK","uKLRA20","uxLvvKK","x2HHBMrSzu8","s3HLDeC","DKrXywW","r0z3s2e","vMPewfq","zNjVBunOyxi","rKLmrv9ot1q","Bwjsuw0","x0vysvnu","v0jTrxe","vxbftum","tevZt0m","z2TyCw4","t2fRDuu","z1rPBwvVDxq","A2v5","sevMC08","tLb1CvC","tMfTzq","Dw5KzwzPBMu","DgjxqKC","zMzMzG","igXHCMDLCIa","AwPhwMG","AvzVyNK","v2vPEgLUsLm","vvbguLC","lcbxzwjtB2m","uLLnsLe","uvH2A3i","y3jLyxrLq2W","B25LCNjVCG","BvbTDg4","sfHSs3G","AM9PBG","B2TeAwW","yxv0BW","A0zkBgO","Bg9Nsurhzw4","CMvKDwnL","A2v0ignVBNm","A0Diu08","t1bftG","Bw1WAgO","D09JCKK","zgnYtha","CMnPwNG","whLTBMO","zwvKzwq","AgreuNG","zgvMAw5Luhi","q09otKvdveK","AgLMChC","zxj2AwnL","Aw9UvgLTzw8","B3bLBKrc","r0vAs0m","tvLXq2y","CfnLAxi","y3vZDg9Tshq","yKH1CMq","z2vjBMzVu3K","ihrPBwvVDxq","CMPTtxK","EfbKsLu","BNbQBw4","q0Xpu0LorW","ywDLsgLKzq","rhngtxe","CvvKq3C","D1b6EvG","v0jqwfq","B3nLza","qxP3qvi","y3vYC29Yx2y","x3DZ","y2DLzwS","DxnLCKLW","tunozvq","BhrPCgXLihq","vwv4wha","wMvfCe0","AMrKv1a","yNDXsM0","vu5XChe","mtuWoduWmhPtsuDTqq","DhbizwfKzxi","C2v0","CMfNzvn5BMm","qKHsyxK","zMDfqwK","ug5rteq","BwvKAwf0zwW","D3LMuMy","jMPZy2fSBgi","AgfZ","AfPgEuu","sg9PsuK","y29TCgXLDgu","yMj2s0q","z2v0qwXS","ihrPBwvZ","y3jLyxrLuMu","Aw9U","C0XPC3rLBMu","Afbhvxq","AgLNAa","wvnzAgi","CMLLC0nVDw4","DwzXufm","z2v0qwXSs2u","De1HBMfNzxi","mdaWmdaWmda","D1vbCMq","zw1PDa","whfhzNK","BNrNwfK","zw5JB2rPBMC","De9xvwK","z2v0u3rVCMe","x2rLyNvN","CfjyA3C","yMLUyxj5","x3bPBMDqB24","AxrAwLu","s3fuB0u","x2LZtwLUAvq","DxDbsNi","igzHAwWSig0","A0jWwNG","x2rPC2nVBM4","tuvtu0fhrv8","vNHHuhm","DePgrgW","D1HwwgS","BMnLq2XVC2u","ywnRtxnNswq","mxWYFdn8nhW","zxjFCw9Zx2e","x21LC3nHz2u","Dxnqy0O","vwjszNm","rezht0i","CuXHC1y","B2nRzxrtDwm","B2nRzxrgywK","twvZC2fNzuu","vK1JDNa","wwfRBMq","tKX4uhu","DeL3Eum","ywnRx2LK","uvvQtgO","zxH0ugf5Bg8","q0L2Cxq","BM9Uzv9UB24","zMzmAw5L","yNLL","yxn2z1G","EMHdt2O","CNjVCK1LC3m","rLbNrgO","x2HHBMrSzva","CgfYC2u","x2HHBMrSzvi","twLZC2LUzYa","z0z4rNO","CMvJB25Uzwm","rgvKAwnHDgu","vw5PBxbSzw0","swjKsw8","x29UugfNzu4","C3bSAMu","uwLZA3e","zLbjEuC","zMLUza","B2jPqLO","AMrkyLG","q1j2wKO","r1fpExi","Bxvkug8","C1r4z1G","ufvpDKO","mNWZ","Bg9buwi","id4G","v3n5A1q","Chjivwm","B0fWr3q","r2LwCMi","B25dBg9Zzq","CuPeBhy","ru5NrhK","zNnpENa","z0Dcvg8","BwfW","t0fzsK0","A1LZB0m","q01eA2e","CgvYC2LZDgu","zNH0reC","n3W0Fdz8mNW","wvfozxO","qvv6ywm","q3vZDg9Trxi","uKDYDgW","y3vYCMvUDeK","y2HLy2TdDxi","s3HdvKe","s0fND1C","sNz5u0K","re5ou0u","CNPgwwu","tMT6B2y","B2jQzwn0u3q","yxKSihrYEsa","sgn5z00","zNjVBuj5Dgu","B3bLCNr5tMe","BwvY","BxD6v04","tNfwve0","ChjVDg90Exa","r2PsueC","aaaaaaaaaaa","ywnRDxbfBMq","ANbxEuK","BeHHBMrSzxi","DgHLBG","tgz1qM8","z1zfDe0","rM5jD1K","D3jPDgu","yxrLq291BNq","BvLms1i","q1bUugm","m3WX","DvDcteq","DxPxALi","CwvNwMq","AevLD3C","CMvQzwn0","AgfUz2u","ywDLrxzLBNq","zfz1q1e","rxzLBNq","Au11zeW","Buziwhm","Bgf6EM8","swPztLm","vMfzD1e","ywTpywC","mtb8nNWZFdC","Ae9Wzw5fDMu","wwv5zwi","vxHwDey","Ec11C2uT","qK1TCu0","r3jvs1u","AM91sLu","x3bPBMDmB3m","t3HVwgO","EwzXzeu","qu10r0y","zw5JB2rLrNi","zxq9DxrMltG","qvjzugS","yxbWBgLJyxq","Aw50zwDLCIa","yMHdqw8","DgLTzw91DcW","weLiuwS","CxPir08","tKHhCMK","Dg9cExrLC0W","C3vIC3rYAw4","z2vtEw5J","zMLSzw5HBwu","CePZCxq","zNHpyuC","CMvTB3zLq2G","wgnuqxK","Bffruu4","wwTgqKK","wfDjrMe","rufevNy","whHsufq","zNjVBNrPzxi","t1jLqMW","AhH4req","rhvmrfa","seLZr1C","twzgALe","A3DhtgS","CLzHBhvLCW","wuvcr0K","rg5wzKe","pxv0zI04","Bg9IywXty28","ugnLy2m","CgfNzxnOB3C","y2XLyxjtDg8","DhzHAhe","t0TbDuW","y3jLyxrLt3a","BxnNsuq","ELnlr2S","rxjqC1q","u2POzLG","x2nVBM5Ly3q","shrTtLi","Dg9tDhjPBMC","DMvYC2LVBG","zxH0zw5ZAw8","wwnMt3u","x3bYB3rVy28","y3jLyxrLt2i","zxjFywnRx20","zerqsNi","Ce5ttfG","C1zgugq","BKvoue8","C1Pkvw8","igzPzwXKoIa","Dw50","Ag52wuS","CM92AwrLihC","s3rhu1e","y1fiwxG","y2XVC2u","uNztveK","z29PBMCGyxC","uMn3zfi","Bwf4tg9ZC0m","vxPcrvK","Aw9Ul2PZB24","sLLnwuq","u0rswLG","BxfTChu","wwTly1a","C2nYAxb0","C2Hcwxm","tLjdAMq","x2n1CNnVCK0","DfPtDeW","qwT5wxK","BM93","wvL5vwG","CMvZzxrfBMq","Axnby2TdBgu","vgDJs0y","CLzlAhG","tffJzu4","BIWGAg9ZDg4","CxjezM4","ywXPzcb1CMW","BML0AwfSAxO","sujNs2u","Eef4u0S","Cuz3tLi","C3vJy2vZCW","Aw1LCYbPBIa","AefJA01LC3m","r3nAvey","CNzHBa","EfLnzLm","yw1LoIa","z2jfy3u","zw5HyMXLqxu","uu9jCKq","vhDYqxi","sKjVzgC","rMDHrw4","vNLPt2q","wvfsAfK","zfHrufK","y3jOrfC","ser0qwC","s1H0vw8","uK9fvwW","uurPvxy","q2HHrLK","DxbKyxrLq3u","zxjYB3i","tg9RzK8","q0Xpu0ve","D0Xxsha","CM92AwrLige","AMD2txu","zxbhvuy","Bvj0q0y","BgrZuKi","zMvY","zK1zv1u","zM9YrwfJAa","Dg53vum","Aw5KzxGGB3u","rvzgyNu","sLvkAKi","qNnmEwy","zfDptvq","x2nSzwfYugK","C2rkqNq","ihzHBgLKihm","x3nLBMrby2S","x2zVCM1HDeu","C1nmAwy","yMf1Cfi","EfjHtxO","vMDtEgG","zuz6v1C","y3vYDMfSDwu","zwDIsg4","Durjq3C","tLzNAhO","Dg9Y","CxHAuMK","DMvYC2LVBMm","DgLLCKPtt04","r29sAM8","y29UBMvJDfm","x2LZtM9Kzq","BM11uNy","r0L3Bfq","twfuqNG","terts2u","yMfSu2nVCgu","mZuXnZuXohvryLblDG","qKjhD2K","y2DkDMO","tuDcAum","DhjPzxmGCMu","AwjuCuW","t2L1wNm","sgrHuKG","t3LJrhO","rxHWve4","B25tDg9Wsw0","uMLzqwi","CejeBhq","B25Uzwn0Aw4","uMvHzcbWyxm","x2nSzwfYvgK","zxr3weS","BMvJDa","tg9Nsuq","zxrxB3jRq2G","x3DHAxq","wuDmsMm","tezWrgy","q1njBLm","qMvtALi","x2LUAxrhBg8","sLnptLa","z2v0sxrLBq","rxDpsge","BxjKteO","CMX4Ae4","DxbNCMfKzw4","t1PYreK","lcbTyxGGCMu","zuLArgm","y2fSBa","wwvhv3O","uMvJB25Uzwm","suT1Chq","D3LdD1C","zu5wBgK","Bg93","ENbgELa","C2XMweG","uMnHDMC","Dg9cExrLC0i","C2PWzhy","swrNBhK","BezSDxnO","sKjdvhq","sfjovve","wvziwNG","qw1stNe","zNvUy3rPB24","y29UBMvJDca","z0DZq0W","EM1sD0q","tw9KDwXL","A2PnwgS","Cg9PBNrdB24","t3Lrwwi","zMnKuKO","s1PNzKy","yxnL","zu9AChO","yxrHlcbKyxq","D1zqAg4","zNjVBuHHC2G","AuH3C1y","vxntww0","EMvoB1u","BxnN","yw1Lu3bHy2u","yMfSrxzLBNq","Aw47y2HHCNm","zcWGDw5RBM8","Dhr3Awq","C29Tzq","B25pCgvU","ywDdz2y","BKXPBMu","A2zJzeC","tuPgv2O","mtf8mtb8mhW","y3jLyxrLtwu","C2P6y3a","x2rItMfTzq","CfDYsvO","A1n0yxr1C0m","C29YDa","BuvqsK0","wfLewLu","q0rssfy","B0Drr0K","y291BNq","AgfZt3DUuhi","zfbnsNe","wg54zeu","ihn1y2nLC3m","B1vMrLi","su5tvefova","wgXHsve","zNbkqwK","CejbquS","zfjswfm","sM1RvLy","EgrQBwG","zKXPDuG","vurovwe","DKPSrvC","ywzL","rKLUtLy","x21PBMLoyxy","zw5XDwv1zq","CMfTzq","BMDuAw1LCG","z2v0q3vYCMu","AvrnB1u","AwjuwvK","zxjFCw9Z","D1PWsvC","BLDdwNi","D1vyvgG","q3PbDwm","A3rgq2G","Bwu6ia","CKnfCeG","vurOs3i","BevIqNy","C1Dxzvm","DNbwrwq","zxf1ywXZ","vMHpzNC","AMLLEum","sK1XtMW","sfPADLy","ugDtBNa","ExbL","zgf0yq","Bhm6ia","yu1Hr0y","ywnSywG","B2zMBgLUzq","B25SAw5L","zwnVBM5Ly3q","zcbLCNjVCI4","Ewvmqw8","B3vUDa","BuH6zue","CfjNr1q","uLn6CKO","yuD6sw8","y2HnyxHuCMK","zhfqywS","AgjvCvu","BKn3AgW","Dg5Ivxu","z2v0","BMfTzq","AwXLx25HBwu","swrQCfi","uw1Tz2K","q0HYEMS","Bw5cweS","qMPjzfm","CNnVCL9Uyw0","ug9kBhy","B0XYCe4","DxLUBKu","v1nAA0C","rLbis1q","AfzUs20","BNjtv0e","ANvNsgK","x29Ut3bLBG","uxzYseW","uuDNvNG","q3HWC2K","EfnLz1C","BNzcBgO","tgvNALy","y2HLy2Tszwe","Dg9VigXHCMC","uKrwDgC","zMLN","shvpC08","yNvMzMvY","BKD3EuC","D2vrvMS","wLj5zuq","tK5usNe","CefgwK0","C01sr08","r2XAr0i","zgrjrcWGzgu","t3bLBKv2zw4","qwXOtxa","B25fCNjVCG","D2juAM0","BMvLzf9Hy2S","q3ndqu8","ufHLAfu","t2j0CxG","qNvwreK","B0vhCNC","vgz5sKK","ChbL","y3ruAw1LB3u","B0XIB0K","rNjVBNrPzxi","sLDjCM8","muX3AM5fra","zxjFAxnFywm","tNjlr1m","DhjPBq","z2vY","x2jPBMfYEvq","zK1zzu4","C2TQy0e","v3rSwuC","B2zM","rxrYvva","icSG","EuDPqMC","DMfSDwu","DgzIELe","zxmGCMvHy2G","CYbPBNn0yw4","ugTUz08","x2vUzhbVAw4","sKHrALu","Bg9N","AxnszwfKEq","uwzpwwm","x3bPBMC","svrfugq","Ef9MCM9UDgK","y29Uy2f0","ChjVy2vZCW","u01Squq","u2DZC28","CgjICdi","A1ffz0u","B25mAw5L","BMnVzgLUzW","Dg9iyxnO","se92qLu","zxjFDhrS","sKzoyuy","uMX1B3i","zfjWEMK","x3nVy2TLDa","zw50tgLZDgu","teLVB1m","yw5Hz2vY","A3HNzKy","rNvwA2O","ENvNvKm","vvjXAxm","B2D6yw8","qureBeO","ywDLu2HVDW","BgLTAxq","vuLPD20","CNHhuKe","y0n4AK0","BwvZC2fNzv8","Dxz2s1G","D29iwxm","BgLZDgvUtMu","AKHjrMC","EuTQDwK","uKrvAe4","C3rLBMvYCW","z3D3BgS","DgXPAge","uMPAwLG","r3DozeC","y1r2zve","CfD4r08","CMfUzg9T","zK9lzeC","t2jQzwn0","s1zeCLG","ihzHBgLKigq","Cg93","q2jVzLa","B1j3q3K","uKrSsfe","rwH4wue","BNrfBMrWB2K","sKvkzMu","vhvsDMu","y29Kzq","AeT4zg8","Bgvgy0i","ywnR","tLf4vuq","y2vZC0HHBMq","vuDYBNq","sNjAtxK","C2Lmwuq","zcWG","CMnZBxe","zwn0","zgv2AwnLx2K","Ehz0Cfm","teT3Ehy","ExDoEgO","r2Hcv2u","BfrPBwvVDxq","C3rVCMu","zK9MAe8","zsbHihn0CMK","Avf0z3C","ywnOzwq","B2LUDfjLywm","zMLSDgvY","zhfMthq","CKnLEvm","EwjQzva","B2nRzxq","zervCfO","EK5RuwC","CxD3DKy","qNbSCNK","uLv3EvK","mJfMtwnnzfK","y0jMu3e","tevTrwW","swTNCuW","C2v0sxrLBq","teH3y0i","ywrKrxzLBNq","vKfJree","x2DLBMvYyxq","C2vYDMLJzq","B25nzxnZywC","zw5fDMvUDa","vxvLChy","igfYCMf5yNu","z2v0s2v5","sLH3sxa","B25TzxnZywC","CevztLe","tu1uAeq","q0rvrgS","CgfNzwHPzgu","AxLRr3a","yu5OC1q","vxL4CMi","zhPwt3y","rLzhq2u","Dw5ZAwDUzwq","AMnNtMG","whnOvuC","D09Hzvi","D3jPDgvvAw4","DhjHBNnHy3q","C2fNzq","yML6rvm","zw5HyMXLvhi","CfDPBhe","tKrXDfm","CMvHC29U","C3rHCNq","rNbQBgi","CMvHzfvjBNq","yMfJA3vWigu","wezqs08","B3vRCeu","ywrKq291BNq","x2nYzwf0zvm","Dgv4DfbHEwW","sxPJv3y","uKLhCgW","Chv0","y2HnyxHdB3u","CMvHzhDYAxq","AhvYrLq","q29Kzq","tKfusvzfx0u","qNLyy20","y0fqr0y","u2vYDMLJzvC","x29WDgLVBNm","Cg9PBNrbBMq","B3bLCNr5","uwPIs0y","tMHTBue","x3fVC0rc","Ee93zMe","BKPKufG","v1nKA0C","zw5HyMXLuw8","v0rwtfG","ugPbzwm","r3nqzK4","s3nQC2m","Aw5KzxHpzG","yw5Nzq","ywrK","rxjYB3jdB2q","CMvJzwL2zwq","vwXXsfa"];return Ro=function(){return t},Ro()}(()=>{let t=z,e={aclah:t(711),XlaIQ:t(1287),aVJxw:function(a,n){return a+n},oPslN:function(a,n){return a+n},qUdCw:function(a,n){return a*n},TwrAr:function(a,n){return a+n},iMudL:function(a,n){return a(n)},FnzHC:function(a,n,s){return a(n,s)},nWCZr:t(1135),ojTIG:function(a,n){return a===n},GinVp:"DQZHA",ciNUu:function(a,n){return a+n},UDhKr:function(a,n){return a(n)},gVOec:"0000",NRCjd:t(773),IWfIH:function(a,n){return a!==n},PjAec:t(930),CHrzk:function(a,n){return a(n)},mnBXK:t(864)+t(864)+"00000000"+t(864),mmphj:function(a,n){return a|n},zhltC:function(a,n){return a<<n},qcUUY:function(a,n){return a<<n},PoTKz:function(a,n){return a|n},QvynW:function(a,n){return a|n},XVyDI:function(a,n){return a<<n},MaTBx:function(a,n){return a>n},NHGri:function(a,n){return a<n},YTIiH:function(a,n){return a>n},RjZZX:function(a,n){return a-n},Oimnj:t(1402),iwxke:function(a,n){return a!==n},xVpcC:"nBoyR",inygQ:"RuBBS",NDqKD:function(a,n){return a(n)},eFzWW:t(417)+t(637)+"s",jRXtq:t(417)+"e_timeout",fLiuH:function(a,n){return a===n},uzWjR:t(594),MKPBU:function(a,n){return a!==n},fngCs:function(a,n,s){return a(n,s)},LQOjU:function(a,n,s,d){return a(n,s,d)},JFNaF:"LDhTY",YPXZJ:function(a,n){return a(n)},IdjpR:function(a,n){return a(n)},RDlHQ:function(a,n){return a>>>n},EZTHo:function(a,n,s){return a(n,s)},XxRPT:function(a,n){return a(n)},CDUDk:function(a,n,s){return a(n,s)},etwXK:function(a,n){return a===n},KGyMa:function(a){return a()},zstKz:t(618),SwKgC:function(a,n,s){return a(n,s)},YoIru:function(a,n){return a!==n},ovFhY:function(a,n,s){return a(n,s)},kBpZx:function(a,n){return a!==n},UGrnt:function(a,n,s){return a(n,s)},JWIro:function(a,n,s){return a(n,s)},bsiwl:function(a,n,s){return a(n,s)},bwqxX:function(a,n,s){return a(n,s)},YASNS:function(a,n,s){return a(n,s)},ntgXY:function(a,n){return a!==n},uDICw:function(a,n,s){return a(n,s)},JRTYM:function(a,n){return a!==n},wPzyX:function(a,n,s){return a(n,s)},YgOhG:function(a,n,s){return a(n,s)},rTbBc:function(a,n){return a!==n},dVuCQ:function(a,n,s){return a(n,s)},siLYD:function(a,n){return a<n},Uokkj:function(a,n){return a<n},koYbC:function(a,n){return a>>n},YeGWz:function(a,n){return a|n},bsmSL:function(a,n){return a&n},WPdls:function(a,n){return a&n},oApGt:function(a,n){return a+n},cyCff:t(1706)+t(935),wxAbB:function(a,n){return a+n},pBDlt:function(a,n){return a+n},Nkzof:function(a,n){return a&n},Syfqs:function(a,n){return a&n},JUlva:function(a,n){return a|n},VMcvp:function(a,n){return a>>n},mYLKR:function(a,n){return a>>n},Ondln:function(a,n){return a|n},NVghz:function(a,n){return a&n},LwpWq:function(a,n){return a|n},BBGwi:t(825),RDVtg:t(323),jugHi:function(a,n){return a(n)},zWfSU:function(a,n){return a(n)},mbRQm:function(a,n){return a(n)},oGQGI:function(a,n){return a(n)},ujfHz:function(a,n){return a(n)},QwDio:function(a,n){return a(n)},mwzWN:function(a,n,s){return a(n,s)},rxGRA:t(917)+t(1660)+t(1075)+"SeqID",sVFPd:function(a,n){return a===n},nUJhf:t(917)+t(1660)+t(1075)+t(1197),jOLXp:t(917)+t(1660)+t(1075)+t(1515),lEbBv:t(917)+"required field: "+t(550),ZmJTK:function(a,n){return a===n},dWOMT:"HwxKY",ZRyeD:t(1605),BIubc:function(a,n){return a(n)},wUySr:function(a,n){return a&n},OPyMe:function(a,n,s){return a(n,s)},oLboI:function(a,n){return a(n)},qFZqK:function(a,n){return a>>n},pkgbg:function(a,n){return a>=n},CLccB:function(a,n){return a>=n},zVbTF:function(a,n){return a*n},VxXWz:function(a,n){return a>n},qppbZ:function(a,n){return a+n},TBoYE:t(1193)+t(240),nENPO:function(a,n){return a||n},VhOfw:function(a,n){return a===n},splje:t(1266),QOIrD:function(a,n){return a+n},QDiUv:function(a,n){return a+n},Uugav:function(a,n){return a*n},rSTfG:function(a,n){return a&n},bQSLE:function(a,n){return a>>>n},zbCeb:function(a,n){return a>>>n},DXKll:function(a,n){return a>>>n},CPnPc:function(a,n){return a>>>n},PilHO:function(a,n){return a===n},IFwlt:function(a,n){return a&n},jcgNh:function(a,n){return a===n},KDVAw:function(a,n){return a>=n},JDqDl:function(a,n){return a+n},YJbzM:function(a,n){return a!==n},hnymf:"umGUi",eNVli:function(a,n){return a<n},AvncA:function(a,n){return a>=n},wXVXk:function(a,n){return a+n},UPFRW:function(a,n){return a&n},kqZqg:function(a,n){return a|n},fDJFN:function(a,n){return a<<n},pEYNQ:function(a,n){return a<<n},QfOYc:function(a,n){return a&n},HdaRH:function(a,n){return a<n},pymKf:function(a,n){return a<=n},VFpQl:function(a,n){return a(n)},JXwIp:function(a,n){return a==n},GQOyr:function(a,n){return a+n},YTmei:function(a,n){return a+n},Obtqx:function(a,n){return a+n},xdjmh:function(a,n){return a&n},tvahq:function(a,n){return a|n},ktFCh:function(a,n){return a<<n},NNTJq:function(a,n){return a|n},RrnpL:function(a,n){return a<<n},XfUop:function(a,n){return a&n},irTHC:function(a,n){return a<<n},aMCyG:function(a,n){return a&n},GjRPG:function(a,n){return a<n},eNHhN:function(a,n){return a+n},dhRlU:function(a,n){return a+n},UbRfs:function(a,n){return a&n},BMmqM:function(a,n){return a===n},dRpzi:function(a,n){return a<=n},lzEsf:function(a,n){return a<<n},GrUKU:function(a,n){return a<n},QqUPN:function(a,n){return a<n},ibTqL:function(a,n){return a<n},ybjeP:function(a,n){return a<=n},RcwdR:function(a,n){return a<n},qwNid:function(a,n){return a<n},lsVTe:function(a,n){return a===n},BeSjR:"gZtbp",TqLNY:function(a,n){return a<n},HcygM:function(a,n){return a&n},HIsGW:function(a,n){return a>>n},WBPXT:function(a,n){return a<n},WBmEq:function(a,n){return a|n},iVoby:function(a,n){return a|n},nITjO:function(a,n){return a>>n},omGzI:function(a,n){return a|n},WsykT:function(a,n){return a|n},GUVvy:function(a,n,s){return a(n,s)},vaNlx:function(a,n){return a<n},MCmNq:function(a,n,s){return a(n,s)},OAIHA:function(a,n,s){return a(n,s)},zazSt:function(a,n){return a>=n},SrRlG:t(1518),QXvkr:t(1007),QhXyn:function(a,n){return a!==n},QKnKG:"GDRHp",TJrwd:t(1682),LexfM:function(a,n){return a&n},mHzeA:function(a,n){return a|n},TJejK:function(a,n,s){return a(n,s)},FPHKT:function(a,n){return a(n)},VrVCj:function(a,n){return a&n},whfUt:function(a,n){return a(n)},iQtgw:function(a,n){return a<<n},cAPGF:function(a,n){return a&n},zZLkz:function(a,n){return a(n)},ogzao:function(a,n){return a&n},NPuqW:function(a,n){return a&n},crhDW:t(1466),rCeyS:function(a,n){return a(n)},sjpdv:function(a,n){return a<<n},NQxUD:function(a,n){return a&n},qLasV:function(a,n){return a===n},rsYLV:t(1727),EoopF:function(a,n){return a(n)},HXOGn:function(a,n){return a(n)},gktBQ:function(a,n){return a<<n},ytZSx:function(a,n){return a&n},lIZjQ:function(a,n){return a|n},xrvCi:function(a,n){return a<<n},kQEgE:function(a,n){return a>>>n},Fpjlb:function(a,n){return a&n},KXiCj:function(a,n){return a&n},OReBl:function(a,n){return a&n},ZTNSv:function(a,n){return a(n)},bPLll:function(a,n){return a!==n},UexXp:t(1355),RGrtl:function(a,n){return a>>>n},WaVos:function(a,n){return a<<n},SYXyu:function(a,n){return a===n},rIAtS:function(a,n){return a<n},gXQmk:function(a,n){return a<n},WROno:function(a,n){return a<n},Idgly:function(a,n){return a&n},EkpgF:function(a,n){return a+n},URqNy:function(a,n){return a|n},XIHQk:function(a,n){return a&n},pyoaE:function(a,n){return a&n},oSrlW:function(a,n){return a+n},hVnKm:function(a,n){return a!==n},JMqNl:function(a,n){return a&n},CHMQX:function(a,n){return a&n},IeOFB:function(a,n){return a!==n},UzBEY:function(a,n){return a&n},pWxGO:function(a,n){return a>>>n},PTXjs:function(a,n){return a!==n},KxetG:function(a,n){return a|n},UkvpV:function(a,n){return a&n},Cygca:function(a,n){return a(n)},oLrpN:function(a,n){return a|n},baiLa:function(a,n){return a<<n},bbvKD:function(a,n){return a>>n},jtmeC:function(a,n){return a!==n},FInNV:t(1698),XcBrT:function(a,n){return a===n},gGBTo:function(a,n){return a|n},KxXIX:function(a,n){return a|n},tbWBG:function(a,n){return a<<n},LVMOC:function(a,n){return a<<n},wyCwW:function(a,n){return a<<n},VyiOd:function(a,n){return a|n},QyUVI:function(a,n){return a<<n},OsfMd:function(a,n){return a<<n},mfVoD:function(a,n){return a|n},dRYUW:function(a,n){return a<<n},gokxz:function(a,n){return a<<n},RIGpl:function(a,n){return a===n},AUzac:function(a,n){return a|n},eOZpz:function(a,n){return a<<n},MAqKx:function(a,n){return a<<n},LvGFc:function(a,n){return a>>>n},tfbzQ:function(a,n){return a>>>n},fgEAi:function(a,n){return a&n},nSpuA:function(a,n){return a&n},rNBiq:function(a,n){return a&n},agCgf:function(a,n,s){return a(n,s)},Rluor:function(a,n){return a!==n},AVkJV:t(1042),SMDSi:t(1535),sZJUo:function(a,n){return a+n},mfBei:function(a,n){return a|n},aEdpQ:function(a,n){return a%n},QhHQL:function(a,n){return a/n},xUuZB:function(a,n){return a+n},RAGIP:function(a,n){return a*n},OZrDI:function(a,n){return a>>>n},NrKGS:function(a,n){return a*n},WSZkG:function(a,n){return a>>>n},VaYwQ:function(a,n){return a===n},AkyYy:function(a,n){return a===n},LDSKe:function(a,n){return a>>>n},tnwUC:function(a,n){return a>>>n},MfFjQ:function(a,n){return a&n},xXphq:function(a,n){return a+n},DKjJV:function(a,n){return a+n},rDUKh:function(a,n){return a>>>n},lmDZw:function(a,n){return a+n},MlnCd:function(a,n){return a<<n},HtmNR:function(a,n){return a!==n},HEfsO:function(a,n){return a===n},AmXSq:function(a,n){return a===n},uvvKX:function(a,n){return a===n},Rcavg:function(a,n){return a&n},fshbA:function(a,n){return a&n},BrFlU:function(a,n){return a&n},NyUaq:function(a,n){return a&n},LDNNg:function(a,n){return a>>>n},EpbWP:function(a,n){return a+n},hbUqU:function(a,n){return a+n},YXTxH:function(a,n){return a|n},iHwsV:function(a,n){return a<<n},weQVk:function(a,n){return a<<n},mRtCF:function(a,n){return a&n},SsTxA:function(a,n){return a<n},LEmEl:function(a,n){return a>=n},fRGYX:function(a,n){return a<=n},zeSGz:function(a,n){return a(n)},oMDNE:function(a,n){return a===n},uJkcH:t(342),yTgMx:function(a,n){return a>>>n},itZZU:function(a,n){return a&n},Yaknd:function(a,n){return a&n},cUWIM:"NATIVE_E"+t(464),VxaPs:t(803)+"NG_ERROR",gxrIQ:t(883)+"ERROR",kYsoC:t(1639)+"OR",jouJU:t(582),uCoMn:t(1030),Smxgh:function(a,n){return a!==n},mTQlo:function(a,n){return a==n},EkQOe:function(a,n){return a>n},rIFYr:function(a,n){return a+n},LEsOC:function(a,n){return a(n)},JHQjU:function(a,n,s){return a(n,s)},wVPhn:t(1112),kGHSO:t(941),wOcrI:function(a,n){return a<n},lDPUf:function(a,n){return a===n},UIiwm:"twnte",brJlY:t(889)+"0",IKupt:t(1301),HRNUQ:t(1081),TPKVH:t(470),baupR:function(a,n,s){return a(n,s)},VAcDA:function(a,n,s){return a(n,s)},kFJlj:function(a,n,s){return a(n,s)},EhxYA:t(1708),rDhWK:function(a,n){return a!==n},AXZHX:t(1190),YGLJc:function(a,n){return a>>>n},YTCVm:function(a,n){return a+n},cMHLp:function(a,n){return a|n},bgnSE:function(a,n){return a>=n},RZCgM:function(a,n){return a&n},xtAYn:function(a,n,s,d){return a(n,s,d)},cbmhB:"VRqwV",HKQOC:function(a,n,s){return a(n,s)},jHIFg:t(1004)+"|8|5|9|0|2|11|4|1",pNSLX:function(a,n){return a<n},ISQch:function(a,n){return a>>>n},EKxZo:function(a,n,s,d){return a(n,s,d)},uVDxa:function(a,n){return a<n},WSdkG:function(a,n){return a|n},jddWP:function(a,n){return a|n},ldsRB:function(a,n){return a|n},VjDXT:function(a,n){return a&n},sUkdP:t(1013),kfcdG:function(a,n){return a instanceof n},IzcWv:function(a,n){return a+n},LIooS:function(a,n){return a||n},RUwyY:t(771)+"d",tliha:function(a,n){return a||n},vGUJA:function(a,n){return a!=n},DFqfG:"next() c"+t(547)+t(831)+t(1113)+t(1417),AlGdB:function(a,n){return a<n},asvgX:function(a,n){return a<n},qBUMZ:function(a,n){return a&n},Rxoru:function(a,n){return a-n},xVZmH:function(a,n){return a<=n},lazzo:function(a,n){return a|n},nhrbj:function(a,n){return a&n},jmutK:function(a,n){return a<n},DaTXN:function(a,n){return a|n},xSegW:function(a,n){return a|n},Ksjsc:function(a,n){return a&n},wtajP:function(a,n){return a|n},AaTxc:function(a,n){return a|n},gspIP:function(a,n){return a&n},wyfRf:function(a,n){return a<<n},LzyRO:function(a,n){return a&n},JBCTt:function(a,n){return a<<n},oNBLr:function(a,n){return a&n},QjbKF:function(a,n){return a&n},JrZMy:function(a,n){return a<=n},SjhfX:function(a,n){return a<n},wfxev:function(a,n){return a>>n},rliTg:function(a,n){return a&n},rbEAQ:function(a,n){return a===n},UlqHP:function(a,n){return a|n},HDRyk:function(a,n){return a&n},mBnMk:function(a,n){return a<<n},ppXiC:function(a,n){return a&n},HoWhu:function(a,n){return a>>n},XnxdE:function(a,n){return a|n},rzENe:t(1234),RSzrJ:t(877),LHwcB:function(a,n){return a>>n},LgqhD:function(a,n){return a|n},WGAOX:function(a,n){return a&n},SEpQa:function(a,n){return a-n},BUhnJ:t(496),OUlzI:"string",jghcl:function(a,n){return a===n},KtGSQ:t(1130),FnxrB:t(351),KxCVA:function(a,n){return a instanceof n},TZlqF:function(a,n){return a+n},svwAw:function(a,n){return a|n},flfiC:function(a,n){return a&n},YSaHx:function(a,n){return a(n)},JXIuO:function(a,n){return a instanceof n},hxxDD:function(a,n){return a!=n},HbfIQ:t(687),NDqtS:t(1789)+t(1253)+t(1017),fxOaG:"boe",pRgGT:t(1385),mqmpu:function(a,n){return a(n)},UsSYm:t(846)+t(296)+t(1170)+"P",URqis:t(1617),FgaEn:t(1407),owDLd:function(a){return a()},DzWLO:function(a,n,s,d){return a(n,s,d)},WxYxw:function(a,n){return a+n},BjIdS:function(a,n,s){return a(n,s)},jdJbX:function(a,n){return a===n},rzFYe:t(992),jPmWb:function(a,n){return a===n},QbEMu:t(1397),VVQoZ:t(1451),fsOzp:t(1482),UxhKT:function(a,n){return a(n)},vkrZw:t(885),YkKcP:function(a,n){return a-n},KvGjh:"DGjrd",xkmhh:function(a,n){return a||n},YQNez:t(1436),uIHES:t(1221),KgMgO:t(1646),GtKKk:t(1103),QtRoF:t(867),kbCCT:function(a,n){return a||n},wpSsK:t(1723),KgHzK:t(1445)+"id",eohld:"going aw"+t(1719)+t(1828)+"ine",PaDGG:function(a,n){return a<n},FVGCe:t(1628),qFwNR:t(324),gbEcu:t(1241),FuVkj:t(555),EtrUP:function(a,n){return a(n)},YSYhb:function(a,n){return a|n},VgSxh:function(a,n){return a<<n},rqefH:function(a,n){return a===n},ycZMy:function(a,n){return a<n},xAxSK:function(a,n){return a<n},jowDm:function(a,n){return a<n},huejT:function(a,n,s){return a(n,s)},MQmTe:function(a,n){return a&n},HDtAg:function(a,n){return a+n},rDOUl:function(a,n){return a!==n},YkFBI:function(a,n){return a&n},GZKXl:function(a,n){return a|n},jOqqN:function(a,n){return a&n},VwzGw:function(a,n){return a&n},QJEXw:function(a,n){return a>>>n},lmbWi:function(a,n){return a&n},zvpAC:function(a,n){return a&n},eWqxu:t(1509),qrDfn:t(1312),RNyRL:"9|1|3|8|"+t(1262)+t(953)+"5",aLQVM:function(a,n){return a>>>n},tOWUi:function(a,n){return a&n},HoWIO:function(a,n){return a|n},aVgCS:function(a,n,s,d){return a(n,s,d)},pBAAK:function(a,n){return a>>>n},xhalk:function(a,n){return a<<n},wxXRA:function(a,n){return a&n},ZHWTS:function(a,n){return a>>>n},WuTXp:function(a,n){return a|n},qVMbH:function(a,n){return a<n},zeNoU:function(a,n){return a|n},ADDlJ:function(a,n){return a|n},TfyJI:function(a,n){return a<n},uJWpk:function(a,n){return a|n},vnXrv:function(a,n){return a<n},nvBlj:function(a,n){return a&n},MhdcR:t(414),ysOIW:function(a,n){return a(n)},hTtLm:function(a,n){return a!==n},YxUFe:t(542),dzVOv:"x_fronti"+t(1298),CMKRM:t(1415)+t(1391)+"k",sZgKA:t(1378),JIbca:"is_ack",EFxco:t(630),JeDQO:function(a){return a()},Ntjry:t(1582),ENgDy:function(a){return a()},JkUuY:function(a,n){return a(n)},pgdYE:function(a,n){return a instanceof n},RLppS:t(1019)+t(1087),pAFZM:t(1019)+t(1087)+t(503)+t(1049),JDrNR:t(907)+"e",slfXH:"binary",eCnPq:t(1656),vFdJW:function(a,n){return a>n},gbrsS:function(a,n){return a&n},xYMfS:function(a,n){return a+n},epGUF:function(a,n){return a+n},wZpIW:function(a,n){return a+n},JxzCL:t(1148)+t(362)+"ge: ",CDRHV:t(937),igjhv:function(a,n){return a+n},BsLyf:function(a,n){return a<<n},Yeyeb:t(521)+"4",zrUlK:function(a,n){return a+n},bhCAo:function(a,n,s,d){return a(n,s,d)},Bplry:function(a,n){return a>>>n},xHQer:function(a,n){return a|n},sCejZ:function(a,n){return a|n},hnvYK:function(a,n){return a<<n},gkXqn:function(a,n){return a+n},cQHYx:function(a,n){return a<<n},nqwRr:function(a,n){return a<<n},MGBiC:function(a,n){return a|n},uwAJr:function(a,n){return a|n},YEBGI:function(a,n){return a+n},VtUBQ:function(a,n){return a+n},QDajy:function(a,n){return a>>>n},YcfOu:function(a,n){return a+n},pzcfI:function(a,n){return a+n},zhCOj:function(a,n){return a>>>n},usPcJ:function(a,n){return a&n},gVYev:function(a,n){return a+n},xIkuS:function(a,n){return a>>>n},zwdaK:function(a,n){return a&n},cVbxG:function(a,n){return a>>>n},hJJVp:function(a,n){return a+n},FzLqZ:function(a,n){return a+n},jgvMu:function(a,n){return a&n},sjOnM:function(a,n){return a+n},pfRRS:t(534),jgQZD:function(a,n){return a||n},sQsha:function(a,n){return a>>>n},cAhEI:function(a,n){return a<n},WXrdx:function(a,n){return a|n},nenhj:function(a,n){return a&n},ChaFY:function(a,n){return a|n},EcfWX:function(a,n){return a+n},npjmn:"2|0|6|5|1|9|8|4|"+t(288),NhmmA:"service",ALvhe:t(1163),ROEUl:t(1720)+"name",pSeir:function(a,n){return a(n)},GFwKa:function(a,n){return a(n)},JmkVV:t(826)+t(1338),bwqJm:function(a,n,s,d){return a(n,s,d)},dPMJq:t(758)+t(760),IjYNS:"iLicz",yeLAo:t(656),GTsvp:"cursor_n"+t(1817),oudDZ:t(361),jfvKv:t(1279),IQkKP:"CONTINUE",JzqzW:t(812),SDRZX:"setdb",aJXBS:function(a,n){return a(n)},amJzi:t(495)+"r",qxZRi:t(1762),WtlYG:"WkKQm",Qiskq:function(a,n){return a||n},mFHXs:t(939),cBfSq:t(432),sWWeS:"reconnect",Xhqxl:t(1544),EADVv:t(1472),pKuEy:function(a,n,s,d){return a(n,s,d)},mrdLJ:t(1415)+t(1426),GRvFS:t(477)+"s",TuRve:function(a,n,s){return a(n,s)},HejUq:t(1799)+t(1344)+"e",XabJF:function(a,n){return a(n)},zKAxv:function(a,n,s){return a(n,s)},GPOur:t(1799)+t(593)+"ue",LvoXD:function(a,n){return a>n},DnoaD:function(a,n){return a===n},cCxjM:t(1354),nKAUJ:function(a){return a()},OAYJM:function(a,n){return a===n},akOag:t(1800),CIvqt:function(a,n){return a<n},tZStL:function(a,n){return a===n},KatyX:function(a,n){return a===n},jnDwZ:function(a,n){return a&&n},qwwvF:function(a){return a()},fcdRJ:function(a,n){return a(n)},htRGx:function(a,n,s,d){return a(n,s,d)},DtIEG:t(228),yfqdE:function(a,n,s){return a(n,s)},rbJaw:"bye",IIxkU:function(a,n){return a!==n},jKINh:function(a,n,s,d){return a(n,s,d)},UELWu:t(1099),dMxrV:t(638),OPmFr:function(a,n){return a===n},hPGUt:function(a,n){return a===n},sSLif:t(788),CMMDN:t(1145),KPsBr:t(1549),GJccT:function(a,n){return a!==n},dcrLp:t(843),aGzIo:t(425)+t(1144),Pbveq:t(1420),LKwxv:t(322)+t(431)+t(1107),qmsUx:function(a,n){return a(n)},KKFgr:function(a,n,s){return a(n,s)},qLLYA:"stop imm"+t(1666)+" reconnect",WDVLX:t(1322),GoRjo:t(1321),PUOvJ:t(1052),OiuZs:"pagehide",BHRay:"ziiJI",GwNdG:function(a,n){return a!==n},ZFQSD:function(a,n){return a!==n},uHAyS:function(a,n){return a==n},xtPIz:t(308),PWmxm:"bd_did",xZYTu:t(1255),RLGky:"please p"+t(661)+t(1373)+t(1680)+t(1765),KChui:function(a,n){return a==n},XshUG:t(1232),CfsMQ:"web",rjmMy:function(a,n,s){return a(n,s)},cJXNt:function(a,n,s){return a(n,s)},lvIkT:function(a,n){return a-n},pFGea:function(a,n){return a(n)},TQccg:t(936),MJFWj:t(1686),oEGgk:function(a,n){return a*n},UpEMC:function(a,n){return a===n},ywNxj:function(a,n,s){return a(n,s)},TcxOn:t(699),aTiMM:t(1083)+t(967)+t(919)+t(1731)+t(510),AFBgN:function(a){return a()},qJDlv:function(a,n,s){return a(n,s)},JEJfe:"Scdrl",odLEO:t(733),XFPKO:t(1022)+" try rec"+t(1192)+"g",mfjxA:function(a,n){return a!==n},MMThD:function(a,n){return a>>>n},ANyBB:function(a,n){return a>>>n},nrSWA:function(a,n){return a===n},nyFzN:t(1104),xOwfa:function(a,n){return a(n)},fPIyG:"1|0|2|3|4",gmHPu:"1|2|0|4|3",cTveQ:"DHIGf",uZNlK:function(a,n,s){return a(n,s)},Aqses:function(a,n,s){return a(n,s)},EVFbu:t(1475),GIwlT:t(1603)+">",mlykh:"ycwzK",bizES:"kOKPm",YHMqz:t(749),nmqUU:t(1703)+t(419),dRRXS:function(a,n){return a===n},punyY:t(485)+"s already closed",iXloa:"close, w"+t(1406)+"ce not i"+t(1108)+"ed",vUKmA:function(a,n){return a||n},iTMoU:function(a,n){return a>>>n},xPwrN:function(a,n){return a<n},vqPmO:function(a,n){return a>n},nTpsS:function(a,n){return a+n},osGWW:function(a,n){return a(n)},llLqu:function(a,n){return a|n},qSTKX:function(a,n){return a==n},GhBWe:"please provide a"+t(1463)+t(1244)+t(1743)+t(1492)+t(675)+t(1519)+"ffer",xRaMz:function(a,n){return a==n},OEpBm:t(353),cCXuU:t(322)+t(1139)+t(1155)+t(805),JUJjB:function(a,n){return a instanceof n},cKLEC:function(a,n){return a(n)},HXlKx:"sent",fetpm:function(a,n){return a<n},aluLW:t(1292),zmRwD:function(a,n){return a===n},ZaGmS:"zrWtU",FAlqN:function(a,n){return a<n},RfZHW:"manual r"+t(1323)+"ing",ogWQi:t(1702),wmCJa:"vYmrG",sTxgX:t(1812)+"1",QrxxZ:"VyYvr",blliK:function(a,n){return a(n)},fxtDG:function(a,n,s){return a(n,s)},fMYeN:function(a,n){return a|n},PXehU:function(a,n){return a&n},qCXAy:function(a,n){return a&n},LurcE:t(976),lyqZc:function(a,n){return a*n},SoDuu:function(a,n){return a===n},bgSDe:t(1589),qfkhq:function(a,n){return a===n},dqfLt:function(a,n){return a!=n},prXqu:function(a,n){return a===n},BwBrM:function(a,n){return a!=n},HvoKh:function(a,n){return a===n},FPgDj:t(1461),Pcecc:function(a,n){return a==n},muJPo:function(a,n){return a!=n},fcriC:t(920)+"dWorkerG"+t(1050)+"pe",reCPR:function(a,n){return a===n},RuWRj:t(1563)+"orkerGlo"+t(1178),YjsDz:function(a,n,s){return a(n,s)},HOhXs:"__x_msg_qos__"};Bt.r(Re),Bt.d(Re,{FWS:()=>Wp,CustomErrorEvent:()=>Wd,createCloseEvent:()=>ht,ReconnectEvent:()=>Hd,createErrorEvent:()=>at,decodedFrame:()=>tn,createOpenEvent:()=>Xd,CustomCloseEvent:()=>Kd,createReconnectEvent:()=>ca,FrontierMessageEvent:()=>Vd,encodeFrame:()=>Ut,createMessageEvent:()=>Zd,OpenEvent:()=>Jd,ErrorCode:()=>rn,Event:()=>tr,MessageEvent:()=>$d});let r="";function i(a=""){let n=t;if(e[n(1320)]!==e[n(1280)]){let d=""+Date[n(1098)](),f=r||(r=x(a)),p=Math[n(1459)]()[n(1063)](16)[n(1651)](-6);return e[n(586)](e.oPslN("02"+d,f),p)}else this[n(827)]&&this._ws[n(608)](_0x4ae0d4),this[n(891)+"Queue"][_0x142599]=null}function o(){let a=t;return e.aVJxw(e[a(821)](1e4,Date.now()),Math.floor(e.qUdCw(1e4,Math[a(1459)]())))}function c(a){let n=t;return e[n(1122)](e.iMudL(Array,8).join("0"),e[n(574)](parseInt,a,10)[n(1063)](2))[n(1651)](-8)}function l(a){let n=t;return e[n(1608)](Array(4)[n(786)]("0"),e[n(574)](parseInt,a,2)[n(1063)](16))[n(1651)](-4)}function u(a){let n=t,s={DHwLP:e[n(1300)],yKjui:function(d,f){return d+f}};if(e[n(1584)](n(339),e[n(1725)])){let d={Pbypr:s[n(1829)]},f=_0x49e254[n(1365)][n(1651)](_0x475fca[n(655)+"et"],s[n(1450)](_0x1591dc[n(253)+"th"],_0x52798c[n(655)+"et"]));this._socket&&this[n(1430)][n(608)]({data:f,fail:p=>{let m=n;this[m(866)](d[m(245)],_0x19fcc8(d[m(245)],{message:this[m(1157)+"rrorMessage"](p)}))}})}else{let d=a[n(702)](/\./)[n(947)](m=>c(m)),f=[];return f[0]=e[n(998)](l,e.ciNUu(d[0],d[1])),f[1]=e[n(1306)](l,e[n(706)](d[2],d[3])),[e[n(384)],e[n(384)],e[n(384)],e.gVOec,e[n(384)],e[n(1094)],f[0],f[1]][n(786)]("")}}function x(a){let n=t;if(e[n(269)](n(930),e[n(1575)]))this._isBrowser&&_0x30e628[n(256)+n(1431)+n(564)](n(1526),this["_handleP"+n(819)]),this[n(1672)+"er"]&&_0x4fc85e["removeEv"+n(1431)+n(564)]("pageshow",this["_handleP"+n(1440)]),this[n(1081)]();else{let s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(373)](a),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(a);return s?e[n(1341)](u,a):d?e.UDhKr(g,a):e[n(1342)]}}function g(a){let n=t,s="",d=[],f=0,p=0,m=!0,_=e.gVOec;if(e[n(1176)](a[n(1578)]("::"),-1)){let h=a[n(702)]("::");for(let R=0;e[n(1025)](R,h.length);R++){let M=h[R];if(e[n(707)](M[n(1578)](":"),0)){let F=M[n(702)](":");m&&(f=F.length),p+=F[n(599)];for(let H=0;H<F[n(599)];H++)if(F[H][n(599)]!==4){let de=_[n(1027)+"g"](0,4-F[H][n(599)]),Ie=de[n(1416)](F[H]);d[n(411)](Ie)}else d.push(F[H]);m=!1}else{if(e[n(269)](4,M[n(599)])){let F=_[n(1027)+"g"](0,4-M[n(599)]),H=F.concat(M);d[n(411)](H)}else d[n(411)](M);m&&(f+=1),p+=1,m=!1}}let I="";for(let R=0;e[n(1025)](R,e[n(1455)](8,p));R++)I=I[n(1416)](_);for(let R=0;e[n(1025)](R,d[n(599)]);R++)e[n(1584)](R,f)&&(s=s[n(1416)](I)),s=s[n(1416)](d[R]);return s}{let h=a[n(702)](":");for(let I=0;I<h[n(599)];I++){if(e[n(269)](e[n(1679)],e[n(1679)]))return this[n(1569)]?.[n(1411)];{let R=h[I];if(e[n(602)](4,h[I][n(599)]))if(e.xVpcC!==e.inygQ){let M=_[n(1027)+"g"](0,e[n(1455)](4,h[I][n(599)])),F=M[n(1416)](R);s=s[n(1416)](F)}else return new _0x238d9e(e.mmphj(e[n(795)](_0x479fe5[0]|_0x21997d[1]<<8,e[n(567)](_0x4677f8[2],16)),e[n(1643)](_0x331f65[3],24)),e[n(1595)](e.QvynW(_0x1e6a45[4]|e[n(1643)](_0x1948c3[5],8),e[n(258)](_0x54e7ca[6],16)),e.XVyDI(_0xf44d40[7],24)),_0x2fd1cb);else s=s[n(1416)](R)}}return s}}function w(a,n){let s=t;if(e[s(1286)](s(729),e[s(990)]))e.NDqKD(_0xb2fb4,s(699)),this[s(1399)](e[s(1162)],_0xb50006),this[s(1399)](e[s(340)],_0x2675c9);else{let d=a[s(767)];e[s(412)](void 0,d)&&(fe(n,10),j(n,d));let f=a[s(1403)];f!==void 0&&(e[s(1747)](fe,n,18),j(n,f))}}function E(a){let n=t,s={KkjZc:function(d,f,p,m){return e[N(487)](d,f,p,m)}};if(e.fLiuH("LDhTY",e[n(1427)])){let d={};e:for(;!e.YPXZJ($,a);){let f=e[n(1339)](ue,a);switch(e[n(1467)](f,3)){case 0:break e;case 1:d[n(767)]=L(a,ue(a));break;case 2:d.value=e[n(721)](L,a,e.XxRPT(ue,a));break;default:e.CDUDk(D,a,7&f)}}if(e[n(1195)](void 0,d[n(767)]))throw new Error(n(917)+n(1660)+n(1075)+n(767));if(e[n(1195)](void 0,d[n(1403)]))throw new Error(n(917)+n(1660)+n(1075)+n(1403));return d}else throw _0x2b59ba=_0x2c9176[n(599)],s[n(365)](_0x138c33,_0x14a472,10,_0x5e40ee[n(599)])}function S(a){let n=t,s=e[n(357)](k);return e[n(574)](y,a,s),e[n(1306)](B,s)}function y(a,n){let s=t,d=a[s(482)];if(e[s(602)](void 0,d)){if(e[s(269)](s(618),e[s(282)]))return new _0x5223cb(_0x42347e,{message:_0x4169e3,code:_0x20bed6,error:_0x233f0d});e[s(574)](fe,n,8),e[s(737)](xt,n,d)}let f=a.LogID;e[s(424)](void 0,f)&&(fe(n,16),e[s(415)](xt,n,f));let p=a[s(1515)];e[s(881)](void 0,p)&&(e[s(1478)](fe,n,24),e[s(1389)](xt,n,e.IdjpR(P,p)));let m=a[s(550)];e[s(602)](void 0,m)&&(fe(n,32),e[s(457)](xt,n,e[s(1306)](P,m)));let _=a.headers;if(_!==void 0)for(let Ie of _){e.bwqxX(fe,n,42);let ee=k();e.fngCs(w,Ie,ee),e[s(1786)](fe,n,ee[s(1441)]),e[s(1635)](K,n,ee),e.YPXZJ(O,ee)}let h=a[s(1613)+"ncoding"];e[s(868)](void 0,h)&&(fe(n,50),e[s(1165)](j,n,h));let I=a[s(710)+s(1316)];e.IWfIH(void 0,I)&&(e[s(1389)](fe,n,58),e[s(1635)](j,n,I));let R=a[s(691)];e.JRTYM(void 0,R)&&(e[s(822)](fe,n,66),e[s(737)](fe,n,R[s(599)]),pe(n,R));let M=a[s(1616)];e[s(424)](void 0,M)&&(fe(n,74),e[s(1478)](j,n,M));let F=a["serverTi"+s(1592)];F!==void 0&&(fe(n,82),j(n,F));let H=a.msgID;H!==void 0&&(e[s(580)](fe,n,90),e[s(1635)](j,n,H));let de=a[s(289)+"e"];e[s(378)](void 0,de)&&(e[s(574)](fe,n,96),e.dVuCQ(xt,n,e[s(1306)](P,de)))}function v(a){let n=t;if(e[n(1180)]===e[n(1362)])if(_0x432029=_0x318c3f[n(280)+"At"](_0x387131),e[n(1480)](_0x196726,128))_0x30b060[_0x5c5914++]=_0x144241;else if(e[n(647)](_0x543250,2048))_0x29f05d[_0x36d75a++]=e[n(1595)](e[n(681)](_0x3137ee,6),192),_0x3d67dd[_0x3a67df++]=e[n(1215)](63&_0x3880fa,128);else if(e.etwXK(e.bsmSL(64512,_0x27e6c3),55296)&&e.ojTIG(e[n(563)](64512,_0x3b39bc=_0x29dc1a[n(280)+"At"](e[n(940)](_0x592dc1,1))),56320)){let s=e[n(1767)][n(702)]("|"),d=0;for(;;){switch(s[d++]){case"0":_0x21cc8e=e[n(1774)](e[n(1191)](65536,e[n(567)](1023&_0x18496d,10)),e.Nkzof(1023,_0xc8bf6));continue;case"1":++_0x8afb25;continue;case"2":_0x2ff8d0[_0x5bcf23++]=e[n(413)](_0x1c14fe>>6,63)|128;continue;case"3":_0x4ef384[_0x31d82c++]=e.JUlva(e.WPdls(63,_0x57305c),128);continue;case"4":_0x1f8c58[_0x37eec2++]=e[n(899)](_0x3aee11,18)|240;continue;case"5":_0x4b5650[_0x5313d2++]=e[n(1595)](e.bsmSL(e[n(986)](_0x569210,12),63),128);continue}break}}else _0x435a87[_0x45cc8e++]=e[n(681)](_0x112bd9,12)|224,_0x38fe8d[_0x31e9ea++]=e.Ondln(e[n(1166)](e[n(899)](_0x27d044,6),63),128),_0x57b01e[_0x31dd58++]=e.LwpWq(63&_0x44a6aa,128);else return e[n(1352)](A,e[n(1038)](U,a))}function A(a){let n=t,s={};e:for(;!e[n(1601)]($,a);){let d=e.zWfSU(ue,a);switch(e.RDlHQ(d,3)){case 0:break e;case 1:s[n(482)]=St(a,!0);break;case 2:s.LogID=e[n(574)](St,a,!0);break;case 3:s[n(1515)]=e[n(435)](ue,a);break;case 4:s.method=e[n(759)](ue,a);break;case 5:{let f=T(a);(s[n(326)]||(s[n(326)]=[]))[n(411)](e[n(1306)](E,a)),a[n(1441)]=f;break}case 6:s[n(1613)+n(1423)]=e[n(737)](L,a,e.oGQGI(ue,a));break;case 7:s[n(710)+n(1316)]=L(a,e.ujfHz(ue,a));break;case 8:s[n(691)]=Se(a,ue(a));break;case 9:s[n(1616)]=e[n(457)](L,a,e[n(1339)](ue,a));break;case 10:s[n(1717)+n(1592)]=e[n(1389)](L,a,e[n(715)](ue,a));break;case 11:s[n(1057)]=e[n(972)](L,a,e[n(1601)](ue,a));break;case 12:s[n(289)+"e"]=ue(a);break;default:e[n(1786)](D,a,7&d)}}if(e[n(1286)](void 0,s[n(482)]))throw new Error(e[n(1443)]);if(e[n(1072)](void 0,s[n(1197)]))throw new Error(e[n(354)]);if(e[n(1195)](void 0,s[n(1515)]))throw new Error(e[n(1657)]);if(e[n(1286)](void 0,s[n(550)]))throw new Error(e[n(1307)]);return s}function T(a){let n=t;if(e[n(254)](e[n(1152)],e[n(1368)]))return _0x43bdaa?.find(s=>s[n(767)]===_0x590706)?.[n(1403)];{let s=e[n(393)](ue,a),d=a[n(1441)];return a.limit=a[n(1614)]+s,d}}function D(a,n){let s=t;switch(n){case 0:for(;e.wUySr(128,e[s(1272)](ie,a)););break;case 2:e[s(1711)](J,a,e[s(1387)](ue,a));break;case 5:e[s(721)](J,a,4);break;case 1:e[s(737)](J,a,8);break;default:throw new Error(s(921)+s(382)+s(423)+n)}}function P(a){let n=t;return a|=0,{low:a,high:e.qFZqK(a,31),unsigned:e[n(1665)](a,0)}}let b=[];function k(){let a=t,n=b[a(740)]();return n?(n.offset=n[a(1441)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(a){b[t(411)](a)}function U(a){return{bytes:a,offset:0,limit:a[t(599)]}}function B(a){let n=t,s=a[n(1760)],d=a[n(1441)];return s[n(599)]===d?s:s[n(696)](0,d)}function J(a,n){let s=t;if(a[s(1614)]+n>a[s(1441)])throw new Error(s(1791)+s(240));a.offset+=n}function $(a){let n=t;return e[n(262)](a[n(1614)],a[n(1441)])}function re(a,n){let s=t,d=a[s(1760)],f=a[s(1614)],p=a[s(1441)],m=f+n;if(e.YTIiH(m,d[s(599)])){let _=new Uint8Array(e.zVbTF(2,m));_[s(839)](d),a[s(1760)]=_}return a[s(1614)]=m,e.VxXWz(m,p)&&(a.limit=m),f}function X(a,n){let s=t,d=a.offset;if(e[s(720)](e.qppbZ(d,n),a.limit))throw new Error(e[s(475)]);return a[s(1614)]+=n,d}function Se(a,n){let s=t,d={iWJRc:function(f,p){return e.nENPO(f,p)}};if(e[s(1311)](e[s(924)],s(1202))){let f=this._qosDB[s(1206)](this[s(359)]),p=_0x7bd195[s(915)](d[s(1716)](f,"{}"));return p[_0x439465]=void 0,this._qosDB[s(1510)](this[s(359)],_0x952a6a.stringify(p))}else{let f=X(a,n);return a[s(1760)][s(696)](f,e[s(1121)](f,n))}}function pe(a,n){let s=t,d=re(a,n.length);a[s(1760)][s(839)](n,d)}function L(a,n){let s=t,d=e.OPyMe(X,a,n),f=String["fromChar"+s(1559)],p=a[s(1760)],m="\uFFFD",_="";for(let h=0;e[s(647)](h,n);h++){let I=p[e[s(1122)](h,d)],R,M,F,H;if(e.PilHO(e.IFwlt(128,I),0))_+=e[s(435)](f,I);else if(e.jcgNh(e.wUySr(224,I),192))if(e[s(302)](e[s(683)](h,1),n))_+=m;else if(R=p[e[s(940)](e[s(236)](h,d),1)],e[s(412)](192&R,128))_+=m;else{if(e[s(1652)](e[s(1688)],e[s(1688)]))return e[s(1132)](e[s(348)](1e4,_0x1a9bd9[s(1098)]()),_0x3f5fe6.floor(1e4*_0x1ffc93[s(1459)]()));if(H=e[s(689)]((31&I)<<6,e[s(563)](63,R)),e[s(1219)](H,128))_+=m;else if(e[s(881)](s(1383),s(1070)))_+=e[s(1732)](f,H),h++;else return _0x341199[s(757)+s(1559)](e[s(413)](255,this[s(1220)]),e.rSTfG(e[s(622)](this[s(1220)],8),255),e.bQSLE(this[s(1220)],16)&255,e[s(1467)](this.low,24),e[s(413)](255,this[s(858)]),e.zbCeb(this[s(858)],8)&255,e[s(287)](this[s(858)],16)&255,e.CPnPc(this.high,24))}else e.WPdls(240,I)==224?e[s(747)](e.wXVXk(h,2),n)?_+=m:(R=p[e.wXVXk(h,d)+1],M=p[e[s(1608)](h+d,2)],e[s(868)](e[s(778)](e[s(1803)](R,e[s(726)](M,8)),49344),32896)?_+=m:(H=e.Ondln(e[s(1523)](e[s(1412)](15,I),12),e[s(660)](63,R)<<6)|63&M,e[s(1186)](H,2048)||e[s(302)](H,55296)&&e[s(330)](H,57343)?_+=m:(_+=e[s(301)](f,H),h+=2))):e[s(1521)](e.Syfqs(248,I),240)?e[s(931)](h,3)>=n?_+=m:(R=p[e[s(292)](h,d)+1],M=p[e[s(706)](h,d)+2],F=p[e[s(1381)](h,d)+3],e[s(269)](e[s(1285)](e[s(1054)](e[s(344)](R,M<<8),e[s(1303)](F,16)),12632256),8421504)?_+=m:(H=e[s(1054)](e[s(1369)](e[s(1523)](7&I,18),e[s(1701)](e[s(447)](63,R),12))|e[s(422)](e[s(270)](63,M),6),e[s(1412)](63,F)),e[s(975)](H,65536)||H>1114111?_+=m:(H-=65536,_+=f(e[s(601)](e[s(319)](H,10),55296),e.dhRlU(e[s(893)](1023,H),56320)),h+=3))):_+=m}return _}function j(a,n){let s=t,d={OZzJT:function(h,I){return e[N(1286)](h,I)},AmRNq:function(h,I){return e[N(1009)](h,I)},ozAEG:function(h,I){return e[N(1774)](h,I)},gwwlk:function(h,I){return h+I}},f=n.length,p=0;for(let h=0;h<f;h++){let I=n[s(280)+"At"](h);e[s(302)](I,55296)&&e[s(1429)](I,56319)&&e[s(886)](h,1)<f&&(I=e.RjZZX(e[s(931)](e.lzEsf(I,10),n[s(280)+"At"](++h)),56613888)),p+=e.GrUKU(I,128)?1:e.QqUPN(I,2048)?2:e[s(1186)](I,65536)?3:4}fe(a,p);let m=e[s(1478)](re,a,p),_=a[s(1760)];for(let h=0;e[s(1184)](h,f);h++){let I=n[s(280)+"At"](h);if(e.KDVAw(I,55296)&&e[s(1499)](I,56319)&&e[s(1084)](h+1,f)&&(I=e[s(1455)](e[s(940)](I<<10,n.charCodeAt(++h)),56613888)),e.qwNid(I,128))_[m++]=I;else if(e[s(540)]("gZtbp",e[s(1203)]))e.TqLNY(I,2048)?_[m++]=e.kqZqg(e.HcygM(e[s(1043)](I,6),31),192):(e[s(823)](I,65536)?_[m++]=e[s(761)](e.QfOYc(I>>12,15),224):(_[m++]=e[s(776)](e[s(968)](e.nITjO(I,18),7),240),_[m++]=e.omGzI(e.nITjO(I,12)&63,128)),_[m++]=e[s(795)](I>>6&63,128)),_[m++]=e[s(938)](63&I,128);else return d[s(736)](-1,this[s(1220)])&&d[s(1231)](-1,this[s(858)])?_0x1b3ffd.fromBits(0,0,this[s(1532)]):this[s(1220)]===-1?_0x4ba3dc[s(1685)](0,d[s(641)](this[s(858)],1),this[s(1532)]):_0x122788[s(1685)](d[s(1453)](this[s(1220)],1),this[s(858)],this.unsigned)}}function K(a,n){let s=t,d=e[s(1670)](re,a,n[s(1441)]),f=a[s(1760)],p=n.bytes;for(let m=0,_=n.limit;e.vaNlx(m,_);m++)f[e.QDiUv(m,d)]=p[m]}function ie(a){let n=t;return a[n(1760)][e[n(607)](X,a,1)]}function Xe(a,n){let s=t,d=e.OAIHA(re,a,1);a[s(1760)][d]=n}function ue(a){let n=t;if(e[n(378)](e[n(492)],e[n(781)])){let s=0,d=0,f;do if(e.QhXyn(e[n(1694)],e.TJrwd))f=ie(a),e[n(823)](s,32)&&(d|=(127&f)<<s),s+=7;else return _0x24ae90|=0,{low:_0x41fc78,high:e[n(986)](_0x5ee35c,31),unsigned:e.zazSt(_0x36beb6,0)};while(e[n(300)](128,f));return d}else _0x326730[n(411)](_0x5dd547)}function fe(a,n){let s=t;for(n>>>=0;n>=128;)e[s(1525)](Xe,a,e.mHzeA(127&n,128)),n>>>=7;e.TJejK(Xe,a,n)}function St(a,n){let s=t,d=0,f=0,p=0,m;return m=ie(a),d=127&m,128&m&&(m=e.FPHKT(ie,a),d|=e[s(1523)](e[s(1642)](127,m),7),e[s(660)](128,m)&&(m=e[s(539)](ie,a),d|=e[s(1493)](127&m,14),e[s(1562)](128,m)&&(m=e.zZLkz(ie,a),d|=e[s(1493)](e.ogzao(127,m),21),e[s(300)](128,m)&&(m=e[s(715)](ie,a),f=127&m,e.NPuqW(128,m)&&(e[s(254)](s(754),e[s(1128)])?(this[s(1291)+s(1645)+s(662)]=_0x170da9,_0x3e8133?this[s(752)+s(1259)]():this[s(752)+s(908)]()):(m=e[s(1498)](ie,a),f|=e[s(1225)](e[s(1476)](127,m),7),128&m&&(e[s(895)](s(1727),e.rsYLV)?(m=e[s(438)](ie,a),f|=(127&m)<<14,e[s(561)](128,m)&&(m=e[s(727)](ie,a),f|=e.gktBQ(e.NPuqW(127,m),21),e[s(1412)](128,m)&&(m=e[s(998)](ie,a),p=e[s(1713)](127,m),128&m&&(m=e[s(1341)](ie,a),p|=e[s(660)](127,m)<<7)))):this[s(1399)](_0x195a05,_0x22bacd)))))))),{low:e[s(529)](d,e.xrvCi(f,28)),high:e[s(529)](e[s(1421)](f,4),p<<24),unsigned:n}}function xt(a,n){let s=t;if(e.bPLll(e[s(832)],e[s(832)]))_0x162eca=e[s(393)](_0x101fd8,_0x54138b),_0x33e820|=e.qcUUY(e[s(1545)](127,_0x18dc27),14),e[s(1438)](128,_0x3cbe80)&&(_0x19a359=_0x3d82d5(_0x443795),_0x24a1f8|=e[s(1801)](127,_0x33db04)<<21,128&_0x2238eb&&(_0x37607e=_0x59f18c(_0x1e4473),_0x122fe7=e[s(1545)](127,_0x16dc1e),e[s(1040)](128,_0x3864a1)&&(_0x406b97=e.ZTNSv(_0x2f9003,_0x476982),_0x2b300f|=e[s(1643)](e[s(769)](127,_0x407215),7))));else{let d=n.low>>>0,f=e.RGrtl(e.DXKll(n[s(1220)],28)|e[s(626)](n[s(858)],4),0),p=e.RGrtl(n[s(858)],24),m=e[s(369)](0,p)?f===0?e[s(975)](d,16384)?e[s(666)](d,128)?1:2:e[s(1780)](d,2097152)?3:4:e[s(647)](f,16384)?e[s(645)](f,128)?5:6:e[s(1010)](f,2097152)?7:8:e[s(1219)](p,128)?9:10,_=re(a,m),h=a[s(1760)];switch(m){case 10:h[e[s(236)](_,9)]=e[s(1226)](e[s(957)](p,7),1);case 9:h[e[s(1622)](_,8)]=m!==9?e.URqNy(128,p):e[s(1023)](127,p);case 8:h[e.QOIrD(_,7)]=m!==8?e[s(795)](e[s(987)](f,21),128):e[s(413)](f>>>21,127);case 7:h[e[s(601)](_,6)]=m!==7?e[s(1595)](f>>>14,128):e.pyoaE(e[s(1421)](f,14),127);case 6:h[e[s(523)](_,5)]=e[s(1350)](6,m)?f>>>7|128:e[s(1313)](e[s(668)](f,7),127);case 5:h[e[s(931)](_,4)]=m!==5?e.WBmEq(128,f):e[s(1734)](127,f);case 4:h[_+3]=e[s(1810)](4,m)?e[s(1803)](e.RGrtl(d,21),128):e[s(1086)](e[s(1421)](d,21),127);case 3:h[_+2]=m!==3?e[s(287)](d,14)|128:e[s(561)](e[s(1458)](d,14),127);case 2:h[e[s(1122)](_,1)]=e[s(1607)](2,m)?e.RGrtl(d,7)|128:d>>>7&127;case 1:h[_]=m!==1?e[s(753)](128,d):e[s(1775)](127,d)}}}function tn(a){return e.CHrzk(v,a)}function Ut(a){return e[t(1632)](S,a)}let nn=65536,Zr=e[t(239)],me=e.Uugav(nn,nn),Ae=e[t(237)](me,me),er=Ae/2,Pe=String[t(974)+"e"].charCodeAt;class ce{constructor(n,s,d){let f=t;this[f(1629)]=!0,this[f(1220)]=e[f(1346)](0,n),this[f(858)]=0|s,this.unsigned=!!d}static[t(1629)](n){let s=t,d={ppUzX:function(f,p){return e[N(1455)](f,p)},HuOsO:function(f,p){return f|p},kxgfF:function(f,p){return e[N(776)](f,p)},rlxhN:function(f,p){return f&p},tnbUu:function(f,p){return e[N(491)](f,p)},aVTfZ:function(f,p){return e.wUySr(f,p)},mlybM:function(f,p){return f&p},feOTG:function(f,p){return e[N(851)](f,p)}};if(e[s(530)](e[s(1290)],s(1698))){let f=d.ppUzX(d[s(1364)](d[s(1434)](d[s(1209)](7,_0x4c0560)<<18,d[s(1335)](d.aVTfZ(63,_0x1497b1[_0x438854++]),12))|(63&_0x5ae591[_0x3a4e29++])<<6,d.mlybM(63,_0x23dff7[_0x52e10f++])),65536);_0x4fdab3+=_0x585d9c["fromChar"+s(1559)](55296+d[s(390)](f,10)),_0x338ed1+=_0x2bb325[s(757)+s(1559)](56320+d.rlxhN(1023,f))}else return n&&e[s(548)](!0,n[s(1629)])}static[t(1685)](n,s,d){return new ce(n,s,d)}static fromBytes(n,s,d){let f=t;return d?ce[f(969)+"sLE"](n,s):ce[f(969)+"sBE"](n,s)}static["fromByte"+t(603)](n,s){let d=t;return new ce(e[d(946)](e[d(471)](n[0]|e[d(1303)](n[1],8),e[d(772)](n[2],16)),n[3]<<24),e.iVoby(e[d(1215)](n[4],e.baiLa(n[5],8))|e[d(452)](n[6],16),e[d(1218)](n[7],24)),s)}static[t(969)+t(502)](n,s){let d=t;return new ce(e.PoTKz(e.VyiOd(e[d(751)](n[4],24),n[5]<<16),e[d(227)](n[6],8))|n[7],e[d(795)](e.mfVoD(e.dRYUW(n[0],24),e[d(588)](n[1],16))|e[d(588)](n[2],8),n[3]),s)}static[t(1246)](n){let s=t;return e[s(1554)](n,Zr)?jd:new ce(e[s(987)](e.AUzac(e[s(1215)](e[s(955)](Pe[s(1214)](n,0),e[s(1243)](Pe[s(1214)](n,1),8)),e[s(567)](Pe[s(1214)](n,2),16)),Pe[s(1214)](n,3)<<24),0),e.DXKll(e[s(761)](Pe.call(n,4),Pe[s(1214)](n,5)<<8)|Pe[s(1214)](n,6)<<16|e[s(1650)](Pe[s(1214)](n,7),24),0),!0)}[t(1424)](){let n=t;return String[n(757)+n(1559)](255&this[n(1220)],e[n(734)](this.low,8)&255,e[n(413)](e[n(287)](this[n(1220)],16),255),e[n(1404)](this[n(1220)],24),e.fgEAi(255,this[n(858)]),e[n(680)](e.RGrtl(this[n(858)],8),255),e[n(480)](this.high>>>16,255),this.high>>>24)}static[t(1735)+"er"](n,s=!0){let d=t,f={MGuDS:function(p,m,_){return p(m,_)},WGSlL:function(p,m,_){return e[N(1258)](p,m,_)}};if(e[d(998)](isNaN,n))return s?rp:jd;if(s)if(e[d(1428)](e[d(355)],e.SMDSi)){if(n>=Ae)return sp}else jNeUVX[d(1790)](_0x50a92e,_0x3d4f71,82),jNeUVX[d(1692)](_0x3788a4,_0x599162,_0x9ad0a6);else{if(n<=-er)return op;if(e[d(262)](e[d(1074)](n,1),er))return ip}return ce.fromBits(e[d(222)](e[d(537)](n,me),0),e[d(938)](e[d(1740)](n,me),0),s)}[t(273)](){let n=t;return this[n(1532)]?e[n(451)](e[n(1751)](this.high>>>0,me),e[n(1211)](this[n(1220)],0)):e[n(1392)](this.high,me)+e[n(1348)](this.low,0)}[t(604)](){let n=t;return e[n(1002)](0,this[n(858)])&&e[n(1097)](0,this.low)}add(n){let s=t;ce.isLong(n)||(n=ce[s(1735)+"er"](n));let d=e.LDSKe(this[s(858)],16),f=e[s(270)](65535,this.high),p=e[s(1147)](this[s(1220)],16),m=e[s(1775)](65535,this[s(1220)]),_=n[s(858)]>>>16,h=e.UbRfs(65535,n[s(858)]),I=n.low>>>16,R=e[s(1044)](65535,n[s(1220)]),M=0,F=0,H=0,de=0;return de+=e[s(238)](m,R),H+=e[s(622)](de,16),de&=65535,H+=e[s(549)](p,I),F+=e[s(506)](H,16),H&=65535,F+=e[s(523)](f,h),M+=e[s(622)](F,16),F&=65535,M+=e.lmDZw(d,_),M&=65535,ce[s(1685)](e[s(955)](H<<16,de),e[s(1691)](M,16)|F,this[s(1532)])}[t(1310)](n){let s=t;return ce[s(1629)](n)||(n=ce[s(1735)+"er"](n)),e[s(1062)](this.unsigned,n[s(1532)])&&e.RGrtl(this[s(858)],31)===1&&e[s(768)](n.high>>>31,1)?!1:e.AmXSq(this[s(858)],n[s(858)])&&this[s(1220)]===n[s(1220)]}addOne(){let n=t;return e[n(1286)](-1,this.low)&&this[n(858)]===-1?ce.fromBits(0,0,this[n(1532)]):e[n(1446)](-1,this[n(1220)])?ce[n(1685)](0,e[n(549)](this[n(858)],1),this.unsigned):ce[n(1685)](this[n(1220)]+1,this[n(858)],this[n(1532)])}[t(693)](n){return n?this[t(1026)+"E"]():this.toBytesBE()}[t(1026)+"E"](){let n=t,s=this[n(858)],d=this.low;return[e[n(1438)](255,d),e.OReBl(e[n(1458)](d,8),255),e[n(1223)](e[n(1147)](d,16),255),e[n(287)](d,24),e[n(1661)](255,s),e[n(399)](s>>>8,255),e[n(1667)](e[n(221)](s,16),255),e[n(1348)](s,24)]}toBytesBE(){let n=t;if(e[n(1637)](n(342),e[n(1626)])){let s=this[n(858)],d=this[n(1220)];return[e[n(506)](s,24),e[n(1775)](e[n(271)](s,16),255),e[n(668)](s,8)&255,e[n(876)](255,s),e[n(734)](d,24),e[n(1044)](d>>>16,255),e[n(957)](d,8)&255,e[n(900)](255,d)]}else _0xc5ad56=_0x403015[e.QDiUv(e[n(278)](_0x96a946,_0x520d8c),1)],_0xcf5e0a=_0x177820[e.EpbWP(e[n(1333)](_0x1f7e7d,_0x17f999),2)],e[n(1607)](e[n(300)](e.YXTxH(_0x35a6b1,e[n(1218)](_0x286464,8)),49344),32896)?_0x1109dc+=_0x5af5ed:(_0x4e3df5=e.URqNy(e[n(1125)](e[n(1247)](15&_0x158d44,12),e[n(1367)](e[n(1142)](63,_0x1d2d0b),6)),e[n(447)](63,_0x320f35)),e[n(589)](_0x4bcd3f,2048)||e[n(1508)](_0x2c0226,55296)&&e[n(352)](_0x4cee3c,57343)?_0x82c780+=_0x5f2b10:(_0x13a819+=e[n(320)](_0x3dedb8,_0x23f754),_0x4a61af+=2))}}let jd=new ce(0,0,!1),rp=new ce(0,0,!0),ip=ce[t(1685)](-1,2147483647,!1),sp=ce[t(1685)](-1,-1,!0),op=ce[t(1685)](0,-2147483648,!1);var rn=(function(a){let n=t;return a[a[e[n(1653)]]=5001]=n(1560)+"RROR",a[a[e[n(884)]]=5002]=e[n(884)],a[a[n(1746)+n(225)+"R"]=5003]=n(1746)+n(225)+"R",a[a[e[n(1797)]]=5004]=e.gxrIQ,a[a[e[n(949)]]=5005]=n(1639)+"OR",a})({});class tr{constructor(n){let s=t;this[s(430)]=n,this.target=null}}class Hd extends tr{constructor(n,s){let d=t;super(n),this[d(1708)]=s&&s[d(1708)]||null}}class Wd extends tr{constructor(n,s){let d=t;super(n),this[d(1135)]=s&&s[d(1135)]||null,this[d(587)]=s&&s[d(587)]||0,this[d(1029)]=s&&s[d(1029)]||"",this[d(600)]=s&&s[d(600)]||0,this[d(1708)]=s&&s.message||"",this[d(1472)]=s&&s.code||5001}}class Kd extends tr{constructor(n,s){let d=t;super(n),this[d(1472)]=s&&s[d(1472)]||0,this.reason=s&&s[d(1543)]||"",this[d(223)]=s&&s[d(223)]||!1,this[d(1745)+d(1654)]=s&&s[d(1745)+"nnect"]||!1}}class $d extends tr{constructor(n,s){let d=t;if(e.sVFPd(e[d(1011)],e[d(445)]))return this[d(1430)].url;super(n),this[d(1317)]=s&&s[d(1317)]||null}}class Vd extends $d{constructor(n,s){let d=t;super(n),this[d(1317)]=s&&s[d(1317)]||null,this.message=s&&s.message||null}}class Jd extends tr{constructor(n,s){let d=t;super(n),this[d(1317)]=s&&s[d(1317)]||null}}function at(a,{message:n,code:s,error:d}){return new Wd(a,{message:n,code:s,error:d})}function ht(a,{code:n,reason:s,wasClean:d,willReconnect:f}){return new Kd(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function Zd(a,{data:n,message:s}){return new Vd(a,{data:n,message:s})}function Xd(a,{data:n}){return new Jd(a,{data:n})}function ca(a,{message:n}){let s=t;return e[s(318)]("MCNeT",s(830))?null:new Hd(a,{message:n})}class Yd{constructor(n,s){let d=t;this[d(1707)+"s"]=n,this[d(746)+"es"]=s,this[d(958)+"ndex"]=0,this["currentE"+d(1763)+d(860)+"t"]=0}[t(1100)+t(1238)+t(1363)](){let n=t;this[n(958)+"ndex"]=0,this["currentE"+n(1763)+"riesCount"]=0}[t(241)+"es"](){let n=t;this[n(524)+n(1763)+"riesCount"]=0}getCurrentEndpoint(){let n=t;return this[n(1707)+"s"][this[n(958)+n(1766)]]}[t(1295)+t(1469)+"ntTriesC"+t(1326)](){let n=t;return this["currentE"+n(1763)+n(860)+"t"]}[t(1360)+"chMaxTries"](){let n=t;return this[n(958)+n(1766)]>=this[n(1707)+"s"][n(599)]||this["currentI"+n(1766)]===e[n(1455)](this[n(1707)+"s"].length,1)&&this["currentE"+n(1763)+n(860)+"t"]===this[n(746)+"es"]}[t(959)+"rentEndp"+t(1495)+t(377)+t(628)](){let n=t;return e.mTQlo(this[n(958)+n(1766)],this[n(1707)+"s"][n(599)])?!0:e[n(389)](this[n(524)+n(1763)+n(860)+"t"],this[n(746)+"es"])}[t(625)+t(977)+t(1565)+t(525)+"unt"](){let n=t;return this[n(524)+n(1763)+n(860)+"t"]=1,this[n(958)+n(1766)]++,this[n(1707)+"s"][this["currentI"+n(1766)]]}["getCurrentEndpoi"+t(479)+t(985)](){let n=t;return this["currentE"+n(1763)+n(860)+"t"]++,this[n(1295)+n(1469)+"nt"]()}}let nr=(e[t(1610)](e.RUwyY,typeof globalThis)&&e.SoDuu(e[t(331)],globalThis.constructor[t(1337)])||e[t(1505)]!=typeof window&&e.qfkhq(e[t(331)],window[t(276)+t(1167)][t(1337)]))&&e[t(1497)](t(771)+"d",typeof document),Rn=t(771)+"d"!=typeof globalThis&&(e.prXqu("Object",globalThis[t(276)+"tor"].name)||t(920)+"dWorkerG"+t(1050)+"pe"===globalThis[t(276)+t(1167)][t(1337)])&&e[t(337)](t(771)+"d",typeof tt),Xr=(e.hxxDD(e[t(1505)],typeof globalThis)&&e[t(398)](e[t(913)],globalThis[t(276)+"tor"].name)||e[t(1051)](e[t(1505)],typeof globalThis)||typeof globalThis<"u"&&!!globalThis[t(777)+t(1631)])&&e[t(932)](e[t(1505)],typeof wx),Yr=e.BwBrM(e[t(1505)],typeof globalThis)&&(e[t(1311)](e.fcriC,globalThis[t(276)+"tor"].name)||e[t(347)]("SharedWorkerGlobalScope",globalThis[t(276)+t(1167)][t(1337)])||e[t(1584)](e[t(281)],globalThis[t(276)+"tor"][t(1337)]))&&e[t(1041)](e.RUwyY,typeof self),ap=e[t(1497)](e.RUwyY,typeof globalThis)&&globalThis[t(276)+t(1167)][t(1337)]==="Object"&&e[t(1505)]!=typeof global&&e[t(701)](e.FPgDj,global["construc"+t(1167)][t(1337)])&&e[t(337)](e[t(1505)],typeof process)&&!!process[t(1064)];class da{constructor(){let n=t;this[n(1620)+"rs"]={}}[t(866)](n,...s){let d=t,f=this._listeners[n];if(f)f[d(1651)]()[d(1146)](p=>p.fn[d(332)](p[d(1825)],s));else if(e[d(1300)]===n&&!this[d(783)]){let p=s.length&&s[0];if(p instanceof Error)throw p;let m=new Error(d(1710)+d(1324)+(p?e[d(1779)](e.dhRlU(" (",p[d(1708)]),")"):""));throw m.context=p,p}return this}[t(1399)](n,s){let d=t,f={eAeCe:e[d(1245)],kIJIb:e[d(1162)],YaNaZ:d(417)+d(1599)+"t"};if(e[d(768)](e[d(793)],e[d(793)])){if(e[d(548)](void 0,n))this[d(1620)+"rs"]={};else if(s===void 0)this._listeners[n]=null;else if(d(634)==="AMRNJ"){let p={XYDZU:function(h,I){return e[d(763)](h,I)},yvfDI:e[d(1162)],YVHZx:d(417)+d(1599)+"t"};this["_clearPi"+d(1294)](),this[d(875)+"gTimeoutId"]=e[d(1409)](_0x14ba92,this[d(1413)].bind(this),this[d(1564)][d(730)+d(1116)]);let m=()=>{let h=d;_0x1e8fc0(f[h(383)]),this[h(1399)](f[h(376)],m),this.off(f[h(677)],_)},_=()=>{let h=d;p[h(1270)](_0x493567,h(699)),this[h(1399)](p.yvfDI,m),this.off(p[h(1230)],_)};this.on(e[d(1162)],m),this.on(e[d(340)],_),this[d(1413)]()}else{let p=this._listeners[n];if(p)for(let m=0;e.wOcrI(m,p.length);)e.lDPUf(p[m].fn,s)?p.splice(m,1):++m}return this}else this[d(1620)+"rs"]={}}on(n,s,d){let f=t;return(this[f(1620)+"rs"][n]||(this[f(1620)+"rs"][n]=[])).push({fn:s,ctx:d||this}),this}}class cp extends da{[t(1157)+t(912)+t(516)](n){let s=t;return n[s(650)]||n[s(570)]?("message: "+(n[s(650)]||"")+s(1721)+(n.errNo||""))[s(1393)]():JSON.stringify(n)}constructor(n,s,d){let f=t;super(),this[f(1430)]=null,Xr&&wx[f(1172)+f(1500)]&&(this[f(1430)]=wx[f(1172)+f(1500)]({url:n,protocols:s,header:d,fail:this[f(1551)+f(897)+f(979)][f(672)](this),success:this[f(1551)+f(896)+f(1477)+"ler"].bind(this)})),Rn&&tt[f(1172)+f(1500)]&&(this[f(1430)]=tt[f(1172)+"ocket"]({url:n,protocols:s,header:d,fail:this[f(1551)+f(897)+f(979)][f(672)](this),success:this[f(1551)+f(896)+f(1477)+f(610)][f(672)](this)}))}[t(1551)+t(896)+t(1477)+t(610)](){let n=t,s={OxaUI:function(d,f){return d||f}};if(e[n(1442)]===n(685))Promise.resolve()[n(980)](()=>{let d=n;this[d(242)+d(1452)]()});else{if(_0x155b7a)return new _0x3fa8e6(_0x3621c8[n(731)],_0x1ef072[n(566)]);if(s[n(1755)](_0x34d8a0,_0x47f25f))return new _0x393d43(_0x5347c0.url,_0x121276[n(566)],_0x477524[n(326)]);if(s[n(1755)](_0x116a06,_0xe579a6)&&n(771)+"d"!=typeof _0x36dbb6&&_0x5c3e50)return new _0x57d77d(_0x355eee[n(731)],_0x99927b[n(566)+"s"])}}[t(1551)+"ocketFai"+t(979)](n){let s=t,d={NrkaC:e[s(293)],lvUEg:function(f,p){return f!==p},KVDrX:e[s(1217)],MRKZo:function(f,p,m){return e.YASNS(f,p,m)},zNkQg:e[s(1300)],oUfFR:e[s(1229)]};Promise[s(429)]()[s(980)](()=>{let f=s;if(d.lvUEg(d[f(1462)],d[f(1462)])){let p=d.NrkaC.split("|"),m=0;for(;;){switch(p[m++]){case"0":this[f(1061)]();continue;case"1":this[f(1408)+f(863)]?.[f(1100)+"pointCon"+f(1363)]();continue;case"2":this[f(1012)+f(1699)]?.[f(1807)+f(532)]();continue;case"3":this[f(264)+f(824)]=!1;continue;case"4":this[f(460)]=!0;continue}break}}else{let p=d[f(1754)](at,d[f(1502)],{message:this[f(1157)+"rrorMess"+f(516)](n)});this[f(866)](d[f(1502)],p);let m=d[f(1754)](ht,d[f(1278)],{reason:this[f(1157)+f(912)+f(516)](n)});this[f(866)](d[f(1278)],m)}})}["_addWsLi"+t(1452)](){let n=t,s={Xymnj:function(d,f){return e[N(1404)](d,f)},wUArd:function(d,f){return e.BrFlU(d,f)},tgemu:function(d,f){return d&f},fpJAi:function(d,f){return e[N(1200)](d,f)},QcZVy:function(d,f){return e[N(1285)](d,f)},okDil:function(d,f){return e[N(1779)](d,f)},UNqpq:function(d,f){return e[N(658)](d,f)},eoQoj:function(d,f){return e[N(278)](d,f)},TPJFy:function(d,f){return e[N(938)](d,f)},QGBgw:function(d,f){return d<<f},XWIFa:function(d,f){return e[N(405)](d,f)},vJlEW:function(d,f){return d<<f}};this[n(1430)][n(1257)](d=>{let f=n;this[f(866)](e[f(572)],e[f(1159)](Xd,e[f(572)],{...d,data:d[f(650)]||""}))}),this[n(1430)][n(942)](d=>{let f=n;this[f(866)](f(1081),e[f(1513)](ht,f(1081),{...d}))}),this[n(1430)][n(1516)+"e"](d=>{let f=n;this[f(866)](f(1708),e[f(789)](Zd,e[f(1468)],{...d}))}),this[n(1430)][n(1376)](d=>{let f=n;if(e[f(643)](e.AXZHX,e.AXZHX)){_0x43a7b0[f(1629)](_0x329cd6)||(_0x2cc7d5=_0x4c016d.fromNumber(_0x59092d));let p=USUFAk[f(799)](this.high,16),m=USUFAk[f(865)](65535,this[f(858)]),_=USUFAk[f(799)](this.low,16),h=USUFAk.tgemu(65535,this[f(1220)]),I=USUFAk.Xymnj(_0x14aae6[f(858)],16),R=USUFAk.tgemu(65535,_0x530fb7.high),M=USUFAk.fpJAi(_0x29b4a7.low,16),F=USUFAk[f(299)](65535,_0x300932[f(1220)]),H=0,de=0,Ie=0,ee=0;return ee+=USUFAk[f(787)](h,F),Ie+=ee>>>16,ee&=65535,Ie+=USUFAk[f(836)](_,M),de+=Ie>>>16,Ie&=65535,de+=m+R,H+=USUFAk[f(1281)](de,16),de&=65535,H+=USUFAk[f(371)](p,I),H&=65535,_0x3ae968[f(1685)](USUFAk.TPJFy(USUFAk[f(1669)](Ie,16),ee),USUFAk[f(1036)](USUFAk[f(1288)](H,16),de),this[f(1532)])}else this[f(866)](f(1135),e[f(996)](at,e.nWCZr,{...d,message:d[f(650)]||""}))})}send(n){let s=t;if(e[s(1260)](n,Uint8Array)){let d=n[s(1365)][s(1651)](n.byteOffset,e.IzcWv(n[s(253)+"th"],n[s(655)+"et"]));this[s(1430)]&&this[s(1430)].send({data:d,fail:f=>{let p=s,m={jcXqj:function(_,h){return e[N(389)](_,h)},ZbZnr:function(_,h){return e[N(700)](_,h)},eRkyo:function(_,h){return e[N(714)](_,h)},HIMqb:function(_,h,I,R){return e.xtAYn(_,h,I,R)},sMRGO:function(_,h){return e[N(601)](_,h)},BNrgj:function(_,h){return _+h}};if(e[p(1709)]!==e.cbmhB){if(m[p(474)](_0x287b00,_0xf45b9))throw new _0x30fcba("integer too large");let _=3;for(;m[p(648)](_,0);){let h=m[p(501)](255,_0x25f7be);m[p(623)](_0x2e46a7,h,_0x53990a,m[p(1371)](_0x342d82,_)),_0x102143>>>=8,_--}return m.BNrgj(_0x326c93,4)}else this.emit(e[p(1300)],e.HKQOC(at,e[p(1300)],{message:this[p(1157)+p(912)+"age"](f)}))}})}else this[s(1430)]&&this[s(1430)][s(608)]({data:n,fail:d=>{let f=s,p={LFpDf:e[f(1449)],mqpZJ:function(m,_){return e[f(1071)](m,_)},LegjV:function(m,_){return e[f(344)](m,_)},rwLYO:function(m,_){return m<<_},ErLct:function(m,_){return e.fgEAi(m,_)},QgBFZ:function(m,_){return e.ISQch(m,_)},qegZd:function(m,_){return m|_},FSMib:function(m,_){return e[f(1176)](m,_)},bXmAd:function(m,_,h,I){return e.EKxZo(m,_,h,I)},ExpTN:function(m,_){return e[f(1821)](m,_)},dZfwy:function(m,_){return e[f(1572)](m,_)},hKxdo:function(m,_){return e[f(834)](m,_)},hZFyE:function(m,_){return e[f(506)](m,_)},hdDRx:function(m,_){return e[f(1143)](m,_)},XXYmP:function(m,_){return e[f(756)](m,_)},ljxwv:function(m,_){return e[f(1348)](m,_)},DnVfA:function(m,_){return m|_}};if(f(1013)===e.sUkdP)this[f(866)](e[f(1300)],e[f(1165)](at,f(1135),{message:this[f(1157)+f(912)+f(516)](d)}));else{let m=4294967295;return function(_,h,I=!0){let R=f,M=p[R(1201)][R(702)]("|"),F=0;for(;;){switch(M[F++]){case"0":if(p.mqpZJ(_[h++],128))return{value:I?m:p[R(1359)](0,m),offset:h};continue;case"1":return{value:I?m:p[R(1359)](0,m),offset:h};case"2":m=p[R(1359)](m,p[R(1741)](p[R(368)](15,_[h]),28))>>>0;continue;case"3":m=p[R(614)](p[R(991)](m,p[R(1741)](p[R(368)](127,_[h]),7)),0);continue;case"4":if(p.FSMib(h+=5,_[R(599)]))throw h=_[R(599)],p[R(1621)](_0x56f8e8,h,10,_[R(599)]);continue;case"5":if(p[R(568)](_[h++],128))return{value:I?m:p[R(1359)](0,m),offset:h};continue;case"6":if(p[R(1188)](_[h++],128))return{value:I?m:p[R(991)](0,m),offset:h};continue;case"7":if(_[h++]<128)return{value:I?m:p.dZfwy(0,m),offset:h};continue;case"8":m=p[R(1473)](m,p[R(1741)](127&_[h],14))>>>0;continue;case"9":m=p[R(848)](p[R(801)](m,p.rwLYO(p.XXYmP(127,_[h]),21)),0);continue;case"10":m=p.ljxwv(p[R(368)](127,_[h]),0);continue;case"11":if(p[R(1188)](_[h++],128))return{value:I?m:p[R(1048)](0,m),offset:h};continue}break}}}}})}close(n,s){let d=t;this._socket&&this[d(1430)][d(1081)]({code:n,reason:s})}[t(1512)+t(724)](n,s){this.on(n,s)}[t(256)+t(1431)+t(564)](n,s){this[t(1399)](n,s)}get[t(284)+"te"](){let n=t;return this[n(1430)][n(284)+"te"]}get[t(1683)+"pe"](){return this[t(1430)].binaryType}set binaryType(n){}get[t(731)](){return this[t(1430)].url}get[t(566)](){let n=t;return this[n(1430)][n(566)]}get extensions(){let n=t;return this[n(1430)][n(1065)+"ns"]}get[t(327)+t(1655)](){return 0}}function dp(a,n){let s=t;if(n)return new n(a[s(731)],a[s(566)]);if(e[s(1073)](Xr,Rn))return new cp(a[s(731)],a[s(566)],a[s(326)]);if(e[s(1432)](nr,Yr)&&e[s(1505)]!=typeof WebSocket&&WebSocket)return new WebSocket(a[s(731)],a[s(566)+"s"])}function lp(a){let n=t;return!!(a||Xr&&wx[n(1172)+n(1500)]||Rn&&tt[n(1172)+n(1500)]||e.tliha(nr,Yr)&&e[n(1610)](n(771)+"d",typeof WebSocket)&&WebSocket)}function Qd(a,n,s){let d=-1;async function f(p){let m=N;return e[m(330)](p,d)?Promise[m(993)](new Error(e[m(250)])):(d=p,e[m(1533)](p,s[m(599)])?Promise.resolve():s[p][m(672)](a)(n,f[m(672)](null,p+1)))}f(0)}function el(a){let n=t,s=0,d=0;for(let f=0;e[n(494)](f,a[n(599)]);++f)d=a[n(280)+"At"](f),e[n(910)](d,128)?s+=1:e[n(1590)](d,2048)?s+=2:e.qBUMZ(64512,d)===55296&&e.BMmqM(e[n(1223)](64512,a[n(280)+"At"](f+1)),56320)?(++f,s+=4):s+=3;return s}function tl(a,n,s){let d=t;if(e[d(704)](e[d(718)](s,n),1))return"";let f="";for(let p=n;e[d(1184)](p,s);){let m=a[p++];if(e[d(518)](m,127))f+=String[d(757)+d(1559)](m);else if(e.zazSt(m,192)&&m<224)f+=String[d(757)+"Code"](e[d(1e3)](e[d(1247)](e[d(725)](31,m),6),e.XIHQk(63,a[p++])));else if(m>=224&&e.jmutK(m,240))f+=String[d(757)+d(1559)](e[d(395)](e[d(1357)](e[d(1691)](e[d(1577)](15,m),12),e.dRYUW(e[d(1545)](63,a[p++]),6)),e[d(893)](63,a[p++])));else if(e[d(747)](m,240)){let _=e[d(955)](e[d(1718)](e.AaTxc(e[d(726)](e[d(577)](7,m),18),e.wyfRf(e[d(627)](63,a[p++]),12)),e[d(1228)](e[d(233)](63,a[p++]),6)),e[d(1567)](63,a[p++]))-65536;f+=String[d(757)+d(1559)](e[d(586)](55296,e[d(851)](_,10))),f+=String["fromChar"+d(1559)](e[d(1381)](56320,1023&_))}}return f}function la(a,n,s){let d=t,f={NCmOp:function(h,I){return e[N(1479)](h,I)}},p=s,m,_;for(let h=0;h<a[d(599)];++h)if(m=a[d(280)+"At"](h),e[d(1060)](m,128))n[s++]=m;else if(e[d(743)](m,2048))n[s++]=e[d(1327)](e[d(1634)](m,6),192),n[s++]=e.rliTg(63,m)|128;else if(e[d(1554)](e[d(1223)](64512,m),55296)&&e.rbEAQ(e[d(498)](64512,_=a[d(280)+"At"](e[d(1381)](h,1))),56320)){let I=(d(592)+d(988))[d(702)]("|"),R=0;for(;;){switch(I[R++]){case"0":n[s++]=e[d(319)](m,12)&63|128;continue;case"1":n[s++]=e[d(1583)](e[d(343)](63,m),128);continue;case"2":m=e[d(586)](65536,e.mBnMk(e[d(270)](1023,m),10))+(1023&_);continue;case"3":n[s++]=e[d(312)](e[d(1647)](e.HoWhu(m,6),63),128);continue;case"4":++h;continue;case"5":n[s++]=e[d(1276)](e[d(899)](m,18),240);continue}break}}else if(e.rzENe===e[d(1329)]){if(uHpoOr[d(1808)](_0x5ae36c,-_0x85c7e))return _0x27ab10;if(_0x2d43fb+1>=_0x1b9b58)return _0x37d7bb}else n[s++]=e[d(1511)](m,12)|224,n[s++]=e[d(712)](m>>6&63,128),n[s++]=e[d(1583)](e.WGAOX(63,m),128);return e[d(454)](s,p)}async function nl(a){let n=t;if(e[n(378)](e.BUhnJ,n(496)))this[n(1430)]&&this[n(1430)][n(1081)]({code:_0xe9fee0,reason:_0x3febc4});else{if(e[n(257)]==typeof a)if(e[n(490)](e[n(1079)],e[n(1594)])){if(!this[n(827)])return;this[n(1778)+n(739)+"t"](_0x4096d7,_0x2223c2,_0x19ff66)}else{let s=new Uint8Array(e[n(438)](el,a));return e.xtAYn(la,a,s,0),s}return e[n(960)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1365)],a[n(655)+"et"],a.byteLength)}}function up(a){let n=t;try{return e.OUlzI!=typeof a&&(e.KxCVA(a,ArrayBuffer)||a[n(1365)]&&e.JXIuO(a[n(1365)],ArrayBuffer))||e[n(1041)](n(434),typeof a)?"":(JSON[n(915)](a),"applicat"+n(1087))}catch{if(e[n(1554)](n(687),e[n(473)]))return typeof a=="string"?e[n(1542)]:"";_0x246586=_0x199585[e[n(356)](_0x361afb+_0x1133a9,1)],e[n(283)](e.xdjmh(192,_0x43f107),128)?_0x203673+=_0x5d3ab1:(_0x40dcfc=e.svwAw(e[n(845)](31&_0x271e68,6),e.flfiC(63,_0x2433d2)),e[n(1586)](_0x5dab43,128)?_0x4b9b41+=_0x91afe0:(_0x22b905+=e[n(392)](_0x1a51bf,_0x4f75f8),_0x2cd3ad++))}}let fp=(a,n)=>{let s=t;switch(a){case e[s(1031)]:case e[s(1328)]:return{[s(1008)+a]:1,"x-tt-env":n};default:return{}}};class xp{constructor(n){let s=t;this[s(1085)+s(1326)]=n,this[s(1273)]=0}[t(1550)](){let n=t;this[n(1273)]++}["checkRea"+t(1556)+"nt"](){let n=t;return e.KDVAw(this[n(1273)],this[n(1085)+n(1326)])}[t(1807)+"nter"](n=0){let s=t;e[s(1554)](s(444),s(1136))?_0x13aef4(_0x191220,this[s(268)+s(1705)+"e"](_0x29e150)):(this[s(1085)+s(1326)]=n,this[s(1273)]=0)}}async function hp(a){let n=t,s={kensO:function(d,f){return e[N(1090)](d,f)},OakuE:n(591)+n(1543),OycDz:n(1681)+"ascript",egbHn:e[n(1248)]};return new Promise(d=>{let f=n;if(!nr)return s[f(629)](d,s[f(765)]);try{let p=document[f(1818)+"ement"](f(1092));window["frontier"+f(1205)]=m=>{let _=f;document.body[_(1032)+_(226)](p),window[_(1039)+_(1205)]=void 0,s.kensO(d,m&&m[_(1250)]||s[_(765)])},p[f(430)]=s[f(1187)],p[f(1704)]=a[f(467)](/^ws/,"http")+s[f(1164)];try{document[f(522)]["appendCh"+f(226)](p)}catch{document[f(522)]["removeCh"+f(226)](p)}}catch{window.frontierJSONP=void 0,s[f(629)](d,s.OakuE)}})}function sn(a,n,s){let d=t;return!!a?.[d(927)](f=>f[d(767)]===n&&f[d(1403)]===s)}function rr(a,n){let s=t;return a?.[s(927)](d=>d[s(767)]===n)?.[s(1403)]}let ua=null;async function pp(){let a=t;return ua||(ua=Promise[a(429)]()[a(980)](Bt[a(672)](Bt,e[a(1437)]))),ua}class gp extends da{constructor(n,s){let d=t;super(),this[d(1265)]=n,this[d(466)]=s,this[d(1569)]=void 0,this[d(1633)+d(717)]=null}async openDB(){await this._init()}async[t(1769)](){let n=t,s={VvWOd:e[n(1124)],eyBwy:function(d){return e[n(462)](d)},pJkvH:function(d,f,p,m){return e[n(249)](d,f,p,m)}};if(!this[n(1569)]){if(this[n(1633)+n(717)])return this[n(1633)+n(717)];try{let d=this._dbName,f=this[n(466)];this[n(1633)+"mise"]=(async()=>{let p=n,m={CzAuc:function(_,h,I){return _(h,I)},mPmtn:function(_,h){return _(h)}};if(s[p(325)]==="AdjUA"){let _=_0x3cdda7();return qbTZuE[p(1302)](_0x32be8e,_0x2be1b7,_),qbTZuE[p(784)](_0x18cf51,_)}else{let{openDB:_}=await s[p(1644)](pp);this[p(1569)]=await s.pJkvH(_,"frontier_"+d,1,{upgrade(h){h[p(1068)+"jectStore"](d,{keyPath:f})}})}})(),await this[n(1633)+n(717)]}catch(d){console[n(1410)](d)}finally{this[n(1633)+n(717)]=null}}}async[t(1336)](n){let s=t;try{return await this[s(1769)](),this[s(1569)]?.[s(1336)](this[s(1265)],n)}catch(d){console.log(d)}}async[t(839)](n,s){let d=t;return await this[d(1769)](),this[d(1569)]?.put(this[d(1265)],n)}async[t(294)](n){let s=t;try{return await this[s(1769)](),this[s(1569)]?.[s(543)](this._dbName,n)}catch(d){console[s(1410)](d)}}async[t(232)](){let n=t,s={DzzWU:function(d,f){return e[N(488)](d,f)},UkRLn:function(d,f){return e.siLYD(d,f)},PdDTN:function(d,f,p){return e.BjIdS(d,f,p)},MYqCf:function(d,f){return e[N(734)](d,f)},cYALW:function(d,f){return e.qcUUY(d,f)}};try{if(e.jdJbX(n(1109),e[n(964)])){let d=0,f=_0x220293,p=s[n(581)](_0x30334f,4);for(;s[n(303)](f,p);){let{value:m,offset:_}=s[n(1659)](_0x314e24,_0x201378,f);f=_,d=s[n(809)](s.cYALW(d,8),0),d+=m}return{value:d,offset:p}}else return await this[n(1769)](),this[n(1569)]?.[n(232)](this[n(1265)])}catch(d){console.log(d)}}async[t(409)](){let n=t;return await this[n(1769)](),this[n(1569)]?.[n(862)+"ys"](this._dbName)}async[t(852)](){let n=t;return await this[n(1769)](),this._qosDB?.[n(852)](this[n(1265)])}async closeDB(){let n=t;try{this[n(1569)]?.[n(1081)](),this._qosDB=void 0}catch(s){console[n(1410)](s)}}get[t(1411)](){let n=t;if(e[n(436)](e.QbEMu,e.VVQoZ))this[n(958)+n(1766)]=0,this[n(524)+n(1763)+n(860)+"t"]=0;else try{return!!this[n(1569)]}catch(s){return console[n(1410)](s),!1}}}class mp{constructor(n,s){let d=t;this._DBName=n,this[d(427)]=s,this._qosDB=localStorage}async openDB(){}get[t(359)](){let n=t;if(e[n(369)](e[n(945)],e[n(945)]))return"frontier_"+this[n(695)];++_0x2a9bfe,_0x2986e1+=4}async[t(1336)](n){let s=t,d={nujGl:function(f,p){return e[N(671)](f,p)}};if(e.vkrZw===e.vkrZw){let f=this[s(1569)][s(1206)](this[s(359)]);return JSON[s(915)](e.tliha(f,"{}"))[n]}else return cNUitC[s(679)](_0x1f1242,_0x2e23a0(_0x97772f))}async[t(839)](n,s){let d=t,f=this[d(1569)][d(1206)](this[d(359)]),p=JSON[d(915)](f||"{}");return p[s||n[this[d(427)]]]=n,this[d(1569)][d(1510)](this[d(359)],JSON.stringify(p)),s||n[this[d(427)]]}async del(n){let s=t,d=this[s(1569)][s(1206)](this._prefix),f=JSON[s(915)](d||"{}");return f[n]=void 0,this._qosDB[s(1510)](this[s(359)],JSON.stringify(f))}async[t(232)](){let n=t;return this[n(1569)][n(232)]()}async[t(409)](){let n=t;if(e[n(254)](e.KvGjh,e[n(450)])){let s=this[n(1569)].getItem(this[n(359)]),d=JSON[n(915)](s||"{}");return Object.keys(d)}else{let s=_0x52540d[n(702)](":");for(let d=0;e[n(645)](d,s[n(599)]);d++){let f=s[d];if(e[n(269)](4,s[d][n(599)])){let p=_0x107d8c[n(1027)+"g"](0,e[n(1091)](4,s[d][n(599)])),m=p[n(1416)](f);_0x56105f=_0x305bae.concat(m)}else _0x3f35fc=_0x4676b7[n(1416)](f)}return _0x557dd9}}async getAll(){let n=t,s=this[n(1569)][n(1206)](this[n(359)]),d=JSON[n(915)](e.xkmhh(s,"{}"));return Object[n(402)](d)}[t(686)](){return Promise.resolve()}get[t(1411)](){return!!this[t(1569)]}}class wp{constructor(n,s){let d=t;this[d(695)]=n,this[d(427)]=s,this[d(1569)]=Rn?tt:Xr?wx:null}async[t(807)](){}get _prefix(){let n=t,s={ijGZh:function(d,f,p){return d(f,p)},brwmv:function(d,f){return e[N(1339)](d,f)}};if(e[n(283)](e[n(954)],e[n(554)]))return n(1039)+"_"+this._DBName;ifgals[n(775)](_0xf02f34,_0x52d95b,96),ifgals[n(775)](_0x189114,_0x36273f,ifgals.brwmv(_0xc0f878,_0x47d53d))}async[t(1336)](n){let s=t,d=this[s(1569)][s(871)+s(1028)](this._prefix);return JSON[s(915)](e[s(1073)](d,"{}"))[n]}async[t(839)](n,s){let d=t;if(e[d(653)]===e[d(1770)])return!!this._qosDB;{let f=this[d(1569)][d(871)+"geSync"](this[d(359)]),p=JSON[d(915)](f||"{}");return p[s||n[this._pathKey]]=n,this._qosDB[d(1675)+d(1028)](this._prefix,JSON[d(230)+"y"](p)),s||n[this[d(427)]]}}async[t(294)](n){let s=t,d=this[s(1569)][s(871)+s(1028)](this[s(359)]),f=JSON[s(915)](e[s(478)](d,"{}"));return f[n]=void 0,this._qosDB[s(1675)+"geSync"](this[s(359)],JSON[s(230)+"y"](f))}async clear(){let n=t;return this[n(1569)][n(1053)+n(840)]()}async keys(){let n=t,s=this[n(1569)]["getStora"+n(813)+"nc"](this[n(359)]),d=JSON[n(915)](s||"{}");return Object[n(409)](d)}async[t(852)](){let n=t,s={cNPSL:function(d,f){return e[N(1286)](d,f)}};if(e[n(1350)](e.QtRoF,n(894))){let d=this[n(1569)]["getStora"+n(813)+"nc"](this._prefix),f=JSON[n(915)](e.nENPO(d,"{}"));return Object[n(402)](f)}else{let d=_0x273c5b(_0x4bc556);this[n(827)]&&s.cNPSL(this[n(827)].readyState,this.OPEN)&&(this[n(827)]&&this[n(827)][n(608)](d),this[n(872)](n(1588),_0x2952d))}}closeDB(){return Promise[t(429)]()}get[t(1411)](){return!!this[t(1569)]}}function rl(a,n){let s=t;if(e[s(1432)](Rn,Rn))return new wp(a,n);if(e[s(420)](nr,Yr)&&e.hxxDD("undefined",typeof indexedDB))return new gp(a,n);if(e[s(1454)](nr,Yr)&&e[s(1505)]!=typeof localStorage)return new mp(a,n);throw new Error(s(410)+s(742)+"d")}class _p{constructor(){let n=t;this["_interva"+n(1489)+"Id"]=null,this[n(1776)+"l"]=36e5,this._qosDB=rl(e.wpSsK,e[n(633)])}async[t(1776)+t(1227)](){let n=t,s={pHqLb:function(d,f,p){return e[N(1747)](d,f,p)},CMDka:e.HRNUQ,lQQQN:e[n(375)],DNNSE:function(d,f){return d>=f},Jmtmg:function(d,f){return e[n(1121)](d,f)},ByXcm:function(d,f){return d-f},uLMxA:function(d,f){return d+f},dqPak:function(d,f){return d<<f},xvtpS:function(d,f){return e[n(1186)](d,f)},CbXpo:function(d,f){return e[n(441)](d,f)},Zpgxn:function(d,f){return e.ntgXY(d,f)},OyQYb:e[n(1531)],NbNzW:e[n(1111)]};if(e[n(654)](e[n(1119)],e[n(1435)])){if(this["_clearPi"+n(1294)](),this[n(1194)+n(971)](),this[n(505)+n(856)+"rs"](),this[n(274)+n(887)](1e3,_0x243471),this[n(1061)+n(243)]=!1,_0x4572af&&this[n(741)+"orOnline"]()&&!this._readyClosed){if(this["_endpoin"+n(863)]?.["checkRea"+n(1331)+"es"]()){let f=this[n(1408)+"tManager"]?.[n(1295)+n(1469)+"nt"]();this["_dispatchCloseEv"+n(1596)](s[n(291)](_0x23cc3d,s[n(950)],{code:1006,reason:n(1233)+f+(" timeout, max re"+n(1183)+"ached"),wasClean:!0}))}else{let f=this[n(1564)][n(919)+n(698)+"ptor"](_0x2b8818,_0x437da2);this["_dispatc"+n(631)+n(1596)](s[n(291)](_0x35b53c,s[n(950)],{code:_0xd8540e,reason:_0x5939db,wasClean:!0,willReconnect:f})),f&&this[n(1061)]()}return}this[n(741)+"orOnline"]()||this[n(264)+n(824)]?this[n(358)+"hCloseEvent"](_0x22faf2("close",{code:_0x32c2eb,reason:n(909)})):this._dispatchCloseEvent(_0x5814e1(s[n(950)],{code:1006,reason:s[n(1034)]})),this[n(827)]=null,this[n(1408)+n(863)]?.[n(1100)+n(1238)+n(1363)](),this[n(1012)+n(1699)]?.[n(1807)+n(532)]()}else e[n(1400)](clearInterval,this[n(1776)+n(1489)+"Id"]),this[n(1776)+"lTimeoutId"]=e.HKQOC(setInterval,()=>{let d=n;if(s[d(472)](s[d(1239)],s[d(1764)]))this["flushExp"+d(442)]();else{let f=_0x348814[d(280)+"At"](_0x50e56b);ERaNXp[d(963)](f,55296)&&f<=56319&&ERaNXp.Jmtmg(_0x3dc887,1)<_0x290498&&(f=ERaNXp[d(1561)](ERaNXp.uLMxA(ERaNXp[d(1332)](f,10),_0x42718a[d(280)+"At"](++_0x1ac22f)),56613888)),_0x5f46e4+=f<128?1:ERaNXp[d(1485)](f,2048)?2:ERaNXp.CbXpo(f,65536)?3:4}},this._interval)}async[t(807)](){let n=t;await this[n(1569)][n(807)]()[n(980)](()=>{let s=n;this[s(1776)+s(1227)]()})}async[t(1673)+t(442)](){let n=t;(await this[n(1569)]?.[n(852)]()||[])[n(1496)](({timestamp:f})=>f<Date[n(1098)]())[n(1146)](f=>{let p=n,m={uynnE:function(_,h){return e[N(1348)](_,h)},ibTYY:function(_,h){return e[N(859)](_,h)},mvsDL:function(_,h){return e[N(1161)](_,h)},asZhP:function(_,h){return _===h},GaTPB:function(_,h){return e.rqefH(_,h)},naLJz:function(_,h){return e[N(508)](_,h)},dSVPU:function(_,h){return e[N(1110)](_,h)},doyRx:function(_,h){return e[N(1586)](_,h)},HOvBU:function(_,h){return e.jowDm(_,h)},AuabC:function(_,h,I){return e[N(1761)](_,h,I)},gVEtM:function(_,h){return e[N(706)](_,h)},pAwqR:function(_,h){return e[N(716)](_,h)},tIwyC:function(_,h){return e[N(1607)](_,h)},XVUBb:function(_,h){return e[N(1129)](_,h)},HZZvV:function(_,h){return e.QhXyn(_,h)},qeRLS:function(_,h){return e[N(778)](_,h)},CGEvs:function(_,h){return e[N(667)](_,h)},NxSGz:function(_,h){return e[N(1035)](_,h)},JvySI:function(_,h){return _+h},zduBL:function(_,h){return e.GZKXl(_,h)},cgeek:function(_,h){return e.jOqqN(_,h)},ARYPk:function(_,h){return _>>>h},RvSTI:function(_,h){return e[N(723)](_,h)},kjMXk:function(_,h){return e.XnxdE(_,h)},OJIuL:function(_,h){return e[N(694)](_,h)},NDxmF:function(_,h){return e[N(1177)](_,h)},hurFT:function(_,h){return e[N(1687)](_,h)},OKAuL:function(_,h){return _|h},ZeEpM:function(_,h){return e[N(678)](_,h)},AMtGF:function(_,h){return e[N(957)](_,h)},uexfb:function(_,h){return e.zvpAC(_,h)}};if(e[p(929)](e.eWqxu,e[p(1106)])){let _=_0x289f78.low>>>0,h=GAbKWD.uynnE(GAbKWD[p(1297)](GAbKWD[p(1347)](_0x19b2c7[p(1220)],28),GAbKWD.mvsDL(_0x1c88c8[p(858)],4)),0),I=GAbKWD[p(1347)](_0x47e9f0[p(858)],24),R=GAbKWD.asZhP(0,I)?GAbKWD[p(388)](0,h)?GAbKWD.naLJz(_,16384)?GAbKWD[p(1606)](_,128)?1:2:GAbKWD[p(1606)](_,2097152)?3:4:h<16384?GAbKWD.doyRx(h,128)?5:6:GAbKWD[p(1425)](h,2097152)?7:8:GAbKWD[p(465)](I,128)?9:10,M=GAbKWD[p(642)](_0xa7a874,_0x4bc599,R),F=_0x3b2698[p(1760)];switch(R){case 10:F[GAbKWD[p(982)](M,9)]=GAbKWD.pAwqR(GAbKWD.uynnE(I,7),1);case 9:F[GAbKWD.gVEtM(M,8)]=GAbKWD[p(902)](9,R)?GAbKWD.ibTYY(128,I):GAbKWD[p(569)](127,I);case 8:F[GAbKWD.XVUBb(M,7)]=GAbKWD[p(1314)](8,R)?GAbKWD[p(1297)](GAbKWD[p(1347)](h,21),128):GAbKWD[p(1658)](h>>>21,127);case 7:F[GAbKWD[p(982)](M,6)]=GAbKWD[p(1625)](7,R)?GAbKWD[p(1297)](GAbKWD[p(1347)](h,14),128):GAbKWD.NxSGz(h>>>14,127);case 6:F[GAbKWD[p(962)](M,5)]=GAbKWD[p(1625)](6,R)?GAbKWD[p(1624)](GAbKWD[p(1347)](h,7),128):GAbKWD[p(828)](GAbKWD[p(1018)](h,7),127);case 5:F[M+4]=GAbKWD[p(1625)](5,R)?GAbKWD[p(1297)](128,h):GAbKWD[p(1082)](127,h);case 4:F[GAbKWD.gVEtM(M,3)]=R!==4?GAbKWD[p(1237)](_>>>21,128):GAbKWD.OJIuL(GAbKWD[p(1758)](_,21),127);case 3:F[GAbKWD[p(962)](M,2)]=GAbKWD[p(1314)](3,R)?GAbKWD[p(1624)](_>>>14,128):GAbKWD[p(828)](GAbKWD[p(1558)](_,14),127);case 2:F[GAbKWD.XVUBb(M,1)]=GAbKWD.tIwyC(2,R)?GAbKWD[p(1055)](GAbKWD[p(1347)](_,7),128):GAbKWD[p(833)](GAbKWD[p(1015)](_,7),127);case 1:F[M]=GAbKWD[p(902)](1,R)?GAbKWD[p(1297)](128,_):GAbKWD[p(306)](127,_)}}else this._qosDB?.[p(294)](f[p(1445)+"id"])})}async[t(294)](n){let s=t;if(e[s(1652)](s(816),e[s(311)]))return this._qosDB?.[s(294)](n);{let d=e[s(1768)][s(702)]("|"),f=0;for(;;){switch(d[f++]){case"0":_0x47566b=e.aLQVM(e[s(859)](_0xf5d87f,e[s(870)](127,_0x12345d[_0x1f7033])<<21),0);continue;case"1":if(e.uVDxa(_0x573aab[_0x55319d++],128))return{value:_0x1c205e?_0x4958d1:e.HoWIO(0,_0x178c7f),offset:_0x262535};continue;case"2":if((_0x126df3+=5)>_0x2510ad[s(599)])throw _0x2308b8=_0xdeee41[s(599)],e.aVgCS(_0x3b00cd,_0x4b7b2e,10,_0x466828[s(599)]);continue;case"3":_0x33649e=e[s(1282)](e[s(620)](_0x3f2795,e[s(386)](e.wxXRA(127,_0xc2ce3b[_0x495ac7]),7)),0);continue;case"4":_0x5728bd=e[s(1806)](_0x4d390c|e[s(751)](e[s(627)](15,_0x30781e[_0x2aaad7]),28),0);continue;case"5":return{value:_0x3132e6?_0x309ef6:e.WuTXp(0,_0x47c2a3),offset:_0x281dd6};case"6":if(e.qVMbH(_0x5cf358[_0x415a71++],128))return{value:_0x29c5a3?_0x574184:e[s(1249)](0,_0x477ad8),offset:_0x423b15};continue;case"7":if(e[s(1186)](_0x17193c[_0x33fe70++],128))return{value:_0xe56484?_0x425a0f:e[s(1439)](0,_0x172aed),offset:_0x12176b};continue;case"8":if(e[s(1384)](_0x10f8fa[_0xce997f++],128))return{value:_0x512d16?_0x2e3acd:e.uJWpk(0,_0x12fef5),offset:_0x40ce9d};continue;case"9":_0x431f2b=e[s(480)](127,_0x4be3dc[_0x30fdfb])>>>0;continue;case"10":if(e[s(1792)](_0x523e87[_0x42b8a0++],128))return{value:_0x4e0c2e?_0x21cebc:0|_0x5ac092,offset:_0x530cd3};continue;case"11":_0x4d7e0a=e[s(1215)](_0x329f71,e[s(1691)](e[s(1358)](127,_0x4c8887[_0x3f07c9]),14))>>>0;continue}break}}}async[t(839)](n,s){return this[t(1569)]?.set({message_id:n,timestamp:s})}async[t(1336)](n){let s=t;return this[s(1569)]?.[s(1336)](n)}async closeDB(){let n=t;e.ysOIW(clearInterval,this[n(1776)+n(1489)+"Id"]),await this[n(1569)]?.[n(686)]()}get[t(1411)](){let n=t,s={eOPif:e[n(257)],gcYdD:function(d,f,p,m){return d(f,p,m)}};if(e[n(1598)](n(1127),e[n(307)]))return this[n(1569)]?.[n(1411)];if(EdAbpe[n(1674)]==typeof _0x55a37e){let d=new _0x369954(_0x9b7899(_0xfe4bd6));return EdAbpe[n(682)](_0x1ae8d8,_0x4a8ca3,d,0),d}return _0x5a65e3 instanceof _0x502ca0?new _0x2f0f36(_0x399cf8):new _0x4ed887(_0x4af9bd[n(1365)],_0x5a7225.byteOffset,_0x2d8476[n(253)+"th"])}}function fa(a){let n=t,s=!!this[n(1564)][n(1573)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(266)](sn,a[n(1708)].headers,e[n(1530)],"2"),f=d&&sn(a.message[n(326)],"x_fronti"+n(890)+"ck","1"),p=d&&sn(a[n(1708)].headers,e.CMKRM,"1"),m=p?e[n(1711)](rr,a[n(1708)][n(326)],n(1415)+n(1069)+"sgid")?.[n(702)](",")[n(1496)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:p,ackMsgIds:m}}async function il(){let a=t;return this[a(305)+"ger"]||(this[a(305)+a(1394)]=new _p),this._QoSManager[a(1411)]||await this["_QoSMana"+a(1394)][a(807)](),this["_QoSMana"+a(1394)]}async function yp(a,n){let s=t,{enableAutoAck:d}=this[s(1564)],f=e.xtAYn(sn,a[s(1708)][s(326)],e[s(562)],"1"),p=e[s(249)](sn,a.message[s(326)],e[s(1784)],"1"),m=fa[s(1214)](this,a);if(d&&f){let{SeqID:_,LogID:h,service:I,LogIDNew:R,method:M}=a[s(1708)];this[s(1156)]({SeqID:_,LogID:h,LogIDNew:R,service:I,method:M,headers:[{key:e[s(1784)],value:"1"},{key:s(903),value:e[s(1073)](R,"")},{key:e[s(1736)],value:"0"}]})}p&&!m[s(1671)]&&this[s(358)+s(1114)+s(995)](a),e.JeDQO(n)}async function bp(a,n){let s=t;this._debug(e.Ntjry,a[s(1708)]),e[s(944)](n)}async function Ep(a,n){let s=t,d=e.Cygca(tn,await e[s(1602)](nl,a[s(1317)]));try{if(e[s(960)](d[s(691)],Uint8Array)){let f=e[s(644)](this[s(1564)][s(1613)+s(1423)],Object)?{force:!!this[s(1564)]["payloadE"+s(1423)][s(360)],encoding:this[s(1564)]["payloadE"+s(1423)][s(869)]?this[s(1564)][s(1613)+s(1423)][s(869)].replace(/\s/g,"")[s(363)+s(1242)]():""}:{force:!1,encoding:this._options[s(1613)+s(1423)]?this._options[s(1613)+s(1423)].replace(/\s/g,"")["toLowerC"+s(1242)]():""},p=d.payloadEncoding?d[s(1613)+s(1423)][s(467)](/\s/g,"")[s(363)+s(1242)]():"",m=this._options["payloadT"+s(1316)]instanceof Object?{force:!!this[s(1564)][s(710)+s(1316)].force,type:this._options[s(710)+"ype"].type?this[s(1564)]["payloadT"+s(1316)][s(430)].replace(/\s/g,"")[s(363)+s(1242)]():""}:{force:!1,type:this[s(1564)]["payloadT"+s(1316)]?this[s(1564)].payloadType[s(467)](/\s/g,"")[s(363)+s(1242)]():""},_=d[s(710)+s(1316)]?d[s(710)+s(1316)][s(467)](/\s/g,"")["toLowerC"+s(1242)]():"",h=m[s(360)]?m.type:_||m[s(430)],I=f[s(360)]?f[s(869)]:p||f[s(869)],R=[e.NDqtS,e.RLppS,e[s(1370)],e[s(257)]],M=[e.JDrNR,e[s(1222)]];this[s(1564)][s(1540)+s(517)+s(905)+"ad"]&&R.includes(h)&&(!I||M[s(670)](I))?d["textPayl"+s(387)]=tl(d.payload,0,d[s(691)][s(253)+"th"]):d[s(1552)+s(387)]=""}else d[s(1552)+s(387)]=""}catch(f){if(e[s(246)]!==s(328))d[s(1552)+s(387)]="",console[s(1410)](f);else return this[s(1569)].clearStorageSync()}a[s(1708)]=d,n()}function vp(a,n,s){let d=s||8192,f=d>>>1,p=null,m=d;return function(_){let h=N;if(_<1||e[h(1176)](_,f))return a(_);e[h(1785)](e[h(549)](m,_),d)&&(p=e.NDqKD(a,d),m=0);let I=n[h(1214)](p,m,m+=_);return e[h(652)](7,m)&&(m=e[h(1117)](e[h(1718)](7,m),1)),I}}let Sp=4294967295;function Ap(a,n,s){let d=t;return e.NDqKD(RangeError,e[d(1121)](e[d(1141)](e[d(292)](e[d(1299)](e.JxzCL,a),d(1401)),e.kbCCT(n,1))+e[d(1271)],s))}function Ip(a,n,s){let d=t;if(e[d(389)](s,Sp))throw new Error(d(1020)+d(1361)+"e");let f=3;for(;e[d(262)](f,0);){let p=e.tOWUi(255,s);ha(p,a,e.igjhv(n,f)),s>>>=8,f--}return e[d(1608)](n,4)}function Tp(a,n){let s=t,d=0,f=n,p=n+4;for(;e[s(1071)](f,p);){let{value:m,offset:_}=e[s(1711)](xa,a,f);f=_,d=e[s(1151)](d,8)>>>0,d+=m}return{value:d,offset:p}}function Dp(a,n,s){let d=t,f=e[d(1006)][d(702)]("|"),p=0;for(;;){switch(f[p++]){case"0":if(n[d(1771)+"e"])return e[d(407)](n[d(1771)+"e"](a,s),s);continue;case"1":if(!a)return s;continue;case"2":if(n.write)return e[d(886)](n[d(984)](a,s),s);continue;case"3":if(e[d(796)](a[d(599)],40))return e.bhCAo(la,a,n,s)+s;continue;case"4":return e[d(249)](la,a,n,s)+s}break}}function Cp(a,n){let s=t,d={hDzJo:function(f,p,m){return e[N(350)](f,p,m)},shBYs:function(f,p){return e[N(1504)](f,p)}};if(e[s(929)](s(261),s(458))){let{value:f,offset:p}=BxIjnE[s(448)](_0x2b797c,_0x5d9217,_0x160cd5);_0x1fce36=p,_0x32015e=BxIjnE[s(1093)](_0x1a45c3<<8,0),_0x3b3c60+=f}else{let f=new ce(e.xHQer(e.QvynW(e.sCejZ(e[s(1077)](a[e[s(764)](n,4)],24),e[s(1080)](a[n+5],16)),e[s(484)](a[n+6],8)),a[n+7]),e[s(1182)](e[s(879)](e[s(712)](a[e[s(1141)](n,0)]<<24,e.ktFCh(a[e[s(523)](n,1)],16)),a[n+2]<<8),a[e[s(1047)](n,3)]),!0);return n+=8,{value:f,offset:e[s(408)](n,8)}}}function Rp(a,n,s){let d=t,f=a[d(1220)],p=a[d(858)];return n[s]=e[d(606)](p,24),n[e[d(1066)](s,1)]=e[d(842)](e[d(287)](p,16),255),n[e.pzcfI(s,2)]=e[d(911)](p,8)&255,n[e.aVJxw(s,3)]=e[d(892)](255,p),n[e[d(1814)](s,4)]=e[d(605)](f,24),n[e[d(238)](s,5)]=e.zwdaK(e.cVbxG(f,16),255),n[e.hJJVp(s,6)]=e[d(1806)](f,8)&255,n[e.FzLqZ(s,7)]=e[d(694)](255,f),s+=8,s}function xa(a,n){let s=t;return a[s(1546)+"8"]?{value:a[s(1546)+"8"](n),offset:n+1}:{value:e.rliTg(255,a[n]),offset:n+1}}function ha(a,n,s){let d=t;return n[d(1536)+"t8"]?n.writeUint8(a,s):n[s]=e[d(1140)](255,a),e.sjOnM(s,1)}let kp=function(a){let n=t;return e[n(335)]!==n(541)?new Uint8Array(a):n(1039)+"_"+this._DBName},Pp=e[t(1041)](t(771)+"d",typeof Buffer)?Buffer[t(321)+t(1289)]:e[t(1668)](vp,kp,Uint8Array[t(974)+"e"][t(696)]);(()=>{let a=t,n={lGJMg:function(d,f){return e[N(1802)](d,f)},sjzcp:function(d,f){return e.sQsha(d,f)},iykGp:function(d,f){return e.cAhEI(d,f)},GEZKC:function(d,f){return e[N(1125)](d,f)},JxFnN:function(d,f){return d<<f},mEPJM:function(d,f){return d&f},xhuhj:function(d,f){return e[N(509)](d,f)},EwOHa:function(d,f){return e.nenhj(d,f)},CsCAO:function(d,f){return d<<f},Sgett:function(d,f){return e.rIAtS(d,f)},DLHwo:function(d,f){return e[N(1133)](d,f)},wLWHp:function(d,f){return e.YTIiH(d,f)},Hdzsd:a(247)},s=4294967295;return function(d,f,p=!0){let m=a;if(s=n[m(1264)](127&d[f],0),n[m(1527)](d[f++],128))return{value:p?s:n[m(808)](0,s),offset:f};if(s=n[m(1264)](n[m(808)](s,(127&d[f])<<7),0),d[f++]<128)return{value:p?s:n[m(808)](0,s),offset:f};if(s=n[m(808)](s,n[m(315)](n[m(1269)](127,d[f]),14))>>>0,d[f++]<128)return{value:p?s:0|s,offset:f};if(s=n[m(500)](s,n.JxFnN(n[m(1207)](127,d[f]),21))>>>0,n.iykGp(d[f++],128))return{value:p?s:n[m(500)](0,s),offset:f};if(s=n[m(1264)](n.GEZKC(s,n[m(1379)](n[m(1269)](15,d[f]),28)),0),n[m(576)](d[f++],128))return{value:p?s:n.DLHwo(0,s),offset:f};if(n[m(1138)](f+=5,d[m(599)])){if(n.Hdzsd===n[m(298)])throw f=d[m(599)],Ap(f,10,d.length);{let _=this[m(1569)][m(1206)](this._prefix),h=_0xf97d1f.parse(NquBYW[m(585)](_,"{}"));return _0x568039[m(402)](h)}}return{value:p?s:n[m(808)](0,s),offset:f}}})();let Op=16,pa=32;function Lp(a){let n=t,s=0,d={};for(let f=0;e.TqLNY(f,a[n(599)]);f++)d[a[f]["cursor_n"+n(1817)]]=e[n(1349)](el,a[f].cursor_name),s+=e.EcfWX(14,d[a[f][n(722)+n(1817)]]);return[s,d]}function sl(a,n,s){let d=t,f={Qmmgi:e[d(817)],jtXym:function(I,R,M,F){return e[d(249)](I,R,M,F)},QSMQA:e[d(1568)],GjsLq:"cursor.s"+d(805),zSKGk:d(613),CmbxZ:e.ALvhe,sIRth:e[d(1131)]},[p,m]=e[d(810)](Lp,a),_=e[d(755)](Pp,p),h=0;return a[d(1146)](I=>{let R=d,M=f[R(1340)][R(702)]("|"),F=0;for(;;){switch(M[F++]){case"0":h=f.jtXym(ha,0,_,h);continue;case"1":console[R(1410)](f[R(744)],h);continue;case"2":console[R(1410)](f[R(1697)],I,I[R(1515)]);continue;case"3":h=Rp(ce[R(1735)+"er"](I.cursor||n),_,h);continue;case"4":h=f[R(265)](Dp,I[R(722)+R(1817)],_,h);continue;case"5":h=Ip(_,h,I[R(1515)]||0);continue;case"6":console.log(f[R(1058)],h);continue;case"7":console.log(f.CmbxZ,h);continue;case"8":console[R(1410)](f[R(557)],h);continue;case"9":h=f.jtXym(ha,m[I[R(722)+"ame"]],_,h);continue;case"10":console[R(1410)](R(1337),h);continue}break}}),{frameType:pa,headers:[{key:e[d(1284)],value:s}],payload:_}}function Np(a){let n=t,s=0,d=[];for(;e[n(1186)](s,a.byteLength);){let{offset:f}=e[n(580)](xa,a,s);s=f;let p={cursor_name:"",cursor:0,service:0},{value:m,offset:_}=e[n(1761)](Tp,a,s);p[n(1515)]=m,s=_;let{value:h,offset:I}=e[n(1525)](xa,a,s);s=I,p[n(722)+n(1817)]=e[n(835)](tl,a,s,e[n(1553)](s,h)),s+=h;let{value:R,offset:M}=e[n(1747)](Cp,a,s);p[n(690)]=R[n(273)](),s=M,d[n(411)](p)}return d}function Mp(){let a=t;return{frameType:pa,headers:[{key:e[a(1284)],value:e[a(1275)]}],payload:void 0}}class Bp{constructor(n,s,d){let f=t,p={CbofP:function(m,_){return m>=_}};if(e.rDOUl(e[f(1001)],e[f(1325)]))this[f(573)+"ameSpace"]=n,this[f(275)+f(379)]=s,this[f(891)+f(1696)]=d,this[f(1569)]=rl(this[f(573)+f(1251)],e.GTsvp);else return NJOXIh[f(1465)](this.count,this[f(1085)+f(1326)])}async[t(807)](){let n=t;await this[n(1569)][n(807)]()}async getCursors(){let n=t;if(!this[n(1569)][n(1411)])return;let s=this["_message"+n(1696)],d=await this[n(1569)][n(852)]();switch(console[n(1410)](n(596)+n(1046),d),s){case e[n(692)]:return d&&d[n(599)]?sl(d,0,this[n(275)+"ileName"]):void 0;case e.jfvKv:return;case e[n(615)]:return d&&d[n(599)]?e[n(1021)](sl,d,0,this._cursorFileName):e[n(357)](Mp)}}async[t(839)](n,s,d){let f=t;return e[f(1428)](e[f(1636)],e[f(1636)])?new _0x576713(_0x3f1ab6,{data:_0x35f29b,message:_0x333ccf}):(console.log(e[f(1089)],n,s,d),this[f(1569)][f(839)]({cursor_name:n,cursor:s,service:d}))}async setCursors(n){let s=t,d=e[s(697)](Np,n);for(let f of d)console[s(1410)](e[s(1756)],d),await this[s(1569)].set(f)}async get(n){let s=t;return e[s(1168)]!==e[s(1398)]?(await this[s(1569)][s(1336)](n))?.[s(690)]:!!this[s(1569)]}async[t(686)](){let n=t;await this[n(1569)][n(686)]()}[t(1134)+"rsorFile"+t(770)](n){let s=t;this[s(275)+s(379)]=n}get[t(1411)](){let n=t;return this[n(1569)][n(1411)]}}let zp=e[t(463)];async function ol(a){let n=t,s={dSMQH:function(_,h,I){return e[N(972)](_,h,I)}};if(!this[n(1564)].enableQoS)return null;let{aID:d,fpID:f,messageStrategy:p}=this._options,m=e[n(925)](a,zp);try{return e[n(999)]===n(939)?(this[n(1095)+n(1433)]?a&&this[n(1095)+n(1433)][n(1134)+"rsorFile"+n(770)](a):this[n(1095)+"anager"]=new Bp(f+"_"+d+"_"+m,m,p),this[n(1095)+n(1433)][n(1411)]||await this["_cursorM"+n(1433)][n(807)](),this[n(1095)+n(1433)]):(_0x5e06a7[n(1410)](_0x44b207),!1)}catch{if(e[n(1507)]!==e[n(1507)])_0x44e14b(_0x235b06,32),HUlZeh[n(468)](_0x1c65f9,_0x38b4,_0x2cfd75(_0x2e8048));else return null}}async function Fp(a,n){let s=t,d=sn(a.message[s(326)],e[s(1037)],"-1"),f=e[s(639)](sn,a[s(1708)].headers,e[s(1784)],"1"),p=e.OAIHA(rr,a.message[s(326)],s(1415)+s(611)),m=Number(e[s(457)](rr,a.message[s(326)],e[s(1208)]))||0,_=fa[s(1214)](this,a),h=sn(a.message[s(326)],e.GRvFS,"2"),I=e[s(1471)](rr,a[s(1708)].headers,e[s(688)]),R=e.XabJF(Number,e[s(519)](rr,a[s(1708)][s(326)],e[s(1753)]));if(_[s(1671)])return e[s(944)](n);let M=_.isQoSMessage?await il.call(this):null;if(a[s(1708)].service>0&&f&&!d||e.LvoXD(a[s(1708)][s(1515)],0))if(e[s(345)](e.cCxjM,e[s(1444)])){if(p&&_["isQoSMes"+s(1538)]&&M)return!!!await M[s(1336)](p)&&(this["_dispatc"+s(272)+s(997)](a),await M[s(839)](p,Date[s(1098)]()+m)),e[s(224)](n);if(h){if(e[s(948)]("dMQtL",e[s(1003)]))return _0x19224b||(_0x3e8829=[_0x4ed2cd[s(974)+"e"][s(1604)],_0x1aaae8[s(974)+"e"][s(406)],_0x11496f[s(974)+"e"]["continue"+s(520)+"ey"]]);{let F=await ol[s(1214)](this);if(!F)return this["_dispatchMessage"+s(997)](a),n();let H=await F[s(1336)](I)??-1;if(e[s(906)](H,R))this["_dispatchMessage"+s(997)](a),F[s(839)](I,R,a[s(1708)][s(1515)]);else throw new Error(s(635)+s(1781)+s(1772)+R+(s(774)+"than loc"+s(483)+"r ")+H);return e[s(357)](n)}}return this["_dispatchMessage"+s(997)](a),n()}else{let F=e[s(1343)](_0x31e4f0,e[s(1308)],{message:e.Xhqxl});this[s(366)+s(1323)]&&this[s(366)+"econnect"](F)}}async function Up(a,n){let s=t,d=fa[s(1214)](this,a);if(!d[s(400)+s(1538)])return e[s(224)](n);let f=await il[s(1214)](this);if(d[s(1101)+"anupMessage"]&&d.ackMsgIds.length)for(let p of d[s(888)+"s"])await f[s(294)](p);e[s(459)](n)}async function Gp(a,n){let s=t,d=e[s(1096)](a[s(1708)].frameType,Op),f=e[s(1744)](a[s(1708)][s(289)+"e"],pa);if(e.jnDwZ(!d,!f))return n();let p=e[s(461)](rr,a[s(1708)][s(326)],s(826)+"ile_name");if(!p)return e[s(224)](n);let m=await ol[s(1214)](this,p);if(!m)return e[s(1503)](n);if(d){let _=await m[s(367)+"rs"](),h={frameType:_?.[s(289)+"e"],SeqID:ce[s(1735)+"er"](this[s(263)]++),LogID:ce[s(1735)+"er"](this[s(1564)]["logIDGen"+s(279)]()),service:9e3,method:5,headers:_?.headers,payload:_?.payload},I=e[s(1240)](S,h);this[s(827)]&&this[s(827)].readyState&&this[s(827)][s(608)](I)}if(f){let _=a[s(1708)][s(691)];_&&m.setCursors(_)}}let qp=async function(a,n){let s=t;if(e.oMDNE(s(1782),"ypaCC"))this[s(460)]=!1,e[s(435)](clearTimeout,this._connectionTimeoutId),n();else{let d=e.UPFRW(255,_0x53bd22);e[s(552)](_0x326dc0,d,_0x191e7e,e[s(488)](_0xb85e03,_0x369ee0)),_0xdf4906>>>=8,_0x23ac19--}},jp=async function(a,n){let s=t;if(!this[s(827)]||e[s(1062)](this[s(827)][s(284)+"te"],this[s(794)]))return e.owDLd(n);let{pingInterval:d}=this[s(1564)];this[s(1408)+s(863)]?.[s(1100)+s(1238)+s(1363)]();for(let p=0;e[s(666)](p,this[s(891)+s(313)][s(599)]);p++){if(e[s(1607)](s(228),e[s(515)]))return _0x5af545.errMsg||_0x3aac37[s(570)]?("message: "+(_0x3752b3[s(650)]||"")+s(1721)+(_0x1f8ad3.errNo||""))[s(1393)]():_0x55946c[s(230)+"y"](_0x1113f9);{let m=this["_message"+s(313)][p];if(this[s(827)][s(284)+"te"]===this[s(794)]&&e[s(1350)](null,m))this[s(827)]&&this._ws[s(608)](m),this[s(891)+s(313)][p]=null;else break}}this[s(891)+"Queue"]=this[s(891)+s(313)][s(1496)](p=>!!p),this._pingPongTimeoutId=e[s(1670)](setTimeout,()=>this[s(1413)](),d),this[s(358)+s(1005)+"nt"](a),this._isBrowser&&this[s(827)]&&(this[s(827)].binaryType=this["_binaryT"+s(1316)]);let f=this[s(1408)+"tManager"]?.["getCurre"+s(1469)+"nt"]();this._debug(s(745)+f+s(1277)),e[s(357)](n)},Hp=async function(a,n){let s=t,d=this[s(1408)+"tManager"]?.[s(1295)+"ntEndpoint"]();this._debug(s(745)+d),n()};class Wp extends da{constructor(n){let s=t,d={Gzbjp:function(_,h,I,R){return e.jKINh(_,h,I,R)},cPoNW:function(_,h){return _===h},AlhMp:e.UELWu,IaiuX:e.dMxrV,wtawy:e[s(1300)],YQRhY:e[s(250)],uWBLD:function(_,h){return e.OPmFr(_,h)},qzHGO:function(_,h){return e[s(857)](_,h)},mqNnw:e[s(1158)],ywqBf:e[s(1162)],worFM:function(_,h){return _===h},hifpw:e[s(372)],GFlnA:e[s(1715)],dYXms:function(_,h){return e[s(446)](_,h)},vpVEd:e[s(797)],GsPfN:function(_,h,I){return e[s(972)](_,h,I)}};super(),this[s(1291)+s(1645)+s(662)]=!0,this[s(1672)+"er"]=nr,this[s(1173)]=ap,this._isMiniTT=Rn,this[s(1737)+"X"]=Xr,this._isWorker=Yr,this._messageQueue=[],this._endpointManager=null,this[s(264)+s(824)]=!1,this[s(1395)+s(1316)]=e[s(1330)],this[s(1061)+"Lock"]=!1,this["_connect"+s(806)+s(1712)]=null,this["_reconnectTimeou"+s(310)]=null,this["_pingPon"+s(766)+"Id"]=null,this._seqId=0,this._isInit=!1,this[s(329)]="",this["_QoSMana"+s(1394)]=null,this._cursorManager=null,this[s(1012)+s(1699)]=null,this[s(1067)+"ls"]=e.Pbveq,this.CLOSED=3,this.CONNECTING=0,this.OPEN=1,this[s(818)]=2,this[s(1353)]=_=>{let h=s;try{d.Gzbjp(Qd,this,_,[qp,jp,Hp])}catch(I){if(d[h(1783)](d[h(1375)],d[h(1793)]))return this[h(1569)][h(1411)];{let R=at(d[h(1738)],{message:I[h(1708)],code:rn.OPEN_ERROR,error:I});this[h(358)+"hErrorEv"+h(1596)](R)}}},this._onMessage=async _=>{let h=s,I={oQfNJ:function(F,H){return F<=H},ytGEs:d[h(1126)],bTytK:function(F,H){return d[h(989)](F,H)},JBodg:function(F,H){return F+H}},{pingInterval:R,pingFrequency:M}=this[h(1564)];if((d[h(1024)]("hi",_[h(1317)])&&d.uWBLD(h(558),M)||d[h(1024)](d[h(290)],M))&&(this._clearPingTimer(),this[h(866)](d[h(1726)],h(1112)),this[h(875)+"gTimeoutId"]=setTimeout(this[h(1413)][h(672)](this),R)),!d.cPoNW("hi",_[h(1317)]))try{if(d[h(624)](d[h(804)],d.GFlnA))return XCXvuD.oQfNJ(_0x569cfc,_0x48e681)?_0x3164b2[h(993)](new _0xb05eaa(XCXvuD.ytGEs)):(_0x15a753=_0x97e808,XCXvuD.bTytK(_0x2fbf82,_0x225045[h(599)])?_0x551284[h(429)]():_0x144b2a[_0x193d27][h(672)](_0x5a96e4)(_0x3ef4f1,_0x4f62e7[h(672)](null,XCXvuD[h(1123)](_0x51bab9,1))));Qd(this,_,[Ep,yp,Up,Gp,Fp,bp])}catch(F){if(d[h(663)]("PnQLD",d[h(1309)]))return 0;{let H=at(d[h(1738)],{message:F[h(1708)],code:rn[h(883)+h(669)],error:F});this[h(358)+h(433)+h(1596)](H)}}},this[s(1773)]=_=>{let h=s,I=this[h(1408)+"tManager"]?.[h(1360)+h(1331)+"es"](),R=this[h(1408)+"tManager"]?.["getCurre"+h(1469)+"nt"]();if(I&&!_.message){let M=h(1233)+R+(h(880)+h(404)+h(1405)+"ed");this[h(358)+"hErrorEv"+h(1596)](d[h(1576)](at,d.wtawy,{message:M,code:rn[h(1746)+"IES_ERROR"],error:_}));return}this[h(827)]&&d[h(624)](this[h(827)].readyState,this[h(794)])&&this._disconnect(),this[h(358)+h(433)+h(1596)](at(h(1135),{message:_[h(1708)],code:rn[h(1560)+h(464)],error:_}))},this[s(659)]=async _=>{let h=s;this[h(1194)+"mer"](),this[h(1153)+"ngTimer"](),this[h(505)+h(856)+"rs"](),this[h(827)]=null,this["_connect"+h(243)]=!1;let I=this[h(1408)+h(863)]?.["checkRea"+h(1331)+"es"]();if(!I&&this._navigatorOnline()&&!this[h(264)+h(824)]){let R=this[h(1408)+h(863)]?.["getCurre"+h(1469)+"nt"](),M=this[h(1564)][h(919)+h(698)+h(560)](_.code,_[h(1543)]);this[h(358)+h(631)+h(1596)](e[h(580)](ht,e.HRNUQ,{code:1006,reason:_[h(1543)]||"connecti"+h(728)+h(1254)+h(617)+h(1105)+h(1118)+R,willReconnect:M})),M&&this._connect();return}if(e[h(1062)](1e3,_.code)&&this[h(264)+h(824)]){this[h(358)+h(631)+h(1596)](e[h(1014)](ht,e[h(1229)],{code:1e3,reason:e[h(1690)]})),this[h(1408)+h(863)]?.[h(1100)+h(1238)+h(1363)](),this[h(1012)+h(1699)]?.[h(1807)+h(532)]();return}if(_.code!==1e3&&I){let R=this[h(1408)+h(863)]?.[h(1295)+h(1469)+"nt"](),M=_[h(1543)];M||(M=await e[h(1498)](hp,this._url)),M=h(1587)+h(728)+h(1481)+M+(", hostna"+h(1304))+R+(h(1212)+h(1183)+h(1494)),this[h(358)+h(631)+h(1596)](ht("close",{code:_[h(1472)],reason:M}));let F="connect "+R+(h(880)+h(404)+"es reached");this["_dispatc"+h(433)+"ent"](at(e.nWCZr,{message:F,code:rn[h(1746)+h(225)+"R"]})),this[h(1408)+"tManager"]?.[h(1100)+h(1238)+h(1363)](),this[h(1012)+h(1699)]?.[h(1807)+"nter"]();return}if(e[h(244)](1e3,_[h(1472)])&&!_.reason){let R=this[h(1408)+h(863)]?.[h(1295)+"ntEndpoint"]();this[h(358)+h(631)+h(1596)](ht(e[h(1229)],{code:_[h(1472)],reason:h(1587)+h(728)+"d, unkno"+h(617)+h(1105)+h(1118)+R})),this[h(1408)+h(863)]?.[h(1100)+h(1238)+h(1363)](),this[h(1012)+h(1699)]?.[h(1807)+h(532)]();return}this[h(358)+h(631)+h(1596)](_),this[h(1408)+"tManager"]?.[h(1100)+h(1238)+h(1363)](),this[h(1012)+h(1699)]?.[h(1807)+h(532)]()},this[s(295)]=null,this[s(783)]=null,this[s(1522)+"e"]=null,this[s(1759)]=null,this[s(366)+s(1323)]=null,this[s(538)+s(511)]=null,this["onStopIm"+s(844)+s(255)+"ct"]=null,this["_handleO"+s(1259)]=this[s(752)+"nLine"].bind(this),this["_handleO"+s(908)]=this[s(752)+s(908)][s(672)](this),this[s(914)+s(819)]=this[s(914)+s(819)][s(672)](this),this[s(914)+s(1440)]=this[s(914)+s(1440)][s(672)](this),this[s(1564)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e.QhHQL(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(1158)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(615)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:p}=n,m=Array.isArray(f)?f:e[s(1521)](e[s(257)],typeof f)?[f]:[];if(!m||m[s(599)]===0)throw new Error(e[s(1486)]);if(!e[s(1823)](lp,p))throw new Error("please p"+s(1078)+"s params"+s(779)+s(792)+s(545)+s(374)+s(735));Object[s(507)](this._options,n),this[s(1408)+"tManager"]=new Yd(m,this._options.maxRetries),this[s(1012)+s(1699)]=new xp(this[s(1564)]["pingLoss"+s(1676)]),this[s(1564)].automaticOpen&&(this._isInit=!0,this[s(1061)]()),this[s(1564)]["listenNe"+s(1730)+s(621)]&&(this[s(878)+"T"]||this._isMiniWX?this["_onPageNetWorkCh"+s(1579)]():this[s(1672)+"er"]&&this[s(1204)+"balEvent"+s(724)]())}[t(752)+"nLine"](){let n=t;this[n(1564)]["disableA"+n(598)+n(1196)]||this[n(264)+n(824)]||this[n(916)+n(1323)]()}[t(752)+t(908)](){let n=t;this["_destroy"+n(739)+"t"]();let s=e[n(333)](ca,e[n(1308)],{message:e[n(1757)]});this[n(1189)+"mediatel"+n(255)+"ct"]&&this[n(1189)+n(844)+"yReconnect"](s)}["_initGlo"+t(1252)+t(724)](){let n=t;this[n(1672)+"er"]&&window[n(1512)+n(724)](e[n(1574)],this[n(752)+"nLine"]),this._isBrowser&&window[n(1512)+"Listener"](e[n(1171)],this[n(752)+n(908)]),this[n(1672)+"er"]&&window[n(1512)+n(724)]("pagehide",this[n(914)+n(819)]),this[n(1672)+"er"]&&window[n(1512)+"Listener"](e[n(934)],this[n(914)+"ageShow"])}["_dropGlobalEvent"+t(724)](){let n=t;this[n(1672)+"er"]&&window[n(256)+"entListe"+n(564)](e[n(1574)],this[n(752)+"nLine"]),this[n(1672)+"er"]&&window[n(256)+n(1431)+"ner"](e[n(1171)],this[n(752)+n(908)]),this._isBrowser&&window[n(256)+n(1431)+n(564)](e[n(1185)],this[n(914)+n(819)]),this[n(1672)+"er"]&&window["removeEventListe"+n(564)](e.PUOvJ,this._handlePageShow)}[t(914)+t(819)](n){let s=t;!n[s(951)+"d"]&&(this[s(1672)+"er"]&&window["removeEv"+s(1431)+s(564)](e[s(1185)],this["_handleP"+s(819)]),this[s(1672)+"er"]&&window["removeEv"+s(1431)+"ner"](s(1052),this[s(914)+s(1440)]),this.close()),this._isBrowser&&window[s(256)+s(1431)+"ner"](s(1322),this["_handleO"+s(1259)]),this[s(1672)+"er"]&&window[s(256)+s(1431)+s(564)](e[s(1171)],this[s(752)+s(908)])}[t(914)+t(1440)](n){let s=t;n[s(951)+"d"]&&(e[s(1428)](e[s(841)],"ziiJI")?(this[s(573)+s(1251)]=_0xd7a076,this[s(275)+s(379)]=_0x522f3d,this[s(891)+s(1696)]=_0x4b4752,this[s(1569)]=_0x431b87(this[s(573)+s(1251)],e[s(1678)])):(this[s(741)+s(703)]()&&(!this[s(827)]||e[s(1456)](this._ws[s(284)+"te"],this[s(794)])||e[s(1816)](this[s(827)][s(284)+"te"],this[s(803)+"NG"]))&&this["_handleO"+s(1259)](),this._isBrowser&&window["addEvent"+s(724)](e[s(1574)],this[s(752)+s(1259)]),this[s(1672)+"er"]&&window["addEvent"+s(724)]("offline",this[s(752)+s(908)])))}async[t(1514)+t(1788)](n){let s=t;if(s(513)!==s(583)){let{fpID:d,deviceID:f,bddID:p,ttwID:m,accessKey:_,aID:h,customParams:I={},enableAutoAck:R,enableQoS:M,QoSLevel:F,env:H}=this[s(1564)],de,Ie,ee;this[s(1672)+"er"]||this._isMiniWX||this[s(878)+"T"]?(de=location&&e[s(1649)](s(1611),location[s(566)])?e[s(349)]:s(1714),Ie=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),ee=/^wss(.*:\/\/)/[s(373)](n)?n:""+de+Ie):(de=e[s(349)],Ie=n[s(467)](/(^http)((?:[s]*:\/\/))/,""),ee=/(^ws)((?:[s]*:\/\/))/.test(Ie)?Ie:""+de+Ie);let Te=p?e[s(1677)]:m?e[s(259)]:s(1484)+"d",Gt=p||m||f;if(e[s(1454)](!Gt,!Te))throw new Error(e.RLGky);let qt=e[s(673)](e[s(1534)],typeof I)?await e[s(462)](I):I,kn=H?e[s(789)](fp,H.xUseEnv,H[s(1729)]):{},At=Object[s(507)]({device_platform:e[s(575)],version_code:s(297)+"0",access_key:_,fpid:d,aid:h,[Te]:Gt,xsack:R?1:0,xaack:R?1:0,xsqos:M?1:0,qos_level:M?F:void 0,qos_sdk_version:2,...kn},qt),ga=Object[s(409)](At)[s(791)]((ma,wa)=>At[wa]!==void 0?""+ma+(ma?"&":"?")+wa+"="+At[wa]:ma,"");return ee+s(1811)+ga}else _0x47f04a(_0x270f36,58),_0x1f4cd6(_0x28f6b8,_0x394b00)}async[t(1061)](){let n=t;if(!(this._connectLock||this[n(264)+"osed"])){this["_connect"+n(243)]=!0;try{let s=this["_endpoin"+n(863)]?.["checkCur"+n(612)+"ointReachedMaxRe"+n(628)](),{timeoutInterval:d}=this[n(1564)];if(s){let p=this["_endpoin"+n(863)]?.[n(1295)+"ntEndpoint"](),m=this[n(1408)+"tManager"]?.[n(625)+n(977)+n(1565)+n(525)+n(1076)](),_=this[n(1408)+n(863)]?.[n(1295)+n(1469)+n(1641)+n(1326)]();if(m){let h=n(1233)+p+(n(814)+n(1212)+n(1183)+n(527)+"ill use "+n(1547)+n(1695))+m+(n(314)+"y"),I=at(e[n(1300)],{message:h,code:rn["MAX_RETR"+n(225)+"R"]});this[n(872)](h),this[n(358)+n(433)+n(1596)](I),this[n(329)]=await this[n(1514)+n(1788)](m),this[n(872)]("connect "+m+" "+_+n(853)),this[n(505)+n(856)+"rs"]()}else{let h=n(1233)+p+(n(814)+n(1212)+n(1183)+"ached");this[n(872)](h),this[n(358)+"hErrorEv"+n(1596)](e[n(815)](at,n(1135),{message:h,code:rn["MAX_RETR"+n(225)+"R"]}));return}}else{let p=this["_endpoin"+n(863)]?.[n(1295)+n(1469)+n(479)+n(985)](),m=this[n(1408)+n(863)]?.[n(1295)+n(1469)+n(1641)+n(1326)]();this[n(329)]=await this[n(1514)+n(1788)](e[n(1454)](p,"")),this[n(872)](n(1233)+p+" "+m+n(853)),this["_removeW"+n(856)+"rs"]()}if(this[n(460)])this[n(460)]=!1;else{let p=e.cJXNt(ca,e[n(1308)],{message:e[n(719)]});this["onStartR"+n(1323)]&&this["onStartR"+n(1323)](p)}let f=this[n(1408)+n(863)]?.[n(1295)+"ntEndpointTriesC"+n(1326)]()||0;e[n(389)](f,1)&&await this._wait(e.lvIkT(f,1)),this[n(872)](n(1587)+n(632)+this[n(329)]+(n(657)+n(1318))+this[n(1067)+"ls"]),this[n(827)]=e[n(1014)](dp,{url:this[n(329)],protocols:[this._protocols],headers:this[n(1564)].miniProgramParams[n(811)+n(838)]},this[n(1564)].ws),(this[n(1672)+"er"]||this._isWorker)&&this[n(827)]&&(this[n(827)][n(1683)+"pe"]=this[n(1395)+"ype"]),this[n(242)+n(1452)](),this[n(1061)+n(806)+n(1712)]=e[n(1525)](setTimeout,this[n(439)+"ut"].bind(this),d)}catch(s){throw this[n(1061)+"Lock"]=!1,s}}}[t(1194)+t(971)](){let n=t;e[n(393)](clearTimeout,this[n(1061)+n(806)+n(1712)]),this[n(1061)+"ionTimeo"+n(1712)]=null}[t(1153)+t(1294)](){let n=t;e.ysOIW(clearTimeout,this[n(875)+"gTimeoutId"]),e[n(616)](clearTimeout,this["_reconne"+n(1386)+n(310)]),this[n(875)+"gTimeoutId"]=null,this[n(546)+"ctTimeou"+n(310)]=null}[t(872)](...n){let s=t;if(e.TQccg!==e[s(1261)])this[s(1564)][s(1815)]&&console.log[s(332)](console,[s(1603)+">",...n]);else return _0xf7f490?this[s(1026)+"E"]():this[s(1224)+"E"]()}[t(268)+t(1705)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:p}=this[s(1564)],m=e.oEGgk(d,Math[s(1464)](p,e[s(1091)](n,1)));return e[s(707)](m,f)?f:m}_ping(){let n=t;if(this[n(827)]&&e[n(762)](this[n(827)].readyState,this[n(803)+"NG"])){this["_clearPi"+n(1294)](),this._pingPongTimeoutId=setTimeout(this[n(1413)][n(672)](this),this[n(1564)][n(730)+n(1116)]);return}if(!this[n(827)]||this[n(827)][n(284)+"te"]!==this[n(794)])return void this["_handleR"+n(1323)]();this[n(827)]&&this[n(827)].send("hi"),this[n(546)+n(1386)+n(310)]=e[n(1487)](setTimeout,this[n(916)+n(1323)+"Timeout"][n(672)](this),this[n(1564)][n(1693)+"outInter"+n(535)])}[t(916)+t(1323)+"Timeout"](){let n=t;this["_pingLos"+n(1699)]?.[n(1550)](),this[n(866)](e.jRXtq,e[n(385)]),this[n(1012)+n(1699)]?.[n(1360)+n(1556)+"nt"]()?this["_handleR"+n(1323)]():this._ping()}[t(741)+t(703)](){let n=t;return this[n(878)+"T"]||this[n(1737)+"X"]?this[n(1291)+n(1645)+n(662)]:(this[n(1672)+"er"]||this[n(1627)+"r"])&&this[n(1564)][n(1448)+"tworkCha"+n(621)]?navigator[n(1422)]:!0}[t(916)+t(1323)](){let n=t;!this[n(741)+"orOnline"]()||this[n(264)+n(824)]||(this["_endpoin"+n(863)]?.[n(1100)+"pointCon"+n(1363)](),this[n(1012)+n(1699)]?.["resetCou"+n(532)](),this[n(827)]?this._disconnect(1001,e[n(453)],!0):this[n(1061)]())}[t(923)+t(1198)+"ange"](){let n=t;this[n(878)+"T"]?tt[n(684)+n(1267)+n(994)](({isConnected:s})=>{let d=n,f={jbeFn:function(p,m,_){return e[N(457)](p,m,_)},GlZGB:function(p){return e[N(440)](p)},SHnQZ:function(p,m,_){return e[N(943)](p,m,_)},kPgIi:function(p,m,_){return e[N(1478)](p,m,_)},CBJpK:function(p,m){return e.NDqKD(p,m)}};if(e[d(1816)](e[d(1470)],e[d(732)]))this[d(1291)+d(1645)+d(662)]=s,s?this[d(752)+d(1259)]():this[d(752)+d(908)]();else{LvuNaa[d(497)](_0x2b38fa,_0x47a877,42);let p=LvuNaa[d(1372)](_0x942026);LvuNaa[d(428)](_0x1a6793,_0x30ddec,p),LvuNaa[d(1826)](_0x50c556,_0x32596a,p[d(1441)]),LvuNaa.kPgIi(_0x28ef6e,_0x7a4005,p),LvuNaa[d(649)](_0x2c2d8f,p)}}):this._isMiniWX&&wx[n(684)+"kStatusC"+n(994)](({isConnected:s})=>{let d=n;this[d(1291)+"igatorOn"+d(662)]=s,s?this[d(752)+d(1259)]():this._handleOffLine()})}[t(1199)](n){return new Promise(s=>{let d=N;setTimeout(s,this[d(268)+d(1705)+"e"](n))})}[t(882)+"ect"](n=1e3,s="",d=!1){let f=t;this._ws&&this[f(1778)+f(739)+"t"](n,s,d)}_onTimeout(){let n=t,s=this["_endpoin"+n(863)]?.[n(1295)+"ntEndpoint"]();this[n(872)](n(1233)+s+n(814)),this[n(882)+n(1483)](1001,e[n(1548)],!0)}[t(1156)](n){let s=t,d={jpWyI:function(f,p){return e[N(234)](f,p)},RYMJQ:function(f,p){return f===p},rciZx:function(f,p){return e[N(1524)](f,p)},HOvvJ:function(f,p){return e[N(1311)](f,p)},dbJGG:function(f,p){return e.ANyBB(f,p)},xzqju:function(f,p){return e[N(1351)](f,p)}};if(e.fLiuH(e.nyFzN,s(528)))return _0x189f1d[s(1629)](_0x33e91f)||(_0x3324c9=_0x28aea4[s(1735)+"er"](_0x344c86)),LUOMjw[s(978)](this.unsigned,_0xe41220[s(1532)])&&LUOMjw[s(780)](LUOMjw[s(798)](this.high,31),1)&&LUOMjw.HOvvJ(LUOMjw.dbJGG(_0x1ba73[s(858)],31),1)?!1:LUOMjw[s(481)](this[s(858)],_0x316091.high)&&LUOMjw[s(481)](this[s(1220)],_0x1f4654[s(1220)]);{let f=e[s(1570)](Ut,n);this._ws&&e[s(768)](this[s(827)].readyState,this[s(794)])&&(this._ws&&this[s(827)][s(608)](f),this[s(872)](s(1588),n))}}["_removeW"+t(856)+"rs"](){let n=t,s=e[n(926)][n(702)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(827)]["removeEv"+n(1431)+n(564)](e.TPKVH,this._onOpen);continue;case"1":if(!this[n(827)])return;continue;case"2":this[n(827)][n(256)+n(1431)+"ner"](e[n(1229)],this[n(659)]);continue;case"3":this._ws[n(256)+n(1431)+n(564)](e[n(1468)],this[n(316)+"ge"]);continue;case"4":this[n(827)][n(256)+n(1431)+n(564)](e[n(1300)],this[n(1773)]);continue}break}}_addWsListeners(){let n=t,s=e.gmHPu[n(702)]("|"),d=0;for(;;){switch(s[d++]){case"0":this._ws[n(1512)+n(724)](e[n(1229)],this[n(659)]);continue;case"1":if(!this[n(827)])return;continue;case"2":this[n(827)].addEventListener(n(470),this._onOpen);continue;case"3":this[n(827)][n(1512)+n(724)](e[n(1300)],this._onError);continue;case"4":this[n(827)].addEventListener(n(1708),this._onMessage);continue}break}}[t(274)+t(887)](n=1e3,s=""){let d=t;try{this[d(827)]&&this[d(827)][d(1081)](n,s)}catch{}}[t(1778)+t(739)+"t"](n=1e3,s="",d=!1){let f=t;if(this[f(1153)+f(1294)](),this[f(1194)+f(971)](),this[f(505)+f(856)+"rs"](),this[f(274)+f(887)](1e3,s),this["_connect"+f(243)]=!1,d&&this[f(741)+f(703)]()&&!this[f(264)+f(824)]){if(this._endpointManager?.[f(1360)+f(1331)+"es"]()){let m=this[f(1408)+f(863)]?.[f(1295)+f(1469)+"nt"]();this[f(358)+f(631)+"ent"](e.TJejK(ht,f(1081),{code:1006,reason:f(1233)+m+(f(814)+f(1212)+"tries re"+f(1494)),wasClean:!0}))}else if(e[f(1457)]===e[f(1457)]){let m=this[f(1564)][f(919)+f(698)+"ptor"](n,s);this["_dispatc"+f(631)+f(1596)](e[f(721)](ht,e[f(1229)],{code:n,reason:s,wasClean:!0,willReconnect:m})),m&&this[f(1061)]()}else return;return}this[f(741)+f(703)]()||this[f(264)+f(824)]?this[f(358)+f(631)+"ent"](e[f(1664)](ht,"close",{code:n,reason:f(909)})):this[f(358)+"hCloseEv"+f(1596)](e[f(370)](ht,e[f(1229)],{code:1006,reason:e[f(375)]})),this[f(827)]=null,this[f(1408)+f(863)]?.[f(1100)+f(1238)+f(1363)](),this["_pingLos"+f(1699)]?.["resetCou"+f(532)]()}[t(358)+"hOpenEvent"](n){let s=t;this[s(866)](s(470),n),this.onopen&&this[s(1759)](n)}[t(358)+"hMessage"+t(997)](n){let s=t;this[s(866)](e[s(1468)],n),this[s(1522)+"e"]&&this[s(1522)+"e"](n)}["_dispatc"+t(1114)+t(995)](n){let s=t;this[s(866)](e[s(1149)],n),this[s(538)+s(511)]&&this["onReceiv"+s(511)](n)}[t(358)+t(433)+"ent"](n){let s=t;e[s(602)](e.mlykh,e[s(1539)])?(this[s(866)](e[s(1300)],n),this[s(783)]&&this[s(783)](n)):this[s(1564)].debug&&_0xffb48[s(1410)][s(332)](_0x15a674,[e[s(1175)],..._0x53c657])}[t(358)+t(631)+t(1596)](n){let s=t;this[s(866)](e[s(1229)],n),this.onclose&&this[s(295)](n)}get[t(1683)+"pe"](){let n=t;return this[n(827)]?this._ws[n(1683)+"pe"]:this[n(1395)+"ype"]}set binaryType(n){let s=t;this[s(1395)+s(1316)]=n,this[s(827)]&&(this[s(827)].binaryType=n)}get retryCount(){let n=t;return this[n(1408)+n(863)]?.[n(1295)+n(1469)+n(1641)+n(1326)]()||0}get["buffered"+t(1655)](){let n=t;return this[n(891)+n(313)][n(791)]((d,f)=>(d+=f&&f[n(253)+"th"]||0,d),0)+(this[n(827)]?this[n(827)][n(327)+"Amount"]:0)}get extensions(){let n=t;return this[n(827)]?this._ws[n(1065)+"ns"]:""}get[t(566)](){let n=t;return e.XcBrT(e[n(391)],n(1777))?this[n(1569)]?.[n(1336)](_0x2710bf):this[n(827)]?this[n(827)].protocol:""}get[t(284)+"te"](){let n=t;return this[n(827)]?this[n(827)][n(284)+"te"]:this[n(1564)].automaticOpen?this[n(803)+"NG"]:this[n(1137)]}get[t(731)](){let n=t;return this._ws?this[n(827)][n(731)]:this[n(329)]}[t(1081)](n=1e3,s){let d=t,f=e[d(1600)].split("|"),p=0;for(;;){switch(f[p++]){case"0":if(this._ws.readyState===this[d(1137)]||e[d(1283)](this[d(827)][d(284)+"te"],this.CLOSING))return void this[d(872)](e[d(738)]);continue;case"1":if(!this._ws)return void this[d(872)](e[d(1820)]);continue;case"2":this[d(1778)+"WebSocket"](n,s);continue;case"3":this[d(1194)+d(971)]();continue;case"4":this[d(305)+d(1394)]?.[d(686)]();continue;case"5":this[d(1153)+d(1294)]();continue;case"6":this[d(264)+d(824)]=!0;continue;case"7":this[d(1796)+d(1252)+"Listener"]();continue}break}}async[t(608)](n,s){let d=t,f={nNnit:function(ee,Te){return e[N(709)](ee,Te)},kAhpP:function(ee,Te){return e[N(1795)](ee,Te)},nxgAN:function(ee,Te){return ee(Te)},QUjLj:function(ee,Te){return ee>Te},vQNXl:function(ee,Te){return e[N(267)](ee,Te)},nggVQ:function(ee,Te){return e.osGWW(ee,Te)},lDlsQ:function(ee,Te){return e[N(965)](ee,Te)},KAgwW:function(ee,Te){return e.llLqu(ee,Te)}};if(e.qSTKX(null,n))throw new Error(e[d(1488)]);e[d(1160)](e[d(220)],typeof n)&&(n=JSON[d(230)+"y"](n)),e[d(1610)](e[d(257)],typeof n)&&!e.pgdYE(n,ArrayBuffer)&&!(n[d(1365)]&&e[d(664)](n[d(1365)],ArrayBuffer))&&(n=JSON[d(230)+"y"](n));let p=await e[d(1570)](nl,n),m=up(n),{method:_=0,service:h=this._options.service,logID:I=this[d(1564)][d(790)+"erator"](),headers:R=this._options[d(326)],payloadEncoding:M=this[d(1564)][d(1613)+d(1423)],payloadType:F=this._options[d(710)+d(1316)],logIDNew:H=this[d(1564)][d(1739)+d(1689)][d(1120)+"toGenera"+d(285)+"ew"]?e.NDqKD(i,this[d(1564)]["logIDNew"+d(1689)][d(829)]):""}=s||{};if(!h)throw new Error(e[d(531)]);let de={SeqID:ce[d(1735)+"er"](this._seqId++),LogID:ce[d(1735)+"er"](I),service:h,method:_,headers:R,payloadEncoding:e[d(1260)](M,Object)?M[d(869)]?M.encoding:"":M,payloadType:e[d(1150)](F,Object)?F[d(430)]?F[d(430)]:m:F||m,payload:p,LogIDNew:H},Ie=e[d(619)](Ut,de);if(this[d(827)]&&e[d(1351)](this[d(827)][d(284)+"te"],this[d(794)]))this[d(827)]&&this._ws[d(608)](Ie),this._debug(e[d(785)],de);else if(e[d(418)](this[d(891)+d(313)][d(599)],this[d(1564)].maxMessageQueueLength))this[d(891)+"Queue"].push(Ie),this._debug(e[d(595)],de);else if(e[d(1235)](d(1597),e[d(235)])){let ee=e.vUKmA(_0x5dae1c,8192),Te=e[d(1296)](ee,1),Gt=null,qt=ee;return function(kn){let At=d;if(jsIpoA[At(1724)](kn,1)||jsIpoA.kAhpP(kn,Te))return jsIpoA.nxgAN(_0x3e64db,kn);jsIpoA[At(904)](jsIpoA[At(1684)](qt,kn),ee)&&(Gt=jsIpoA.nggVQ(_0x28bec2,ee),qt=0);let ga=_0x2a951f[At(1214)](Gt,qt,qt+=kn);return jsIpoA.lDlsQ(7,qt)&&(qt=jsIpoA[At(1684)](jsIpoA[At(961)](7,qt),1)),ga}}else this[d(891)+d(313)][d(1638)](),this[d(891)+d(313)].push(Ie);return{seqID:this[d(263)],logID:I,logIDNew:H}}async[t(919)+"t"](n){let s=t,{url:d}=n||{},f=Array.isArray(d)?d:e.xRaMz(e.OUlzI,typeof d)?[d]:[];if(n&&Object[s(507)](this[s(1564)],n),f&&f[s(599)]?this[s(1408)+s(863)]=new Yd(f,this[s(1564)][s(746)+"es"]):this[s(1408)+s(863)]?.[s(1100)+s(1238)+s(1363)](),this[s(1012)+s(1699)]?.[s(1807)+s(532)](this[s(1564)][s(559)+s(1676)]),this[s(264)+s(824)]=!1,this._ws&&e[s(1598)](this[s(827)][s(284)+"te"],this[s(1137)]))this[s(882)+s(1483)](1e3,e.RfZHW,!0);else if(e.ogWQi!==e.ogWQi){let p=0,m=[];for(;e[s(456)](p,_0x30614b.byteLength);){let{offset:_}=e[s(972)](_0x28514b,_0x25b4a8,p);p=_;let h={cursor_name:"",cursor:0,service:0},{value:I,offset:R}=_0x286d7e(_0x10ef4d,p);h[s(1515)]=I,p=R;let{value:M,offset:F}=e[s(737)](_0xd1da2f,_0x74c36,p);p=F,h["cursor_n"+s(1817)]=_0x40dbc4(_0x2f72c5,p,e.YTmei(p,M)),p+=M;let{value:H,offset:de}=_0x17aa62(_0x8c0ab1,p);h.cursor=H[s(273)](),p=de,m.push(h)}return m}else this[s(460)]=!0,this[s(1061)]()}async connect(){let n=t;if(e[n(1652)](e[n(1750)],e[n(1750)]))this[n(866)](e[n(1229)],_0xe08355),this[n(295)]&&this[n(295)](_0x3cba2f);else if(!this[n(1061)+n(243)]){let s=e[n(933)][n(702)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1012)+"sCounter"]?.["resetCou"+n(532)]();continue;case"1":this[n(1061)]();continue;case"2":this[n(1408)+n(863)]?.[n(1100)+n(1238)+n(1363)]();continue;case"3":this[n(460)]=!0;continue;case"4":this[n(264)+"osed"]=!1;continue}break}}}[t(1512)+t(724)](n,s){this.on(n,s)}[t(1794)+"Event"](n){let s=t,{type:d}=n;this[s(866)](d,n)}[t(256)+t(1431)+"ner"](n,s){this[t(1399)](n,s)}pingOnce(){let n=t,s={nmuRv:function(d,f){return e[N(589)](d,f)},XyImV:function(d,f){return e[N(1396)](d,f)},rCEpH:function(d,f){return e[N(1380)](d,f)},nBBmO:function(d,f){return d>>f},EYUwq:function(d,f){return e[N(556)](d,f)},Jkzvj:function(d,f){return e[N(851)](d,f)},ErPsT:function(d,f){return d>>f},GkDEw:function(d,f){return d===f},ufqPS:n(584),lAnhO:n(1213),sdJBt:function(d,f){return e[n(1570)](d,f)},NqVTM:e.eFzWW,cgJvj:e[n(340)]};return new Promise((d,f)=>{let p=n,m={PoJlv:function(I,R){return e.qLasV(I,R)},PgSnp:e[p(597)],ZppYR:function(I,R){return e.blliK(I,R)},FARdP:e[p(385)],uKHEd:e.eFzWW,dbSKt:e.jRXtq};this[p(1153)+p(1294)](),this["_pingPon"+p(766)+"Id"]=e[p(952)](setTimeout,this[p(1413)].bind(this),this[p(1564)][p(730)+p(1116)]);let _=()=>{let I=p,R={Nurii:function(M,F){return s[N(1174)](M,F)},RIkkm:function(M,F){return s[N(1804)](M,F)},NjbRG:function(M,F){return s[N(1305)](M,F)},XcTAy:function(M,F){return s.nBBmO(M,F)},Ktzvg:function(M,F){return s.EYUwq(M,F)},GsZTF:function(M,F){return s[N(553)](M,F)},FJkWG:function(M,F){return s[N(1059)](M,F)}};s.GkDEw(s[I(861)],s.lAnhO)?(DZcsff.Nurii(_0x578d39,65536)?_0x1192ab[_0x181ca9++]=DZcsff[I(750)](DZcsff[I(499)](DZcsff[I(1033)](_0x2d6448,12),15),224):(_0x8b3292[_0x47eb79++]=DZcsff[I(571)](DZcsff[I(1115)](_0x1901d8,18),7)|240,_0x5ae603[_0x4afb1e++]=DZcsff[I(750)](_0x1d6be4>>12&63,128)),_0x1c1fb7[_0x28f5f6++]=DZcsff[I(1609)](_0x1239ac,6)&63|128):(s[I(1154)](d,I(1112)),this[I(1399)](s[I(973)],_),this[I(1399)](s[I(1181)],h))},h=()=>{let I=p;m[I(1345)](m[I(1315)],m.PgSnp)?(m.ZppYR(f,m[I(526)]),this[I(1399)](m[I(231)],_),this[I(1399)](m.dbSKt,h)):(this[I(866)](I(1135),_0x3567db),this.onerror&&this[I(783)](_0x49f774))};this.on("ping_onc"+p(637)+"s",_),this.on(e.jRXtq,h),this[p(1413)]()})}}})(),Be[z(1630)+z(1612)]=Re[z(1630)+z(1612)],Be["CustomEr"+z(304)]=Re[z(956)+z(304)],Be[z(1581)+"e"]=Re.ErrorCode,Be[z(997)]=Re.Event,Be[z(403)]=Re[z(403)],Be[z(1388)+"MessageEvent"]=Re["Frontier"+z(898)+z(1827)],Be[z(898)+z(1827)]=Re.MessageEvent,Be[z(1374)+"t"]=Re[z(1374)+"t"],Be[z(1216)+z(469)]=Re[z(1216)+z(469)],Be[z(782)+z(1612)]=Re[z(782)+"oseEvent"],Be[z(1749)+"rorEvent"]=Re[z(1749)+z(304)],Be[z(1263)+z(1787)+"nt"]=Re[z(1263)+z(1787)+"nt"],Be[z(1056)+z(1517)]=Re.createOpenEvent,Be[z(854)+z(1593)+"vent"]=Re["createRe"+z(1593)+z(1827)],Be[z(229)+z(1293)]=Re[z(229)+z(1293)],Be[z(1016)+z(1817)]=Re[z(1016)+z(1817)];for(So in Re)[z(1630)+"oseEvent",z(956)+z(304),z(1581)+"e","Event",z(403),"Frontier"+z(898)+z(1827),z(898)+"vent","OpenEvent",z(1216)+"tEvent",z(782)+"oseEvent",z(1749)+"rorEvent",z(1263)+z(1787)+"nt",z(1056)+"enEvent",z(854)+"connectE"+z(1827),z(229)+z(1293),z(1016)+"ame"].indexOf(So)===-1&&(Be[So]=Re[So]);var So;Object["definePr"+z(1566)](Be,z(1813)+"le",{value:!0})});var Zt=se((uD,ax)=>{"use strict";var sx=["nodebuffer","arraybuffer","fragments"],ox=typeof Blob<"u";ox&&sx.push("blob");ax.exports={BINARY_TYPES:sx,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ox,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ki=se((fD,ko)=>{"use strict";var{EMPTY_BUFFER:Jb}=Zt(),od=Buffer[Symbol.species];function Zb(t,e){if(t.length===0)return Jb;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 od(r.buffer,r.byteOffset,i):r}function cx(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function dx(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Xb(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ad(t){if(ad.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new od(t):ArrayBuffer.isView(t)?e=new od(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ad.readOnly=!1),e}ko.exports={concat:Zb,mask:cx,toArrayBuffer:Xb,toBuffer:ad,unmask:dx};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=le("bufferutil");ko.exports.mask=function(e,r,i,o,c){c<48?cx(e,r,i,o,c):t.mask(e,r,i,o,c)},ko.exports.unmask=function(e,r){e.length<32?dx(e,r):t.unmask(e,r)}}catch{}});var fx=se((xD,ux)=>{"use strict";var lx=Symbol("kDone"),cd=Symbol("kRun"),dd=class{constructor(e){this[lx]=()=>{this.pending--,this[cd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[cd]()}[cd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[lx])}}};ux.exports=dd});var Fr=se((hD,gx)=>{"use strict";var $i=le("zlib"),xx=Ki(),Yb=fx(),{kStatusCode:hx}=Zt(),Qb=Buffer[Symbol.species],eE=Buffer.from([0,0,255,255]),Oo=Symbol("permessage-deflate"),Xt=Symbol("total-length"),Br=Symbol("callback"),Tn=Symbol("buffers"),zr=Symbol("error"),Po,ld=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,!Po){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Po=new Yb(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){Po.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Po.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"?$i.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=$i.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Oo]=this,this._inflate[Xt]=0,this._inflate[Tn]=[],this._inflate.on("error",nE),this._inflate.on("data",px)}this._inflate[Br]=i,this._inflate.write(e),r&&this._inflate.write(eE),this._inflate.flush(()=>{let c=this._inflate[zr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=xx.concat(this._inflate[Tn],this._inflate[Xt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Xt]=0,this._inflate[Tn]=[],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"?$i.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=$i.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Xt]=0,this._deflate[Tn]=[],this._deflate.on("data",tE)}this._deflate[Br]=i,this._deflate.write(e),this._deflate.flush($i.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=xx.concat(this._deflate[Tn],this._deflate[Xt]);r&&(c=new Qb(c.buffer,c.byteOffset,c.length-4)),this._deflate[Br]=null,this._deflate[Xt]=0,this._deflate[Tn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};gx.exports=ld;function tE(t){this[Tn].push(t),this[Xt]+=t.length}function px(t){if(this[Xt]+=t.length,this[Oo]._maxPayload<1||this[Xt]<=this[Oo]._maxPayload){this[Tn].push(t);return}this[zr]=new RangeError("Max payload size exceeded"),this[zr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[zr][hx]=1009,this.removeListener("data",px),this.reset()}function nE(t){if(this[Oo]._inflate=null,this[zr]){this[Br](this[zr]);return}t[hx]=1007,this[Br](t)}});var Ur=se((pD,Lo)=>{"use strict";var{isUtf8:mx}=le("buffer"),{hasBlob:rE}=Zt(),iE=[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 sE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function ud(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 oE(t){return rE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Lo.exports={isBlob:oE,isValidStatusCode:sE,isValidUTF8:ud,tokenChars:iE};if(mx)Lo.exports.isValidUTF8=function(t){return t.length<24?ud(t):mx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=le("utf-8-validate");Lo.exports.isValidUTF8=function(e){return e.length<32?ud(e):t(e)}}catch{}});var gd=se((gD,Ax)=>{"use strict";var{Writable:aE}=le("stream"),_x=Fr(),{BINARY_TYPES:cE,EMPTY_BUFFER:yx,kStatusCode:dE,kWebSocket:lE}=Zt(),{concat:fd,toArrayBuffer:uE,unmask:fE}=Ki(),{isValidStatusCode:xE,isValidUTF8:bx}=Ur(),No=Buffer[Symbol.species],ut=0,Ex=1,vx=2,Sx=3,xd=4,hd=5,Mo=6,pd=class extends aE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||cE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[lE]=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=ut}_write(e,r,i){if(this._opcode===8&&this._state==ut)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 No(i.buffer,i.byteOffset+e,i.length-e),new No(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 No(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 ut:this.getInfo(e);break;case Ex:this.getPayloadLength16(e);break;case vx:this.getPayloadLength64(e);break;case Sx:this.getMask();break;case xd:this.getData(e);break;case hd:case Mo: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[_x.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=Ex:this._payloadLength===127?this._state=vx: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=Sx:this._state=xd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=xd}getData(e){let r=yx;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&&fE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=hd,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[_x.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===ut&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=ut;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=fd(i,r):this._binaryType==="arraybuffer"?o=uE(fd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=ut):(this._state=Mo,setImmediate(()=>{this.emit("message",o,!0),this._state=ut,this.startLoop(e)}))}else{let o=fd(i,r);if(!this._skipUTF8Validation&&!bx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===hd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=ut):(this._state=Mo,setImmediate(()=>{this.emit("message",o,!1),this._state=ut,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,yx),this.end();else{let i=e.readUInt16BE(0);if(!xE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new No(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!bx(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=ut;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ut):(this._state=Mo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ut,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[dE]=o,l}};Ax.exports=pd});var _d=se((wD,Dx)=>{"use strict";var{Duplex:mD}=le("stream"),{randomFillSync:hE}=le("crypto"),Ix=Fr(),{EMPTY_BUFFER:pE,kWebSocket:gE,NOOP:mE}=Zt(),{isBlob:Gr,isValidStatusCode:wE}=Ur(),{mask:Tx,toBuffer:Vn}=Ki(),ft=Symbol("kByteLength"),_E=Buffer.alloc(4),Bo=8*1024,Jn,qr=Bo,vt=0,yE=1,bE=2,md=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=vt,this.onerror=mE,this[gE]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||_E,r.generateMask?r.generateMask(i):(qr===Bo&&(Jn===void 0&&(Jn=Buffer.alloc(Bo)),hE(Jn,0,Bo),qr=0),i[0]=Jn[qr++],i[1]=Jn[qr++],i[2]=Jn[qr++],i[3]=Jn[qr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[ft]!==void 0?u=r[ft]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=126);let g=Buffer.allocUnsafe(o?u+c:c);return g[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(g[0]|=64),g[1]=x,x===126?g.writeUInt16BE(u,2):x===127&&(g[2]=g[3]=0,g.writeUIntBE(u,4,6)),r.mask?(g[1]|=128,g[c-4]=i[0],g[c-3]=i[1],g[c-2]=i[2],g[c-1]=i[3],l?[g,e]:o?(Tx(e,i,g,c,u),[g]):(Tx(e,i,e,0,u),[g,e])):[g,e]}close(e,r,i,o){let c;if(e===void 0)c=pE;else{if(typeof e!="number"||!wE(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={[ft]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==vt?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):Gr(e)?(o=e.size,c=!1):(e=Vn(e),o=e.length,c=Vn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ft]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Gr(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?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):Gr(e)?(o=e.size,c=!1):(e=Vn(e),o=e.length,c=Vn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ft]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Gr(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[Ix.extensionName],c=r.binary?2:1,l=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):Gr(e)?(u=e.size,x=!1):(e=Vn(e),u=e.length,x=Vn.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 g={[ft]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};Gr(e)?this._state!==vt?this.enqueue([this.getBlobData,e,this._compress,g,i]):this.getBlobData(e,this._compress,g,i):this._state!==vt?this.enqueue([this.dispatch,e,this._compress,g,i]):this.dispatch(e,this._compress,g,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ft],this._state=bE,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(wd,this,u,o);return}this._bufferedBytes-=i[ft];let l=Vn(c);r?this.dispatch(l,r,i,o):(this._state=vt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(EE,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Ix.extensionName];this._bufferedBytes+=i[ft],this._state=yE,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");wd(this,x,o);return}this._bufferedBytes-=i[ft],this._state=vt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===vt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ft],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ft],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)}};Dx.exports=md;function wd(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 EE(t,e,r){wd(t,e,r),t.onerror(e)}});var Bx=se((_D,Mx)=>{"use strict";var{kForOnEventAttribute:Vi,kListener:yd}=Zt(),Cx=Symbol("kCode"),Rx=Symbol("kData"),kx=Symbol("kError"),Px=Symbol("kMessage"),Ox=Symbol("kReason"),jr=Symbol("kTarget"),Lx=Symbol("kType"),Nx=Symbol("kWasClean"),Yt=class{constructor(e){this[jr]=null,this[Lx]=e}get target(){return this[jr]}get type(){return this[Lx]}};Object.defineProperty(Yt.prototype,"target",{enumerable:!0});Object.defineProperty(Yt.prototype,"type",{enumerable:!0});var Zn=class extends Yt{constructor(e,r={}){super(e),this[Cx]=r.code===void 0?0:r.code,this[Ox]=r.reason===void 0?"":r.reason,this[Nx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Cx]}get reason(){return this[Ox]}get wasClean(){return this[Nx]}};Object.defineProperty(Zn.prototype,"code",{enumerable:!0});Object.defineProperty(Zn.prototype,"reason",{enumerable:!0});Object.defineProperty(Zn.prototype,"wasClean",{enumerable:!0});var Hr=class extends Yt{constructor(e,r={}){super(e),this[kx]=r.error===void 0?null:r.error,this[Px]=r.message===void 0?"":r.message}get error(){return this[kx]}get message(){return this[Px]}};Object.defineProperty(Hr.prototype,"error",{enumerable:!0});Object.defineProperty(Hr.prototype,"message",{enumerable:!0});var Ji=class extends Yt{constructor(e,r={}){super(e),this[Rx]=r.data===void 0?null:r.data}get data(){return this[Rx]}};Object.defineProperty(Ji.prototype,"data",{enumerable:!0});var vE={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Vi]&&o[yd]===e&&!o[Vi])return;let i;if(t==="message")i=function(c,l){let u=new Ji("message",{data:l?c:c.toString()});u[jr]=this,zo(e,this,u)};else if(t==="close")i=function(c,l){let u=new Zn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[jr]=this,zo(e,this,u)};else if(t==="error")i=function(c){let l=new Hr("error",{error:c,message:c.message});l[jr]=this,zo(e,this,l)};else if(t==="open")i=function(){let c=new Yt("open");c[jr]=this,zo(e,this,c)};else return;i[Vi]=!!r[Vi],i[yd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[yd]===e&&!r[Vi]){this.removeListener(t,r);break}}};Mx.exports={CloseEvent:Zn,ErrorEvent:Hr,Event:Yt,EventTarget:vE,MessageEvent:Ji};function zo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Fo=se((yD,zx)=>{"use strict";var{tokenChars:Zi}=Ur();function Ft(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function SE(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,x=-1,g=-1,w=-1,E=0;for(;E<t.length;E++)if(g=t.charCodeAt(E),l===void 0)if(w===-1&&Zi[g]===1)x===-1&&(x=E);else if(E!==0&&(g===32||g===9))w===-1&&x!==-1&&(w=E);else if(g===59||g===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);w===-1&&(w=E);let y=t.slice(x,w);g===44?(Ft(e,y,r),r=Object.create(null)):l=y,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(u===void 0)if(w===-1&&Zi[g]===1)x===-1&&(x=E);else if(g===32||g===9)w===-1&&x!==-1&&(w=E);else if(g===59||g===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);w===-1&&(w=E),Ft(r,t.slice(x,w),!0),g===44&&(Ft(e,l,r),r=Object.create(null),l=void 0),x=w=-1}else if(g===61&&x!==-1&&w===-1)u=t.slice(x,E),x=w=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(o){if(Zi[g]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);x===-1?x=E:i||(i=!0),o=!1}else if(c)if(Zi[g]===1)x===-1&&(x=E);else if(g===34&&x!==-1)c=!1,w=E;else if(g===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(g===34&&t.charCodeAt(E-1)===61)c=!0;else if(w===-1&&Zi[g]===1)x===-1&&(x=E);else if(x!==-1&&(g===32||g===9))w===-1&&(w=E);else if(g===59||g===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);w===-1&&(w=E);let y=t.slice(x,w);i&&(y=y.replace(/\\/g,""),i=!1),Ft(r,u,y),g===44&&(Ft(e,l,r),r=Object.create(null),l=void 0),u=void 0,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(x===-1||c||g===32||g===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=E);let S=t.slice(x,w);return l===void 0?Ft(e,S,r):(u===void 0?Ft(r,S,!0):i?Ft(r,u,S.replace(/\\/g,"")):Ft(r,u,S),Ft(e,l,r)),e}function AE(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(", ")}zx.exports={format:AE,parse:SE}});var jo=se((vD,Zx)=>{"use strict";var IE=le("events"),TE=le("https"),DE=le("http"),Gx=le("net"),CE=le("tls"),{randomBytes:RE,createHash:kE}=le("crypto"),{Duplex:bD,Readable:ED}=le("stream"),{URL:bd}=le("url"),Dn=Fr(),PE=gd(),OE=_d(),{isBlob:LE}=Ur(),{BINARY_TYPES:Fx,CLOSE_TIMEOUT:NE,EMPTY_BUFFER:Uo,GUID:ME,kForOnEventAttribute:Ed,kListener:BE,kStatusCode:zE,kWebSocket:qe,NOOP:qx}=Zt(),{EventTarget:{addEventListener:FE,removeEventListener:UE}}=Bx(),{format:GE,parse:qE}=Fo(),{toBuffer:jE}=Ki(),jx=Symbol("kAborted"),vd=[8,13],Qt=["CONNECTING","OPEN","CLOSING","CLOSED"],HE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ge=class t extends IE{constructor(e,r,i){super(),this._binaryType=Fx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Uo,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]),Hx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Fx.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 PE({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new OE(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[qe]=this,c[qe]=this,e[qe]=this,o.on("conclude",$E),o.on("drain",VE),o.on("error",JE),o.on("message",ZE),o.on("ping",XE),o.on("pong",YE),c.onerror=QE,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",$x),e.on("data",qo),e.on("end",Vx),e.on("error",Jx),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[Dn.extensionName]&&this._extensions[Dn.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){ot(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())}),Kx(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){Sd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Uo,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){Sd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Uo,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){Sd(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Dn.extensionName]||(o.compress=!1),this._sender.send(e||Uo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ot(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(ge,"CONNECTING",{enumerable:!0,value:Qt.indexOf("CONNECTING")});Object.defineProperty(ge.prototype,"CONNECTING",{enumerable:!0,value:Qt.indexOf("CONNECTING")});Object.defineProperty(ge,"OPEN",{enumerable:!0,value:Qt.indexOf("OPEN")});Object.defineProperty(ge.prototype,"OPEN",{enumerable:!0,value:Qt.indexOf("OPEN")});Object.defineProperty(ge,"CLOSING",{enumerable:!0,value:Qt.indexOf("CLOSING")});Object.defineProperty(ge.prototype,"CLOSING",{enumerable:!0,value:Qt.indexOf("CLOSING")});Object.defineProperty(ge,"CLOSED",{enumerable:!0,value:Qt.indexOf("CLOSED")});Object.defineProperty(ge.prototype,"CLOSED",{enumerable:!0,value:Qt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(ge.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(ge.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ed])return e[BE];return null},set(e){for(let r of this.listeners(t))if(r[Ed]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Ed]:!0})}})});ge.prototype.addEventListener=FE;ge.prototype.removeEventListener=UE;Zx.exports=ge;function Hx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:NE,protocolVersion:vd[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,!vd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${vd.join(", ")})`);let c;if(e instanceof bd)c=e;else try{c=new bd(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:",x;if(c.protocol!=="ws:"&&!l&&!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 A=new SyntaxError(x);if(t._redirects===0)throw A;Go(t,A);return}let g=l?443:80,w=RE(16).toString("base64"),E=l?TE.request:DE.request,S=new Set,y;if(o.createConnection=o.createConnection||(l?KE:WE),o.defaultPort=o.defaultPort||g,o.port=c.port||g,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&&(y=new Dn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=GE({[Dn.extensionName]:y.offer()})),r.length){for(let A of r){if(typeof A!="string"||!HE.test(A)||S.has(A))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(A)}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 A=o.path.split(":");o.socketPath=A[0],o.path=A[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let A=i&&i.headers;if(i={...i,headers:{}},A)for(let[T,D]of Object.entries(A))i.headers[T.toLowerCase()]=D}else if(t.listenerCount("redirect")===0){let A=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!A||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,A||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=E(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=E(o);o.timeout&&v.on("timeout",()=>{ot(t,v,"Opening handshake has timed out")}),v.on("error",A=>{v===null||v[jx]||(v=t._req=null,Go(t,A))}),v.on("response",A=>{let T=A.headers.location,D=A.statusCode;if(T&&o.followRedirects&&D>=300&&D<400){if(++t._redirects>o.maxRedirects){ot(t,v,"Maximum redirects exceeded");return}v.abort();let P;try{P=new bd(T,e)}catch{let k=new SyntaxError(`Invalid URL: ${T}`);Go(t,k);return}Hx(t,P,r,i)}else t.emit("unexpected-response",v,A)||ot(t,v,`Unexpected server response: ${A.statusCode}`)}),v.on("upgrade",(A,T,D)=>{if(t.emit("upgrade",A),t.readyState!==ge.CONNECTING)return;v=t._req=null;let P=A.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){ot(t,T,"Invalid Upgrade header");return}let b=kE("sha1").update(w+ME).digest("base64");if(A.headers["sec-websocket-accept"]!==b){ot(t,T,"Invalid Sec-WebSocket-Accept header");return}let k=A.headers["sec-websocket-protocol"],O;if(k!==void 0?S.size?S.has(k)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":S.size&&(O="Server sent no subprotocol"),O){ot(t,T,O);return}k&&(t._protocol=k);let U=A.headers["sec-websocket-extensions"];if(U!==void 0){if(!y){ot(t,T,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=qE(U)}catch{ot(t,T,"Invalid Sec-WebSocket-Extensions header");return}let J=Object.keys(B);if(J.length!==1||J[0]!==Dn.extensionName){ot(t,T,"Server indicated an extension that was not requested");return}try{y.accept(B[Dn.extensionName])}catch{ot(t,T,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Dn.extensionName]=y}t.setSocket(T,D,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function Go(t,e){t._readyState=ge.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function WE(t){return t.path=t.socketPath,Gx.connect(t)}function KE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Gx.isIP(t.host)?"":t.host),CE.connect(t)}function ot(t,e,r){t._readyState=ge.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ot),e.setHeader?(e[jx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Go,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Sd(t,e,r){if(e){let i=LE(e)?e.size:jE(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Qt[t.readyState]})`);process.nextTick(r,i)}}function $E(t,e){let r=this[qe];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[qe]!==void 0&&(r._socket.removeListener("data",qo),process.nextTick(Wx,r._socket),t===1005?r.close():r.close(t,e))}function VE(){let t=this[qe];t.isPaused||t._socket.resume()}function JE(t){let e=this[qe];e._socket[qe]!==void 0&&(e._socket.removeListener("data",qo),process.nextTick(Wx,e._socket),e.close(t[zE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ux(){this[qe].emitClose()}function ZE(t,e){this[qe].emit("message",t,e)}function XE(t){let e=this[qe];e._autoPong&&e.pong(t,!this._isServer,qx),e.emit("ping",t)}function YE(t){this[qe].emit("pong",t)}function Wx(t){t.resume()}function QE(t){let e=this[qe];e.readyState!==ge.CLOSED&&(e.readyState===ge.OPEN&&(e._readyState=ge.CLOSING,Kx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Kx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function $x(){let t=this[qe];if(this.removeListener("close",$x),this.removeListener("data",qo),this.removeListener("end",Vx),t._readyState=ge.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[qe]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ux),t._receiver.on("finish",Ux))}function qo(t){this[qe]._receiver.write(t)||this.pause()}function Vx(){let t=this[qe];t._readyState=ge.CLOSING,t._receiver.end(),this.end()}function Jx(){let t=this[qe];this.removeListener("error",Jx),this.on("error",qx),t&&(t._readyState=ge.CLOSING,this.destroy())}});var eh=se((AD,Qx)=>{"use strict";var SD=jo(),{Duplex:ev}=le("stream");function Xx(t){t.emit("close")}function tv(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Yx(t){this.removeListener("error",Yx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function nv(t,e){let r=!0,i=new ev({...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(Xx,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick(Xx,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",tv),i.on("error",Yx),i}Qx.exports=nv});var Ad=se((ID,th)=>{"use strict";var{tokenChars:rv}=Ur();function iv(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&&rv[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}th.exports={parse:iv}});var ch=se((DD,ah)=>{"use strict";var sv=le("events"),Ho=le("http"),{Duplex:TD}=le("stream"),{createHash:ov}=le("crypto"),nh=Fo(),Xn=Fr(),av=Ad(),cv=jo(),{CLOSE_TIMEOUT:dv,GUID:lv,kWebSocket:uv}=Zt(),fv=/^[+/0-9A-Za-z]{22}==$/,rh=0,ih=1,oh=2,Id=class extends sv{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:dv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:cv,...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=Ho.createServer((i,o)=>{let c=Ho.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=xv(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=rh}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===oh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Xi,this);return}if(e&&this.once("close",e),this._state!==ih)if(this._state=ih,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(Xi,this):process.nextTick(Xi,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Xi(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",sh);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Yn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Yn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!fv.test(c)){Yn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Yn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Yi(r,400);return}let x=e.headers["sec-websocket-protocol"],g=new Set;if(x!==void 0)try{g=av.parse(x)}catch{Yn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&w!==void 0){let S=new Xn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=nh.parse(w);y[Xn.extensionName]&&(S.accept(y[Xn.extensionName]),E[Xn.extensionName]=S)}catch{Yn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={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(S,(y,v,A,T)=>{if(!y)return Yi(r,v||401,A,T);this.completeUpgrade(E,c,g,e,r,i,o)});return}if(!this.options.verifyClient(S))return Yi(r,401)}this.completeUpgrade(E,c,g,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[uv])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>rh)return Yi(c,503);let g=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ov("sha1").update(r+lv).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(i.size){let E=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;E&&(g.push(`Sec-WebSocket-Protocol: ${E}`),w._protocol=E)}if(e[Xn.extensionName]){let E=e[Xn.extensionName].params,S=nh.format({[Xn.extensionName]:[E]});g.push(`Sec-WebSocket-Extensions: ${S}`),w._extensions=e}this.emit("headers",g,o),c.write(g.concat(`\r
10
+ `),this.stream=void 0;return}this.currentDate!==void 0&&os(this.dir,this.prefix,e,this.opts.retentionDays),this.currentDate=e}close(){this.stream?.end(),this.stream=void 0,this.currentDate=void 0}}});import{appendFileSync as ug,mkdirSync as fg}from"node:fs";import{join as xg}from"node:path";function fl(t){let e=t.retentionDays??gg,r=t.clock??(()=>kn(new Date));cs={bridgeSink:new Yr(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new Yr(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();os(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])os(t.agentLogsDir(o),"agent",i,e)}function mg(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function xl(t){Sa=t}function hl(t){return ir[Sa]<=ir[t]}function pl(t,e){let r=ir[t];return r===void 0?!0:r>=ir[e]}function ds(t){ul={...t}}function gl(t){let e=(u,x=2)=>String(u).padStart(x,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),l=e(o%60);return`${kn(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${l}`}function St(t,e,r,i,o){try{let c=`${JSON.stringify({ts:gl(new Date),level:e,module:r,msg:i,...o})}
11
+ `;fg(t,{recursive:!0}),ug(xg(t,rr("bridge",kn(new Date))),c)}catch{}}function wg(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function as(t,e,r,i,o){if(ir[t]<ir[Sa])return;let c=`${JSON.stringify({ts:gl(new Date),level:t,module:e,msg:r,...ul,...i})}
12
+ `;if(cs){let l=wg(o,i),u=l?mg(cs,l):cs.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?pg.write(c):hg.write(c)}function q(t,e){return{debug:(r,i)=>as("debug",t,r,i,e),info:(r,i)=>as("info",t,r,i,e),warn:(r,i)=>as("warn",t,r,i,e),error:(r,i)=>as("error",t,r,i,e),child:r=>q(`${t}.${r}`,e),forAgent:r=>q(t,r)}}var ir,Sa,hg,pg,ul,gg,cs,re=Ye(()=>{"use strict";nr();va();ir={debug:10,info:20,warn:30,error:40},Sa=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),hg=process.stdout,pg=process.stderr,ul={},gg=We("COZE_BRIDGE_LOG_RETENTION_DAYS",30),cs=null});var C,Ke=Ye(()=>{"use strict";C=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var yl={};Ea(yl,{ACP_WRAPPER_NPM_PACKAGES:()=>Qr,_resetAcpInstallerForTests:()=>Sg,_setBinaryPathCacheForTests:()=>Ig,buildAcpSpawn:()=>ei,ensureAcpInstalled:()=>sr,getAcpBinaryPath:()=>ls,pickWhichLine:()=>Ta,probeAcpVersion:()=>vg,resolveAcpCommand:()=>_l});import{readFileSync as ml}from"node:fs";import{createRequire as _g}from"node:module";import{dirname as yg,resolve as Eg}from"node:path";function Ta(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]}function bg(t){let e=wl.resolve(`${t.npmPackage}/package.json`),r=yg(e),i=JSON.parse(ml(e,"utf8")),o=typeof i.bin=="string"?i.bin:i.bin?.[t.binary];if(!o)throw new Error(`${t.npmPackage} package.json \u7F3A bin[${t.binary}]`);return Eg(r,o)}async function sr(t,e){let r=Aa[t];if(!r)throw new C("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Xr.get(t);if(i)return i;try{let o=bg(r);return Xr.set(t,o),Ia.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw Ia.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:r.npmPackage,err:String(o)}),new C("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${r.npmPackage} (framework=${t})`,"\u8BE5 wrapper \u968F coze-bridge \u4E00\u8D77\u5B89\u88C5 (\u56FA\u5316\u5230 ~/.coze/bridge/lib/node_modules)\u3002","\u8BF7\u91CD\u8DD1 `coze-bridge pair` / `connect` \u89E6\u53D1\u56FA\u5316\u5B89\u88C5; \u82E5\u4ECD\u5931\u8D25, \u68C0\u67E5\u7F51\u7EDC / npm \u7F13\u5B58\u3002"].join(`
13
+ `),{cause:o})}}async function vg(t){let e=Aa[t];if(e)try{let r=wl.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(ml(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){Ia.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function ls(t){return Xr.get(t)}function _l(t,e){if(e)return e;let r=ls(t);if(!r)throw new C("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function ei(t,e,r){if(e)return{command:e,args:[...r]};let i=_l(t);return{command:process.execPath,args:[i,...r]}}function Sg(){Xr.clear()}function Ig(t,e){Xr.set(t,e)}var Ia,Aa,Qr,wl,Xr,rn=Ye(()=>{"use strict";Ke();re();Ia=q("agents.acp-installer"),Aa={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@agentclientprotocol/codex-acp",binary:"codex-acp"}},Qr=Object.values(Aa).filter(t=>t!==void 0).map(t=>t.npmPackage),wl=_g(import.meta.url),Xr=new Map});import{chmod as Tg,mkdir as Cg,readFile as Rg,rename as kg,rm as Dg,writeFile as Pg}from"node:fs/promises";import{dirname as Og}from"node:path";async function or(t){try{let e=await Rg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function sn(t,e,r){await Cg(Og(t),{recursive:!0});let i=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{await Pg(i,e,{encoding:"utf8",mode:r?.mode}),await kg(i,t),r?.mode!==void 0&&await Tg(t,r.mode)}catch(o){throw await Dg(i,{force:!0}).catch(()=>{}),o}}async function ar(t,e,r){await sn(t,`${JSON.stringify(e,null,2)}
14
+ `,r)}var on=Ye(()=>{"use strict"});import{promises as vl,readdirSync as Lg}from"node:fs";import{homedir as Ng}from"node:os";import{sep as Mg,join as Re,resolve as Sl}from"node:path";function ee(t){let e=t??Ng(),r=Re(e,".coze"),i=Re(r,"bridge"),o=Re(i,"lib"),c=Re(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Re(o,"index.js"),binDir:Re(i,"bin"),pidFile:Re(i,"bridge.pid"),portFile:Re(i,"bridge.port"),tokenFile:Re(i,"bridge.token"),patTokenFile:Re(i,"pat-token"),agentEnvFile:Re(i,"agent-env.json"),logFile:Re(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Re(c,"daemon-stdio.log"),installLock:Re(i,"install.lock"),configFile:Re(i,"config.json"),agentsRoot:Re(r,"agents")}}function Xe(t,e=ee()){let r=Re(e.agentsRoot,t);return{root:r,config:Re(r,"config.json"),workspace:Re(r,"workspace"),logs:Re(r,"logs")}}function us(t=ee()){try{return Lg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function ti(t,e){let r=await vl.realpath(Sl(t)).catch(()=>null);if(!r)return!1;let i=await vl.realpath(Sl(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+Mg)}var Le=Ye(()=>{"use strict"});var hs={};Ea(hs,{AGENT_CONFIG_FILE_MODE:()=>fs,enforceAgentConfigMode:()=>zg,loadAgentConfig:()=>Be,persistAgentSessions:()=>ni,persistAgentSkills:()=>xs,saveAgentConfig:()=>Qe});import{chmod as Bg,stat as Fg}from"node:fs/promises";function Be(t,e){return or(Xe(t,e).config)}function Qe(t,e){return ar(Xe(t.agentId,e).config,t,{mode:fs})}async function zg(t,e){if(process.platform==="win32")return;let r=Xe(t,e).config;try{let i=await Fg(r);if(!i.isFile())return;let o=i.mode&511;o!==fs&&(await Bg(r,fs),Il.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;Il.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ni(t,e,r){let i=await Be(t,r);i&&(i.sessions=Object.fromEntries(e),await Qe(i,r))}async function xs(t,e,r){let i=await Be(t,r);i&&(i.skills=e,await Qe(i,r))}var Il,fs,an=Ye(()=>{"use strict";on();re();Le();Il=q("agent-config"),fs=384});var ka=ce((S2,Cl)=>{Cl.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 gs=ce(kl=>{var Rl={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 Wg(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(Rl))kl[t]=Wg(Rl[t])});var Nl=ce((A2,Ll)=>{var Kg=fe("fs"),Ne=fe("path"),Dl=ka(),$g=gs(),Vg=typeof process=="object"&&process.platform==="win32",Pl=t=>typeof t=="object"&&t!==null,Ol=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 ve(t){this.sep=Ne.sep,this.fs=Kg,Pl(t)&&Pl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Ll.exports=ve;ve.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 $g.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};ve.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=Ne.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};ve.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,x){if(l&&x.isDirectory())return o(!1);var p=Ne.dirname(t);c.fs.exists(p,function(w){w||c.makeDir(p),c.fs.open(t,"w",438,function(_,I){_?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,S){c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):I?c.fs.write(I,e,0,e.length,0,function(){c.fs.close(I,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};ve.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 x=Ne.join(i,u),p=e.fs.statSync(x);(!o||o.test(x))&&l.push(Ne.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(l=l.concat(r(x,o,c)))}),l}return r(t,void 0,!0)};ve.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=Ne.join(t,u),r.fs.stat(u,function(x,p){if(x)return e(x);p&&(i.push(Ne.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(w,_){if(w)return e(w);i=i.concat(_),--l||e(null,i)}):--l||e(null,i))})})})};ve.prototype.getAttributes=function(){};ve.prototype.setAttributes=function(){};ve.crc32update=function(t,e){return Ol[(t^e)&255]^t>>>8};ve.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=ve.crc32update(r,t[i++]);return~r>>>0};ve.methodToString=function(t){switch(t){case Dl.STORED:return"STORED ("+t+")";case Dl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ve.canonical=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.join(".",e)};ve.zipnamefix=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.posix.join(".",e)};ve.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]};ve.sanitize=function(t,e){t=Ne.resolve(Ne.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Ne.normalize(Ne.join(t,r.slice(i,o).join(Ne.sep)));if(c.indexOf(t)===0)return c}return Ne.normalize(Ne.join(t,Ne.basename(e)))};ve.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};ve.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};ve.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)};ve.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};ve.isWin=Vg;ve.crcTable=Ol});var Bl=ce((T2,Ml)=>{var Jg=fe("path");Ml.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=Jg.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 zl=ce((C2,Fl)=>{Fl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var lr=ce((R2,dr)=>{dr.exports=Nl();dr.exports.Constants=ka();dr.exports.Errors=gs();dr.exports.FileAttr=Bl();dr.exports.decoder=zl()});var ql=ce((k2,Ul)=>{var cn=lr(),z=cn.Constants;Ul.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,x=0,p=0,w=0,_=0,I=0,y=0,S=0;t|=cn.isWin?2560:768,r|=z.FLG_EFS;let A={extraLen:0},T=E=>Math.max(0,E)>>>0,R=E=>Math.max(0,E)&65535,P=E=>Math.max(0,E)&255;return o=cn.fromDate2DOS(new Date),{get made(){return t},set made(E){t=E},get version(){return e},set version(E){e=E},get flags(){return r},set flags(E){r=E},get flags_efs(){return(r&z.FLG_EFS)>0},set flags_efs(E){E?r|=z.FLG_EFS:r&=~z.FLG_EFS},get flags_desc(){return(r&z.FLG_DESC)>0},set flags_desc(E){E?r|=z.FLG_DESC:r&=~z.FLG_DESC},get method(){return i},set method(E){switch(E){case z.STORED:this.version=10;case z.DEFLATED:default:this.version=20}i=E},get time(){return cn.fromDOS2Date(this.timeval)},set time(E){E=new Date(E),this.timeval=cn.fromDate2DOS(E)},get timeval(){return o},set timeval(E){o=T(E)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(E){c=T(E)},get compressedSize(){return l},set compressedSize(E){l=T(E)},get size(){return u},set size(E){u=T(E)},get fileNameLength(){return x},set fileNameLength(E){x=E},get extraLength(){return p},set extraLength(E){p=E},get extraLocalLength(){return A.extraLen},set extraLocalLength(E){A.extraLen=E},get commentLength(){return w},set commentLength(E){w=E},get diskNumStart(){return _},set diskNumStart(E){_=T(E)},get inAttr(){return I},set inAttr(E){I=T(E)},get attr(){return y},set attr(E){y=T(E)},get fileAttr(){return(y||0)>>16&4095},get offset(){return S},set offset(E){S=T(E)},get encrypted(){return(r&z.FLG_ENC)===z.FLG_ENC},get centralHeaderSize(){return z.CENHDR+x+p+w},get realDataOffset(){return S+z.LOCHDR+A.fnameLen+A.extraLen},get localHeader(){return A},loadLocalHeaderFromBinary:function(E){var k=E.slice(S,S+z.LOCHDR);if(k.readUInt32LE(0)!==z.LOCSIG)throw cn.Errors.INVALID_LOC();A.version=k.readUInt16LE(z.LOCVER),A.flags=k.readUInt16LE(z.LOCFLG),A.flags_desc=(A.flags&z.FLG_DESC)>0,A.method=k.readUInt16LE(z.LOCHOW),A.time=k.readUInt32LE(z.LOCTIM),A.crc=k.readUInt32LE(z.LOCCRC),A.compressedSize=k.readUInt32LE(z.LOCSIZ),A.size=k.readUInt32LE(z.LOCLEN),A.fnameLen=k.readUInt16LE(z.LOCNAM),A.extraLen=k.readUInt16LE(z.LOCEXT);let O=S+z.LOCHDR+A.fnameLen,F=O+A.extraLen;return E.slice(O,F)},loadFromBinary:function(E){if(E.length!==z.CENHDR||E.readUInt32LE(0)!==z.CENSIG)throw cn.Errors.INVALID_CEN();t=E.readUInt16LE(z.CENVEM),e=E.readUInt16LE(z.CENVER),r=E.readUInt16LE(z.CENFLG),i=E.readUInt16LE(z.CENHOW),o=E.readUInt32LE(z.CENTIM),c=E.readUInt32LE(z.CENCRC),l=E.readUInt32LE(z.CENSIZ),u=E.readUInt32LE(z.CENLEN),x=E.readUInt16LE(z.CENNAM),p=E.readUInt16LE(z.CENEXT),w=E.readUInt16LE(z.CENCOM),_=E.readUInt16LE(z.CENDSK),I=E.readUInt16LE(z.CENATT),y=E.readUInt32LE(z.CENATX),S=E.readUInt32LE(z.CENOFF)},localHeaderToBinary:function(){var E=Buffer.alloc(z.LOCHDR);return E.writeUInt32LE(z.LOCSIG,0),E.writeUInt16LE(e,z.LOCVER),E.writeUInt16LE(r,z.LOCFLG),E.writeUInt16LE(i,z.LOCHOW),E.writeUInt32LE(o,z.LOCTIM),E.writeUInt32LE(c,z.LOCCRC),E.writeUInt32LE(l,z.LOCSIZ),E.writeUInt32LE(u,z.LOCLEN),E.writeUInt16LE(x,z.LOCNAM),E.writeUInt16LE(A.extraLen,z.LOCEXT),E},centralHeaderToBinary:function(){var E=Buffer.alloc(z.CENHDR+x+p+w);return E.writeUInt32LE(z.CENSIG,0),E.writeUInt16LE(t,z.CENVEM),E.writeUInt16LE(e,z.CENVER),E.writeUInt16LE(r,z.CENFLG),E.writeUInt16LE(i,z.CENHOW),E.writeUInt32LE(o,z.CENTIM),E.writeUInt32LE(c,z.CENCRC),E.writeUInt32LE(l,z.CENSIZ),E.writeUInt32LE(u,z.CENLEN),E.writeUInt16LE(x,z.CENNAM),E.writeUInt16LE(p,z.CENEXT),E.writeUInt16LE(w,z.CENCOM),E.writeUInt16LE(_,z.CENDSK),E.writeUInt16LE(I,z.CENATT),E.writeUInt32LE(y,z.CENATX),E.writeUInt32LE(S,z.CENOFF),E},toJSON:function(){let E=function(k){return k+" bytes"};return{made:t,version:e,flags:r,method:cn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:E(l),size:E(u),fileNameLength:E(x),extraLength:E(p),commentLength:E(w),diskNumStart:_,inAttr:I,attr:y,offset:S,centralHeaderSize:E(z.CENHDR+x+p+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Hl=ce((D2,Gl)=>{var ur=lr(),ye=ur.Constants;Gl.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 ye.ENDHDR+o},loadFromBinary:function(c){if((c.length!==ye.ENDHDR||c.readUInt32LE(0)!==ye.ENDSIG)&&(c.length<ye.ZIP64HDR||c.readUInt32LE(0)!==ye.ZIP64SIG))throw ur.Errors.INVALID_END();c.readUInt32LE(0)===ye.ENDSIG?(t=c.readUInt16LE(ye.ENDSUB),e=c.readUInt16LE(ye.ENDTOT),r=c.readUInt32LE(ye.ENDSIZ),i=c.readUInt32LE(ye.ENDOFF),o=c.readUInt16LE(ye.ENDCOM)):(t=ur.readBigUInt64LE(c,ye.ZIP64SUB),e=ur.readBigUInt64LE(c,ye.ZIP64TOT),r=ur.readBigUInt64LE(c,ye.ZIP64SIZE),i=ur.readBigUInt64LE(c,ye.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(ye.ENDHDR+o);return c.writeUInt32LE(ye.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,ye.ENDSUB),c.writeUInt16LE(e,ye.ENDTOT),c.writeUInt32LE(r,ye.ENDSIZ),c.writeUInt32LE(i,ye.ENDOFF),c.writeUInt16LE(o,ye.ENDCOM),c.fill(" ",ye.ENDHDR),c},toJSON:function(){let c=function(l,u){let x=l.toString(16).toUpperCase();for(;x.length<u;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Pa=ce(Da=>{Da.EntryHeader=ql();Da.MainHeader=Hl()});var Wl=ce((O2,jl)=>{jl.exports=function(t){var e=fe("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),x=0;u.fill(0);for(var p=0;p<c.length;p++){var w=c[p];w.copy(u,x),x+=w.length}i&&i(u)}),o.end(t)}}}});var $l=ce((L2,Kl)=>{var Zg=+(process.versions?process.versions.node:"").split(".")[0]||0;Kl.exports=function(t,e){var r=fe("zlib");let i=Zg>=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(x){l.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),p=0;x.fill(0);for(var w=0;w<l.length;w++){var _=l[w];_.copy(x,p),p+=_.length}o&&o(x)}),c.end(t)}}}});var Xl=ce((N2,Yl)=>{"use strict";var{randomFillSync:Vl}=fe("crypto"),Yg=gs(),Xg=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}),Zl=(t,e)=>Math.imul(t,e)>>>0,Jl=(t,e)=>Xg[(t^e)&255]^t>>>8,ri=()=>typeof Vl=="function"?Vl(Buffer.alloc(12)):ri.node();ri.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 ms={genSalt:ri};function ws(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])}ws.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Jl(e[0],t),e[1]+=e[0]&255,e[1]=Zl(e[1],134775813)+1,e[2]=Jl(e[2],e[1]>>>24),t};ws.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Zl(t,t^1)>>8&255};function Qg(t){let e=new ws(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 em(t){let e=new ws(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 tm(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Qg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Yg.WRONG_PASSWORD();return i(t.slice(12))}function nm(t){Buffer.isBuffer(t)&&t.length>=12?ms.genSalt=function(){return t.slice(0,12)}:t==="node"?ms.genSalt=ri.node:ms.genSalt=ri}function rm(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=em(r),c=ms.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)}Yl.exports={decrypt:tm,encrypt:rm,_salter:nm}});var Ql=ce(_s=>{_s.Deflater=Wl();_s.Inflater=$l();_s.ZipCrypto=Xl()});var La=ce((B2,eu)=>{var de=lr(),im=Pa(),Se=de.Constants,Oa=Ql();eu.exports=function(t,e){var r=new im.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let w=t,_=typeof w.decoder=="object"?w.decoder:de.decoder;p=_.hasOwnProperty("efs")?_.efs:!1;function I(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function y(E){if(!r.flags_desc&&!r.localHeader.flags_desc){if(de.crc32(E)!==r.localHeader.crc)return!1}else{let k={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==Se.LOCSIG||e.readUInt32LE(O)==Se.CENSIG)throw de.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==Se.EXTSIG)k.crc=e.readUInt32LE(O+Se.EXTCRC),k.compressedSize=e.readUInt32LE(O+Se.EXTSIZ),k.size=e.readUInt32LE(O+Se.EXTLEN);else if(e.readUInt16LE(O+12)===19280)k.crc=e.readUInt32LE(O+Se.EXTCRC-4),k.compressedSize=e.readUInt32LE(O+Se.EXTSIZ-4),k.size=e.readUInt32LE(O+Se.EXTLEN-4);else throw de.Errors.DESCRIPTOR_UNKNOWN();if(k.compressedSize!==r.compressedSize||k.size!==r.size||k.crc!==r.crc)throw de.Errors.DESCRIPTOR_FAULTY();if(de.crc32(E)!==k.crc)return!1}return!0}function S(E,k,O){if(typeof k>"u"&&typeof E=="string"&&(O=E,E=void 0),c)return E&&k&&k(Buffer.alloc(0),de.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=I();if(F.length===0)return E&&k&&k(F),F;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw de.Errors.INVALID_PASS_PARAM();F=Oa.ZipCrypto.decrypt(F,r,O)}var B=Buffer.alloc(r.size);switch(r.method){case de.Constants.STORED:if(F.copy(B),y(B))return E&&k&&k(B),B;throw E&&k&&k(B,de.Errors.BAD_CRC()),de.Errors.BAD_CRC();case de.Constants.DEFLATED:var V=new Oa.Inflater(F,r.size);if(E)V.inflateAsync(function($){$.copy($,0),k&&(y($)?k($):k($,de.Errors.BAD_CRC()))});else{if(V.inflate(B).copy(B,0),!y(B))throw de.Errors.BAD_CRC(`"${_.decode(i)}"`);return B}break;default:throw E&&k&&k(Buffer.alloc(0),de.Errors.UNKNOWN_METHOD()),de.Errors.UNKNOWN_METHOD()}}function A(E,k){if((!l||!l.length)&&Buffer.isBuffer(e))return E&&k&&k(I()),I();if(l.length&&!c){var O;switch(r.method){case de.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(l.length),l.copy(O),E&&k&&k(O),O;default:case de.Constants.DEFLATED:var F=new Oa.Deflater(l);if(E)F.deflateAsync(function(V){O=Buffer.alloc(V.length),r.compressedSize=V.length,V.copy(O),k&&k(O)});else{var B=F.deflate();return r.compressedSize=B.length,B}F=null;break}}else if(E&&k)k(Buffer.alloc(0));else return Buffer.alloc(0)}function T(E,k){return de.readBigUInt64LE(E,k)}function R(E){try{for(var k=0,O,F,B;k+4<E.length;)O=E.readUInt16LE(k),k+=2,F=E.readUInt16LE(k),k+=2,B=E.slice(k,k+F),k+=F,Se.ID_ZIP64===O&&P(B)}catch{throw de.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(E){var k,O,F,B;E.length>=Se.EF_ZIP64_SCOMP&&(k=T(E,Se.EF_ZIP64_SUNCOMP),r.size===Se.EF_ZIP64_OR_32&&(r.size=k)),E.length>=Se.EF_ZIP64_RHO&&(O=T(E,Se.EF_ZIP64_SCOMP),r.compressedSize===Se.EF_ZIP64_OR_32&&(r.compressedSize=O)),E.length>=Se.EF_ZIP64_DSN&&(F=T(E,Se.EF_ZIP64_RHO),r.offset===Se.EF_ZIP64_OR_32&&(r.offset=F)),E.length>=Se.EF_ZIP64_DSN+4&&(B=E.readUInt32LE(Se.EF_ZIP64_DSN),r.diskNumStart===Se.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return _.decode(i)},get rawEntryName(){return i},set entryName(E){i=de.toBuffer(E,_.encode);var k=i[i.length-1];c=k===47||k===92,r.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return u},set extra(E){u=E,r.extraLength=E.length,R(E)},get comment(){return _.decode(o)},set comment(E){if(o=de.toBuffer(E,_.encode),r.commentLength=o.length,o.length>65535)throw de.Errors.COMMENT_TOO_LONG()},get name(){var E=_.decode(i);return c?E.substr(E.length-1).split("/").pop():E.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return A(!1,null)},getCompressedDataAsync:function(E){A(!0,E)},setData:function(E){l=de.toBuffer(E,de.decoder.encode),!c&&l.length?(r.size=l.length,r.method=de.Constants.DEFLATED,r.crc=de.crc32(E),r.changed=!0):r.method=de.Constants.STORED},getData:function(E){return r.changed?l:S(!1,null,E)},getDataAsync:function(E,k){r.changed?E(l):S(!0,E,k)},set attr(E){r.attr=E},get attr(){return r.attr},set header(E){r.loadFromBinary(E)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var E=r.centralHeaderToBinary(),k=de.Constants.CENHDR;return i.copy(E,k),k+=i.length,u.copy(E,k),k+=r.extraLength,o.copy(E,k),E},packLocalHeader:function(){let E=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let k=r.localHeaderToBinary(),O=Buffer.alloc(k.length+i.length+r.extraLocalLength);return k.copy(O,E),E+=k.length,i.copy(O,E),E+=i.length,x.copy(O,E),E+=x.length,O},toJSON:function(){let E=function(k){return"<"+(k&&k.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:E(e),data:E(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ru=ce((F2,nu)=>{var tu=La(),sm=Pa(),je=lr();nu.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new sm.MainHeader,l=!1,u=null;let x=new Set,p=e,{noSort:w,decoder:_}=p;t?S(p.readEntries):l=!0;function I(){let T=new Set;for(let R of Object.keys(i)){let P=R.split("/");if(P.pop(),!!P.length)for(let E=0;E<P.length;E++){let k=P.slice(0,E+1).join("/")+"/";T.add(k)}}for(let R of T)if(!(R in i)){let P=new tu(p);P.entryName=R,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,x.add(P)}}function y(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/je.Constants.CENHDR)throw je.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var T=c.offset,R=0;R<r.length;R++){var P=T,E=new tu(p,t);E.header=t.slice(P,P+=je.Constants.CENHDR),E.entryName=t.slice(P,P+=E.header.fileNameLength),E.header.extraLength&&(E.extra=t.slice(P,P+=E.header.extraLength)),E.header.commentLength&&(E.comment=t.slice(P,P+E.header.commentLength)),T+=E.header.centralHeaderSize,r[R]=E,i[E.entryName]=E}x.clear(),I()}function S(T){var R=t.length-je.Constants.ENDHDR,P=Math.max(0,R-65535),E=P,k=t.length,O=-1,F=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(P=0),R;R>=E;R--)if(t[R]===80){if(t.readUInt32LE(R)===je.Constants.ENDSIG){O=R,F=R,k=R+je.Constants.ENDHDR,E=R-je.Constants.END64HDR;continue}if(t.readUInt32LE(R)===je.Constants.END64SIG){E=P;continue}if(t.readUInt32LE(R)===je.Constants.ZIP64SIG){O=R,k=R+je.readBigUInt64LE(t,R+je.Constants.ZIP64SIZE)+je.Constants.ZIP64LEAD;break}}if(O==-1)throw je.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,k)),c.commentLength&&(o=t.slice(F+je.Constants.ENDHDR)),T&&y()}function A(){r.length>1&&!w&&r.sort((T,R)=>T.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return l||y(),r.filter(T=>!x.has(T))},get comment(){return _.decode(o)},set comment(T){o=je.toBuffer(T,_.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(T){this.entries.forEach(T)},getEntry:function(T){return l||y(),i[T]||null},setEntry:function(T){l||y(),r.push(T),i[T.entryName]=T,c.totalEntries=r.length},deleteFile:function(T,R=!0){l||y();let P=i[T];this.getEntryChildren(P,R).map(k=>k.entryName).forEach(this.deleteEntry)},deleteEntry:function(T){l||y();let R=i[T],P=r.indexOf(R);P>=0&&(r.splice(P,1),delete i[T],c.totalEntries=r.length)},getEntryChildren:function(T,R=!0){if(l||y(),typeof T=="object")if(T.isDirectory&&R){let P=[],E=T.entryName;for(let k of r)k.entryName.startsWith(E)&&P.push(k);return P}else return[T];return[]},getChildCount:function(T){if(T&&T.isDirectory){let R=this.getEntryChildren(T);return R.includes(T)?R.length-1:R.length}return 0},compressToBuffer:function(){l||y(),A();let T=[],R=[],P=0,E=0;c.size=0,c.offset=0;let k=0;for(let B of this.entries){let V=B.getCompressedData();B.header.offset=E;let $=B.packLocalHeader(),ne=$.length+V.length;E+=ne,T.push($),T.push(V);let Z=B.packCentralHeader();R.push(Z),c.size+=Z.length,P+=ne+Z.length,k++}P+=c.mainHeaderSize,c.offset=E,c.totalEntries=k,E=0;let O=Buffer.alloc(P);for(let B of T)B.copy(O,E),E+=B.length;for(let B of R)B.copy(O,E),E+=B.length;let F=c.toBinary();return o&&o.copy(F,je.Constants.ENDHDR),F.copy(O,E),t=O,l=!1,O},toAsyncBuffer:function(T,R,P,E){try{l||y(),A();let k=[],O=[],F=0,B=0,V=0;c.size=0,c.offset=0;let $=function(ne){if(ne.length>0){let Z=ne.shift(),se=Z.entryName+Z.extra.toString();P&&P(se),Z.getCompressedDataAsync(function(ae){E&&E(se),Z.header.offset=B;let L=Z.packLocalHeader(),G=L.length+ae.length;B+=G,k.push(L),k.push(ae);let K=Z.packCentralHeader();O.push(K),c.size+=K.length,F+=G+K.length,V++,$(ne)})}else{F+=c.mainHeaderSize,c.offset=B,c.totalEntries=V,B=0;let Z=Buffer.alloc(F);k.forEach(function(ae){ae.copy(Z,B),B+=ae.length}),O.forEach(function(ae){ae.copy(Z,B),B+=ae.length});let se=c.toBinary();o&&o.copy(se,je.Constants.ENDHDR),se.copy(Z,B),t=Z,l=!1,T(Z)}};$(Array.from(this.entries))}catch(k){R(k)}}}}});var ou=ce((z2,su)=>{var be=lr(),Ee=fe("path"),om=La(),am=ru(),Dn=(...t)=>be.findLast(t,e=>typeof e=="boolean"),iu=(...t)=>be.findLast(t,e=>typeof e=="string"),cm=(...t)=>be.findLast(t,e=>typeof e=="function"),dm={noSort:!1,readEntries:!1,method:be.Constants.NONE,fs:null};su.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),dm);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=be.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new be(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=be.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=be.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw be.Errors.INVALID_FILENAME();let c=new am(r,i),{canonical:l,sanitize:u,zipnamefix:x}=be;function p(y){if(y&&c){var S;if(typeof y=="string"&&(S=c.getEntry(Ee.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(S=c.getEntry(y.entryName)),S)return S}return null}function w(y){let{join:S,normalize:A,sep:T}=Ee.posix;return S(Ee.isAbsolute(y)?"/":".",A(T+y.split("\\").join(T)+T))}function _(y){return y instanceof RegExp?(function(S){return function(A){return S.test(A)}})(y):typeof y!="function"?()=>!0:y}let I=(y,S)=>{let A=S.slice(-1);return A=A===o.sep?o.sep:"",Ee.relative(y,S)+A};return{readFile:function(y,S){var A=p(y);return A&&A.getData(S)||null},childCount:function(y){let S=p(y);if(S)return c.getChildCount(S)},readFileAsync:function(y,S){var A=p(y);A?A.getDataAsync(S):S(null,"getEntry failed for:"+y)},readAsText:function(y,S){var A=p(y);if(A){var T=A.getData();if(T&&T.length)return T.toString(S||"utf8")}return""},readAsTextAsync:function(y,S,A){var T=p(y);T?T.getDataAsync(function(R,P){if(P){S(R,P);return}R&&R.length?S(R.toString(A||"utf8")):S("")}):S("")},deleteFile:function(y,S=!0){var A=p(y);A&&c.deleteFile(A.entryName,S)},deleteEntry:function(y){var S=p(y);S&&c.deleteEntry(S.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,S){var A=p(y);A&&(A.comment=S)},getZipEntryComment:function(y){var S=p(y);return S&&S.comment||""},updateFile:function(y,S){var A=p(y);A&&A.setData(S)},addLocalFile:function(y,S,A,T){if(o.fs.existsSync(y)){S=S?w(S):"";let R=Ee.win32.basename(Ee.win32.normalize(y));S+=A||R;let P=o.fs.statSync(y),E=P.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);P.isDirectory()&&(S+=o.sep),this.addFile(S,E,T,P)}else throw be.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,S){y=typeof y=="object"?y:{localPath:y};let A=Ee.resolve(y.localPath),{comment:T}=y,{zipPath:R,zipName:P}=y,E=this;o.fs.stat(A,function(k,O){if(k)return S(k,!1);R=R?w(R):"";let F=Ee.win32.basename(Ee.win32.normalize(A));if(R+=P||F,O.isFile())o.fs.readFile(A,function(B,V){return B?S(B,!1):(E.addFile(R,V,T,O),setImmediate(S,void 0,!0))});else if(O.isDirectory())return R+=o.sep,E.addFile(R,Buffer.alloc(0),T,O),setImmediate(S,void 0,!0)})},addLocalFolder:function(y,S,A){if(A=_(A),S=S?w(S):"",y=Ee.normalize(y),o.fs.existsSync(y)){let T=o.findFiles(y),R=this;if(T.length)for(let P of T){let E=Ee.join(S,I(y,P));A(E)&&R.addLocalFile(P,Ee.dirname(E))}}else throw be.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,S,A,T){T=_(T),A=A?w(A):"",y=Ee.normalize(y);var R=this;o.fs.open(y,"r",function(P){if(P&&P.code==="ENOENT")S(void 0,be.Errors.FILE_NOT_FOUND(y));else if(P)S(void 0,P);else{var E=o.findFiles(y),k=-1,O=function(){if(k+=1,k<E.length){var F=E[k],B=I(y,F).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),T(B)?o.fs.stat(F,function(V,$){V&&S(void 0,V),$.isFile()?o.fs.readFile(F,function(ne,Z){ne?S(void 0,ne):(R.addFile(A+B,Z,"",$),O())}):(R.addFile(A+B+"/",Buffer.alloc(0),"",$),O())}):process.nextTick(()=>{O()})}else S(!0,void 0)};O()}})},addLocalFolderAsync2:function(y,S){let A=this;y=typeof y=="object"?y:{localPath:y},localPath=Ee.resolve(w(y.localPath));let{zipPath:T,filter:R,namefix:P}=y;R instanceof RegExp?R=(function(O){return function(F){return O.test(F)}})(R):typeof R!="function"&&(R=function(){return!0}),T=T?w(T):"",P=="latin1"&&(P=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=O=>O);let E=O=>Ee.join(T,P(I(localPath,O))),k=O=>Ee.win32.basename(Ee.win32.normalize(P(O)));o.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?S(void 0,be.Errors.FILE_NOT_FOUND(localPath)):O?S(void 0,O):o.findFilesAsync(localPath,function(F,B){if(F)return S(F);B=B.filter(V=>R(E(V))),B.length||S(void 0,!1),setImmediate(B.reverse().reduce(function(V,$){return function(ne,Z){if(ne||Z===!1)return setImmediate(V,ne,!1);A.addLocalFileAsync({localPath:$,zipPath:Ee.dirname(E($)),zipName:k($)},V)}},S))})})},addLocalFolderPromise:function(y,S){return new Promise((A,T)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},S),(R,P)=>{R&&T(R),P&&A(this)})})},addFile:function(y,S,A,T){y=x(y);let R=p(y),P=R!=null;P||(R=new om(i),R.entryName=y),R.comment=A||"";let E=typeof T=="object"&&T instanceof o.fs.Stats;E&&(R.header.time=T.mtime);var k=R.isDirectory?16:0;let O=R.isDirectory?16384:32768;return E?O|=4095&T.mode:typeof T=="number"?O|=4095&T:O|=R.isDirectory?493:420,k=(k|O<<16)>>>0,R.attr=k,R.setData(S),P||c.setEntry(R),R},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return p(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,S,A,T,R,P){T=Dn(!1,T),R=Dn(!1,R),A=Dn(!0,A),P=iu(R,P);var E=p(y);if(!E)throw be.Errors.NO_ENTRY();var k=l(E.entryName),O=u(S,P&&!E.isDirectory?P:A?k:Ee.basename(k));if(E.isDirectory){var F=c.getEntryChildren(E);return F.forEach(function($){if($.isDirectory)return;var ne=$.getData();if(!ne)throw be.Errors.CANT_EXTRACT_FILE();var Z=l($.entryName),se=u(S,A?Z:Ee.basename(Z));let ae=R?$.header.fileAttr:void 0;o.writeFileTo(se,ne,T,ae)}),!0}var B=E.getData(c.password);if(!B)throw be.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(O)&&!T)throw be.Errors.CANT_OVERRIDE();let V=R?y.header.fileAttr:void 0;return o.writeFileTo(O,B,T,V),!0},test:function(y){if(!c)return!1;for(var S in c.entries)try{if(S.isDirectory)continue;var A=c.entries[S].getData(y);if(!A)return!1}catch{return!1}return!0},extractAllTo:function(y,S,A,T){if(A=Dn(!1,A),T=iu(A,T),S=Dn(!1,S),!c)throw be.Errors.NO_ZIP();c.entries.forEach(function(R){var P=u(y,l(R.entryName));if(R.isDirectory){o.makeDir(P);return}var E=R.getData(T);if(!E)throw be.Errors.CANT_EXTRACT_FILE();let k=A?R.header.fileAttr:void 0;o.writeFileTo(P,E,S,k);try{o.fs.utimesSync(P,R.header.time,R.header.time)}catch{throw be.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,S,A,T){if(T=cm(S,A,T),A=Dn(!1,A),S=Dn(!1,S),!T)return new Promise((O,F)=>{this.extractAllToAsync(y,S,A,function(B){B?F(B):O(this)})});if(!c){T(be.Errors.NO_ZIP());return}y=Ee.resolve(y);let R=O=>u(y,Ee.normalize(l(O.entryName))),P=(O,F)=>new Error(O+': "'+F+'"'),E=[],k=[];c.entries.forEach(O=>{O.isDirectory?E.push(O):k.push(O)});for(let O of E){let F=R(O),B=A?O.header.fileAttr:void 0;try{o.makeDir(F),B&&o.fs.chmodSync(F,B),o.fs.utimesSync(F,O.header.time,O.header.time)}catch{T(P("Unable to create folder",F))}}k.reverse().reduce(function(O,F){return function(B){if(B)O(B);else{let V=Ee.normalize(l(F.entryName)),$=u(y,V);F.getDataAsync(function(ne,Z){if(Z)O(Z);else if(!ne)O(be.Errors.CANT_EXTRACT_FILE());else{let se=A?F.header.fileAttr:void 0;o.writeFileToAsync($,ne,S,se,function(ae){ae||O(P("Unable to write file",$)),o.fs.utimes($,F.header.time,F.header.time,function(L){L?O(P("Unable to set times",$)):O()})})}})}}},T)()},writeZip:function(y,S){if(arguments.length===1&&typeof y=="function"&&(S=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var A=c.compressToBuffer();if(A){var T=o.writeFileTo(y,A,!0);typeof S=="function"&&S(T?null:new Error("failed"),"")}}},writeZipPromise:function(y,S){let{overwrite:A,perm:T}=Object.assign({overwrite:!0},S);return new Promise((R,P)=>{!y&&i.filename&&(y=i.filename),y||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(E=>{let k=O=>O?R(O):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,E,A,T,k)},P)})},toBufferPromise:function(){return new Promise((y,S)=>{c.toAsyncBuffer(y,S)})},toBuffer:function(y,S,A,T){return typeof y=="function"?(c.toAsyncBuffer(y,S,A,T),null):c.compressToBuffer()}}}});import{execFile as p_,spawn as g_,spawnSync as rA}from"node:child_process";import{promisify as m_}from"node:util";function __(t){if(process.platform!=="win32")return!1;if(Af.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Af,"").toLowerCase();return w_.has(r)}function Tf(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return __(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function nt(t,e=[],r={}){return g_(t,e,Tf(t,r))}function Cf(t,e=[],r={}){return y_(t,e,Tf(t,r))}var w_,Af,y_,Wt=Ye(()=>{"use strict";w_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Af=/\.(cmd|bat|ps1)$/i;y_=m_(p_)});var $t=ce((LR,rx)=>{"use strict";var tx=["nodebuffer","arraybuffer","fragments"],nx=typeof Blob<"u";nx&&tx.push("blob");rx.exports={BINARY_TYPES:tx,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:nx,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var ji=ce((NR,Io)=>{"use strict";var{EMPTY_BUFFER:Y1}=$t(),ad=Buffer[Symbol.species];function X1(t,e){if(t.length===0)return Y1;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 ad(r.buffer,r.byteOffset,i):r}function ix(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function sx(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Q1(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function cd(t){if(cd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new ad(t):ArrayBuffer.isView(t)?e=new ad(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),cd.readOnly=!1),e}Io.exports={concat:X1,mask:ix,toArrayBuffer:Q1,toBuffer:cd,unmask:sx};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=fe("bufferutil");Io.exports.mask=function(e,r,i,o,c){c<48?ix(e,r,i,o,c):t.mask(e,r,i,o,c)},Io.exports.unmask=function(e,r){e.length<32?sx(e,r):t.unmask(e,r)}}catch{}});var cx=ce((MR,ax)=>{"use strict";var ox=Symbol("kDone"),dd=Symbol("kRun"),ld=class{constructor(e){this[ox]=()=>{this.pending--,this[dd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[dd]()}[dd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ox])}}};ax.exports=ld});var Br=ce((BR,fx)=>{"use strict";var Wi=fe("zlib"),dx=ji(),eE=cx(),{kStatusCode:lx}=$t(),tE=Buffer[Symbol.species],nE=Buffer.from([0,0,255,255]),To=Symbol("permessage-deflate"),Vt=Symbol("total-length"),Nr=Symbol("callback"),An=Symbol("buffers"),Mr=Symbol("error"),Ao,ud=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Ao){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Ao=new eE(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[Nr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Ao.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Ao.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Wi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Wi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[To]=this,this._inflate[Vt]=0,this._inflate[An]=[],this._inflate.on("error",iE),this._inflate.on("data",ux)}this._inflate[Nr]=i,this._inflate.write(e),r&&this._inflate.write(nE),this._inflate.flush(()=>{let c=this._inflate[Mr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=dx.concat(this._inflate[An],this._inflate[Vt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Vt]=0,this._inflate[An]=[],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"?Wi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Wi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Vt]=0,this._deflate[An]=[],this._deflate.on("data",rE)}this._deflate[Nr]=i,this._deflate.write(e),this._deflate.flush(Wi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=dx.concat(this._deflate[An],this._deflate[Vt]);r&&(c=new tE(c.buffer,c.byteOffset,c.length-4)),this._deflate[Nr]=null,this._deflate[Vt]=0,this._deflate[An]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};fx.exports=ud;function rE(t){this[An].push(t),this[Vt]+=t.length}function ux(t){if(this[Vt]+=t.length,this[To]._maxPayload<1||this[Vt]<=this[To]._maxPayload){this[An].push(t);return}this[Mr]=new RangeError("Max payload size exceeded"),this[Mr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Mr][lx]=1009,this.removeListener("data",ux),this.reset()}function iE(t){if(this[To]._inflate=null,this[Mr]){this[Nr](this[Mr]);return}t[lx]=1007,this[Nr](t)}});var Fr=ce((FR,Co)=>{"use strict";var{isUtf8:xx}=fe("buffer"),{hasBlob:sE}=$t(),oE=[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 aE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function fd(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 cE(t){return sE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Co.exports={isBlob:cE,isValidStatusCode:aE,isValidUTF8:fd,tokenChars:oE};if(xx)Co.exports.isValidUTF8=function(t){return t.length<24?fd(t):xx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=fe("utf-8-validate");Co.exports.isValidUTF8=function(e){return e.length<32?fd(e):t(e)}}catch{}});var md=ce((zR,Ex)=>{"use strict";var{Writable:dE}=fe("stream"),hx=Br(),{BINARY_TYPES:lE,EMPTY_BUFFER:px,kStatusCode:uE,kWebSocket:fE}=$t(),{concat:xd,toArrayBuffer:xE,unmask:hE}=ji(),{isValidStatusCode:pE,isValidUTF8:gx}=Fr(),Ro=Buffer[Symbol.species],lt=0,mx=1,_x=2,yx=3,hd=4,pd=5,ko=6,gd=class extends dE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||lE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[fE]=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=lt}_write(e,r,i){if(this._opcode===8&&this._state==lt)return i();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){i(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}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 Ro(i.buffer,i.byteOffset+e,i.length-e),new Ro(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 Ro(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 lt:this.getInfo(e);break;case mx:this.getPayloadLength16(e);break;case _x:this.getPayloadLength64(e);break;case yx:this.getMask();break;case hd:this.getData(e);break;case pd:case ko: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[hx.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=mx:this._payloadLength===127?this._state=_x: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=yx:this._state=hd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=hd}getData(e){let r=px;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&&hE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=pd,this.decompress(r,e);return}if(r.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let i=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(i);return}this._messageLength=this._totalPayloadLength,this._fragments.push(r)}this.dataMessage(e)}decompress(e,r){this._extensions[hx.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}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let l=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===lt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=lt;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=xd(i,r):this._binaryType==="arraybuffer"?o=xE(xd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=lt):(this._state=ko,setImmediate(()=>{this.emit("message",o,!0),this._state=lt,this.startLoop(e)}))}else{let o=xd(i,r);if(!this._skipUTF8Validation&&!gx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===pd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=lt):(this._state=ko,setImmediate(()=>{this.emit("message",o,!1),this._state=lt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,px),this.end();else{let i=e.readUInt16BE(0);if(!pE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Ro(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!gx(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=lt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=lt):(this._state=ko,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=lt,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[uE]=o,l}};Ex.exports=gd});var yd=ce((qR,Sx)=>{"use strict";var{Duplex:UR}=fe("stream"),{randomFillSync:gE}=fe("crypto"),{types:{isUint8Array:mE}}=fe("util"),bx=Br(),{EMPTY_BUFFER:wE,kWebSocket:_E,NOOP:yE}=$t(),{isBlob:zr,isValidStatusCode:EE}=Fr(),{mask:vx,toBuffer:Kn}=ji(),ut=Symbol("kByteLength"),bE=Buffer.alloc(4),Do=8*1024,$n,Ur=Do,bt=0,vE=1,SE=2,wd=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=bt,this.onerror=yE,this[_E]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||bE,r.generateMask?r.generateMask(i):(Ur===Do&&($n===void 0&&($n=Buffer.alloc(Do)),gE($n,0,Do),Ur=0),i[0]=$n[Ur++],i[1]=$n[Ur++],i[2]=$n[Ur++],i[3]=$n[Ur++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[ut]!==void 0?u=r[ut]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=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]=x,x===126?p.writeUInt16BE(u,2):x===127&&(p[2]=p[3]=0,p.writeUIntBE(u,4,6)),r.mask?(p[1]|=128,p[c-4]=i[0],p[c-3]=i[1],p[c-2]=i[2],p[c-1]=i[3],l?[p,e]:o?(vx(e,i,p,c,u),[p]):(vx(e,i,e,0,u),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=wE;else{if(typeof e!="number"||!EE(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");if(c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string")c.write(r,2);else if(mE(r))c.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let l={[ut]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==bt?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):zr(e)?(o=e.size,c=!1):(e=Kn(e),o=e.length,c=Kn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ut]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};zr(e)?this._state!==bt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==bt?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):zr(e)?(o=e.size,c=!1):(e=Kn(e),o=e.length,c=Kn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ut]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};zr(e)?this._state!==bt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==bt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[bx.extensionName],c=r.binary?2:1,l=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):zr(e)?(u=e.size,x=!1):(e=Kn(e),u=e.length,x=Kn.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={[ut]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};zr(e)?this._state!==bt?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==bt?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ut],this._state=SE,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(_d,this,u,o);return}this._bufferedBytes-=i[ut];let l=Kn(c);r?this.dispatch(l,r,i,o):(this._state=bt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(IE,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[bx.extensionName];this._bufferedBytes+=i[ut],this._state=vE,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");_d(this,x,o);return}this._bufferedBytes-=i[ut],this._state=bt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===bt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ut],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ut],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)}};Sx.exports=wd;function _d(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 IE(t,e,r){_d(t,e,r),t.onerror(e)}});var Ox=ce((GR,Px)=>{"use strict";var{kForOnEventAttribute:Ki,kListener:Ed}=$t(),Ix=Symbol("kCode"),Ax=Symbol("kData"),Tx=Symbol("kError"),Cx=Symbol("kMessage"),Rx=Symbol("kReason"),qr=Symbol("kTarget"),kx=Symbol("kType"),Dx=Symbol("kWasClean"),Jt=class{constructor(e){this[qr]=null,this[kx]=e}get target(){return this[qr]}get type(){return this[kx]}};Object.defineProperty(Jt.prototype,"target",{enumerable:!0});Object.defineProperty(Jt.prototype,"type",{enumerable:!0});var Vn=class extends Jt{constructor(e,r={}){super(e),this[Ix]=r.code===void 0?0:r.code,this[Rx]=r.reason===void 0?"":r.reason,this[Dx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Ix]}get reason(){return this[Rx]}get wasClean(){return this[Dx]}};Object.defineProperty(Vn.prototype,"code",{enumerable:!0});Object.defineProperty(Vn.prototype,"reason",{enumerable:!0});Object.defineProperty(Vn.prototype,"wasClean",{enumerable:!0});var Gr=class extends Jt{constructor(e,r={}){super(e),this[Tx]=r.error===void 0?null:r.error,this[Cx]=r.message===void 0?"":r.message}get error(){return this[Tx]}get message(){return this[Cx]}};Object.defineProperty(Gr.prototype,"error",{enumerable:!0});Object.defineProperty(Gr.prototype,"message",{enumerable:!0});var $i=class extends Jt{constructor(e,r={}){super(e),this[Ax]=r.data===void 0?null:r.data}get data(){return this[Ax]}};Object.defineProperty($i.prototype,"data",{enumerable:!0});var AE={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Ki]&&o[Ed]===e&&!o[Ki])return;let i;if(t==="message")i=function(c,l){let u=new $i("message",{data:l?c:c.toString()});u[qr]=this,Po(e,this,u)};else if(t==="close")i=function(c,l){let u=new Vn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[qr]=this,Po(e,this,u)};else if(t==="error")i=function(c){let l=new Gr("error",{error:c,message:c.message});l[qr]=this,Po(e,this,l)};else if(t==="open")i=function(){let c=new Jt("open");c[qr]=this,Po(e,this,c)};else return;i[Ki]=!!r[Ki],i[Ed]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Ed]===e&&!r[Ki]){this.removeListener(t,r);break}}};Px.exports={CloseEvent:Vn,ErrorEvent:Gr,Event:Jt,EventTarget:AE,MessageEvent:$i};function Po(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Oo=ce((HR,Lx)=>{"use strict";var{tokenChars:Vi}=Fr();function Lt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function TE(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,x=-1,p=-1,w=-1,_=0;for(;_<t.length;_++)if(p=t.charCodeAt(_),l===void 0)if(w===-1&&Vi[p]===1)x===-1&&(x=_);else if(_!==0&&(p===32||p===9))w===-1&&x!==-1&&(w=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);w===-1&&(w=_);let y=t.slice(x,w);p===44?(Lt(e,y,r),r=Object.create(null)):l=y,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(u===void 0)if(w===-1&&Vi[p]===1)x===-1&&(x=_);else if(p===32||p===9)w===-1&&x!==-1&&(w=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);w===-1&&(w=_),Lt(r,t.slice(x,w),!0),p===44&&(Lt(e,l,r),r=Object.create(null),l=void 0),x=w=-1}else if(p===61&&x!==-1&&w===-1)u=t.slice(x,_),x=w=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(o){if(Vi[p]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);x===-1?x=_:i||(i=!0),o=!1}else if(c)if(Vi[p]===1)x===-1&&(x=_);else if(p===34&&x!==-1)c=!1,w=_;else if(p===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(p===34&&t.charCodeAt(_-1)===61)c=!0;else if(w===-1&&Vi[p]===1)x===-1&&(x=_);else if(x!==-1&&(p===32||p===9))w===-1&&(w=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);w===-1&&(w=_);let y=t.slice(x,w);i&&(y=y.replace(/\\/g,""),i=!1),Lt(r,u,y),p===44&&(Lt(e,l,r),r=Object.create(null),l=void 0),u=void 0,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=_);let I=t.slice(x,w);return l===void 0?Lt(e,I,r):(u===void 0?Lt(r,I,!0):i?Lt(r,u,I.replace(/\\/g,"")):Lt(r,u,I),Lt(e,l,r)),e}function CE(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(", ")}Lx.exports={format:CE,parse:TE}});var Bo=ce((KR,Kx)=>{"use strict";var RE=fe("events"),kE=fe("https"),DE=fe("http"),Bx=fe("net"),PE=fe("tls"),{randomBytes:OE,createHash:LE}=fe("crypto"),{Duplex:jR,Readable:WR}=fe("stream"),{URL:bd}=fe("url"),Tn=Br(),NE=md(),ME=yd(),{isBlob:BE}=Fr(),{BINARY_TYPES:Nx,CLOSE_TIMEOUT:FE,EMPTY_BUFFER:Lo,GUID:zE,kForOnEventAttribute:vd,kListener:UE,kStatusCode:qE,kWebSocket:Ge,NOOP:Fx}=$t(),{EventTarget:{addEventListener:GE,removeEventListener:HE}}=Ox(),{format:jE,parse:WE}=Oo(),{toBuffer:KE}=ji(),zx=Symbol("kAborted"),Sd=[8,13],Zt=["CONNECTING","OPEN","CLOSING","CLOSED"],$E=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,we=class t extends RE{constructor(e,r,i){super(),this._binaryType=Nx[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?(i=r,r=[]):r=[r]),Ux(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Nx.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 NE({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new ME(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ge]=this,c[Ge]=this,e[Ge]=this,o.on("conclude",ZE),o.on("drain",YE),o.on("error",XE),o.on("message",QE),o.on("ping",eb),o.on("pong",tb),c.onerror=nb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Hx),e.on("data",Mo),e.on("end",jx),e.on("error",Wx),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[Tn.extensionName]&&this._extensions[Tn.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){ot(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())}),Gx(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){Id(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Lo,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){Id(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Lo,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){Id(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Tn.extensionName]||(o.compress=!1),this._sender.send(e||Lo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ot(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(we,"CONNECTING",{enumerable:!0,value:Zt.indexOf("CONNECTING")});Object.defineProperty(we.prototype,"CONNECTING",{enumerable:!0,value:Zt.indexOf("CONNECTING")});Object.defineProperty(we,"OPEN",{enumerable:!0,value:Zt.indexOf("OPEN")});Object.defineProperty(we.prototype,"OPEN",{enumerable:!0,value:Zt.indexOf("OPEN")});Object.defineProperty(we,"CLOSING",{enumerable:!0,value:Zt.indexOf("CLOSING")});Object.defineProperty(we.prototype,"CLOSING",{enumerable:!0,value:Zt.indexOf("CLOSING")});Object.defineProperty(we,"CLOSED",{enumerable:!0,value:Zt.indexOf("CLOSED")});Object.defineProperty(we.prototype,"CLOSED",{enumerable:!0,value:Zt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(we.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(we.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[vd])return e[UE];return null},set(e){for(let r of this.listeners(t))if(r[vd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[vd]:!0})}})});we.prototype.addEventListener=GE;we.prototype.removeEventListener=HE;Kx.exports=we;function Ux(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:FE,protocolVersion:Sd[1],maxBufferedChunks:1048576,maxFragments:131072,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,!Sd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Sd.join(", ")})`);let c;if(e instanceof bd)c=e;else try{c=new bd(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:",x;if(c.protocol!=="ws:"&&!l&&!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 A=new SyntaxError(x);if(t._redirects===0)throw A;No(t,A);return}let p=l?443:80,w=OE(16).toString("base64"),_=l?kE.request:DE.request,I=new Set,y;if(o.createConnection=o.createConnection||(l?JE:VE),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&&(y=new Tn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=jE({[Tn.extensionName]:y.offer()})),r.length){for(let A of r){if(typeof A!="string"||!$E.test(A)||I.has(A))throw new SyntaxError("An invalid or duplicated subprotocol was specified");I.add(A)}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 A=o.path.split(":");o.socketPath=A[0],o.path=A[1]}let S;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let A=i&&i.headers;if(i={...i,headers:{}},A)for(let[T,R]of Object.entries(A))i.headers[T.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let A=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!A||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,A||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),S=t._req=_(o),t._redirects&&t.emit("redirect",t.url,S)}else S=t._req=_(o);o.timeout&&S.on("timeout",()=>{ot(t,S,"Opening handshake has timed out")}),S.on("error",A=>{S===null||S[zx]||(S=t._req=null,No(t,A))}),S.on("response",A=>{let T=A.headers.location,R=A.statusCode;if(T&&o.followRedirects&&R>=300&&R<400){if(++t._redirects>o.maxRedirects){ot(t,S,"Maximum redirects exceeded");return}S.abort();let P;try{P=new bd(T,e)}catch{let k=new SyntaxError(`Invalid URL: ${T}`);No(t,k);return}Ux(t,P,r,i)}else t.emit("unexpected-response",S,A)||ot(t,S,`Unexpected server response: ${A.statusCode}`)}),S.on("upgrade",(A,T,R)=>{if(t.emit("upgrade",A),t.readyState!==we.CONNECTING)return;S=t._req=null;let P=A.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){ot(t,T,"Invalid Upgrade header");return}let E=LE("sha1").update(w+zE).digest("base64");if(A.headers["sec-websocket-accept"]!==E){ot(t,T,"Invalid Sec-WebSocket-Accept header");return}let k=A.headers["sec-websocket-protocol"],O;if(k!==void 0?I.size?I.has(k)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":I.size&&(O="Server sent no subprotocol"),O){ot(t,T,O);return}k&&(t._protocol=k);let F=A.headers["sec-websocket-extensions"];if(F!==void 0){if(!y){ot(t,T,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=WE(F)}catch{ot(t,T,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(B);if(V.length!==1||V[0]!==Tn.extensionName){ot(t,T,"Server indicated an extension that was not requested");return}try{y.accept(B[Tn.extensionName])}catch{ot(t,T,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Tn.extensionName]=y}t.setSocket(T,R,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,t):S.end()}function No(t,e){t._readyState=we.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function VE(t){return t.path=t.socketPath,Bx.connect(t)}function JE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Bx.isIP(t.host)?"":t.host),PE.connect(t)}function ot(t,e,r){t._readyState=we.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ot),e.setHeader?(e[zx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(No,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Id(t,e,r){if(e){let i=BE(e)?e.size:KE(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Zt[t.readyState]})`);process.nextTick(r,i)}}function ZE(t,e){let r=this[Ge];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Ge]!==void 0&&(r._socket.removeListener("data",Mo),process.nextTick(qx,r._socket),t===1005?r.close():r.close(t,e))}function YE(){let t=this[Ge];t.isPaused||t._socket.resume()}function XE(t){let e=this[Ge];e._socket[Ge]!==void 0&&(e._socket.removeListener("data",Mo),process.nextTick(qx,e._socket),e.close(t[qE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Mx(){this[Ge].emitClose()}function QE(t,e){this[Ge].emit("message",t,e)}function eb(t){let e=this[Ge];e._autoPong&&e.pong(t,!this._isServer,Fx),e.emit("ping",t)}function tb(t){this[Ge].emit("pong",t)}function qx(t){t.resume()}function nb(t){let e=this[Ge];e.readyState!==we.CLOSED&&(e.readyState===we.OPEN&&(e._readyState=we.CLOSING,Gx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Gx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Hx(){let t=this[Ge];if(this.removeListener("close",Hx),this.removeListener("data",Mo),this.removeListener("end",jx),t._readyState=we.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[Ge]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Mx),t._receiver.on("finish",Mx))}function Mo(t){this[Ge]._receiver.write(t)||this.pause()}function jx(){let t=this[Ge];t._readyState=we.CLOSING,t._receiver.end(),this.end()}function Wx(){let t=this[Ge];this.removeListener("error",Wx),this.on("error",Fx),t&&(t._readyState=we.CLOSING,this.destroy())}});var Zx=ce((VR,Jx)=>{"use strict";var $R=Bo(),{Duplex:rb}=fe("stream");function $x(t){t.emit("close")}function ib(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Vx(t){this.removeListener("error",Vx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function sb(t,e){let r=!0,i=new rb({...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($x,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick($x,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",ib),i.on("error",Vx),i}Jx.exports=sb});var Ad=ce((JR,Yx)=>{"use strict";var{tokenChars:ob}=Fr();function ab(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&&ob[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}Yx.exports={parse:ab}});var ih=ce((YR,rh)=>{"use strict";var cb=fe("events"),Fo=fe("http"),{Duplex:ZR}=fe("stream"),{createHash:db}=fe("crypto"),Xx=Oo(),Jn=Br(),lb=Ad(),ub=Bo(),{CLOSE_TIMEOUT:fb,GUID:xb,kWebSocket:hb}=$t(),pb=/^[+/0-9A-Za-z]{22}==$/,Qx=0,eh=1,nh=2,Td=class extends cb{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:fb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ub,...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=Fo.createServer((i,o)=>{let c=Fo.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=gb(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=Qx}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===nh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ji,this);return}if(e&&this.once("close",e),this._state!==eh)if(this._state=eh,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(Ji,this):process.nextTick(Ji,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ji(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",th);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Zn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Zn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!pb.test(c)){Zn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Zn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Zi(r,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=lb.parse(x)}catch{Zn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&w!==void 0){let I=new Jn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=Xx.parse(w);y[Jn.extensionName]&&(I.accept(y[Jn.extensionName]),_[Jn.extensionName]=I)}catch{Zn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let I={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(I,(y,S,A,T)=>{if(!y)return Zi(r,S||401,A,T);this.completeUpgrade(_,c,p,e,r,i,o)});return}if(!this.options.verifyClient(I))return Zi(r,401)}this.completeUpgrade(_,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[hb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Qx)return Zi(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${db("sha1").update(r+xb).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(i.size){let _=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;_&&(p.push(`Sec-WebSocket-Protocol: ${_}`),w._protocol=_)}if(e[Jn.extensionName]){let _=e[Jn.extensionName].params,I=Xx.format({[Jn.extensionName]:[_]});p.push(`Sec-WebSocket-Extensions: ${I}`),w._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
15
15
  `).join(`\r
16
- `)),c.removeListener("error",sh),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(Xi,this)})),u(w,o)}};ah.exports=Id;function xv(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 Xi(t){t._state=oh,t.emit("close")}function sh(){this.destroy()}function Yi(t,e,r,i){r=r||Ho.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} ${Ho.STATUS_CODES[e]}\r
16
+ `)),c.removeListener("error",th),w.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,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(Ji,this)})),u(w,o)}};rh.exports=Td;function gb(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 Ji(t){t._state=nh,t.emit("close")}function th(){this.destroy()}function Zi(t,e,r,i){r=r||Fo.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} ${Fo.STATUS_CODES[e]}\r
17
17
  `+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
18
18
  `)+`\r
19
19
  \r
20
- `+r)}function Yn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Yn),t.emit("wsClientError",l,r,e)}else Yi(r,i,o,c)}});import{existsSync as zv,openSync as Fv}from"node:fs";import{mkdir as Uv}from"node:fs/promises";import{dirname as Gv}from"node:path";import{fileURLToPath as qv}from"node:url";function Hv(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Rd(t=Y()){return zv(t.libEntry)?t.libEntry:qv(new URL("../index.ts",import.meta.url))}async function Eh(t={}){let e=t.paths??Y(),r=t.entryOverride??Rd(e),i=Hv(e,process.env.COZE_BRIDGE_LOG_MODE);await Uv(Gv(i),{recursive:!0});let o=Fv(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=lt(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[ts]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return jv.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var jv,ts,Jo=Ye(()=>{"use strict";An();te();Oe();jv=q("spawn-daemon"),ts="COZE_BRIDGE_DAEMON"});import{spawn as B1}from"node:child_process";import{mkdir as z1,unlink as F1,writeFile as U1}from"node:fs/promises";import{dirname as G1,join as q1}from"node:path";function Vr(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function j1(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Vr(r)}</key>
21
- <string>${Vr(i)}</string>`).join(`
20
+ `+r)}function Zn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Zn),t.emit("wsClientError",l,r,e)}else Zi(r,i,o,c)}});var mh=ce(Te=>{"use strict";var M=U;function U(t,e){t=t-260;let r=Wo(),i=r[t];if(U.kgmvAg===void 0){var o=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",_="";for(let I=0,y,S,A=0;S=x.charAt(A++);~S&&(y=I%4?y*64+S:S,I++%4)?w+=String.fromCharCode(255&y>>(-2*I&6)):0)S=p.indexOf(S);for(let I=0,y=w.length;I<y;I++)_+="%"+("00"+w.charCodeAt(I).toString(16)).slice(-2);return decodeURIComponent(_)};U.PXmQyz=o,U.fAUtys={},U.kgmvAg=!0}let c=r[0],l=t+c,u=U.fAUtys[l];return u?i=u:(i=U.PXmQyz(i),U.fAUtys[l]=i),i}(function(t,e){let r=U,i=t();for(;;)try{if(parseInt(r(1637))/1+-parseInt(r(994))/2+-parseInt(r(1699))/3*(parseInt(r(688))/4)+parseInt(r(1620))/5*(parseInt(r(1167))/6)+-parseInt(r(520))/7*(parseInt(r(1807))/8)+parseInt(r(826))/9*(parseInt(r(1072))/10)+parseInt(r(1475))/11*(parseInt(r(695))/12)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Wo,747792);var Sb=Object[M(640)+"operty"],Ib=Object[M(742)+"opertyNames"],fh=(t,e)=>function(){return t&&(e=(0,t[{ZidkW:function(c,l){return c(l)}}[M(530)](Ib,t)[0]])(t=0)),e},Ab=(t,e)=>{let r=M,i={ziwLo:function(c,l,u,x){return c(l,u,x)}};for(var o in e)i[r(1581)](Sb,t,o,{get:e[o],enumerable:!0})};function Tb(){return ah||(ah=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Cb(){let t=M;return ch||(ch=[IDBCursor.prototype[t(734)],IDBCursor.prototype[t(1764)],IDBCursor[t(1587)+"e"][t(1764)+t(739)+"ey"]])}function Rb(t){let e=M,r={tvyPE:e(379),LPPlO:e(1786),GImsy:function(o,c){return o(c)},taerK:function(o,c){return o+c},BMsVk:function(o,c){return o===c},vdAfc:"pQNiu",XvxUC:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,u={eZpWN:r[l(1319)],IclYK:function(_){return _()}},x=()=>{let _=l;t["removeEv"+_(518)+"ner"](u.eZpWN,p),t[_(1785)+_(518)+_(663)]("error",w)},p=()=>{o(Mt(t[l(1367)])),x()},w=()=>{let _=l;c(t[_(1786)]),u[_(514)](x)};t[l(469)+l(286)](l(379),p),t[l(469)+l(286)](r[l(1449)],w)});return i[e(313)](o=>{let c=e;if(r[c(879)](r[c(581)],c(1307))){let u=""+_0x586a24[c(795)](),x=_0x21e144||(_0x1d15f2=r[c(1619)](_0x534f10,_0x3dc3e6)),p=_0x25f6ca[c(1546)]()[c(589)](16).slice(-6);return r[c(506)](r[c(506)](r.taerK("02",u),x),p)}else r[c(747)](o,IDBCursor)&&Rd[c(1462)](o,t)})[e(1765)](()=>{}),Ho[e(1462)](i,t),i}function kb(t){let e=M,r={NbtAV:function(o,c){return o===c},yOhhw:e(1803),kKaKZ:e(1020),ywlLX:"error",GPJqC:"abort"};if(Go[e(1614)](t))return;let i=new Promise((o,c)=>{let l=e,u={RNaDT:function(_,I){return r[U(883)](_,I)},YIKAA:r.yOhhw,GXmmg:l(1786),oMrkp:"abort",lWoZN:function(_){return _()},TRYnE:l(347)+"or"},x=()=>{let _=l;u.RNaDT(u[_(1348)],_(1803))?(t[_(1785)+"entListe"+_(663)](_(1020),p),t[_(1785)+_(518)+_(663)](u[_(487)],w),t[_(1785)+_(518)+_(663)](u[_(1801)],w)):(this[_(736)+"igatorOn"+_(1187)]=_0x3af49a,_0x17b096?this[_(1480)+"nLine"]():this[_(1480)+_(919)]())},p=()=>{let _=l;u.lWoZN(o),u[_(1397)](x)},w=()=>{let _=l;c(t.error||new DOMException(u.TRYnE,u[_(584)])),x()};t[l(469)+"Listener"](r[l(454)],p),t[l(469)+l(286)](r[l(1200)],w),t[l(469)+l(286)](r[l(1400)],w)});Go.set(t,i)}function Db(t){jo={Altwz:function(i,o){return i(o)}}[M(546)](t,jo)}function Pb(t){let e=M,r={mKoIQ:function(i,o){return i(o)},xTkNs:function(i,o){return i(o)},iHLjy:function(i,o){return i(o)},YLSJO:"objectSt"+e(1224),MKIDc:function(i){return i()}};return t===IDBDatabase.prototype["transact"+e(1234)]&&!(r[e(1819)]in IDBTransaction.prototype)?function(i,...o){let c=e,l=t[c(307)](r[c(1703)](Yi,this),i,...o);return Cd[c(1462)](l,i[c(1326)]?i.sort():[i]),r[c(1703)](Mt,l)}:r[e(269)](Cb).includes(t)?function(...i){let o=e;return t[o(1259)](r[o(1340)](Yi,this),i),r[o(1703)](Mt,Rd[o(495)](this))}:function(...i){let o=e;return Mt(t[o(1259)](r[o(1163)](Yi,this),i))}}function Ob(t){let e=M,r={MhXAj:function(i,o){return i===o},NNPuh:"function",dKZZV:function(i,o){return i(o)},frqKd:function(i,o,c){return i(o,c)}};return r[e(1051)](typeof t,r[e(1272)])?r.dKZZV(Pb,t):(t instanceof IDBTransaction&&kb(t),r[e(791)](xh,t,Tb())?new Proxy(t,jo):t)}function Mt(t){let e=M,r={NXfJm:function(o,c){return o instanceof c},cYUnm:function(o,c){return o(c)},awwdE:function(o,c){return o!==c},tbuDI:e(486)};if(r.NXfJm(t,IDBRequest))return Rb(t);if(Uo[e(1614)](t))return Uo[e(495)](t);let i=r[e(732)](Ob,t);if(r.awwdE(i,t))if(e(613)!==r[e(1256)])Uo[e(1462)](t,i),Ho[e(1462)](i,t);else return this[e(393)]?.[e(1462)]({message_id:_0x265bc5,timestamp:_0x4fa8e4});return i}var xh,ah,ch,Rd,Go,Cd,Uo,Ho,jo,Yi,dh=fh({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={ILGEn:function(r,i){return r===i},tyswK:"done",Zrmao:function(r,i){return r===i},PcHjj:t(1173)+t(1224),Yspat:function(r,i){return r instanceof i},IWSOd:function(r,i){return r===i},iWahb:t(1075),lXNLK:function(r,i){return r in i}};xh=(r,i)=>i[t(1839)](o=>r instanceof o),Rd=new WeakMap,Go=new WeakMap,Cd=new WeakMap,Uo=new WeakMap,Ho=new WeakMap,jo={get(r,i,o){let c=t;if(r instanceof IDBTransaction){if(e.ILGEn(i,e[c(1091)]))return Go.get(r);if(e[c(1598)](i,e[c(1552)]))return r[c(1173)+"oreNames"]||Cd.get(r);if(e[c(1112)](i,c(1075)))return o[c(1173)+c(1224)][1]?void 0:o[c(1173)+c(860)](o[c(1173)+"oreNames"][0])}return Mt(r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e[o(877)](r,IDBTransaction)&&(e[o(757)](i,e[o(1091)])||i===e[o(1695)])?!0:e[o(907)](i,r)}},Yi=r=>Ho[t(495)](r)}}),hh={};Ab(hh,{deleteDB:()=>Nb,openDB:()=>Lb,unwrap:()=>Yi,wrap:()=>Mt});function Lb(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=M,u={vTruz:function(w,_,I,y,S){return w(_,I,y,S)},ShbvR:function(w,_){return w(_)},FEcCk:function(w,_){return w(_)},vlUBj:l(1811),xbVbD:l(1361)+l(807),SbdSO:function(w,_){return w(_)},CaUtI:"upgraden"+l(1464)},x=indexedDB[l(477)](t,e),p=u[l(1426)](Mt,x);return i&&x[l(469)+l(286)](u[l(1343)],w=>{let _=l;u[_(344)](i,u.ShbvR(Mt,x.result),w[_(390)+"on"],w[_(802)+"on"],u[_(809)](Mt,x[_(381)+_(1234)]))}),r&&x[l(469)+"Listener"](l(1412),()=>r()),p[l(313)](w=>{let _=l;c&&w[_(469)+_(286)](u[_(1641)],()=>c()),o&&w[_(469)+_(286)](u[_(318)],()=>o())})[l(1765)](()=>{}),p}function Nb(t,{blocked:e}={}){let r=M,i={HiIzu:function(c,l){return c(l)}},o=indexedDB[r(1746)+r(1427)](t);return e&&o[r(469)+r(286)](r(1412),()=>e()),i.HiIzu(Mt,o)[r(313)](()=>{})}function lh(t,e){let r=M,i={tKwOc:function(x,p){return x+p},nJVUW:r(781)+"e",FTxsO:r(272),KaJpU:function(x,p){return x instanceof p},EgTNW:function(x,p){return x in p},IUsqP:"string",aAfFy:"AChpz",RHvud:function(x,p){return x!==p}};if(!(i[r(1611)](t,IDBDatabase)&&!i[r(1417)](e,t)&&typeof e===i[r(645)]))return i[r(792)]!==i[r(792)]?_0x529497[r(1491)+"8"]?{value:_0x5b7329[r(1491)+"8"](_0x5d5901),offset:i[r(1022)](_0x554e66,1)}:{value:255&_0x3932b5[_0x53037b],offset:_0xa9beee+1}:void 0;if(qo[r(495)](e))return qo[r(495)](e);let o=e[r(1299)](/FromIndex$/,""),c=i[r(1317)](e,o),l=gh[r(1037)](o);if(!(o in(c?IDBIndex:IDBObjectStore).prototype)||!(l||ph[r(1037)](o)))return;let u=async function(x,...p){let w=r,_=this.transaction(x,l?i[w(938)]:i.FTxsO),I=_[w(1075)];return c&&(I=I.index(p[w(1252)]())),(await Promise.all([I[o](...p),l&&_[w(1715)]]))[0]};return qo[r(1462)](e,u),u}var ph,gh,qo,Mb=fh({"node_modules/idb/build/index.js"(){let t=M,e={kcADM:t(495),PVjkx:"getKey",zwMMG:"getAll",peKfh:t(590),WhBct:function(o){return o()},fdjBI:function(o){return o()},FdaRb:t(1543),OvUCi:t(1375),DyQUr:function(o,c){return o(c)}},r=(t(1292)+t(779))[t(485)]("|"),i=0;for(;;){switch(r[i++]){case"0":ph=[e.kcADM,e.PVjkx,e.zwMMG,t(1787)+"ys",e[t(1243)]];continue;case"1":qo=new Map;continue;case"2":e[t(1313)](dh);continue;case"3":e.fdjBI(dh);continue;case"4":gh=[e[t(1288)],e[t(1610)],t(1289),t(724)];continue;case"5":e.DyQUr(Db,o=>({...o,get:(c,l,u)=>lh(c,l)||o[t(495)](c,l,u),has:(c,l)=>!!lh(c,l)||o[t(1614)](c,l)}));continue}break}}}),Bb={idb:function(t){let e=M;t[e(1518)]=Promise[e(1380)]()[e(313)](()=>(Mb(),hh))[e(313)](function(r){return r})}},uh={};function Nt(t){let e=M,r=(e(1768)+"4")[e(485)]("|"),i=0;for(;;){switch(r[i++]){case"0":var o=uh[t];continue;case"1":Bb[t](c,c[e(1518)],Nt);continue;case"2":if(o!==void 0)return o[e(1518)];continue;case"3":var c=uh[t]={exports:{}};continue;case"4":return c[e(1518)]}break}}Nt.d=(t,e)=>{let r=U;for(var i in e)Nt.o(e,i)&&!Nt.o(t,i)&&Object[r(640)+"operty"](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Nt.o=(e,r)=>Object.prototype[t(778)+t(1418)][t(307)](e,r)})(),(()=>{let t=M,e={NXncX:function(r,i){return r!=i},TNREe:"undefined",XKQiK:"Module",ZSupc:t(1350)+"le"};Nt.r=r=>{let i=t;e.NXncX(e[i(671)],typeof Symbol)&&Symbol[i(589)+i(1477)]&&Object[i(640)+i(1418)](r,Symbol[i(589)+"Tag"],{value:e[i(1080)]}),Object[i(640)+"operty"](r,e[i(1798)],{value:!0})}})();var De={};(()=>{let t=M,e={HqhCK:function(a,n){return a+n},pNTzN:function(a,n,s){return a(n,s)},twbKD:function(a,n){return a!==n},GmZmf:t(453),ECNVC:function(a,n){return a+n},rdgeD:function(a,n,s){return a(n,s)},bWOWY:function(a,n){return a>>>n},Ayynb:function(a,n){return a<<n},Lhpxo:function(a,n){return a===n},alduN:t(513),QMELo:function(a,n){return a(n)},dItbP:function(a,n){return a+n},DazdF:function(a,n){return a(n)},WBQQr:t(1648),xBktF:t(1177),HPsCR:function(a,n){return a(n)},iGmVh:function(a,n){return a(n)},qfxsz:"00000000"+t(1718)+t(1718)+t(1718),arNWu:"received",jIWVK:function(a){return a()},RmxVy:function(a,n){return a>n},SRNot:function(a,n){return a<n},uSymE:function(a,n){return a!==n},rVenx:t(1226),xraOu:t(996),DIgHd:function(a,n){return a!==n},LZndK:function(a,n){return a-n},zSaID:t(1459),aZFqj:function(a,n){return a-n},Kzcev:function(a,n){return a<n},CqIiE:function(a,n){return a<n},MfwGN:function(a,n){return a!==n},YehPM:function(a,n){return a!==n},xmKyJ:function(a,n,s){return a(n,s)},sQcZz:function(a,n,s){return a(n,s)},gxBbr:function(a,n){return a(n)},BhkPH:function(a,n){return a(n)},BnYxn:function(a,n){return a(n)},YRBOk:function(a,n,s){return a(n,s)},ltfMC:t(933)+t(1458)+t(958)+t(740),VTZmq:function(a,n,s){return a(n,s)},GmUFg:function(a,n){return a+n},UGTVR:function(a,n){return a>n},rKqZJ:function(a,n){return a*n},rjPpJ:function(a,n){return a>n},WlTbG:t(831),XLHmu:function(a,n){return a!==n},bCFHv:t(1492),HFEYt:function(a,n,s){return a(n,s)},bdiWn:function(a,n,s){return a(n,s)},IlUWA:function(a,n){return a!==n},BlzqT:function(a,n,s){return a(n,s)},FZusK:function(a,n){return a(n)},yFEzt:function(a,n){return a(n)},ISeRs:function(a,n){return a!==n},BuIQL:"USjSV",mRCoL:t(1063),PgAlz:function(a){return a()},niXwV:function(a,n,s){return a(n,s)},uiVIh:function(a,n){return a(n)},bwJqw:function(a,n,s){return a(n,s)},hqXkm:function(a,n){return a!==n},agylE:function(a,n){return a===n},LpLzt:t(471),lAzvy:function(a,n,s){return a(n,s)},mRixc:function(a,n,s){return a(n,s)},wcCNf:function(a,n){return a!==n},VTMOG:function(a,n,s){return a(n,s)},pFYEO:function(a,n,s){return a(n,s)},xRDFU:function(a,n){return a!==n},VSRYp:function(a,n,s){return a(n,s)},JAKpO:function(a,n,s){return a(n,s)},RqfCJ:function(a,n){return a(n)},EIlnW:function(a,n){return a|n},hBcKU:function(a,n){return a<<n},ABqVE:function(a,n){return a<<n},maKUa:function(a,n){return a<<n},yLqBN:function(a,n){return a|n},kwNHo:t(1606),yGweM:function(a,n){return a(n)},jNYAs:function(a,n){return a(n)},bYhJm:function(a,n){return a(n)},ZEDNX:function(a,n){return a(n)},ljmph:function(a,n,s){return a(n,s)},tjMyl:t(933)+t(1458)+t(958)+t(1248),QvQiS:function(a,n){return a===n},qWKPg:t(933)+t(1458)+t(958)+t(315),DWDwH:t(933)+t(1458)+t(958)+t(965),kutmg:function(a,n){return a(n)},ahOxE:t(646),bnFLI:function(a,n){return a&n},pCiqs:function(a,n,s){return a(n,s)},BxyXZ:t(422)+t(1709)+"pe: ",yHClv:function(a,n){return a>>n},ZoQHI:function(a,n){return a>=n},HNSTt:t(475)+"t limit",NiSwa:function(a,n){return a+n},VUYex:function(a,n){return a>n},YjPaW:function(a,n){return a*n},BIXfF:function(a,n){return a>n},xbZKY:t(1586)+t(1108),WzQzy:function(a,n){return a&n},oiUdr:function(a,n){return a&n},zWOjt:function(a,n){return a&n},PTwgo:"knElf",FAgPE:function(a,n,s){return a(n,s)},YINJH:function(a,n){return a>>>n},aVvyR:t(1154)+t(467),eSUyu:function(a,n){return a+n},Qlnem:function(a,n){return a&n},EHVMg:function(a,n){return a===n},yoKFz:function(a,n){return a>>n},ARLUN:function(a,n){return a&n},NVPHa:function(a,n){return a&n},SHCRj:function(a,n){return a|n},XYbXD:function(a,n){return a>>n},jWbbT:function(a,n){return a|n},rVUAE:function(a,n){return a|n},xdkXd:function(a,n){return a+n},DJtfD:function(a,n){return a===n},piOmp:function(a,n){return a&n},mAGbB:function(a,n){return a(n)},ScQdv:function(a,n){return a+n},Kgnki:t(1444),vzIUF:function(a,n){return a|n},klGgM:function(a,n){return a<<n},GNyDT:function(a,n){return a&n},VsmTi:function(a,n){return a<n},AfbRl:t(903),iUNeq:function(a,n){return a==n},usdmp:function(a,n){return a&n},eJJWB:function(a,n){return a+n},aSYjR:"XJcef",EFHhC:t(1066),JGNiW:function(a,n){return a+n},zuwZq:function(a,n){return a<<n},ttOMv:function(a,n){return a<<n},KrUMF:function(a,n){return a>=n},kSkOg:function(a,n){return a<=n},JVcxu:function(a,n){return a&n},iPMIH:function(a,n){return a+n},pclbd:function(a,n){return a+n},IJHUn:function(a,n){return a+n},vcaWk:function(a,n){return a+n},yuMPo:function(a,n){return a!==n},rXBbM:function(a,n){return a&n},wdewy:function(a,n){return a<<n},wsGly:function(a,n){return a&n},VtMbp:function(a,n){return a<<n},CSeXx:function(a,n){return a&n},utYDx:function(a,n){return a<n},Ifvov:function(a,n){return a+n},RyPKq:t(763),duUKJ:function(a,n){return a<=n},cqbRZ:function(a,n){return a-n},FSuYs:function(a,n){return a<n},JfsgA:function(a,n){return a<n},wbxnD:function(a,n,s){return a(n,s)},cqPZw:function(a,n,s){return a(n,s)},ngTIG:function(a,n){return a>=n},sxEia:function(a,n){return a<=n},iVQHe:function(a,n){return a<<n},rdBrH:function(a,n){return a|n},UjQqV:function(a,n){return a&n},iqsqy:function(a,n){return a>>n},FvoHI:function(a,n){return a<n},TvfeO:function(a,n){return a&n},VFKaD:function(a,n){return a>>n},NQHHB:function(a,n){return a|n},YKdHh:function(a,n,s){return a(n,s)},IfZpk:"gvCYQ",atNdM:function(a,n,s){return a(n,s)},zqhHX:function(a,n){return a<<n},GtFPV:function(a,n){return a&n},FAgqv:t(1436),ZSmsG:function(a,n){return a|n},ZwOLd:function(a,n,s){return a(n,s)},dbmMd:function(a,n){return a||n},PfLwo:t(856)+t(798)+t(716)+t(1221)+t(963),XzuLi:function(a,n){return a&n},qOMtN:function(a,n){return a(n)},ruzXs:function(a,n){return a&n},RdgLy:function(a,n){return a(n)},spBtQ:function(a,n){return a===n},RsdeJ:"tdQny",KNuyQ:function(a,n){return a(n)},yTOJt:function(a,n){return a&n},ihxmG:function(a,n){return a&n},WKRCh:function(a,n){return a&n},jKlDo:function(a,n){return a&n},DhISS:function(a,n){return a&n},EbMOt:function(a,n){return a&n},UjSLl:t(1215),TJkcr:function(a,n){return a&n},qdsxt:function(a,n){return a&n},oCCaD:function(a,n){return a|n},kxrrL:function(a,n){return a<<n},uetJf:function(a,n){return a<<n},hijMo:function(a,n){return a|n},jHUuD:function(a,n){return a>>>n},RlULf:function(a,n){return a<<n},MwFHA:function(a,n){return a===n},IZnXu:function(a,n){return a<n},jVfDQ:function(a,n){return a<n},ORLlN:function(a,n){return a<n},Xqzdl:function(a,n){return a&n},FrJeU:function(a,n){return a|n},DQMHt:function(a,n){return a>>>n},GRYqX:function(a,n){return a&n},GgUiY:function(a,n){return a>>>n},Sdprb:function(a,n){return a+n},lSFqw:function(a,n){return a|n},LiJZr:function(a,n){return a&n},UOxnZ:function(a,n){return a|n},Krols:function(a,n){return a&n},urjKQ:function(a,n){return a|n},ohICC:function(a,n){return a&n},XEGDs:function(a,n){return a+n},RiXaE:function(a,n){return a|n},ssQui:function(a,n){return a|n},bkBje:function(a,n){return a>>>n},mZhyq:function(a,n){return a(n)},JPmIz:function(a,n){return a-n},uWVBM:t(1374),vXpFe:function(a,n){return a===n},bZekB:"kiMSI",wpGmo:"jFEay",benIp:function(a,n){return a===n},KFywX:t(1735)+"2|7|3|0|5|10|4",Jkkiw:t(746)+t(1651),eeapY:t(315),zSIju:t(1413)+"name",vCyng:t(1212),roqIX:t(1689),XUGGJ:function(a,n){return a(n)},NhANO:t(1771)+"ile_name",ydwAn:function(a,n){return a===n},BcxbL:t(1682),uhBuU:function(a,n){return a|n},VUkVX:function(a,n){return a<<n},gUwZg:function(a,n){return a<<n},Ycjsx:function(a,n){return a|n},CNFwr:function(a,n){return a<<n},mnaTY:function(a,n){return a|n},HqArt:function(a,n){return a|n},eiWWc:function(a,n){return a<<n},JqJNz:function(a,n){return a|n},zrSXe:function(a,n){return a===n},ifFgS:function(a,n){return a>>>n},TLfFT:function(a,n){return a|n},MttfT:function(a,n){return a<<n},TJQKt:function(a,n){return a<<n},mGAGf:function(a,n){return a>>>n},UZpZS:function(a,n){return a<<n},JEnXU:function(a,n){return a<<n},zuSul:function(a,n){return a>>>n},SBAAo:function(a,n){return a>>>n},XkCzq:function(a,n){return a&n},INtWZ:function(a,n){return a>>>n},bVJMK:function(a,n){return a&n},gkcdS:function(a,n){return a>>>n},ioRbN:function(a,n){return a(n)},qGSne:function(a,n){return a>=n},LKhyk:function(a,n){return a>=n},HnGnM:function(a,n){return a+n},KNoAK:function(a,n){return a%n},MfNRa:function(a,n){return a|n},RxnWN:function(a,n){return a+n},NbjTL:function(a,n){return a>>>n},clbnk:function(a,n){return a*n},dKiRI:function(a,n){return a>>>n},oKyja:function(a,n){return a&n},Mrxpq:function(a,n){return a>>>n},HCpMf:function(a,n){return a>>>n},TvsHg:function(a,n){return a|n},uTCtC:function(a,n){return a|n},gZJaO:function(a,n){return a<<n},AxOZf:function(a,n){return a===n},KndFb:function(a,n){return a>>>n},PfTvl:function(a,n){return a===n},gVRFy:"JnaVQ",oTJLF:function(a,n){return a===n},ibzmn:function(a,n){return a===n},UmAyS:function(a,n){return a===n},ntKHY:function(a,n){return a&n},YfHvv:function(a,n){return a&n},ZGvbq:t(526)+t(349)+"R",loKir:t(1053)+"OR",iBhMJ:"CONNECTI"+t(1018),NNwog:t(503)+t(1448),ZASHC:t(1392)+t(642),OnRJu:function(a,n){return a!==n},UXJUw:t(480),zReMl:"ynegh",LIFJf:function(a,n){return a|n},RfDOt:function(a,n){return a<<n},BnLuN:function(a,n){return a&n},sVLfK:function(a,n){return a>>n},XSLnS:function(a,n){return a+n},JwLvL:t(446),VyUkk:t(904),DifwT:"wxYuW",zuoMJ:t(749),cShbc:t(1209),BIcSZ:function(a,n){return a|n},bwkUL:function(a,n){return a|n},gEttg:function(a,n){return a===n},Sczcw:"vPddU",soSBV:function(a,n){return a===n},pBoae:t(271),AEoxA:t(1312),FjQjn:function(a,n){return a+n},WQyzm:function(a,n){return a+n},kLzoq:function(a,n){return a===n},ZUTgE:function(a,n){return a===n},EhCEs:function(a,n){return a<n},qLOJb:function(a,n){return a!==n},aTcfE:t(643),fbioT:t(1786),zVqPJ:t(1811),XhfBm:t(477),wWyYe:t(560),Iunlr:"aymKe",eafgm:"NJqtc",fXCGX:function(a,n){return a instanceof n},dbDgl:t(1594)+t(1455)+"|0|10|9|1",xrFVB:function(a,n){return a&n},qONAL:function(a,n){return a<n},ykgpW:function(a,n){return a|n},eyMtV:function(a,n){return a|n},WdHpj:t(370),zGiCm:function(a,n){return a(n)},BjZNV:t(713),vdHDd:" > ",wNKpX:t(1623)+"d",cWcRs:function(a,n){return a||n},HhfIZ:function(a,n){return a<=n},CFDxm:t(427)+t(1760)+t(1193)+t(1834)+t(1318),WjdUq:function(a,n){return a(n)},UyRBH:function(a,n){return a<n},DlTHL:function(a,n){return a<n},pqZqH:function(a,n){return a&n},FwjtW:function(a,n){return a&n},wqRQb:function(a,n){return a+n},IEQqY:function(a,n){return a|n},ZoyPM:function(a,n){return a|n},rxnEG:function(a,n){return a|n},cmfHv:function(a,n){return a|n},tQNlw:function(a,n){return a<<n},LdPnk:function(a,n){return a<<n},vQJtC:function(a,n){return a===n},YFCRS:"wECvc",BjYXE:"MBuDW",UtGeW:function(a,n){return a<n},ozUAI:function(a,n){return a|n},DMWMt:function(a,n){return a|n},YnTSY:function(a,n){return a+n},nfQjL:function(a,n){return a>>n},IwclK:function(a,n){return a&n},AWjIL:function(a,n){return a<n},uphEZ:function(a,n){return a|n},WSAcR:function(a,n){return a|n},LGwHa:function(a,n){return a===n},treEL:function(a,n){return a+n},sQLct:t(774)+t(1372),PgMEs:function(a,n){return a>>n},PuEqQ:function(a,n){return a&n},xLwdN:function(a,n){return a|n},kiFVx:function(a,n){return a|n},TYSOg:function(a,n){return a&n},FaMlV:function(a,n){return a>>n},hUNLs:function(a,n){return a+n},LVxAV:function(a,n){return a|n},dhjev:function(a,n){return a|n},tvUvt:function(a,n){return a&n},UXELW:function(a,n){return a==n},upusf:t(1572),PkPAh:function(a,n,s,d){return a(n,s,d)},aYowp:function(a,n){return a!==n},lzESh:t(372),GCpty:function(a,n){return a!=n},SeXOt:function(a,n){return a instanceof n},SbYRP:function(a,n){return a instanceof n},rJPGQ:t(696)+t(1393),ouVXJ:"text/pla"+t(1460)+"et=utf-8",AqDLc:function(a,n){return a===n},OMNuI:t(447),uoPqP:t(1065),xUNui:"ppe",NWfUy:function(a,n){return a>=n},bYkAX:t(1038)+"reason",cXOgR:t(1321)+t(1179),RYpKk:function(a,n){return a+n},ykjCk:t(588),Koqfi:"&jscallb"+t(821)+t(1439)+"P",PVcvp:t(1741),jCtVp:t(512),gxuzE:function(a,n){return a(n)},WUKpI:function(a,n){return a&n},nJGUd:function(a,n){return a|n},ILWuP:function(a,n){return a&n},ovnMb:function(a,n){return a(n)},IdqGY:"ckMGr",segEz:function(a,n){return a!==n},YkBcJ:t(788),KfOca:t(696)+t(1393)+t(329)+t(1117),isMan:t(1496)+"e",LtPtM:t(629),pzPNq:function(a,n,s,d){return a(n,s,d)},JpkfQ:function(a,n){return a!==n},fWWsd:t(979),rFivy:t(400),zzxrg:function(a,n){return a<=n},iCsor:function(a){return a()},gWKww:t(1308),Dmbed:function(a,n){return a|n},liBBw:function(a,n){return a&n},jyblR:function(a,n){return a&n},aefYh:function(a,n){return a&n},wtPmA:function(a,n){return a>=n},qmyxD:function(a,n){return a(n)},EIUug:"frngF",nTFiL:function(a,n,s){return a(n,s)},MCvuy:function(a,n){return a===n},obreH:"RkTCZ",EioFO:"CLmdG",yZNRG:"cursor_n"+t(981),rXIfy:function(a,n){return a!==n},VOtdw:t(1101),jVlvK:function(a,n){return a&n},QcwzC:function(a,n){return a!==n},mOFSU:t(320),gBzCH:function(a,n,s,d){return a(n,s,d)},SlSUO:function(a,n){return a===n},NdRRk:"ULkHs",dXIEt:function(a,n){return a||n},hJjeW:function(a,n){return a||n},QvrXr:function(a,n){return a===n},zyzjQ:t(633),eiEsY:"Adgid",XfOof:function(a,n){return a===n},jdwJQ:t(456),JzzAm:function(a,n){return a||n},VcvIl:function(a,n,s){return a(n,s)},hfoPN:function(a,n){return a!==n},WtbSq:"XtbsM",HLfxe:t(482),LgwWB:function(a,n){return a>n},fTCFL:t(984),IeYJq:t(999),gboas:function(a,n){return a!=n},IHXxU:"init QoS"+t(350)+"d",wKMVA:t(1599)+"id",dZqhb:t(408),abdsC:t(1686),ECOdJ:t(1355)+t(404)+"e",owmJU:t(857),msrkt:"paJKB",RgJen:function(a,n){return a!==n},Qtpro:"ZYVId",rLHNl:function(a,n){return a(n)},qwLLD:t(899)+t(1432),aWIlp:t(899)+"er_qos_ack",DqyPG:function(a,n,s,d){return a(n,s,d)},TxIQg:t(899)+t(955)+t(601),jXzAx:function(a,n,s){return a(n,s)},CFvAT:function(a,n){return a&&n},DRNRs:t(794),vSXvi:"is_ack",BvqAW:t(851),jtyec:t(1244),KYjLC:"qhVUZ",eqHqN:function(a){return a()},NyNET:function(a,n){return a===n},LiZPQ:t(1823),dxXKk:function(a,n){return a instanceof n},ZOeCp:function(a,n){return a instanceof n},xOgfI:function(a,n){return a<n},cDLGK:function(a,n){return a>n},rpyLr:function(a,n){return a&n},ygqjY:function(a,n){return a+n},oDSxK:function(a,n){return a|n},gEORo:function(a,n){return a(n)},ysvwE:function(a,n){return a+n},TBWDR:function(a,n){return a+n},aMxHH:function(a,n){return a+n},SYeQY:function(a,n){return a+n},tPaYu:function(a,n){return a>>>n},TRXUS:function(a,n){return a<<n},iEqVJ:t(828),JShGh:function(a,n){return a|n},vddCy:function(a,n){return a|n},McxnJ:function(a,n){return a<<n},DWmyR:function(a,n){return a<<n},dkyVL:function(a,n){return a+n},aHWyU:function(a,n){return a<<n},zDzqh:function(a,n){return a+n},XSTdz:function(a,n){return a|n},SfSbf:function(a,n){return a<<n},PLfJb:function(a,n){return a<<n},rSDSk:function(a,n){return a+n},MhUsr:function(a,n){return a+n},wgEJk:function(a,n){return a+n},hsyMa:function(a,n){return a>>>n},lYEcM:function(a,n){return a+n},CBrEK:function(a,n){return a&n},jwwKo:function(a,n){return a+n},HyIjo:function(a,n){return a&n},sQzKa:function(a,n){return a+n},BRLmA:function(a,n){return a&n},FpyNN:function(a,n){return a&n},pvVQL:function(a,n){return a>>>n},lDQMZ:function(a,n){return a<n},RCLqc:function(a,n){return a>n},bzKRr:function(a,n,s,d){return a(n,s,d)},pplPc:function(a,n){return a(n)},DUXyJ:t(744)+t(326)+"|1|6|4",HgMzu:t(962),JTDcM:t(991),xlWgz:function(a,n){return a<n},FIpBx:function(a,n,s){return a(n,s)},ZpfDW:function(a,n){return a+n},ifRcx:t(769)+t(1067),kIPvs:function(a,n){return a!==n},zORBo:"ALL",whlzG:t(598),AKoKi:t(997),GfEut:function(a,n,s,d){return a(n,s,d)},fYfbG:function(a,n){return a(n)},lbqEc:function(a,n){return a+n},YWggt:function(a,n){return a!==n},bQcjm:"npxjd",AcDOS:t(1780),SxkbL:function(a,n){return a(n)},CfScp:t(347)+"or",rqcZJ:function(a,n){return a===n},koSVv:t(1601),AtkpG:t(1129),NhTLV:function(a,n){return a===n},Qosbv:t(1097),QHSgI:function(a,n,s,d){return a(n,s,d)},XhOLy:t(363),aPUHZ:function(a,n,s,d){return a(n,s,d)},oCpKX:"x_fronti"+t(1149),sQfLb:t(1647)+"s",EeOwv:t(1188)+t(714)+"e",yazJs:function(a,n,s){return a(n,s)},wUZMb:t(1188)+t(361)+"ue",SnDgG:function(a,n){return a>n},kxShZ:function(a,n){return a+n},lhpXZ:function(a){return a()},KQMGS:function(a,n){return a<n},rYcjq:function(a){return a()},nORXP:function(a){return a()},SQwFK:function(a,n){return a===n},pNxoT:function(a){return a()},jqqwe:function(a){return a()},jTYdk:function(a){return a()},vmiOZ:function(a,n){return a(n)},FiqGa:function(a,n){return a(n)},PWTmK:function(a){return a()},opqWe:function(a){return a()},mlKnI:function(a,n){return a<n},arIpJ:function(a,n,s){return a(n,s)},xASTx:function(a){return a()},bGljO:"always",RNNil:"auto",IvogE:"ping_onc"+t(748)+"s",ctgqj:t(379),kNwYZ:function(a,n){return a===n},jiuhK:function(a,n,s,d){return a(n,s,d)},TgFNz:function(a,n,s){return a(n,s)},jekJt:t(790),IhaQo:t(1303),tmKmy:function(a,n){return a===n},RkIXf:function(a,n,s){return a(n,s)},EIzXk:"complete",LMyqm:"abort",OHuVe:t(888),imtFM:function(a,n,s){return a(n,s)},UvprQ:function(a,n){return a!==n},fIavF:function(a,n){return a(n)},XGlbG:function(a,n,s){return a(n,s)},HqNNr:t(765),GRXGv:function(a,n,s){return a(n,s)},uImMV:function(a,n){return a!==n},pRKpV:t(1482),MhRGt:function(a,n){return a/n},jmWrY:function(a,n){return a==n},cryhN:function(a,n){return a(n)},YdJgJ:t(875)+t(1563)+t(1742)+t(599)+"ket cons"+t(1385)+"is undef"+t(1624),hSojn:function(a,n){return a===n},pozHg:t(1213),hOlbn:t(415),dcOgi:t(346),Cugeh:t(716)+"t",Xgskg:t(1204)+t(1041)+" reconnect",vskjF:"nbZCL",JSeeh:t(693),uZExn:t(1162),sGNCW:"pagehide",ZIKBk:t(1011),wpxRY:function(a,n){return a===n},rwjgi:t(1230),aHJOH:function(a,n){return a(n)},idmCj:function(a,n){return a!==n},SaIWC:t(1377),RyOaW:t(1087),VVWig:t(319),hUdVA:t(1137),rkvqx:t(432),IeEPV:t(1116),VKtNB:"device_id",UeVfK:"please p"+t(1157)+t(1489)+t(1830)+t(1106),IkOBp:t(1454),TcnCk:t(448),MRZVj:t(574)+"0",cEJti:function(a,n,s){return a(n,s)},dDdQx:function(a,n,s){return a(n,s)},TlfYY:t(1452),ndOMo:t(489),KkKbP:function(a,n){return a||n},rkNqM:function(a,n,s){return a(n,s)},kvsIm:t(1774),xrdqt:function(a,n,s){return a(n,s)},kQRWh:function(a,n,s){return a(n,s)},XaRjI:t(1391)+t(1692)+"t",UnBAL:function(a,n){return a===n},APYfR:t(1379),uSgQj:t(1653),XMPiq:function(a,n){return a(n)},jvVrX:function(a,n){return a(n)},ugLgx:function(a,n){return a(n)},xcTnI:function(a,n){return a===n},sziKk:t(439),BqOko:t(1784),gZbMu:function(a,n){return a*n},vyRGo:function(a,n){return a-n},vuLRc:function(a,n){return a>n},RfoWP:function(a,n){return a===n},tVRpt:function(a,n){return a!==n},SSQZC:function(a,n,s){return a(n,s)},IwgbL:t(887),sOipo:function(a,n){return a===n},eLKiI:"zmlHd",JdZeH:"rLuiG",XmKvV:"timeout,"+t(1560)+t(912)+"g",qHXtm:t(1568),TLZnU:t(1350)+"le",GHgjV:t(1009),ixjHC:t(1676),TmaIj:t(920)+"0",XVKEC:"0|2|1|4|3",pHprs:t(856)+t(1390)+t(1532)+t(666),Mdueg:t(552),YXlNF:t(881)+"eeded",kqgEY:function(a,n,s,d,f){return a(n,s,d,f)},LdtxM:t(568),zUrIO:t(1551),cznJI:t(957),infsl:t(517)+"s instan"+t(710)+t(355)+"ed",oUoWP:function(a,n){return a===n},pZFZe:function(a,n){return a===n},cMvUp:t(517)+t(1337)+t(1781),oNkap:function(a,n){return a===n},LvfoO:"pyDwV",TCviy:t(875)+t(1369)+t(1138)+t(1636)+t(1579)+t(337)+"ng or an"+t(451)+t(906),PNuuc:t(262),QgjrN:function(a,n){return a(n)},yGXja:"please p"+t(1369)+t(884)+t(1651),qbYXN:function(a,n){return a instanceof n},AUDWB:function(a,n){return a(n)},yRNVV:"sent",tgIrD:function(a,n){return a<n},BWCZP:function(a,n){return a||n},DbnPo:function(a,n){return a!==n},dzlbR:t(1031)+"econnect"+t(498),tDMLB:t(586),xcTnD:t(1019)+"2",GwuWk:t(761),BVzjQ:"PNibt",RWgJG:t(1126),bUVaD:t(970),pntvF:"vLvmZ",IfpyK:function(a,n){return a(n)},esbEv:t(1580),iGmxr:function(a,n){return a!==n},AfYcr:function(a,n,s){return a(n,s)},ufhQr:t(1407),NdXtS:function(a,n){return a!=n},Acruh:t(1098),GOfww:function(a,n){return a!=n},SLXRC:"Object",yfBqU:t(431)+t(767)+t(441)+"pe",pMoHO:function(a,n){return a!=n},Iopuj:function(a,n){return a==n},BmATj:function(a,n){return a===n},tNOGp:function(a,n){return a!=n},yRCGe:function(a,n){return a!=n},TYBDJ:t(1793)+"qos__"};Nt.r(De),Nt.d(De,{FWS:()=>Yp,CustomErrorEvent:()=>Vd,createCloseEvent:()=>xt,ReconnectEvent:()=>$d,createErrorEvent:()=>at,decodedFrame:()=>Xt,createOpenEvent:()=>el,CustomCloseEvent:()=>Jd,createReconnectEvent:()=>da,FrontierMessageEvent:()=>Yd,encodeFrame:()=>Bt,createMessageEvent:()=>Qd,OpenEvent:()=>Xd,ErrorCode:()=>en,Event:()=>Qn,MessageEvent:()=>Zd});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(795)](),f=r||(r=x(a)),h=Math[n(1546)]().toString(16).slice(-6);return e[n(1818)](s+d+f,h)}function o(){let a=t;if(e[a(1376)](a(453),e[a(1205)])){let n=e[a(535)](_0x4b3e09,_0x2488ac,_0x4da21e.length);_0x550d92[a(1122)][a(1462)](_0x5b9483,n)}else return e[a(1820)](1e4*Date[a(795)](),Math[a(873)](1e4*Math.random()))}function c(a){let n=t;if(e[n(362)](n(394),e[n(789)])){let{value:s,offset:d}=e[n(1713)](_0x2d3210,_0x202735,_0x5c157f);_0x11ffff=d,_0x534631=e[n(657)](e[n(1270)](_0x4418ca,8),0),_0x1df8e2+=s}else return e.ECNVC(e[n(1631)](Array,8)[n(939)]("0"),parseInt(a,10)[n(589)](2))[n(264)](-8)}function l(a){let n=t;return e[n(571)](e[n(1631)](Array,4)[n(939)]("0"),e[n(535)](parseInt,a,2)[n(589)](16)).slice(-4)}function u(a){let n=t,s=a[n(485)](/\./).map(h=>c(h)),d=[];return d[0]=e.QMELo(l,s[0]+s[1]),d[1]=e[n(1762)](l,s[2]+s[3]),[n(1648),e[n(1450)],e.WBQQr,n(1648),e[n(1450)],e[n(580)],d[0],d[1]][n(939)]("")}function x(a){let n=t,s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(521)](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(521)](a);return s?e[n(457)](u,a):d?e.iGmVh(p,a):e[n(1012)]}function p(a){let n=t,s="",d=[],f=0,h=0,m=!0,b=e.WBQQr;if(e[n(1536)](a[n(822)]("::"),-1)){let g=a[n(485)]("::");for(let D=0;e[n(931)](D,g[n(1524)]);D++){let N=g[D];if(e[n(1536)](N.indexOf(":"),0))if(e[n(927)](e.rVenx,e.xraOu)){let H=N[n(485)](":");m&&(f=H[n(1524)]),h+=H[n(1524)];for(let J=0;e.SRNot(J,H[n(1524)]);J++)if(e[n(1387)](4,H[J].length)){let X=b.substring(0,e[n(1142)](4,H[J][n(1524)])),Q=X.concat(H[J]);d[n(354)](Q)}else d.push(H[J]);m=!1}else this._debug(e[n(1831)],_0x1acfbd.message),e[n(722)](_0x225dd2);else{if(e[n(1387)](4,N[n(1524)])){if(e.DIgHd(e[n(1544)],e[n(1544)]))return _0x536843+=_0x37cf44&&_0x28a0af.byteLength||0,_0x5f4812;{let H=b[n(292)+"g"](0,e.LZndK(4,N.length)),J=H[n(576)](N);d[n(354)](J)}}else d.push(N);m&&(f+=1),h+=1,m=!1}}let v="";for(let D=0;e.SRNot(D,e.aZFqj(8,h));D++)v=v.concat(b);for(let D=0;e[n(1443)](D,d[n(1524)]);D++)e[n(362)](D,f)?(s=s[n(576)](v),s=s[n(576)](d[D])):s=s.concat(d[D]);return s}{let g=a[n(485)](":");for(let v=0;e.CqIiE(v,g[n(1524)]);v++){let D=g[v];if(e.MfwGN(4,g[v][n(1524)])){let N=b[n(292)+"g"](0,e[n(392)](4,g[v][n(1524)])),H=N[n(576)](D);s=s.concat(H)}else s=s.concat(D)}return s}}function w(a,n){let s=t,d=a.key;d!==void 0&&(e[s(535)](pe,n,10),e[s(1713)](G,n,d));let f=a.value;e[s(754)](void 0,f)&&(e[s(1656)](pe,n,18),e[s(729)](G,n,f))}function _(a){let n=t,s={};e:for(;!e[n(1217)]($,a);){let d=e[n(855)](he,a);switch(e[n(657)](d,3)){case 0:break e;case 1:s[n(740)]=e[n(729)](L,a,e.BnYxn(he,a));break;case 2:s.value=e[n(1713)](L,a,he(a));break;default:e[n(1310)](R,a,7&d)}}if(s[n(740)]===void 0)throw new Error(e[n(1238)]);if(e[n(362)](void 0,s[n(1045)]))throw new Error("Missing required"+n(958)+n(1045));return s}function I(a){let n=t,s=e[n(722)](k);return e.VTZmq(y,a,s),e[n(1631)](B,s)}function y(a,n){let s=t;if(e[s(362)](e[s(1332)],"VCYKq"))_0x166459&&this[s(1258)+s(1127)][s(745)+"rsorFile"+s(1203)](_0x599175);else{let d=a[s(301)];e[s(1025)](void 0,d)&&(e[s(1376)](s(1255),e[s(1567)])?(e[s(1333)](pe,n,8),e[s(753)](ft,n,d)):this[s(896)+"T"]?_0x201b3b["onNetwor"+s(917)+s(807)](({isConnected:Q})=>{let ge=s;this[ge(736)+"igatorOn"+ge(1187)]=Q,Q?this[ge(1480)+ge(1331)]():this[ge(1480)+"ffLine"]()}):this._isMiniWX&&_0x5aaed2[s(1105)+"kStatusC"+s(807)](({isConnected:Q})=>{let ge=s;this[ge(736)+"igatorOn"+ge(1187)]=Q,Q?this["_handleO"+ge(1331)]():this[ge(1480)+ge(919)]()}));let f=a[s(1248)];e[s(1376)](void 0,f)&&(pe(n,16),e.YRBOk(ft,n,f));let h=a[s(315)];e.IlUWA(void 0,h)&&(pe(n,24),e[s(1245)](ft,n,e[s(1778)](P,h)));let m=a[s(965)];m!==void 0&&(pe(n,32),ft(n,e[s(1704)](P,m)));let b=a[s(296)];if(e.ISeRs(void 0,b))for(let Q of b){if(e[s(362)](e[s(1751)],e[s(815)]))return new _0x179886(_0x53aa64,_0x50e3af,_0x501800);{e[s(1713)](pe,n,42);let ge=e[s(1717)](k);e.xmKyJ(w,Q,ge),e.niXwV(pe,n,ge[s(523)]),e.sQcZz(K,n,ge),e.uiVIh(O,ge)}}let g=a[s(1239)+"ncoding"];g!==void 0&&(e[s(900)](pe,n,50),e[s(729)](G,n,g));let v=a[s(1001)+s(874)];if(e[s(536)](void 0,v))if(e[s(1082)](e[s(1816)],e.LpLzt))e[s(1437)](pe,n,58),e[s(1245)](G,n,v);else{let Q=_0x5c632d[s(1122)],ge=_0x198d26[s(1528)],is=_0x3d216e[s(523)],nn=e[s(1694)](ge,_0x202398);if(e.UGTVR(nn,Q[s(1524)])){let ss=new _0x3168f5(e.rKqZJ(2,nn));ss[s(1462)](Q),_0x449d30[s(1122)]=ss}return _0x2026ad[s(1528)]=nn,e[s(1470)](nn,is)&&(_0x2ade9f[s(523)]=nn),ge}let D=a[s(756)];e[s(754)](void 0,D)&&(e[s(1245)](pe,n,66),pe(n,D[s(1524)]),e[s(1310)](ae,n,D));let N=a.LogIDNew;N!==void 0&&(e[s(1333)](pe,n,74),e[s(1354)](G,n,N));let H=a["serverTi"+s(908)];e[s(1387)](void 0,H)&&(e[s(1310)](pe,n,82),G(n,H));let J=a[s(290)];e[s(737)](void 0,J)&&(e[s(1269)](pe,n,90),e[s(305)](G,n,J));let X=a[s(1145)+"e"];e[s(1673)](void 0,X)&&(e[s(617)](pe,n,96),e[s(735)](ft,n,e[s(1704)](P,X)))}}function S(a){let n=t;return e[n(1023)](A,e[n(1631)](F,a))}function A(a){let n=t;if(e.kwNHo===n(971))return new _0x29e8dc(e.EIlnW(e[n(426)](_0x24e250[4],24),e[n(654)](_0x155e20[5],16))|e.maKUa(_0xa2c4dc[6],8)|_0x4e952b[7],e[n(684)](e.yLqBN(e[n(1270)](_0x58d480[0],24),e[n(426)](_0x39a77c[1],16)),e[n(426)](_0x50acf1[2],8))|_0x4c69b5[3],_0x1d0201);{let s={};e:for(;!e.yGweM($,a);){let d=e[n(1704)](he,a);switch(e[n(657)](d,3)){case 0:break e;case 1:s.SeqID=e.BlzqT(vt,a,!0);break;case 2:s.LogID=vt(a,!0);break;case 3:s[n(315)]=e[n(1800)](he,a);break;case 4:s[n(965)]=e[n(457)](he,a);break;case 5:{let f=e[n(662)](T,a);(s.headers||(s[n(296)]=[]))[n(354)](_(a)),a[n(523)]=f;break}case 6:s.payloadEncoding=e[n(1333)](L,a,he(a));break;case 7:s[n(1001)+n(874)]=e[n(1656)](L,a,e[n(855)](he,a));break;case 8:s[n(756)]=e[n(535)](se,a,e[n(1748)](he,a));break;case 9:s[n(1658)]=e[n(305)](L,a,e.ZEDNX(he,a));break;case 10:s.serverTiming=e[n(1629)](L,a,e[n(1062)](he,a));break;case 11:s.msgID=e[n(1437)](L,a,he(a));break;case 12:s[n(1145)+"e"]=e[n(1062)](he,a);break;default:R(a,7&d)}}if(e.Lhpxo(void 0,s.SeqID))throw new Error(n(933)+n(1458)+n(958)+n(301));if(s.LogID===void 0)throw new Error(e[n(1431)]);if(e.QvQiS(void 0,s.service))throw new Error(e[n(1328)]);if(e[n(1278)](void 0,s[n(965)]))throw new Error(e[n(694)]);return s}}function T(a){let n=t,s=e.kutmg(he,a),d=a[n(523)];return a[n(523)]=e[n(1820)](a[n(1528)],s),d}function R(a,n){let s=t;if(e[s(1082)](e[s(1516)],s(1513)))this[s(1632)+"s"]=_0x283f6b,this[s(1542)+"es"]=_0x2bc986,this[s(924)+"ndex"]=0,this["currentEndpointT"+s(911)+"t"]=0;else switch(n){case 0:for(;e[s(1657)](128,e[s(1762)](oe,a)););break;case 2:e.pCiqs(V,a,e.jNYAs(he,a));break;case 5:e[s(1713)](V,a,4);break;case 1:V(a,8);break;default:throw new Error(e[s(843)]+n)}}function P(a){let n=t;return a|=0,{low:a,high:e[n(1446)](a,31),unsigned:e[n(359)](a,0)}}let E=[];function k(){let a=t,n=E[a(316)]();return n?(n[a(1528)]=n[a(523)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(a){E[t(354)](a)}function F(a){return{bytes:a,offset:0,limit:a[t(1524)]}}function B(a){let n=t,s=a.bytes,d=a.limit;return e[n(1082)](s[n(1524)],d)?s:s.subarray(0,d)}function V(a,n){let s=t;if(e[s(1820)](a[s(1528)],n)>a[s(523)])throw new Error(e[s(423)]);a[s(1528)]+=n}function $(a){let n=t;return a.offset>=a[n(523)]}function ne(a,n){let s=t,d=a[s(1122)],f=a[s(1528)],h=a.limit,m=e[s(967)](f,n);if(e[s(1577)](m,d.length)){let b=new Uint8Array(e[s(416)](2,m));b[s(1462)](d),a[s(1122)]=b}return a.offset=m,e[s(1536)](m,h)&&(a[s(523)]=m),f}function Z(a,n){let s=t,d={FGuwY:function(f,h){return f+h},OkCvU:function(f,h){return e[U(1665)](f,h)},dRLli:function(f,h,m){return e[U(1354)](f,h,m)}};if(e[s(1278)](s(1770),s(1770))){let f=a[s(1528)];if(e.BIXfF(e.GmUFg(f,n),a[s(523)]))throw new Error(e[s(725)]);return a[s(1528)]+=n,f}else return cCgmrk[s(1073)](cCgmrk[s(631)](_0x5c0050,4).join("0"),cCgmrk[s(1401)](_0x10061c,_0x18a527,2).toString(16))[s(264)](-4)}function se(a,n){let s=t,d=e[s(1656)](Z,a,n);return a[s(1122)][s(647)](d,e[s(967)](d,n))}function ae(a,n){let s=t,d={VrDOu:function(f,h){return f(h)},vTffs:function(f,h){return e[U(1210)](f,h)},UHXjg:function(f,h){return f<<h},hTSjF:function(f,h){return f&h},HLUNJ:function(f,h){return e[U(770)](f,h)},gPZzK:function(f,h){return e[U(570)](f,h)},vpaTr:function(f,h){return e[U(1210)](f,h)}};if(e.PTwgo===e[s(1840)]){let f=e[s(436)](ne,a,n.length);a.bytes[s(1462)](n,f)}else _0x2b12dd=d.VrDOu(_0xe5eab3,_0x399c21),_0x44edf2|=d.vTffs(127,_0x1e9a0c)<<14,d[s(1202)](128,_0x620a5e)&&(_0x49d57e=_0x2f47b9(_0x3551d1),_0x58ca25|=d[s(1797)](d[s(1371)](127,_0x412d65),21),d[s(1597)](128,_0x53a0c4)&&(_0x107575=d[s(402)](_0x12d545,_0x573919),_0x504e33=d.gPZzK(127,_0x27ea77),d[s(1584)](128,_0x1e7901)&&(_0x1ad23f=d[s(402)](_0x564d48,_0x12537a),_0x11f1b3|=d[s(1584)](127,_0x2eaa65)<<7)))}function L(a,n){let s=t,d={iighS:function(v,D){return e[U(684)](v,D)},srZth:function(v,D){return e.QvQiS(v,D)},okjNy:function(v,D){return e.Qlnem(v,D)},jsXWB:function(v,D){return e[U(1024)](v,D)},mVxLS:function(v,D){return v&D},TXRjN:function(v,D){return e[U(967)](v,D)},Hmqap:function(v,D){return e[U(967)](v,D)},cYKCT:function(v,D){return e[U(936)](v,D)},qeOkJ:function(v,D){return e[U(770)](v,D)},NIkuf:function(v,D){return v>>D},nSxlM:function(v,D){return e[U(1424)](v,D)},AyWac:function(v,D){return e[U(1505)](v,D)},VfNme:function(v,D){return e[U(1115)](v,D)},RaHZc:function(v,D){return e.XYbXD(v,D)},rLUua:function(v,D){return e[U(1773)](v,D)},FPdIU:function(v,D){return e[U(936)](v,D)},pkKHS:function(v,D){return e[U(1276)](v,D)}},f=Z(a,n),h=String[s(1507)+"Code"],m=a[s(1122)],b="\uFFFD",g="";for(let v=0;e[s(931)](v,n);v++)if(s(1233)===s(1233)){let D=m[e.xdkXd(v,f)],N,H,J,X;if(e[s(1294)](e[s(974)](128,D),0))g+=e.mAGbB(h,D);else if((224&D)===192)if(e[s(1113)](v,1)>=n)g+=b;else if(N=m[e[s(1113)](e[s(1558)](v,f),1)],e.xRDFU(192&N,128))g+=b;else if(e.Kgnki===s(1444))X=e[s(1565)](e[s(283)](31&D,6),e[s(1109)](63,N)),e[s(1071)](X,128)?g+=b:e[s(927)](s(903),e[s(420)])?(_0x11f54e=_0x483b95[s(1649)+"At"](_0x5afb8e),_0x30c194<128?_0x18dd1f[_0x466374++]=_0x354072:_0x9dcb4e<2048?(_0x1d548b[_0x3183f5++]=d.iighS(_0x3c8b0a>>6,192),_0x21967e[_0x4437f9++]=63&_0x2fbc59|128):d[s(1166)](d.okjNy(64512,_0x120c63),55296)&&d[s(1172)](d.mVxLS(64512,_0x154b6c=_0x7d8351[s(1649)+"At"](d[s(1554)](_0x3f65ff,1))),56320)?(_0x177b4=d[s(805)](d[s(1554)](65536,(1023&_0x2ab50e)<<10),d[s(1548)](1023,_0x526b95)),++_0x59080c,_0x4c6b34[_0x283379++]=d[s(1671)](_0x3b14df,18)|240,_0x339928[_0x36a891++]=d[s(606)](d[s(1285)](d.NIkuf(_0x3b0ad5,12),63),128),_0x269212[_0x174169++]=d[s(403)](d.NIkuf(_0x2bad1c,6),63)|128,_0x1ce2c1[_0x3c874c++]=d[s(1483)](63,_0xa46bf2)|128):(_0x4a660f[_0xc34ff0++]=d.VfNme(d[s(776)](_0x351d39,12),224),_0xf2b969[_0x113207++]=d[s(545)](d.AyWac(d.FPdIU(_0x58053e,6),63),128),_0x481381[_0x28f1ba++]=d.pkKHS(d[s(1483)](63,_0x564819),128))):(g+=h(X),v++);else return _0xabffe[_0x27fd50]=_0x2d2280,!0;else if(e[s(622)](e[s(915)](240,D),224))if(e.eJJWB(v,2)>=n)g+=b;else if(e[s(1025)](e[s(384)],e.EFHhC))N=m[e.GmUFg(v,f)+1],H=m[e.eJJWB(e.JGNiW(v,f),2)],e[s(1025)](e[s(1109)](e[s(1276)](N,e[s(1201)](H,8)),49344),32896)?g+=b:(X=e[s(1773)](e[s(540)](e.piOmp(15,D),12)|e[s(1210)](63,N)<<6,e[s(1657)](63,H)),X<2048||e[s(819)](X,55296)&&e[s(709)](X,57343)?g+=b:(g+=e[s(1631)](h,X),v+=2));else return _0x5313bd[s(1817)](_0x7e6f5d)||(_0x592974=_0x562585[s(297)+"er"](_0x56ad2c)),e[s(927)](this[s(1722)],_0x5c3775[s(1722)])&&e[s(657)](this[s(388)],31)===1&&e[s(1525)](_0x50f7e9[s(388)],31)===1?!1:e[s(362)](this[s(388)],_0x3ccbdc.high)&&e.agylE(this[s(1453)],_0x3eb1a3.low);else e.JVcxu(248,D)==240?e[s(571)](v,3)>=n?g+=b:(N=m[e.iPMIH(e.pclbd(v,f),1)],H=m[e[s(1335)](e.vcaWk(v,f),2)],J=m[e.NiSwa(e[s(1352)](v,f),3)],e.yuMPo(e[s(644)](N|e.wdewy(H,8)|e[s(426)](J,16),12632256),8421504)?g+=b:(X=e[s(637)](e[s(1456)](7,D)<<18,e[s(1210)](63,N)<<12)|e[s(1207)](63&H,6)|e[s(721)](63,J),e[s(944)](X,65536)||X>1114111?g+=b:(X-=65536,g+=e[s(535)](h,(X>>10)+55296,e.Ifvov(1023&X,56320)),v+=3))):g+=b}else{let D=_0x5ad564[s(1524)]&&_0x3e5e11[0];if(D instanceof _0x4ed775)throw D;let N=new _0x14ed1f(e[s(1694)](e[s(323)],D?e[s(1113)](" ("+D.message,")"):""));throw N.context=D,D}return g}function G(a,n){let s=t;if(e[s(1278)](e[s(322)],"XbYRE")){let d=_0x28a51a.bytes,f=_0x2172d9[s(523)];return d[s(1524)]===f?d:d.subarray(0,f)}else{let d=n[s(1524)],f=0;for(let b=0;e[s(931)](b,d);b++){let g=n[s(1649)+"At"](b);e[s(819)](g,55296)&&e[s(1158)](g,56319)&&e.CqIiE(e.ScQdv(b,1),d)&&(g=e[s(1330)](e.IJHUn(e[s(540)](g,10),n[s(1649)+"At"](++b)),56613888)),f+=g<128?1:e[s(274)](g,2048)?2:e.JfsgA(g,65536)?3:4}e[s(1079)](pe,a,f);let h=e.cqPZw(ne,a,f),m=a.bytes;for(let b=0;e[s(641)](b,d);b++){let g=n.charCodeAt(b);e[s(1171)](g,55296)&&e[s(1498)](g,56319)&&b+1<d&&(g=e.iVQHe(g,10)+n[s(1649)+"At"](++b)-56613888),g<128?m[h++]=g:(g<2048?m[h++]=e.rdBrH(e[s(830)](e[s(1810)](g,6),31),192):(e[s(1253)](g,65536)?m[h++]=e[s(930)](e.TvfeO(e[s(936)](g,12),15),224):(m[h++]=e[s(1565)](e[s(1540)](e.XYbXD(g,18),7),240),m[h++]=e[s(1565)](e.XYbXD(g,12)&63,128)),m[h++]=e.piOmp(e[s(1211)](g,6),63)|128),m[h++]=e[s(889)](63&g,128))}}}function K(a,n){let s=t,d=e[s(1777)](ne,a,n[s(523)]),f=a.bytes,h=n[s(1122)];for(let m=0,b=n[s(523)];e[s(838)](m,b);m++)f[m+d]=h[m]}function oe(a){let n=t;if(e[n(1278)](e[n(1485)],e[n(1485)]))return a.bytes[e.atNdM(Z,a,1)];this[n(845)](n(1811),_0x4b8501),this[n(1254)]&&this[n(1254)](_0x50bc75)}function Ze(a,n){let s=t,d=e.cqPZw(ne,a,1);a[s(1122)][d]=n}function he(a){let n=t,s=0,d=0,f;do f=e[n(1762)](oe,a),s<32&&(d|=e[n(854)](e.GtFPV(127,f),s)),s+=7;while(128&f);return d}function pe(a,n){let s=t;if(e[s(387)]!==e[s(387)])return this._ws?this._ws[s(497)]:this._url;for(n>>>=0;n>=128;)e[s(1488)](Ze,a,e[s(1364)](e[s(770)](127,n),128)),n>>>=7;e[s(1021)](Ze,a,n)}function vt(a,n){let s=t,d={zjkCz:e.PfLwo},f=0,h=0,m=0,b;if(b=e[s(1748)](oe,a),f=e[s(558)](127,b),e.TvfeO(128,b)&&(b=e[s(685)](oe,a),f|=e.VtMbp(127&b,7),e[s(1008)](128,b)&&(b=e[s(1316)](oe,a),f|=e[s(1505)](127,b)<<14,e[s(1008)](128,b))))if(e.spBtQ(e[s(960)],e[s(960)])){if(b=e[s(1687)](oe,a),f|=e.GNyDT(127,b)<<21,e[s(892)](128,b)&&(b=e[s(1631)](oe,a),h=e[s(799)](127,b),e.WKRCh(128,b)&&(b=e[s(457)](oe,a),h|=e[s(1358)](127,b)<<7,e[s(850)](128,b)))){if(s(1549)!=="XQqXc"){if(!this[s(1602)+s(1042)]()||this["_readyCl"+s(988)])return;this["_endpoin"+s(976)]?.[s(1730)+s(621)+s(334)](),this[s(270)+s(579)]?.[s(683)+"nter"](),this[s(528)]?this[s(1291)+"ect"](1001,d.zjkCz,!0):this[s(424)]()}else if(b=e[s(685)](oe,a),h|=e[s(1237)](e[s(733)](127,b),14),128&b)if(e.xRDFU(e[s(1794)],e.UjSLl)){let g=this[s(393)][s(950)+s(1341)+"nc"](this[s(263)]),v=_0x48c5ac[s(869)](e[s(1521)](g,"{}"));return _0xcfbdfc[s(627)](v)}else b=e.jNYAs(oe,a),h|=e.ttOMv(e.GtFPV(127,b),21),e[s(644)](128,b)&&(b=e.jNYAs(oe,a),m=127&b,e[s(872)](128,b)&&(b=e[s(1316)](oe,a),m|=e[s(651)](127,b)<<7))}}else return _0x4e4fc3[s(1173)+s(1224)]||_0x3fadbd[s(495)](_0x29aa74);return{low:e[s(1799)](f,e[s(1143)](h,28)),high:e.rVUAE(h>>>4,e.uetJf(m,24)),unsigned:n}}function ft(a,n){let s=t,d=n[s(1453)]>>>0,f=e.bWOWY(e.hijMo(e[s(947)](n[s(1453)],28),e[s(1706)](n[s(388)],4)),0),h=n[s(388)]>>>24,m=e.EHVMg(0,h)?e[s(483)](0,f)?e[s(1071)](d,16384)?e.IZnXu(d,128)?1:2:d<2097152?3:4:f<16384?e[s(775)](f,128)?5:6:e.VsmTi(f,2097152)?7:8:e[s(983)](h,128)?9:10,b=ne(a,m),g=a.bytes;switch(m){case 10:g[e[s(940)](b,9)]=e[s(1835)](h>>>7,1);case 9:g[e[s(808)](b,8)]=e[s(754)](9,m)?e[s(1799)](128,h):e.oiUdr(127,h);case 8:g[b+7]=e[s(1673)](8,m)?e[s(1728)](e[s(905)](f,21),128):e.GRYqX(e[s(1595)](f,21),127);case 7:g[e[s(1829)](b,6)]=m!==7?e[s(1103)](e[s(1525)](f,14),128):e[s(1754)](f>>>14,127);case 6:g[e.pclbd(b,5)]=e[s(975)](6,m)?e[s(1084)](f>>>7,128):e[s(995)](f>>>7,127);case 5:g[e.GmUFg(b,4)]=e.twbKD(5,m)?e[s(325)](128,f):e[s(1028)](127,f);case 4:g[e[s(1359)](b,3)]=m!==4?e[s(930)](e[s(905)](d,21),128):e[s(850)](e.GgUiY(d,21),127);case 3:g[e[s(1352)](b,2)]=m!==3?e[s(865)](d>>>14,128):e[s(905)](d,14)&127;case 2:g[e.pclbd(b,1)]=e[s(927)](2,m)?e[s(1409)](e[s(657)](d,7),128):e[s(1447)](d,7)&127;case 1:g[b]=e[s(975)](1,m)?128|d:127&d}}function Xt(a){return e[t(342)](S,a)}function Bt(a){return e[t(1665)](I,a)}let Qt=65536,Vr=e.ufhQr,_e=e.clbnk(Qt,Qt),Ce=_e*_e,Xn=Ce/2,Oe=String[t(1587)+"e"][t(1649)+"At"];class xe{constructor(n,s,d){let f=t;if(e[f(1095)]!==e.uWVBM){let h=_0x2d9264[_0x4e7287];if(e[f(927)](4,_0x10c363[_0x1711ce][f(1524)])){let m=_0x2fae1d.substring(0,e.JPmIz(4,_0xc89d0[_0x11132d][f(1524)])),b=m[f(576)](h);_0x1257a2=_0x385afd.concat(b)}else _0x30a221=_0x5aea4c[f(576)](h)}else this.isLong=!0,this[f(1453)]=0|n,this.high=e[f(1276)](0,s),this[f(1722)]=!!d}static[t(1817)](n){let s=t;return e[s(1e3)](e[s(324)],e[s(852)])?this[s(1632)+"s"][this[s(924)+s(273)]]:n&&e[s(1016)](!0,n[s(1817)])}static[t(1758)](n,s,d){let f=t;if(e[f(909)](e[f(1085)],e[f(1085)]))return new xe(n,s,d);{let h={kXUBs:e[f(295)],ahlAc:function(D,N,H,J){return D(N,H,J)},RLeqL:e.Jkkiw,JBQke:e.eeapY,Wfrhp:e[f(1144)],GASvM:e[f(1222)],AYDfn:e.roqIX},[m,b]=_0x2ab55a(_0x5debb0),g=e[f(681)](_0x1989ab,m),v=0;return _0x3fe3a0[f(1300)](D=>{let N=f,H=h[N(784)][N(485)]("|"),J=0;for(;;){switch(H[J++]){case"0":v=h.ahlAc(_0x4a01ca,D["cursor_n"+N(981)],g,v);continue;case"1":_0x27a6f1.log(h.RLeqL,D,D.service);continue;case"2":_0x2fb733[N(1688)](h[N(1634)],v);continue;case"3":_0xfd6c61[N(1688)](h[N(1574)],v);continue;case"4":_0xc7e9f1[N(1688)](h.GASvM,v);continue;case"5":_0x113d19.log("name",v);continue;case"6":_0x558c15[N(1688)](h[N(1347)],v);continue;case"7":v=h[N(1061)](_0xe1d010,b[D[N(1302)+"ame"]],g,v);continue;case"8":v=_0x4b9023(0,g,v);continue;case"9":v=h.ahlAc(_0x1b1519,g,v,D[N(315)]||0);continue;case"10":v=_0x2c4f79(_0x4f5428.fromNumber(D.cursor||_0x1a37a9),g,v);continue}break}}),{frameType:_0x420e3b,headers:[{key:e[f(1005)],value:_0x2f9871}],payload:g}}}static[t(1373)+"s"](n,s,d){let f=t;return d?xe[f(1373)+f(1090)](n,s):xe["fromByte"+f(878)](n,s)}static[t(1373)+"sLE"](n,s){let d=t;return new xe(e[d(889)](e[d(276)](n[0],e.VUkVX(n[1],8))|e[d(612)](n[2],16),n[3]<<24),e.Ycjsx(n[4]|e[d(1270)](n[5],8)|e[d(1270)](n[6],16),e[d(689)](n[7],24)),s)}static[t(1373)+t(878)](n,s){let d=t;return new xe(e.mnaTY(e[d(1661)](n[4]<<24,n[5]<<16),e.eiWWc(n[6],8))|n[7],e[d(1276)](e[d(1236)](e.VUkVX(n[0],24)|e.maKUa(n[1],16),n[2]<<8),n[3]),s)}static[t(1621)](n){let s=t;return e.zrSXe(n,Vr)?Kd:new xe(e[s(1078)](e.TLfFT(e[s(637)](Oe[s(307)](n,0),e.MttfT(Oe[s(307)](n,1),8))|e[s(728)](Oe.call(n,2),16),e[s(582)](Oe[s(307)](n,3),24)),0),e[s(557)](e[s(865)](e[s(1615)](Oe.call(n,4),e[s(1625)](Oe[s(307)](n,5),8)),e[s(564)](Oe[s(307)](n,6),16))|e[s(426)](Oe.call(n,7),24),0),!0)}[t(455)](){let n=t;return String["fromChar"+n(507)](255&this.low,e[n(338)](this[n(1453)],8)&255,this[n(1453)]>>>16&255,e[n(783)](this[n(1453)],24),e[n(1505)](255,this[n(388)]),e[n(876)](e[n(771)](this.high,8),255),e[n(1526)](e[n(1734)](this[n(388)],16),255),this.high>>>24)}static[t(297)+"er"](n,s=!0){let d=t;if(e[d(1428)](isNaN,n))return s?dp:Kd;if(s){if(e.qGSne(n,Ce))return up}else{if(n<=-Xn)return fp;if(e[d(1539)](e[d(336)](n,1),Xn))return lp}return xe[d(1758)](e[d(1084)](e[d(1523)](n,_e),0),e[d(484)](n/_e,0),s)}toNumber(){let n=t;return this.unsigned?e[n(1329)](e[n(1315)](e.NbjTL(this[n(388)],0),_e),e[n(1525)](this[n(1453)],0)):e[n(967)](e[n(1531)](this[n(388)],_e),e[n(961)](this[n(1453)],0))}[t(901)](){let n=t;return e[n(483)](0,this[n(388)])&&this.low===0}[t(1375)](n){let s=t;xe[s(1817)](n)||(n=xe[s(297)+"er"](n));let d=e[s(1043)](this[s(388)],16),f=e[s(1679)](65535,this[s(388)]),h=this.low>>>16,m=e.ihxmG(65535,this[s(1453)]),b=n.high>>>16,g=e[s(770)](65535,n[s(388)]),v=e[s(1595)](n[s(1453)],16),D=e[s(1526)](65535,n.low),N=0,H=0,J=0,X=0;return X+=e[s(808)](m,D),J+=X>>>16,X&=65535,J+=h+v,H+=e.Mrxpq(J,16),J&=65535,H+=e[s(1113)](f,g),N+=e[s(1752)](H,16),H&=65535,N+=e[s(834)](d,b),N&=65535,xe[s(1758)](e.TvsHg(e[s(564)](J,16),X),e.uTCtC(e.gZJaO(N,16),H),this[s(1722)])}[t(332)](n){let s=t;return xe[s(1817)](n)||(n=xe[s(297)+"er"](n)),e[s(1025)](this.unsigned,n[s(1722)])&&e[s(783)](this[s(388)],31)===1&&e[s(1559)](e[s(1107)](n[s(388)],31),1)?!1:e.spBtQ(this[s(388)],n[s(388)])&&e[s(785)](this[s(1453)],n[s(1453)])}[t(1590)](){let n=t;if(e.AxOZf(e.gVRFy,e[n(1199)]))return e[n(1756)](-1,this.low)&&e[n(1690)](-1,this[n(388)])?xe[n(1758)](0,0,this[n(1722)]):e[n(1670)](-1,this.low)?xe[n(1758)](0,e[n(1820)](this.high,1),this.unsigned):xe[n(1758)](this[n(1453)]+1,this[n(388)],this.unsigned);for(var s in _0x44465f)_0x4ab454.o(_0x3d98aa,s)&&!_0x24a294.o(_0x3d2bda,s)&&_0x4acabb[n(640)+n(1418)](_0x183087,s,{enumerable:!0,get:_0x1d728c[s]})}[t(556)](n){return n?this[t(1365)+"E"]():this.toBytesBE()}[t(1365)+"E"](){let n=t,s=this[n(388)],d=this.low;return[e[n(733)](255,d),e[n(1752)](d,8)&255,e[n(657)](d,16)&255,d>>>24,255&s,e[n(1659)](e[n(783)](s,8),255),e[n(1210)](e[n(1107)](s,16),255),s>>>24]}[t(1592)+"E"](){let n=t,s=this[n(388)],d=this[n(1453)];return[s>>>24,e.WzQzy(s>>>16,255),e[n(1505)](e[n(338)](s,8),255),255&s,d>>>24,e.DhISS(d>>>16,255),e.YfHvv(e[n(1107)](d,8),255),255&d]}}let Kd=new xe(0,0,!1),dp=new xe(0,0,!0),lp=xe[t(1758)](-1,2147483647,!1),up=xe[t(1758)](-1,-1,!0),fp=xe[t(1758)](0,-2147483648,!1);var en=(function(a){let n=t,s=(n(1292)+n(779))[n(485)]("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[e[n(1121)]]=5003]=n(526)+n(349)+"R";continue;case"1":a[a[e[n(532)]]=5005]=e[n(532)];continue;case"2":a[a[e[n(864)]]=5002]=e[n(864)];continue;case"3":a[a[e[n(314)]]=5001]=n(503)+n(1448);continue;case"4":a[a[e[n(1125)]]=5004]=e[n(1125)];continue;case"5":return a}break}})({});class Qn{constructor(n){let s=t;this[s(519)]=n,this[s(1183)]=null}}class $d extends Qn{constructor(n,s){let d=t;super(n),this[d(560)]=s&&s.message||null}}class Vd extends Qn{constructor(n,s){let d=t;if(e.OnRJu(e[d(285)],e[d(1396)])){let f=(d(1324)+d(511))[d(485)]("|"),h=0;for(;;){switch(f[h++]){case"0":this[d(267)]=s&&s[d(267)]||0;continue;case"1":super(n);continue;case"2":this[d(1786)]=s&&s[d(1786)]||null;continue;case"3":this[d(635)]=s&&s[d(635)]||0;continue;case"4":this[d(560)]=s&&s[d(560)]||"";continue;case"5":this[d(345)]=s&&s.filename||"";continue;case"6":this[d(363)]=s&&s[d(363)]||5001;continue}break}}else throw this[d(424)+d(395)]=!1,_0x59ee87}}class Jd extends Qn{constructor(n,s){let d=t,f={nvwix:function(h,m){return e.LIFJf(h,m)},WUOkG:function(h,m){return h<<m},jixTk:function(h,m){return e[U(1540)](h,m)},grdBE:function(h,m){return h&m},jALhB:function(h,m){return e.RfDOt(h,m)},WUljC:function(h,m){return e[U(1832)](h,m)},ZGbUy:function(h,m){return e[U(1792)](h,m)},ckjWv:function(h,m){return e[U(969)](h,m)}};if(e[d(1082)](d(1644),e[d(922)])){let h=f.nvwix(f[d(1353)](f.WUOkG(f[d(464)](7,_0x56c665),18)|f[d(1691)](63,_0x410f91[_0x4cc9c2++])<<12,f[d(1338)](f[d(464)](63,_0x4ae254[_0x407c46++]),6)),f[d(1229)](63,_0xc0c0c9[_0x4355e7++]))-65536;_0x511025+=_0x412978[d(1507)+"Code"](55296+f[d(1541)](h,10)),_0x5b6364+=_0x483ec9[d(1507)+"Code"](f[d(566)](56320,1023&h))}else{let h=(d(615)+"2").split("|"),m=0;for(;;){switch(h[m++]){case"0":super(n);continue;case"1":this[d(481)]=s&&s[d(481)]||"";continue;case"2":this[d(493)+d(1223)]=s&&s.willReconnect||!1;continue;case"3":this[d(551)]=s&&s[d(551)]||!1;continue;case"4":this[d(363)]=s&&s[d(363)]||0;continue}break}}}}class Zd extends Qn{constructor(n,s){let d=t;super(n),this[d(1283)]=s&&s[d(1283)]||null}}class Yd extends Zd{constructor(n,s){let d=t;super(n),this[d(1283)]=s&&s[d(1283)]||null,this[d(560)]=s&&s[d(560)]||null}}class Xd extends Qn{constructor(n,s){let d=t;super(n),this[d(1283)]=s&&s.data||null}}function at(a,{message:n,code:s,error:d}){return new Vd(a,{message:n,code:s,error:d})}function xt(a,{code:n,reason:s,wasClean:d,willReconnect:f}){return new Jd(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function Qd(a,{data:n,message:s}){let d=t,f={eHVtT:"online",qUXuh:e[d(1769)]};if(e.DifwT===e[d(1044)])this[d(353)+"er"]&&_0x3ebce2[d(1785)+"entListener"](f[d(782)],this[d(1480)+d(1331)]),this[d(353)+"er"]&&_0x39c3aa[d(1785)+d(518)+d(663)](f[d(1729)],this["_handleO"+d(919)]),this._isBrowser&&_0x3a19af[d(1785)+d(518)+"ner"](d(1745),this[d(1423)+"ageHide"]),this[d(353)+"er"]&&_0x436187[d(1785)+"entListe"+d(663)](d(1011),this[d(1423)+d(1007)]);else return new Yd(a,{data:n,message:s})}function el(a,{data:n}){return new Xd(a,{data:n})}function da(a,{message:n}){return new $d(a,{message:n})}class tl{constructor(n,s){let d=t;e[d(1481)](e[d(1054)],"omfGO")?_0x516f37[d(1843)]["appendCh"+d(450)](_0x34d735):(this[d(1632)+"s"]=n,this[d(1542)+"es"]=s,this.currentIndex=0,this["currentEndpointT"+d(911)+"t"]=0)}[t(1730)+"pointCon"+t(334)](){let n=t;this[n(924)+n(273)]=0,this[n(918)+n(925)+"riesCount"]=0}[t(1838)+"es"](){let n=t;this[n(918)+n(925)+"riesCount"]=0}[t(638)+t(1643)+"nt"](){let n=t,s={hJBqY:function(d,f){return e[U(1486)](d,f)},ddAGL:function(d,f){return d<<f},NnZrO:function(d,f){return e[U(1728)](d,f)},mnord:function(d,f){return e[U(998)](d,f)},QaANo:function(d,f){return e[U(1409)](d,f)}};return e.gEttg(n(632),e[n(1414)])?new _0x4eb65e(iNojpS[n(711)](_0x58ad63[0]|_0x3ff864[1]<<8,iNojpS[n(1530)](_0x13dbdb[2],16))|iNojpS.ddAGL(_0x278982[3],24),iNojpS[n(1501)](iNojpS[n(1617)](iNojpS[n(510)](_0xa49fb9[4],_0x2945b9[5]<<8),iNojpS[n(1530)](_0x37d095[6],16)),_0x2ff847[7]<<24),_0x5adf8c):this[n(1632)+"s"][this[n(924)+n(273)]]}["getCurre"+t(1643)+t(1014)+"ount"](){let n=t;return this[n(918)+n(925)+"riesCount"]}["checkRea"+t(266)+"es"](){let n=t;return!!(e[n(359)](this["currentI"+n(273)],this.endpoints[n(1524)])||this[n(924)+n(273)]===e.cqbRZ(this.endpoints[n(1524)],1)&&e[n(1294)](this[n(918)+"ndpointT"+n(911)+"t"],this.maxRetries))}[t(720)+t(1635)+t(460)+t(268)+t(810)](){let n=t;return e[n(622)](this[n(924)+"ndex"],this[n(1632)+"s"][n(1524)])?!0:e[n(1470)](this[n(918)+n(925)+n(911)+"t"],this[n(1542)+"es"])}["replaceB"+t(800)+t(1716)+"UpdateCo"+t(543)](){let n=t;return this[n(918)+"ndpointT"+n(911)+"t"]=1,this[n(924)+n(273)]++,this.endpoints[this[n(924)+n(273)]]}[t(638)+t(1643)+t(777)+"ateCount"](){let n=t;return this[n(918)+n(925)+"riesCount"]++,this["getCurre"+n(1643)+"nt"]()}}let er=(e[t(435)](e[t(977)],typeof globalThis)&&e.SlSUO("Window",globalThis[t(1747)+t(610)][t(962)])||e.NdXtS(e[t(977)],typeof window)&&e[t(1089)](e[t(820)],window[t(1747)+"tor"].name))&&e[t(751)](e[t(977)],typeof document),Rn=e[t(399)](e[t(977)],typeof globalThis)&&(e[t(494)]===globalThis["construc"+t(610)][t(962)]||e[t(928)]===globalThis[t(1747)+"tor"][t(962)])&&e[t(977)]!=typeof tt,Jr=(e[t(300)](t(1623)+"d",typeof globalThis)&&t(1573)===globalThis[t(1747)+t(610)][t(962)]||e.Iopuj("undefined",typeof globalThis)||e[t(435)](e[t(977)],typeof globalThis)&&!!globalThis[t(1591)+t(1070)])&&e[t(399)](e[t(977)],typeof wx),Zr=typeof globalThis<"u"&&(e.gEttg(e[t(928)],globalThis["construc"+t(610)][t(962)])||e[t(1327)](t(1120)+"rkerGlobalScope",globalThis["construc"+t(610)][t(962)])||e[t(1294)](t(1263)+t(458)+"balScope",globalThis.constructor.name))&&t(1623)+"d"!=typeof self,xp=e[t(914)]("undefined",typeof globalThis)&&e.vQJtC(t(1573),globalThis[t(1747)+t(610)][t(962)])&&e.yRCGe(t(1623)+"d",typeof global)&&e[t(1082)](e[t(494)],global[t(1747)+t(610)][t(962)])&&e.GOfww(e[t(977)],typeof process)&&!!process[t(608)];class la{constructor(){let n=t;this[n(672)+"rs"]={}}[t(845)](n,...s){let d=t,f=this[d(672)+"rs"][n];if(f)f[d(264)]()[d(1300)](h=>h.fn[d(1259)](h[d(1195)],s));else if(e[d(1559)](d(1786),n)&&!this[d(1088)]){if(e.soSBV(e[d(547)],e[d(948)]))return _0x367caa||(_0x37af92=[_0x5b654e[d(1587)+"e"][d(734)],_0x56f8af[d(1587)+"e"][d(1764)],_0x4e8795[d(1587)+"e"].continuePrimaryKey]);{let h=s.length&&s[0];if(h instanceof Error)throw h;let m=new Error(e.FjQjn(e[d(323)],h?e[d(289)](e[d(289)](" (",h.message),")"):""));throw m[d(1533)]=h,h}}return this}[t(284)](n,s){let d=t;if(e.kLzoq(void 0,n))this[d(672)+"rs"]={};else if(e.ZUTgE(void 0,s))this._listeners[n]=null;else{let f=this[d(672)+"rs"][n];if(f)for(let h=0;e[d(1701)](h,f[d(1524)]);)e[d(1690)](f[h].fn,s)?f.splice(h,1):++h}return this}on(n,s,d){let f=t;return(this[f(672)+"rs"][n]||(this._listeners[n]=[]))[f(354)]({fn:s,ctx:d||this}),this}}class hp extends la{_formatErrorMessage(n){let s=t;return n[s(1389)]||n[s(508)]?(s(1561)+" "+(n[s(1389)]||"")+s(1737)+(n[s(508)]||""))[s(405)]():JSON[s(1789)+"y"](n)}constructor(n,s,d){let f=t;super(),this[f(548)]=null,Jr&&wx[f(708)+f(1520)]&&(this[f(548)]=wx[f(708)+f(1520)]({url:n,protocols:s,header:d,fail:this[f(697)+f(1821)+f(1744)][f(636)](this),success:this[f(697)+f(755)+f(1578)+f(1465)][f(636)](this)})),Rn&&tt[f(708)+f(1520)]&&(this[f(548)]=tt[f(708)+"ocket"]({url:n,protocols:s,header:d,fail:this[f(697)+f(1821)+"lHandler"].bind(this),success:this[f(697)+f(755)+f(1578)+"ler"][f(636)](this)}))}[t(697)+"ocketSuc"+t(1578)+t(1465)](){let n=t;e[n(1257)](e.aTcfE,e[n(812)])?(_0x1a34e2[n(1462)](_0x55518a,_0x587ea6),_0x3d2541.set(_0x568106,_0x377c3e)):Promise[n(1380)]()[n(313)](()=>{let s=n;this[s(358)+s(1841)]()})}[t(697)+"ocketFai"+t(1744)](n){let s=t;Promise[s(1380)]()[s(313)](()=>{let d=s,f=at(e[d(1806)],{message:this[d(1467)+d(433)+d(1654)](n)});this[d(845)](e[d(1806)],f);let h=e[d(1434)](xt,e.zVqPJ,{reason:this["_formatErrorMess"+d(1654)](n)});this[d(845)](d(1811),h)})}[t(358)+t(1841)](){let n=t,s={RlNQL:e[n(1306)],pISnF:e[n(1666)],ArTxk:function(d,f,h){return e[n(1629)](d,f,h)},nJQeR:e.fbioT};this[n(548)][n(839)](d=>{let f=n;this.emit(s.RlNQL,el(f(477),{...d,data:d[f(1389)]||""}))}),this._socket[n(442)](d=>{let f=n;this[f(845)](e[f(1249)],e.ZwOLd(xt,e[f(1249)],{...d}))}),this._socket[n(577)+"e"](d=>{let f=n;this[f(845)](s[f(1720)],s[f(1123)](Qd,s[f(1720)],{...d}))}),this[n(548)].onError(d=>{let f=n;this.emit(f(1786),at(s[f(1280)],{...d,message:d.errMsg||""}))})}[t(1118)](n){let s=t,d={wCXbg:function(f,h,m){return f(h,m)},oolME:e[s(1806)],ibMSd:function(f,h){return f(h)}};if(e[s(445)](n,Uint8Array)){let f=n[s(1612)][s(264)](n[s(569)+"et"],n.byteLength+n.byteOffset);this[s(548)]&&this[s(548)][s(1118)]({data:f,fail:h=>{let m=s;this.emit(m(1786),d[m(1408)](at,d.oolME,{message:this[m(1467)+m(433)+"age"](h)}))}})}else this._socket&&this[s(548)][s(1118)]({data:n,fail:f=>{let h=s;e[h(1262)]===e[h(1004)]?(_0x3c11ef=d[h(280)](_0xc13d47,_0x1c3102),_0x249a1d=0):this[h(845)](e[h(1806)],at(e[h(1806)],{message:this[h(1467)+h(433)+"age"](f)}))}})}[t(1811)](n,s){let d=t;this[d(548)]&&this[d(548)][d(1811)]({code:n,reason:s})}[t(469)+t(286)](n,s){this.on(n,s)}[t(1785)+t(518)+t(663)](n,s){this[t(284)](n,s)}get[t(398)+"te"](){return this[t(548)].readyState}get[t(1370)+"pe"](){let n=t;return this[n(548)][n(1370)+"pe"]}set binaryType(n){}get[t(497)](){let n=t;return this[n(548)][n(497)]}get[t(956)](){let n=t,s={Eemqe:e[n(340)],BZWNd:function(d,f){return e.mGAGf(d,f)},uLDvh:function(d,f){return e[n(684)](d,f)},BmidF:function(d,f){return e[n(934)](d,f)},xyQNx:function(d,f){return d<<f},NOgBX:function(d,f){return e[n(1835)](d,f)},DkhiT:function(d,f){return e.qONAL(d,f)},BfPbS:function(d,f){return e.uTCtC(d,f)},VPddI:function(d,f){return e.Mrxpq(d,f)},dwajS:function(d,f){return d<f},RJRGv:function(d,f,h,m){return d(f,h,m)},yxXot:function(d,f){return e[n(604)](d,f)},WRLPZ:function(d,f){return e[n(341)](d,f)}};if(e[n(308)]==="lVwbC"){let d=4294967295;return function(f,h,m=!0){let b=n,g=s.Eemqe.split("|"),v=0;for(;;){switch(g[v++]){case"0":d=s[b(1588)](s[b(853)](d,s[b(559)](15,f[h])<<28),0);continue;case"1":return{value:m?d:0|d,offset:h};case"2":if(f[h++]<128)return{value:m?d:s[b(853)](0,d),offset:h};continue;case"3":d=s.uLDvh(d,s[b(1040)](s.BmidF(127,f[h]),14))>>>0;continue;case"4":d=(d|s[b(559)](127,f[h])<<21)>>>0;continue;case"5":d=s[b(1705)](127,f[h])>>>0;continue;case"6":if(s[b(1055)](f[h++],128))return{value:m?d:s[b(504)](0,d),offset:h};continue;case"7":d=s[b(1357)](d|s.xyQNx(s.NOgBX(127,f[h]),7),0);continue;case"8":if(s[b(726)](f[h++],128))return{value:m?d:0|d,offset:h};continue;case"9":if((h+=5)>f[b(1524)])throw h=f[b(1524)],s.RJRGv(_0x106d41,h,10,f[b(1524)]);continue;case"10":if(s.dwajS(f[h++],128))return{value:m?d:s.yxXot(0,d),offset:h};continue;case"11":if(s.DkhiT(f[h++],128))return{value:m?d:s[b(531)](0,d),offset:h};continue}break}}}else return this[n(548)].protocol}get[t(649)+"ns"](){let n=t,s={ndfBl:function(d,f){return e[U(335)](d,f)},QcIgH:function(d,f){return d+f},dWiJc:e[n(553)],Avveq:function(d,f){return d||f},PVARI:e[n(1228)]};return n(1503)!=="NkAwm"?this[n(548)][n(649)+"ns"]:s[n(1519)](_0x2f2e8e,s[n(1036)](s[n(1036)](s[n(1036)](s[n(1036)](n(1583)+n(275)+"ge: ",_0x224008),s.dWiJc),s[n(1176)](_0x4b9a02,1)),s[n(1284)])+_0x213694)}get[t(554)+t(1445)](){return 0}}function pp(a,n){let s=t;if(n)return new n(a[s(497)],a.protocol);if(Jr||Rn)return new hp(a[s(497)],a.protocol,a[s(296)]);if((er||Zr)&&e.wNKpX!=typeof WebSocket&&WebSocket)return new WebSocket(a.url,a[s(956)+"s"])}function gp(a){let n=t,s="4|3|1|0|2"[n(485)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(e[n(304)](er,Zr)&&e[n(977)]!=typeof WebSocket&&WebSocket)return!0;continue;case"1":if(Rn&&tt[n(708)+"ocket"])return!0;continue;case"2":return!1;case"3":if(Jr&&wx[n(708)+n(1520)])return!0;continue;case"4":if(a)return!0;continue}break}}function nl(a,n,s){let d=-1;async function f(h){let m=U;return e[m(397)](h,d)?Promise[m(1273)](new Error(e[m(1074)])):(d=h,e[m(1024)](h,s.length)?Promise[m(1380)]():s[h][m(636)](a)(n,f[m(636)](null,h+1)))}e.WjdUq(f,0)}function rl(a){let n=t,s=0,d=0;for(let f=0;e[n(1253)](f,a.length);++f)d=a[n(1649)+"At"](f),e[n(650)](d,128)?s+=1:e[n(376)](d,2048)?s+=2:e[n(703)](e[n(890)](64512,d),55296)&&e[n(265)](64512,a[n(1649)+"At"](e[n(1440)](f,1)))===56320?(++f,s+=4):s+=3;return s}function il(a,n,s){let d=t,f={RKaEm:function(h,m){return e[U(764)](h,m)},fNaYf:function(h,m){return e.ZoyPM(h,m)},bnVsq:function(h,m){return e[U(1329)](h,m)},uBcXK:function(h,m){return h+m},pIfGu:function(h,m){return h|m},pOxwR:function(h,m){return e[U(1181)](h,m)},zfmlW:function(h,m){return e[U(1214)](h,m)},uAhos:function(h,m){return e[U(1457)](h,m)},utKhl:function(h,m){return e.LdPnk(h,m)},tNxOj:function(h,m){return h<<m},nDRKZ:function(h,m){return e[U(1440)](h,m)}};if(e[d(639)](e[d(648)],e[d(773)])){let h=new _0x20877e(f[d(1159)](f[d(1287)](f[d(1159)](_0x5d2648[f.bnVsq(_0x64e025,4)]<<24,_0x26826f[f[d(291)](_0x4b2fdb,5)]<<16),_0x3bd309[_0x1a3169+6]<<8),_0x4a6117[_0xed2bd2+7]),f[d(1650)](f[d(1184)](f.zfmlW(f.uAhos(_0x54ba39[f[d(1208)](_0x32edd5,0)],24),f[d(437)](_0x33ce41[f.uBcXK(_0x2e4217,1)],16)),f[d(1494)](_0x12a1dd[f[d(1508)](_0x4c5ef0,2)],8)),_0x3e7255[f[d(291)](_0xddeb86,3)]),!0);return _0x5d7ff7+=8,{value:h,offset:f[d(1208)](_0x1831cf,8)}}else{if(e[d(392)](s,n)<1)return"";let h="";for(let m=n;e.JfsgA(m,s);){let b=a[m++];if(b<=127)h+=String[d(1507)+d(507)](b);else if(b>=192&&e[d(1153)](b,224))h+=String.fromCharCode(e[d(449)](e[d(1267)](e.GNyDT(31,b),6),63&a[m++]));else if(e[d(1171)](b,224)&&e[d(931)](b,240))h+=String[d(1507)+d(507)](e.oCCaD(e[d(1364)](e[d(1109)](15,b)<<12,e.bnFLI(63,a[m++])<<6),63&a[m++]));else if(e[d(359)](b,240)){let g=e[d(392)](e[d(1364)](e[d(341)](e[d(1622)](e.kxrrL(7&b,18),e[d(1216)](e[d(651)](63,a[m++]),12)),e[d(564)](63&a[m++],6)),e.FwjtW(63,a[m++])),65536);h+=String[d(1507)+d(507)](e[d(605)](55296,e[d(538)](g,10))),h+=String[d(1507)+d(507)](56320+e[d(1264)](1023,g))}}return h}}function ua(a,n,s){let d=t,f=s,h,m;for(let b=0;b<a[d(1524)];++b)if(h=a[d(1649)+"At"](b),h<128)n[s++]=h;else if(e.AWjIL(h,2048))n[s++]=e[d(1827)](h>>6,192),n[s++]=e[d(616)](e[d(265)](63,h),128);else if(e[d(1690)](e.DhISS(64512,h),55296)&&e[d(417)](e[d(1659)](64512,m=a.charCodeAt(e[d(1271)](b,1))),56320)){let g=e[d(561)][d(485)]("|"),v=0;for(;;){switch(g[v++]){case"0":n[s++]=e.yLqBN(e[d(567)](h,18),240);continue;case"1":n[s++]=e[d(1083)](e[d(1545)](63,h),128);continue;case"2":++b;continue;case"3":n[s++]=e[d(1804)](e[d(567)](h,6)&63,128);continue;case"4":n[s++]=e[d(369)](e.TYSOg(e[d(1119)](h,12),63),128);continue;case"5":h=e[d(1708)](65536+(e.ARLUN(1023,h)<<10),e[d(1832)](1023,m));continue}break}}else n[s++]=e[d(407)](h>>12,224),n[s++]=e[d(1103)](e.usdmp(h>>6,63),128),n[s++]=e[d(1039)](e.tvUvt(63,h),128);return e[d(1330)](s,f)}async function sl(a){let n=t;if(e[n(1788)](e[n(1557)],typeof a)){let s=new Uint8Array(e[n(1748)](rl,a));return e.PkPAh(ua,a,s,0),s}return e[n(445)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1612)],a[n(569)+"et"],a.byteLength)}function mp(a){let n=t;if(e[n(550)](e[n(1311)],e.lzESh))return null;try{return e[n(399)](e[n(1557)],typeof a)&&(e[n(669)](a,ArrayBuffer)||a[n(1612)]&&e[n(1060)](a[n(1612)],ArrayBuffer))||e[n(1557)]!=typeof a?"":(JSON[n(869)](a),e[n(1422)])}catch{return typeof a=="string"?e[n(1791)]:""}}let wp=(a,n)=>{let s=t;if(e[s(1304)](e.OMNuI,e[s(607)]))switch(a){case e[s(653)]:case e[s(1779)]:return{[s(1721)+a]:1,"x-tt-env":n};default:return{}}else Te[s(926)+"ount"]=_0x2e9759,Te[s(590)]=0};class _p{constructor(n){let s=t;this[s(926)+s(389)]=n,this[s(590)]=0}[t(814)](){let n=t;this[n(590)]++}["checkRea"+t(1566)+"nt"](){let n=t;return e[n(1700)](this[n(590)],this[n(926)+n(389)])}["resetCou"+t(659)](n=0){let s=t;this[s(926)+"ount"]=n,this[s(590)]=0}}async function yp(a){let n=t;if(e[n(1305)]===n(1646))return new Promise(s=>{let d=n,f={hsCDE:function(h,m){return h(m)},HEtTi:e[d(985)]};if(!er)return s(e.bYkAX);try{let h=document[d(544)+d(1029)](d(1600));window[d(1048)+d(413)]=m=>{let b=d;document[b(1843)]["removeCh"+b(450)](h),window[b(1048)+b(413)]=void 0,f[b(1842)](s,m&&m.msg||f[b(1613)])},h.type=e[d(1564)],h.src=e[d(1626)](a.replace(/^ws/,e[d(491)]),e[d(866)]);try{e[d(639)](e[d(743)],e[d(1575)])?this[d(528)]&&this._ws[d(1811)](_0x14a3b1,_0x38cf37):document[d(1843)][d(1368)+"ild"](h)}catch{document[d(1843)][d(1710)+"ild"](h)}}catch{window.frontierJSONP=void 0,e[d(614)](s,e[d(985)])}});_0x393f3c=_0x24e76d[e[n(1271)](e.HqhCK(_0x2c5f96,_0x383008),1)],e[n(754)](e[n(352)](192,_0x146cf9),128)?_0x394372+=_0x324beb:(_0x586cf5=e[n(1235)](e[n(715)](e[n(699)](31,_0xf813a4),6),e[n(876)](63,_0xaf61f0)),e[n(931)](_0x5130f9,128)?_0x2fdee9+=_0x5d13d6:(_0xe27528+=e[n(972)](_0x1d1ce4,_0x3e315f),_0x310519++))}function tn(a,n,s){let d=t,f={nwHcH:function(h,m,b){return h(m,b)}};if(e[d(592)](e.YkBcJ,d(788)))hXepLI[d(1178)](_0x51cb28,_0x4b69ae,58),hXepLI[d(1178)](_0x37e855,_0x7bd136,_0x2340ac);else return!!a?.[d(1433)](h=>h[d(740)]===n&&h[d(1045)]===s)}function tr(a,n){let s=t;return a?.[s(1433)](d=>d[s(740)]===n)?.[s(1045)]}let fa=null;async function Ep(){let a=t;if(e[a(758)](a(979),e[a(1609)]))if(e.SeXOt(_0x323a78.payload,_0x2096c1)){let n=e[a(669)](this[a(1736)][a(1239)+a(1406)],_0x36a662)?{force:!!this[a(1736)]["payloadE"+a(1406)][a(478)],encoding:this._options[a(1239)+"ncoding"][a(527)]?this[a(1736)]["payloadE"+a(1406)][a(527)][a(1299)](/\s/g,"")[a(691)+a(1265)]():""}:{force:!1,encoding:this[a(1736)][a(1239)+a(1406)]?this._options.payloadEncoding[a(1299)](/\s/g,"")[a(691)+a(1265)]():""},s=_0x5021c6[a(1239)+a(1406)]?_0x39ad86[a(1239)+"ncoding"].replace(/\s/g,"")[a(691)+a(1265)]():"",d=e[a(445)](this[a(1736)][a(1001)+"ype"],_0x1cbfc0)?{force:!!this._options[a(1001)+a(874)][a(478)],type:this[a(1736)][a(1001)+a(874)][a(519)]?this[a(1736)][a(1001)+a(874)][a(519)][a(1299)](/\s/g,"")[a(691)+"ase"]():""}:{force:!1,type:this[a(1736)][a(1001)+a(874)]?this[a(1736)][a(1001)+"ype"][a(1299)](/\s/g,"")[a(691)+a(1265)]():""},f=_0x559eee[a(1001)+a(874)]?_0x941a0e[a(1001)+a(874)][a(1299)](/\s/g,"")[a(691)+a(1265)]():"",h=d[a(478)]?d[a(519)]:f||d[a(519)],m=n[a(478)]?n.encoding:s||n[a(527)],b=[e.ouVXJ,e.rJPGQ,e.KfOca,e[a(1557)]],g=[e.isMan,e.LtPtM];this[a(1736)][a(1164)+"ansformT"+a(1013)+"ad"]&&b[a(1037)](h)&&(!m||g[a(1037)](m))?_0x17ab9b["textPayl"+a(1349)]=e[a(1124)](_0xc63190,_0x59b271[a(756)],0,_0x58905d[a(756)][a(1134)+"th"]):_0x1008a2["textPayl"+a(1349)]=""}else _0x462f81[a(980)+a(1349)]="";else return fa||(fa=Promise.resolve()[a(313)](Nt.bind(Nt,e[a(1663)]))),fa}class bp extends la{constructor(n,s){let d=t;super(),this[d(1059)]=n,this[d(1696)]=s,this[d(393)]=void 0,this[d(1141)+"mise"]=null}async[t(288)](){await this[t(1535)]()}async[t(1535)](){let n=t,s={PYmgG:function(d,f){return d>=f},Xxotv:function(d,f){return e.zzxrg(d,f)},bJYjP:function(d,f){return d+f},MZXrD:function(d,f){return d-f},VzMue:function(d,f){return e[U(654)](d,f)},zGMdh:function(d,f){return e[U(707)](d,f)},rJXmg:n(964),IMzhl:"ByIHs",dRlZM:function(d){return e[n(1344)](d)},XQWKj:function(d,f,h,m){return d(f,h,m)}};if(!this._qosDB){if(this[n(1141)+n(1077)])return this[n(1141)+"mise"];try{if(e.vXpFe(e[n(690)],e[n(690)])){let d=this[n(1059)],f=this._keyPath;this[n(1141)+n(1077)]=(async()=>{let h=n,m={fEzdB:function(g,v){return s[U(1553)](g,v)},uXQlK:function(g,v){return s[U(348)](g,v)},lvHrn:function(g,v){return g<v},DMjmJ:function(g,v){return s[U(836)](g,v)},ISHcX:function(g,v){return s.MZXrD(g,v)},acOCb:function(g,v){return s[U(793)](g,v)},rcetq:function(g,v){return s[U(1290)](g,v)},BRViH:function(g,v){return s[U(1290)](g,v)},zzLNy:function(g,v){return g!==v},RSiMF:s[h(1495)],gRbJn:s[h(1743)]},{openDB:b}=await s[h(1719)](Ep);this._qosDB=await s[h(966)](b,"frontier_"+d,1,{upgrade(g){let v=h;if(m.zzLNy(m[v(1026)],m[v(1161)]))g["createOb"+v(1404)+"e"](d,{keyPath:f});else{let D=_0x117b5d.charCodeAt(_0xff013f);qvoIoU[v(1497)](D,55296)&&qvoIoU[v(1547)](D,56319)&&qvoIoU[v(1049)](qvoIoU[v(1281)](_0x448e32,1),_0x42cf46)&&(D=qvoIoU[v(1170)](qvoIoU[v(1281)](qvoIoU[v(1685)](D,10),_0x369a69[v(1649)+"At"](++_0x36560b)),56613888)),_0xdbfd+=qvoIoU[v(1049)](D,128)?1:qvoIoU[v(1740)](D,2048)?2:qvoIoU[v(1282)](D,65536)?3:4}}})})(),await this[n(1141)+"mise"]}else{let d=this[n(393)][n(1346)](this[n(263)]);return _0x5e4abc[n(869)](e.cWcRs(d,"{}"))[_0x3065d1]}}catch(d){console[n(1688)](d)}finally{this[n(1141)+n(1077)]=null}}}async[t(495)](n){let s=t;if(e[s(1670)]("tZFja",e[s(1068)]))_0x2a26a2=e.Dmbed(e[s(1622)](e[s(540)](e[s(587)](15,_0x529d29),12),e[s(283)](e[s(837)](63,_0x8458fa),6)),e[s(982)](63,_0x556f82)),_0x29846d<2048||e[s(1168)](_0x77f1e5,55296)&&e[s(1158)](_0x1f30cc,57343)?_0x12b14e+=_0x2f0692:(_0x347ed8+=e.qmyxD(_0x3d51a0,_0x105718),_0x1793f8+=2);else try{return await this[s(1535)](),this[s(393)]?.[s(495)](this[s(1059)],n)}catch(d){console[s(1688)](d)}}async[t(1462)](n,s){let d=t;return await this[d(1535)](),this[d(393)]?.[d(1543)](this[d(1059)],n)}async[t(1047)](n){let s=t;try{if(e[s(870)](e[s(943)],e[s(1017)])){if(this[s(1638)+s(976)]?.[s(385)+s(266)+"es"]()){let f=this[s(1638)+s(976)]?.[s(638)+"ntEndpoint"]();this[s(1618)+s(539)+s(618)](e[s(1021)](_0x272276,e.zVqPJ,{code:1006,reason:s(1093)+f+(s(1678)+s(1405)+s(1052)+"ached"),wasClean:!0}))}else{let f=this[s(1736)]["reconnectInterce"+s(1714)](_0x31d07e,_0x4bb73a);this[s(1618)+"hCloseEv"+s(618)](e[s(591)](_0x364442,e.zVqPJ,{code:_0x257494,reason:_0x426288,wasClean:!0,willReconnect:f})),f&&this._connect()}return}else return await this[s(1535)](),this[s(393)]?.[s(1289)](this[s(1059)],n)}catch(d){console.log(d)}}async[t(724)](){let n=t;try{return await this._init(),this._qosDB?.[n(724)](this[n(1059)])}catch(s){console[n(1688)](s)}}async keys(){let n=t,s={oKXAt:e[n(1295)]};if(e[n(1266)](e[n(1261)],e[n(1261)]))this["_cursorN"+n(1757)]=_0x433e10,this[n(1081)+n(310)]=_0x1b7057,this[n(430)+n(414)]=_0x199c14,this[n(393)]=_0x361d64(this[n(501)+"ameSpace"],s[n(895)]);else return await this._init(),this[n(393)]?.[n(1787)+"ys"](this[n(1059)])}async[t(1766)](){let n=t;return await this[n(1535)](),this[n(393)]?.[n(1766)](this[n(1059)])}async closeDB(){let n=t,s={dqRmk:function(d,f){return e[U(600)](d,f)},rPFsc:function(d,f){return e[U(657)](d,f)},hhFBm:function(d,f){return e[U(705)](d,f)},rFYad:function(d,f){return e[U(1043)](d,f)},MCwzG:function(d,f){return d>>>f}};try{if(e[n(1232)]("wtrjJ",e.mOFSU)){let d=this[n(388)],f=this[n(1453)];return[d>>>24,d>>>16&255,YtvlAq.dqRmk(YtvlAq[n(287)](d,8),255),YtvlAq[n(525)](255,d),YtvlAq[n(287)](f,24),YtvlAq.hhFBm(YtvlAq[n(585)](f,16),255),YtvlAq[n(396)](f,8)&255,255&f]}else this[n(393)]?.[n(1811)](),this._qosDB=void 0}catch(d){console.log(d)}}get[t(1822)](){let n=t;if(e[n(1814)](e[n(1410)],"ULkHs"))try{return!!this._qosDB}catch(s){return console[n(1688)](s),!1}else e[n(1702)](_0x165f0f,this,_0x4cb9bb,[_0x20d0df,_0x5c8b80,_0x5e69cf])}}class vp{constructor(n,s){let d=t;this[d(811)]=n,this[d(1146)]=s,this[d(393)]=localStorage}async openDB(){}get[t(263)](){let n=t;return n(1048)+"_"+this[n(811)]}async[t(495)](n){let s=t,d=this[s(393)][s(1346)](this._prefix);return JSON.parse(e[s(1761)](d,"{}"))[n]}async set(n,s){let d=t,f=this[d(393)][d(1346)](this[d(263)]),h=JSON.parse(e[d(841)](f,"{}"));return h[s||n[this[d(1146)]]]=n,this[d(393)][d(1419)](this[d(263)],JSON[d(1789)+"y"](h)),s||n[this._pathKey]}async[t(1047)](n){let s=t,d=this._qosDB[s(1346)](this[s(263)]),f=JSON[s(869)](d||"{}");return f[n]=void 0,this._qosDB[s(1419)](this._prefix,JSON.stringify(f))}async[t(724)](){let n=t;return this[n(393)][n(724)]()}async keys(){let n=t,s={BRxxv:function(d,f,h){return e.YKdHh(d,f,h)}};if(e[n(846)](e[n(1826)],n(752))){let d=s.BRxxv(_0x47d453,"reconnect",{message:n(1774)});this[n(1683)+n(945)]&&this[n(1683)+n(945)](d)}else{let d=this._qosDB.getItem(this._prefix),f=JSON.parse(e[n(841)](d,"{}"));return Object.keys(f)}}async[t(1766)](){let n=t,s={khNkt:function(d,f,h){return e[U(735)](d,f,h)}};if(e[n(365)](e[n(302)],n(1727)))TBrYtb[n(1836)](_0x1e4994,_0x4e6d59,66),_0x44be07(_0x3a0c3d,_0x95e851[n(1524)]),TBrYtb[n(1836)](_0x4cd1ff,_0x29cb4,_0x49ec6a);else{let d=this[n(393)][n(1346)](this[n(263)]),f=JSON[n(869)](e[n(1761)](d,"{}"));return Object[n(627)](f)}}[t(1808)](){return Promise.resolve()}get[t(1822)](){return!!this._qosDB}}class Sp{constructor(n,s){let d=t;this._DBName=n,this._pathKey=s,this[d(393)]=Rn?tt:Jr?wx:null}async[t(288)](){}get[t(263)](){let n=t;return n(1048)+"_"+this[n(811)]}async get(n){let s=t,d=this._qosDB[s(950)+"geSync"](this[s(263)]);return JSON.parse(e.hJjeW(d,"{}"))[n]}async[t(1462)](n,s){let d=t;if(e[d(1296)](e[d(1186)],e[d(1186)])){let f=this[d(393)][d(950)+d(261)](this[d(263)]),h=JSON[d(869)](f||"{}");return h[s||n[this[d(1146)]]]=n,this[d(393)][d(1247)+d(261)](this._prefix,JSON[d(1789)+"y"](h)),s||n[this[d(1146)]]}else return(this._listeners[_0x1352ef]||(this._listeners[_0x455b4c]=[]))[d(354)]({fn:_0x534f8c,ctx:_0x191de6||this}),this}async[t(1047)](n){let s=t,d=this._qosDB[s(950)+s(261)](this[s(263)]),f=JSON[s(869)](e[s(658)](d,"{}"));return f[n]=void 0,this[s(393)][s(1247)+"geSync"](this._prefix,JSON[s(1789)+"y"](f))}async[t(724)](){let n=t;if(e[n(1150)](e.WtbSq,e.HLfxe))return this[n(393)][n(1111)+n(910)]();{let s=_0x3b8a11.key;e[n(787)](void 0,s)&&(_0x3894c5(_0x43b16e,10),e[n(305)](_0xe899a5,_0xe0a84e,s));let d=_0x27f44d[n(1045)];d!==void 0&&(_0x13b039(_0x43ef1c,18),e[n(1165)](_0x39f628,_0x46c8c9,d))}}async[t(306)](){let n=t,s=this[n(393)][n(950)+"geInfoSync"](this[n(263)]),d=JSON[n(869)](s||"{}");return Object.keys(d)}async[t(1766)](){let n=t,s=this[n(393)][n(950)+n(1341)+"nc"](this[n(263)]),d=JSON.parse(e[n(1521)](s,"{}"));return Object[n(627)](d)}[t(1808)](){return Promise.resolve()}get[t(1822)](){return!!this._qosDB}}function ol(a,n){let s=t;if(e[s(1559)](e.fTCFL,e[s(1570)])){let{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:h}=this[s(1736)],m=e[s(1315)](d,_0x1e7b75[s(712)](h,e[s(1330)](_0x5d6863,1)));return e[s(1471)](m,f)?f:m}else{if(e[s(1521)](Rn,Rn))return new Sp(a,n);if(e[s(1761)](er,Zr)&&e.GCpty(s(1623)+"d",typeof indexedDB))return new bp(a,n);if(e[s(1761)](er,Zr)&&e[s(435)](e[s(977)],typeof localStorage))return new vp(a,n);throw new Error(e[s(935)])}}class Ip{constructor(){let n=t;this[n(863)+"lTimeoutId"]=null,this[n(863)+"l"]=36e5,this[n(393)]=ol(n(470),e.wKMVA)}async["_interva"+t(847)](){let n=t;e[n(972)](clearInterval,this[n(863)+n(1655)+"Id"]),this[n(863)+"lTimeoutId"]=setInterval(()=>{let s=n;this[s(260)+s(817)]()},this._interval)}async[t(288)](){let n=t;await this[n(393)][n(288)]()[n(313)](()=>{this[n(863)+"lFlush"]()})}async["flushExp"+t(817)](){let n=t,s={IhqBq:e[n(1438)]};if(e.msrkt==="paJKB")(await this[n(393)]?.getAll()||[])[n(634)](({timestamp:h})=>h<Date.now()).forEach(h=>{let m=n;e[m(1025)](e[m(1309)],e[m(524)])?this[m(393)]?.del(h.message_id):(this[m(845)](s[m(1378)],_0x2992dc),this[m(1783)+"eAck"]&&this["onReceiv"+m(1739)](_0xedbb61))});else{if(e.VUYex(_0x180336,_0x303ff2))throw new _0x25aab2(e[n(411)]);let d=3;for(;e[n(1168)](d,0);){let f=255&_0x4332df;_0x2857a2(f,_0x1834c6,_0x461077+d),_0x512498>>>=8,d--}return e[n(1113)](_0x47677b,4)}}async del(n){let s=t;return this._qosDB?.[s(1047)](n)}async[t(1462)](n,s){let d=t;return e[d(730)](e[d(1003)],e.Qtpro)?(this[d(918)+d(925)+d(911)+"t"]=1,this[d(924)+d(273)]++,this.endpoints[this[d(924)+"ndex"]]):this._qosDB?.[d(1462)]({message_id:n,timestamp:s})}async[t(495)](n){let s=t;return this[s(393)]?.[s(495)](n)}async closeDB(){let n=t;e[n(1628)](clearInterval,this[n(863)+n(1655)+"Id"]),await this._qosDB?.closeDB()}get[t(1822)](){let n=t;return this[n(393)]?.[n(1822)]}}function xa(a){let n=t,s=!!this[n(1736)][n(1345)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=tn(a.message.headers,e[n(827)],"2"),f=d&&e.gBzCH(tn,a.message[n(296)],e.aWIlp,"1"),h=d&&e.DqyPG(tn,a.message.headers,n(899)+n(1825)+"k","1"),m=h?tr(a[n(560)][n(296)],e[n(366)])?.split(",")[n(634)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:h,ackMsgIds:m}}async function al(){let a=t;return this[a(766)+a(664)]||(this[a(766)+a(664)]=new Ip),this._QoSManager.isReady||await this[a(766)+a(664)].openDB(),this[a(766)+"ger"]}async function Ap(a,n){let s=t,d={sEKUl:function(g,v,D){return e[U(1506)](g,v,D)},TKxtN:e[s(1249)]},{enableAutoAck:f}=this._options,h=tn(a[s(560)][s(296)],"need_ack","1"),m=e[s(1702)](tn,a[s(560)][s(296)],s(1668),"1"),b=xa[s(307)](this,a);if(e.CFvAT(f,h))if(s(1191)!==e[s(1268)]){let{SeqID:g,LogID:v,service:D,LogIDNew:N,method:H}=a[s(560)];this[s(1274)]({SeqID:g,LogID:v,LogIDNew:N,service:D,method:H,headers:[{key:e.vSXvi,value:"1"},{key:e[s(844)],value:e[s(1521)](N,"")},{key:e[s(1411)],value:"0"}]})}else{let g=this[s(1736)][s(716)+s(1537)+s(1714)](_0x43dac3,_0x9c8f2d);this[s(1618)+s(539)+s(618)](d[s(1684)](_0x55bd2d,d[s(806)],{code:_0x1d96ad,reason:_0x44e3ca,wasClean:!0,willReconnect:g})),g&&this._connect()}m&&!b[s(1362)]&&this["_dispatc"+s(816)+s(825)](a),n()}async function Tp(a,n){let s=t;e.AqDLc(e[s(364)],s(343))?(this[s(528)]&&this._ws.send(_0x113f4a),this[s(932)]("sent",_0x4ea8fc)):(this[s(932)](e[s(1831)],a.message),e[s(1190)](n))}async function Cp(a,n){let s=t,d=Xt(await e[s(855)](sl,a.data));try{if(e.NyNET(e.LiZPQ,"pktHi"))this[s(863)+s(847)]();else if(e.dxXKk(d[s(756)],Uint8Array)){let f=e.ZOeCp(this[s(1736)]["payloadE"+s(1406)],Object)?{force:!!this._options[s(1239)+"ncoding"].force,encoding:this[s(1736)][s(1239)+s(1406)][s(527)]?this._options[s(1239)+s(1406)][s(527)][s(1299)](/\s/g,"")[s(691)+s(1265)]():""}:{force:!1,encoding:this[s(1736)][s(1239)+s(1406)]?this[s(1736)][s(1239)+s(1406)].replace(/\s/g,"")[s(691)+s(1265)]():""},h=d[s(1239)+s(1406)]?d[s(1239)+s(1406)][s(1299)](/\s/g,"")[s(691)+s(1265)]():"",m=e[s(1813)](this._options[s(1001)+s(874)],Object)?{force:!!this._options["payloadT"+s(874)][s(478)],type:this._options[s(1001)+"ype"].type?this._options.payloadType[s(519)][s(1299)](/\s/g,"")[s(691)+s(1265)]():""}:{force:!1,type:this._options[s(1001)+s(874)]?this[s(1736)][s(1001)+s(874)].replace(/\s/g,"")[s(691)+s(1265)]():""},b=d[s(1001)+s(874)]?d[s(1001)+s(874)].replace(/\s/g,"")[s(691)+s(1265)]():"",g=m[s(478)]?m[s(519)]:b||m[s(519)],v=f.force?f[s(527)]:h||f[s(527)],D=[e[s(1791)],e[s(1422)],s(696)+s(1393)+s(329)+s(1117),s(1572)],N=[s(1496)+"e",s(629)];this[s(1736)][s(1164)+s(968)+"extPayload"]&&D[s(1037)](g)&&(!v||N[s(1037)](v))?d[s(980)+"oad"]=e[s(1702)](il,d[s(756)],0,d[s(756)][s(1134)+"th"]):d.textPayload=""}else d["textPayl"+s(1349)]=""}catch(f){d[s(980)+"oad"]="",console[s(1688)](f)}a[s(560)]=d,n()}function Rp(a,n,s){let d={TNyHk:function(g,v){return e[U(278)](g,v)},zneGw:function(g,v){return e[U(421)](g,v)},LdJhi:function(g,v){return e[U(342)](g,v)},WlVjr:function(g,v){return e[U(1697)](g,v)},ejTaH:function(g,v){return e[U(1712)](g,v)},KYehp:function(g,v){return e[U(682)](g,v)}},f=s||8192,h=e.NbjTL(f,1),m=null,b=f;return function(g){let v=U;if(d[v(374)](g,1)||d[v(542)](g,h))return d[v(1469)](a,g);d[v(542)](b+g,f)&&(m=d[v(1469)](a,f),b=0);let D=n[v(307)](m,b,b+=g);return d[v(382)](7,b)&&(b=d[v(959)](d[v(1132)](7,b),1)),D}}let kp=4294967295;function Dp(a,n,s){let d=t;return e.gEORo(RangeError,e[d(1189)](e.ysvwE(e[d(1820)](e[d(1484)]("index out of ran"+d(1398)+a,e[d(553)]),n||1),d(1076)),s))}function Pp(a,n,s){let d=t;if(e.RmxVy(s,kp))throw new Error(e[d(411)]);let f=3;for(;f>=0;){let h=255&s;pa(h,a,n+f),s>>>=8,f--}return e[d(533)](n,4)}function Op(a,n){let s=t,d=0,f=n,h=e[s(1479)](n,4);for(;f<h;){let{value:m,offset:b}=e[s(1629)](ha,a,f);f=b,d=e[s(624)](e[s(630)](d,8),0),d+=m}return{value:d,offset:h}}function Lp(a,n,s){let d=t;return e[d(862)]===d(1058)?_0x3c0cdf?this[d(1365)+"E"]():this.toBytesBE():a?a[d(1524)]<40?e[d(1538)](ua,a,n,s)+s:n.utf8Write?e[d(1829)](n.utf8Write(a,s),s):n[d(1522)]?e[d(1712)](n.write(a,s),s):e[d(571)](ua(a,n,s),s):s}function Np(a,n){let s=t,d=new xe(e.JShGh(e.vddCy(e[s(859)](a[e[s(1006)](n,4)],24),e[s(418)](a[e.dkyVL(n,5)],16)),e[s(383)](a[e[s(609)](n,6)],8))|a[n+7],e.jWbbT(e[s(515)](e[s(341)](e.SfSbf(a[e[s(533)](n,0)],24),e[s(564)](a[e.dItbP(n,1)],16)),e[s(1027)](a[e[s(419)](n,2)],8)),a[e[s(858)](n,3)]),!0);return n+=8,{value:d,offset:e[s(1585)](n,8)}}function Mp(a,n,s){let d=t,f=a[d(1453)],h=a[d(388)];return n[s]=h>>>24,n[e[d(571)](s,1)]=e[d(699)](e.hsyMa(h,16),255),n[e.lYEcM(s,2)]=e[d(303)](e[d(1734)](h,8),255),n[e.ECNVC(s,3)]=255&h,n[e[d(1110)](s,4)]=e[d(1078)](f,24),n[e[d(1829)](s,5)]=e.tvUvt(f>>>16,255),n[e[d(1329)](s,6)]=e[d(1160)](f>>>8,255),n[e[d(1352)](s,7)]=255&f,s+=8,s}function ha(a,n){let s=t;return a.readUInt8?{value:a.readUInt8(n),offset:e[s(602)](n,1)}:{value:e.BRLmA(255,a[n]),offset:n+1}}function pa(a,n,s){let d=t;return n[d(281)+"t8"]?n[d(281)+"t8"](a,s):n[s]=e[d(1540)](255,a),e[d(1277)](s,1)}let Bp=function(a){return new Uint8Array(a)},Fp=e.GCpty(e[t(977)],typeof Buffer)?Buffer["allocUns"+t(1527)]:e.wbxnD(Rp,Bp,Uint8Array.prototype.subarray);(()=>{let a=t,n={bhbJY:function(d,f){return e[U(1628)](d,f)},KCOhx:e[a(985)],uAGkO:function(d,f){return d>>>f},BJtoq:function(d,f){return e[a(1240)](d,f)},FFqyb:function(d,f){return e[a(1701)](d,f)},gCJgR:function(d,f){return e[a(660)](d,f)},baGbX:function(d,f){return e[a(670)](d,f)},bkVtB:function(d,f){return d<<f},PfwlB:function(d,f){return e[a(282)](d,f)},UYKIn:function(d,f){return d>>>f},SEBCz:function(d,f){return d|f},Ijovw:function(d,f){return e.hijMo(d,f)},ktDTG:function(d,f){return e[a(1681)](d,f)},FvVEi:function(d,f){return e[a(426)](d,f)},sVNds:function(d,f){return e[a(641)](d,f)},wKxDl:function(d,f){return e.Ycjsx(d,f)},RYbgi:function(d,f){return e.RCLqc(d,f)},JwhmU:function(d,f){return d===f},UxHOh:a(1680),hzjwX:function(d,f,h,m){return e[a(1334)](d,f,h,m)}},s=4294967295;return function(d,f,h=!0){let m=a;if(s=n[m(537)](n[m(692)](127,d[f]),0),n[m(1698)](d[f++],128))return{value:h?s:0|s,offset:f};if(s=n[m(1738)](n.baGbX(s,n[m(1131)](n[m(692)](127,d[f]),7)),0),n[m(1733)](d[f++],128))return{value:h?s:n.baGbX(0,s),offset:f};if(s=n.UYKIn(n[m(1640)](s,n[m(692)](127,d[f])<<14),0),d[f++]<128)return{value:h?s:n[m(1499)](0,s),offset:f};if(s=n[m(1056)](s,n[m(1099)](n[m(692)](127,d[f]),21))>>>0,n[m(1733)](d[f++],128))return{value:h?s:0|s,offset:f};if(s=n[m(537)](s|n[m(1750)](15&d[f],28),0),n[m(801)](d[f++],128))return{value:h?s:n[m(1034)](0,s),offset:f};if(n[m(665)](f+=5,d[m(1524)]))if(n.JwhmU("HxrlF",n[m(923)]))_0x28846e[m(1843)][m(1710)+m(450)](_0x5ac795),_0x4703d8["frontier"+m(413)]=void 0,tqSGhZ[m(465)](_0x23d179,_0x45d674&&_0x218088[m(762)]||tqSGhZ[m(894)]);else throw f=d[m(1524)],n[m(1755)](Dp,f,10,d[m(1524)]);return{value:h?s:0|s,offset:f}}})();let zp=16,ga=32;function Up(a){let n=t,s=0,d={};for(let f=0;f<a.length;f++)d[a[f]["cursor_n"+n(981)]]=e.pplPc(rl,a[f][n(1302)+"ame"]),s+=14+d[a[f][n(1302)+n(981)]];return[s,d]}function cl(a,n,s){let d=t;if(e[d(1304)](e[d(1672)],e[d(1672)])){let[f,h]=e[d(335)](Up,a),m=Fp(f),b=0;return a[d(1300)](g=>{let v=d,D=e.DUXyJ[v(485)]("|"),N=0;for(;;){switch(D[N++]){case"0":b=pa(0,m,b);continue;case"1":console[v(1688)](e[v(1046)],b);continue;case"2":b=e.bzKRr(Lp,g["cursor_n"+v(981)],m,b);continue;case"3":b=pa(h[g[v(1302)+v(981)]],m,b);continue;case"4":console[v(1688)]("curvalue",b);continue;case"5":b=Pp(m,b,g.service||0);continue;case"6":b=e.gBzCH(Mp,xe[v(297)+"er"](g[v(1645)]||n),m,b);continue;case"7":console.log(v(746)+"ervice",g,g[v(315)]);continue;case"8":console[v(1688)](e.roqIX,b);continue;case"9":console.log(e[v(1144)],b);continue;case"10":console.log(v(315),b);continue}break}}),{frameType:ga,headers:[{key:e[d(1005)],value:s}],payload:m}}else _0xb6fafe(_0x28e2ae,50),_0x48e083(_0x1752f7,_0x2a61b9)}function qp(a){let n=t,s=0,d=[];for(;e[n(555)](s,a.byteLength);){let{offset:f}=e[n(1667)](ha,a,s);s=f;let h={cursor_name:"",cursor:0,service:0},{value:m,offset:b}=Op(a,s);h[n(315)]=m,s=b;let{value:g,offset:v}=e.pNTzN(ha,a,s);s=v,h[n(1302)+n(981)]=e[n(1702)](il,a,s,e.ZpfDW(s,g)),s+=g;let{value:D,offset:N}=Np(a,s);h[n(1645)]=D[n(1639)](),s=N,d[n(354)](h)}return d}function Gp(){return{frameType:ga,headers:[{key:e.NhANO,value:e.ifRcx}],payload:void 0}}class Hp{constructor(n,s,d){let f=t;if(e[f(1487)](f(1366),f(1366))){let h=this._qosDB.getItem(this[f(263)]),m=_0x2ede98[f(869)](h||"{}");return m[_0x30ebac]=void 0,this[f(393)][f(1419)](this[f(263)],_0x441bc2[f(1789)+"y"](m))}else this["_cursorN"+f(1757)]=n,this[f(1081)+f(310)]=s,this[f(430)+"Strategy"]=d,this[f(393)]=e.bdiWn(ol,this[f(501)+"ameSpace"],"cursor_name")}async[t(288)](){let n=t;await this[n(393)][n(288)]()}async getCursors(){let n=t;if(!this._qosDB[n(1822)])return;let s=this[n(430)+n(414)],d=await this[n(393)][n(1766)]();switch(console[n(1688)](n(333)+n(893),d),s){case e[n(1057)]:return d&&d[n(1524)]?cl(d,0,this["_cursorF"+n(310)]):void 0;case e.whlzG:return;case e[n(1383)]:return d&&d[n(1524)]?e[n(674)](cl,d,0,this[n(1081)+"ileName"]):e[n(722)](Gp)}}async[t(1462)](n,s,d){let f=t;return console[f(1688)]("setdb",n,s,d),this[f(393)].set({cursor_name:n,cursor:s,service:d})}async setCursors(n){let s=t,d=qp(n);for(let f of d)console[s(1688)](s(459)+"r",d),await this._qosDB.set(f)}async[t(495)](n){let s=t;return(await this[s(393)].get(n))?.[s(1645)]}async[t(1808)](){let n=t;if(e[n(867)](e[n(1726)],e[n(1759)]))await this[n(393)][n(1808)]();else{let s=_0x4a2443.split(/\./)[n(992)](h=>_0x483dd6(h)),d=[];return d[0]=e[n(549)](_0x3da8be,e[n(1359)](s[0],s[1])),d[1]=e[n(1316)](_0xfec9ab,e[n(1500)](s[2],s[3])),[n(1648),e[n(1450)],e[n(1450)],n(1648),n(1648),e[n(580)],d[0],d[1]][n(939)]("")}}[t(745)+"rsorFile"+t(1203)](n){let s=t;this[s(1081)+s(310)]=n}get isReady(){return this._qosDB.isReady}}let jp=e.TYBDJ;async function dl(a){let n=t,s={cbNmC:function(b,g){return e.gxuzE(b,g)},HJRIE:e[n(1724)],wNEwG:function(b){return e.iCsor(b)}};if(!this._options[n(1345)+"S"])return null;let{aID:d,fpID:f,messageStrategy:h}=this._options,m=a||jp;try{if(this[n(1258)+n(1127)]){if(e.rqcZJ(e[n(1473)],e[n(1490)]))return e[n(1665)](_0x2832ef,e[n(1616)](_0x28a681,_0x3632a4));a&&this[n(1258)+"anager"][n(745)+n(298)+n(1203)](a)}else this[n(1258)+n(1127)]=new Hp(f+"_"+d+"_"+m,m,h);return this["_cursorM"+n(1127)][n(1822)]||await this["_cursorM"+n(1127)][n(288)](),this["_cursorM"+n(1127)]}catch{if(e[n(1298)](e.Qosbv,n(1097)))return null;ugddOY[n(1796)](_0x1b100a,_0x4b4686.error||new _0x4e0ec4(ugddOY.HJRIE,ugddOY.HJRIE)),ugddOY[n(1442)](_0x1ed32f)}}async function Wp(a,n){let s=t,d=e[s(1441)](tn,a.message[s(296)],e[s(1677)],"-1"),f=e[s(1198)](tn,a.message[s(296)],e.vSXvi,"1"),h=tr(a[s(560)][s(296)],s(899)+s(1002)),m=e[s(662)](Number,e.jXzAx(tr,a[s(560)][s(296)],e[s(1605)]))||0,b=xa[s(307)](this,a),g=tn(a.message[s(296)],e.sQfLb,"2"),v=e[s(436)](tr,a[s(560)][s(296)],e.EeOwv),D=Number(e[s(1782)](tr,a[s(560)][s(296)],e[s(891)]));if(b[s(1362)])return n();let N=b[s(466)+s(656)]?await al[s(307)](this):null;if(e[s(1577)](a[s(560)][s(315)],0)&&f&&!d||e[s(502)](a[s(560)].service,0)){if(h&&b["isQoSMes"+s(656)]&&N)return!!!await N[s(495)](h)&&(this[s(1618)+s(1425)+"Event"](a),await N[s(1462)](h,e[s(840)](Date.now(),m))),n();if(g){let H=await dl.call(this);if(!H)return this[s(1618)+s(1425)+s(1382)](a),e[s(1514)](n);let J=await H[s(495)](v)??-1;if(e.KQMGS(J,D))this[s(1618)+"hMessage"+s(1382)](a),H[s(1462)](v,D,a.message[s(315)]);else throw new Error(s(499)+s(1323)+s(1174)+D+(s(786)+s(1010)+s(1763)+"r ")+J);return e[s(722)](n)}return this["_dispatchMessage"+s(1382)](a),e[s(871)](n)}}async function Kp(a,n){let s=t,d=xa[s(307)](this,a);if(!d["isQoSMes"+s(656)])return e[s(368)](n);let f=await al[s(307)](this);if(d["isAckCle"+s(500)+s(1654)]&&d.ackMsgIds[s(1524)])for(let h of d.ackMsgIds)await f[s(1047)](h);e[s(368)](n)}async function $p(a,n){let s=t,d=e[s(1399)](a[s(560)].frameType,zp),f=e[s(626)](a[s(560)][s(1145)+"e"],ga);if(!d&&!f)return e.pNxoT(n);let h=tr(a[s(560)][s(296)],e[s(1005)]);if(!h)return e.jqqwe(n);let m=await dl[s(307)](this,h);if(!m)return e.jTYdk(n);if(d){let b=await m[s(1451)+"rs"](),g={frameType:b?.[s(1145)+"e"],SeqID:xe[s(297)+"er"](this[s(1351)]++),LogID:xe[s(297)+"er"](this[s(1736)][s(1151)+"erator"]()),service:9e3,method:5,headers:b?.[s(296)],payload:b?.[s(756)]},v=e[s(1136)](I,g);this[s(528)]&&this[s(528)].readyState&&this[s(528)][s(1118)](v)}if(f){let b=a.message[s(756)];b&&m[s(1833)+"rs"](b)}}let Vp=async function(a,n){let s=t;this[s(848)]=!1,e[s(1320)](clearTimeout,this[s(424)+s(1725)+s(1589)]),e[s(356)](n)},Jp=async function(a,n){let s=t;if(!this[s(528)]||e.aYowp(this[s(528)][s(398)+"te"],this[s(1517)]))return e[s(401)](n);let{pingInterval:d}=this[s(1736)];this[s(1638)+s(976)]?.[s(1730)+"pointCon"+s(334)]();for(let h=0;e[s(861)](h,this["_message"+s(1512)].length);h++){let m=this[s(430)+s(1512)][h];if(this[s(528)][s(398)+"te"]===this[s(1517)]&&e.hqXkm(null,m))this[s(528)]&&this[s(528)][s(1118)](m),this[s(430)+"Queue"][h]=null;else break}this[s(430)+s(1512)]=this[s(430)+"Queue"].filter(h=>!!h),this[s(898)+s(1753)+"Id"]=e.arIpJ(setTimeout,()=>this._ping(),d),this[s(1618)+s(973)+"nt"](a),this[s(353)+"er"]&&this[s(528)]&&(this[s(528)][s(1370)+"pe"]=this[s(1633)+s(874)]);let f=this[s(1638)+s(976)]?.[s(638)+"ntEndpoint"]();this[s(932)]("open "+f+s(1139)),e[s(1732)](n)},Zp=async function(a,n){let s=t,d=this[s(1638)+s(976)]?.[s(638)+"ntEndpoint"]();this[s(932)]("open "+d),e[s(401)](n)};class Yp extends la{constructor(n){let s=t,d={TZTkE:function(b,g,v,D){return e.PkPAh(b,g,v,D)},Rxzew:s(1786),KsJvH:function(b,g){return b||g},zWtFw:function(b,g){return e[s(622)](b,g)},BBAkm:s(1572),AvJVZ:function(b,g){return e[s(1642)](b,g)},TWhJm:function(b,g,v){return b(g,v)},wpSWV:s(1020),vbkTI:s(293)};super(),this[s(736)+s(1231)+s(1187)]=!0,this[s(353)+"er"]=er,this[s(1293)]=xp,this._isMiniTT=Rn,this[s(655)+"X"]=Jr,this[s(1463)+"r"]=Zr,this._messageQueue=[],this["_endpoin"+s(976)]=null,this["_readyCl"+s(988)]=!1,this[s(1633)+s(874)]=s(1197)+"fer",this[s(424)+s(395)]=!1,this[s(424)+"ionTimeo"+s(1589)]=null,this["_reconne"+s(902)+s(1749)]=null,this[s(898)+s(1753)+"Id"]=null,this[s(1351)]=0,this[s(848)]=!1,this._url="",this[s(766)+s(664)]=null,this["_cursorM"+s(1127)]=null,this[s(270)+"sCounter"]=null,this[s(620)+"ls"]=e[s(492)],this.CLOSED=3,this[s(412)+"NG"]=0,this[s(1517)]=1,this[s(1386)]=2,this[s(880)]=b=>{let g=s;try{d[g(1196)](nl,this,b,[Vp,Jp,Zp])}catch(v){let D=at(d[g(1430)],{message:v[g(560)],code:en[g(1053)+"OR"],error:v});this[g(1618)+"hErrorEv"+g(618)](D)}},this._onMessage=async b=>{let g=s,{pingInterval:v,pingFrequency:D}=this[g(1736)];if((e.UmAyS("hi",b[g(1283)])&&e[g(1242)]===D||e[g(1363)]===D)&&(this._clearPingTimer(),this[g(845)](e[g(1772)],e[g(1218)]),this[g(898)+g(1753)+"Id"]=e[g(1269)](setTimeout,this._ping[g(636)](this),v)),!e[g(1571)]("hi",b.data))try{e[g(534)](nl,this,b,[Cp,Ap,Kp,$p,Wp,Tp])}catch(N){let H=e[g(596)](at,e.fbioT,{message:N[g(560)],code:en[g(1392)+"ERROR"],error:N});this["_dispatc"+g(701)+g(618)](H)}},this[s(897)]=b=>{let g=s;if(e[g(909)](e[g(1461)],e[g(597)])){let{url:v}=d[g(1815)](_0x265789,{}),D=_0x13c82d.isArray(v)?v:d.zWtFw(d.BBAkm,typeof v)?[v]:[];_0x35f1dc&&_0x353e72[g(1241)](this[g(1736)],_0x2f3c1e),D&&D.length?this[g(1638)+g(976)]=new _0xb7ed2e(D,this._options.maxRetries):this[g(1638)+g(976)]?.[g(1730)+g(621)+g(334)](),this[g(270)+"sCounter"]?.resetCounter(this[g(1736)]["pingLoss"+g(833)]),this["_readyCl"+g(988)]=!1,this[g(528)]&&d[g(1429)](this._ws[g(398)+"te"],this[g(954)])?this[g(1291)+g(951)](1e3,g(1031)+g(945)+g(498),!0):(this[g(848)]=!0,this[g(424)]())}else{let v=this[g(1638)+g(976)]?.[g(385)+"chMaxTries"](),D=this[g(1638)+g(976)]?.["getCurre"+g(1643)+"nt"]();if(v&&!b[g(560)]){let N=g(1093)+D+(" fail, m"+g(593)+g(578)+"ed");this[g(1618)+g(701)+g(618)](at(e[g(1806)],{message:N,code:en[g(526)+g(349)+"R"],error:b}));return}this._ws&&e[g(1534)](this[g(528)][g(398)+"te"],this.OPEN)&&this._disconnect(),this[g(1618)+"hErrorEv"+g(618)](e[g(946)](at,e.fbioT,{message:b[g(560)],code:en[g(503)+"RROR"],error:b}))}},this[s(277)]=async b=>{let g=s,v={XSJoW:e[g(1468)],AwCJe:e[g(1806)],gEqjI:e[g(1724)],UiToP:function(N){return e[g(871)](N)},OWisp:e.LMyqm};this[g(1510)+g(1767)](),this[g(949)+g(913)](),this[g(1152)+"sListeners"](),this._ws=null,this[g(424)+"Lock"]=!1;let D=this[g(1638)+g(976)]?.[g(385)+g(266)+"es"]();if(!D&&this[g(1602)+"orOnline"]()&&!this[g(1206)+g(988)])if(e[g(362)](e[g(575)],e.OHuVe)){let N=this[g(1638)+g(976)]?.[g(638)+g(1643)+"nt"](),H=this[g(1736)][g(716)+g(1537)+"ptor"](b[g(363)],b[g(481)]);this[g(1618)+"hCloseEv"+g(618)](e[g(1279)](xt,e[g(1249)],{code:1006,reason:b[g(481)]||g(1776)+"ng failed, unkno"+g(1342)+g(1582)+"ame: "+N,willReconnect:H})),H&&this._connect();return}else{let N={Ozrgr:iBScDU[g(1608)],gMtMl:function(Q){let ge=g;return iBScDU[ge(1596)](Q)}},H=()=>{let Q=g;_0x430b7b[Q(1785)+Q(518)+Q(663)](iBScDU[Q(1339)],J),_0x1f5baf[Q(1785)+"entListe"+Q(663)](iBScDU.AwCJe,X),_0x5b5174["removeEv"+Q(518)+Q(663)](Q(293),X)},J=()=>{_0x56f9de(),H()},X=()=>{let Q=g;_0x23ba74(_0x14f59b[Q(1786)]||new _0x369792(N.Ozrgr,N.Ozrgr)),N[Q(294)](H)};_0x461c55[g(469)+"Listener"](iBScDU[g(1339)],J),_0x51a63b[g(469)+g(286)](iBScDU[g(1593)],X),_0x11c576["addEvent"+g(286)](iBScDU[g(1092)],X)}if(b[g(363)]!==1e3&&this[g(1206)+g(988)]){this[g(1618)+g(539)+g(618)](e.YKdHh(xt,e.zVqPJ,{code:1e3,reason:g(1662)})),this[g(1638)+"tManager"]?.[g(1730)+g(621)+g(334)](),this[g(270)+g(579)]?.["resetCou"+g(659)]();return}if(e[g(768)](1e3,b[g(363)])&&D){let N=this._endpointManager?.[g(638)+g(1643)+"nt"](),H=b[g(481)];H||(H=await e[g(1130)](yp,this[g(1094)])),H=g(1776)+g(1711)+g(463)+H+(g(1707)+g(1251))+N+(g(1405)+"tries reached"),this[g(1618)+"hCloseEvent"](e[g(440)](xt,g(1811),{code:b[g(363)],reason:H}));let J=g(1093)+N+(g(474)+g(593)+g(578)+"ed");this[g(1618)+g(701)+g(618)](e[g(305)](at,e.fbioT,{message:J,code:en[g(526)+"IES_ERROR"]})),this[g(1638)+g(976)]?.[g(1730)+g(621)+"fig"](),this[g(270)+g(579)]?.[g(683)+g(659)]();return}if(b[g(363)]!==1e3&&!b[g(481)])if(e.HqNNr===e[g(1133)]){let N=this._endpointManager?.[g(638)+g(1643)+"nt"]();this[g(1618)+g(539)+g(618)](e[g(488)](xt,e[g(1249)],{code:b[g(363)],reason:"connecti"+g(1711)+"d, unkno"+g(1342)+"n, hostname: "+N})),this["_endpoin"+g(976)]?.[g(1730)+"pointCon"+g(334)](),this[g(270)+g(579)]?.["resetCou"+g(659)]();return}else FVaqLp[g(1194)](_0x6d3ec7,_0x2b2fef,8),FVaqLp[g(1194)](_0x718d10,_0x2c3b5b,_0x1dce8e);this["_dispatc"+g(539)+g(618)](b),this[g(1638)+g(976)]?.[g(1730)+g(621)+g(334)](),this[g(270)+g(579)]?.[g(683)+"nter"]()},this[s(1254)]=null,this[s(1088)]=null,this.onmessage=null,this[s(476)]=null,this[s(1683)+"econnect"]=null,this[s(1783)+s(1739)]=null,this[s(868)+s(1128)+s(1032)+"ct"]=null,this[s(1480)+"nLine"]=this["_handleO"+s(1331)].bind(this),this[s(1480)+s(919)]=this[s(1480)+s(919)].bind(this),this[s(1423)+s(330)]=this[s(1423)+"ageHide"][s(636)](this),this[s(1423)+s(1007)]=this[s(1423)+s(1007)][s(636)](this),this[s(1736)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(719)](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:s(1148),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(1383)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:h}=n,m=Array[s(1416)](f)?f:e[s(1775)](s(1572),typeof f)?[f]:[];if(!m||e[s(1296)](0,m[s(1524)]))throw new Error(s(875)+s(375)+"alid url");if(!e[s(1478)](gp,h))throw new Error(e.YdJgJ);if(Object.assign(this[s(1736)],n),this["_endpoin"+s(976)]=new tl(m,this[s(1736)].maxRetries),this[s(270)+"sCounter"]=new _p(this[s(1736)]["pingLoss"+s(833)]),this[s(1736)][s(921)+s(1395)])if(e.hSojn(s(1213),e.pozHg))this[s(848)]=!0,this[s(424)]();else{if(_0x650a05)return new _0x56fb67(_0x5e42f0[s(497)],_0x4afaee[s(956)]);if(_0x94dc55||_0x415faf)return new _0x37c857(_0x2bc2f7[s(497)],_0x64ac23[s(956)],_0x39ae54[s(296)]);if((_0x17cb41||_0xc89cbb)&&e[s(435)](e[s(977)],typeof _0x121ad3)&&_0x592aa5)return new _0x467563(_0x2c34ca[s(497)],_0x58ee59[s(956)+"s"])}this[s(1736)][s(1576)+s(1790)+s(1182)]&&(e[s(1030)]!==e[s(1630)]?this[s(896)+"T"]||this[s(655)+"X"]?this["_onPageNetWorkCh"+s(1015)]():this[s(353)+"er"]&&this[s(1652)+s(1086)+s(286)]():(_0x41ca6c["removeEv"+s(518)+s(663)](FVaqLp[s(522)],_0x587eb3),_0x1cc66f[s(1785)+s(518)+s(663)](FVaqLp[s(1430)],_0x4eee2a),_0x512a04["removeEv"+s(518)+s(663)](FVaqLp.vbkTI,_0x4b0bb1)))}[t(1480)+"nLine"](){let n=t;this._options[n(1493)+"utoReconnect"]||this[n(1206)+n(988)]||this[n(1550)+n(945)]()}["_handleO"+t(919)](){let n=t;this[n(1381)+"WebSocket"]();let s=e[n(617)](da,e[n(1360)],{message:e.Xgskg});this[n(868)+"mediatel"+n(1032)+"ct"]&&this[n(868)+n(1128)+n(1032)+"ct"](s)}[t(1652)+t(1086)+"Listener"](){let n=t;if(e[n(1220)]!==e.JSeeh)this[n(353)+"er"]&&window[n(469)+"Listener"](e[n(823)],this[n(1480)+n(1331)]),this[n(353)+"er"]&&window["addEvent"+n(286)](n(904),this["_handleO"+n(919)]),this[n(353)+"er"]&&window[n(469)+n(286)](n(1745),this._handlePageHide),this._isBrowser&&window["addEvent"+n(286)]("pageshow",this[n(1423)+n(1007)]);else return _0x597ffa.offset>=_0x173b6c[n(523)]}[t(1114)+t(1086)+"Listener"](){let n=t;this[n(353)+"er"]&&window[n(1785)+n(518)+"ner"](e[n(823)],this._handleOnLine),this[n(353)+"er"]&&window[n(1785)+n(518)+n(663)](e.VyUkk,this["_handleO"+n(919)]),this[n(353)+"er"]&&window[n(1785)+n(518)+"ner"](e[n(1156)],this["_handleP"+n(330)]),this[n(353)+"er"]&&window[n(1785)+n(518)+n(663)](e[n(625)],this["_handleP"+n(1007)])}[t(1423)+"ageHide"](n){let s=t;e[s(1603)](e.rwjgi,s(409))||(!n[s(1250)+"d"]&&(this[s(353)+"er"]&&window["removeEv"+s(518)+s(663)](e[s(1156)],this[s(1423)+s(330)]),this[s(353)+"er"]&&window.removeEventListener(e[s(625)],this[s(1423)+"ageShow"]),this.close()),this[s(353)+"er"]&&window[s(1785)+"entListe"+s(663)](e[s(823)],this[s(1480)+"nLine"]),this._isBrowser&&window[s(1785)+s(518)+s(663)](s(904),this[s(1480)+s(919)]))}_handlePageShow(n){let s=t;n[s(1250)+"d"]&&(this._navigatorOnline()&&(!this[s(528)]||e.JpkfQ(this[s(528)][s(398)+"te"],this[s(1517)])||e[s(867)](this[s(528)][s(398)+"te"],this[s(412)+"NG"]))&&this._handleOnLine(),this[s(353)+"er"]&&window[s(469)+s(286)](e[s(823)],this["_handleO"+s(1331)]),this._isBrowser&&window[s(469)+"Listener"](e[s(1769)],this[s(1480)+s(919)]))}async["_generat"+t(667)](n){let s=t,{fpID:d,deviceID:f,bddID:h,ttwID:m,accessKey:b,aID:g,customParams:v={},enableAutoAck:D,enableQoS:N,QoSLevel:H,env:J}=this._options,X,Q,ge;this[s(353)+"er"]||this._isMiniWX||this[s(896)+"T"]?e[s(1403)](e[s(1297)],s(832))?(X=location&&e[s(1788)](e[s(1555)],location.protocol)?e[s(882)]:e[s(804)],Q=n[s(1299)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),ge=/^wss(.*:\/\/)/[s(521)](n)?n:""+X+Q):(twxDtO.aHJOH(_0x213eee,twxDtO[s(1136)](_0x25518f,_0x330ac9.result)),twxDtO[s(1732)](_0x53fa8b)):(X=e[s(882)],Q=n[s(1299)](/(^http)((?:[s]*:\/\/))/,""),ge=/(^ws)((?:[s]*:\/\/))/[s(521)](Q)?Q:""+X+Q);let is=h?e[s(380)]:m?e[s(700)]:e[s(986)],nn=h||m||f;if(e[s(304)](!nn,!is))throw new Error(e.UeVfK);let ss=e[s(687)]==typeof v?await v():v,Xp=J?wp(J[s(623)],J[s(1102)]):{},ma=Object[s(1241)]({device_platform:e[s(673)],version_code:e[s(772)],access_key:b,fpid:d,aid:g,[is]:nn,xsack:D?1:0,xaack:D?1:0,xsqos:N?1:0,qos_level:N?H:void 0,qos_sdk_version:2,...Xp},ss),Qp=Object[s(306)](ma)[s(803)]((wa,_a)=>ma[_a]!==void 0?""+wa+(wa?"&":"?")+_a+"="+ma[_a]:wa,"");return ge+s(849)+Qp}async[t(424)](){let n=t;if(!(this["_connect"+n(395)]||this._readyClosed)){this._connectLock=!0;try{let s=this["_endpoin"+n(976)]?.[n(720)+n(1635)+n(460)+n(268)+n(810)](),{timeoutInterval:d}=this[n(1736)];if(s){let h=this[n(1638)+"tManager"]?.[n(638)+n(1643)+"nt"](),m=this[n(1638)+"tManager"]?.[n(1175)+"ackupEndpointAnd"+n(1286)+n(543)](),b=this[n(1638)+"tManager"]?.[n(638)+n(1643)+n(1014)+"ount"]();if(m){let g="connect "+h+(n(1678)+n(1405)+n(1052)+n(942)+n(1314)+n(990)+n(796))+m+(n(1096)+"y"),v=e.cEJti(at,e[n(1806)],{message:g,code:en[n(526)+n(349)+"R"]});this[n(932)](g),this["_dispatc"+n(701)+"ent"](v),this[n(1094)]=await this["_generat"+n(667)](m),this[n(932)](n(1093)+m+" "+b+" times"),this[n(1152)+"sListeners"]()}else{let g=n(1093)+h+(n(1678)+n(1405)+n(1052)+n(1562));this._debug(g),this[n(1618)+"hErrorEvent"](e[n(357)](at,e.fbioT,{message:g,code:en[n(526)+"IES_ERROR"]}));return}}else if(e[n(594)]!==e[n(727)]){let h=this[n(1638)+n(976)]?.[n(638)+n(1643)+n(777)+"ateCount"](),m=this[n(1638)+"tManager"]?.[n(638)+n(1643)+n(1014)+n(389)]();this[n(1094)]=await this[n(572)+n(667)](e[n(1795)](h,"")),this[n(932)](n(1093)+h+" "+m+" times"),this[n(1152)+n(1607)+"rs"]()}else _0x253896[n(980)+n(1349)]="",_0x17d30e[n(1688)](_0x50f7b3);if(this._isInit)this._isInit=!1;else{let h=e[n(704)](da,"reconnect",{message:e[n(1180)]});this[n(1683)+n(945)]&&this[n(1683)+n(945)](h)}let f=this[n(1638)+n(976)]?.[n(638)+n(1643)+n(1014)+n(389)]()||0;e[n(1470)](f,1)&&await this[n(438)](f-1),this[n(932)](n(1776)+n(429)+this[n(1094)]+(n(1569)+n(1509))+this[n(620)+"ls"]),this[n(528)]=e[n(760)](pp,{url:this[n(1094)],protocols:[this[n(620)+"ls"]],headers:this._options[n(425)+n(391)+"s"][n(1219)+n(1135)]},this[n(1736)].ws),(this[n(353)+"er"]||this[n(1463)+"r"])&&this[n(528)]&&(this[n(528)][n(1370)+"pe"]=this[n(1633)+n(874)]),this[n(358)+"steners"](),this[n(424)+n(1725)+n(1589)]=e[n(371)](setTimeout,this[n(937)+"ut"][n(636)](this),d)}catch(s){throw this[n(424)+"Lock"]=!1,s}}}_clearTimer(){let n=t;e.UnBAL(e[n(360)],e[n(1336)])?(e[n(367)](_0x14bbf1,e.ctgqj),this[n(284)](e.IvogE,_0x4301e9),this[n(284)](e.XaRjI,_0x1f38c7)):(e[n(490)](clearTimeout,this[n(424)+"ionTimeo"+n(1589)]),this[n(424)+n(1725)+n(1589)]=null)}[t(949)+"ngTimer"](){let n=t;e[n(886)](clearTimeout,this[n(898)+n(1753)+"Id"]),e[n(1384)](clearTimeout,this[n(299)+n(902)+"tId"]),this[n(898)+n(1753)+"Id"]=null,this[n(299)+"ctTimeou"+n(1749)]=null}[t(932)](...n){let s=t;this[s(1736)].debug&&console[s(1688)].apply(console,[s(443)+">",...n])}[t(1301)+t(1502)+"e"](n){let s=t;if(e[s(1388)](e.sziKk,e[s(603)]))return this[s(1618)+s(1425)+s(1382)](_0x502bff),e[s(1732)](_0x467c8b);{let{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:h}=this[s(1736)],m=e[s(1275)](d,Math[s(712)](h,e.vyRGo(n,1)));return e[s(428)](m,f)?f:m}}_ping(){let n=t;if(this[n(528)]&&e.RfoWP(this[n(528)][n(398)+"te"],this[n(412)+"NG"])){this[n(949)+n(913)](),this[n(898)+n(1753)+"Id"]=setTimeout(this[n(1515)][n(636)](this),this._options[n(686)+"rval"]);return}if(!this[n(528)]||e.tVRpt(this[n(528)].readyState,this[n(1517)]))return void this[n(1550)+"econnect"]();this[n(528)]&&this[n(528)][n(1118)]("hi"),this[n(299)+n(902)+"tId"]=e[n(668)](setTimeout,this[n(1550)+n(945)+n(1033)].bind(this),this[n(1736)][n(331)+n(702)+n(541)])}[t(1550)+t(945)+t(1033)](){let n=t;this._pingLossCounter?.[n(814)](),this.emit("ping_once_timeout",e.IwgbL),this[n(270)+"sCounter"]?.[n(385)+n(1566)+"nt"]()?this[n(1550)+n(945)]():this[n(1515)]()}[t(1602)+t(1042)](){let n=t;return this[n(896)+"T"]||this[n(655)+"X"]?this[n(736)+"igatorOn"+n(1187)]:(this._isBrowser||this[n(1463)+"r"])&&this[n(1736)][n(1576)+n(1790)+"nged"]?navigator[n(1420)]:!0}["_handleR"+t(945)](){let n=t;!this["_navigat"+n(1042)]()||this[n(1206)+n(988)]||(this[n(1638)+"tManager"]?.[n(1730)+n(621)+"fig"](),this["_pingLos"+n(579)]?.[n(683)+n(659)](),this[n(528)]?this[n(1291)+n(951)](1001,e.PfLwo,!0):this._connect())}[t(309)+t(1805)+t(1015)](){let n=t,s={SWuIV:function(d,f,h){return d(f,h)},Xvoki:e[n(1806)],TYZuw:function(d,f){return e[n(1050)](d,f)},qnQTP:function(d,f){return d===f},uPifk:e[n(1246)],dNBCP:e.JdZeH};this[n(896)+"T"]?tt[n(1105)+n(917)+n(807)](({isConnected:d})=>{let f=n;if(s.qnQTP(s.uPifk,s[f(1155)])){let h=this[f(1638)+"tManager"]?.[f(385)+f(266)+"es"](),m=this[f(1638)+"tManager"]?.[f(638)+f(1643)+"nt"]();if(h&&!_0x1b7db7.message){let b=f(1093)+m+(" fail, m"+f(593)+f(578)+"ed");this[f(1618)+f(701)+f(618)](MmgpHM[f(978)](_0x390e2a,MmgpHM[f(1394)],{message:b,code:_0x275080[f(526)+f(349)+"R"],error:_0x403c96}));return}this[f(528)]&&MmgpHM.TYZuw(this[f(528)][f(398)+"te"],this[f(1517)])&&this[f(1291)+f(951)](),this[f(1618)+f(701)+f(618)](MmgpHM.SWuIV(_0x551649,MmgpHM[f(1394)],{message:_0x4298f4.message,code:_0x2b4f13.NATIVE_ERROR,error:_0x424ac8}))}else this["_miniNav"+f(1231)+f(1187)]=d,d?this[f(1480)+"nLine"]():this["_handleO"+f(919)]()}):this[n(655)+"X"]&&wx[n(1105)+"kStatusC"+n(807)](({isConnected:d})=>{let f=n;this["_miniNav"+f(1231)+"line"]=d,d?this[f(1480)+f(1331)]():this._handleOffLine()})}[t(438)](n){let s=t,d={oMTlZ:function(f,h,m){return f(h,m)},yCVkL:e[s(1306)]};if(e[s(417)](s(628),s(628)))return new Promise(f=>{let h=s;d[h(468)](setTimeout,f,this[h(1301)+h(1502)+"e"](n))});this[s(845)](d[s(327)],_0x1affb5),this[s(476)]&&this[s(476)](_0x6a1c59)}[t(1291)+t(951)](n=1e3,s="",d=!1){let f=t;this[f(528)]&&this["_destroy"+f(941)+"t"](n,s,d)}[t(937)+"ut"](){let n=t,s=this["_endpoin"+n(976)]?.[n(638)+n(1643)+"nt"]();this[n(932)](n(1093)+s+n(1678)),this["_disconn"+n(951)](1001,e[n(462)],!0)}[t(1274)](n){let s=t,d=e[s(1628)](Bt,n);if(this[s(528)]&&e[s(1278)](this[s(528)][s(398)+"te"],this.OPEN))if(e[s(1674)]===e[s(1674)])this[s(528)]&&this._ws[s(1118)](d),this[s(932)](e.ixjHC,n);else{let f={MyxWc:function(h,m){return h!=m},IFvUZ:twxDtO[s(977)],oqCMf:twxDtO[s(516)],NTEJB:twxDtO[s(680)]};_0xcfa9f1.r=h=>{let m=s;f[m(505)](f[m(1064)],typeof _0x2cd921)&&_0x311698[m(589)+m(1477)]&&_0x280568[m(640)+m(1418)](h,_0x11d6c0[m(589)+m(1477)],{value:f[m(595)]}),_0x1fc2e7[m(640)+"operty"](h,f.NTEJB,{value:!0})}}}[t(1152)+t(1607)+"rs"](){let n=t,s=e[n(717)][n(485)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(528)][n(1785)+n(518)+n(663)]("error",this._onError);continue;case"1":this[n(528)][n(1785)+n(518)+n(663)](e[n(1666)],this._onMessage);continue;case"2":this[n(528)]["removeEv"+n(518)+n(663)](n(1811),this[n(277)]);continue;case"3":this._ws[n(1785)+n(518)+n(663)](n(477),this._onOpen);continue;case"4":if(!this[n(528)])return;continue}break}}[t(358)+t(1841)](){let n=t,s=e[n(1035)][n(485)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(!this[n(528)])return;continue;case"1":this[n(528)][n(469)+n(286)](e.zVqPJ,this[n(277)]);continue;case"2":this[n(528)][n(469)+n(286)](e[n(1306)],this._onOpen);continue;case"3":this[n(528)][n(469)+n(286)](e[n(1806)],this[n(897)]);continue;case"4":this._ws["addEvent"+n(286)](e[n(1666)],this._onMessage);continue}break}}[t(1824)+t(479)](n=1e3,s=""){let d=t;try{this[d(528)]&&this[d(528)][d(1811)](n,s)}catch{}}[t(1381)+t(941)+"t"](n=1e3,s="",d=!1){let f=t;if(this[f(949)+f(913)](),this[f(1510)+"mer"](),this[f(1152)+f(1607)+"rs"](),this[f(1824)+f(479)](1e3,s),this[f(424)+f(395)]=!1,d&&this[f(1602)+"orOnline"]()&&!this[f(1206)+"osed"]){if(this[f(1638)+f(976)]?.[f(385)+f(266)+"es"]()){let m=this[f(1638)+"tManager"]?.["getCurre"+f(1643)+"nt"]();this[f(1618)+f(539)+"ent"](xt("close",{code:1006,reason:f(1093)+m+(" timeout"+f(1405)+"tries re"+f(1562)),wasClean:!0}))}else{let m=this[f(1736)][f(716)+f(1537)+f(1714)](n,s);this[f(1618)+"hCloseEv"+f(618)](e[f(591)](xt,f(1811),{code:n,reason:s,wasClean:!0,willReconnect:m})),m&&this[f(424)]()}return}this._navigatorOnline()||this[f(1206)+f(988)]?this["_dispatchCloseEv"+f(618)](e.lAzvy(xt,e[f(1249)],{code:n,reason:f(1662)})):this["_dispatc"+f(539)+f(618)](e[f(753)](xt,f(1811),{code:1006,reason:e.pHprs})),this._ws=null,this._endpointManager?.[f(1730)+f(621)+f(334)](),this["_pingLos"+f(579)]?.[f(683)+f(659)]()}["_dispatc"+t(973)+"nt"](n){let s=t;this.emit("open",n),this[s(476)]&&this[s(476)](n)}[t(1618)+t(1425)+t(1382)](n){let s=t;this[s(845)](s(560),n),this.onmessage&&this[s(1837)+"e"](n)}[t(1618)+t(816)+t(825)](n){let s=t;this[s(845)](e[s(1438)],n),this["onReceiv"+s(1739)]&&this[s(1783)+s(1739)](n)}["_dispatc"+t(701)+t(618)](n){let s=t;this[s(845)](e.fbioT,n),this[s(1088)]&&this.onerror(n)}[t(1618)+t(539)+t(618)](n){let s=t;this[s(845)](e[s(1249)],n),this[s(1254)]&&this[s(1254)](n)}get[t(1370)+"pe"](){let n=t;return this[n(528)]?this[n(528)][n(1370)+"pe"]:this[n(1633)+"ype"]}set binaryType(n){let s=t,d={mCAFu:function(f,h){return f===h},HvohI:function(f,h){return f===h},BDYoq:function(f,h){return f+h},qNQBo:function(f,h){return e[U(1329)](f,h)}};if(e.Mdueg===e[s(1147)])this[s(1633)+s(874)]=n,this[s(528)]&&(this._ws[s(1370)+"pe"]=n);else return ZUDeVf[s(1472)](-1,this.low)&&ZUDeVf[s(1472)](-1,this.high)?_0x5365a2[s(1758)](0,0,this[s(1722)]):ZUDeVf[s(611)](-1,this.low)?_0x24d5ba[s(1758)](0,ZUDeVf[s(1802)](this[s(388)],1),this[s(1722)]):_0x5538fd.fromBits(ZUDeVf[s(679)](this.low,1),this[s(388)],this.unsigned)}get[t(312)+"nt"](){let n=t;return this[n(1638)+n(976)]?.[n(638)+n(1643)+n(1014)+"ount"]()||0}get[t(554)+"Amount"](){let n=t,s={Vrhzj:function(d,f,h,m,b){return e[U(813)](d,f,h,m,b)},mlFQL:function(d,f){return e[U(662)](d,f)}};if(e.ibzmn(e[n(993)],e.zUrIO))_0x57bb87[n(469)+n(286)](twxDtO[n(929)],d=>{let f=n;vlJAjc[f(1660)](_0x845cc5,vlJAjc.mlFQL(_0x1a89a8,_0x4fd43a[f(1367)]),d[f(390)+"on"],d.newVersion,vlJAjc[f(444)](_0x30540a,_0x20fa61[f(381)+f(1234)]))});else{let d=this[n(430)+n(1512)][n(803)]((f,h)=>(f+=h&&h.byteLength||0,f),0);return e[n(1352)](d,this[n(528)]?this[n(528)][n(554)+"Amount"]:0)}}get[t(649)+"ns"](){let n=t;return this[n(528)]?this[n(528)][n(649)+"ns"]:""}get[t(956)](){let n=t;return this[n(528)]?this[n(528)][n(956)]:""}get readyState(){let n=t;return e[n(473)]!==n(957)?this[n(528)]?this._ws[n(1370)+"pe"]:this[n(1633)+n(874)]:this[n(528)]?this[n(528)][n(398)+"te"]:this._options["automati"+n(1395)]?this[n(412)+"NG"]:this.CLOSED}get[t(497)](){let n=t;return this._ws?this[n(528)][n(497)]:this[n(1094)]}[t(1811)](n=1e3,s){let d=t;if(this[d(1206)+d(988)]=!0,this[d(1510)+d(1767)](),this[d(949)+d(913)](),this["_dropGlo"+d(1086)+d(286)](),this[d(766)+d(664)]?.[d(1808)](),!this[d(528)])return void this._debug(e[d(675)]);if(e.oUoWP(this[d(528)][d(398)+"te"],this[d(954)])||e.pZFZe(this[d(528)][d(398)+"te"],this[d(1386)]))return void this._debug(e[d(562)]);this[d(1381)+d(941)+"t"](n,s)}async[t(1118)](n,s){let d=t,f={KWwKx:function(h,m){return h|m}};if(e[d(1529)](e[d(1421)],e[d(1421)])){if(n==null)throw new Error(e.TCviy);e[d(622)](e[d(509)],typeof n)&&(n=JSON[d(1789)+"y"](n)),d(1572)!=typeof n&&!(n instanceof ArrayBuffer)&&!(n[d(1612)]&&e[d(1060)](n.buffer,ArrayBuffer))&&(n=JSON[d(1789)+"y"](n));let h=await e[d(529)](sl,n),m=e[d(335)](mp,n),{method:b=0,service:g=this[d(1736)][d(315)],logID:v=this[d(1736)][d(1151)+"erator"](),headers:D=this[d(1736)][d(296)],payloadEncoding:N=this[d(1736)][d(1239)+d(1406)],payloadType:H=this[d(1736)][d(1001)+d(874)],logIDNew:J=this[d(1736)][d(1225)+d(1504)][d(311)+d(952)+"teLogIDNew"]?e.pplPc(i,this[d(1736)][d(1225)+"Config"][d(835)]):""}=s||{};if(!g)throw new Error(e[d(818)]);let X={SeqID:xe[d(297)+"er"](this._seqId++),LogID:xe.fromNumber(v),service:g,method:b,headers:D,payloadEncoding:e[d(1474)](N,Object)?N[d(527)]?N[d(527)]:"":N,payloadType:e[d(1813)](H,Object)?H[d(519)]?H[d(519)]:m:H||m,payload:h,LogIDNew:J},Q=e.AUDWB(Bt,X);return this._ws&&this[d(528)].readyState===this[d(1517)]?(this._ws&&this[d(528)].send(Q),this[d(932)](e[d(738)],X)):e[d(731)](this[d(430)+d(1512)][d(1524)],this[d(1736)]["maxMessa"+d(780)+d(1693)])?(this[d(430)+"Queue"].push(Q),this._debug(d(1731),X)):(this[d(430)+"Queue"].shift(),this[d(430)+d(1512)][d(354)](Q)),{seqID:this._seqId,logID:v,logIDNew:J}}else this.isLong=!0,this[d(1453)]=YENXPE[d(377)](0,_0x8a5397),this.high=0|_0x52b0e6,this[d(1722)]=!!_0x3dbf27}async reconnect(n){let s=t,{url:d}=e[s(953)](n,{}),f=Array.isArray(d)?d:e[s(1788)](e[s(1557)],typeof d)?[d]:[];if(n&&Object[s(1241)](this[s(1736)],n),f&&f[s(1524)]?this[s(1638)+"tManager"]=new tl(f,this._options[s(1542)+"es"]):this[s(1638)+s(976)]?.["resetEnd"+s(621)+s(334)](),this[s(270)+s(579)]?.[s(683)+s(659)](this[s(1736)][s(410)+s(833)]),this._readyClosed=!1,this[s(528)]&&e[s(386)](this[s(528)].readyState,this[s(954)]))this[s(1291)+s(951)](1e3,e.dzlbR,!0);else if(s(1604)!==e[s(1828)])this[s(848)]=!0,this[s(424)]();else return _0x35a887[_0x515f4f[e[s(314)]]=5001]=e[s(314)],_0x2e6a90[_0x33d267[s(412)+"NG_ERROR"]=5002]="CONNECTI"+s(1018),_0x1d16ff[_0x529904[e[s(1121)]]=5003]=e.ZGvbq,_0x579430[_0x5c77b2[e.ZASHC]=5004]=s(1392)+s(642),_0x483d83[_0x2c4967[s(1053)+"OR"]=5005]=e.loKir,_0x62be7}async connect(){let n=t;if(!this[n(424)+"Lock"]){let s=e[n(452)].split("|"),d=0;for(;;){switch(s[d++]){case"0":this._isInit=!0;continue;case"1":this[n(1206)+n(988)]=!1;continue;case"2":this[n(424)]();continue;case"3":this[n(270)+n(579)]?.[n(683)+n(659)]();continue;case"4":this[n(1638)+n(976)]?.[n(1730)+n(621)+n(334)]();continue}break}}}[t(469)+"Listener"](n,s){let d=t,f={gaXyA:function(h,m,b){return e.VSRYp(h,m,b)}};if(e.yuMPo(e[d(563)],e[d(1556)]))this.on(n,s);else{let h={xwUzQ:e.fbioT};if(e[d(1474)](_0xd7ca29,_0x3ce837)){let m=_0x28a336[d(1612)][d(264)](_0xa191f3[d(569)+"et"],e[d(1694)](_0x25e0a1.byteLength,_0x479823[d(569)+"et"]));this[d(548)]&&this._socket.send({data:m,fail:b=>{let g=d;this[g(845)](h[g(723)],_0x375616(h[g(723)],{message:this[g(1467)+g(433)+g(1654)](b)}))}})}else this[d(548)]&&this._socket[d(1118)]({data:_0x311c47,fail:m=>{let b=d;this[b(845)](b(1786),WgAYmY[b(565)](_0x54cbd1,"error",{message:this["_formatErrorMess"+b(1654)](m)}))}})}}[t(1675)+t(1382)](n){let s=t,{type:d}=n;this[s(845)](d,n)}[t(1785)+t(518)+"ner"](n,s){let d=t,f={pkgfO:function(h,m){return e[U(1069)](h,m)},nlomc:function(h,m,b){return h(m,b)}};e[d(1642)](e[d(1227)],e.RWgJG)?(yKiZbH.pkgfO(_0x459c1d,this[d(863)+d(1655)+"Id"]),this[d(863)+d(1655)+"Id"]=yKiZbH[d(829)](_0x96e2a,()=>{let h=d;this[h(260)+h(817)]()},this[d(863)+"l"])):this[d(284)](n,s)}[t(328)](){let n=t,s={pBQcI:function(d,f){return d!==f},ujsUE:e[n(1812)],mOMvq:e[n(759)],jfPbt:function(d,f){return e[n(1169)](d,f)},YJRnN:n(379),HleFS:n(1391)+n(748)+"s",uaLAm:function(d,f,h){return e[n(704)](d,f,h)},NhgDe:e[n(1809)],Hyxtd:n(887),OoGQx:e[n(1806)],DxnzX:function(d,f){return e.iGmxr(d,f)},shQpS:n(750),nHCqy:function(d,f,h){return e.AfYcr(d,f,h)},VRasU:e[n(676)]};return new Promise((d,f)=>{let h=n,m={uOhut:function(b,g,v){return s[U(1476)](b,g,v)},mwSBN:function(b,g,v){return b(g,v)},ddcQi:function(b,g){return b(g)},lnNGq:function(b,g){return b!==g},FLNpW:s[h(1664)],EZNUI:function(b,g){return b(g)},yntTf:s[h(1100)],CBEFy:s.HleFS,CapTr:h(1391)+h(1692)+"t",HGdjs:s.OoGQx};if(s[h(1140)](h(706),s[h(885)])){this[h(949)+h(913)](),this[h(898)+h(1753)+"Id"]=s[h(842)](setTimeout,this[h(1515)][h(636)](this),this[h(1736)][h(686)+h(378)]);let b=()=>{let v=h;s[v(351)](s[v(1192)],s[v(1185)])?(s[v(583)](d,s[v(1260)]),this[v(284)](s[v(989)],b),this[v(284)](v(1391)+"e_timeout",g)):(EeMIWF[v(661)](_0x1e62ee,_0x1a23b9,96),EeMIWF[v(339)](_0x5739cd,_0x581499,EeMIWF[v(1104)](_0x294a91,_0xaa3c00)))},g=()=>{let v=h,D={UoRHY:function(N,H,J){return N(H,J)}};if(m[v(1322)](m[v(678)],m[v(678)])){this[v(949)+v(913)](),this[v(898)+v(1753)+"Id"]=SPAiTw[v(1627)](_0x435c65,this[v(1515)][v(636)](this),this[v(1736)][v(686)+v(378)]);return}else m[v(317)](f,m[v(1325)]),this.off(m[v(741)],b),this[v(284)](m[v(619)],g)};this.on(s.HleFS,b),this.on(s[h(677)],g),this[h(1515)]()}else{let b=EeMIWF[h(661)](_0x1fe38c,EeMIWF[h(279)],{message:_0x3bc43d[h(560)],code:_0x266b21[h(1392)+h(642)],error:_0x563611});this[h(1618)+h(701)+h(618)](b)}})}}})(),Te[M(434)+M(373)]=De[M(434)+"oseEvent"],Te[M(1402)+"rorEvent"]=De["CustomEr"+M(916)],Te.ErrorCode=De[M(698)+"e"],Te[M(1382)]=De[M(1382)],Te[M(1723)]=De[M(1723)],Te[M(321)+M(1356)+M(1435)]=De[M(321)+M(1356)+M(1435)],Te[M(1356)+M(1435)]=De[M(1356)+"vent"],Te[M(718)+"t"]=De[M(718)+"t"],Te["Reconnec"+M(824)]=De[M(987)+"tEvent"],Te[M(496)+M(373)]=De["createCl"+M(373)],Te[M(1466)+M(916)]=De[M(1466)+M(916)],Te["createMe"+M(1669)+"nt"]=De[M(472)+"ssageEvent"],Te[M(406)+M(797)]=De[M(406)+M(797)],Te["createRe"+M(1511)+M(1435)]=De[M(461)+M(1511)+"vent"],Te[M(1415)+M(573)]=De[M(1415)+M(573)],Te[M(652)+M(981)]=De[M(652)+M(981)];for(zo in De)[M(434)+M(373),M(1402)+M(916),"ErrorCode","Event",M(1723),M(321)+M(1356)+M(1435),M(1356)+M(1435),"OpenEvent",M(987)+M(824),"createCl"+M(373),M(1466)+M(916),M(472)+M(1669)+"nt","createOp"+M(797),M(461)+M(1511)+M(1435),M(1415)+M(573),"encodeFr"+M(981)][M(822)](zo)===-1&&(Te[zo]=De[zo]);var zo;function Wo(){let t=["A21gtfa","Bg93","zNvUy3rPB24","m3W2Fdr8mte","D3nhBhK","DffoBhC","CMvXDwLYzwq","qM9kB1m","Aw47y2HHCNm","AMvRsNq","C2v0","x2LZv29YA2u","zwvKzwq","BgvY","y3jLyxrLrxi","x2zVCM1HDeu","ruL6wgS","tgrkAgK","CMPqCeO","tgD3v0i","BunbrNu","A29tvNy","Cwjzwe4","mtK4vNHRrer3","Dwfmqw0","vgfN","y3j5Ae4","u1LLuvK","x2HHBMrSzu8","twz3r04","CgjICdi","qxLxywm","vejxrfi","swzACgS","qKLJu1O","A0LqDNm","BMLyD1y","zgrjrcWGzgu","qxrRCeC","CMvHzfvjBNq","v0TozwS","zgLZywjSzue","De54t2O","CKPyBwC","BM9Uzv9UB24","zKv6zei","C3HfAwe","u0vcq3O","BgjXrwm","tM5ACK8","CNzHBfzHBhu","AurIyNC","q29UzMLN","tLzqsge","ALH6qxG","zNjVBunOyxi","BKrss1O","Bhm6ia","x2nSzwfYvgK","y29UBMvJDeu","uxvLDwu","y0jctK0","BgHWwfO","x3bPBMC","ywHpEeu","t1bftG","zxHWB3j0CW","BMrMqMW","B2nRzxq","zgjTtwq","D3jPDgu","s05VquS","BgvUz3rO","wuLosKG","yLzktuS","ywzL","B2zMC2v0","B05Ryxa","zgrbr0W","y2XIBMS","B3jRig9MzMW","y29UDgv4Da","Dg1lBxK","x2LUAxq","uM14vNK","DeLUDgvYy2u","rhf5ueC","teTOEwS","sLzJEhu","wKDIvxK","Bwf4uMv0CMK","Chv0","ELnHsuq","uhvfCve","CMfUzg9T","DvHrBeS","Bvz4tfm","wffXwgm","x2HHBMrSzvi","zMLArKK","ugniAMO","ufLTz0C","vfHsAK4","uNLpyvC","qLz6ALe","Dxb1C2y","u2nrzhy","qxHpwMy","ihrYEsbYzwm","BwvZC2fNztO","ywnOzwq","CM92AwrLihC","y1Hpz1i","DNPjvuy","y2HnyxHdB3u","yKngshy","tw9KDwXL","ihbYB3rVy28","swvzsNe","A053wvO","C3rYAw5N","t2jQzwn0","v2zYAha","AKn0vNa","BgLZDgvUtMu","vLvzzxG","y2vZC0HHBMq","ysbTDxn0igi","t1juDMS","EML3tg8","BIWGAg9ZDg4","Aw5KzxGGB3u","DNbHvhi","D2DfsMS","uMvHzcbWyxm","ChjVDg90Exa","qLPxtMq","Dxrjza","ywrKt25L","v2vPEgLUsLm","Dg9cExrLC0i","qxDdsMu","nxW4FdD8mNW","r2DvAvK","vwLuB1a","seXvtKO","wNjTyw8","BwvZC2fNzv8","C2nYAxb0","vxvdy1i","x25HDMLNyxq","D3b4uLK","vM5Aq2C","B0nWs1G","qwTwANa","C0XPC3rLBMu","z0vXAKK","zLDxC2q","t3zvq2K","s2fkCfu","yNvMzMvY","sev0vgK","AgfZ","Bw5HvfK","u3HRyKW","Bw5VCMq","x2rPC3bHDgm","r0LTC3K","mty3ntqZnwXsuwnPqq","zNjVBuHHC2G","re1xtxq","Dw5KzwzPBMu","Aw5Lza","vvPWwLm","uLLWs2S","vw9ssfK","CKXitMW","BgPTCgG","zgnpz2K","uu1ftg8","zw5KCg9PBNq","x2jPBMfYEvq","sKjrA2u","CMvUDevUzha","yxrHlcbKyxq","mte4ndK0n0LkBMD6za","x2vUzhbVAw4","Dg9oDw1Izxi","yMfhyLG","DMXvqMO","DuLTtvy","BNrfBMrWB2K","DNnoEhG","y3vYC29Y","y2Tnr3i","Ec1TC2CTCw8","mdaWma","y2HHCKnVzgu","CeLMr3u","zxj2AwnL","x2LUAxrhBg8","D0PpuM4","ywDL","BfrPBwvVDxq","Eg1lEuO","yM5gteK","tg9NsurozxC","BNrlsfK","vNjOEMO","shfbCNq","yNLL","CKzPDNK","tMHNrgu","DwLwswG","D1D5wwu","rKLWqNG","AxnFywnR","C3nHz2vfDMu","vw1bEvm","y1Llq1q","sLrey00","EfjerLu","r0HNALy","zgLZCgf0y2G","C2vUzf9Hy2S","wgHpthK","ihrPBwvVDxq","B0T5AMe","Du9utwy","vLvRvLG","uNzoyLu","B25tDgfYDfi","C0vlvwW","ywnpq2i","EMzttvO","s051Eve","Bg9N","AgvHzgvY","Awj6Bw4","z3jKqKu","zv90Aw1LB3u","zw5NDgG","r21vrMC","AvDHAgi","x2TLEvbHDgG","CNb5thi","rKzXEwi","mZm0mJK5yu1jqNfH","tLDMvxK","rwHdrxm","z0j6q0G","BuTVsve","EuzfENq","tK9NqLG","uMXvtgy","lcbOB3n0BMe","Afvothm","zw50zwqGDhK","CMvTB3zLq2G","BMCGzMfPBgu","EwDXALK","CMrNzuq","ChrVCG","zg9Uzq","Cg9PBNrbBMq","ugDbBhO","mdaWmdaWmda","zfjSwK0","CeLtBKy","Ec11C2uT","Dw5ZAwDUzwq","rLDt","q2zty3a","Aw9UvgLTzw8","yLfJAM0","rMf1A2m","rNjkzvu","CvvyDwG","CMvZzxrfBMq","zw5XDwv1zq","EeftvhG","ugz3Bei","z2TJzfm","mxW4Fdz8oxW","x29WDgLVBNm","ignVzgu6ia","z0nkz1i","zufJAW","CMnLDhe","sMP4tM8","CYbWyxjHBxm","su16AgW","BeHHBMrSzxi","CgfNzwHPzgu","zgvSzxrLrge","y29UC3rYDwm","qM5zEg4","DeLK","rNzwrwK","qNvjuuW","senWtwy","z1rPBwvVDxq","tgLkwNi","AhPQD1G","B1rktey","yw1Lu3bHy2u","zNjVBujPDhm","qwnet1m","ywXSzwqGBxu","zfHjrxq","rgf6zey","ywWGy3vYC28","y29UDgLUDwu","y2f0y2G","z2v0qwXS","BwvY","mhWYFdn8mxW","vNLvA2S","tuPxuMe","y3vYC29Yx2y","sxzVz0u","ALDIyLq","C3rHCNq","AM1xCLK","y29UBMvJDgK","wuTKsgG","rLP1C0S","EfvoDwK","u1v2vgC","EsbJBg9Zzwq","Ewf6sNm","B25szwnLAxy","yMrQCMW","CMvTB3zLrxy","zxjYB3i","z2v0qwXSs2u","vvHftfC","C3rYAw5NAwy","DhDVCMTdAge","B3vwweO","C1zmzKS","x194x21Zz18","vwPttgW","s2TlyLa","y2joBum","vuHyAMC","wLn1Cgm","B0ndyuq","AK5zqxm","B01YA3a","qKrzB3e","qKPwC3K","EeX3ze4","zxrxB3jRq2G","zMjPB1q","mtC5ndC3nNvkA3P5Cq","y2XVC2veqG","zxnIrxy","AxfZCxK","y2XVC2u","yLvwyuq","zhHys2S","u2Xtvu8","s3nkDKG","thbmENq","AxnmB25N","shfOq0S","wuXtsK8","runovKm","B2nRzxrgywK","AxnszwfKEq","t0jAq2q","x3DZsw5ZDge","zxjFAxnFywm","ENL6ALe","DxbOrvO","Derntei","u2rWCMi","DMLJzuLeig8","yxjov3u","qM5mDu4","C2v0q3vYC28","Aw1LCYbPBIa","whf6zgW","A2HoA3q","B25TzxnZywC","CMvZzxruCMK","C29Tzq","ufr3z28","C3rLBMvYCW","Ahndreu","yM9KEq","zMX1C2HfEha","z2vtEw5J","BNvTyMvY","x3bYzwzPEa","C2XPy2u","rNDQDfC","y2HnyxHuCMK","y29SBM8","AgvKtwf4uMu","tuTjrgm","x3bPBMDmB3m","qMnHwwO","CMvHzg9UBhK","BMrLEa","rLn1wxm","DcbVzIbYyw4","DwHcDvu","x29Uq2XVC2u","Ee9NzKK","seDKANm","Awjnu2q","D3jPDgvvAw4","BerrtvO","A2Xhz00","B2zM","vvHkvxC","tgLZDgvUzxi","CLbgC2m","B3bLBKrc","v1f5EM0","BxnNsuq","DujJweS","C3vIC3rYAw4","ywjVCNq","z010twW","s0z5D1G","AgvHzgvYCW","zNjVBu51Bwi","CNnVCKzPBgu","x3jLy29UBMu","Ce1Vse8","u2vXsuq","zwLfC1K","q0jYruS","y1DJuNm","Cezzru8","A2v5CW","y2fSBa","v2riCgO","x29UugfNzu4","AwXLtMfTzq","zw5HyMXLqxu","CMv0CNLdB3u","DgHLBG","tK53B2C","C2vYDMLJzq","Cg9W","rvPovuK","EgjwyKq","D3nZoI8V","D3rYAKO","rNjVBNrPzxi","uNLqs3e","yvz2Evi","yLPLA0i","DxjQs1e","mtb8m3W5Fdi","EunwA0W","CgLUz09Uy2u","o2nOyxjZzxq","ywDLsgLKzq","CgLUz1rPBwu","zxf1ywXZ","ywXSq3vYC28","zMLN","EKDPq20","sg5hBK0","zsbHihn0CMK","ENvtDwW","BxDtqK4","zgjez2W","zxLnDfy","BvPOExe","tvvZv2u","DLrYDxO","zMLSzw5HBwu","t2X3DeK","qwjVCNrfCNi","whHVDhy","suvtx0vsuK8","reiGzMfPBgu","Cejry0K","v1vlCeK","x2LZqNjVD3m","ChvZAa","BML0AwfSAxO","ufDuBuS","zerKuxG","x2fKzfDZtgK","wM9rseK","qvbzzLi","CNnVCL92ywW","tgHWEg8","y29Kzq","s1LQtem","z0v0DgC","vhHjuwC","A3v0BwC","BK9swfa","A2LgvNG","uNf3C3K","A1fsv2G","A3Lfqu0","B3nLrxzLBNq","ve55sgS","CM92AwrLihy","rgXuseW","s1D3s3G","CNzHBa","C3vJy2vZCW","CMT2CxG","DhjHBNnHy3q","v2XwANi","yuHxEvu","yvnzALi","y2HLy2Tszwe","rgjUug8","rKfNCxy","AgLNAa","B3vUDa","B2XKvMvYC2K","CMfTugfYyw0","yvPgCwO","x3fVC0rc","BwPhywe","tg9JAW","tun3EKC","sgHMsvO","CMvHzhLtDge","r0nWDhK","AwrI","B3bXv2u","vNjet3u","BLn4Be0","Dg9VigXHCMC","DhjPBq","y3jLyxrLt3a","tfz4qvy","yufjC2u","B3nHExu","CgLUz0XVC3m","runpzeO","q09otKvdveK","sLnptLa","u3rYyxrLz3K","u1f3BK0","wwPqyvC","teD3sge","rfDTEvi","CLneu2S","qwzIuMW","y0rmr0S","vw5PBxbSzw0","se5tvhq","x2nVBM5Ly3q","BwLUAvbYB2C","AejJs1u","BMv4DcGPigm","DNvmuMm","BMCGDxjSoIa","x21LC3nHz2u","rgvKAwnHDgu","yMrFzgLK","CNjVCK1LC3m","q3vZDg9Tq2W","z2jVyxm","rKfNueu","DxrlAgW","x3DHAxq","rgPttNm","weDSyKC","Bg9IywXty28","B25dBg9Zzq","rLjptLrjrvi","BwXguuW","zLHdr1G","vefzBuO","DxP4zKS","D2vI","B3PvquK","AwXK","igfYCMf5yNu","EgnuBKq","rwjeteq","A0THs1O","Dg9iyxnO","ELLAAui","sfbZq1i","B3jRzxjhBg8","C2v0y3vYC28","B2LUDfjLywm","y3jLyxrLuMu","wg1lDLy","zcWG","AML4vgS","yMHIsLK","AxnrB1nnzxm","zcbLCNjVCI4","B01uBfO","ywrKrxzLBNq","Cw9Z","Cw9Oreq","y3jLyxrLtwu","y3PUsKK","igzHAwWSig0","u2TPCcbWyxm","B25VCgvU","B3bLBG","zM9Yy2u","BMnLq2XVC2u","B2XqtuW","CMvHC29U","v1DSwwC","txDgsee","twzouMe","C3bSAxq","v3jTtgu","r1HTBwC","r1jyr3y","qM13u0q","we1qAxe","EwTQq2S","CfjlCfy","D2LSBfjLy28","u0XyuKm","z2v0","y3jLyxrLq2W","DxjS","Aw5N","CMvJzxzPzwq","yw51Ce1LC3m","x2n1CNnVCK4","u25ez0C","tKfusvzfx0u","qMzqyLm","txL4v2m","DgfLCKS","q29Kzq","zxjYtM8","ue51Dwm","uwfbtM8","m3W0Fdy","wLjyBuu","ufvwu3O","swnSwuS","wfnuzhO","CuHyDg0","y2XVC2uSihC","zw50tgLZDgu","DhLWzq","mZvjDxbvuwO","DgvZDa","D3btv1y","BgLTAxq","ywjKC0m","zhfsBwS","tufyx1jfvfi","zw5JB2rPBMC","x3DZ","uwDQCK4","wMLKA1C","v1jmufO","Bg9lAxi","yu14seG","AML1AeS","Ce5uEK4","AhfyA20","DufhA08","BMzrAKW","AenSB3nLrxy","Dhrptxy","DMfS","EM5Lr3C","Dw50","y3jLyxrLrwW","CKXvDwe","qwX0D3O","CejVywu","x3nVy2TLDa","zLLMyKC","yvLVD3a","D2fZq2XLyw4","v3HHvNy","qMPAtLy","yNvMzMvYzwq","EgXxz3O","Dg9cExrLCW","BuDbr2y","whP1tgK","qM1Pzey","BwvZC2fNzq","C1fmy3q","y012vxa","r3D1v2S","sKvUwfu","z2fyEue","y2TQv3y","ugDnrxm","ANvNzuC","yNL0zu9MzNm","ELDpANq","zeL0yLa","x2DLBMvYyxq","CMfTzq","zNDZxZeUmc4","t0H1vMu","y29Uy2f0","B25nzxnZywC","zxmGCMvHy2G","C0nVDw50zxi","EejRDey","DMrbzMm","vePrs3q","AMzqyNq","vfjzBKu","CKzzywq","ELfNuwK","BgLcqNC","Ahr0Ca","Dg9tDhjPBMC","y291BNq","BLrgAuW","C2vNrxO","yxGGCMv0CMK","vgXMwvK","B3fdtwy","vgDgtNO","swHHuw8","su5tvefova","lcbxzwjtB2m","ALzSDKS","C2DPza","C1f6s2e","qNfpA28","EwTNCfC","ww5uu1K","AwLNAfm","t01oDuK","DMvYC2LVBG","EKr6CwG","Dg9Y","shzVAeK","z1v3wMC","ue9Rs0G","z3H1EKu","mhW0Fdf8m3W","v1nby1i","vLnswxa","zw50","q2fWvhi","x3bYB3rVy28","Cg9PBNrdB24","Avvozxe","EfvZzuvUDG","DfbHwxu","wKLlqMS","u1f3rKS","DMfSDwvZ","rePkvvG","yMLUyxj5","vfjyvvm","t2TdDLu","vgXKyxq","AerXEeq","zMLSDgvY","BgLUzw5V","yMLUza","ruLSBLC","z2v0q3vYCMu","DLfkDem","zgvMAw5Luhi","q3fjAuu","rvjst1i","sK1Mq0e","CLHcyK0","svvZCva","t0j6Cwi","C3vIyxjYyxK","wuzduLm","zxH0zw5ZAw8","vxLsqKG","CwrZEhq","zw5JB2rLrNi","Dw9qCva","qujXvKu","x2LZtwLUAvC","C2fNzq","yLDpv1K","sNP6qw0","BNrLCG","ChzwuuW","Du9ODxq","yLLOsM0","BMvY","z2vY","uLLIz2K","Aw5L","zvvYBa","u1nrwKm","u2vyt3q","AgLQtw8","ve5srwu","x2XPC3rLBMu","vgnUq2S","r2zfDxq","Aw5MC2W","wgfsAKK","vLjHC1u","rKXoCfC","Cu5rqM8","veXABLu","wfvhr0O","B0rtEeS","CMvZzxrdB3u","EuXXqK4","Cu9nDe4","CgLUz0LUDgu","swTpqNa","nfjRzvPIuW","q05gD3i","z1DlD3C","Dg9mB3DLCKm","qKP0B3e","Dff2Bem","rfDeD0G","mJu4nti4rLr6Cg1w","yxbWBgLJyxq","x2nYzwf0zvm","rxjYB3jdB2q","suXxDva","swvfufy","AevYCM9Yrxy","B3v0sw50zxi","C29tqLy","CMToCu0","wwziDNy","A0f2uLO","svPUwhu","y29UBMvJDfm","A1nRt2C","y2uGBM90igK","AePcCvK","Cg93","icSG","CNnVCL9Uyw0","zwLxv2m","CMvJB25Uzwm","vg1HswO","t3bLBKv2zw4","twHsr3q","y2HLy2TdDxi","q1nLwhG","AKLxvKS","EhDvELe","y2XLyxi","EgjAs1K","zhDHALm","BMrptw8","Dwv0sMy","C1fJwNO","uMDkzw4","DgDjCKq","y1LvBM0","rwjnt3q","ywr2yw5Jzq","sKflCe8","x21PBMLoyxy","D2ndtMy","EvjovLy","uhjPBwfYEuS","A2v5","q0jfrNK","z2v0t3DUuhi","ufzJDNa","n3WWFdH8nxW","DxbKyxrLq3u","y3vYC29YlNm","whz4vum","zv9ZDwnJzxm","y1bsyKG","vhbPEKi","r09MD3C","wvnquum","yMrPv24","wwvOue0","B2nRzxrtDwm","Cgf5Bg9Hza","svDtt2q","sNbRzLe","Cg50DKy","EhjKCxq","z3jVC3K","BxnN","qMPjuKG","suvrCvK","rLLbwNu","x1fVu01HBMe","zfDVCMTLCKC","vxzWCLe","rKLmrv9ot1q","B2Lvzhi","su50v1O","tvjAvMO","qMPzweu","nxWYFdb8nhW","ALzMrfe","uMfiwMm","BNrbBMrvCgq","AgfZt3DUuhi","mxW1","z2vrDwv1zuW","CMvHzhDYAxq","zuHwDfq","u0jbqw8","A1HvqNm","ugzuDMW","igXHCMDLCIa","t25ssNu","BMXUrNq","ywXKDu4","EM1ozfe","zNjXs2q","yufMrNK","vNPnDwu","s2LdDNy","BM93","BMrWB2LUDca","zw5fDMvUDa","yxKSihrYEsa","AwH4BuC","ywnRDxbfBMq","C1zozhm","BMv3vMvYC2K","CMvKDwnL","AfvKvKe","sg1Xyxa","veT4De4","AgfUz2u","swz2B3y","rKvJq2S","DhjPzxm","x0rctMfTzq","yvrJzKu","A3fNrvK","ywrKq291BNq","BvjdB0W","AefJA01LC3m","AxjLza","EuDyAMe","s3jvtuy","qwnYDwG","ywnRpwzYB24","Aw5KzxHpzG","DvPfEg4","Dev2zw50","ywDLrxzLBNq","ownMEMDgra","CxDmteq","CfjeAMK","BMXVBwm","vwPrCvy","quvYBhi","rg1ZBuK","q291BNq","DMnHv2S","DxnLCKLW","yKPzALa","ANLIBfi","sMzZz0e","B25pCgvU","A3HtAfO","AePQzvC","BKHdCxK","qNH5wfO","qNzXqvC","zw1PDa","uxzYwhi","BezSDxnO","x2LZsw5PDa","l3DZl3yY","rgHju1m","ywnRx2LK","D3bhBw8","DuXeDMG","ENfOsfG","qMHRueG","z29PBMCGyxC","ywnR","twHvC3i","twn4BKO","B3jL","BwXlBKK","AuvXvKO","x2LUDgvYDMe","AujOtuO","uMLyyuu","s29XzMK","wvDNz3q","B25tDg9Wsw0","CgfYC2u","tun2DxK","CLLJANe","vePRy3i","zMXVB3i","ExbL","CgXLyxnLiha","wgTdENe","wxnWyxq","C0jf","qK1ZvMS","x29Ut3bLBG","DxbNCMfKzw4","vLzxAwC","tMj0qvy","ihzHBgLKihm","C2HrCfm","ANzwCLG","DgLTzw91Da","rMPbufm","tLfisei","ChfACuG","D1vAtwi","EvrpsNq","CLzHBhvLCW","s0npAhG","B0Tyqxq","x2LZtwLUAvq","x29UrxjYB3i","x3bPBMDqB24","Ef9MCM9UDgK","yNDkCxC","AxnAzxjV","y3ruAw1LB3u","zwrtv2S","B2zMBgLUzq","rffnshq","zMzLCG","BfHoteS","BwLUzW","Ewr3qw4","CMfNzvn5BMm","CMLLC0nVDw4","B25Uzwn0Aw4","BMDuAw1LCG","De5pr3a","DxnKBxa","CM9YrxzLBNq","A1n0yxr1C0m","y3vYCMvUDeu","zMzmAw5L","nhWZFdj8mxW","yxv0B21HDgK","sNDmDKW","vxHit2G","y3vYCMvUDeK","BMrWB2LUDfq","Bwf4tg9ZC0m","Dvn5Buu","EwzcCvu","wvHStKy","CMrcCKG","u1joB3q","x2rLyNvN","twLZC2LUzYa","EhjgvKi","suHyEfu","Ew9lrNO","x29UvgLTzw8","BKPwvvC","AM9PBG","CgnSyMq","v2vIu29JA2u","ywnOzwqSihC","B2jYzuG","DxrzrhG","zwnVBM5Ly3q","uMTjwgy","AKHvDuq","quvVEee","x2nSzwfYugK","z2v0u3rVCMe","zwn0","Dg9hzw5LCMe","qLDdwLa","q0Xpu0ve","zxjFywnRx20","ChjVDg9JB2W","ug9Mq1C","igzPzwXKoIa","zwPuyuG","uNnKzuO","zeTPuKK","BMfTzq","DMvY","yw9nugO","Bwv0Ag9K","wffxs2O","tMLtD2e","yw5ZzM9YBvq","wfnmBLm","D2P2rKG","shbwD1m","B3zUtwi","Ae9Wzw5fDMu","CgLpBxa","swXvv0e","De1HBMfNzxi","D05lCfG","u1D1svy","Dhv0s1u","Dgv4DfbHEwW","yw1L","ywvMwwG","t1jmBe4","rK9ABfq","yLLRqvG","vKT0tKi","uMvJB25Uzwm","B3nLza","sgXLrLm","yMfJA3vWigu","sM9wDw4","BwfW","tgr0Ee0","mZeYotm4vxn1sunN","s3jVBhm","sLnJwuu","q09oveLovuu","yNDRvuW","u0vqALi","DLHWrMu","Cgf5Bg9Hzfq","zxjFBxnNAwq","uxrWCM8","zwfMz20","tMHbtK8","EgrRwgq","ywDLu2HVDW","CNv6whm","uKr2uxi","DgHHBIbSB2m","CgfNzxnOB3C","Cwz4C3O","zxH0ugf5Bg8","BNruCMLLC0m","yw5Nzq","yMvUsxa","rwLVrK8","tKDFrvjst1i","nhWZFdf8mhW","y29TCgXLDgu","wNDptgq","DeT3t2m","uNfMq0O","ruHwtwC","weXiBxu","uLnPtuy","ueXMsMi","B2Hjq0m","zw1LBNq","Ae9SyM4","BwfUDwfSihi","EvjLy29UBMu","vgLTzw91Da","D0T4rgW","wfzlrum","uwnjz0G","Aw5JBhvKzxm","Dw5RBM93BIa","zgHQzxy","EhLrtNG","zwrPyxrLBhK","B3jpBMXPBMu","tMjQveW","ENvVtuO","DMfSDwu","sgDnENu","zgvS","zNjVBNrPzxi","BhziCM4","C09PCg8","twHyqwO","DhjPzxmGCMu","t1bftL9fuLi","y1nOyMm","rgTOAvq","swPVDNC","EK9sqM8","sKzNvxi","x2rItMfTzq","u2jzuLa","ywHSqwm","EuD3zu0","EKXbqNy","suz2vvO","yM9L","ywDgq0C","x0vysvnu","ruLvDwC","ChbSugm","qNjPzgDL","vNnTvgK","mJi5nJaZmfjKrfbtzG","rKD1D1K","q0zeEg0","C3rVCMu","id4G","BwLZzq","Awzgz1m","D2j4BKq","weTrAuS","x2n1CNnVCKy","ywD5Beu","wwnQC3G","vu94BLO","qMn4yKW","yMfSrxzLBNq","Ahr0Chm6","B25LCNjVCG","uMzVv1a","C0Xf","DhLZD0S","t1DPC3a","y29UBMvJDca","x3vYBa","DvDwqK0","ihrVihjLDhi","tMX3Cue","v2LUzg93","A3reveC","shL4Dgq","r0nLDhi","Efrurw52","BfngCxC","zgrJuwK","B25ozxr3B3i","CIb0DhDjra","s25KrMi","DcbSAw1PDa","r055rfq","AND3s28","y2XLyxjtDg8","suXhrw4","zvnvExu","x2rYB3bhBg8","u0HduMO","Dhr3Awq","pxv0zI04","C2vUza","rMfnBfy","u2HHCMvKv28","wKD2yNe","yNL0zxm","qxjuEgS","ChPqtNe","wKftsem","DKLNvgO","yw5Hz2vY","BwvKAwf0zwW","D2TPyLO","zKLHDKy","yMTwDei","s1LLAha","shfotNi","yNL0zuXLBMC","DhbizwfKzxi","DM1Pt1O","D3m6lY8","ihzHBgLKigq","ihn1y2nLC3m","rhHUELG","x2LUAxrqCM8","tfPUzeS","A3HYCKW","ELnjANu","zNjHBwvuExa","x3bHDgHlzxK","twr1zwC","yxv0BW","zxjFDhrS","AgzVue4","Bg9Nsurhzw4","x3jLBw92zvC","vxrhzvC","vw5Oyw5KBgu","ze5cq1a","C0Doq1C","CM92AwrLigi","zhvvs0O","uKTHrw0","shLjAM8","z1jIsM4","B25SAw5L","AuHmANK","zw5HyMXLvhi","vMn2swW","C3jADgG","nKnXvenbuG","D3rqBue","swzWEuS","svniy1G","BMDusuC","ANnyv0i","B2jQzwn0u3q","ign1CNnVCIa","CMvWBgfJzui","qxz2zxe","zMzMzG","BNDiy0G","yxnJCMLWDa","A3zZsw0","CNHUruC","BMDLza","DgfYz2v0","Ce94D1i","Bu9nDNe","AMr3sLe","BgLUzq","Ec1TC2CTy3u","rMPrAM4","zxfiCu4","svb0uMS","DwPZvuu","BhrPCgXLihq","vfDOsM0","y3r4","vfPuA0u","yxjYyxLIDwy","yvbvsfO","z1zsrNK","ExDStfG","ENv3wNe","DLrMzNm","tMfTzq","C3rVCcbPBw0","r21ABwy","x3jLywr5q2W","vNrnyNa","yM5wC3e","B21Mr08","v3PrENK","vKzlyuq","y3vYDMfSDwu","AhbzEfm","y21Mshy","AeXvs1i","D2rLD3K","z3HcyNi","y3rNCwO","y3vZDg9Tshq","DNnRAKy","DgLUzYbZzxi","DKn5BMC","BM5Ly3q","B3jLtMfTzxm","Bg9NsurozxC","A3HjyK8","uLDNsKC","DMrirgq","v1vSAKm","CKf1quq","AwDHDg9Yt24","uwn3EKm","zKTusxO","Aw9U","BKPhvwq","sNfktNO","Avzrsgu","BhrMtum","Cgf5Bg9Hzeu","rNb5tK4","yxnZAwDU","yKDSAK8","CgvlzMG","ywnRx2nVzgu","qMX6Cvq","zuXlAuK","C2v0u3rVCMe","tg9Nsuq","ELzXueO","CgvYC2LZDgu","Bwu6ia","C2HPzNq","rNzVseK","B25JBg9Zzq","ve9nuhG","Dgj1reK","CuXpsMi","x2n1CNnVCK0","yxbWBhK","wuPsBK4","vK90zhC","sxvUBhi","u2vYDMLJzvC","sxDJBeS","yxnL","CLHjzNK","uMzet3q","rfjouNm","vLrnt0C","qxL5BMi","DhjLruW","tK5qDwG","CMvQzwn0","x3nLBMrby2S","z1PItxu","CLzvquu","zuPkv0i","uxzrAvm","Aw10rK0","BKPrzvi","re1QBuO","qLjwAuG","zgf0yq","ufzbuKK","CwvpA0O","vxbKyxrLq28","zK5Hwwy","rMrHuMi","zgvSzxrL","EKDnzgG","x2rPC2nVBM4","m3WYFdb8nhW","x2LZtM9Kzq","reP0zKq","EvPouKC","wgzpB2y","u2fjv0m","tMHutfy","CMvWBgfJzq","zM9YrwfJAa","x2DLDeLUDgu","y3vYC29Yx24","shfdwfO","qxfetgm","swrXr1K","wgHMqM0","r2P1Ag8","t3rMDNy","zfPXAgi","wvjct2S","BhPfu2G","u0DmExK","v2Hcy3q","AwXSihvZzsa","CKTXwKO","uMrNthK","uKH2Dwq","ChjVy2vZCW","Dhz5ueu","rMLXr2e","Dgv4Dc9Qyxy","Bg5or3e","ig1LC3nHz2u","mxWYFdb8nxW","Ew50vgy","C29YDa","qM1bvgO","CvDlugC","uNHUv04","y3fIuLO","BKXPBMu","v2XuyKC","sezfwxq","yNPluNi","suPivw4","DvnNuwO","CYbHBhjLywq","AKfmAei","wfnkB1C","EfrRtNm","z2vjBMzVu3K","D24GCMvHC28","q2fvDeK","AunZB3i","zw5HyMXLuw8","z2v0sxrLBq","qvLezM4","wuLlque","B2fK","x19LC01Vzhu","x3nLCuLK","sKDoAvC","BNz3AxG","BvjPEgm","Aw50zwDLCIa","twvZC2fNzuu","vLbKzeK","AKTSrg8","wevhrhm","q3vNzwG","DMvYC2LVBMm","AxnrB1nby2S","uK5oAwW","wLnTC0C","Dg9cExrLC0W","yvbvy0K","CMvZDwX0","yxbWzw5Kq2G","CM92AwrLige","yMLUyxj5vhK","AfrtAKy","m3WX","zNjVBuj5Dgu","AevQBeC","ywrK","DhDIs0q","ufDzAKe","swHXqNe","r3zQqNu","CMvZB2X2zq","x2rLC3rYB3K","rxzLBNq","quTVs2K","DwDmz3G","Dhj1y3rVCIa","q0Xpu0LorW","reLNsgq","EgnuBKK","zxjYtxnN","yxKSig5LDhC","CgLUz19VBMm","tuvtu0fhrv8","Aw9Ul2PZB24","whzVA2K","y09Wzw4","ELjLtwW","BfDVwK4","z2u6ia","ENjtwgu","r1bkCum","zfjmBgK","q3vZDg9Trxi","AwrTq2O","AMvJDfn0B3i","lcbTyxGGCMu","BMnVzgLUzW","aaaaaaaaaaa","D0nyyMC","C3nrDwK","tMrsuMS","ANr5zwm","yMXVy2TLza","C2vYDMLJzs0","u2n6y3C","zgvJB2rLzey","AxnbCNjHEq","rwDutLC","B3bLCNr5","C2v0sxrLBq","B25mAw5L","thzMB08","CKPqr1e","x2HHBMrSzva","qvjmvu4","Ae1LC3nHz2u","u2jKu08","DgfIyxnL","Aw9syK4","qxzkvLO","uNH6zxC","DgPnEwW","zxjFCw9Z","zMLUza","vLrABxe","DMvUDa","z3PyvNi","Bef6DNK","B3DTsLu","DgLLCKPtt04","D3fsuwi","uuHtz0K","D05fD0C","s3PJzxy","r1zXA08","qw1VDw50","EuHdBhy","yMTcAMu","uLjpuG","tfbqBe8","v0jruxi","z2v0q3vYC28"];return Wo=function(){return t},Wo()}Object["definePr"+M(1418)](Te,M(1350)+"le",{value:!0})});import{existsSync as nv,openSync as rv}from"node:fs";import{mkdir as iv}from"node:fs/promises";import{dirname as sv}from"node:path";import{fileURLToPath as ov}from"node:url";function cv(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Od(t=ee()){return nv(t.libEntry)?t.libEntry:ov(new URL("../index.ts",import.meta.url))}async function Ch(t={}){let e=t.paths??ee(),r=t.entryOverride??Od(e),i=cv(e,process.env.COZE_BRIDGE_LOG_MODE);await iv(sv(i),{recursive:!0});let o=rv(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=nt(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[es]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return av.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var av,es,Zo=Ye(()=>{"use strict";Wt();re();Le();av=q("spawn-daemon"),es="COZE_BRIDGE_DAEMON"});import{spawn as tS}from"node:child_process";import{mkdir as nS,unlink as rS,writeFile as iS}from"node:fs/promises";import{dirname as sS,join as oS}from"node:path";function Kr(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function aS(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Kr(r)}</key>
21
+ <string>${Kr(i)}</string>`).join(`
22
22
  `);return e?`
23
23
  <key>EnvironmentVariables</key>
24
24
  <dict>
25
25
  ${e}
26
- </dict>`:""}function H1(t,e){return new Promise((r,i)=>{let o=B1(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 $r,rs,na,Fd,qh=Ye(()=>{"use strict";te();$r=q("supervisor.launchd"),rs="ai.coze.bridge",na=H1,Fd={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
26
+ </dict>`:""}function cS(t,e){return new Promise((r,i)=>{let o=tS(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 Wr,ns,ra,Gd,Vh=Ye(()=>{"use strict";re();Wr=q("supervisor.launchd"),ns="ai.coze.bridge",ra=cS,Gd={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
27
27
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
28
28
  <plist version="1.0">
29
29
  <dict>
30
30
  <key>Label</key>
31
- <string>${rs}</string>
31
+ <string>${ns}</string>
32
32
  <key>ProgramArguments</key>
33
33
  <array>
34
- <string>${Vr(t.nodeBin)}</string>
35
- <string>${Vr(t.entry)}</string>
34
+ <string>${Kr(t.nodeBin)}</string>
35
+ <string>${Kr(t.entry)}</string>
36
36
  <string>--daemon</string>
37
37
  </array>
38
38
  <key>RunAtLoad</key>
@@ -42,13 +42,13 @@ ${e}
42
42
  <key>ThrottleInterval</key>
43
43
  <integer>10</integer>
44
44
  <key>StandardOutPath</key>
45
- <string>${Vr(t.logFile)}</string>
45
+ <string>${Kr(t.logFile)}</string>
46
46
  <key>StandardErrorPath</key>
47
- <string>${Vr(t.logFile)}</string>${j1(t.env)}
47
+ <string>${Kr(t.logFile)}</string>${aS(t.env)}
48
48
  </dict>
49
49
  </plist>
50
- `},configPath(t){return q1(t.homeDir,"Library","LaunchAgents",`${rs}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await z1(G1(i),{recursive:!0}),await U1(i,this.renderConfig(t),"utf8"),$r.info("plist written",{plistPath:i,activate:r}),!r)return;await na("launchctl",["unload","-w",i]).catch(c=>$r.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await na("launchctl",["load","-w",i]),$r.info("launchd job loaded",{label:rs});let o=process.getuid?.()??0;await na("launchctl",["kickstart","-k",`gui/${o}/${rs}`]),$r.info("launchd job kickstarted",{label:rs,uid:o})},async uninstall(t){let e=this.configPath(t);await na("launchctl",["unload","-w",e]).catch(r=>$r.warn("launchctl unload failed (ignored)",{err:String(r)})),await F1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),$r.info("launchd job removed",{plistPath:e})}}});import{spawn as W1}from"node:child_process";import{mkdir as K1,unlink as $1,writeFile as V1}from"node:fs/promises";import{dirname as J1,join as jh}from"node:path";function ia(t,e){return t.isRoot?e:["--user",...e]}function X1(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
51
- `):""}function sa(t,e){return new Promise((r,i)=>{let o=W1(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 ra,Jr,Z1,Ud,Hh=Ye(()=>{"use strict";te();ra=q("supervisor.systemd"),Jr="coze-bridge.service",Z1="/etc/systemd/system";Ud={platform:"linux",renderConfig(t){let e=t.isRoot?"multi-user.target":"default.target";return`[Unit]
50
+ `},configPath(t){return oS(t.homeDir,"Library","LaunchAgents",`${ns}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await nS(sS(i),{recursive:!0}),await iS(i,this.renderConfig(t),"utf8"),Wr.info("plist written",{plistPath:i,activate:r}),!r)return;await ra("launchctl",["unload","-w",i]).catch(c=>Wr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await ra("launchctl",["load","-w",i]),Wr.info("launchd job loaded",{label:ns});let o=process.getuid?.()??0;await ra("launchctl",["kickstart","-k",`gui/${o}/${ns}`]),Wr.info("launchd job kickstarted",{label:ns,uid:o})},async uninstall(t){let e=this.configPath(t);await ra("launchctl",["unload","-w",e]).catch(r=>Wr.warn("launchctl unload failed (ignored)",{err:String(r)})),await rS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Wr.info("launchd job removed",{plistPath:e})}}});import{spawn as dS}from"node:child_process";import{mkdir as lS,unlink as uS,writeFile as fS}from"node:fs/promises";import{dirname as xS,join as Jh}from"node:path";function sa(t,e){return t.isRoot?e:["--user",...e]}function pS(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
51
+ `):""}function oa(t,e){return new Promise((r,i)=>{let o=dS(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 ia,$r,hS,Hd,Zh=Ye(()=>{"use strict";re();ia=q("supervisor.systemd"),$r="coze-bridge.service",hS="/etc/systemd/system";Hd={platform:"linux",renderConfig(t){let e=t.isRoot?"multi-user.target":"default.target";return`[Unit]
52
52
  Description=Coze Bridge daemon
53
53
  After=network.target
54
54
 
@@ -59,10 +59,10 @@ Restart=always
59
59
  RestartSec=3
60
60
  StandardOutput=append:${t.logFile}
61
61
  StandardError=append:${t.logFile}
62
- ${X1(t.env)}
62
+ ${pS(t.env)}
63
63
  [Install]
64
64
  WantedBy=${e}
65
- `},configPath(t){return t.isRoot?jh(Z1,Jr):jh(t.homeDir,".config","systemd","user",Jr)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await K1(J1(i),{recursive:!0}),await V1(i,this.renderConfig(t),"utf8"),ra.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await sa("systemctl",ia(t,["daemon-reload"])),await sa("systemctl",ia(t,r?["enable","--now",Jr]:["enable",Jr])),ra.info("systemd unit enabled",{unitName:Jr,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await sa("systemctl",ia(t,["disable","--now",Jr])).catch(r=>ra.warn("systemctl disable failed (ignored)",{err:String(r)})),await $1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await sa("systemctl",ia(t,["daemon-reload"])).catch(()=>{}),ra.info("systemd unit removed",{unitPath:e})}}});import{spawn as Y1}from"node:child_process";import{join as Q1}from"node:path";function Wh(t,e){return new Promise((r,i)=>{let o=Y1(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 Gd,oa,qd,Kh=Ye(()=>{"use strict";te();Gd=q("supervisor.taskscheduler"),oa="CozeBridge",qd={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
65
+ `},configPath(t){return t.isRoot?Jh(hS,$r):Jh(t.homeDir,".config","systemd","user",$r)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await lS(xS(i),{recursive:!0}),await fS(i,this.renderConfig(t),"utf8"),ia.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await oa("systemctl",sa(t,["daemon-reload"])),await oa("systemctl",sa(t,r?["enable","--now",$r]:["enable",$r])),ia.info("systemd unit enabled",{unitName:$r,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await oa("systemctl",sa(t,["disable","--now",$r])).catch(r=>ia.warn("systemctl disable failed (ignored)",{err:String(r)})),await uS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await oa("systemctl",sa(t,["daemon-reload"])).catch(()=>{}),ia.info("systemd unit removed",{unitPath:e})}}});import{spawn as gS}from"node:child_process";import{join as mS}from"node:path";function Yh(t,e){return new Promise((r,i)=>{let o=gS(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 jd,aa,Wd,Xh=Ye(()=>{"use strict";re();jd=q("supervisor.taskscheduler"),aa="CozeBridge",Wd={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
66
66
  <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
67
67
  <RegistrationInfo>
68
68
  <Description>Coze Bridge daemon</Description>
@@ -86,45 +86,48 @@ WantedBy=${e}
86
86
  </Exec>
87
87
  </Actions>
88
88
  </Task>
89
- `},configPath(t){return Q1(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 Wh("schtasks",["/Create","/SC","ONLOGON","/TN",oa,"/TR",r,"/RU",t.userName,"/F"]),Gd.info("task scheduler entry created",{task:oa,logFile:t.logFile})},async uninstall(t){await Wh("schtasks",["/Delete","/TN",oa,"/F"]).catch(e=>Gd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Gd.info("task scheduler entry removed",{task:oa})}}});var $h={};ya($h,{buildContext:()=>sS,getSupervisor:()=>nS,launchdSupervisor:()=>Fd,systemdSupervisor:()=>Ud,taskSchedulerSupervisor:()=>qd});import{homedir as eS,userInfo as tS}from"node:os";function nS(t=process.platform){switch(t){case"darwin":return Fd;case"linux":return Ud;case"win32":return qd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function iS(){let t={};for(let e of rS){let r=process.env[e];r&&(t[e]=r)}return t}function sS(){let t=Y();return{nodeBin:process.execPath,entry:Rd(t),logFile:t.logFile,homeDir:eS(),userName:tS().username,isRoot:process.getuid?.()===0,env:iS()}}var rS,Vh=Ye(()=>{"use strict";Oe();Jo();qh();Hh();Kh();rS=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});te();on();var wl=q("acp-installer-warmup"),wg=["claude-code","codex"];async function _l(t={}){let e=t.ensure??ar,i=(await Promise.allSettled(wg.map(async o=>{let c=await e(o);wl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&wl.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}dn();te();import{readdir as Og}from"node:fs/promises";import{mkdir as vl,writeFile as Sl}from"node:fs/promises";import{join as Ta}from"node:path";var Pg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function lr(t,e,r){await vl(t,{recursive:!0});let i=Pg[e],o=Ta(t,i);return await Sl(o,r??"","utf8"),o}async function Al(t,e){let r=Ta(t,".claude");await vl(r,{recursive:!0});let i=Ta(r,"settings.local.json"),o={permissions:{defaultMode:"bypassPermissions"}};e==="cloud"&&(o.autoCompactWindow=15e4);let c=JSON.stringify(o,null,2);return await Sl(i,c,"utf8"),i}var Je=q("agent-detail-sync"),Lg=6e4,Ng=5*6e4,hs=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Og(r)}catch(o){Je.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Je.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await He(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Je.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){Je.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),Je.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){Je.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Je.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await He(e,this.opts.paths);if(!i){Je.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(x){Je.warn("detail RPC failed, using local data",{agentId:e,err:String(x)});let g=this.retryQueue.get(e),w=g?Math.min(g.currentDelay*2,Ng):Lg;this.retryQueue.set(e,{dueAt:Date.now()+w,currentDelay:w});return}if(o.agentId&&o.agentId!==e){Je.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;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);let u=!1;if(o.deployType==="cloud"&&i.deployType!=="cloud"?(Je.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&Je.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Je.debug("detail sync: no diff",{agentId:e});return}await et(i,this.opts.paths),Je.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),u?(await this.opts.agentManager.createAgent({agentId:e,framework:i.framework,_meta:{cozeDeployType:"cloud"},cozeIdentity:i.cozeIdentity,model:i.model}),Je.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):l&&(await lr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var G0=It(iu(),1);import{lstat as qc,mkdir as jc,readFile as B0,readdir as c_,rm as d_,stat as l_,writeFile as Hc}from"node:fs/promises";import{dirname as u_,join as Lt,normalize as f_,relative as $c,resolve as Wc,sep as z0}from"node:path";import{Readable as F0}from"node:stream";import{pipeline as U0}from"node:stream/promises";import rm from"events";import nt from"fs";import{EventEmitter as Ic}from"node:events";import Fu from"node:stream";import{StringDecoder as im}from"node:string_decoder";import qu from"node:path";import Er from"node:fs";import{dirname as mm,parse as wm}from"path";import{EventEmitter as Im}from"events";import ac from"assert";import{Buffer as jn}from"buffer";import*as du from"zlib";import Tm from"zlib";import{posix as pr}from"node:path";import{basename as ew}from"node:path";import Ks from"fs";import kt from"fs";import gu from"path";import{win32 as uw}from"node:path";import vu from"path";import r0 from"node:fs";import Dw from"node:assert";import{randomBytes as i0}from"node:crypto";import ne from"node:fs";import Ne from"node:path";import s0 from"fs";import to from"node:fs";import vi from"node:path";import st from"node:fs";import Nw from"node:fs/promises";import Js from"node:path";import{join as g0}from"node:path";import it from"node:fs";import _0 from"node:path";var tm=Object.defineProperty,nm=(t,e)=>{for(var r in e)tm(t,r,{get:e[r],enumerable:!0})},su=typeof process=="object"&&process?process:{stdout:null,stderr:null},sm=t=>!!t&&typeof t=="object"&&(t instanceof Kn||t instanceof Fu||om(t)||am(t)),om=t=>!!t&&typeof t=="object"&&t instanceof Ic&&typeof t.pipe=="function"&&t.pipe!==Fu.Writable.prototype.pipe,am=t=>!!t&&typeof t=="object"&&t instanceof Ic&&typeof t.write=="function"&&typeof t.end=="function",jt=Symbol("EOF"),Ht=Symbol("maybeEmitEnd"),un=Symbol("emittedEnd"),_s=Symbol("emittingEnd"),oi=Symbol("emittedError"),ys=Symbol("closed"),ou=Symbol("read"),bs=Symbol("flush"),au=Symbol("flushChunk"),pt=Symbol("encoding"),hr=Symbol("decoder"),ze=Symbol("flowing"),ai=Symbol("paused"),_r=Symbol("resume"),Fe=Symbol("buffer"),Ze=Symbol("pipes"),Ue=Symbol("bufferLength"),Oa=Symbol("bufferPush"),Es=Symbol("bufferShift"),$e=Symbol("objectMode"),ve=Symbol("destroyed"),La=Symbol("error"),Na=Symbol("emitData"),cu=Symbol("emitEnd"),Ma=Symbol("emitEnd2"),Dt=Symbol("async"),Ba=Symbol("abort"),vs=Symbol("aborted"),ci=Symbol("signal"),Ln=Symbol("dataListeners"),rt=Symbol("discarded"),di=t=>Promise.resolve().then(t),cm=t=>t(),dm=t=>t==="end"||t==="finish"||t==="prefinish",lm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,um=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Uu=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[_r](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},fm=class extends Uu{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)}},xm=t=>!!t.objectMode,hm=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Kn=class extends Ic{[ze]=!1;[ai]=!1;[Ze]=[];[Fe]=[];[$e];[pt];[Dt];[hr];[jt]=!1;[un]=!1;[_s]=!1;[ys]=!1;[oi]=null;[Ue]=0;[ve]=!1;[ci];[vs]=!1;[Ln]=0;[rt]=!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");xm(e)?(this[$e]=!0,this[pt]=null):hm(e)?(this[pt]=e.encoding,this[$e]=!1):(this[$e]=!1,this[pt]=null),this[Dt]=!!e.async,this[hr]=this[pt]?new im(this[pt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Fe]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ze]});let{signal:r}=e;r&&(this[ci]=r,r.aborted?this[Ba]():r.addEventListener("abort",()=>this[Ba]()))}get bufferLength(){return this[Ue]}get encoding(){return this[pt]}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[$e]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Dt]}set async(t){this[Dt]=this[Dt]||!!t}[Ba](){this[vs]=!0,this.emit("abort",this[ci]?.reason),this.destroy(this[ci]?.reason)}get aborted(){return this[vs]}set aborted(t){}write(t,e,r){if(this[vs])return!1;if(this[jt])throw new Error("write after end");if(this[ve])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[Dt]?di:cm;if(!this[$e]&&!Buffer.isBuffer(t)){if(um(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(lm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[$e]?(this[ze]&&this[Ue]!==0&&this[bs](!0),this[ze]?this.emit("data",t):this[Oa](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze]):t.length?(typeof t=="string"&&!(e===this[pt]&&!this[hr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[pt]&&(t=this[hr].write(t)),this[ze]&&this[Ue]!==0&&this[bs](!0),this[ze]?this.emit("data",t):this[Oa](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze]):(this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze])}read(t){if(this[ve])return null;if(this[rt]=!1,this[Ue]===0||t===0||t&&t>this[Ue])return this[Ht](),null;this[$e]&&(t=null),this[Fe].length>1&&!this[$e]&&(this[Fe]=[this[pt]?this[Fe].join(""):Buffer.concat(this[Fe],this[Ue])]);let e=this[ou](t||null,this[Fe][0]);return this[Ht](),e}[ou](t,e){if(this[$e])this[Es]();else{let r=e;t===r.length||t===null?this[Es]():typeof r=="string"?(this[Fe][0]=r.slice(t),e=r.slice(0,t),this[Ue]-=t):(this[Fe][0]=r.subarray(t),e=r.subarray(0,t),this[Ue]-=t)}return this.emit("data",e),!this[Fe].length&&!this[jt]&&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[jt]=!0,this.writable=!1,(this[ze]||!this[ai])&&this[Ht](),this}[_r](){this[ve]||(!this[Ln]&&!this[Ze].length&&(this[rt]=!0),this[ai]=!1,this[ze]=!0,this.emit("resume"),this[Fe].length?this[bs]():this[jt]?this[Ht]():this.emit("drain"))}resume(){return this[_r]()}pause(){this[ze]=!1,this[ai]=!0,this[rt]=!1}get destroyed(){return this[ve]}get flowing(){return this[ze]}get paused(){return this[ai]}[Oa](t){this[$e]?this[Ue]+=1:this[Ue]+=t.length,this[Fe].push(t)}[Es](){return this[$e]?this[Ue]-=1:this[Ue]-=this[Fe][0].length,this[Fe].shift()}[bs](t=!1){do;while(this[au](this[Es]())&&this[Fe].length);!t&&!this[Fe].length&&!this[jt]&&this.emit("drain")}[au](t){return this.emit("data",t),this[ze]}pipe(t,e){if(this[ve])return t;this[rt]=!1;let r=this[un];return e=e||{},t===su.stdout||t===su.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ze].push(e.proxyErrors?new fm(this,t,e):new Uu(this,t,e)),this[Dt]?di(()=>this[_r]()):this[_r]()),t}unpipe(t){let e=this[Ze].find(r=>r.dest===t);e&&(this[Ze].length===1?(this[ze]&&this[Ln]===0&&(this[ze]=!1),this[Ze]=[]):this[Ze].splice(this[Ze].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[rt]=!1,this[Ln]++,!this[Ze].length&&!this[ze]&&this[_r]();else if(t==="readable"&&this[Ue]!==0)super.emit("readable");else if(dm(t)&&this[un])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[oi]){let i=e;this[Dt]?di(()=>i.call(this,this[oi])):i.call(this,this[oi])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Ln]=this.listeners("data").length,this[Ln]===0&&!this[rt]&&!this[Ze].length&&(this[ze]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Ln]=0,!this[rt]&&!this[Ze].length&&(this[ze]=!1)),e}get emittedEnd(){return this[un]}[Ht](){!this[_s]&&!this[un]&&!this[ve]&&this[Fe].length===0&&this[jt]&&(this[_s]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ys]&&this.emit("close"),this[_s]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==ve&&this[ve])return!1;if(t==="data")return!this[$e]&&!r?!1:this[Dt]?(di(()=>this[Na](r)),!0):this[Na](r);if(t==="end")return this[cu]();if(t==="close"){if(this[ys]=!0,!this[un]&&!this[ve])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[oi]=r,super.emit(La,r);let o=!this[ci]||this.listeners("error").length?super.emit("error",r):!1;return this[Ht](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ht](),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[Ht](),i}[Na](t){for(let r of this[Ze])r.dest.write(t)===!1&&this.pause();let e=this[rt]?!1:super.emit("data",t);return this[Ht](),e}[cu](){return this[un]?!1:(this[un]=!0,this.readable=!1,this[Dt]?(di(()=>this[Ma]()),!0):this[Ma]())}[Ma](){if(this[hr]){let e=this[hr].end();if(e){for(let r of this[Ze])r.dest.write(e);this[rt]||super.emit("data",e)}}for(let e of this[Ze])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[$e]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[$e]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[$e])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[pt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ve,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[rt]=!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[jt])return e();let i,o,c=g=>{this.off("data",l),this.off("end",u),this.off(ve,x),e(),o(g)},l=g=>{this.off("error",c),this.off("end",u),this.off(ve,x),this.pause(),i({value:g,done:!!this[jt]})},u=()=>{this.off("error",c),this.off("data",l),this.off(ve,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((g,w)=>{o=w,i=g,this.once(ve,x),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[rt]=!1;let t=!1,e=()=>(this.pause(),this.off(La,e),this.off(ve,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(La,e),this.once(ve,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[ve])return t?this.emit("error",t):this.emit(ve),this;this[ve]=!0,this[rt]=!0,this[Fe].length=0,this[Ue]=0;let e=this;return typeof e.close=="function"&&!this[ys]&&e.close(),t?this.emit("error",t):this.emit(ve),this}static get isStream(){return sm}},pm=nt.writev,bn=Symbol("_autoClose"),_t=Symbol("_close"),li=Symbol("_ended"),ae=Symbol("_fd"),za=Symbol("_finished"),Vt=Symbol("_flags"),Fa=Symbol("_flush"),sc=Symbol("_handleChunk"),oc=Symbol("_makeBuf"),bi=Symbol("_mode"),Ss=Symbol("_needDrain"),Sr=Symbol("_onerror"),Ar=Symbol("_onopen"),Ua=Symbol("_onread"),yr=Symbol("_onwrite"),En=Symbol("_open"),wt=Symbol("_path"),gn=Symbol("_pos"),Ct=Symbol("_queue"),br=Symbol("_read"),Ga=Symbol("_readSize"),$t=Symbol("_reading"),ui=Symbol("_remain"),qa=Symbol("_size"),Ls=Symbol("_write"),Nn=Symbol("_writing"),Ns=Symbol("_defaultFlag"),qn=Symbol("_errored"),Tc=class extends Kn{[qn]=!1;[ae];[wt];[Ga];[$t]=!1;[qa];[ui];[bn];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[qn]=!1,this[ae]=typeof e.fd=="number"?e.fd:void 0,this[wt]=t,this[Ga]=e.readSize||16*1024*1024,this[$t]=!1,this[qa]=typeof e.size=="number"?e.size:1/0,this[ui]=this[qa],this[bn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ae]=="number"?this[br]():this[En]()}get fd(){return this[ae]}get path(){return this[wt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[En](){nt.open(this[wt],"r",(t,e)=>this[Ar](t,e))}[Ar](t,e){t?this[Sr](t):(this[ae]=e,this.emit("open",e),this[br]())}[oc](){return Buffer.allocUnsafe(Math.min(this[Ga],this[ui]))}[br](){if(!this[$t]){this[$t]=!0;let t=this[oc]();if(t.length===0)return process.nextTick(()=>this[Ua](null,0,t));nt.read(this[ae],t,0,t.length,null,(e,r,i)=>this[Ua](e,r,i))}}[Ua](t,e,r){this[$t]=!1,t?this[Sr](t):this[sc](e,r)&&this[br]()}[_t](){if(this[bn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,nt.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Sr](t){this[$t]=!0,this[_t](),this.emit("error",t)}[sc](t,e){let r=!1;return this[ui]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ui]<=0)&&(r=!1,this[_t](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ae]=="number"&&this[br](),!1;case"error":return this[qn]?!1:(this[qn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},gm=class extends Tc{[En](){let t=!0;try{this[Ar](null,nt.openSync(this[wt],"r")),t=!1}finally{t&&this[_t]()}}[br](){let t=!0;try{if(!this[$t]){this[$t]=!0;do{let e=this[oc](),r=e.length===0?0:nt.readSync(this[ae],e,0,e.length,null);if(!this[sc](r,e))break}while(!0);this[$t]=!1}t=!1}finally{t&&this[_t]()}}[_t](){if(this[bn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,nt.closeSync(t),this.emit("close")}}},Zs=class extends rm{readable=!1;writable=!0;[qn]=!1;[Nn]=!1;[li]=!1;[Ct]=[];[Ss]=!1;[wt];[bi];[bn];[ae];[Ns];[Vt];[za]=!1;[gn];constructor(t,e){e=e||{},super(e),this[wt]=t,this[ae]=typeof e.fd=="number"?e.fd:void 0,this[bi]=e.mode===void 0?438:e.mode,this[gn]=typeof e.start=="number"?e.start:void 0,this[bn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[gn]!==void 0?"r+":"w";this[Ns]=e.flags===void 0,this[Vt]=e.flags===void 0?r:e.flags,this[ae]===void 0&&this[En]()}emit(t,...e){if(t==="error"){if(this[qn])return!1;this[qn]=!0}return super.emit(t,...e)}get fd(){return this[ae]}get path(){return this[wt]}[Sr](t){this[_t](),this[Nn]=!0,this.emit("error",t)}[En](){nt.open(this[wt],this[Vt],this[bi],(t,e)=>this[Ar](t,e))}[Ar](t,e){this[Ns]&&this[Vt]==="r+"&&t&&t.code==="ENOENT"?(this[Vt]="w",this[En]()):t?this[Sr](t):(this[ae]=e,this.emit("open",e),this[Nn]||this[Fa]())}end(t,e){return t&&this.write(t,e),this[li]=!0,!this[Nn]&&!this[Ct].length&&typeof this[ae]=="number"&&this[yr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[li]?(this.emit("error",new Error("write() after end()")),!1):this[ae]===void 0||this[Nn]||this[Ct].length?(this[Ct].push(t),this[Ss]=!0,!1):(this[Nn]=!0,this[Ls](t),!0)}[Ls](t){nt.write(this[ae],t,0,t.length,this[gn],(e,r)=>this[yr](e,r))}[yr](t,e){t?this[Sr](t):(this[gn]!==void 0&&typeof e=="number"&&(this[gn]+=e),this[Ct].length?this[Fa]():(this[Nn]=!1,this[li]&&!this[za]?(this[za]=!0,this[_t](),this.emit("finish")):this[Ss]&&(this[Ss]=!1,this.emit("drain"))))}[Fa](){if(this[Ct].length===0)this[li]&&this[yr](null,0);else if(this[Ct].length===1)this[Ls](this[Ct].pop());else{let t=this[Ct];this[Ct]=[],pm(this[ae],t,this[gn],(e,r)=>this[yr](e,r))}}[_t](){if(this[bn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,nt.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Gu=class extends Zs{[En](){let t;if(this[Ns]&&this[Vt]==="r+")try{t=nt.openSync(this[wt],this[Vt],this[bi])}catch(e){if(e?.code==="ENOENT")return this[Vt]="w",this[En]();throw e}else t=nt.openSync(this[wt],this[Vt],this[bi]);this[Ar](null,t)}[_t](){if(this[bn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,nt.closeSync(t),this.emit("close")}}[Ls](t){let e=!0;try{this[yr](null,nt.writeSync(this[ae],t,0,t.length,this[gn])),e=!1}finally{if(e)try{this[_t]()}catch{}}}},_m=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"]]),ym=t=>!!t.sync&&!!t.file,bm=t=>!t.sync&&!!t.file,Em=t=>!!t.sync&&!t.file,vm=t=>!t.sync&&!t.file,Sm=t=>!!t.file,Am=t=>_m.get(t)||t,Dc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=Am(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Ri=(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 x=Dc(c);if(o?.(x,l),ym(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(bm(x)){let g=e(x,l);return u?g.then(()=>u(),u):g}else if(Em(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,l)}else if(vm(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(x,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),Dm=Tm.constants||{ZLIB_VERNUM:4736},Ot=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},Dm)),Cm=jn.concat,lu=Object.getOwnPropertyDescriptor(jn,"concat"),Rm=t=>t,ja=lu?.writable===!0||lu?.set!==void 0?t=>{jn.concat=t?Rm:Cm}:t=>{},Hn=Symbol("_superWrite"),As=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},Ha=Symbol("flushFlag"),Cc=class extends Kn{#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 du[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new du[e](t)}catch(r){throw new As(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 As(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ac(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(jn.alloc(0),{[Ha]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[Hn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=jn.from(t,e)),this.#e)return;ac(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},ja(!0);let l;try{let x=typeof t[Ha]=="number"?t[Ha]:this.#r;l=this.#t._processChunk(t,x),ja(!1)}catch(x){ja(!1),this.#o(new As(x,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",x=>this.#o(new As(x,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];u=this[Hn](jn.from(x));for(let g=1;g<l.length;g++)u=this[Hn](l[g])}else u=this[Hn](jn.from(l));return r&&r(),u}},ju=class extends Cc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Ot.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Ot.Z_FINISH,t.fullFlushFlag=Ot.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(Ot.Z_SYNC_FLUSH),ac(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)}}}},km=class extends ju{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Hn](t){return this.#e?(this.#e=!1,t[9]=255,super[Hn](t)):super[Hn](t)}},Pm=class extends ju{constructor(t){super(t,"Unzip")}},Hu=class extends Cc{constructor(t,e){t=t||{},t.flush=t.flush||Ot.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Ot.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Ot.BROTLI_OPERATION_FLUSH,super(t,e)}},Om=class extends Hu{constructor(t){super(t,"BrotliCompress")}},Lm=class extends Hu{constructor(t){super(t,"BrotliDecompress")}},Wu=class extends Cc{constructor(t,e){t=t||{},t.flush=t.flush||Ot.ZSTD_e_continue,t.finishFlush=t.finishFlush||Ot.ZSTD_e_end,t.fullFlushFlag=Ot.ZSTD_e_flush,super(t,e)}},Nm=class extends Wu{constructor(t){super(t,"ZstdCompress")}},Mm=class extends Wu{constructor(t){super(t,"ZstdDecompress")}},Bm=(t,e)=>{if(Number.isSafeInteger(t))t<0?Fm(t,e):zm(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},zm=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Fm=(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]=Ku(o):o===0?e[i-1]=0:(r=!0,e[i-1]=$u(o))}},Um=t=>{let e=t[0],r=e===128?qm(t.subarray(1,t.length)):e===255?Gm(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},Gm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Ku(c):c===0?l=c:(i=!0,l=$u(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},qm=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},Ku=t=>(255^t)&255,$u=t=>(255^t)+1&255,jm={};nm(jm,{code:()=>Rc,isCode:()=>Ms,isName:()=>Hm,name:()=>Xs});var Ms=t=>Xs.has(t),Hm=t=>Rc.has(t),Xs=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"]]),Rc=new Map(Array.from(Xs).map(t=>[t[1],t[0]])),Wn=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??Mn(t,e,100),this.mode=r?.mode??i?.mode??mn(t,e+100,8),this.uid=r?.uid??i?.uid??mn(t,e+108,8),this.gid=r?.gid??i?.gid??mn(t,e+116,8),this.size=r?.size??i?.size??mn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Wa(t,e+136,12),this.cksum=mn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Mn(t,e+156,1);if(Ms(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Mn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Mn(t,e+265,32),this.gname=r?.gname??i?.gname??Mn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??mn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??mn(t,e+337,8)??0,t[e+475]!==0){let l=Mn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Mn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??Wa(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Wa(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=Wm(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Bn(t,e,100,o)||this.needPax,this.needPax=wn(t,e+100,8,this.mode)||this.needPax,this.needPax=wn(t,e+108,8,this.uid)||this.needPax,this.needPax=wn(t,e+116,8,this.gid)||this.needPax,this.needPax=wn(t,e+124,12,this.size)||this.needPax,this.needPax=Ka(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Bn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Bn(t,e+265,32,this.uname)||this.needPax,this.needPax=Bn(t,e+297,32,this.gname)||this.needPax,this.needPax=wn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=wn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Bn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Bn(t,e+345,155,c)||this.needPax:(this.needPax=Bn(t,e+345,130,c)||this.needPax,this.needPax=Ka(t,e+476,12,this.atime)||this.needPax,this.needPax=Ka(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,wn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Xs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Rc.get(t));if(Ms(e)||e==="Unsupported")this.#e=e;else if(Ms(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Wm=(t,e)=>{let r=t,i="",o,c=pr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=pr.dirname(r),r=pr.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=pr.join(pr.basename(i),r),i=pr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Mn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Wa=(t,e,r)=>Km(mn(t,e,r)),Km=t=>t===void 0?void 0:new Date(t*1e3),mn=(t,e,r)=>Number(t[e])&128?Um(t.subarray(e,e+r)):Vm(t,e,r),$m=t=>isNaN(t)?void 0:t,Vm=(t,e,r)=>$m(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Jm={12:8589934591,8:2097151},wn=(t,e,r,i)=>i===void 0?!1:i>Jm[r]||i<0?(Bm(i,t.subarray(e,e+r)),!0):(Zm(t,e,r,i),!1),Zm=(t,e,r,i)=>t.write(Xm(i,r),e,r,"ascii"),Xm=(t,e)=>Ym(Math.floor(t).toString(8),e),Ym=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ka=(t,e,r,i)=>i===void 0?!1:wn(t,e,r,i.getTime()/1e3),Qm=new Array(156).join("\0"),Bn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Qm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Ws=class Vu{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 Wn({path:("PaxHeader/"+ew(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+`
90
- `,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 Vu(tw(nw(e),r),i)}},tw=(t,e)=>e?Object.assign({},e,t):t,nw=t=>t.replace(/\n$/,"").split(`
91
- `).reduce(rw,Object.create(null)),rw=(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},iw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=iw!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Ju=class extends Kn{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))))}},Ys=(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))},sw=1024*1024,cc=Buffer.from([31,139]),dc=Buffer.from([40,181,47,253]),ow=Math.max(cc.length,dc.length),ct=Symbol("state"),zn=Symbol("writeEntry"),Wt=Symbol("readEntry"),$a=Symbol("nextEntry"),uu=Symbol("processEntry"),Rt=Symbol("extendedHeader"),fi=Symbol("globalExtendedHeader"),fn=Symbol("meta"),fu=Symbol("emitMeta"),xe=Symbol("buffer"),Kt=Symbol("queue"),xn=Symbol("ended"),Va=Symbol("emittedEnd"),Fn=Symbol("emit"),Ce=Symbol("unzip"),Is=Symbol("consumeChunk"),Ts=Symbol("consumeChunkSub"),Ja=Symbol("consumeBody"),xu=Symbol("consumeMeta"),hu=Symbol("consumeHeader"),xi=Symbol("consuming"),Za=Symbol("bufferConcat"),Ds=Symbol("maybeEnd"),gr=Symbol("writing"),hn=Symbol("aborted"),Cs=Symbol("onDone"),Un=Symbol("sawValidEntry"),Rs=Symbol("sawNullBlock"),ks=Symbol("sawEOF"),pu=Symbol("closeStream"),aw=()=>!0,Ci=class extends Im{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Kt]=[];[xe];[Wt];[zn];[ct]="begin";[fn]="";[Rt];[fi];[xn]=!1;[Ce];[hn]=!1;[Un];[Rs]=!1;[ks]=!1;[gr]=!1;[xi]=!1;[Va]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Cs,()=>{(this[ct]==="begin"||this[Un]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Cs,t.ondone):this.on(Cs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||sw,this.filter=typeof t.filter=="function"?t.filter:aw;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[pu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ys(this,t,e,r)}[hu](t,e){this[Un]===void 0&&(this[Un]=!1);let r;try{r=new Wn(t,e,this[Rt],this[fi])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Rs]?(this[ks]=!0,this[ct]==="begin"&&(this[ct]="header"),this[Fn]("eof")):(this[Rs]=!0,this[Fn]("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 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[zn]=new Ju(r,this[Rt],this[fi]);if(!this[Un])if(o.remain){let c=()=>{o.invalid||(this[Un]=!0)};o.on("end",c)}else this[Un]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Fn]("ignoredEntry",o),this[ct]="ignore",o.resume()):o.size>0&&(this[fn]="",o.on("data",c=>this[fn]+=c),this[ct]="meta"):(this[Rt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Fn]("ignoredEntry",o),this[ct]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ct]="body":(this[ct]="header",o.end()),this[Wt]?this[Kt].push(o):(this[Kt].push(o),this[$a]())))}}}[pu](){queueMicrotask(()=>this.emit("close"))}[uu](t){let e=!0;if(!t)this[Wt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Wt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[$a]()),e=!1);return e}[$a](){do;while(this[uu](this[Kt].shift()));if(this[Kt].length===0){let t=this[Wt];!t||t.flowing||t.size===t.remain?this[gr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ja](t,e){let r=this[zn];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[ct]="header",this[zn]=void 0,r.end()),o.length}[xu](t,e){let r=this[zn],i=this[Ja](t,e);return!this[zn]&&r&&this[fu](r),i}[Fn](t,e,r){this[Kt].length===0&&!this[Wt]?this.emit(t,e,r):this[Kt].push([t,e,r])}[fu](t){switch(this[Fn]("meta",this[fn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Rt]=Ws.parse(this[fn],this[Rt],!1);break;case"GlobalExtendedHeader":this[fi]=Ws.parse(this[fn],this[fi],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Rt]??Object.create(null);this[Rt]=e,e.path=this[fn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Rt]||Object.create(null);this[Rt]=e,e.linkpath=this[fn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[hn]=!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[hn])return r?.(),!1;if((this[Ce]===void 0||this.brotli===void 0&&this[Ce]===!1)&&t){if(this[xe]&&(t=Buffer.concat([this[xe],t]),this[xe]=void 0),t.length<ow)return this[xe]=t,r?.(),!0;for(let l=0;this[Ce]===void 0&&l<cc.length;l++)t[l]!==cc[l]&&(this[Ce]=!1);let o=!1;if(this[Ce]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<dc.length;l++)if(t[l]!==dc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ce]===!1&&c)if(t.length<512)if(this[xn])this.brotli=!0;else return this[xe]=t,r?.(),!0;else try{new Wn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ce]===void 0||this[Ce]===!1&&(this.brotli||o)){let l=this[xn];this[xn]=!1,this[Ce]=this[Ce]===void 0?new Pm({}):o?new Mm({}):new Lm({}),this[Ce].on("data",x=>this[Is](x)),this[Ce].on("error",x=>this.abort(x)),this[Ce].on("end",()=>{this[xn]=!0,this[Is]()}),this[gr]=!0;let u=!!this[Ce][l?"end":"write"](t);return this[gr]=!1,r?.(),u}}this[gr]=!0,this[Ce]?this[Ce].write(t):this[Is](t),this[gr]=!1;let i=this[Kt].length>0?!1:this[Wt]?this[Wt].flowing:!0;return!i&&this[Kt].length===0&&this[Wt]?.once("drain",()=>this.emit("drain")),r?.(),i}[Za](t){t&&!this[hn]&&(this[xe]=this[xe]?Buffer.concat([this[xe],t]):t)}[Ds](){if(this[xn]&&!this[Va]&&!this[hn]&&!this[xi]){this[Va]=!0;let t=this[zn];if(t&&t.blockRemain){let e=this[xe]?this[xe].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[xe]&&t.write(this[xe]),t.end()}this[Fn](Cs)}}[Is](t){if(this[xi]&&t)this[Za](t);else if(!t&&!this[xe])this[Ds]();else if(t){if(this[xi]=!0,this[xe]){this[Za](t);let e=this[xe];this[xe]=void 0,this[Ts](e)}else this[Ts](t);for(;this[xe]&&this[xe]?.length>=512&&!this[hn]&&!this[ks];){let e=this[xe];this[xe]=void 0,this[Ts](e)}this[xi]=!1}(!this[xe]||this[xn])&&this[Ds]()}[Ts](t){let e=0,r=t.length;for(;e+512<=r&&!this[hn]&&!this[ks];)switch(this[ct]){case"begin":case"header":this[hu](t,e),e+=512;break;case"ignore":case"body":e+=this[Ja](t,e);break;case"meta":e+=this[xu](t,e);break;default:throw new Error("invalid state: "+this[ct])}e<r&&(this[xe]=this[xe]?Buffer.concat([t.subarray(e),this[xe]]):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[hn]||(this[Ce]?(t&&this[Ce].write(t),this[Ce].end()):(this[xn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Ds]())),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)},cw=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},Zu=(t,e)=>{let r=new Map(e.map(c=>[Ei(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||wm(c).root||".",x;if(c===u)x=!1;else{let g=r.get(c);x=g!==void 0?g:o(mm(c),u)}return r.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(Ei(c)):c=>o(Ei(c))},dw=t=>{let e=new Ci(t),r=t.file,i;try{i=Er.openSync(r,"r");let o=Er.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=Er.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 x=Er.readSync(i,u,0,c,l);if(x===0)break;l+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{Er.closeSync(i)}catch{}}},lw=(t,e)=>{let r=new Ci(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),Er.stat(o,(u,x)=>{if(u)l(u);else{let g=new Tc(o,{readSize:i,size:x.size});g.on("error",l),g.pipe(r)}})})},Ir=Ri(dw,lw,t=>new Ci(t),t=>new Ci(t),(t,e)=>{e?.length&&Zu(t,e),t.noResume||cw(t)}),Xu=(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:fw,parse:mu}=uw,kc=t=>{let e="",r=mu(t);for(;fw(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=mu(t)}return[e,t]},Qs=["|","<",">","?",":"],Pc=Qs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),xw=new Map(Qs.map((t,e)=>[t,Pc[e]])),hw=new Map(Pc.map((t,e)=>[t,Qs[e]])),wu=t=>Qs.reduce((e,r)=>e.split(r).join(xw.get(r)),t),pw=t=>Pc.reduce((e,r)=>e.split(r).join(hw.get(r)),t),Yu=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),Ei(e)+"/"+t):Z(t),gw=16*1024*1024,_u=Symbol("process"),yu=Symbol("file"),bu=Symbol("directory"),lc=Symbol("symlink"),Eu=Symbol("hardlink"),hi=Symbol("header"),Bs=Symbol("read"),uc=Symbol("lstat"),zs=Symbol("onlstat"),fc=Symbol("onread"),xc=Symbol("onreadlink"),hc=Symbol("openfile"),pc=Symbol("onopenfile"),_n=Symbol("close"),$s=Symbol("mode"),gc=Symbol("awaitDrain"),Xa=Symbol("ondrain"),Pt=Symbol("prefix"),Qu=class extends Kn{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=Dc(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||gw,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]=kc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=pw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||gu.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[zs](o):this[uc]()}warn(t,e,r={}){return Ys(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[uc](){kt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[zs](e)})}[zs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=_w(t),this.emit("stat",t),this[_u]()}[_u](){switch(this.type){case"File":return this[yu]();case"Directory":return this[bu]();case"SymbolicLink":return this[lc]();default:return this.end()}}[$s](t){return Xu(t,this.type==="Directory",this.portable)}[Pt](t){return Yu(t,this.prefix)}[hi](){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 Wn({path:this[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](this.linkpath):this.linkpath,mode:this[$s](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[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](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)}[bu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[hi](),this.end()}[lc](){kt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[xc](e)})}[xc](t){this.linkpath=Z(t),this[hi](),this.end()}[Eu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(gu.relative(this.cwd,t)),this.stat.size=0,this[hi](),this.end()}[yu](){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[Eu](e);this.linkCache.set(t,this.absolute)}if(this[hi](),this.stat.size===0)return this.end();this[hc]()}[hc](){kt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[pc](e)})}[pc](t){if(this.fd=t,this.#e)return this[_n]();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[Bs]()}[Bs](){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");kt.read(t,e,r,i,o,(c,l)=>{if(c)return this[_n](()=>this.emit("error",c));this[fc](l)})}[_n](t=()=>{}){this.fd!==void 0&&kt.close(this.fd,t)}[fc](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[_n](()=>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[_n](()=>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[Xa]():this[gc](()=>this[Xa]())}[gc](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)}[Xa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[_n](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[Bs]()}},mw=class extends Qu{sync=!0;[uc](){this[zs](kt.lstatSync(this.absolute))}[lc](){this[xc](kt.readlinkSync(this.absolute))}[hc](){this[pc](kt.openSync(this.absolute,"r"))}[Bs](){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=kt.readSync(e,r,i,o,c);this[fc](l),t=!1}finally{if(t)try{this[_n](()=>{})}catch{}}}[gc](t){t()}[_n](t=()=>{}){this.fd!==void 0&&kt.closeSync(this.fd),t()}},ww=class extends Kn{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 Ys(this,t,e,r)}constructor(t,e={}){let r=Dc(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[$s](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]=kc(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 Wn({path:this[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](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 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[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](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)}[Pt](t){return Yu(t,this.prefix)}[$s](t){return Xu(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}},_w=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",yw=class vr{tail;head;length=0;static create(e=[]){return new vr(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++)Ew(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)vw(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 vr;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 vr;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 vr;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 vr;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=bw(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 bw(t,e,r){let i=e,o=e?e.next:t.head,c=new Oc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function Ew(t,e){t.tail=new Oc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function vw(t,e){t.head=new Oc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Oc=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}},Su=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Au=Buffer.alloc(1024),Fs=Symbol("onStat"),pi=Symbol("ended"),gt=Symbol("queue"),gi=Symbol("queue"),pn=Symbol("current"),Gn=Symbol("process"),mi=Symbol("processing"),Ps=Symbol("processJob"),mt=Symbol("jobs"),Ya=Symbol("jobDone"),Us=Symbol("addFSEntry"),Iu=Symbol("addTarEntry"),mc=Symbol("stat"),wc=Symbol("readdir"),Gs=Symbol("onreaddir"),qs=Symbol("pipe"),Tu=Symbol("entry"),Qa=Symbol("entryOpt"),js=Symbol("writeEntryClass"),e0=Symbol("write"),ec=Symbol("ondrain"),eo=class extends Kn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[js];onWriteEntry;[gt];[gi]=new Map;[mt]=0;[mi]=!1;[pi]=!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[js]=Qu,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 km(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Om(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Nm(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[ec]()),this.on("resume",()=>e.resume())}else this.on("drain",this[ec]);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[gt]=new yw,this[mt]=0,this.jobs=Number(t.jobs)||4,this[mi]=!1,this[pi]=!1}[e0](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[pi]=!0,this[Gn](),r&&r(),this}write(t){if(this[pi])throw new Error("write after end");return t instanceof Ju?this[Iu](t):this[Us](t),this.flowing}[Iu](t){let e=Z(vu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Su(t.path,e);r.entry=new ww(t,this[Qa](r)),r.entry.on("end",()=>this[Ya](r)),this[mt]+=1,this[gt].push(r)}this[Gn]()}[Us](t){let e=Z(vu.resolve(this.cwd,t));this[gt].push(new Su(t,e)),this[Gn]()}[mc](t){t.pending=!0,this[mt]+=1;let e=this.follow?"stat":"lstat";Ks[e](t.absolute,(r,i)=>{t.pending=!1,this[mt]-=1,r?this.emit("error",r):this[Fs](t,i)})}[Fs](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[pn])this[Ps](t);else{let r=`${e.dev}:${e.ino}`,i=this[gi].get(r);i?i.push(t):this[gi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Gn]()}[wc](t){t.pending=!0,this[mt]+=1,Ks.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[mt]-=1,e)return this.emit("error",e);this[Gs](t,r)})}[Gs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Gn]()}[Gn](){if(!this[mi]){this[mi]=!0;for(let t=this[gt].head;t&&this[mt]<this.jobs;t=t.next)if(this[Ps](t.value),t.value.ignore){let e=t.next;this[gt].removeNode(t),t.next=e}this[mi]=!1,this[pi]&&this[gt].length===0&&this[mt]===0&&(this.zip?this.zip.end(Au):(super.write(Au),super.end()))}}get[pn](){return this[gt]&&this[gt].head&&this[gt].head.value}[Ya](t){this[gt].shift(),this[mt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[gi].get(r);if(i){this[gi].delete(r);for(let o of i)o.pending=!1,this[Ps](o)}}this[Gn]()}[Ps](t){if(t.pending&&t.pendingLink&&t===this[pn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[pn]&&!t.piped&&this[qs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Fs](t,e):this[mc](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[wc](t),!t.readdir)return}if(t.entry=this[Tu](t),!t.entry){t.ignore=!0;return}t===this[pn]&&!t.piped&&this[qs](t)}}}[Qa](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}}[Tu](t){this[mt]+=1;try{return new this[js](t.path,this[Qa](t)).on("end",()=>this[Ya](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[ec](){this[pn]&&this[pn].entry&&this[pn].entry.resume()}[qs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Us](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={}){Ys(this,t,e,r)}},Lc=class extends eo{sync=!0;constructor(t){super(t),this[js]=mw}pause(){}resume(){}[mc](t){let e=this.follow?"statSync":"lstatSync";this[Fs](t,Ks[e](t.absolute))}[wc](t){this[Gs](t,Ks.readdirSync(t.absolute))}[qs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Us](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[e0](i)})}},Sw=(t,e)=>{let r=new Lc(t),i=new Gu(t.file,{mode:t.mode||438});r.pipe(i),t0(r,e)},Aw=(t,e)=>{let r=new eo(t),i=new Zs(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 n0(r,e).catch(c=>r.emit("error",c)),o},t0=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Ir({file:qu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},n0=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Ir({file:qu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},Iw=(t,e)=>{let r=new Lc(t);return t0(r,e),r},Tw=(t,e)=>{let r=new eo(t);return n0(r,e).catch(i=>r.emit("error",i)),r},G2=Ri(Sw,Aw,Iw,Tw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Cw=process.env.__FAKE_PLATFORM__||process.platform,o0=Cw==="win32",{O_CREAT:a0,O_NOFOLLOW:Du,O_TRUNC:c0,O_WRONLY:d0}=s0.constants,l0=Number(process.env.__FAKE_FS_O_FILENAME__)||s0.constants.UV_FS_O_FILEMAP||0,Rw=o0&&!!l0,kw=512*1024,Pw=l0|c0|a0|d0,Cu=!o0&&typeof Du=="number"?Du|c0|a0|d0:null,u0=Cu!==null?()=>Cu:Rw?t=>t<kw?Pw:"w":()=>"w",_c=(t,e,r)=>{try{return to.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Vs=(t,e,r,i)=>{to.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Ow=(t,e,r,i,o)=>{if(e.isDirectory())f0(vi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=vi.resolve(t,e.name);Vs(l,r,i,o)});else{let c=vi.resolve(t,e.name);Vs(c,r,i,o)}},f0=(t,e,r,i)=>{to.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,x=g=>{if(!u){if(g)return i(u=g);if(--l===0)return Vs(t,e,r,i)}};for(let g of c)Ow(t,g,e,r,x)})},Lw=(t,e,r,i)=>{e.isDirectory()&&x0(vi.resolve(t,e.name),r,i),_c(vi.resolve(t,e.name),r,i)},x0=(t,e,r)=>{let i;try{i=to.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return _c(t,e,r);throw c}for(let o of i)Lw(t,o,e,r);return _c(t,e,r)},h0=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"}},no=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"}},Mw=(t,e)=>{st.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new h0(t,r?.code||"ENOTDIR")),e(r)})},Bw=(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,x=typeof l=="number"&&typeof u=="number"&&(l!==e.processUid||u!==e.processGid),g=e.preserve,w=e.unlink,E=Z(e.cwd),S=(v,A)=>{v?r(v):A&&x?f0(A,l,u,T=>S(T)):c?st.chmod(t,o,r):r()};if(t===E)return Mw(t,S);if(g)return Nw.mkdir(t,{mode:o,recursive:!0}).then(v=>S(null,v??void 0),S);let y=Z(Js.relative(E,t)).split("/");yc(E,y,o,w,E,void 0,S)},yc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),x=Z(Js.resolve(t+"/"+u));st.mkdir(x,r,p0(x,e,r,i,o,c,l))},p0=(t,e,r,i,o,c,l)=>u=>{u?st.lstat(t,(x,g)=>{if(x)x.path=x.path&&Z(x.path),l(x);else if(g.isDirectory())yc(t,e,r,i,o,c,l);else if(i)st.unlink(t,w=>{if(w)return l(w);st.mkdir(t,r,p0(t,e,r,i,o,c,l))});else{if(g.isSymbolicLink())return l(new no(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,yc(t,e,r,i,o,c,l))},zw=t=>{let e=!1,r;try{e=st.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new h0(t,r??"ENOTDIR")}},Fw=(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),x=e.preserve,g=e.unlink,w=Z(e.cwd),E=v=>{v&&u&&x0(v,c,l),o&&st.chmodSync(t,i)};if(t===w)return zw(w),E();if(x)return E(st.mkdirSync(t,{mode:i,recursive:!0})??void 0);let S=Z(Js.relative(w,t)).split("/"),y;for(let v=S.shift(),A=w;v&&(A+="/"+v);v=S.shift()){A=Z(Js.resolve(A));try{st.mkdirSync(A,i),y=y||A}catch{let T=st.lstatSync(A);if(T.isDirectory())continue;if(g){st.unlinkSync(A),st.mkdirSync(A,i),y=y||A;continue}else if(T.isSymbolicLink())return new no(A,A+"/"+S.join("/"))}}return E(y)},tc=Object.create(null),Ru=1e4,mr=new Set,Uw=t=>{mr.has(t)?mr.delete(t):tc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),mr.add(t);let e=tc[t],r=mr.size-Ru;if(r>Ru/10){for(let i of mr)if(mr.delete(i),delete tc[i],--r<=0)break}return e},Gw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,qw=Gw==="win32",jw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=g0(i,r)),e.push(r||"/"),e},[]),Hw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=qw?["win32 parallelization disabled"]:t.map(i=>Ei(g0(Uw(i))));let r=new Set(t.map(i=>jw(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 x of u)o.add(x)}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 x=l[0];typeof x=="function"&&o.add(x)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Ww=()=>process.umask(),ku=Symbol("onEntry"),bc=Symbol("checkFs"),Pu=Symbol("checkFs2"),Ec=Symbol("isReusable"),dt=Symbol("makeFs"),vc=Symbol("file"),Sc=Symbol("directory"),Hs=Symbol("link"),Ou=Symbol("symlink"),Lu=Symbol("hardlink"),yi=Symbol("ensureNoSymlink"),Nu=Symbol("unsupported"),Mu=Symbol("checkPath"),nc=Symbol("stripAbsolutePath"),yn=Symbol("mkdir"),Ge=Symbol("onError"),Os=Symbol("pending"),Bu=Symbol("pend"),wr=Symbol("unpend"),rc=Symbol("ended"),ic=Symbol("maybeClose"),Ac=Symbol("skip"),Si=Symbol("doChown"),Ai=Symbol("uid"),Ii=Symbol("gid"),Ti=Symbol("checkedCwd"),Kw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Di=Kw==="win32",$w=1024,Vw=(t,e)=>{if(!Di)return ne.unlink(t,e);let r=t+".DELETE."+i0(16).toString("hex");ne.rename(t,r,i=>{if(i)return e(i);ne.unlink(r,e)})},Jw=t=>{if(!Di)return ne.unlinkSync(t);let e=t+".DELETE."+i0(16).toString("hex");ne.renameSync(t,e),ne.unlinkSync(e)},zu=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Nc=class extends Ci{[rc]=!1;[Ti]=!1;[Os]=0;reservations=new Hw;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[rc]=!0,this[ic]()},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:$w,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Di,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Ne.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Ww():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[ku](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[ic](){this[rc]&&this[Os]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[nc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=kc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Di&&/^[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=Ne.posix.dirname(t.path),x=Ne.posix.normalize(Ne.posix.join(u,l.join("/")));if(x.startsWith("../")||x==="..")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}[Mu](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[nc](t,"path")||!this[nc](t,"linkpath"))return!1;if(t.absolute=Ne.isAbsolute(t.path)?Z(Ne.resolve(t.path)):Z(Ne.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}=Ne.win32.parse(String(t.absolute));t.absolute=i+wu(String(t.absolute).slice(i.length));let{root:o}=Ne.win32.parse(t.path);t.path=o+wu(t.path.slice(o.length))}return!0}[ku](t){if(!this[Mu](t))return t.resume();switch(Dw.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[bc](t);default:return this[Nu](t)}}[Ge](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[wr](),e.resume())}[yn](t,e,r){Bw(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)}[Si](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}[Ai](t){return zu(this.uid,t.uid,this.processUid)}[Ii](t){return zu(this.gid,t.gid,this.processGid)}[vc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Zs(String(t.absolute),{flags:u0(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ne.close(i.fd,()=>{}),i.write=()=>!0,this[Ge](u,t),e()});let o=1,c=u=>{if(u){i.fd&&ne.close(i.fd,()=>{}),this[Ge](u,t),e();return}--o===0&&i.fd!==void 0&&ne.close(i.fd,x=>{x?this[Ge](x,t):this[wr](),e()})};i.on("finish",()=>{let u=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let g=t.atime||new Date,w=t.mtime;ne.futimes(x,g,w,E=>E?ne.utimes(u,g,w,S=>c(S&&E)):c())}if(typeof x=="number"&&this[Si](t)){o++;let g=this[Ai](t),w=this[Ii](t);typeof g=="number"&&typeof w=="number"&&ne.fchown(x,g,w,E=>E?ne.chown(u,g,w,S=>c(S&&E)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[Ge](u,t),e()}),t.pipe(l)),l.pipe(i)}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[yn](String(t.absolute),r,i=>{if(i){this[Ge](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[wr](),t.resume())};t.mtime&&!this.noMtime&&(o++,ne.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[Si](t)&&(o++,ne.chown(String(t.absolute),Number(this[Ai](t)),Number(this[Ii](t)),c)),c()})}[Nu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Ou](t,e){let r=Z(Ne.relative(this.cwd,Ne.resolve(Ne.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[yi](t,this.cwd,r,()=>this[Hs](t,String(t.linkpath),"symlink",e),i=>{this[Ge](i,t),e()})}[Lu](t,e){let r=Z(Ne.resolve(this.cwd,String(t.linkpath))),i=Z(String(t.linkpath)).split("/");this[yi](t,this.cwd,i,()=>this[Hs](t,r,"link",e),o=>{this[Ge](o,t),e()})}[yi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Ne.resolve(e,c);ne.lstat(l,(u,x)=>{if(u)return i();if(x?.isSymbolicLink())return o(new no(l,Ne.resolve(l,r.join("/"))));this[yi](t,l,r,i,o)})}[Bu](){this[Os]++}[wr](){this[Os]--,this[ic]()}[Ac](t){this[wr](),t.resume()}[Ec](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Di}[bc](t){this[Bu]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Pu](t,r))}[Pu](t,e){let r=l=>{e(l)},i=()=>{this[yn](this.cwd,this.dmode,l=>{if(l){this[Ge](l,t),r();return}this[Ti]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Z(Ne.dirname(String(t.absolute)));if(l!==this.cwd)return this[yn](l,this.dmode,u=>{if(u){this[Ge](u,t),r();return}c()})}c()},c=()=>{ne.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Ac](t),r();return}if(l||this[Ec](t,u))return this[dt](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,g=w=>this[dt](w??null,t,r);return x?ne.chmod(String(t.absolute),Number(t.mode),g):g()}if(t.absolute!==this.cwd)return ne.rmdir(String(t.absolute),x=>this[dt](x??null,t,r))}if(t.absolute===this.cwd)return this[dt](null,t,r);Vw(String(t.absolute),x=>this[dt](x??null,t,r))})};this[Ti]?o():i()}[dt](t,e,r){if(t){this[Ge](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[vc](e,r);case"Link":return this[Lu](e,r);case"SymbolicLink":return this[Ou](e,r);case"Directory":case"GNUDumpDir":return this[Sc](e,r)}}[Hs](t,e,r,i){ne[r](e,String(t.absolute),o=>{o?this[Ge](o,t):(this[wr](),t.resume()),i()})}},wi=t=>{try{return[null,t()]}catch(e){return[e,null]}},m0=class extends Nc{sync=!0;[dt](t,e){return super[dt](t,e,()=>{})}[bc](t){if(!this[Ti]){let o=this[yn](this.cwd,this.dmode);if(o)return this[Ge](o,t);this[Ti]=!0}if(t.absolute!==this.cwd){let o=Z(Ne.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[yn](o,this.dmode);if(c)return this[Ge](c,t)}}let[e,r]=wi(()=>ne.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ac](t);if(e||this[Ec](t,r))return this[dt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?wi(()=>{ne.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[dt](l,t)}let[o]=wi(()=>ne.rmdirSync(String(t.absolute)));this[dt](o,t)}let[i]=t.absolute===this.cwd?[]:wi(()=>Jw(String(t.absolute)));this[dt](i,t)}[vc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{ne.closeSync(o)}catch(x){u=x}(l||u)&&this[Ge](l||u,t),e()},o;try{o=ne.openSync(String(t.absolute),u0(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[Ge](l,t)),t.pipe(c)),c.on("data",l=>{try{ne.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,x=t.mtime;try{ne.futimesSync(o,u,x)}catch(g){try{ne.utimesSync(String(t.absolute),u,x)}catch{l=g}}}if(this[Si](t)){let u=this[Ai](t),x=this[Ii](t);try{ne.fchownSync(o,Number(u),Number(x))}catch(g){try{ne.chownSync(String(t.absolute),Number(u),Number(x))}catch{l=l||g}}}i(l)})}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[yn](String(t.absolute),r);if(i){this[Ge](i,t),e();return}if(t.mtime&&!this.noMtime)try{ne.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Si](t))try{ne.chownSync(String(t.absolute),Number(this[Ai](t)),Number(this[Ii](t)))}catch{}e(),t.resume()}[yn](t,e){try{return Fw(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}}[yi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Ne.resolve(c,l);let[u,x]=wi(()=>ne.lstatSync(c));if(u)return i();if(x.isSymbolicLink())return o(new no(c,Ne.resolve(e,r.join("/"))))}i()}[Hs](t,e,r,i){let o=`${r}Sync`;try{ne[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[Ge](c,t)}}},Zw=t=>{let e=new m0(t),r=t.file,i=r0.statSync(r),o=t.maxReadSize||16*1024*1024;new gm(r,{readSize:o,size:i.size}).pipe(e)},Xw=(t,e)=>{let r=new Nc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),r0.stat(o,(u,x)=>{if(u)l(u);else{let g=new Tc(o,{readSize:i,size:x.size});g.on("error",l),g.pipe(r)}})})},w0=Ri(Zw,Xw,t=>new m0(t),t=>new Nc(t),(t,e)=>{e?.length&&Zu(t,e)}),Yw=(t,e)=>{let r=new Lc(t),i=!0,o,c;try{try{o=it.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=it.openSync(t.file,"w+");else throw x}let l=it.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let w=0,E=0;w<512;w+=E){if(E=it.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(!E)break e}let x=new Wn(u);if(!x.cksumValid)break;let g=512*Math.ceil((x.size||0)/512);if(c+g+512>l.size)break;c+=g,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Qw(t,r,c,o,e)}finally{if(i)try{it.closeSync(o)}catch{}}},Qw=(t,e,r,i,o)=>{let c=new Gu(t.file,{fd:i,start:r});e.pipe(c),t_(e,o)},e_=(t,e)=>{e=Array.from(e);let r=new eo(t),i=(o,c,l)=>{let u=(S,y)=>{S?it.close(o,v=>l(S)):l(null,y)},x=0;if(c===0)return u(null,0);let g=0,w=Buffer.alloc(512),E=(S,y)=>{if(S||y===void 0)return u(S);if(g+=y,g<512&&y)return it.read(o,w,g,w.length-g,x+g,E);if(x===0&&w[0]===31&&w[1]===139)return u(new Error("cannot append to compressed archives"));if(g<512)return u(null,x);let v=new Wn(w);if(!v.cksumValid)return u(null,x);let A=512*Math.ceil((v.size??0)/512);if(x+A+512>c||(x+=A+512,x>=c))return u(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),g=0,it.read(o,w,0,512,x,E)};it.read(o,w,0,512,x,E)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(x,g)=>{if(x&&x.code==="ENOENT"&&l==="r+")return l="w+",it.open(t.file,l,u);if(x||!g)return c(x);it.fstat(g,(w,E)=>{if(w)return it.close(g,()=>c(w));i(g,E.size,(S,y)=>{if(S)return c(S);let v=new Zs(t.file,{fd:g,start:y});r.pipe(v),v.on("error",c),v.on("close",o),n_(r,e)})})};it.open(t.file,l,u)})},t_=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Ir({file:_0.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},n_=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Ir({file:_0.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},_i=Ri(Yw,e_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Sm(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")}),nA=Ri(_i.syncFile,_i.asyncFile,_i.syncNoFile,_i.asyncNoFile,(t,e=[])=>{_i.validate?.(t,e),r_(t)}),r_=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))};dn();var yt={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 ro(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function y0(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Mc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function b0(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function Tr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Ve();te();Oe();Ve();function Jt(t,e){if(ro(t)!=="cloud")throw new C("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function io(t){return t.startsWith("http://")||t.startsWith("https://")}function so(t){return t.endsWith("/")?t.slice(0,-1):t}Ve();te();var oo="1008033",E0="1289";var v0="pbbp2",S0="https://www.coze.cn",A0="/api/coze_claw/resource/get_frontier_key",s_="https://www.coze.cn",o_="wss://frontier.coze.cn";function ao(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??s_}function I0(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??o_}function Dr(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 Pi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var ki=q("handshake");async function Bc(t){let e=ao(t.endpoint),r=t.timeoutMs??1e4,i=`${so(e)}${A0}?aid=${encodeURIComponent(oo)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Dr(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);ki.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=u.headers.get("x-tt-logid")??"",g=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${v.slice(0,200)}`)}let w=await u.json();if(w.code!==void 0&&w.code!==0)throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${x}`);let E=w.data??{},S=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,y=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!S||!y){let v=JSON.stringify(w).slice(0,500);throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return ki.info("handshake ok",{remoteDeviceId:y,logid:x,traceId:g}),{accessKey:S,deviceId:y}}catch(u){if(u instanceof C)throw ki.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw ki.warn("handshake timeout",{base:e,timeoutMs:r}),new C("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw ki.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 C("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(l)}}var zc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",bt="auto",T0=15e4;function D0(t){return{model:Fc(t.model)??bt,...t.modelToken?{modelToken:t.modelToken}:{}}}function C0(t){return!t||t===bt}var a_=new Set(["auto","\u81EA\u52A8"]);function Fc(t){let e=t?.trim();if(e)return a_.has(e.toLowerCase())?bt:e}function R0(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=zc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||bt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,e.CLAUDE_CODE_ATTRIBUTION_HEADER="0",t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else C0(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function k0(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||bt}"`):C0(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="${zc}/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"');let r=t.modelInfo?.contextWindow??T0;e.push("-c",`model_context_window=${r}`)}return e}function P0(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Uc(t,e){let{ttEnv:r,usePpe:i}=Pi(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function O0(t,e,r){if(!t.modelToken)return{};let i=Uc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
92
- `)}}function Gc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function L0(t,e,r){if(!t.modelToken)return null;let i=t.model||bt,o=Uc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${zc}/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??T0,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function N0(t,e,r){if(!t.modelToken)return[];let i=Uc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Me=q("agent-handlers"),M0=5*1024*1024,x_=1,h_=6,p_=new Set(["node_modules",".git",".coze","dist","build",".next"]),co=class{constructor(e){this.opts=e}opts;async listSkills(e){Jt(e._meta,"_agent/listSkills");let r=Tr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Qe(r).workspace,c=i?.skills??[],l=[];for(let u of c){let x=Lt(o,u.relPath,"SKILL.md");await l_(x).then(w=>w.isFile()).catch(()=>!1)&&l.push(y_(u))}return{skills:l}}async addSkills(e){Jt(e._meta,"_agent/addSkills");let r=Tr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((x,g)=>[x.skillId,g])),u=[];for(let x of o){let g=await Vc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Jc(c,l,g),u.push(x)}return await fs(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Jt(e._meta,"_agent/removeSkills");let r=Tr(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 x=Lt(i.workspace,u.relPath);await d_(x,{recursive:!0,force:!0}),Me.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await fs(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,Me.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let x=c.downstream;c.downstream=void 0,Me.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(r).catch(g=>Me.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(g)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Me.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await He(r);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Me.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await lr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Me.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new C("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await et(i),Me.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new C("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await He(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await et(i),Me.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}):(Me.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Jt(e._meta,"_agent/switchModel"),!e.agentId)throw new C("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Fc(e.model)??bt,i=await He(e.agentId);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await et(i),Me.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Me.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=>Me.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 x=o.sessions.get(l);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Me.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(Jt(e._meta,yt.RESET),!e.agentId)throw new C("IPC_BAD_REQUEST",`${yt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,yt.RESET),await this.runDetailSync(e.agentId,yt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Me.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await ii(e,o)}async clearPersistedAcpSessionIds(e){let r=await He(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await et(r)}async repairAgent(e){if(Jt(e._meta,yt.REPAIR),!e.agentId)throw new C("IPC_BAD_REQUEST",`${yt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new C("IPC_BAD_REQUEST",`${yt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Me.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,yt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Me.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Me.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Jt(e._meta,"_agent/getFileTree");let r=e._meta,i=Tr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await qc(l).catch(()=>null);if(!u)throw new C("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await ri(l,o))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=k_(e.depth);return u.isDirectory()?{tree:await R_(o,l,c,x)}:{tree:[{name:P_(c),path:j0(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Jt(e._meta,"_agent/getFileContent");let r=Tr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new C("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await qc(o).catch(()=>null);if(!c||!c.isFile())throw new C("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await ri(o,i))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>M0)throw new C("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${M0})`);let l=await B0(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await He(e).catch(()=>null))?.workspace??Qe(e).workspace}safeJoin(e,r){let i=Wc(e,r||"."),o=$c(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${z0}`))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return He(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new C("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function g_(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new C("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new C("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function m_(t){return t==="claude-code"?Lt(".claude","skills"):Lt(".agents","skills")}var w_=3e4,__=50*1024*1024,Cr=3e4;async function Vc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new C("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new C("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=g_(o.skillName),x=m_(i),g=Lt(x,u),w=Lt(r,g);if(await jc(w,{recursive:!0}),c){let S=Buffer.from(o.content,"utf8");Oi(S.length),await Hc(Lt(w,"SKILL.md"),S,"utf8")}else{let S=await b_(o.downloadUrl);v_(S)?await T_(S,w):S_(S)?await A_(S,w):await Hc(Lt(w,"SKILL.md"),S.toString("utf8"),"utf8")}let E={skillId:o.skillId,skillName:o.skillName,relPath:g,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 Me.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:g,source:c?"content":"downloadUrl"}),E}function Jc(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 y_(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 b_(t){if(!t)throw new C("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Oi(e);let r=E_(t);return Oi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await B0(e);return Oi(r.length),r}if(io(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),w_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new C("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Oi(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new C("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Oi(t){if(t>__)throw new C("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function E_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new C("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function v_(t){return t.length>=2&&t[0]===31&&t[1]===139}function S_(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 Kc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function A_(t,e){let r,i;try{r=new G0.default(t),i=r.getEntries()}catch(l){throw new C("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||Kc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new C("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(g=>g===".."))throw new C("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=l.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new C("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=I_(i),c=Wc(e);for(let l of i){if(Kc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let x=Wc(e,u),g=$c(c,x);if(g.startsWith("..")||g==="..")throw new C("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await jc(x,{recursive:!0});continue}await jc(u_(x),{recursive:!0});let w;try{w=l.getData()}catch(E){throw new C("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${E.message}`,{cause:E})}await Hc(x,w)}}function I_(t){let e;for(let r of t){let i=r.entryName;if(!i||Kc(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 T_(t,e){await D_(t);let r=w0({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar extract timeout (${Cr}ms)`))},Cr);try{await U0(F0.from(t),r)}catch(c){throw c instanceof C?c:i?new C("IPC_BAD_REQUEST",`tar extract timeout (${Cr}ms)`):new C("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function D_(t){let e=[],r=Ir({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(g=>g==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar list timeout (${Cr}ms)`))},Cr);try{await U0(F0.from(t),r)}catch(c){throw i?new C("IPC_BAD_REQUEST",`tar list timeout (${Cr}ms)`):new C("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new C("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var C_=5e3;async function R_(t,e,r,i){return q0(t,e,r,i,{count:0})}async function q0(t,e,r,i,o){if(i<=0)return[];let c;try{c=await c_(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(p_.has(u.name)||u.isSymbolicLink())continue;if(o.count>=C_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Lt(e,u.name),g=f_(Lt(r,u.name)),w=null;try{w=await qc(x)}catch{continue}if(w.isSymbolicLink())continue;o.count++;let E={name:u.name,path:j0($c(t,x)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&i>1&&(E.children=await q0(t,x,g,i-1,o)),l.push(E)}return l.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),l}function k_(t){return!t||t<=0?x_:Math.min(t,h_)}function P_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function j0(t){return t.split(z0).join("/")}te();import{readFileSync as f3}from"node:fs";import{dirname as h3,join as p3}from"node:path";import{fileURLToPath as m3}from"node:url";var Rr="0.1.103";var vn=q("agent-health-reporter"),O_=1e4,Li=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??O_}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()}),vn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),vn.info("heartbeat stopped"))}async tick(){if(this.inFlight){vn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){vn.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=L_(l);if(!u)continue;let x={agentId:l.agentId,status:u};l.patToken&&(x.patToken=l.patToken),l.accountId&&(x.accountId=l.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:Rr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){vn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(vn.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){vn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){vn.warn("onTickEnd hook failed",{err:String(r)})}}};function L_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}dn();import{mkdir as ed,rm as ky,stat as Py}from"node:fs/promises";import{homedir as Oy}from"node:os";import{join as _f}from"node:path";on();import{existsSync as Q_}from"node:fs";import{release as ey}from"node:os";import{basename as ty,isAbsolute as ny}from"node:path";function Ni(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function kr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Pr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function Sn(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ve();var lo=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,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function H0(t){return"method"in t&&"id"in t&&t.id!==void 0}function W0(t){return"method"in t&&!("id"in t)}function uo(t){return!("method"in t)&&"id"in t}var N_={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,AGENT_DEPENDENCY_INSTALL_FAILED:Q.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:Q.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:Q.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:Q.AGENT_ENV_NOT_READY};function M_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Mi(t.message)}:typeof t=="string"?Mi(t):typeof t=="object"?z_(t):t}var B_=[[/\/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 Mi(t){let e=t;for(let[r,i]of B_)e=e.replace(r,i);return e}function z_(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Mi(i):e[r]=i;return e}function Bi(t){if(t instanceof C){let e=M_(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:N_[t.code]??Q.INTERNAL_ERROR,message:Mi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:Mi(t instanceof Error?t.message:String(t))}}function K0(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 C(r,o,{retriable:e?.retriable??!1,cause:c})}function V0(t){return`${JSON.stringify(t)}
93
- `}var $0=10*1024*1024,fo=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>$0){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${$0} bytes`)}),[]}let r=this.buffer.split(`
94
- `);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 Z0={"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"},D3=Object.fromEntries(Object.entries(Z0).map(([t,e])=>[e,t])),F_={"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:[]},Or=class{seq=0;next(e,r){this.seq+=1;let i=Z0[e]??U_(e),o=F_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>J0(r?.[x]??"")),u=G_(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>J0(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function U_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function J0(t){return t.replace(/[:_\s]+/g,"-")}function G_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}cn();import{readFileSync as q_}from"node:fs";var j_=384;async function Zc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await dr(t.agentEnvFile,r,{mode:j_})}function Xc(t){try{let e=JSON.parse(q_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function X0(t,e,r={},i=o=>o){return{...i({...t,...Xc(e)}),...r}}An();ir();Ve();te();Oe();import{execFileSync as Z_,spawnSync as X_}from"node:child_process";function zi(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Fi(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),X_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var Yc=new Set;function tf(t){typeof t=="number"&&t>0&&Yc.add(t)}function nf(t){typeof t=="number"&&Yc.delete(t)}function rf(){for(let t of Yc)Fi(t,"SIGKILL")}var Lr="coze-bridge-daemon";function sf(t){let e=t?.execFn??(()=>{if(process.platform==="win32")return"";let o=process.getuid?.()??0;return Z_("pgrep",["-U",String(o),"-f",Lr],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3})}),r;try{r=e()}catch{return[]}let i=process.pid;return r.split(`
95
- `).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function of(t,e){if(t.length===0)return;let r=e?.killFn??Fi,i=e?.isAliveFn??zi,o=e?.sleepFn??(u=>new Promise(x=>setTimeout(x,u))),c=e?.graceMs??3e3,l=e?.pollMs??100;for(let u of t)r(u,"SIGTERM");for(let u=0;u<c&&t.some(x=>i(x));u+=l)await o(Math.min(l,c-u));for(let u of t)i(u)&&r(u,"SIGKILL")}var Y_=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: (Node binary not found|QCLAW_CLI_NODE_BINARY not set)/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"acp_module_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code","codex"],match:/Cannot find module[^\n]*node_modules[\\/]@(agentclientprotocol[\\/]claude-agent-acp|zed-industries[\\/]codex-acp)/i,message:"ACP \u4F9D\u8D56\u672A\u6B63\u786E\u5B89\u88C5 (wrapper \u5165\u53E3\u7F3A\u5931)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u91CD\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"},{reason:"prompt_too_long",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/Prompt is too long|bad request: failed to read body: length limit exceeded/i,message:"\u672C\u8F6E\u8F93\u5165\u8FC7\u957F\uFF0C\u8D85\u8FC7\u6A21\u578B\u4E0A\u4E0B\u6587\u4E0A\u9650\uFF0C\u8BF7\u7CBE\u7B80\u8F93\u5165\u6216\u5F00\u542F\u65B0\u4F1A\u8BDD\u540E\u91CD\u8BD5"}];function af(t,e){if(!e)return null;for(let r of Y_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function cf(t,e){return af(t,e)}function df(t,e){return af(t,e)}function Nr(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function lf(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let g=t.suspendedMs+o,w=r-t.startedAt-g;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Nr(w,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,l=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=l?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Nr(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Nr(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Nr(c,!1,e)}}var uf=Ke("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),ry=200,iy=40,sy=Ke("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),oy=Ke("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),ay=Ke("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),cy=Ke("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),dy=Ke("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),ly=Ke("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),ff=500;function uy(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=ff?t:`${e.slice(0,ff)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function fy(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function xf(t){try{return Q_(t)}catch{return}}function xy(t,e){return{platform:process.platform,osRelease:ey(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:ny(e.command)?xf(e.command):void 0,cwd:e.cwd,cwdExists:xf(e.cwd),envKeys:e.envKeys}}function hy(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${ty(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Nt=class{constructor(e){this.opts=e;this.log=q(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new fo({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Or;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;sanitizeEnv(e){return e}async start(){if(this.child)throw new C("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=X0(process.env,this.opts.agentEnvFile??Y().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=lt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,tf(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>ry&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,nf(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=xy(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new C("AGENT_SPAWN_FAILED",hy(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));Fi(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Fi(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}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){let i={firstUpdateMs:dy,phase2GateMs:sy,livenessWindowMs:oy,absoluteMaxMs:ay,approvalMaxMs:ly,suspendThresholdMs:cy,...r};return this.call("session/prompt",e,uf,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(kr("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(Pr(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(Sn(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=uf,o){if(!this.child||this.stopped)return Promise.reject(new C("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=Ni(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let x=r.sessionId;return typeof x=="string"?x:void 0})();return new Promise((x,g)=>{let w={resolve:x,reject:g,timer:null,method:e,promptTimeout:null};if(o){let E=this.now(),S={cfg:o,startedAt:E,lastActivityAt:E,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:E,expectedIntervalMs:Nr(0,!1,o),sessionId:u};w.promptTimeout=S;let y=()=>{let v={startedAt:S.startedAt,lastActivityAt:S.lastActivityAt,firstFrameSeen:S.firstFrameSeen,hasActiveTool:S.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:S.suspendedMs,armedAt:S.armedAt,expectedIntervalMs:S.expectedIntervalMs},A=this.now(),T=lf(v,S.cfg,A),D=P=>{S.armedAt=A,S.expectedIntervalMs=P,w.timer=setTimeout(y,P)};if(T.action==="suspend"){S.suspendedMs+=T.suspendedDeltaMs,S.lastActivityAt=A,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:T.suspendedDeltaMs,suspendedMs:S.suspendedMs,...S.sessionId?{sessionId:S.sessionId}:{}}),D(T.rearmMs);return}if(T.action==="continue"){D(T.rearmMs);return}this.pending.delete(c),T.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:T.awaitingApproval,...S.sessionId?{sessionId:S.sessionId}:{}}),g(T.awaitingApproval?new C("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${S.cfg.approvalMaxMs}ms`):new C("AGENT_TIMEOUT",`${e} timed out after ${S.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...S.sessionId?{sessionId:S.sessionId}:{}}),g(new C("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${S.cfg.livenessWindowMs}ms`)))};w.timer=setTimeout(y,S.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(w.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),g(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,w);try{this.writeFrame(l)}catch(E){w.timer&&clearTimeout(w.timer),this.pending.delete(c),g(E)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new C("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(V0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(uo(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),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(this.wireErrorToBridge(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new C("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:uy(e.result)}),r.resolve(e.result));return}if(W0(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(H0(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)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let l=typeof i.status=="string"?i.status:void 0,u=l==="completed"||l==="failed"||l==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(Sn(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(Sn(e.id,Bi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=K0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=df(this.framework,fy(e));return i?new C(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new C("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(iy).join(`
96
- `),o=cf(this.framework,i);return o?new C(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new C("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function py(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 xo=class extends Nt{framework="claude-code";constructor(e){let{command:r,args:i}=ni("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return py(e)}};on();import{mkdtempSync as gy,rmSync as my}from"node:fs";import{tmpdir as wy}from"node:os";import{join as _y}from"node:path";var ho=class extends Nt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=ni("codex",e.command,i),l=e.isolateCodexHome?gy(_y(wy(),"coze-bridge-codex-home-")):void 0,u=l?{...e.env??{},CODEX_HOME:l}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(x),this.authMethodId=e.authMethodId,this.codexHomeDir=l}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{my(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var yy=3e4,Mr=class extends Nt{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,agentId:e.agentId,...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.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},yy))}get acpSessionName(){return this.sessionName}};cn();Ve();te();Oe();function Qc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}on();var In=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 po=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 In,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)Ui(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 Ui(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}An();te();import{constants as hf}from"node:fs";import{access as by}from"node:fs/promises";import{delimiter as Ey,join as vy}from"node:path";var Et=q("framework-detector"),pf={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Sy=[".exe",".cmd",".bat",".ps1"],$n=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??lt,access:e.access??by}}async detect(e){let r=pf[e],i=await this.which(r);if(!i)return Et.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(pf).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(Ey).filter(Boolean),i=this.env.platform==="win32"?["",...Sy]:[""];for(let o of r)for(let c of i){let l=vy(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?hf.F_OK:hf.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 Et.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return Et.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 Et.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 Et.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?(Et.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}:(Et.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return Et.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return Et.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||Et.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let l=JSON.parse(c[0]);typeof l.gateway?.port=="number"&&(o.port=l.gateway.port),typeof l.service?.runtime?.status=="string"&&(o.runtime=l.service.runtime.status),!i&&typeof l.rpc?.error=="string"&&(o.detail=l.rpc.error)}catch(l){Et.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(Iy(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=x=>{c||(c=!0,l&&clearTimeout(l),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{x.kill("SIGKILL"),u(null)},15e3),x.stdout?.on("data",g=>{o+=g.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",g=>u({code:g,stdout:o}))}catch{u(null)}})}},Ay=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Iy(t){return t.replace(Ay,"")}import{homedir as Ty}from"node:os";import{join as Dy}from"node:path";cn();An();ir();Ve();te();async function wf(){let t=Dy(Ty(),".openclaw/openclaw.json");return(await cr(t))?.gateway?.auth?.token??""}var gf=q("openclaw.config"),Cy=[0,5e3,5e3],Ry=Ke("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),mf="models.providers.",go="agents.defaults.models",mo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new In;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Cy,this.cliTimeoutMs=e.cliTimeoutMs??Ry}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,gf.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new C("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=lt(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",l=!1,u=g=>{l||(l=!0,clearTimeout(x),g())};o.stderr?.on("data",g=>{c+=g.toString("utf8")});let x=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);x.unref(),o.on("error",g=>u(()=>i(g))),o.on("close",g=>u(()=>{g===0?r():i(new Error(`exit ${g}: ${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){gf.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",`${mf}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${mf}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${go}[${e}]`,()=>this.runCli(["config","set",go,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${go}[${e}]`,`${go}.${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"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var he=q("agent-manager"),Ly=(t,e,r,i,o,c,l,u,x)=>{switch(t){case"claude-code":{let g={...o?{...R0(o),...O0(o,l,u)}:{},...x??{},IS_SANDBOX:"1"};return new xo({cwd:r,env:g,agentId:i})}case"codex":{let w=[...o?[...k0(o),...N0(o,l,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...o?P0(o):{},...x??{}},S=!!o;return new ho({cwd:r,agentId:i,...w.length>0?{extraArgs:w}:{},...Object.keys(E).length>0?{env:E}:{},...S?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Mr({command:e,cwd:r,agentId:i,...c?{sessionName:Qc(c)}:{}})}};function td(t){return t==="claude-code"||t==="codex"}function Ny(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(My(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
89
+ `},configPath(t){return mS(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 Yh("schtasks",["/Create","/SC","ONLOGON","/TN",aa,"/TR",r,"/RU",t.userName,"/F"]),jd.info("task scheduler entry created",{task:aa,logFile:t.logFile})},async uninstall(t){await Yh("schtasks",["/Delete","/TN",aa,"/F"]).catch(e=>jd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),jd.info("task scheduler entry removed",{task:aa})}}});var Qh={};Ea(Qh,{buildContext:()=>vS,getSupervisor:()=>yS,launchdSupervisor:()=>Gd,systemdSupervisor:()=>Hd,taskSchedulerSupervisor:()=>Wd});import{homedir as wS,userInfo as _S}from"node:os";function yS(t=process.platform){switch(t){case"darwin":return Gd;case"linux":return Hd;case"win32":return Wd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function bS(){let t={};for(let e of ES){let r=process.env[e];r&&(t[e]=r)}return t}function vS(){let t=ee();return{nodeBin:process.execPath,entry:Od(t),logFile:t.logFile,homeDir:wS(),userName:_S().username,isRoot:process.getuid?.()===0,env:bS()}}var ES,ep=Ye(()=>{"use strict";Le();Zo();Vh();Zh();Xh();ES=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});re();rn();var El=q("acp-installer-warmup"),Ag=["claude-code","codex"];async function bl(t={}){let e=t.ensure??sr,i=(await Promise.allSettled(Ag.map(async o=>{let c=await e(o);El.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&El.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}an();re();import{readdir as Gg}from"node:fs/promises";import{mkdir as Al,readFile as Ug,writeFile as Tl}from"node:fs/promises";import{join as Ca}from"node:path";var qg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function cr(t,e,r){await Al(t,{recursive:!0});let i=qg[e],o=Ca(t,i);return await Tl(o,r??"","utf8"),o}async function Ra(t,e,r){let i=Ca(t,".claude");await Al(i,{recursive:!0});let o=Ca(i,"settings.local.json"),c={};try{let u=await Ug(o,"utf8"),x=JSON.parse(u);typeof x=="object"&&x!==null&&!Array.isArray(x)&&(c=x)}catch{}let l=typeof c.permissions=="object"&&c.permissions!==null&&!Array.isArray(c.permissions)?c.permissions:{};if(e==="cloud")l.defaultMode="bypassPermissions",c.autoCompactWindow=15e4;else{if(!r)throw new Error("writeCcPermissionSettings: local deployType requires permissionMode (caller bug)");l.defaultMode===void 0&&(l.defaultMode=r)}return c.permissions=l,await Tl(o,JSON.stringify(c,null,2),"utf8"),o}var Ve=q("agent-detail-sync"),Hg=6e4,jg=5*6e4,ps=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Gg(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 Be(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 Be(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(x){Ve.warn("detail RPC failed, using local data",{agentId:e,err:String(x)});let p=this.retryQueue.get(e),w=p?Math.min(p.currentDelay*2,jg):Hg;this.retryQueue.set(e,{dueAt:Date.now()+w,currentDelay:w});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;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);let u=!1;if(o.deployType==="cloud"&&i.deployType!=="cloud"?(Ve.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&Ve.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Ve.debug("detail sync: no diff",{agentId:e});return}await Qe(i,this.opts.paths),Ve.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),u?(await this.opts.agentManager.createAgent({agentId:e,framework:i.framework,_meta:{cozeDeployType:"cloud"},cozeIdentity:i.cozeIdentity,model:i.model}),Ve.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):l&&(await cr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Vf=Ft(ou(),1);import{lstat as Hc,mkdir as jc,readFile as jf,readdir as S_,rm as I_,stat as A_,writeFile as Wc}from"node:fs/promises";import{dirname as T_,join as Dt,normalize as C_,relative as Vc,resolve as Kc,sep as Wf}from"node:path";import{Readable as Kf}from"node:stream";import{pipeline as $f}from"node:stream/promises";import fm from"events";import et from"fs";import{EventEmitter as Cc}from"node:events";import qu from"node:stream";import{StringDecoder as xm}from"node:string_decoder";import ju from"node:path";import yr from"node:fs";import{dirname as Am,parse as Tm}from"path";import{EventEmitter as Nm}from"events";import dc from"assert";import{Buffer as qn}from"buffer";import*as uu from"zlib";import Mm from"zlib";import{posix as xr}from"node:path";import{basename as dw}from"node:path";import $s from"fs";import Ct from"fs";import wu from"path";import{win32 as Ew}from"node:path";import Iu from"path";import of from"node:fs";import Fw from"node:assert";import{randomBytes as af}from"node:crypto";import ie from"node:fs";import Me from"node:path";import cf from"fs";import no from"node:fs";import Ei from"node:path";import st from"node:fs";import Ww from"node:fs/promises";import Zs from"node:path";import{join as _f}from"node:path";import it from"node:fs";import bf from"node:path";var lm=Object.defineProperty,um=(t,e)=>{for(var r in e)lm(t,r,{get:e[r],enumerable:!0})},au=typeof process=="object"&&process?process:{stdout:null,stderr:null},hm=t=>!!t&&typeof t=="object"&&(t instanceof jn||t instanceof qu||pm(t)||gm(t)),pm=t=>!!t&&typeof t=="object"&&t instanceof Cc&&typeof t.pipe=="function"&&t.pipe!==qu.Writable.prototype.pipe,gm=t=>!!t&&typeof t=="object"&&t instanceof Cc&&typeof t.write=="function"&&typeof t.end=="function",zt=Symbol("EOF"),Ut=Symbol("maybeEmitEnd"),dn=Symbol("emittedEnd"),ys=Symbol("emittingEnd"),ii=Symbol("emittedError"),Es=Symbol("closed"),cu=Symbol("read"),bs=Symbol("flush"),du=Symbol("flushChunk"),ht=Symbol("encoding"),fr=Symbol("decoder"),Fe=Symbol("flowing"),si=Symbol("paused"),mr=Symbol("resume"),ze=Symbol("buffer"),Je=Symbol("pipes"),Ue=Symbol("bufferLength"),Na=Symbol("bufferPush"),vs=Symbol("bufferShift"),$e=Symbol("objectMode"),Ie=Symbol("destroyed"),Ma=Symbol("error"),Ba=Symbol("emitData"),lu=Symbol("emitEnd"),Fa=Symbol("emitEnd2"),It=Symbol("async"),za=Symbol("abort"),Ss=Symbol("aborted"),oi=Symbol("signal"),Pn=Symbol("dataListeners"),rt=Symbol("discarded"),ai=t=>Promise.resolve().then(t),mm=t=>t(),wm=t=>t==="end"||t==="finish"||t==="prefinish",_m=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,ym=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Gu=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[mr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Em=class extends Gu{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)}},bm=t=>!!t.objectMode,vm=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",jn=class extends Cc{[Fe]=!1;[si]=!1;[Je]=[];[ze]=[];[$e];[ht];[It];[fr];[zt]=!1;[dn]=!1;[ys]=!1;[Es]=!1;[ii]=null;[Ue]=0;[Ie]=!1;[oi];[Ss]=!1;[Pn]=0;[rt]=!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");bm(e)?(this[$e]=!0,this[ht]=null):vm(e)?(this[ht]=e.encoding,this[$e]=!1):(this[$e]=!1,this[ht]=null),this[It]=!!e.async,this[fr]=this[ht]?new xm(this[ht]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ze]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Je]});let{signal:r}=e;r&&(this[oi]=r,r.aborted?this[za]():r.addEventListener("abort",()=>this[za]()))}get bufferLength(){return this[Ue]}get encoding(){return this[ht]}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[$e]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[It]}set async(t){this[It]=this[It]||!!t}[za](){this[Ss]=!0,this.emit("abort",this[oi]?.reason),this.destroy(this[oi]?.reason)}get aborted(){return this[Ss]}set aborted(t){}write(t,e,r){if(this[Ss])return!1;if(this[zt])throw new Error("write after end");if(this[Ie])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[It]?ai:mm;if(!this[$e]&&!Buffer.isBuffer(t)){if(ym(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(_m(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[$e]?(this[Fe]&&this[Ue]!==0&&this[bs](!0),this[Fe]?this.emit("data",t):this[Na](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[Fe]):t.length?(typeof t=="string"&&!(e===this[ht]&&!this[fr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ht]&&(t=this[fr].write(t)),this[Fe]&&this[Ue]!==0&&this[bs](!0),this[Fe]?this.emit("data",t):this[Na](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[Fe]):(this[Ue]!==0&&this.emit("readable"),r&&i(r),this[Fe])}read(t){if(this[Ie])return null;if(this[rt]=!1,this[Ue]===0||t===0||t&&t>this[Ue])return this[Ut](),null;this[$e]&&(t=null),this[ze].length>1&&!this[$e]&&(this[ze]=[this[ht]?this[ze].join(""):Buffer.concat(this[ze],this[Ue])]);let e=this[cu](t||null,this[ze][0]);return this[Ut](),e}[cu](t,e){if(this[$e])this[vs]();else{let r=e;t===r.length||t===null?this[vs]():typeof r=="string"?(this[ze][0]=r.slice(t),e=r.slice(0,t),this[Ue]-=t):(this[ze][0]=r.subarray(t),e=r.subarray(0,t),this[Ue]-=t)}return this.emit("data",e),!this[ze].length&&!this[zt]&&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[zt]=!0,this.writable=!1,(this[Fe]||!this[si])&&this[Ut](),this}[mr](){this[Ie]||(!this[Pn]&&!this[Je].length&&(this[rt]=!0),this[si]=!1,this[Fe]=!0,this.emit("resume"),this[ze].length?this[bs]():this[zt]?this[Ut]():this.emit("drain"))}resume(){return this[mr]()}pause(){this[Fe]=!1,this[si]=!0,this[rt]=!1}get destroyed(){return this[Ie]}get flowing(){return this[Fe]}get paused(){return this[si]}[Na](t){this[$e]?this[Ue]+=1:this[Ue]+=t.length,this[ze].push(t)}[vs](){return this[$e]?this[Ue]-=1:this[Ue]-=this[ze][0].length,this[ze].shift()}[bs](t=!1){do;while(this[du](this[vs]())&&this[ze].length);!t&&!this[ze].length&&!this[zt]&&this.emit("drain")}[du](t){return this.emit("data",t),this[Fe]}pipe(t,e){if(this[Ie])return t;this[rt]=!1;let r=this[dn];return e=e||{},t===au.stdout||t===au.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Je].push(e.proxyErrors?new Em(this,t,e):new Gu(this,t,e)),this[It]?ai(()=>this[mr]()):this[mr]()),t}unpipe(t){let e=this[Je].find(r=>r.dest===t);e&&(this[Je].length===1?(this[Fe]&&this[Pn]===0&&(this[Fe]=!1),this[Je]=[]):this[Je].splice(this[Je].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[rt]=!1,this[Pn]++,!this[Je].length&&!this[Fe]&&this[mr]();else if(t==="readable"&&this[Ue]!==0)super.emit("readable");else if(wm(t)&&this[dn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ii]){let i=e;this[It]?ai(()=>i.call(this,this[ii])):i.call(this,this[ii])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Pn]=this.listeners("data").length,this[Pn]===0&&!this[rt]&&!this[Je].length&&(this[Fe]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Pn]=0,!this[rt]&&!this[Je].length&&(this[Fe]=!1)),e}get emittedEnd(){return this[dn]}[Ut](){!this[ys]&&!this[dn]&&!this[Ie]&&this[ze].length===0&&this[zt]&&(this[ys]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Es]&&this.emit("close"),this[ys]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Ie&&this[Ie])return!1;if(t==="data")return!this[$e]&&!r?!1:this[It]?(ai(()=>this[Ba](r)),!0):this[Ba](r);if(t==="end")return this[lu]();if(t==="close"){if(this[Es]=!0,!this[dn]&&!this[Ie])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ii]=r,super.emit(Ma,r);let o=!this[oi]||this.listeners("error").length?super.emit("error",r):!1;return this[Ut](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ut](),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[Ut](),i}[Ba](t){for(let r of this[Je])r.dest.write(t)===!1&&this.pause();let e=this[rt]?!1:super.emit("data",t);return this[Ut](),e}[lu](){return this[dn]?!1:(this[dn]=!0,this.readable=!1,this[It]?(ai(()=>this[Fa]()),!0):this[Fa]())}[Fa](){if(this[fr]){let e=this[fr].end();if(e){for(let r of this[Je])r.dest.write(e);this[rt]||super.emit("data",e)}}for(let e of this[Je])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[$e]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[$e]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[$e])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ht]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ie,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[rt]=!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[zt])return e();let i,o,c=p=>{this.off("data",l),this.off("end",u),this.off(Ie,x),e(),o(p)},l=p=>{this.off("error",c),this.off("end",u),this.off(Ie,x),this.pause(),i({value:p,done:!!this[zt]})},u=()=>{this.off("error",c),this.off("data",l),this.off(Ie,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,w)=>{o=w,i=p,this.once(Ie,x),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[rt]=!1;let t=!1,e=()=>(this.pause(),this.off(Ma,e),this.off(Ie,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(Ma,e),this.once(Ie,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ie])return t?this.emit("error",t):this.emit(Ie),this;this[Ie]=!0,this[rt]=!0,this[ze].length=0,this[Ue]=0;let e=this;return typeof e.close=="function"&&!this[Es]&&e.close(),t?this.emit("error",t):this.emit(Ie),this}static get isStream(){return hm}},Sm=et.writev,_n=Symbol("_autoClose"),wt=Symbol("_close"),ci=Symbol("_ended"),le=Symbol("_fd"),Ua=Symbol("_finished"),jt=Symbol("_flags"),qa=Symbol("_flush"),ac=Symbol("_handleChunk"),cc=Symbol("_makeBuf"),_i=Symbol("_mode"),Is=Symbol("_needDrain"),br=Symbol("_onerror"),vr=Symbol("_onopen"),Ga=Symbol("_onread"),wr=Symbol("_onwrite"),yn=Symbol("_open"),mt=Symbol("_path"),hn=Symbol("_pos"),At=Symbol("_queue"),_r=Symbol("_read"),Ha=Symbol("_readSize"),Ht=Symbol("_reading"),di=Symbol("_remain"),ja=Symbol("_size"),Ns=Symbol("_write"),On=Symbol("_writing"),Ms=Symbol("_defaultFlag"),Un=Symbol("_errored"),Rc=class extends jn{[Un]=!1;[le];[mt];[Ha];[Ht]=!1;[ja];[di];[_n];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[Un]=!1,this[le]=typeof e.fd=="number"?e.fd:void 0,this[mt]=t,this[Ha]=e.readSize||16*1024*1024,this[Ht]=!1,this[ja]=typeof e.size=="number"?e.size:1/0,this[di]=this[ja],this[_n]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[le]=="number"?this[_r]():this[yn]()}get fd(){return this[le]}get path(){return this[mt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[yn](){et.open(this[mt],"r",(t,e)=>this[vr](t,e))}[vr](t,e){t?this[br](t):(this[le]=e,this.emit("open",e),this[_r]())}[cc](){return Buffer.allocUnsafe(Math.min(this[Ha],this[di]))}[_r](){if(!this[Ht]){this[Ht]=!0;let t=this[cc]();if(t.length===0)return process.nextTick(()=>this[Ga](null,0,t));et.read(this[le],t,0,t.length,null,(e,r,i)=>this[Ga](e,r,i))}}[Ga](t,e,r){this[Ht]=!1,t?this[br](t):this[ac](e,r)&&this[_r]()}[wt](){if(this[_n]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[br](t){this[Ht]=!0,this[wt](),this.emit("error",t)}[ac](t,e){let r=!1;return this[di]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[di]<=0)&&(r=!1,this[wt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[le]=="number"&&this[_r](),!1;case"error":return this[Un]?!1:(this[Un]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Im=class extends Rc{[yn](){let t=!0;try{this[vr](null,et.openSync(this[mt],"r")),t=!1}finally{t&&this[wt]()}}[_r](){let t=!0;try{if(!this[Ht]){this[Ht]=!0;do{let e=this[cc](),r=e.length===0?0:et.readSync(this[le],e,0,e.length,null);if(!this[ac](r,e))break}while(!0);this[Ht]=!1}t=!1}finally{t&&this[wt]()}}[wt](){if(this[_n]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,et.closeSync(t),this.emit("close")}}},Ys=class extends fm{readable=!1;writable=!0;[Un]=!1;[On]=!1;[ci]=!1;[At]=[];[Is]=!1;[mt];[_i];[_n];[le];[Ms];[jt];[Ua]=!1;[hn];constructor(t,e){e=e||{},super(e),this[mt]=t,this[le]=typeof e.fd=="number"?e.fd:void 0,this[_i]=e.mode===void 0?438:e.mode,this[hn]=typeof e.start=="number"?e.start:void 0,this[_n]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[hn]!==void 0?"r+":"w";this[Ms]=e.flags===void 0,this[jt]=e.flags===void 0?r:e.flags,this[le]===void 0&&this[yn]()}emit(t,...e){if(t==="error"){if(this[Un])return!1;this[Un]=!0}return super.emit(t,...e)}get fd(){return this[le]}get path(){return this[mt]}[br](t){this[wt](),this[On]=!0,this.emit("error",t)}[yn](){et.open(this[mt],this[jt],this[_i],(t,e)=>this[vr](t,e))}[vr](t,e){this[Ms]&&this[jt]==="r+"&&t&&t.code==="ENOENT"?(this[jt]="w",this[yn]()):t?this[br](t):(this[le]=e,this.emit("open",e),this[On]||this[qa]())}end(t,e){return t&&this.write(t,e),this[ci]=!0,!this[On]&&!this[At].length&&typeof this[le]=="number"&&this[wr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ci]?(this.emit("error",new Error("write() after end()")),!1):this[le]===void 0||this[On]||this[At].length?(this[At].push(t),this[Is]=!0,!1):(this[On]=!0,this[Ns](t),!0)}[Ns](t){et.write(this[le],t,0,t.length,this[hn],(e,r)=>this[wr](e,r))}[wr](t,e){t?this[br](t):(this[hn]!==void 0&&typeof e=="number"&&(this[hn]+=e),this[At].length?this[qa]():(this[On]=!1,this[ci]&&!this[Ua]?(this[Ua]=!0,this[wt](),this.emit("finish")):this[Is]&&(this[Is]=!1,this.emit("drain"))))}[qa](){if(this[At].length===0)this[ci]&&this[wr](null,0);else if(this[At].length===1)this[Ns](this[At].pop());else{let t=this[At];this[At]=[],Sm(this[le],t,this[hn],(e,r)=>this[wr](e,r))}}[wt](){if(this[_n]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Hu=class extends Ys{[yn](){let t;if(this[Ms]&&this[jt]==="r+")try{t=et.openSync(this[mt],this[jt],this[_i])}catch(e){if(e?.code==="ENOENT")return this[jt]="w",this[yn]();throw e}else t=et.openSync(this[mt],this[jt],this[_i]);this[vr](null,t)}[wt](){if(this[_n]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,et.closeSync(t),this.emit("close")}}[Ns](t){let e=!0;try{this[wr](null,et.writeSync(this[le],t,0,t.length,this[hn])),e=!1}finally{if(e)try{this[wt]()}catch{}}}},Cm=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"]]),Rm=t=>!!t.sync&&!!t.file,km=t=>!t.sync&&!!t.file,Dm=t=>!!t.sync&&!t.file,Pm=t=>!t.sync&&!t.file,Om=t=>!!t.file,Lm=t=>Cm.get(t)||t,kc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=Lm(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 x=kc(c);if(o?.(x,l),Rm(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(km(x)){let p=e(x,l);return u?p.then(()=>u(),u):p}else if(Dm(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,l)}else if(Pm(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(x,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),Bm=Mm.constants||{ZLIB_VERNUM:4736},kt=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},Bm)),Fm=qn.concat,fu=Object.getOwnPropertyDescriptor(qn,"concat"),zm=t=>t,Wa=fu?.writable===!0||fu?.set!==void 0?t=>{qn.concat=t?zm:Fm}:t=>{},Gn=Symbol("_superWrite"),As=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"}},Ka=Symbol("flushFlag"),Dc=class extends jn{#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 uu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new uu[e](t)}catch(r){throw new As(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 As(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return dc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(qn.alloc(0),{[Ka]: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}[Gn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=qn.from(t,e)),this.#e)return;dc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Wa(!0);let l;try{let x=typeof t[Ka]=="number"?t[Ka]:this.#r;l=this.#t._processChunk(t,x),Wa(!1)}catch(x){Wa(!1),this.#o(new As(x,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",x=>this.#o(new As(x,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];u=this[Gn](qn.from(x));for(let p=1;p<l.length;p++)u=this[Gn](l[p])}else u=this[Gn](qn.from(l));return r&&r(),u}},Wu=class extends Dc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||kt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||kt.Z_FINISH,t.fullFlushFlag=kt.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(kt.Z_SYNC_FLUSH),dc(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)}}}},Um=class extends Wu{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Gn](t){return this.#e?(this.#e=!1,t[9]=255,super[Gn](t)):super[Gn](t)}},qm=class extends Wu{constructor(t){super(t,"Unzip")}},Ku=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||kt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||kt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=kt.BROTLI_OPERATION_FLUSH,super(t,e)}},Gm=class extends Ku{constructor(t){super(t,"BrotliCompress")}},Hm=class extends Ku{constructor(t){super(t,"BrotliDecompress")}},$u=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||kt.ZSTD_e_continue,t.finishFlush=t.finishFlush||kt.ZSTD_e_end,t.fullFlushFlag=kt.ZSTD_e_flush,super(t,e)}},jm=class extends $u{constructor(t){super(t,"ZstdCompress")}},Wm=class extends $u{constructor(t){super(t,"ZstdDecompress")}},Km=(t,e)=>{if(Number.isSafeInteger(t))t<0?Vm(t,e):$m(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},$m=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Vm=(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]=Vu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Ju(o))}},Jm=t=>{let e=t[0],r=e===128?Ym(t.subarray(1,t.length)):e===255?Zm(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},Zm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Vu(c):c===0?l=c:(i=!0,l=Ju(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},Ym=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},Vu=t=>(255^t)&255,Ju=t=>(255^t)+1&255,Xm={};um(Xm,{code:()=>Pc,isCode:()=>Bs,isName:()=>Qm,name:()=>Xs,normalFsTypes:()=>Zu});var Bs=t=>Xs.has(t),Qm=t=>Pc.has(t),Zu=new Set(["0","","1","2","3","4","5","6","7","D"]),Xs=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"]]),Pc=new Map(Array.from(Xs).map(t=>[t[1],t[0]])),Hn=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");let o=Ln(t,e+156,1),c=Zu.has(o),l=c?r:void 0,u=c?i:void 0;if(this.path=l?.path??Ln(t,e,100),this.mode=l?.mode??u?.mode??pn(t,e+100,8),this.uid=l?.uid??u?.uid??pn(t,e+108,8),this.gid=l?.gid??u?.gid??pn(t,e+116,8),this.size=l?.size??u?.size??pn(t,e+124,12),this.mtime=l?.mtime??u?.mtime??$a(t,e+136,12),this.cksum=pn(t,e+148,12),u&&this.#n(u,!0),l&&this.#n(l),Bs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Ln(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=l?.uname??u?.uname??Ln(t,e+265,32),this.gname=l?.gname??u?.gname??Ln(t,e+297,32),this.devmaj=l?.devmaj??u?.devmaj??pn(t,e+329,8)??0,this.devmin=l?.devmin??u?.devmin??pn(t,e+337,8)??0,t[e+475]!==0){let p=Ln(t,e+345,155);this.path=p+"/"+this.path}else{let p=Ln(t,e+345,130);p&&(this.path=p+"/"+this.path),this.atime=r?.atime??i?.atime??$a(t,e+476,12),this.ctime=r?.ctime??i?.ctime??$a(t,e+488,12)}let x=256;for(let p=e;p<e+148;p++)x+=t[p];for(let p=e+156;p<e+512;p++)x+=t[p];this.cksumValid=x===this.cksum,this.cksum===void 0&&x===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=ew(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Nn(t,e,100,o)||this.needPax,this.needPax=gn(t,e+100,8,this.mode)||this.needPax,this.needPax=gn(t,e+108,8,this.uid)||this.needPax,this.needPax=gn(t,e+116,8,this.gid)||this.needPax,this.needPax=gn(t,e+124,12,this.size)||this.needPax,this.needPax=Va(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Nn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Nn(t,e+265,32,this.uname)||this.needPax,this.needPax=Nn(t,e+297,32,this.gname)||this.needPax,this.needPax=gn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=gn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Nn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Nn(t,e+345,155,c)||this.needPax:(this.needPax=Nn(t,e+345,130,c)||this.needPax,this.needPax=Va(t,e+476,12,this.atime)||this.needPax,this.needPax=Va(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,gn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Xs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Pc.get(t));if(Bs(e)||e==="Unsupported")this.#e=e;else if(Bs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},ew=(t,e)=>{let r=t,i="",o,c=xr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=xr.dirname(r),r=xr.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=xr.join(xr.basename(i),r),i=xr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Ln=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),$a=(t,e,r)=>tw(pn(t,e,r)),tw=t=>t===void 0?void 0:new Date(t*1e3),pn=(t,e,r)=>Number(t[e])&128?Jm(t.subarray(e,e+r)):rw(t,e,r),nw=t=>isNaN(t)?void 0:t,rw=(t,e,r)=>nw(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),iw={12:8589934591,8:2097151},gn=(t,e,r,i)=>i===void 0?!1:i>iw[r]||i<0?(Km(i,t.subarray(e,e+r)),!0):(sw(t,e,r,i),!1),sw=(t,e,r,i)=>t.write(ow(i,r),e,r,"ascii"),ow=(t,e)=>aw(Math.floor(t).toString(8),e),aw=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Va=(t,e,r,i)=>i===void 0?!1:gn(t,e,r,i.getTime()/1e3),cw=new Array(156).join("\0"),Nn=(t,e,r,i)=>i===void 0?!1:(t.write(i+cw,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Ks=class Yu{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 Hn({path:("PaxHeader/"+dw(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+`
90
+ `,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 Yu(lw(uw(e),r),i)}},lw=(t,e)=>e?Object.assign({},e,t):t,uw=t=>t.replace(/\n$/,"").split(`
91
+ `).reduce(fw,Object.create(null)),fw=(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},xw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Y=xw!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),hw=class extends jn{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=Y(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?Y(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=Y(t.path)),t.linkpath&&(t.linkpath=Y(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Qs=(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))},pw=1024*1024,lc=Buffer.from([31,139]),uc=Buffer.from([40,181,47,253]),gw=Math.max(lc.length,uc.length),ct=Symbol("state"),Mn=Symbol("writeEntry"),qt=Symbol("readEntry"),Ja=Symbol("nextEntry"),xu=Symbol("processEntry"),Tt=Symbol("extendedHeader"),li=Symbol("globalExtendedHeader"),ln=Symbol("meta"),hu=Symbol("emitMeta"),me=Symbol("buffer"),Gt=Symbol("queue"),un=Symbol("ended"),Za=Symbol("emittedEnd"),Bn=Symbol("emit"),ke=Symbol("unzip"),Ts=Symbol("consumeChunk"),Cs=Symbol("consumeChunkSub"),Ya=Symbol("consumeBody"),pu=Symbol("consumeMeta"),gu=Symbol("consumeHeader"),ui=Symbol("consuming"),Xa=Symbol("bufferConcat"),Rs=Symbol("maybeEnd"),hr=Symbol("writing"),fn=Symbol("aborted"),ks=Symbol("onDone"),Fn=Symbol("sawValidEntry"),Ds=Symbol("sawNullBlock"),Ps=Symbol("sawEOF"),mu=Symbol("closeStream"),mw=()=>!0,Ti=class extends Nm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Gt]=[];[me];[qt];[Mn];[ct]="begin";[ln]="";[Tt];[li];[un]=!1;[ke];[fn]=!1;[Fn];[Ds]=!1;[Ps]=!1;[hr]=!1;[ui]=!1;[Za]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(ks,()=>{(this[ct]==="begin"||this[Fn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(ks,t.ondone):this.on(ks,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||pw,this.filter=typeof t.filter=="function"?t.filter:mw;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[mu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Qs(this,t,e,r)}[gu](t,e){this[Fn]===void 0&&(this[Fn]=!1);let r;try{r=new Hn(t,e,this[Tt],this[li])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Ds]?(this[Ps]=!0,this[ct]==="begin"&&(this[ct]="header"),this[Bn]("eof")):(this[Ds]=!0,this[Bn]("nullBlock"));else if(this[Ds]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let 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[Mn]=new hw(r,this[Tt],this[li]);if(!this[Fn])if(o.remain){let c=()=>{o.invalid||(this[Fn]=!0)};o.on("end",c)}else this[Fn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Bn]("ignoredEntry",o),this[ct]="ignore",o.resume()):o.size>0&&(this[ln]="",o.on("data",c=>this[ln]+=c),this[ct]="meta"):(this[Tt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Bn]("ignoredEntry",o),this[ct]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ct]="body":(this[ct]="header",o.end()),this[qt]?this[Gt].push(o):(this[Gt].push(o),this[Ja]())))}}}[mu](){queueMicrotask(()=>this.emit("close"))}[xu](t){let e=!0;if(!t)this[qt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[qt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Ja]()),e=!1);return e}[Ja](){do;while(this[xu](this[Gt].shift()));if(this[Gt].length===0){let t=this[qt];!t||t.flowing||t.size===t.remain?this[hr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ya](t,e){let r=this[Mn];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[ct]="header",this[Mn]=void 0,r.end()),o.length}[pu](t,e){let r=this[Mn],i=this[Ya](t,e);return!this[Mn]&&r&&this[hu](r),i}[Bn](t,e,r){this[Gt].length===0&&!this[qt]?this.emit(t,e,r):this[Gt].push([t,e,r])}[hu](t){switch(this[Bn]("meta",this[ln]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Tt]=Ks.parse(this[ln],this[Tt],!1);break;case"GlobalExtendedHeader":this[li]=Ks.parse(this[ln],this[li],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Tt]??Object.create(null);this[Tt]=e,e.path=this[ln].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Tt]||Object.create(null);this[Tt]=e,e.linkpath=this[ln].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[fn]=!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[fn])return r?.(),!1;if((this[ke]===void 0||this.brotli===void 0&&this[ke]===!1)&&t){if(this[me]&&(t=Buffer.concat([this[me],t]),this[me]=void 0),t.length<gw)return this[me]=t,r?.(),!0;for(let l=0;this[ke]===void 0&&l<lc.length;l++)t[l]!==lc[l]&&(this[ke]=!1);let o=!1;if(this[ke]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<uc.length;l++)if(t[l]!==uc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[ke]===!1&&c)if(t.length<512)if(this[un])this.brotli=!0;else return this[me]=t,r?.(),!0;else try{new Hn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ke]===void 0||this[ke]===!1&&(this.brotli||o)){let l=this[un];this[un]=!1,this[ke]=this[ke]===void 0?new qm({}):o?new Wm({}):new Hm({}),this[ke].on("data",x=>this[Ts](x)),this[ke].on("error",x=>this.abort(x)),this[ke].on("end",()=>{this[un]=!0,this[Ts]()}),this[hr]=!0;let u=!!this[ke][l?"end":"write"](t);return this[hr]=!1,r?.(),u}}this[hr]=!0,this[ke]?this[ke].write(t):this[Ts](t),this[hr]=!1;let i=this[Gt].length>0?!1:this[qt]?this[qt].flowing:!0;return!i&&this[Gt].length===0&&this[qt]?.once("drain",()=>this.emit("drain")),r?.(),i}[Xa](t){t&&!this[fn]&&(this[me]=this[me]?Buffer.concat([this[me],t]):t)}[Rs](){if(this[un]&&!this[Za]&&!this[fn]&&!this[ui]){this[Za]=!0;let t=this[Mn];if(t&&t.blockRemain){let e=this[me]?this[me].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[me]&&t.write(this[me]),t.end()}this[Bn](ks)}}[Ts](t){if(this[ui]&&t)this[Xa](t);else if(!t&&!this[me])this[Rs]();else if(t){if(this[ui]=!0,this[me]){this[Xa](t);let e=this[me];this[me]=void 0,this[Cs](e)}else this[Cs](t);for(;this[me]&&this[me]?.length>=512&&!this[fn]&&!this[Ps];){let e=this[me];this[me]=void 0,this[Cs](e)}this[ui]=!1}(!this[me]||this[un])&&this[Rs]()}[Cs](t){let e=0,r=t.length;for(;e+512<=r&&!this[fn]&&!this[Ps];)switch(this[ct]){case"begin":case"header":this[gu](t,e),e+=512;break;case"ignore":case"body":e+=this[Ya](t,e);break;case"meta":e+=this[pu](t,e);break;default:throw new Error("invalid state: "+this[ct])}e<r&&(this[me]=this[me]?Buffer.concat([t.subarray(e),this[me]]):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[fn]||(this[ke]?(t&&this[ke].write(t),this[ke].end()):(this[un]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Rs]())),this}},yi=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)},ww=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},Xu=(t,e)=>{let r=new Map(e.map(c=>[yi(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||Tm(c).root||".",x;if(c===u)x=!1;else{let p=r.get(c);x=p!==void 0?p:o(Am(c),u)}return r.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(yi(c)):c=>o(yi(c))},_w=t=>{let e=new Ti(t),r=t.file,i;try{i=yr.openSync(r,"r");let o=yr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=yr.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 x=yr.readSync(i,u,0,c,l);if(x===0)break;l+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{yr.closeSync(i)}catch{}}},yw=(t,e)=>{let r=new Ti(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),yr.stat(o,(u,x)=>{if(u)l(u);else{let p=new Rc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(r)}})})},Sr=Ci(_w,yw,t=>new Ti(t),t=>new Ti(t),(t,e)=>{e?.length&&Xu(t,e),t.noResume||ww(t)}),Qu=(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:bw,parse:_u}=Ew,Oc=t=>{let e="",r=_u(t);for(;bw(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=_u(t)}return[e,t]},eo=["|","<",">","?",":"],Lc=eo.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),vw=new Map(eo.map((t,e)=>[t,Lc[e]])),Sw=new Map(Lc.map((t,e)=>[t,eo[e]])),yu=t=>eo.reduce((e,r)=>e.split(r).join(vw.get(r)),t),Iw=t=>Lc.reduce((e,r)=>e.split(r).join(Sw.get(r)),t),ef=(t,e)=>e?(t=Y(t).replace(/^\.(\/|$)/,""),yi(e)+"/"+t):Y(t),Aw=16*1024*1024,Eu=Symbol("process"),bu=Symbol("file"),vu=Symbol("directory"),fc=Symbol("symlink"),Su=Symbol("hardlink"),fi=Symbol("header"),Fs=Symbol("read"),xc=Symbol("lstat"),zs=Symbol("onlstat"),hc=Symbol("onread"),pc=Symbol("onreadlink"),gc=Symbol("openfile"),mc=Symbol("onopenfile"),mn=Symbol("close"),Vs=Symbol("mode"),wc=Symbol("awaitDrain"),Qa=Symbol("ondrain"),Rt=Symbol("prefix"),tf=class extends jn{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=kc(e);super(),this.path=Y(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Aw,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Y(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Y(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]=Oc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Iw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Y(r.absolute||wu.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[zs](o):this[xc]()}warn(t,e,r={}){return Qs(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[xc](){Ct.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[zs](e)})}[zs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Rw(t),this.emit("stat",t),this[Eu]()}[Eu](){switch(this.type){case"File":return this[bu]();case"Directory":return this[vu]();case"SymbolicLink":return this[fc]();default:return this.end()}}[Vs](t){return Qu(t,this.type==="Directory",this.portable)}[Rt](t){return ef(t,this.prefix)}[fi](){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 Hn({path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,mode:this[Vs](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 Ks({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[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](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)}[vu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[fi](),this.end()}[fc](){Ct.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[pc](e)})}[pc](t){this.linkpath=Y(t),this[fi](),this.end()}[Su](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Y(wu.relative(this.cwd,t)),this.stat.size=0,this[fi](),this.end()}[bu](){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[Su](e);this.linkCache.set(t,this.absolute)}if(this[fi](),this.stat.size===0)return this.end();this[gc]()}[gc](){Ct.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[mc](e)})}[mc](t){if(this.fd=t,this.#e)return this[mn]();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:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Ct.read(t,e,r,i,o,(c,l)=>{if(c)return this[mn](()=>this.emit("error",c));this[hc](l)})}[mn](t=()=>{}){this.fd!==void 0&&Ct.close(this.fd,t)}[hc](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[mn](()=>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[mn](()=>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[Qa]():this[wc](()=>this[Qa]())}[wc](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)}[Qa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[mn](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]()}},Tw=class extends tf{sync=!0;[xc](){this[zs](Ct.lstatSync(this.absolute))}[fc](){this[pc](Ct.readlinkSync(this.absolute))}[gc](){this[mc](Ct.openSync(this.absolute,"r"))}[Fs](){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=Ct.readSync(e,r,i,o,c);this[hc](l),t=!1}finally{if(t)try{this[mn](()=>{})}catch{}}}[wc](t){t()}[mn](t=()=>{}){this.fd!==void 0&&Ct.closeSync(this.fd),t()}},Cw=class extends jn{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 Qs(this,t,e,r)}constructor(t,e={}){let r=kc(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=Y(t.path),this.mode=t.mode!==void 0?this[Vs](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?Y(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,u]=Oc(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 Hn({path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](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 Ks({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[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](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)}[Rt](t){return ef(t,this.prefix)}[Vs](t){return Qu(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}},Rw=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",kw=class Er{tail;head;length=0;static create(e=[]){return new Er(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++)Pw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)Ow(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 Er;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 Er;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 Er;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 Er;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=Dw(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 Dw(t,e,r){let i=e,o=e?e.next:t.head,c=new Nc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function Pw(t,e){t.tail=new Nc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function Ow(t,e){t.head=new Nc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Nc=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}},Au=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Tu=Buffer.alloc(1024),Us=Symbol("onStat"),xi=Symbol("ended"),pt=Symbol("queue"),hi=Symbol("pendingLinks"),xn=Symbol("current"),zn=Symbol("process"),pi=Symbol("processing"),Os=Symbol("processJob"),gt=Symbol("jobs"),ec=Symbol("jobDone"),qs=Symbol("addFSEntry"),Cu=Symbol("addTarEntry"),_c=Symbol("stat"),yc=Symbol("readdir"),Gs=Symbol("onreaddir"),Hs=Symbol("pipe"),Ru=Symbol("entry"),tc=Symbol("entryOpt"),js=Symbol("writeEntryClass"),nf=Symbol("write"),nc=Symbol("ondrain"),to=class extends jn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[js];onWriteEntry;[pt];[hi]=new Map;[gt]=0;[pi]=!1;[xi]=!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=Y(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[js]=tf,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 Um(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Gm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new jm(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[nc]()),this.on("resume",()=>e.resume())}else this.on("drain",this[nc]);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[pt]=new kw,this[gt]=0,this.jobs=Number(t.jobs)||4,this[pi]=!1,this[xi]=!1}[nf](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[xi]=!0,this[zn](),r&&r(),this}write(t){if(this[xi])throw new Error("write after end");return typeof t=="string"?this[qs](t):this[Cu](t),this.flowing}[Cu](t){let e=Y(Iu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Au(t.path,e);r.entry=new Cw(t,this[tc](r)),r.entry.on("end",()=>this[ec](r)),this[gt]+=1,this[pt].push(r)}this[zn]()}[qs](t){let e=Y(Iu.resolve(this.cwd,t));this[pt].push(new Au(t,e)),this[zn]()}[_c](t){t.pending=!0,this[gt]+=1;let e=this.follow?"stat":"lstat";$s[e](t.absolute,(r,i)=>{t.pending=!1,this[gt]-=1,r?this.emit("error",r):this[Us](t,i)})}[Us](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[xn])this[Os](t);else{let r=`${e.dev}:${e.ino}`,i=this[hi].get(r);i?i.push(t):this[hi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[zn]()}[yc](t){t.pending=!0,this[gt]+=1,$s.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[gt]-=1,e)return this.emit("error",e);this[Gs](t,r)})}[Gs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[zn]()}[zn](){if(!this[pi]){this[pi]=!0;for(let t=this[pt].head;t&&this[gt]<this.jobs;t=t.next)if(this[Os](t.value),t.value.ignore){let e=t.next;this[pt].removeNode(t),t.next=e}this[pi]=!1,this[xi]&&this[pt].length===0&&this[gt]===0&&(this.zip?this.zip.end(Tu):(super.write(Tu),super.end()))}}get[xn](){return this[pt]&&this[pt].head&&this[pt].head.value}[ec](t){this[pt].shift(),this[gt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[hi].get(r);if(i){this[hi].delete(r);for(let o of i)o.pending=!1,this[Os](o)}}this[zn]()}[Os](t){if(t.pending&&t.pendingLink&&t===this[xn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[xn]&&!t.piped&&this[Hs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Us](t,e):this[_c](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[yc](t),!t.readdir)return}if(t.entry=this[Ru](t),!t.entry){t.ignore=!0;return}t===this[xn]&&!t.piped&&this[Hs](t)}}}[tc](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}}[Ru](t){this[gt]+=1;try{return new this[js](t.path,this[tc](t)).on("end",()=>this[ec](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[nc](){this[xn]&&this[xn].entry&&this[xn].entry.resume()}[Hs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[qs](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={}){Qs(this,t,e,r)}},Mc=class extends to{sync=!0;constructor(t){super(t),this[js]=Tw}pause(){}resume(){}[_c](t){let e=this.follow?"statSync":"lstatSync";this[Us](t,$s[e](t.absolute))}[yc](t){this[Gs](t,$s.readdirSync(t.absolute))}[Hs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[qs](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[nf](i)})}},Lw=(t,e)=>{let r=new Mc(t),i=new Hu(t.file,{mode:t.mode||438});r.pipe(i),rf(r,e)},Nw=(t,e)=>{let r=new to(t),i=new Ys(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 sf(r,e).catch(c=>r.emit("error",c)),o},rf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Sr({file:ju.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},sf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Sr({file:ju.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},Mw=(t,e)=>{let r=new Mc(t);return rf(r,e),r},Bw=(t,e)=>{let r=new to(t);return sf(r,e).catch(i=>r.emit("error",i)),r},sI=Ci(Lw,Nw,Mw,Bw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),zw=process.env.__FAKE_PLATFORM__||process.platform,df=zw==="win32",{O_CREAT:lf,O_NOFOLLOW:ku,O_TRUNC:uf,O_WRONLY:ff}=cf.constants,xf=Number(process.env.__FAKE_FS_O_FILENAME__)||cf.constants.UV_FS_O_FILEMAP||0,Uw=df&&!!xf,qw=512*1024,Gw=xf|uf|lf|ff,Du=!df&&typeof ku=="number"?ku|uf|lf|ff:null,hf=Du!==null?()=>Du:Uw?t=>t<qw?Gw:"w":()=>"w",Ec=(t,e,r)=>{try{return no.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Js=(t,e,r,i)=>{no.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Hw=(t,e,r,i,o)=>{if(e.isDirectory())pf(Ei.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=Ei.resolve(t,e.name);Js(l,r,i,o)});else{let c=Ei.resolve(t,e.name);Js(c,r,i,o)}},pf=(t,e,r,i)=>{no.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 Js(t,e,r,i);let l=c.length,u=null,x=p=>{if(!u){if(p)return i(u=p);if(--l===0)return Js(t,e,r,i)}};for(let p of c)Hw(t,p,e,r,x)})},jw=(t,e,r,i)=>{e.isDirectory()&&gf(Ei.resolve(t,e.name),r,i),Ec(Ei.resolve(t,e.name),r,i)},gf=(t,e,r)=>{let i;try{i=no.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Ec(t,e,r);throw c}for(let o of i)jw(t,o,e,r);return Ec(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"}},ro=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"}},Kw=(t,e)=>{st.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new mf(t,r?.code||"ENOTDIR")),e(r)})},$w=(t,e,r)=>{t=Y(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,u=e.gid,x=typeof l=="number"&&typeof u=="number"&&(l!==e.processUid||u!==e.processGid),p=e.preserve,w=e.unlink,_=Y(e.cwd),I=(S,A)=>{S?r(S):A&&x?pf(A,l,u,T=>I(T)):c?st.chmod(t,o,r):r()};if(t===_)return Kw(t,I);if(p)return Ww.mkdir(t,{mode:o,recursive:!0}).then(S=>I(null,S??void 0),I);let y=Y(Zs.relative(_,t)).split("/");bc(_,y,o,w,_,void 0,I)},bc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),x=Y(Zs.resolve(t+"/"+u));st.mkdir(x,r,wf(x,e,r,i,o,c,l))},wf=(t,e,r,i,o,c,l)=>u=>{u?st.lstat(t,(x,p)=>{if(x)x.path=x.path&&Y(x.path),l(x);else if(p.isDirectory())bc(t,e,r,i,o,c,l);else if(i)st.unlink(t,w=>{if(w)return l(w);st.mkdir(t,r,wf(t,e,r,i,o,c,l))});else{if(p.isSymbolicLink())return l(new ro(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,bc(t,e,r,i,o,c,l))},Vw=t=>{let e=!1,r;try{e=st.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new mf(t,r??"ENOTDIR")}},Jw=(t,e)=>{t=Y(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),x=e.preserve,p=e.unlink,w=Y(e.cwd),_=S=>{S&&u&&gf(S,c,l),o&&st.chmodSync(t,i)};if(t===w)return Vw(w),_();if(x)return _(st.mkdirSync(t,{mode:i,recursive:!0})??void 0);let I=Y(Zs.relative(w,t)).split("/"),y;for(let S=I.shift(),A=w;S&&(A+="/"+S);S=I.shift()){A=Y(Zs.resolve(A));try{st.mkdirSync(A,i),y=y||A}catch{let T=st.lstatSync(A);if(T.isDirectory())continue;if(p){st.unlinkSync(A),st.mkdirSync(A,i),y=y||A;continue}else if(T.isSymbolicLink())return new ro(A,A+"/"+I.join("/"))}}return _(y)},rc=Object.create(null),Pu=1e4,pr=new Set,Zw=t=>{pr.has(t)?pr.delete(t):rc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),pr.add(t);let e=rc[t],r=pr.size-Pu;if(r>Pu/10){for(let i of pr)if(pr.delete(i),delete rc[i],--r<=0)break}return e},Yw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Xw=Yw==="win32",Qw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=_f(i,r)),e.push(r||"/"),e},[]),e_=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Xw?["win32 parallelization disabled"]:t.map(i=>yi(_f(Zw(i))));let r=new Set(t.map(i=>Qw(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 x of u)o.add(x)}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 x=l[0];typeof x=="function"&&o.add(x)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},t_=()=>process.umask(),Ou=Symbol("onEntry"),vc=Symbol("checkFs"),Lu=Symbol("checkFs2"),Sc=Symbol("isReusable"),dt=Symbol("makeFs"),Ic=Symbol("file"),Ac=Symbol("directory"),Ws=Symbol("link"),Nu=Symbol("symlink"),Mu=Symbol("hardlink"),wi=Symbol("ensureNoSymlink"),Bu=Symbol("unsupported"),Fu=Symbol("checkPath"),ic=Symbol("stripAbsolutePath"),wn=Symbol("mkdir"),qe=Symbol("onError"),Ls=Symbol("pending"),zu=Symbol("pend"),gr=Symbol("unpend"),sc=Symbol("ended"),oc=Symbol("maybeClose"),Tc=Symbol("skip"),bi=Symbol("doChown"),vi=Symbol("uid"),Si=Symbol("gid"),Ii=Symbol("checkedCwd"),n_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ai=n_==="win32",r_=1024,i_=(t,e)=>{if(!Ai)return ie.unlink(t,e);let r=t+".DELETE."+af(16).toString("hex");ie.rename(t,r,i=>{if(i)return e(i);ie.unlink(r,e)})},s_=t=>{if(!Ai)return ie.unlinkSync(t);let e=t+".DELETE."+af(16).toString("hex");ie.renameSync(t,e),ie.unlinkSync(e)},Uu=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Bc=class extends Ti{[sc]=!1;[Ii]=!1;[Ls]=0;reservations=new e_;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[sc]=!0,this[oc]()},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:r_,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Ai,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Y(Me.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:t_():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[Ou](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[oc](){this[sc]&&this[Ls]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[ic](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Oc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Ai&&/^[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=Me.posix.dirname(t.path),x=Me.posix.normalize(Me.posix.join(u,l.join("/")));if(x.startsWith("../")||x==="..")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}[Fu](t){let e=Y(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Y(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[ic](t,"path")||!this[ic](t,"linkpath"))return!1;if(t.absolute=Me.isAbsolute(t.path)?Y(Me.resolve(t.path)):Y(Me.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:Y(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}=Me.win32.parse(String(t.absolute));t.absolute=i+yu(String(t.absolute).slice(i.length));let{root:o}=Me.win32.parse(t.path);t.path=o+yu(t.path.slice(o.length))}return!0}[Ou](t){if(!this[Fu](t))return t.resume();switch(Fw.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[vc](t);default:return this[Bu](t)}}[qe](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[gr](),e.resume())}[wn](t,e,r){$w(Y(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)}[bi](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}[vi](t){return Uu(this.uid,t.uid,this.processUid)}[Si](t){return Uu(this.gid,t.gid,this.processGid)}[Ic](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Ys(String(t.absolute),{flags:hf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ie.close(i.fd,()=>{}),i.write=()=>!0,this[qe](u,t),e()});let o=1,c=u=>{if(u){i.fd&&ie.close(i.fd,()=>{}),this[qe](u,t),e();return}--o===0&&i.fd!==void 0&&ie.close(i.fd,x=>{x?this[qe](x,t):this[gr](),e()})};i.on("finish",()=>{let u=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,w=t.mtime;ie.futimes(x,p,w,_=>_?ie.utimes(u,p,w,I=>c(I&&_)):c())}if(typeof x=="number"&&this[bi](t)){o++;let p=this[vi](t),w=this[Si](t);typeof p=="number"&&typeof w=="number"&&ie.fchown(x,p,w,_=>_?ie.chown(u,p,w,I=>c(I&&_)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[qe](u,t),e()}),t.pipe(l)),l.pipe(i)}[Ac](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[wn](String(t.absolute),r,i=>{if(i){this[qe](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[gr](),t.resume())};t.mtime&&!this.noMtime&&(o++,ie.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[bi](t)&&(o++,ie.chown(String(t.absolute),Number(this[vi](t)),Number(this[Si](t)),c)),c()})}[Bu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Nu](t,e){let r=Y(Me.relative(this.cwd,Me.resolve(Me.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[wi](t,this.cwd,r,()=>this[Ws](t,String(t.linkpath),"symlink",e),i=>{this[qe](i,t),e()})}[Mu](t,e){let r=Y(Me.resolve(this.cwd,String(t.linkpath))),i=Y(String(t.linkpath)).split("/");this[wi](t,this.cwd,i,()=>this[Ws](t,r,"link",e),o=>{this[qe](o,t),e()})}[wi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Me.resolve(e,c);ie.lstat(l,(u,x)=>{if(u)return i();if(x?.isSymbolicLink())return o(new ro(l,Me.resolve(l,r.join("/"))));this[wi](t,l,r,i,o)})}[zu](){this[Ls]++}[gr](){this[Ls]--,this[oc]()}[Tc](t){this[gr](),t.resume()}[Sc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ai}[vc](t){this[zu]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Lu](t,r))}[Lu](t,e){let r=l=>{e(l)},i=()=>{this[wn](this.cwd,this.dmode,l=>{if(l){this[qe](l,t),r();return}this[Ii]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Y(Me.dirname(String(t.absolute)));if(l!==this.cwd)return this[wn](l,this.dmode,u=>{if(u){this[qe](u,t),r();return}c()})}c()},c=()=>{ie.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Tc](t),r();return}if(l||this[Sc](t,u))return this[dt](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=w=>this[dt](w??null,t,r);return x?ie.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return ie.rmdir(String(t.absolute),x=>this[dt](x??null,t,r))}if(t.absolute===this.cwd)return this[dt](null,t,r);i_(String(t.absolute),x=>this[dt](x??null,t,r))})};this[Ii]?o():i()}[dt](t,e,r){if(t){this[qe](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Ic](e,r);case"Link":return this[Mu](e,r);case"SymbolicLink":return this[Nu](e,r);case"Directory":case"GNUDumpDir":return this[Ac](e,r)}}[Ws](t,e,r,i){ie[r](e,String(t.absolute),o=>{o?this[qe](o,t):(this[gr](),t.resume()),i()})}},gi=t=>{try{return[null,t()]}catch(e){return[e,null]}},yf=class extends Bc{sync=!0;[dt](t,e){return super[dt](t,e,()=>{})}[vc](t){if(!this[Ii]){let o=this[wn](this.cwd,this.dmode);if(o)return this[qe](o,t);this[Ii]=!0}if(t.absolute!==this.cwd){let o=Y(Me.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[wn](o,this.dmode);if(c)return this[qe](c,t)}}let[e,r]=gi(()=>ie.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Tc](t);if(e||this[Sc](t,r))return this[dt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?gi(()=>{ie.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[dt](l,t)}let[o]=gi(()=>ie.rmdirSync(String(t.absolute)));this[dt](o,t)}let[i]=t.absolute===this.cwd?[]:gi(()=>s_(String(t.absolute)));this[dt](i,t)}[Ic](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{ie.closeSync(o)}catch(x){u=x}(l||u)&&this[qe](l||u,t),e()},o;try{o=ie.openSync(String(t.absolute),hf(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[qe](l,t)),t.pipe(c)),c.on("data",l=>{try{ie.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,x=t.mtime;try{ie.futimesSync(o,u,x)}catch(p){try{ie.utimesSync(String(t.absolute),u,x)}catch{l=p}}}if(this[bi](t)){let u=this[vi](t),x=this[Si](t);try{ie.fchownSync(o,Number(u),Number(x))}catch(p){try{ie.chownSync(String(t.absolute),Number(u),Number(x))}catch{l=l||p}}}i(l)})}[Ac](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[wn](String(t.absolute),r);if(i){this[qe](i,t),e();return}if(t.mtime&&!this.noMtime)try{ie.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[bi](t))try{ie.chownSync(String(t.absolute),Number(this[vi](t)),Number(this[Si](t)))}catch{}e(),t.resume()}[wn](t,e){try{return Jw(Y(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}}[wi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Me.resolve(c,l);let[u,x]=gi(()=>ie.lstatSync(c));if(u)return i();if(x.isSymbolicLink())return o(new ro(c,Me.resolve(e,r.join("/"))))}i()}[Ws](t,e,r,i){let o=`${r}Sync`;try{ie[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[qe](c,t)}}},o_=t=>{let e=new yf(t),r=t.file,i=of.statSync(r),o=t.maxReadSize||16*1024*1024;new Im(r,{readSize:o,size:i.size}).pipe(e)},a_=(t,e)=>{let r=new Bc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),of.stat(o,(u,x)=>{if(u)l(u);else{let p=new Rc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(r)}})})},Ef=Ci(o_,a_,t=>new yf(t),t=>new Bc(t),(t,e)=>{e?.length&&Xu(t,e)}),c_=(t,e)=>{let r=new Mc(t),i=!0,o,c;try{try{o=it.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=it.openSync(t.file,"w+");else throw x}let l=it.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let w=0,_=0;w<512;w+=_){if(_=it.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(!_)break e}let x=new Hn(u);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>l.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,d_(t,r,c,o,e)}finally{if(i)try{it.closeSync(o)}catch{}}},d_=(t,e,r,i,o)=>{let c=new Hu(t.file,{fd:i,start:r});e.pipe(c),u_(e,o)},l_=(t,e)=>{e=Array.from(e);let r=new to(t),i=(o,c,l)=>{let u=(I,y)=>{I?it.close(o,S=>l(I)):l(null,y)},x=0;if(c===0)return u(null,0);let p=0,w=Buffer.alloc(512),_=(I,y)=>{if(I||y===void 0)return u(I);if(p+=y,p<512&&y)return it.read(o,w,p,w.length-p,x+p,_);if(x===0&&w[0]===31&&w[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,x);let S=new Hn(w);if(!S.cksumValid)return u(null,x);let A=512*Math.ceil((S.size??0)/512);if(x+A+512>c||(x+=A+512,x>=c))return u(null,x);t.mtimeCache&&S.mtime&&t.mtimeCache.set(String(S.path),S.mtime),p=0,it.read(o,w,0,512,x,_)};it.read(o,w,0,512,x,_)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(x,p)=>{if(x&&x.code==="ENOENT"&&l==="r+")return l="w+",it.open(t.file,l,u);if(x||!p)return c(x);it.fstat(p,(w,_)=>{if(w)return it.close(p,()=>c(w));i(p,_.size,(I,y)=>{if(I)return c(I);let S=new Ys(t.file,{fd:p,start:y});r.pipe(S),S.on("error",c),S.on("close",o),f_(r,e)})})};it.open(t.file,l,u)})},u_=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Sr({file:bf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},f_=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Sr({file:bf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},mi=Ci(c_,l_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Om(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")}),yI=Ci(mi.syncFile,mi.asyncFile,mi.syncNoFile,mi.asyncNoFile,(t,e=[])=>{mi.validate?.(t,e),x_(t)}),x_=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))};an();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",UPGRADE:"_agent/upgrade",DELETE:"_agent/delete"};function io(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function vf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function so(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Sf(t){let e=t?.permissionMode;if(typeof e!="string")return;let r=e.trim();return r===""?void 0:r}function If(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function Ir(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Wt();Ke();re();Le();Ke();function En(t,e){if(io(t)!=="cloud")throw new C("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ri(t){return t.startsWith("http://")||t.startsWith("https://")}function oo(t){return t.endsWith("/")?t.slice(0,-1):t}Ke();re();var ao="1008033",Rf="1289";var kf="pbbp2",Df="https://www.coze.cn",Pf="/api/coze_claw/resource/get_frontier_key",E_="https://www.coze.cn",b_="wss://frontier.coze.cn";function co(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??E_}function Of(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??b_}function Ar(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 Di(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var ki=q("handshake");async function Fc(t){let e=co(t.endpoint),r=t.timeoutMs??1e4,i=`${oo(e)}${Pf}?aid=${encodeURIComponent(ao)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Ar(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);ki.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=u.headers.get("x-tt-logid")??"",p=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let S=await u.text().catch(()=>"");throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${S.slice(0,200)}`)}let w=await u.json();if(w.code!==void 0&&w.code!==0)throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${x}`);let _=w.data??{},I=typeof _.access_key=="string"&&_.access_key||typeof _.accessKey=="string"&&_.accessKey||void 0,y=typeof _.device_id=="string"&&_.device_id||typeof _.deviceId=="string"&&_.deviceId||void 0;if(!I||!y){let S=JSON.stringify(w).slice(0,500);throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${S}`)}return ki.info("handshake ok",{remoteDeviceId:y,logid:x,traceId:p}),{accessKey:I,deviceId:y}}catch(u){if(u instanceof C)throw ki.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw ki.warn("handshake timeout",{base:e,timeoutMs:r}),new C("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw ki.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 C("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(l)}}var zc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",yt="auto",Lf=15e4;function Nf(t){return{model:Uc(t.model)??yt,...t.modelToken?{modelToken:t.modelToken}:{}}}function Mf(t){return!t||t===yt}var v_=new Set(["auto","\u81EA\u52A8"]);function Uc(t){let e=t?.trim();if(e)return v_.has(e.toLowerCase())?yt:e}function Bf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=zc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||yt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,e.CLAUDE_CODE_ATTRIBUTION_HEADER="0",t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else Mf(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Ff(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||yt}"`):Mf(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="${zc}/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"');let r=t.modelInfo?.contextWindow??Lf;e.push("-c",`model_context_window=${r}`)}return e}function zf(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function qc(t,e){let{ttEnv:r,usePpe:i}=Di(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Uf(t,e,r){if(!t.modelToken)return{};let i=qc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
92
+ `)}}function Gc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function qf(t,e,r){if(!t.modelToken)return null;let i=t.model||yt,o=qc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${zc}/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??Lf,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Gf(t,e,r){if(!t.modelToken)return[];let i=qc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Ae=q("agent-handlers"),Hf=5*1024*1024,R_=1,k_=6,D_=new Set(["node_modules",".git",".coze","dist","build",".next"]),P_=/^(ppe|boe)_[A-Za-z0-9_-]{1,120}$/,O_=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/,L_=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function N_(t){let e=t?.trim();return e?L_.test(e)||O_.test(e)?e:(Ae.warn("_agent/upgrade: invalid targetVersion, fallback to latest",{targetVersion:t}),"latest"):"latest"}function M_(t){return new Promise((e,r)=>{let i=nt("npx",t,{detached:!0,stdio:"ignore",windowsHide:!0}),o=!1,c=l=>{o||(o=!0,l?r(l):e(i.pid??0))};i.once("spawn",()=>{i.unref(),c()}),i.once("error",l=>c(l))})}var lo=class{constructor(e){this.opts=e}opts;async listSkills(e){En(e._meta,"_agent/listSkills");let r=Ir(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Xe(r).workspace,c=i?.skills??[],l=[];for(let u of c){let x=Dt(o,u.relPath,"SKILL.md");await A_(x).then(w=>w.isFile()).catch(()=>!1)&&l.push(q_(u))}return{skills:l}}async addSkills(e){let r=Ir(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((x,p)=>[x.skillId,p])),u=[];for(let x of o){let p=await Jc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Zc(c,l,p),u.push(x)}return await xs(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){En(e._meta,"_agent/removeSkills");let r=Ir(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 x=Dt(i.workspace,u.relPath);await I_(x,{recursive:!0,force:!0}),Ae.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await xs(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,Ae.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let x=c.downstream;c.downstream=void 0,Ae.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(r).catch(p=>Ae.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 Ae.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Be(r);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Ae.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await cr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Ae.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new C("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Qe(i),Ae.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async upgradeBridge(e){let r=e.agentId||e._meta?.cozeAgentId;if(!r)throw new C("IPC_BAD_REQUEST","_agent/upgrade: missing agentId");if(!await Be(r))throw new C("AGENT_NOT_FOUND",`agent not found: ${r}`);let o=["-y"];e.registry&&Ri(e.registry)&&o.push(`--registry=${e.registry}`);let c=N_(e.targetVersion);o.push("--ignore-existing",`coze-bridge@${c}`,"connect");let l=e._meta?.cozeEnv;l&&P_.test(l)&&o.push("--env",l);let u=await M_(o);return Ae.info("_agent/upgrade: spawned bridge upgrade process",{agentId:r,pid:u,targetVersion:c,currentVersion:e.currentVersion??"",reason:e.reason??""}),{ok:!0,accepted:!0,pid:u,message:"bridge upgrade started"}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new C("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Be(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Qe(i),Ae.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}):(Ae.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(En(e._meta,"_agent/switchModel"),!e.agentId)throw new C("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Uc(e.model)??yt,i=await Be(e.agentId);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Qe(i),Ae.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Ae.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=>Ae.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 x=o.sessions.get(l);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Ae.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(En(e._meta,_t.RESET),!e.agentId)throw new C("IPC_BAD_REQUEST",`${_t.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,_t.RESET),await this.runDetailSync(e.agentId,_t.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Ae.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await ni(e,o)}async clearPersistedAcpSessionIds(e){let r=await Be(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Qe(r)}async repairAgent(e){if(En(e._meta,_t.REPAIR),!e.agentId)throw new C("IPC_BAD_REQUEST",`${_t.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new C("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(i){Ae.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,_t.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Ae.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Ae.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){En(e._meta,"_agent/getFileTree");let r=e._meta,i=Ir(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await Hc(l).catch(()=>null);if(!u)throw new C("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await ti(l,o))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=X_(e.depth);return u.isDirectory()?{tree:await Y_(o,l,c,x)}:{tree:[{name:Q_(c),path:Zf(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){En(e._meta,"_agent/getFileContent");let r=Ir(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new C("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Hc(o).catch(()=>null);if(!c||!c.isFile())throw new C("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await ti(o,i))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Hf)throw new C("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Hf})`);let l=await jf(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 Be(e).catch(()=>null))?.workspace??Xe(e).workspace}safeJoin(e,r){let i=Kc(e,r||"."),o=Vc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Wf}`))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Be(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new C("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function B_(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new C("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new C("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function F_(t){return t==="claude-code"?Dt(".claude","skills"):Dt(".agents","skills")}var z_=3e4,U_=50*1024*1024,Tr=3e4;async function Jc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new C("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new C("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=B_(o.skillName),x=F_(i),p=Dt(x,u),w=Dt(r,p);if(await jc(w,{recursive:!0}),c){let I=Buffer.from(o.content,"utf8");Pi(I.length),await Wc(Dt(w,"SKILL.md"),I,"utf8")}else{let I=await G_(o.downloadUrl);j_(I)?await V_(I,w):W_(I)?await K_(I,w):await Wc(Dt(w,"SKILL.md"),I.toString("utf8"),"utf8")}let _={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 Ae.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),_}function Zc(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 q_(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 G_(t){if(!t)throw new C("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Pi(e);let r=H_(t);return Pi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await jf(e);return Pi(r.length),r}if(Ri(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),z_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new C("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Pi(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new C("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Pi(t){if(t>U_)throw new C("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function H_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new C("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function j_(t){return t.length>=2&&t[0]===31&&t[1]===139}function W_(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 $c(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function K_(t,e){let r,i;try{r=new Vf.default(t),i=r.getEntries()}catch(l){throw new C("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||$c(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new C("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new C("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=l.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new C("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=$_(i),c=Kc(e);for(let l of i){if($c(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let x=Kc(e,u),p=Vc(c,x);if(p.startsWith("..")||p==="..")throw new C("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await jc(x,{recursive:!0});continue}await jc(T_(x),{recursive:!0});let w;try{w=l.getData()}catch(_){throw new C("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${_.message}`,{cause:_})}await Wc(x,w)}}function $_(t){let e;for(let r of t){let i=r.entryName;if(!i||$c(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 V_(t,e){await J_(t);let r=Ef({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar extract timeout (${Tr}ms)`))},Tr);try{await $f(Kf.from(t),r)}catch(c){throw c instanceof C?c:i?new C("IPC_BAD_REQUEST",`tar extract timeout (${Tr}ms)`):new C("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function J_(t){let e=[],r=Sr({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 C("IPC_BAD_REQUEST",`tar list timeout (${Tr}ms)`))},Tr);try{await $f(Kf.from(t),r)}catch(c){throw i?new C("IPC_BAD_REQUEST",`tar list timeout (${Tr}ms)`):new C("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new C("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var Z_=5e3;async function Y_(t,e,r,i){return Jf(t,e,r,i,{count:0})}async function Jf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await S_(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(D_.has(u.name)||u.isSymbolicLink())continue;if(o.count>=Z_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Dt(e,u.name),p=C_(Dt(r,u.name)),w=null;try{w=await Hc(x)}catch{continue}if(w.isSymbolicLink())continue;o.count++;let _={name:u.name,path:Zf(Vc(t,x)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&i>1&&(_.children=await Jf(t,x,p,i-1,o)),l.push(_)}return l.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),l}function X_(t){return!t||t<=0?R_:Math.min(t,k_)}function Q_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Zf(t){return t.split(Wf).join("/")}re();import{readFileSync as NA}from"node:fs";import{dirname as BA,join as FA}from"node:path";import{fileURLToPath as UA}from"node:url";var Cr="0.1.104-beta.0";var bn=q("agent-health-reporter"),ey=1e4,Oi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??ey}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()}),bn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),bn.info("heartbeat stopped"))}async tick(){if(this.inFlight){bn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){bn.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=ty(l);if(!u)continue;let x={agentId:l.agentId,status:u};l.patToken&&(x.patToken=l.patToken),l.accountId&&(x.accountId=l.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:Cr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){bn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(bn.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){bn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){bn.warn("onTickEnd hook failed",{err:String(r)})}}};function ty(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}an();import{mkdir as nd,rm as Ky,stat as $y}from"node:fs/promises";import{homedir as Vy}from"node:os";import{join as S0}from"node:path";rn();import{existsSync as hy}from"node:fs";import{release as py}from"node:os";import{basename as gy,isAbsolute as my}from"node:path";function Li(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Rr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function kr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function vn(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ke();var uo=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)}},te={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021,OPERATION_NOT_ALLOWED_FOR_CLOUD:-32022};function Yf(t){return"method"in t&&"id"in t&&t.id!==void 0}function Xf(t){return"method"in t&&!("id"in t)}function fo(t){return!("method"in t)&&"id"in t}var ny={AGENT_NOT_FOUND:te.AGENT_NOT_FOUND,AGENT_BUSY:te.AGENT_BUSY,AGENT_DISCONNECTED:te.AGENT_DISCONNECTED,AGENT_TIMEOUT:te.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:te.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:te.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:te.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:te.INTERNAL_ERROR,BRIDGE_INTERNAL:te.INTERNAL_ERROR,IPC_AUTH_FAILED:te.INTERNAL_ERROR,IPC_BAD_REQUEST:te.INVALID_REQUEST,METHOD_NOT_FOUND:te.METHOD_NOT_FOUND,MODEL_TOKEN_GEN_FAILED:te.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:te.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:te.OPERATION_NOT_ALLOWED_FOR_LOCAL,OPERATION_NOT_ALLOWED_FOR_CLOUD:te.OPERATION_NOT_ALLOWED_FOR_CLOUD,UPSTREAM_DISCONNECTED:te.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:te.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:te.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:te.FILE_TOO_LARGE,UNSUPPORTED_MIME:te.UNSUPPORTED_MIME,UPLOAD_FAILED:te.UPLOAD_FAILED,UPSTREAM_NOT_READY:te.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:te.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:te.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:te.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:te.AGENT_ENV_NOT_READY};function ry(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ni(t.message)}:typeof t=="string"?Ni(t):typeof t=="object"?sy(t):t}var iy=[[/\/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 Ni(t){let e=t;for(let[r,i]of iy)e=e.replace(r,i);return e}function sy(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ni(i):e[r]=i;return e}function Mi(t){if(t instanceof C){let e=ry(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:ny[t.code]??te.INTERNAL_ERROR,message:Ni(t.message),data:r}}return{code:te.INTERNAL_ERROR,message:Ni(t instanceof Error?t.message:String(t))}}function Qf(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 C(r,o,{retriable:e?.retriable??!1,cause:c})}function t0(t){return`${JSON.stringify(t)}
93
+ `}var e0=10*1024*1024,xo=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>e0){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${e0} bytes`)}),[]}let r=this.buffer.split(`
94
+ `);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 r0={"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","session/set_mode":"session.setMode",initialize:"initialize"},YA=Object.fromEntries(Object.entries(r0).map(([t,e])=>[e,t])),oy={"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"],"session.setMode":["agentId","sessionId"],"agent.pair":[],initialize:[]},Dr=class{seq=0;next(e,r){this.seq+=1;let i=r0[e]??ay(e),o=oy[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>n0(r?.[x]??"")),u=cy(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>n0(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function ay(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function n0(t){return t.replace(/[:_\s]+/g,"-")}function cy(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}on();import{readFileSync as dy}from"node:fs";var ly=384;async function Yc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await ar(t.agentEnvFile,r,{mode:ly})}function Xc(t){try{let e=JSON.parse(dy(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function i0(t,e,r={},i=o=>o){return{...i({...t,...Xc(e)}),...r}}Wt();nr();Ke();re();Le();import{execFileSync as uy,spawnSync as fy}from"node:child_process";function Bi(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Fi(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),fy("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var Qc=new Set;function s0(t){typeof t=="number"&&t>0&&Qc.add(t)}function o0(t){typeof t=="number"&&Qc.delete(t)}function a0(){for(let t of Qc)Fi(t,"SIGKILL")}var Pr="coze-bridge-daemon";function c0(t){let e=t?.execFn??(()=>{if(process.platform==="win32")return"";let o=process.getuid?.()??0;return uy("pgrep",["-U",String(o),"-f",Pr],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3})}),r;try{r=e()}catch{return[]}let i=process.pid;return r.split(`
95
+ `).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function d0(t,e){if(t.length===0)return;let r=e?.killFn??Fi,i=e?.isAliveFn??Bi,o=e?.sleepFn??(u=>new Promise(x=>setTimeout(x,u))),c=e?.graceMs??3e3,l=e?.pollMs??100;for(let u of t)r(u,"SIGTERM");for(let u=0;u<c&&t.some(x=>i(x));u+=l)await o(Math.min(l,c-u));for(let u of t)i(u)&&r(u,"SIGKILL")}var xy=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: (Node binary not found|QCLAW_CLI_NODE_BINARY not set)/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @(zed-industries|agentclientprotocol)\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"acp_module_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code","codex"],match:/Cannot find module[^\n]*node_modules[\\/]@(agentclientprotocol[\\/](claude-agent-acp|codex-acp)|zed-industries[\\/]codex-acp)/i,message:"ACP \u4F9D\u8D56\u672A\u6B63\u786E\u5B89\u88C5 (wrapper \u5165\u53E3\u7F3A\u5931)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u91CD\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"},{reason:"prompt_too_long",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/Prompt is too long|bad request: failed to read body: length limit exceeded/i,message:"\u672C\u8F6E\u8F93\u5165\u8FC7\u957F\uFF0C\u8D85\u8FC7\u6A21\u578B\u4E0A\u4E0B\u6587\u4E0A\u9650\uFF0C\u8BF7\u7CBE\u7B80\u8F93\u5165\u6216\u5F00\u542F\u65B0\u4F1A\u8BDD\u540E\u91CD\u8BD5"}];function l0(t,e){if(!e)return null;for(let r of xy)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function u0(t,e){return l0(t,e)}function f0(t,e){return l0(t,e)}function Or(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function x0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let p=t.suspendedMs+o,w=r-t.startedAt-p;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Or(w,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,l=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=l?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Or(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Or(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Or(c,!1,e)}}var h0=We("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),wy=200,_y=40,yy=We("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Ey=We("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),by=We("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),vy=We("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),Sy=We("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),Iy=We("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),p0=500;function Ay(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=p0?t:`${e.slice(0,p0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Ty(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function g0(t){try{return hy(t)}catch{return}}function Cy(t,e){return{platform:process.platform,osRelease:py(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:my(e.command)?g0(e.command):void 0,cwd:e.cwd,cwdExists:g0(e.cwd),envKeys:e.envKeys}}function Ry(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${gy(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Pt=class{constructor(e){this.opts=e;this.log=q(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new xo({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Dr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;sanitizeEnv(e){return e}async start(){if(this.child)throw new C("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=i0(process.env,this.opts.agentEnvFile??ee().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=nt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,s0(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>wy&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,o0(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=Cy(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new C("AGENT_SPAWN_FAILED",Ry(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));Fi(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Fi(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}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){let i={firstUpdateMs:Sy,phase2GateMs:yy,livenessWindowMs:Ey,absoluteMaxMs:by,approvalMaxMs:Iy,suspendThresholdMs:vy,...r};return this.call("session/prompt",e,h0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Rr("session/cancel",e))}setSessionMode(e){return this.call("session/set_mode",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(kr(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(vn(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=h0,o){if(!this.child||this.stopped)return Promise.reject(new C("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=Li(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let x=r.sessionId;return typeof x=="string"?x:void 0})();return new Promise((x,p)=>{let w={resolve:x,reject:p,timer:null,method:e,promptTimeout:null};if(o){let _=this.now(),I={cfg:o,startedAt:_,lastActivityAt:_,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:_,expectedIntervalMs:Or(0,!1,o),sessionId:u};w.promptTimeout=I;let y=()=>{let S={startedAt:I.startedAt,lastActivityAt:I.lastActivityAt,firstFrameSeen:I.firstFrameSeen,hasActiveTool:I.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:I.suspendedMs,armedAt:I.armedAt,expectedIntervalMs:I.expectedIntervalMs},A=this.now(),T=x0(S,I.cfg,A),R=P=>{I.armedAt=A,I.expectedIntervalMs=P,w.timer=setTimeout(y,P)};if(T.action==="suspend"){I.suspendedMs+=T.suspendedDeltaMs,I.lastActivityAt=A,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:T.suspendedDeltaMs,suspendedMs:I.suspendedMs,...I.sessionId?{sessionId:I.sessionId}:{}}),R(T.rearmMs);return}if(T.action==="continue"){R(T.rearmMs);return}this.pending.delete(c),T.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:T.awaitingApproval,...I.sessionId?{sessionId:I.sessionId}:{}}),p(T.awaitingApproval?new C("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${I.cfg.approvalMaxMs}ms`):new C("AGENT_TIMEOUT",`${e} timed out after ${I.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...I.sessionId?{sessionId:I.sessionId}:{}}),p(new C("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${I.cfg.livenessWindowMs}ms`)))};w.timer=setTimeout(y,I.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(w.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),p(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,w);try{this.writeFrame(l)}catch(_){w.timer&&clearTimeout(w.timer),this.pending.delete(c),p(_)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new C("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(t0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(fo(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),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(this.wireErrorToBridge(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new C("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Ay(e.result)}),r.resolve(e.result));return}if(Xf(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(Yf(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)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let l=typeof i.status=="string"?i.status:void 0,u=l==="completed"||l==="failed"||l==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(vn(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(vn(e.id,Mi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=Qf(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=f0(this.framework,Ty(e));return i?new C(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new C("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(_y).join(`
96
+ `),o=u0(this.framework,i);return o?new C(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new C("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function ky(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 ho=class extends Pt{framework="claude-code";constructor(e){let{command:r,args:i}=ei("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return ky(e)}};rn();import{mkdtempSync as Dy,rmSync as Py}from"node:fs";import{tmpdir as Oy}from"node:os";import{join as Ly}from"node:path";var po=class extends Pt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=ei("codex",e.command,i),l=e.isolateCodexHome?Dy(Ly(Oy(),"coze-bridge-codex-home-")):void 0,u=l?{...e.env??{},CODEX_HOME:l}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(x),this.authMethodId=e.authMethodId,this.codexHomeDir=l}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{Py(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};Ke();var Ny=3e4,Lr=class extends Pt{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,agentId:e.agentId,...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.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Ny))}get acpSessionName(){return this.sessionName}setSessionMode(e){return Promise.reject(new C("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"))}};var m0=["default","acceptEdits","plan","auto","bypassPermissions"],w0=["read-only","auto","full-access"];function Sn(t,e){if(typeof e!="string")return!1;switch(t){case"claude-code":return m0.includes(e);case"codex":return w0.includes(e);case"openclaw":return!1}}function ed(t){switch(t){case"claude-code":return m0.join("/");case"codex":return w0.join("/");case"openclaw":return""}}on();Ke();re();Le();function td(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}rn();var In=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 go=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 In,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)zi(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 zi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}function Kt(t){return t.deployType!=="local"?!1:t.framework==="claude-code"||t.framework==="codex"}Wt();re();import{constants as _0}from"node:fs";import{access as My}from"node:fs/promises";import{delimiter as By,join as Fy}from"node:path";var Et=q("framework-detector"),y0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},zy=[".exe",".cmd",".bat",".ps1"],Wn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??nt,access:e.access??My}}async detect(e){let r=y0[e],i=await this.which(r);if(!i)return Et.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(y0).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(By).filter(Boolean),i=this.env.platform==="win32"?["",...zy]:[""];for(let o of r)for(let c of i){let l=Fy(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?_0.F_OK:_0.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 Et.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return Et.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 Et.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 Et.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?(Et.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}:(Et.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return Et.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return Et.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||Et.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let l=JSON.parse(c[0]);typeof l.gateway?.port=="number"&&(o.port=l.gateway.port),typeof l.service?.runtime?.status=="string"&&(o.runtime=l.service.runtime.status),!i&&typeof l.rpc?.error=="string"&&(o.detail=l.rpc.error)}catch(l){Et.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(qy(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=x=>{c||(c=!0,l&&clearTimeout(l),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{x.kill("SIGKILL"),u(null)},15e3),x.stdout?.on("data",p=>{o+=p.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",p=>u({code:p,stdout:o}))}catch{u(null)}})}},Uy=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function qy(t){return t.replace(Uy,"")}import{homedir as Gy}from"node:os";import{join as Hy}from"node:path";on();Wt();nr();Ke();re();async function v0(){let t=Hy(Gy(),".openclaw/openclaw.json");return(await or(t))?.gateway?.auth?.token??""}var E0=q("openclaw.config"),jy=[0,5e3,5e3],Wy=We("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),b0="models.providers.",mo="agents.defaults.models",wo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new In;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??jy,this.cliTimeoutMs=e.cliTimeoutMs??Wy}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,E0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new C("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=nt(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",l=!1,u=p=>{l||(l=!0,clearTimeout(x),p())};o.stderr?.on("data",p=>{c+=p.toString("utf8")});let x=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);x.unref(),o.on("error",p=>u(()=>i(p))),o.on("close",p=>u(()=>{p===0?r():i(new Error(`exit ${p}: ${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){E0.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",`${b0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${b0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${mo}[${e}]`,()=>this.runCli(["config","set",mo,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${mo}[${e}]`,`${mo}.${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"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var ue=q("agent-manager"),id="bypassPermissions",T0="full-access",C0="full-access";function Jy(t){switch(t){case"read-only":return["-c",'sandbox_mode="read-only"',"-c",'approval_policy="on-request"'];case"auto":return["-c",'sandbox_mode="workspace-write"',"-c",'approval_policy="on-failure"'];case"full-access":return["-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"']}}var Zy=(t,e,r,i,o,c,l,u,x,p)=>{switch(t){case"claude-code":{let w={...o?{...Bf(o),...Uf(o,l,u)}:{},...x??{},IS_SANDBOX:"1"};return new ho({cwd:r,env:w,agentId:i})}case"codex":{let w=o?[...Ff(o),...Gf(o,l,u)]:[],_=T0;p!==void 0&&(Sn("codex",p)?_=p:ue.warn("codex spawn: invalid codexPermissionMode, falling back to full-access",{agentId:i,received:p}));let I=[...w,...Jy(_)],y={...o?zf(o):{},...x??{}},S=!!o;return new po({cwd:r,agentId:i,...I.length>0?{extraArgs:I}:{},...Object.keys(y).length>0?{env:y}:{},...S?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Lr({command:e,cwd:r,agentId:i,...c?{sessionName:td(c)}:{}})}};function rd(t){return t==="claude-code"||t==="codex"}function Yy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(Xy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
97
97
  `)}
98
- `}function My(t){if(t.includes(`
99
- `)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var By={path:"",version:"cloud-deployed"},yf="openclaw_gateway_unavailable",zy="openclaw_default_agent_missing";function bf(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var Fy={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Uy=6e4,wo=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Ly,this.createTimeoutMs=e.createTimeoutMs??Uy,this.detectorFactory=e.detectorFactory??(()=>new $n),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new mo({command:r})),this.openclawConfigDir=e.openclawConfigDir??_f(Oy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{he.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=_f(e,".env");if(await Py(r).then(c=>c.isFile()).catch(()=>!1)){he.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}let o=Ny({...process.env,...Xc(this.paths.agentEnvFile)});await an(r,o,{mode:384}),he.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),he.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new C("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new C("IPC_BAD_REQUEST","framework required");let i=await He(e.agentId,this.paths).catch(()=>null),o=ro(e._meta)==="cloud"||i?.deployType==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let c=this.registry.get(e.agentId);if(c){if(c.framework!==e.framework)throw new C("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${c.framework})`);if(c.status==="error")he.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(D=>he.warn("dispose stale agent failed (ignored)",{err:String(D)})),this.registry.unregister(e.agentId);else if(o&&c.deployType!=="cloud")he.warn("existing agent deployType drifted to local, rebuilding as cloud",{agentId:e.agentId}),await c.dispose("rebuild after deployType drift").catch(D=>he.warn("dispose drifted agent failed (ignored)",{err:String(D)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==c.patToken){he.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),c.setPatToken(e.patToken);let D=await He(e.agentId,this.paths).catch(()=>null);D&&(D.patToken=e.patToken,await et(D,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){he.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let D=await He(e.agentId,this.paths).catch(()=>null);D&&(D.modelInfo=e.modelInfo,await et(D,this.paths))}return he.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:c.agentId,workspace:c.workspace,framework:c.framework}}}if(!o&&!this.config.frameworksCache?.[e.framework])throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let u=Qe(e.agentId,this.paths),x=o?"cloud":"local",g=e.framework==="openclaw"&&x==="local",w;g&&!r?.revive&&(w=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let E=w??(g?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),S=e.workspace??E??u.workspace,y=new AbortController,v=setTimeout(()=>y.abort(new C("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,T=!1;try{o&&td(e.framework)&&await ar(e.framework,y.signal);let D=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new C("AGENT_TIMEOUT","_agent/create aborted")};await ed(u.root,{recursive:!0}),await ed(S,{recursive:!0}),await ed(u.logs,{recursive:!0}),D(),g||await lr(S,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await Al(S,x),D();let P=i,b=D0({model:e.model??P?.model}),k=y0(e._meta)??P?.accountId,O=e.patToken??P?.patToken,U=x==="cloud"?e.modelInfo??P?.modelInfo:void 0;if(A=new po({agentId:e.agentId,framework:e.framework,workspace:S,model:b.model??bt,deployType:x,...k?{accountId:k}:{},...O?{patToken:O}:{},...U?{modelInfo:U}:{}}),A.status="ok",P?.sessions){for(let[re,X]of Object.entries(P.sessions))A.sessions.set(re,{acpSessionId:X.acpSessionId,modelToken:X.modelToken,tokenGeneratedAt:X.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let $=Object.keys(P.sessions).length;$>0&&he.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:$})}this.registry.register(A),T=!0;let B={agentId:e.agentId,framework:e.framework,workspace:S,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:b.model};x==="cloud"&&(B.deployType="cloud"),k&&(B.accountId=k),O&&(B.patToken=O),U&&(B.modelInfo=U),P?.skills&&(B.skills=P.skills),P?.agentName&&(B.agentName=P.agentName),P?.description&&(B.description=P.description),e.framework==="openclaw"&&x==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,S)):he.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let J=e.initialSkills??[];if(J.length>0){let $=[...B.skills??[]],re=new Map($.map((pe,L)=>[pe.skillId,L])),X=await Promise.allSettled(J.map(pe=>Vc({agentId:e.agentId,workspace:S,framework:e.framework,skill:pe}))),Se=0;for(let[pe,L]of X.entries()){let j=J[pe];j&&(L.status==="fulfilled"?(Jc($,re,L.value),Se++):he.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:j.skillId,skillName:j.skillName,err:String(L.reason)}))}Se>0&&(B.skills=$,he.info("initialSkills installed",{agentId:e.agentId,installed:Se,requested:J.length}))}return await et(B,this.paths),he.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:x}),{ok:!0,agentId:e.agentId,workspace:S,framework:e.framework}}catch(D){throw he.error("agent create failed, rolling back",{agentId:e.agentId,err:String(D)}),T&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ky(u.root,{recursive:!0,force:!0}).catch(P=>he.warn("rm agent dir failed (ignored)",{err:String(P)})),D instanceof C?D:new C("AGENT_SPAWN_FAILED",String(D),{cause:D})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&td(e.framework))u=By;else throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);td(e.framework)&&!ds(e.framework)&&(he.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await ar(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,g;e.framework==="openclaw"?g=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path}):g=this.factory(e.framework,u.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv());try{return await g.start(),await g.initialize(Fy),g}catch(w){let E=g instanceof Nt?g.getStderrTail():[];throw E.length>0&&he.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof C?w.code:"unknown",recentStderr:E}),await g.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,w)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new C("AGENT_ENV_NOT_READY",bf(o),{cause:{reason:yf}})}catch(o){he.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof C?i:new C("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};he.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return he.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new C("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:zy}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new C("AGENT_ENV_NOT_READY",bf(r),{cause:{reason:yf}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,x=Qc(o);if(r.deployType==="local"){let S=await this.ensureOpenclawDefaultAgent();return new Mr({command:u,cwd:S.workspace,agentId:S.id,sessionName:x})}let g=await wf(),w=i?L0(i,c,l):null,E;if(w){let S=Gc(o),v=w.models[0]?.id??bt,A=`${S}/${v}`;if(!this.ensuredProviders.has(A)){let T=this.getOpenclawConfig();await T.ensureProvider(S,w),await T.addModelToAllowlist(A),this.ensuredProviders.add(A)}E=A}return new Mr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...g?{gatewayToken:g}:{},...E?{slashModelOnStart:E}:{}})}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=Gc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,he.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,he.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as If}from"node:crypto";import{promises as Vy}from"node:fs";import{basename as Tf}from"node:path";Ve();te();import{promises as qy}from"node:fs";import{basename as jy}from"node:path";var Ef=q("file-upload"),Hy="/api/coze_claw/file/agent_upload",Wy=6e4;async function vf(t,e={}){let i=`${so(ao(e.handshakeBase))}${Hy}`,o=e.timeoutMs??Wy,c=await qy.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",...Dr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,g=setTimeout(()=>x.abort(),o);Ef.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:x.signal}),E=w.headers.get("x-tt-logid")??"";if(!w.ok){let v=await w.text().catch(()=>"");throw new C("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${E}: ${v.slice(0,200)}`)}let S=await w.json();if(S.code!==void 0&&S.code!==0)throw new C("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${E}`);let y=S.data?.file?.file_url;if(!y)throw new C("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(S).slice(0,200)}`);return Ef.info("file upload ok",{uri:y,logid:E}),{uri:y}}catch(w){throw w instanceof C?w:w.name==="AbortError"?new C("UPLOAD_FAILED",`upload timeout (${o}ms) for ${jy(t.path)}`):new C("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(g)}}Ve();te();import{extname as Ky}from"node:path";var $y={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function Sf(t){let e=Ky(t).toLowerCase();return $y[e]??"application/octet-stream"}Oe();var _o=q("agent-send"),Af=50*1024*1024;function Df(t,e,r){let i=t.get(e);if(!i)throw new C("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new C("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new C("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function Cf(t,e,r,i,o,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(g){u=g,x<2&&(_o.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(g)}),await new Promise(w=>setTimeout(w,5e3)))}throw new C("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function Rf(t,e){let{session:r,runtime:i}=Df(e.core,t.agentId,t.sessionId);if(!await ri(t.path,r.workspace))throw new C("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Vy.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new C("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>Af)throw new C("FILE_TOO_LARGE",`${o.size} bytes > limit ${Af}`);let c=await Sf(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new C("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??Tf(t.path),u;try{u=await vf({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(g){throw _o.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:g instanceof C?g.code:"UNKNOWN",message:g instanceof Error?g.message:String(g)}),g}let x={sessionUpdate:"agent_file",messageId:If(),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 Cf(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),_o.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 kf(t,e){let{session:r,runtime:i}=Df(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new C("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??Tf(t.path),c={sessionUpdate:"group_file",messageId:If(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Cf(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),_o.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 Pf(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}on();An();te();var Mt=q("coze-cli-installer"),Of="@coze/cli@latest",Jy="coze",Lf="0.1.8",Zy=5e3,Xy=5e3,Yy=9e4,Nf=1e4,Gi=null,yo=!1;async function nd(t,e={}){if(yo)return;if(Gi)return Gi;let r=e.exec??ef;return Gi=(async()=>{try{let i=await Qy(Jy,r),o=!1;if(i){let l=await eb(r);if(l===void 0)Mt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(Pf(l,Lf))Mt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:Lf}),o=!0;else{Mt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),yo=!0;return}}let c=o?"upgrade-only":"full";Mt.info("coze-cli install start",{package:Of,mode:c});try{await r("npm",["i","-g","--prefer-online",Of],{timeout:Yy,maxBuffer:10*1024*1024}),Mt.info("coze-cli install ok")}catch(l){Mt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){yo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Nf}),Mt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Mt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Nf}),Mt.info("coze auth login ok")}catch(l){Mt.warn("coze auth login failed",{err:String(l)});return}yo=!0}finally{Gi=null}})(),Gi}async function Qy(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Zy});return Ia(i)}catch{return}}async function eb(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Xy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}cn();Oe();var tb=10*6e4;function Mf(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?tb:e}function bo(t){return cr(t??Y().configFile)}function qi(t,e){return dr(e??Y().configFile,t)}import{randomBytes as bb}from"node:crypto";ir();Ve();te();import{createReadStream as nb}from"node:fs";import{mkdir as rb,readFile as ib,realpath as sb,stat as ob,writeFile as ab}from"node:fs/promises";import{basename as cb,dirname as rd,isAbsolute as db,join as lb,relative as ub,resolve as Bf,sep as fb}from"node:path";import{createInterface as xb}from"node:readline";var Ff=q("fs-rpc"),ji=Ke("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Uf(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>ji)throw new C("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${ji} bytes`);let i=await qf(t.path,e);return await rb(rd(i),{recursive:!0}),await ab(i,t.content,"utf8"),Ff.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Gf(t,e){let r=await qf(t.path,e),i=await ob(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>ji&&!o)throw new C("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${ji} bytes`);let c;if(o&&i.size>ji)c=await hb(r,t.line??1,t.limit);else{let l=await ib(r,"utf8");if(o){let u=l.split(`
100
- `),x=Math.max(0,(t.line??1)-1),g=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,g).join(`
101
- `)}else c=l}return Ff.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function hb(t,e,r){let i=xb({input:nb(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 x of i)if(u>=o&&u<c&&l.push(x),u++,u>=c)break}finally{i.close()}return l.join(`
102
- `)}async function qf(t,e){if(typeof t!="string"||t.length===0)throw new C("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([zf(Bf(e)),zf(Bf(t))]),o=ub(r,i);if(pb(o,fb,db(o)))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function pb(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function zf(t){let e=[],r=t;for(;r!==rd(r);)try{let i=await sb(r);return e.length?lb(i,...e.reverse()):i}catch{e.push(cb(r)),r=rd(r)}return t}te();var jf=q("prompt-multimodal"),Hf=10*1024*1024,gb=15e3,mb=6;async function Wf(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 wb(l))}}let o=Array.from({length:Math.min(mb,t.length)},()=>i());return await Promise.all(o),e}function Kf(t){return t.some(e=>e.type==="image")}async function wb(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!io(e.uri))return t;try{let{buf:r,contentType:i}=await yb(e.uri),o=e.mimeType||_b(i)||"application/octet-stream";return jf.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 jf.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function _b(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function yb(t){let e=new AbortController,r=setTimeout(()=>e.abort(),gb);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>Hf)throw new Error(`image too large: ${o.byteLength} bytes (max ${Hf})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}dn();Ve();te();var V=q("core"),Eb=3e4,vb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,Sb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",Ab="\u5BA1\u6279\u5DF2\u8D85\u65F6",Ib=3e4,Eo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Or;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=Mf(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)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}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}),Ui(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(Sn(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.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new C("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(uo(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&&vb.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(Pr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Pr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Pr(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(Sn(r,Bi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new C("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new C("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new C("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new C("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let g=r._meta?.cozeTriggerMsgId,w=Mc(r._meta);return V.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,Sb,g,w)}}let l=Date.now(),u=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,x}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}=b0(i);switch(r){case"session/new":{let c=Tb();return V.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return V.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,l);if(u.replySeq=0,await this.ensureDownstream(e,l,u),!u.downstream||!u.acpSessionId)throw new C("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(u.acpSessionId,x):e.activeTriggers.delete(u.acpSessionId);let g=Mc(i._meta);if(g?e.activeGroupIds.set(u.acpSessionId,g):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Kf(c.prompt))throw new C("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await Wf(c.prompt);try{let E=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:w});return u.lastActiveAt=Date.now(),E}catch(E){if(E instanceof C&&E.code==="AGENT_APPROVAL_TIMEOUT"){let S=u.pendingPermission;S&&(S.downstream.respondAgentRequest(S.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(S.upstreamId),u.pendingPermission=void 0);let y=u.acpSessionId,v=y?e.activeTriggers.get(y):void 0,A=y?e.activeGroupIds.get(y):void 0;return V.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,u,l,Ab,v,A)}throw E}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.pendingPermission=void 0,u.reloadAfterTurn){u.reloadAfterTurn=!1;let E=u.downstream;E&&(u.downstream=void 0,V.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:u.acpSessionId}),E.stop("reload-after-turn").catch(S=>V.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(S)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,l,u)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let x=e.getSessionQueue(l);x.size>0&&(V.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:x.size}),x.dispose(new C("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 C("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(yt.GEN_MODEL_TOKEN,i,Ib);if(!o?.modelToken)throw new C("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof C&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new C("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Ui(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new C("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new C("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(g){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),g}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),V.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(g){V.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(g)}),i.acpSessionId=void 0;let w=await x.sessionNew({cwd:e.workspace});i.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let g=await x.sessionNew({cwd:e.workspace});i.acpSessionId=g.sessionId,await this.persistSessionMapping(e)}}catch(g){throw V.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(g)}),await x.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,g}x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Ui(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(kr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),l&&(u.cozeGroupId=l),await this.upstream.send(kr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(x=>V.warn("synthesizePromptReply update send failed (ignored)",{err:String(x)})),{stopReason:"end_turn"}}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(Rb(r)){V.debug("drop codex noise 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 x=e.activeGroupIds.get(i);x&&(l.cozeGroupId=x),this.upstream.send(kr("session/update",{...r,sessionId:o,_meta:l})).catch(g=>V.warn("forward update failed",{agentId:e.agentId,err:String(g)}))}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 Uf(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Gf(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,Bi(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,g={cozeAgentId:e.agentId};x&&(g.cozeTriggerMsgId=x);let w=u?e.activeGroupIds.get(u):void 0;w&&(g.cozeGroupId=w);let E=u?this.reverseSessionId(e,u):void 0,S=E?e.sessions.get(E):void 0;S&&(S.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let y={...c,...E?{sessionId:E}:{},_meta:g};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:E}),V.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Ni(o,"session/request_permission",y)).catch(v=>{this.pendingUpstream.delete(o),V.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}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;this.clearPendingPermissionFor(o),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"&&Db(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 lo(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=Eb){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(Ni(o,e,r)).catch(x=>{let g=this.pendingBridge.get(o);g&&(clearTimeout(g.timer),this.pendingBridge.delete(o)),l(x)})})}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 ii(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(Sn(e,{code:r,message:i,data:{bridgeVersion:Rr}}))}};function Tb(){return bb(16).toString("hex")}function Db(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})}var Cb=["Model metadata for `","Falling back from WebSockets to HTTPS transport.","Heads up: Long threads and multiple compactions can cause the model to be less accurate."];function Rb(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;if(i.type!=="text"||typeof i.text!="string")return!1;let{text:o}=i;return Cb.some(c=>o.startsWith(c))}cn();te();Oe();import{randomBytes as kb}from"node:crypto";import{createServer as Pb}from"node:http";var Ob=1e6,$f=q("ipc"),vo=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??Y()}async start(){this.token=kb(32).toString("hex");let e=Pb((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(),$f.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 an(this.paths.portFile,String(this.port)),await an(this.paths.tokenFile,this.token,{mode:384})}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Hi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Hi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await Lb(e)}catch(u){Hi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Hi(r,200,u??{ok:!0})}catch(u){$f.error("IPC handler failed",{key:o,err:String(u)}),Hi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Hi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function Lb(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>Ob)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var gh=It(ix(),1);var hv=It(eh(),1),pv=It(Fo(),1),gv=It(Fr(),1),mv=It(gd(),1),wv=It(_d(),1),_v=It(Ad(),1),dh=It(jo(),1),yv=It(ch(),1);var lh=dh.default;Ve();te();var ke=q("upstream.frontier"),fh="application/json",xh="none",Ev=15e3;function vv(t){class e extends lh{constructor(i){super(i,v0,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>ke.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(ul("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");ke.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){ke.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Qi=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){ke.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:S0,...Dr(this.opts.ppeOverride)},r=vv(e),i=I0(this.opts.urlOverride),o={url:i,ws:r,fpID:E0,aID:oo,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:fh,force:!0},payloadEncoding:{encoding:xh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new gh.FWS(o),l=!1,u=null,x,g,w=new Promise((y,v)=>{x=y,g=v}),E=y=>{l||(l=!0,u&&(clearTimeout(u),u=null),y?g(y):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;ke.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&E();for(let v of this.connectHandlers)Promise.resolve(v({initial:y})).catch(A=>ke.warn("onConnect handler threw (ignored)",{err:String(A)}))},c.onclose=y=>{this.opened=!1,ke.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{ke.warn("frontier error",{code:y.code,msg:y.message}),E(new C("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let S=this.opts.openTimeoutMs??Ev;u=setTimeout(()=>{E(new C("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${S}ms (handshake or upgrade slow)`))},S),await c.connect();try{await w}catch(y){try{c.close(1e3,"open failed")}catch(v){ke.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,y}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){ke.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw ke.warn("frontier send refused: upstream not started",{method:i}),new C("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(ke.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 C("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;hh(c)||ke.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:fh,payloadEncoding:xh})}catch(u){throw ke.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new C("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){ke.debug("drop non-adapter frontier frame",{service:r});return}let i=Iv(e);if(!i){ke.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){ke.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){ke.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;hh(c)||ke.info("frontier frame in",{logid:Av(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:Sv(i)}),Promise.resolve(this.handler(o)).catch(l=>ke.warn("frontier frame handler threw",{err:String(l)}))}};function hh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var ph=2e3;function Sv(t){return t.length<=ph?t:`${t.slice(0,ph)}...<truncated, total ${t.length} chars>`}function Av(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function Iv(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}te();var Td=q("upstream.switchable"),Wo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Td.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 Td.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Td.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()}};te();var Dd=q("upstream"),Wr=class{handler=null;async start(){Dd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Dd.info("NoopUpstream stopped",{reason:e})}async send(e){Dd.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)}};Ve();te();cn();te();Oe();import{promises as Tv}from"node:fs";var mh=q("pat-token-store");async function Ko(t=Y()){try{let r=(await Tv.readFile(t.patTokenFile,"utf8")).trim();return r.length===0?(mh.warn("pat-token exists but empty (treating as missing; likely interrupted write)",{path:t.patTokenFile}),null):r}catch(e){let r=e?.code;return r!=="ENOENT"&&mh.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function es(t,e=Y()){if(!t)throw new Error("writePatToken: empty patToken");await an(e.patTokenFile,t,{mode:384})}Oe();Oe();import{promises as $o}from"node:fs";import{join as Dv}from"node:path";function Cv(t,e){return`#!/bin/sh
98
+ `}function Xy(t){if(t.includes(`
99
+ `)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var Qy={path:"",version:"cloud-deployed"},I0="openclaw_gateway_unavailable",e1="openclaw_default_agent_missing";function A0(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var t1={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},n1=6e4,_o=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Zy,this.createTimeoutMs=e.createTimeoutMs??n1,this.detectorFactory=e.detectorFactory??(()=>new Wn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new wo({command:r})),this.openclawConfigDir=e.openclawConfigDir??S0(Vy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{ue.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=S0(e,".env");if(await $y(r).then(c=>c.isFile()).catch(()=>!1)){ue.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}let o=Yy({...process.env,...Xc(this.paths.agentEnvFile)});await sn(r,o,{mode:384}),ue.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),ue.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new C("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new C("IPC_BAD_REQUEST","framework required");let i=await Be(e.agentId,this.paths).catch(()=>null),o=io(e._meta)==="cloud"||i?.deployType==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let c=this.registry.get(e.agentId);if(c){if(c.framework!==e.framework)throw new C("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${c.framework})`);if(c.status==="error")ue.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(R=>ue.warn("dispose stale agent failed (ignored)",{err:String(R)})),this.registry.unregister(e.agentId);else if(o&&c.deployType!=="cloud")ue.warn("existing agent deployType drifted to local, rebuilding as cloud",{agentId:e.agentId}),await c.dispose("rebuild after deployType drift").catch(R=>ue.warn("dispose drifted agent failed (ignored)",{err:String(R)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==c.patToken){ue.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),c.setPatToken(e.patToken);let R=await Be(e.agentId,this.paths).catch(()=>null);R&&(R.patToken=e.patToken,await Qe(R,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){ue.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let R=await Be(e.agentId,this.paths).catch(()=>null);R&&(R.modelInfo=e.modelInfo,await Qe(R,this.paths))}return ue.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:c.agentId,workspace:c.workspace,framework:c.framework}}}if(!o&&!this.config.frameworksCache?.[e.framework])throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let u=Xe(e.agentId,this.paths),x=o?"cloud":"local",p=e.framework==="openclaw"&&x==="local",w;p&&!r?.revive&&(w=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let _=w??(p?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),I=e.workspace??_??u.workspace,y=new AbortController,S=setTimeout(()=>y.abort(new C("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,T=!1;try{o&&rd(e.framework)&&await sr(e.framework,y.signal);let R=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new C("AGENT_TIMEOUT","_agent/create aborted")};await nd(u.root,{recursive:!0}),await nd(I,{recursive:!0}),await nd(u.logs,{recursive:!0}),R(),p||await cr(I,e.framework,e.cozeIdentity),e.framework==="claude-code"&&(x==="cloud"?await Ra(I,"cloud"):await Ra(I,"local",id)),R();let P=i,E=Nf({model:e.model??P?.model}),k=vf(e._meta)??P?.accountId,O=e.patToken??P?.patToken,F=x==="cloud"?e.modelInfo??P?.modelInfo:void 0;if(A=new go({agentId:e.agentId,framework:e.framework,workspace:I,model:E.model??yt,deployType:x,...k?{accountId:k}:{},...O?{patToken:O}:{},...F?{modelInfo:F}:{}}),A.status="ok",P?.sessions){let $=x==="local"&&(e.framework==="claude-code"||e.framework==="codex");for(let[Z,se]of Object.entries(P.sessions)){let ae={acpSessionId:se.acpSessionId,modelToken:se.modelToken,tokenGeneratedAt:se.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};$?se.permissionMode===void 0?(ae.permissionMode=e.framework==="claude-code"?"bypassPermissions":"full-access",ue.info("autoRevive: legacy session (no permissionMode) \u2192 fallback to D80/D84 default",{agentId:e.agentId,cloudId:Z,framework:e.framework,fallback:ae.permissionMode})):Sn(e.framework,se.permissionMode)?ae.permissionMode=se.permissionMode:ue.warn("autoRevive: dropping invalid persisted permissionMode",{agentId:e.agentId,cloudId:Z,framework:e.framework,value:se.permissionMode}):se.permissionMode!==void 0&&ue.info("autoRevive: dropping persisted permissionMode (gate disabled)",{agentId:e.agentId,cloudId:Z,framework:e.framework,deployType:x}),se.cozeGroupId&&(ae.cozeGroupId=se.cozeGroupId),A.sessions.set(Z,ae)}let ne=Object.keys(P.sessions).length;ne>0&&ue.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ne})}this.registry.register(A),T=!0;let B={agentId:e.agentId,framework:e.framework,workspace:I,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:E.model};x==="cloud"&&(B.deployType="cloud"),k&&(B.accountId=k),O&&(B.patToken=O),F&&(B.modelInfo=F),P?.skills&&(B.skills=P.skills),P?.agentName&&(B.agentName=P.agentName),P?.description&&(B.description=P.description),e.framework==="openclaw"&&x==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,I)):ue.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let V=e.initialSkills??[];if(V.length>0){let $=[...B.skills??[]],ne=new Map($.map((ae,L)=>[ae.skillId,L])),Z=await Promise.allSettled(V.map(ae=>Jc({agentId:e.agentId,workspace:I,framework:e.framework,skill:ae}))),se=0;for(let[ae,L]of Z.entries()){let G=V[ae];G&&(L.status==="fulfilled"?(Zc($,ne,L.value),se++):ue.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:G.skillId,skillName:G.skillName,err:String(L.reason)}))}se>0&&(B.skills=$,ue.info("initialSkills installed",{agentId:e.agentId,installed:se,requested:V.length}))}return await Qe(B,this.paths),ue.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:x}),{ok:!0,agentId:e.agentId,workspace:I,framework:e.framework}}catch(R){throw ue.error("agent create failed, rolling back",{agentId:e.agentId,err:String(R)}),T&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Ky(u.root,{recursive:!0,force:!0}).catch(P=>ue.warn("rm agent dir failed (ignored)",{err:String(P)})),R instanceof C?R:new C("AGENT_SPAWN_FAILED",String(R),{cause:R})}finally{clearTimeout(S)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&rd(e.framework))u=Qy;else throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);rd(e.framework)&&!ls(e.framework)&&(ue.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await sr(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;if(e.framework==="openclaw")p=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path});else{let w=e.sessions.get(i),_=Kt(e)?w?.permissionMode??T0:"full-access";p=this.factory(e.framework,u.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv(),_)}try{return await p.start(),await p.initialize(t1),p}catch(w){let _=p instanceof Pt?p.getStderrTail():[];throw _.length>0&&ue.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof C?w.code:"unknown",recentStderr:_}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,w)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new C("AGENT_ENV_NOT_READY",A0(o),{cause:{reason:I0}})}catch(o){ue.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof C?i:new C("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};ue.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return ue.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new C("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:e1}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new C("AGENT_ENV_NOT_READY",A0(r),{cause:{reason:I0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,x=td(o);if(r.deployType==="local"){let I=await this.ensureOpenclawDefaultAgent();return new Lr({command:u,cwd:I.workspace,agentId:I.id,sessionName:x})}let p=await v0(),w=i?qf(i,c,l):null,_;if(w){let I=Gc(o),S=w.models[0]?.id??yt,A=`${I}/${S}`;if(!this.ensuredProviders.has(A)){let T=this.getOpenclawConfig();await T.ensureProvider(I,w),await T.addModelToAllowlist(A),this.ensuredProviders.add(A)}_=A}return new Lr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...p?{gatewayToken:p}:{},..._?{slashModelOnStart:_}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Gc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,ue.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,ue.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as O0}from"node:crypto";import{promises as l1}from"node:fs";import{basename as L0}from"node:path";Ke();re();import{promises as i1}from"node:fs";import{basename as s1}from"node:path";var R0=q("file-upload"),o1="/api/coze_claw/file/agent_upload",a1=6e4;async function k0(t,e={}){let i=`${oo(co(e.handshakeBase))}${o1}`,o=e.timeoutMs??a1,c=await i1.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",...Ar(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),o);R0.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:x.signal}),_=w.headers.get("x-tt-logid")??"";if(!w.ok){let S=await w.text().catch(()=>"");throw new C("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${_}: ${S.slice(0,200)}`)}let I=await w.json();if(I.code!==void 0&&I.code!==0)throw new C("UPLOAD_FAILED",`upload code=${I.code} msg=${I.msg??"-"} logid=${_}`);let y=I.data?.file?.file_url;if(!y)throw new C("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(I).slice(0,200)}`);return R0.info("file upload ok",{uri:y,logid:_}),{uri:y}}catch(w){throw w instanceof C?w:w.name==="AbortError"?new C("UPLOAD_FAILED",`upload timeout (${o}ms) for ${s1(t.path)}`):new C("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(p)}}Ke();re();import{extname as c1}from"node:path";var d1={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function D0(t){let e=c1(t).toLowerCase();return d1[e]??"application/octet-stream"}Le();var yo=q("agent-send"),P0=50*1024*1024;function N0(t,e,r){let i=t.get(e);if(!i)throw new C("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new C("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new C("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function M0(t,e,r,i,o,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(p){u=p,x<2&&(yo.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(w=>setTimeout(w,5e3)))}throw new C("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function B0(t,e){let{session:r,runtime:i}=N0(e.core,t.agentId,t.sessionId);if(!await ti(t.path,r.workspace))throw new C("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await l1.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new C("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>P0)throw new C("FILE_TOO_LARGE",`${o.size} bytes > limit ${P0}`);let c=await D0(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new C("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??L0(t.path),u;try{u=await k0({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 yo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof C?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:O0(),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 M0(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),yo.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 F0(t,e){let{session:r,runtime:i}=N0(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new C("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??L0(t.path),c={sessionUpdate:"group_file",messageId:O0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await M0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),yo.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 z0(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}rn();Wt();re();var Ot=q("coze-cli-installer"),U0="@coze/cli@latest",u1="coze",q0="0.1.8",f1=5e3,x1=5e3,h1=9e4,G0=1e4,Ui=null,Eo=!1;async function sd(t,e={}){if(Eo)return;if(Ui)return Ui;let r=e.exec??Cf;return Ui=(async()=>{try{let i=await p1(u1,r),o=!1;if(i){let l=await g1(r);if(l===void 0)Ot.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(z0(l,q0))Ot.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:q0}),o=!0;else{Ot.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),Eo=!0;return}}let c=o?"upgrade-only":"full";Ot.info("coze-cli install start",{package:U0,mode:c});try{await r("npm",["i","-g","--prefer-online",U0],{timeout:h1,maxBuffer:10*1024*1024}),Ot.info("coze-cli install ok")}catch(l){Ot.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){Eo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:G0}),Ot.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Ot.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:G0}),Ot.info("coze auth login ok")}catch(l){Ot.warn("coze auth login failed",{err:String(l)});return}Eo=!0}finally{Ui=null}})(),Ui}async function p1(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:f1});return Ta(i)}catch{return}}async function g1(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:x1});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}on();Le();var m1=10*6e4;function H0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?m1:e}function bo(t){return or(t??ee().configFile)}function qi(t,e){return ar(e??ee().configFile,t)}import{randomBytes as B1}from"node:crypto";nr();Ke();re();import{createReadStream as w1}from"node:fs";import{mkdir as _1,readFile as y1,realpath as E1,stat as b1,writeFile as v1}from"node:fs/promises";import{basename as S1,dirname as od,isAbsolute as I1,join as A1,relative as T1,resolve as j0,sep as C1}from"node:path";import{createInterface as R1}from"node:readline";var K0=q("fs-rpc"),Gi=We("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function $0(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Gi)throw new C("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Gi} bytes`);let i=await J0(t.path,e);return await _1(od(i),{recursive:!0}),await v1(i,t.content,"utf8"),K0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function V0(t,e){let r=await J0(t.path,e),i=await b1(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Gi&&!o)throw new C("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Gi} bytes`);let c;if(o&&i.size>Gi)c=await k1(r,t.line??1,t.limit);else{let l=await y1(r,"utf8");if(o){let u=l.split(`
100
+ `),x=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,p).join(`
101
+ `)}else c=l}return K0.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function k1(t,e,r){let i=R1({input:w1(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 x of i)if(u>=o&&u<c&&l.push(x),u++,u>=c)break}finally{i.close()}return l.join(`
102
+ `)}async function J0(t,e){if(typeof t!="string"||t.length===0)throw new C("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([W0(j0(e)),W0(j0(t))]),o=T1(r,i);if(D1(o,C1,I1(o)))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function D1(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function W0(t){let e=[],r=t;for(;r!==od(r);)try{let i=await E1(r);return e.length?A1(i,...e.reverse()):i}catch{e.push(S1(r)),r=od(r)}return t}re();var Z0=q("prompt-multimodal"),Y0=10*1024*1024,P1=15e3,O1=6;async function X0(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 L1(l))}}let o=Array.from({length:Math.min(O1,t.length)},()=>i());return await Promise.all(o),e}function Q0(t){return t.some(e=>e.type==="image")}async function L1(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ri(e.uri))return t;try{let{buf:r,contentType:i}=await M1(e.uri),o=e.mimeType||N1(i)||"application/octet-stream";return Z0.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 Z0.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function N1(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function M1(t){let e=new AbortController,r=setTimeout(()=>e.abort(),P1);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>Y0)throw new Error(`image too large: ${o.byteLength} bytes (max ${Y0})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}an();Ke();re();var W=q("core"),F1=3e4,z1=/^(boe|ppe)_[A-Za-z0-9_-]+$/,U1="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",q1="\u5BA1\u6279\u5DF2\u8D85\u65F6",G1=3e4,vo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Dr;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=H0(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(),W.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){W.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),W.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){W.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)&&W.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)=>{W.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),zi(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){W.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(vn(o,{code:te.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>W.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:te.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){W.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:te.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new C("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(fo(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&&z1.test(i)?this.currentCozeEnv=i:i&&W.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,te.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):W.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(kr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(kr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(kr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,te.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):W.warn("drop unknown notification",{method:e.method})}catch(o){W.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(vn(r,Mi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new C("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new C("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new C("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new C("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||e.method==="session/set_mode"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let p=r._meta?.cozeTriggerMsgId,w=so(r._meta);return W.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,U1,p,w)}}let l=Date.now(),u=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,x}finally{W.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}=If(i);switch(r){case"session/new":{let c=H1();return W.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return W.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=Kt(e)?Sf(i._meta):void 0;if(u!==void 0&&!Sn(e.framework,u))throw new C("IPC_BAD_REQUEST",`unsupported permissionMode for ${e.framework}: ${u}; allowed: ${ed(e.framework)}`);let x=await this.ensureRuntime(e,l);if(u!==void 0&&x.permissionMode===void 0&&(x.permissionMode=u,await this.persistSessionMapping(e)),x.replySeq=0,await this.ensureDownstream(e,l,x),!x.downstream||!x.acpSessionId)throw new C("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");if(u!==void 0&&x.permissionMode!==void 0&&x.permissionMode!==u){let I=x.permissionMode;x.permissionMode=u,await this.persistSessionMapping(e);try{await x.downstream.setSessionMode({sessionId:x.acpSessionId,modeId:u})}catch(y){throw x.permissionMode=I,await this.persistSessionMapping(e).catch(()=>{}),y}}let p=i._meta?.cozeTriggerMsgId;p?e.activeTriggers.set(x.acpSessionId,p):e.activeTriggers.delete(x.acpSessionId);let w=so(i._meta);if(w?e.activeGroupIds.set(x.acpSessionId,w):e.activeGroupIds.delete(x.acpSessionId),w&&x.cozeGroupId!==w&&(x.cozeGroupId=w,await this.persistSessionMapping(e)),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Q0(c.prompt))throw new C("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let _=await X0(c.prompt);try{let I=await x.downstream.sessionPrompt({...c,sessionId:x.acpSessionId,prompt:_});return x.lastActiveAt=Date.now(),I}catch(I){if(I instanceof C&&I.code==="AGENT_APPROVAL_TIMEOUT"){let y=x.pendingPermission;y&&(y.downstream.respondAgentRequest(y.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(y.upstreamId),x.pendingPermission=void 0);let S=x.acpSessionId,A=S?e.activeTriggers.get(S):void 0,T=S?e.activeGroupIds.get(S):void 0;return W.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,x,l,q1,A,T)}throw I}finally{if(e.activeTriggers.delete(x.acpSessionId),e.activeGroupIds.delete(x.acpSessionId),x.pendingPermission=void 0,x.reloadAfterTurn){x.reloadAfterTurn=!1;let I=x.downstream;I&&(x.downstream=void 0,W.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:x.acpSessionId}),I.stop("reload-after-turn").catch(y=>W.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(y)})))}else x.downstream?.isAlive()&&this.armIdleTimer(e,l,x)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let x=e.getSessionQueue(l);x.size>0&&(W.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:x.size}),x.dispose(new C("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}case"session/set_mode":{let c=o,l=c.sessionId,u=c.modeId,x=so(i._meta);if(!l)throw new C("IPC_BAD_REQUEST","session/set_mode: missing sessionId");if(!Kt(e))throw e.framework==="openclaw"?new C("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"):new C("OPERATION_NOT_ALLOWED_FOR_CLOUD","session/set_mode is local-deploy only in this iteration");if(!Sn(e.framework,u))throw new C("IPC_BAD_REQUEST",`unsupported modeId for ${e.framework}: ${String(u)}; allowed: ${ed(e.framework)}`);if(x)return await this.handleGroupSetMode(e,x,u);let p=e.sessions.get(l)??await this.ensureRuntime(e,l);if(p.permissionMode===u)return{};let w=p.permissionMode;if(p.permissionMode=u,await this.persistSessionMapping(e),p.downstream?.isAlive()&&p.acpSessionId)try{await p.downstream.setSessionMode({sessionId:p.acpSessionId,modeId:u})}catch(_){throw p.permissionMode=w,await this.persistSessionMapping(e).catch(()=>{}),_}else W.info("session/set_mode: runtime not active, persisted only",{framework:e.framework,agentId:e.agentId,cloudId:l,modeId:u});return{}}default:throw new C("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async handleGroupSetMode(e,r,i){let o=[];for(let[l,u]of e.sessions)u.cozeGroupId===r&&u.permissionMode!==i&&o.push({cloudId:l,runtime:u,oldMode:u.permissionMode});if(o.length===0)return W.info("group session/set_mode: no active runtime (db-only path)",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i}),{};W.info("group session/set_mode: applying to runtimes",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i,targets:o.length});for(let l of o)l.runtime.permissionMode=i;await this.persistSessionMapping(e);let c=[];for(let l of o){let u=l.runtime.downstream,x=l.runtime.acpSessionId;u?.isAlive()&&x&&c.push({downstream:u,acpSessionId:x,oldMode:l.oldMode,runtime:l.runtime})}for(let l of c)try{await l.downstream.setSessionMode({sessionId:l.acpSessionId,modeId:i})}catch(u){for(let x of o)x.runtime.permissionMode=x.oldMode;throw await this.persistSessionMapping(e).catch(()=>{}),u}return{}}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 Kt(e)&&(c.permissionMode=e.framework==="claude-code"?id:C0),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(_t.GEN_MODEL_TOKEN,i,G1);if(!o?.modelToken)throw new C("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof C&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new C("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(zi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new C("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new C("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let x;try{x=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&&(W.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),p}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),W.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){W.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 x.sessionNew({cwd:e.workspace});i.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let p=await x.sessionNew({cwd:e.workspace});i.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}}catch(p){throw W.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),await x.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,p}if(x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId),Kt(e)&&i.acpSessionId&&i.permissionMode)try{await x.setSessionMode({sessionId:i.acpSessionId,modeId:i.permissionMode})}catch(p){W.warn("post-spawn set_mode failed, framework using its own startup default",{framework:e.framework,agentId:e.agentId,cloudId:r,mode:i.permissionMode,err:String(p)})}}armIdleTimer(e,r,i){if(zi(i),this.isRuntimeBusy(e,i)){W.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)){W.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}W.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=>W.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(Rr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),l&&(u.cozeGroupId=l),await this.upstream.send(Rr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(x=>W.warn("synthesizePromptReply update send failed (ignored)",{err:String(x)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){W.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){W.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(K1(r)){W.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let l=r.update;if(l&&typeof l=="object"&&l.sessionUpdate==="current_mode_update"&&Kt(e)){let w=l.currentModeId;Sn(e.framework,w)&&c.permissionMode!==w?(c.permissionMode=w,this.persistSessionMapping(e).catch(_=>W.warn("persist mode (from current_mode_update) failed",{framework:e.framework,agentId:e.agentId,err:String(_)}))):typeof w=="string"&&!Sn(e.framework,w)&&W.warn("current_mode_update with invalid modeId for framework, not persisting",{framework:e.framework,agentId:e.agentId,modeId:w})}let u={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},x=e.activeTriggers.get(i);x&&(u.cozeTriggerMsgId=x);let p=e.activeGroupIds.get(i);p&&(u.cozeGroupId=p),this.upstream.send(Rr("session/update",{...r,sessionId:o,_meta:u})).catch(w=>W.warn("forward update failed",{agentId:e.agentId,err:String(w)}))}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}W.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:te.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 $0(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await V0(c,o);r.respondAgentRequest(i.id,l)}}catch(o){W.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Mi(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let w=u?e.activeGroupIds.get(u):void 0;w&&(p.cozeGroupId=w);let _=u?this.reverseSessionId(e,u):void 0,I=_?e.sessions.get(_):void 0;I&&(I.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let y={...c,..._?{sessionId:_}:{},_meta:p};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:_}),W.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:_,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(S=>({optionId:S.optionId,kind:S.kind,name:S.name}))}),this.upstream.send(Li(o,"session/request_permission",y)).catch(S=>{this.pendingUpstream.delete(o),W.error("forward permission request failed",{agentId:e.agentId,err:String(S)}),r.respondAgentRequestError(i.id,{code:te.INTERNAL_ERROR,message:`upstream send failed: ${String(S)}`})})}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;this.clearPendingPermissionFor(o),e.error?(W.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"&&j1(e.result,o),W.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 uo(e.error)):i.value.resolve(e.result);return}W.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 W.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=F1){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(Li(o,e,r)).catch(x=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),l(x)})})}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),o.permissionMode&&Kt(e)&&(c.permissionMode=o.permissionMode),o.cozeGroupId&&(c.cozeGroupId=o.cozeGroupId),r.set(i,c)}await ni(e.agentId,r,this.paths)}catch(r){W.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(vn(e,{code:r,message:i,data:{bridgeVersion:Cr}}))}};function H1(){return B1(16).toString("hex")}function j1(t,e){if(!t||typeof t!="object"){W.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){W.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"){W.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")&&W.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var W1=["Model metadata for `","Falling back from WebSockets to HTTPS transport.","Heads up: Long threads and multiple compactions can cause the model to be less accurate."];function K1(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;if(i.type!=="text"||typeof i.text!="string")return!1;let{text:o}=i;return W1.some(c=>o.startsWith(c))}on();re();Le();import{randomBytes as $1}from"node:crypto";import{createServer as V1}from"node:http";var J1=1e6,ex=q("ipc"),So=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??ee()}async start(){this.token=$1(32).toString("hex");let e=V1((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(),ex.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 sn(this.paths.portFile,String(this.port)),await sn(this.paths.tokenFile,this.token,{mode:384})}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Hi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Hi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await Z1(e)}catch(u){Hi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Hi(r,200,u??{ok:!0})}catch(u){ex.error("IPC handler failed",{key:o,err:String(u)}),Hi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Hi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function Z1(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>J1)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}import"node:module";var mb=Ft(Zx(),1),wb=Ft(Oo(),1),_b=Ft(Br(),1),yb=Ft(md(),1),Eb=Ft(yd(),1),bb=Ft(Ad(),1),sh=Ft(Bo(),1),vb=Ft(ih(),1);var oh=sh.default;Ke();re();var{FWS:zb}=mh(),Pe=q("upstream.frontier"),_h="application/json",yh="none",Ub=15e3;function qb(t){class e extends oh{constructor(i){super(i,kf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Pe.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(hl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Pe.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Pe.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Xi=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){Pe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Df,...Ar(this.opts.ppeOverride)},r=qb(e),i=Of(this.opts.urlOverride),o={url:i,ws:r,fpID:Rf,aID:ao,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:_h,force:!0},payloadEncoding:{encoding:yh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new zb(o),l=!1,u=null,x,p,w=new Promise((y,S)=>{x=y,p=S}),_=y=>{l||(l=!0,u&&(clearTimeout(u),u=null),y?p(y):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Pe.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&_();for(let S of this.connectHandlers)Promise.resolve(S({initial:y})).catch(A=>Pe.warn("onConnect handler threw (ignored)",{err:String(A)}))},c.onclose=y=>{this.opened=!1,Pe.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Pe.warn("frontier error",{code:y.code,msg:y.message}),_(new C("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let I=this.opts.openTimeoutMs??Ub;u=setTimeout(()=>{_(new C("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${I}ms (handshake or upgrade slow)`))},I),await c.connect();try{await w}catch(y){try{c.close(1e3,"open failed")}catch(S){Pe.warn("fws close during start failure threw (ignored)",{err:String(S)})}throw this.fws=null,this.opened=!1,y}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Pe.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Pe.warn("frontier send refused: upstream not started",{method:i}),new C("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Pe.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 C("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;Eh(c)||Pe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:_h,payloadEncoding:yh})}catch(u){throw Pe.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new C("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){Pe.debug("drop non-adapter frontier frame",{service:r});return}let i=jb(e);if(!i){Pe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Pe.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Pe.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Eh(c)||Pe.info("frontier frame in",{logid:Hb(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:Gb(i)}),Promise.resolve(this.handler(o)).catch(l=>Pe.warn("frontier frame handler threw",{err:String(l)}))}};function Eh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var bh=2e3;function Gb(t){return t.length<=bh?t:`${t.slice(0,bh)}...<truncated, total ${t.length} chars>`}function Hb(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function jb(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}re();var kd=q("upstream.switchable"),Ko=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;kd.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 kd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>kd.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()}};re();var Dd=q("upstream"),Hr=class{handler=null;async start(){Dd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Dd.info("NoopUpstream stopped",{reason:e})}async send(e){Dd.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)}};Ke();re();on();re();Le();import{promises as Wb}from"node:fs";var vh=q("pat-token-store");async function $o(t=ee()){try{let r=(await Wb.readFile(t.patTokenFile,"utf8")).trim();return r.length===0?(vh.warn("pat-token exists but empty (treating as missing; likely interrupted write)",{path:t.patTokenFile}),null):r}catch(e){let r=e?.code;return r!=="ENOENT"&&vh.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Qi(t,e=ee()){if(!t)throw new Error("writePatToken: empty patToken");await sn(e.patTokenFile,t,{mode:384})}Le();Le();import{promises as Vo}from"node:fs";import{join as Kb}from"node:path";function $b(t,e){return`#!/bin/sh
103
103
  exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
104
- `}function Rv(t,e){return`@echo off\r
104
+ `}function Vb(t,e){return`@echo off\r
105
105
  "${e}" "${t}" %*\r
106
- `}async function wh(t,e=Y()){let r=e.binDir;await $o.mkdir(r,{recursive:!0});let i=Dv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?Rv(t,o):Cv(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}te();Oe();import{execSync as _h}from"node:child_process";import{readFileSync as yh,unlinkSync as kv}from"node:fs";import{mkdir as Pv,open as Ov,readFile as bh,unlink as Cd,writeFile as Lv}from"node:fs/promises";import{dirname as Nv}from"node:path";var Mv=q("single-instance"),Bv=t=>new Promise(e=>setTimeout(e,t)),Vo=class{pidFile;selfPid;probe;claimLockMaxAttempts;claimLockIntervalMs;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Y().pidFile,this.selfPid=e.selfPid??process.pid,this.claimLockMaxAttempts=e.claimLockMaxAttempts??50,this.claimLockIntervalMs=e.claimLockIntervalMs??20,this.probe=e.probe??{isAlive:r=>zi(r),isDaemon:r=>this.matchesDaemonTitle(r)},e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();if(e!==null&&e!==this.selfPid&&this.isLiveDaemon(e))return{kind:"already-running",pid:e};let r=await this.withClaimLock(async()=>{let i=await this.readExistingPid();return i!==null&&i!==this.selfPid&&this.isLiveDaemon(i)?{kind:"already-running",pid:i}:(i!==null&&i!==this.selfPid&&Mv.warn("removing stale pid file",{stalePid:i}),await Lv(this.pidFile,String(this.selfPid),"utf8"),{kind:"acquired"})});return r.kind==="acquired"&&(this.acquired=!0,this.installCleanupHooks()),r}async release(){if(this.acquired){try{(await bh(this.pidFile,"utf8")).trim()===String(this.selfPid)&&await Cd(this.pidFile)}catch{}this.acquired=!1}}isLiveDaemon(e){return this.probe.isAlive(e)&&this.probe.isDaemon(e)}async readExistingPid(){return this.readPidFrom(this.pidFile)}async readPidFrom(e){try{let r=await bh(e,"utf8"),i=Number.parseInt(r.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(r){if(r.code==="ENOENT")return null;throw r}}async withClaimLock(e){let r=`${this.pidFile}.lock`;await Pv(Nv(r),{recursive:!0});for(let i=0;i<this.claimLockMaxAttempts;i++){let o;try{o=await Ov(r,"wx")}catch(c){if(c.code!=="EEXIST")throw c;let l=await this.readPidFrom(r);if(l!==null&&l!==this.selfPid&&this.probe.isAlive(l)){await Bv(this.claimLockIntervalMs);continue}await Cd(r).catch(()=>{});continue}try{return await o.writeFile(String(this.selfPid)),await e()}finally{await o.close().catch(()=>{}),await Cd(r).catch(()=>{})}}throw new Error(`failed to acquire claim lock: ${r} (after ${this.claimLockMaxAttempts} attempts)`)}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=yh(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes(Lr)||r.includes("lib/index.js"))}catch{}try{let r=_h(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes(Lr)||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=_h(`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{yh(this.pidFile,"utf8").trim()===String(this.selfPid)&&kv(this.pidFile)}catch{}})}};Jo();te();var Qn=q("daemon.upstream-watchdog"),Wv=12e4,Kv=9e5,$v=3e4;function kd(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Zo=class{constructor(e){this.opts=e;this.softMs=e.softMs??kd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",Wv),this.hardMs=e.hardMs??kd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",Kv),this.intervalMs=e.intervalMs??kd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",$v),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),Qn.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&Qn.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&Qn.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,Qn.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){Qn.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,Qn.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>Qn.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var W=q("daemon");async function Sh(){let t=Y();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&dl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:L=>Qe(L,t).logs,listAgentIds:()=>ls(t)});let e=new Vo({processTitle:Lr}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await bo(),o=i??{};cs({pid:process.pid}),W.info(i?"loaded bridge config":"initialized bridge config");let c=new Wo(new Wr),l=null,u=new Eo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(L,j,K,ie)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(L,j,K,ie)}}),x=new wo({paths:t,config:o,registry:u});l=x;let g,w,E=null,S={},y,v=null,A=null,T=null,D=new In;function P(L,j){return D.enqueue(()=>k(L,j))}function b(){A||(A=new Zo({isConnected:()=>c.isConnected(),forceReconnect:()=>T?P(T,{force:!0}):void 0,onFatal:L=>{if(process.env[ts]==="1"){W.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:L});return}W.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:L}),process.exit(1)}})),A.start()}async function k(L,j){let K=L,ie=K?.privatecode;if(!ie)throw new C("IPC_BAD_REQUEST","/connect requires privatecode");let Xe=Pi(K.env),ue=K.handshake_url,fe=K.frontier_url,St=vh(K.env,ue,fe);if(T=K,!j?.force&&g===ie&&w===St){let me=await Vv(t);return u.agents.size===0&&me?(W.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Yo(t,x).catch(Ae=>W.warn("connect-noop auto-revive error (ignored)",{err:String(Ae)}))):W.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let xt=!!g&&g!==ie,tn=w!==void 0&&w!==St,Ut=xt||tn,nn=await Bc({privatecode:ie,...ue?{endpoint:ue}:{},ppeOverride:Xe});if(Ut){W.warn("connect config switched, resetting agents",{pcChanged:xt,envChanged:tn,previousPc:g?Xo(g):"",nextPc:Xo(ie)});for(let me of[...u.agents.values()])await me.dispose("connect config switch").catch(()=>{}),u.agents.delete(me.agentId);u.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Wr,"connect switch").catch(()=>{})}E=nn.deviceId,cs({deviceId:E,pid:process.pid}),nd({patToken:ie,env:K.env}).catch(me=>W.warn("coze-cli setup error (ignored)",{err:String(me)}));let Zr=new Qi({handshake:nn,privatecode:ie,...fe?{urlOverride:fe}:{},ppeOverride:Xe,getPatTokenForAgent:me=>u.agents.get(me)?.patToken});return await c.swap(Zr,"connect"),g=ie,w=St,S=Xe,y=ue,K.mock_scenario!==void 0&&(u.setMockScenario(K.mock_scenario),W.info("mock scenario set",{scenario:K.mock_scenario})),v||(v=new Li({core:u,getDeviceId:()=>E??"",onTickEnd:()=>B.retryPending().catch(me=>W.warn("detailSync.retryPending failed (ignored)",{err:String(me)})),onAuthFailures:J})),v.start(),b(),Ut&&Yo(t,x).catch(me=>W.warn("post-connect-switch auto-revive error (ignored)",{err:String(me)})),es(ie,t).catch(me=>W.warn("writePatToken after /connect failed (ignored)",{err:String(me)})),W.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async L=>x.createAgent(L.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let O={},U=new co({agents:u.agents,disposeAndMarkDisconnected:async(L,j)=>{let K=u.agents.get(L);if(K){await x.cleanupOpenclawSessionProviders(K).catch(Xe=>W.warn("cleanup openclaw providers failed (ignored)",{agentId:L,err:String(Xe)}));let ie=!0;try{await K.dispose(`disconnect: ${j}`)}catch(Xe){ie=!1,W.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:L,err:String(Xe)}),K.status="error"}ie&&(K.status="disconnected",u.unregister(L),u.disconnectedAgents.add(L))}else u.disconnectedAgents.add(L)},detailSyncer:async L=>{if(!O.ref)throw new Error("agent-detail-sync not initialized yet");await O.ref.syncOne(L)},cleanupOpenclawProviders:async L=>{await x.cleanupOpenclawSessionProviders(L)},openclawRepair:async(L,j)=>{await x.openclawRepair(L,j)},isRuntimePendingPermission:L=>u.hasPendingPermissionFor(L)});u.registerExtension("_agent/listSkills",L=>U.listSkills(L.params)),u.registerExtension("_agent/addSkills",L=>U.addSkills(L.params)),u.registerExtension("_agent/removeSkills",L=>U.removeSkills(L.params)),u.registerExtension("_agent/getFileTree",L=>U.getFileTree(L.params)),u.registerExtension("_agent/getFileContent",L=>U.getFileContent(L.params)),u.registerExtension("_agent/update",L=>U.updateAgent(L.params)),u.registerExtension("_agent/disconnect",L=>U.disconnectAgent(L.params)),u.registerExtension("_agent/switchModel",L=>U.switchModel(L.params)),u.registerExtension("_agent/reset",L=>U.resetAgent(L.params)),u.registerExtension("_agent/repair",L=>U.repairAgent(L.params));let B=new hs({paths:t,handlers:U,agentManager:x,sendDetail:L=>u.sendRequest("_agent/detail",L)});O.ref=B;let J=async L=>{await Promise.allSettled(L.map(async j=>{try{await U.disconnectAgent({agentId:j.agentId,reason:`auth_failure: code=${j.code} ${j.message}`}),W.info("agent disconnected due to auth failure from heartbeat response",{agentId:j.agentId,code:j.code,message:j.message})}catch(K){W.warn("disconnect during authFailure handling failed (ignored)",{agentId:j.agentId,err:String(K)})}}))};c.onConnect(({initial:L})=>{W.info("frontier upstream connected, triggering detail sync",{initial:L}),B.syncAll(L?"initial-connect":"reconnect").catch(j=>W.warn("detail sync top-level error (ignored)",{err:String(j)}))});let $=new vo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let L=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[ts]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{},...L?{mockScenario:L}:{}}}},{method:"POST",path:"/pair",handler:async L=>{let j=L,K=j?.privatecode,ie=j?.pairing_code;if(!K||!ie)throw new C("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Xe=Pi(j.env),ue=j.handshake_url,fe=j.frontier_url,St=vh(j.env,ue,fe),xt=!!g&&g!==K,tn=w!==void 0&&w!==St,Ut=xt||tn,nn=await Bc({privatecode:K,...ue?{endpoint:ue}:{},ppeOverride:Xe});if(Ut){W.warn("pair config switched, resetting agents",{pcChanged:xt,envChanged:tn,previousPc:g?Xo(g):"",nextPc:Xo(K),previousEnvKey:w??"",nextEnvKey:St});for(let Ae of[...u.agents.values()])await Ae.dispose("pair config switch").catch(()=>{}),u.agents.delete(Ae.agentId);u.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Wr,"pair switch").catch(()=>{})}E=nn.deviceId,cs({deviceId:E,pid:process.pid}),nd({patToken:K,env:j.env}).catch(Ae=>W.warn("coze-cli setup error (ignored)",{err:String(Ae)}));let Zr=new Qi({handshake:nn,privatecode:K,...fe?{urlOverride:fe}:{},ppeOverride:Xe,getPatTokenForAgent:Ae=>u.agents.get(Ae)?.patToken});await c.swap(Zr,"pair");try{let Ae=new $n;o.frameworksCache=await Ae.detectAll(),await qi(o),W.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ae){W.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ae)})}let me=Object.keys(o.frameworksCache??{});try{let Ae=await u.sendRequest("_agent/pair",{pairCode:ie,patToken:K,frameworks:me,_meta:{cozeDeviceId:E}});W.info("_agent/pair ok",{pairResult:Ae}),g=K,w=St,S=Xe,y=ue,j.mock_scenario!==void 0&&(u.setMockScenario(j.mock_scenario),W.info("mock scenario set",{scenario:j.mock_scenario})),es(K,t).catch(Pe=>W.warn("writePatToken after /pair failed (ignored)",{err:String(Pe)})),v||(v=new Li({core:u,getDeviceId:()=>E??"",onTickEnd:()=>B.retryPending().catch(Pe=>W.warn("detailSync.retryPending failed (ignored)",{err:String(Pe)})),onAuthFailures:J})),v.start(),b(),Ut&&Yo(t,x).catch(Pe=>W.warn("post-pair-switch auto-revive error (ignored)",{err:String(Pe)}));let er;return j.agent_id&&(er=await Zv(j.agent_id,t,x,Pe=>u.sendRequest("_agent/detail",Pe),K).catch(Pe=>(W.error("--agent-id ensureAgent failed",{agentId:j.agent_id,err:String(Pe)}),{ok:!1,agentId:j.agent_id??"",note:String(Pe)}))),{ok:!0,note:"paired with cloud",...er?{agent:er}:{}}}catch(Ae){return W.error("_agent/pair failed",{err:String(Ae)}),{ok:!1,note:`pair failed: ${String(Ae)}`}}}},{method:"POST",path:"/connect",handler:L=>P(L)},{method:"POST",path:"/_agent/create",handler:async L=>{let j=L;return{ok:!0,result:await x.createAgent(j)}}},{method:"POST",path:"/agent/send",handler:async L=>{let j=L;if(!j?.agentId||!j?.sessionId||!j?.kind||!j?.path)throw new C("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!g)throw new C("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let K=j;return await(K.groupFile?kf:Rf)(K,{core:u,patToken:g,handshakeBase:y,ppeOverride:S})}catch(K){if(K instanceof C)return{ok:!1,code:K.code,message:K.message};throw K}}},{method:"POST",path:"/reload",handler:async L=>{let j=L?.agent_id,K=await u.reloadAgents(j);return W.info("IPC /reload: recycled agent subprocesses",{agentId:j??"(all)",recycled:K}),{ok:!0,recycled:K}}},{method:"POST",path:"/shutdown",handler:async()=>(W.info("IPC /shutdown received"),setImmediate(()=>{pe.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:re,token:X}=await $.start();try{await wh(t.libEntry,t)}catch(L){W.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(L)})}await u.start(),Xv({paths:t,core:u,agentManager:x,detectAll:async()=>(o.frameworksCache=await new $n().detectAll(),await qi(o),o.frameworksCache)}).catch(L=>W.warn("startup warmup error (ignored)",{err:String(L)})),_l().then(async()=>{let{probeAcpVersion:L}=await Promise.resolve().then(()=>(on(),ml));for(let j of["claude-code","codex"]){let K=await L(j);K&&W.info("acp wrapper version",{framework:j,version:K})}}).catch(L=>W.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(L)}));let Se=null,pe={port:re,token:X,core:u,ipc:$,shutdown(L){return Se||(W.info("daemon shutdown",{reason:L}),Se=(async()=>{v?.stop(),A?.stop(),await u.stop(L),await $.stop(),await e.release()})(),Se)}};for(let L of["SIGTERM","SIGINT"])process.on(L,()=>{pe.shutdown(L).then(()=>process.exit(0))});return process.on("exit",()=>rf()),process.on("unhandledRejection",L=>{W.error("unhandledRejection",{reason:L instanceof Error?L.message:String(L),stack:L instanceof Error?L.stack:void 0})}),process.on("uncaughtException",L=>{W.error("uncaughtException (will exit, supervisor will restart)",{message:L.message,stack:L.stack,name:L.name});try{process.stderr.write(`FATAL uncaughtException: ${L.stack??L.message}
107
- `)}catch{}process.exit(1)}),W.info("daemon ready",{port:re,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),Yv({cliSpawned:process.env[ts]==="1",readPatToken:()=>Ko(t),connect:P}).catch(L=>W.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(L)})),pe}async function Vv(t){return ls(t).length>0}function Xo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function vh(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function Jv(t,e){let r=ls(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(dn(),xs));for(let c of r){await o(c,t).catch(l=>W.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(l)}));try{let l=await i(c,t);l?.disconnectedAt&&(e.disconnectedAgents.add(c),W.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){W.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(l)})}}}async function Zv(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(dn(),xs)),l=await c(t,e);if(l){W.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let w=Ah(l),E={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{},...w?{_meta:w}:{}};return await r.createAgent(E),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}W.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await i({_meta:{cozeAgentId:t}});if(!u.framework)throw new C("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let x={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(x);let g=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:g?"cloud agent acknowledged":"created from cloud detail"}}async function Xv(t){let e=t.logger??W;try{let r=await t.detectAll();e.info("refreshed frameworks_cache",{detected:Object.keys(r??{})})}catch(r){e.warn("framework detection failed (using cached)",{err:String(r)})}await Jv(t.paths,t.core).catch(r=>e.warn("scanAgentsOnStartup failed (ignored)",{err:String(r)})),await Yo(t.paths,t.agentManager).catch(r=>e.warn("auto-revive top-level error (ignored)",{err:String(r)}))}async function Yo(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(()=>(dn(),xs));W.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let u of i){let x;try{x=await o(u,t)}catch(g){W.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(g)}),l+=1;continue}if(!x){l+=1;continue}if(x.disconnectedAt){W.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),l+=1;continue}try{W.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let g=Ah(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...g?{_meta:g}:{}},{revive:!0}),c+=1}catch(g){W.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:x.framework,err:String(g)}),l+=1}}return W.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}async function Yv(t){let e=t.logger??W;if(t.cliSpawned)return"skipped-cli";let r=await t.readPatToken();return r?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:r}).catch(i=>e.warn("startup auto-connect failed (staying idle)",{err:String(i)})),"connecting"):(e.info("no stored PAT, skip startup auto-connect"),"skipped-no-pat")}function Ah(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Jo();Oe();import{readFile as Ih}from"node:fs/promises";var en=class{paths;constructor(e){this.paths=e??Y()}async probe(e=1e3){let r=await Qo(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:e1(i)}}}async request(e){let r=await Qo(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}),x=await u.text();return{status:u.status,body:Qv(x)}}finally{clearTimeout(l)}}};async function Qo(t){try{let[e,r]=await Promise.all([Ih(t.portFile,"utf8"),Ih(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 Qv(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function e1(t){return t instanceof Error?t.message:String(t)}An();te();ir();import{spawn as t1}from"node:child_process";import{userInfo as Dh}from"node:os";var Pd="__COZE_BRIDGE_ENV_SENTINEL_5f3c91__",n1=new Set(["bash","zsh","sh","dash","ksh"]),Th=Ke("COZE_BRIDGE_SHELLENV_TIMEOUT_MS",1e4),r1=2e3;function i1(t,e=Pd){let r=t.indexOf(e);if(r===-1)return null;let i=t.indexOf(e,r+e.length);if(i===-1)return null;let o=t.slice(r+e.length,i),c={};for(let l of o.split(`
108
- `)){let u=l.indexOf("=");u<=0||(c[l.slice(0,u)]=l.slice(u+1))}return c}function s1(){let t=(process.env.SHELL??"").trim()||(Dh().shell??"").trim();if(!t)return null;let e=t.slice(t.lastIndexOf("/")+1);return n1.has(e)?t:null}function o1(t){return new Promise(e=>{let r=`printf '%s' '${Pd}'; env; printf '%s' '${Pd}'`,i;try{i=t1(t,["-ilc",r],{detached:!0,stdio:["ignore","pipe","ignore"],env:{...process.env,HOME:process.env.HOME??Dh().homedir}})}catch{e(null);return}let o="",c=!1,l=w=>{try{i.pid&&process.kill(-i.pid,w)}catch{}},u=w=>{c||(c=!0,clearTimeout(x),clearTimeout(g),e(w))};i.stdout?.on("data",w=>{o+=w.toString("utf8")}),i.on("error",()=>u(null)),i.on("close",()=>u(o.length>0?o:null));let x=setTimeout(()=>l("SIGTERM"),Th),g=setTimeout(()=>{l("SIGKILL"),u(o.length>0?o:null)},Th+r1)})}async function Od(t={}){if((t.platform??process.platform)==="win32")return{kind:"skipped",reason:"windows"};let r=s1();if(!r)return{kind:"skipped",reason:"no-supported-login-shell"};let i=await(t.run??o1)(r);if(i==null)return{kind:"failed",reason:"shell-timeout-or-error"};let o=i1(i);return o==null?{kind:"failed",reason:"unparseable-output"}:{kind:"ok",env:o}}Oe();function Cn(t,...e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o],l=!1;for(let u of e){if(c===u){i=t[o+1],o+=1,l=!0;break}if(c.startsWith(`${u}=`)){i=c.slice(u.length+1),l=!0;break}}l||r.push(c)}return{value:i,rest:r}}on();import{chmod as a1,copyFile as Ch,mkdir as kh,readFile as ea,rename as Rh,rm as Ld,stat as Ph,writeFile as c1}from"node:fs/promises";import{homedir as VC}from"node:os";import{dirname as d1,join as Kr,resolve as Nd,sep as ns}from"node:path";import{fileURLToPath as l1}from"node:url";An();te();Oe();var Md=q("dist-install");function u1(t){let e=l1(t),r=d1(e),i=`${ns}src${ns}`;if(r.includes(i)||r.endsWith(`${ns}src${ns}cli`))return null;let o=Nd(r,"index.js"),c=Nd(r,"..","package.json");return{dist:o,pkgJson:c}}async function zd(t={}){let e=t.paths??Y(),r=u1(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,l;try{let S=JSON.parse(await ea(o,"utf8"));c=S.version??"unknown",l=S.dependencies??{}}catch(S){return Md.warn("cannot read source package.json,skip dist install",{err:String(S)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(S)}`}}let u=ti.map(S=>`${S}@${l[S]??"latest"}`),x=await bo(e.configFile)??{},g=x.libVersion,w=await ea(e.libEntry).then(()=>!0).catch(()=>!1),E=g===c;if(E&&w&&await Bd(e))return{kind:"already-current",libVersion:c};if(!E||!w){await kh(e.libDir,{recursive:!0}),await Ch(i,e.libEntry),await Ch(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let S=Nd(e.libDir,"package.json"),y=`${JSON.stringify({type:"module"},null,2)}
109
- `;await ea(S,"utf8").catch(()=>null)!==y&&await c1(S,y)}return(!E||!await Bd(e))&&await(t.installWrappers??f1)(e,u),x.libVersion=c,await qi(x,e.configFile),Md.info("dist installed",{libEntry:e.libEntry,fromVersion:g,toVersion:c}),E&&w?{kind:"already-current",libVersion:c}:g?{kind:"version-changed",fromVersion:g,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function Bd(t){for(let e of ti){let r=Kr(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await Ph(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function f1(t,e){await p1(t.installLock,async()=>{if(await Bd(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${ns}.staging-${process.pid}-${r}`,o=Kr(i,"node_modules"),c=Kr(t.libDir,"node_modules");try{await kh(i,{recursive:!0}),await x1(e,i),await h1(o);let l=`${c}.trash-${r}`;await Rh(c,l).catch(()=>{}),await Rh(o,c),await Ld(l,{recursive:!0,force:!0}).catch(()=>{}),Md.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Ld(i,{recursive:!0,force:!0}).catch(()=>{})}})}function x1(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=lt("npm",r,{stdio:["ignore","pipe","pipe"]}),l="";c.stderr?.on("data",x=>{l.length<8192&&(l+=x.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",x=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(x)}`))}),c.once("close",x=>{clearTimeout(u),x===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${x}: ${l.trim().slice(0,2e3)}`))})})}async function h1(t){for(let e of ti){let r=Kr(t,...e.split("/")),i=JSON.parse(await ea(Kr(r,"package.json"),"utf8"));if(!i.version)throw new Error(`${e}: package.json \u7F3A version`);let o=typeof i.bin=="string"?e.split("/").pop():Object.keys(i.bin??{})[0];if(!o)throw new Error(`${e}: package.json \u7F3A bin`);let c=Kr(t,".bin",o),l=await Ph(c);process.platform!=="win32"&&!(l.mode&73)&&await a1(c,l.mode|73).catch(()=>{})}}async function p1(t,e){let{open:r}=await import("node:fs/promises"),i=!1;for(let o=0;o<60&&!i;o++)try{await(await r(t,"wx")).close(),i=!0}catch{await new Promise(c=>setTimeout(c,500))}try{return await e()}finally{i&&await Ld(t,{force:!0}).catch(()=>{})}}Ea();te();Oe();import{closeSync as Lh,fstatSync as Nh,openSync as Mh,readFileSync as g1,readSync as m1,readdirSync as w1,statSync as _1}from"node:fs";import{join as ta}from"node:path";var y1=new Set(["debug","info","warn","error"]);function Bh(t){let e=t,r=Cn(e,"--agent-id");e=r.rest;let i=Cn(e,"--date");e=i.rest;let o=Cn(e,"-n","--lines");e=o.rest;let c=Cn(e,"--level");e=c.rest;let l=Cn(e,"--grep");e=l.rest;let u=o.value===void 0?200:Number(o.value),x=Number.isInteger(u)&&u>=0?u:200,g=c.value&&y1.has(c.value)?c.value:void 0,w={lines:x,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(w.agentId=r.value),i.value&&(w.date=i.value),g&&(w.level=g),l.value&&(w.grep=l.value),w}function b1(t,e){return t.agentId?ta(Qe(t.agentId,e).logs,sr("agent",t.date)):ta(e.bridgeLogsDir,sr("bridge",t.date))}function E1(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function v1(t,e){let r;try{r=w1(t)}catch{return[]}let i=[];for(let o of r){let c=ba(o,e);if(!c)continue;let l=0;try{l=_1(ta(t,o)).size}catch{}i.push({file:ta(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function zh(t,e){if(e.grep&&!t.includes(e.grep))return!1;if(e.level){let r;try{r=JSON.parse(t).level}catch{return!0}if(typeof r=="string"&&!fl(r,e.level))return!1}return!0}var Oh={debug:"90",info:"36",warn:"33",error:"31"},S1=new Set(["ts","level","module","msg"]);function A1(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function Fh(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=A1(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&Oh[o]&&(c=`\x1B[${Oh[o]}m${c}\x1B[0m`);let l=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",x=Object.entries(r).filter(([g])=>!S1.has(g)).map(([g,w])=>` ${g}=${typeof w=="string"?w:JSON.stringify(w)}`).join("");return`${i} ${c} ${l} ${u}${x}`}function I1(t,e,r){let c=g1(t,"utf8").split(`
110
- `).filter(l=>l.length>0).filter(l=>zh(l,{level:e.level,grep:e.grep}));for(let l of E1(c,e.lines))process.stdout.write(`${Fh(l,{raw:e.raw,color:r})}
111
- `)}async function Uh(t,e){let r=e.paths??Y(),i=process.stdout.isTTY===!0;if(t.list){let l=t.agentId?Qe(t.agentId,r).logs:r.bridgeLogsDir,u=t.agentId?"agent":"bridge",x=v1(l,u);if(x.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${l}
112
- `),1;for(let g of x)process.stdout.write(`${g.date} ${(g.size/1024).toFixed(1)}KB ${g.file}
113
- `);return 0}let o=t.date??Pn(new Date),c=b1({agentId:t.agentId,date:o},r);try{I1(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
106
+ `}async function Sh(t,e=ee()){let r=e.binDir;await Vo.mkdir(r,{recursive:!0});let i=Kb(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?Vb(t,o):$b(t,o);return await Vo.readFile(i,"utf8").catch(()=>null)===c||(await Vo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Vo.chmod(i,493)),r}re();Le();import{execSync as Ih}from"node:child_process";import{readFileSync as Ah,unlinkSync as Jb}from"node:fs";import{mkdir as Zb,open as Yb,readFile as Th,unlink as Pd,writeFile as Xb}from"node:fs/promises";import{dirname as Qb}from"node:path";var ev=q("single-instance"),tv=t=>new Promise(e=>setTimeout(e,t)),Jo=class{pidFile;selfPid;probe;claimLockMaxAttempts;claimLockIntervalMs;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??ee().pidFile,this.selfPid=e.selfPid??process.pid,this.claimLockMaxAttempts=e.claimLockMaxAttempts??50,this.claimLockIntervalMs=e.claimLockIntervalMs??20,this.probe=e.probe??{isAlive:r=>Bi(r),isDaemon:r=>this.matchesDaemonTitle(r)},e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();if(e!==null&&e!==this.selfPid&&this.isLiveDaemon(e))return{kind:"already-running",pid:e};let r=await this.withClaimLock(async()=>{let i=await this.readExistingPid();return i!==null&&i!==this.selfPid&&this.isLiveDaemon(i)?{kind:"already-running",pid:i}:(i!==null&&i!==this.selfPid&&ev.warn("removing stale pid file",{stalePid:i}),await Xb(this.pidFile,String(this.selfPid),"utf8"),{kind:"acquired"})});return r.kind==="acquired"&&(this.acquired=!0,this.installCleanupHooks()),r}async release(){if(this.acquired){try{(await Th(this.pidFile,"utf8")).trim()===String(this.selfPid)&&await Pd(this.pidFile)}catch{}this.acquired=!1}}isLiveDaemon(e){return this.probe.isAlive(e)&&this.probe.isDaemon(e)}async readExistingPid(){return this.readPidFrom(this.pidFile)}async readPidFrom(e){try{let r=await Th(e,"utf8"),i=Number.parseInt(r.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(r){if(r.code==="ENOENT")return null;throw r}}async withClaimLock(e){let r=`${this.pidFile}.lock`;await Zb(Qb(r),{recursive:!0});for(let i=0;i<this.claimLockMaxAttempts;i++){let o;try{o=await Yb(r,"wx")}catch(c){if(c.code!=="EEXIST")throw c;let l=await this.readPidFrom(r);if(l!==null&&l!==this.selfPid&&this.probe.isAlive(l)){await tv(this.claimLockIntervalMs);continue}await Pd(r).catch(()=>{});continue}try{return await o.writeFile(String(this.selfPid)),await e()}finally{await o.close().catch(()=>{}),await Pd(r).catch(()=>{})}}throw new Error(`failed to acquire claim lock: ${r} (after ${this.claimLockMaxAttempts} attempts)`)}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Ah(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes(Pr)||r.includes("lib/index.js"))}catch{}try{let r=Ih(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes(Pr)||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=Ih(`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{Ah(this.pidFile,"utf8").trim()===String(this.selfPid)&&Jb(this.pidFile)}catch{}})}};Zo();re();var Yn=q("daemon.upstream-watchdog"),dv=12e4,lv=9e5,uv=3e4;function Ld(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Yo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Ld("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",dv),this.hardMs=e.hardMs??Ld("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",lv),this.intervalMs=e.intervalMs??Ld("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",uv),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),Yn.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&Yn.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&Yn.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,Yn.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){Yn.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,Yn.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>Yn.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var j=q("daemon");async function kh(){let t=ee();if(process.env.COZE_BRIDGE_LOG_MODE!=="legacy"){fl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:L=>Xe(L,t).logs,listAgentIds:()=>us(t)});try{let{writeFileSync:L}=await import("node:fs");L(t.logFile,`\u8FD0\u884C\u65E5\u5FD7\u5DF2\u8FC1\u79FB\u5230 dated \u6587\u4EF6, \u6B64\u6587\u4EF6 (bridge.log) \u4E0D\u518D\u5199\u5165\u8FD0\u884C\u65E5\u5FD7\u3002
107
+ \u8BF7\u67E5\u770B: ${t.bridgeLogsDir}/bridge-<YYYY-MM-DD>.log
108
+ \u6216\u4F7F\u7528: coze-bridge log [-f] [--lines N]
109
+ `)}catch{}}let e=new Jo({processTitle:Pr}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await bo(),o=i??{};ds({pid:process.pid}),j.info(i?"loaded bridge config":"initialized bridge config");let c=new Ko(new Hr),l=null,u=new vo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(L,G,K,oe)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(L,G,K,oe)}}),x=new _o({paths:t,config:o,registry:u});l=x;let p,w,_=null,I={},y,S=null,A=null,T=null,R=new In;function P(L,G){return R.enqueue(()=>k(L,G))}function E(){A||(A=new Yo({isConnected:()=>c.isConnected(),forceReconnect:()=>T?P(T,{force:!0}):void 0,onFatal:L=>{if(process.env[es]==="1"){j.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:L});return}j.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:L}),process.exit(1)}})),A.start()}async function k(L,G){let K=L,oe=K?.privatecode;if(!oe)throw new C("IPC_BAD_REQUEST","/connect requires privatecode");let Ze=Di(K.env),he=K.handshake_url,pe=K.frontier_url,vt=Rh(K.env,he,pe);if(T=K,!G?.force&&p===oe&&w===vt){let _e=await fv(t);return u.agents.size===0&&_e?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Qo(t,x).catch(Ce=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Ce)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ft=!!p&&p!==oe,Xt=w!==void 0&&w!==vt,Bt=ft||Xt,Qt=await Fc({privatecode:oe,...he?{endpoint:he}:{},ppeOverride:Ze});if(Bt){j.warn("connect config switched, resetting agents",{pcChanged:ft,envChanged:Xt,previousPc:p?Xo(p):"",nextPc:Xo(oe)});for(let _e of[...u.agents.values()])await _e.dispose("connect config switch").catch(()=>{}),u.agents.delete(_e.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Hr,"connect switch").catch(()=>{})}_=Qt.deviceId,ds({deviceId:_,pid:process.pid}),sd({patToken:oe,env:K.env}).catch(_e=>j.warn("coze-cli setup error (ignored)",{err:String(_e)}));let Vr=new Xi({handshake:Qt,privatecode:oe,...pe?{urlOverride:pe}:{},ppeOverride:Ze,getPatTokenForAgent:_e=>u.agents.get(_e)?.patToken});return await c.swap(Vr,"connect"),p=oe,w=vt,I=Ze,y=he,K.mock_scenario!==void 0&&(u.setMockScenario(K.mock_scenario),j.info("mock scenario set",{scenario:K.mock_scenario})),S||(S=new Oi({core:u,getDeviceId:()=>_??"",onTickEnd:()=>B.retryPending().catch(_e=>j.warn("detailSync.retryPending failed (ignored)",{err:String(_e)})),onAuthFailures:V})),S.start(),E(),Bt&&Qo(t,x).catch(_e=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(_e)})),Qi(oe,t).catch(_e=>j.warn("writePatToken after /connect failed (ignored)",{err:String(_e)})),j.info("/connect: WS established",{deviceId:_}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async L=>x.createAgent(L.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let O={},F=new lo({agents:u.agents,disposeAndMarkDisconnected:async(L,G)=>{let K=u.agents.get(L);if(K){await x.cleanupOpenclawSessionProviders(K).catch(Ze=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:L,err:String(Ze)}));let oe=!0;try{await K.dispose(`disconnect: ${G}`)}catch(Ze){oe=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:L,err:String(Ze)}),K.status="error"}oe&&(K.status="disconnected",u.unregister(L),u.disconnectedAgents.add(L))}else u.disconnectedAgents.add(L)},detailSyncer:async L=>{if(!O.ref)throw new Error("agent-detail-sync not initialized yet");await O.ref.syncOne(L)},cleanupOpenclawProviders:async L=>{await x.cleanupOpenclawSessionProviders(L)},openclawRepair:async(L,G)=>{await x.openclawRepair(L,G)},isRuntimePendingPermission:L=>u.hasPendingPermissionFor(L)});u.registerExtension("_agent/listSkills",L=>F.listSkills(L.params)),u.registerExtension("_agent/addSkills",L=>F.addSkills(L.params)),u.registerExtension("_agent/removeSkills",L=>F.removeSkills(L.params)),u.registerExtension("_agent/getFileTree",L=>F.getFileTree(L.params)),u.registerExtension("_agent/getFileContent",L=>F.getFileContent(L.params)),u.registerExtension("_agent/update",L=>F.updateAgent(L.params)),u.registerExtension("_agent/disconnect",L=>F.disconnectAgent(L.params)),u.registerExtension("_agent/switchModel",L=>F.switchModel(L.params)),u.registerExtension("_agent/reset",L=>F.resetAgent(L.params)),u.registerExtension("_agent/repair",L=>F.repairAgent(L.params)),u.registerExtension("_agent/upgrade",L=>F.upgradeBridge(L.params));let B=new ps({paths:t,handlers:F,agentManager:x,sendDetail:L=>u.sendRequest("_agent/detail",L)});O.ref=B;let V=async L=>{await Promise.allSettled(L.map(async G=>{try{await F.disconnectAgent({agentId:G.agentId,reason:`auth_failure: code=${G.code} ${G.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:G.agentId,code:G.code,message:G.message})}catch(K){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:G.agentId,err:String(K)})}}))};c.onConnect(({initial:L})=>{j.info("frontier upstream connected, triggering detail sync",{initial:L}),B.syncAll(L?"initial-connect":"reconnect").catch(G=>j.warn("detail sync top-level error (ignored)",{err:String(G)}))});let $=new So({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let L=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[es]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:_??"",frameworksCache:o.frameworksCache??{},...L?{mockScenario:L}:{}}}},{method:"POST",path:"/pair",handler:async L=>{let G=L,K=G?.privatecode,oe=G?.pairing_code;if(!K||!oe)throw new C("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ze=Di(G.env),he=G.handshake_url,pe=G.frontier_url,vt=Rh(G.env,he,pe),ft=!!p&&p!==K,Xt=w!==void 0&&w!==vt,Bt=ft||Xt,Qt=await Fc({privatecode:K,...he?{endpoint:he}:{},ppeOverride:Ze});if(Bt){j.warn("pair config switched, resetting agents",{pcChanged:ft,envChanged:Xt,previousPc:p?Xo(p):"",nextPc:Xo(K),previousEnvKey:w??"",nextEnvKey:vt});for(let Ce of[...u.agents.values()])await Ce.dispose("pair config switch").catch(()=>{}),u.agents.delete(Ce.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Hr,"pair switch").catch(()=>{})}_=Qt.deviceId,ds({deviceId:_,pid:process.pid}),sd({patToken:K,env:G.env}).catch(Ce=>j.warn("coze-cli setup error (ignored)",{err:String(Ce)}));let Vr=new Xi({handshake:Qt,privatecode:K,...pe?{urlOverride:pe}:{},ppeOverride:Ze,getPatTokenForAgent:Ce=>u.agents.get(Ce)?.patToken});await c.swap(Vr,"pair");try{let Ce=new Wn;o.frameworksCache=await Ce.detectAll(),await qi(o),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ce){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ce)})}let _e=Object.keys(o.frameworksCache??{});try{let Ce=await u.sendRequest("_agent/pair",{pairCode:oe,patToken:K,frameworks:_e,_meta:{cozeDeviceId:_}});j.info("_agent/pair ok",{pairResult:Ce}),p=K,w=vt,I=Ze,y=he,G.mock_scenario!==void 0&&(u.setMockScenario(G.mock_scenario),j.info("mock scenario set",{scenario:G.mock_scenario})),Qi(K,t).catch(Oe=>j.warn("writePatToken after /pair failed (ignored)",{err:String(Oe)})),S||(S=new Oi({core:u,getDeviceId:()=>_??"",onTickEnd:()=>B.retryPending().catch(Oe=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Oe)})),onAuthFailures:V})),S.start(),E(),Bt&&Qo(t,x).catch(Oe=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(Oe)}));let Xn;return G.agent_id&&(Xn=await hv(G.agent_id,t,x,Oe=>u.sendRequest("_agent/detail",Oe),K).catch(Oe=>(j.error("--agent-id ensureAgent failed",{agentId:G.agent_id,err:String(Oe)}),{ok:!1,agentId:G.agent_id??"",note:String(Oe)}))),{ok:!0,note:"paired with cloud",...Xn?{agent:Xn}:{}}}catch(Ce){return j.error("_agent/pair failed",{err:String(Ce)}),{ok:!1,note:`pair failed: ${String(Ce)}`}}}},{method:"POST",path:"/connect",handler:L=>P(L)},{method:"POST",path:"/_agent/create",handler:async L=>{let G=L;return{ok:!0,result:await x.createAgent(G)}}},{method:"POST",path:"/agent/send",handler:async L=>{let G=L;if(!G?.agentId||!G?.sessionId||!G?.kind||!G?.path)throw new C("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new C("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let K=G;return await(K.groupFile?F0:B0)(K,{core:u,patToken:p,handshakeBase:y,ppeOverride:I})}catch(K){if(K instanceof C)return{ok:!1,code:K.code,message:K.message};throw K}}},{method:"POST",path:"/reload",handler:async L=>{let G=L?.agent_id,K=await u.reloadAgents(G);return j.info("IPC /reload: recycled agent subprocesses",{agentId:G??"(all)",recycled:K}),{ok:!0,recycled:K}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{ae.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ne,token:Z}=await $.start();try{await Sh(t.libEntry,t)}catch(L){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(L)})}await u.start(),pv({paths:t,core:u,agentManager:x,detectAll:async()=>(o.frameworksCache=await new Wn().detectAll(),await qi(o),o.frameworksCache)}).catch(L=>j.warn("startup warmup error (ignored)",{err:String(L)})),bl().then(async()=>{let{probeAcpVersion:L}=await Promise.resolve().then(()=>(rn(),yl));for(let G of["claude-code","codex"]){let K=await L(G);K&&j.info("acp wrapper version",{framework:G,version:K})}}).catch(L=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(L)}));let se=null,ae={port:ne,token:Z,core:u,ipc:$,shutdown(L){return se||(j.info("daemon shutdown",{reason:L}),se=(async()=>{S?.stop(),A?.stop(),await u.stop(L),await $.stop(),await e.release()})(),se)}};for(let L of["SIGTERM","SIGINT"])process.on(L,()=>{ae.shutdown(L).then(()=>process.exit(0))});return process.on("exit",()=>a0()),process.on("unhandledRejection",L=>{j.error("unhandledRejection",{reason:L instanceof Error?L.message:String(L),stack:L instanceof Error?L.stack:void 0})}),process.on("uncaughtException",L=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:L.message,stack:L.stack,name:L.name});try{process.stderr.write(`FATAL uncaughtException: ${L.stack??L.message}
110
+ `)}catch{}process.exit(1)}),j.info("daemon ready",{port:ne,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),gv({cliSpawned:process.env[es]==="1",readPatToken:()=>$o(t),connect:P}).catch(L=>j.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(L)})),ae}async function fv(t){return us(t).length>0}function Xo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Rh(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function xv(t,e){let r=us(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(an(),hs));for(let c of r){await o(c,t).catch(l=>j.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(l)}));try{let l=await i(c,t);l?.disconnectedAt&&(e.disconnectedAgents.add(c),j.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){j.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(l)})}}}async function hv(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(an(),hs)),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=Dh(l),_={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{},...w?{_meta:w}:{}};return await r.createAgent(_),{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 C("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let x={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(x);let p=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function pv(t){let e=t.logger??j;try{let r=await t.detectAll();e.info("refreshed frameworks_cache",{detected:Object.keys(r??{})})}catch(r){e.warn("framework detection failed (using cached)",{err:String(r)})}await xv(t.paths,t.core).catch(r=>e.warn("scanAgentsOnStartup failed (ignored)",{err:String(r)})),await Qo(t.paths,t.agentManager).catch(r=>e.warn("auto-revive top-level error (ignored)",{err:String(r)}))}async function Qo(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(()=>(an(),hs));j.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let u of i){let x;try{x=await o(u,t)}catch(p){j.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(p)}),l+=1;continue}if(!x){l+=1;continue}if(x.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),l+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let p=Dh(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...p?{_meta:p}:{}},{revive:!0}),c+=1}catch(p){j.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:x.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}}async function gv(t){let e=t.logger??j;if(t.cliSpawned)return"skipped-cli";let r=await t.readPatToken();return r?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:r}).catch(i=>e.warn("startup auto-connect failed (staying idle)",{err:String(i)})),"connecting"):(e.info("no stored PAT, skip startup auto-connect"),"skipped-no-pat")}function Dh(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Zo();Le();import{readFile as Ph}from"node:fs/promises";var Yt=class{paths;constructor(e){this.paths=e??ee()}async probe(e=1e3){let r=await ea(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:wv(i)}}}async request(e){let r=await ea(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}),x=await u.text();return{status:u.status,body:mv(x)}}finally{clearTimeout(l)}}};async function ea(t){try{let[e,r]=await Promise.all([Ph(t.portFile,"utf8"),Ph(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 mv(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function wv(t){return t instanceof Error?t.message:String(t)}Wt();re();nr();import{spawn as _v}from"node:child_process";import{userInfo as Lh}from"node:os";var Nd="__COZE_BRIDGE_ENV_SENTINEL_5f3c91__",yv=new Set(["bash","zsh","sh","dash","ksh"]),Oh=We("COZE_BRIDGE_SHELLENV_TIMEOUT_MS",1e4),Ev=2e3;function bv(t,e=Nd){let r=t.indexOf(e);if(r===-1)return null;let i=t.indexOf(e,r+e.length);if(i===-1)return null;let o=t.slice(r+e.length,i),c={};for(let l of o.split(`
111
+ `)){let u=l.indexOf("=");u<=0||(c[l.slice(0,u)]=l.slice(u+1))}return c}function vv(){let t=(process.env.SHELL??"").trim()||(Lh().shell??"").trim();if(!t)return null;let e=t.slice(t.lastIndexOf("/")+1);return yv.has(e)?t:null}function Sv(t){return new Promise(e=>{let r=`printf '%s' '${Nd}'; env; printf '%s' '${Nd}'`,i;try{i=_v(t,["-ilc",r],{detached:!0,stdio:["ignore","pipe","ignore"],env:{...process.env,HOME:process.env.HOME??Lh().homedir}})}catch{e(null);return}let o="",c=!1,l=w=>{try{i.pid&&process.kill(-i.pid,w)}catch{}},u=w=>{c||(c=!0,clearTimeout(x),clearTimeout(p),e(w))};i.stdout?.on("data",w=>{o+=w.toString("utf8")}),i.on("error",()=>u(null)),i.on("close",()=>u(o.length>0?o:null));let x=setTimeout(()=>l("SIGTERM"),Oh),p=setTimeout(()=>{l("SIGKILL"),u(o.length>0?o:null)},Oh+Ev)})}async function Md(t={}){if((t.platform??process.platform)==="win32")return{kind:"skipped",reason:"windows"};let r=vv();if(!r)return{kind:"skipped",reason:"no-supported-login-shell"};let i=await(t.run??Sv)(r);if(i==null)return{kind:"failed",reason:"shell-timeout-or-error"};let o=bv(i);return o==null?{kind:"failed",reason:"unparseable-output"}:{kind:"ok",env:o}}Le();function Cn(t,...e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o],l=!1;for(let u of e){if(c===u){i=t[o+1],o+=1,l=!0;break}if(c.startsWith(`${u}=`)){i=c.slice(u.length+1),l=!0;break}}l||r.push(c)}return{value:i,rest:r}}rn();import{chmod as Iv,copyFile as Nh,mkdir as Bh,readFile as ta,rename as Mh,rm as Bd,stat as Fh,writeFile as Av}from"node:fs/promises";import{homedir as y3}from"node:os";import{dirname as Tv,join as jr,resolve as Fd,sep as ts}from"node:path";import{fileURLToPath as Cv}from"node:url";Wt();re();Le();var zd=q("dist-install");function Rv(t){let e=Cv(t),r=Tv(e),i=`${ts}src${ts}`;if(r.includes(i)||r.endsWith(`${ts}src${ts}cli`))return null;let o=Fd(r,"index.js"),c=Fd(r,"..","package.json");return{dist:o,pkgJson:c}}async function qd(t={}){let e=t.paths??ee(),r=Rv(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,l;try{let I=JSON.parse(await ta(o,"utf8"));c=I.version??"unknown",l=I.dependencies??{}}catch(I){return zd.warn("cannot read source package.json,skip dist install",{err:String(I)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(I)}`}}let u=Qr.map(I=>`${I}@${l[I]??"latest"}`),x=await bo(e.configFile)??{},p=x.libVersion,w=await ta(e.libEntry).then(()=>!0).catch(()=>!1),_=p===c;if(_&&w&&await Ud(e))return{kind:"already-current",libVersion:c};if(!_||!w){await Bh(e.libDir,{recursive:!0}),await Nh(i,e.libEntry),await Nh(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let I=Fd(e.libDir,"package.json"),y=`${JSON.stringify({type:"module"},null,2)}
112
+ `;await ta(I,"utf8").catch(()=>null)!==y&&await Av(I,y)}return(!_||!await Ud(e))&&await(t.installWrappers??kv)(e,u),x.libVersion=c,await qi(x,e.configFile),zd.info("dist installed",{libEntry:e.libEntry,fromVersion:p,toVersion:c}),_&&w?{kind:"already-current",libVersion:c}:p?{kind:"version-changed",fromVersion:p,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function Ud(t){for(let e of Qr){let r=jr(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await Fh(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function kv(t,e){await Ov(t.installLock,async()=>{if(await Ud(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${ts}.staging-${process.pid}-${r}`,o=jr(i,"node_modules"),c=jr(t.libDir,"node_modules");try{await Bh(i,{recursive:!0}),await Dv(e,i),await Pv(o);let l=`${c}.trash-${r}`;await Mh(c,l).catch(()=>{}),await Mh(o,c),await Bd(l,{recursive:!0,force:!0}).catch(()=>{}),zd.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Bd(i,{recursive:!0,force:!0}).catch(()=>{})}})}function Dv(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=nt("npm",r,{stdio:["ignore","pipe","pipe"]}),l="";c.stderr?.on("data",x=>{l.length<8192&&(l+=x.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",x=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(x)}`))}),c.once("close",x=>{clearTimeout(u),x===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${x}: ${l.trim().slice(0,2e3)}`))})})}async function Pv(t){for(let e of Qr){let r=jr(t,...e.split("/")),i=JSON.parse(await ta(jr(r,"package.json"),"utf8"));if(!i.version)throw new Error(`${e}: package.json \u7F3A version`);let o=typeof i.bin=="string"?e.split("/").pop():Object.keys(i.bin??{})[0];if(!o)throw new Error(`${e}: package.json \u7F3A bin`);let c=jr(t,".bin",o),l=await Fh(c);process.platform!=="win32"&&!(l.mode&73)&&await Iv(c,l.mode|73).catch(()=>{})}}async function Ov(t,e){let{open:r}=await import("node:fs/promises"),i=!1;for(let o=0;o<60&&!i;o++)try{await(await r(t,"wx")).close(),i=!0}catch{await new Promise(c=>setTimeout(c,500))}try{return await e()}finally{i&&await Bd(t,{force:!0}).catch(()=>{})}}va();re();Le();import{closeSync as Uh,fstatSync as qh,openSync as Gh,readFileSync as Lv,readSync as Nv,readdirSync as Mv,statSync as Bv}from"node:fs";import{join as na}from"node:path";var Fv=new Set(["debug","info","warn","error"]);function Hh(t){let e=t,r=Cn(e,"--agent-id");e=r.rest;let i=Cn(e,"--date");e=i.rest;let o=Cn(e,"-n","--lines");e=o.rest;let c=Cn(e,"--level");e=c.rest;let l=Cn(e,"--grep");e=l.rest;let u=o.value===void 0?200:Number(o.value),x=Number.isInteger(u)&&u>=0?u:200,p=c.value&&Fv.has(c.value)?c.value:void 0,w={lines:x,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(w.agentId=r.value),i.value&&(w.date=i.value),p&&(w.level=p),l.value&&(w.grep=l.value),w}function zv(t,e){return t.agentId?na(Xe(t.agentId,e).logs,rr("agent",t.date)):na(e.bridgeLogsDir,rr("bridge",t.date))}function Uv(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function qv(t,e){let r;try{r=Mv(t)}catch{return[]}let i=[];for(let o of r){let c=ba(o,e);if(!c)continue;let l=0;try{l=Bv(na(t,o)).size}catch{}i.push({file:na(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function jh(t,e){if(e.grep&&!t.includes(e.grep))return!1;if(e.level){let r;try{r=JSON.parse(t).level}catch{return!0}if(typeof r=="string"&&!pl(r,e.level))return!1}return!0}var zh={debug:"90",info:"36",warn:"33",error:"31"},Gv=new Set(["ts","level","module","msg"]);function Hv(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function Wh(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=Hv(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&zh[o]&&(c=`\x1B[${zh[o]}m${c}\x1B[0m`);let l=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",x=Object.entries(r).filter(([p])=>!Gv.has(p)).map(([p,w])=>` ${p}=${typeof w=="string"?w:JSON.stringify(w)}`).join("");return`${i} ${c} ${l} ${u}${x}`}function jv(t,e,r){let c=Lv(t,"utf8").split(`
113
+ `).filter(l=>l.length>0).filter(l=>jh(l,{level:e.level,grep:e.grep}));for(let l of Uv(c,e.lines))process.stdout.write(`${Wh(l,{raw:e.raw,color:r})}
114
+ `)}async function Kh(t,e){let r=e.paths??ee(),i=process.stdout.isTTY===!0;if(t.list){let l=t.agentId?Xe(t.agentId,r).logs:r.bridgeLogsDir,u=t.agentId?"agent":"bridge",x=qv(l,u);if(x.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${l}
115
+ `),1;for(let p of x)process.stdout.write(`${p.date} ${(p.size/1024).toFixed(1)}KB ${p.file}
116
+ `);return 0}let o=t.date??kn(new Date),c=zv({agentId:t.agentId,date:o},r);try{jv(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
114
117
  \u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
115
118
  (legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
116
- `),1}return t.follow&&await C1(c,t,i),0}var T1=500;function D1(t){try{let e=Mh(t,"r");try{return Nh(e).size}finally{Lh(e)}}catch{return 0}}async function C1(t,e,r){let i=D1(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let u="";try{let x=Mh(t,"r");try{let g=Nh(x).size;if(g>i){let w=Buffer.allocUnsafe(g-i),E=m1(x,w,0,w.length,i);u=w.subarray(0,E).toString("utf8"),i+=E}}finally{Lh(x)}}catch{}if(u){let x=(o+u).split(`
117
- `);o=x.pop()??"";for(let g of x)g.length>0&&zh(g,{level:e.level,grep:e.grep})&&process.stdout.write(`${Fh(g,{raw:e.raw,color:r})}
118
- `)}await new Promise(x=>setTimeout(x,T1))}}finally{process.off("SIGINT",l)}}import{basename as R1,resolve as k1}from"node:path";Oe();var P1=9e4,O1={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,AGENT_TURN_ABORTED:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1,AGENT_ENV_NOT_READY:1};function L1(t){return O1[t]??1}async function Gh(t,e={}){let r=e.paths??Y();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>
119
+ `),1}return t.follow&&await $v(c,t,i),0}var Wv=500;function Kv(t){try{let e=Gh(t,"r");try{return qh(e).size}finally{Uh(e)}}catch{return 0}}async function $v(t,e,r){let i=Kv(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let u="";try{let x=Gh(t,"r");try{let p=qh(x).size;if(p>i){let w=Buffer.allocUnsafe(p-i),_=Nv(x,w,0,w.length,i);u=w.subarray(0,_).toString("utf8"),i+=_}}finally{Uh(x)}}catch{}if(u){let x=(o+u).split(`
120
+ `);o=x.pop()??"";for(let p of x)p.length>0&&jh(p,{level:e.level,grep:e.grep})&&process.stdout.write(`${Wh(p,{raw:e.raw,color:r})}
121
+ `)}await new Promise(x=>setTimeout(x,Wv))}}finally{process.off("SIGINT",l)}}import{basename as Vv,resolve as Jv}from"node:path";Le();var Zv=9e4,Yv={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,AGENT_TURN_ABORTED:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,OPERATION_NOT_ALLOWED_FOR_CLOUD:1,METHOD_NOT_FOUND:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1,AGENT_ENV_NOT_READY:1};function Xv(t){return Yv[t]??1}async function $h(t,e={}){let r=e.paths??ee();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
119
122
  `),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.
120
- `),3;let i=await Qo(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.
121
- `),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:k1(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 N1(i,"/agent/send",o,P1)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
123
+ `),3;let i=await ea(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.
124
+ `),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:Jv(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 Qv(i,"/agent/send",o,Zv)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
122
125
  `),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
123
- `),L1(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
124
- `);else{let l=t.name??R1(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})
125
- `)}else process.stdout.write(`Sent ${t.kind} ${l} (${M1(c.bytes)})
126
- `)}return 0}async function N1(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(),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=${l.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function M1(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Zh=q("cli");function je(t,e){let{value:r,rest:i}=Cn(t,e);return{value:r,rest:i}}function aa(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
127
- `)}function oS(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]==="reload"){let{value:P}=je(e.slice(1),"--agent-id");return P?{mode:"reload",agentId:P}:{mode:"reload"}}if(e[0]==="update")return{mode:"update"};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 aS(e.slice(1));if(e[0]==="log")return{mode:"log",...Bh(e.slice(1))};if(e[0]==="connect")return cS(e.slice(1));if(e.includes("--status"))return aa("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return aa("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return aa("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return aa("--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}=je(r,"--pat-token");r=o;let{value:c,rest:l}=je(r,"--pair-code");r=l;let{value:u,rest:x}=je(r,"--env");r=x;let{value:g,rest:w}=je(r,"--handshake-url");r=w;let{value:E,rest:S}=je(r,"--frontier-url");r=S;let{value:y,rest:v}=je(r,"--mock-scenario");r=v;let{value:A}=je(r,"--agent-id"),T=r.includes("--skip-rebuild-env");if(!i||!c)return{mode:"help"};let D={mode:"pair",privatecode:i,pairingCode:c};return u&&(D.env=u),g&&(D.handshakeUrl=g),E&&(D.frontierUrl=E),y&&(D.mockScenario=y),A&&(D.agentId=A),T&&(D.skipRebuildEnv=!0),D}function aS(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}=je(i,"--caption");i=c;let{value:l,rest:u}=je(i,"--name");i=u;let{value:x,rest:g}=je(i,"--agent-id");i=g;let{value:w,rest:E}=je(i,"--session-id");i=E;let{value:S,rest:y}=je(i,"--mime");i=y;let v=i.includes("--group-file");i=i.filter(D=>D!=="--group-file");let A=i.includes("--json"),T={mode:"send",kind:e,path:r,json:A};return o&&(T.caption=o),l&&(T.name=l),x&&(T.agentId=x),w&&(T.sessionId=w),v&&(T.groupFile=!0),S&&(T.mimeType=S),T}function cS(t){let e=t,{value:r,rest:i}=je(e,"--pat-token");e=i;let{value:o,rest:c}=je(e,"--env");e=c;let{value:l,rest:u}=je(e,"--handshake-url");e=u;let{value:x,rest:g}=je(e,"--frontier-url");e=g;let{value:w,rest:E}=je(e,"--mock-scenario");e=E;let S=e.includes("--skip-rebuild-env"),y={mode:"connect"};return r&&(y.privatecode=r),o&&(y.env=o),l&&(y.handshakeUrl=l),x&&(y.frontierUrl=x),w&&(y.mockScenario=w),S&&(y.skipRebuildEnv=!0),y}var dS=`
126
+ `),Xv(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
127
+ `);else{let l=t.name??Vv(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})
128
+ `)}else process.stdout.write(`Sent ${t.kind} ${l} (${eS(c.bytes)})
129
+ `)}return 0}async function Qv(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(),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=${l.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function eS(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var np=q("cli");function He(t,e){let{value:r,rest:i}=Cn(t,e);return{value:r,rest:i}}function ca(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
130
+ `)}function SS(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]==="reload"){let{value:P}=He(e.slice(1),"--agent-id");return P?{mode:"reload",agentId:P}:{mode:"reload"}}if(e[0]==="update")return{mode:"update"};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 IS(e.slice(1));if(e[0]==="log")return{mode:"log",...Hh(e.slice(1))};if(e[0]==="connect")return AS(e.slice(1));if(e.includes("--status"))return ca("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return ca("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return ca("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return ca("--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:x}=He(r,"--env");r=x;let{value:p,rest:w}=He(r,"--handshake-url");r=w;let{value:_,rest:I}=He(r,"--frontier-url");r=I;let{value:y,rest:S}=He(r,"--mock-scenario");r=S;let{value:A}=He(r,"--agent-id"),T=r.includes("--skip-rebuild-env");if(!i||!c)return{mode:"help"};let R={mode:"pair",privatecode:i,pairingCode:c};return u&&(R.env=u),p&&(R.handshakeUrl=p),_&&(R.frontierUrl=_),y&&(R.mockScenario=y),A&&(R.agentId=A),T&&(R.skipRebuildEnv=!0),R}function IS(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:x,rest:p}=He(i,"--agent-id");i=p;let{value:w,rest:_}=He(i,"--session-id");i=_;let{value:I,rest:y}=He(i,"--mime");i=y;let S=i.includes("--group-file");i=i.filter(R=>R!=="--group-file");let A=i.includes("--json"),T={mode:"send",kind:e,path:r,json:A};return o&&(T.caption=o),l&&(T.name=l),x&&(T.agentId=x),w&&(T.sessionId=w),S&&(T.groupFile=!0),I&&(T.mimeType=I),T}function AS(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:x,rest:p}=He(e,"--frontier-url");e=p;let{value:w,rest:_}=He(e,"--mock-scenario");e=_;let I=e.includes("--skip-rebuild-env"),y={mode:"connect"};return r&&(y.privatecode=r),o&&(y.env=o),l&&(y.handshakeUrl=l),x&&(y.frontierUrl=x),w&&(y.mockScenario=w),I&&(y.skipRebuildEnv=!0),y}var TS=`
128
131
  coze-bridge - local bridge daemon for cloud Agent Service
129
132
 
130
133
  Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
@@ -205,57 +208,57 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
205
208
 
206
209
  Internal:
207
210
  <node> <entry> --daemon daemon mode (OS supervisor only)
208
- `.trimStart();async function Xh(t=process.argv,e={}){let r=oS(t);switch(r.mode){case"help":return process.stdout.write(dS),0;case"version":return process.stdout.write(`${Rr}
209
- `),0;case"daemon":{try{await Sh()}catch(i){return Zh.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return lS(e);case"stop":return Qh(e);case"reload":return xS(r.agentId,e);case"log":return Uh(r,e);case"update":return uS(e);case"purge":return hS(e);case"service-install":return pS(e);case"service-uninstall":return gS(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),mS(r.privatecode,r.pairingCode,e,i,r.agentId,r.skipRebuildEnv)}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),wS(r.privatecode,e,i,r.skipRebuildEnv)}case"send":return Gh({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 Yh(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 lS(t){let e=t.paths??Y(),r=new en(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
210
- `),1;if(i.kind==="stale")return await Yh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
211
+ `.trimStart();async function rp(t=process.argv,e={}){let r=SS(t);switch(r.mode){case"help":return process.stdout.write(TS),0;case"version":return process.stdout.write(`${Cr}
212
+ `),0;case"daemon":{try{await kh()}catch(i){return np.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return CS(e);case"stop":return sp(e);case"reload":return DS(r.agentId,e);case"log":return Kh(r,e);case"update":return RS(e);case"purge":return PS(e);case"service-install":return OS(e);case"service-uninstall":return LS(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),NS(r.privatecode,r.pairingCode,e,i,r.agentId,r.skipRebuildEnv)}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),MS(r.privatecode,e,i,r.skipRebuildEnv)}case"send":return $h({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 ip(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 CS(t){let e=t.paths??ee(),r=new Yt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
213
+ `),1;if(i.kind==="stale")return await ip(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
211
214
  `),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
212
215
  ${JSON.stringify(o.body,null,2)}
213
- `),0}async function Qh(t){let e=t.paths??Y(),r=new en(e),i=t.daemonSweep??(async()=>{let x=sf();return await of(x),x}),o=async()=>{t.skipProcessKill||await i(e)},c=await is(t),l=!1;if(c)try{await c.uninstall(),l=!0}catch(x){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(x)}
216
+ `),0}async function sp(t){let e=t.paths??ee(),r=new Yt(e),i=t.daemonSweep??(async()=>{let x=c0();return await d0(x),x}),o=async()=>{t.skipProcessKill||await i(e)},c=await rs(t),l=!1;if(c)try{await c.uninstall(),l=!0}catch(x){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(x)}
214
217
  `)}let u=await r.probe();if(u.kind==="not-running")return await o(),process.stdout.write(l?`coze-bridge: stopped
215
218
  `:`coze-bridge: not running
216
- `),0;if(u.kind==="stale")return await Yh(e),await o(),process.stdout.write(`coze-bridge: not running (cleaned stale state)
219
+ `),0;if(u.kind==="stale")return await ip(e),await o(),process.stdout.write(`coze-bridge: not running (cleaned stale state)
217
220
  `),0;try{return await r.request({method:"POST",path:"/shutdown"}),await o(),process.stdout.write(`coze-bridge: stopped
218
221
  `),0}catch(x){return(await r.probe()).kind!=="connected"?(await o(),process.stdout.write(`coze-bridge: stopped
219
222
  `),0):(await o(),process.stdout.write(`coze-bridge: stop failed: ${String(x)}
220
- `),1)}}async function uS(t){return await Qh(t),(t.spawnNpx??fS)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function fS(t){return new Promise(e=>{let r=lt("npx",t,{stdio:"inherit"});r.on("exit",i=>e(i??1)),r.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
221
- `),e(1)})})}async function xS(t,e){let r=new en(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
223
+ `),1)}}async function RS(t){return await sp(t),(t.spawnNpx??kS)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function kS(t){return new Promise(e=>{let r=nt("npx",t,{stdio:"inherit"});r.on("exit",i=>e(i??1)),r.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
224
+ `),e(1)})})}async function DS(t,e){let r=new Yt(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
222
225
  `),1;try{let o=await r.request({method:"POST",path:"/reload",body:t?{agent_id:t}:{},timeoutMs:35e3});if(o.status===200&&o.body?.ok){let c=o.body.recycled??[];return t&&c.length===0?process.stdout.write(`coze-bridge: agent ${t} \u65E0\u8FD0\u884C\u4E2D\u5B50\u8FDB\u7A0B\u53EF\u56DE\u6536 (\u672A\u6CE8\u518C / \u5DF2 idle)
223
226
  `):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
224
227
  `),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
225
228
  `),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
226
- `),1}}async function is(t){if(t.supervisor){let c=t.supervisor,l={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:u=>c.install(l,u),uninstall:()=>c.uninstall(l)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Vh(),$h)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function ep(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??Eh,o=t.waitTimeoutMs??15e3,c=t.sleep??yS,l=t.paths??Y(),u=await is(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let x=await Jh(e,o,c);if(x.kind==="connected")return x;Tt(l.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(x){Tt(l.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(x)})}Tt(l.bridgeLogsDir,"warn","cli","\u79FB\u9664\u5F00\u673A\u81EA\u542F\u914D\u7F6E (supervisor \u63A5\u7BA1\u672A\u6210\u529F, \u56DE\u9000\u624B\u52A8 spawn; \u4E0B\u6B21\u91CD\u542F\u4E0D\u518D\u81EA\u542F, \u9700\u91CD\u65B0 service install)",{platform:u.platform}),await u.uninstall().catch(()=>{}),await _S(l.pidFile,c)}else u&&await u.install({activate:!1}).catch(x=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(x)}
229
+ `),1}}async function rs(t){if(t.supervisor){let c=t.supervisor,l={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:u=>c.install(l,u),uninstall:()=>c.uninstall(l)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(ep(),Qh)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function op(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??Ch,o=t.waitTimeoutMs??15e3,c=t.sleep??FS,l=t.paths??ee(),u=await rs(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let x=await tp(e,o,c);if(x.kind==="connected")return x;St(l.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(x){St(l.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(x)})}St(l.bridgeLogsDir,"warn","cli","\u79FB\u9664\u5F00\u673A\u81EA\u542F\u914D\u7F6E (supervisor \u63A5\u7BA1\u672A\u6210\u529F, \u56DE\u9000\u624B\u52A8 spawn; \u4E0B\u6B21\u91CD\u542F\u4E0D\u518D\u81EA\u542F, \u9700\u91CD\u65B0 service install)",{platform:u.platform}),await u.uninstall().catch(()=>{}),await BS(l.pidFile,c)}else u&&await u.install({activate:!1}).catch(x=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(x)}
227
230
  `));return process.stdout.write(`coze-bridge: starting daemon...
228
- `),await i({paths:t.paths}),Jh(e,o,c)}async function hS(t){let e=new en(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
231
+ `),await i({paths:t.paths}),tp(e,o,c)}async function PS(t){let e=new Yt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
229
232
  `);try{await e.request({method:"POST",path:"/shutdown"})}catch(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
230
- `)}await new Promise(l=>setTimeout(l,500))}let i=await is(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
233
+ `)}await new Promise(l=>setTimeout(l,500))}let i=await rs(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
231
234
  `)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
232
- `)}let o=t.paths??Y(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
235
+ `)}let o=t.paths??ee(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
233
236
  `)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
234
237
  `),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
235
- `),0}async function pS(t){let e=await is(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
238
+ `),0}async function OS(t){let e=await rs(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
236
239
  `),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
237
240
  `),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
238
- `),1}}async function gS(t){let e=await is(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
241
+ `),1}}async function LS(t){let e=await rs(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
239
242
  `),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
240
- `),1}}async function tp(t,e,r){if(e)return Tt(t.bridgeLogsDir,"info","cli","agent-env: skip rebuild, use process.env",{}),process.env;let i=await r();return i.kind==="ok"?(Tt(t.bridgeLogsDir,"info","cli","agent-env: rebuilt from login shell",{vars:Object.keys(i.env).length}),i.env):i.kind==="skipped"?(Tt(t.bridgeLogsDir,"info","cli","agent-env: rebuild not applicable, use process.env",{reason:i.reason}),process.env):(process.stderr.write(`coze-bridge: \u91CD\u5EFA shell \u73AF\u5883\u5931\u8D25, \u56DE\u9000\u5F53\u524D\u8FDB\u7A0B\u73AF\u5883 (\u53EF\u7528 --skip-rebuild-env \u663E\u5F0F\u8DF3\u8FC7)
241
- `),Tt(t.bridgeLogsDir,"warn","cli","reconstructLoginShellEnv failed, fell back to process.env",{reason:i.reason}),process.env)}async function mS(t,e,r,i={},o,c){let l=new en(r.paths),u=r.paths??Y(),x=await tp(u,c,r.reconstructEnv??Od);if(await Zc(u,x).catch(E=>Tt(u.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(E)})),!r.skipDistInstall){let E=await zd({paths:r.paths});E.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${E.fromVersion} \u2192 ${E.toVersion}
242
- `),(await l.probe()).kind==="connected"&&(await l.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):E.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${E.libVersion}
243
- `)}let g=await ep(r,l);if(g.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${g.kind}
244
- `),1;let w={privatecode:t,pairing_code:e};i.env&&(w.env=i.env),i.handshakeUrl&&(w.handshake_url=i.handshakeUrl),i.frontierUrl&&(w.frontier_url=i.frontierUrl),i.mockScenario&&(w.mock_scenario=i.mockScenario),o&&(w.agent_id=o);try{let E=await l.request({method:"POST",path:"/pair",body:w,timeoutMs:35e3});if(E.status===200&&E.body?.ok){let S=E.body.agent;return S&&!S.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${S.agentId}): ${S.note}
243
+ `),1}}async function ap(t,e,r){if(e)return St(t.bridgeLogsDir,"info","cli","agent-env: skip rebuild, use process.env",{}),process.env;let i=await r();return i.kind==="ok"?(St(t.bridgeLogsDir,"info","cli","agent-env: rebuilt from login shell",{vars:Object.keys(i.env).length}),i.env):i.kind==="skipped"?(St(t.bridgeLogsDir,"info","cli","agent-env: rebuild not applicable, use process.env",{reason:i.reason}),process.env):(process.stderr.write(`coze-bridge: \u91CD\u5EFA shell \u73AF\u5883\u5931\u8D25, \u56DE\u9000\u5F53\u524D\u8FDB\u7A0B\u73AF\u5883 (\u53EF\u7528 --skip-rebuild-env \u663E\u5F0F\u8DF3\u8FC7)
244
+ `),St(t.bridgeLogsDir,"warn","cli","reconstructLoginShellEnv failed, fell back to process.env",{reason:i.reason}),process.env)}async function NS(t,e,r,i={},o,c){let l=new Yt(r.paths),u=r.paths??ee(),x=await ap(u,c,r.reconstructEnv??Md);if(await Yc(u,x).catch(_=>St(u.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(_)})),!r.skipDistInstall){let _=await qd({paths:r.paths});_.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${_.fromVersion} \u2192 ${_.toVersion}
245
+ `),(await l.probe()).kind==="connected"&&(await l.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):_.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${_.libVersion}
246
+ `)}let p=await op(r,l);if(p.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${p.kind}
247
+ `),1;let w={privatecode:t,pairing_code:e};i.env&&(w.env=i.env),i.handshakeUrl&&(w.handshake_url=i.handshakeUrl),i.frontierUrl&&(w.frontier_url=i.frontierUrl),i.mockScenario&&(w.mock_scenario=i.mockScenario),o&&(w.agent_id=o);try{let _=await l.request({method:"POST",path:"/pair",body:w,timeoutMs:35e3});if(_.status===200&&_.body?.ok){let I=_.body.agent;return I&&!I.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${I.agentId}): ${I.note}
245
248
  `),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"
246
- `),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(E.body)}
247
- `),1}catch(E){return process.stderr.write(`coze-bridge: pair failed: ${String(E)}
248
- `),1}}async function wS(t,e,r={},i){let o=e.paths??Y(),c=t??await Ko(o);if(!c)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 l=new en(e.paths),u=await tp(o,i,e.reconstructEnv??Od);if(await Zc(o,u).catch(w=>Tt(o.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(w)})),!e.skipDistInstall){let w=await zd({paths:e.paths});w.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${w.fromVersion} \u2192 ${w.toVersion}
249
- `),(await l.probe()).kind==="connected"&&(await l.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(S=>setTimeout(S,500)))):w.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${w.libVersion}
250
- `)}let x=await ep(e,l);if(x.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
251
- `),1;let g={privatecode:c};r.env&&(g.env=r.env),r.handshakeUrl&&(g.handshake_url=r.handshakeUrl),r.frontierUrl&&(g.frontier_url=r.frontierUrl),r.mockScenario&&(g.mock_scenario=r.mockScenario);try{let w=await l.request({method:"POST",path:"/connect",body:g,timeoutMs:35e3});return w.status===200&&w.body?.ok?(process.stdout.write(`coze-bridge: connected (${w.body.note??"ok"})
252
- `),t!==void 0&&await es(c,o).catch(E=>Zh.warn("writePatToken after connect failed (ignored)",{err:String(E)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(w.body)}
249
+ `),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(_.body)}
250
+ `),1}catch(_){return process.stderr.write(`coze-bridge: pair failed: ${String(_)}
251
+ `),1}}async function MS(t,e,r={},i){let o=e.paths??ee(),c=t??await $o(o);if(!c)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 l=new Yt(e.paths),u=await ap(o,i,e.reconstructEnv??Md);if(await Yc(o,u).catch(w=>St(o.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(w)})),!e.skipDistInstall){let w=await qd({paths:e.paths});w.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${w.fromVersion} \u2192 ${w.toVersion}
252
+ `),(await l.probe()).kind==="connected"&&(await l.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(I=>setTimeout(I,500)))):w.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${w.libVersion}
253
+ `)}let x=await op(e,l);if(x.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
254
+ `),1;let p={privatecode:c};r.env&&(p.env=r.env),r.handshakeUrl&&(p.handshake_url=r.handshakeUrl),r.frontierUrl&&(p.frontier_url=r.frontierUrl),r.mockScenario&&(p.mock_scenario=r.mockScenario);try{let w=await l.request({method:"POST",path:"/connect",body:p,timeoutMs:35e3});return w.status===200&&w.body?.ok?(process.stdout.write(`coze-bridge: connected (${w.body.note??"ok"})
255
+ `),t!==void 0&&await Qi(c,o).catch(_=>np.warn("writePatToken after connect failed (ignored)",{err:String(_)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(w.body)}
253
256
  `),1)}catch(w){return process.stderr.write(`coze-bridge: connect failed: ${String(w)}
254
- `),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)}async function _S(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let l;try{l=await o(t,"utf8")}catch{return}let u=Number.parseInt(l.trim(),10);if(!Number.isFinite(u)||u<=0||!zi(u))return;await e(i)}}function yS(t){return new Promise(e=>setTimeout(e,t))}te();function bS(t){let e=/^v?(\d+)(?:\.(\d+))?/.exec(t.trim());if(!e)return"ok";let r=Number(e[1]),i=Number(e[2]??0);return r<18||r===18&&i<4?"fatal":r<20?"warn":"ok"}function np(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=bS(t);if(i==="ok")return;let o=t.replace(/^v/,"");i==="fatal"?(e(`[coze-bridge] \u5F53\u524D Node.js \u7248\u672C v${o} \u8FC7\u4F4E,\u65E0\u6CD5\u8FD0\u884C(\u6700\u4F4E v18.4.0,\u63A8\u8350 v20+)\u3002\u8BF7\u5347\u7EA7\u540E\u91CD\u8BD5:https://nodejs.org(\u6216\u7528 nvm/fnm)\u3002
257
+ `),1}}async function tp(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)}async function BS(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let l;try{l=await o(t,"utf8")}catch{return}let u=Number.parseInt(l.trim(),10);if(!Number.isFinite(u)||u<=0||!Bi(u))return;await e(i)}}function FS(t){return new Promise(e=>setTimeout(e,t))}re();function zS(t){let e=/^v?(\d+)(?:\.(\d+))?/.exec(t.trim());if(!e)return"ok";let r=Number(e[1]),i=Number(e[2]??0);return r<18||r===18&&i<4?"fatal":r<20?"warn":"ok"}function cp(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=zS(t);if(i==="ok")return;let o=t.replace(/^v/,"");i==="fatal"?(e(`[coze-bridge] \u5F53\u524D Node.js \u7248\u672C v${o} \u8FC7\u4F4E,\u65E0\u6CD5\u8FD0\u884C(\u6700\u4F4E v18.4.0,\u63A8\u8350 v20+)\u3002\u8BF7\u5347\u7EA7\u540E\u91CD\u8BD5:https://nodejs.org(\u6216\u7528 nvm/fnm)\u3002
255
258
  `),r(1)):e(`[coze-bridge] \u68C0\u6D4B\u5230 Node.js v${o},\u672C\u9879\u76EE\u63A8\u8350 v20+,\u4F4E\u4E8E v20 \u540E\u7EED\u5347\u7EA7\u53EF\u80FD\u6709\u517C\u5BB9\u95EE\u9898,\u5EFA\u8BAE\u5347\u7EA7\u3002
256
259
  \u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
257
260
  npx -y coze-bridge@latest stop
258
261
  npx -y coze-bridge@latest connect
259
262
 
260
- `)}np();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&ll("warn");Xh(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
263
+ `)}cp();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&xl("warn");rp(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
261
264
  `),process.exit(1)});