coze-bridge 0.1.38 → 0.1.39

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 +54 -54
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,25 +5,25 @@ 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 j0=Object.create;var Cr=Object.defineProperty;var G0=Object.getOwnPropertyDescriptor;var W0=Object.getOwnPropertyNames;var J0=Object.getPrototypeOf,V0=Object.prototype.hasOwnProperty;var $=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Le=(n,e)=>()=>(n&&(e=n(n=0)),e);var le=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ki=(n,e)=>{for(var s in e)Cr(n,s,{get:e[s],enumerable:!0})},$0=(n,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of W0(e))!V0.call(n,c)&&c!==s&&Cr(n,c,{get:()=>e[c],enumerable:!(a=G0(e,c))||a.enumerable});return n};var Oe=(n,e,s)=>(s=n!=null?j0(J0(n)):{},$0(e||!n||!n.__esModule?Cr(s,"default",{value:n,enumerable:!0}):s,n));import{chmod as X0,mkdir as Z0,readFile as Y0,rename as ji,writeFile as Gi}from"node:fs/promises";import{dirname as Q0}from"node:path";async function pt(n){try{let e=await Y0(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function sn(n,e,s){await Z0(Q0(n),{recursive:!0});let a=`${JSON.stringify(e,null,2)}
9
- `,c=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await Gi(c,a,{encoding:"utf8",mode:s.mode}):await Gi(c,a,"utf8"),await ji(c,n),s?.mode!==void 0&&await X0(n,s.mode)}catch(u){await ji(c,c).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(c,{force:!0}).catch(()=>{}),u}}var on=Le(()=>{"use strict"});function Vi(n){return cn[Wi]<=cn[n]}function Ar(n){Ji={...n}}function an(n,e,s,a){if(cn[n]<cn[Wi])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...Ji,...a});n==="error"||n==="warn"?tc.write(`${c}
10
- `):ec.write(`${c}
11
- `)}function N(n){return{debug:(e,s)=>an("debug",n,e,s),info:(e,s)=>an("info",n,e,s),warn:(e,s)=>an("warn",n,e,s),error:(e,s)=>an("error",n,e,s),child:e=>N(`${n}.${e}`)}}var cn,Wi,ec,tc,Ji,q=Le(()=>{"use strict";cn={debug:10,info:20,warn:30,error:40},Wi=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),ec=process.stdout,tc=process.stderr,Ji={}});import{promises as $i}from"node:fs";import{homedir as nc}from"node:os";import{sep as rc,join as ce,resolve as Xi}from"node:path";function W(n){let e=n??nc(),s=ce(e,".coze"),a=ce(s,"bridge"),c=ce(a,"lib");return{cozeRoot:s,bridgeRoot:a,libDir:c,libEntry:ce(c,"index.js"),binDir:ce(a,"bin"),pidFile:ce(a,"bridge.pid"),portFile:ce(a,"bridge.port"),tokenFile:ce(a,"bridge.token"),logFile:ce(a,"bridge.log"),installLock:ce(a,"install.lock"),configFile:ce(a,"config.json"),agentsRoot:ce(s,"agents")}}function Be(n,e=W()){let s=ce(e.agentsRoot,n);return{root:s,config:ce(s,"config.json"),workspace:ce(s,"workspace"),logs:ce(s,"logs")}}async function Zi(n,e){let s=await $i.realpath(Xi(n)).catch(()=>null);if(!s)return!1;let a=await $i.realpath(Xi(e)).catch(()=>null);if(!a)return!1;let c=process.platform==="win32"?s.toLowerCase():s,u=process.platform==="win32"?a.toLowerCase():a;return c===u||c.startsWith(u+rc)}var fe=Le(()=>{"use strict"});var fn={};Ki(fn,{AGENT_CONFIG_FILE_MODE:()=>xn,enforceAgentConfigMode:()=>oc,loadAgentConfig:()=>he,persistAgentSessions:()=>Ir,persistAgentSkills:()=>un,saveAgentConfig:()=>be});import{chmod as ic,stat as sc}from"node:fs/promises";function he(n,e){return pt(Be(n,e).config)}function be(n,e){return sn(Be(n.agentId,e).config,n,{mode:xn})}async function oc(n,e){if(process.platform==="win32")return;let s=Be(n,e).config;try{let a=await sc(s);if(!a.isFile())return;let c=a.mode&511;c!==xn&&(await ic(s,xn),Yi.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(a){if(a.code==="ENOENT")return;Yi.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(a)})}}async function Ir(n,e,s){let a=await he(n,s);a&&(a.sessions=Object.fromEntries(e),await be(a,s))}async function un(n,e,s){let a=await he(n,s);a&&(a.skills=e,await be(a,s))}var Yi,xn,$e=Le(()=>{"use strict";on();q();fe();Yi=N("agent-config"),xn=384});var mo=le(ee=>{"use strict";var A=T;function qn(){let n=["BMvJDa","Dg9cExrLC0i","Ahzjzve","uuXVCeS","zhvOBu4","zwn0","AeL5vwO","ugTID2u","BerkAgm","zw5HyMXLqxu","uMvJB25Uzwm","vfDNAwu","igfYCMf5yNu","yNDNy1O","vuPjA0O","u21TvMi","vuLjzvG","qMjkywi","mdaWmdaWmda","AvbPAg8","BMv3vMvYC2K","yMLUza","CxLLsfy","wKzpzfu","C2DPza","BvHYsM8","vu1MtKq","mNW1","BgLUzq","sLnptLa","zvjkuNa","B3DuAMy","B3jpBMXPBMu","ig1LC3nHz2u","DM9dCfa","B2nRzxrtDwm","uNLpDuq","qMruuNi","yw5Nzq","y2uGBM90igK","z2f5sNu","se9evM8","yMXVy2TLza","rhrcr0G","D01jte0","Bwf4uMv0CMK","tKDhuKW","yxrLq291BNq","r05kv0i","CMvZzxruCMK","AMDbseS","z3LtvvK","t1bftL9fuLi","y3ruAw1LB3u","wfvevhi","BgrftLy","r0rzEK0","z2u6ia","yNL0zu9MzNm","sMPfEeu","BurpwwG","BKDUrK0","weXfquK","DhHYquS","BMrLEa","AxjjzxC","zvvYBa","ihrPBwvZ","sfDTzg4","yMjpvNO","vKTnyLK","sMXHvvu","vhLTueK","CMfTzq","EwPLt0W","zgPmDKy","uxH4v2O","DMvY","wNjiAxy","B25dBg9Zzq","Bg9N","wMHfzvi","x3bPBMDqB24","DMjir3e","CMXlAMC","twLZC2LUzYa","qK1SvgW","DgHHBIbSB2m","D3m6lY8","B2zMC2v0","DLDIy2K","sNDQAxC","y0Xoteu","DxrMofDYAxq","A1n0yxr1C0m","v3jizuG","D3bgzg4","reDlsvy","wxHHtK4","A1blzvC","y0rcs0e","ze1NANO","s1fVB2O","C3vIyxjYyxK","x3bPBMDmB3m","AeHfrLa","sufLy1e","Aw47y2HHCNm","zhD4DwO","ALjZugW","Bgfsvhe","CLv3AvC","EsbJBg9Zzwq","CMfUzg9T","Eg92AwG","uvrqqxK","sxfWvgC","z3beqLO","Ew94t0W","CejszeS","vuzRtfO","wwTmuuq","sezkDMe","DhbizwfKzxi","uerTrMK","DcbSAw1PDa","wKf5z0q","uxzYEfi","vejPwgC","DMfSDwu","vvrhv0O","uwnJvLu","uxDZrNK","CMvKDwnL","Cgf5Bg9Hzeu","AurOs1G","tLLOt2m","r1rdChi","zw5JB2rPBMC","zxjFBxnNAwq","zNjHBwvuExa","EKjrDwO","zMLUza","renMA0m","u0rkDgq","C3vIC3rYAw4","zxf3vfi","rvfRqLG","zMXVB3i","q3n6vNK","CMLLC0nVDw4","u3rYyxrLz3K","DgHLBG","CejKwwi","r05jrei","A2jqEMK","Cg9W","shj3CLa","yLDsvMW","wfrKAfq","DxrVuMvJB24","swzXuuy","CM92AwrLihC","CgXLyxnLiha","BwfW","AfHguhu","vNjywMi","wMHntKe","wMvJCg0","re1VD0u","DwTLqLi","y29Kzq","Ew14BMW","z2v0s2v5","rxrLu00","tLPrExe","CMT2teO","ignVzgu6ia","zxmGCMvHy2G","t0jIExi","r0vcqKG","C2TOrwC","ywXPzcb1CMW","A1H1sLG","x2LZqNjVD3m","C2r0ELi","ExjqB20","wuLSyM8","zMfHteG","rLPqrhe","uLjQrgy","v2fPDMS","DfvAvKG","B2zMBgLUzq","x29Ut3bLBG","yxjYyxLIDwy","B3v0sw50zxi","v2rnuwq","vvnMBvy","AMPxCg0","wMvMt2W","Dw50","CNzHBfzHBhu","ChjVDg9JB2W","y29UBMvJDfm","B095BNa","q291BNq","B1n6v0m","B25VCgvU","t3bLBKv2zw4","EvjLy29UBMu","Eur4BxO","yw5Hz2vY","tNLSrxa","Axbczem","qK5JAgm","zvjQqMW","zNjVBunOyxi","C29Tzq","sg95Axq","shDoBxK","zhjLCKW","t3f0uKq","C0zXBem","BgDAwgm","ywWGy3vYC28","ANbxu2u","zhfNBMy","zxjFAxnFywm","x0rctMfTzq","uxjkqLq","zuTeBuW","rNPqq3O","DMvzwfC","AfHWv1q","y3vYC29Yx24","s3Lyrvi","zMX1C2HfEha","C3jJ","Cu5JzNG","EwzLqvi","B0X4Bee","uMPdBNu","zNjVBuj5Dgu","zxH0zw5ZAw8","txv5u1m","y2HHCKnVzgu","DxnLCKLW","D25gEKW","DKv2tgy","wMP6wNO","sMjWDfy","sxf0wwC","yLPqugW","CNnrsfC","Bw1Mz1i","zuTYzNK","seTnvgi","wgfVsvy","zfPTzva","zNb6DgS","rhPNsxe","Dg9mB3DLCKm","y3jLyxrLtwu","C0XPC3rLBMu","ywnRtxnNswq","zNzvsLy","zv90Aw1LB3u","B25mAw5L","tuvtu0fhrv8","vM9kAw0","r2ffsxO","q0Xpu0ve","ywXty29Wzq","r1ziAM4","C3b3B3O","BwvKAwf0zwW","B3vUDa","Au5gEgS","Bw5iCLi","m3WXFdv8mhW","zNDZxZeUmc4","zu1YsxO","CM92AwrLihy","zu5hCNa","Dw5dBgC","wxrZq3y","yMjZv0W","zg15Aha","CNnVCL92ywW","zw50zwqGDhK","tgTeqMu","mtm0mZq3mdrMweT0rwW","yxHgvui","rhPdBeC","CIb0DhDjra","nhW1Fdn8mte","Dxn6zg8","EMLhCgG","BvHzvvi","Der5vMu","zwrPyxrLBhK","BKXPBMu","D0rVv1e","y29UBMvJDgK","AM9PBG","x2rLyNvN","tMzXz2y","u1zMExi","BwvZC2fNztO","zhnRv0u","yxbWBhK","Aw5JBhvKzxm","x3bYzwzPEa","vxLcv0O","weLty1a","ywrK","y2XVC2u","y0Tkt3a","x29UtwvZC2e","t1zmCgO","vgLTzw91Da","u0jmswK","Dgv4DfbHEwW","BNrLCG","qxfrsLK","EursqwW","x2jPBMfYEvq","yML0BMu","vKj6CLm","s21rueu","swfNCe0","Ae9Wzw5fDMu","DNrdtuW","C2v0q3vYC28","Dg9Y","qMfeBLK","CMvZDwX0","D2LIy3q","ihzHBgLKihm","q0Xpu0LorW","u3j6rKS","EgrVCLK","CMvJB25Uzwm","C29YDa","Auv1AfK","EvDlq1a","BMCGDxjSoIa","DgLUzYbZzxi","ywrKt25L","yxKSihrYEsa","wNDACKe","zfPuwKS","C2vYDMLJzq","CMvZB2X2zq","Chv0","rez0tLm","DhvxvvG","uvfIzxy","rKfLy0G","B25szwnLAxy","AMLkEuC","C2HptvK","zw5fBxm","ugjNCvq","vNv4v0y","BKTsqKu","nhWWFdD8mG","D2LSBfjLy28","rhzMuha","qNLODfa","thHxCwK","DfjuEKm","v05fs3m","C1bPt1y","yu1Wz0C","AMj3rNi","v3LAtNG","ExHMrhi","zuPhDuy","C3bSAxq","z0TwqNi","ywnQAfO","s053yKK","u1rIu3K","BgvUz3rO","EKPdAfq","sePMwu0","uNrPwwC","vNz1CKG","BwLUzW","ChjVDg90Exa","x2HHBMrSzvi","A3vQrLy","tvrwyuO","teLAwxu","u1DhExq","z2v0","ExbL","CwTZu0i","DNjHvwe","ww9vuuS","B2DRAuK","sffnBuG","y29UDgLUDwu","zfv3t0u","y2XVC2uSihC","BxnN","BwfUDwfSihi","vLLNAuO","s0HvAgm","vKPHvMu","zLbqv0i","C2XPy2u","yxKSig5LDhC","vK93C0m","Aw9Xwem","Cgu6ia","t0rzDw4","zvzxuw4","tejdCxu","AwrI","zgvJB2rLzey","CMvHC29U","CYbHBhjLywq","CM92AwrLige","CgLUz0LUDgu","u0DVB2e","tMvREgS","mNW1Fdr8m3W","yxv0BW","rNDAsK4","zcWGDw5RBM8","Dujwq3K","DhvfCwG","DhbRvMe","zLDtvMC","uMPlu3m","Ae9qAhe","Dg9jC0K","BLHWuwW","wLL4r2K","Ew5lA1O","z29PBMCGyxC","seTkD0C","CNnVCL9Uyw0","BefXu08","mxWZFdv8nNW","wLn3Eee","zvfiyuu","wMHLuLO","Dvfqrg0","z0X0rve","qu5bCfi","y3D1A0i","mta0mty2mtz3y01Yq2W","B25Uzwn0Aw4","CKLVt2e","ywnOzwq","rLnpy3e","uLjpuG","x3jLy29UBMu","Ec1TC2CTy3u","quHVt1a","EhHIqMS","ANL4B0q","BeXouxm","rNvusNe","q1joCwq","BwvZC2fNzv8","vLHqvhC","uKTIs0G","C0nVDw50zxi","qKDcwMq","zfDVCMTLCKC","DgDqDha","uKf3vfK","yMfJA3vWigu","q1DAswO","vw53EfO","r0PmruK","zgvIDwC","x2nVBM5Ly3q","AxnszwfKEq","zw1PDa","vNLqueG","EgzHDw4","qxfiCNa","CgjICdi","lcbxzwjtB2m","AMfUqMC","zgvSzxrL","suXJDxm","DgvZDa","r3n0D28","AwrvDLa","y2HnyxHuCMK","wLnHq2y","reXHC2m","rvPHtKm","zxHWB3j0CW","x2LZsw5PDa","tKzNANe","Ae5KsNy","C2vUza","zxj2AwnL","ufz0A3O","x29UrxjYB3i","x21PBMLoyxy","ru1vyLO","C3rLBMvYCW","y3jLyxrLt2i","seT1Cw0","A2vwA2u","B25tDg9Wsw0","wxH1wNe","EejjCxy","CMLxrNO","tfbJCgO","wKzItuy","r0Hoz1C","vxPYuve","sNj2weK","zMzMzG","tLvYq2C","CLbNCMC","y3DYqMq","tevkz1C","rxDUzha","BM5Ly3q","BMfTzq","m3WYFdb8nhW","x1fVu01HBMe","vLvbvfK","BgLZDgvUtMu","y1LHBfO","DwXYvfq","v2vIu29JA2u","Aw9OrNy","C1Hbvei","svP6Ew0","y2f0y2G","AxnrB1nby2S","zgv2AwnLx2K","teHbz2u","rvPZzNC","wuzHAM8","tfLwruy","vNfxrgq","vK5Iuxa","AKrtyNm","AgfUz2u","mZG3ntvVCxvbwhu","vLzgAKK","vuz0BgW","s1f1ALi","zxjHDg9Y","B2LUDfjLywm","AwPss2y","svHZAuW","qMnAAeO","B3jRzxjhBg8","CgTzs20","rLDt","B3bLBKrc","vwrpDxm","BMvY","AuDvAeO","thzoDMK","v0vYEfu","rKjNqva","zgvMAw5Luhi","x3nVy2TLDa","CwPUrhq","AevYCM9Yrxy","Ae5hyKu","zNjVBuHHC2G","AwHmCLe","zg9uywy","lcbTyxGGCMu","zxjYtM8","vNbysuy","y29SBM8","yNHXCgS","sxb6sMu","uNz6Dvu","CNffyNK","mxWXFdb8ohW","vhHsA24","zgvgCwi","sennDLm","BfLOwuq","uhr3vKu","wuvttuG","Ahr0Chm6","wxH3Dg0","v1fzzwe","y291BNq","CwP2Duq","BMCGB3iGyw4","zxf1ywXZ","uNHYAhO","y2zZBfe","DMvUDa","CMvUDevUzha","Eu5twwm","BwLUAvbYB2C","rNbvBuW","ywnR","s1jfz2W","DK1oC2q","yNvMzMvYzwq","CLfOzue","DMjJrxK","t3DqBe4","DhvoteC","r0rRBM8","BNrbBMrvCgq","ufj4DNy","AwvoC2q","ruvUBxK","Bwf4twvZC2e","s3DXt2e","tg1lvwW","Ec11C2uT","vfbouLm","wwjIug8","ugDcwxO","Eff4wva","DKzTDe8","DhLWzq","A0nmwwm","rLPwqva","ufrWvwC","id4G","Dhr3Awq","ywzL","y2HnyxHdB3u","C3viCMO","D01NvwW","sgHABuq","uxnutg8","D3nZoI8V","Aw50zwDLCIa","AerNCxy","quXm","B1PRu1y","AwXK","z2vtEw5J","BNruCMLLC0m","igzPzwXKoIa","rKLmrv9ot1q","C013Cue","BMDLza","A3rKzwe","t2Lzv2e","u2vYDMLJzvC","CunJy08","CMTLCKDSB2i","q0Dbz0i","x3bPBMC","v2LUzg93","D1P1ue4","CLrcDvO","qwD5CgC","swXetfC","vvzxD1O","yNL0zuXLBMC","z2vjBMzVu3K","y29UDgv4Da","zgLkseO","z2nlCve","sKzdsNq","wKHqs0u","D1rqv3C","zKTQz3C","q3vZDg9Tq2W","v0PRqvG","Dg9iyxnO","x3jLywr5q2W","ywDLu2HVDW","zw50tgLZDgu","qwzMs2S","zwHVtNa","BgLUzw5V","CLzWBgq","Dw5Jv0i","DxbKyxrLq3u","CgvXtKm","BMCGzMfPBgu","r1HuB0G","CxPhzeu","vw5PBxbSzw0","wLfxy2O","CgfYC2u","Ae1LC3nHz2u","se1ZAKe","ywXS","rNjVBNrPzxi","x3DHAxq","x3vYBa","vKjrDgC","s3zSuKm","ufjxCg8","tMXrDxy","DLrrqxC","r2XeyKW","vKvAs0u","yNL0zxm","CMvZzxrdB3u","m3WWFdz8nq","rwrqzLq","veDMvhy","B1rkzMq","txrVzha","BxnNsuq","zeHOyKW","Cfz6sLC","BKLWu1K","x2n1CNnVCK0","svHZCKW","r3HywMO","t3rssfG","BfrPBwvVDxq","y29UBMvJDca","q3zVvuq","C0jf","txHXrLG","wLbmBwK","txPIC1C","DKnPs1G","u1DtyK0","EgrYy1u","CxfQBue","sxnPAgC","BfrNsvm","x2n1CNnVCKy","yM9KEq","r05msfG","AgvHzgvY","rK9XCg8","CuzYBuS","zM9YrwfJAa","yuvIrxq","svzIvK4","ywDLrxzLBNq","CxbsBey","y09Wzw4","Cg9PBNrdB24","x29UugfNzu4","zcbLCNjVCI4","q3bNBuS","DKTwDgG","x2vUzhbVAw4","DwTTBuS","Afnuufq","BLj4tem","DMXZEMq","ruPSre4","z2v0q3vYCMu","BwLZzq","vwDWqK0","q29Kzq","t1bftG","suHly2G","vxnuCNG","wNL0BKe","tMrLy3K","AxjPs0K","tevhA00","vw5kB1a","zsbHihn0CMK","uNblz2G","vxHrvum","C3rVCMu","sK9jDuy","CMfNzvn5BMm","q3PpAK8","ihrPBwvVDxq","zMLSDgvY","Bu1sq3e","te5JAvi","zunSCwS","rNrRDum","BMnVzgLUzW","z2Xjrhm","Aw5L","qNjsDLe","ywjlEKe","ELvNzvq","yKzuCNi","DMfS","x2rPC3bHDgm","yMfSu2nVCgu","AgvHzgvYCW","y2H2BKm","EMvSvwu","D1rtshi","AgfZt3DUuhi","zvrWB24","Dw5ZAwDUzwq","BLjjr3y","sLLvr2m","sw1fChG","DxbNCMfKzw4","zhbAuui","swndCwm","B2zM","yLvHsMu","CMvTB3zLq2G","DMXQr1q","BMDuAw1LCG","z29NtxO","thnuveG","uuvNq0y","uvjOAeW","y2nrshq","Cxvzve4","wLLbuhu","sLzkzxq","ALHPCgG","z0HhDMu","z3Hhywm","BxnSDe8","B3rPs3O","svbjCLO","Cg9PBNrbBMq","C1jLvM8","C2v0","y2jjrLq","ug5cswG","t01IteG","ign1CNnVCIa","DgfIyxnL","C2vYDMvYvgK","r3rRA2S","sLHAt1u","y3vYC29Yx2y","CMvHzfvjBNq","qKTWEee","AxnrB1nnzxm","yuDoyKi","y29UBMvJDeu","EhnQwgK","Bg9Nsurhzw4","rhDLz1i","q25SzKC","Bg9NsurozxC","rNvpy3C","Cxblq2O","tMH2AMC","EeDtBLC","v1nQuNa","txjuAw8","lcbOB3n0BMe","C3nHz2vfDMu","suXXC1e","DgLLCKPtt04","qK1YCwm","AKDqrNK","v3v0txG","mte4otHOy01rthm","Dxb1v1y","nNW4Fdb8oxW","DcbVzIbYyw4","B2fK","Ec1TC2CTCw8","u3Pyrva","BML0AwfSAxO","BhburKy","Dg9hzw5LCMe","v21PwNe","BMrNvLa","C2v0zgi","vNfKwum","ENPrBvK","sKLeDwG","CM9YrxzLBNq","rujSuuG","wwroAhq","sxzSt3O","rhPlvwy","vMf5uge","z2rIALm","Aev3s2O","ENvcAu8","vLHPEe4","A2PMseG","rwrLrNa","EKfJDLC","r2P0zxu","Bhm6ia","zNPVugy","DKrgDK8","A2v5","DKXSu2S","Ae5Qwe0","wuDfzLq","C3vJy2vZCW","yxbWBgLJyxq","vuTSve4","vhjlDgi","x2LZtM9Kzq","Dxn5AwS","nhWZFdj8mhW","tMfTzq","EwXby3y","zMHTD3C","CMvQzwn0","su1Uu3i","A2X6uvK","DMXPt28","ALjfuK8","AvPXq2e","z2vY","wvHfuuW","u0vctvK","zgvS","ywDbD2y","AgLNAa","zurure4","z2v0qwXS","BvzoEK4","A2XXtKK","uffMAe8","CvDfB3u","x2rItMfTzq","v3zQtLC","B25LCNjVCG","BeHHBMrSzxi","tuHlzMC","vfr0EuG","zgf0yq","BxbZs2O","BfnbrMe","C0LLA0G","C3rYAw5NAwy","AfzNsxq","DMfSDwvZ","DMvYC2LVBMm","zunnrxy","vvbUsem","x2HHBMrSzu8","CLnft00","BgPnC0q","DNzMC3G","wNjfz0G","zgLZywjSzue","BhrPCgXLihq","teLrs2O","yvj6tNm","twnxEey","DvbxtNm","DhfvvNq","BxftDMG","B3bLBG","wNzNwxe","ihrYEsbYzwm","qvnmuuC","A0LLDNy","y3jLyxrLrxi","tMf0C1K","Ew9tEKS","AuvXBLu","ywDL","ywr2yw5Jzq","zxjYtxnN","AhnQqKG","Dhj1y3rVCIa","EfHJv0q","Aw1LCYbPBIa","AKn2vha","y3bTy1m","q3DZy24","x3jLBw92zvC","B3bLCNr5","yxrHlcbKyxq","BgLgAuy","EhzIwNC","BM1hreO","zw5JB2rLrNi","u0vzwKe","CMvWBgfJzui","igXHCMDLCIa","Aw5PDcbrB1m","ALrPvhu","wgnjEei","Dg9tDhjPBMC","yK1IzLC","mZj2s29YCKm","igzHAwWSig0","x2XPC3rLBMu","Cu9ozhK","tMjwDKO","Exv0ru8","BxL3CK4","zefItwq","zM1ot0K","wfb0sgC","teXMtMm","y3vPrg8","yNvMzMvY","zw50","B0Llwhi","u2f2uhC","B2jQzwn0u3q","wwfoD20","D2LArvq","rwfuEw0","q0fHsNK","tg9NsurozxC","sw5st1i","DhDVCMTdAge","CgnqwgO","wLL2Bwm","DgfYz2v0","CMvTB3zLrxy","sLLls2y","ChrVCG","zxq9DxrMltG","zxjYB3i","Der5yKC","AwDHDg9Yt24","D0rrBum","B25ozxr3B3i","CLnABuq","DeDPsuS","BM9Uzv9UB24","q3LUq2W","q09otKvdveK","qMvHBgy","ugLzrfq","DvD2y0u","Dw5RBM93BIa","B3HJteO","A3rgwKi","x29Uq2XVC2u","vvjJC04","CMvJzwL2zwq","BMv4DcGPigm","sMTNBxK","zg9Uzq","svHyreS","y3r4","y2XLyxi","zMzLCG","q3PUCKS","rhjMze8","yMLUyxj5vhK","CMv0CNLdB3u","wuTVuhq","wePOwxi","ELLXDee","BMrWB2LUDfq","nhW3Fdj8mxW","AKX4Cg4","zunkvhK","s0fIBfy","mxWZFdj8nhW","zgvSzxrLrge","ENL3DvG","AMvSvhi","x2rYB3bhBg8","u3zZzNC","q3bwtui","y3jLyxrLt3a","B2nRzxq","yNLL","AK5uyvC","Ef9MCM9UDgK","ywnRDxbfBMq","yuHVCg0","EfvZzuvUDG","zMLSzw5HBwu","CgvYC2LZDgu","uvb5y1m","m3W0FdeWFde","A1LMBhK","zxnwBM8","Ehjtzvy","D0T5rfa","y3zowgm","D1jTtfK","C3rVCcbPBw0","vM5wvgW","zNjVBNrPzxi","BfPfsw0","v1PqCvm","rgTkzuq","tfzgywK","rgHUvMS","C3rYAw5N","CMvWBgfJzq","zgn6vNm","D0LwBw4","A2Dhsfm","C0vNDwm","t3nXAva","ru1Wt2u","ntCZotbWCe5fBLG","zxrxB3jRq2G","EezQrg4","m3WXFdj8mhW","qNnyDMm","rMHUAwy","turyquW","D3rxvMG","DLjYrwS","ihzHBgLKigq","B3jRig9MzMW","y29TCgXLDgu","y2HfCuq","Axnby2TdBgu","Dfz0u3G","zxH0ugf5Bg8","zw5et1u","AxnbCNjHEq","wePRrvO","C2vUzf9Hy2S","ruH0yM8","yMnnvfG","uxvivgK","mta5mJqWmdjxqKLfsLa","Cw9Ts2y","zMncz3O","ENjKyuW","y3jLyxrLrwW","s1DKswu","shvWBKO","x2LUAxrqCM8","zKHiEve","uvDdzLO","tujzCKK","zxjFCw9Zx2e","y0n4A1O","u0PSsfC","weToCLa","r2PSAge","rgXdq0u","rKDLvwe","qLnJuuu","vwjoC3u","uKvUEhq","yxrZyKu","Cgf5Bg9Hzfq","CMvZzxrfBMq","rgX0tLa","q0DHyvi","CMvHzhLtDge","q3vZDg9Trxi","uxv6vha","EK16zMu","tufyx1jfvfi","wNLdvNy","yMfSrxzLBNq","uLrUAg4","txfwAgm","B2fMBLK","sunVD1u","m3WXFdb8nhW","yLbUBue","uxvLDwu","z3fODhy","rur2Du4","zurKs28","zuzMt08","Dezytu8","wuzQuLy","ywnRx2LK","y3PyD3C","Aw5AvNG","x3DZsw5ZDge","B2XKvMvYC2K","y3vZDg9Tshq","EvPevgK","x2LUAxrhBg8","z3bdwwK","BwLqA0G","Dg9VigXHCMC","ywjVCNq","BvLfteG","CM5Wwva","Dg9oDw1Izxi","CwP5uvC","C3LmBKS","zMvY","ChbArM4","y3vYDMfSDwu","y29UC3rYDwm","vw5Oyw5KBgu","zv9ZDwnJzxm","t1nXwfO","x19LC01Vzhu","u3HXy1K","ihjLy29UBMu","EgrRrwe","yxnZAwDU","uMvurMu","B3DJzKy","rNH5Cwe","vxjUu2y","zMXOC00","AuTjEKC","A21RBe0","Curlwe4","AKHHBhO","zLjHENq","A3zluM8","D2vI","CgLUz1rPBwu","qLfswha","uejRBue","x3bYB3rVy28","rhftDfa","Exnxywq","EenZu3C","x25HDMLNyxq","v2L3wKC","Aw9UvgLTzw8","mxWW","CKneDu4","tu5UrLG","Dev2zw50","yxnJCMLWDa","C2P2ueO","B3nLrxzLBNq","zu1LAM4","aaaaaaaaaaa","se1Nrhu","r3DqqKi","AhDdC0u","B0vQvMy","AeDoz00","y2vZC0HHBMq","A2v5CW","Aw5KzxGGB3u","BKneBwy","yMrFzgLK","zfLhDNG","y3vYCMvUDeK","BgTktuO","tg9JAW","y2XHEMW","yxfuD0u","B25TzxnZywC","v05UquS","ChPKEeW","AefJA01LC3m","z3LZExi","zMzmAw5L","tg5jz2G","D2fZq2XLyw4","EMflzMq","CM92AwrLigi","y2HLy2TdDxi","B0vdqxO","DeXOue4","AKrmBuG","vvHksgC","s09fCwy","vLnvAgG","BeXJBuK","C2v0sxrLBq","uuPKwLC","q0DyvMq","z0n2rhe","CfzrBvK","x3DZ","uK51uvC","x2rLC3rYB3K","CufxELi","x3nLBMrby2S","BNrfBMrWB2K","whjAwhO","qvvZseS","vKLOrwW","q1LdC2S","B3jLtMfTzxm","DK9Ky0C","sKvWz1a","wvblrwu","zw1LBNq","ugHNvuy","Bgvcthu","zxjFDhrS","r1n3ree","CgfNzwHPzgu","r09kEfe","BwvY","vKHwwfy","x2nSzwfYugK","Aw9U","u3LpD3i","AejmAKC","D24GCMvHC28","x2TLEvbHDgG","zhbRy1m","Cg9Lt00","qw1VDw50","Dw5KzwzPBMu","u21guhO","C3Pev28","uwv6z2u","BfbbAwS","zNjVBu51Bwi","AgfZ","CgLUz19VBMm","DNbXD0u","y3vYC29Y","D0j4Ce4","q3H3A0G","reiGzMfPBgu","C1r2sem","BMrWB2LUDca","uM5Iwey","tLDHAve","twvZC2fNzuu","x194x21Zz18","zM9Yy2u","Dw5TC0O","CeHIvhy","uKfizgi","De1HBMfNzxi","x2nYzwf0zvm","BMDnB28","sKDeCMO","AMXxsKC","zgXyr00","A1LHzMi","u2vXsuq","A0nlwK0","D3jPDgu","AxnAzxjV","Aw9Ul2PZB24","CNzHBa","vhzLuxa","qvDNteO","tg9Nsuq","BM1JELa","AgvKtwf4uMu","C2v0u3rVCMe","v2nSqKi","C3rIzfa","CNnVCKzPBgu","z2v0sxrLBq","tgLZDgvUzxi","qxPdC2e","wM1Psg0","zgfREKu","vxzqseC","DeP5wgq","rxjYB3jdB2q","DgLTzw91Da","mMzNrKrKsa","x3nLCuLK","ENHNs3C","qvriv08","vg1gsNC","uu1wAwy","CLDVDLa","BgvY","rLjuBuW","Aw5KzxG","sxDfuLi","AxrXtK8","DunOALu","zNjVBujPDhm","yw1L","z2v0q3vYC28","x2zVCM1HDeu","qNzYt0W","vhPnvuy","x2DLDeLUDgu","suvtx0vsuK8","wefVC2y","uNHWsge","x2DLBMvYyxq","zw5HyMXLuw8","s01uuMm","EevoA1m","x3bHDgHlzxK","AxnFywnR","o2nOyxjZzxq","yw51Ce1LC3m","z2vrDwv1zuW","rwzVCgG","ENDQueK","Bwf4tg9ZC0m","AfHowMO","wNHVBfq","ywnRpwzYB24","AxnmB25N","B2PVsge","zufJAW","rLD3tvK","x29WDgLVBNm","zw5fDMvUDa","Aw5KzxHpzG","CMfTugfYyw0","DuTKzMu","y2XLyxjtDg8","zLL2rwm","zMLN","tuDtz0G","DhrVALu","se9OzLa","zw5HyMXLvhi","EMzgAxG","whb2t1G","x29UvgLTzw8","D3jPDgvvAw4","whHbCeS","ywDXqva","Bwv0Ag9K","uwP6Auu","ruLhCgK","y3jLyxrLq2W","ywDLsgLKzq","ywXSq3vYC28","qwjVCNrfCNi","r0nmAvq","z0XereC","C2vUDa","qNHoAhK","tNrNsvG","qMj4qve","s05xvxC","AerXB00","mtC5otqXmuXftvfiuW","AKriuKi","ufrstKS","Dg5Ns04","ywrKrxzLBNq","Dwr1B2S","vgfN","z1rPBwvVDxq","jMPZy2fSBgi","y3vYCMvUDeu","rxzLBNq","CLbXC2m","ExDXy0K","Bg9IywXty28","x2LZv29YA2u","C2HPzNq","BMT0thu","ufr2ALy","EgDuzKe","B2nRzxrgywK","DuP3uuC","vMXHr1O","uw5tq3G","Dw1Ys0W","x2fKzfDZtgK","y3DLrwi","q2DvAuG","r1f1A0K","AenSB3nLrxy","yMfbCNa","B25nzxnZywC","sMTiu2e","rvjst1i","zNvWuui","CuLYExu","qNHXC2O","B2vkALe","z2v0u3rVCMe","u3jbA24","q09oveLovuu","BefmALO","uuzbu1i","sKzqA3a","Ce9NBeq","tLbvBha","B3bLBIa","zvbSBMW","B25JBg9Zzq","vMrkBNK","u2HHCMvKv28","se5JB1G","yxnL","uhvLA1m","Avjxv0q","CgfNzxnOB3C","ywnOzwqSihC","q21Tu1y","zcWG","D1n1D1q","CNjVCK1LC3m","rg1HCuW","Dxrjza","s05qrve","BKTYv2G","BwvZ","uxfPuhK","x2LUDgvYDMe","Bvr2zgu","q25RqM4","A3nVtNO","x3fVC0rc","qwzeyum","sg9KAMy","DMvYC2LVBG","u1Lhzgm","y2XVC2veqG","zwnVBM5Ly3q","rLjptLrjrvi","DxjS","B1bWCve","BgLTAxq","zNLurMO","vfnZqKK","ywrKq291BNq","vurAv0q","Aw1NuKe","EffwwvO","u1fkDfq","x2LZtwLUAvq","qwTvy2C","uej1r0O","Aw5N","Bg93","C2vYDMLJzs0","zNf4EeW","Afvdyui","wNzOweC","B3nLza","x2HHBMrSzva","B3rJwwO","q2DqtKO","y2HLy2Tszwe","D3n1sgO","qLjprgG","Cgf5Bg9Hza","tKfusvzfx0u","z2L5qMW","AwXLtMfTzq","BMnLq2XVC2u","AuHWqNO","CeTluNu","mNW0","ENP5Bfu","DKXUruC","z0DwEum","wxHPB0G","DMD1Bgy","A2v0ignVBNm","DhjPzxmGCMu","DeXSBeK","DeLUDgvYy2u","yM9L","l3DZl3yY","DeT3BMe","zM9dvgK","C2fNzq","zw5KCg9PBNq","CeXWtLC","DgLTzw91DcW","u1nfz04","ywX3yxLZ","qKLtB3y","wuPrAxu","BgLNEfu","tLrtCuq","yxGGCMv0CMK","C0Xf","y3jLyxrLuMu","wfLQuxu","CffVC0q","EhzwBei","nteZmZmZnKrdELvewa","Agz0s0y","tMnICu0","rvreshq","vxfpDg8","y0Tvz3m","B2rwuvm","CfPNzKC","Aw5Lza","y29UBMvJDa","s25rqNa","vxL6vLi","tMTkCNe","BfrvAgy","t0Tzrgq","vwTZvuy","zhbtExG","Dg9cExrLC0W","tNbUAei","x21LC3nHz2u","yNLMre0","shPUquq","ENLQELq","A3fNtei","zxjFywnRx20","thrRD20","sM1RC1u","DhD1qKi","ve5cvgO","u2TPCcbWyxm","yvjlsvC","DhjHBNnHy3q","BezSDxnO","y29Uy2f0","DNnVAfu","BM1bB0i","ywnRx2nVzgu","yxv0B21HDgK","y2fSBa","FdeWFdj8mxW","z2v0qwXSs2u","CgLUz0XVC3m","A3rlCNe","x2rPC2nVBM4","wNHQwLe","x2nSzwfYvgK","sLfXugu","AxjLza","CMvXDwLYzwq","uK1jtxy","zw5NDgG","vgjir1e","B05iyK8","DeLK","wgPkt04","quzxEfa","ENzRAM4","yKDArM4","mdaWma","BM93","x2LUAxq","x2n1CNnVCK4","B25tDgfYDfi","B0TIwKy","A0ndB0m","uuLuv2S","s0TSzu8","A2PVq0m","DhjPzxm","BNvTyMvY","CMvHzg9UBhK","uKzOD2O","sKPVwwy","yw1LoIa","yuf1EK8","B25pCgvU","A09hBe4","x2LZtwLUAvC","CfDSqxm","BIWGAg9ZDg4","ChvZAa","v0rJwMm","BwvZC2fNzq"];return qn=function(){return n},qn()}(function(n,e){let s=T,a=n();for(;;)try{if(parseInt(s(1346))/1*(parseInt(s(1271))/2)+parseInt(s(1487))/3+-parseInt(s(907))/4*(-parseInt(s(470))/5)+parseInt(s(1040))/6+parseInt(s(373))/7+parseInt(s(1862))/8+parseInt(s(779))/9*(-parseInt(s(1017))/10)===e)break;a.push(a.shift())}catch{a.push(a.shift())}})(qn,973666);var yu=Object[A(489)+A(893)],bu=Object["getOwnPropertyNa"+A(1410)],fo=(n,e)=>function(){return n&&(e=(0,n[{Bealf:function(u,f){return u(f)}}[A(948)](bu,n)[0]])(n=0)),e},vu=(n,e)=>{for(var s in e)yu(n,s,{get:e[s],enumerable:!0})};function Su(){return oo||(oo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Eu(){let n=A;return ao||(ao=[IDBCursor[n(1961)+"e"][n(883)],IDBCursor.prototype[n(1974)],IDBCursor.prototype[n(1974)+"PrimaryKey"]])}function Cu(n){let e=A,s={lALjZ:e(1588)+e(1588)+e(1588)+e(1588),Gnnty:e(1707),SfPHH:e(781)+e(1866)+e(1526)+"7",cweEb:function(c,u){return c<u},SJlHW:function(c,u){return c|u},OKMHE:function(c,u){return c<<u},LHqka:function(c,u){return c===u},HKuqm:e(845),oKbZF:e(1128),CNPVm:function(c){return c()},YKoPt:e(1491),kOGBg:"success",KmQPE:e(938),iPiho:function(c,u){return c instanceof u}},a=new Promise((c,u)=>{let f=e,h={vKVth:function(w,S){return w(S)},JtmhN:s[f(1386)],EZaNC:s.Gnnty,ATHWO:f(816),FAaWy:"error",jbwFr:s.SfPHH,xQVYZ:function(w,S){return w>>>S},leBLu:function(w,S){return w&S},tFXMO:function(w,S){return s[f(1371)](w,S)},QdIln:function(w,S){return s[f(1053)](w,S)},QwsFy:function(w,S){return w<<S},VlaGZ:function(w,S){return w|S},dvQdF:function(w,S){return s.OKMHE(w,S)},JkHSa:function(w,S){return s.LHqka(w,S)},HMsjA:s[f(430)],PBuGJ:s[f(1550)],LLfNc:function(w){return s.CNPVm(w)},cDBKA:s[f(968)],YUhuf:function(w,S){return w(S)},UqUTD:function(w){return w()}},m=()=>{let w=f;if(w(1707)===h[w(417)])n["removeEv"+w(599)+"ner"](h[w(1274)],y),n[w(934)+w(599)+"ner"](h.FAaWy,b);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}/[w(411)](_0x37576a),C=/(([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]))/[w(411)](_0x26b57c);return S?h[w(670)](_0x332629,_0x39ba45):C?h.vKVth(_0x3a715c,_0x54b6df):h.JtmhN}},y=()=>{let w=f,S={SmmVb:h[w(1946)],AFWxP:function(C,I){return h[w(1432)](C,I)},VSUhh:function(C,I){return h[w(1201)](C,I)},TmFJw:function(C,I){return h[w(1084)](C,I)},CxwkH:function(C,I){return h.QdIln(C,I)},VoJim:function(C,I){return h[w(1702)](C,I)},XTdhT:function(C,I){return h.VlaGZ(C,I)},oIKXr:function(C,I){return h.dvQdF(C,I)},jGCUh:function(C,I){return h[w(1367)](C,I)},fHHyQ:function(C,I){return C|I},LVFai:function(C,I){return C<I}};if(h[w(1377)](h[w(614)],h[w(1436)])){let C=4294967295;return function(I,k,L=!0){let B=w,Z=S[B(1585)][B(1950)]("|"),Y=0;for(;;){switch(Z[Y++]){case"0":C=S[B(1542)](C|S.VSUhh(127,I[k])<<7,0);continue;case"1":if((k+=5)>I[B(1955)])throw k=I.length,_0x249ed9(k,10,I[B(1955)]);continue;case"2":if(S.TmFJw(I[k++],128))return{value:L?C:S[B(1228)](0,C),offset:k};continue;case"3":C=S[B(1228)](C,S[B(1840)](S[B(1178)](127,I[k]),21))>>>0;continue;case"4":C=S[B(1729)](C,S[B(921)](S[B(1178)](127,I[k]),14))>>>0;continue;case"5":if(S.TmFJw(I[k++],128))return{value:L?C:S.XTdhT(0,C),offset:k};continue;case"6":C=S.AFWxP(S[B(1178)](127,I[k]),0);continue;case"7":return{value:L?C:S.jGCUh(0,C),offset:k};case"8":if(I[k++]<128)return{value:L?C:0|C,offset:k};continue;case"9":if(S[B(1275)](I[k++],128))return{value:L?C:S.XTdhT(0,C),offset:k};continue;case"10":C=S[B(1048)](C,S.VoJim(15&I[k],28))>>>0;continue;case"11":if(S[B(1007)](I[k++],128))return{value:L?C:0|C,offset:k};continue}break}}}else h[w(670)](c,Te(n[w(1907)])),h[w(917)](m)},b=()=>{let w=f,S={xovih:function(C,I){return C>=I}};if(h[w(1377)](h.cDBKA,h[w(1670)]))h.YUhuf(u,n[w(938)]),h.UqUTD(m);else if(S[w(1684)](_0xc1dbb3,_0x26d79f))return _0x145faa};n[f(1350)+f(1263)](s.kOGBg,y),n[f(1350)+"Listener"](s[f(1900)],b)});return a[e(1722)](c=>{let u=e;s[u(1589)](c,IDBCursor)&&Ur[u(746)](c,n)})[e(459)](()=>{}),Hn.set(a,n),a}function Au(n){let e=A,s={poeOM:"AbortError",sMwqA:e(1028),BRODh:e(938),oNHbO:e(1097),mywrN:function(c){return c()},uChjU:function(c){return c()}};if(Un.has(n))return;let a=new Promise((c,u)=>{let f=e,h={KnQBp:s[f(570)],qyeHV:s.BRODh,JVJet:s[f(1539)],tJyXd:function(w){return s[f(913)](w)},UdOus:function(w){return s[f(1283)](w)}},m=()=>{let w=f;n[w(934)+w(599)+w(484)](h[w(1497)],y),n["removeEv"+w(599)+w(484)](h[w(1592)],b),n["removeEv"+w(599)+"ner"](h[w(737)],b)},y=()=>{let w=f;h[w(1268)](c),h[w(483)](m)},b=()=>{let w=f;u(n[w(938)]||new DOMException(s.poeOM,s[w(1215)])),m()};n[f(1350)+f(1263)](s[f(570)],y),n[f(1350)+f(1263)](s[f(1449)],b),n[f(1350)+f(1263)](f(1097),b)});Un[e(746)](n,a)}function Iu(n){Kn=n(Kn)}function Pu(n){let e=A,s={CRNqd:function(a,c){return a(c)},OMbLH:function(a,c){return a(c)},rhUOw:function(a,c){return a(c)},ZxjZQ:e(941),tuEqh:function(a,c){return a(c)},WBkfJ:function(a,c){return a in c},xBIqv:e(2005),KOEqf:e(1717),QvrxR:function(a){return a()}};if(n===IDBDatabase.prototype["transact"+e(1209)]&&!s.WBkfJ(e(923)+e(1195),IDBTransaction[e(1961)+"e"])){if(s[e(434)]!==s[e(1177)])return function(a,...c){let u=e,f=n[u(1525)](s[u(386)](Vt,this),a,...c);return qr[u(746)](f,a[u(1914)]?a[u(1914)]():[a]),s[u(386)](Te,f)};_0x5f1e3b+=s[e(749)](_0xc4c6e1,_0x5803ec),_0x4e18a4+=2}return s[e(1697)](Eu)[e(1882)](n)?function(...a){let c=e;return n[c(1881)](s[c(749)](Vt,this),a),s.rhUOw(Te,Ur[c(1967)](this))}:function(...a){let c=e;if(s[c(1531)]!==c(941))try{this[c(1416)]?.close(),this._qosDB=void 0}catch(u){_0x309c34[c(1650)](u)}else return s[c(2004)](Te,n.apply(Vt(this),a))}}function ku(n){let e=A,s={WQYea:function(a,c){return a===c},rotxA:"function",oPpqQ:function(a,c){return a(c)},tXwit:function(a,c){return a instanceof c},zBQuj:function(a){return a()}};return s[e(514)](typeof n,s.rotxA)?s[e(1425)](Pu,n):(s.tXwit(n,IDBTransaction)&&s.oPpqQ(Au,n),lo(n,s[e(1711)](Su))?new Proxy(n,Kn):n)}function Te(n){let e=A,s={vraUa:"error",xsjXi:function(c,u,f){return c(u,f)},eJAWH:function(c,u){return c instanceof u},XaoIV:function(c,u){return c+u},JGDrj:function(c,u){return c instanceof u},hNGbE:function(c,u){return c(u)},hXNZj:function(c,u){return c!==u},OrwhV:e(1785),LNciR:e(776)};if(s[e(1243)](n,IDBRequest))return s[e(493)](Cu,n);if(zn[e(1223)](n))return zn[e(1967)](n);let a=s.hNGbE(ku,n);if(s[e(1306)](a,n))if(s.OrwhV===s[e(699)]){let c={hsjBH:s[e(1970)],KNPEQ:function(u,f,h){return s[e(761)](u,f,h)}};if(s.eJAWH(_0x160099,_0x2a1960)){let u=_0x42c5a7[e(919)][e(1983)](_0x1b3940[e(1628)+"et"],s[e(1828)](_0x475421[e(585)+"th"],_0x2c2de6[e(1628)+"et"]));this[e(490)]&&this[e(490)][e(422)]({data:u,fail:f=>{let h=e;this[h(402)](c.hsjBH,c[h(1408)](_0x419fc3,c[h(885)],{message:this[h(1287)+h(1405)+h(882)](f)}))}})}else this[e(490)]&&this[e(490)][e(422)]({data:_0x10d4a5,fail:u=>{let f=e;this[f(402)](c[f(885)],_0x433658(f(938),{message:this[f(1287)+f(1405)+"age"](u)}))}})}else zn.set(n,a),Hn[e(746)](a,n);return a}var lo,oo,ao,Ur,Un,qr,zn,Hn,Kn,Vt,co=fo({"node_modules/idb/build/wrap-idb-value.js"(){let n=A,e={AqQJY:function(s,a){return s instanceof a},VdJny:function(s,a){return s===a},WIwyy:n(923)+"oreNames",ziGph:function(s,a){return s===a},vsohU:n(692),iriKI:function(s,a){return s(a)},vbHGq:n(959),xGSnW:function(s,a){return s===a},BjKLL:function(s,a){return s in a}};lo=(s,a)=>a[n(1788)](c=>s instanceof c),Ur=new WeakMap,Un=new WeakMap,qr=new WeakMap,zn=new WeakMap,Hn=new WeakMap,Kn={get(s,a,c){let u=n;if(e[u(1895)](s,IDBTransaction)){if(e[u(1394)](a,u(959)))return Un[u(1967)](s);if(a===e.WIwyy)return s[u(923)+u(1195)]||qr.get(s);if(e[u(1868)](a,e[u(1521)]))return c[u(923)+"oreNames"][1]?void 0:c[u(923)+"ore"](c["objectSt"+u(1195)][0])}return e[u(686)](Te,s[a])},set(s,a,c){return s[a]=c,!0},has(s,a){let c=n;return s instanceof IDBTransaction&&(e.ziGph(a,e[c(1653)])||e[c(769)](a,e.vsohU))?!0:e.BjKLL(a,s)}},Vt=s=>Hn[n(1967)](s)}}),ho={};vu(ho,{deleteDB:()=>Du,openDB:()=>Tu,unwrap:()=>Vt,wrap:()=>Te});function Tu(n,e,{blocked:s,upgrade:a,blocking:c,terminated:u}={}){let f=A,h={mmfgR:function(b,w,S,C,I){return b(w,S,C,I)},Gjlha:function(b,w){return b(w)},zaKfd:function(b,w){return b(w)},pQosD:function(b,w,S){return b(w,S)},ojoHa:"close",ENqrm:f(857)+f(469),xXcWD:function(b,w){return b(w)},WirXW:function(b,w){return b===w},bGZFn:f(611),qQgga:f(722)+"eeded",lTUhf:f(1612)},m=indexedDB[f(873)](n,e),y=h[f(887)](Te,m);if(a)if(h.WirXW(h[f(1544)],h[f(1544)]))m.addEventListener(h.qQgga,b=>{let w=f;h[w(1825)](a,h[w(1055)](Te,m[w(1907)]),b.oldVersion,b.newVersion,h[w(1170)](Te,m[w(1518)+w(1209)]))});else{let b={ZrHiv:function(w,S,C){return h[f(1485)](w,S,C)}};return new _0x49a568(w=>{let S=f;b[S(1648)](_0x2e0787,w,this[S(1290)+S(1772)+"e"](_0x24af6f))})}return s&&m[f(1350)+f(1263)](h[f(1500)],()=>s()),y[f(1722)](b=>{let w=f;u&&b[w(1350)+w(1263)](h[w(1310)],()=>u()),c&&b["addEvent"+w(1263)](h.ENqrm,()=>c())}).catch(()=>{}),y}function Du(n,{blocked:e}={}){let s=A,a={uQPDm:s(1612),TymPI:function(u,f){return u(f)}},c=indexedDB[s(977)+s(751)](n);return e&&c[s(1350)+"Listener"](a[s(369)],()=>e()),a[s(1642)](Te,c)[s(1722)](()=>{})}function xo(n,e){let s=A,a={ZjzZz:"readwrite",ZxolT:s(1557),ktjxv:s(1009),rqEby:function(m,y){return m!==y},upuWV:function(m,y){return m in y}};if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e===a.ktjxv))return;if(Fn[s(1967)](e))return Fn[s(1967)](e);let c=e[s(1010)](/FromIndex$/,""),u=a[s(504)](e,c),f=po[s(1882)](c);if(!a[s(780)](c,(u?IDBIndex:IDBObjectStore)[s(1961)+"e"])||!(f||go[s(1882)](c)))return;let h=async function(m,...y){let b=s,w=this["transact"+b(1209)](m,f?a[b(1820)]:a[b(1307)]),S=w[b(692)];return u&&(S=S[b(1280)](y.shift())),(await Promise[b(615)]([S[c](...y),f&&w[b(959)]]))[0]};return Fn.set(e,h),h}function T(n,e){n=n-355;let s=qn(),a=s[n];if(T.cXMqET===void 0){var c=function(m){let y="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",b="",w="";for(let S=0,C,I,k=0;I=m.charAt(k++);~I&&(C=S%4?C*64+I:I,S++%4)?b+=String.fromCharCode(255&C>>(-2*S&6)):0)I=y.indexOf(I);for(let S=0,C=b.length;S<C;S++)w+="%"+("00"+b.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(w)};T.TXndFE=c,T.UFhdGh={},T.cXMqET=!0}let u=s[0],f=n+u,h=T.UFhdGh[f];return h?a=h:(a=T.TXndFE(a),T.UFhdGh[f]=a),a}var go,po,Fn,Nu=fo({"node_modules/idb/build/index.js"(){let n=A,e={oSzWC:"add",MHKfg:n(409),Nhvjg:n(962),BaDnY:function(c){return c()},InROR:function(c){return c()},ZefOl:function(c,u){return c(u)},eXwIu:n(1967),WSjRp:n(1743),kCLYc:n(839),LnIgh:"count"},s=(n(1850)+n(1457))[n(1950)]("|"),a=0;for(;;){switch(s[a++]){case"0":po=["put",e[n(1777)],e[n(848)],e[n(768)]];continue;case"1":e[n(1906)](co);continue;case"2":Fn=new Map;continue;case"3":e[n(929)](co);continue;case"4":e[n(1770)](Iu,c=>({...c,get:(u,f,h)=>xo(u,f)||c.get(u,f,h),has:(u,f)=>!!xo(u,f)||c[n(1223)](u,f)}));continue;case"5":go=[e.eXwIu,e[n(770)],e[n(549)],"getAllKeys",e[n(1168)]];continue}break}}}),Ru={idb:function(n){let e=A;n.exports=Promise.resolve()[e(1722)](()=>(Nu(),ho))[e(1722)](function(s){return s})}},uo={};function ke(n){let e=A,s={suHrj:"4|0|3|2|1"},a=s[e(556)].split("|"),c=0;for(;;){switch(a[c++]){case"0":if(f!==void 0)return f[e(418)];continue;case"1":return u.exports;case"2":Ru[n](u,u[e(418)],ke);continue;case"3":var u=uo[n]={exports:{}};continue;case"4":var f=uo[n];continue}break}}ke.d=(n,e)=>{let s=T;for(var a in e)ke.o(e,a)&&!ke.o(n,a)&&Object["definePr"+s(893)](n,a,{enumerable:!0,get:e[a]})},(()=>{let n=A;ke.o=(e,s)=>Object[n(1961)+"e"][n(716)+n(893)].call(e,s)})(),(()=>{let n=A,e={OOxVG:function(s,a){return s!=a},DCfkC:n(1217)+"d",qjhUG:"Module",cpmcS:"__esModule"};ke.r=s=>{let a=n;e.OOxVG(e[a(1713)],typeof Symbol)&&Symbol[a(905)+a(1352)]&&Object[a(489)+"operty"](s,Symbol[a(905)+a(1352)],{value:e.qjhUG}),Object[a(489)+a(893)](s,e[a(890)],{value:!0})}})();var X={};(()=>{let n=A,e={lPAik:function(i,t){return i(t)},lDJhc:function(i,t){return i+t},gpCYi:function(i,t){return i<t},QxxWj:function(i,t){return i(t)},klqNI:n(891),kXuJX:function(i,t){return i*t},QjziE:function(i,t){return i+t},UgpBM:function(i,t){return i(t)},ANApR:function(i,t){return i(t)},xrSeV:function(i,t,r){return i(t,r)},VuxWF:function(i,t){return i(t)},lLNQs:n(1545),SEYZA:n(441),xdorY:function(i,t){return i===t},HrwrP:n(1056),eVWQn:function(i,t){return i(t)},JeLnB:n(1588)+n(1588)+"00000000"+n(1588),JEpgP:function(i,t){return i||t},fcBgz:function(i,t){return i||t},VUATY:function(i,t){return i||t},cwrBd:"undefined",diJHJ:function(i,t){return i||t},CszVy:function(i,t){return i!=t},iNFxk:n(902)+n(1229)+"d",eRjBl:function(i,t){return i!==t},kujFV:function(i,t){return i>>>t},NFgjq:function(i,t){return i>t},BrRvQ:function(i,t){return i>t},ADaul:n(1679),DhnVk:n(814),vliOo:function(i,t){return i-t},tRTzC:n(793),dHhbL:function(i,t){return i<t},YoUQK:function(i,t){return i<t},zUgeT:function(i,t,r){return i(t,r)},dczVs:function(i,t){return i===t},lAqSO:n(1289),GdSpE:function(i,t){return i(t)},TbHGQ:function(i,t){return i>>>t},QMVif:function(i,t){return i(t)},enDOU:function(i,t,r){return i(t,r)},GNIDB:function(i,t){return i&t},gysyr:function(i,t){return i===t},VmDQO:"Missing "+n(1535)+n(568)+n(1699),LsTTH:function(i,t){return i|t},UFtll:function(i,t){return i>>>t},BdTRr:function(i,t){return i|t},glIDs:function(i,t){return i<<t},bwgcZ:function(i,t){return i|t},zzylU:function(i,t){return i|t},zAcvW:function(i,t){return i&t},KNwbI:function(i,t){return i|t},dAbMd:function(i,t){return i<t},EBlQH:function(i,t){return i===t},ktdea:n(604),YbbPo:function(i){return i()},QccVU:function(i,t){return i(t)},VVFjI:function(i,t){return i==t},ligxU:n(512),AWgLJ:"wss://",DmaqL:n(1658),mVNzN:function(i,t){return i(t)},Gjteu:function(i,t,r){return i(t,r)},BcZhJ:function(i,t){return i>>t},FSOcq:"DqStP",PuekS:function(i,t,r){return i(t,r)},yNSYc:function(i,t,r){return i(t,r)},kbPzi:function(i,t,r){return i(t,r)},atsbE:function(i,t){return i===t},YFjRV:"MXtjY",oOynp:n(1057),YGZjX:function(i,t){return i(t)},LYVEF:function(i,t){return i!==t},gLDDG:function(i,t,r){return i(t,r)},jgAHK:function(i,t,r){return i(t,r)},YxioH:function(i,t){return i(t)},veYXW:function(i,t){return i!==t},jRERO:function(i){return i()},tVtSx:function(i,t,r){return i(t,r)},CzOjO:function(i,t){return i!==t},unClg:function(i,t,r){return i(t,r)},wTSHr:function(i,t,r){return i(t,r)},kgGHS:function(i,t,r){return i(t,r)},aYCTv:n(391),aHopm:function(i,t,r){return i(t,r)},WZPqS:function(i,t){return i!==t},FwZJN:function(i,t){return i!==t},MqVhc:n(1641),eRJRp:function(i,t,r){return i(t,r)},QnSCx:function(i,t){return i!==t},MfoBh:function(i,t){return i!==t},GCLiT:n(778),PtwVE:function(i,t){return i(t)},DrfdO:"rdwwf",YxuZq:function(i,t,r){return i(t,r)},dUwOE:function(i,t){return i(t)},wtWVh:function(i,t,r){return i(t,r)},VBQtg:function(i,t){return i(t)},lpTFF:function(i,t){return i(t)},vbcEy:function(i,t,r){return i(t,r)},yqlcW:function(i,t){return i(t)},ZheRZ:function(i,t){return i&t},iGUhJ:n(1655)+n(1535)+" field: "+n(1247),SrzFK:function(i,t){return i===t},liFiF:n(1655)+n(1535)+" field: service",yZDTi:"Missing "+n(1535)+n(568)+n(1331),qWEou:function(i,t){return i+t},kCCoC:function(i,t){return i&t},ymxnl:function(i,t){return i(t)},qjnDt:n(610)+n(1860)+n(1987),iDhKX:function(i,t){return i===t},GlDbL:function(i,t){return i===t},kOGlN:n(2e3),aEbEt:n(1224)+n(1108)+"s",dlXGM:n(816),mTvde:function(i,t){return i===t},vvfsx:"LjWbL",jyxoD:n(724),VXixN:function(i,t){return i>>t},xvVlB:function(i,t){return i>=t},mnHrR:function(i,t){return i!==t},hGNgM:n(1214),WyZNx:function(i,t){return i==t},SSEgN:n(1009),enEms:function(i,t){return i!==t},Qezge:n(1969),lYhYD:n(1071),xQxYP:"Read past limit",CGAgB:function(i,t){return i+t},ILqsQ:function(i,t){return i===t},JjExE:n(1513),AvoFs:n(673),BKpxA:function(i,t){return i===t},JXZOU:function(i,t){return i&t},byfDM:function(i,t){return i>=t},dJfVT:function(i,t){return i+t},Hodjf:function(i,t){return i<<t},ZytnA:function(i,t){return i<t},ulrTT:function(i,t){return i(t)},syLnK:function(i,t){return i==t},nmczP:function(i,t){return i+t},YzAzr:function(i,t){return i+t},xFjDn:function(i,t){return i!==t},DGKIV:function(i,t){return i&t},JrvXI:function(i,t){return i|t},EJlDN:function(i,t){return i&t},xfaun:function(i,t){return i<<t},VayPa:function(i,t){return i&t},pWlAs:function(i,t){return i<t},BxNhy:function(i,t){return i<=t},FZPDq:function(i,t){return i==t},DMowE:function(i,t){return i&t},qDKXN:function(i,t){return i+t},cKUgs:function(i,t){return i&t},TWgie:function(i,t){return i<<t},zYqtA:function(i,t){return i|t},tuWUX:function(i,t){return i&t},foCTi:function(i,t){return i<t},aMpgG:function(i,t){return i>t},qIryu:function(i,t,r){return i(t,r)},KyXER:function(i,t){return i>>t},cfslQ:function(i,t){return i+t},WiwZG:function(i,t){return i<t},pPgNg:function(i,t){return i<<t},wMgUl:function(i,t){return i<t},WJkAX:function(i,t){return i<t},QTPAy:function(i,t,r){return i(t,r)},NZQyq:function(i,t){return i<t},XPtHg:function(i,t){return i+t},shOMY:function(i,t){return i<<t},pLEwp:function(i,t){return i|t},foFAb:function(i,t){return i>>t},PgBYz:function(i,t){return i!==t},GJLEI:n(1635),AZYxl:n(1098),zxgKw:function(i,t){return i|t},GxXZj:function(i,t){return i>>t},idUvP:function(i,t){return i|t},VpXIF:function(i,t){return i&t},ljMsD:function(i,t){return i|t},dwxuj:function(i,t){return i>>t},zrdaL:function(i,t){return i|t},nCDmf:function(i,t){return i&t},NPUlp:function(i,t){return i+t},kTZLH:function(i,t){return i+t},jNTaW:function(i,t){return i&t},PVtkz:function(i,t){return i|t},wRmLY:function(i,t){return i<<t},REnxt:n(1455),Zecpm:function(i,t,r){return i(t,r)},LxWqi:function(i,t){return i<<t},GXToH:function(i,t){return i&t},IXsiL:function(i,t,r){return i(t,r)},fupQB:function(i,t){return i(t)},ZSwxA:function(i,t){return i>t},JYUGc:function(i,t){return i(t)},sdtzR:function(i,t){return i+t},ODYun:function(i,t){return i|t},QsTLo:function(i,t){return i||t},LIZYu:function(i,t){return i>>>t},vLlSk:function(i,t){return i===t},duhmN:"AgKbe",JOIuF:function(i,t){return i(t)},cvNXc:function(i,t){return i&t},sIekH:function(i,t){return i&t},xdkEa:function(i,t){return i<<t},XpvOX:function(i,t){return i&t},qpRlF:n(806),EIGpi:n(501),agAwf:function(i,t){return i&t},xgTfA:function(i,t){return i(t)},yHdWE:function(i,t){return i&t},PDmFi:function(i,t){return i(t)},HVNxM:function(i,t){return i&t},YaNwm:function(i,t){return i<<t},klzQY:function(i,t){return i&t},hOPhq:function(i,t){return i(t)},oTJfd:function(i,t){return i&t},uduok:function(i,t){return i(t)},MGSgH:function(i,t){return i&t},uJwQG:n(580),Ndecy:function(i,t){return i&t},AkUcg:function(i,t){return i<<t},tqUVt:function(i,t){return i|t},ByhtP:function(i,t){return i>>>t},tKwna:function(i,t){return i<<t},pLpNW:function(i,t){return i|t},gCvDq:function(i,t){return i>>>t},eTpon:function(i,t){return i===t},YkLQD:function(i,t){return i<t},qomKf:function(i,t){return i<t},ttojU:function(i,t){return i<t},CIUQy:function(i,t){return i<t},ePlnl:function(i,t){return i+t},abKzA:function(i,t){return i+t},YJQiu:function(i,t){return i|t},hXpWT:function(i,t){return i&t},JJoYf:function(i,t){return i!==t},PbgqT:function(i,t){return i>>>t},dZTZK:function(i,t){return i>>>t},UxQUC:function(i,t){return i>>>t},iEuhY:function(i,t){return i>>>t},dakzE:function(i,t){return i+t},JQqPe:function(i,t){return i>>>t},DFtNS:function(i,t){return i&t},ZYvmc:function(i,t){return i+t},voCpP:function(i,t){return i!==t},KvlRC:function(i,t){return i!==t},fhmww:function(i,t){return i|t},uPWNs:function(i,t){return i&t},WmiZq:function(i,t){return i!==t},CvoUD:function(i,t){return i|t},psGHZ:function(i,t){return i&t},FRTmL:function(i,t){return i>>>t},wHDEX:function(i,t){return i!==t},ILcus:function(i,t){return i|t},gdbjS:function(i,t){return i&t},dZmeP:function(i,t){return i===t},ZHPKE:"bye",WDcZc:n(1396),rsQHW:function(i,t){return i|t},rkvLJ:function(i,t){return i<<t},NTSqD:function(i,t){return i|t},sJmCz:function(i,t){return i<<t},QRhhL:function(i,t){return i<<t},Ltkwm:function(i,t){return i|t},UFkLZ:function(i,t){return i<<t},PTpUg:function(i,t){return i!==t},mXYUR:n(592),ngMoo:function(i,t){return i===t},UXJHg:function(i,t){return i<<t},BMlTl:function(i,t){return i<<t},zMzfe:function(i,t){return i<<t},bbOVz:function(i,t){return i<<t},bPnmA:function(i,t){return i<<t},MzbsW:function(i,t){return i<<t},ccQHt:function(i,t){return i&t},mpsKj:function(i,t){return i>>>t},uszdo:function(i,t){return i>>>t},janBg:function(i,t){return i+t},NGGRL:function(i,t){return i%t},xOJfl:function(i,t){return i|t},wKyDP:function(i,t){return i*t},TrKtb:function(i,t){return i>>>t},axFUB:function(i,t){return i>>>t},itqNO:function(i,t){return i*t},OsqiP:function(i,t){return i===t},SmFPz:function(i,t){return i>>>t},vdXVq:function(i,t){return i&t},fxpNr:function(i,t){return i>>>t},fvUJV:function(i,t){return i&t},SavPw:function(i,t){return i&t},vCiKX:function(i,t){return i+t},kvKRo:function(i,t){return i+t},XAosf:function(i,t){return i>>>t},kCKZM:function(i,t){return i+t},yfeAR:function(i,t){return i>>>t},cnify:function(i,t){return i<<t},GOJxQ:function(i,t){return i===t},cbIFT:function(i,t){return i>>>t},qpKCj:function(i,t){return i===t},eCJTy:n(436),HupnJ:function(i,t){return i===t},PQfhO:function(i,t){return i+t},fqxxL:n(944),djLvF:function(i,t){return i&t},dpZQB:function(i,t){return i&t},DtBGH:function(i,t){return i>>>t},SWGyt:function(i,t){return i&t},xdrcU:function(i,t){return i&t},ZwZrA:function(i,t){return i>>>t},zuBiO:function(i,t){return i>>>t},nIpSY:function(i,t){return i&t},UQXjh:function(i,t){return i&t},skhEg:function(i,t){return i&t},mMFFq:"NATIVE_ERROR",jTiTu:n(947)+"NG_ERROR",bZPPl:n(1070)+n(1291)+"R",RxpHa:n(1839)+n(1378),rSZmD:n(449)+"1",YPKEe:function(i,t){return i>>>t},yoxOL:function(i,t){return i>>>t},lTgIS:n(1757),SVfyr:"cdTUV",rnpYP:function(i,t){return i===t},ioqXC:function(i,t){return i-t},fKjgw:function(i,t){return i===t},CynCl:function(i,t){return i instanceof t},chvnC:n(1107)+n(668),GrION:function(i,t){return i+t},LEJgW:function(i,t){return i-t},VXPTw:n(1957),Ewndp:n(938),gcKqQ:n(1887),doTaf:function(i,t){return i===t},cCxkZ:n(683),NylEp:"open",gKVBr:function(i,t,r){return i(t,r)},Isihg:n(534),mMRCq:n(1569),MBYrI:function(i,t,r){return i(t,r)},TPNRS:function(i,t,r){return i(t,r)},ktKrq:"iwXET",HQMmH:function(i,t){return i+t},LBCqu:function(i,t){return i===t},dmyhp:n(1979),gayJu:"GEjiv",pHbTv:function(i,t){return i||t},gySUY:n(1020)+"4",hHEFP:function(i,t){return i||t},gHGve:function(i,t){return i!=t},zJChT:n(957)+"alled mu"+n(866)+n(888)+"process",ZrEgH:function(i,t){return i+t},eqwTR:function(i,t){return i<t},RyOuD:function(i,t){return i===t},Pkbwe:function(i,t){return i&t},LHAge:function(i,t){return i|t},DvfPp:function(i,t){return i|t},ICowU:function(i,t){return i&t},RAwTY:function(i,t){return i&t},twuBB:function(i,t){return i-t},HKJwG:function(i,t){return i|t},hVgIt:function(i,t){return i&t},OKYDd:function(i,t){return i&t},LIQKj:function(i,t){return i>>t},esVno:function(i,t){return i|t},gpDBZ:function(i,t){return i|t},bbsWL:function(i,t){return i&t},ASLQG:function(i,t){return i===t},tgPtp:function(i,t){return i+t},MkLDB:n(1999)+n(1137),IwERR:function(i,t){return i|t},vTQAw:function(i,t){return i|t},VKMbY:function(i,t){return i>>t},KwqOa:function(i,t){return i<t},Svsfw:n(687),bhJgy:function(i,t){return i|t},TMgNH:function(i,t){return i===t},IXXDK:function(i,t){return i===t},puwyw:function(i,t){return i+t},DzgIq:function(i,t){return i>>t},flhsM:function(i,t){return i&t},mXrJo:function(i,t){return i&t},qqjmA:function(i,t){return i!==t},USfmV:"JQhWd",szDWo:"OhCFI",Jkgmy:function(i,t){return i>>t},ldENV:function(i,t){return i&t},Nekxk:function(i,t,r,o){return i(t,r,o)},imgRA:function(i,t){return i instanceof t},PFPgN:function(i,t){return i|t},KKleO:function(i,t){return i<<t},dMgjz:function(i,t){return i<<t},ehoNp:function(i,t){return i instanceof t},usyik:n(817)+"ion/json",SyOwr:n(1880),Jwjiw:function(i,t){return i==t},wSuwT:"text/pla"+n(1677)+n(937),TxRkn:n(1467),UyzVR:"ppe",JKeHg:function(i,t){return i>=t},EEnmy:function(i,t){return i|t},jDLmH:function(i,t){return i!==t},GSwDA:n(1082),msltO:"APMYH",hDqoM:function(i,t){return i!==t},HznAD:n(622),yDxmz:n(1014),sFqlC:"script",ReTFe:"text/jav"+n(1141),bWRVl:n(1354)+n(1308)+n(775)+"P",dYEYU:function(i,t){return i!==t},LkDBe:n(1363),KNWUw:n(1160),AUsHK:n(951)+"reason",NPndy:n(659),ZhMNA:n(1991),ieNsd:n(1153)+n(782)+n(1627),zyjzT:" + ",DLasc:function(i,t){return i||t},iZqCa:n(552),TSsBI:function(i,t){return i===t},cYpCo:n(1505),IVbVN:n(1442),NWaiQ:function(i,t){return i!==t},pcPXj:n(1954),nXSTO:n(1039),HOhfP:function(i,t){return i===t},laRTq:n(1124),qjyQW:function(i,t){return i===t},qNcfx:n(799),tDyVe:n(1297),zlmke:n(1644),sFqfF:function(i,t){return i+t},NbVvJ:function(i,t){return i+t},hEwKj:function(i,t){return i+t},ijRKf:function(i,t){return i+t},CLfCt:function(i,t){return i+t},ETDHt:function(i,t){return i&t},PCVLI:function(i,t){return i&t},uPOiB:function(i,t){return i&t},gLtEQ:function(i,t){return i<t},ujgPk:n(635),OwPlN:function(i,t){return i||t},GXDvB:function(i,t){return i<t},yBhsD:function(i,t){return i+t},FPaIZ:"Waivk",TNBTj:n(1023),pzdxL:function(i,t){return i||t},VHVXV:function(i){return i()},oeJjQ:n(861),AffKk:function(i,t,r){return i(t,r)},msFQU:function(i,t){return i!==t},VEZKE:n(1329),JFPkp:n(1025),acjhZ:function(i,t){return i||t},sPiOV:n(480),IXsrL:function(i,t){return i||t},Bxqsj:"qos",hIyUj:n(387)+"id",beWvL:n(439),lBhJX:n(1028),ZBjSz:n(1097),KQooj:function(i){return i()},tLllI:function(i,t){return i!==t},kIevv:"xLYlC",Agypg:n(1626),GwPBB:n(1194),iEqnU:n(1174),nXpQl:function(i,t){return i===t},unmsJ:"fCxxC",febbu:n(1758),kyiXd:function(i,t,r,o,x){return i(t,r,o,x)},MvPfZ:function(i,t){return i(t)},cYalZ:function(i,t){return i!==t},KAblV:n(1411),PnBIh:function(i,t){return i(t)},qONdy:n(987)+"er_qos",xnFvq:n(987)+n(1051)+"ck",bitne:n(987)+n(1798)+"k",nGnFM:n(987)+n(1511)+n(1594),GXEJS:"need_ack",yWKCP:n(1299),rQheA:n(1086),FBgAP:n(1523),iohFv:function(i,t){return i instanceof t},wsuHj:n(817)+n(1251)+n(1300)+"=utf-8",RqeaJ:n(945)+"e",kYfly:"binary",MNnFX:function(i,t,r,o){return i(t,r,o)},GaEIz:function(i,t){return i>t},TveQp:function(i,t){return i|t},eJGuF:function(i,t){return i===t},ciUsd:n(1494),rgVqK:function(i,t,r){return i(t,r)},cwukB:function(i,t){return i<<t},NatsY:function(i,t){return i===t},vpqwE:n(1948),kqgLB:function(i,t){return i+t},XJkEZ:function(i,t){return i+t},xEpPi:function(i,t){return i+t},egUZA:function(i,t){return i||t},XHnKj:n(561)+n(1096)+"e",SNJoL:function(i,t){return i>=t},CmmSV:function(i,t){return i+t},gVdGA:function(i,t){return i<t},UnJoP:function(i,t){return i<<t},ksoxM:n(976)+"0",HODVo:function(i,t,r,o){return i(t,r,o)},GEBBH:function(i,t){return i|t},rTBuZ:function(i,t){return i+t},nKrWh:function(i,t){return i<<t},pBRdK:function(i,t){return i+t},owTjf:function(i,t){return i+t},WErxU:function(i,t){return i+t},umrKL:function(i,t){return i+t},EMpOe:function(i,t){return i&t},jGPFy:function(i,t){return i>>>t},toIsI:function(i,t){return i&t},gwuxI:function(i,t){return i+t},czXww:function(i,t){return i&t},ksoNz:function(i,t){return i+t},ZQawz:function(i,t){return i(t)},zfFix:function(i,t){return i+t},oxcLJ:function(i,t){return i!==t},wibct:function(i,t){return i&t},jpWSe:function(i,t){return i<t},XjJON:function(i,t){return i&t},RNuQW:function(i,t){return i>>>t},ZhEeR:function(i,t){return i&t},CpIbY:function(i,t){return i>>>t},vlszd:function(i,t){return i<<t},vtCML:function(i,t){return i|t},AqHrp:function(i,t){return i>>>t},oEjVf:n(1083),edjyL:function(i,t){return i<t},tUZVH:n(657),zndnZ:function(i,t,r,o){return i(t,r,o)},HFJva:n(1105),UVWwZ:n(755)+"ile_name",ppZFn:function(i,t,r){return i(t,r)},xLHYl:function(i,t,r){return i(t,r)},QrJBT:function(i,t,r,o){return i(t,r,o)},WrHeH:function(i,t){return i+t},SzXEP:n(827),rIoOa:n(569)+"_EXIST",ogkiI:"cursor_n"+n(1285),IpzJe:n(1336)+"rValues",eNGrp:n(563),EaTym:"INSTANT",KMTRc:function(i){return i()},stbdP:function(i,t){return i!==t},lSKLY:n(1227),QEgCF:n(791),uBVCy:"iRWWD",WNEKs:"YXEQL",YtsCv:function(i,t){return i===t},pKKRu:n(1784),sJVpL:n(1049),DKaCZ:n(442),nKRBE:function(i,t,r,o){return i(t,r,o)},RpKgh:function(i,t){return i(t)},SQJtT:function(i,t,r){return i(t,r)},iKIzG:n(987)+n(1202),jelTr:function(i,t,r,o){return i(t,r,o)},wDoWQ:n(784)+"s",SDJtd:n(380)+n(363)+"e",sYGfn:n(380)+n(1859)+"ue",qXYwx:n(742),PBkmA:function(i){return i()},YxaNN:function(i,t){return i&&t},kYafb:n(630),UTGWJ:n(1818),Fxyqa:function(i,t){return i(t)},XrZXz:function(i,t){return i!==t},jDHRB:function(i){return i()},bmAFU:"wiZET",tktXd:function(i,t,r){return i(t,r)},RAHdb:function(i,t){return i===t},hNdJv:function(i,t){return i===t},TBLte:function(i,t){return i(t)},rGVlB:function(i,t,r){return i(t,r)},eClqk:function(i,t){return i!==t},lnrQd:n(1765)+n(1103),oECAz:n(406),VJaVe:function(i,t){return i/t},Ckecg:n(1385),IgWHE:function(i,t){return i==t},FZVAP:n(1733)+n(1853)+n(1752),tDRHw:function(i,t){return i(t)},qzGdE:n(1733)+n(1732)+"s params"+n(407)+n(1463)+n(886)+"is undef"+n(1495),toQbm:function(i,t,r){return i(t,r)},JbptV:n(1913)+"t",SGaeP:n(1001)+n(1871)+n(1112)+"ct",RvzuU:"online",vFmtO:n(1763),zelUe:n(1204),AHoOP:n(1400),HhZmD:function(i,t){return i!==t},zvkjn:function(i,t){return i===t},yutEO:function(i,t){return i<t},ZYxGi:function(i,t){return i*t},UPnHC:function(i,t){return i!==t},xxbBk:"IhZXk",FtkuC:n(649),iugyP:function(i,t){return i==t},sjvPJ:n(590),qAWzR:n(1155),UMfND:n(553),gogMz:n(1733)+n(1171)+"ddID, deviceID o"+n(1865),VOwsC:function(i){return i()},KlSKq:n(1126),fzoPf:n(1851)+"0",IZzym:n(1121),EDvuN:function(i,t){return i!==t},yrPom:n(763),VrXZb:function(i,t){return i(t)},OiYWa:n(1423)+">",IqpTg:n(972)+n(628),LmKUl:n(1976)+"s instan"+n(1609)+n(786)+"ed",JIDuh:"close, w"+n(1994)+n(1682),SKWIZ:n(1389),CgPNJ:"fzbtV",eMejn:function(i,t){return i*t},giyBl:function(i,t){return i>t},FOqpo:function(i,t,r){return i(t,r)},ukeBR:function(i,t){return i===t},AzCsa:n(1224)+n(1837)+"t",nRxLC:"timeout",NYhOc:n(361)+n(1920)+n(1913)+n(1918)+n(1647),kPKeW:function(i,t){return i<<t},CGXVd:function(i,t){return i<t},uKdfe:function(i,t){return i===t},ZPLmi:n(1148),ZSaCf:n(1812),DzClG:n(1474)+n(875)+n(374)+"g",atYRs:function(i,t){return i===t},CRbMw:n(1036),RKbKH:"0|3|4|1|2",afSRi:"3|1|2|4|0",deFqb:function(i,t){return i<=t},mvcrx:function(i,t){return i<<t},ucoEE:function(i,t){return i&t},hUCaB:function(i,t){return i&t},QITWk:n(583),GVHjn:function(i,t,r){return i(t,r)},eKDmL:function(i,t,r){return i(t,r)},cLNLE:function(i,t,r){return i(t,r)},Fhnif:n(361)+n(1984)+n(1027)+n(704),QuzTp:function(i,t){return i(t)},mDOYh:n(526),EteSM:function(i,t){return i!==t},UyBWJ:n(1477),SxqcY:function(i,t,r){return i(t,r)},dpSyx:n(852),tWoRk:n(743),fPPWB:function(i,t){return i|t},VnVTl:function(i,t){return i>t},SrAkn:function(i,t){return i+t},gfZar:function(i,t){return i+t},JxbxG:"cywUV",qjvuD:n(1362),NkJrq:function(i,t){return i+t},XYjQu:function(i,t){return i!==t},EMUbZ:n(1964),RnbXF:n(365)+n(1937),AfDaC:function(i,t){return i===t},hXFPu:function(i,t){return i+t},RMIMv:"ctyAm",EqanM:"aqDkl",GNLHX:function(i,t){return i==t},YkTiy:n(1733)+n(1995)+n(1026)+n(894)+"a must b"+n(689)+n(517)+n(1582)+n(963),URcsN:n(1556),otcYj:function(i,t){return i instanceof t},tngKN:n(1733)+"rovide a"+n(1909)+"ervice",CWZIj:function(i,t){return i instanceof t},GrkkR:function(i,t){return i<t},IvlOz:"hdGok",BsXvc:function(i,t){return i==t},neNIz:n(1978)+n(1422)+n(1437),FzPCz:n(822)+"1",DkJeD:function(i,t){return i===t},Rxrhz:"XuibA",bcMTX:n(1852),rCDuN:n(1493),sXATB:function(i,t){return i(t)},wAJag:function(i,t){return i(t)},BbJab:n(1145),NJYeJ:function(i,t){return i*t},YdNht:function(i,t){return i/t},yoSzK:function(i,t){return i!=t},QJdZW:n(579),ZGoJg:function(i,t){return i!=t},rUwiW:function(i,t){return i===t},FpUmL:"Object",BvrOL:function(i,t){return i===t},EHtbo:"Dedicate"+n(392)+n(1359)+"pe",WNnAK:function(i,t){return i!=t},wKXYg:function(i,t){return i!=t},rZBzb:function(i,t){return i!=t},rVpld:function(i,t){return i===t},NcbqM:function(i,t){return i!=t},oafnY:function(i,t){return i===t},MuySS:function(i,t,r){return i(t,r)},otKRT:n(1235)+"qos__"};ke.r(X),ke.d(X,{FWS:()=>q0,CustomErrorEvent:()=>Ii,createCloseEvent:()=>ye,ReconnectEvent:()=>Ai,createErrorEvent:()=>pe,decodedFrame:()=>Re,createOpenEvent:()=>Ri,CustomCloseEvent:()=>Pi,createReconnectEvent:()=>pr,FrontierMessageEvent:()=>Ti,encodeFrame:()=>gr,createMessageEvent:()=>Ni,OpenEvent:()=>Di,ErrorCode:()=>je,Event:()=>lt,MessageEvent:()=>ki});let s="";function a(i=""){let t=n,r="02",o=""+Date[t(1546)](),x=s||(s=e[t(1221)](m,i)),l=Math[t(1683)]().toString(16).slice(-6);return e[t(1578)](e[t(1578)](e[t(1578)](r,o),x),l)}function c(){let i=n;if(e[i(841)]===e[i(841)])return e[i(1753)](1e4,Date.now())+Math[i(1718)](1e4*Math.random());{let t=0,r={};for(let o=0;e.gpCYi(o,_0x36722e[i(1955)]);o++)r[_0x485525[o][i(1805)+"ame"]]=e.QxxWj(_0x460ddf,_0x12c185[o][i(1805)+i(1285)]),t+=14+r[_0x471409[o][i(1805)+i(1285)]];return[t,r]}}function u(i){let t=n;return e[t(1332)](e.UgpBM(Array,8)[t(1875)]("0"),parseInt(i,10)[t(905)](2)).slice(-8)}function f(i){let t=n;return e[t(1578)](e[t(371)](Array,4)[t(1875)]("0"),e[t(997)](parseInt,i,2).toString(16))[t(1983)](-4)}function h(i){let t=n,r=i.split(/\./)[t(1734)](l=>u(l)),o=[];return o[0]=e[t(1935)](f,r[0]+r[1]),o[1]=f(e.lDJhc(r[2],r[3])),[e[t(384)],e[t(384)],"0000",t(1545),t(1545),e[t(899)],o[0],o[1]][t(1875)]("")}function m(i){let t=n;if(e[t(1912)]("BODXN",e[t(1727)]))this[t(1157)+"ndex"]=0,this[t(1355)+"ndpointT"+t(1720)+"t"]=0;else{let r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(411)](i),o=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[t(411)](i);return r?e[t(371)](h,i):o?e[t(1989)](y,i):e.JeLnB}}function y(i){let t=n,r={owcfF:function(_,v){return e[T(1786)](_,v)},HKMTb:function(_,v){return e[T(1912)](_,v)},Mtodp:function(_,v){return e[T(1963)](_,v)}},o="",x=[],l=0,g=0,p=!0,d="0000";if(e[t(420)](i[t(1315)]("::"),-1)){let _=i.split("::");for(let P=0;e.gpCYi(P,_[t(1955)]);P++)if(t(1387)===t(1387)){let O=_[P];if(e[t(705)](O[t(1315)](":"),0)){let R=O[t(1950)](":");p&&(l=R[t(1955)]),g+=R[t(1955)];for(let G=0;e[t(1094)](G,R.length);G++)if(e.eRjBl(4,R[G][t(1955)]))if(e.ADaul===e[t(1008)]){let se=this[t(1416)][t(1383)+t(566)](this[t(1883)]),K=_0x1a311a.parse(e[t(1197)](se,"{}"));return K[_0x111ba3]=void 0,this[t(1416)][t(1258)+t(566)](this._prefix,_0x5bd267[t(854)+"y"](K))}else{let se=d[t(1715)+"g"](0,e[t(829)](4,R[G][t(1955)])),K=se[t(1520)](R[G]);x[t(1567)](K)}else x.push(R[G]);p=!1}else if(e[t(1786)](t(431),e[t(1942)])){if(e[t(1786)](4,O[t(1955)])){let R=d[t(1715)+"g"](0,e[t(829)](4,O[t(1955)])),G=R[t(1520)](O);x[t(1567)](G)}else x.push(O);p&&(l+=1),g+=1,p=!1}else{if(e[t(1042)](_0x2820cb,_0x109f77))return new _0x5751bf(_0x3e7e35,_0x4b39cf);if(e[t(451)](_0x3ca458,_0x2b622a)&&e[t(444)]!=typeof _0x5aba24)return new _0x3cf7d1(_0x16f1c2,_0x31137f);if(e[t(588)](_0x22d54d,_0x4cb9b7)&&e[t(1719)](e.cwrBd,typeof _0x2aac56))return new _0x556458(_0x3ce2af,_0x511ffb);throw new _0x266509(e[t(1848)])}}else return _0x5e1587[t(1309)](_0x2b661d)||(_0x5d1d19=_0x1a8856[t(1222)+"er"](_0x19a841)),r[t(1116)](this[t(718)],_0x501e76[t(718)])&&r[t(1827)](r[t(632)](this[t(837)],31),1)&&r.Mtodp(_0x1452f8[t(837)],31)===1?!1:r[t(1827)](this[t(837)],_0xf241b3[t(837)])&&r.HKMTb(this[t(1438)],_0x276d06[t(1438)]);let v="";for(let P=0;P<e[t(829)](8,g);P++)v=v[t(1520)](d);for(let P=0;e.dHhbL(P,x[t(1955)]);P++)e[t(1912)](P,l)&&(o=o[t(1520)](v)),o=o[t(1520)](x[P]);return o}{let _=i[t(1950)](":");for(let v=0;e[t(1971)](v,_[t(1955)]);v++){let P=_[v];if(e.eRjBl(4,_[v][t(1955)])){let O=d[t(1715)+"g"](0,e.vliOo(4,_[v][t(1955)])),R=O[t(1520)](P);o=o[t(1520)](R)}else o=o[t(1520)](P)}return o}}function b(i,t){let r=n,o=i.key;e[r(1786)](void 0,o)&&(e[r(997)](Q,t,10),e[r(707)](Se,t,o));let x=i[r(1699)];if(e[r(1786)](void 0,x)){if(e[r(1011)](e[r(364)],r(1459)))return r(1003)+"_"+this._DBName;Q(t,18),e[r(997)](Se,t,x)}}function w(i){let t=n,r={};e:for(;!e.GdSpE(U,i);){let o=ie(i);switch(e.TbHGQ(o,3)){case 0:break e;case 1:r[t(812)]=we(i,ie(i));break;case 2:r[t(1699)]=e[t(997)](we,i,e.QMVif(ie,i));break;default:e[t(1033)](B,i,e[t(1724)](7,o))}}if(r[t(812)]===void 0)throw new Error("Missing "+t(1535)+t(568)+t(812));if(e[t(1166)](void 0,r[t(1699)]))throw new Error(e.VmDQO);return r}function S(i){let t=n,r={tbqcb:t(994)+t(505)+"6|7|2|5|9",FuTJq:function(o,x){return e[t(634)](o,x)},uUouK:function(o,x){return e[t(731)](o,x)},QLopK:function(o,x){return e[t(472)](o,x)},ZvgYq:function(o,x){return e[t(1607)](o,x)},lkJMJ:function(o,x){return e[t(703)](o,x)},zwjPI:function(o,x){return e[t(1724)](o,x)},SGooa:function(o,x){return e.bwgcZ(o,x)},lgZXc:function(o,x){return e[t(1458)](o,x)},Hoyit:function(o,x,l,g){return o(x,l,g)},WdMQd:function(o,x){return e.zzylU(o,x)},IagpM:function(o,x){return e[t(807)](o,x)},mlbJE:function(o,x){return e.KNwbI(o,x)},RTnhn:function(o,x){return e[t(1607)](o,x)},bMbfW:function(o,x){return o|x},OSqXZ:function(o,x){return o<<x},UDZWD:function(o,x){return e[t(807)](o,x)},vEvLf:function(o,x){return e[t(914)](o,x)},wRnDn:function(o,x){return e[t(731)](o,x)}};if(e[t(796)](e[t(572)],e[t(572)])){let o=e[t(544)](te);return C(i,o),e[t(1701)](D,o)}else{let o=r.tbqcb[t(1950)]("|"),x=0;for(;;){switch(o[x++]){case"0":if(r[t(385)](_0x34d158[_0x3213e8++],128))return{value:_0x1b1b36?_0xc70487:r.uUouK(0,_0x1ad639),offset:_0x19f9c3};continue;case"1":_0x10a84a=r.QLopK(r[t(874)](_0x3c2005,r[t(1158)](r[t(1304)](127,_0x44cb1f[_0x3215af]),14)),0);continue;case"2":if(r[t(385)](_0xee874e[_0x50e7f7++],128))return{value:_0x5f0870?_0x23e273:r[t(1997)](0,_0x5d336d),offset:_0x502538};continue;case"3":_0x5e36b0=r[t(1573)](127&_0xfef568[_0x5193c4],0);continue;case"4":if(_0x5aa502[_0x27aa1e++]<128)return{value:_0x1c2b9d?_0x212351:r[t(1794)](0,_0x52a53a),offset:_0x49dd88};continue;case"5":if((_0x1fec02+=5)>_0x38f468[t(1955)])throw _0x23f9b0=_0x5eecc3.length,r[t(1789)](_0x12d100,_0x1084d6,10,_0x22e708[t(1955)]);continue;case"6":if(_0x303f10[_0x5c9669++]<128)return{value:_0x594101?_0x3b52a7:r[t(1997)](0,_0x57fa1c),offset:_0xa1a3aa};continue;case"7":_0x3446fc=r.QLopK(r[t(1767)](_0x3da358,r[t(1158)](r[t(1901)](15,_0x10fe4f[_0x5dc2f2]),28)),0);continue;case"8":_0xcd26af=r.mlbJE(_0x10a0e1,r[t(1304)](127,_0x12a829[_0x2daa1f])<<21)>>>0;continue;case"9":return{value:_0x15edc9?_0x5f3d6a:r[t(1073)](0,_0xf7b1fd),offset:_0x51a06a};case"10":_0xd9b511=r[t(1573)](r[t(906)](_0x3e4da1,r[t(1109)](r[t(1430)](127,_0x36009d[_0xa5d7cc]),7)),0);continue;case"11":if(r[t(1819)](_0x3150ef[_0x420439++],128))return{value:_0x3f13e4?_0x8e9cf9:r.wRnDn(0,_0x48b9ff),offset:_0x1a985e};continue}break}}}function C(i,t){let r=n,o={NVPWn:function(K,V){return e[T(840)](K,V)},miPkH:function(K,V,We){return e.Gjteu(K,V,We)},BTeuk:function(K,V){return e[T(1578)](K,V)},fWSVg:function(K,V){return e[T(478)](K,V)},IfqQF:function(K,V){return K+V},aRzNs:function(K,V){return e[T(1724)](K,V)}},x=i[r(1247)];x!==void 0&&(e[r(1786)](e[r(377)],r(1131))?(o.NVPWn(_0x12d3bd,this[r(1412)+r(641)+"Id"]),this[r(1412)+"lTimeoutId"]=_0x487eee(()=>{let K=r;this[K(1807)+K(1534)]()},this[r(1412)+"l"])):(Q(t,8),e[r(1398)](Ne,t,x)));let l=i[r(1255)];e[r(1786)](void 0,l)&&(e[r(523)](Q,t,16),e[r(1725)](Ne,t,l));let g=i.service;if(e[r(1786)](void 0,g))if(e[r(1061)](e[r(1085)],e[r(1775)])){let K=this[r(1416)][r(1262)](this._prefix);return _0x3ca13f[r(612)](e[r(1197)](K,"{}"))[_0x38e10b]}else e[r(1033)](Q,t,24),Ne(t,e.YGZjX(Z,g));let p=i.method;e[r(465)](void 0,p)&&(e.gLDDG(Q,t,32),e[r(1620)](Ne,t,e.YxioH(Z,p)));let d=i.headers;if(e.veYXW(void 0,d))for(let K of d){e.yNSYc(Q,t,42);let V=e[r(830)](te);e.PuekS(b,K,V),Q(t,V[r(1426)]),e[r(1031)](rn,t,V),e[r(679)](ne,V)}let _=i["payloadE"+r(702)];e[r(695)](void 0,_)&&(e[r(808)](Q,t,50),e.PuekS(Se,t,_));let v=i[r(1062)+r(1968)];v!==void 0&&(e[r(1855)](Q,t,58),e.zUgeT(Se,t,v));let P=i[r(1450)];e[r(1803)](void 0,P)&&(e.wTSHr(Q,t,66),e[r(1013)](Q,t,P[r(1955)]),Rt(t,P));let O=i[r(928)];O!==void 0&&(e.aYCTv===r(1156)?(_0x2501f0=_0x42d889&&e.VVFjI(e[r(1479)],_0x379004[r(1773)])?e[r(1254)]:e[r(1406)],_0x41e1d2=_0x35e789[r(1010)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),_0x1635c4=/^wss(.*:\/\/)/[r(411)](_0x11a41b)?_0x800c84:""+_0x4832cb+_0xc28ffa):(e[r(989)](Q,t,74),e[r(1855)](Se,t,O)));let R=i["serverTi"+r(1960)];e[r(1005)](void 0,R)&&(e[r(2001)](e[r(1074)],r(1641))?(_0xffb7d5-=65536,_0x333b98+=o[r(1095)](_0xf66807,o.BTeuk(o[r(2006)](_0x312820,10),55296),o[r(1731)](o[r(868)](1023,_0x53dcf2),56320)),_0xbffdb8+=3):(e[r(1600)](Q,t,82),e.kbPzi(Se,t,R)));let G=i[r(633)];G!==void 0&&(Q(t,90),Se(t,G));let se=i.frameType;e.QnSCx(void 0,se)&&(Q(t,96),Ne(t,e[r(1221)](Z,se)))}function I(i){return k(e[n(1461)](He,i))}function k(i){let t=n;if(e.MfoBh(e[t(1338)],t(778)))return this[t(1355)+t(971)+t(1720)+"t"]++,this[t(677)+"ntEndpoint"]();{let r={};e:for(;!e[t(510)](U,i);)if(e[t(465)](t(1211),e[t(965)])){let o=e.eVWQn(ie,i);switch(e.TbHGQ(o,3)){case 0:break e;case 1:r[t(1247)]=e[t(997)](ae,i,!0);break;case 2:r[t(1255)]=e.YxuZq(ae,i,!0);break;case 3:r[t(1923)]=e[t(1975)](ie,i);break;case 4:r.method=ie(i);break;case 5:{let x=L(i);(r[t(712)]||(r[t(712)]=[]))[t(1567)](e.GdSpE(w,i)),i[t(1426)]=x;break}case 6:r[t(1704)+"ncoding"]=e[t(1725)](we,i,e[t(679)](ie,i));break;case 7:r["payloadT"+t(1968)]=we(i,ie(i));break;case 8:r[t(1450)]=ft(i,ie(i));break;case 9:r[t(928)]=e.wtWVh(we,i,e[t(619)](ie,i));break;case 10:r[t(752)+"ming"]=we(i,e[t(787)](ie,i));break;case 11:r.msgID=e[t(531)](we,i,e[t(1461)](ie,i));break;case 12:r[t(1710)+"e"]=e.yqlcW(ie,i);break;default:B(i,e[t(368)](7,o))}}else _0x1ed400.log(_0x43c3b3);if(e[t(1061)](void 0,r.SeqID))throw new Error(e[t(485)]);if(e[t(1911)](void 0,r[t(1255)]))throw new Error(t(1655)+t(1535)+t(568)+t(1255));if(r[t(1923)]===void 0)throw new Error(e[t(895)]);if(e[t(796)](void 0,r[t(1331)]))throw new Error(e[t(1092)]);return r}}function L(i){let t=n,r=ie(i),o=i[t(1426)];return i[t(1426)]=e[t(843)](i[t(1659)],r),o}function B(i,t){let r=n;switch(t){case 0:for(;e.kCCoC(128,e[r(1742)](ue,i)););break;case 2:M(i,e[r(1221)](ie,i));break;case 5:e[r(989)](M,i,4);break;case 1:M(i,8);break;default:throw new Error(e[r(491)]+t)}}function Z(i){let t=n;if(e[t(1005)](e[t(863)],e[t(383)]))return i|=0,{low:i,high:e[t(804)](i,31),unsigned:e[t(1486)](i,0)};{let{pingInterval:r,pingFrequency:o}=this[t(1313)];if((e[t(1705)]("hi",_0x403a98[t(850)])&&e[t(1166)](t(1476),o)||e[t(624)](e[t(1563)],o))&&(this[t(1208)+"ngTimer"](),this[t(402)](e.aEbEt,e.dlXGM),this[t(1652)+t(1353)+"Id"]=e[t(1339)](_0x1e12e5,this._ping[t(1591)](this),r)),e[t(1413)]("hi",_0x379948[t(850)]))return;try{_0x1129aa(this,_0x32553d,[_0x60477c,_0x4eaf77,_0x253aff,_0x30de8b,_0x40f7cd,_0x58e842])}catch(x){let l=_0x35a2eb(t(938),{message:x[t(1569)],code:_0x49d019.MESSAGE_ERROR,error:x});this["_dispatc"+t(492)+t(920)](l)}}}let Y=[];function te(){let i=n;if(e.mnHrR("dpkcS",e[i(1150)]))_0x2d239a[i(746)](_0x594bf5,_0x43af8b);else{let t=Y[i(1726)]();return t?(t.offset=t[i(1426)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}}function ne(i){Y.push(i)}function He(i){let t=n,r={HWmdn:function(o,x){return o||x},aBFbv:function(o,x){return e[T(1947)](o,x)},hDgqv:e[t(1475)],xCsSw:function(o,x){return e[t(1933)](o,x)}};if(e[t(1220)]===e[t(1220)])return{bytes:i,offset:0,limit:i[t(1955)]};{let{url:o}=r[t(1638)](_0x30d1ec,{}),x=_0x4eed6e[t(1034)](o)?o:r.aBFbv(r[t(562)],typeof o)?[o]:[];_0x1f9092&&_0xdd5526.assign(this[t(1313)],_0x281bde),x&&x[t(1955)]?this[t(671)+t(1240)]=new _0x3cfeae(x,this._options[t(1615)+"es"]):this["_endpoin"+t(1240)]?.[t(1063)+"pointCon"+t(1320)](),this[t(1674)+t(390)]?.[t(627)+t(1894)](this[t(1313)]["pingLoss"+t(1776)]),this[t(597)+t(1443)]=!1,this[t(1185)]&&r[t(1133)](this._ws.readyState,this[t(1842)])?this[t(1530)+t(1575)](1e3,t(1978)+"econnecting",!0):(this._isInit=!0,this[t(400)]())}}function D(i){let t=n;if(e[t(509)]==="ukVJz")this._clearPingTimer(),this[t(402)](t(1224)+"e_success",t(816)),this[t(1652)+"gTimeoutId"]=e[t(989)](_0x2626d9,this._ping.bind(this),_0x562b14);else{let r=i.bytes,o=i[t(1426)];return e[t(1911)](r.length,o)?r:r[t(1673)](0,o)}}function M(i,t){let r=n;if(e.BrRvQ(i[r(1659)]+t,i[r(1426)]))throw new Error(r(1516)+r(1695));i[r(1659)]+=t}function U(i){return i[n(1659)]>=i.limit}function oe(i,t){let r=n,o=i[r(626)],x=i[r(1659)],l=i.limit,g=e[r(1578)](x,t);if(g>o[r(1955)]){let p=new Uint8Array(2*g);p[r(746)](o),i[r(626)]=p}return i[r(1659)]=g,e[r(705)](g,l)&&(i.limit=g),x}function rt(i,t){let r=n,o=i.offset;if(e[r(705)](e[r(843)](o,t),i[r(1426)]))throw new Error(e[r(546)]);return i[r(1659)]+=t,o}function ft(i,t){let r=n,o=rt(i,t);return i.bytes.subarray(o,e[r(577)](o,t))}function Rt(i,t){let r=n,o=e[r(531)](oe,i,t[r(1955)]);i[r(626)][r(746)](t,o)}function we(i,t){let r=n;if(e[r(774)](e[r(1629)],e.AvoFs))return{bytes:_0x2b12db,offset:0,limit:_0x5b8ae1[r(1955)]};{let o=e[r(808)](rt,i,t),x=String["fromChar"+r(680)],l=i[r(626)],g="\uFFFD",p="";for(let d=0;e.dHhbL(d,t);d++){let _=l[d+o],v,P,O,R;e[r(757)](e[r(754)](128,_),0)?p+=e[r(1935)](x,_):e[r(774)](e[r(754)](224,_),192)?e[r(1507)](e.dJfVT(d,1),t)?p+=g:(v=l[e[r(1332)](d+o,1)],e[r(1368)](e.kCCoC(192,v),128)?p+=g:(R=e.KNwbI(e.Hodjf(e[r(368)](31,_),6),e[r(368)](63,v)),e[r(684)](R,128)?p+=g:(p+=e[r(454)](x,R),d++))):e[r(1102)](e[r(754)](240,_),224)?e[r(1507)](e[r(1256)](d,2),t)?p+=g:(v=l[e[r(1256)](e.YzAzr(d,o),1)],P=l[e[r(843)](e[r(1332)](d,o),2)],e[r(1019)](e[r(1667)](v|e[r(1418)](P,8),49344),32896)?p+=g:(R=e[r(440)](e[r(1583)](e[r(676)](15,_)<<12,e.xfaun(e[r(800)](63,v),6)),e[r(1551)](63,P)),e[r(1565)](R,2048)||R>=55296&&e.BxNhy(R,57343)?p+=g:(p+=x(R),d+=2))):e[r(1759)](e[r(1739)](248,_),240)?e.CGAgB(d,3)>=t?p+=g:(v=l[e[r(577)](d+o,1)],P=l[e[r(843)](e[r(577)](d,o),2)],O=l[e[r(1122)](d,o)+3],e[r(1005)](e.cKUgs(e[r(1953)](e.KNwbI(v,e.TWgie(P,8)),O<<16),12632256),8421504)?p+=g:(R=e.zYqtA(e[r(703)](7&_,18)|e[r(1581)](e[r(800)](63,v),12)|e[r(1927)](63,P)<<6,e.kCCoC(63,O)),e[r(1470)](R,65536)||e[r(1945)](R,1114111)?p+=g:(R-=65536,p+=e[r(1380)](x,e.KyXER(R,10)+55296,e[r(520)](e.EJlDN(1023,R),56320)),d+=3))):p+=g}return p}}function Se(i,t){let r=n,o=t[r(1955)],x=0;for(let p=0;e[r(1135)](p,o);p++){let d=t.charCodeAt(p);e[r(1507)](d,55296)&&d<=56319&&e[r(684)](e.cfslQ(p,1),o)&&(d=e.vliOo(e.pPgNg(d,10)+t[r(1816)+"At"](++p),56613888)),x+=e[r(557)](d,128)?1:e[r(595)](d,2048)?2:e[r(557)](d,65536)?3:4}e[r(1398)](Q,i,x);let l=e[r(1685)](oe,i,x),g=i[r(626)];for(let p=0;e[r(1971)](p,o);p++){let d=t[r(1816)+"At"](p);d>=55296&&d<=56319&&e[r(1745)](p+1,o)&&(d=e.XPtHg(e[r(1932)](d,10),t[r(1816)+"At"](++p))-56613888),e.pWlAs(d,128)?g[l++]=d:(e.dHhbL(d,2048)?g[l++]=e.pLEwp(e.foFAb(d,6)&31,192):e[r(545)](e[r(398)],e.AZYxl)?(d<65536?g[l++]=e[r(1273)](e[r(1667)](e[r(639)](d,12),15),224):(g[l++]=e[r(440)](e[r(368)](e.VXixN(d,18),7),240),g[l++]=e.idUvP(e[r(499)](e[r(1806)](d,12),63),128)),g[l++]=e[r(862)](e[r(1551)](e.dwxuj(d,6),63),128)):(this[r(1185)]&&this[r(1185)][r(422)](_0x36bd93),this[r(1876)](r(1036),_0x49db10)),g[l++]=e[r(1043)](e[r(1154)](63,d),128))}}function rn(i,t){let r=n;if(e[r(757)](r(1455),e[r(1060)])){let o=oe(i,t[r(1426)]),x=i.bytes,l=t[r(626)];for(let g=0,p=t.limit;e.WJkAX(g,p);g++)x[g+o]=l[g]}else _0x4b2c36=_0x45bf3f[e[r(1390)](e.kTZLH(_0x2e85fa,_0x1d469a),1)],e[r(1933)](e[r(986)](192,_0xa4346a),128)?_0x485226+=_0x269f7d:(_0xc61498=e[r(424)](e[r(1e3)](e[r(1492)](31,_0x2c32cf),6),63&_0x943352),_0x27bd40<128?_0x5818e5+=_0x2ba1e7:(_0x45f2f0+=_0x5231bd(_0x526966),_0x479156++))}function ue(i){let t=n;return i.bytes[e[t(1738)](rt,i,1)]}function Lt(i,t){let r=n,o=e[r(433)](oe,i,1);i[r(626)][o]=t}function ie(i){let t=n,r=0,o=0,x;do x=ue(i),e[t(1470)](r,32)&&(o|=e.LxWqi(e[t(368)](127,x),r)),r+=7;while(e[t(800)](128,x));return o}function Q(i,t){let r=n;for(t>>>=0;t>=128;)Lt(i,e[r(608)](127,t)|128),t>>>=7;e[r(477)](Lt,i,t)}function ae(i,t){let r=n,o={nmAoB:function(x,l){return e.fupQB(x,l)},KWdIe:e[r(1245)],XWOtW:r(1270),eQHaE:e[r(661)],CgUiH:r(1224)+r(1837)+"t",HwkNX:function(x,l,g){return x(l,g)},VBzrS:function(x,l){return e[r(366)](x,l)},jlWJG:function(x,l){return e[r(720)](x,l)},pVQmY:function(x,l){return e[r(1755)](x,l)},vmNri:function(x,l){return e[r(1988)](x,l)},XIScP:function(x,l){return e[r(559)](x,l)},ihLrQ:function(x,l){return e[r(1965)](x,l)}};if(e[r(813)](e[r(1574)],e.duhmN)){let x=0,l=0,g=0,p;if(p=e.JOIuF(ue,i),x=e[r(608)](127,p),e.cvNXc(128,p)&&(p=e[r(1221)](ue,i),x|=e[r(853)](127,p)<<7,128&p&&(p=e[r(1701)](ue,i),x|=e[r(1113)](127&p,14),e[r(1326)](128,p))))if(e[r(664)]!==e[r(1333)]){if(p=e[r(619)](ue,i),x|=e[r(1113)](e[r(836)](127,p),21),e[r(1154)](128,p)&&(p=e[r(1364)](ue,i),l=127&p,e.yHdWE(128,p)&&(p=e[r(1694)](ue,i),l|=e[r(1941)](127&p,7),e.HVNxM(128,p)&&(p=e[r(1276)](ue,i),l|=e[r(924)](127&p,14),e[r(828)](128,p)&&(p=e[r(356)](ue,i),l|=e[r(1113)](e[r(999)](127,p),21),e[r(631)](128,p)&&(p=e[r(1351)](ue,i),g=e[r(1321)](127,p),128&p))))))if(e[r(1366)]===r(1088)){this[r(1208)+r(729)](),this[r(1652)+"gTimeoutId"]=o.HwkNX(_0x2f237b,this[r(578)][r(1591)](this),this[r(1313)][r(1996)+r(1252)]);let d=()=>{let v=r;o[v(1522)](_0x4de7b2,o[v(1045)]),this[v(725)]("ping_once_success",d),this[v(725)](v(1224)+"e_timeout",_)},_=()=>{let v=r;_0xfb2431(o.XWOtW),this[v(725)](o[v(367)],d),this[v(725)](o[v(1372)],_)};this.on(o[r(367)],d),this.on(o[r(1372)],_),this._ping()}else p=e[r(1351)](ue,i),g|=e[r(1932)](e[r(685)](127,p),7)}else try{return!!this[r(1416)]}catch(d){return _0x415032[r(1650)](d),!1}return{low:e.KNwbI(x,e[r(1435)](l,28)),high:e[r(871)](e.ByhtP(l,4),e[r(1469)](g,24)),unsigned:t}}else{let x={FKEYM:function(_,v){return o[r(1899)](_,v)},fYvEc:function(_,v){return o[r(1244)](_,v)},KQujR:function(_,v){return o[r(1184)](_,v)},mqSvh:function(_,v){return o.vmNri(_,v)}},l=o[r(1885)](_0x1fbcdb,8192),g=o[r(495)](l,1),p=null,d=l;return function(_){let v=r;if(_<1||x.FKEYM(_,g))return x[v(1319)](_0x18b072,_);d+_>l&&(p=x[v(1319)](_0x4792e5,l),d=0);let P=_0x30b689[v(1525)](p,d,d+=_);return 7&d&&(d=x[v(473)](x[v(872)](7,d),1)),P}}}function Ne(i,t){let r=n,o=e[r(1965)](t[r(1438)],0),x=e[r(1538)](e[r(1473)](e.TbHGQ(t[r(1438)],28),e[r(1581)](t[r(837)],4)),0),l=e[r(1183)](t[r(837)],24),g=l===0?e[r(717)](0,x)?e[r(1691)](o,16384)?e[r(1041)](o,128)?1:2:e[r(634)](o,2097152)?3:4:x<16384?e[r(1094)](x,128)?5:6:e[r(1322)](x,2097152)?7:8:e.CIUQy(l,128)?9:10,p=e[r(1600)](oe,i,g),d=i[r(626)];switch(g){case 10:d[e[r(1392)](p,9)]=e[r(1963)](l,7)&1;case 9:d[e[r(706)](p,8)]=e[r(1786)](9,g)?e[r(1478)](128,l):e[r(1804)](127,l);case 8:d[e[r(843)](p,7)]=e[r(1559)](8,g)?e[r(871)](e[r(1934)](x,21),128):e[r(608)](e[r(1922)](x,21),127);case 7:d[p+6]=e[r(465)](7,g)?e[r(862)](e[r(691)](x,14),128):e[r(999)](e[r(1915)](x,14),127);case 6:d[e[r(1266)](p,5)]=g!==6?e[r(413)](e[r(1533)](x,7),128):e[r(1926)](e[r(1934)](x,7),127);case 5:d[e[r(932)](p,4)]=e[r(1604)](5,g)?e[r(424)](128,x):127&x;case 4:d[p+3]=e[r(620)](4,g)?e.kujFV(o,21)|128:e.iEuhY(o,21)&127;case 3:d[e.qWEou(p,2)]=e.enEms(3,g)?e[r(825)](e[r(1934)](o,14),128):e[r(870)](o>>>14,127);case 2:d[p+1]=e[r(789)](2,g)?e[r(643)](e.TbHGQ(o,7),128):e.psGHZ(e[r(1279)](o,7),127);case 1:d[p]=e.wHDEX(1,g)?e[r(410)](128,o):e[r(801)](127,o)}}function Re(i){return e[n(619)](I,i)}function gr(i){return S(i)}let vi=65536,Za=e[n(1587)],dt=vi*vi,Si=e.NJYeJ(dt,dt),Ei=e[n(797)](Si,2),Ke=String[n(1961)+"e"][n(1816)+"At"];class H{constructor(t,r,o){let x=n;this[x(1309)]=!0,this[x(1438)]=0|t,this[x(837)]=e.zzylU(0,r),this[x(718)]=!!o}static isLong(t){let r=n;return t&&e[r(1829)](!0,t[r(1309)])}static[n(1284)](t,r,o){return new H(t,r,o)}static fromBytes(t,r,o){let x=n;return o?H[x(1813)+x(1482)](t,r):H[x(1813)+x(644)](t,r)}static[n(1813)+n(1482)](t,r){let o=n,x={OBbyr:o(1887),oLxlA:e[o(591)]};if(e[o(545)](e[o(1568)],e[o(1568)])){this[o(710)+o(1374)+o(920)](_0x5eeb1b(x[o(1749)],{code:1e3,reason:x[o(1811)]})),this[o(671)+o(1240)]?.[o(1063)+"pointCon"+o(1320)](),this[o(1674)+o(390)]?.[o(627)+o(1894)]();return}else return new H(e[o(1273)](e[o(1824)](e[o(1824)](t[0],e[o(1418)](t[1],8)),e[o(1746)](t[2],16)),t[3]<<24),e.YJQiu(e[o(1480)](t[4],e[o(404)](t[5],8)),e[o(1e3)](t[6],16))|e.sJmCz(t[7],24),r)}static[n(1813)+n(644)](t,r){let o=n;return new H(e[o(424)](e[o(825)](e[o(970)](e.QRhhL(t[4],24),e[o(1113)](t[5],16)),e[o(1469)](t[6],8)),t[7]),e[o(1824)](e[o(1512)](e.ILcus(e[o(1690)](t[0],24),t[1]<<16),e[o(1690)](t[2],8)),t[3]),r)}static[n(494)](t){let r=n;return e[r(551)](r(1618),e[r(1869)])?e[r(1242)](t,Za)?Ci:new H(e[r(1538)](Ke[r(1525)](t,0)|e[r(1176)](Ke.call(t,1),8)|e[r(1656)](Ke[r(1525)](t,2),16)|e[r(1069)](Ke[r(1525)](t,3),24),0),(Ke[r(1525)](t,4)|e[r(1639)](Ke.call(t,5),8)|e.bPnmA(Ke[r(1525)](t,6),16)|e.MzbsW(Ke.call(t,7),24))>>>0,!0):_0x497a34["objectSt"+r(1195)][1]?void 0:_0x2e2255[r(923)+"ore"](_0x37280f[r(923)+r(1195)][0])}[n(596)](){let t=n;return String[t(1787)+"Code"](255&this[t(1438)],e[t(734)](e[t(1279)](this[t(1438)],8),255),e[t(1154)](this.low>>>16,255),this[t(1438)]>>>24,e.HVNxM(255,this[t(837)]),e[t(1321)](e[t(851)](this[t(837)],8),255),e[t(853)](e[t(1867)](this[t(837)],16),255),e[t(1183)](this[t(837)],24))}static fromNumber(t,r=!0){let o=n;if(isNaN(t))return r?Ya:Ci;if(r){if(e[o(1486)](t,Si))return e0}else{if(t<=-Ei)return t0;if(e[o(408)](t,1)>=Ei)return Qa}return H[o(1284)](e[o(1473)](e.NGGRL(t,dt),0),e.xOJfl(t/dt,0),r)}[n(1100)](){let t=n;return this[t(718)]?e[t(998)](e[t(819)](this[t(837)],0),dt)+e[t(1863)](this.low,0):e[t(1282)](this[t(837)],dt)+(this[t(1438)]>>>0)}[n(1250)](){let t=n;return this[t(837)]===0&&e[t(1015)](0,this[t(1438)])}[n(1886)](t){let r=n;H[r(1309)](t)||(t=H[r(1222)+"er"](t));let o=e.SmFPz(this[r(837)],16),x=e.vdXVq(65535,this[r(837)]),l=e.fxpNr(this.low,16),g=e[r(1836)](65535,this.low),p=e[r(1867)](t[r(837)],16),d=e[r(922)](65535,t[r(837)]),_=t[r(1438)]>>>16,v=e[r(1154)](65535,t[r(1438)]),P=0,O=0,R=0,G=0;return G+=e[r(648)](g,v),R+=G>>>16,G&=65535,R+=e[r(1125)](l,_),O+=e[r(1292)](R,16),R&=65535,O+=e[r(1248)](x,d),P+=e[r(1810)](O,16),O&=65535,P+=e[r(706)](o,p),P&=65535,H[r(1284)](e[r(862)](e.bPnmA(R,16),G),e[r(1043)](e.cnify(P,16),O),this[r(718)])}[n(518)](t){let r=n;return H[r(1309)](t)||(t=H.fromNumber(t)),e[r(1368)](this[r(718)],t[r(718)])&&e[r(1205)](e[r(747)](this.high,31),1)&&e.qpKCj(t.high>>>31,1)?!1:this[r(837)]===t.high&&this.low===t[r(1438)]}[n(1919)](){let t=n;return e[t(974)]!==t(436)?_0xccd768(_0x53c758):this.low===-1&&e[t(1046)](-1,this.high)?H[t(1284)](0,0,this.unsigned):e.GOJxQ(-1,this[t(1438)])?H[t(1284)](0,e.PQfhO(this[t(837)],1),this[t(718)]):H[t(1284)](e.dakzE(this.low,1),this[t(837)],this[t(718)])}toBytes(t){return t?this[n(1504)+"E"]():this.toBytesBE()}[n(1504)+"E"](){let t=n;if(e.GlDbL(t(944),e[t(1440)])){let r=this.high,o=this[t(1438)];return[255&o,e[t(1645)](e.axFUB(o,8),255),e[t(723)](e[t(1940)](o,16),255),e[t(1613)](o,24),e[t(1966)](255,r),e[t(650)](e[t(851)](r,8),255),r>>>16&255,e[t(1921)](r,24)]}else return new _0x1b81ff(_0xa06080)}[n(1571)+"E"](){let t=n,r=this[t(837)],o=this[t(1438)];return[e[t(1922)](r,24),e[t(1613)](r,16)&255,e[t(608)](e[t(803)](r,8),255),255&r,o>>>24,e[t(636)](e.cbIFT(o,16),255),e.UQXjh(o>>>8,255),e[t(1751)](255,o)]}}let Ci=new H(0,0,!1),Ya=new H(0,0,!0),Qa=H[n(1284)](-1,2147483647,!1),e0=H[n(1284)](-1,-1,!0),t0=H[n(1284)](0,-2147483648,!1);var je=(function(i){let t=n;return i[i[e.mMFFq]=5001]=t(1451)+t(378),i[i[e[t(903)]]=5002]=e[t(903)],i[i[t(1070)+t(1291)+"R"]=5003]=e[t(1823)],i[i[t(1839)+t(1378)]=5004]=e[t(1293)],i[i[t(1622)+"OR"]=5005]=t(1622)+"OR",i})({});class lt{constructor(t){let r=n;this.type=t,this[r(933)]=null}}class Ai extends lt{constructor(t,r){super(t),this.message=r&&r.message||null}}class Ii extends lt{constructor(t,r){let o=n;super(t),this[o(938)]=r&&r.error||null,this[o(500)]=r&&r[o(500)]||0,this[o(991)]=r&&r[o(991)]||"",this[o(602)]=r&&r[o(602)]||0,this[o(1569)]=r&&r[o(1569)]||"",this[o(1741)]=r&&r.code||5001}}class Pi extends lt{constructor(t,r){let o=n,x=e[o(943)].split("|"),l=0;for(;;){switch(x[l++]){case"0":this.reason=r&&r.reason||"";continue;case"1":this[o(1938)+"nnect"]=r&&r[o(1938)+o(447)]||!1;continue;case"2":this[o(1741)]=r&&r[o(1741)]||0;continue;case"3":super(t);continue;case"4":this.wasClean=r&&r[o(1169)]||!1;continue}break}}}class ki extends lt{constructor(t,r){let o=n;super(t),this[o(850)]=r&&r[o(850)]||null}}class Ti extends ki{constructor(t,r){let o=n;super(t),this[o(850)]=r&&r.data||null,this.message=r&&r[o(1569)]||null}}class Di extends lt{constructor(t,r){let o=n;super(t),this[o(850)]=r&&r[o(850)]||null}}function pe(i,{message:t,code:r,error:o}){return new Ii(i,{message:t,code:r,error:o})}function ye(i,{code:t,reason:r,wasClean:o,willReconnect:x}){return new Pi(i,{code:t,reason:r,wasClean:o,willReconnect:x})}function Ni(i,{data:t,message:r}){return new Ti(i,{data:t,message:r})}function Ri(i,{data:t}){let r=n,o={RFhwj:function(x,l){return x>>>l},tuNLG:function(x,l){return e[T(1198)](x,l)},VqWDd:function(x,l){return x>>>l},ovKya:function(x,l){return x&l},IHKch:function(x,l){return e[T(1688)](x,l)}};if(e[r(1786)](e[r(653)],e[r(1878)]))return new Di(i,{data:t});{let x=this[r(837)],l=this[r(1438)];return[255&l,BeZsBJ[r(1558)](l,8)&255,BeZsBJ[r(533)](l,16)&255,l>>>24,255&x,BeZsBJ[r(466)](x,8)&255,BeZsBJ.ovKya(BeZsBJ[r(682)](x,16),255),x>>>24]}}function pr(i,{message:t}){return new Ai(i,{message:t})}class Li{constructor(t,r){let o=n;this.endpoints=t,this.maxRetries=r,this[o(1157)+o(1634)]=0,this.currentEndpointTriesCount=0}["resetEnd"+n(666)+n(1320)](){let t=n;this[t(1157)+t(1634)]=0,this["currentE"+t(971)+"riesCount"]=0}[n(1619)+"es"](){let t=n;this[t(1355)+t(971)+t(1720)+"t"]=0}getCurrentEndpoint(){let t=n;return this.endpoints[this[t(1157)+"ndex"]]}[n(677)+n(1190)+"ntTriesC"+n(1847)](){let t=n;return this[t(1355)+"ndpointT"+t(1720)+"t"]}[n(1447)+n(414)+"es"](){let t=n;return!!(e[t(1507)](this[t(1157)+t(1634)],this[t(1472)+"s"].length)||e[t(1099)](this[t(1157)+t(1634)],e[t(1986)](this[t(1472)+"s"][t(1955)],1))&&e[t(1705)](this[t(1355)+t(971)+t(1720)+"t"],this[t(1615)+"es"]))}[n(1172)+"rentEndp"+n(475)+n(1257)+n(1555)](){let t=n;return this[t(1157)+"ndex"]==this.endpoints[t(1955)]?!0:this[t(1355)+t(971)+t(1720)+"t"]>this[t(1615)+"es"]}[n(900)+n(988)+n(744)+"UpdateCo"+n(1771)](){let t=n;return this[t(1355)+t(971)+t(1720)+"t"]=1,this[t(1157)+t(1634)]++,this.endpoints[this[t(1157)+t(1634)]]}[n(677)+"ntEndpoi"+n(535)+n(1617)](){let t=n;return this["currentE"+t(971)+t(1720)+"t"]++,this[t(677)+t(1190)+"nt"]()}}let ht=(e[n(880)](n(1217)+"d",typeof globalThis)&&e[n(1181)]===globalThis["construc"+n(1905)][n(448)]||e.ZGoJg(e.cwrBd,typeof window)&&e[n(1681)](n(579),window[n(1106)+"tor"][n(448)]))&&e[n(880)](n(1217)+"d",typeof document),it=e[n(1719)]("undefined",typeof globalThis)&&(e[n(525)]===globalThis["construc"+n(1905)][n(448)]||e[n(1288)](e[n(1037)],globalThis[n(1106)+n(1905)][n(448)]))&&e[n(1163)](e[n(444)],typeof tt),Ot=(e[n(444)]!=typeof globalThis&&e[n(1046)](e.FpUmL,globalThis[n(1106)+"tor"][n(448)])||e.GNLHX(n(1217)+"d",typeof globalThis)||e.wKXYg(e[n(444)],typeof globalThis)&&!!globalThis.WeixinJSBridge)&&e.gHGve(e[n(444)],typeof wx),Bt=e.rZBzb(e[n(444)],typeof globalThis)&&(e[n(603)](e[n(1037)],globalThis[n(1106)+"tor"].name)||e.eTpon(n(1395)+n(576)+n(1843),globalThis[n(1106)+n(1905)][n(448)])||e[n(496)](n(574)+n(479)+n(711),globalThis[n(1106)+"tor"].name))&&e[n(1163)](e[n(444)],typeof self),n0=e[n(1489)]("undefined",typeof globalThis)&&e[n(1075)](e.FpUmL,globalThis[n(1106)+n(1905)][n(448)])&&e[n(444)]!=typeof global&&e[n(525)]===global[n(1106)+n(1905)][n(448)]&&e[n(444)]!=typeof process&&!!process[n(1419)];class mr{constructor(){this._listeners={}}[n(402)](t,...r){let o=n,x=this._listeners[t];if(x)x[o(1983)]()[o(660)](l=>l.fn[o(1881)](l[o(961)],r));else if(e[o(593)](o(938),t)&&!this[o(846)]){let l=r[o(1955)]&&r[0];if(e.CynCl(l,Error))throw l;let g=new Error(e[o(713)]+(l?e.GrION(e.XPtHg(" (",l[o(1569)]),")"):""));throw g[o(587)]=l,l}return this}off(t,r){let o=n;if(e[o(1011)](void 0,t))this[o(909)+"rs"]={};else if(e[o(1099)](void 0,r))this._listeners[t]=null;else{let x=this[o(909)+"rs"][t];if(x)for(let l=0;e[o(1565)](l,x[o(1955)]);)x[l].fn===r?x.splice(l,1):++l}return this}on(t,r,o){let x=n;if(e[x(774)](e[x(388)],e[x(388)]))return(this._listeners[t]||(this[x(909)+"rs"][t]=[]))[x(1567)]({fn:r,ctx:o||this}),this;{let l=_0x3b8c8b[_0x37df10];if(e[x(1368)](4,_0x609299[_0x3cbe1b][x(1955)])){let g=_0x24a6c3[x(1715)+"g"](0,e.LEJgW(4,_0x1959ac[_0x5229c2][x(1955)])),p=g[x(1520)](l);_0x3e402a=_0x35202d.concat(p)}else _0xe13c55=_0x3a103e[x(1520)](l)}}}class r0 extends mr{["_formatE"+n(1405)+n(882)](t){let r=n;return t[r(884)]||t[r(498)]?(r(1879)+" "+(t[r(884)]||"")+r(1747)+(t[r(498)]||"")).trim():JSON.stringify(t)}constructor(t,r,o){let x=n;super(),this[x(490)]=null,Ot&&wx[x(1774)+x(984)]&&(this[x(490)]=wx["connectS"+x(984)]({url:t,protocols:r,header:o,fail:this[x(1241)+x(1365)+x(847)][x(1591)](this),success:this[x(1241)+x(1605)+x(1151)+x(1278)].bind(this)})),it&&tt[x(1774)+"ocket"]&&(this[x(490)]=tt[x(1774)+x(984)]({url:t,protocols:r,header:o,fail:this[x(1241)+x(1365)+x(847)][x(1591)](this),success:this[x(1241)+x(1605)+x(1151)+x(1278)][x(1591)](this)}))}[n(1241)+n(1605)+n(1151)+"ler"](){Promise.resolve().then(()=>{let t=T;this[t(1370)+t(428)]()})}[n(1241)+n(1365)+n(847)](t){let r=n;if(e[r(496)](e[r(1052)],e[r(1052)]))Promise.resolve()[r(1722)](()=>{let o=r,x=e[o(997)](pe,e[o(446)],{message:this[o(1287)+o(1405)+o(882)](t)});this.emit(e.Ewndp,x);let l=e[o(1380)](ye,e.gcKqQ,{reason:this[o(1287)+o(1405)+o(882)](t)});this[o(402)](o(1887),l)});else return this[r(1434)+"T"]||this[r(1564)+"X"]?this[r(426)+r(940)+r(1598)]:(this[r(1754)+"er"]||this[r(1360)+"r"])&&this[r(1313)][r(452)+r(930)+r(571)]?_0x28fba0.onLine:!0}[n(1370)+n(428)](){let t=n,r={zqoyz:function(o,x){return e[T(551)](o,x)},mkDHZ:e[t(652)],eDTDN:e.mMRCq,MRujH:function(o,x,l){return e.MBYrI(o,x,l)}};this._socket[t(1562)](o=>{let x=t;this.emit(e[x(1783)],e[x(1725)](Ri,e[x(1783)],{...o,data:o[x(884)]||""}))}),this[t(490)][t(1649)](o=>{this[t(402)]("close",e.kgGHS(ye,e.gcKqQ,{...o}))}),this[t(490)][t(1376)+"e"](o=>{let x=t;r.zqoyz(r.mkDHZ,x(534))?(this["_miniNav"+x(940)+"line"]=_0x5bc128,_0x4d17db?this[x(860)+x(1872)]():this[x(860)+x(1167)]()):this[x(402)](r[x(838)],r.MRujH(Ni,r[x(838)],{...o}))}),this._socket.onError(o=>{let x=t;this.emit(e[x(446)],e[x(1951)](pe,"error",{...o,message:o.errMsg||""}))})}[n(422)](t){let r=n,o={FWwMY:e[r(446)],vljGT:function(x,l,g){return x(l,g)}};if(e[r(593)](e[r(1529)],e[r(1529)]))if(e[r(946)](t,Uint8Array)){let x=t[r(919)][r(1983)](t.byteOffset,e[r(1973)](t[r(585)+"th"],t[r(1628)+"et"]));this[r(490)]&&this[r(490)][r(422)]({data:x,fail:l=>{let g=r;this[g(402)](o[g(1312)],o[g(728)](pe,o[g(1312)],{message:this[g(1287)+g(1405)+"age"](l)}))}})}else this._socket&&this[r(490)].send({data:t,fail:x=>{let l=r;this[l(402)](e[l(446)],e[l(543)](pe,l(938),{message:this[l(1287)+l(1405)+l(882)](x)}))}});else this[r(402)](r(1887),_0x3cd9b1),this[r(1393)]&&this[r(1393)](_0x302de4)}[n(1887)](t,r){let o=n;this._socket&&this[o(490)][o(1887)]({code:t,reason:r})}addEventListener(t,r){this.on(t,r)}[n(934)+n(599)+n(484)](t,r){let o=n;if(e[o(1990)](e[o(1858)],e[o(1610)])){if(!this[o(1185)])return;this[o(1187)+"WebSocket"](_0x1309e7,_0x9ab99a,_0x50a74e)}else this[o(725)](t,r)}get readyState(){let t=n;return this[t(490)][t(1066)+"te"]}get[n(966)+"pe"](){let t=n;return this[t(490)][t(966)+"pe"]}set[n(966)+"pe"](t){}get[n(1424)](){let t=n;return this[t(490)][t(1424)]}get[n(1773)](){let t=n;return this[t(490)][t(1773)]}get[n(1814)+"ns"](){return this[n(490)].extensions}get[n(529)+n(1216)](){return 0}}function i0(i,t){let r=n;if(t)return new t(i[r(1424)],i[r(1773)]);if(Ot||it)return new r0(i[r(1424)],i[r(1773)],i[r(712)]);if(e.pHbTv(ht,Bt)&&e[r(444)]!=typeof WebSocket&&WebSocket)return new WebSocket(i[r(1424)],i[r(1773)+"s"])}function s0(i){let t=n,r=e[t(1621)][t(1950)]("|"),o=0;for(;;){switch(r[o++]){case"0":if(e[t(1675)](ht,Bt)&&e[t(739)](e.cwrBd,typeof WebSocket)&&WebSocket)return!0;continue;case"1":if(Ot&&wx[t(1774)+t(984)])return!0;continue;case"2":if(it&&tt[t(1774)+t(984)])return!0;continue;case"3":if(i)return!0;continue;case"4":return!1}break}}function Oi(i,t,r){let o=n,x={uiwce:e[o(1956)],RRjDf:function(p,d){return e[o(1242)](p,d)},UKlTN:function(p,d){return e[o(864)](p,d)}},l=-1;async function g(p){let d=o;return p<=l?Promise[d(826)](new Error(x.uiwce)):(l=p,x[d(1760)](p,r[d(1955)])?Promise[d(1924)]():r[p][d(1591)](i)(t,g[d(1591)](null,x[d(818)](p,1))))}e[o(1701)](g,0)}function Bi(i){let t=n,r=0,o=0;for(let x=0;e[t(634)](x,i[t(1955)]);++x)o=i[t(1816)+"At"](x),e[t(1716)](o,128)?r+=1:e[t(1691)](o,2048)?r+=2:e[t(1606)](e[t(723)](64512,o),55296)&&(64512&i[t(1816)+"At"](e[t(577)](x,1)))===56320?(++x,r+=4):r+=3;return r}function Mi(i,t,r){let o=n;if(e[o(1986)](r,t)<1)return"";let x="";for(let l=t;e[o(1470)](l,r);){let g=i[l++];if(e[o(1341)](g,127))x+=String.fromCharCode(g);else if(e[o(1507)](g,192)&&e[o(1094)](g,224))x+=String["fromChar"+o(680)](e[o(413)](e.TWgie(e[o(1577)](31,g),6),63&i[l++]));else if(g>=224&&g<240)x+=String[o(1787)+o(680)](e[o(462)](e.DvfPp(e[o(1078)](e[o(1076)](15,g),12),e.djLvF(63,i[l++])<<6),e[o(394)](63,i[l++])));else if(e[o(1507)](g,240)){let p=e[o(1514)](e[o(1939)](e[o(871)](e[o(362)](e[o(647)](e[o(870)](7,g),18),e[o(855)](63,i[l++])<<12),e[o(1113)](e[o(1501)](63,i[l++]),6)),63&i[l++]),65536);x+=String["fromChar"+o(680)](e[o(1755)](55296,e[o(867)](p,10))),x+=String[o(1787)+o(680)](56320+(1023&p))}}return x}function _r(i,t,r){let o=n,x={YwFjb:function(d,_){return e[T(634)](d,_)},gxGac:function(d,_){return e[T(996)](d,_)},HMgDu:function(d,_){return e[T(1687)](d,_)},qCccO:function(d,_){return e[T(1857)](d,_)},cTaOl:function(d,_){return e[T(876)](d,_)},bPaxK:function(d,_){return e[T(393)](d,_)},jHalz:e.MkLDB,WOIdR:function(d,_){return e[T(1281)](d,_)},dWPpL:function(d,_){return d&_},txrAK:function(d,_){return e.SavPw(d,_)},fyTFj:function(d,_){return d>>_},PAFrC:function(d,_){return d&_},ZmiHm:function(d,_){return e[T(623)](d,_)},ktFZB:function(d,_){return e[T(1640)](d,_)}},l=r,g,p;for(let d=0;e[o(1135)](d,i[o(1955)]);++d)if(g=i[o(1816)+"At"](d),e[o(557)](g,128))t[r++]=g;else if(e[o(540)](g,2048))if(e[o(695)](e[o(981)],e.Svsfw))if(_0x68c337=_0x15d5d8.charCodeAt(_0x1fd935),_0xf0a20e<128)_0x30f3b0[_0x718206++]=_0x26019c;else if(x.YwFjb(_0x4e2f8d,2048))_0x2d49e7[_0x32ac5c++]=x[o(740)](_0x370f73>>6,192),_0x2debd6[_0x2d8e1c++]=x[o(1146)](x.qCccO(63,_0x2cfb99),128);else if(x.cTaOl(x[o(575)](64512,_0x1f4b48),55296)&&x[o(575)](64512,_0x882819=_0x391695[o(1816)+"At"](x.bPaxK(_0x46f6de,1)))===56320){let _=x[o(1123)][o(1950)]("|"),v=0;for(;;){switch(_[v++]){case"0":_0x23a37d[_0x4c0c77++]=x.WOIdR(x.dWPpL(63,_0x50d224),128);continue;case"1":_0x4d1d53[_0x62f25d++]=x[o(740)](x[o(1633)](x[o(1427)](_0x41a1e0,6),63),128);continue;case"2":_0x215524=x.bPaxK(65536+((1023&_0xd9ce39)<<10),x.PAFrC(1023,_0x331cee));continue;case"3":_0x255c22[_0x3fbe0f++]=x[o(1265)](x.qCccO(x[o(953)](_0x9b8cc2,12),63),128);continue;case"4":_0x3c50f3[_0x28f5c2++]=x[o(1265)](_0x16304d>>18,240);continue;case"5":++_0x233648;continue}break}}else _0x2eaead[_0xa19bfc++]=x[o(740)](_0x896942>>12,224),_0x206a9a[_0x55a082++]=x[o(575)](_0x30f9ae>>6,63)|128,_0x4ac5b8[_0x421804++]=63&_0x2e3cc8|128;else t[r++]=e[o(1043)](g>>6,192),t[r++]=e.bhJgy(e.DFtNS(63,g),128);else if(e.TMgNH(e.jNTaW(64512,g),55296)&&e[o(960)](64512&(p=i.charCodeAt(e.puwyw(d,1))),56320)){let _=(o(1077)+o(1597))[o(1950)]("|"),v=0;for(;;){switch(_[v++]){case"0":t[r++]=e[o(1988)](e[o(1831)](g,18),240);continue;case"1":++d;continue;case"2":t[r++]=e.MGSgH(e[o(639)](g,6),63)|128;continue;case"3":g=e.tgPtp(65536+(e[o(870)](1023,g)<<10),e[o(1119)](1023,p));continue;case"4":t[r++]=e[o(1678)](g,12)&63|128;continue;case"5":t[r++]=e[o(1595)](63,g)|128;continue}break}}else if(e.qqjmA(e[o(1768)],e[o(1219)]))t[r++]=e[o(643)](e[o(958)](g,12),224),t[r++]=e.skhEg(g>>6,63)|128,t[r++]=e.pLpNW(e[o(1625)](63,g),128);else{let _=this[o(671)+"tManager"]?.[o(677)+o(1190)+"nt"]();this[o(710)+"hCloseEvent"](e[o(997)](_0x3a2956,"close",{code:1006,reason:o(642)+_+(o(696)+o(497)+"tries re"+o(376)),wasClean:!0}))}return e[o(1986)](r,l)}async function zi(i){let t=n;if(e[t(1947)](e.SSEgN,typeof i)){let r=new Uint8Array(Bi(i));return e[t(1998)](_r,i,r,0),r}return e.imgRA(i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(919)],i[t(1628)+"et"],i[t(585)+"th"])}function o0(i){let t=n,r={SEBMY:function(o,x){return e.PFPgN(o,x)},CznrK:function(o,x){return e[T(1273)](o,x)},vDFvO:function(o,x){return e.xdkEa(o,x)},bFTrr:function(o,x){return e[T(1553)](o,x)},UrnSf:function(o,x){return e[T(1671)](o,x)}};try{return e[t(1719)]("string",typeof i)&&(e[t(601)](i,ArrayBuffer)||i[t(919)]&&i[t(919)]instanceof ArrayBuffer)||e[t(1475)]!=typeof i?"":(JSON[t(612)](i),e[t(821)])}catch{return e[t(651)](e[t(1210)],e[t(1210)])?new _0x3edf91(ZPqiXL[t(834)](ZPqiXL[t(834)](ZPqiXL[t(964)](ZPqiXL[t(811)](_0x542d7f[4],24),ZPqiXL[t(708)](_0x1fc2bd[5],16)),ZPqiXL.vDFvO(_0x529e85[6],8)),_0x4faf8c[7]),ZPqiXL[t(834)](ZPqiXL[t(964)](ZPqiXL[t(834)](_0xe5e761[0]<<24,ZPqiXL[t(1118)](_0x23db11[1],16)),ZPqiXL[t(708)](_0x315799[2],8)),_0x4f45f2[3]),_0x25a306):e[t(1661)](t(1009),typeof i)?e[t(1404)]:""}}let a0=(i,t)=>{let r=n;switch(i){case e[r(506)]:case e[r(1498)]:return{[r(542)+i]:1,"x-tt-env":t};default:return{}}};class c0{constructor(t){let r=n;if(e[r(1175)](e[r(1203)],e[r(741)]))this["maxLossC"+r(1847)]=t,this.count=0;else{if(_0x13911f(_0x482189))return _0x307783?_0x48d798:_0x459007;if(_0x5dcce6){if(_0x241b3e>=_0x318c46)return _0x525832}else{if(e.BxNhy(_0x306f46,-_0x1f61f6))return _0x2bf311;if(e.JKeHg(e.ZYvmc(_0x30d8e2,1),_0x590951))return _0xaaf4ea}return _0x2276e9[r(1284)](e[r(538)](e[r(1616)](_0x2a66df,_0x38d2b6),0),e.JrvXI(_0x1619e1/_0x1c8349,0),_0x50083e)}}[n(1429)](){this.count++}["checkRea"+n(555)+"nt"](){let t=n;return this.count>=this[t(1305)+"ount"]}[n(627)+n(1894)](t=0){let r=n;this[r(1305)+r(1847)]=t,this[r(515)]=0}}async function x0(i){let t=n,r={QPycS:t(1980),XcIxB:e.NPndy,rPqsc:function(o,x){return e[t(693)](o,x)},PRWpo:e[t(1192)]};return new Promise(o=>{let x=t;if(!ht)return e.hOPhq(o,x(951)+x(1993));try{if(e[x(1345)](e[x(1508)],e[x(1781)])){let l=document[x(1044)+x(1199)](e[x(1793)]);window[x(1003)+x(1599)]=g=>{let p=x,d={XUDTr:function(_,v){return _-v}};if(r[p(993)]!==r[p(904)])document[p(655)][p(727)+p(565)](l),window.frontierJSONP=void 0,r[p(1357)](o,g&&g[p(1977)]||r[p(621)]);else{let _=_0x145b35[p(1715)+"g"](0,Codbuk[p(1624)](4,_0xe451f8[p(1955)])),v=_[p(1520)](_0x1e3c69);_0x25980c.push(v)}},l.type=e[x(1115)],l[x(1808)]=i[x(1010)](/^ws/,"http")+e[x(1728)];try{e.dYEYU(e[x(1861)],e.LkDBe)?_0x1779f2&&this[x(637)+"anager"][x(605)+x(1261)+"Name"](_0x2f7202):document[x(655)].appendChild(l)}catch{e[x(1413)](e.KNWUw,e[x(1344)])?document[x(655)][x(727)+x(565)](l):(this[x(402)](x(938),_0x69c414),this[x(846)]&&this[x(846)](_0x46c726))}}else this.endpoints=_0x99a7b1,this[x(1615)+"es"]=_0x11913b,this[x(1157)+"ndex"]=0,this[x(1355)+x(971)+x(1720)+"t"]=0}catch{window[x(1003)+x(1599)]=void 0,o(e[x(1192)])}})}function Ge(i,t,r){let o=n;return!!i?.[o(1712)](x=>x[o(812)]===t&&x[o(1699)]===r)}function gt(i,t){let r=n;return i?.find(o=>o.key===t)?.[r(1699)]}let wr=null;async function u0(){let i=n;return wr||(wr=Promise.resolve()[i(1722)](ke.bind(ke,e[i(1737)]))),wr}class f0 extends mr{constructor(t,r){let o=n;super(),this[o(844)]=t,this[o(1213)]=r,this[o(1416)]=void 0,this[o(1047)+o(678)]=null}async openDB(){await this[n(1547)]()}async[n(1547)](){let t=n,r={OtRHX:function(o,x){return o(x)},VyPPH:function(o,x){return e[T(706)](o,x)},PiYDT:function(o,x){return e.XPtHg(o,x)},jiJyG:function(o,x){return o+x},Gtkkk:e[t(537)],UksUF:e[t(1509)],CGaaR:function(o,x){return e[t(416)](o,x)},FWjIM:e.iZqCa};if(e[t(1428)](e.cYpCo,e[t(662)]))return r[t(640)](_0x58ae22,r[t(403)](r[t(949)](r[t(1931)](r[t(753)],_0x337e55)+r[t(1502)]+r[t(1065)](_0xe993c0,1),r.FWjIM),_0x308216));if(this._qosDB)return;if(this[t(1047)+"mise"])return this[t(1047)+t(678)];try{if(e[t(1233)](e[t(931)],e.nXSTO)){let o=this._dbName,x=this[t(1213)];this[t(1047)+t(678)]=(async()=>{let l=t,{openDB:g}=await u0();this[l(1416)]=await g(l(1003)+"_"+o,1,{upgrade(p){p[l(429)+"jectStore"](o,{keyPath:x})}})})(),await this[t(1047)+"mise"]}else this[t(1807)+t(1534)]()}catch(o){console[t(1650)](o)}finally{this[t(1047)+t(678)]=null}}async[n(1967)](t){let r=n;try{return await this[r(1547)](),this[r(1416)]?.[r(1967)](this[r(844)],t)}catch(o){console.log(o)}}async[n(746)](t,r){let o=n;return await this[o(1547)](),this[o(1416)]?.[o(1925)](this[o(844)],t)}async[n(835)](t){let r=n;if(e[r(1323)]("fRazt",e[r(1680)]))try{return await this._init(),this[r(1416)]?.delete(this[r(844)],t)}catch(o){console.log(o)}else throw this[r(400)+r(1159)]=!1,_0x52bbc2}async[n(962)](){let t=n;try{return await this[t(1547)](),this._qosDB?.[t(962)](this[t(844)])}catch(r){if(e[t(1101)](e[t(1809)],e[t(1870)]))return this[t(671)+t(1240)]?.[t(677)+t(1190)+"ntTriesC"+t(1847)]()||0;console[t(1650)](r)}}async keys(){let t=n;return await this[t(1547)](),this[t(1416)]?.[t(1527)+"ys"](this._dbName)}async getAll(){let t=n;return await this._init(),this._qosDB?.getAll(this[t(844)])}async[n(1421)](){let t=n;try{this[t(1416)]?.[t(1887)](),this[t(1416)]=void 0}catch(r){if(e.zlmke==="BBylK")return!!_0x1da032?.find(o=>o[t(812)]===_0x11cc0e&&o[t(1699)]===_0x102816);console[t(1650)](r)}}get[n(401)](){let t=n;try{if(e[t(960)](t(635),e.ujgPk))return!!this[t(1416)];_0x1e0d35=_0x555bfc[e.sFqfF(e[t(911)](_0x62ebe,_0x14581e),1)],_0x1a3b63=_0x18c236[e[t(802)](e[t(1392)](_0x292cd9,_0xafb7d),2)],_0x1a755e=_0xbb7d3f[e[t(476)](e.CLfCt(_0x57e9bd,_0x564963),3)],e[t(1490)](e[t(825)](e.LHAge(_0x232a83,_0x47a78d<<8),e[t(1671)](_0x35a538,16)),12632256)!==8421504?_0x2ae4b8+=_0x56a8a6:(_0x15506f=e[t(1281)](e[t(1553)](7&_0x2fee85,18),e[t(1671)](e.PCVLI(63,_0x38513d),12))|e[t(986)](63,_0x3b399c)<<6|e.uPOiB(63,_0x433e73),e[t(370)](_0x31dec9,65536)||_0x41ea77>1114111?_0x28e93e+=_0x3f7d15:(_0xd13fd7-=65536,_0x3c6ca9+=e[t(715)](_0x587108,e[t(639)](_0x28ee48,10)+55296,e.EJlDN(1023,_0x5112fb)+56320),_0x140dd6+=3))}catch(r){return console[t(1650)](r),!1}}}class d0{constructor(t,r){this._DBName=t,this._pathKey=r,this._qosDB=localStorage}async openDB(){}get[n(1883)](){let t=n;return t(1003)+"_"+this[t(1799)]}async[n(1967)](t){let r=n,o=this._qosDB[r(1262)](this[r(1883)]);return JSON[r(612)](e[r(532)](o,"{}"))[t]}async[n(746)](t,r){let o=n,x=this[o(1416)][o(1262)](this[o(1883)]),l=JSON.parse(e[o(1197)](x,"{}"));return l[r||t[this[o(1298)]]]=t,this[o(1416)][o(1180)](this[o(1883)],JSON[o(854)+"y"](l)),r||t[this._pathKey]}async[n(835)](t){let r=n,o=this[r(1416)][r(1262)](this[r(1883)]),x=JSON[r(612)](e[r(451)](o,"{}"));return x[t]=void 0,this[r(1416)][r(1180)](this[r(1883)],JSON[r(854)+"y"](x))}async[n(962)](){let t=n;return this[t(1416)][t(962)]()}async[n(1152)](){let t=n,r=this._qosDB[t(1262)](this[t(1883)]),o=JSON[t(612)](r||"{}");return Object[t(1152)](o)}async[n(839)](){let t=n,r=this[t(1416)][t(1262)](this[t(1883)]),o=JSON[t(612)](r||"{}");return Object[t(856)](o)}[n(1421)](){let t=n;if(e[t(545)](t(1761),e.FPaIZ)){let r=e.IXsiL(_0x5f02e1,_0x34c573,_0xceadf6[t(1426)]),o=_0x54b07b[t(626)],x=_0x2805af[t(626)];for(let l=0,g=_0x65cee4[t(1426)];e.GXDvB(l,g);l++)o[e.yBhsD(l,r)]=x[l]}else return Promise.resolve()}get[n(401)](){return!!this._qosDB}}class l0{constructor(t,r){let o=n;this._DBName=t,this[o(1298)]=r,this[o(1416)]=it?tt:Ot?wx:null}async[n(482)](){}get _prefix(){let t=n;if(t(1023)!==e[t(1515)])this[t(1305)+"ount"]=_0x513c73,this[t(515)]=0;else return t(1003)+"_"+this[t(1799)]}async get(t){let r=n,o=this._qosDB[r(1383)+r(566)](this._prefix);return JSON[r(612)](e.pzdxL(o,"{}"))[t]}async[n(746)](t,r){let o=n,x={MRvGE:o(1337)+"or",gqhtv:function(l){return e.VHVXV(l)}};if(e[o(1382)]!==o(606)){let l=this[o(1416)][o(1383)+o(566)](this[o(1883)]),g=JSON[o(612)](e[o(451)](l,"{}"));return g[r||t[this[o(1298)]]]=t,this[o(1416)].setStorageSync(this[o(1883)],JSON[o(854)+"y"](g)),r||t[this[o(1298)]]}else _0x360e4b(_0x375cc2.error||new _0x44c949(gMzmEJ.MRvGE,o(1337)+"or")),gMzmEJ[o(1080)](_0x44621e)}async[n(835)](t){let r=n,o={cuiDo:function(x,l,g){return e[T(600)](x,l,g)},YGEfT:function(x,l,g){return x(l,g)}};if(e.msFQU(e[r(625)],e[r(1388)])){let x=this[r(1416)][r(1383)+"geSync"](this[r(1883)]),l=JSON[r(612)](e[r(1164)](x,"{}"));return l[t]=void 0,this[r(1416)][r(1258)+r(566)](this._prefix,JSON[r(854)+"y"](l))}else VThBWm[r(918)](_0x21b1eb,_0x48ebf2,74),VThBWm[r(815)](_0x455b4e,_0x12a6cd,_0x6eee01)}async[n(962)](){let t=n;return this[t(1416)][t(1318)+t(694)]()}async[n(1152)](){let t=n,r=this[t(1416)]["getStora"+t(586)+"nc"](this._prefix),o=JSON.parse(e[t(1952)](r,"{}"));return Object[t(1152)](o)}async[n(839)](){let t=n,r=this[t(1416)]["getStora"+t(586)+"nc"](this[t(1883)]),o=JSON[t(612)](r||"{}");return Object[t(856)](o)}[n(1421)](){return Promise.resolve()}get[n(401)](){let t=n;if(e[t(496)](e[t(1944)],"RxjAL"))e[t(1380)](_0x573904,_0x18405c,10),_0x18cf19(_0xdfd876,_0x206328);else return!!this[t(1416)]}}function Fi(i,t){let r=n;if(e[r(638)](it,it))return new l0(i,t);if(e[r(638)](ht,Bt)&&e[r(444)]!=typeof indexedDB)return new f0(i,t);if((ht||Bt)&&e[r(444)]!=typeof localStorage)return new d0(i,t);throw new Error(r(902)+r(1229)+"d")}class h0{constructor(){let t=n;this[t(1412)+t(641)+"Id"]=null,this[t(1412)+"l"]=36e5,this._qosDB=Fi(e[t(1381)],e[t(1576)])}async[n(1412)+n(1519)](){let t=n,r={wIVmn:function(o,x){return e[T(1933)](o,x)},vOdcG:e.beWvL,gGVyC:e.lBhJX,CkBbw:e[t(446)],Gstwo:e.ZBjSz,EdPfT:function(o){return e[t(1672)](o)},oZkSV:function(o,x){return o(x)}};if(e[t(1465)](e[t(877)],e[t(582)]))e[t(1935)](clearInterval,this["_interva"+t(641)+"Id"]),this[t(1412)+t(641)+"Id"]=setInterval(()=>{let o=t;if(r[o(1012)]("IyIVs",r[o(1196)]))this["flushExp"+o(1534)]();else return this._qosDB?.del(_0x7d089a)},this[t(1412)+"l"]);else{let o={XKNrP:function(p,d){let _=t;return wJnSOy[_(564)](p,d)},ndgVP:t(1337)+"or",KREgl:function(p){let d=t;return wJnSOy[d(629)](p)}},x=()=>{let p=t;_0x29e5e7[p(934)+p(599)+p(484)](wJnSOy[p(1460)],l),_0x29f054[p(934)+"entListener"](wJnSOy.CkBbw,g),_0x19cee2[p(934)+p(599)+p(484)](wJnSOy[p(412)],g)},l=()=>{let p=t;wJnSOy[p(629)](_0x1e0814),x()},g=()=>{let p=t;o[p(1054)](_0x2c156c,_0xab66a0[p(938)]||new _0x2c0bee(o[p(790)],o.ndgVP)),o[p(527)](x)};_0x4755c3[t(1350)+t(1263)](wJnSOy[t(1460)],l),_0x357c1a.addEventListener(t(938),g),_0x3e0077["addEvent"+t(1263)](t(1097),g)}}async[n(482)](){let t=n;await this[t(1416)][t(482)]()[t(1722)](()=>{let r=t;e[r(1147)]===e[r(881)]?this[r(1370)+r(428)]():this["_interva"+r(1519)]()})}async[n(1807)+"ired"](){let t=n;(await this[t(1416)]?.[t(839)]()||[]).filter(({timestamp:x})=>x<Date.now())[t(660)](x=>{let l=t;this[l(1416)]?.[l(835)](x[l(387)+"id"])})}async[n(835)](t){let r=n,o={RjKSs:function(x,l){return e[T(451)](x,l)}};if(e[r(358)](e[r(1237)],e.febbu)){let x=this[r(1416)][r(1383)+r(566)](this[r(1883)]);return _0xfca138[r(612)](xNMIHK[r(355)](x,"{}"))[_0x3e1fe6]}else return this[r(1416)]?.[r(835)](t)}async[n(746)](t,r){let o=n;return this[o(1416)]?.[o(746)]({message_id:t,timestamp:r})}async get(t){return this[n(1416)]?.get(t)}async[n(1421)](){let t=n;e[t(453)](e[t(975)],e[t(975)])?eBzNvk.kyiXd(_0x280b0d,eBzNvk.MvPfZ(_0x21286f,_0xcb390[t(1907)]),_0x12d723[t(1090)+"on"],_0x2a8185[t(1590)+"on"],eBzNvk[t(356)](_0x1a5c95,_0x16bec2[t(1518)+t(1209)])):(e[t(748)](clearInterval,this[t(1412)+t(641)+"Id"]),await this[t(1416)]?.[t(1421)]())}get isReady(){let t=n;return this[t(1416)]?.[t(401)]}}function yr(i){let t=n;if(e[t(717)](t(645),t(939)))_0x166cd2.log(_0x28ff05);else{let r=!!this[t(1313)].enableQoS;if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let o=Ge(i[t(1569)][t(712)],e[t(910)],"2"),x=o&&Ge(i[t(1569)][t(712)],e.xnFvq,"1"),l=o&&e[t(1998)](Ge,i.message[t(712)],e[t(1898)],"1"),g=l?gt(i[t(1569)][t(712)],e[t(1631)])?.[t(1950)](",")[t(697)](Boolean)||[]:[];return{enabled:r,isQoSMessage:o,isQoSAck:x,isAckCleanupMessage:l,ackMsgIds:g}}}async function qi(){let i=n;return this[i(450)+i(832)]||(this[i(450)+i(832)]=new h0),this[i(450)+i(832)].isReady||await this._QoSManager[i(482)](),this[i(450)+i(832)]}async function g0(i,t){let r=n,{enableAutoAck:o}=this[r(1313)],x=e[r(1998)](Ge,i[r(1569)][r(712)],e.GXEJS,"1"),l=Ge(i[r(1569)].headers,e[r(1916)],"1"),g=yr[r(1525)](this,i);if(o&&x){let{SeqID:p,LogID:d,service:_,LogIDNew:v,method:P}=i.message;this[r(1189)]({SeqID:p,LogID:d,LogIDNew:v,service:_,method:P,headers:[{key:e[r(1916)],value:"1"},{key:e[r(530)],value:v||""},{key:e[r(488)],value:"0"}]})}l&&!g[r(460)]&&this[r(710)+r(1165)+r(663)](i),t()}async function p0(i,t){let r=n;this[r(1876)](r(956),i[r(1569)]),t()}async function m0(i,t){let r=n,o=e[r(510)](Re,await e[r(1646)](zi,i.data));try{if(o[r(1450)]instanceof Uint8Array){let x=e.iohFv(this._options[r(1704)+r(702)],Object)?{force:!!this[r(1313)]["payloadE"+r(702)][r(1236)],encoding:this[r(1313)][r(1704)+r(702)].encoding?this._options[r(1704)+r(702)][r(1708)].replace(/\s/g,"")["toLowerC"+r(1397)]():""}:{force:!1,encoding:this[r(1313)][r(1704)+r(702)]?this._options.payloadEncoding[r(1010)](/\s/g,"")[r(1832)+r(1397)]():""},l=o[r(1704)+r(702)]?o[r(1704)+r(702)][r(1010)](/\s/g,"")["toLowerC"+r(1397)]():"",g=e[r(456)](this[r(1313)]["payloadT"+r(1968)],Object)?{force:!!this[r(1313)][r(1062)+r(1968)][r(1236)],type:this[r(1313)][r(1062)+r(1968)][r(548)]?this[r(1313)][r(1062)+r(1968)][r(548)][r(1010)](/\s/g,"")["toLowerC"+r(1397)]():""}:{force:!1,type:this[r(1313)][r(1062)+"ype"]?this[r(1313)][r(1062)+r(1968)].replace(/\s/g,"")["toLowerC"+r(1397)]():""},p=o["payloadT"+r(1968)]?o.payloadType[r(1010)](/\s/g,"")[r(1832)+"ase"]():"",d=g[r(1236)]?g[r(548)]:p||g.type,_=x[r(1236)]?x[r(1708)]:l||x[r(1708)],v=[e[r(1404)],e.usyik,e[r(1448)],e.SSEgN],P=[e.RqeaJ,e[r(995)]];this._options[r(1324)+"ansformT"+r(1032)+"ad"]&&v[r(1882)](d)&&(!_||P.includes(_))?o["textPayl"+r(783)]=e[r(1139)](Mi,o.payload,0,o[r(1450)][r(585)+"th"]):o[r(1893)+r(783)]=""}else o[r(1893)+r(783)]=""}catch(x){o[r(1893)+"oad"]="",console[r(1650)](x)}i[r(1569)]=o,e[r(830)](t)}function _0(i,t,r){let o=n,x={riWFz:o(1913)+"t"};if(e[o(1949)](e.ciUsd,e.ciUsd)){let l=e[o(1042)](r,8192),g=e[o(691)](l,1),p=null,d=l;return function(_){let v=o;if(_<1||e[v(1841)](_,g))return i(_);d+_>l&&(p=e[v(748)](i,l),d=0);let P=t.call(p,d,d+=_);return 7&d&&(d=e.ePlnl(e[v(1253)](7,d),1)),P}}else{this[o(1187)+o(455)+"t"]();let l=_0x47ff1b(x[o(435)],{message:"stop imm"+o(1871)+o(1112)+"ct"});this[o(432)+"mediatel"+o(1780)+"ct"]&&this[o(432)+"mediatel"+o(1780)+"ct"](l)}}let w0=4294967295;function y0(i,t,r){let o=n,x={XcmuY:function(l,g){return e[T(842)](l,g)},ZFOdU:function(l,g){return e.ZytnA(l,g)},FSucw:function(l,g,p){return e.rgVqK(l,g,p)},ShGuw:function(l,g){return e[T(1218)](l,g)},llSrc:function(l,g){return e[T(372)](l,g)}};if(e[o(879)](e[o(1225)],e[o(1225)]))return e[o(1364)](RangeError,e[o(1510)](e[o(1035)](e.xEpPi("index ou"+o(782)+o(1627),i),e[o(1509)]),e.egUZA(t,1))+e[o(831)]+r);{let l=0,g=_0x55dc64,p=x.XcmuY(_0x52ebfa,4);for(;x[o(1593)](g,p);){let{value:d,offset:_}=x.FSucw(_0x326b38,_0x4d3acc,g);g=_,l=x.ShGuw(x.llSrc(l,8),0),l+=d}return{value:l,offset:p}}}function b0(i,t,r){let o=n;if(e.BrRvQ(r,w0))throw new Error(e.XHnKj);let x=3;for(;e.SNJoL(x,0);){let l=255&r;e[o(1998)](vr,l,i,e[o(408)](t,x)),r>>>=8,x--}return e[o(911)](t,4)}function v0(i,t){let r=n,o=0,x=t,l=e[r(1402)](t,4);for(;e.gVdGA(x,l);){let{value:g,offset:p}=br(i,x);x=p,o=e[r(1810)](e[r(688)](o,8),0),o+=g}return{value:o,offset:l}}function S0(i,t,r){let o=n,x=e.ksoxM[o(1950)]("|"),l=0;for(;;){switch(x[l++]){case"0":return e[o(393)](e.HODVo(_r,i,t,r),r);case"1":if(!i)return r;continue;case"2":if(t[o(1663)+"e"])return e.ijRKf(t.utf8Write(i,r),r);continue;case"3":if(e[o(684)](i.length,40))return _r(i,t,r)+r;continue;case"4":if(t.write)return t[o(1249)](i,r)+r;continue}break}}function E0(i,t){let r=n,o=new H(e[r(1253)](e[r(1750)](e[r(1583)](i[e[r(581)](t,4)]<<24,e[r(1409)](i[e[r(1689)](t,5)],16)),e.pPgNg(i[t+6],8)),i[e[r(1392)](t,7)]),e[r(1750)](e[r(1553)](i[e.CLfCt(t,0)],24)|i[e.QjziE(t,1)]<<16|e.QRhhL(i[e[r(1601)](t,2)],8),i[t+3]),!0);return t+=8,{value:o,offset:e[r(487)](t,8)}}function C0(i,t,r){let o=n,x=i[o(1438)],l=i[o(837)];return t[r]=l>>>24,t[e[o(1369)](r,1)]=e.hVgIt(e.dZTZK(l,16),255),t[r+2]=e[o(1965)](l,8)&255,t[e.PQfhO(r,3)]=e[o(1016)](255,l),t[e[o(393)](r,4)]=e[o(1183)](x,24),t[e[o(916)](r,5)]=e[o(777)](x,16)&255,t[r+6]=e[o(357)](x>>>8,255),t[e.gwuxI(r,7)]=e[o(1087)](255,x),r+=8,r}function br(i,t){let r=n;return i[r(756)+"8"]?{value:i[r(756)+"8"](t),offset:t+1}:{value:e[r(368)](255,i[t]),offset:t+1}}function vr(i,t,r){let o=n;return t[o(1328)+"t8"]?t[o(1328)+"t8"](i,r):t[r]=e[o(357)](255,i),e[o(1415)](r,1)}let A0=function(i){return new Uint8Array(i)},I0=e[n(444)]!=typeof Buffer?Buffer["allocUns"+n(554)]:e[n(1815)](_0,A0,Uint8Array[n(1961)+"e"][n(1673)]);(()=>{let i=n,t={ApiMo:function(o,x){return e.ZQawz(o,x)},TBiXg:function(o,x){return e[T(1325)](o,x)},quYTN:e[i(384)],DltNP:function(o,x){return e[i(952)](o,x)},vgulf:"eFaSz",eKrfy:function(o,x){return e[i(1908)](o,x)},UIIeX:function(o,x){return e[i(1796)](o,x)},UbNsu:function(o,x){return o|x},IAecQ:function(o,x){return o<<x},zdrln:function(o,x){return e[i(1541)](o,x)},veJPx:function(o,x){return e[i(1186)](o,x)},aJexl:function(o,x){return e[i(733)](o,x)},UJIkJ:function(o,x){return e[i(1651)](o,x)},ieXDf:function(o,x){return e[i(1565)](o,x)},drerL:function(o,x){return e.CpIbY(o,x)},RtiYg:function(o,x){return e[i(675)](o,x)},wMILM:function(o,x){return e[i(1926)](o,x)},fBacl:function(o,x){return e[i(595)](o,x)},WclBB:function(o,x){return e[i(1903)](o,x)},MJliY:function(o,x){return e[i(405)](o,x)},zywuX:function(o,x){return o<x},AnnXq:function(o,x){return o|x},BbxAQ:function(o,x,l,g){return e.MNnFX(o,x,l,g)},aAuzO:function(o,x){return e[i(1750)](o,x)}},r=4294967295;return function(o,x,l=!0){let g=i,p={sReVo:function(d,_){return t.ApiMo(d,_)},TTtyH:function(d,_){return t[T(1698)](d,_)},SYGdc:t[g(735)],JYKKf:g(441)};if(t[g(1064)](t.vgulf,t[g(1462)])){let d=_0x9f05ea[g(1950)](/\./)[g(1734)](P=>_0x33ceb9(P)),_=[];return _[0]=qnzuNu[g(745)](_0x5db142,d[0]+d[1]),_[1]=_0x574f93(qnzuNu[g(849)](d[2],d[3])),[qnzuNu.SYGdc,qnzuNu[g(1420)],g(1545),qnzuNu.SYGdc,qnzuNu.SYGdc,qnzuNu[g(935)],_[0],_[1]][g(1875)]("")}else{if(r=t[g(1826)](127,o[x])>>>0,t[g(1586)](o[x++],128))return{value:l?r:t[g(1059)](0,r),offset:x};if(r=t[g(1059)](r,t[g(1676)](t.zdrln(127,o[x]),7))>>>0,o[x++]<128)return{value:l?r:0|r,offset:x};if(r=t.veJPx(t.UbNsu(r,t.aJexl(t[g(1584)](127,o[x]),14)),0),t.ieXDf(o[x++],128))return{value:l?r:t[g(1059)](0,r),offset:x};if(r=t[g(1791)](t[g(1059)](r,t[g(1958)](t[g(1614)](127,o[x]),21)),0),t.fBacl(o[x++],128))return{value:l?r:t[g(1259)](0,r),offset:x};if(r=t.MJliY(t[g(1259)](r,t[g(1676)](t[g(1584)](15,o[x]),28)),0),t[g(978)](o[x++],128))return{value:l?r:t.AnnXq(0,r),offset:x};if((x+=5)>o.length)throw x=o[g(1955)],t[g(1343)](y0,x,10,o[g(1955)]);return{value:l?r:t[g(1561)](0,r),offset:x}}}})();let P0=16,Sr=32;function k0(i){let t=n;if(e[t(1149)]!=="eFfOO")eBzNvk.ehoNp(_0x1ffe06,_0x566892)&&_0x10855c[t(746)](_0x15f824,_0x1677bb);else{let r=0,o={};for(let x=0;e.edjyL(x,i[t(1955)]);x++)o[i[x][t(1805)+"ame"]]=e[t(1379)](Bi,i[x][t(1805)+t(1285)]),r+=14+o[i[x].cursor_name];return[r,o]}}function Ui(i,t,r){let o=n,x={bwvHr:e[o(1762)],mcoMx:"service",CnlfG:o(1439)+o(448),yDRAl:o(448),rvoET:function(_,v,P,O){return e.zndnZ(_,v,P,O)},IqtYg:e[o(1692)]},[l,g]=e.QMVif(k0,i),p=I0(l),d=0;return i[o(660)](_=>{let v=o;console.log("cursor.s"+v(423),_,_[v(1923)]),d=vr(0,p,d),console[v(1650)](x.bwvHr,d),d=b0(p,d,_[v(1923)]||0),console[v(1650)](x.mcoMx,d),d=vr(g[_[v(1805)+v(1285)]],p,d),console[v(1650)](x[v(764)],d),d=S0(_[v(1805)+v(1285)],p,d),console[v(1650)](x[v(1896)],d),d=x.rvoET(C0,H[v(1222)+"er"](_.cursor||t),p,d),console[v(1650)](x[v(1822)],d)}),{frameType:Sr,headers:[{key:e[o(584)],value:r}],payload:p}}function T0(i){let t=n,r=0,o=[];for(;e[t(1691)](r,i[t(585)+"th"]);){let{offset:x}=e[t(1104)](br,i,r);r=x;let l={cursor_name:"",cursor:0,service:0},{value:g,offset:p}=e.xLHYl(v0,i,r);l[t(1923)]=g,r=p;let{value:d,offset:_}=br(i,r);r=_,l[t(1805)+t(1285)]=e[t(1800)](Mi,i,r,e[t(1665)](r,d)),r+=d;let{value:v,offset:P}=E0(i,r);l[t(1226)]=v.toNumber(),r=P,o[t(1567)](l)}return o}function D0(){let i=n,t={ImEpx:function(r,o){return r(o)}};return e[i(2001)](i(1342),e[i(785)])?{frameType:Sr,headers:[{key:e[i(584)],value:e[i(375)]}],payload:void 0}:(_0x5986e9&&(_0x308d05=(0,_0x146556[WJtcWw[i(721)](_0x28834e,_0x18f97f)[0]])(_0x1762ed=0)),_0x54448b)}class N0{constructor(t,r,o){let x=n;this[x(1548)+"ameSpace"]=t,this[x(654)+"ileName"]=r,this["_message"+x(1721)]=o,this[x(1416)]=Fi(this[x(1548)+"ameSpace"],e[x(1972)])}async[n(482)](){let t=n;await this[t(1416)][t(482)]()}async getCursors(){let t=n;if(!this._qosDB[t(401)])return;let r=this[t(1506)+t(1721)],o=await this[t(1416)].getAll();switch(console[t(1650)](e[t(502)],o),r){case e[t(1854)]:return o&&o[t(1955)]?Ui(o,0,this._cursorFileName):void 0;case e[t(926)]:return;case t(1385):return o&&o[t(1955)]?e[t(1998)](Ui,o,0,this[t(654)+t(1453)]):e[t(1296)](D0)}}async[n(746)](t,r,o){let x=n;if(e[x(1260)]("QzgPc",e.lSKLY))return console[x(1650)](e[x(732)],t,r,o),this[x(1416)][x(746)]({cursor_name:t,cursor:r,service:o});_0x23391f&&_0x5643a9[x(1350)+x(1263)](eBzNvk.gcKqQ,()=>_0x119da1()),_0x534bff&&_0x49b08a[x(1350)+x(1263)](x(857)+x(469),()=>_0x5668f2())}async[n(1904)+"rs"](t){let r=n,o=T0(t);for(let x of o)console[r(1650)]("setcursor",o),await this._qosDB[r(746)](x)}async get(t){let r=n;return(await this._qosDB[r(1967)](t))?.[r(1226)]}async[n(1421)](){let t=n;await this._qosDB[t(1421)]()}[n(605)+n(1261)+n(823)](t){let r=n;if(e.QnSCx(e[r(2003)],r(1399)))switch(_0x1fb82){case"boe":case e.UyzVR:return{[r(542)+_0xdc58ee]:1,"x-tt-env":_0x25f1ef};default:return{}}else this[r(654)+r(1453)]=t}get[n(401)](){return this[n(1416)].isReady}}let R0=e.otKRT;async function Hi(i){let t=n,r={HMgEv:function(o,x){return e[T(1069)](o,x)},OVLpj:function(o,x){return e[T(1369)](o,x)},eCMEv:function(o,x){return e.wKyDP(o,x)},aqTwE:function(o,x){return e[T(1753)](o,x)}};if(e[t(1849)](t(833),e[t(1943)]))_0x1d0e3e=_0x48507b(_0x43a36e),_0x4755c2<32&&(_0x1bccc8|=qerYAa.HMgEv(127&_0x179642,_0x3ee45d)),_0x551e5e+=7;else{if(!this[t(1313)][t(1295)+"S"])return null;let{aID:o,fpID:x,messageStrategy:l}=this[t(1313)],g=i||R0;try{if(this[t(637)+"anager"]){if(e[t(1856)](e[t(1456)],e.sJVpL))return qerYAa[t(1890)](qerYAa[t(858)](1e4,_0x53d359.now()),_0x55d41b[t(1718)](qerYAa[t(1161)](1e4,_0x3930ce[t(1683)]())));i&&this[t(637)+"anager"][t(605)+t(1261)+"Name"](i)}else this["_cursorM"+t(1782)]=new N0(x+"_"+o+"_"+g,g,l);return this[t(637)+t(1782)][t(401)]||await this[t(637)+t(1782)][t(482)](),this[t(637)+t(1782)]}catch{return null}}}async function L0(i,t){let r=n;if(e[r(496)](e.DKaCZ,"UnePe")){let{type:o}=_0xe29a93;this[r(402)](o,_0x5b3ae2)}else{let o=e[r(1998)](Ge,i[r(1569)][r(712)],"code","-1"),x=e[r(1936)](Ge,i[r(1569)][r(712)],e.yWKCP,"1"),l=e.xrSeV(gt,i.message[r(712)],r(987)+r(1709)),g=e[r(690)](Number,e[r(1433)](gt,i[r(1569)][r(712)],e[r(1120)]))||0,p=yr.call(this,i),d=e[r(979)](Ge,i.message[r(712)],e[r(1873)],"2"),_=gt(i[r(1569)][r(712)],e[r(1714)]),v=e[r(371)](Number,e[r(1104)](gt,i[r(1569)][r(712)],e.sYGfn));if(p[r(460)])return t();let P=p[r(758)+r(1471)]?await qi[r(1525)](this):null;if(e[r(1945)](i[r(1569)][r(1923)],0)&&x&&!o||i[r(1569)][r(1923)]>0){if(l&&p[r(758)+r(1471)]&&P)return!!!await P[r(1967)](l)&&(this[r(710)+r(613)+r(1356)](i),await P[r(746)](l,e[r(1266)](Date[r(1546)](),g))),e[r(544)](t);if(d){let O=await Hi.call(this);if(!O)return this[r(710)+r(613)+r(1356)](i),t();let R=await O[r(1967)](_)??-1;if(e.gLtEQ(R,v)){if(e[r(465)](e.qXYwx,r(742)))return _0x2d8f46?_0x770b18[r(1813)+r(1482)](_0x2ebead,_0x7d09f1):_0x2ad153[r(1813)+r(644)](_0x45cf75,_0x3ad9ad);this._dispatchMessageEvent(i),O.set(_,v,i[r(1569)][r(1923)])}else throw new Error("recevied"+r(1603)+r(750)+v+(r(901)+r(1657)+r(1795)+"r ")+R);return e[r(1672)](t)}return this["_dispatc"+r(613)+r(1356)](i),e[r(1129)](t)}}}async function O0(i,t){let r=n,o=yr[r(1525)](this,i);if(!o["isQoSMes"+r(1471)])return t();let x=await qi[r(1525)](this);if(o[r(1030)+r(1301)+r(882)]&&o[r(1835)+"s"][r(1955)])for(let l of o[r(1835)+"s"])await x.del(l);e[r(1672)](t)}async function B0(i,t){let r=n,o=e.BKpxA(i[r(1569)][r(1710)+"e"],P0),x=e.ngMoo(i[r(1569)].frameType,Sr);if(e[r(1668)](!o,!x))return t();let l=e.wtWVh(gt,i[r(1569)][r(712)],e[r(584)]);if(!l)return e.KQooj(t);let g=await Hi[r(1525)](this,l);if(!g)return e[r(1296)](t);if(o){let p=await g[r(1286)+"rs"](),d={frameType:p?.[r(1710)+"e"],SeqID:H[r(1222)+"er"](this[r(1272)]++),LogID:H.fromNumber(this[r(1313)][r(762)+r(474)]()),service:9e3,method:5,headers:p?.[r(712)],payload:p?.payload},_=S(d);this._ws&&this[r(1185)].readyState&&this[r(1185)][r(422)](_)}if(x){let p=i[r(1569)].payload;p&&g[r(1904)+"rs"](p)}}let M0=async function(i,t){let r=n;e[r(1849)](e[r(1246)],e[r(1700)])?(this._isInit=!1,e[r(1117)](clearTimeout,this["_connect"+r(1136)+"utId"]),e[r(1207)](t)):(this[r(402)](e[r(1783)],_0x293b8a),this[r(1778)]&&this[r(1778)](_0x1aacb3))},z0=async function(i,t){let r=n;if(!this[r(1185)]||e[r(1175)](this[r(1185)].readyState,this[r(681)]))return t();let{pingInterval:o}=this._options;this[r(671)+r(1240)]?.[r(1063)+"pointConfig"]();for(let l=0;e[r(914)](l,this[r(1506)+r(1079)][r(1955)]);l++){let g=this._messageQueue[l];if(e[r(1413)](this[r(1185)][r(1066)+"te"],this[r(681)])&&e[r(1191)](null,g))this[r(1185)]&&this[r(1185)][r(422)](g),this[r(1506)+r(1079)][l]=null;else break}this[r(1506)+r(1079)]=this[r(1506)+r(1079)][r(697)](l=>!!l),this[r(1652)+"gTimeoutId"]=setTimeout(()=>this[r(578)](),o),this["_dispatc"+r(1902)+"nt"](i),this[r(1754)+"er"]&&this[r(1185)]&&(this[r(1185)][r(966)+"pe"]=this[r(1897)+r(1968)]);let x=this[r(671)+r(1240)]?.[r(677)+r(1190)+"nt"]();this[r(1876)](r(1391)+x+" success"),e[r(544)](t)},F0=async function(i,t){let r=n,o=this._endpointManager?.[r(677)+r(1190)+"nt"]();this[r(1876)](r(1391)+o),e[r(1347)](t)};class q0 extends mr{constructor(t){let r=n,o={PhgUF:function(p,d){return e[T(421)](p,d)},pBdYb:e[r(661)],cKJOp:e[r(1245)],SpKaP:function(p,d,_){return e[r(531)](p,d,_)},FuOcw:function(p,d,_,v){return e[r(979)](p,d,_,v)},hftKF:function(p,d,_){return e.vbcEy(p,d,_)},spuHJ:function(p,d,_){return e[r(477)](p,d,_)},fmNOI:e[r(589)],baArp:function(p,d){return p!==d},jndPY:e[r(591)],kjfHH:function(p,d){return e.TBLte(p,d)},jLxpn:function(p,d,_){return e.rGVlB(p,d,_)},jCvTp:function(p,d,_){return p(d,_)},UvPHG:e[r(446)],jjWpm:function(p,d){return e[r(700)](p,d)},XEHaJ:function(p,d,_){return e[r(1024)](p,d,_)}};super(),this[r(426)+r(940)+r(1598)]=!0,this[r(1754)+"er"]=ht,this[r(820)]=n0,this._isMiniTT=it,this._isMiniWX=Ot,this[r(1360)+"r"]=Bt,this["_message"+r(1079)]=[],this[r(671)+"tManager"]=null,this[r(597)+"osed"]=!1,this[r(1897)+"ype"]=e.lnrQd,this[r(400)+"Lock"]=!1,this["_connect"+r(1136)+r(1407)]=null,this["_reconne"+r(1623)+r(1540)]=null,this._pingPongTimeoutId=null,this._seqId=0,this[r(419)]=!1,this[r(618)]="",this[r(450)+"ger"]=null,this[r(637)+r(1782)]=null,this[r(1674)+r(390)]=null,this[r(1130)+"ls"]=e[r(1173)],this.CLOSED=3,this.CONNECTING=0,this[r(681)]=1,this[r(1910)]=2,this[r(1764)]=p=>{let d=r;try{Oi(this,p,[M0,z0,F0])}catch(_){if(e[d(1856)](e.bmAFU,d(925))){let v=pe(e.Ewndp,{message:_[d(1569)],code:je.OPEN_ERROR,error:_});this[d(710)+d(492)+"ent"](v)}else return _0xcbfdd3?this[d(1504)+"E"]():this[d(1571)+"E"]()}},this._onMessage=async p=>{let d=r,{pingInterval:_,pingFrequency:v}=this[d(1313)];if((o[d(1200)]("hi",p[d(850)])&&o.PhgUF(d(1476),v)||d(2e3)===v)&&(this["_clearPi"+d(729)](),this[d(402)](o[d(1723)],o[d(1888)]),this[d(1652)+"gTimeoutId"]=o.SpKaP(setTimeout,this[d(578)].bind(this),_)),p.data!=="hi")try{o[d(766)](Oi,this,p,[m0,g0,O0,B0,L0,p0])}catch(P){let O=o[d(1488)](pe,"error",{message:P[d(1569)],code:je[d(1839)+d(1378)],error:P});this[d(710)+"hErrorEvent"](O)}},this._onError=p=>{let d=r,_=this[d(671)+"tManager"]?.[d(1447)+d(414)+"es"](),v=this[d(671)+d(1240)]?.[d(677)+d(1190)+"nt"]();if(_&&!p[d(1569)]){let P=d(642)+v+(d(908)+d(1481)+d(1748)+"ed");this[d(710)+d(492)+"ent"](e.tktXd(pe,e.Ewndp,{message:P,code:je[d(1070)+d(1291)+"R"],error:p}));return}this[d(1185)]&&e[d(1239)](this[d(1185)][d(1066)+"te"],this.OPEN)&&this[d(1530)+d(1575)](),this[d(710)+d(492)+d(920)](pe(d(938),{message:p[d(1569)],code:je[d(1451)+d(378)],error:p}))},this[r(954)]=async p=>{let d=r;this[d(1532)+d(1206)](),this[d(1208)+"ngTimer"](),this["_removeW"+d(1834)+"rs"](),this[d(1185)]=null,this[d(400)+d(1159)]=!1;let _=this[d(671)+"tManager"]?.[d(1447)+d(414)+"es"]();if(!_&&this["_navigat"+d(1602)]()&&!this["_readyCl"+d(1443)]){let v=this["_endpoin"+d(1240)]?.[d(677)+d(1190)+"nt"](),P=this[d(1313)]["reconnec"+d(1466)+d(936)](p[d(1741)],p[d(1993)]);this[d(710)+d(1374)+d(920)](o.spuHJ(ye,o.fmNOI,{code:1006,reason:p[d(1993)]||d(1874)+d(607)+"d, unkno"+d(1212)+d(1566)+d(1560)+v,willReconnect:P})),P&&this[d(400)]();return}if(o.baArp(1e3,p.code)&&this[d(597)+d(1443)]){this["_dispatc"+d(1374)+d(920)](o[d(1488)](ye,d(1887),{code:1e3,reason:o.jndPY})),this[d(671)+d(1240)]?.["resetEnd"+d(666)+d(1320)](),this["_pingLos"+d(390)]?.[d(627)+d(1894)]();return}if(o[d(1375)](1e3,p[d(1741)])&&_){let v=this[d(671)+d(1240)]?.[d(677)+d(1190)+"nt"](),P=p[d(1993)];P||(P=await o[d(805)](x0,this[d(618)])),P=d(1874)+d(607)+d(1403)+P+(d(772)+"me: ")+v+(d(497)+d(1464)+d(376)),this[d(710)+"hCloseEv"+d(920)](o[d(973)](ye,o.fmNOI,{code:p[d(1741)],reason:P}));let O=d(642)+v+(d(908)+d(1481)+d(1748)+"ed");this["_dispatc"+d(492)+"ent"](o[d(889)](pe,o[d(1267)],{message:O,code:je[d(1070)+d(1291)+"R"]})),this._endpointManager?.[d(1063)+d(666)+"fig"](),this[d(1674)+d(390)]?.[d(627)+d(1894)]();return}if(o[d(1769)](1e3,p[d(1741)])&&!p[d(1993)]){let v=this["_endpoin"+d(1240)]?.[d(677)+d(1190)+"nt"]();this["_dispatc"+d(1374)+d(920)](o.XEHaJ(ye,o[d(915)],{code:p[d(1741)],reason:d(1874)+d(607)+d(2002)+"wn reaso"+d(1566)+d(1560)+v})),this[d(671)+"tManager"]?.[d(1063)+d(666)+d(1320)](),this[d(1674)+d(390)]?.resetCounter();return}this[d(710)+"hCloseEvent"](p),this[d(671)+d(1240)]?.["resetEnd"+d(666)+"fig"](),this[d(1674)+d(390)]?.[d(627)+d(1894)]()},this[r(1393)]=null,this[r(846)]=null,this[r(1162)+"e"]=null,this[r(1778)]=null,this["onStartR"+r(1422)]=null,this[r(1930)+r(1311)]=null,this["onStopIm"+r(1846)+"yReconnect"]=null,this[r(860)+r(1872)]=this["_handleO"+r(1872)][r(1591)](this),this[r(860)+r(1167)]=this[r(860)+"ffLine"][r(1591)](this),this._handlePageHide=this[r(1444)+r(1335)].bind(this),this[r(1444)+"ageShow"]=this[r(1444)+r(598)].bind(this),this[r(1313)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(1981)](1,0),service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[r(1563)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.Ckecg,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:l}=t,g=Array[r(1034)](x)?x:e.IgWHE(r(1009),typeof x)?[x]:[];if(!g||g.length===0)throw new Error(e[r(550)]);if(!e.tDRHw(s0,l))throw new Error(e[r(609)]);Object[r(1114)](this[r(1313)],t),this[r(671)+"tManager"]=new Li(g,this._options[r(1615)+"es"]),this[r(1674)+r(390)]=new c0(this[r(1313)][r(1528)+"Count"]),this._options[r(1524)+r(665)]&&(this[r(419)]=!0,this[r(400)]()),this[r(1313)][r(452)+r(930)+r(571)]&&(this[r(1434)+"T"]||this[r(1564)+"X"]?this["_onPageN"+r(1018)+r(1608)]():this[r(1754)+"er"]&&this[r(1093)+r(1072)+r(1263)]())}[n(860)+n(1872)](){let t=n;this._options[t(865)+t(1730)+t(1570)]||this[t(597)+t(1443)]||this["_handleR"+t(1422)]()}[n(860)+n(1167)](){let t=n;this[t(1187)+"WebSocket"]();let r=e.toQbm(pr,e.JbptV,{message:e.SGaeP});this[t(432)+t(1846)+t(1780)+"ct"]&&this["onStopIm"+t(1846)+t(1780)+"ct"](r)}[n(1093)+"balEventListener"](){let t=n;this[t(1754)+"er"]&&window[t(1350)+t(1263)](e.RvzuU,this[t(860)+"nLine"]),this._isBrowser&&window["addEvent"+t(1263)](e[t(547)],this["_handleO"+t(1167)]),this[t(1754)+"er"]&&window[t(1350)+t(1263)](e[t(714)],this[t(1444)+t(1335)]),this[t(1754)+"er"]&&window[t(1350)+t(1263)](t(1400),this[t(1444)+"ageShow"])}["_dropGlobalEvent"+n(1263)](){let t=n;this[t(1754)+"er"]&&window["removeEv"+t(599)+t(484)](e[t(503)],this[t(860)+t(1872)]),this[t(1754)+"er"]&&window["removeEv"+t(599)+"ner"](e[t(547)],this[t(860)+t(1167)]),this[t(1754)+"er"]&&window[t(934)+t(599)+t(484)](t(1204),this[t(1444)+t(1335)]),this[t(1754)+"er"]&&window[t(934)+"entListe"+t(484)](e[t(381)],this[t(1444)+t(598)])}[n(1444)+n(1335)](t){let r=n;!t[r(992)+"d"]&&(this[r(1754)+"er"]&&window[r(934)+r(599)+r(484)](e.zelUe,this[r(1444)+r(1335)]),this._isBrowser&&window[r(934)+r(599)+r(484)](e[r(381)],this[r(1444)+"ageShow"]),this[r(1887)]()),this[r(1754)+"er"]&&window[r(934)+"entListe"+r(484)](e[r(503)],this["_handleO"+r(1872)]),this[r(1754)+"er"]&&window[r(934)+r(599)+r(484)](e[r(547)],this[r(860)+r(1167)])}_handlePageShow(t){let r=n;t[r(992)+"d"]&&(this[r(1134)+r(1602)]()&&(!this[r(1185)]||this[r(1185)][r(1066)+"te"]!==this[r(681)]||e[r(558)](this[r(1185)].readyState,this[r(947)+"NG"]))&&this[r(860)+r(1872)](),this[r(1754)+"er"]&&window[r(1350)+r(1263)](e[r(503)],this[r(860)+r(1872)]),this[r(1754)+"er"]&&window["addEvent"+r(1263)](e[r(547)],this["_handleO"+r(1167)]))}async[n(1294)+n(1636)](t){let r=n;if(e[r(859)](e[r(382)],e[r(701)])){let{fpID:o,deviceID:x,bddID:l,ttwID:g,accessKey:p,aID:d,customParams:_={},enableAutoAck:v,enableQoS:P,QoSLevel:O,env:R}=this[r(1313)],G,se,K;if(this[r(1754)+"er"]||this[r(1564)+"X"]||this[r(1434)+"T"])G=location&&e.iugyP(e.ligxU,location[r(1773)])?e[r(1254)]:e.DmaqL,se=t.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),K=/^wss(.*:\/\/)/[r(411)](t)?t:""+G+se;else if(e[r(358)](e[r(1142)],e[r(1142)]))G=r(560),se=t[r(1010)](/(^http)((?:[s]*:\/\/))/,""),K=/(^ws)((?:[s]*:\/\/))/[r(411)](se)?se:""+G+se;else{if(e[r(1543)](void 0,_0x24bd64))this[r(909)+"rs"]={};else if(e.EBlQH(void 0,_0x3c0152))this[r(909)+"rs"][_0x2c58a9]=null;else{let Je=this[r(909)+"rs"][_0x3de520];if(Je)for(let Ve=0;e[r(912)](Ve,Je[r(1955)]);)e.hNdJv(Je[Ve].fn,_0xd64470)?Je.splice(Ve,1):++Ve}return this}let V=l?e[r(1188)]:g?e[r(1596)]:r(461)+"d",We=l||g||x;if(e.fcBgz(!We,!V))throw new Error(e[r(730)]);let U0=e[r(1759)]("function",typeof _)?await e[r(1985)](_):_,H0=R?a0(R[r(990)],R.xTTEnv):{},Er=Object[r(1114)]({device_platform:e.KlSKq,version_code:e[r(810)],access_key:p,fpid:o,aid:d,[V]:We,xsack:v?1:0,xaack:v?1:0,xsqos:P?1:0,qos_level:P?O:void 0,qos_sdk_version:2,...H0},U0),K0=Object[r(1152)](Er)[r(1703)]((Je,Ve)=>Er[Ve]!==void 0?""+Je+(Je?"&":"?")+Ve+"="+Er[Ve]:Je,"");return K+r(1468)+K0}else{let o=new _0x57dbfe(e[r(359)](2,_0x6e3398));o[r(746)](_0x3296f6),_0x2fa15d[r(626)]=o}}async[n(400)](){let t=n,r={wpFdn:e[t(589)],bUaJe:function(o,x,l){return o(x,l)}};if(!(this[t(400)+t(1159)]||this["_readyCl"+t(1443)])){this[t(400)+"Lock"]=!0;try{let o=this[t(671)+t(1240)]?.[t(1172)+t(522)+t(475)+t(1257)+"tries"](),{timeoutInterval:x}=this[t(1313)];if(o)if(e[t(859)](t(1303),e[t(458)])){let g=this[t(671)+t(1240)]?.[t(677)+"ntEndpoint"](),p=this[t(671)+"tManager"]?.[t(900)+t(988)+t(744)+"UpdateCo"+t(1771)](),d=this[t(671)+t(1240)]?.[t(677)+t(1190)+t(567)+"ount"]();if(p){let _=t(642)+g+(" timeout"+t(497)+t(1464)+t(1401)+"ill use "+t(395)+t(1231))+p+" to retry",v=e.YxuZq(pe,e[t(446)],{message:_,code:je["MAX_RETR"+t(1291)+"R"]});this[t(1876)](_),this["_dispatchErrorEv"+t(920)](v),this[t(618)]=await this[t(1294)+"eUrl"](p),this._debug(t(642)+p+" "+d+" times"),this[t(892)+t(1834)+"rs"]()}else{let _=t(642)+g+(t(696)+t(497)+t(1464)+t(376));this[t(1876)](_),this[t(710)+"hErrorEv"+t(920)](e[t(1951)](pe,t(938),{message:_,code:je[t(1070)+t(1291)+"R"]}));return}}else{if(this[t(671)+t(1240)]?.[t(1447)+t(414)+"es"]()){let p=this[t(671)+"tManager"]?.[t(677)+t(1190)+"nt"]();this[t(710)+t(1374)+t(920)](_0x49859a(r[t(1666)],{code:1006,reason:t(642)+p+(t(696)+t(497)+t(1464)+"ached"),wasClean:!0}))}else{let p=this[t(1313)]["reconnec"+t(1466)+t(936)](_0x5d8965,_0x37e61c);this[t(710)+t(1374)+t(920)](r[t(726)](_0x125ddb,r[t(1666)],{code:_0x5a20de,reason:_0x297e7a,wasClean:!0,willReconnect:p})),p&&this[t(400)]()}return}else{let g=this[t(671)+"tManager"]?.["getCurre"+t(1190)+t(535)+t(1617)](),p=this[t(671)+t(1240)]?.["getCurre"+t(1190)+t(567)+t(1847)]();this[t(618)]=await this[t(1294)+t(1636)](e[t(1238)](g,"")),this._debug("connect "+g+" "+p+t(1637)),this["_removeW"+t(1834)+"rs"]()}if(this[t(419)])this[t(419)]=!1;else{let g=e[t(1951)](pr,e[t(1821)],{message:"start"});this[t(1549)+t(1422)]&&this[t(1549)+"econnect"](g)}let l=this._endpointManager?.["getCurre"+t(1190)+t(567)+"ount"]()||0;l>1&&await this[t(617)](e.twuBB(l,1)),this[t(1876)]("connecti"+t(1917)+this[t(618)]+(" protoco"+t(809))+this[t(1130)+"ls"]),this._ws=i0({url:this._url,protocols:[this[t(1130)+"ls"]],headers:this[t(1313)][t(524)+t(1316)+"s"][t(1091)+t(1693)]},this[t(1313)].ws),(this[t(1754)+"er"]||this[t(1360)+"r"])&&this[t(1185)]&&(this[t(1185)][t(966)+"pe"]=this[t(1897)+t(1968)]),this[t(1370)+"steners"](),this[t(400)+t(1136)+t(1407)]=setTimeout(this[t(1327)+"ut"][t(1591)](this),x)}catch(o){throw this[t(400)+t(1159)]=!1,o}}}[n(1532)+n(1206)](){let t=n,r={vMNsd:function(o,x){return e[T(1935)](o,x)},YFajo:function(o,x){return o(x)}};if(e.EDvuN(e[t(1756)],e[t(1756)]))return _0x8994cf.apply(sUPBjc[t(528)](_0x49d858,this),_0x683d1c),sUPBjc[t(464)](_0x4fb04a,_0x1ee82b[t(1967)](this));e[t(1461)](clearTimeout,this[t(400)+t(1136)+t(1407)]),this["_connect"+t(1136)+t(1407)]=null}["_clearPi"+n(729)](){let t=n;e.VrXZb(clearTimeout,this[t(1652)+t(1353)+"Id"]),clearTimeout(this["_reconne"+t(1623)+t(1540)]),this[t(1652)+t(1353)+"Id"]=null,this["_reconne"+t(1623)+t(1540)]=null}_debug(...t){let r=n;this[r(1313)][r(399)]&&console.log[r(1881)](console,[e[r(573)],...t])}[n(1290)+n(1772)+"e"](t){let r=n,o={nRIGv:e[r(1686)],MrTio:e[r(541)],xvbZw:function(x,l){return x===l},BScQE:e[r(794)]};if(e[r(960)](e.SKWIZ,e[r(1446)])){let x=o[r(719)][r(1950)]("|"),l=0;for(;;){switch(x[l++]){case"0":if(!this._ws)return void this[r(1876)](o[r(771)]);continue;case"1":this[r(980)+"balEvent"+r(1263)]();continue;case"2":this["_clearPi"+r(729)]();continue;case"3":this["_QoSMana"+r(832)]?.[r(1421)]();continue;case"4":this._readyClosed=!0;continue;case"5":this[r(1187)+r(455)+"t"](_0x3194ab,_0x14f0f8);continue;case"6":if(o[r(896)](this[r(1185)].readyState,this[r(1842)])||o[r(896)](this._ws[r(1066)+"te"],this[r(1910)]))return void this[r(1876)](o[r(1058)]);continue;case"7":this["_clearTi"+r(1206)]();continue}break}}else{let{initReconnectInterval:x,maxReconnectInterval:l,reconnectIntervalGrowFactor:g}=this._options,p=e[r(1144)](x,Math.pow(g,e[r(829)](t,1)));return e[r(1452)](p,l)?l:p}}_ping(){let t=n;if(this._ws&&e[t(767)](this[t(1185)].readyState,this[t(947)+"NG"])){this[t(1208)+t(729)](),this[t(1652)+"gTimeoutId"]=e.wtWVh(setTimeout,this._ping.bind(this),this[t(1313)]["pingInte"+t(1252)]);return}if(!this._ws||e.WmiZq(this[t(1185)][t(1066)+"te"],this[t(681)]))return void this[t(1962)+t(1422)]();this[t(1185)]&&this._ws[t(422)]("hi"),this[t(379)+t(1623)+t(1540)]=e[t(658)](setTimeout,this[t(1962)+t(1422)+t(1891)][t(1591)](this),this[t(1313)][t(1127)+t(1766)+t(709)])}["_handleR"+n(1422)+"Timeout"](){let t=n;e[t(1740)]("vgspx","hWqnJ")?this._options.debug&&_0x1297bf[t(1650)][t(1881)](_0x594958,[e.OiYWa,..._0x266109]):(this[t(1674)+t(390)]?.addCount(),this[t(402)](e[t(1264)],e[t(674)]),this["_pingLos"+t(390)]?.[t(1447)+"chMaxCount"]()?this[t(1962)+t(1422)]():this[t(578)]())}[n(1134)+n(1602)](){let t=n;return this[t(1434)+"T"]||this[t(1564)+"X"]?this["_miniNav"+t(940)+t(1598)]:(this[t(1754)+"er"]||this._isWorker)&&this[t(1313)][t(452)+t(930)+"nged"]?navigator[t(1838)]:!0}[n(1962)+n(1422)](){let t=n;!this[t(1134)+"orOnline"]()||this[t(597)+t(1443)]||(this["_endpoin"+t(1240)]?.[t(1063)+t(666)+t(1320)](),this._pingLossCounter?.[t(627)+t(1894)](),this[t(1185)]?this[t(1530)+t(1575)](1001,e[t(1706)],!0):this[t(400)]())}[n(667)+n(1018)+n(1608)](){let t=n,r={CpgmK:function(o,x){return e[T(1341)](o,x)},ZFbMF:function(o,x){return o<x},CAaJy:function(o,x){return o+x},LvNvi:function(o,x){return e[T(445)](o,x)},ukmmK:function(o,x){return e[T(1669)](o,x)},uSFkd:function(o,x){return e[T(1182)](o,x)}};if(e[t(1317)](e[t(646)],e[t(646)]))this[t(1434)+"T"]?tt[t(942)+t(1664)+t(469)](({isConnected:o})=>{let x=t;this["_miniNav"+x(940)+"line"]=o,o?this["_handleO"+x(1872)]():this[x(860)+x(1167)]()}):this[t(1564)+"X"]&&wx[t(942)+t(1664)+"hange"](({isConnected:o})=>{let x=t;this[x(426)+x(940)+x(1598)]=o,o?this[x(860)+x(1872)]():this[x(860)+x(1167)]()});else{let o=_0x2ba473.charCodeAt(_0x5f32c2);o>=55296&&fBdvSn[t(669)](o,56319)&&fBdvSn[t(437)](fBdvSn[t(927)](_0x24683d,1),_0x1b8a08)&&(o=fBdvSn[t(486)](fBdvSn[t(672)](o,10)+_0x4190c5.charCodeAt(++_0x3d5613),56613888)),_0x483079+=o<128?1:o<2048?2:fBdvSn.uSFkd(o,65536)?3:4}}[n(617)](t){let r={agqAP:function(o,x,l){return e[T(1050)](o,x,l)}};return new Promise(o=>{let x=T;r[x(1330)](setTimeout,o,this[x(1290)+"rvalValue"](t))})}[n(1530)+n(1575)](t=1e3,r="",o=!1){let x=n,l={FAecH:function(g,p,d,_){return e[T(1611)](g,p,d,_)}};if(e[x(1829)](e[x(415)],x(1179)))RyPehw[x(1929)](_0xc21d8f,this,_0x4b54d6,[_0x207370,_0x435561,_0x57ea32]);else{if(!this[x(1185)])return;this._destroyWebSocket(t,r,o)}}_onTimeout(){let t=n,r=this["_endpoin"+t(1240)]?.[t(677)+"ntEndpoint"]();this._debug("connect "+r+" timeout"),this[t(1530)+t(1575)](1001,e[t(1864)],!0)}_sendAck(t){let r=n,o=e[r(679)](gr,t);this._ws&&e.atYRs(this[r(1185)][r(1066)+"te"],this[r(681)])&&(this[r(1185)]&&this[r(1185)].send(o),this[r(1876)](e.CRbMw,t))}[n(892)+n(1834)+"rs"](){let t=n,r=e[t(389)][t(1950)]("|"),o=0;for(;;){switch(r[o++]){case"0":if(!this[t(1185)])return;continue;case"1":this[t(1185)][t(934)+"entListe"+t(484)](e[t(698)],this[t(1889)+"ge"]);continue;case"2":this[t(1185)]["removeEv"+t(599)+"ner"](e[t(446)],this[t(425)]);continue;case"3":this[t(1185)][t(934)+"entListener"](e[t(1783)],this[t(1764)]);continue;case"4":this[t(1185)][t(934)+"entListe"+t(484)](t(1887),this[t(954)]);continue}break}}[n(1370)+"steners"](){let t=n,r=e.afSRi[t(1950)]("|"),o=0;for(;;){switch(r[o++]){case"0":this._ws[t(1350)+t(1263)](e.Ewndp,this[t(425)]);continue;case"1":this._ws[t(1350)+"Listener"](t(873),this[t(1764)]);continue;case"2":this[t(1185)][t(1350)+t(1263)](e[t(589)],this[t(954)]);continue;case"3":if(!this[t(1185)])return;continue;case"4":this[t(1185)][t(1350)+"Listener"](e.mMRCq,this[t(1889)+"ge"]);continue}break}}["_wsInsta"+n(1454)](t=1e3,r=""){let o=n;try{this[o(1185)]&&this[o(1185)][o(1887)](t,r)}catch{}}[n(1187)+n(455)+"t"](t=1e3,r="",o=!1){let x=n,l={sTvHC:function(g,p){return g<p},Nfqgf:function(g,p){return e[T(829)](g,p)},GQukI:function(g,p){return e[T(1322)](g,p)},jDSbs:function(g,p){return e[T(507)](g,p)},aRKIW:function(g,p){return g>=p},VvurH:function(g,p){return g|p},hvIeQ:function(g,p){return e.mvcrx(g,p)},SBLIi:function(g,p){return e.ucoEE(g,p)},XJhYr:function(g,p){return g>=p},fpztk:function(g,p){return e[T(1669)](g,p)},rWovP:function(g,p){return e[T(1441)](g,p)},OqtRD:function(g,p){return e[T(1514)](g,p)},PRxvv:function(g,p){return e[T(1256)](g,p)}};if(e[x(1552)]==="jAMjQ")_0x17212e[x(1924)]()[x(1722)](()=>{let g=x;this[g(1370)+g(428)]()});else{if(this._clearPingTimer(),this[x(1532)+x(1206)](),this[x(892)+x(1834)+"rs"](),this[x(1089)+"nceClose"](1e3,r),this[x(400)+x(1159)]=!1,o&&this[x(1134)+"orOnline"]()&&!this[x(597)+x(1443)]){if(this[x(671)+x(1240)]?.[x(1447)+"chMaxTries"]())if(x(438)===x(438)){let p=this[x(671)+"tManager"]?.["getCurre"+x(1190)+"nt"]();this[x(710)+x(1374)+x(920)](e[x(1844)](ye,e[x(589)],{code:1006,reason:x(642)+p+(x(696)+x(497)+x(1464)+x(376)),wasClean:!0}))}else{if(xyyZwd[x(1230)](xyyZwd[x(1877)](_0xe1e984,_0x319f34),1))return"";let p="";for(let d=_0x5ce597;xyyZwd.GQukI(d,_0x5e725b);){let _=_0x4d3d2f[d++];if(xyyZwd[x(468)](_,127))p+=_0x6752fd["fromChar"+x(680)](_);else if(xyyZwd[x(1517)](_,192)&&xyyZwd[x(1373)](_,224))p+=_0x28c5ab["fromChar"+x(680)](xyyZwd[x(1959)](xyyZwd[x(1572)](xyyZwd[x(1892)](31,_),6),xyyZwd.SBLIi(63,_0x354b38[d++])));else if(xyyZwd[x(969)](_,224)&&xyyZwd[x(1230)](_,240))p+=_0x1c6dbb["fromChar"+x(680)](xyyZwd.VvurH((15&_)<<12,xyyZwd[x(1830)](xyyZwd[x(1892)](63,_0x2b77e8[d++]),6))|xyyZwd.rWovP(63,_0x4e3f0a[d++]));else if(xyyZwd.aRKIW(_,240)){let v=xyyZwd[x(1792)](xyyZwd[x(1959)](xyyZwd.VvurH((7&_)<<18|xyyZwd[x(1830)](xyyZwd[x(1277)](63,_0x8e266d[d++]),12),xyyZwd.hvIeQ(xyyZwd[x(1892)](63,_0x51a7d4[d++]),6)),xyyZwd.rWovP(63,_0x24ab0c[d++])),65536);p+=_0x4d4f99["fromChar"+x(680)](xyyZwd[x(536)](55296,v>>10)),p+=_0x5aeefc[x(1787)+x(680)](xyyZwd[x(536)](56320,xyyZwd[x(1892)](1023,v)))}}return p}else{let p=this[x(1313)][x(1913)+"tInterce"+x(936)](t,r);this[x(710)+x(1374)+"ent"](e[x(1801)](ye,e.gcKqQ,{code:t,reason:r,wasClean:!0,willReconnect:p})),p&&this[x(400)]()}return}this[x(1134)+x(1602)]()||this[x(597)+"osed"]?this[x(710)+x(1374)+x(920)](e[x(1662)](ye,e[x(589)],{code:t,reason:x(985)})):this[x(710)+"hCloseEv"+x(920)](ye(e.gcKqQ,{code:1006,reason:e[x(1022)]})),this[x(1185)]=null,this[x(671)+x(1240)]?.["resetEnd"+x(666)+x(1320)](),this["_pingLos"+x(390)]?.[x(627)+x(1894)]()}}[n(710)+"hOpenEvent"](t){let r=n;r(950)===r(950)?(this.emit(e[r(1783)],t),this[r(1778)]&&this[r(1778)](t)):(e[r(1068)](_0x4474e3,e[r(674)]),this[r(725)](e[r(661)],_0x37a9e1),this.off(e[r(1264)],_0x4183ad))}[n(710)+n(613)+n(1356)](t){let r=n;this[r(402)](r(1569),t),this[r(1162)+"e"]&&this[r(1162)+"e"](t)}[n(710)+n(1165)+"ageEvent"](t){let r=n;this.emit(e[r(1630)],t),this[r(1930)+"eAck"]&&this[r(1930)+r(1311)](t)}[n(710)+"hErrorEvent"](t){this.emit(e.Ewndp,t),this.onerror&&this.onerror(t)}["_dispatchCloseEv"+n(920)](t){let r=n;this[r(402)](e.gcKqQ,t),this[r(1393)]&&this[r(1393)](t)}get[n(966)+"pe"](){let t=n,r={LhjjP:function(o,x){return e[T(1736)](o,x)}};if(e[t(1744)](t(467),e[t(1884)]))return this[t(1185)]?this[t(1185)].binaryType:this[t(1897)+t(1968)];llQlSx.LhjjP(_0x4901d5,this[t(400)+"ionTimeo"+t(1407)]),this[t(400)+t(1136)+t(1407)]=null}set[n(966)+"pe"](t){let r=n,o={vWbci:e[r(698)],CnkBn:function(x,l,g){return e[r(1111)](x,l,g)}};e.cYalZ(e[r(1503)],e.tWoRk)?(this[r(1897)+r(1968)]=t,this[r(1185)]&&(this[r(1185)][r(966)+"pe"]=t)):this[r(402)](fVhHcm[r(1660)],fVhHcm[r(1414)](_0x103c6a,fVhHcm.vWbci,{..._0x289ed4}))}get[n(967)+"nt"](){let t=n;return this[t(671)+t(1240)]?.["getCurre"+t(1190)+t(567)+t(1847)]()||0}get[n(529)+n(1216)](){let t=n,r={PTRNK:function(o,x){return e[T(1982)](o,x)},XLEAI:function(o,x){return o|x},dqgnf:function(o,x){return o&x},lZEIm:function(o,x){return o<<x},QQbev:function(o,x){return e[T(631)](o,x)},nmGDJ:function(o,x){return o<x},mDbiR:function(o,x){return e[T(1002)](o,x)},rlKjg:function(o,x,l){return e[T(1725)](o,x,l)},kjoCC:function(o,x){return e[T(1384)](o,x)},ZAygD:function(o,x){return e.gfZar(o,x)},jXiph:e.JxbxG,chEqD:t(397)};if(e[t(516)]===e[t(516)]){let o=this[t(1506)+t(1079)].reduce((x,l)=>{let g=t;if(r[g(738)]===r[g(1029)])_0x16b902=kHNXdj[g(1348)](kHNXdj[g(1348)](kHNXdj[g(1632)](kHNXdj[g(1797)](7,_0x41ca18)<<18,kHNXdj[g(1004)](kHNXdj[g(1928)](63,_0x2c3195),12)),kHNXdj.lZEIm(63&_0x3eb926,6)),63&_0xeefc74),kHNXdj[g(897)](_0x29b33b,65536)||kHNXdj.mDbiR(_0x11bbde,1114111)?_0x366070+=_0xb490e8:(_0x4f634a-=65536,_0x351d45+=kHNXdj[g(1654)](_0x2bda3e,kHNXdj[g(1554)](_0x36fd66>>10,55296),kHNXdj[g(1696)](kHNXdj[g(1797)](1023,_0x5ef882),56320)),_0x1507aa+=3);else return x+=l&&l.byteLength||0,x},0);return e[t(1499)](o,this._ws?this[t(1185)][t(529)+t(1216)]:0)}else this[t(909)+"rs"]={}}get[n(1814)+"ns"](){let t=n;return this[t(1185)]?this._ws[t(1814)+"ns"]:""}get protocol(){let t=n;return this[t(1185)]?this[t(1185)][t(1773)]:""}get readyState(){let t=n;return this._ws?this[t(1185)].readyState:this._options.automaticOpen?this[t(947)+"NG"]:this.CLOSED}get[n(1424)](){let t=n,r={oPrBt:function(o,x,l){return e.ppZFn(o,x,l)},SgrDx:e[t(589)]};if(e[t(1484)](e[t(427)],t(792)))return this[t(1185)]?this._ws.url:this[t(618)];{let o=this[t(671)+t(1240)]?.[t(677)+t(1190)+"nt"](),x=this[t(1313)]["reconnec"+t(1466)+"ptor"](_0x592ede[t(1741)],_0x51978.reason);this[t(710)+"hCloseEv"+t(920)](DYBoFK.oPrBt(_0x4dd389,DYBoFK.SgrDx,{code:1006,reason:_0x5a637e[t(1993)]||t(1874)+t(607)+"d, unknown reason, hostname: "+o,willReconnect:x})),x&&this[t(400)]();return}}[n(1887)](t=1e3,r){let o=n,x=e[o(1232)][o(1950)]("|"),l=0;for(;;){switch(x[l++]){case"0":if(!this[o(1185)])return void this._debug(e[o(541)]);continue;case"1":this["_readyCl"+o(1443)]=!0;continue;case"2":this[o(1187)+o(455)+"t"](t,r);continue;case"3":this["_clearTi"+o(1206)]();continue;case"4":this._QoSManager?.[o(1421)]();continue;case"5":this._clearPingTimer();continue;case"6":this[o(980)+o(1072)+o(1263)]();continue;case"7":if(e[o(1101)](this[o(1185)][o(1066)+"te"],this[o(1842)])||e[o(1417)](this[o(1185)][o(1066)+"te"],this.CLOSING))return void this[o(1876)](e[o(794)]);continue}break}}async[n(422)](t,r){let o=n,x={ylAcv:function(l,g){return e[T(912)](l,g)},HwNmy:function(l,g){return e.KwqOa(l,g)},FZgai:function(l,g){return e[T(421)](l,g)},jiDzb:function(l,g){return e.ZhEeR(l,g)},bHCUe:function(l,g){return l===g},VqZkV:function(l,g){return e[T(368)](l,g)},GteCC:function(l,g){return e[T(1735)](l,g)}};if(e[o(1081)](e[o(1536)],e.EqanM)){if(e[o(656)](null,t))throw new Error(e.YkTiy);e[o(471)](e[o(955)],typeof t)&&(t=JSON[o(854)+"y"](t)),e[o(1475)]!=typeof t&&!e[o(1445)](t,ArrayBuffer)&&!(t[o(919)]&&e[o(1445)](t[o(919)],ArrayBuffer))&&(t=JSON[o(854)+"y"](t));let l=await zi(t),g=e[o(1701)](o0,t),{method:p=0,service:d=this[o(1313)].service,logID:_=this[o(1313)][o(762)+o(474)](),headers:v=this[o(1313)][o(712)],payloadEncoding:P=this[o(1313)][o(1704)+o(702)],payloadType:O=this._options[o(1062)+"ype"],logIDNew:R=this[o(1313)].logIDNewConfig[o(1579)+o(788)+"teLogIDNew"]?e.ZQawz(a,this[o(1313)][o(765)+"Config"][o(1817)]):""}=r||{};if(!d)throw new Error(e[o(1349)]);let G={SeqID:H[o(1222)+"er"](this._seqId++),LogID:H.fromNumber(_),service:d,method:p,headers:v,payloadEncoding:e[o(396)](P,Object)?P[o(1708)]?P[o(1708)]:"":P,payloadType:e[o(1431)](O,Object)?O[o(548)]?O[o(548)]:g:O||g,payload:l,LogIDNew:R},se=gr(G);return this[o(1185)]&&e[o(1099)](this[o(1185)].readyState,this.OPEN)?(this[o(1185)]&&this[o(1185)][o(422)](se),this._debug(o(1340),G)):e.GrkkR(this._messageQueue[o(1955)],this._options[o(539)+o(1302)+o(1537)])?(this[o(1506)+o(1079)][o(1567)](se),this[o(1876)]("enqueue",G)):e[o(496)](e[o(798)],e[o(798)])?(this[o(1506)+o(1079)][o(1361)](),this["_message"+o(1079)][o(1567)](se)):(_0x31bd2e=_0x212ec2[o(1816)+"At"](_0x592edd),zVYfZW[o(824)](_0x3dea74,128)?_0x18cd5a+=1:zVYfZW[o(1790)](_0x44e134,2048)?_0x2b8154+=2:zVYfZW.FZgai(zVYfZW.jiDzb(64512,_0x4e5ddc),55296)&&zVYfZW.bHCUe(zVYfZW.VqZkV(64512,_0x33c904[o(1816)+"At"](zVYfZW.GteCC(_0xdd6d6d,1))),56320)?(++_0x65ac39,_0x5cd444+=4):_0x406a19+=3),{seqID:this._seqId,logID:_,logIDNew:R}}else _0x2b27c3[o(1650)](_0x3a1d15)}async reconnect(t){let r=n,{url:o}=e[r(1197)](t,{}),x=Array[r(1034)](o)?o:e[r(1021)]("string",typeof o)?[o]:[];t&&Object.assign(this[r(1313)],t),x&&x[r(1955)]?this[r(671)+r(1240)]=new Li(x,this[r(1313)][r(1615)+"es"]):this[r(671)+"tManager"]?.[r(1063)+r(666)+r(1320)](),this["_pingLos"+r(390)]?.[r(627)+r(1894)](this._options[r(1528)+"Count"]),this[r(597)+r(1443)]=!1,this[r(1185)]&&e[r(465)](this[r(1185)][r(1066)+"te"],this[r(1842)])?this["_disconn"+r(1575)](1e3,e.neNIz,!0):(this._isInit=!0,this._connect())}async[n(1496)](){let t=n;if(!this[t(400)+"Lock"]){let r=e[t(1802)].split("|"),o=0;for(;;){switch(r[o++]){case"0":this[t(419)]=!0;continue;case"1":this[t(400)]();continue;case"2":this[t(597)+t(1443)]=!1;continue;case"3":this[t(1674)+t(390)]?.[t(627)+"nter"]();continue;case"4":this[t(671)+t(1240)]?.[t(1063)+t(666)+t(1320)]();continue}break}}}addEventListener(t,r){this.on(t,r)}["dispatch"+n(1356)](t){let r=n;if(e[r(1006)](e[r(519)],e[r(1038)]))this[r(725)](_0x297609,_0xbdaff6);else{let{type:o}=t;this.emit(o,t)}}[n(934)+"entListe"+n(484)](t,r){this[n(725)](t,r)}pingOnce(){let t=n,r={spwoz:function(o,x){return o!==x},CpVMB:t(443),VIhEl:e[t(1138)],HCMvS:function(o,x){return e[t(457)](o,x)},jokjr:e[t(1245)],ywqcI:function(o,x){return e.wAJag(o,x)},ysWad:t(1270),aGNbB:e.aEbEt,ynKkZ:e[t(1264)],ZYAPu:function(o,x){return e[t(1939)](o,x)},EZsfw:function(o,x){return e[t(1551)](o,x)},McWxF:function(o,x,l){return o(x,l)}};return new Promise((o,x)=>{let l=t,g={kHSVd:function(_,v){return r[T(736)](_,v)},YESMH:function(_,v){return r[T(736)](_,v)},Yxwtm:function(_,v){return r[T(463)](_,v)},AxBWe:function(_,v){return r[T(736)](_,v)}};this[l(1208)+l(729)](),this[l(1652)+l(1353)+"Id"]=r[l(869)](setTimeout,this._ping[l(1591)](this),this[l(1313)][l(1996)+"rval"]);let p=()=>{let _=l;r[_(1845)](r[_(982)],r[_(1193)])?(r[_(508)](o,r.jokjr),this.off(_(1224)+_(1108)+"s",p),this[_(725)]("ping_onc"+_(1837)+"t",d)):(_0x25ba63[_0x3b38e0++]=wifrUU.kHSVd(_0x5becea>>12,224),_0x5d1f40[_0x28bbb0++]=wifrUU[_(511)](wifrUU.Yxwtm(_0x8baafa>>6,63),128),_0x105f14[_0x2b8643++]=wifrUU.AxBWe(wifrUU[_(513)](63,_0xb48159),128))},d=()=>{let _=l;r[_(1358)](x,r[_(1132)]),this[_(725)](r[_(759)],p),this[_(725)](r[_(360)],d)};this.on(r[l(759)],p),this.on(r[l(360)],d),this[l(578)]()})}}})(),ee["CustomCl"+A(1143)]=X["CustomCl"+A(1143)],ee[A(1067)+"rorEvent"]=X[A(1067)+A(795)],ee[A(1269)+"e"]=X[A(1269)+"e"],ee[A(1356)]=X[A(1356)],ee[A(481)]=X[A(481)],ee["FrontierMessageE"+A(521)]=X["Frontier"+A(1234)+A(521)],ee[A(1234)+A(521)]=X[A(1234)+A(521)],ee[A(1779)+"t"]=X[A(1779)+"t"],ee[A(1580)+A(1140)]=X[A(1580)+A(1140)],ee[A(1334)+"oseEvent"]=X[A(1334)+A(1143)],ee[A(878)+A(795)]=X[A(878)+A(795)],ee[A(1833)+A(773)+"nt"]=X["createMe"+A(773)+"nt"],ee[A(983)+"enEvent"]=X["createOp"+A(1314)],ee[A(1483)+A(760)+A(521)]=X[A(1483)+A(760)+A(521)],ee["decodedF"+A(1643)]=X[A(1992)+"rame"],ee["encodeFr"+A(1285)]=X[A(898)+"ame"];for(Mn in X)[A(594)+"oseEvent","CustomEr"+A(795),A(1269)+"e",A(1356),"FWS",A(616)+A(1234)+A(521),A(1234)+"vent","OpenEvent",A(1580)+A(1140),A(1334)+A(1143),A(878)+A(795),A(1833)+"ssageEvent",A(983)+A(1314),"createRe"+A(760)+A(521),A(1992)+A(1643),A(898)+A(1285)].indexOf(Mn)===-1&&(ee[Mn]=X[Mn]);var Mn;Object[A(489)+A(893)](ee,A(1110)+"le",{value:!0})});var ze=le((Kp,yo)=>{"use strict";var _o=["nodebuffer","arraybuffer","fragments"],wo=typeof Blob<"u";wo&&_o.push("blob");yo.exports={BINARY_TYPES:_o,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:wo,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var $t=le((jp,jn)=>{"use strict";var{EMPTY_BUFFER:Lu}=ze(),Hr=Buffer[Symbol.species];function Ou(n,e){if(n.length===0)return Lu;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),a=0;for(let c=0;c<n.length;c++){let u=n[c];s.set(u,a),a+=u.length}return a<e?new Hr(s.buffer,s.byteOffset,a):s}function bo(n,e,s,a,c){for(let u=0;u<c;u++)s[a+u]=n[u]^e[u&3]}function vo(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function Bu(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function Kr(n){if(Kr.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new Hr(n):ArrayBuffer.isView(n)?e=new Hr(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),Kr.readOnly=!1),e}jn.exports={concat:Ou,mask:bo,toArrayBuffer:Bu,toBuffer:Kr,unmask:vo};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=$("bufferutil");jn.exports.mask=function(e,s,a,c,u){u<48?bo(e,s,a,c,u):n.mask(e,s,a,c,u)},jn.exports.unmask=function(e,s){e.length<32?vo(e,s):n.unmask(e,s)}}catch{}});var Co=le((Gp,Eo)=>{"use strict";var So=Symbol("kDone"),jr=Symbol("kRun"),Gr=class{constructor(e){this[So]=()=>{this.pending--,this[jr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[jr]()}[jr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[So])}}};Eo.exports=Gr});var It=le((Wp,ko)=>{"use strict";var Xt=$("zlib"),Ao=$t(),Mu=Co(),{kStatusCode:Io}=ze(),zu=Buffer[Symbol.species],Fu=Buffer.from([0,0,255,255]),Wn=Symbol("permessage-deflate"),Fe=Symbol("total-length"),Ct=Symbol("callback"),Ye=Symbol("buffers"),At=Symbol("error"),Gn,Wr=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,!Gn){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Gn=new Mu(s)}}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[Ct];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,a=e.find(c=>!(s.serverNoContextTakeover===!1&&c.server_no_context_takeover||c.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>c.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!c.client_max_window_bits));if(!a)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(a.server_no_context_takeover=!0),s.clientNoContextTakeover&&(a.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(a.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?a.client_max_window_bits=s.clientMaxWindowBits:(a.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete a.client_max_window_bits,a}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(a=>{let c=s[a];if(c.length>1)throw new Error(`Parameter "${a}" must have only a single value`);if(c=c[0],a==="client_max_window_bits"){if(c!==!0){let u=+c;if(!Number.isInteger(u)||u<8||u>15)throw new TypeError(`Invalid value for parameter "${a}": ${c}`);c=u}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${a}": ${c}`)}else if(a==="server_max_window_bits"){let u=+c;if(!Number.isInteger(u)||u<8||u>15)throw new TypeError(`Invalid value for parameter "${a}": ${c}`);c=u}else if(a==="client_no_context_takeover"||a==="server_no_context_takeover"){if(c!==!0)throw new TypeError(`Invalid value for parameter "${a}": ${c}`)}else throw new Error(`Unknown parameter "${a}"`);s[a]=c})}),e}decompress(e,s,a){Gn.add(c=>{this._decompress(e,s,(u,f)=>{c(),a(u,f)})})}compress(e,s,a){Gn.add(c=>{this._compress(e,s,(u,f)=>{c(),a(u,f)})})}_decompress(e,s,a){let c=this._isServer?"client":"server";if(!this._inflate){let u=`${c}_max_window_bits`,f=typeof this.params[u]!="number"?Xt.Z_DEFAULT_WINDOWBITS:this.params[u];this._inflate=Xt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[Wn]=this,this._inflate[Fe]=0,this._inflate[Ye]=[],this._inflate.on("error",Uu),this._inflate.on("data",Po)}this._inflate[Ct]=a,this._inflate.write(e),s&&this._inflate.write(Fu),this._inflate.flush(()=>{let u=this._inflate[At];if(u){this._inflate.close(),this._inflate=null,a(u);return}let f=Ao.concat(this._inflate[Ye],this._inflate[Fe]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Fe]=0,this._inflate[Ye]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),a(null,f)})}_compress(e,s,a){let c=this._isServer?"server":"client";if(!this._deflate){let u=`${c}_max_window_bits`,f=typeof this.params[u]!="number"?Xt.Z_DEFAULT_WINDOWBITS:this.params[u];this._deflate=Xt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Fe]=0,this._deflate[Ye]=[],this._deflate.on("data",qu)}this._deflate[Ct]=a,this._deflate.write(e),this._deflate.flush(Xt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let u=Ao.concat(this._deflate[Ye],this._deflate[Fe]);s&&(u=new zu(u.buffer,u.byteOffset,u.length-4)),this._deflate[Ct]=null,this._deflate[Fe]=0,this._deflate[Ye]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),a(null,u)})}};ko.exports=Wr;function qu(n){this[Ye].push(n),this[Fe]+=n.length}function Po(n){if(this[Fe]+=n.length,this[Wn]._maxPayload<1||this[Fe]<=this[Wn]._maxPayload){this[Ye].push(n);return}this[At]=new RangeError("Max payload size exceeded"),this[At].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[At][Io]=1009,this.removeListener("data",Po),this.reset()}function Uu(n){if(this[Wn]._inflate=null,this[At]){this[Ct](this[At]);return}n[Io]=1007,this[Ct](n)}});var Pt=le((Jp,Jn)=>{"use strict";var{isUtf8:To}=$("buffer"),{hasBlob:Hu}=ze(),Ku=[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 ju(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function Jr(n){let e=n.length,s=0;for(;s<e;)if((n[s]&128)===0)s++;else if((n[s]&224)===192){if(s+1===e||(n[s+1]&192)!==128||(n[s]&254)===192)return!1;s+=2}else if((n[s]&240)===224){if(s+2>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||n[s]===224&&(n[s+1]&224)===128||n[s]===237&&(n[s+1]&224)===160)return!1;s+=3}else if((n[s]&248)===240){if(s+3>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||(n[s+3]&192)!==128||n[s]===240&&(n[s+1]&240)===128||n[s]===244&&n[s+1]>143||n[s]>244)return!1;s+=4}else return!1;return!0}function Gu(n){return Hu&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}Jn.exports={isBlob:Gu,isValidStatusCode:ju,isValidUTF8:Jr,tokenChars:Ku};if(To)Jn.exports.isValidUTF8=function(n){return n.length<24?Jr(n):To(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=$("utf-8-validate");Jn.exports.isValidUTF8=function(e){return e.length<32?Jr(e):n(e)}}catch{}});var Yr=le((Vp,Mo)=>{"use strict";var{Writable:Wu}=$("stream"),Do=It(),{BINARY_TYPES:Ju,EMPTY_BUFFER:No,kStatusCode:Vu,kWebSocket:$u}=ze(),{concat:Vr,toArrayBuffer:Xu,unmask:Zu}=$t(),{isValidStatusCode:Yu,isValidUTF8:Ro}=Pt(),Vn=Buffer[Symbol.species],me=0,Lo=1,Oo=2,Bo=3,$r=4,Xr=5,$n=6,Zr=class extends Wu{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Ju[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[$u]=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=me}_write(e,s,a){if(this._opcode===8&&this._state==me)return a();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(a)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let a=this._buffers[0];return this._buffers[0]=new Vn(a.buffer,a.byteOffset+e,a.length-e),new Vn(a.buffer,a.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let a=this._buffers[0],c=s.length-e;e>=a.length?s.set(this._buffers.shift(),c):(s.set(new Uint8Array(a.buffer,a.byteOffset,e),c),this._buffers[0]=new Vn(a.buffer,a.byteOffset+e,a.length-e)),e-=a.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case me:this.getInfo(e);break;case Lo:this.getPayloadLength16(e);break;case Oo:this.getPayloadLength64(e);break;case Bo:this.getMask();break;case $r:this.getData(e);break;case Xr:case $n:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let c=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(c);return}let a=(s[0]&64)===64;if(a&&!this._extensions[Do.extensionName]){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(a){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(!this._fragmented){let c=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._compressed=a}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let c=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(c);return}if(a){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let c=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(c);return}}else{let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let c=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(c);return}}else if(this._masked){let c=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(c);return}this._payloadLength===126?this._state=Lo:this._payloadLength===127?this._state=Oo: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 s=this.consume(8),a=s.readUInt32BE(0);if(a>Math.pow(2,21)-1){let c=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(c);return}this._payloadLength=a*Math.pow(2,32)+s.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 s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=Bo:this._state=$r}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=$r}getData(e){let s=No;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Zu(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=Xr,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[Do.extensionName].decompress(e,this._fin,(c,u)=>{if(c)return s(c);if(u.length){if(this._messageLength+=u.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(f);return}this._fragments.push(u)}this.dataMessage(s),this._state===me&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=me;return}let s=this._messageLength,a=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let c;this._binaryType==="nodebuffer"?c=Vr(a,s):this._binaryType==="arraybuffer"?c=Xu(Vr(a,s)):this._binaryType==="blob"?c=new Blob(a):c=a,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=me):(this._state=$n,setImmediate(()=>{this.emit("message",c,!0),this._state=me,this.startLoop(e)}))}else{let c=Vr(a,s);if(!this._skipUTF8Validation&&!Ro(c)){let u=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(u);return}this._state===Xr||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=me):(this._state=$n,setImmediate(()=>{this.emit("message",c,!1),this._state=me,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,No),this.end();else{let a=e.readUInt16BE(0);if(!Yu(a)){let u=this.createError(RangeError,`invalid status code ${a}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(u);return}let c=new Vn(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ro(c)){let u=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(u);return}this._loop=!1,this.emit("conclude",a,c),this.end()}this._state=me;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=me):(this._state=$n,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=me,this.startLoop(s)}))}createError(e,s,a,c,u){this._loop=!1,this._errored=!0;let f=new e(a?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(f,this.createError),f.code=u,f[Vu]=c,f}};Mo.exports=Zr});var ti=le((Xp,qo)=>{"use strict";var{Duplex:$p}=$("stream"),{randomFillSync:Qu}=$("crypto"),zo=It(),{EMPTY_BUFFER:ef,kWebSocket:tf,NOOP:nf}=ze(),{isBlob:kt,isValidStatusCode:rf}=Pt(),{mask:Fo,toBuffer:ot}=$t(),_e=Symbol("kByteLength"),sf=Buffer.alloc(4),Xn=8*1024,at,Tt=Xn,ve=0,of=1,af=2,Qr=class n{constructor(e,s,a){this._extensions=s||{},a&&(this._generateMask=a,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=ve,this.onerror=nf,this[tf]=void 0}static frame(e,s){let a,c=!1,u=2,f=!1;s.mask&&(a=s.maskBuffer||sf,s.generateMask?s.generateMask(a):(Tt===Xn&&(at===void 0&&(at=Buffer.alloc(Xn)),Qu(at,0,Xn),Tt=0),a[0]=at[Tt++],a[1]=at[Tt++],a[2]=at[Tt++],a[3]=at[Tt++]),f=(a[0]|a[1]|a[2]|a[3])===0,u=6);let h;typeof e=="string"?(!s.mask||f)&&s[_e]!==void 0?h=s[_e]:(e=Buffer.from(e),h=e.length):(h=e.length,c=s.mask&&s.readOnly&&!f);let m=h;h>=65536?(u+=8,m=127):h>125&&(u+=2,m=126);let y=Buffer.allocUnsafe(c?h+u:u);return y[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(y[0]|=64),y[1]=m,m===126?y.writeUInt16BE(h,2):m===127&&(y[2]=y[3]=0,y.writeUIntBE(h,4,6)),s.mask?(y[1]|=128,y[u-4]=a[0],y[u-3]=a[1],y[u-2]=a[2],y[u-1]=a[3],f?[y,e]:c?(Fo(e,a,y,u,h),[y]):(Fo(e,a,e,0,h),[y,e])):[y,e]}close(e,s,a,c){let u;if(e===void 0)u=ef;else{if(typeof e!="number"||!rf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)u=Buffer.allocUnsafe(2),u.writeUInt16BE(e,0);else{let h=Buffer.byteLength(s);if(h>123)throw new RangeError("The message must not be greater than 123 bytes");u=Buffer.allocUnsafe(2+h),u.writeUInt16BE(e,0),typeof s=="string"?u.write(s,2):u.set(s,2)}}let f={[_e]:u.length,fin:!0,generateMask:this._generateMask,mask:a,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==ve?this.enqueue([this.dispatch,u,!1,f,c]):this.sendFrame(n.frame(u,f),c)}ping(e,s,a){let c,u;if(typeof e=="string"?(c=Buffer.byteLength(e),u=!1):kt(e)?(c=e.size,u=!1):(e=ot(e),c=e.length,u=ot.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[_e]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:u,rsv1:!1};kt(e)?this._state!==ve?this.enqueue([this.getBlobData,e,!1,f,a]):this.getBlobData(e,!1,f,a):this._state!==ve?this.enqueue([this.dispatch,e,!1,f,a]):this.sendFrame(n.frame(e,f),a)}pong(e,s,a){let c,u;if(typeof e=="string"?(c=Buffer.byteLength(e),u=!1):kt(e)?(c=e.size,u=!1):(e=ot(e),c=e.length,u=ot.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[_e]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:u,rsv1:!1};kt(e)?this._state!==ve?this.enqueue([this.getBlobData,e,!1,f,a]):this.getBlobData(e,!1,f,a):this._state!==ve?this.enqueue([this.dispatch,e,!1,f,a]):this.sendFrame(n.frame(e,f),a)}send(e,s,a){let c=this._extensions[zo.extensionName],u=s.binary?2:1,f=s.compress,h,m;typeof e=="string"?(h=Buffer.byteLength(e),m=!1):kt(e)?(h=e.size,m=!1):(e=ot(e),h=e.length,m=ot.readOnly),this._firstFragment?(this._firstFragment=!1,f&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=h>=c._threshold),this._compress=f):(f=!1,u=0),s.fin&&(this._firstFragment=!0);let y={[_e]:h,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:u,readOnly:m,rsv1:f};kt(e)?this._state!==ve?this.enqueue([this.getBlobData,e,this._compress,y,a]):this.getBlobData(e,this._compress,y,a):this._state!==ve?this.enqueue([this.dispatch,e,this._compress,y,a]):this.dispatch(e,this._compress,y,a)}getBlobData(e,s,a,c){this._bufferedBytes+=a[_e],this._state=af,e.arrayBuffer().then(u=>{if(this._socket.destroyed){let h=new Error("The socket was closed while the blob was being read");process.nextTick(ei,this,h,c);return}this._bufferedBytes-=a[_e];let f=ot(u);s?this.dispatch(f,s,a,c):(this._state=ve,this.sendFrame(n.frame(f,a),c),this.dequeue())}).catch(u=>{process.nextTick(cf,this,u,c)})}dispatch(e,s,a,c){if(!s){this.sendFrame(n.frame(e,a),c);return}let u=this._extensions[zo.extensionName];this._bufferedBytes+=a[_e],this._state=of,u.compress(e,a.fin,(f,h)=>{if(this._socket.destroyed){let m=new Error("The socket was closed while data was being compressed");ei(this,m,c);return}this._bufferedBytes-=a[_e],this._state=ve,a.readOnly=!1,this.sendFrame(n.frame(h,a),c),this.dequeue()})}dequeue(){for(;this._state===ve&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][_e],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][_e],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};qo.exports=Qr;function ei(n,e,s){typeof s=="function"&&s(e);for(let a=0;a<n._queue.length;a++){let c=n._queue[a],u=c[c.length-1];typeof u=="function"&&u(e)}}function cf(n,e,s){ei(n,e,s),n.onerror(e)}});var $o=le((Zp,Vo)=>{"use strict";var{kForOnEventAttribute:Zt,kListener:ni}=ze(),Uo=Symbol("kCode"),Ho=Symbol("kData"),Ko=Symbol("kError"),jo=Symbol("kMessage"),Go=Symbol("kReason"),Dt=Symbol("kTarget"),Wo=Symbol("kType"),Jo=Symbol("kWasClean"),qe=class{constructor(e){this[Dt]=null,this[Wo]=e}get target(){return this[Dt]}get type(){return this[Wo]}};Object.defineProperty(qe.prototype,"target",{enumerable:!0});Object.defineProperty(qe.prototype,"type",{enumerable:!0});var ct=class extends qe{constructor(e,s={}){super(e),this[Uo]=s.code===void 0?0:s.code,this[Go]=s.reason===void 0?"":s.reason,this[Jo]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Uo]}get reason(){return this[Go]}get wasClean(){return this[Jo]}};Object.defineProperty(ct.prototype,"code",{enumerable:!0});Object.defineProperty(ct.prototype,"reason",{enumerable:!0});Object.defineProperty(ct.prototype,"wasClean",{enumerable:!0});var Nt=class extends qe{constructor(e,s={}){super(e),this[Ko]=s.error===void 0?null:s.error,this[jo]=s.message===void 0?"":s.message}get error(){return this[Ko]}get message(){return this[jo]}};Object.defineProperty(Nt.prototype,"error",{enumerable:!0});Object.defineProperty(Nt.prototype,"message",{enumerable:!0});var Yt=class extends qe{constructor(e,s={}){super(e),this[Ho]=s.data===void 0?null:s.data}get data(){return this[Ho]}};Object.defineProperty(Yt.prototype,"data",{enumerable:!0});var xf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[Zt]&&c[ni]===e&&!c[Zt])return;let a;if(n==="message")a=function(u,f){let h=new Yt("message",{data:f?u:u.toString()});h[Dt]=this,Zn(e,this,h)};else if(n==="close")a=function(u,f){let h=new ct("close",{code:u,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});h[Dt]=this,Zn(e,this,h)};else if(n==="error")a=function(u){let f=new Nt("error",{error:u,message:u.message});f[Dt]=this,Zn(e,this,f)};else if(n==="open")a=function(){let u=new qe("open");u[Dt]=this,Zn(e,this,u)};else return;a[Zt]=!!s[Zt],a[ni]=e,s.once?this.once(n,a):this.on(n,a)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[ni]===e&&!s[Zt]){this.removeListener(n,s);break}}};Vo.exports={CloseEvent:ct,ErrorEvent:Nt,Event:qe,EventTarget:xf,MessageEvent:Yt};function Zn(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var Yn=le((Yp,Xo)=>{"use strict";var{tokenChars:Qt}=Pt();function De(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function uf(n){let e=Object.create(null),s=Object.create(null),a=!1,c=!1,u=!1,f,h,m=-1,y=-1,b=-1,w=0;for(;w<n.length;w++)if(y=n.charCodeAt(w),f===void 0)if(b===-1&&Qt[y]===1)m===-1&&(m=w);else if(w!==0&&(y===32||y===9))b===-1&&m!==-1&&(b=w);else if(y===59||y===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${w}`);b===-1&&(b=w);let C=n.slice(m,b);y===44?(De(e,C,s),s=Object.create(null)):f=C,m=b=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(h===void 0)if(b===-1&&Qt[y]===1)m===-1&&(m=w);else if(y===32||y===9)b===-1&&m!==-1&&(b=w);else if(y===59||y===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${w}`);b===-1&&(b=w),De(s,n.slice(m,b),!0),y===44&&(De(e,f,s),s=Object.create(null),f=void 0),m=b=-1}else if(y===61&&m!==-1&&b===-1)h=n.slice(m,w),m=b=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(c){if(Qt[y]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);m===-1?m=w:a||(a=!0),c=!1}else if(u)if(Qt[y]===1)m===-1&&(m=w);else if(y===34&&m!==-1)u=!1,b=w;else if(y===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(y===34&&n.charCodeAt(w-1)===61)u=!0;else if(b===-1&&Qt[y]===1)m===-1&&(m=w);else if(m!==-1&&(y===32||y===9))b===-1&&(b=w);else if(y===59||y===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${w}`);b===-1&&(b=w);let C=n.slice(m,b);a&&(C=C.replace(/\\/g,""),a=!1),De(s,h,C),y===44&&(De(e,f,s),s=Object.create(null),f=void 0),h=void 0,m=b=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(m===-1||u||y===32||y===9)throw new SyntaxError("Unexpected end of input");b===-1&&(b=w);let S=n.slice(m,b);return f===void 0?De(e,S,s):(h===void 0?De(s,S,!0):a?De(s,h,S.replace(/\\/g,"")):De(s,h,S),De(e,f,s)),e}function ff(n){return Object.keys(n).map(e=>{let s=n[e];return Array.isArray(s)||(s=[s]),s.map(a=>[e].concat(Object.keys(a).map(c=>{let u=a[c];return Array.isArray(u)||(u=[u]),u.map(f=>f===!0?c:`${c}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Xo.exports={format:ff,parse:uf}});var nr=le((tm,ca)=>{"use strict";var df=$("events"),lf=$("https"),hf=$("http"),Qo=$("net"),gf=$("tls"),{randomBytes:pf,createHash:mf}=$("crypto"),{Duplex:Qp,Readable:em}=$("stream"),{URL:ri}=$("url"),Qe=It(),_f=Yr(),wf=ti(),{isBlob:yf}=Pt(),{BINARY_TYPES:Zo,CLOSE_TIMEOUT:bf,EMPTY_BUFFER:Qn,GUID:vf,kForOnEventAttribute:ii,kListener:Sf,kStatusCode:Ef,kWebSocket:re,NOOP:ea}=ze(),{EventTarget:{addEventListener:Cf,removeEventListener:Af}}=$o(),{format:If,parse:Pf}=Yn(),{toBuffer:kf}=$t(),ta=Symbol("kAborted"),si=[8,13],Ue=["CONNECTING","OPEN","CLOSING","CLOSED"],Tf=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,J=class n extends df{constructor(e,s,a){super(),this._binaryType=Zo[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Qn,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(a=s,s=[]):s=[s]),na(this,e,s,a)):(this._autoPong=a.autoPong,this._closeTimeout=a.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Zo.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,s,a){let c=new _f({allowSynchronousEvents:a.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation}),u=new wf(e,this._extensions,a.generateMask);this._receiver=c,this._sender=u,this._socket=e,c[re]=this,u[re]=this,e[re]=this,c.on("conclude",Rf),c.on("drain",Lf),c.on("error",Of),c.on("message",Bf),c.on("ping",Mf),c.on("pong",zf),u.onerror=Ff,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",sa),e.on("data",tr),e.on("end",oa),e.on("error",aa),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Qe.extensionName]&&this._extensions[Qe.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){ge(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,s,!this._isServer,a=>{a||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ia(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,a){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(a=e,e=s=void 0):typeof s=="function"&&(a=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){oi(this,e,a);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||Qn,s,a)}pong(e,s,a){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(a=e,e=s=void 0):typeof s=="function"&&(a=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){oi(this,e,a);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||Qn,s,a)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,a){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(a=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){oi(this,e,a);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[Qe.extensionName]||(c.compress=!1),this._sender.send(e||Qn,c,a)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){ge(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(J,"CONNECTING",{enumerable:!0,value:Ue.indexOf("CONNECTING")});Object.defineProperty(J.prototype,"CONNECTING",{enumerable:!0,value:Ue.indexOf("CONNECTING")});Object.defineProperty(J,"OPEN",{enumerable:!0,value:Ue.indexOf("OPEN")});Object.defineProperty(J.prototype,"OPEN",{enumerable:!0,value:Ue.indexOf("OPEN")});Object.defineProperty(J,"CLOSING",{enumerable:!0,value:Ue.indexOf("CLOSING")});Object.defineProperty(J.prototype,"CLOSING",{enumerable:!0,value:Ue.indexOf("CLOSING")});Object.defineProperty(J,"CLOSED",{enumerable:!0,value:Ue.indexOf("CLOSED")});Object.defineProperty(J.prototype,"CLOSED",{enumerable:!0,value:Ue.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(J.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(J.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[ii])return e[Sf];return null},set(e){for(let s of this.listeners(n))if(s[ii]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[ii]:!0})}})});J.prototype.addEventListener=Cf;J.prototype.removeEventListener=Af;ca.exports=J;function na(n,e,s,a){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:bf,protocolVersion:si[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...a,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=c.autoPong,n._closeTimeout=c.closeTimeout,!si.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${si.join(", ")})`);let u;if(e instanceof ri)u=e;else try{u=new ri(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}u.protocol==="http:"?u.protocol="ws:":u.protocol==="https:"&&(u.protocol="wss:"),n._url=u.href;let f=u.protocol==="wss:",h=u.protocol==="ws+unix:",m;if(u.protocol!=="ws:"&&!f&&!h?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:h&&!u.pathname?m="The URL's pathname is empty":u.hash&&(m="The URL contains a fragment identifier"),m){let k=new SyntaxError(m);if(n._redirects===0)throw k;er(n,k);return}let y=f?443:80,b=pf(16).toString("base64"),w=f?lf.request:hf.request,S=new Set,C;if(c.createConnection=c.createConnection||(f?Nf:Df),c.defaultPort=c.defaultPort||y,c.port=u.port||y,c.host=u.hostname.startsWith("[")?u.hostname.slice(1,-1):u.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":b,Connection:"Upgrade",Upgrade:"websocket"},c.path=u.pathname+u.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(C=new Qe({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=If({[Qe.extensionName]:C.offer()})),s.length){for(let k of s){if(typeof k!="string"||!Tf.test(k)||S.has(k))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(k)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(u.username||u.password)&&(c.auth=`${u.username}:${u.password}`),h){let k=c.path.split(":");c.socketPath=k[0],c.path=k[1]}let I;if(c.followRedirects){if(n._redirects===0){n._originalIpc=h,n._originalSecure=f,n._originalHostOrSocketPath=h?c.socketPath:u.host;let k=a&&a.headers;if(a={...a,headers:{}},k)for(let[L,B]of Object.entries(k))a.headers[L.toLowerCase()]=B}else if(n.listenerCount("redirect")===0){let k=h?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:u.host===n._originalHostOrSocketPath;(!k||n._originalSecure&&!f)&&(delete c.headers.authorization,delete c.headers.cookie,k||delete c.headers.host,c.auth=void 0)}c.auth&&!a.headers.authorization&&(a.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),I=n._req=w(c),n._redirects&&n.emit("redirect",n.url,I)}else I=n._req=w(c);c.timeout&&I.on("timeout",()=>{ge(n,I,"Opening handshake has timed out")}),I.on("error",k=>{I===null||I[ta]||(I=n._req=null,er(n,k))}),I.on("response",k=>{let L=k.headers.location,B=k.statusCode;if(L&&c.followRedirects&&B>=300&&B<400){if(++n._redirects>c.maxRedirects){ge(n,I,"Maximum redirects exceeded");return}I.abort();let Z;try{Z=new ri(L,e)}catch{let te=new SyntaxError(`Invalid URL: ${L}`);er(n,te);return}na(n,Z,s,a)}else n.emit("unexpected-response",I,k)||ge(n,I,`Unexpected server response: ${k.statusCode}`)}),I.on("upgrade",(k,L,B)=>{if(n.emit("upgrade",k),n.readyState!==J.CONNECTING)return;I=n._req=null;let Z=k.headers.upgrade;if(Z===void 0||Z.toLowerCase()!=="websocket"){ge(n,L,"Invalid Upgrade header");return}let Y=mf("sha1").update(b+vf).digest("base64");if(k.headers["sec-websocket-accept"]!==Y){ge(n,L,"Invalid Sec-WebSocket-Accept header");return}let te=k.headers["sec-websocket-protocol"],ne;if(te!==void 0?S.size?S.has(te)||(ne="Server sent an invalid subprotocol"):ne="Server sent a subprotocol but none was requested":S.size&&(ne="Server sent no subprotocol"),ne){ge(n,L,ne);return}te&&(n._protocol=te);let He=k.headers["sec-websocket-extensions"];if(He!==void 0){if(!C){ge(n,L,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let D;try{D=Pf(He)}catch{ge(n,L,"Invalid Sec-WebSocket-Extensions header");return}let M=Object.keys(D);if(M.length!==1||M[0]!==Qe.extensionName){ge(n,L,"Server indicated an extension that was not requested");return}try{C.accept(D[Qe.extensionName])}catch{ge(n,L,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[Qe.extensionName]=C}n.setSocket(L,B,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(I,n):I.end()}function er(n,e){n._readyState=J.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function Df(n){return n.path=n.socketPath,Qo.connect(n)}function Nf(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Qo.isIP(n.host)?"":n.host),gf.connect(n)}function ge(n,e,s){n._readyState=J.CLOSING;let a=new Error(s);Error.captureStackTrace(a,ge),e.setHeader?(e[ta]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(er,n,a)):(e.destroy(a),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function oi(n,e,s){if(e){let a=yf(e)?e.size:kf(e).length;n._socket?n._sender._bufferedBytes+=a:n._bufferedAmount+=a}if(s){let a=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ue[n.readyState]})`);process.nextTick(s,a)}}function Rf(n,e){let s=this[re];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[re]!==void 0&&(s._socket.removeListener("data",tr),process.nextTick(ra,s._socket),n===1005?s.close():s.close(n,e))}function Lf(){let n=this[re];n.isPaused||n._socket.resume()}function Of(n){let e=this[re];e._socket[re]!==void 0&&(e._socket.removeListener("data",tr),process.nextTick(ra,e._socket),e.close(n[Ef])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Yo(){this[re].emitClose()}function Bf(n,e){this[re].emit("message",n,e)}function Mf(n){let e=this[re];e._autoPong&&e.pong(n,!this._isServer,ea),e.emit("ping",n)}function zf(n){this[re].emit("pong",n)}function ra(n){n.resume()}function Ff(n){let e=this[re];e.readyState!==J.CLOSED&&(e.readyState===J.OPEN&&(e._readyState=J.CLOSING,ia(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function ia(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function sa(){let n=this[re];if(this.removeListener("close",sa),this.removeListener("data",tr),this.removeListener("end",oa),n._readyState=J.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[re]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Yo),n._receiver.on("finish",Yo))}function tr(n){this[re]._receiver.write(n)||this.pause()}function oa(){let n=this[re];n._readyState=J.CLOSING,n._receiver.end(),this.end()}function aa(){let n=this[re];this.removeListener("error",aa),this.on("error",ea),n&&(n._readyState=J.CLOSING,this.destroy())}});var da=le((rm,fa)=>{"use strict";var nm=nr(),{Duplex:qf}=$("stream");function xa(n){n.emit("close")}function Uf(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ua(n){this.removeListener("error",ua),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function Hf(n,e){let s=!0,a=new qf({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(u,f){let h=!f&&a._readableState.objectMode?u.toString():u;a.push(h)||n.pause()}),n.once("error",function(u){a.destroyed||(s=!1,a.destroy(u))}),n.once("close",function(){a.destroyed||a.push(null)}),a._destroy=function(c,u){if(n.readyState===n.CLOSED){u(c),process.nextTick(xa,a);return}let f=!1;n.once("error",function(m){f=!0,u(m)}),n.once("close",function(){f||u(c),process.nextTick(xa,a)}),s&&n.terminate()},a._final=function(c){if(n.readyState===n.CONNECTING){n.once("open",function(){a._final(c)});return}n._socket!==null&&(n._socket._writableState.finished?(c(),a._readableState.endEmitted&&a.destroy()):(n._socket.once("finish",function(){c()}),n.close()))},a._read=function(){n.isPaused&&n.resume()},a._write=function(c,u,f){if(n.readyState===n.CONNECTING){n.once("open",function(){a._write(c,u,f)});return}n.send(c,f)},a.on("end",Uf),a.on("error",ua),a}fa.exports=Hf});var ai=le((im,la)=>{"use strict";var{tokenChars:Kf}=Pt();function jf(n){let e=new Set,s=-1,a=-1,c=0;for(c;c<n.length;c++){let f=n.charCodeAt(c);if(a===-1&&Kf[f]===1)s===-1&&(s=c);else if(c!==0&&(f===32||f===9))a===-1&&s!==-1&&(a=c);else if(f===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);a===-1&&(a=c);let h=n.slice(s,a);if(e.has(h))throw new SyntaxError(`The "${h}" subprotocol is duplicated`);e.add(h),s=a=-1}else throw new SyntaxError(`Unexpected character at index ${c}`)}if(s===-1||a!==-1)throw new SyntaxError("Unexpected end of input");let u=n.slice(s,c);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);return e.add(u),e}la.exports={parse:jf}});var ya=le((om,wa)=>{"use strict";var Gf=$("events"),rr=$("http"),{Duplex:sm}=$("stream"),{createHash:Wf}=$("crypto"),ha=Yn(),xt=It(),Jf=ai(),Vf=nr(),{CLOSE_TIMEOUT:$f,GUID:Xf,kWebSocket:Zf}=ze(),Yf=/^[+/0-9A-Za-z]{22}==$/,ga=0,pa=1,_a=2,ci=class extends Gf{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:$f,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Vf,...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=rr.createServer((a,c)=>{let u=rr.STATUS_CODES[426];c.writeHead(426,{"Content-Length":u.length,"Content-Type":"text/plain"}),c.end(u)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let a=this.emit.bind(this,"connection");this._removeListeners=Qf(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,u,f)=>{this.handleUpgrade(c,u,f,a)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=ga}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===_a){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(en,this);return}if(e&&this.once("close",e),this._state!==pa)if(this._state=pa,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(en,this):process.nextTick(en,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{en(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,a,c){s.on("error",ma);let u=e.headers["sec-websocket-key"],f=e.headers.upgrade,h=+e.headers["sec-websocket-version"];if(e.method!=="GET"){ut(this,e,s,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){ut(this,e,s,400,"Invalid Upgrade header");return}if(u===void 0||!Yf.test(u)){ut(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(h!==13&&h!==8){ut(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){tn(s,400);return}let m=e.headers["sec-websocket-protocol"],y=new Set;if(m!==void 0)try{y=Jf.parse(m)}catch{ut(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let b=e.headers["sec-websocket-extensions"],w={};if(this.options.perMessageDeflate&&b!==void 0){let S=new xt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let C=ha.parse(b);C[xt.extensionName]&&(S.accept(C[xt.extensionName]),w[xt.extensionName]=S)}catch{ut(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={origin:e.headers[`${h===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(S,(C,I,k,L)=>{if(!C)return tn(s,I||401,k,L);this.completeUpgrade(w,u,y,e,s,a,c)});return}if(!this.options.verifyClient(S))return tn(s,401)}this.completeUpgrade(w,u,y,e,s,a,c)}completeUpgrade(e,s,a,c,u,f,h){if(!u.readable||!u.writable)return u.destroy();if(u[Zf])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ga)return tn(u,503);let y=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Wf("sha1").update(s+Xf).digest("base64")}`],b=new this.options.WebSocket(null,void 0,this.options);if(a.size){let w=this.options.handleProtocols?this.options.handleProtocols(a,c):a.values().next().value;w&&(y.push(`Sec-WebSocket-Protocol: ${w}`),b._protocol=w)}if(e[xt.extensionName]){let w=e[xt.extensionName].params,S=ha.format({[xt.extensionName]:[w]});y.push(`Sec-WebSocket-Extensions: ${S}`),b._extensions=e}this.emit("headers",y,c),u.write(y.concat(`\r
8
+ var W0=Object.create;var Pr=Object.defineProperty;var J0=Object.getOwnPropertyDescriptor;var V0=Object.getOwnPropertyNames;var $0=Object.getPrototypeOf,Y0=Object.prototype.hasOwnProperty;var Y=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Me=(n,e)=>()=>(n&&(e=n(n=0)),e);var he=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Wi=(n,e)=>{for(var s in e)Pr(n,s,{get:e[s],enumerable:!0})},X0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of V0(e))!Y0.call(n,c)&&c!==s&&Pr(n,c,{get:()=>e[c],enumerable:!(o=J0(e,c))||o.enumerable});return n};var ze=(n,e,s)=>(s=n!=null?W0($0(n)):{},X0(e||!n||!n.__esModule?Pr(s,"default",{value:n,enumerable:!0}):s,n));import{chmod as Z0,mkdir as Q0,readFile as ec,rename as Ji,writeFile as Vi}from"node:fs/promises";import{dirname as tc}from"node:path";async function gt(n){try{let e=await ec(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function xn(n,e,s){await Q0(tc(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
9
+ `,c=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await Vi(c,o,{encoding:"utf8",mode:s.mode}):await Vi(c,o,"utf8"),await Ji(c,n),s?.mode!==void 0&&await Z0(n,s.mode)}catch(u){await Ji(c,c).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(c,{force:!0}).catch(()=>{}),u}}var un=Me(()=>{"use strict"});function Xi(n){return dn[$i]<=dn[n]}function kr(n){Yi={...n}}function fn(n,e,s,o){if(dn[n]<dn[$i])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...Yi,...o});n==="error"||n==="warn"?rc.write(`${c}
10
+ `):nc.write(`${c}
11
+ `)}function O(n){return{debug:(e,s)=>fn("debug",n,e,s),info:(e,s)=>fn("info",n,e,s),warn:(e,s)=>fn("warn",n,e,s),error:(e,s)=>fn("error",n,e,s),child:e=>O(`${n}.${e}`)}}var dn,$i,nc,rc,Yi,q=Me(()=>{"use strict";dn={debug:10,info:20,warn:30,error:40},$i=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),nc=process.stdout,rc=process.stderr,Yi={}});import{promises as Zi}from"node:fs";import{homedir as ic}from"node:os";import{sep as sc,join as ce,resolve as Qi}from"node:path";function H(n){let e=n??ic(),s=ce(e,".coze"),o=ce(s,"bridge"),c=ce(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:ce(c,"index.js"),binDir:ce(o,"bin"),pidFile:ce(o,"bridge.pid"),portFile:ce(o,"bridge.port"),tokenFile:ce(o,"bridge.token"),logFile:ce(o,"bridge.log"),installLock:ce(o,"install.lock"),configFile:ce(o,"config.json"),agentsRoot:ce(s,"agents")}}function Fe(n,e=H()){let s=ce(e.agentsRoot,n);return{root:s,config:ce(s,"config.json"),workspace:ce(s,"workspace"),logs:ce(s,"logs")}}async function es(n,e){let s=await Zi.realpath(Qi(n)).catch(()=>null);if(!s)return!1;let o=await Zi.realpath(Qi(e)).catch(()=>null);if(!o)return!1;let c=process.platform==="win32"?s.toLowerCase():s,u=process.platform==="win32"?o.toLowerCase():o;return c===u||c.startsWith(u+sc)}var fe=Me(()=>{"use strict"});var gn={};Wi(gn,{AGENT_CONFIG_FILE_MODE:()=>ln,enforceAgentConfigMode:()=>cc,loadAgentConfig:()=>ge,persistAgentSessions:()=>Tr,persistAgentSkills:()=>hn,saveAgentConfig:()=>Se});import{chmod as oc,stat as ac}from"node:fs/promises";function ge(n,e){return gt(Fe(n,e).config)}function Se(n,e){return xn(Fe(n.agentId,e).config,n,{mode:ln})}async function cc(n,e){if(process.platform==="win32")return;let s=Fe(n,e).config;try{let o=await ac(s);if(!o.isFile())return;let c=o.mode&511;c!==ln&&(await oc(s,ln),ts.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;ts.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Tr(n,e,s){let o=await ge(n,s);o&&(o.sessions=Object.fromEntries(e),await Se(o,s))}async function hn(n,e,s){let o=await ge(n,s);o&&(o.skills=e,await Se(o,s))}var ts,ln,Ve=Me(()=>{"use strict";un();q();fe();ts=O("agent-config"),ln=384});var bo=he(Q=>{"use strict";var C=P;(function(n,e){let s=P,o=n();for(;;)try{if(parseInt(s(768))/1*(-parseInt(s(466))/2)+parseInt(s(197))/3+-parseInt(s(1518))/4*(parseInt(s(886))/5)+-parseInt(s(642))/6*(-parseInt(s(1498))/7)+-parseInt(s(1499))/8+-parseInt(s(1426))/9*(parseInt(s(1363))/10)+parseInt(s(1144))/11===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(Jn,508916);var bu=Object[C(1356)+C(901)],vu=Object[C(1184)+"opertyNa"+C(1162)],po=(n,e)=>function(){return n&&(e=(0,n[{ByNOK:function(u,f){return u(f)}}[C(1208)](vu,n)[0]])(n=0)),e},Su=(n,e)=>{let s=C,o={RnjDF:function(u,f,h,m){return u(f,h,m)}};for(var c in e)o[s(179)](bu,n,c,{get:e[c],enumerable:!0})};function P(n,e){n=n-156;let s=Jn(),o=s[n];if(P.CCfXpQ===void 0){var c=function(m){let w="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",b="",S="";for(let A=0,N,D,R=0;D=m.charAt(R++);~D&&(N=A%4?N*64+D:D,A++%4)?b+=String.fromCharCode(255&N>>(-2*A&6)):0)D=w.indexOf(D);for(let A=0,N=b.length;A<N;A++)S+="%"+("00"+b.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(S)};P.UojvVb=c,P.wrBkRl={},P.CCfXpQ=!0}let u=s[0],f=n+u,h=P.wrBkRl[f];return h?o=h:(o=P.UojvVb(o),P.wrBkRl[f]=o),o}function Eu(){return uo||(uo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Cu(){let n=C;return fo||(fo=[IDBCursor[n(1706)+"e"][n(672)],IDBCursor[n(1706)+"e"][n(1002)],IDBCursor[n(1706)+"e"][n(1002)+n(592)+"ey"]])}function Au(n){let e=C,s={ytRyz:function(c,u){return c*u},SPhOm:function(c,u){return c>>>u},DNFPG:function(c,u){return c+u},YnXHy:function(c,u){return c>>>u},DbYjg:e(1616),dgzsi:e(1296),FBTFm:function(c,u){return c(u)},MyZiV:function(c){return c()},nTZNp:function(c,u){return c===u},IxnVE:e(1092),muVio:"nfifj",pVOUo:function(c,u){return c instanceof u}},o=new Promise((c,u)=>{let f=e;if(s[f(975)](s[f(248)],s[f(479)]))return this[f(290)]?s[f(419)](s[f(1592)](this.high,0),_0x1e24e1)+s.SPhOm(this.low,0):s[f(203)](s[f(419)](this[f(1332)],_0x329fef),s[f(942)](this[f(1200)],0));{let h=()=>{let b=f;n[b(1614)+b(1475)+b(1593)](s.DbYjg,m),n[b(1614)+b(1475)+b(1593)](s[b(1410)],w)},m=()=>{let b=f;s[b(392)](c,s[b(392)](Re,n[b(1632)])),s[b(1137)](h)},w=()=>{let b=f;u(n.error),s[b(1137)](h)};n["addEvent"+f(1624)](s.DbYjg,m),n[f(1690)+f(1624)](s[f(1410)],w)}});return o.then(c=>{let u=e;s[u(215)](c,IDBCursor)&&Gr[u(643)](c,n)})[e(578)](()=>{}),Hn[e(643)](o,n),o}function Iu(n){let e=C,s={ltuDF:function(c,u){return c(u)},rsqAB:e(599)+"or",aMOYP:function(c){return c()},RpxAN:e(607),qvhfS:function(c){return c()},aVEdI:"error",rqEtH:"abort"};if(Gn[e(1718)](n))return;let o=new Promise((c,u)=>{let f=e,h={hVUzV:s[f(1396)],KKKCq:"error",CvcTr:function(S){return S()},RxJGR:function(S){return s[f(1673)](S)}},m=()=>{let S=f;n[S(1614)+"entListener"](h[S(720)],w),n[S(1614)+S(1475)+S(1593)](h[S(611)],b),n[S(1614)+S(1475)+S(1593)]("abort",b)},w=()=>{let S=f;h.CvcTr(c),h[S(169)](m)},b=()=>{let S=f;s[S(1508)](u,n[S(1296)]||new DOMException(s.rsqAB,s[S(957)])),s.aMOYP(m)};n[f(1690)+f(1624)](s[f(1396)],w),n[f(1690)+f(1624)](s[f(1123)],b),n[f(1690)+f(1624)](s.rqEtH,b)});Gn[e(643)](n,o)}function Pu(n){Wn={crTng:function(s,o){return s(o)}}.crTng(n,Wn)}function ku(n){let e=C,s={IMWUe:function(o,c){return o(c)},MqbIW:function(o,c){return o(c)},STAkg:function(o,c){return o===c},SagGj:"ACKhF",NjhJh:function(o,c){return o in c},Kgexl:"objectStoreNames",vPLsZ:function(o){return o()}};return n===IDBDatabase[e(1706)+"e"][e(1018)+e(1639)]&&!s.NjhJh(s[e(1319)],IDBTransaction.prototype)?function(o,...c){let u=e,f=n[u(1054)](s.IMWUe(Yt,this),o,...c);return jr[u(643)](f,o.sort?o[u(410)]():[o]),s[u(1304)](Re,f)}:s[e(1007)](Cu)[e(842)](n)?function(...o){let c=e;return n[c(1683)](Yt(this),o),s[c(533)](Re,Gr[c(205)](this))}:function(...o){let c=e;if(s[c(1004)](s.SagGj,s.SagGj))return s.MqbIW(Re,n.apply(Yt(this),o));throw this[c(340)+c(1693)]=!1,_0x149506}}function Tu(n){let e=C,s={spYep:function(o,c){return o===c},IytkZ:e(1206),ZlGZU:function(o,c){return o(c)},udotr:function(o,c){return o instanceof c},WxHaM:function(o){return o()}};return s[e(1195)](typeof n,s[e(1072)])?s[e(1292)](ku,n):(s[e(161)](n,IDBTransaction)&&s[e(1292)](Iu,n),mo(n,s[e(1521)](Eu))?new Proxy(n,Wn):n)}function Re(n){let e=C,s={MiPQw:function(c,u){return c instanceof u},gAWxD:function(c,u){return c(u)}};if(s.MiPQw(n,IDBRequest))return s.gAWxD(Au,n);if(Kn[e(1718)](n))return Kn[e(205)](n);let o=s[e(246)](Tu,n);return o!==n&&(Kn.set(n,o),Hn.set(o,n)),o}var mo,uo,fo,Gr,Gn,jr,Kn,Hn,Wn,Yt,lo=po({"node_modules/idb/build/wrap-idb-value.js"(){let n=C,e={cnOet:function(s,o){return s==o},mffGs:"wss://",fpNAQ:function(s,o){return s instanceof o},SKEEL:function(s,o){return s!==o},dewvw:n(653),wRuDp:n(779),LwHwy:function(s,o){return s===o},tvMFy:n(1251)+n(214),MErkn:function(s,o){return s===o},msrAG:n(1431),eOoeW:function(s,o){return s(o)},lSlQA:function(s,o){return s in o}};mo=(s,o)=>o[n(517)](c=>s instanceof c),Gr=new WeakMap,Gn=new WeakMap,jr=new WeakMap,Kn=new WeakMap,Hn=new WeakMap,Wn={get(s,o,c){let u=n;if(e[u(462)](s,IDBTransaction))if(e[u(185)](e[u(1107)],e[u(1107)]))_0x5265d0=_0x1311e7&&e[u(1210)]("https:",_0x20a8d9[u(1074)])?e[u(562)]:u(422),_0x2bc2e0=_0x331baf.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),_0x47d382=/^wss(.*:\/\/)/.test(_0x7e1e1f)?_0x5d40c2:""+_0x355918+_0x540d1b;else{if(o===e[u(973)])return Gn[u(205)](s);if(e.LwHwy(o,e[u(1588)]))return s[u(1251)+"oreNames"]||jr[u(205)](s);if(e[u(564)](o,e[u(1135)]))return c[u(1251)+u(214)][1]?void 0:c[u(1251)+"ore"](c[u(1251)+u(214)][0])}return e[u(962)](Re,s[o])},set(s,o,c){return s[o]=c,!0},has(s,o){let c=n;return s instanceof IDBTransaction&&(e[c(564)](o,e[c(973)])||e[c(674)](o,e[c(1135)]))?!0:e[c(673)](o,s)}},Yt=s=>Hn[n(205)](s)}}),_o={};Su(_o,{deleteDB:()=>Ru,openDB:()=>Du,unwrap:()=>Yt,wrap:()=>Re});function Du(n,e,{blocked:s,upgrade:o,blocking:c,terminated:u}={}){let f=C,h={GBsTl:function(b,S,A,N,D){return b(S,A,N,D)},KUblA:function(b,S){return b(S)},BDciI:function(b,S){return b(S)},JOTcp:f(616),tFGRZ:f(818)+"hange",XkntK:f(603)},m=indexedDB[f(473)](n,e),w=h[f(236)](Re,m);return o&&m[f(1690)+f(1624)](f(210)+f(424),b=>{let S=f;h[S(1720)](o,h[S(236)](Re,m[S(1632)]),b[S(877)+"on"],b[S(705)+"on"],h[S(618)](Re,m["transact"+S(1639)]))}),s&&m[f(1690)+"Listener"](h[f(1416)],()=>s()),w.then(b=>{let S=f;u&&b[S(1690)+S(1624)](h[S(726)],()=>u()),c&&b[S(1690)+"Listener"](h[S(389)],()=>c())})[f(578)](()=>{}),w}function Ru(n,{blocked:e}={}){let s=C,o={LZByW:s(603),pDKvp:function(u,f){return u(f)}},c=indexedDB[s(478)+"tabase"](n);return e&&c[s(1690)+s(1624)](o[s(372)],()=>e()),o[s(165)](Re,c)[s(476)](()=>{})}function ho(n,e){let s=C,o={EAGce:function(m,w){return m instanceof w},lJPFn:function(m,w){return m in w},UQznn:function(m,w){return m===w},mKYxa:s(324),dcyxL:function(m,w){return m!==w}};if(!(o.EAGce(n,IDBDatabase)&&!o.lJPFn(e,n)&&o[s(931)](typeof e,o[s(477)])))return;if(jn[s(205)](e))return jn.get(e);let c=e[s(1052)](/FromIndex$/,""),u=o.dcyxL(e,c),f=yo[s(842)](c);if(!o[s(225)](c,(u?IDBIndex:IDBObjectStore).prototype)||!(f||wo[s(842)](c)))return;let h=async function(m,...w){let b=s,S=this[b(1018)+b(1639)](m,f?b(192)+"e":b(208)),A=S.store;return u&&(A=A[b(278)](w[b(1652)]())),(await Promise[b(280)]([A[c](...w),f&&S[b(779)]]))[0]};return jn[s(643)](e,h),h}var wo,yo,jn,Ou=po({"node_modules/idb/build/index.js"(){let n=C,e={XBrOl:n(1183)+n(979),QNzhj:function(c){return c()},HKbDK:"put",LekcY:n(1631),GooXB:n(402),srprN:n(255),VcqXM:n(205),tRHas:n(848)+"ys",WtxwD:n(446)},s=e[n(535)][n(1708)]("|"),o=0;for(;;){switch(s[o++]){case"0":e[n(795)](lo);continue;case"1":Pu(c=>({...c,get:(u,f,h)=>ho(u,f)||c[n(205)](u,f,h),has:(u,f)=>!!ho(u,f)||c[n(1718)](u,f)}));continue;case"2":jn=new Map;continue;case"3":yo=[e[n(1335)],e[n(870)],e.GooXB,e[n(709)]];continue;case"4":wo=[e.VcqXM,n(951),n(1389),e.tRHas,e.WtxwD];continue;case"5":lo();continue}break}}}),Lu={idb:function(n){let e=C;n[e(906)]=Promise[e(1577)]()[e(476)](()=>(Ou(),_o))[e(476)](function(s){return s})}},go={};function De(n){let e=C,s={IcDRI:e(394)+"1",gvmCr:function(h,m){return h!==m}},o=s[e(405)][e(1708)]("|"),c=0;for(;;){switch(o[c++]){case"0":var u=go[n]={exports:{}};continue;case"1":return u[e(906)];case"2":if(s[e(469)](void 0,f))return f[e(906)];continue;case"3":var f=go[n];continue;case"4":Lu[n](u,u[e(906)],De);continue}break}}De.d=(n,e)=>{let s=P;for(var o in e)De.o(e,o)&&!De.o(n,o)&&Object[s(1356)+s(901)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=C;De.o=(e,s)=>Object[n(1706)+"e"]["hasOwnPr"+n(901)].call(e,s)})(),(()=>{let n=C,e={GaIrK:function(s,o){return s!=o},NFqwn:n(1096)+"d",gYqHS:n(1608)+"le"};De.r=s=>{let o=n;e[o(553)](e[o(173)],typeof Symbol)&&Symbol["toString"+o(382)]&&Object[o(1356)+o(901)](s,Symbol[o(175)+o(382)],{value:o(262)}),Object[o(1356)+o(901)](s,e.gYqHS,{value:!0})}})();var X={};(()=>{let n=C,e={VjbYc:function(i,t){return i(t)},pSZJn:function(i,t){return i+t},KndiN:function(i,t,r){return i(t,r)},EjZhe:function(i,t){return i!==t},cbMsU:"eqXSs",QWPvB:n(1126),CInAg:function(i,t){return i*t},WoTcD:function(i,t){return i*t},TpxWG:n(843),AeNbA:function(i,t){return i(t)},lieuv:function(i,t,r){return i(t,r)},IqEkU:function(i,t){return i+t},JRbyL:function(i,t){return i(t)},DJmiK:"0000",jOSie:n(189),FmhHC:function(i,t){return i(t)},nueWj:n(288)+n(288)+"00000000"+n(288),OehqM:function(i,t){return i<t},KJzlz:function(i,t){return i>t},uFbbP:function(i,t){return i!==t},kHLGG:function(i,t){return i-t},sFwuv:function(i,t){return i!==t},iZrnP:function(i,t){return i===t},cvIaZ:function(i,t){return i!==t},VYhRF:n(1524),nSsfX:function(i,t,r){return i(t,r)},SNKKd:function(i,t){return i!==t},gLPUA:function(i,t){return i>>>t},NzeoY:function(i,t){return i(t)},noaMB:function(i,t){return i===t},zFGDj:n(1429)+n(1338)+n(1173)+n(1057),uvEMZ:n(1429)+n(1338)+" field: "+n(1613),mPwsk:function(i){return i()},NCIOv:function(i,t){return i!==t},IztgT:function(i,t,r){return i(t,r)},nuYgl:function(i,t,r){return i(t,r)},ygNox:function(i,t,r){return i(t,r)},wlknv:function(i,t,r){return i(t,r)},czqYS:function(i,t){return i(t)},IlJGG:function(i,t){return i!==t},undYE:function(i,t,r){return i(t,r)},PUpXe:function(i,t,r){return i(t,r)},fiLTT:n(1671),cbSVO:n(1675),MsMJJ:function(i,t){return i!==t},TemAX:function(i,t,r){return i(t,r)},tLRCl:function(i,t,r){return i(t,r)},lSIhH:n(237),yTVEN:function(i,t,r){return i(t,r)},AeFrH:function(i,t,r){return i(t,r)},TkTyI:function(i,t){return i!==t},qmMuP:function(i,t){return i===t},Fzuzr:"amtLR",jRPeO:function(i,t){return i!==t},MRubH:function(i,t,r){return i(t,r)},mGWSU:function(i,t){return i(t)},qTaeN:n(656),MObaP:function(i,t){return i(t)},ZdVUu:function(i,t){return i(t)},ZgskS:function(i,t){return i(t)},OlRAh:function(i,t){return i(t)},pXnJD:function(i,t,r){return i(t,r)},RVYfL:function(i,t){return i(t)},FeVPY:function(i,t,r){return i(t,r)},mOujg:function(i,t){return i(t)},UiBsB:function(i,t,r){return i(t,r)},jjLgM:function(i,t){return i(t)},pNMVc:function(i,t,r){return i(t,r)},vRZVu:function(i,t){return i&t},YwMMX:function(i,t){return i===t},RwogY:n(1429)+n(1338)+" field: SeqID",PtUpH:n(1429)+n(1338)+n(1173)+"service",TJRUf:"Missing required field: "+n(784),YqIuX:function(i,t){return i(t)},VTVjz:function(i,t){return i&t},unBvZ:function(i,t,r){return i(t,r)},FfnNG:function(i,t){return i>>t},PYzjO:function(i,t){return i>=t},QZwaG:function(i,t){return i===t},NszVd:n(1307)+n(1203),dafdA:function(i,t){return i>=t},DwZtK:n(1166),FwujJ:function(i,t){return i+t},nxEoI:function(i,t){return i>t},nUOqa:function(i,t){return i+t},subni:n(1143)+n(1203),qIyeh:function(i,t,r){return i(t,r)},zSlhY:n(616),HCNMv:"bye",lGtSi:"going aw"+n(1182)+n(1086)+n(1371),BUoJc:function(i,t){return i instanceof t},pqInz:function(i,t,r){return i(t,r)},ADRXO:"JsNAW",Eyugq:function(i,t){return i<t},cpTfu:function(i,t){return i&t},hJwzB:function(i,t){return i(t)},OfnQw:function(i,t){return i===t},dKtzD:function(i,t){return i+t},NxwCa:function(i,t){return i&t},LKmLx:function(i,t){return i|t},aQTcU:function(i,t){return i<<t},WHikM:function(i,t){return i==t},Pprfy:function(i,t){return i&t},sasWQ:function(i,t){return i+t},hlssG:function(i,t){return i+t},pULBR:function(i,t){return i|t},PjPFd:function(i,t){return i<<t},KqKar:function(i,t){return i|t},SnWIV:function(i,t){return i&t},hMLCO:function(i,t){return i>=t},CCxIB:function(i,t){return i<=t},mldOA:function(i,t){return i>=t},jvbDL:"gTInZ",LzAJb:function(i,t){return i+t},RbdhJ:function(i,t){return i+t},QOeCU:function(i,t){return i+t},iZtZv:function(i,t){return i!==t},lEMCM:function(i,t){return i&t},LipHP:function(i,t){return i<<t},SWFIn:function(i,t){return i|t},tfcwv:function(i,t){return i&t},sGjYW:function(i,t){return i&t},BduUZ:function(i,t){return i+t},ePrAy:function(i,t){return i+t},txsju:function(i,t){return i!=t},dNQyB:"undefined",AVcms:n(262),pSeAY:n(1608)+"le",VdxZb:n(1699)+n(1242),pUTTk:function(i,t){return i===t},YoOsz:n(1063)+n(968)+n(1651),UypCn:n(1063)+"s instan"+n(1731)+n(1299)+"ed",kTTcn:function(i,t){return i<=t},BAKFU:function(i,t){return i<t},ayXSz:function(i,t){return i+t},YlHCn:function(i,t){return i<t},MGtmI:function(i,t){return i<t},YDYIM:function(i,t,r){return i(t,r)},dVKdf:function(i,t,r){return i(t,r)},KJumn:n(1212),QwzZt:function(i,t){return i+t},XflOR:function(i,t){return i-t},wLrxu:function(i,t){return i&t},ipBwL:function(i,t){return i>>t},jdusq:n(252),LCgMs:function(i,t){return i<t},AHMAK:function(i,t){return i|t},ufvUu:function(i,t){return i>>t},VNzGo:function(i,t){return i>>t},jTsgG:function(i,t){return i>>t},OuZYf:function(i,t){return i|t},xODMc:function(i,t){return i&t},PXqDx:function(i,t){return i+t},DgNfN:n(1066),dYLMh:function(i,t,r){return i(t,r)},SNGqJ:function(i,t){return i+t},kJLIq:function(i,t){return i(t)},bSZiI:function(i,t){return i<t},BxMGo:function(i,t){return i&t},oDlCR:function(i,t){return i&t},oFgxS:function(i,t){return i!==t},ZEnVU:"RVDDp",DmoMU:n(182),ZKYnQ:function(i,t,r){return i(t,r)},IvMek:function(i,t){return i<<t},PxglB:function(i,t){return i>t},UujPE:n(1271),KTHMl:"rqKpv",CCjsf:function(i,t){return i&t},lxRZh:function(i,t){return i|t},hjRFj:function(i,t){return i|t},jaDqP:function(i,t){return i&t},pYwfK:function(i,t){return i&t},DlCTt:function(i,t){return i&t},mqFgG:function(i,t){return i(t)},XtuIR:function(i,t){return i<<t},RnmQt:function(i,t){return i(t)},UNYfJ:function(i,t){return i<<t},hiWBE:function(i,t){return i&t},tdiGj:function(i,t){return i&t},TXDST:function(i,t){return i<<t},OzcdL:function(i,t){return i&t},BKlQK:n(1418),TuECj:function(i,t){return i&t},wsJeW:function(i,t){return i&t},YwALT:n(1497),BRMsZ:n(334),RYZPf:function(i,t){return i&t},WKBKn:function(i,t){return i|t},jkDYU:function(i,t){return i<<t},nmevJ:function(i,t){return i|t},JCAps:function(i,t){return i<<t},bYuJp:function(i,t){return i>>>t},ULIqv:function(i,t){return i<t},CsUtt:function(i,t){return i<t},eSOHD:function(i,t){return i<t},zQylX:function(i,t){return i+t},CQHHs:function(i,t){return i!==t},qnrOs:function(i,t){return i|t},MXpOK:function(i,t){return i&t},lpPmC:function(i,t){return i>>>t},iEltx:function(i,t){return i>>>t},PBxGz:function(i,t){return i&t},tZYyy:function(i,t){return i!==t},pKIQA:function(i,t){return i!==t},KNETO:function(i,t){return i&t},aMDod:function(i,t){return i+t},dIDwL:function(i,t){return i&t},JGYuG:function(i,t){return i>>>t},FZWAa:function(i,t){return i!==t},rNPyP:function(i,t){return i|t},BIHBB:function(i,t){return i&t},bJqqA:function(i,t){return i&t},cjMxg:function(i,t){return i>>>t},GNDPf:function(i,t){return i!==t},ipcms:function(i,t){return i<=t},LYCVQ:function(i,t){return i&t},hyHpX:function(i,t){return i&t},DxMmT:function(i,t){return i|t},peDND:function(i,t){return i===t},kXbnD:n(888),ddHsv:n(1378),dPvoq:function(i,t){return i(t)},Evvot:function(i,t){return i===t},GIVMF:n(1161),AKTgH:function(i,t){return i|t},NWHXf:function(i,t){return i|t},ROhhB:function(i,t){return i===t},kMhoJ:function(i,t){return i|t},LPTjy:function(i,t){return i|t},KQTAs:function(i,t){return i<<t},EvXlh:function(i,t){return i|t},IaFvs:function(i,t){return i|t},GXeqT:function(i,t){return i|t},JxSxm:function(i,t){return i<<t},XDkid:function(i,t){return i|t},dSBWd:function(i,t){return i<<t},URLkF:function(i,t){return i|t},jDnZw:function(i,t){return i|t},mUGIp:function(i,t){return i<<t},hibap:function(i,t){return i<<t},kFGrd:function(i,t){return i<<t},QqVSp:function(i,t){return i!==t},DZakr:n(303),jksTj:n(184),PqdJd:function(i,t){return i|t},npWxh:function(i,t){return i|t},QHvny:function(i,t){return i<<t},enCZy:function(i,t){return i<<t},XdMHn:function(i,t){return i|t},pnhCG:function(i,t){return i<<t},abHlM:function(i,t){return i&t},YqdKX:function(i,t){return i>>>t},iStTG:function(i,t){return i>>>t},YpqiZ:function(i,t){return i>=t},mnnpP:function(i,t){return i<=t},Xwkvx:function(i,t){return i%t},EGiLv:function(i,t){return i/t},IshXh:function(i,t){return i+t},YaOrf:function(i,t){return i*t},NecpK:function(i,t){return i>>>t},MhsYY:function(i,t){return i&t},lwPro:function(i,t){return i>>>t},vUbFc:function(i,t){return i>>>t},POQHt:function(i,t){return i+t},ehrJB:function(i,t){return i+t},PQiVc:function(i,t){return i!==t},OmWMA:function(i,t){return i>>>t},JDiim:function(i,t){return i===t},wsNWg:function(i,t){return i===t},CknRm:function(i,t){return i===t},UwCHx:function(i,t){return i===t},NcFxf:function(i,t){return i&t},NiCcj:function(i,t){return i>>>t},YHDdn:function(i,t){return i&t},XUJDo:function(i,t){return i>>>t},yodHJ:function(i,t){return i&t},pfyjy:function(i,t){return i&t},cWtqb:function(i,t){return i>>>t},kvtLy:function(i,t){return i>>>t},NdnAN:function(i,t){return i&t},GOcpH:function(i,t){return i>>>t},EteAL:"string",WtokT:function(i,t){return i instanceof t},vspeL:function(i,t){return i!=t},rpPMZ:n(1321)+n(1576),TSaSt:"text/plain;chars"+n(1118),dnEiE:n(762),jtBkd:n(1461),BzoJN:n(1005)+"3|2",KLwsi:n(366)+n(821)+"R",tvzxT:n(1449)+"OR",XSYKt:n(644)+n(1011),eMCil:"MESSAGE_ERROR",jzQjr:function(i,t){return i+t},MZNtr:"tzWDP",hpnoN:function(i,t){return i(t)},sePaV:n(974),qWZHo:"tOjrc",NssIP:"XUfyo",zckyH:function(i,t){return i-t},LjGrZ:function(i,t){return i===t},vVwEm:function(i,t){return i==t},nQfug:function(i,t){return i>t},mLrnD:function(i,t){return i>t},qRwFT:function(i,t){return i===t},FUQpV:n(260),kpLWy:function(i,t){return i|t},KpGTD:n(1084),djZnT:n(1296),xjrVH:function(i,t){return i+t},guAZD:function(i,t){return i<=t},ZFVlq:n(1231)+n(1008)+n(1594)+"imes in "+n(1080),UVXze:function(i,t){return i===t},RwNXe:n(428),KbanT:n(727),GDKYt:function(i,t,r){return i(t,r)},AgvDw:function(i,t,r){return i(t,r)},Slhxw:"dQyQo",lDGTS:n(1589),MKCaB:n(473),GngbU:n(1713),NODup:n(1542),elqai:function(i,t,r){return i(t,r)},ZmyHL:function(i,t){return i instanceof t},Zsvpt:function(i,t){return i===t},GBpOo:function(i,t){return i<t},KHNZM:function(i,t){return i&t},yCclA:function(i,t){return i>>t},iKkKp:function(i,t){return i>>t},YDyxm:function(i,t){return i>>t},IzVaP:function(i,t){return i>>t},LrPvp:function(i,t){return i|t},fecaL:n(1536),FOHXb:function(i,t){return i||t},jJrMN:function(i,t){return i||t},zPbtN:function(i,t){return i!=t},RnilA:function(i,t){return i!==t},nepiv:"TgrmM",eFpmP:function(i,t){return i<=t},jvOxM:function(i,t){return i<t},dPLLP:function(i,t){return i===t},Doyqj:function(i,t){return i&t},KVfSJ:function(i,t){return i&t},sifXI:function(i,t){return i===t},lXpVz:n(1202),QNyFS:function(i,t){return i<t},PpXIf:function(i,t){return i-t},yTpMZ:function(i,t){return i<=t},fmnaN:function(i,t){return i&t},lLhFJ:function(i,t){return i&t},vMCrB:function(i,t){return i<<t},msdCp:function(i,t){return i&t},EzAue:function(i,t){return i<<t},EoHxk:function(i,t){return i>=t},eYfbm:function(i,t){return i|t},AjAaP:function(i,t){return i&t},xuuDw:function(i,t){return i>>t},FATwd:function(i,t){return i+t},cNuyn:function(i,t){return i<t},GvtSd:function(i,t){return i&t},gUkET:function(i,t){return i===t},fhxBF:function(i,t){return i&t},xIinq:function(i,t){return i===t},HexIo:function(i,t){return i&t},ApNJE:n(443)+n(274),lFVmo:function(i,t){return i>>t},QuPGi:function(i,t){return i<<t},fpFfT:function(i,t){return i|t},ePwut:function(i,t){return i&t},TtZDd:function(i,t){return i>>t},OSvAy:function(i,t){return i>>t},SBjsA:function(i,t){return i|t},regTR:function(i,t){return i&t},zKhxF:function(i,t){return i-t},wkSTx:function(i,t,r,a){return i(t,r,a)},PauYx:function(i,t){return i instanceof t},haWcb:function(i,t){return i!=t},NwESy:function(i,t){return i instanceof t},cBaca:"boe",Vtwsa:"ppe",cWTXJ:n(1151),KIgcJ:"unknown reason",tnOtV:n(460),KXdEI:n(157)+n(1031),fPEro:"http",LGpqw:n(1398)+n(681)+n(341)+"P",LXmUJ:n(1315),buxJI:n(1644),VtFCE:n(838),igQrl:n(669),oFgTE:n(1566),EJnFo:function(i,t){return i!==t},dmlhU:n(1302),LliDV:function(i,t){return i(t)},uvXga:n(384),nuWDw:n(941),hRlGL:n(813),rCUIx:function(i,t){return i||t},HUxss:function(i,t){return i||t},fCxNI:function(i,t){return i||t},nwWsC:function(i,t){return i||t},pBsgb:function(i,t){return i!==t},skqqI:"uOUuU",cTunr:function(i,t){return i-t},hSRer:function(i,t){return i|t},uRYyV:function(i,t){return i<<t},UmUkt:function(i,t){return i+t},saCZn:"kYXnq",FsEfk:function(i,t){return i||t},rKJEi:function(i,t){return i!=t},DKLPP:n(1654)+n(1178)+"d",NCJnK:n(442)+"id",SywPm:function(i,t,r){return i(t,r)},IZMGV:function(i,t){return i===t},OxzkK:function(i,t){return i===t},mDiXb:n(652),JMyny:n(263),OCNQr:function(i,t){return i(t)},stJEc:function(i,t,r,a){return i(t,r,a)},WSkjA:n(1238)+n(403),SOzgG:n(1238)+n(1083)+"ck",FQueJ:function(i,t,r,a){return i(t,r,a)},GiFpr:n(1238)+n(702)+"k",awGVw:n(1238)+n(265)+"sgid",JPxLi:n(1560),YifTw:"need_ack",LikFI:n(698),JdCkb:function(i,t){return i&&t},HouJT:n(1495),vgdCf:n(216),HRigu:function(i){return i()},PYdJj:"irWBj",NGlAA:function(i,t){return i instanceof t},yfeYT:n(1321)+n(1576)+n(1504)+n(304),tqadn:n(1252)+"e",UYENW:n(909),lbFje:function(i){return i()},NzFvy:function(i,t){return i<t},wjgna:n(1014),OKrbp:function(i,t){return i|t},XpKCm:function(i,t){return i||t},wsqPl:function(i,t){return i>>>t},cvggD:function(i,t){return i+t},JLlLR:function(i,t){return i+t},BNKpA:" + ",IZAqN:function(i,t,r,a){return i(t,r,a)},zXHnS:function(i,t){return i+t},uOUVa:function(i,t){return i+t},mOMMo:function(i,t){return i<t},IlcNN:function(i,t){return i||t},XcSJl:function(i,t){return i!==t},vaBhl:"3|0|1|2|4",yrJvB:function(i,t){return i<<t},eOggU:function(i,t){return i+t},wyIwG:function(i,t){return i|t},EBNHL:function(i,t){return i|t},bhRwx:function(i,t){return i+t},QsCGS:function(i,t){return i!==t},lfgvU:n(771),qIjCG:n(1257),UWaBx:function(i,t){return i>>>t},ctssG:function(i,t){return i&t},LNeFf:function(i,t){return i&t},FRvxJ:function(i,t){return i>>>t},uahOw:function(i,t){return i&t},gmJPq:function(i,t){return i+t},UiNho:n(666),xlzOb:function(i,t){return i+t},KUkTw:n(589),Hyeng:n(1629)+n(1408)+"|6|11|9|5",QVBug:function(i,t){return i>>>t},euscp:function(i,t){return i<t},YUFsX:function(i,t){return i<t},npxoR:function(i,t){return i|t},kqNyQ:function(i,t){return i>>>t},ORPNc:function(i,t){return i|t},zVVKm:function(i,t){return i<<t},daCXP:function(i,t){return i|t},sKuEx:function(i,t){return i>>>t},Pknew:function(i,t){return i|t},VfGLR:function(i,t){return i>t},zitkI:function(i,t){return i>t},tCNSc:n(233),Acufj:"qFzOj",GqzXo:n(1131),fQykE:n(929)+n(554)+n(383),utkex:function(i,t,r,a){return i(t,r,a)},FLboG:n(418),VmwQf:n(1216),CnoCV:n(1039)+n(1207),Podoh:"curvalue",yCJVB:n(199),nnZdD:n(915)+"name",yHvZm:function(i,t,r,a){return i(t,r,a)},uROuS:function(i,t,r,a){return i(t,r,a)},SpNNp:function(i,t){return i(t)},bSxtx:function(i,t){return i instanceof t},GKHiW:n(474)+"d error.",aKTir:function(i,t){return i+t},ZGpPG:function(i,t){return i<t},Ihfqg:function(i,t,r){return i(t,r)},XbIxV:function(i,t,r,a){return i(t,r,a)},zlRBs:"cursor_f"+n(1399),ejlzz:n(229)+n(467),Srzlg:"ALL",srCgt:n(1053),ZNILy:n(1185),fKIlu:function(i,t,r,a){return i(t,r,a)},qzols:function(i,t){return i===t},lgkqu:n(561),PEoJO:n(1393),osPxk:n(378)+"10|2|1|7"+n(693),hmXjj:function(i,t,r,a){return i(t,r,a)},TQOyI:function(i,t){return i(t)},trjaH:n(1156),sooxU:n(482),ouACl:n(1043)+"r",xNlOH:"NKjYX",lZghs:n(358),VWFxy:n(1476),TBNyc:n(1616),ORGia:function(i,t,r,a){return i(t,r,a)},WRLRF:n(615),VJwuc:function(i,t,r,a){return i(t,r,a)},CAzFt:function(i,t,r){return i(t,r)},QtJwZ:"x_fronti"+n(620),RbBsL:n(1438)+"s",BqqdF:function(i,t,r){return i(t,r)},PtXDj:function(i,t){return i(t)},cjUCh:"XyabF",PHYGW:function(i,t){return i!==t},cVSEG:n(970),HsoCi:function(i){return i()},fTNpB:function(i,t){return i===t},xaFVJ:"GgwRu",arIKq:function(i){return i()},YDGYB:function(i,t){return i&&t},QriWN:function(i,t,r){return i(t,r)},GnWRK:function(i){return i()},ggdts:function(i){return i()},ShSfe:function(i,t){return i<t},diMUR:function(i,t){return i<t},ImPVO:function(i,t){return i&t},HqQbR:function(i,t){return i<t},uxXPD:function(i,t){return i-t},nzTrW:function(i,t){return i<<t},bjqpw:function(i,t){return i>>t},rZjdH:function(i,t){return i!==t},DdepB:function(i,t){return i!==t},exora:function(i){return i()},vsIOU:function(i,t){return i(t)},atKHh:function(i,t){return i&t},nhEsa:n(585),lWGGS:function(i,t){return i===t},Ymums:"KfPae",slGSB:"LMWXu",bHogh:function(i,t,r){return i(t,r)},Onkhk:n(601),AeoKC:n(741),dfQRj:function(i,t){return i===t},SduoA:n(1556),XmVLN:n(447),WmUps:n(417),VGkVj:function(i,t){return i(t)},bMIYB:function(i,t){return i!==t},Njzif:n(619)+n(640),MUShB:n(963),jETbV:function(i,t){return i==t},QNbAe:function(i,t){return i===t},sLbZE:n(575)+n(1401)+n(757),nkpvu:function(i,t){return i(t)},UQJmb:n(575)+n(1571)+n(1353)+n(1132)+"ket cons"+n(777)+n(1247)+"ined",rfxVT:"IiwCR",nBLkX:"stop imm"+n(1702)+n(776)+"ct",bRlDP:n(1258),cGQBz:"offline",saYmt:n(833),AzwGa:"pageshow",oqpZj:function(i,t){return i!==t},XhJKH:function(i,t){return i==t},EwxdJ:n(1301),mDpdN:n(1500),FrvlR:n(422),REtoX:n(250)+"d",EBhaR:function(i,t){return i||t},Ysnzw:n(575)+n(852)+n(361)+n(944)+n(916),FqtLK:n(1206),EkhVY:function(i){return i()},ULjRy:n(773),AqXzu:n(555)+"0",vYGel:function(i,t){return i>=t},mzPMm:function(i,t){return i<=t},oIVEv:function(i,t){return i!==t},eXYFV:n(1189),WaPOi:n(1342),CMfwL:n(408),janFB:function(i,t){return i>t},dgeDW:function(i,t){return i&t},fcirL:n(352),McPIt:n(988),WYgYe:function(i,t){return i(t)},XQZzQ:function(i,t){return i(t)},ESOnb:n(1049)+">",YDMOB:function(i,t){return i-t},qvnZW:function(i,t){return i<t},MIwjj:n(1050),JerWv:function(i,t){return i===t},GiAuG:function(i,t,r){return i(t,r)},zrNYx:"RlgzZ",iIRlt:"timeout",CsWdt:n(1255),sREwH:n(270),Dsmna:"going aw"+n(241)+n(200)+n(1293)+n(703),sKsEL:n(1486)+"3",VCCvf:n(1609),dtKPX:n(344),ziztK:n(994),bSinh:function(i,t,r){return i(t,r)},Jkycy:function(i,t){return i!==t},xnbPM:"FPsKb",LKvtO:"send_ack",ttdQh:function(i,t){return i!==t},dhfol:n(1505),klXzn:"0|3|1|4|2",vxgXE:"2|3|1|0|4",yWJfu:n(1235),oWeJs:n(1627),rFovy:function(i,t){return i!==t},vIbUY:"VOdaH",wrLay:function(i,t,r){return i(t,r)},rHrFU:function(i,t){return i===t},oVFVw:"tuvQs",zDrhi:n(1547)+"3|2|1|6",gQmaN:function(i,t){return i<t},dwFDS:function(i,t,r){return i(t,r)},ItoCC:function(i,t){return i+t},rcjNY:function(i,t){return i==t},xuthC:"please provide a"+n(1415)+n(249)+n(676)+n(1480)+"ng or an arraybu"+n(695),zpeSj:function(i,t){return i==t},bMVYJ:"number",WQyai:function(i,t){return i instanceof t},GYHOc:function(i,t){return i(t)},hgJSR:function(i,t){return i(t)},fAXDy:n(575)+n(1268)+n(733)+n(1207),yQaEF:function(i,t){return i instanceof t},cQnjj:function(i,t){return i(t)},hQwEr:n(922),UqKRW:n(1489),Ytxsh:function(i,t){return i<t},uXpja:function(i,t){return i==t},ygbnh:function(i,t){return i!==t},PIKRm:n(534)+n(542)+n(1691),GnkfB:n(506)+"3",TGapa:function(i,t){return i>>t},setgB:n(1443)+n(492)+"s",CAxZx:n(1443)+n(1262)+"t",zJRZe:function(i,t,r){return i(t,r)},PVmIx:function(i,t){return i(t)},PTUzm:n(770),kZRJb:function(i,t){return i*t},kmWEP:function(i,t){return i*t},BIUSg:function(i,t){return i===t},QiwLu:n(213),qezII:function(i,t){return i!=t},EXheL:function(i,t){return i===t},piJvp:function(i,t){return i!=t},aNAHb:function(i,t){return i!=t},NeJdd:"Object",WAKQs:function(i,t){return i===t},wBIXm:n(1725)+n(1432)+n(696)+"pe",YgIEF:function(i,t){return i!=t},WCawe:function(i,t){return i!=t},kzFbj:function(i,t){return i===t},Cljkf:n(500)+n(329)+"alScope",lwXfh:function(i,t){return i===t},kfSnt:n(256)+n(338)+n(719),hxISy:function(i,t){return i!=t},lbiJX:function(i,t){return i===t},JiGBh:function(i,t){return i!=t},ZDgTm:function(i,t){return i!=t}};De.r(X),De.d(X,{FWS:()=>G0,CustomErrorEvent:()=>Ti,createCloseEvent:()=>be,ReconnectEvent:()=>ki,createErrorEvent:()=>me,decodedFrame:()=>Ne,createOpenEvent:()=>Bi,CustomCloseEvent:()=>Di,createReconnectEvent:()=>yr,FrontierMessageEvent:()=>Oi,encodeFrame:()=>wr,createMessageEvent:()=>Ni,OpenEvent:()=>Li,ErrorCode:()=>We,Event:()=>dt,MessageEvent:()=>Ri});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(840)](),x=s||(s=e[t(1222)](m,i)),l=Math.random()[t(175)](16)[t(774)](-6);return e[t(746)](e[t(746)](r,a),x)+l}function c(){let i=n,t={mdSLg:function(r,a,x){return e[P(436)](r,a,x)},RkKYb:function(r,a,x){return r(a,x)}};if(e[i(456)](e[i(960)],e[i(318)]))return e[i(746)](e[i(1010)](1e4,Date[i(840)]()),Math[i(170)](e[i(1452)](1e4,Math.random())));t[i(969)](_0x11aee6,_0x2b02e9,82),t.RkKYb(_0xd8775d,_0xf73754,_0x3c4d3d)}function u(i){let t=n;if(t(839)!==e.TpxWG)return(e.AeNbA(Array,8).join("0")+e[t(436)](parseInt,i,10).toString(2))[t(774)](-8);_0x244fe0[t(1071)](_0xc97301)}function f(i){let t=n;return e[t(746)](Array(4)[t(687)]("0"),e.lieuv(parseInt,i,2).toString(16))[t(774)](-4)}function h(i){let t=n,r=i[t(1708)](/\./)[t(1502)](l=>u(l)),a=[];return a[0]=f(e[t(1274)](r[0],r[1])),a[1]=e.JRbyL(f,r[2]+r[3]),[e[t(594)],t(1412),e[t(594)],e[t(594)],e[t(594)],e[t(416)],a[0],a[1]][t(687)]("")}function m(i){let t=n,r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(993)](i),a=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[t(993)](i);return r?e[t(593)](h,i):a?w(i):e.nueWj}function w(i){let t=n,r="",a=[],x=0,l=0,p=!0,g=e[t(594)];if(i[t(1733)]("::")>-1){let d=i[t(1708)]("::");for(let y=0;e.OehqM(y,d.length);y++){let v=d[y];if(e[t(1655)](v[t(1733)](":"),0)){let I=v[t(1708)](":");p&&(x=I[t(1309)]),l+=I[t(1309)];for(let k=0;k<I.length;k++)if(e.uFbbP(4,I[k][t(1309)])){let L=g[t(464)+"g"](0,e[t(692)](4,I[k][t(1309)])),J=L[t(1710)](I[k]);a[t(636)](J)}else a[t(636)](I[k]);p=!1}else{if(e.sFwuv(4,v[t(1309)])){let I=g[t(464)+"g"](0,e[t(692)](4,v[t(1309)])),k=I[t(1710)](v);a[t(636)](k)}else a.push(v);p&&(x+=1),l+=1,p=!1}}let _="";for(let y=0;e[t(176)](y,e[t(692)](8,l));y++)_=_[t(1710)](g);for(let y=0;e.OehqM(y,a[t(1309)]);y++)e[t(513)](y,x)&&(r=r[t(1710)](_)),r=r.concat(a[y]);return r}{let d=i[t(1708)](":");for(let _=0;e[t(176)](_,d.length);_++){let y=d[_];if(e[t(269)](4,d[_][t(1309)])){let v=g[t(464)+"g"](0,e[t(692)](4,d[_][t(1309)])),I=v.concat(y);r=r[t(1710)](I)}else r=r.concat(y)}return r}}function b(i,t){let r=n,a=i[r(1057)];e[r(456)](void 0,a)&&(e[r(857)](r(715),e[r(251)])?(e[r(436)](Z,t,10),e.nSsfX(Ce,t,a)):this[r(625)+r(258)]=_0x1cfc48);let x=i[r(1613)];e[r(1441)](void 0,x)&&(Z(t,18),Ce(t,x))}function S(i){let t=n,r={};e:for(;!e.JRbyL(K,i);){let a=e[t(272)](ne,i);switch(e[t(1585)](a,3)){case 0:break e;case 1:r.key=e[t(359)](ye,i,e[t(1222)](ne,i));break;case 2:r[t(1613)]=e[t(1117)](ye,i,e[t(1362)](ne,i));break;default:e[t(436)](V,i,7&a)}}if(e.noaMB(void 0,r[t(1057)]))throw new Error(e[t(514)]);if(e[t(513)](void 0,r.value))throw new Error(e.uvEMZ);return r}function A(i){let t=n,r=e[t(398)](se);return e[t(359)](N,i,r),e[t(1362)](T,r)}function N(i,t){let r=n,a=i.SeqID;e[r(461)](void 0,a)&&(e[r(505)](Z,t,8),e[r(359)](Le,t,a));let x=i.LogID;e[r(857)](void 0,x)&&(Z(t,16),e[r(1117)](Le,t,x));let l=i[r(1216)];l!==void 0&&(e[r(1217)](Z,t,24),e.KndiN(Le,t,te(l)));let p=i[r(784)];p!==void 0&&(e[r(1088)](Z,t,32),e.wlknv(Le,t,e[r(1634)](te,p)));let g=i[r(1140)];if(e[r(1386)](void 0,g))for(let J of g){Z(t,42);let B=e[r(398)](se);e[r(1164)](b,J,B),e[r(1117)](Z,t,B[r(1374)]),e[r(1117)](on,t,B),$(B)}let d=i[r(1405)+r(648)];e[r(1121)](void 0,d)&&(Z(t,50),e[r(1425)](Ce,t,d));let _=i["payloadT"+r(572)];_!==void 0&&(e[r(1534)]===e[r(1520)]?_0x5290d6.set(_0x127982,_0x5b933c):(e[r(1164)](Z,t,58),e[r(359)](Ce,t,_)));let y=i.payload;e[r(860)](void 0,y)&&(e[r(312)](Z,t,66),e[r(630)](Z,t,y[r(1309)]),Ot(t,y));let v=i[r(1570)];if(e.SNKKd(void 0,v))if(e[r(1372)]!==e[r(1372)]){let J=_0x4d6206[_0x4b67b3];if(_0x48ecd2[_0x38ea70][r(1309)]!==4){let B=_0x12c77a.substring(0,4-_0x235530[_0x1d1028][r(1309)]),re=B[r(1710)](J);_0x39f195=_0x5b2c6d[r(1710)](re)}else _0x81d867=_0x52dc4d[r(1710)](J)}else e[r(917)](Z,t,74),e[r(1312)](Ce,t,v);let I=i["serverTi"+r(690)];e[r(781)](void 0,I)&&(e.qmMuP(e[r(924)],e[r(924)])?(Z(t,82),e[r(911)](Ce,t,I)):this[r(438)]?.[r(254)](_0x858c34.message_id));let k=i[r(1360)];k!==void 0&&(Z(t,90),Ce(t,k));let L=i[r(1414)+"e"];e[r(547)](void 0,L)&&(e[r(1217)](Z,t,96),e[r(650)](Le,t,e[r(1647)](te,L)))}function D(i){let t=n;return e[t(860)](e[t(787)],t(1503))?e[t(322)](R,e[t(1196)](le,i)):_0x4e9beb?this[t(426)+"E"]():this[t(1454)+"E"]()}function R(i){let t=n,r={};e:for(;!K(i);){let a=e[t(1330)](ne,i);switch(e[t(1585)](a,3)){case 0:break e;case 1:r[t(1523)]=ae(i,!0);break;case 2:r[t(1618)]=ae(i,!0);break;case 3:r[t(1216)]=e.OlRAh(ne,i);break;case 4:r[t(784)]=ne(i);break;case 5:{let x=e[t(272)](M,i);(r[t(1140)]||(r.headers=[])).push(S(i)),i[t(1374)]=x;break}case 6:r["payloadE"+t(648)]=e[t(650)](ye,i,ne(i));break;case 7:r[t(980)+t(572)]=e[t(775)](ye,i,e[t(272)](ne,i));break;case 8:r.payload=e.KndiN(ut,i,e[t(1270)](ne,i));break;case 9:r[t(1570)]=e[t(385)](ye,i,e[t(1318)](ne,i));break;case 10:r[t(433)+t(690)]=e.UiBsB(ye,i,e[t(1662)](ne,i));break;case 11:r[t(1360)]=e[t(505)](ye,i,e[t(1362)](ne,i));break;case 12:r.frameType=e.VjbYc(ne,i);break;default:e[t(496)](V,i,e.vRZVu(7,a))}}if(e[t(1058)](void 0,r[t(1523)]))throw new Error(e[t(872)]);if(e.qmMuP(void 0,r.LogID))throw new Error(t(1429)+t(1338)+t(1173)+t(1618));if(e[t(513)](void 0,r[t(1216)]))throw new Error(e[t(1552)]);if(r[t(784)]===void 0)throw new Error(e[t(1543)]);return r}function M(i){let t=n,r=e[t(976)](ne,i),a=i[t(1374)];return i.limit=i[t(1127)]+r,a}function V(i,t){let r=n;switch(t){case 0:for(;e[r(510)](128,ue(i)););break;case 2:e.unBvZ(z,i,ne(i));break;case 5:z(i,4);break;case 1:e[r(359)](z,i,8);break;default:throw new Error(e.IqEkU("Unimplem"+r(1223)+r(614),t))}}function te(i){let t=n;return i|=0,{low:i,high:e[t(296)](i,31),unsigned:e.PYzjO(i,0)}}let ie=[];function se(){let i=n,t=ie[i(1264)]();return t?(t[i(1127)]=t[i(1374)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function $(i){ie.push(i)}function le(i){return{bytes:i,offset:0,limit:i[n(1309)]}}function T(i){let t=n,r=i[t(659)],a=i.limit;return e.QZwaG(r[t(1309)],a)?r:r[t(1668)](0,a)}function z(i,t){let r=n;if(e[r(1274)](i[r(1127)],t)>i[r(1374)])throw new Error(e[r(1563)]);i[r(1127)]+=t}function K(i){let t=n;return e[t(276)](i[t(1127)],i.limit)}function oe(i,t){let r=n,a={TQqNa:function(x,l){return x(l)}};if(e[r(1661)]===r(865))return _0x5dbfea.apply(_0x4b454a(this),_0x238ad4),oiasJZ.TQqNa(_0xc85e50,_0x26bd74[r(205)](this));{let x=i[r(659)],l=i[r(1127)],p=i[r(1374)],g=e[r(903)](l,t);if(e.KJzlz(g,x[r(1309)])){let d=new Uint8Array(2*g);d[r(643)](x),i[r(659)]=d}return i[r(1127)]=g,e[r(894)](g,p)&&(i[r(1374)]=g),l}}function nt(i,t){let r=n,a=i[r(1127)];if(e[r(536)](a,t)>i[r(1374)])throw new Error(e[r(1611)]);return i[r(1127)]+=t,a}function ut(i,t){let r=n,a=nt(i,t);return i[r(659)][r(1668)](a,e.pSZJn(a,t))}function Ot(i,t){let r=n,a=oe(i,t[r(1309)]);i[r(659)].set(t,a)}function ye(i,t){let r=n,a={ZclhK:r(1296),vxSrL:function(x,l,p){return e[r(1068)](x,l,p)}};if(e[r(190)]===e[r(190)]){let x=nt(i,t),l=String[r(1230)+"Code"],p=i[r(659)],g="\uFFFD",d="";for(let _=0;e.Eyugq(_,t);_++){let y=p[e[r(903)](_,x)],v,I,k,L;if(e[r(590)](128,y)===0)d+=e[r(1350)](l,y);else if(e[r(293)](224&y,192))e.PYzjO(e[r(536)](_,1),t)?d+=g:(v=p[e[r(1623)](_,x)+1],e[r(1689)](192,v)!==128?d+=g:(L=e[r(499)](e[r(570)](31&y,6),e[r(1403)](63,v)),e[r(176)](L,128)?d+=g:(d+=e[r(1330)](l,L),_++)));else if(e[r(1146)](e[r(1468)](240,y),224))_+2>=t?d+=g:(v=p[e.sasWQ(e.pSZJn(_,x),1)],I=p[e[r(1256)](_,x)+2],e[r(1689)](e[r(1243)](v,e[r(556)](I,8)),49344)!==32896?d+=g:(L=e.pULBR(e[r(1001)](e.aQTcU(e[r(1468)](15,y),12),e.vRZVu(63,v)<<6),e[r(529)](63,I)),e[r(631)](L,2048)||e[r(423)](L,55296)&&e[r(1601)](L,57343)?d+=g:(d+=l(L),_+=2)));else if(e[r(1146)](e[r(1403)](248,y),240))if(e[r(1154)](_+3,t))d+=g;else if(e[r(456)](e[r(586)],r(984)))v=p[_+x+1],I=p[e.LzAJb(e[r(1648)](_,x),2)],k=p[e.QOeCU(e.RbdhJ(_,x),3)],e[r(1344)](e[r(551)](e[r(499)](v,I<<8)|e[r(191)](k,16),12632256),8421504)?d+=g:(L=e[r(390)](e.cpTfu(7,y)<<18,e[r(967)](63,v)<<12)|e[r(556)](63&I,6)|e[r(654)](63,k),e.OehqM(L,65536)||e[r(894)](L,1114111)?d+=g:(L-=65536,d+=e.unBvZ(l,e.BduUZ(e.FfnNG(L,10),55296),e[r(1643)](e.NxwCa(1023,L),56320)),_+=3));else{if(this[r(1656)+"ngTimer"](),this[r(1549)+r(1572)](),this[r(772)+"sListeners"](),this[r(1603)+r(743)](1e3,_0x512357),this[r(340)+r(1693)]=!1,_0x1ba54d&&this[r(1322)+r(1559)]()&&!this[r(1041)+r(247)]){if(this["_endpoin"+r(914)]?.[r(396)+"chMaxTries"]()){let B=this[r(1407)+r(914)]?.[r(809)+"ntEndpoint"]();this[r(1155)+r(1538)+"ent"](_0x4144a9(r(616),{code:1006,reason:r(299)+B+(" timeout"+r(1409)+r(736)+r(830)),wasClean:!0}))}else{let B=this[r(921)][r(200)+"tInterce"+r(1089)](_0x191833,_0x4eea0c);this[r(1155)+r(1538)+r(560)](e[r(911)](_0xca6d28,"close",{code:_0x1a66af,reason:_0x12ea8b,wasClean:!0,willReconnect:B})),B&&this[r(340)]()}return}this[r(1322)+"orOnline"]()||this[r(1041)+"osed"]?this[r(1155)+"hCloseEv"+r(560)](e.qIyeh(_0x91c1a3,e.zSlhY,{code:_0x55e7c5,reason:e.HCNMv})):this[r(1155)+r(1538)+"ent"](e[r(1088)](_0x6794b1,r(616),{code:1006,reason:e.lGtSi})),this[r(563)]=null,this[r(1407)+r(914)]?.["resetEnd"+r(1042)+r(297)](),this[r(952)+r(195)]?.["resetCou"+r(231)]()}else d+=g}return d}else if(e.BUoJc(_0x1131ca,_0x40d004)){let x=_0x2409e5[r(819)][r(774)](_0x11a382[r(357)+"et"],e.nUOqa(_0x33344[r(1630)+"th"],_0x304172[r(357)+"et"]));this._socket&&this[r(965)][r(1367)]({data:x,fail:l=>{let p=r;this.emit(a.ZclhK,a[p(220)](_0x374b7e,a[p(1420)],{message:this[p(531)+p(1583)+"age"](l)}))}})}else this[r(965)]&&this[r(965)][r(1367)]({data:_0x1b9b1e,fail:x=>{let l=r;this[l(1170)](a[l(1420)],a[l(220)](_0x52de9a,a[l(1420)],{message:this[l(531)+l(1583)+l(796)](x)}))}})}function Ce(i,t){let r=n,a={APDBt:e[r(1394)],iBAsI:function(d,_){return e[r(253)](d,_)},glFNC:e[r(525)],NUbyz:e[r(637)]},x=t.length,l=0;for(let d=0;e[r(176)](d,x);d++){let _=t.charCodeAt(d);_>=55296&&e[r(1197)](_,56319)&&e.BAKFU(d+1,x)&&(_=e[r(1645)](e[r(191)](_,10),t[r(391)+"At"](++d))-56613888),l+=e[r(935)](_,128)?1:e[r(935)](_,2048)?2:e.MGtmI(_,65536)?3:4}e[r(1229)](Z,i,l);let p=e.dVKdf(oe,i,l),g=i[r(659)];for(let d=0;e[r(935)](d,x);d++)if(e.KJumn!==r(1212))tuxLLj[r(512)](tuxLLj[r(577)],typeof _0x352e0f)&&_0x204e06[r(175)+"Tag"]&&_0x284cbb[r(1356)+r(901)](_0x216a68,_0x87a6aa[r(175)+"Tag"],{value:tuxLLj[r(949)]}),_0xd46578[r(1356)+r(901)](_0x53df1d,tuxLLj[r(209)],{value:!0});else{let _=t[r(391)+"At"](d);if(e[r(1154)](_,55296)&&_<=56319&&e[r(880)](d,1)<x&&(_=e[r(445)](e[r(556)](_,10)+t[r(391)+"At"](++d),56613888)),e[r(935)](_,128))g[p++]=_;else{if(e.BAKFU(_,2048))g[p++]=e[r(1243)](e[r(1241)](e[r(1120)](_,6),31),192);else if(e[r(1344)](e.jdusq,e[r(1533)])){let y=a[r(212)].split("|"),v=0;for(;;){switch(y[v++]){case"0":this[r(1041)+r(247)]=!0;continue;case"1":this["_QoSMana"+r(306)]?.[r(1037)]();continue;case"2":this[r(1423)+r(365)+"t"](_0x4eb5cf,_0x595b03);continue;case"3":if(this[r(563)][r(489)+"te"]===this.CLOSED||a.iBAsI(this[r(563)][r(489)+"te"],this[r(1175)]))return void this._debug(a.glFNC);continue;case"4":this[r(1656)+"ngTimer"]();continue;case"5":if(!this[r(563)])return void this[r(1272)](a[r(1729)]);continue;case"6":this["_clearTi"+r(1572)]();continue;case"7":this["_dropGlo"+r(711)+r(1624)]();continue}break}}else e.LCgMs(_,65536)?g[p++]=e.AHMAK(e[r(590)](e[r(1120)](_,12),15),224):(g[p++]=e[r(390)](e[r(435)](_,18)&7,240),g[p++]=e.LKmLx(e.tfcwv(e[r(950)](_,12),63),128)),g[p++]=e[r(1001)](e[r(654)](e[r(168)](_,6),63),128);g[p++]=e[r(1069)](e[r(186)](63,_),128)}}}function on(i,t){let r=n,a={bJVvc:function(x,l){return x&l},ULBKW:function(x,l){return e.PXqDx(x,l)}};if(e[r(253)](r(1066),e[r(663)])){let x=e[r(983)](oe,i,t[r(1374)]),l=i[r(659)],p=t[r(659)];for(let g=0,d=t[r(1374)];g<d;g++)l[e[r(1666)](g,x)]=p[g]}else return _0x47a53f[r(409)+"t8"]?_0x21efd9[r(409)+"t8"](_0x21b5bf,_0xd07b0e):_0x54bd1f[_0x1f98e2]=a[r(799)](255,_0x3ad8b4),a.ULBKW(_0x104f45,1)}function ue(i){let t=n;if(e[t(583)](e[t(1462)],e[t(1136)]))return i[t(659)][e[t(1728)](nt,i,1)];{let r=0,a=0,x;do x=e[t(475)](_0x5c2382,_0x517f92),e[t(1473)](r,32)&&(a|=e[t(570)](e[t(737)](127,x),r)),r+=7;while(e[t(1422)](128,x));return a}}function Lt(i,t){let r=n,a=e[r(1088)](oe,i,1);i[r(659)][a]=t}function ne(i){let t=n,r=0,a=0,x;do x=e[t(1362)](ue,i),r<32&&(a|=e[t(992)](e[t(967)](127,x),r)),r+=7;while(e[t(967)](128,x));return a}function Z(i,t){let r=n,a={hpjXX:r(1443)+r(492)+"s",JvagX:r(1443)+r(1262)+"t",jGwhh:function(x,l){return e[r(1228)](x,l)},GoTko:function(x,l){return e.mOujg(x,l)},OAMnA:function(x,l){return x&l},vVrjT:function(x,l){return x+l},TmaoZ:function(x,l){return e[r(499)](x,l)}};if(e[r(293)](e[r(581)],"UYBVb")){for(t>>>=0;e.mldOA(t,128);)e[r(812)](e[r(540)],e[r(540)])?(Lt(i,e[r(1515)](127,t)|128),t>>>=7):(_0x656cbd(r(904)),this[r(801)](a[r(1595)],_0x332688),this[r(801)](a[r(866)],_0x3782c));e.IztgT(Lt,i,t)}else{if(_0x5093ba<1||a.jGwhh(_0x318c29,_0x2be84d))return a[r(1022)](_0x402591,_0x3d76e4);_0x3c452b+_0x4b561b>_0x4b3cc9&&(_0x113a99=a[r(1022)](_0x3126f7,_0x32f3ab),_0x2ea407=0);let x=_0x52b3c6.call(_0x48623d,_0x4c03c9,_0x3b19f3+=_0x17593e);return a[r(1246)](7,_0x263764)&&(_0x30b721=a.vVrjT(a.TmaoZ(7,_0x4ce7d3),1)),x}}function ae(i,t){let r=n,a={wJYUd:function(d,_,y,v){return d(_,y,v)},gUAhE:function(d,_){return e[P(1585)](d,_)},FEDZu:function(d,_){return e.lxRZh(d,_)},oDdip:function(d,_){return e[P(1585)](d,_)},kenPB:function(d,_){return e[P(737)](d,_)},jAKdH:function(d,_){return d<_},DFGta:function(d,_){return e[P(1526)](d,_)},trrzw:function(d,_){return e[P(211)](d,_)},KVbsD:function(d,_){return d&_}},x=0,l=0,p=0,g;if(g=e[r(1350)](ue,i),x=e[r(1003)](127,g),e[r(682)](128,g)&&(g=e[r(1545)](ue,i),x|=e[r(556)](e.jaDqP(127,g),7),e[r(551)](128,g)&&(g=ue(i),x|=e.XtuIR(e[r(654)](127,g),14),e[r(967)](128,g)&&(g=e[r(1085)](ue,i),x|=e[r(1501)](e[r(1115)](127,g),21),e[r(186)](128,g)&&(g=e[r(475)](ue,i),l=e[r(1115)](127,g),e[r(1689)](128,g)&&(g=e[r(322)](ue,i),l|=(127&g)<<7,e[r(204)](128,g)&&(g=ue(i),l|=e[r(1108)](e.OzcdL(127,g),14),e[r(282)](128,g))))))))if(e[r(458)]===e[r(458)])g=ue(i),l|=e[r(1108)](e[r(654)](127,g),21),e[r(193)](128,g)&&(g=ue(i),p=e.wsJeW(127,g),128&g&&(e.cvIaZ(e[r(504)],e[r(634)])?(g=e.hJwzB(ue,i),p|=e[r(227)](127,g)<<7):_0x5103c1[r(906)]=_0x41c3fe[r(1577)]()[r(476)](()=>(_0x4e9a48(),_0xce0857))[r(476)](function(d){return d})));else{let d={FmqAH:function(y,v){return y>v},JnZJI:function(y,v,I,k){return a[r(1597)](y,v,I,k)},iLInO:function(y,v){return a.gUAhE(y,v)},QPyvo:function(y,v){return a[r(591)](y,v)},pqIdr:function(y,v){return y<<v},BzeNi:function(y,v){return y&v},YNYVH:function(y,v){return a[r(374)](y,v)},AJKYz:function(y,v){return a[r(591)](y,v)},beFdi:function(y,v){return a[r(1638)](y,v)},zQgjB:function(y,v){return a[r(1160)](y,v)},EXyVM:function(y,v){return a[r(855)](y,v)},KYuyu:function(y,v){return a[r(591)](y,v)},vyEUs:function(y,v){return y<v},isAGy:function(y,v){return a[r(825)](y,v)},QgWjb:function(y,v){return a[r(1638)](y,v)},OnwWH:function(y,v){return a[r(1328)](y,v)},eIZwi:function(y,v){return y>>>v},Zplkc:function(y,v){return a[r(595)](y,v)}},_=4294967295;return function(y,v,I=!0){let k=r,L=(k(1723)+"|5|4|11|"+k(1392)+"3").split("|"),J=0;for(;;){switch(L[J++]){case"0":if(d.FmqAH(v+=5,y.length))throw v=y[k(1309)],d[k(1517)](_0x3deb8b,v,10,y[k(1309)]);continue;case"1":_=d[k(1471)](d.QPyvo(_,d[k(934)](d.BzeNi(15,y[v]),28)),0);continue;case"2":_=d.YNYVH(d.QPyvo(_,d.pqIdr(127&y[v],7)),0);continue;case"3":return{value:I?_:d[k(187)](0,_),offset:v};case"4":if(y[v++]<128)return{value:I?_:0|_,offset:v};continue;case"5":_=d[k(732)](_|d.pqIdr(d.zQgjB(127,y[v]),14),0);continue;case"6":if(y[v++]<128)return{value:I?_:d.QPyvo(0,_),offset:v};continue;case"7":if(d[k(853)](y[v++],128))return{value:I?_:d[k(1167)](0,_),offset:v};continue;case"8":if(d[k(1574)](y[v++],128))return{value:I?_:d[k(187)](0,_),offset:v};continue;case"9":if(d[k(853)](y[v++],128))return{value:I?_:d[k(738)](0,_),offset:v};continue;case"10":_=d[k(370)](d[k(1368)](127,y[v]),0);continue;case"11":_=d[k(266)](d.QPyvo(_,d.pqIdr(d.Zplkc(127,y[v]),21)),0);continue}break}}}return{low:e[r(1048)](x,e.IvMek(l,28)),high:e.WKBKn(l>>>4,e[r(1553)](p,24)),unsigned:t}}function Le(i,t){let r=n,a=e[r(1585)](t[r(1200)],0),x=e.gLPUA(e[r(1334)](t[r(1200)]>>>28,e.JCAps(t[r(1332)],4)),0),l=e.bYuJp(t[r(1332)],24),p=e.iZrnP(0,l)?x===0?a<16384?e[r(631)](a,128)?1:2:a<2097152?3:4:e[r(814)](x,16384)?e[r(668)](x,128)?5:6:x<2097152?7:8:e[r(526)](l,128)?9:10,g=oe(i,p),d=i[r(659)];switch(p){case 10:d[e.zQylX(g,9)]=e[r(1585)](l,7)&1;case 9:d[g+8]=e[r(457)](9,p)?e.qnrOs(128,l):e[r(841)](127,l);case 8:d[e[r(1643)](g,7)]=p!==8?e.bYuJp(x,21)|128:e.MXpOK(e[r(437)](x,21),127);case 7:d[e.hlssG(g,6)]=e[r(547)](7,p)?e.LKmLx(e[r(1276)](x,14),128):e[r(1492)](x>>>14,127);case 6:d[e[r(1635)](g,5)]=e[r(961)](6,p)?e[r(1532)](e[r(1276)](x,7),128):e.jaDqP(e[r(1585)](x,7),127);case 5:d[g+4]=e[r(1313)](5,p)?128|x:e.KNETO(127,x);case 4:d[e.aMDod(g,3)]=p!==4?e.SWFIn(a>>>21,128):e[r(1153)](e[r(1280)](a,21),127);case 3:d[e[r(835)](g,2)]=e[r(748)](3,p)?e[r(1114)](a>>>14,128):e[r(1700)](a>>>14,127);case 2:d[e.LzAJb(g,1)]=e[r(457)](2,p)?e[r(1176)](e[r(437)](a,7),128):e[r(689)](e[r(1248)](a,7),127);case 1:d[g]=e[r(797)](1,p)?e[r(1114)](128,a):127&a}}function Ne(i){let t=n,r={QpIUp:function(a,x){return e[P(1484)](a,x)},Dorel:function(a,x){return e[P(423)](a,x)},tfQko:function(a,x){return a|x},gRCSJ:function(a,x){return e[P(484)](a,x)},ATvLJ:function(a,x){return e[P(1561)](a,x)},yYDsY:function(a,x){return e[P(1541)](a,x)},ZQWxt:function(a,x){return a>=x},kabiT:function(a,x){return e[P(1473)](a,x)},EDTXF:function(a,x){return e[P(1048)](a,x)},krePk:function(a,x){return e[P(1541)](a,x)},BcMAH:function(a,x){return e.XflOR(a,x)},nVypj:function(a,x){return e[P(1526)](a,x)},vwStj:function(a,x){return e[P(923)](a,x)},DTVto:function(a,x){return e.AHMAK(a,x)},TGQnD:function(a,x){return e[P(298)](a,x)},DSeqO:function(a,x){return e[P(168)](a,x)}};if(e[t(972)](e[t(718)],e.ddHsv)){let a=_0x20cc60[_0x1177aa++];if(r.QpIUp(a,127))_0x4ba033+=_0x542f1d["fromChar"+t(1490)](a);else if(r[t(782)](a,192)&&a<224)_0xf5336a+=_0x1d1950[t(1230)+"Code"](r.tfQko(r[t(907)](r[t(1642)](31,a),6),r[t(431)](63,_0xaab82[_0x4bc2ac++])));else if(r[t(800)](a,224)&&r.kabiT(a,240))_0x473bb6+=_0xaac2e2[t(1230)+"Code"](r[t(1628)](r[t(907)](r[t(431)](15,a),12),r[t(907)](63&_0x35bd24[_0x431878++],6))|r[t(226)](63,_0xad358f[_0xf3bc58++]));else if(r[t(800)](a,240)){let x=r[t(1193)](r[t(1227)](r[t(1569)](r.DTVto((7&a)<<18,r[t(907)](63&_0x364dea[_0x411fad++],12)),r[t(431)](63,_0x4722bb[_0x554938++])<<6),r.ATvLJ(63,_0x1d32e3[_0x154a3c++])),65536);_0x23dbee+=_0x5c5e28[t(1230)+t(1490)](r.TGQnD(55296,r[t(1254)](x,10))),_0x3954f7+=_0x2b2fda[t(1230)+t(1490)](56320+r[t(226)](1023,x))}}else return e[t(1318)](D,i)}function wr(i){return e[n(1149)](A,i)}let Ci=65536,t0=e[n(1622)],ft=e.kZRJb(Ci,Ci),Ai=e.kmWEP(ft,ft),Ii=Ai/2,He=String[n(1706)+"e"][n(391)+"At"];class j{constructor(t,r,a){let x=n;if(e[x(1477)](e.GIVMF,x(889)))return new _0x516ec2(_0x42db54,_0x3f53be,_0x5c818d);this[x(490)]=!0,this[x(1200)]=e[x(884)](0,t),this[x(1332)]=e.NWHXf(0,r),this[x(290)]=!!a}static[n(490)](t){return t&&e[n(313)](!0,t.isLong)}static[n(557)](t,r,a){return new j(t,r,a)}static fromBytes(t,r,a){let x=n;return a?j[x(1245)+x(881)](t,r):j[x(1245)+x(1663)](t,r)}static["fromByte"+n(881)](t,r){let a=n;return new j(e.kMhoJ(e[a(1114)](e.LPTjy(t[0],t[1]<<8),e.KQTAs(t[2],16)),t[3]<<24),e.EvXlh(e[a(430)](e.GXeqT(t[4],e[a(1358)](t[5],8)),e[a(1553)](t[6],16)),e.jkDYU(t[7],24)),r)}static[n(1245)+n(1663)](t,r){let a=n;return new j(e.XDkid(e[a(432)](e[a(432)](t[4]<<24,e[a(1701)](t[5],16)),e.dSBWd(t[6],8)),t[7]),e[a(371)](e[a(1606)](e[a(1038)](t[0],24),e[a(765)](t[1],16)),e[a(1445)](t[2],8))|t[3],r)}static[n(1099)](t){let r=n;if(e[r(849)](e[r(1434)],e[r(927)]))return e[r(513)](t,t0)?Pi:new j(e[r(657)](e[r(311)](He.call(t,0)|e[r(1687)](He.call(t,1),8),e[r(897)](He[r(1054)](t,2),16)),e[r(1108)](He[r(1054)](t,3),24))>>>0,e.bYuJp(e.lxRZh(e[r(1334)](e[r(1402)](He[r(1054)](t,4),e[r(793)](He[r(1054)](t,5),8)),e[r(1501)](He[r(1054)](t,6),16)),e.pnhCG(He[r(1054)](t,7),24)),0),!0);{let a=_0x5422d4.message.payload;a&&_0x4900ce[r(1317)+"rs"](a)}}[n(1479)](){let t=n;return String["fromChar"+t(1490)](e[t(1492)](255,this[t(1200)]),e[t(529)](e[t(1248)](this[t(1200)],8),255),e[t(804)](e.YqdKX(this[t(1200)],16),255),this[t(1200)]>>>24,255&this[t(1332)],e.iStTG(this[t(1332)],8)&255,e.lpPmC(this[t(1332)],16)&255,e[t(1079)](this[t(1332)],24))}static[n(1138)+"er"](t,r=!0){let a=n;if(isNaN(t))return r?n0:Pi;if(r){if(e[a(882)](t,Ai))return i0}else{if(e[a(1724)](t,-Ii))return s0;if(e[a(1623)](t,1)>=Ii)return r0}return j.fromBits(e[a(311)](e[a(1139)](t,ft),0),e[a(829)](e.EGiLv(t,ft),0),r)}toNumber(){let t=n;return this[t(290)]?e[t(710)](e[t(1010)](e[t(605)](this[t(1332)],0),ft),e[t(1585)](this[t(1200)],0)):e[t(1256)](e[t(1598)](this[t(1332)],ft),e[t(1413)](this[t(1200)],0))}[n(411)](){let t=n;return this[t(1332)]===0&&e.ROhhB(0,this[t(1200)])}[n(1631)](t){let r=n;j[r(490)](t)||(t=j[r(1138)+"er"](t));let a=e[r(1079)](this[r(1332)],16),x=e.TuECj(65535,this[r(1332)]),l=this[r(1200)]>>>16,p=e[r(694)](65535,this[r(1200)]),g=e[r(1040)](t[r(1332)],16),d=e[r(1153)](65535,t[r(1332)]),_=e[r(1147)](t[r(1200)],16),y=65535&t[r(1200)],v=0,I=0,k=0,L=0;return L+=e.hlssG(p,y),k+=e[r(1079)](L,16),L&=65535,k+=l+_,I+=e[r(1413)](k,16),k&=65535,I+=e[r(1530)](x,d),v+=e[r(1280)](I,16),I&=65535,v+=e[r(1507)](a,g),v&=65535,j[r(557)](e.qnrOs(e[r(1038)](k,16),L),v<<16|I,this[r(290)])}[n(946)](t){let r=n;return j[r(490)](t)||(t=j[r(1138)+"er"](t)),e[r(528)](this.unsigned,t[r(290)])&&e[r(293)](e[r(1546)](this[r(1332)],31),1)&&e.qmMuP(e[r(1040)](t[r(1332)],31),1)?!1:e[r(279)](this[r(1332)],t.high)&&e[r(1051)](this[r(1200)],t[r(1200)])}[n(1682)](){let t=n;return this[t(1200)]===-1&&e[t(1456)](-1,this[t(1332)])?j[t(557)](0,0,this[t(290)]):e[t(1450)](-1,this[t(1200)])?j[t(557)](0,e[t(710)](this[t(1332)],1),this[t(290)]):j[t(557)](e[t(1666)](this[t(1200)],1),this[t(1332)],this[t(290)])}toBytes(t){return t?this.toBytesLE():this.toBytesBE()}toBytesLE(){let t=n,r=this.high,a=this.low;return[e[t(1241)](255,a),e.NcFxf(e[t(1564)](a,8),255),e[t(1361)](e.cjMxg(a,16),255),e[t(1481)](a,24),255&r,e[t(552)](e[t(1147)](r,8),255),e[t(1040)](r,16)&255,e[t(1147)](r,24)]}[n(1454)+"E"](){let t=n,r=this[t(1332)],a=this[t(1200)];return[r>>>24,e.pfyjy(r>>>16,255),e[t(1027)](r,8)&255,255&r,e[t(537)](a,24),e[t(1466)](e.GOcpH(a,16),255),a>>>8&255,255&a]}}let Pi=new j(0,0,!1),n0=new j(0,0,!0),r0=j.fromBits(-1,2147483647,!1),i0=j[n(557)](-1,-1,!0),s0=j[n(557)](0,-2147483648,!1);var We=(function(i){let t=n;if(e[t(279)](e[t(1075)],e[t(1021)]))try{return e.txsju(e[t(826)],typeof _0xedc3dd)&&(e[t(760)](_0x36a8c5,_0x2737ac)||_0x5235b6[t(819)]&&e[t(714)](_0x31017c.buffer,_0x56ced3))||e[t(1665)](e[t(826)],typeof _0x1aa038)?"":(_0x6664c7.parse(_0x4ccf68),e[t(164)])}catch{return t(324)==typeof _0x342a38?e.TSaSt:""}else{let r=e[t(1525)][t(1708)]("|"),a=0;for(;;){switch(r[a++]){case"0":i[i[t(366)+t(821)+"R"]=5003]=e[t(1172)];continue;case"1":i[i[t(527)+"NG_ERROR"]=5002]=t(527)+t(811);continue;case"2":return i;case"3":i[i[e.tvzxT]=5005]=t(1449)+"OR";continue;case"4":i[i[t(644)+t(1011)]=5001]=e[t(163)];continue;case"5":i[i[e[t(336)]]=5004]=e.eMCil;continue}break}}})({});class dt{constructor(t){let r=n;this.type=t,this[r(1550)]=null}}class ki extends dt{constructor(t,r){let a=n;if(e[a(972)](e[a(412)],a(486)))super(t),this.message=r&&r.message||null;else{let l=""+_0x2b6330[a(840)](),p=_0x1825e3||(_0x553b29=e[a(1330)](_0x3865f9,_0x4b8b13)),g=_0x73322a[a(1259)]()[a(175)](16)[a(774)](-6);return e.RbdhJ(e[a(862)]("02"+l,p),g)}}}class Ti extends dt{constructor(t,r){let a=n;super(t),this[a(1296)]=r&&r.error||null,this.colno=r&&r[a(1250)]||0,this[a(1544)]=r&&r.filename||"",this[a(327)]=r&&r[a(327)]||0,this[a(727)]=r&&r[a(727)]||"",this[a(1381)]=r&&r[a(1381)]||5001}}class Di extends dt{constructor(t,r){let a=n;super(t),this[a(1381)]=r&&r[a(1381)]||0,this[a(1044)]=r&&r[a(1044)]||"",this.wasClean=r&&r.wasClean||!1,this[a(864)+a(1076)]=r&&r[a(864)+"nnect"]||!1}}class Ri extends dt{constructor(t,r){let a=n;super(t),this.data=r&&r[a(956)]||null}}class Oi extends Ri{constructor(t,r){let a=n;super(t),this[a(956)]=r&&r[a(956)]||null,this.message=r&&r.message||null}}class Li extends dt{constructor(t,r){let a=n;super(t),this[a(956)]=r&&r[a(956)]||null}}function me(i,{message:t,code:r,error:a}){let x=n,l={lBYEQ:function(p,g){return e[P(292)](p,g)}};return e.CQHHs(e.sePaV,e[x(376)])?function(p,...g){let d=x,_=_0x4ed441[d(1054)](QUWqie[d(700)](_0x417dc0,this),p,...g);return _0x257a83.set(_,p.sort?p.sort():[p]),QUWqie[d(700)](_0xf1f6ab,_)}:new Ti(i,{message:t,code:r,error:a})}function be(i,{code:t,reason:r,wasClean:a,willReconnect:x}){return new Di(i,{code:t,reason:r,wasClean:a,willReconnect:x})}function Ni(i,{data:t,message:r}){return new Oi(i,{data:t,message:r})}function Bi(i,{data:t}){return new Li(i,{data:t})}function yr(i,{message:t}){return new ki(i,{message:t})}class Mi{constructor(t,r){let a=n;this.endpoints=t,this[a(645)+"es"]=r,this[a(1679)+a(933)]=0,this[a(339)+"ndpointT"+a(1424)+"t"]=0}["resetEnd"+n(1042)+n(297)](){let t=n;this[t(1679)+"ndex"]=0,this[t(339)+t(1337)+t(1424)+"t"]=0}[n(1455)+"es"](){let t=n;this[t(339)+"ndpointT"+t(1424)+"t"]=0}[n(809)+"ntEndpoint"](){return this[n(379)+"s"][this.currentIndex]}["getCurrentEndpointTriesC"+n(893)](){let t=n;if(e[t(1640)]===e.NssIP)this.endpoints=_0x246949,this[t(645)+"es"]=_0x4f4eda,this["currentI"+t(933)]=0,this[t(339)+t(1337)+"riesCount"]=0;else return this.currentEndpointTriesCount}[n(396)+n(756)+"es"](){let t=n;return!!(this[t(1679)+"ndex"]>=this[t(379)+"s"][t(1309)]||e[t(253)](this[t(1679)+"ndex"],e.zckyH(this[t(379)+"s"][t(1309)],1))&&e[t(1326)](this[t(339)+t(1337)+t(1424)+"t"],this[t(645)+"es"]))}[n(1712)+"rentEndp"+n(1249)+n(688)+n(188)](){let t=n;return e[t(345)](this[t(1679)+t(933)],this[t(379)+"s"][t(1309)])?!0:e[t(1033)](this[t(339)+t(1337)+"riesCount"],this.maxRetries)}["replaceB"+n(1637)+n(285)+n(869)+"unt"](){let t=n;return this[t(339)+t(1337)+t(1424)+"t"]=1,this[t(1679)+t(933)]++,this.endpoints[this[t(1679)+t(933)]]}[n(809)+n(277)+"ntAndUpd"+n(448)](){let t=n;return this["currentE"+t(1337)+t(1424)+"t"]++,this[t(809)+t(277)+"nt"]()}}let lt=(e[n(521)](e[n(577)],typeof globalThis)&&e[n(1236)](e[n(1565)],globalThis[n(769)+n(639)][n(199)])||e[n(896)]("undefined",typeof window)&&e[n(815)](n(213),window[n(769)+n(639)].name))&&e[n(822)](e[n(577)],typeof document),rt=e[n(264)](e[n(577)],typeof globalThis)&&(e[n(1179)]===globalThis[n(769)+n(639)][n(199)]||e[n(574)](e[n(465)],globalThis["construc"+n(639)].name))&&e[n(512)](e[n(577)],typeof tt),Nt=(e[n(1692)](e.dNQyB,typeof globalThis)&&e[n(513)](e[n(1179)],globalThis[n(769)+n(639)].name)||e[n(343)](e[n(577)],typeof globalThis)||e[n(512)](e[n(577)],typeof globalThis)&&!!globalThis[n(878)+n(1204)])&&e[n(1380)](e.dNQyB,typeof wx),Bt=e[n(577)]!=typeof globalThis&&(e.iZrnP(e.wBIXm,globalThis[n(769)+"tor"][n(199)])||e[n(686)](e.Cljkf,globalThis[n(769)+n(639)][n(199)])||e.lwXfh(e[n(230)],globalThis[n(769)+n(639)][n(199)]))&&e[n(1458)](e[n(577)],typeof self),o0=e[n(730)](e[n(577)],typeof globalThis)&&n(1224)===globalThis[n(769)+n(639)][n(199)]&&e[n(264)](n(1096)+"d",typeof global)&&e[n(982)](e.NeJdd,global[n(769)+n(639)].name)&&e[n(959)](n(1096)+"d",typeof process)&&!!process.version;class br{constructor(){let t=n,r={kCUWw:function(a,x){return e[P(721)](a,x)},GWwhx:e[t(1611)]};if(e[t(926)](e[t(600)],e.FUQpV))this[t(808)+"rs"]={};else{let a=_0x292ad7[t(1127)];if(aAGOsV.kCUWw(a+_0xcd098c,_0xd424ce[t(1374)]))throw new _0x2edaa8(aAGOsV[t(778)]);return _0xf651bc.offset+=_0x5251fa,a}}[n(1170)](t,...r){let a=n;if(a(1084)===e[a(1103)]){let x=this[a(808)+"rs"][t];if(x)x.slice()[a(1190)](l=>l.fn[a(1683)](l.ctx,r));else if(e[a(1370)](e.djZnT,t)&&!this[a(810)]){let l=r[a(1309)]&&r[0];if(e.WtokT(l,Error))throw l;let p=new Error(e.aMDod(a(474)+"d error.",l?e[a(761)](" ("+l.message,")"):""));throw p[a(890)]=l,l}return this}else this[a(490)]=!0,this.low=0|_0x40f85f,this.high=e[a(1685)](0,_0xce2a1d),this.unsigned=!!_0x4086f1}off(t,r){let a=n;if(e[a(926)](void 0,t))this[a(808)+"rs"]={};else if(r===void 0)this._listeners[t]=null;else{let x=this[a(808)+"rs"][t];if(x)for(let l=0;l<x[a(1309)];)x[l].fn===r?x[a(597)](l,1):++l}return this}on(t,r,a){let x=n;return(this[x(808)+"rs"][t]||(this._listeners[t]=[]))[x(636)]({fn:r,ctx:a||this}),this}}class a0 extends br{[n(531)+n(1583)+n(796)](t){let r=n;return t[r(1599)]||t[r(632)]?(r(953)+" "+(t.errMsg||"")+r(749)+(t.errNo||""))[r(604)]():JSON.stringify(t)}constructor(t,r,a){let x=n;super(),this._socket=null,Nt&&wx["connectS"+x(284)]&&(this[x(965)]=wx["connectS"+x(284)]({url:t,protocols:r,header:a,fail:this[x(1288)+x(342)+x(257)][x(1013)](this),success:this[x(1288)+x(1607)+x(244)+x(831)].bind(this)})),rt&&tt[x(321)+"ocket"]&&(this._socket=tt[x(321)+x(284)]({url:t,protocols:r,header:a,fail:this[x(1288)+"ocketFailHandler"][x(1013)](this),success:this[x(1288)+x(1607)+x(244)+x(831)][x(1013)](this)}))}[n(1288)+n(1607)+n(244)+n(831)](){let t=n;Promise[t(1577)]().then(()=>{let r=t;this[r(955)+r(928)]()})}[n(1288)+n(342)+n(257)](t){let r=n,a={TqxNS:function(x,l){return e[P(641)](x,l)},BAkdW:e.ZFVlq,TiJVR:function(x,l){return e.UVXze(x,l)},GpTHy:function(x,l){return x+l}};if(e[r(972)](e[r(393)],"xKvLg"))Promise[r(1577)]()[r(476)](()=>{let x=r,l=e[x(1425)](me,x(1296),{message:this[x(531)+x(1583)+x(796)](t)});this[x(1170)](e[x(697)],l);let p=be(e[x(401)],{reason:this[x(531)+x(1583)+"age"](t)});this[x(1170)](e[x(401)],p)});else return a[r(487)](_0x2bddbb,_0x5b9502)?_0x4755ce[r(1354)](new _0x4328e2(a[r(1095)])):(_0xee5d70=_0x3cbba5,a[r(725)](_0x35de2d,_0x1b5224.length)?_0x35461d[r(1577)]():_0x599ba7[_0x2c7d34][r(1013)](_0x176f00)(_0x37fd30,_0x383322[r(1013)](null,a.GpTHy(_0x47f965,1))))}[n(955)+n(928)](){let t=n,r={ioxBJ:function(a,x,l){return e.AgvDw(a,x,l)},mwphO:function(a,x){return e[P(1222)](a,x)},CYVIu:function(a,x){return a===x},pLCxG:e.Slhxw,yUUIz:e[t(1029)],zOYQG:e[t(1055)],VOYYx:e.zSlhY,amtXt:e[t(868)],wFNBE:e[t(697)],pNFak:function(a,x,l){return e[t(436)](a,x,l)}};this._socket[t(699)](a=>{let x=t;r[x(162)](r[x(670)],r[x(859)])?(wzkYlE[x(354)](_0x2ce0a8,_0x47ed36,24),wzkYlE[x(354)](_0x455d02,_0x59ac63,wzkYlE[x(1348)](_0x161e71,_0x1efe9c))):this[x(1170)](r[x(633)],r[x(354)](Bi,r[x(633)],{...a,data:a[x(1599)]||""}))}),this[t(965)][t(1133)](a=>{let x=t;this.emit(r[x(1032)],be(r[x(1032)],{...a}))}),this._socket.onMessage(a=>{let x=t;this[x(1170)](e[x(1016)],e[x(823)](Ni,e[x(1016)],{...a}))}),this[t(965)][t(404)](a=>{let x=t;r[x(1660)]!==r[x(1660)]?(this["_binaryT"+x(572)]=_0xbe4549,this._ws&&(this[x(563)][x(1111)+"pe"]=_0x363eb9)):this[x(1170)](r.wFNBE,r[x(790)](me,x(1296),{...a,message:a[x(1599)]||""}))})}send(t){let r=n,a={occxo:"error",TzSwP:function(x,l,p){return e[P(439)](x,l,p)}};if(e[r(1019)](t,Uint8Array)){let x=t[r(819)].slice(t[r(357)+"et"],e.hlssG(t[r(1630)+"th"],t[r(357)+"et"]));this[r(965)]&&this[r(965)][r(1367)]({data:x,fail:l=>{let p=r;e[p(1456)](e[p(222)],e[p(222)])?this[p(1170)](e[p(697)],e.PUpXe(me,p(1296),{message:this[p(531)+p(1583)+p(796)](l)})):(this[p(563)]&&this[p(563)][p(1367)](_0x1f6542),this._debug(p(1267),_0x76137f))}})}else this[r(965)]&&this[r(965)][r(1367)]({data:t,fail:x=>{let l=r;this[l(1170)](a[l(399)],a[l(1506)](me,"error",{message:this[l(531)+"rrorMess"+l(796)](x)}))}})}[n(616)](t,r){let a=n;this._socket&&this[a(965)][a(616)]({code:t,reason:r})}[n(1690)+n(1624)](t,r){this.on(t,r)}[n(1614)+n(1475)+n(1593)](t,r){this.off(t,r)}get readyState(){let t=n;return this[t(965)][t(489)+"te"]}get[n(1111)+"pe"](){let t=n;return this._socket[t(1111)+"pe"]}set[n(1111)+"pe"](t){}get[n(1279)](){let t=n;return this._socket[t(1279)]}get[n(1074)](){let t=n;return this[t(965)][t(1074)]}get[n(873)+"ns"](){let t=n;if(e.Zsvpt(t(667),t(667)))return this[t(965)][t(873)+"ns"];this[t(999)]=_0x5e316e,this[t(1550)]=null}get[n(1453)+n(609)](){return 0}}function c0(i,t){let r=n,a={WZItd:function(x,l){return e.GBpOo(x,l)},zVGuJ:function(x,l){return e[P(1114)](x,l)},COQeA:function(x,l){return e[P(159)](x,l)},pKQUQ:function(x,l){return e.yCclA(x,l)},vwhKS:function(x,l){return x|l},ybhOO:function(x,l){return e.iKkKp(x,l)},XJgbJ:function(x,l){return e[P(1493)](x,l)},QhEra:function(x,l){return x>>l},CKbZN:function(x,l){return e[P(1073)](x,l)},HslHy:function(x,l){return e[P(665)](x,l)},Swlyu:function(x,l){return e[P(1554)](x,l)},sLusc:function(x,l){return x&l}};if(e[r(1386)](e.fecaL,r(1536)))vnEMyp[r(407)](_0x295ca0,2048)?_0x3ac101[_0x46392c++]=vnEMyp[r(498)](vnEMyp[r(1253)](vnEMyp[r(501)](_0x55b2f7,6),31),192):(vnEMyp[r(407)](_0x243552,65536)?_0x4d97a1[_0x5d8557++]=vnEMyp[r(1527)](vnEMyp.ybhOO(_0xc04139,12)&15,224):(_0x37917c[_0x2e0273++]=vnEMyp[r(498)](vnEMyp[r(1253)](vnEMyp[r(1686)](_0x11820f,18),7),240),_0x28ce9e[_0x5a21df++]=vnEMyp[r(1253)](vnEMyp.QhEra(_0x434a3d,12),63)|128),_0x270b70[_0x9e9161++]=vnEMyp[r(1382)](vnEMyp.HslHy(_0x273a06,6)&63,128)),_0x550e0b[_0x1b2a80++]=vnEMyp[r(1698)](vnEMyp[r(1451)](63,_0x2122aa),128);else{if(t)return new t(i[r(1279)],i[r(1074)]);if(Nt||rt)return new a0(i[r(1279)],i[r(1074)],i.headers);if(e[r(1286)](lt,Bt)&&e[r(512)](r(1096)+"d",typeof WebSocket)&&WebSocket)return new WebSocket(i[r(1279)],i[r(1074)+"s"])}}function x0(i){let t=n;return!!(i||Nt&&wx[t(321)+t(284)]||rt&&tt[t(321)+t(284)]||e[t(1676)](lt,Bt)&&e.zPbtN(e[t(577)],typeof WebSocket)&&WebSocket)}function zi(i,t,r){let a=n,x=-1;async function l(p){let g=P;return e[g(1097)](e[g(1310)],e[g(1310)])?this["currentE"+g(1337)+g(1424)+"t"]:e[g(1596)](p,x)?Promise.reject(new Error(e.ZFVlq)):(x=p,p===r[g(1309)]?Promise.resolve():r[p].bind(i)(t,l[g(1013)](null,e.zQylX(p,1))))}e[a(1270)](l,0)}function Fi(i){let t=n,r=0,a=0;for(let x=0;e.jvOxM(x,i[t(1309)]);++x)a=i[t(391)+"At"](x),a<128?r+=1:a<2048?r+=2:e[t(879)](e[t(291)](64512,a),55296)&&e[t(972)](e[t(1516)](64512,i[t(391)+"At"](x+1)),56320)?(++x,r+=4):r+=3;return r}function Ui(i,t,r){let a=n;if(e[a(945)](a(1390),e[a(245)]))return _0x21a54e(e[a(976)](_0x2f7c1b,_0x1c78de));{if(e[a(507)](e[a(434)](r,t),1))return"";let x="";for(let l=t;l<r;){let p=i[l++];if(e[a(691)](p,127))x+=String[a(1230)+a(1490)](p);else if(e[a(882)](p,192)&&e[a(507)](p,224))x+=String["fromChar"+a(1490)](e[a(657)](e[a(1687)](e[a(503)](31,p),6),e[a(360)](63,i[l++])));else if(e[a(792)](p,224)&&p<240)x+=String[a(1230)+"Code"](e[a(371)](e.vMCrB(e.msdCp(15,p),12),e.EzAue(e[a(1700)](63,i[l++]),6))|e.pfyjy(63,i[l++]));else if(e.EoHxk(p,240)){let g=e[a(1678)](e[a(503)](7,p)<<18|(63&i[l++])<<12|e[a(1284)](63,i[l++])<<6,63&i[l++])-65536;x+=String["fromChar"+a(1490)](e[a(761)](55296,e[a(1198)](g,10))),x+=String[a(1230)+a(1490)](e[a(767)](56320,e[a(204)](1023,g)))}}return x}}function vr(i,t,r){let a=n,x=r,l,p;for(let g=0;e[a(526)](g,i[a(1309)]);++g)if(l=i[a(391)+"At"](g),l<128)t[r++]=l;else if(e.cNuyn(l,2048))t[r++]=e[a(1073)](l>>6,192),t[r++]=e[a(871)](e.GvtSd(63,l),128);else if(e[a(224)](e.fhxBF(64512,l),55296)&&e[a(287)](e[a(1732)](64512,p=i.charCodeAt(e[a(671)](g,1))),56320)){let d=e[a(573)].split("|"),_=0;for(;;){switch(d[_++]){case"0":t[r++]=e[a(871)](e[a(602)](l,12)&63,128);continue;case"1":++g;continue;case"2":l=e[a(880)](e[a(1256)](65536,e.QuPGi(e[a(694)](1023,l),10)),e[a(1561)](1023,p));continue;case"3":t[r++]=e[a(228)](l>>18,240);continue;case"4":t[r++]=e.DxMmT(e[a(1306)](e[a(301)](l,6),63),128);continue;case"5":t[r++]=e[a(1532)](63&l,128);continue}break}}else t[r++]=e[a(1073)](e.OSvAy(l,12),224),t[r++]=e[a(206)](e.Doyqj(e.OSvAy(l,6),63),128),t[r++]=e.regTR(63,l)|128;return e[a(1417)](r,x)}async function qi(i){let t=n;if(e.WHikM(e[t(826)],typeof i)){let r=new Uint8Array(e[t(1196)](Fi,i));return e[t(1460)](vr,i,r,0),r}return e[t(899)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(819)],i.byteOffset,i[t(1630)+"th"])}function u0(i){let t=n;try{return e[t(1458)](e[t(826)],typeof i)&&(e.NwESy(i,ArrayBuffer)||i[t(819)]&&i[t(819)]instanceof ArrayBuffer)||e[t(1665)](e[t(826)],typeof i)?"":(JSON[t(1612)](i),e[t(164)])}catch{return e[t(826)]==typeof i?e[t(201)]:""}}let f0=(i,t)=>{let r=n;switch(i){case e[r(1400)]:case e[r(267)]:return{["x-use-"+i]:1,"x-tt-env":t};default:return{}}};class d0{constructor(t){let r=n,a={SHMnw:e[r(697)]};if(e.JDiim(e[r(981)],r(463))){let x=_0x40b12a(a[r(1464)],{message:_0x58ba14[r(727)],code:_0x2f775f[r(1449)+"OR"],error:_0x53bb40});this["_dispatc"+r(1442)+r(560)](x)}else this[r(1646)+r(893)]=t,this[r(446)]=0}[n(1012)](){this.count++}[n(396)+n(680)+"nt"](){let t=n;return e.dafdA(this[t(446)],this.maxLossCount)}[n(837)+n(231)](t=0){let r=n;this["maxLossC"+r(893)]=t,this.count=0}}async function l0(i){let t={IEGhM:function(r,a){return r(a)},ektDl:e.KIgcJ};return new Promise(r=>{let a=P;if(!lt)return r(e[a(1721)]);try{let x=document["createEl"+a(234)](e[a(832)]);window[a(559)+a(598)]=l=>{let p=a;document[p(450)][p(1277)+p(791)](x),window.frontierJSONP=void 0,t[p(1087)](r,l&&l.msg||t[p(386)])},x[a(999)]=e[a(333)],x[a(646)]=i.replace(/^ws/,e[a(1180)])+e.LGpqw;try{document[a(450)][a(1620)+"ild"](x)}catch{document[a(450)]["removeCh"+a(791)](x)}}catch{window[a(559)+a(598)]=void 0,r(e[a(1721)])}})}function Je(i,t,r){let a=n;return!!i?.[a(315)](x=>x[a(1057)]===t&&x.value===r)}function ht(i,t){let r=n;return i?.[r(315)](a=>a[r(1057)]===t)?.[r(1613)]}let Sr=null;async function h0(){let i=n;return Sr||(Sr=Promise[i(1577)]()[i(476)](De[i(1013)](De,e.LXmUJ))),Sr}class g0 extends br{constructor(t,r){let a=n;if(e.wsNWg(e[a(1657)],e.VtFCE)){if(e[a(1154)](_0x272851,_0x4d87a6))return _0x178509}else super(),this._dbName=t,this._keyPath=r,this[a(438)]=void 0,this[a(576)+a(427)]=null}async[n(1065)](){await this[n(273)]()}async _init(){let t=n;if(!this._qosDB){if(this[t(576)+t(427)])return this[t(576)+"mise"];try{let r=this[t(1404)],a=this[t(268)];this[t(576)+"mise"]=(async()=>{let x=t,{openDB:l}=await e[x(398)](h0);this[x(438)]=await e.wkSTx(l,x(559)+"_"+r,1,{upgrade(p){p[x(355)+"jectStore"](r,{keyPath:a})}})})(),await this["_initPro"+t(427)]}catch(r){console[t(1071)](r)}finally{this[t(576)+t(427)]=null}}}async[n(205)](t){let r=n;try{return await this[r(273)](),this._qosDB?.get(this[r(1404)],t)}catch(a){console[r(1071)](a)}}async[n(643)](t,r){let a=n;return await this[a(273)](),this[a(438)]?.[a(1300)](this._dbName,t)}async del(t){let r=n,a={AjQfe:e[r(1016)],XMDab:e[r(697)],ESEsG:e[r(1055)],Qagfy:e[r(401)]};try{if(e[r(1477)](e[r(918)],e.oFgTE)){let x=(r(172)+"1")[r(1708)]("|"),l=0;for(;;){switch(x[l++]){case"0":this[r(563)][r(1690)+r(1624)](a[r(566)],this[r(353)+"ge"]);continue;case"1":this[r(563)]["addEvent"+r(1624)](a.XMDab,this[r(1078)]);continue;case"2":this._ws[r(1690)+r(1624)](a.ESEsG,this._onOpen);continue;case"3":if(!this[r(563)])return;continue;case"4":this[r(563)][r(1690)+r(1624)](a[r(664)],this._onClose);continue}break}}else return await this[r(273)](),this._qosDB?.[r(402)](this[r(1404)],t)}catch(x){console[r(1071)](x)}}async[n(255)](){let t=n;try{if(e[t(1562)]("DNIUV",e[t(846)]))return await this[t(273)](),this._qosDB?.[t(255)](this[t(1404)]);_0x27f45d[t(450)][t(1620)+t(791)](_0x5323ad)}catch(r){console[t(1071)](r)}}async keys(){let t=n,r={OnhAy:function(a,x){return e[P(750)](a,x)},tcTdx:function(a,x){return e[P(710)](a,x)},zoiKz:e[t(594)],XwqsV:e[t(416)]};if(e.uvXga===e[t(1266)])return await this[t(273)](),this[t(438)]?.[t(848)+"ys"](this[t(1404)]);{let a=_0x3c195a[t(1708)](/\./)[t(1502)](p=>_0x34039d(p)),x=[];return x[0]=NEpSjg[t(1513)](_0x34d7f7,a[0]+a[1]),x[1]=_0x48df8c(NEpSjg[t(1555)](a[2],a[3])),[t(1412),NEpSjg.zoiKz,NEpSjg[t(1211)],t(1412),t(1412),NEpSjg[t(397)],x[0],x[1]][t(687)]("")}}async[n(1389)](){let t=n;return await this._init(),this[t(438)]?.[t(1389)](this._dbName)}async[n(1037)](){let t=n;try{this[t(438)]?.[t(616)](),this[t(438)]=void 0}catch(r){console.log(r)}}get[n(271)](){let t=n;try{return!!this[t(438)]}catch(r){return console[t(1071)](r),!1}}}class p0{constructor(t,r){let a=n;this._DBName=t,this._pathKey=r,this[a(438)]=localStorage}async openDB(){}get[n(1650)](){let t=n;return t(559)+"_"+this[t(912)]}async[n(205)](t){let r=n,a={KorLR:function(x){return x()}};if(e[r(313)](r(441),e[r(739)]))EXJuxw[r(1602)](_0x129357),EXJuxw[r(1602)](_0x1668d5);else{let x=this[r(438)][r(1124)](this[r(1650)]);return JSON[r(1612)](e[r(1676)](x,"{}"))[t]}}async[n(643)](t,r){let a=n;if(e[a(480)]===e.hRlGL){let x=this[a(438)].getItem(this[a(1650)]),l=JSON[a(1612)](e[a(596)](x,"{}"));return l[r||t[this[a(421)]]]=t,this[a(438)][a(235)](this[a(1650)],JSON.stringify(l)),r||t[this[a(421)]]}else return}async[n(254)](t){let r=n,a=this[r(438)].getItem(this[r(1650)]),x=JSON[r(1612)](e[r(520)](a,"{}"));return x[t]=void 0,this[r(438)][r(235)](this._prefix,JSON[r(828)+"y"](x))}async clear(){return this[n(438)].clear()}async keys(){let t=n,r=this._qosDB.getItem(this[t(1650)]),a=JSON[t(1612)](e.fCxNI(r,"{}"));return Object.keys(a)}async getAll(){let t=n,r=this[t(438)][t(1124)](this[t(1650)]),a=JSON[t(1612)](e[t(545)](r,"{}"));return Object[t(1215)](a)}closeDB(){return Promise[n(1577)]()}get[n(271)](){return!!this[n(438)]}}class m0{constructor(t,r){let a=n;this._DBName=t,this[a(421)]=r,this[a(438)]=rt?tt:Nt?wx:null}async[n(1065)](){}get[n(1650)](){let t=n;return t(559)+"_"+this[t(912)]}async[n(205)](t){let r=n,a=this[r(438)]["getStora"+r(1287)](this._prefix);return JSON[r(1612)](a||"{}")[t]}async[n(643)](t,r){let a=n,x=this[a(438)][a(1568)+a(1287)](this[a(1650)]),l=JSON[a(1612)](e[a(1496)](x,"{}"));return l[r||t[this._pathKey]]=t,this[a(438)][a(905)+a(1287)](this[a(1650)],JSON[a(828)+"y"](l)),r||t[this[a(421)]]}async[n(254)](t){let r=n,a=this._qosDB[r(1568)+r(1287)](this[r(1650)]),x=JSON[r(1612)](a||"{}");return x[t]=void 0,this._qosDB["setStora"+r(1287)](this[r(1650)],JSON[r(828)+"y"](x))}async[n(255)](){let t=n;if(e[t(1375)](e[t(1261)],t(788))){let x=(t(239)+"2")[t(1708)]("|"),l=0;for(;;){switch(x[l++]){case"0":_0x44ff4d[_0x428100](r,r.exports,_0x4c4662);continue;case"1":var r=_0x4e1596[_0x5bdec6]={exports:{}};continue;case"2":return r[t(906)];case"3":var a=_0xd00dcb[_0x190d2f];continue;case"4":if(tuxLLj[t(583)](void 0,a))return a[t(906)];continue}break}}else return this._qosDB[t(1677)+t(744)]()}async keys(){let t=n;if(t(685)!==e[t(1109)]){let r=this[t(438)][t(1568)+t(1557)+"nc"](this[t(1650)]),a=JSON[t(1612)](e[t(1496)](r,"{}"));return Object[t(1333)](a)}else{let r=e[t(1323)](e[t(420)](e.LrPvp((7&_0x2c23a6)<<18,e.dSBWd(e.TuECj(63,_0x2a27c6[_0x5a2436++]),12))|e[t(1448)](63&_0x527854[_0x3479f7++],6),e[t(159)](63,_0x37219f[_0xe3fa53++])),65536);_0x318fde+=_0x4c5c0f[t(1230)+t(1490)](e[t(569)](55296,e[t(435)](r,10))),_0xae3964+=_0x23eb66[t(1230)+t(1490)](e[t(1696)](56320,1023&r))}}async[n(1389)](){let t=n,r=this._qosDB[t(1568)+"geInfoSync"](this[t(1650)]),a=JSON[t(1612)](r||"{}");return Object[t(1215)](a)}closeDB(){return Promise[n(1577)]()}get[n(271)](){return!!this[n(438)]}}function Ki(i,t){let r=n;if(e[r(520)](rt,rt))return new m0(i,t);if(e[r(532)](lt,Bt)&&e[r(512)](e[r(577)],typeof indexedDB))return new g0(i,t);if((lt||Bt)&&e.rKJEi(e[r(577)],typeof localStorage))return new p0(i,t);throw new Error(e[r(1134)])}class _0{constructor(){let t=n;this[t(1024)+t(1285)+"Id"]=null,this._interval=36e5,this._qosDB=Ki("qos",e.NCJnK)}async[n(1024)+n(1308)](){let t=n;e[t(1036)](clearInterval,this._intervalTimeoutId),this[t(1024)+t(1285)+"Id"]=e[t(1709)](setInterval,()=>{this.flushExpired()},this[t(1024)+"l"])}async[n(1065)](){let t=n;await this._qosDB[t(1065)]()[t(476)](()=>{let r=t;this[r(1024)+r(1308)]()})}async[n(658)+n(1220)](){let t=n,r={UwTxE:function(a,x){return e[P(849)](a,x)},eXcmf:function(a,x){return e[P(943)](a,x)},SXZZg:function(a,x){return e[P(1147)](a,x)},JfzGa:function(a,x){return a>>>x},WOfSc:function(a,x){return a===x}};if(e[t(1722)](e[t(1324)],e[t(380)]))return _0x339bdf.isLong(_0x3e5ab9)||(_0x465617=_0x5d7cf1.fromNumber(_0x120558)),JbiyLO[t(1101)](this[t(290)],_0x901cfd[t(290)])&&JbiyLO[t(1680)](JbiyLO[t(1152)](this[t(1332)],31),1)&&JbiyLO[t(1680)](JbiyLO[t(180)](_0x16b549[t(1332)],31),1)?!1:JbiyLO[t(936)](this[t(1332)],_0x4467dd[t(1332)])&&JbiyLO[t(936)](this.low,_0x14a4c1.low);(await this[t(438)]?.[t(1389)]()||[])[t(1436)](({timestamp:l})=>l<Date[t(840)]())[t(1190)](l=>{let p=t;this[p(438)]?.[p(254)](l.message_id)})}async[n(254)](t){let r=n;return this[r(438)]?.[r(254)](t)}async[n(643)](t,r){let a=n;return this[a(438)]?.[a(643)]({message_id:t,timestamp:r})}async get(t){let r=n;return this[r(438)]?.[r(205)](t)}async[n(1037)](){let t=n;e[t(806)](clearInterval,this[t(1024)+"lTimeoutId"]),await this[t(438)]?.closeDB()}get[n(271)](){let t=n;return this[t(438)]?.[t(271)]}}function Er(i){let t=n,r=!!this[t(921)].enableQoS;if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=e[t(1667)](Je,i.message[t(1140)],e.WSkjA,"2"),x=a&&e[t(1667)](Je,i[t(727)][t(1140)],e[t(742)],"1"),l=a&&e[t(1142)](Je,i[t(727)][t(1140)],e[t(1704)],"1"),p=l?e.dYLMh(ht,i.message[t(1140)],e[t(1188)])?.[t(1708)](",")[t(1436)](Boolean)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:x,isAckCleanupMessage:l,ackMsgIds:p}}async function ji(){let i=n;return this[i(755)+"ger"]||(this[i(755)+i(306)]=new _0),this[i(755)+i(306)].isReady||await this[i(755)+"ger"][i(1065)](),this[i(755)+"ger"]}async function w0(i,t){let r=n;if(e[r(1347)]===e[r(1347)]){let{enableAutoAck:a}=this[r(921)],x=e[r(1667)](Je,i[r(727)].headers,e[r(1511)],"1"),l=Je(i[r(727)][r(1140)],e.LikFI,"1"),p=Er.call(this,i);if(e[r(1e3)](a,x)){let{SeqID:g,LogID:d,service:_,LogIDNew:y,method:v}=i.message;this[r(1437)]({SeqID:g,LogID:d,LogIDNew:y,service:_,method:v,headers:[{key:e.LikFI,value:"1"},{key:e.HouJT,value:e[r(1496)](y,"")},{key:e[r(851)],value:"0"}]})}l&&!p.isQoSAck&&this[r(1155)+"hAckMess"+r(747)](i),e.mPwsk(t)}else{let a=_0x517c3c();return _0x315a97(_0x469ed2,a),_0x587b3e(a)}}async function y0(i,t){let r=n;this[r(1272)](r(1070),i[r(727)]),e.HRigu(t)}async function b0(i,t){let r=n;if(e[r(1058)](e[r(425)],e.PYdJj)){let a=e[r(1647)](Ne,await qi(i.data));try{if(a[r(1395)]instanceof Uint8Array){let x=e[r(1201)](this[r(921)][r(1405)+r(648)],Object)?{force:!!this[r(921)][r(1405)+r(648)][r(275)],encoding:this._options[r(1405)+r(648)][r(1717)]?this._options[r(1405)+r(648)][r(1717)][r(1052)](/\s/g,"")[r(381)+"ase"]():""}:{force:!1,encoding:this[r(921)][r(1405)+r(648)]?this._options[r(1405)+r(648)].replace(/\s/g,"")[r(381)+r(1467)]():""},l=a["payloadE"+r(648)]?a["payloadE"+r(648)][r(1052)](/\s/g,"")["toLowerC"+r(1467)]():"",p=e[r(760)](this[r(921)][r(980)+r(572)],Object)?{force:!!this[r(921)][r(980)+r(572)].force,type:this[r(921)].payloadType[r(999)]?this[r(921)][r(980)+r(572)][r(999)][r(1052)](/\s/g,"")["toLowerC"+r(1467)]():""}:{force:!1,type:this[r(921)][r(980)+"ype"]?this._options.payloadType[r(1052)](/\s/g,"")[r(381)+r(1467)]():""},g=a[r(980)+r(572)]?a[r(980)+r(572)][r(1052)](/\s/g,"")["toLowerC"+r(1467)]():"",d=p[r(275)]?p.type:g||p.type,_=x[r(275)]?x.encoding:l||x[r(1717)],y=[e.TSaSt,e[r(164)],e[r(1707)],e[r(826)]],v=[e[r(218)],e[r(1191)]];this[r(921)][r(649)+r(364)+r(1674)+"ad"]&&y.includes(d)&&(!_||v[r(842)](_))?a[r(876)+r(1474)]=Ui(a.payload,0,a[r(1395)].byteLength):a[r(876)+r(1474)]=""}else a[r(876)+r(1474)]=""}catch(x){a[r(876)+r(1474)]="",console[r(1071)](x)}i.message=a,e[r(1519)](t)}else{let a=this[r(921)]["reconnec"+r(519)+r(1089)](_0x328b26,_0x1bc3cf);this["_dispatchCloseEv"+r(560)](e[r(630)](_0x25aec4,r(616),{code:_0x56cfbe,reason:_0x2f5bf7,wasClean:!0,willReconnect:a})),a&&this[r(340)]()}}function v0(i,t,r){let a=n,x={kQvlr:function(_,y){return e[P(1181)](_,y)},KmiRN:function(_,y){return _(y)},LKmgM:function(_,y){return _+y},CkgpM:e[a(1388)],VMQdD:function(_,y){return _+y},kmYcH:function(_,y){return e[a(836)](_,y)}},l=e[a(834)](r,8192),p=e[a(346)](l,1),g=null,d=l;return function(_){let y=a;if(x[y(622)](_,1)||_>p)return x.KmiRN(i,_);if(x[y(805)](d,_)>l)if(x.CkgpM!==y(1014)){let I=this[y(438)]["getStora"+y(1287)](this[y(1650)]),k=_0xbb9578[y(1612)](I||"{}");return k[_0xade80||_0x102c73[this[y(421)]]]=_0x16e43f,this[y(438)][y(905)+y(1287)](this._prefix,_0x51dd29[y(828)+"y"](k)),_0x599c81||_0x3573f[this._pathKey]}else g=i(l),d=0;let v=t.call(g,d,d+=_);return 7&d&&(d=x[y(1684)](x[y(302)](7,d),1)),v}}let S0=4294967295;function E0(i,t,r){let a=n;return e[a(1662)](RangeError,e[a(1221)](e[a(746)](e[a(1670)](a(158)+a(1349)+a(1591)+i,e[a(368)]),e[a(1286)](t,1)),a(1094))+r)}function C0(i,t,r){let a=n;if(e.mLrnD(r,S0))throw new Error(a(996)+a(1020)+"e");let x=3;for(;x>=0;){let l=e.abHlM(255,r);e.IZAqN(Ar,l,i,e[a(1623)](t,x)),r>>>=8,x--}return e[a(202)](t,4)}function A0(i,t){let r=n,a=0,x=t,l=e[r(177)](t,4);for(;e[r(1165)](x,l);){let{value:p,offset:g}=Cr(i,x);x=g,a=e.XUJDo(a<<8,0),a+=p}return{value:a,offset:l}}function I0(i,t,r){let a=n;if(e[a(1314)](a(494),"rUWok")){let x=(a(181)+"3")[a(1708)]("|"),l=0;for(;;){switch(x[l++]){case"0":if(_0x5f06ee&&_0x273611[a(321)+a(284)])return!0;continue;case"1":if(e[a(932)](_0xec8d36,_0x579ffd)&&e[a(1665)](e[a(577)],typeof _0x4331e7)&&_0x343947)return!0;continue;case"2":if(_0x71fce0&&_0x20e25e[a(321)+a(284)])return!0;continue;case"3":return!1;case"4":if(_0x257a09)return!0;continue}break}}else{let x=e[a(1605)][a(1708)]("|"),l=0;for(;;){switch(x[l++]){case"0":if(i[a(1309)]<40)return e[a(1635)](e[a(1142)](vr,i,t,r),r);continue;case"1":if(t.utf8Write)return t.utf8Write(i,r)+r;continue;case"2":if(t[a(998)])return t[a(998)](i,r)+r;continue;case"3":if(!i)return r;continue;case"4":return vr(i,t,r)+r}break}}}function P0(i,t){let r=n,a=new j(e[r(1343)](i[e[r(862)](t,4)],24)|e[r(992)](i[e[r(1256)](t,5)],16)|i[e[r(347)](t,6)]<<8|i[e.BduUZ(t,7)],e[r(679)](e[r(920)](e[r(499)](e.enCZy(i[e.QwzZt(t,0)],24),i[e.ePrAy(t,1)]<<16),i[e[r(767)](t,2)]<<8),i[e[r(202)](t,3)]),!0);return t+=8,{value:a,offset:e[r(1397)](t,8)}}function k0(i,t,r){let a=n,x={THuUF:e[a(1721)]};if(e.QsCGS(e[a(497)],e[a(1340)])){let l=i.low,p=i[a(1332)];return t[r]=e.UWaBx(p,24),t[r+1]=e[a(1491)](e[a(1564)](p,16),255),t[e[a(1623)](r,2)]=e[a(1361)](p>>>8,255),t[e[a(1507)](r,3)]=e[a(612)](255,p),t[r+4]=l>>>24,t[r+5]=e[a(694)](e.JGYuG(l,16),255),t[r+6]=e.GvtSd(e[a(310)](l,8),255),t[r+7]=e[a(326)](255,l),r+=8,r}else _0x601019["frontier"+a(598)]=void 0,_0x21e7fa(XhgdDr[a(1093)])}function Cr(i,t){let r=n;return i[r(1463)+"8"]?{value:i[r(1463)+"8"](t),offset:e[r(1150)](t,1)}:{value:e[r(503)](255,i[t]),offset:t+1}}function Ar(i,t,r){let a=n,x={zkjlT:function(l,p){return e[P(532)](l,p)}};if(e[a(1097)](a(1232),e[a(1157)]))return t[a(409)+"t8"]?t[a(409)+"t8"](i,r):t[r]=e[a(1153)](255,i),e[a(627)](r,1);{let l=this[a(438)][a(1124)](this[a(1650)]),p=_0x4d0755[a(1612)](FxvSpn[a(1387)](l,"{}"));return p[_0x2a8c15]=void 0,this[a(438)][a(235)](this[a(1650)],_0x3705eb.stringify(p))}}let T0=function(i){return new Uint8Array(i)},D0=e.ZDgTm(e[n(577)],typeof Buffer)?Buffer[n(1590)+n(348)]:e[n(1728)](v0,T0,Uint8Array.prototype[n(1668)]),R0=16,Ir=32;function O0(i){let t=n,r={qjjth:function(a,x){return e[P(835)](a,x)},ISoyA:function(a,x){return e[P(728)](a,x)},mzyWr:function(a,x){return a*x},dinwo:function(a,x){return e[P(1158)](a,x)}};if(e[t(879)](e[t(1214)],e[t(971)])){let a=_0x31e8df[t(659)],x=_0x5a7812[t(1127)],l=_0x1919d2[t(1374)],p=QmOaWX[t(309)](x,_0x211ead);if(QmOaWX[t(817)](p,a[t(1309)])){let g=new _0x23f152(QmOaWX.mzyWr(2,p));g[t(643)](a),_0x10ea40[t(659)]=g}return _0x4e066a[t(1127)]=p,QmOaWX.dinwo(p,l)&&(_0x544bc0[t(1374)]=p),x}else{let a=0,x={};for(let l=0;l<i[t(1309)];l++)if(e[t(1456)](t(546),e[t(1316)])){let p=this._qosDB[t(1568)+t(1557)+"nc"](this._prefix),g=_0x261e0e.parse(p||"{}");return _0x27c5f8[t(1215)](g)}else x[i[l][t(990)+"ame"]]=e[t(493)](Fi,i[l][t(990)+t(1586)]),a+=e.zXHnS(14,x[i[l]["cursor_n"+t(1586)]]);return[a,x]}}function Gi(i,t,r){let a=n,[x,l]=e[a(1222)](O0,i),p=e[a(1695)](D0,x),g=0;return i[a(1190)](d=>{let _=a,y=e[_(1379)][_(1708)]("|"),v=0;for(;;){switch(y[v++]){case"0":g=e[_(989)](k0,j[_(1138)+"er"](d[_(1329)]||t),p,g);continue;case"1":console[_(1071)](e[_(286)],g);continue;case"2":g=I0(d.cursor_name,p,g);continue;case"3":console[_(1071)](e[_(1194)],g);continue;case"4":g=e[_(1460)](Ar,0,p,g);continue;case"5":console[_(1071)](e.CnoCV,d,d.service);continue;case"6":console.log(e[_(1617)],g);continue;case"7":console.log(e[_(867)],g);continue;case"8":console[_(1071)](e[_(571)],g);continue;case"9":g=e[_(1240)](C0,p,g,d.service||0);continue;case"10":g=e.uROuS(Ar,l[d[_(990)+_(1586)]],p,g);continue}break}}),{frameType:Ir,headers:[{key:"cursor_f"+a(1399),value:r}],payload:p}}function L0(i){let t=n,r=0,a=[];for(;e[t(1384)](r,i[t(1630)+"th"]);)if(e[t(1375)](t(1110),t(1110))){let x=_0x326983[t(1309)]&&_0x4df6e8[0];if(e.bSxtx(x,_0x28b276))throw x;let l=new _0x2c20bc(e[t(734)]+(x?e[t(1221)](e[t(1715)](" (",x[t(727)]),")"):""));throw l.context=x,x}else{let{offset:x}=e[t(1205)](Cr,i,r);r=x;let l={cursor_name:"",cursor:0,service:0},{value:p,offset:g}=e.Ihfqg(A0,i,r);l[t(1216)]=p,r=g;let{value:d,offset:_}=e.unBvZ(Cr,i,r);r=_,l[t(990)+t(1586)]=e[t(1234)](Ui,i,r,e[t(1715)](r,d)),r+=d;let{value:y,offset:v}=P0(i,r);l[t(1329)]=y[t(1457)](),r=v,a.push(l)}return a}function N0(){let i=n;return{frameType:Ir,headers:[{key:e.zlRBs,value:e[i(413)]}],payload:void 0}}class B0{constructor(t,r,a){let x=n;this[x(1281)+"ameSpace"]=t,this[x(625)+x(258)]=r,this[x(780)+x(1494)]=a,this[x(438)]=e[x(630)](Ki,this[x(1281)+x(395)],x(990)+x(1586))}async[n(1065)](){let t=n;await this[t(438)][t(1065)]()}async[n(400)+"rs"](){let t=n;if(!this._qosDB[t(271)])return;let r=this[t(780)+"Strategy"],a=await this[t(438)][t(1389)]();switch(console[t(1071)](t(387)+t(261),a),r){case e[t(1351)]:return a&&a.length?Gi(a,0,this[t(625)+t(258)]):void 0;case e[t(1303)]:return;case e[t(1705)]:return a&&a[t(1309)]?e[t(415)](Gi,a,0,this[t(625)+t(258)]):N0()}}async[n(643)](t,r,a){let x=n;if(e.qzols(e[x(337)],e.lgkqu))return console[x(1071)](e[x(328)],t,r,a),this[x(438)][x(643)]({cursor_name:t,cursor:r,service:a});e[x(989)](_0x50ed15,this,_0x4562b1,[_0x3d6f6f,_0x5a5222,_0x448f86,_0x22a9fe,_0x18a9e9,_0x472765])}async[n(1317)+"rs"](t){let r=n,a={ggLjP:e[r(908)],vcWwh:function(l,p,g,d){return e[r(606)](l,p,g,d)},pqwfs:e[r(286)],wxveB:r(548),XqblW:function(l,p,g,d){return e[r(606)](l,p,g,d)},DmmIM:e[r(349)],YbCcz:e[r(1194)]},x=e[r(308)](L0,t);for(let l of x)if(e[r(1364)]===e[r(1535)]){let p=a[r(1658)][r(1708)]("|"),g=0;for(;;){switch(p[g++]){case"0":_0x2f938c=gxVPVX.vcWwh(_0x15d80c,_0x490d67[r(1138)+"er"](_0xc5856c[r(1329)]||_0x137d78),_0x2dc7d4,_0x31292e);continue;case"1":_0x48671a.log(r(915)+r(199),_0x1c27ef);continue;case"2":_0x24fa30=_0x109df2(_0x1b742a[_0xa46e52[r(990)+r(1586)]],_0x94f54c,_0x1f787e);continue;case"3":_0x1a6bb7=_0x1a1e20(0,_0x1e82cf,_0x529982);continue;case"4":_0x1b2f83[r(1071)](gxVPVX[r(1046)],_0x4a3112);continue;case"5":_0x3c6ad8=gxVPVX[r(1082)](_0x3e82b6,_0x3d494f,_0x1d6e4c,_0x108c35.service||0);continue;case"6":_0x583b3c[r(1071)](gxVPVX.wxveB,_0x19cd4a);continue;case"7":_0x55c9a8=gxVPVX.XqblW(_0x528dfd,_0x4e22b9["cursor_n"+r(1586)],_0x529f6d,_0x4f178c);continue;case"8":_0x4f6d90[r(1071)](gxVPVX[r(1289)],_0x1d1c0b,_0x535fc3.service);continue;case"9":_0x138371.log("name",_0x3113a3);continue;case"10":_0xd5a0f3[r(1071)](gxVPVX.YbCcz,_0x5771b9);continue}break}}else console[r(1071)](e.ouACl,x),await this[r(438)].set(l)}async[n(205)](t){let r=n;return(await this[r(438)][r(205)](t))?.[r(1329)]}async[n(1037)](){let t=n;e.UVXze(t(1263),e[t(1283)])?await this[t(438)][t(1037)]():(e[t(1205)](_0x9e1eff,_0x24d2e5,10),e.AgvDw(_0x251153,_0x354406,_0x57edaa))}["updateCursorFile"+n(985)](t){let r=n;this[r(625)+r(258)]=t}get[n(271)](){let t=n;return this[t(438)][t(271)]}}let M0=n(1345)+n(1447);async function Hi(i){let t=n;if(!this[t(921)][t(455)+"S"])return null;let{aID:r,fpID:a,messageStrategy:x}=this[t(921)],l=e.rCUIx(i,M0);try{if(e[t(331)]!==e[t(331)]){let{pingInterval:p,pingFrequency:g}=this._options;if((e[t(1298)]("hi",_0xe32579.data)&&e.YwMMX(e[t(1056)],g)||e[t(513)](e.VWFxy,g))&&(this[t(1656)+t(1433)](),this[t(1170)](t(1443)+t(492)+"s",e[t(1633)]),this[t(1174)+"gTimeoutId"]=e[t(823)](_0x3743a2,this._ping[t(1013)](this),p)),e[t(1477)]("hi",_0x414b7a[t(956)]))return;try{e[t(1439)](_0x829d55,this,_0xc2fd9d,[_0x67e81f,_0x97645a,_0x20d29c,_0x2eaeba,_0x175bdd,_0x43185a])}catch(d){let _=e[t(947)](_0x46bcd0,t(1296),{message:d[t(727)],code:_0x56f921["MESSAGE_"+t(1171)],error:d});this[t(1155)+t(1442)+"ent"](_)}}else return this["_cursorM"+t(588)]?i&&this[t(452)+t(588)][t(786)+t(515)+"Name"](i):this[t(452)+t(588)]=new B0(a+"_"+r+"_"+l,l,x),this._cursorManager.isReady||await this[t(452)+t(588)][t(1065)](),this._cursorManager}catch{return null}}async function z0(i,t){let r=n,a={QXooq:function(k,L){return k===L},XctCz:e.djZnT,IItIF:function(k,L){return k>>L},xgnjY:function(k,L){return k>=L}},x=Je(i[r(727)].headers,"code","-1"),l=e[r(468)](Je,i[r(727)][r(1140)],e[r(549)],"1"),p=e[r(1510)](ht,i.message[r(1140)],e[r(1025)]),g=Number(e[r(1295)](ht,i.message[r(1140)],r(1238)+r(459)))||0,d=Er.call(this,i),_=e[r(1667)](Je,i[r(727)][r(1140)],e.RbBsL,"2"),y=e.BqqdF(ht,i[r(727)][r(1140)],"x-msg-cu"+r(713)+"e"),v=e.PtXDj(Number,ht(i[r(727)].headers,r(377)+r(1269)+"ue"));if(d[r(892)])return t();let I=d["isQoSMes"+r(1141)]?await ji[r(1054)](this):null;if(i[r(727)].service>0&&l&&!x||e[r(1228)](i.message.service,0))if(r(1105)!==e[r(1641)]){if(p&&d[r(1130)+"sage"]&&I){if(!!!await I[r(205)](p))if(e[r(712)](r(1482),e.cVSEG))this[r(1155)+r(722)+r(1472)](i),await I[r(643)](p,e[r(1643)](Date[r(840)](),g));else{let L=this._endpointManager?.[r(396)+r(756)+"es"](),J=this[r(1407)+"tManager"]?.[r(809)+"ntEndpoint"]();if(L&&!_0x251bc7.message){let B=r(299)+J+(r(807)+r(323)+r(198)+"ed");this["_dispatc"+r(1442)+r(560)](_0x2b1061("error",{message:B,code:_0x3f91ac[r(366)+r(821)+"R"],error:_0x1ff1e3}));return}this._ws&&a[r(745)](this[r(563)].readyState,this.OPEN)&&this["_disconn"+r(1125)](),this[r(1155)+r(1442)+r(560)](_0x2d6125(a[r(1440)],{message:_0xe2c0f8[r(727)],code:_0x48b1d5[r(644)+"RROR"],error:_0x11bbd5}))}return t()}if(_){let k=await Hi[r(1054)](this);if(!k)return this["_dispatchMessage"+r(1472)](i),e[r(1487)](t);let L=await k[r(205)](y)??-1;if(e.Eyugq(L,v))if(e[r(362)](e[r(958)],e[r(958)]))this["_dispatchMessage"+r(1472)](i),k[r(643)](y,v,i[r(727)].service);else return this[r(438)]?.set({message_id:_0x1ea683,timestamp:_0xdf39c1});else throw new Error(r(495)+r(1483)+" cursor "+v+(" larger "+r(789)+r(221)+"r ")+L);return e[r(1487)](t)}return this["_dispatc"+r(722)+r(1472)](i),e.lbFje(t)}else return _0x63f37d|=0,{low:_0x5e46ec,high:lQexQE[r(300)](_0x4ab3d9,31),unsigned:lQexQE[r(1265)](_0x2a2b28,0)}}async function F0(i,t){let r=n,a=Er[r(1054)](this,i);if(!a["isQoSMes"+r(1141)])return e[r(1377)](t);let x=await ji[r(1054)](this);if(a["isAckCle"+r(1512)+r(796)]&&a.ackMsgIds[r(1309)])for(let l of a[r(1446)+"s"])await x[r(254)](l);t()}async function U0(i,t){let r=n,a=e[r(943)](i[r(727)][r(1414)+"e"],R0),x=e.Zsvpt(i[r(727)][r(1414)+"e"],Ir);if(e[r(1128)](!a,!x))return t();let l=e[r(1015)](ht,i[r(727)].headers,e[r(1244)]);if(!l)return e.lbFje(t);let p=await Hi[r(1054)](this,l);if(!p)return e.GnWRK(t);if(a){let g=await p.getCursors(),d={frameType:g?.["frameType"],SeqID:j[r(1138)+"er"](this._seqId++),LogID:j[r(1138)+"er"](this[r(921)][r(913)+r(1681)]()),service:9e3,method:5,headers:g?.headers,payload:g?.[r(1395)]},_=e[r(1330)](A,d);this[r(563)]&&this[r(563)][r(489)+"te"]&&this[r(563)][r(1367)](_)}if(x){let g=i[r(727)][r(1395)];g&&p[r(1317)+"rs"](g)}}let q0=async function(i,t){let r=n;this[r(740)]=!1,clearTimeout(this[r(340)+r(1291)+r(1529)]),e[r(1355)](t)},K0=async function(i,t){let r=n,a={vfeop:function(p,g){return e[P(1218)](p,g)},mahsq:function(p,g){return p-g},ZmRwi:function(p,g){return e.diMUR(p,g)},SNkue:function(p,g){return p<=g},HJDya:function(p,g){return e.jkDYU(p,g)},BbnCw:function(p,g){return e.ImPVO(p,g)},TKrTl:function(p,g){return e[P(1604)](p,g)},OlENm:function(p,g){return e[P(1114)](p,g)},XArRr:function(p,g){return p<<g},MEoZU:function(p,g){return p&g},Pmnzz:function(p,g){return e.uxXPD(p,g)},PreYv:function(p,g){return e[P(499)](p,g)},bnKef:function(p,g){return p&g},hoFuL:function(p,g){return e[P(1567)](p,g)},UAcez:function(p,g){return e[P(1670)](p,g)},CHaJC:function(p,g){return e[P(964)](p,g)}};if(!this[r(563)]||e.rZjdH(this[r(563)][r(489)+"te"],this[r(1102)]))return t();let{pingInterval:x}=this[r(921)];this["_endpoin"+r(914)]?.[r(289)+"pointConfig"]();for(let p=0;e[r(759)](p,this._messageQueue[r(1309)]);p++){let g=this[r(780)+"Queue"][p];if(this._ws.readyState===this[r(1102)]&&e.DdepB(null,g))if(e[r(253)]("GkUTG",r(1199)))this[r(563)]&&this[r(563)].send(g),this[r(780)+"Queue"][p]=null;else{if(chvjJF[r(937)](chvjJF[r(683)](_0x1b63f6,_0x41f096),1))return"";let d="";for(let _=_0x1a2c6b;chvjJF[r(491)](_,_0x3ea1fa);){let y=_0x1d94c6[_++];if(chvjJF.SNkue(y,127))d+=_0x418b48[r(1230)+r(1490)](y);else if(y>=192&&chvjJF[r(491)](y,224))d+=_0x400d40[r(1230)+r(1490)](chvjJF[r(1537)](31&y,6)|chvjJF[r(930)](63,_0x5ab2ed[_++]));else if(y>=224&&chvjJF[r(335)](y,240))d+=_0x490eae[r(1230)+r(1490)](chvjJF[r(1260)](chvjJF[r(1260)](chvjJF[r(930)](15,y)<<12,chvjJF[r(1341)](chvjJF[r(930)](63,_0x1a2ea1[_++]),6)),chvjJF[r(1278)](63,_0x6507ff[_++])));else if(y>=240){let v=chvjJF[r(1060)](chvjJF.OlENm(chvjJF.PreYv(chvjJF.OlENm(chvjJF.HJDya(7&y,18),chvjJF[r(1537)](chvjJF[r(1129)](63,_0x1eb273[_++]),12)),chvjJF[r(678)](chvjJF.BbnCw(63,_0x12192d[_++]),6)),chvjJF[r(1278)](63,_0x249975[_++])),65536);d+=_0x133e2d["fromChar"+r(1490)](chvjJF[r(883)](55296,chvjJF[r(1664)](v,10))),d+=_0x4f1e67[r(1230)+r(1490)](56320+(1023&v))}}return d}else break}this[r(780)+r(1579)]=this[r(780)+r(1579)][r(1436)](p=>!!p),this[r(1174)+r(351)+"Id"]=e.QriWN(setTimeout,()=>this[r(451)](),x),this[r(1155)+r(764)+"nt"](i),this[r(219)+"er"]&&this[r(563)]&&(this[r(563)].binaryType=this[r(1213)+r(572)]);let l=this[r(1407)+r(914)]?.[r(809)+r(277)+"nt"]();this[r(1272)](r(1226)+l+" success"),e[r(1209)](t)},j0=async function(i,t){let r=n,a=this["_endpoin"+r(914)]?.[r(809)+"ntEndpoint"]();this[r(1272)](r(1226)+a),t()};class G0 extends br{constructor(t){let r=n,a={axsYK:function(g,d){return e[P(1688)](g,d)},DEtum:"always",TKiIX:function(g,d){return e[P(1121)](g,d)},efcFz:e[r(735)],QxJkO:e[r(1023)],MyvFd:r(1443)+r(492)+"s",YYRBR:e[r(1633)],BCytT:function(g,d,_){return e[r(523)](g,d,_)},bDGhC:e.Onkhk,HiWik:e[r(1470)],RFTIW:function(g,d,_){return e.dYLMh(g,d,_)},BmzoT:function(g,d){return e.dfQRj(g,d)},CESmL:e[r(697)],IeKoS:function(g,d){return e[r(456)](g,d)},jdOVL:e[r(156)],axZfA:e[r(1035)],ZbFZk:e[r(401)],YLyUV:function(g,d){return e[r(858)](g,d)},vQhVc:function(g,d,_){return g(d,_)},vvMrc:e.HCNMv,uvPzE:function(g,d){return e[r(1456)](g,d)},QUIhi:e.WmUps,aoJCg:function(g,d){return e.VGkVj(g,d)},bFabJ:function(g,d){return e[r(910)](g,d)}};super(),this["_miniNav"+r(854)+r(856)]=!0,this[r(219)+"er"]=lt,this[r(1177)]=o0,this[r(579)+"T"]=rt,this[r(706)+"X"]=Nt,this._isWorker=Bt,this[r(780)+r(1579)]=[],this[r(1407)+r(914)]=null,this[r(1041)+r(247)]=!1,this[r(1213)+r(572)]=e[r(1581)],this[r(340)+"Lock"]=!1,this[r(340)+"ionTimeoutId"]=null,this["_reconne"+r(938)+"tId"]=null,this["_pingPon"+r(351)+"Id"]=null,this[r(543)]=0,this[r(740)]=!1,this[r(488)]="",this[r(755)+r(306)]=null,this[r(452)+r(588)]=null,this[r(952)+r(195)]=null,this[r(751)+"ls"]=e[r(295)],this[r(610)]=3,this.CONNECTING=0,this[r(1102)]=1,this.CLOSING=2,this._onOpen=g=>{let d=r,_={vcwEw:function(y,v){return e[P(1406)](y,v)},MJoPu:function(y,v){return e[P(1435)](y,v)}};try{e.nhEsa===e[d(1045)]?zi(this,g,[q0,K0,j0]):(_0x16503a=CFzrMD[d(925)](_0x104b36,_0x4cb3b5),_0x25b078=127&_0xac8a2a,CFzrMD[d(1694)](128,_0x3f06f5)&&(_0x5537e4=CFzrMD[d(925)](_0x2c17fa,_0x4e0ad8),_0x5c2cca|=(127&_0x1ab42c)<<7))}catch(y){let v=me(d(1296),{message:y[d(727)],code:We[d(1449)+"OR"],error:y});this[d(1155)+"hErrorEv"+d(560)](v)}},this[r(353)+"ge"]=async g=>{let d=r,_={kBQVI:function(I,k){return I<k}},{pingInterval:y,pingFrequency:v}=this._options;if(a[d(1028)]("hi",g[d(956)])&&a[d(1028)](a[d(1391)],v)||d(1476)===v)if(a[d(684)](a[d(874)],a[d(1081)]))this["_clearPi"+d(1433)](),this[d(1170)](a[d(550)],a[d(752)]),this[d(1174)+d(351)+"Id"]=a[d(1098)](setTimeout,this[d(451)].bind(this),y);else{let I=this[d(808)+"rs"][_0x59cbad];if(I)for(let k=0;qFtFrh[d(1273)](k,I[d(1309)]);)I[k].fn===_0x4c2fd7?I[d(597)](k,1):++k}if(!a[d(1028)]("hi",g[d(956)]))try{zi(this,g,[b0,w0,F0,U0,z0,y0])}catch(I){let k=a.BCytT(me,d(1296),{message:I[d(727)],code:We["MESSAGE_"+d(1171)],error:I});this[d(1155)+"hErrorEv"+d(560)](k)}},this[r(1078)]=g=>{let d=r;if(a[d(1028)](a.bDGhC,a[d(518)]))return _0x678a18.objectStoreNames||_0x252725[d(205)](_0x2a2a0e);{let _=this["_endpoin"+d(914)]?.[d(396)+d(756)+"es"](),y=this[d(1407)+d(914)]?.["getCurre"+d(277)+"nt"]();if(_&&!g[d(727)]){let v="connect "+y+(d(807)+d(323)+"es reached");this[d(1155)+"hErrorEvent"](a.RFTIW(me,d(1296),{message:v,code:We[d(366)+"IES_ERROR"],error:g}));return}this[d(563)]&&a[d(816)](this[d(563)].readyState,this[d(1102)])&&this[d(320)+d(1125)](),this["_dispatc"+d(1442)+d(560)](me(a.CESmL,{message:g[d(727)],code:We[d(644)+d(1011)],error:g}))}},this[r(223)]=async g=>{let d=r,_={EOmiu:d(1393)};if(a[d(991)](a[d(587)],a[d(638)])){this["_clearTi"+d(1572)](),this[d(1656)+d(1433)](),this[d(772)+"sListeners"](),this[d(563)]=null,this[d(340)+d(1693)]=!1;let y=this[d(1407)+d(914)]?.["checkRea"+d(756)+"es"]();if(!y&&this[d(1322)+d(1559)]()&&!this[d(1041)+d(247)]){let v=this[d(1407)+d(914)]?.getCurrentEndpoint(),I=this[d(921)][d(200)+d(519)+d(1089)](g[d(1381)],g[d(1044)]);this[d(1155)+d(1538)+"ent"](be(a[d(1148)],{code:1006,reason:g[d(1044)]||d(485)+d(1290)+d(1573)+d(356)+"n, hostn"+d(1459)+v,willReconnect:I})),I&&this[d(340)]();return}if(a[d(1465)](1e3,g[d(1381)])&&this[d(1041)+"osed"]){this[d(1155)+d(1538)+"ent"](a[d(429)](be,a.ZbFZk,{code:1e3,reason:a[d(1168)]})),this["_endpoin"+d(914)]?.[d(289)+d(1042)+d(297)](),this[d(952)+d(195)]?.["resetCou"+d(231)]();return}if(a[d(991)](1e3,g.code)&&y)if(a.uvPzE("MiRKT",a[d(1006)])){let v=this[d(1407)+"tManager"]?.["getCurre"+d(277)+"nt"](),I=g.reason;I||(I=await a[d(330)](l0,this[d(488)])),I="connecti"+d(1290)+"d, "+I+(", hostna"+d(316))+v+(", max retries re"+d(830)),this["_dispatc"+d(1538)+d(560)](be(a[d(1148)],{code:g[d(1381)],reason:I}));let k=d(299)+v+(d(807)+d(323)+d(198)+"ed");this[d(1155)+"hErrorEv"+d(560)](a[d(1098)](me,a[d(940)],{message:k,code:We[d(366)+d(821)+"R"]})),this[d(1407)+"tManager"]?.["resetEndpointCon"+d(297)](),this[d(952)+"sCounter"]?.[d(837)+d(231)]();return}else return _0x3e9685[d(1071)](ALdqfF.EOmiu,_0x466bb9,_0x3d6ffd,_0x17a8cc),this[d(438)][d(643)]({cursor_name:_0x59fab6,cursor:_0x2bffb4,service:_0x469534});if(a[d(568)](1e3,g[d(1381)])&&!g.reason){let v=this[d(1407)+d(914)]?.getCurrentEndpoint();this["_dispatc"+d(1538)+d(560)](be(d(616),{code:g.code,reason:"connecti"+d(1290)+"d, unkno"+d(356)+"n, hostn"+d(1459)+v})),this[d(1407)+"tManager"]?.[d(289)+"pointCon"+d(297)](),this[d(952)+d(195)]?.[d(837)+d(231)]();return}this[d(1155)+d(1538)+d(560)](g),this[d(1407)+d(914)]?.[d(289)+d(1042)+"fig"](),this[d(952)+d(195)]?.[d(837)+d(231)]()}else this[d(1170)](d(1296),_0x15e08c),this[d(810)]&&this[d(810)](_0x568841)},this[r(898)]=null,this[r(810)]=null,this[r(900)+"e"]=null,this[r(617)]=null,this[r(509)+r(542)]=null,this[r(675)+r(1719)]=null,this["onStopIm"+r(1077)+"yReconnect"]=null,this[r(567)+"nLine"]=this[r(567)+r(803)][r(1013)](this),this["_handleO"+r(986)]=this[r(567)+"ffLine"][r(1013)](this),this[r(1034)+r(729)]=this[r(1034)+r(729)].bind(this),this[r(1034)+r(1669)]=this[r(1034)+r(1669)].bind(this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:1/0,service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[r(178)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.ZNILy,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:l}=t,p=Array[r(655)](x)?x:e[r(1331)](e[r(826)],typeof x)?[x]:[];if(!p||e[r(1030)](0,p[r(1309)]))throw new Error(e[r(1385)]);if(!e[r(481)](x0,l))throw new Error(e.UQJmb);if(Object[r(661)](this[r(921)],t),this[r(1407)+r(914)]=new Mi(p,this[r(921)].maxRetries),this[r(952)+"sCounter"]=new d0(this[r(921)][r(1444)+r(1730)]),this[r(921)][r(1649)+r(1219)])if(e[r(863)]===e[r(863)])this._isInit=!0,this._connect();else return _0x359802.resolve();this[r(921)][r(1059)+"tworkCha"+r(314)]&&(this[r(579)+"T"]||this[r(706)+"X"]?this[r(662)+"etWorkCh"+r(369)]():this[r(219)+"er"]&&this[r(1122)+"balEvent"+r(1624)]())}[n(567)+"nLine"](){let t=n;this[t(921)][t(844)+t(626)+"nect"]||this["_readyCl"+t(247)]||this[t(820)+"econnect"]()}[n(567)+"ffLine"](){let t=n;this[t(1423)+t(365)+"t"]();let r=yr(t(200)+"t",{message:e[t(847)]});this[t(1551)+t(1077)+t(243)+"ct"]&&this[t(1551)+t(1077)+t(243)+"ct"](r)}[n(1122)+n(711)+"Listener"](){let t=n;this[t(219)+"er"]&&window[t(1690)+t(1624)](e[t(544)],this[t(567)+t(803)]),this[t(219)+"er"]&&window[t(1690)+"Listener"](e[t(677)],this["_handleO"+t(986)]),this[t(219)+"er"]&&window[t(1690)+t(1624)](e[t(1514)],this[t(1034)+t(729)]),this[t(219)+"er"]&&window[t(1690)+"Listener"](e.AzwGa,this[t(1034)+t(1669)])}["_dropGlo"+n(711)+n(1624)](){let t=n;this[t(219)+"er"]&&window[t(1614)+t(1475)+"ner"](t(1258),this[t(567)+t(803)]),this[t(219)+"er"]&&window["removeEv"+t(1475)+"ner"](t(850),this[t(567)+t(986)]),this[t(219)+"er"]&&window[t(1614)+t(1475)+t(1593)]("pagehide",this[t(1034)+t(729)]),this[t(219)+"er"]&&window["removeEv"+t(1475)+t(1593)](e[t(731)],this[t(1034)+t(1669)])}[n(1034)+n(729)](t){let r=n;!t[r(325)+"d"]&&(this[r(219)+"er"]&&window[r(1614)+r(1475)+r(1593)](r(833),this[r(1034)+r(729)]),this._isBrowser&&window[r(1614)+r(1475)+r(1593)](e[r(731)],this[r(1034)+r(1669)]),this[r(616)]()),this._isBrowser&&window["removeEventListe"+r(1593)](e.bRlDP,this[r(567)+r(803)]),this[r(219)+"er"]&&window["removeEv"+r(1475)+r(1593)](e[r(677)],this[r(567)+r(986)])}["_handleP"+n(1669)](t){let r=n;t[r(325)+"d"]&&(this["_navigat"+r(1559)]()&&(!this[r(563)]||e[r(194)](this[r(563)].readyState,this[r(1102)])||this[r(563)][r(489)+"te"]!==this[r(527)+"NG"])&&this[r(567)+r(803)](),this[r(219)+"er"]&&window[r(1690)+r(1624)](e[r(544)],this[r(567)+r(803)]),this._isBrowser&&window["addEvent"+r(1624)](e[r(677)],this[r(567)+r(986)]))}async["_generat"+n(1297)](t){let r=n,{fpID:a,deviceID:x,bddID:l,ttwID:p,accessKey:g,aID:d,customParams:_={},enableAutoAck:y,enableQoS:v,QoSLevel:I,env:k}=this[r(921)],L,J,B;this[r(219)+"er"]||this[r(706)+"X"]||this[r(579)+"T"]?(L=location&&e.XhJKH(e.EwxdJ,location[r(1074)])?e[r(1336)]:e[r(502)],J=t[r(1052)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),B=/^wss(.*:\/\/)/.test(t)?t:""+L+J):(L=e.mDpdN,J=t[r(1052)](/(^http)((?:[s]*:\/\/))/,""),B=/(^ws)((?:[s]*:\/\/))/[r(993)](J)?J:""+L+J);let re=l?r(621):p?r(608):e.REtoX,ve=l||p||x;if(e[r(1159)](!ve,!re))throw new Error(e.Ysnzw);let Be=e[r(1331)](e[r(1320)],typeof _)?await e[r(1369)](_):_,an=k?e[r(436)](f0,k[r(1411)],k[r(259)]):{},Mt=Object[r(661)]({device_platform:e[r(861)],version_code:e[r(1359)],access_key:g,fpid:a,aid:d,[re]:ve,xsack:y?1:0,xaack:y?1:0,xsqos:v?1:0,qos_level:v?I:void 0,qos_sdk_version:2,...an},Be),cn=Object[r(1333)](Mt).reduce((zt,Ft)=>Mt[Ft]!==void 0?""+zt+(zt?"&":"?")+Ft+"="+Mt[Ft]:zt,"");return B+r(613)+cn}async[n(340)](){let t=n,r={zERlD:function(a,x){return e[P(1716)](a,x)},ATyNq:function(a,x){return e[P(1528)](a,x)},UKyUb:function(a,x){return e[P(1165)](a,x)},vFwdY:function(a,x){return e[P(569)](a,x)},qOkUt:function(a,x){return a-x},mBWpA:function(a,x){return e[P(1038)](a,x)},fzsPu:function(a,x){return a<x},XMbtM:function(a,x){return a<x}};if(!(this[t(340)+"Lock"]||this[t(1041)+t(247)])){this[t(340)+t(1693)]=!0;try{if(e[t(375)](e.eXYFV,e[t(232)])){let a=this[t(1407)+"tManager"]?.["checkCur"+t(802)+"ointReachedMaxRe"+t(188)](),{timeoutInterval:x}=this[t(921)];if(a){let p=this[t(1407)+"tManager"]?.["getCurre"+t(277)+"nt"](),g=this._endpointManager?.[t(1626)+t(1637)+t(285)+"UpdateCo"+t(1558)](),d=this[t(1407)+t(914)]?.["getCurre"+t(277)+"ntTriesC"+t(893)]();if(g){let _=t(299)+p+(t(948)+", max re"+t(736)+t(1067)+t(1339)+t(954)+t(539))+g+(t(966)+"y"),y=e.dVKdf(me,e[t(697)],{message:_,code:We["MAX_RETR"+t(821)+"R"]});this[t(1272)](_),this["_dispatc"+t(1442)+"ent"](y),this._url=await this["_generat"+t(1297)](g),this[t(1272)](t(299)+g+" "+d+t(240)),this[t(772)+t(723)+"rs"]()}else{let _=t(299)+p+(" timeout"+t(1409)+t(736)+t(830));this[t(1272)](_),this[t(1155)+"hErrorEv"+t(560)](e[t(1709)](me,e.djZnT,{message:_,code:We["MAX_RETR"+t(821)+"R"]}));return}}else{let p=this[t(1407)+t(914)]?.[t(809)+t(277)+t(1711)+t(448)](),g=this[t(1407)+t(914)]?.[t(809)+t(277)+"ntTriesC"+t(893)]();this[t(488)]=await this[t(995)+t(1297)](p||""),this[t(1272)](t(299)+p+" "+g+" times"),this._removeWsListeners()}if(this[t(740)])this[t(740)]=!1;else{let p=e[t(983)](yr,t(200)+"t",{message:e[t(1726)]});this.onStartReconnect&&this[t(509)+"econnect"](p)}let l=this[t(1407)+t(914)]?.[t(809)+t(277)+t(406)+t(893)]()||0;e[t(522)](l,1)&&await this._wait(e[t(692)](l,1)),this._debug(t(485)+"ng url: "+this._url+(t(763)+t(1091))+this._protocols),this[t(563)]=e[t(1068)](c0,{url:this[t(488)],protocols:[this[t(751)+"ls"]],headers:this[t(921)][t(183)+t(1584)+"s"][t(717)+t(367)]},this[t(921)].ws),(this._isBrowser||this._isWorker)&&this._ws&&(this[t(563)].binaryType=this[t(1213)+"ype"]),this[t(955)+t(928)](),this[t(340)+t(1291)+t(1529)]=setTimeout(this._onTimeout[t(1013)](this),x)}else{let a=_0x41afc5[t(391)+"At"](_0x3a8fb8);IcmzYA[t(1365)](a,55296)&&IcmzYA[t(167)](a,56319)&&IcmzYA[t(758)](IcmzYA[t(1427)](_0x2afd12,1),_0x49ebe7)&&(a=IcmzYA.qOkUt(IcmzYA[t(1427)](IcmzYA[t(171)](a,10),_0x2170c7.charCodeAt(++_0x2979f6)),56613888)),_0x223f15+=IcmzYA[t(1703)](a,128)?1:IcmzYA[t(704)](a,2048)?2:a<65536?3:4}}catch(a){throw this["_connect"+t(1693)]=!1,a}}}["_clearTi"+n(1572)](){let t=n,r={swmyx:function(a,x,l){return e[P(312)](a,x,l)},boWyf:function(a,x){return e.LzAJb(a,x)},uwaYK:function(a,x){return e[P(454)](a,x)}};e.fcirL!==e[t(1578)]?(e[t(541)](clearTimeout,this[t(340)+t(1291)+t(1529)]),this["_connectionTimeo"+t(1529)]=null):(_0x1d08d0-=65536,_0x445bec+=tcKoPO[t(414)](_0x2f61ff,(_0x4c4d21>>10)+55296,tcKoPO[t(1672)](tcKoPO[t(1009)](1023,_0x347e0e),56320)),_0x3b62c7+=3)}[n(1656)+n(1433)](){let t=n;e[t(524)](clearTimeout,this[t(1174)+t(351)+"Id"]),e[t(593)](clearTimeout,this[t(1485)+t(938)+t(1727)]),this["_pingPon"+t(351)+"Id"]=null,this[t(1485)+"ctTimeou"+t(1727)]=null}[n(1272)](...t){let r=n;this[r(921)].debug&&console[r(1071)][r(1683)](console,[e[r(875)],...t])}[n(1187)+n(754)+"e"](t){let r=n,{initReconnectInterval:a,maxReconnectInterval:x,reconnectIntervalGrowFactor:l}=this[r(921)],p=e[r(1452)](a,Math.pow(l,e[r(1419)](t,1)));return p>x?x:p}_ping(){let t=n;if(e[t(712)]("vIQsB",e.MIwjj))_0x8c09f=e.ORPNc(e[t(1038)](31&_0x1e332e,6),e[t(1435)](63,_0x5bd92f)),e[t(1714)](_0x28c168,128)?_0x4bcad2+=_0x5ce466:(_0x4ac208+=e[t(1350)](_0xe1f3a5,_0x579dcd),_0xd86ae3++);else{if(this[t(563)]&&e[t(783)](this[t(563)][t(489)+"te"],this[t(527)+"NG"])){this[t(1656)+"ngTimer"](),this[t(1174)+t(351)+"Id"]=e[t(647)](setTimeout,this[t(451)][t(1013)](this),this[t(921)][t(1697)+t(891)]);return}if(!this[t(563)]||this[t(563)][t(489)+"te"]!==this[t(1102)])return void this[t(820)+t(542)]();this[t(563)]&&this[t(563)][t(1367)]("hi"),this[t(1485)+t(938)+"tId"]=e.nuYgl(setTimeout,this[t(820)+"econnectTimeout"][t(1013)](this),this[t(921)]["pingTime"+t(1017)+"val"])}}["_handleR"+n(542)+n(1305)](){let t=n,r={yUjRx:function(a,x){return e[P(1531)](a,x)}};e[t(253)](e[t(1294)],e[t(1294)])?(this["_pingLos"+t(195)]?.addCount(),this[t(1170)](t(1443)+t(1262)+"t",e.iIRlt),this[t(952)+"sCounter"]?.["checkRea"+t(680)+"nt"]()?this[t(820)+"econnect"]():this[t(451)]()):(_0x2f0061=pgjmQP[t(707)](_0x3cf227,_0x193a83),_0x405510=0)}[n(1322)+n(1559)](){let t=n;return e.CsWdt!==e[t(1062)]?this[t(579)+"T"]||this[t(706)+"X"]?this[t(558)+t(854)+"line"]:(this[t(219)+"er"]||this[t(483)+"r"])&&this._options[t(1059)+t(1163)+t(314)]?navigator[t(565)]:!0:(_0xd6aa57||(_0xecffe1=_0x55d264.resolve()[t(476)](_0x4f21ae[t(1013)](_0x2a9ec7,t(1315)))),_0x1a3c41)}[n(820)+n(542)](){let t=n;!this[t(1322)+"orOnline"]()||this[t(1041)+"osed"]||(this._endpointManager?.[t(289)+t(1042)+t(297)](),this[t(952)+t(195)]?.["resetCou"+t(231)](),this._ws?this[t(320)+t(1125)](1001,e[t(1325)],!0):this[t(340)]())}[n(662)+n(987)+"ange"](){let t=n,r={FpkcB:e[t(1145)]};if(e.VCCvf!==e[t(997)])this[t(579)+"T"]?tt["onNetwor"+t(651)+t(1587)](({isConnected:a})=>{let x=t;this[x(558)+"igatorOnline"]=a,a?this[x(567)+x(803)]():this[x(567)+"ffLine"]()}):this[t(706)+"X"]&&wx[t(1582)+"kStatusChange"](({isConnected:a})=>{let x=t;this[x(558)+x(854)+"line"]=a,a?this["_handleO"+x(803)]():this[x(567)+x(986)]()});else{let a=r[t(470)][t(1708)]("|"),x=0;for(;;){switch(a[x++]){case"0":this[t(952)+t(195)]?.[t(837)+t(231)]();continue;case"1":this[t(1041)+t(247)]=!1;continue;case"2":this[t(740)]=!0;continue;case"3":this[t(340)]();continue;case"4":this["_endpoin"+t(914)]?.[t(289)+t(1042)+t(297)]();continue}break}}}_wait(t){let r=n,a={oYSJE:function(x,l){return x===l},sslvX:e[r(516)],kdAeP:function(x,l,p){return e[r(708)](x,l,p)}};return new Promise(x=>{let l=r;a[l(1621)](a.sslvX,"QQSnj")?a[l(1119)](setTimeout,x,this[l(1187)+l(754)+"e"](t)):_0x5eda4d(_0x2b62d8,this._getIntervalValue(_0x40dfa4))})}[n(320)+n(1125)](t=1e3,r="",a=!1){let x=n,l={qXvht:function(p,g){return e[P(529)](p,g)},MkMvJ:function(p,g){return e[P(1027)](p,g)},qOvAq:function(p,g){return e[P(503)](p,g)},zCMxQ:function(p,g){return e[P(1491)](p,g)},VoRFt:function(p,g){return p&g}};if(e[x(584)](e[x(885)],e[x(885)])){let p=this[x(1332)],g=this[x(1200)];return[p>>>24,ZyFpoe.qXvht(p>>>16,255),ZyFpoe.MkMvJ(p,8)&255,255&p,g>>>24,ZyFpoe[x(1575)](ZyFpoe[x(1625)](g,16),255),ZyFpoe[x(1112)](g>>>8,255),ZyFpoe[x(1653)](255,g)]}else{if(!this._ws)return;this[x(1423)+x(365)+"t"](t,r,a)}}[n(1282)+"ut"](){let t=n,r=this[t(1407)+t(914)]?.["getCurre"+t(277)+"nt"]();this[t(1272)]("connect "+r+" timeout"),this["_disconn"+t(1125)](1001,t(242)+" try rec"+t(794)+"g",!0)}[n(1437)](t){let r=n,a=e[r(308)](wr,t);this[r(563)]&&e.xIinq(this._ws.readyState,this.OPEN)&&(this._ws&&this._ws[r(1367)](a),this[r(1272)](e[r(1233)],t))}[n(772)+n(723)+"rs"](){let t=n;if(e[t(1383)](e.dhfol,t(1275))){let r=e[t(453)].split("|"),a=0;for(;;){switch(r[a++]){case"0":if(!this[t(563)])return;continue;case"1":this[t(563)]["removeEv"+t(1475)+t(1593)](e[t(401)],this[t(223)]);continue;case"2":this[t(563)][t(1614)+t(1475)+t(1593)](e.djZnT,this._onError);continue;case"3":this[t(563)]["removeEv"+t(1475)+t(1593)](e[t(1055)],this._onOpen);continue;case"4":this[t(563)][t(1614)+t(1475)+t(1593)]("message",this[t(353)+"ge"]);continue}break}}else _0x197883[t(325)+"d"]&&(this[t(1322)+t(1559)]()&&(!this[t(563)]||this[t(563)][t(489)+"te"]!==this[t(1102)]||e[t(797)](this[t(563)][t(489)+"te"],this.CONNECTING))&&this[t(567)+t(803)](),this._isBrowser&&_0x1d1caf[t(1690)+t(1624)](e[t(544)],this[t(567)+t(803)]),this[t(219)+"er"]&&_0xd3c5db[t(1690)+"Listener"](t(850),this[t(567)+"ffLine"]))}["_addWsLi"+n(928)](){let t=n,r=e[t(440)][t(1708)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(563)][t(1690)+"Listener"](e[t(1016)],this[t(353)+"ge"]);continue;case"1":this[t(563)][t(1690)+t(1624)](e[t(401)],this[t(223)]);continue;case"2":if(!this._ws)return;continue;case"3":this[t(563)][t(1690)+t(1624)](e[t(1055)],this._onOpen);continue;case"4":this[t(563)][t(1690)+t(1624)]("error",this._onError);continue}break}}[n(1603)+n(743)](t=1e3,r=""){let a=n;try{this[a(563)]&&this[a(563)].close(t,r)}catch{}}[n(1423)+n(365)+"t"](t=1e3,r="",a=!1){let x=n;if(this[x(1656)+x(1433)](),this[x(1549)+x(1572)](),this[x(772)+x(723)+"rs"](),this[x(1603)+x(743)](1e3,r),this[x(340)+x(1693)]=!1,a&&this[x(1322)+x(1559)]()&&!this[x(1041)+"osed"])if(e[x(293)](e[x(1539)],e[x(824)]))this[x(921)][x(1488)]&&_0x1e09da[x(1071)].apply(_0x52b0da,[e.ESOnb,..._0x2206b2]);else{if(this[x(1407)+x(914)]?.checkReachMaxTries())if(e[x(1469)](x(1090),e[x(902)]))try{this[x(563)]&&this[x(563)].close(_0x31aa26,_0x3a74d0)}catch{}else{let p=this["_endpoin"+x(914)]?.[x(809)+x(277)+"nt"]();this[x(1155)+x(1538)+x(560)](e[x(1312)](be,e[x(401)],{code:1006,reason:x(299)+p+(x(948)+x(1409)+"tries reached"),wasClean:!0}))}else{let p=this._options["reconnec"+x(519)+x(1089)](t,r);this[x(1155)+x(1538)+x(560)](be(e[x(401)],{code:t,reason:r,wasClean:!0,willReconnect:p})),p&&this._connect()}return}this[x(1322)+x(1559)]()||this[x(1041)+x(247)]?this["_dispatc"+x(1538)+x(560)](e[x(630)](be,x(616),{code:t,reason:e[x(785)]})):this[x(1155)+x(1538)+"ent"](e[x(716)](be,e[x(401)],{code:1006,reason:e[x(635)]})),this._ws=null,this[x(1407)+"tManager"]?.["resetEnd"+x(1042)+"fig"](),this[x(952)+x(195)]?.[x(837)+"nter"]()}[n(1155)+n(764)+"nt"](t){let r=n;this.emit(e[r(1055)],t),this[r(617)]&&this[r(617)](t)}[n(1155)+n(722)+"Event"](t){let r=n;this[r(1170)](e[r(1016)],t),this[r(900)+"e"]&&this[r(900)+"e"](t)}["_dispatc"+n(1478)+n(747)](t){let r=n;this.emit("ack",t),this["onReceiv"+r(1719)]&&this[r(675)+r(1719)](t)}[n(1155)+"hErrorEvent"](t){let r=n;this[r(1170)](e[r(697)],t),this[r(810)]&&this[r(810)](t)}["_dispatc"+n(1538)+n(560)](t){let r=n;this[r(1170)](e[r(401)],t),this[r(898)]&&this[r(898)](t)}get binaryType(){let t=n;return this[t(563)]?this[t(563)][t(1111)+"pe"]:this[t(1213)+t(572)]}set[n(1111)+"pe"](t){let r=n;this[r(1213)+r(572)]=t,this[r(563)]&&(this[r(563)].binaryType=t)}get[n(798)+"nt"](){let t=n;return this[t(1407)+"tManager"]?.["getCurre"+t(277)+t(406)+t(893)]()||0}get[n(1453)+"Amount"](){let t=n;return this._messageQueue[t(845)]((a,x)=>(a+=x&&x[t(1630)+"th"]||0,a),0)+(this[t(563)]?this[t(563)][t(1453)+"Amount"]:0)}get[n(873)+"ns"](){return this[n(563)]?this._ws.extensions:""}get[n(1074)](){let t=n;return this._ws?this[t(563)][t(1074)]:""}get[n(489)+"te"](){let t=n,r={KXdkI:function(a,x){return a!=x},WnOHH:t(1096)+"d",oyBgk:t(262)};if(e[t(388)](e[t(472)],e[t(472)]))return this[t(563)]?this[t(563)].readyState:this[t(921)][t(1649)+t(1219)]?this[t(527)+"NG"]:this[t(610)];_0x572ded.r=a=>{let x=t;HPuUGi[x(307)](HPuUGi[x(1192)],typeof _0x1673e0)&&_0x19a362[x(175)+x(382)]&&_0x5d48e0[x(1356)+x(901)](a,_0x274ea8["toString"+x(382)],{value:HPuUGi[x(1548)]}),_0x2af696[x(1356)+x(901)](a,"__esModule",{value:!0})}}get[n(1279)](){let t=n;return this._ws?this[t(563)][t(1279)]:this[t(488)]}[n(616)](t=1e3,r){let a=n,x=e[a(1116)].split("|"),l=0;for(;;){switch(x[l++]){case"0":this[a(363)+a(711)+"Listener"]();continue;case"1":if(e[a(1058)](this[a(563)].readyState,this.CLOSED)||this[a(563)].readyState===this[a(1175)])return void this[a(1272)](e[a(525)]);continue;case"2":if(!this[a(563)])return void this[a(1272)](e[a(637)]);continue;case"3":this["_QoSMana"+a(306)]?.[a(1037)]();continue;case"4":this[a(1549)+a(1572)]();continue;case"5":this[a(1041)+a(247)]=!0;continue;case"6":this[a(1423)+a(365)+"t"](t,r);continue;case"7":this[a(1656)+a(1433)]();continue}break}}async send(t,r){let a=n,x={PEPKk:function(B,re){return e.gQmaN(B,re)},xjXto:function(B,re,ve){return e[P(312)](B,re,ve)},qiRWE:function(B,re,ve){return e.dwFDS(B,re,ve)},HzOlA:function(B,re,ve,Be){return e[P(415)](B,re,ve,Be)},KNRkq:function(B,re){return e[P(174)](B,re)}};if(e.rcjNY(null,t))throw new Error(e[a(538)]);e[a(1352)](e[a(628)],typeof t)&&(t=JSON[a(828)+"y"](t)),e[a(511)](e[a(826)],typeof t)&&!(t instanceof ArrayBuffer)&&!(t[a(819)]&&e[a(1047)](t[a(819)],ArrayBuffer))&&(t=JSON[a(828)+"y"](t));let l=await e[a(1610)](qi,t),p=e[a(1600)](u0,t),{method:g=0,service:d=this._options.service,logID:_=this[a(921)][a(913)+a(1681)](),headers:y=this[a(921)][a(1140)],payloadEncoding:v=this._options[a(1405)+a(648)],payloadType:I=this[a(921)][a(980)+"ype"],logIDNew:k=this[a(921)][a(1186)+a(1026)][a(624)+a(1346)+a(305)+"ew"]?e.RVYfL(o,this[a(921)]["logIDNew"+a(1026)][a(1104)]):""}=e[a(1286)](r,{});if(!d)throw new Error(e[a(1064)]);let L={SeqID:j[a(1138)+"er"](this._seqId++),LogID:j[a(1138)+"er"](_),service:d,method:g,headers:y,payloadEncoding:e[a(760)](v,Object)?v[a(1717)]?v[a(1717)]:"":v,payloadType:e[a(317)](I,Object)?I.type?I[a(999)]:p:I||p,payload:l,LogIDNew:k},J=e[a(1522)](wr,L);if(this[a(563)]&&e[a(287)](this._ws[a(489)+"te"],this[a(1102)]))if(e[a(1450)](a(623),e[a(1636)])){let B=0,re=[];for(;WlQUTO.PEPKk(B,_0x1650ca[a(1630)+"th"]);){let{offset:ve}=WlQUTO.xjXto(_0x48ec7a,_0x3d4942,B);B=ve;let Be={cursor_name:"",cursor:0,service:0},{value:an,offset:Mt}=WlQUTO[a(660)](_0x4c4ddb,_0x23ae20,B);Be[a(1216)]=an,B=Mt;let{value:cn,offset:zt}=WlQUTO.qiRWE(_0x20f2a0,_0x5588d7,B);B=zt,Be.cursor_name=WlQUTO.HzOlA(_0x20d1e4,_0x189077,B,WlQUTO[a(766)](B,cn)),B+=cn;let{value:Ft,offset:H0}=_0x36896c(_0x51aa75,B);Be.cursor=Ft[a(1457)](),B=H0,re[a(636)](Be)}return re}else this[a(563)]&&this[a(563)].send(J),this[a(1272)](e[a(895)],L);else e[a(332)](this[a(780)+a(1579)][a(1309)],this[a(921)][a(1311)+a(160)+a(1100)])?(this[a(780)+a(1579)][a(636)](J),this[a(1272)]("enqueue",L)):(this[a(780)+a(1579)].shift(),this[a(780)+a(1579)][a(636)](J));return{seqID:this[a(543)],logID:_,logIDNew:k}}async[n(200)+"t"](t){let r=n,{url:a}=e[r(520)](t,{}),x=Array[r(655)](a)?a:e[r(1421)](e.EteAL,typeof a)?[a]:[];t&&Object[r(661)](this._options,t),x&&x[r(1309)]?this._endpointManager=new Mi(x,this._options[r(645)+"es"]):this[r(1407)+r(914)]?.[r(289)+"pointConfig"](),this[r(952)+r(195)]?.[r(837)+"nter"](this[r(921)][r(1444)+r(1730)]),this[r(1041)+"osed"]=!1,this[r(563)]&&e[r(508)](this._ws[r(489)+"te"],this.CLOSED)?this[r(320)+r(1125)](1e3,e[r(1509)],!0):(this[r(740)]=!0,this[r(340)]())}async[n(978)](){let t=n;if(!this._connectLock){let r=e[t(629)][t(1708)]("|"),a=0;for(;;){switch(r[a++]){case"0":this._isInit=!0;continue;case"1":this[t(952)+t(195)]?.[t(837)+t(231)]();continue;case"2":this[t(1041)+t(247)]=!1;continue;case"3":this._connect();continue;case"4":this[t(1407)+t(914)]?.[t(289)+t(1042)+t(297)]();continue}break}}}["addEvent"+n(1624)](t,r){this.on(t,r)}[n(530)+n(1472)](t){let r=n,{type:a}=t;this[r(1170)](a,t)}[n(1614)+n(1475)+"ner"](t,r){this[n(801)](t,r)}[n(283)](){let t=n,r={IdREL:function(a,x){return e[P(194)](a,x)},xeXBC:"PdPMa",ByxxB:"KKNFL",GJWKh:function(a,x){return e[P(1106)](a,x)},gTQGA:e[t(1633)],FOPER:"ping_onc"+t(492)+"s"};return new Promise((a,x)=>{let l=t,p={ICOxf:function(_,y){return e[P(657)](_,y)},AlPfK:function(_,y){return e.PBxGz(_,y)},SsmVT:function(_,y){return e[P(1061)](_,y)},ahMyM:e[l(1237)],uSvnV:e[l(294)],CKViQ:e[l(1225)]};this[l(1656)+l(1433)](),this[l(1174)+l(351)+"Id"]=e[l(1366)](setTimeout,this[l(451)][l(1013)](this),this._options["pingInte"+l(891)]);let g=()=>{let _=l;r.IdREL(r[_(1540)],r.ByxxB)?(r.GJWKh(a,r.gTQGA),this[_(801)](r.FOPER,g),this[_(801)](_(1443)+_(1262)+"t",d)):(_0x8f21eb[_0x4f933d++]=MwBEVf[_(207)](MwBEVf[_(1373)](MwBEVf[_(217)](_0x594ed2,18),7),240),_0x1e9f27[_0x18ad22++]=MwBEVf.ICOxf(MwBEVf[_(1373)](_0x3ec2fa>>12,63),128))},d=()=>{let _=l;x(p.ahMyM),this.off(p.uSvnV,g),this[_(801)](p[_(238)],d)};this.on(e[l(294)],g),this.on(e[l(1225)],d),this[l(451)]()})}}})(),Q[C(350)+"oseEvent"]=X[C(350)+C(471)],Q["CustomEr"+C(977)]=X[C(1428)+"rorEvent"],Q[C(281)+"e"]=X[C(281)+"e"],Q[C(1472)]=X.Event,Q[C(1615)]=X[C(1615)],Q["Frontier"+C(1169)+C(1619)]=X[C(939)+C(1169)+"vent"],Q[C(1169)+C(1619)]=X["MessageE"+C(1619)],Q[C(887)+"t"]=X[C(887)+"t"],Q[C(724)+"tEvent"]=X.ReconnectEvent,Q[C(1430)+C(471)]=X[C(1430)+"oseEvent"],Q[C(1239)+C(977)]=X[C(1239)+"rorEvent"],Q[C(580)+C(1376)+"nt"]=X[C(580)+C(1376)+"nt"],Q[C(1580)+C(1327)]=X["createOp"+C(1327)],Q["createRe"+C(449)+C(1619)]=X["createRe"+C(449)+C(1619)],Q[C(827)+C(373)]=X[C(827)+C(373)],Q[C(1659)+"ame"]=X["encodeFr"+C(1586)];for(qn in X)[C(350)+C(471),C(1428)+C(977),C(281)+"e",C(1472),"FWS","Frontier"+C(1169)+"vent",C(1169)+C(1619),"OpenEvent",C(724)+C(1113),"createCloseEvent","createEr"+C(977),C(580)+C(1376)+"nt",C(1580)+C(1327),C(166)+"connectE"+C(1619),C(827)+"rame",C(1659)+C(1586)].indexOf(qn)===-1&&(Q[qn]=X[qn]);function Jn(){let n=["ueLluM0","q0f6rNq","wwLMvhC","yw51Ce1LC3m","t25OqxK","C2fzBxq","q0nQC2y","s1zMu0O","sM5AsKK","mJi3nM9hDvH2CW","BgjgAMu","y2jtvK8","v3Hiyu0","y1fUAMO","u2vXsuq","rffUy2y","qNPVsK4","AgPsrMO","DNDOs1m","BxPqtw0","Dxrjza","ue9rshq","vKDRvMO","Cw5Yt3m","AMr1C3e","zMLmvfq","C29VEfu","wwjluKK","sePeEwe","AenSB3nLrxy","EvDkzNu","EgvyqKm","AhLiCfG","svnXrfy","vePsvwy","zMLSzw5HBwu","Bxfgz0C","t21xtue","nxW0FdD8mhW","B3Lcz2S","x2nSzwfYvgK","DgfYz2v0","B25tDg9Wsw0","uhrvCeG","AMTewvu","thjqDNa","DgnuzhG","uNn3vve","z2vjBMzVu3K","Dw50","B3jpBMXPBMu","Bef2qxm","tfLdvLe","ruPUrM8","tNn6vMq","tMLdy2O","uwL3thu","q3fsCKy","BNPuCLC","z2v0u3rVCMe","DNDtDgO","tg9NsurozxC","CM92AwrLihC","BwvY","zcWGDw5RBM8","DNLfvxm","Cu92qxe","Aw9Ul2PZB24","CMvZB2X2zq","twnqsxq","uxvLDwu","y3jLyxrLt3a","tMP6Awy","B25ozxr3B3i","CNjVCK1LC3m","CMfTugfYyw0","z0Xqvue","yw1L","AgfUz2u","DhznrNK","rKnit0W","ywXSB2nvBNm","z2u6ia","u1bOt20","BMvY","BhrPCgXLihq","AhbQwfG","zuzWBva","D0Pzvwq","wwfpCMy","zxjYtxnN","AgDku1i","q0n4sui","s29Ytfi","x3DZsw5ZDge","shfryLi","DMfcAgW","AKrUwNC","B2nRzxrtDwm","x19LC01Vzhu","CgfZvwm","r1Lit2m","C3vIBMK","CgfYC2u","DMfSDwu","CMvTB3zLrxy","rLDt","C3vJy2vZCW","ug9KB2G","tg9Nsuq","DMvUDa","yxbWzw5Kq2G","B1LtsKu","ufrvEM0","zeT0EKq","tgLZDgvUzxi","twTnDKO","CMvWBgfJzui","zw1Jy3y","ruruwey","mhWXmhW4FdC","yNL0zuXLBMC","ywrK","CMvZDwX0","vejoEwm","y3PXwvm","qMr1vvO","Aff3rxi","ywnRDxbfBMq","B0rKAxa","Aw9U","CvDAsg8","y2Pvq2G","qvr2teO","zvbYqxK","ANLlCMm","yxLyu3O","Bwf4tg9ZC0m","BuDxu1u","uMjKAeO","yxv0B21HDgK","x3bYzwzPEa","EsbJBg9Zzwq","C2HPzNq","vM9srNq","Aw5PDcbrB1m","s0P6BhO","x2nSzwfYugK","yNv4sKK","z2DmALa","zw5JB2rLrNi","yw10whq","rhDADeS","AMPmz00","C0jf","q0HHsKm","DNnWzuW","u05hCuO","C3rkrwm","C3vIyxjYyxK","ywDLu2HVDW","sKXStfi","EeXszLC","yM9xEwy","CxzOzLm","zxH0ugf5Bg8","AvvmENy","AKPYtu4","y2XLyxjtDg8","zvLMyM0","y3vYCMvUDeK","zvHJBwy","zxjHDg9Y","ywrKt25L","yxbWBhK","vK1rzeq","A3bmv3K","wePNyKO","uuH2BNK","BfDhr1m","tNH3q2e","ywrKrxzLBNq","Aw5N","wwDjruy","tg9JAW","tuPVuhu","u3botNa","C2fZv1e","CgLUz0LUDgu","u3DSExu","mhW2Fdr8n3W","qKLiqKi","s1fuqxm","zwrPyxrLBhK","zNPZuhu","r2LgChi","wK5jthK","ChjVDg90Exa","EwzLwvq","C3bSAxq","u3L3ug0","y29Uy2f0","BNrbBMrvCgq","y2HLy2TdDxi","BM1fDeS","CxzUwLC","yuTuAxi","DLLhzwW","zw5JB2rPBMC","AgfZ","zufJAW","r0jZvgW","s0LNy0O","t3H6A0S","mtb8n3WYFdG","Bw5UCfa","rgvKAwnHDgu","q01MD0W","DeLK","wKTzBLe","tLvIExO","q291BNq","y2uGBM90igK","sgv4sw8","Aw5KzxHpzG","u2r1B0e","Dgv4Dc9Qyxy","Aw5KzxGGB3u","s0HowK0","z2vrDwv1zuW","DwrVDhi","q1Lwsxu","wfnzs3q","CNbqtvO","CerlDNa","y3jLyxrLuMu","qvr5tNe","ALrZz0C","uNHkr1i","zMXVB3i","BujxCee","m3WYFdr8mhW","tKzXD24","sxrVq0m","Dg9tDhjPBMC","t2vOCu0","Du9vvMe","vLDgEhK","uM5Qrey","sMz6r2e","nhWWFdj8mxW","AuLqELO","BwLUAvbYB2C","wwDQqxi","u0TfruW","Ee9etwm","quPlwxO","DhjPzxm","zMzMzG","qurswe8","tgLWsfa","CMvHzhDYAxq","vhvfq2O","B3fWwMO","C0nVDw50zxi","wNf1EKW","mteZmdG4m05Huw1nrq","zxmGCMvHy2G","BMfTzq","CMvJB25Uzwm","vfnHu3q","ELHiBLm","re5gueC","DgrPr2O","z2v0","u0jQC0e","sunpEgy","CMvHzg9UBhK","CfnLqvK","DxbNCMfKzw4","AMfeCva","qvbeqNq","v2LUzg93","B3jLtMfTzxm","Cfzpvw8","ywnRx2nVzgu","u3nTvLq","DhfHzg4","x2LZqNjVD3m","DNHtCKW","ywWGy3vYC28","tK9eDxa","x29Uq2XVC2u","z1vRrvq","BePqrM4","A3jLugS","uLLAugy","zNbgzLq","rKLmrv9ot1q","A2ztBNq","BNrLCG","v2fqt2K","rfHPDfK","zw1LBNq","C2v0sxrLBq","s1vIBee","seXns2q","q0TwAve","m3W0Fdf8mhW","ihrPBwvZ","yxKSihrYEsa","DgLTzw91DcW","EvjLy29UBMu","y2vZC0HHBMq","BfHWvNO","z0fxEeq","B3nLza","sxHUvKu","yxrHlcbKyxq","zgv2AwnLx2K","vLLOuKy","uNfQqNe","CfvuvgS","zgvS","y2XLyxi","u2vYDMLJzvC","BeHHBMrSzxi","AwXLtMfTzq","Efrurw52","A3rSDg0","CLzHBhvLCW","tw9KDwXL","uxPLDgG","yu5bsgi","zxjFywnRx20","zuLAD2K","vNr3C2e","x2TLEvbHDgG","y3zjyvO","q2votem","AxnszwfKEq","sLjIEuW","x2LUAxq","nhW1","zM9Yy2u","zgfMzee","BNrfBMrWB2K","Aw5KzxG","sKrPAw0","ywXS","rxjYB3jdB2q","t3PJzeW","CgLUz09Uy2u","B2nRzxq","Cg9PBNrbBMq","rKXIB0C","EeLPBNe","mdaWmdaWmda","CMvZzxrfBMq","Dw5ZAwDUzwq","rg95CwO","AhbUB04","t2zUuxC","C2v0z0i","tvvtAei","rMzUtKC","zMLN","yu1eB2q","y29UBMvJDca","suL0suy","vhrArgq","A21zy0G","s1rtzue","pxv0zI04","DgvmB2Djre4","z2vY","s1HKA0K","vffpEuK","CwPQDgG","rLj2EeO","BNbxEgG","vgvTqvG","uK9OAei","BMDLza","zMLUza","Bwu6ia","EvfHruy","uvDqDKi","De5AB3u","x2rPC2nVBM4","y29UBMvJDfm","tu9Iyva","yxGGCMv0CMK","C3rYAw5N","CgvYC2LZDgu","DwfOt3C","BgLUzw5V","uevVsK8","CMTLCKDSB2i","yw9kq2C","v1jmuKy","wxr4C2G","s1HKruK","Avnoz1G","veTYvgW","zu1dAwW","BgDRCxu","B3jRzxjhBg8","y3vYCMvUDeu","x2nVBM5Ly3q","DgLLCKPtt04","B2nRzxrgywK","wgHks0G","tLbLDfi","DLz3rw0","D3nXugW","zu9Nz1u","ywzL","q25Vq1y","q3vZDg9Tq2W","z1rPBwvVDxq","zhHuvNG","x29UtwvZC2e","Aw94qKO","y3jLyxrLt2i","D24GCMvHC28","yNL0zu9MzNm","ywX3yxLZ","BLnZzLG","BeXOrKO","zgrjrcWGzgu","zLroCei","x2rYB3bhBg8","yw5ZzM9YBvq","v2vIu29JA2u","tufyx1jfvfi","DhbizwfKzxi","qK5lCee","yw5Nzq","uwDxAMi","vvjmA0y","tfPcEvC","CMfTzq","z1vbAeu","B0Lwrxy","C2vqyvy","Ec1TC2CTy3u","ohWZFdr8nxW","zw5KCg9PBNq","sK15BNK","Dg9mB3DLCKm","vgfN","FdD8mhW2","BhHxyM8","rMvwufK","zwT0rgW","ywXSq3vYC28","CKHYrLu","DezhuLO","u1Dgsw4","y2HHCKnVzgu","rKjurM0","uNDowgu","m3WYFdb8nhW","yw1Lu3bHy2u","y2HLy2Tszwe","whDXC1y","Bvb3C2S","B2nJEg8","z2v0q3vYC28","ELnSAfK","zgvSzxrL","zxjFCw9Z","B25fCNjVCG","swneuKK","BNruCMLLC0m","v1PjDgq","C3rHCNq","D3jPDgvvAw4","C29YDa","AxnAzxjV","tvPoDhi","zwPSENO","C3DTExG","zKTjBhu","AK9tAwu","twLss1q","AgvHzgvY","ExrsExO","Afnszxi","x3bHDgHlzxK","D3m6lY8","Ae1mq08","zwvKzwq","ufLKsMO","Dg9cExrLC0W","BwLZzq","EeT2tgC","DLfOvMm","swfgDNm","EvLeC1K","r1HLCvq","C2vYDMvYvgK","uhbyswy","Dwz2vxu","s25KAu4","BhbqBum","x3fVC0rc","zwXXywK","DNHNweu","AMjHz00","BwvZC2fNzv8","mNWXFdn8mhW","ELzws20","wgzSt1i","y291BNq","B1Dwsu0","yxrLq291BNq","y29UBMvJDeu","yM9KEq","x3bPBMC","x2n1CNnVCK0","A2XyEM4","zgDLrfC","zw5HyMXLuw8","rwPAAgu","q1fishm","qKTSuuS","zxjFDhrS","C2nYAxb0","tKnjt3y","zNboqve","u2nxAhi","C3vIC3rYAw4","D0jjwg0","mNjfqu1HCa","x0vysvnu","vKP3Dwm","z3zTq3i","rNbRy0i","B3nLrxzLBNq","B1zgvNC","B3bLBG","vw5Oyw5KBgu","A0Pmsxe","DgHLBG","BuTzEge","zgvSzxrLrge","BxvwAw8","AfjSr0W","BMTWDNu","CKDjDLy","x2LZv29YA2u","sKnbChm","y29UBMvJDgK","DhPxrfa","vhf4tLm","x3vYBa","CMvHzhLtDge","AxnmB25N","wM1sD2K","zv9ZDwnJzxm","qwvoyKe","CLvxB2S","CMvJzxzPzwq","Ce5nvMm","BgzNDLu","ELzhDuO","teTTthG","u2HHCMvKv28","CeTrvve","rNj2Bfi","zM1Uyu4","wxDbtfq","sxP0z1q","nhWXFdj8mhW","uu55rLm","EwDIBMG","B25tDgfYDfi","vLrwANO","CKTkrwK","DhHZANu","AvPYBLa","EKzhrgO","CNnVCKzPBgu","EML6DeS","C29Tzq","sgLxAwS","DeLUDgvYy2u","sfv4C3m","ELbIDe4","AMfUrKi","yKHVz2G","wffAELe","ww9pC3O","zvnpseq","q09otKvdveK","uffPvMm","u25xsvy","zgLZCgf0y2G","x2zVCM1HDeu","rNnfzMS","txfIsvC","BwfUDwfSihi","wejYt2W","BLvpCwe","A3z0thK","Ehv0Aem","BMrWB2LUDca","s1ritwW","v1LNwwu","zwnVBM5Ly3q","x3nLCuLK","yLjSrfa","zKn4tKK","vwr5qvy","ALjqzu8","y3vYDMfSDwu","tgLRrKK","txL2rMq","Bevnq00","Ew9KseO","r2fjCKS","m3WXmhW4Fdi","zNDZxZeUmc4","ugPqrMq","zNjVBujPDhm","x21PBMLoyxy","zNjVBNrPzxi","zw50","tK9MBLy","BwzMr3m","x3DZ","tuvYA24","B25mAw5L","qwPrzMu","x2HHBMrSzu8","yKzHyKO","vw1vA3q","yvfuy1u","BM5Azeq","ExbL","qxbosKu","v0fluxm","CgXLyxnLiha","x2LUAxrqCM8","ze5rEui","y2f0y2G","x2LZtwLUAvq","y3jLyxrLtwu","vxvQueu","BNb4B1i","B0zNEfm","sMT5y3K","zhjbDgy","ANzIreW","AMrpvKW","yw5Hz2vY","B25Nywe","y3buzNu","rKvewNu","uhjPBwfYEuS","rM1Osem","rePTAuS","s1zIC0q","CKnvsxG","C3bSAwnL","sLnptLa","qwjVCNrfCNi","rLvrCfy","zgjruuS","BezwBw8","yMXVy2TLza","DhjPBq","wxfKs1G","Ag1yAMO","y29TCgXLDgu","Dhr3Awq","qw1VDw50","q0Xpu0ve","s0Tlq3e","te5LrMy","l3DZl3yY","Cgu6ia","vwDRzg4","y2XVC2u","B25VCgvU","qKrJAuK","yxjYyxLIDwy","zxjFBxnNAwq","yMrFzgLK","A1f2Bhi","wLrIBgS","zw5HyMXLqxu","x2n1CNnVCKy","DxrVuMvJB24","EgX6t2i","yK1wwuO","r25RzKi","DeXsq2W","rxL1z3e","zxjYtM8","EK9zuuC","qLjnC1O","BeD0u2K","ChvZAa","vxLWq24","yxHAzKe","Dg9Y","zMvY","z3vbwKq","mtjKtgPRALK","C2v0","tKfusvzfx0u","Bwf4uMv0CMK","C3jJ","r2LbDuC","BMnVzgLUzW","zw5HyMXLvhi","tvj1yKG","A1n0yxr1C0m","CfjzAK8","zffSvgK","C0DQwvC","AxnbCNjHEq","AeLNDNK","uhfKsMq","zMX1C2HfEha","yNL0zxm","EgPyDg8","yxnZAwDU","x29UugfNzu4","rgDozK4","uwfNzNK","sxPwyva","BezUA1i","rKndugi","q3nvDhq","sgX2sem","CeXdEeC","ufHXrhG","ywr2yw5Jzq","BfnSuue","thDiD3K","B25szwnLAxy","ysbTDxn0igi","y0DrqNO","Ag9gDuW","D3LjD0C","y2HnyxHdB3u","ywnRpwzYB24","rgXdvhq","BwfOC3e","veTPsvG","AefWEwW","A3PgyMO","AM9PBG","AgvKtwf4uMu","yKPXCue","BwLUzW","EvrWtvO","A0Hmr0C","FdL8mhW2","twHZwvK","zMzLCG","Bg9IywXty28","zgPABLq","AxnFywnR","B25pCgvU","Bejzrve","s1vRvhC","zxjFAxnFywm","DMvY","we1IDe0","BMv3vMvYC2K","x2LZtwLUAvC","EvvQuNG","yLnPBMG","C3jWCK4","sxnOwgG","yMfSrxzLBNq","ueHzr1C","CNnVCL9Uyw0","qLvVsMm","EuT1wwS","D3jmyxK","y3vZDg9Tshq","A1HIBKq","yMfSu2nVCgu","AfzvELy","BuXYBKq","Ae1LC3nHz2u","C0XPC3rLBMu","uMvJB25Uzwm","vgLkvLi","sK9uy3a","BwvZC2fNzq","vMzhtfi","ywDLsgLKzq","AhHju3K","qxP3r2e","yMvgzgK","ihzHBgLKihm","r0TiAvC","ww11Bxm","DhjPzxmGCMu","qNHnr28","Axnbr3K","BNvxrhC","x2LZsw5PDa","CM1mqLK","u096z0C","BMnLq2XVC2u","CMfNzvn5BMm","uvHVB3e","CfnAsM4","ywDLrxzLBNq","rLPxqwe","ignVzgu6ia","tgXPrfy","x3bYB3rVy28","wvLsqLi","Cgz5ANK","CNzHBfzHBhu","x1fVu01HBMe","y2HnyxHuCMK","ywXPzcb1CMW","vuT5vwi","wvvgC1G","v3rVA1q","EgPYvKG","CxrkBeG","ihbYB3rVy28","Ae9Wzw5fDMu","AgLIyxa","s05sA3e","rKfuD2q","ntiXotiZyKrYEK5Q","y29UC3rYDwm","aaaaaaaaaaa","Bxj1t1u","x3jLBw92zvC","D2vI","C2XPy2u","CfHUsKq","ihjLy29UBMu","Dhj1y3rVCIa","r1D3AhG","zg9Uzq","x21LC3nHz2u","vgTuEuK","rg9YzwW","sMvYv3y","Bwv0Ag9K","senotxy","DxbKyxrLq3u","CvrHzu4","Du9vDvu","DgHHBIbSB2m","Ce5gywS","AwXK","ufL6AK8","whr1svi","B25Uzwn0Aw4","uu56AgO","ywDL","r05eugy","CMv0CNLdB3u","yKPwDMm","wLfxEhq","B2zM","CMvUDevUzha","BKXPBMu","ywjiBe0","teTTz00","t0nouxi","igzHAwWSig0","x2XPC3rLBMu","z2v0q3vYCMu","B25LCNjVCG","tKDFrvjst1i","BM9Htui","q3n2uei","vuXjCxy","rvHOzuW","qM16B1q","svnVEue","DMvYC2LVBMm","yNvMzMvY","x2HHBMrSzvi","suvtx0vsuK8","CgLkDNa","r0rlwxq","B1DLsNm","rezhDge","rxrLquW","zgvJB2rLzey","C3rYAw5NAwy","v0Tcs24","ywnOzwq","BgvY","Dg5pDfy","CgfNzwHPzgu","whblq20","ELf5BfG","t0TYyNa","CMvZzxrdB3u","AMP1BM8","rfHYDha","BM93","D3nkzvC","Aw5JBhvKzxm","uMzNz1q","zgLZywjSzue","CMvKDwnL","zg1SAfu","BKjmA1G","z2v0qwXSs2u","uxfwu3a","B2zMBgLUzq","DMDKq2y","CM92AwrLigi","rvH5vK0","AwDHDg9Yt24","AKflzeG","BgLUzq","DuzIyLa","CLPQzeG","EvvvsxO","txnnsKO","vuXQuNK","ANPrANi","CMz4vLq","D2LSBfjLy28","u1fSALi","sNzHz1G","EunkvKi","r25NyLu","vxbKyxrLq28","tgvRy1K","A01OB0O","uNDVz1K","zxH0zw5ZAw8","zwzJrNO","rvnpBMi","Dgv4DfbHEwW","B2XKvMvYC2K","v2vPEgLUsLm","zfbmtfa","uxD6wNq","C0Xf","wxbXAvO","vufJzxO","quTuz0G","Eg5Iue0","mtG4nuvnBwn2yW","t3bLBKv2zw4","v1DZwuG","Dgfwr20","y29UDgv4Da","CNzHBa","AxnrB1nby2S","B3vUDa","BNHfB0K","vxfluLC","Cwv6suK","zw5dwNK","B25JBg9Zzq","ugf1wxG","B25TzxnZywC","B3bLCNr5","DKLIvvK","rND1AKO","DgLTzw91Da","C2v0u3rVCMe","zxHWB3j0CW","z1jdu0O","B3nqEgS","yMLUyxj5","yK1jwui","D2XRBNy","x0rctMfTzq","Bg9Nsurhzw4","De1HBMfNzxi","C2vYDMLJzs0","CIb0DhDjra","Evrwru4","AwDrCMW","uvzcDwC","rujoseW","x29WDgLVBNm","tNLmse0","rhHnBvq","rNP1ENi","DMn3rxC","Cvj3rLq","AMTZvgO","C3rLBMvYCW","nxW0Fdf8oxW","qMjUq3C","vvf6BM4","swXJtK4","BMrLEa","Chfjzhi","wwXiq24","v09Mu2m","DMzLB3a","y3ruAw1LB3u","rNjVBNrPzxi","q0vtBuW","t1v3Duy","ww5yshK","svPnr1y","DMLJzuLeig8","C2LMweK","zxf1ywXZ","swHMCwC","ihrPBwvVDxq","qvzJBxm","vK56r28","z2v0s2v5","x3bPBMDmB3m","BwvZC2fNztO","yMfJA3vWigu","x2fKzfDZtgK","zgf0yq","CNnXqui","EgfgvKO","sMLhqMG","y2jnC1u","DfPzExK","zu9VzvC","CgjICdi","yMPXChC","x3nVy2TLDa","ihrVihjLDhi","DgzJD3y","CYbHBhjLywq","BwrttgC","vxrRCwe","qwn1zMO","CgvetKq","D1j1rha","BMP1vLK","BLrAtNa","wxfjDvG","CM9YrxzLBNq","y29UBMvJDa","mNWX","Cgf5Bg9Hzfq","y1DuweO","BgjPsLG","zfLmtwG","rffwwwC","tMfTzq","zMzmAw5L","zxrxB3jRq2G","B05ZrM8","DxrRzxG","y3vYC29Yx24","swvlB1m","sxznzwS","DgvZDa","uvftBMO","x2DLBMvYyxq","Aw50zwDLCIa","zhrlufG","D3jPDgu","DhLWzq","sMrdA2i","s3flyxi","y29UDgLUDwu","CfL3zKS","u1rbA2C","nhWXFdb8nxW","uvvjAgK","DLbmC1O","ywXSzwqGBxu","DxDHwuS","q0LUqwC","uLjpuG","ywrKq291BNq","yMLUza","Axfetgm","uxjPv04","s2jHBLq","B3v0sw50zxi","DhjHBNnHy3q","wM15seW","Dg9VigXHCMC","ANrcA2q","r29uA28","C2Xhu0i","x2LUDgvYDMe","uxrkD1O","q29UzMLN","y1D0Cwi","yxHZwuS","Berhvfm","uu5Iqwu","yxnJCMLWDa","vK9zwxG","BLfMDwC","x2HHBMrSzva","wg1wte4","t2XsqwG","y2XVC2veqG","Bvvhsxa","y3vYC29YlNm","BhDqCM8","x3jLywr5q2W","Cg9PBNrdB24","C2v0y3vYC28","CMvHC29U","BMHfC2e","Chf3zNm","v1f5ywK","quHnquS","rLjptLrjrvi","DKLrC0i","D3nov2C","CMvWBgfJzq","su5tvefova","y2fSBa","tuTdyui","BfPNAhm","A2v5","wxDntvG","BgLZDgvUtMu","ug1UENO","veDHCge","C1jfD0G","y2XVC2uSihC","zKfyrhK","B3bLBKrc","v2jjrKe","ywnOzwqSihC","ChfjBNO","t3vAwwy","CMvJzwL2zwq","Bg9N","sxL0A1O","werRAwq","ChjVDg9JB2W","zg5fAuu","BM5Ly3q","BwvKAwf0zwW","x29UrxjYB3i","yLL1sNa","ChjVy2vZCW","uxHkA08","DMnxD2G","zxjFCw9Zx2e","BeXeCwe","uM5Tuxq","B3jRig9MzMW","suvhAe0","EwDoB3G","ChrVCG","vK9KyuG","Bhm6ia","t2Tkyve","veH1vuy","id4G","qKfRzfC","Dw5KzwzPBMu","uM5PBee","qKn5Dfq","zNjVBuHHC2G","zw5NDgG","vxDuEeu","t1bftG","s3bhveq","DxnLCKLW","y0TfAeO","ufzTsxG","zgv3DNC","vfHeu1q","C2fdwM4","qu1nzhm","yMLUyxj5vhK","EKnnEfe","Dev2zw50","CK5qEva","AgLxqKu","EKrYAgK","BgLLDxy","zxq9DxrMltG","A2rbzva","AxbcD0W","C0z3Dxy","x2LUAxrhBg8","yvzfzeK","z2v0sxrLBq","zwn0","zfPcuK8","B2zMC2v0","wurhwui","yM5lzwy","AxnrB1nnzxm","Be5cDw4","lcbxzwjtB2m","B25dBg9Zzq","reTmufa","BxnYquC","rg1Vtvu","txLAAvy","zNjVBu51Bwi","whDRDNG","AgvHzgvYCW","C2fNzq","rLf1zuO","uMvHzcbWyxm","mJKXmJu2nZLMrwTsEK8","C0TZruW","v0HPA00","DLvIrMm","wMjgwMS","zfb2B3e","z21kuhe","sgntvge","u1HAwMC","zeLeD0W","BwXKt0e","x2rPC3bHDgm","A1jkAuC","vwLoAg8","EML0A0K","rujOyvi","A2vUuei","zgLJsNy","BwvZ","DhDVCMTdAge","Dw5Kwuu","Bu9ntw8","u2PAC0O","s1L1Exu","DNznCMm","twvZC2fNzuu","zw1PDa","rvjst1i","s0X3C2K","igzPzwXKoIa","x3bPBMDqB24","q0Xpu0LorW","BhHswMG","x2LZtM9Kzq","reiGzMfPBgu","tMvkzgq","zLbfCM8","tNPgDNK","yxKSig5LDhC","mhW1Fdr8m3W","z2v0t3DUuhi","q09oveLovuu","Bg9NsurozxC","x2DLDeLUDgu","yxDhvNC","weX4ENi","zM9YrwfJAa","vvLftLC","v25pseG","qMnnquG","vM13uwy","C3bzzxa","wMrwvxu","A1ruy24","Ehv1rhC","r2TvveC","Bg93","tKDSque","vNPXvhe","DcbSAw1PDa","qNjPzgDL","Dw5cDLO","zNvUy3rPB24","zxj2AwnL","qNLot0S","zxHVCMe","y25pzxq","EM9Ps3O","qK9gq28","x2jPBMfYEvq","Denou2m","DMfSDwvZ","C2vYDMLJzq","BNvzz2W","u2HtzMu","y09Wzw4","AxjLza","y3zNz0q","vMPIwwm","zw50zwqGDhK","t2jQzwn0","q0f4wNG","B3bLBIa","BLz5CgO","uhHNBei","wurzsu0","zNjVBunOyxi","BMv4DcGPigm","A2n1zfi","teT2De8","wgjjEfy","tLDJALK","qKLvu2C","AuLsBhq","Ef9MCM9UDgK","y3jLyxrLrxi","EuH2wM0","D0XYEhu","mxW1Fdn8mG","CfvmqLi","EMXsqNm","zNjVBuj5Dgu","t0fnBKe","AxmGDw5Kzwy","y2PnEgC","B2LUDfjLywm","y29SBM8","B2jQzwn0u3q","BM9Uzv9UB24","q09rzue","rfnLCu8","vg1ishi","AgXZC0C","A0LwC24","B25SAw5L","CMfUzg9T","t2XftM0","C2TXCuK","zv90Aw1LB3u","tKTQwvG","Cg9W","EgDUALK","Dxzyz2e","C2vUzf9Hy2S","CM92AwrLige","CNnVCL92ywW","uLzzzKW","vvLcvMi","x2rLyNvN","A0jrvKK","sxffA1u","AvjpwKW","AuvSDhG","CMvTB3zLq2G","tuvVwLu","DxjS","sKDzDuC","x2n1CNnVCK4","x29UvgLTzw8","Ee5St0G","qwPbyva","BfrPBwvVDxq","rK9iwgi","z2vtEw5J","x2nYzwf0zvm","rg1Tsu0","BMCGzMfPBgu","Aw9UvgLTzw8","wMXhwLu","DgLUzYbZzxi","ENjowxG","zfzlzgy","zxjYB3i","zvvYBa","vvzyEMu","BML0AwfSAxO","Chv0","Ahr0Chm6","DeLwDxy","C3jdz3q","su1xvwu","vgLTzw91Da","zvb3Dxq","u2TPCcbWyxm","BezSDxnO","BgvUz3rO","BMvWAxy","Bwf4twvZC2e","qwvgCKG","CeTjuue","wgntsMW","AwrI","r3f6wg8","C2v0q3vYC28","Bu91AMC","s2DLEgW","rNf0teS","yxbWBgLJyxq","x25HDMLNyxq","y1r1BNi","BurPwgi","rhnTBMe","tgPhCLO","zw5fDMvUDa","DhjYENC","y3vYC29Y","wMDZA1m","AKvuyLy","AgLNAa","A2v5CW","BM1LDKO","seTIreS","BurWze4","BMrWB2LUDfq","CMvXDwLYzwq","AwXSihvZzsa","CuLQq0C","wefYuNi","q0DbrMG","ExjkDKi","AvP0wNy","x194x21Zz18","Dg9hzw5LCMe","sLb4tgK","BxDWAe8","DcbVzIbYyw4","AeP3EKi","u3j6BgC","ENbLu2O","CYbWyxjHBxm","CMvQzwn0","z2DKDhm","zgvMAw5Luhi","shLLBMC","sNHtEg0","qxfyENu","BxnNsuq","wuHezg4","tNPLB1K","mtbPww9WswC","DhjQyuG","EKvsBeq","EKPswMu","C2vUza","t253v0G","rwTOvLK","uvP3yuC","Aw5L","BfnjAeG","qwXqzKS","BgLTAxq","CejZz2i","C3nHz2vfDMu","yxjjs3e","vezrCNO","zLf5A0u","v0nHD2u","y29Kzq","q0TIwK4","DhrKuwG","wKDWueC","C0XIwKu","swXkr0C","EMTQBfq","D2PNBMe","z2v0qwXS","uMHTsee","rev0Dw0","oxWXFdz8mhW","C2v0zgi","vMr4wMi","Cgf5Bg9Hza","uNb4qu4","yMHsD3G","jMPZy2fSBgi","AwXLx25HBwu","y0jHy2e","CM92AwrLihy","wgrnsg4","DLjAvNu","x2rItMfTzq","Cgf5Bg9Hzeu","DNnjt1u","x2vUzhbVAw4","Fdr8mNWZFde","lcbTyxGGCMu","zgD6C2K","EfvZzuvUDG","mdaWma","tMvJCeS","zNjHBwvuExa","ihzHBgLKigq","wgTUDeS","EKTOEey","s0HSA1u","wurnt0i","wMnSAeS","DvHWAMe","B0rSq1i","x2rLC3rYB3K","CMLLC0nVDw4","ufvWwgu","nZCYmZu3nxLpBM9yBG","DKz3zfK","q3vZDg9Trxi","twLZC2LUzYa","y3jLyxrLq2W","C3rVCMu","zfDVCMTLCKC","BMDuAw1LCG","rfPHA3i","yxrlsgG","zMLSDgvY","x3nLBMrby2S","Ec1TC2CTCw8","t1jhAwe","wgn0q3O","u05ls2q","AevYCM9Yrxy","CgLUz19VBMm","CgLUz0XVC3m","A0zhCMq","ywnRtxnNswq","Cw9Zx18","DvjzEvy","t1bftL9fuLi","vxDdshG","C0X1C2m","v29uy0q","yNvMzMvYzwq","Dg9cExrLC0i","CMvZzxruCMK","q2TUuM0","Dg9oDw1Izxi","Agfxy2i","yw1LoIa","D2TtvhG","vunNBuS","wKvUvLu","CMvHzfvjBNq","u0HnBNC","wuX5vvy","tMrUqu4","yxnL","uhbYzNK","CKzVDNK","qwvVs0m","AuXjBK8","rxzLBNq","yLnAAuK","B2fK","zw50tgLZDgu","yxv0BW","rxz2B3q","AefJA01LC3m","Dg9iyxnO","zsbHihn0CMK","wfvkrg8","zgzYsue","ig1LC3nHz2u","AxbJBxm","x3jLy29UBMu","nhWWFdf8mNW","shnVq2K","zgvIDwC","C2vUDa","q29Kzq","y3rZC0C","uej4r3O","wur5Eg0","u3rYyxrLz3K","ywnRx2LK","BNDxC0m","uwzLtKS","mJi2ntu1tNvIt29g","nZG4nZyYnefyDLnQrq","D3nZoI8V","vu5zzKO","BwfW","B2fODeO","o2nOyxjZzxq","y0DyqKC","vhPtD1a","zwHYsKi","Bhr1rey"];return Jn=function(){return n},Jn()}var qn;Object[C(1356)+C(901)](Q,C(1608)+"le",{value:!0})});var qe=he((Gp,Eo)=>{"use strict";var vo=["nodebuffer","arraybuffer","fragments"],So=typeof Blob<"u";So&&vo.push("blob");Eo.exports={BINARY_TYPES:vo,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:So,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Xt=he((Hp,Vn)=>{"use strict";var{EMPTY_BUFFER:Nu}=qe(),Hr=Buffer[Symbol.species];function Bu(n,e){if(n.length===0)return Nu;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let c=0;c<n.length;c++){let u=n[c];s.set(u,o),o+=u.length}return o<e?new Hr(s.buffer,s.byteOffset,o):s}function Co(n,e,s,o,c){for(let u=0;u<c;u++)s[o+u]=n[u]^e[u&3]}function Ao(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function Mu(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function Wr(n){if(Wr.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new Hr(n):ArrayBuffer.isView(n)?e=new Hr(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),Wr.readOnly=!1),e}Vn.exports={concat:Bu,mask:Co,toArrayBuffer:Mu,toBuffer:Wr,unmask:Ao};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=Y("bufferutil");Vn.exports.mask=function(e,s,o,c,u){u<48?Co(e,s,o,c,u):n.mask(e,s,o,c,u)},Vn.exports.unmask=function(e,s){e.length<32?Ao(e,s):n.unmask(e,s)}}catch{}});var ko=he((Wp,Po)=>{"use strict";var Io=Symbol("kDone"),Jr=Symbol("kRun"),Vr=class{constructor(e){this[Io]=()=>{this.pending--,this[Jr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Jr]()}[Jr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Io])}}};Po.exports=Vr});var It=he((Jp,Oo)=>{"use strict";var Zt=Y("zlib"),To=Xt(),zu=ko(),{kStatusCode:Do}=qe(),Fu=Buffer[Symbol.species],Uu=Buffer.from([0,0,255,255]),Yn=Symbol("permessage-deflate"),Ke=Symbol("total-length"),Ct=Symbol("callback"),Xe=Symbol("buffers"),At=Symbol("error"),$n,$r=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,!$n){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;$n=new zu(s)}}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[Ct];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,o=e.find(c=>!(s.serverNoContextTakeover===!1&&c.server_no_context_takeover||c.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>c.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!c.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(o.server_no_context_takeover=!0),s.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(o.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?o.client_max_window_bits=s.clientMaxWindowBits:(o.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(o=>{let c=s[o];if(c.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(c=c[0],o==="client_max_window_bits"){if(c!==!0){let u=+c;if(!Number.isInteger(u)||u<8||u>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=u}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else if(o==="server_max_window_bits"){let u=+c;if(!Number.isInteger(u)||u<8||u>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=u}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(c!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else throw new Error(`Unknown parameter "${o}"`);s[o]=c})}),e}decompress(e,s,o){$n.add(c=>{this._decompress(e,s,(u,f)=>{c(),o(u,f)})})}compress(e,s,o){$n.add(c=>{this._compress(e,s,(u,f)=>{c(),o(u,f)})})}_decompress(e,s,o){let c=this._isServer?"client":"server";if(!this._inflate){let u=`${c}_max_window_bits`,f=typeof this.params[u]!="number"?Zt.Z_DEFAULT_WINDOWBITS:this.params[u];this._inflate=Zt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[Yn]=this,this._inflate[Ke]=0,this._inflate[Xe]=[],this._inflate.on("error",Ku),this._inflate.on("data",Ro)}this._inflate[Ct]=o,this._inflate.write(e),s&&this._inflate.write(Uu),this._inflate.flush(()=>{let u=this._inflate[At];if(u){this._inflate.close(),this._inflate=null,o(u);return}let f=To.concat(this._inflate[Xe],this._inflate[Ke]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ke]=0,this._inflate[Xe]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,f)})}_compress(e,s,o){let c=this._isServer?"server":"client";if(!this._deflate){let u=`${c}_max_window_bits`,f=typeof this.params[u]!="number"?Zt.Z_DEFAULT_WINDOWBITS:this.params[u];this._deflate=Zt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Ke]=0,this._deflate[Xe]=[],this._deflate.on("data",qu)}this._deflate[Ct]=o,this._deflate.write(e),this._deflate.flush(Zt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let u=To.concat(this._deflate[Xe],this._deflate[Ke]);s&&(u=new Fu(u.buffer,u.byteOffset,u.length-4)),this._deflate[Ct]=null,this._deflate[Ke]=0,this._deflate[Xe]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,u)})}};Oo.exports=$r;function qu(n){this[Xe].push(n),this[Ke]+=n.length}function Ro(n){if(this[Ke]+=n.length,this[Yn]._maxPayload<1||this[Ke]<=this[Yn]._maxPayload){this[Xe].push(n);return}this[At]=new RangeError("Max payload size exceeded"),this[At].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[At][Do]=1009,this.removeListener("data",Ro),this.reset()}function Ku(n){if(this[Yn]._inflate=null,this[At]){this[Ct](this[At]);return}n[Do]=1007,this[Ct](n)}});var Pt=he((Vp,Xn)=>{"use strict";var{isUtf8:Lo}=Y("buffer"),{hasBlob:ju}=qe(),Gu=[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 Hu(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function Yr(n){let e=n.length,s=0;for(;s<e;)if((n[s]&128)===0)s++;else if((n[s]&224)===192){if(s+1===e||(n[s+1]&192)!==128||(n[s]&254)===192)return!1;s+=2}else if((n[s]&240)===224){if(s+2>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||n[s]===224&&(n[s+1]&224)===128||n[s]===237&&(n[s+1]&224)===160)return!1;s+=3}else if((n[s]&248)===240){if(s+3>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||(n[s+3]&192)!==128||n[s]===240&&(n[s+1]&240)===128||n[s]===244&&n[s+1]>143||n[s]>244)return!1;s+=4}else return!1;return!0}function Wu(n){return ju&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}Xn.exports={isBlob:Wu,isValidStatusCode:Hu,isValidUTF8:Yr,tokenChars:Gu};if(Lo)Xn.exports.isValidUTF8=function(n){return n.length<24?Yr(n):Lo(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=Y("utf-8-validate");Xn.exports.isValidUTF8=function(e){return e.length<32?Yr(e):n(e)}}catch{}});var ti=he(($p,qo)=>{"use strict";var{Writable:Ju}=Y("stream"),No=It(),{BINARY_TYPES:Vu,EMPTY_BUFFER:Bo,kStatusCode:$u,kWebSocket:Yu}=qe(),{concat:Xr,toArrayBuffer:Xu,unmask:Zu}=Xt(),{isValidStatusCode:Qu,isValidUTF8:Mo}=Pt(),Zn=Buffer[Symbol.species],_e=0,zo=1,Fo=2,Uo=3,Zr=4,Qr=5,Qn=6,ei=class extends Ju{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Vu[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Yu]=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=_e}_write(e,s,o){if(this._opcode===8&&this._state==_e)return o();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(o)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let o=this._buffers[0];return this._buffers[0]=new Zn(o.buffer,o.byteOffset+e,o.length-e),new Zn(o.buffer,o.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let o=this._buffers[0],c=s.length-e;e>=o.length?s.set(this._buffers.shift(),c):(s.set(new Uint8Array(o.buffer,o.byteOffset,e),c),this._buffers[0]=new Zn(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case _e:this.getInfo(e);break;case zo:this.getPayloadLength16(e);break;case Fo:this.getPayloadLength64(e);break;case Uo:this.getMask();break;case Zr:this.getData(e);break;case Qr:case Qn:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let c=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(c);return}let o=(s[0]&64)===64;if(o&&!this._extensions[No.extensionName]){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(!this._fragmented){let c=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let c=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(c);return}if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let c=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(c);return}}else{let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let c=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(c);return}}else if(this._masked){let c=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(c);return}this._payloadLength===126?this._state=zo:this._payloadLength===127?this._state=Fo: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 s=this.consume(8),o=s.readUInt32BE(0);if(o>Math.pow(2,21)-1){let c=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(c);return}this._payloadLength=o*Math.pow(2,32)+s.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 s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=Uo:this._state=Zr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Zr}getData(e){let s=Bo;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Zu(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=Qr,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[No.extensionName].decompress(e,this._fin,(c,u)=>{if(c)return s(c);if(u.length){if(this._messageLength+=u.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(f);return}this._fragments.push(u)}this.dataMessage(s),this._state===_e&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=_e;return}let s=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let c;this._binaryType==="nodebuffer"?c=Xr(o,s):this._binaryType==="arraybuffer"?c=Xu(Xr(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=_e):(this._state=Qn,setImmediate(()=>{this.emit("message",c,!0),this._state=_e,this.startLoop(e)}))}else{let c=Xr(o,s);if(!this._skipUTF8Validation&&!Mo(c)){let u=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(u);return}this._state===Qr||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=_e):(this._state=Qn,setImmediate(()=>{this.emit("message",c,!1),this._state=_e,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Bo),this.end();else{let o=e.readUInt16BE(0);if(!Qu(o)){let u=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(u);return}let c=new Zn(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Mo(c)){let u=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(u);return}this._loop=!1,this.emit("conclude",o,c),this.end()}this._state=_e;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=_e):(this._state=Qn,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=_e,this.startLoop(s)}))}createError(e,s,o,c,u){this._loop=!1,this._errored=!0;let f=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(f,this.createError),f.code=u,f[$u]=c,f}};qo.exports=ei});var ii=he((Xp,Go)=>{"use strict";var{Duplex:Yp}=Y("stream"),{randomFillSync:ef}=Y("crypto"),Ko=It(),{EMPTY_BUFFER:tf,kWebSocket:nf,NOOP:rf}=qe(),{isBlob:kt,isValidStatusCode:sf}=Pt(),{mask:jo,toBuffer:st}=Xt(),we=Symbol("kByteLength"),of=Buffer.alloc(4),er=8*1024,ot,Tt=er,Ee=0,af=1,cf=2,ni=class n{constructor(e,s,o){this._extensions=s||{},o&&(this._generateMask=o,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Ee,this.onerror=rf,this[nf]=void 0}static frame(e,s){let o,c=!1,u=2,f=!1;s.mask&&(o=s.maskBuffer||of,s.generateMask?s.generateMask(o):(Tt===er&&(ot===void 0&&(ot=Buffer.alloc(er)),ef(ot,0,er),Tt=0),o[0]=ot[Tt++],o[1]=ot[Tt++],o[2]=ot[Tt++],o[3]=ot[Tt++]),f=(o[0]|o[1]|o[2]|o[3])===0,u=6);let h;typeof e=="string"?(!s.mask||f)&&s[we]!==void 0?h=s[we]:(e=Buffer.from(e),h=e.length):(h=e.length,c=s.mask&&s.readOnly&&!f);let m=h;h>=65536?(u+=8,m=127):h>125&&(u+=2,m=126);let w=Buffer.allocUnsafe(c?h+u:u);return w[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(w[0]|=64),w[1]=m,m===126?w.writeUInt16BE(h,2):m===127&&(w[2]=w[3]=0,w.writeUIntBE(h,4,6)),s.mask?(w[1]|=128,w[u-4]=o[0],w[u-3]=o[1],w[u-2]=o[2],w[u-1]=o[3],f?[w,e]:c?(jo(e,o,w,u,h),[w]):(jo(e,o,e,0,h),[w,e])):[w,e]}close(e,s,o,c){let u;if(e===void 0)u=tf;else{if(typeof e!="number"||!sf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)u=Buffer.allocUnsafe(2),u.writeUInt16BE(e,0);else{let h=Buffer.byteLength(s);if(h>123)throw new RangeError("The message must not be greater than 123 bytes");u=Buffer.allocUnsafe(2+h),u.writeUInt16BE(e,0),typeof s=="string"?u.write(s,2):u.set(s,2)}}let f={[we]:u.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Ee?this.enqueue([this.dispatch,u,!1,f,c]):this.sendFrame(n.frame(u,f),c)}ping(e,s,o){let c,u;if(typeof e=="string"?(c=Buffer.byteLength(e),u=!1):kt(e)?(c=e.size,u=!1):(e=st(e),c=e.length,u=st.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[we]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:u,rsv1:!1};kt(e)?this._state!==Ee?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==Ee?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}pong(e,s,o){let c,u;if(typeof e=="string"?(c=Buffer.byteLength(e),u=!1):kt(e)?(c=e.size,u=!1):(e=st(e),c=e.length,u=st.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[we]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:u,rsv1:!1};kt(e)?this._state!==Ee?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==Ee?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}send(e,s,o){let c=this._extensions[Ko.extensionName],u=s.binary?2:1,f=s.compress,h,m;typeof e=="string"?(h=Buffer.byteLength(e),m=!1):kt(e)?(h=e.size,m=!1):(e=st(e),h=e.length,m=st.readOnly),this._firstFragment?(this._firstFragment=!1,f&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=h>=c._threshold),this._compress=f):(f=!1,u=0),s.fin&&(this._firstFragment=!0);let w={[we]:h,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:u,readOnly:m,rsv1:f};kt(e)?this._state!==Ee?this.enqueue([this.getBlobData,e,this._compress,w,o]):this.getBlobData(e,this._compress,w,o):this._state!==Ee?this.enqueue([this.dispatch,e,this._compress,w,o]):this.dispatch(e,this._compress,w,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[we],this._state=cf,e.arrayBuffer().then(u=>{if(this._socket.destroyed){let h=new Error("The socket was closed while the blob was being read");process.nextTick(ri,this,h,c);return}this._bufferedBytes-=o[we];let f=st(u);s?this.dispatch(f,s,o,c):(this._state=Ee,this.sendFrame(n.frame(f,o),c),this.dequeue())}).catch(u=>{process.nextTick(xf,this,u,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let u=this._extensions[Ko.extensionName];this._bufferedBytes+=o[we],this._state=af,u.compress(e,o.fin,(f,h)=>{if(this._socket.destroyed){let m=new Error("The socket was closed while data was being compressed");ri(this,m,c);return}this._bufferedBytes-=o[we],this._state=Ee,o.readOnly=!1,this.sendFrame(n.frame(h,o),c),this.dequeue()})}dequeue(){for(;this._state===Ee&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][we],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][we],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};Go.exports=ni;function ri(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let c=n._queue[o],u=c[c.length-1];typeof u=="function"&&u(e)}}function xf(n,e,s){ri(n,e,s),n.onerror(e)}});var Qo=he((Zp,Zo)=>{"use strict";var{kForOnEventAttribute:Qt,kListener:si}=qe(),Ho=Symbol("kCode"),Wo=Symbol("kData"),Jo=Symbol("kError"),Vo=Symbol("kMessage"),$o=Symbol("kReason"),Dt=Symbol("kTarget"),Yo=Symbol("kType"),Xo=Symbol("kWasClean"),je=class{constructor(e){this[Dt]=null,this[Yo]=e}get target(){return this[Dt]}get type(){return this[Yo]}};Object.defineProperty(je.prototype,"target",{enumerable:!0});Object.defineProperty(je.prototype,"type",{enumerable:!0});var at=class extends je{constructor(e,s={}){super(e),this[Ho]=s.code===void 0?0:s.code,this[$o]=s.reason===void 0?"":s.reason,this[Xo]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Ho]}get reason(){return this[$o]}get wasClean(){return this[Xo]}};Object.defineProperty(at.prototype,"code",{enumerable:!0});Object.defineProperty(at.prototype,"reason",{enumerable:!0});Object.defineProperty(at.prototype,"wasClean",{enumerable:!0});var Rt=class extends je{constructor(e,s={}){super(e),this[Jo]=s.error===void 0?null:s.error,this[Vo]=s.message===void 0?"":s.message}get error(){return this[Jo]}get message(){return this[Vo]}};Object.defineProperty(Rt.prototype,"error",{enumerable:!0});Object.defineProperty(Rt.prototype,"message",{enumerable:!0});var en=class extends je{constructor(e,s={}){super(e),this[Wo]=s.data===void 0?null:s.data}get data(){return this[Wo]}};Object.defineProperty(en.prototype,"data",{enumerable:!0});var uf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[Qt]&&c[si]===e&&!c[Qt])return;let o;if(n==="message")o=function(u,f){let h=new en("message",{data:f?u:u.toString()});h[Dt]=this,tr(e,this,h)};else if(n==="close")o=function(u,f){let h=new at("close",{code:u,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});h[Dt]=this,tr(e,this,h)};else if(n==="error")o=function(u){let f=new Rt("error",{error:u,message:u.message});f[Dt]=this,tr(e,this,f)};else if(n==="open")o=function(){let u=new je("open");u[Dt]=this,tr(e,this,u)};else return;o[Qt]=!!s[Qt],o[si]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[si]===e&&!s[Qt]){this.removeListener(n,s);break}}};Zo.exports={CloseEvent:at,ErrorEvent:Rt,Event:je,EventTarget:uf,MessageEvent:en};function tr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var nr=he((Qp,ea)=>{"use strict";var{tokenChars:tn}=Pt();function Oe(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function ff(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,u=!1,f,h,m=-1,w=-1,b=-1,S=0;for(;S<n.length;S++)if(w=n.charCodeAt(S),f===void 0)if(b===-1&&tn[w]===1)m===-1&&(m=S);else if(S!==0&&(w===32||w===9))b===-1&&m!==-1&&(b=S);else if(w===59||w===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${S}`);b===-1&&(b=S);let N=n.slice(m,b);w===44?(Oe(e,N,s),s=Object.create(null)):f=N,m=b=-1}else throw new SyntaxError(`Unexpected character at index ${S}`);else if(h===void 0)if(b===-1&&tn[w]===1)m===-1&&(m=S);else if(w===32||w===9)b===-1&&m!==-1&&(b=S);else if(w===59||w===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${S}`);b===-1&&(b=S),Oe(s,n.slice(m,b),!0),w===44&&(Oe(e,f,s),s=Object.create(null),f=void 0),m=b=-1}else if(w===61&&m!==-1&&b===-1)h=n.slice(m,S),m=b=-1;else throw new SyntaxError(`Unexpected character at index ${S}`);else if(c){if(tn[w]!==1)throw new SyntaxError(`Unexpected character at index ${S}`);m===-1?m=S:o||(o=!0),c=!1}else if(u)if(tn[w]===1)m===-1&&(m=S);else if(w===34&&m!==-1)u=!1,b=S;else if(w===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${S}`);else if(w===34&&n.charCodeAt(S-1)===61)u=!0;else if(b===-1&&tn[w]===1)m===-1&&(m=S);else if(m!==-1&&(w===32||w===9))b===-1&&(b=S);else if(w===59||w===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${S}`);b===-1&&(b=S);let N=n.slice(m,b);o&&(N=N.replace(/\\/g,""),o=!1),Oe(s,h,N),w===44&&(Oe(e,f,s),s=Object.create(null),f=void 0),h=void 0,m=b=-1}else throw new SyntaxError(`Unexpected character at index ${S}`);if(m===-1||u||w===32||w===9)throw new SyntaxError("Unexpected end of input");b===-1&&(b=S);let A=n.slice(m,b);return f===void 0?Oe(e,A,s):(h===void 0?Oe(s,A,!0):o?Oe(s,h,A.replace(/\\/g,"")):Oe(s,h,A),Oe(e,f,s)),e}function df(n){return Object.keys(n).map(e=>{let s=n[e];return Array.isArray(s)||(s=[s]),s.map(o=>[e].concat(Object.keys(o).map(c=>{let u=o[c];return Array.isArray(u)||(u=[u]),u.map(f=>f===!0?c:`${c}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}ea.exports={format:df,parse:ff}});var or=he((nm,da)=>{"use strict";var lf=Y("events"),hf=Y("https"),gf=Y("http"),ra=Y("net"),pf=Y("tls"),{randomBytes:mf,createHash:_f}=Y("crypto"),{Duplex:em,Readable:tm}=Y("stream"),{URL:oi}=Y("url"),Ze=It(),wf=ti(),yf=ii(),{isBlob:bf}=Pt(),{BINARY_TYPES:ta,CLOSE_TIMEOUT:vf,EMPTY_BUFFER:rr,GUID:Sf,kForOnEventAttribute:ai,kListener:Ef,kStatusCode:Cf,kWebSocket:ee,NOOP:ia}=qe(),{EventTarget:{addEventListener:Af,removeEventListener:If}}=Qo(),{format:Pf,parse:kf}=nr(),{toBuffer:Tf}=Xt(),sa=Symbol("kAborted"),ci=[8,13],Ge=["CONNECTING","OPEN","CLOSING","CLOSED"],Df=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,W=class n extends lf{constructor(e,s,o){super(),this._binaryType=ta[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=rr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(o=s,s=[]):s=[s]),oa(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){ta.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,s,o){let c=new wf({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),u=new yf(e,this._extensions,o.generateMask);this._receiver=c,this._sender=u,this._socket=e,c[ee]=this,u[ee]=this,e[ee]=this,c.on("conclude",Lf),c.on("drain",Nf),c.on("error",Bf),c.on("message",Mf),c.on("ping",zf),c.on("pong",Ff),u.onerror=Uf,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",xa),e.on("data",sr),e.on("end",ua),e.on("error",fa),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ze.extensionName]&&this._extensions[Ze.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){pe(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,s,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ca(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){xi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||rr,s,o)}pong(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){xi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||rr,s,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(o=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){xi(this,e,o);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[Ze.extensionName]||(c.compress=!1),this._sender.send(e||rr,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){pe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(W,"CONNECTING",{enumerable:!0,value:Ge.indexOf("CONNECTING")});Object.defineProperty(W.prototype,"CONNECTING",{enumerable:!0,value:Ge.indexOf("CONNECTING")});Object.defineProperty(W,"OPEN",{enumerable:!0,value:Ge.indexOf("OPEN")});Object.defineProperty(W.prototype,"OPEN",{enumerable:!0,value:Ge.indexOf("OPEN")});Object.defineProperty(W,"CLOSING",{enumerable:!0,value:Ge.indexOf("CLOSING")});Object.defineProperty(W.prototype,"CLOSING",{enumerable:!0,value:Ge.indexOf("CLOSING")});Object.defineProperty(W,"CLOSED",{enumerable:!0,value:Ge.indexOf("CLOSED")});Object.defineProperty(W.prototype,"CLOSED",{enumerable:!0,value:Ge.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(W.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(W.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[ai])return e[Ef];return null},set(e){for(let s of this.listeners(n))if(s[ai]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[ai]:!0})}})});W.prototype.addEventListener=Af;W.prototype.removeEventListener=If;da.exports=W;function oa(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:vf,protocolVersion:ci[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=c.autoPong,n._closeTimeout=c.closeTimeout,!ci.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${ci.join(", ")})`);let u;if(e instanceof oi)u=e;else try{u=new oi(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}u.protocol==="http:"?u.protocol="ws:":u.protocol==="https:"&&(u.protocol="wss:"),n._url=u.href;let f=u.protocol==="wss:",h=u.protocol==="ws+unix:",m;if(u.protocol!=="ws:"&&!f&&!h?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:h&&!u.pathname?m="The URL's pathname is empty":u.hash&&(m="The URL contains a fragment identifier"),m){let R=new SyntaxError(m);if(n._redirects===0)throw R;ir(n,R);return}let w=f?443:80,b=mf(16).toString("base64"),S=f?hf.request:gf.request,A=new Set,N;if(c.createConnection=c.createConnection||(f?Of:Rf),c.defaultPort=c.defaultPort||w,c.port=u.port||w,c.host=u.hostname.startsWith("[")?u.hostname.slice(1,-1):u.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":b,Connection:"Upgrade",Upgrade:"websocket"},c.path=u.pathname+u.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(N=new Ze({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=Pf({[Ze.extensionName]:N.offer()})),s.length){for(let R of s){if(typeof R!="string"||!Df.test(R)||A.has(R))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(R)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(u.username||u.password)&&(c.auth=`${u.username}:${u.password}`),h){let R=c.path.split(":");c.socketPath=R[0],c.path=R[1]}let D;if(c.followRedirects){if(n._redirects===0){n._originalIpc=h,n._originalSecure=f,n._originalHostOrSocketPath=h?c.socketPath:u.host;let R=o&&o.headers;if(o={...o,headers:{}},R)for(let[M,V]of Object.entries(R))o.headers[M.toLowerCase()]=V}else if(n.listenerCount("redirect")===0){let R=h?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:u.host===n._originalHostOrSocketPath;(!R||n._originalSecure&&!f)&&(delete c.headers.authorization,delete c.headers.cookie,R||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),D=n._req=S(c),n._redirects&&n.emit("redirect",n.url,D)}else D=n._req=S(c);c.timeout&&D.on("timeout",()=>{pe(n,D,"Opening handshake has timed out")}),D.on("error",R=>{D===null||D[sa]||(D=n._req=null,ir(n,R))}),D.on("response",R=>{let M=R.headers.location,V=R.statusCode;if(M&&c.followRedirects&&V>=300&&V<400){if(++n._redirects>c.maxRedirects){pe(n,D,"Maximum redirects exceeded");return}D.abort();let te;try{te=new oi(M,e)}catch{let se=new SyntaxError(`Invalid URL: ${M}`);ir(n,se);return}oa(n,te,s,o)}else n.emit("unexpected-response",D,R)||pe(n,D,`Unexpected server response: ${R.statusCode}`)}),D.on("upgrade",(R,M,V)=>{if(n.emit("upgrade",R),n.readyState!==W.CONNECTING)return;D=n._req=null;let te=R.headers.upgrade;if(te===void 0||te.toLowerCase()!=="websocket"){pe(n,M,"Invalid Upgrade header");return}let ie=_f("sha1").update(b+Sf).digest("base64");if(R.headers["sec-websocket-accept"]!==ie){pe(n,M,"Invalid Sec-WebSocket-Accept header");return}let se=R.headers["sec-websocket-protocol"],$;if(se!==void 0?A.size?A.has(se)||($="Server sent an invalid subprotocol"):$="Server sent a subprotocol but none was requested":A.size&&($="Server sent no subprotocol"),$){pe(n,M,$);return}se&&(n._protocol=se);let le=R.headers["sec-websocket-extensions"];if(le!==void 0){if(!N){pe(n,M,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let T;try{T=kf(le)}catch{pe(n,M,"Invalid Sec-WebSocket-Extensions header");return}let z=Object.keys(T);if(z.length!==1||z[0]!==Ze.extensionName){pe(n,M,"Server indicated an extension that was not requested");return}try{N.accept(T[Ze.extensionName])}catch{pe(n,M,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[Ze.extensionName]=N}n.setSocket(M,V,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(D,n):D.end()}function ir(n,e){n._readyState=W.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function Rf(n){return n.path=n.socketPath,ra.connect(n)}function Of(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=ra.isIP(n.host)?"":n.host),pf.connect(n)}function pe(n,e,s){n._readyState=W.CLOSING;let o=new Error(s);Error.captureStackTrace(o,pe),e.setHeader?(e[sa]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(ir,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function xi(n,e,s){if(e){let o=bf(e)?e.size:Tf(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ge[n.readyState]})`);process.nextTick(s,o)}}function Lf(n,e){let s=this[ee];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[ee]!==void 0&&(s._socket.removeListener("data",sr),process.nextTick(aa,s._socket),n===1005?s.close():s.close(n,e))}function Nf(){let n=this[ee];n.isPaused||n._socket.resume()}function Bf(n){let e=this[ee];e._socket[ee]!==void 0&&(e._socket.removeListener("data",sr),process.nextTick(aa,e._socket),e.close(n[Cf])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function na(){this[ee].emitClose()}function Mf(n,e){this[ee].emit("message",n,e)}function zf(n){let e=this[ee];e._autoPong&&e.pong(n,!this._isServer,ia),e.emit("ping",n)}function Ff(n){this[ee].emit("pong",n)}function aa(n){n.resume()}function Uf(n){let e=this[ee];e.readyState!==W.CLOSED&&(e.readyState===W.OPEN&&(e._readyState=W.CLOSING,ca(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function ca(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function xa(){let n=this[ee];if(this.removeListener("close",xa),this.removeListener("data",sr),this.removeListener("end",ua),n._readyState=W.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[ee]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",na),n._receiver.on("finish",na))}function sr(n){this[ee]._receiver.write(n)||this.pause()}function ua(){let n=this[ee];n._readyState=W.CLOSING,n._receiver.end(),this.end()}function fa(){let n=this[ee];this.removeListener("error",fa),this.on("error",ia),n&&(n._readyState=W.CLOSING,this.destroy())}});var pa=he((im,ga)=>{"use strict";var rm=or(),{Duplex:qf}=Y("stream");function la(n){n.emit("close")}function Kf(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ha(n){this.removeListener("error",ha),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function jf(n,e){let s=!0,o=new qf({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(u,f){let h=!f&&o._readableState.objectMode?u.toString():u;o.push(h)||n.pause()}),n.once("error",function(u){o.destroyed||(s=!1,o.destroy(u))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(c,u){if(n.readyState===n.CLOSED){u(c),process.nextTick(la,o);return}let f=!1;n.once("error",function(m){f=!0,u(m)}),n.once("close",function(){f||u(c),process.nextTick(la,o)}),s&&n.terminate()},o._final=function(c){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(c)});return}n._socket!==null&&(n._socket._writableState.finished?(c(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){c()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(c,u,f){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(c,u,f)});return}n.send(c,f)},o.on("end",Kf),o.on("error",ha),o}ga.exports=jf});var ui=he((sm,ma)=>{"use strict";var{tokenChars:Gf}=Pt();function Hf(n){let e=new Set,s=-1,o=-1,c=0;for(c;c<n.length;c++){let f=n.charCodeAt(c);if(o===-1&&Gf[f]===1)s===-1&&(s=c);else if(c!==0&&(f===32||f===9))o===-1&&s!==-1&&(o=c);else if(f===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);o===-1&&(o=c);let h=n.slice(s,o);if(e.has(h))throw new SyntaxError(`The "${h}" subprotocol is duplicated`);e.add(h),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${c}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let u=n.slice(s,c);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);return e.add(u),e}ma.exports={parse:Hf}});var Ea=he((am,Sa)=>{"use strict";var Wf=Y("events"),ar=Y("http"),{Duplex:om}=Y("stream"),{createHash:Jf}=Y("crypto"),_a=nr(),ct=It(),Vf=ui(),$f=or(),{CLOSE_TIMEOUT:Yf,GUID:Xf,kWebSocket:Zf}=qe(),Qf=/^[+/0-9A-Za-z]{22}==$/,wa=0,ya=1,va=2,fi=class extends Wf{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Yf,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:$f,...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=ar.createServer((o,c)=>{let u=ar.STATUS_CODES[426];c.writeHead(426,{"Content-Length":u.length,"Content-Type":"text/plain"}),c.end(u)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=ed(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,u,f)=>{this.handleUpgrade(c,u,f,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=wa}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===va){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(nn,this);return}if(e&&this.once("close",e),this._state!==ya)if(this._state=ya,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(nn,this):process.nextTick(nn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{nn(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,o,c){s.on("error",ba);let u=e.headers["sec-websocket-key"],f=e.headers.upgrade,h=+e.headers["sec-websocket-version"];if(e.method!=="GET"){xt(this,e,s,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){xt(this,e,s,400,"Invalid Upgrade header");return}if(u===void 0||!Qf.test(u)){xt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(h!==13&&h!==8){xt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){rn(s,400);return}let m=e.headers["sec-websocket-protocol"],w=new Set;if(m!==void 0)try{w=Vf.parse(m)}catch{xt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let b=e.headers["sec-websocket-extensions"],S={};if(this.options.perMessageDeflate&&b!==void 0){let A=new ct({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let N=_a.parse(b);N[ct.extensionName]&&(A.accept(N[ct.extensionName]),S[ct.extensionName]=A)}catch{xt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${h===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(N,D,R,M)=>{if(!N)return rn(s,D||401,R,M);this.completeUpgrade(S,u,w,e,s,o,c)});return}if(!this.options.verifyClient(A))return rn(s,401)}this.completeUpgrade(S,u,w,e,s,o,c)}completeUpgrade(e,s,o,c,u,f,h){if(!u.readable||!u.writable)return u.destroy();if(u[Zf])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>wa)return rn(u,503);let w=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Jf("sha1").update(s+Xf).digest("base64")}`],b=new this.options.WebSocket(null,void 0,this.options);if(o.size){let S=this.options.handleProtocols?this.options.handleProtocols(o,c):o.values().next().value;S&&(w.push(`Sec-WebSocket-Protocol: ${S}`),b._protocol=S)}if(e[ct.extensionName]){let S=e[ct.extensionName].params,A=_a.format({[ct.extensionName]:[S]});w.push(`Sec-WebSocket-Extensions: ${A}`),b._extensions=e}this.emit("headers",w,c),u.write(w.concat(`\r
12
12
  `).join(`\r
13
- `)),u.removeListener("error",ma),b.setSocket(u,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(b),b.on("close",()=>{this.clients.delete(b),this._shouldEmitClose&&!this.clients.size&&process.nextTick(en,this)})),h(b,c)}};wa.exports=ci;function Qf(n,e){for(let s of Object.keys(e))n.on(s,e[s]);return function(){for(let a of Object.keys(e))n.removeListener(a,e[a])}}function en(n){n._state=_a,n.emit("close")}function ma(){this.destroy()}function tn(n,e,s,a){s=s||rr.STATUS_CODES[e],a={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...a},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${rr.STATUS_CODES[e]}\r
14
- `+Object.keys(a).map(c=>`${c}: ${a[c]}`).join(`\r
13
+ `)),u.removeListener("error",ba),b.setSocket(u,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(b),b.on("close",()=>{this.clients.delete(b),this._shouldEmitClose&&!this.clients.size&&process.nextTick(nn,this)})),h(b,c)}};Sa.exports=fi;function ed(n,e){for(let s of Object.keys(e))n.on(s,e[s]);return function(){for(let o of Object.keys(e))n.removeListener(o,e[o])}}function nn(n){n._state=va,n.emit("close")}function ba(){this.destroy()}function rn(n,e,s,o){s=s||ar.STATUS_CODES[e],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...o},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${ar.STATUS_CODES[e]}\r
14
+ `+Object.keys(o).map(c=>`${c}: ${o[c]}`).join(`\r
15
15
  `)+`\r
16
16
  \r
17
- `+s)}function ut(n,e,s,a,c,u){if(n.listenerCount("wsClientError")){let f=new Error(c);Error.captureStackTrace(f,ut),n.emit("wsClientError",f,s,e)}else tn(s,a,c,u)}});import{spawn as Sd}from"node:child_process";import{existsSync as Ed,openSync as Cd}from"node:fs";import{mkdir as Ad}from"node:fs/promises";import{dirname as Id}from"node:path";import{fileURLToPath as Pd}from"node:url";function fi(n=W()){return Ed(n.libEntry)?n.libEntry:Pd(new URL("../index.ts",import.meta.url))}async function za(n={}){let e=n.paths??W(),s=n.entryOverride??fi(e);await Ad(Id(e.logFile),{recursive:!0});let a=Cd(e.logFile,"a"),u=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],f=Sd(process.execPath,u,{detached:!0,stdio:["ignore",a,a],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return kd.info("daemon spawned",{pid:f.pid,entry:s}),{pid:f.pid,entry:s}}var kd,di=Le(()=>{"use strict";q();fe();kd=N("spawn-daemon")});import{spawn as Gd}from"node:child_process";import{mkdir as Wd,unlink as Jd,writeFile as Vd}from"node:fs/promises";import{dirname as $d,join as Xd}from"node:path";function ur(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function ja(n,e){return new Promise((s,a)=>{let c=Gd(n,e,{stdio:["ignore","pipe","pipe"]}),u="";c.stderr?.on("data",f=>{u+=f.toString("utf8")}),c.on("error",a),c.on("close",f=>{f===0?s():a(new Error(`${n} ${e.join(" ")} exited ${f}: ${u.trim()}`))})})}var xr,gi,pi,Ga=Le(()=>{"use strict";q();xr=N("supervisor.launchd"),gi="ai.coze.bridge",pi={platform:"darwin",renderConfig(n){return`<?xml version="1.0" encoding="UTF-8"?>
17
+ `+s)}function xt(n,e,s,o,c,u){if(n.listenerCount("wsClientError")){let f=new Error(c);Error.captureStackTrace(f,xt),n.emit("wsClientError",f,s,e)}else rn(s,o,c,u)}});import{spawn as Ed}from"node:child_process";import{existsSync as Cd,openSync as Ad}from"node:fs";import{mkdir as Id}from"node:fs/promises";import{dirname as Pd}from"node:path";import{fileURLToPath as kd}from"node:url";function hi(n=H()){return Cd(n.libEntry)?n.libEntry:kd(new URL("../index.ts",import.meta.url))}async function Ka(n={}){let e=n.paths??H(),s=n.entryOverride??hi(e);await Id(Pd(e.logFile),{recursive:!0});let o=Ad(e.logFile,"a"),u=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],f=Ed(process.execPath,u,{detached:!0,stdio:["ignore",o,o],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return Td.info("daemon spawned",{pid:f.pid,entry:s}),{pid:f.pid,entry:s}}var Td,gi=Me(()=>{"use strict";q();fe();Td=O("spawn-daemon")});import{spawn as Wd}from"node:child_process";import{mkdir as Jd,unlink as Vd,writeFile as $d}from"node:fs/promises";import{dirname as Yd,join as Xd}from"node:path";function hr(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Va(n,e){return new Promise((s,o)=>{let c=Wd(n,e,{stdio:["ignore","pipe","pipe"]}),u="";c.stderr?.on("data",f=>{u+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${u.trim()}`))})})}var lr,_i,wi,$a=Me(()=>{"use strict";q();lr=O("supervisor.launchd"),_i="ai.coze.bridge",wi={platform:"darwin",renderConfig(n){return`<?xml version="1.0" encoding="UTF-8"?>
18
18
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
19
19
  <plist version="1.0">
20
20
  <dict>
21
21
  <key>Label</key>
22
- <string>${gi}</string>
22
+ <string>${_i}</string>
23
23
  <key>ProgramArguments</key>
24
24
  <array>
25
- <string>${ur(n.nodeBin)}</string>
26
- <string>${ur(n.entry)}</string>
25
+ <string>${hr(n.nodeBin)}</string>
26
+ <string>${hr(n.entry)}</string>
27
27
  <string>--daemon</string>
28
28
  </array>
29
29
  <key>RunAtLoad</key>
@@ -33,12 +33,12 @@ var j0=Object.create;var Cr=Object.defineProperty;var G0=Object.getOwnPropertyDe
33
33
  <key>ThrottleInterval</key>
34
34
  <integer>10</integer>
35
35
  <key>StandardOutPath</key>
36
- <string>${ur(n.logFile)}</string>
36
+ <string>${hr(n.logFile)}</string>
37
37
  <key>StandardErrorPath</key>
38
- <string>${ur(n.logFile)}</string>
38
+ <string>${hr(n.logFile)}</string>
39
39
  </dict>
40
40
  </plist>
41
- `},configPath(n){return Xd(n.homeDir,"Library","LaunchAgents",`${gi}.plist`)},async install(n){let e=this.configPath(n);await Wd($d(e),{recursive:!0}),await Vd(e,this.renderConfig(n),"utf8"),xr.info("plist written",{plistPath:e}),await ja("launchctl",["load","-w",e]),xr.info("launchd job loaded",{label:gi})},async uninstall(n){let e=this.configPath(n);await ja("launchctl",["unload","-w",e]).catch(s=>xr.warn("launchctl unload failed (ignored)",{err:String(s)})),await Jd(e).catch(s=>{if(s.code!=="ENOENT")throw s}),xr.info("launchd job removed",{plistPath:e})}}});import{spawn as Zd}from"node:child_process";import{mkdir as Yd,unlink as Qd,writeFile as el}from"node:fs/promises";import{dirname as tl,join as nl}from"node:path";function lr(n,e){return new Promise((s,a)=>{let c=Zd(n,e,{stdio:["ignore","pipe","pipe"]}),u="";c.stderr?.on("data",f=>{u+=f.toString("utf8")}),c.on("error",a),c.on("close",f=>{f===0?s():a(new Error(`${n} ${e.join(" ")} exited ${f}: ${u.trim()}`))})})}var fr,dr,mi,Wa=Le(()=>{"use strict";q();fr=N("supervisor.systemd"),dr="coze-bridge.service",mi={platform:"linux",renderConfig(n){return`[Unit]
41
+ `},configPath(n){return Xd(n.homeDir,"Library","LaunchAgents",`${_i}.plist`)},async install(n){let e=this.configPath(n);await Jd(Yd(e),{recursive:!0}),await $d(e,this.renderConfig(n),"utf8"),lr.info("plist written",{plistPath:e}),await Va("launchctl",["load","-w",e]),lr.info("launchd job loaded",{label:_i})},async uninstall(n){let e=this.configPath(n);await Va("launchctl",["unload","-w",e]).catch(s=>lr.warn("launchctl unload failed (ignored)",{err:String(s)})),await Vd(e).catch(s=>{if(s.code!=="ENOENT")throw s}),lr.info("launchd job removed",{plistPath:e})}}});import{spawn as Zd}from"node:child_process";import{mkdir as Qd,unlink as el,writeFile as tl}from"node:fs/promises";import{dirname as nl,join as rl}from"node:path";function mr(n,e){return new Promise((s,o)=>{let c=Zd(n,e,{stdio:["ignore","pipe","pipe"]}),u="";c.stderr?.on("data",f=>{u+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${u.trim()}`))})})}var gr,pr,yi,Ya=Me(()=>{"use strict";q();gr=O("supervisor.systemd"),pr="coze-bridge.service",yi={platform:"linux",renderConfig(n){return`[Unit]
42
42
  Description=Coze Bridge daemon
43
43
  After=network.target
44
44
 
@@ -52,7 +52,7 @@ StandardError=append:${n.logFile}
52
52
 
53
53
  [Install]
54
54
  WantedBy=default.target
55
- `},configPath(n){return nl(n.homeDir,".config","systemd","user",dr)},async install(n){let e=this.configPath(n);await Yd(tl(e),{recursive:!0}),await el(e,this.renderConfig(n),"utf8"),fr.info("systemd unit written",{unitPath:e}),await lr("systemctl",["--user","daemon-reload"]),await lr("systemctl",["--user","enable","--now",dr]),fr.info("systemd unit enabled",{unitName:dr})},async uninstall(n){let e=this.configPath(n);await lr("systemctl",["--user","disable","--now",dr]).catch(s=>fr.warn("systemctl disable failed (ignored)",{err:String(s)})),await Qd(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await lr("systemctl",["--user","daemon-reload"]).catch(()=>{}),fr.info("systemd unit removed",{unitPath:e})}}});import{spawn as rl}from"node:child_process";import{join as il}from"node:path";function Ja(n,e){return new Promise((s,a)=>{let c=rl(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),u="";c.stderr?.on("data",f=>{u+=f.toString("utf8")}),c.on("error",a),c.on("close",f=>{f===0?s():a(new Error(`${n} ${e.join(" ")} exited ${f}: ${u.trim()}`))})})}var _i,hr,wi,Va=Le(()=>{"use strict";q();_i=N("supervisor.taskscheduler"),hr="CozeBridge",wi={platform:"win32",renderConfig(n){return`<?xml version="1.0" encoding="UTF-16"?>
55
+ `},configPath(n){return rl(n.homeDir,".config","systemd","user",pr)},async install(n){let e=this.configPath(n);await Qd(nl(e),{recursive:!0}),await tl(e,this.renderConfig(n),"utf8"),gr.info("systemd unit written",{unitPath:e}),await mr("systemctl",["--user","daemon-reload"]),await mr("systemctl",["--user","enable","--now",pr]),gr.info("systemd unit enabled",{unitName:pr})},async uninstall(n){let e=this.configPath(n);await mr("systemctl",["--user","disable","--now",pr]).catch(s=>gr.warn("systemctl disable failed (ignored)",{err:String(s)})),await el(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await mr("systemctl",["--user","daemon-reload"]).catch(()=>{}),gr.info("systemd unit removed",{unitPath:e})}}});import{spawn as il}from"node:child_process";import{join as sl}from"node:path";function Xa(n,e){return new Promise((s,o)=>{let c=il(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),u="";c.stderr?.on("data",f=>{u+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${u.trim()}`))})})}var bi,_r,vi,Za=Me(()=>{"use strict";q();bi=O("supervisor.taskscheduler"),_r="CozeBridge",vi={platform:"win32",renderConfig(n){return`<?xml version="1.0" encoding="UTF-16"?>
56
56
  <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
57
57
  <RegistrationInfo>
58
58
  <Description>Coze Bridge daemon</Description>
@@ -76,17 +76,17 @@ WantedBy=default.target
76
76
  </Exec>
77
77
  </Actions>
78
78
  </Task>
79
- `},configPath(n){return il(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Ja("schtasks",["/Create","/SC","ONLOGON","/TN",hr,"/TR",e,"/RU",n.userName,"/F"]),_i.info("task scheduler entry created",{task:hr})},async uninstall(n){await Ja("schtasks",["/Delete","/TN",hr,"/F"]).catch(e=>_i.warn("schtasks /Delete failed (ignored)",{err:String(e)})),_i.info("task scheduler entry removed",{task:hr})}}});var yi={};Ki(yi,{buildContext:()=>cl,getSupervisor:()=>al,launchdSupervisor:()=>pi,systemdSupervisor:()=>mi,taskSchedulerSupervisor:()=>wi});import{homedir as sl,userInfo as ol}from"node:os";function al(n=process.platform){switch(n){case"darwin":return pi;case"linux":return mi;case"win32":return wi;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function cl(){let n=W();return{nodeBin:process.execPath,entry:fi(n),logFile:n.logFile,homeDir:sl(),userName:ol().username}}var bi=Le(()=>{"use strict";fe();di();Ga();Wa();Va()});$e();q();import{readdir as lc}from"node:fs/promises";import{mkdir as ac,writeFile as cc}from"node:fs/promises";import{join as xc}from"node:path";var uc={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function mt(n,e,s,a){await ac(n,{recursive:!0});let c=uc[e],u=xc(n,c),f=fc(e,s,a);return await cc(u,f,"utf8"),u}function fc(n,e,s){let a=`# Coze Agent: ${e}
79
+ `},configPath(n){return sl(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Xa("schtasks",["/Create","/SC","ONLOGON","/TN",_r,"/TR",e,"/RU",n.userName,"/F"]),bi.info("task scheduler entry created",{task:_r})},async uninstall(n){await Xa("schtasks",["/Delete","/TN",_r,"/F"]).catch(e=>bi.warn("schtasks /Delete failed (ignored)",{err:String(e)})),bi.info("task scheduler entry removed",{task:_r})}}});var Si={};Wi(Si,{buildContext:()=>xl,getSupervisor:()=>cl,launchdSupervisor:()=>wi,systemdSupervisor:()=>yi,taskSchedulerSupervisor:()=>vi});import{homedir as ol,userInfo as al}from"node:os";function cl(n=process.platform){switch(n){case"darwin":return wi;case"linux":return yi;case"win32":return vi;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function xl(){let n=H();return{nodeBin:process.execPath,entry:hi(n),logFile:n.logFile,homeDir:ol(),userName:al().username}}var Ei=Me(()=>{"use strict";fe();gi();$a();Ya();Za()});Ve();q();import{readdir as gc}from"node:fs/promises";import{mkdir as xc,writeFile as uc}from"node:fs/promises";import{join as fc}from"node:path";var dc={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function pt(n,e,s,o){await xc(n,{recursive:!0});let c=dc[e],u=fc(n,c),f=lc(e,s,o);return await uc(u,f,"utf8"),u}function lc(n,e,s){let o=`# Coze Agent: ${e}
80
80
 
81
81
  > framework: \`${n}\`
82
82
 
83
83
  `,c=s?.trim()?s.endsWith(`
84
84
  `)?s:`${s}
85
85
  `:`_No instructions provided._
86
- `;return`${a}---
86
+ `;return`${o}---
87
87
 
88
88
  ${c}
89
- ${dc}`}var dc=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
89
+ ${hc}`}var hc=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
90
90
 
91
91
  \u8981\u628A\u751F\u6210\u7684\u56FE\u7247 / PDF / \u6587\u4EF6\u76F4\u63A5\u53D1\u5230\u7528\u6237 IM, \u7528:
92
92
 
@@ -101,25 +101,25 @@ ${dc}`}var dc=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
101
101
  - \u5931\u8D25\u9519\u8BEF\u4FE1\u606F\u5728 stderr, \u770B\u5B8C\u518D\u8C03\u6574\u91CD\u8BD5
102
102
 
103
103
  \u26A0\uFE0F \u751F\u6210\u6587\u4EF6\u540E\u8BF7**\u7B49\u6587\u4EF6\u5B8C\u6574\u5199\u76D8**\u518D send (\u7528 \`&&\` \u4E32\u884C, \u4E0D\u8981 \`&\` \u540E\u53F0)\u3002
104
- `;var Ee=N("agent-detail-sync"),dn=class{constructor(e){this.opts=e}opts;async syncAll(e){let s=this.opts.paths.agentsRoot,a;try{a=await lc(s)}catch(c){Ee.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}Ee.info("starting detail sync",{reason:e,count:a.length});for(let c of a)try{await this.syncOne(c)}catch(u){Ee.warn("detail sync failed for agent, skipping",{agentId:c,err:String(u)})}Ee.info("detail sync done",{reason:e})}async syncOne(e){let s=await he(e,this.opts.paths);if(!s){Ee.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}})}catch(f){Ee.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});return}if(a.agentId&&a.agentId!==e){Ee.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let c=!1,u=!1;if(a.agentName&&a.agentName!==s.agentName&&(s.agentName=a.agentName,c=!0),a.description!==void 0&&a.description!==s.description&&(s.description=a.description,c=!0),a.cozeIdentity&&a.cozeIdentity!==s.cozeIdentity&&(s.cozeIdentity=a.cozeIdentity,c=!0,u=!0),a.deployType&&Ee.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Ee.debug("detail sync: no diff",{agentId:e});return}await be(s,this.opts.paths),Ee.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:s.agentName}),u&&(await mt(s.workspace,s.framework,e,s.cozeIdentity),await this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};$e();import{spawn as ms}from"node:child_process";import{lstat as Dr,mkdir as pc,readFile as _s,readdir as mc,rm as _c,stat as wc,writeFile as gs}from"node:fs/promises";import{join as Ie,normalize as yc,relative as ws,resolve as bc,sep as ys}from"node:path";var Ce={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 Mt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function Qi(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function _t(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var E=class extends Error{code;retriable;cause;constructor(e,s,a){super(s),this.name="BridgeError",this.code=e,this.retriable=a?.retriable??!1,a?.cause!==void 0&&(this.cause=a.cause)}};q();fe();function Me(n,e){if(Mt(n)!=="cloud")throw new E("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function ln(n){return n.startsWith("http://")||n.startsWith("https://")}function hn(n){return n.endsWith("/")?n.slice(0,-1):n}q();var gn="1008033",es="1289";var ts="pbbp2",ns="https://www.coze.cn",rs="/api/coze_claw/resource/get_frontier_key",hc="https://www.coze.cn",gc="wss://frontier.coze.cn";function pn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??hc}function is(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??gc}function wt(n){let e={},s=n?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,a=n?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return s&&(e["x-tt-env"]=s),a&&(e["x-use-ppe"]=a),e}function mn(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var ss=N("handshake");async function os(n){let e=pn(n.endpoint),s=n.timeoutMs??1e4,a=`${hn(e)}${rs}?aid=${encodeURIComponent(gn)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...wt(n.ppeOverride)},u=new AbortController,f=setTimeout(()=>u.abort(),s);ss.info("frontier key handshake",{base:e});try{let h=await fetch(a,{method:"GET",headers:c,signal:u.signal}),m=h.headers.get("x-tt-logid")??"",y=h.headers.get("x-tt-trace-id")??"";if(!h.ok){let C=await h.text().catch(()=>"");throw new E("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${h.status} logid=${m}: ${C.slice(0,200)}`)}let b=await h.json();if(b.code!==void 0&&b.code!==0)throw new E("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${b.code} msg=${b.msg??"-"} logid=${m}`);let w=b.data?.access_key,S=b.data?.device_id;if(!w||!S)throw new E("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id logid=${m}: ${JSON.stringify(b)}`);return ss.info("handshake ok",{remoteDeviceId:S,logid:m,traceId:y}),{accessKey:w,deviceId:S}}catch(h){throw h instanceof E?h:h.name==="AbortError"?new E("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new E("UPSTREAM_HANDSHAKE_FAILED",String(h),{cause:h})}finally{clearTimeout(f)}}var Pr="https://llm-gateway.coze.cn",Ae="auto";function as(n){return{model:n.model??Ae,...n.modelToken?{modelToken:n.modelToken}:{}}}function cs(n){return!n||n===Ae}function xs(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Pr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Ae):cs(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function us(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Ae}"`):cs(n.model)||e.push("-c",`model="${n.model}"`),n.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Pr}/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"')),e}function fs(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function kr(n){let{ttEnv:e,usePpe:s}=mn(n),a={};return e&&(a["x-tt-env"]=e),s&&(a["x-use-ppe"]=s),a}function ds(n,e){if(!n.modelToken)return{};let s=kr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,u])=>`${c}:${u}`).join(`
105
- `)}}function Tr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function ls(n,e){if(!n.modelToken)return null;let s=n.model||Ae,a=kr(e),c={baseUrl:`${Pr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(a).length>0&&(c.headers=a),c}function hs(n,e){if(!n.modelToken)return[];let s=kr(e),a=[];for(let[c,u]of Object.entries(s))a.push("-c",`model_providers.coze.http_headers.${c}="${u}"`);return a}var de=N("agent-handlers"),ps=5*1024*1024,vc=1,Sc=6,Ec=new Set(["node_modules",".git",".coze","dist","build",".next"]),_n=class{constructor(e){this.opts=e}opts;async listSkills(e){Me(e._meta,"_agent/listSkills");let s=_t(e._meta),a=await this.loadAgentCfg(s),c=a?.workspace??Be(s).workspace,u=a?.skills??[],f=[];for(let h of u){let m=Ie(c,h.relPath,"SKILL.md");await wc(m).then(b=>b.isFile()).catch(()=>!1)&&f.push(kc(h))}return{skills:f}}async addSkills(e){Me(e._meta,"_agent/addSkills");let s=_t(e._meta),a=await this.requireAgentCfg(s),c=e.skills??[],u=[...a.skills??[]],f=new Map(u.map((m,y)=>[m.skillId,y])),h=[];for(let m of c){let y=await Nr({agentId:s,workspace:a.workspace,framework:a.framework,skill:m});Rr(u,f,y),h.push(m)}return await un(s,u),await this.reloadAgentSessions(s,"skills-added"),{installedSkills:h}}async removeSkills(e){Me(e._meta,"_agent/removeSkills");let s=_t(e._meta),a=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),u=a.skills??[],f=[];for(let h of u){if(!c.has(h.skillId)){f.push(h);continue}let m=Ie(a.workspace,h.relPath);await _c(m,{recursive:!0,force:!0}),de.info("skill removed",{agentId:s,skillId:h.skillId,relPath:h.relPath})}return await un(s,f),await this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){return this.reloadAgentSessions(e,s)}async reloadAgentSessions(e,s){let a=this.opts.agents.get(e);if(a&&a.framework!=="codex"){for(let[c,u]of a.sessions)if(!(!u.downstream||!u.acpSessionId)){u.loadingSession=!0;try{await u.downstream.sessionLoad({sessionId:u.acpSessionId,cwd:a.workspace}),de.info("session reloaded",{reason:s,agentId:e,framework:a.framework,cloudId:c,acpId:u.acpSessionId})}catch(f){de.warn("session reload failed",{reason:s,agentId:e,framework:a.framework,cloudId:c,acpId:u.acpSessionId,err:String(f)})}finally{u.loadingSession=!1}}}}async updateAgent(e){if(!e.cozeIdentity?.trim())return de.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,a=await he(s);if(!a)throw new E("AGENT_NOT_FOUND",`agent not found: ${s}`);return a.cozeIdentity===e.cozeIdentity?(de.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0}):(a.cozeIdentity=e.cozeIdentity,await be(a),await mt(a.workspace,a.framework,s,e.cozeIdentity),de.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:a.framework}),await this.reloadAgentSessions(s,"identity-changed"),{ok:!0})}async disconnectAgent(e){let s=e.agentId;if(!s)throw new E("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let a=await he(s);return a?(a.disconnectedAt=Date.now(),a.disconnectReason=e.reason??"",await be(a),de.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(de.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(Me(e._meta,"_agent/switchModel"),!e.agentId)throw new E("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Ae,a=await he(e.agentId);if(!a)throw new E("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);a.model=s,await be(a),de.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return de.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s;let u=[];for(let[f,h]of c.allSessionQueues())u.push(h.enqueue(async()=>{let m=c.sessions.get(f);m?.downstream&&(await m.downstream.stop(`switchModel: ${s}`).catch(()=>{}),m.downstream=void 0)}));return await Promise.all(u),de.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:u.length}),{ok:!0}}async resetAgent(e){if(Me(e._meta,Ce.RESET),!e.agentId)throw new E("IPC_BAD_REQUEST",`${Ce.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Ce.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Me(e._meta,Ce.REPAIR),!e.agentId)throw new E("IPC_BAD_REQUEST",`${Ce.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new E("IPC_BAD_REQUEST",`${Ce.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(a){de.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(a)})}return await this.runDetailSync(e.agentId,Ce.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,a){if(!this.opts.detailSyncer){de.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){de.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:a,err:String(c)})}}async getFileTree(e){Me(e._meta,"_agent/getFileTree");let s=e._meta,a=_t(s),c=await this.resolveWorkspace(a),u=e.filePath??"",f=this.safeJoin(c,u),h=await Dr(f).catch(()=>null);if(!h)throw new E("IPC_BAD_REQUEST",`path not found: ${u}`);if(h.isSymbolicLink())throw new E("IPC_BAD_REQUEST",`symlink not allowed: ${u}`);let m=Oc(e.depth);return h.isDirectory()?{tree:await bs(c,f,u,m)}:{tree:[{name:Bc(u),path:vs(u||"."),isDir:!1,size:h.size,modifiedAt:Math.floor(h.mtimeMs)}]}}async getFileContent(e){Me(e._meta,"_agent/getFileContent");let s=_t(e._meta),a=await this.resolveWorkspace(s);if(!e.filePath)throw new E("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(a,e.filePath),u=await Dr(c).catch(()=>null);if(!u||!u.isFile())throw new E("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(u.isSymbolicLink())throw new E("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(u.size>ps)throw new E("IPC_BAD_REQUEST",`file too large: ${u.size} bytes (max ${ps})`);let f=await _s(c);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:u.size}:{content:f.toString("utf8"),encoding:"utf-8",size:u.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await he(e).catch(()=>null))?.workspace??Be(e).workspace}safeJoin(e,s){let a=bc(e,s||"."),c=ws(e,a);if(c.startsWith("..")||c===".."||c.startsWith(`..${ys}`))throw new E("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return a}loadAgentCfg(e){return he(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new E("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Cc(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new E("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new E("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Ac(n){return n==="claude-code"?Ie(".claude","skills"):Ie(".agents","skills")}var Ic=3e4,Pc=50*1024*1024,wn=3e4;async function Nr(n){let{agentId:e,workspace:s,framework:a,skill:c}=n;if(!c.skillName)throw new E("IPC_BAD_REQUEST","skill missing skillName");let u=typeof c.content=="string"&&c.content.length>0,f=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!u&&!f)throw new E("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let h=Cc(c.skillName),m=Ac(a),y=Ie(m,h),b=Ie(s,y);if(await pc(b,{recursive:!0}),u){let S=Buffer.from(c.content,"utf8");zt(S.length),await gs(Ie(b,"SKILL.md"),S,"utf8")}else{let S=await Tc(c.downloadUrl);Nc(S)?await Rc(S,b):await gs(Ie(b,"SKILL.md"),S.toString("utf8"),"utf8")}let w={skillId:c.skillId,skillName:c.skillName,relPath:y,installedAt:Date.now(),...c.description?{description:c.description}:{},...c.icon?{icon:c.icon}:{},...c.version?{version:c.version}:{},...c.downloadUrl?{downloadUrl:c.downloadUrl}:{},...c.config?{config:c.config}:{},...c.builtin?{builtin:c.builtin}:{}};return de.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:y,source:u?"content":"downloadUrl"}),w}function Rr(n,e,s){let a=e.get(s.skillId);if(a!==void 0){n[a]=s;return}e.set(s.skillId,n.length),n.push(s)}function kc(n){return{skillId:n.skillId,skillName:n.skillName,...n.description?{description:n.description}:{},...n.icon?{icon:n.icon}:{},...n.version?{version:n.version}:{},...n.config?{config:n.config}:{},...n.builtin?{builtin:n.builtin}:{}}}async function Tc(n){if(!n)throw new E("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);zt(e);let s=Dc(n);return zt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await _s(e);return zt(s.length),s}if(ln(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Ic);try{let a=await fetch(n,{signal:e.signal});if(!a.ok)throw new E("IPC_BAD_REQUEST",`fetch skill failed HTTP ${a.status} ${n}`);let c=await a.arrayBuffer();return zt(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new E("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function zt(n){if(n>Pc)throw new E("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Dc(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new E("IPC_BAD_REQUEST","bad data URL");let s=!!e[2],a=e[3]??"";return s?Buffer.from(a,"base64"):Buffer.from(decodeURIComponent(a),"utf8")}function Nc(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Rc(n,e){await Lc(n),await new Promise((s,a)=>{let c=ms("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),u="";c.stderr?.on("data",h=>{u+=String(h)});let f=setTimeout(()=>{c.kill("SIGKILL"),a(new E("IPC_BAD_REQUEST",`tar extract timeout (${wn}ms)`))},wn);c.on("error",h=>{clearTimeout(f),a(new E("IPC_BAD_REQUEST",`tar spawn failed: ${h.message}`,{cause:h}))}),c.on("exit",h=>{clearTimeout(f),h===0?s():a(new E("IPC_BAD_REQUEST",`tar exit ${h}${u?`: ${u.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Lc(n){let e=await new Promise((s,a)=>{let c=ms("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),u="",f="";c.stdout?.on("data",m=>{u+=String(m)}),c.stderr?.on("data",m=>{f+=String(m)});let h=setTimeout(()=>{c.kill("SIGKILL"),a(new E("IPC_BAD_REQUEST",`tar list timeout (${wn}ms)`))},wn);c.on("error",m=>{clearTimeout(h),a(new E("IPC_BAD_REQUEST",`tar list spawn failed: ${m.message}`))}),c.on("exit",m=>{clearTimeout(h),m===0?s(u):a(new E("IPC_BAD_REQUEST",`tar list exit ${m}${f?`: ${f.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
106
- `)){let a=s.trim();if(!a)continue;let c=a.charCodeAt(0);if(c!==45&&c!==100)throw new E("IPC_BAD_REQUEST",`tar entry kind '${a[0]}' not allowed (symlink/hardlink/special): ${a.slice(0,100)}`);let f=(a.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!f)continue;if(f.startsWith("/"))throw new E("IPC_BAD_REQUEST",`tar entry absolute path: ${f}`);if(f.split(/[/\\]/).some(m=>m===".."))throw new E("IPC_BAD_REQUEST",`tar entry contains '..': ${f}`)}}async function bs(n,e,s,a){if(a<=0)return[];let c;try{c=await mc(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let f of c){if(Ec.has(f.name)||f.isSymbolicLink())continue;let h=Ie(e,f.name),m=yc(Ie(s,f.name)),y=null;try{y=await Dr(h)}catch{continue}if(y.isSymbolicLink())continue;let b={name:f.name,path:vs(ws(n,h)),isDir:y.isDirectory(),size:y.size,modifiedAt:Math.floor(y.mtimeMs)};y.isDirectory()&&a>1&&(b.children=await bs(n,h,m,a-1)),u.push(b)}return u.sort((f,h)=>f.isDir!==h.isDir?f.isDir?-1:1:f.name.localeCompare(h.name)),u}function Oc(n){return!n||n<=0?vc:Math.min(n,Sc)}function Bc(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function vs(n){return n.split(ys).join("/")}q();import{readFileSync as _h}from"node:fs";import{dirname as yh,join as bh}from"node:path";import{fileURLToPath as Sh}from"node:url";var yn="0.1.38";var Ft=N("agent-health-reporter"),Mc=1e4,bn=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Mc}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()}),Ft.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Ft.info("heartbeat stopped"))}async tick(){if(this.inFlight){Ft.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){Ft.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let s=[];for(let c of this.opts.core.agents.values()){let u=zc(c);u&&s.push({agentId:c.agentId,status:u})}if(s.length===0)return;let a={agents:s,bridgeVersion:yn,_meta:{cozeDeviceId:e}};try{await this.opts.core.sendRequest("_agent/health",a)}catch(c){Ft.warn("heartbeat batch send failed",{count:s.length,err:String(c)})}}finally{this.inFlight=!1}}};function zc(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}$e();import{mkdir as Br,rm as lx}from"node:fs/promises";q();import{execFile as Fc}from"node:child_process";import{promisify as qc}from"node:util";var Es=qc(Fc),qt=N("agents.acp-installer"),Uc={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Hc=5e4,Kc=5e3,jc=5*6e4,Sn=new Map,vn=new Map,Lr=new Map;async function Ss(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await Es(e,[n],{timeout:Kc});return s.split(`
107
- `)[0]?.trim()||void 0}catch{return}}async function Gc(n){qt.info("npm install -g start",{npmPackage:n}),await Es("npm",["install","-g",`${n}@latest`],{timeout:Hc,maxBuffer:10*1024*1024}),qt.info("npm install -g done",{npmPackage:n})}async function Cs(n){let e=Uc[n];if(!e)return;let s=Sn.get(n);if(s)return s;let a=vn.get(n);if(a&&Date.now()-a<jc)return;let c=Lr.get(n);if(c)return c;let u=(async()=>{let f=await Ss(e.binary);if(f)return Sn.set(n,f),qt.info("acp wrapper found on PATH",{binary:e.binary,path:f}),f;try{await Gc(e.npmPackage)}catch(m){qt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:e.npmPackage,err:String(m)}),vn.set(n,Date.now());return}let h=await Ss(e.binary);if(!h){qt.warn("acp wrapper installed but binary not found on PATH",{binary:e.binary}),vn.set(n,Date.now());return}return Sn.set(n,h),vn.delete(n),h})().finally(()=>{Lr.delete(n)});return Lr.set(n,u),u}function En(n){return Sn.get(n)}import{spawn as Xc,spawnSync as Zc}from"node:child_process";function Ut(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function Ht(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function yt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function st(n,e){return{jsonrpc:"2.0",id:n,error:e}}var Cn=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)}},j={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};function As(n){return"method"in n&&"id"in n&&n.id!==void 0}function Is(n){return"method"in n&&!("id"in n)}function An(n){return!("method"in n)&&"id"in n}var Wc={AGENT_NOT_FOUND:j.AGENT_NOT_FOUND,AGENT_BUSY:j.AGENT_BUSY,AGENT_DISCONNECTED:j.AGENT_DISCONNECTED,AGENT_TIMEOUT:j.AGENT_TIMEOUT,AGENT_SPAWN_FAILED:j.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:j.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:j.INTERNAL_ERROR,BRIDGE_INTERNAL:j.INTERNAL_ERROR,IPC_AUTH_FAILED:j.INTERNAL_ERROR,IPC_BAD_REQUEST:j.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:j.MODEL_TOKEN_GEN_FAILED,OPERATION_NOT_ALLOWED_FOR_LOCAL:j.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:j.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:j.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:j.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:j.FILE_TOO_LARGE,UNSUPPORTED_MIME:j.UNSUPPORTED_MIME,UPLOAD_FAILED:j.UPLOAD_FAILED,UPSTREAM_NOT_READY:j.UPSTREAM_NOT_READY};function Kt(n){return n instanceof E?{code:Wc[n.code]??j.INTERNAL_ERROR,message:n.message,data:{bridgeCode:n.code,retriable:n.retriable}}:{code:j.INTERNAL_ERROR,message:n instanceof Error?n.message:String(n)}}function Ps(n){let e=n.data,s=e?.bridgeCode??"AGENT_PROTOCOL_ERROR";return new E(s,n.message,{retriable:e?.retriable??!1,cause:n.data})}function ks(n){return`${JSON.stringify(n)}
108
- `}var In=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){this.buffer+=typeof e=="string"?e:e.toString("utf8");let s=this.buffer.split(`
109
- `);this.buffer=s.pop()??"";let a=[];for(let c of s){let u=c.replace(/\r$/,"").trim();if(u)try{a.push(JSON.parse(u))}catch(f){this.onError?.({line:u,error:f})}}return a}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(s){return this.onError?.({line:e,error:s}),[]}}};var Ds={"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"},zh=Object.fromEntries(Object.entries(Ds).map(([n,e])=>[e,n])),Jc={"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:[]},bt=class{seq=0;next(e,s){this.seq+=1;let a=Ds[e]??Vc(e),c=Jc[a]??[],u=[a,String(this.seq)];if(c.length>0){let f=c.map(m=>Ts(s?.[m]??"")),h=$c(f).join(":");h&&u.push(h)}else s&&Object.values(s).some(f=>f)&&u.push(Object.values(s).filter(Boolean).map(f=>Ts(String(f))).join(":"));return u.join("_")}reset(){this.seq=0}};function Vc(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Ts(n){return n.replace(/[:_\s]+/g,"-")}function $c(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}q();var Yc=3e4,Qc=50,ex=20,Ns=500;function tx(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=Ns?n:`${e.slice(0,Ns)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Rs(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),Zc("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var Xe=class{constructor(e){this.opts=e;this.log=N(`downstream.${this.constructor.name}`),this.decoder=new In({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new bt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new E("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=Xc(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=s,s.stdout?.setEncoding("utf8"),s.stdout?.on("data",a=>{for(let c of this.decoder.push(a))this.dispatch(c)}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",a=>{let c=a.trimEnd();this.stderrRing.push(c),this.stderrRing.length>Qc&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.on("exit",(a,c)=>{this.stopped=!0,(a!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:a,signal:c,recentStderr:this.stderrRing.slice(-ex)}),this.failAllPending(new E("AGENT_PROTOCOL_ERROR",`agent exited (${a}/${c})`));for(let f of this.exitHandlers)f(a,c)}),s.on("error",a=>{this.log.error("child error",{err:String(a)}),this.failAllPending(new E("AGENT_SPAWN_FAILED",String(a),{cause:a}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,a=new Promise(u=>s.once("exit",()=>u()));Rs(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||Rs(s.pid,"SIGKILL")},5e3);try{await a}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}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){return this.call("session/prompt",e,0)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Ht("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(yt(e,s))}catch(a){this.log.warn("respondAgentRequest write failed",{id:e,err:String(a)})}}respondAgentRequestError(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(st(e,s))}catch(a){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(a)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,a=Yc){if(!this.child||this.stopped)return Promise.reject(new E("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),u=Ut(c,e,s),f=a>0&&Number.isFinite(a);return new Promise((h,m)=>{let y=f?setTimeout(()=>{this.pending.delete(c),m(new E("AGENT_TIMEOUT",`${e} timed out after ${a}ms`))},a):null;this.pending.set(c,{resolve:h,reject:m,timer:y,method:e});try{this.writeFrame(u)}catch(b){y&&clearTimeout(y),this.pending.delete(c),m(b)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new E("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(ks(e))}dispatch(e){if(An(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(Ps(e.error))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:tx(e.result)}),s.resolve(e.result));return}if(Is(e)){if(e.method==="session/update")for(let s of this.updateHandlers)Promise.resolve(s(e.params)).catch(a=>this.log.warn("update handler failed",{err:String(a)}));else this.log.debug("unknown notification",{method:e.method});return}if(As(e)){let s=e;this.handleAgentRequest(s).catch(a=>this.log.error("agent request handler failed",{method:s.method,err:String(a)}))}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(st(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}for(let s of this.agentRequestHandlers)try{await s(e)}catch(a){this.log.error("agentRequestHandler threw",{method:e.method,err:String(a)});try{this.writeFrame(st(e.id,Kt(a)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var nx="@agentclientprotocol/claude-agent-acp@latest";function rx(n){let e={};for(let[s,a]of Object.entries(n))a!==void 0&&(s.startsWith("CLAUDE")||s==="AI_AGENT"||s==="BAGGAGE"||(e[s]=a));return e}var Pn=class extends Xe{framework="claude-code";constructor(e){let s=En("claude-code"),[a,c]=s?[s,[]]:["npx",["-y",nx]],u=e.command??a,f=e.args??c,h={command:u,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(h)}sanitizeEnv(e){return rx(e)}};import{mkdtempSync as ix,rmSync as sx}from"node:fs";import{tmpdir as ox}from"node:os";import{join as ax}from"node:path";var cx="@zed-industries/codex-acp@latest",kn=class extends Xe{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=En("codex"),[a,c]=s?[s,[]]:["npx",["-y",cx]],u=e.command??a,f=e.args??c,h=e.extraArgs?[...f,...e.extraArgs]:f,m=e.isolateCodexHome?ix(ax(ox(),"coze-bridge-codex-home-")):void 0,y=m?{...e.env??{},CODEX_HOME:m}:e.env,b={command:u,args:h,cwd:e.cwd,...y?{env:y}:{}};super(b),this.authMethodId=e.authMethodId,this.codexHomeDir=m}async initialize(e){let s=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),s}async stop(e){if(await super.stop(e),this.codexHomeDir)try{sx(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var jt=class extends Xe{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let s=e.sessionName??"default",a=["acp","--session",`agent:${e.agentId}:${s}`];e.gatewayToken&&a.push("--token",e.gatewayToken);let c={command:e.command,args:a,cwd:e.cwd,...e.env?{env:e.env}:{}};super(c),this.agentId=e.agentId,this.sessionName=s,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]}))}get acpSessionName(){return this.sessionName}};q();fe();function Or(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var vt=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((s,a)=>{this.slots.push({task:e,resolve:s,reject:a}),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}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 s=await e.task();e.resolve(s)}catch(s){e.reject(s)}}}finally{this.running=!1}}}};var Tn=class{agentId;framework;workspace;deployType;sessions=new Map;sessionQueues=new Map;activeTriggers=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"}getSessionQueue(e){let s=this.sessionQueues.get(e);return s||(s=new vt,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}async dispose(e){this.status="stopped";let s=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let a of this.sessionQueues.values())a.dispose(s);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let s=[];for(let[,a]of this.sessions)Gt(a),a.downstream&&(s.push(a.downstream.stop(e).catch(()=>{})),a.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function Gt(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as xx}from"node:child_process";import{homedir as ux}from"node:os";import{join as fx}from"node:path";on();q();async function Bs(){let n=fx(ux(),".openclaw/openclaw.json");return(await pt(n))?.gateway?.auth?.token??""}var Ls=N("openclaw.config"),dx=[0,5e3,5e3],Os="models.providers.",Dn="agents.defaults.models",Nn=class{command;env;retryDelaysMs;queue=new vt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??dx}async withRetry(e,s){let a;for(let c=0;c<this.retryDelaysMs.length;c++){let u=this.retryDelaysMs[c]??0;u>0&&await new Promise(f=>setTimeout(f,u));try{return await s()}catch(f){a=f,Ls.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(f)})}}throw new E("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${a?.message??"unknown"}`)}runCli(e){return new Promise((s,a)=>{let c=xx(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),u="";c.stderr?.on("data",f=>{u+=f.toString("utf8")}),c.on("error",a),c.on("close",f=>{f===0?s():a(new Error(`exit ${f}: ${u.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(a){let c=String(a);if(s.some(u=>c.includes(u)))return;throw a}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(a){Ls.warn(`${e} failed (best-effort)`,{configPath:s,err:String(a)})}}ensureProvider(e,s){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${Os}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Os}${e}`)}addModelToAllowlist(e,s){let a={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Dn}[${e}]`,()=>this.runCli(["config","set",Dn,JSON.stringify(a),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Dn}[${e}]`,`${Dn}.${e}`)}ensureAgent(e,s,a){let c=["agents","add",e,"--workspace",s,"--non-interactive"];return a&&c.push("--model",a),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(c,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Pe=N("agent-manager"),hx=(n,e,s,a,c,u,f,h)=>{switch(n){case"claude-code":{let m={...c?{...xs(c),...ds(c,f)}:{},...h??{}};return new Pn({cwd:s,...Object.keys(m).length>0?{env:m}:{}})}case"codex":{let m=c?[...us(c),...hs(c,f)]:[],y={...c?fs(c):{},...h??{}},b=!!c;return new kn({cwd:s,...m.length>0?{extraArgs:m}:{},...Object.keys(y).length>0?{env:y}:{},...b?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new jt({command:e,cwd:s,agentId:a,...u?{sessionName:Or(u)}:{},...h&&Object.keys(h).length>0?{env:h}:{}})}};function Ms(n){return n==="claude-code"||n==="codex"}var gx={path:"",version:"cloud-deployed"},px={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},mx=6e4,Rn=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;ipcEndpoint=null;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??hx,this.createTimeoutMs=e.createTimeoutMs??mx}setIpcEndpoint(e){this.ipcEndpoint=e}buildCozeBridgeSpawnEnv(e,s){let a=process.platform==="win32"?";":":",c={PATH:`${this.paths.binDir}${a}${process.env.PATH??""}`,COZE_BRIDGE_AGENT_ID:e,COZE_BRIDGE_SESSION_ID:s};return this.ipcEndpoint&&(c.COZE_BRIDGE_IPC_PORT=String(this.ipcEndpoint.port),c.COZE_BRIDGE_IPC_TOKEN=this.ipcEndpoint.token),c}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new E("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Nn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new E("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new E("IPC_BAD_REQUEST","framework required");let s=Mt(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let a=this.registry.get(e.agentId);if(a){if(a.framework!==e.framework)throw new E("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${a.framework})`);if(a.status==="error")Pe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await a.dispose("rebuild after error").catch(S=>Pe.warn("dispose stale agent failed (ignored)",{err:String(S)})),this.registry.unregister(e.agentId);else return Pe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:a.agentId,workspace:a.workspace,framework:a.framework}}if(!s&&!this.config.frameworksCache?.[e.framework])throw new E("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);s&&Ms(e.framework)&&await Cs(e.framework);let u=Be(e.agentId,this.paths),f=e.workspace??u.workspace,h=Mt(e._meta),m=new AbortController,y=setTimeout(()=>m.abort(new E("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),b,w=!1;try{let S=()=>{if(m.signal.aborted)throw m.signal.reason instanceof Error?m.signal.reason:new E("AGENT_TIMEOUT","_agent/create aborted")};await Br(u.root,{recursive:!0}),await Br(f,{recursive:!0}),await Br(u.logs,{recursive:!0}),S(),await mt(f,e.framework,e.agentId,e.cozeIdentity),S();let C=await he(e.agentId,this.paths).catch(()=>null),I=as({model:e.model??C?.model});if(b=new Tn({agentId:e.agentId,framework:e.framework,workspace:f,model:I.model??Ae,deployType:h}),b.status="ok",C?.sessions){for(let[Z,Y]of Object.entries(C.sessions))b.sessions.set(Z,{acpSessionId:Y.acpSessionId,modelToken:Y.modelToken,tokenGeneratedAt:Y.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let B=Object.keys(C.sessions).length;B>0&&Pe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:B})}this.registry.register(b),w=!0;let k={agentId:e.agentId,framework:e.framework,workspace:f,cozeIdentity:e.cozeIdentity,createdAt:C?.createdAt??Date.now(),sessions:C?.sessions??{},model:I.model};h==="cloud"&&(k.deployType="cloud"),C?.skills&&(k.skills=C.skills),C?.agentName&&(k.agentName=C.agentName),C?.description&&(k.description=C.description),e.framework==="openclaw"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,f):Pe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let L=e.initialSkills??[];if(L.length>0){let B=[...k.skills??[]],Z=new Map(B.map((te,ne)=>[te.skillId,ne])),Y=0;for(let te of L)try{let ne=await Nr({agentId:e.agentId,workspace:f,framework:e.framework,skill:te});Rr(B,Z,ne),Y++}catch(ne){Pe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:te.skillId,skillName:te.skillName,err:String(ne)})}Y>0&&(k.skills=B,Pe.info("initialSkills installed",{agentId:e.agentId,installed:Y,requested:L.length}))}return await be(k,this.paths),Pe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:h}),{ok:!0,agentId:e.agentId,workspace:f,framework:e.framework}}catch(S){throw Pe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(S)}),w&&b&&(await b.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await lx(u.root,{recursive:!0,force:!0}).catch(C=>Pe.warn("rm agent dir failed (ignored)",{err:String(C)})),S instanceof E?S:new E("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,s,a,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&Ms(e.framework))f=gx;else throw new E("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let h=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,m=this.buildCozeBridgeSpawnEnv(e.agentId,a),y;e.framework==="openclaw"?y=await this.buildOpenclawDownstream({session:e,modelConfig:h,cloudSessionId:a,cozeEnv:c,command:f.path,cozeBridgeEnv:m}):y=this.factory(e.framework,f.path,e.workspace,e.agentId,h,a,c,m);try{return await y.start(),await y.initialize(px),y}catch(b){throw await y.stop("spawnSessionDownstream failed").catch(()=>{}),b instanceof E?b:new E("AGENT_SPAWN_FAILED",b instanceof Error?b.message:String(b),{cause:b})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:a,cloudSessionId:c,cozeEnv:u,command:f,cozeBridgeEnv:h}=e,m=Or(c),y=await Bs(),b=a?ls(a,u):null,w;if(b){let S=Tr(c),I=b.models[0]?.id??Ae,k=`${S}/${I}`;if(!this.ensuredProviders.has(k)){let L=this.getOpenclawConfig();await L.ensureProvider(S,b),await L.addModelToAllowlist(k),this.ensuredProviders.add(k)}w=k}return new jt({command:f,cwd:s.workspace,agentId:s.agentId,sessionName:m,...y?{gatewayToken:y}:{},...w?{slashModelOnStart:w}:{},...h&&Object.keys(h).length>0?{env:h}:{}})}async openclawRepair(e,s){let a=this.getOpenclawConfig();await a.deleteAgent(e),await a.ensureAgent(e,s)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let s=this.openclawConfigCache;for(let a of e.sessions.keys()){let c=Tr(a),u=`${c}/${e.model}`;this.ensuredProviders.delete(u),await s.removeProvider(c),await s.removeModelFromAllowlist(u)}}};import{randomUUID as kx}from"node:crypto";import{promises as Tx}from"node:fs";import{basename as Dx}from"node:path";import{promises as yx}from"node:fs";import{basename as bx}from"node:path";q();var zs=N("file-upload"),vx="/api/coze_claw/file/agent_upload",Sx=6e4;async function Fs(n,e={}){let a=`${hn(pn(e.handshakeBase))}${vx}`,c=e.timeoutMs??Sx,u=await yx.readFile(n.path),f=new FormData;f.append("agent_id",n.agentId),f.append("session_id",n.sessionId),f.append("file_name",n.name),f.append("file_content",new Blob([u],{type:n.mimeType}),n.name);let h={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...wt(e.ppeOverride)},m=new AbortController,y=setTimeout(()=>m.abort(),c);zs.info("file upload start",{url:a,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let b=await fetch(a,{method:"POST",headers:h,body:f,signal:m.signal}),w=b.headers.get("x-tt-logid")??"";if(!b.ok){let I=await b.text().catch(()=>"");throw new E("UPLOAD_FAILED",`upload HTTP ${b.status} logid=${w}: ${I.slice(0,200)}`)}let S=await b.json();if(S.code!==void 0&&S.code!==0)throw new E("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${w}`);let C=S.data?.file?.file_url;if(!C)throw new E("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${w}: ${JSON.stringify(S).slice(0,200)}`);return zs.info("file upload ok",{uri:C,logid:w}),{uri:C}}catch(b){throw b instanceof E?b:b.name==="AbortError"?new E("UPLOAD_FAILED",`upload timeout (${c}ms) for ${bx(n.path)}`):new E("UPLOAD_FAILED",String(b),{cause:b})}finally{clearTimeout(y)}}q();import{promises as Ex}from"node:fs";import{extname as Cx}from"node:path";var Ax=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function Ix(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var Px={".txt":"text/plain",".md":"text/markdown"};async function qs(n){let e=await Ex.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Ix(s))return"image/webp";for(let a of Ax)if(a.prefix.every((c,u)=>s[u]===c))return a.mime}finally{await e.close()}return Px[Cx(n).toLowerCase()]??"application/octet-stream"}fe();var Nx=N("agent-send"),Us=50*1024*1024,Rx=new Set(["image/png","image/jpeg","image/webp","image/gif","application/pdf","text/plain","text/markdown"]);async function Hs(n,e){let s=e.core.get(n.agentId);if(!s)throw new E("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new E("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);let a=s.sessions.get(n.sessionId);if(!a)throw new E("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await Zi(n.path,s.workspace))throw new E("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Tx.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new E("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>Us)throw new E("FILE_TOO_LARGE",`${c.size} bytes > limit ${Us}`);let u=await qs(n.path);if(!Rx.has(u))throw new E("UNSUPPORTED_MIME",`mime=${u} not in whitelist`);if(n.kind==="image"&&!u.startsWith("image/"))throw new E("UNSUPPORTED_MIME",`kind=image but mime=${u}`);if(!e.core.upstream.isConnected())throw new E("UPSTREAM_NOT_READY","cloud WS not connected");let f=n.name??Dx(n.path),h=await Fs({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:u,name:f,sizeBytes:c.size},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),m={sessionUpdate:"agent_file",messageId:kx(),content:{type:n.kind==="image"?"image":"resource",uri:h.uri,mimeType:u,name:f,sizeBytes:c.size,...h.fileId!==void 0?{fileId:h.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await e.core.sendAgentFileUpdate(s,a,n.sessionId,m),Nx.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:f,bytes:c.size,mime:u,uri:h.uri}),{ok:!0,uri:h.uri,bytes:c.size,mimeType:u,...h.fileId!==void 0?{fileId:h.fileId}:{}}}q();import{execFile as Lx}from"node:child_process";import{promisify as Ox}from"node:util";var Bx=Ox(Lx),Ze=N("coze-cli-installer"),Ks="@coze/cli@0.1.3-alpha.89c42a",js="https://bnpm.byted.org",Mx="coze",zx=5e3,Fx=9e4,Gs=1e4,Wt=null,Mr=!1;async function Ws(n,e={}){if(Mr)return;if(Wt)return Wt;let s=e.exec??Bx;return Wt=(async()=>{try{let a=await qx(Mx,s);if(a){Ze.info("coze-cli already on PATH, skip install + config + auth",{path:a}),Mr=!0;return}Ze.info("coze-cli install start",{package:Ks,registry:js});try{await s("npm",["i","-g",Ks,"--registry",js],{timeout:Fx,maxBuffer:10*1024*1024}),Ze.info("coze-cli install ok")}catch(c){Ze.warn("coze-cli install failed (skip subsequent steps)",{err:String(c)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:Gs}),Ze.info("coze config set xTTEnv ok",{env:n.env})}catch(c){Ze.warn("coze config set failed (continue to auth login)",{err:String(c)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:Gs}),Ze.info("coze auth login ok")}catch(c){Ze.warn("coze auth login failed",{err:String(c)});return}Mr=!0}finally{Wt=null}})(),Wt}async function qx(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:a}=await e(s,[n],{timeout:zx});return a.split(`
110
- `)[0]?.trim()||void 0}catch{return}}q();import{spawn as Ux}from"node:child_process";import{constants as Js,access as Hx}from"node:fs/promises";import{delimiter as Kx,join as jx}from"node:path";var Gx=N("framework-detector"),Vs={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Wx=[".exe",".cmd",".bat",".ps1"],St=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Ux,access:e.access??Hx}}async detect(e){let s=Vs[e],a=await this.which(s);if(!a)return Gx.debug("framework binary not found",{framework:e,bin:s}),null;let c=await this.probeVersion(a);return{path:a,version:c}}async detectAll(){let e=await Promise.all(Object.keys(Vs).map(async a=>[a,await this.detect(a)])),s={};for(let[a,c]of e)c&&(s[a]=c);return s}async which(e){let s=this.env.pathEnv.split(Kx).filter(Boolean),a=this.env.platform==="win32"?["",...Wx]:[""];for(let c of s)for(let u of a){let f=jx(c,e+u);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?Js.F_OK:Js.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeVersion(e){return new Promise(s=>{let a="",c=!1,u,f=h=>{c||(c=!0,u&&clearTimeout(u),s(h.trim()||"unknown"))};try{let h=this.env.spawn(e,["--version"],{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{h.kill("SIGKILL"),f("unknown")},5e3),h.stdout?.on("data",m=>{a+=m.toString("utf8")}),h.on("error",()=>f("unknown")),h.on("close",()=>{let m=Vx(a).split(/\r?\n/)[0]??"";f(m)})}catch{f("unknown")}})}},Jx=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Vx(n){return n.replace(Jx,"")}on();fe();var $x=10*6e4;function $s(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?$x:e}function Ln(n){return pt(n??W().configFile)}function Et(n,e){return sn(e??W().configFile,n)}import{randomBytes as cu}from"node:crypto";import{mkdir as Xx,readFile as Zx,realpath as Yx,writeFile as Qx}from"node:fs/promises";import{basename as eu,dirname as zr,join as tu,relative as nu,resolve as Xs,sep as ru}from"node:path";q();var Ys=N("fs-rpc");async function Qs(n,e){let s=await to(n.path,e);return await Xx(zr(s),{recursive:!0}),await Qx(s,n.content,"utf8"),Ys.info("fs/write_text_file ok",{path:s,size:n.content.length}),null}async function eo(n,e){let s=await to(n.path,e),a=await Zx(s,"utf8"),c=a;if(typeof n.line=="number"||typeof n.limit=="number"){let u=a.split(`
104
+ `;var Ae=O("agent-detail-sync"),pn=class{constructor(e){this.opts=e}opts;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await gc(s)}catch(c){Ae.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}Ae.info("starting detail sync",{reason:e,count:o.length});for(let c of o)try{await this.syncOne(c)}catch(u){Ae.warn("detail sync failed for agent, skipping",{agentId:c,err:String(u)})}Ae.info("detail sync done",{reason:e})}async syncOne(e){let s=await ge(e,this.opts.paths);if(!s){Ae.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}})}catch(f){Ae.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});return}if(o.agentId&&o.agentId!==e){Ae.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,u=!1;if(o.agentName&&o.agentName!==s.agentName&&(s.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==s.description&&(s.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==s.cozeIdentity&&(s.cozeIdentity=o.cozeIdentity,c=!0,u=!0),o.deployType&&Ae.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Ae.debug("detail sync: no diff",{agentId:e});return}await Se(s,this.opts.paths),Ae.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:s.agentName}),u&&(await pt(s.workspace,s.framework,e,s.cozeIdentity),await this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};Ve();import{spawn as ys}from"node:child_process";import{lstat as Lr,mkdir as _c,readFile as bs,readdir as wc,rm as yc,stat as bc,writeFile as _s}from"node:fs/promises";import{join as ke,normalize as vc,relative as vs,resolve as Sc,sep as Ss}from"node:path";var Ie={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 Ut(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function ns(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function mt(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var E=class extends Error{code;retriable;cause;constructor(e,s,o){super(s),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};q();fe();function Ue(n,e){if(Ut(n)!=="cloud")throw new E("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function mn(n){return n.startsWith("http://")||n.startsWith("https://")}function _n(n){return n.endsWith("/")?n.slice(0,-1):n}q();var wn="1008033",rs="1289";var is="pbbp2",ss="https://www.coze.cn",os="/api/coze_claw/resource/get_frontier_key",pc="https://www.coze.cn",mc="wss://frontier.coze.cn";function yn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??pc}function as(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??mc}function _t(n){let e={},s=n?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,o=n?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return s&&(e["x-tt-env"]=s),o&&(e["x-use-ppe"]=o),e}function bn(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var cs=O("handshake");async function xs(n){let e=yn(n.endpoint),s=n.timeoutMs??1e4,o=`${_n(e)}${os}?aid=${encodeURIComponent(wn)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",..._t(n.ppeOverride)},u=new AbortController,f=setTimeout(()=>u.abort(),s);cs.info("frontier key handshake",{base:e});try{let h=await fetch(o,{method:"GET",headers:c,signal:u.signal}),m=h.headers.get("x-tt-logid")??"",w=h.headers.get("x-tt-trace-id")??"";if(!h.ok){let N=await h.text().catch(()=>"");throw new E("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${h.status} logid=${m}: ${N.slice(0,200)}`)}let b=await h.json();if(b.code!==void 0&&b.code!==0)throw new E("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${b.code} msg=${b.msg??"-"} logid=${m}`);let S=b.data?.access_key,A=b.data?.device_id;if(!S||!A)throw new E("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id logid=${m}: ${JSON.stringify(b)}`);return cs.info("handshake ok",{remoteDeviceId:A,logid:m,traceId:w}),{accessKey:S,deviceId:A}}catch(h){throw h instanceof E?h:h.name==="AbortError"?new E("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new E("UPSTREAM_HANDSHAKE_FAILED",String(h),{cause:h})}finally{clearTimeout(f)}}var Dr="https://llm-gateway.coze.cn",Pe="auto";function us(n){return{model:n.model??Pe,...n.modelToken?{modelToken:n.modelToken}:{}}}function fs(n){return!n||n===Pe}function ds(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Dr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Pe):fs(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function ls(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Pe}"`):fs(n.model)||e.push("-c",`model="${n.model}"`),n.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Dr}/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"')),e}function hs(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Rr(n){let{ttEnv:e,usePpe:s}=bn(n),o={};return e&&(o["x-tt-env"]=e),s&&(o["x-use-ppe"]=s),o}function gs(n,e){if(!n.modelToken)return{};let s=Rr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,u])=>`${c}:${u}`).join(`
105
+ `)}}function Or(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function ps(n,e){if(!n.modelToken)return null;let s=n.model||Pe,o=Rr(e),c={baseUrl:`${Dr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function ms(n,e){if(!n.modelToken)return[];let s=Rr(e),o=[];for(let[c,u]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${u}"`);return o}var de=O("agent-handlers"),ws=5*1024*1024,Ec=1,Cc=6,Ac=new Set(["node_modules",".git",".coze","dist","build",".next"]),vn=class{constructor(e){this.opts=e}opts;async listSkills(e){Ue(e._meta,"_agent/listSkills");let s=mt(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Fe(s).workspace,u=o?.skills??[],f=[];for(let h of u){let m=ke(c,h.relPath,"SKILL.md");await bc(m).then(b=>b.isFile()).catch(()=>!1)&&f.push(Dc(h))}return{skills:f}}async addSkills(e){Ue(e._meta,"_agent/addSkills");let s=mt(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],u=[...o.skills??[]],f=new Map(u.map((m,w)=>[m.skillId,w])),h=[];for(let m of c){let w=await Nr({agentId:s,workspace:o.workspace,framework:o.framework,skill:m});Br(u,f,w),h.push(m)}return await hn(s,u),await this.reloadAgentSessions(s,"skills-added"),{installedSkills:h}}async removeSkills(e){Ue(e._meta,"_agent/removeSkills");let s=mt(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),u=o.skills??[],f=[];for(let h of u){if(!c.has(h.skillId)){f.push(h);continue}let m=ke(o.workspace,h.relPath);await yc(m,{recursive:!0,force:!0}),de.info("skill removed",{agentId:s,skillId:h.skillId,relPath:h.relPath})}return await hn(s,f),await this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){return this.reloadAgentSessions(e,s)}async reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o&&o.framework!=="codex"){for(let[c,u]of o.sessions)if(!(!u.downstream||!u.acpSessionId)){u.loadingSession=!0;try{await u.downstream.sessionLoad({sessionId:u.acpSessionId,cwd:o.workspace}),de.info("session reloaded",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u.acpSessionId})}catch(f){de.warn("session reload failed",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u.acpSessionId,err:String(f)})}finally{u.loadingSession=!1}}}}async updateAgent(e){if(!e.cozeIdentity?.trim())return de.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await ge(s);if(!o)throw new E("AGENT_NOT_FOUND",`agent not found: ${s}`);return o.cozeIdentity===e.cozeIdentity?(de.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0}):(o.cozeIdentity=e.cozeIdentity,await Se(o),await pt(o.workspace,o.framework,s,e.cozeIdentity),de.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),await this.reloadAgentSessions(s,"identity-changed"),{ok:!0})}async disconnectAgent(e){let s=e.agentId;if(!s)throw new E("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await ge(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Se(o),de.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(de.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(Ue(e._meta,"_agent/switchModel"),!e.agentId)throw new E("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Pe,o=await ge(e.agentId);if(!o)throw new E("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,await Se(o),de.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return de.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s;let u=[];for(let[f,h]of c.allSessionQueues())u.push(h.enqueue(async()=>{let m=c.sessions.get(f);m?.downstream&&(await m.downstream.stop(`switchModel: ${s}`).catch(()=>{}),m.downstream=void 0)}));return await Promise.all(u),de.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:u.length}),{ok:!0}}async resetAgent(e){if(Ue(e._meta,Ie.RESET),!e.agentId)throw new E("IPC_BAD_REQUEST",`${Ie.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Ie.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Ue(e._meta,Ie.REPAIR),!e.agentId)throw new E("IPC_BAD_REQUEST",`${Ie.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new E("IPC_BAD_REQUEST",`${Ie.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){de.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Ie.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){de.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){de.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){Ue(e._meta,"_agent/getFileTree");let s=e._meta,o=mt(s),c=await this.resolveWorkspace(o),u=e.filePath??"",f=this.safeJoin(c,u),h=await Lr(f).catch(()=>null);if(!h)throw new E("IPC_BAD_REQUEST",`path not found: ${u}`);if(h.isSymbolicLink())throw new E("IPC_BAD_REQUEST",`symlink not allowed: ${u}`);let m=Mc(e.depth);return h.isDirectory()?{tree:await Es(c,f,u,m)}:{tree:[{name:zc(u),path:Cs(u||"."),isDir:!1,size:h.size,modifiedAt:Math.floor(h.mtimeMs)}]}}async getFileContent(e){Ue(e._meta,"_agent/getFileContent");let s=mt(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new E("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(o,e.filePath),u=await Lr(c).catch(()=>null);if(!u||!u.isFile())throw new E("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(u.isSymbolicLink())throw new E("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(u.size>ws)throw new E("IPC_BAD_REQUEST",`file too large: ${u.size} bytes (max ${ws})`);let f=await bs(c);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:u.size}:{content:f.toString("utf8"),encoding:"utf-8",size:u.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await ge(e).catch(()=>null))?.workspace??Fe(e).workspace}safeJoin(e,s){let o=Sc(e,s||"."),c=vs(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${Ss}`))throw new E("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return ge(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new E("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Ic(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new E("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new E("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Pc(n){return n==="claude-code"?ke(".claude","skills"):ke(".agents","skills")}var kc=3e4,Tc=50*1024*1024,Sn=3e4;async function Nr(n){let{agentId:e,workspace:s,framework:o,skill:c}=n;if(!c.skillName)throw new E("IPC_BAD_REQUEST","skill missing skillName");let u=typeof c.content=="string"&&c.content.length>0,f=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!u&&!f)throw new E("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let h=Ic(c.skillName),m=Pc(o),w=ke(m,h),b=ke(s,w);if(await _c(b,{recursive:!0}),u){let A=Buffer.from(c.content,"utf8");qt(A.length),await _s(ke(b,"SKILL.md"),A,"utf8")}else{let A=await Rc(c.downloadUrl);Lc(A)?await Nc(A,b):await _s(ke(b,"SKILL.md"),A.toString("utf8"),"utf8")}let S={skillId:c.skillId,skillName:c.skillName,relPath:w,installedAt:Date.now(),...c.description?{description:c.description}:{},...c.icon?{icon:c.icon}:{},...c.version?{version:c.version}:{},...c.downloadUrl?{downloadUrl:c.downloadUrl}:{},...c.config?{config:c.config}:{},...c.builtin?{builtin:c.builtin}:{}};return de.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:w,source:u?"content":"downloadUrl"}),S}function Br(n,e,s){let o=e.get(s.skillId);if(o!==void 0){n[o]=s;return}e.set(s.skillId,n.length),n.push(s)}function Dc(n){return{skillId:n.skillId,skillName:n.skillName,...n.description?{description:n.description}:{},...n.icon?{icon:n.icon}:{},...n.version?{version:n.version}:{},...n.config?{config:n.config}:{},...n.builtin?{builtin:n.builtin}:{}}}async function Rc(n){if(!n)throw new E("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);qt(e);let s=Oc(n);return qt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await bs(e);return qt(s.length),s}if(mn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),kc);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new E("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let c=await o.arrayBuffer();return qt(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new E("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function qt(n){if(n>Tc)throw new E("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Oc(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new E("IPC_BAD_REQUEST","bad data URL");let s=!!e[2],o=e[3]??"";return s?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function Lc(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Nc(n,e){await Bc(n),await new Promise((s,o)=>{let c=ys("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),u="";c.stderr?.on("data",h=>{u+=String(h)});let f=setTimeout(()=>{c.kill("SIGKILL"),o(new E("IPC_BAD_REQUEST",`tar extract timeout (${Sn}ms)`))},Sn);c.on("error",h=>{clearTimeout(f),o(new E("IPC_BAD_REQUEST",`tar spawn failed: ${h.message}`,{cause:h}))}),c.on("exit",h=>{clearTimeout(f),h===0?s():o(new E("IPC_BAD_REQUEST",`tar exit ${h}${u?`: ${u.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Bc(n){let e=await new Promise((s,o)=>{let c=ys("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),u="",f="";c.stdout?.on("data",m=>{u+=String(m)}),c.stderr?.on("data",m=>{f+=String(m)});let h=setTimeout(()=>{c.kill("SIGKILL"),o(new E("IPC_BAD_REQUEST",`tar list timeout (${Sn}ms)`))},Sn);c.on("error",m=>{clearTimeout(h),o(new E("IPC_BAD_REQUEST",`tar list spawn failed: ${m.message}`))}),c.on("exit",m=>{clearTimeout(h),m===0?s(u):o(new E("IPC_BAD_REQUEST",`tar list exit ${m}${f?`: ${f.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
106
+ `)){let o=s.trim();if(!o)continue;let c=o.charCodeAt(0);if(c!==45&&c!==100)throw new E("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let f=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!f)continue;if(f.startsWith("/"))throw new E("IPC_BAD_REQUEST",`tar entry absolute path: ${f}`);if(f.split(/[/\\]/).some(m=>m===".."))throw new E("IPC_BAD_REQUEST",`tar entry contains '..': ${f}`)}}async function Es(n,e,s,o){if(o<=0)return[];let c;try{c=await wc(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let f of c){if(Ac.has(f.name)||f.isSymbolicLink())continue;let h=ke(e,f.name),m=vc(ke(s,f.name)),w=null;try{w=await Lr(h)}catch{continue}if(w.isSymbolicLink())continue;let b={name:f.name,path:Cs(vs(n,h)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&o>1&&(b.children=await Es(n,h,m,o-1)),u.push(b)}return u.sort((f,h)=>f.isDir!==h.isDir?f.isDir?-1:1:f.name.localeCompare(h.name)),u}function Mc(n){return!n||n<=0?Ec:Math.min(n,Cc)}function zc(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function Cs(n){return n.split(Ss).join("/")}q();import{readFileSync as wh}from"node:fs";import{dirname as bh,join as vh}from"node:path";import{fileURLToPath as Eh}from"node:url";var En="0.1.39";var Kt=O("agent-health-reporter"),Fc=1e4,Cn=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Fc}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()}),Kt.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Kt.info("heartbeat stopped"))}async tick(){if(this.inFlight){Kt.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){Kt.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let s=[];for(let c of this.opts.core.agents.values()){let u=Uc(c);u&&s.push({agentId:c.agentId,status:u})}if(s.length===0)return;let o={agents:s,bridgeVersion:En,_meta:{cozeDeviceId:e}};try{await this.opts.core.sendRequest("_agent/health",o)}catch(c){Kt.warn("heartbeat batch send failed",{count:s.length,err:String(c)})}}finally{this.inFlight=!1}}};function Uc(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}Ve();import{mkdir as Fr,rm as gx}from"node:fs/promises";q();import{execFile as qc}from"node:child_process";import{promisify as Kc}from"node:util";var Is=Kc(qc),jt=O("agents.acp-installer"),jc={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Gc=5e4,Hc=5e3,Wc=5*6e4,In=new Map,An=new Map,Mr=new Map;async function As(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await Is(e,[n],{timeout:Hc});return s.split(`
107
+ `)[0]?.trim()||void 0}catch{return}}async function Jc(n){jt.info("npm install -g start",{npmPackage:n}),await Is("npm",["install","-g",`${n}@latest`],{timeout:Gc,maxBuffer:10*1024*1024}),jt.info("npm install -g done",{npmPackage:n})}async function Ps(n){let e=jc[n];if(!e)return;let s=In.get(n);if(s)return s;let o=An.get(n);if(o&&Date.now()-o<Wc)return;let c=Mr.get(n);if(c)return c;let u=(async()=>{let f=await As(e.binary);if(f)return In.set(n,f),jt.info("acp wrapper found on PATH",{binary:e.binary,path:f}),f;try{await Jc(e.npmPackage)}catch(m){jt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:e.npmPackage,err:String(m)}),An.set(n,Date.now());return}let h=await As(e.binary);if(!h){jt.warn("acp wrapper installed but binary not found on PATH",{binary:e.binary}),An.set(n,Date.now());return}return In.set(n,h),An.delete(n),h})().finally(()=>{Mr.delete(n)});return Mr.set(n,u),u}function Pn(n){return In.get(n)}import{spawn as Zc,spawnSync as Qc}from"node:child_process";function Gt(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function Ht(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function wt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function it(n,e){return{jsonrpc:"2.0",id:n,error:e}}var kn=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)}},G={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};function ks(n){return"method"in n&&"id"in n&&n.id!==void 0}function Ts(n){return"method"in n&&!("id"in n)}function Tn(n){return!("method"in n)&&"id"in n}var Vc={AGENT_NOT_FOUND:G.AGENT_NOT_FOUND,AGENT_BUSY:G.AGENT_BUSY,AGENT_DISCONNECTED:G.AGENT_DISCONNECTED,AGENT_TIMEOUT:G.AGENT_TIMEOUT,AGENT_SPAWN_FAILED:G.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:G.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:G.INTERNAL_ERROR,BRIDGE_INTERNAL:G.INTERNAL_ERROR,IPC_AUTH_FAILED:G.INTERNAL_ERROR,IPC_BAD_REQUEST:G.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:G.MODEL_TOKEN_GEN_FAILED,OPERATION_NOT_ALLOWED_FOR_LOCAL:G.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:G.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:G.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:G.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:G.FILE_TOO_LARGE,UNSUPPORTED_MIME:G.UNSUPPORTED_MIME,UPLOAD_FAILED:G.UPLOAD_FAILED,UPSTREAM_NOT_READY:G.UPSTREAM_NOT_READY};function Wt(n){return n instanceof E?{code:Vc[n.code]??G.INTERNAL_ERROR,message:n.message,data:{bridgeCode:n.code,retriable:n.retriable}}:{code:G.INTERNAL_ERROR,message:n instanceof Error?n.message:String(n)}}function Ds(n){let e=n.data,s=e?.bridgeCode??"AGENT_PROTOCOL_ERROR";return new E(s,n.message,{retriable:e?.retriable??!1,cause:n.data})}function Rs(n){return`${JSON.stringify(n)}
108
+ `}var Dn=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){this.buffer+=typeof e=="string"?e:e.toString("utf8");let s=this.buffer.split(`
109
+ `);this.buffer=s.pop()??"";let o=[];for(let c of s){let u=c.replace(/\r$/,"").trim();if(u)try{o.push(JSON.parse(u))}catch(f){this.onError?.({line:u,error:f})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(s){return this.onError?.({line:e,error:s}),[]}}};var Ls={"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"},Fh=Object.fromEntries(Object.entries(Ls).map(([n,e])=>[e,n])),$c={"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:[]},yt=class{seq=0;next(e,s){this.seq+=1;let o=Ls[e]??Yc(e),c=$c[o]??[],u=[o,String(this.seq)];if(c.length>0){let f=c.map(m=>Os(s?.[m]??"")),h=Xc(f).join(":");h&&u.push(h)}else s&&Object.values(s).some(f=>f)&&u.push(Object.values(s).filter(Boolean).map(f=>Os(String(f))).join(":"));return u.join("_")}reset(){this.seq=0}};function Yc(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Os(n){return n.replace(/[:_\s]+/g,"-")}function Xc(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}q();var ex=3e4,tx=50,nx=20,Ns=500;function rx(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=Ns?n:`${e.slice(0,Ns)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Bs(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),Qc("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var $e=class{constructor(e){this.opts=e;this.log=O(`downstream.${this.constructor.name}`),this.decoder=new Dn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new yt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new E("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=Zc(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=s,s.stdout?.setEncoding("utf8"),s.stdout?.on("data",o=>{for(let c of this.decoder.push(o))this.dispatch(c)}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>tx&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:this.stderrRing.slice(-nx)}),this.failAllPending(new E("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${c})`));for(let f of this.exitHandlers)f(o,c)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new E("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,o=new Promise(u=>s.once("exit",()=>u()));Bs(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||Bs(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}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){return this.call("session/prompt",e,0)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Ht("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(wt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(it(e,s))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,o=ex){if(!this.child||this.stopped)return Promise.reject(new E("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),u=Gt(c,e,s),f=o>0&&Number.isFinite(o);return new Promise((h,m)=>{let w=f?setTimeout(()=>{this.pending.delete(c),m(new E("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o):null;this.pending.set(c,{resolve:h,reject:m,timer:w,method:e});try{this.writeFrame(u)}catch(b){w&&clearTimeout(w),this.pending.delete(c),m(b)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new E("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Rs(e))}dispatch(e){if(Tn(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(Ds(e.error))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:rx(e.result)}),s.resolve(e.result));return}if(Ts(e)){if(e.method==="session/update")for(let s of this.updateHandlers)Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed",{err:String(o)}));else this.log.debug("unknown notification",{method:e.method});return}if(ks(e)){let s=e;this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed",{method:s.method,err:String(o)}))}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(it(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(it(e.id,Wt(o)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var ix="@agentclientprotocol/claude-agent-acp@latest";function sx(n){let e={};for(let[s,o]of Object.entries(n))o!==void 0&&(s.startsWith("CLAUDE")||s==="AI_AGENT"||s==="BAGGAGE"||(e[s]=o));return e}var Rn=class extends $e{framework="claude-code";constructor(e){let s=Pn("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",ix]],u=e.command??o,f=e.args??c,h={command:u,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(h)}sanitizeEnv(e){return sx(e)}};import{mkdtempSync as ox,rmSync as ax}from"node:fs";import{tmpdir as cx}from"node:os";import{join as xx}from"node:path";var ux="@zed-industries/codex-acp@latest",On=class extends $e{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=Pn("codex"),[o,c]=s?[s,[]]:["npx",["-y",ux]],u=e.command??o,f=e.args??c,h=e.extraArgs?[...f,...e.extraArgs]:f,m=e.isolateCodexHome?ox(xx(cx(),"coze-bridge-codex-home-")):void 0,w=m?{...e.env??{},CODEX_HOME:m}:e.env,b={command:u,args:h,cwd:e.cwd,...w?{env:w}:{}};super(b),this.authMethodId=e.authMethodId,this.codexHomeDir=m}async initialize(e){let s=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),s}async stop(e){if(await super.stop(e),this.codexHomeDir)try{ax(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var bt=class extends $e{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let s=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${s}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let c={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(c),this.agentId=e.agentId,this.sessionName=s,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]}))}get acpSessionName(){return this.sessionName}};q();fe();function zr(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var vt=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((s,o)=>{this.slots.push({task:e,resolve:s,reject:o}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}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 s=await e.task();e.resolve(s)}catch(s){e.reject(s)}}}finally{this.running=!1}}}};var Ln=class{agentId;framework;workspace;deployType;sessions=new Map;sessionQueues=new Map;activeTriggers=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"}getSessionQueue(e){let s=this.sessionQueues.get(e);return s||(s=new vt,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}async dispose(e){this.status="stopped";let s=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(s);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let s=[];for(let[,o]of this.sessions)Jt(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function Jt(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as fx}from"node:child_process";import{homedir as dx}from"node:os";import{join as lx}from"node:path";un();q();async function Fs(){let n=lx(dx(),".openclaw/openclaw.json");return(await gt(n))?.gateway?.auth?.token??""}var Ms=O("openclaw.config"),hx=[0,5e3,5e3],zs="models.providers.",Nn="agents.defaults.models",Bn=class{command;env;retryDelaysMs;queue=new vt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??hx}async withRetry(e,s){let o;for(let c=0;c<this.retryDelaysMs.length;c++){let u=this.retryDelaysMs[c]??0;u>0&&await new Promise(f=>setTimeout(f,u));try{return await s()}catch(f){o=f,Ms.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(f)})}}throw new E("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let c=fx(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),u="";c.stderr?.on("data",f=>{u+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`exit ${f}: ${u.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(o){let c=String(o);if(s.some(u=>c.includes(u)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){Ms.warn(`${e} failed (best-effort)`,{configPath:s,err:String(o)})}}ensureProvider(e,s){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${zs}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${zs}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Nn}[${e}]`,()=>this.runCli(["config","set",Nn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Nn}[${e}]`,`${Nn}.${e}`)}ensureAgent(e,s,o){let c=["agents","add",e,"--workspace",s,"--non-interactive"];return o&&c.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(c,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Te=O("agent-manager"),px=(n,e,s,o,c,u,f,h)=>{switch(n){case"claude-code":{let m={...c?{...ds(c),...gs(c,f)}:{},...h??{}};return new Rn({cwd:s,...Object.keys(m).length>0?{env:m}:{}})}case"codex":{let m=c?[...ls(c),...ms(c,f)]:[],w={...c?hs(c):{},...h??{}},b=!!c;return new On({cwd:s,...m.length>0?{extraArgs:m}:{},...Object.keys(w).length>0?{env:w}:{},...b?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new bt({command:e,cwd:s,agentId:o,...u?{sessionName:zr(u)}:{},...h&&Object.keys(h).length>0?{env:h}:{}})}};function Us(n){return n==="claude-code"||n==="codex"}var mx={path:"",version:"cloud-deployed"},_x={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},yx=6e4,Mn=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;ipcEndpoint=null;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??px,this.createTimeoutMs=e.createTimeoutMs??yx}setIpcEndpoint(e){this.ipcEndpoint=e}buildCozeBridgeSpawnEnv(e,s){let o=process.platform==="win32"?";":":",c={PATH:`${this.paths.binDir}${o}${process.env.PATH??""}`,COZE_BRIDGE_AGENT_ID:e,COZE_BRIDGE_SESSION_ID:s};return this.ipcEndpoint&&(c.COZE_BRIDGE_IPC_PORT=String(this.ipcEndpoint.port),c.COZE_BRIDGE_IPC_TOKEN=this.ipcEndpoint.token),c}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new E("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Bn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new E("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new E("IPC_BAD_REQUEST","framework required");let s=Ut(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new E("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")Te.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(D=>Te.warn("dispose stale agent failed (ignored)",{err:String(D)})),this.registry.unregister(e.agentId);else return Te.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}if(!s&&!this.config.frameworksCache?.[e.framework])throw new E("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);s&&Us(e.framework)&&await Ps(e.framework);let u=Fe(e.agentId,this.paths),f=Ut(e._meta),h=e.framework==="openclaw"&&f==="local",m=h?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,w=e.workspace??m??u.workspace,b=new AbortController,S=setTimeout(()=>b.abort(new E("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,N=!1;try{let D=()=>{if(b.signal.aborted)throw b.signal.reason instanceof Error?b.signal.reason:new E("AGENT_TIMEOUT","_agent/create aborted")};await Fr(u.root,{recursive:!0}),await Fr(w,{recursive:!0}),await Fr(u.logs,{recursive:!0}),D(),h||await pt(w,e.framework,e.agentId,e.cozeIdentity),D();let R=await ge(e.agentId,this.paths).catch(()=>null),M=us({model:e.model??R?.model});if(A=new Ln({agentId:e.agentId,framework:e.framework,workspace:w,model:M.model??Pe,deployType:f}),A.status="ok",R?.sessions){for(let[se,$]of Object.entries(R.sessions))A.sessions.set(se,{acpSessionId:$.acpSessionId,modelToken:$.modelToken,tokenGeneratedAt:$.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let ie=Object.keys(R.sessions).length;ie>0&&Te.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ie})}this.registry.register(A),N=!0;let V={agentId:e.agentId,framework:e.framework,workspace:w,cozeIdentity:e.cozeIdentity,createdAt:R?.createdAt??Date.now(),sessions:R?.sessions??{},model:M.model};f==="cloud"&&(V.deployType="cloud"),R?.skills&&(V.skills=R.skills),R?.agentName&&(V.agentName=R.agentName),R?.description&&(V.description=R.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,w):Te.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let te=e.initialSkills??[];if(te.length>0){let ie=[...V.skills??[]],se=new Map(ie.map((le,T)=>[le.skillId,T])),$=0;for(let le of te)try{let T=await Nr({agentId:e.agentId,workspace:w,framework:e.framework,skill:le});Br(ie,se,T),$++}catch(T){Te.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:le.skillId,skillName:le.skillName,err:String(T)})}$>0&&(V.skills=ie,Te.info("initialSkills installed",{agentId:e.agentId,installed:$,requested:te.length}))}return await Se(V,this.paths),Te.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:w,framework:e.framework}}catch(D){throw Te.error("agent create failed, rolling back",{agentId:e.agentId,err:String(D)}),N&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await gx(u.root,{recursive:!0,force:!0}).catch(R=>Te.warn("rm agent dir failed (ignored)",{err:String(R)})),D instanceof E?D:new E("AGENT_SPAWN_FAILED",String(D),{cause:D})}finally{clearTimeout(S)}}async spawnSessionDownstream(e,s,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&Us(e.framework))f=mx;else throw new E("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let h=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,m=this.buildCozeBridgeSpawnEnv(e.agentId,o),w;e.framework==="openclaw"?w=await this.buildOpenclawDownstream({session:e,modelConfig:h,cloudSessionId:o,cozeEnv:c,command:f.path,cozeBridgeEnv:m}):w=this.factory(e.framework,f.path,e.workspace,e.agentId,h,o,c,m);try{return await w.start(),await w.initialize(_x),w}catch(b){throw await w.stop("spawnSessionDownstream failed").catch(()=>{}),b instanceof E?b:new E("AGENT_SPAWN_FAILED",b instanceof Error?b.message:String(b),{cause:b})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:u,command:f,cozeBridgeEnv:h}=e,m=zr(c);if(s.deployType==="local"){let A=this.config.frameworksCache?.openclaw?.defaultAgent;if(!A?.id||!A.workspace)throw new E("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent");return new bt({command:f,cwd:A.workspace,agentId:A.id,sessionName:m,...h&&Object.keys(h).length>0?{env:h}:{}})}let w=await Fs(),b=o?ps(o,u):null,S;if(b){let A=Or(c),D=b.models[0]?.id??Pe,R=`${A}/${D}`;if(!this.ensuredProviders.has(R)){let M=this.getOpenclawConfig();await M.ensureProvider(A,b),await M.addModelToAllowlist(R),this.ensuredProviders.add(R)}S=R}return new bt({command:f,cwd:s.workspace,agentId:s.agentId,sessionName:m,...w?{gatewayToken:w}:{},...S?{slashModelOnStart:S}:{},...h&&Object.keys(h).length>0?{env:h}:{}})}async openclawRepair(e,s){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,s)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let s=this.openclawConfigCache;for(let o of e.sessions.keys()){let c=Or(o),u=`${c}/${e.model}`;this.ensuredProviders.delete(u),await s.removeProvider(c),await s.removeModelFromAllowlist(u)}}};import{randomUUID as Dx}from"node:crypto";import{promises as Rx}from"node:fs";import{basename as Ox}from"node:path";import{promises as vx}from"node:fs";import{basename as Sx}from"node:path";q();var qs=O("file-upload"),Ex="/api/coze_claw/file/agent_upload",Cx=6e4;async function Ks(n,e={}){let o=`${_n(yn(e.handshakeBase))}${Ex}`,c=e.timeoutMs??Cx,u=await vx.readFile(n.path),f=new FormData;f.append("agent_id",n.agentId),f.append("session_id",n.sessionId),f.append("file_name",n.name),f.append("file_content",new Blob([u],{type:n.mimeType}),n.name);let h={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",..._t(e.ppeOverride)},m=new AbortController,w=setTimeout(()=>m.abort(),c);qs.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let b=await fetch(o,{method:"POST",headers:h,body:f,signal:m.signal}),S=b.headers.get("x-tt-logid")??"";if(!b.ok){let D=await b.text().catch(()=>"");throw new E("UPLOAD_FAILED",`upload HTTP ${b.status} logid=${S}: ${D.slice(0,200)}`)}let A=await b.json();if(A.code!==void 0&&A.code!==0)throw new E("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${S}`);let N=A.data?.file?.file_url;if(!N)throw new E("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${S}: ${JSON.stringify(A).slice(0,200)}`);return qs.info("file upload ok",{uri:N,logid:S}),{uri:N}}catch(b){throw b instanceof E?b:b.name==="AbortError"?new E("UPLOAD_FAILED",`upload timeout (${c}ms) for ${Sx(n.path)}`):new E("UPLOAD_FAILED",String(b),{cause:b})}finally{clearTimeout(w)}}q();import{promises as Ax}from"node:fs";import{extname as Ix}from"node:path";var Px=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function kx(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var Tx={".txt":"text/plain",".md":"text/markdown"};async function js(n){let e=await Ax.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),kx(s))return"image/webp";for(let o of Px)if(o.prefix.every((c,u)=>s[u]===c))return o.mime}finally{await e.close()}return Tx[Ix(n).toLowerCase()]??"application/octet-stream"}fe();var Lx=O("agent-send"),Gs=50*1024*1024,Nx=new Set(["image/png","image/jpeg","image/webp","image/gif","application/pdf","text/plain","text/markdown"]);async function Hs(n,e){let s=e.core.get(n.agentId);if(!s)throw new E("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new E("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);let o=s.sessions.get(n.sessionId);if(!o)throw new E("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await es(n.path,s.workspace))throw new E("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Rx.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new E("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>Gs)throw new E("FILE_TOO_LARGE",`${c.size} bytes > limit ${Gs}`);let u=await js(n.path);if(!Nx.has(u))throw new E("UNSUPPORTED_MIME",`mime=${u} not in whitelist`);if(n.kind==="image"&&!u.startsWith("image/"))throw new E("UNSUPPORTED_MIME",`kind=image but mime=${u}`);if(!e.core.upstream.isConnected())throw new E("UPSTREAM_NOT_READY","cloud WS not connected");let f=n.name??Ox(n.path),h=await Ks({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:u,name:f,sizeBytes:c.size},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),m={sessionUpdate:"agent_file",messageId:Dx(),content:{type:n.kind==="image"?"image":"resource",uri:h.uri,mimeType:u,name:f,sizeBytes:c.size,...h.fileId!==void 0?{fileId:h.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await e.core.sendAgentFileUpdate(s,o,n.sessionId,m),Lx.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:f,bytes:c.size,mime:u,uri:h.uri}),{ok:!0,uri:h.uri,bytes:c.size,mimeType:u,...h.fileId!==void 0?{fileId:h.fileId}:{}}}q();import{execFile as Bx}from"node:child_process";import{promisify as Mx}from"node:util";var zx=Mx(Bx),Ye=O("coze-cli-installer"),Ws="@coze/cli@0.1.3-alpha.89c42a",Js="https://bnpm.byted.org",Fx="coze",Ux=5e3,qx=9e4,Vs=1e4,Vt=null,Ur=!1;async function $s(n,e={}){if(Ur)return;if(Vt)return Vt;let s=e.exec??zx;return Vt=(async()=>{try{let o=await Kx(Fx,s);if(o){Ye.info("coze-cli already on PATH, skip install + config + auth",{path:o}),Ur=!0;return}Ye.info("coze-cli install start",{package:Ws,registry:Js});try{await s("npm",["i","-g",Ws,"--registry",Js],{timeout:qx,maxBuffer:10*1024*1024}),Ye.info("coze-cli install ok")}catch(c){Ye.warn("coze-cli install failed (skip subsequent steps)",{err:String(c)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:Vs}),Ye.info("coze config set xTTEnv ok",{env:n.env})}catch(c){Ye.warn("coze config set failed (continue to auth login)",{err:String(c)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:Vs}),Ye.info("coze auth login ok")}catch(c){Ye.warn("coze auth login failed",{err:String(c)});return}Ur=!0}finally{Vt=null}})(),Vt}async function Kx(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Ux});return o.split(`
110
+ `)[0]?.trim()||void 0}catch{return}}q();import{spawn as jx}from"node:child_process";import{constants as Ys,access as Gx}from"node:fs/promises";import{delimiter as Hx,join as Wx}from"node:path";var Xs=O("framework-detector"),Zs={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Jx=[".exe",".cmd",".bat",".ps1"],St=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??jx,access:e.access??Gx}}async detect(e){let s=Zs[e],o=await this.which(s);if(!o)return Xs.debug("framework binary not found",{framework:e,bin:s}),null;let[c,u]=await Promise.all([this.probeVersion(o),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),f={path:o,version:c};return u&&(f.defaultAgent=u),f}async detectAll(){let e=await Promise.all(Object.keys(Zs).map(async o=>[o,await this.detect(o)])),s={};for(let[o,c]of e)c&&(s[o]=c);return s}async which(e){let s=this.env.pathEnv.split(Hx).filter(Boolean),o=this.env.platform==="win32"?["",...Jx]:[""];for(let c of s)for(let u of o){let f=Wx(c,e+u);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?Ys.F_OK:Ys.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let s=await this.runProbe(e,["agents","list","--json"]);if(!s||s.code!==0)return null;try{let o=JSON.parse(s.stdout);if(!Array.isArray(o))return null;let c=o.find(u=>u?.isDefault===!0);return!c?.id||!c.workspace?null:{id:c.id,workspace:c.workspace}}catch(o){return Xs.warn("openclaw agents list --json parse failed",{err:String(o)}),null}}async probeVersion(e){let s=await this.runProbe(e,["--version"]);return s&&($x(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let c="",u=!1,f,h=m=>{u||(u=!0,f&&clearTimeout(f),o(m))};try{let m=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{m.kill("SIGKILL"),h(null)},5e3),m.stdout?.on("data",w=>{c+=w.toString("utf8")}),m.on("error",()=>h(null)),m.on("close",w=>h({code:w,stdout:c}))}catch{h(null)}})}},Vx=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function $x(n){return n.replace(Vx,"")}un();fe();var Yx=10*6e4;function Qs(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Yx:e}function zn(n){return gt(n??H().configFile)}function Et(n,e){return xn(e??H().configFile,n)}import{randomBytes as xu}from"node:crypto";import{mkdir as Xx,readFile as Zx,realpath as Qx,writeFile as eu}from"node:fs/promises";import{basename as tu,dirname as qr,join as nu,relative as ru,resolve as eo,sep as iu}from"node:path";q();var no=O("fs-rpc");async function ro(n,e){let s=await so(n.path,e);return await Xx(qr(s),{recursive:!0}),await eu(s,n.content,"utf8"),no.info("fs/write_text_file ok",{path:s,size:n.content.length}),null}async function io(n,e){let s=await so(n.path,e),o=await Zx(s,"utf8"),c=o;if(typeof n.line=="number"||typeof n.limit=="number"){let u=o.split(`
111
111
  `),f=Math.max(0,(n.line??1)-1),h=typeof n.limit=="number"?f+n.limit:void 0;c=u.slice(f,h).join(`
112
- `)}return Ys.info("fs/read_text_file ok",{path:s,size:c.length}),{content:c}}async function to(n,e){if(typeof n!="string"||n.length===0)throw new E("IPC_BAD_REQUEST","path must be a non-empty string");let[s,a]=await Promise.all([Zs(Xs(e)),Zs(Xs(n))]),c=nu(s,a);if(c.startsWith("..")||c===".."||c.startsWith(`..${ru}`))throw new E("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return a}async function Zs(n){let e=[],s=n;for(;s!==zr(s);)try{let a=await Yx(s);return e.length?tu(a,...e.reverse()):a}catch{e.push(eu(s)),s=zr(s)}return n}q();var no=N("prompt-multimodal"),ro=10*1024*1024,iu=15e3;async function io(n){return Promise.all(n.map(su))}async function su(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!ln(e.uri))return n;try{let{buf:s,contentType:a}=await au(e.uri),c=e.mimeType||ou(a)||"application/octet-stream";return no.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:c}),{type:"image",data:s.toString("base64"),mimeType:c}}catch(s){return no.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function ou(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function au(n){let e=new AbortController,s=setTimeout(()=>e.abort(),iu);try{let a=await fetch(n,{signal:e.signal});if(!a.ok)throw new Error(`HTTP ${a.status} ${a.statusText}`);let c=await a.arrayBuffer();if(c.byteLength>ro)throw new Error(`image too large: ${c.byteLength} bytes (max ${ro})`);return{buf:Buffer.from(c),contentType:a.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}$e();q();var F=N("core"),xu=3e4,uu=3e4,On=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new bt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=$s(e.bridgeConfig)}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),await this.upstream.start(),F.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){F.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(s=>s.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),F.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(a){F.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(a)})}}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)&&F.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,a){let c=a.downstream;c&&(c.onUpdate(u=>{a.loadingSession||this.forwardUpdate(e,u)}),c.onAgentRequest(u=>{this.handleAgentRequest(e,c,u)}),c.onExit((u,f)=>{F.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:u,signal:f}),Gt(a),a.downstream=void 0,a.acpSessionId&&e.activeTriggers.delete(a.acpSessionId)}))}async handleFrame(e){if(An(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let s="id"in e&&e.id!==void 0?e.id:null,a=e.params?._meta?.cozeEnv;a&&(this.currentCozeEnv=a);try{if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,j.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):F.warn("drop notification: extension not registered",{method:e.method});return}let u=await c(e,this);s!==null&&await this.upstream.send(yt(s,u));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(yt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(yt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,j.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):F.warn("drop unknown notification",{method:e.method})}catch(c){F.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(st(s,Kt(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new E("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,a=s._meta?.cozeAgentId;if(!a)throw new E("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(a);if(!c)throw this.disconnectedAgents.has(a)?new E("AGENT_DISCONNECTED",`agent ${a} has been disconnected; cloud must _agent/create to revive`):new E("AGENT_NOT_FOUND",`agent not found: ${a}`);let u=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!u)return this.dispatchSessionCall(c,e.method,s);let f=Date.now(),h=!1;try{let m=await c.getSessionQueue(u).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return h=!0,m}finally{F.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-f,ok:h})}}async dispatchSessionCall(e,s,a){e.lastActiveAt=Date.now();let{stripped:c}=Qi(a);switch(s){case"session/new":{let u=fu();return F.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:u}),{sessionId:u}}case"session/load":{let u=c;return F.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:u.sessionId}),{}}case"session/prompt":{let u=c,f=u.sessionId;if(!f)throw new E("IPC_BAD_REQUEST","session/prompt: missing sessionId");let h=await this.ensureRuntime(e,f);if(h.replySeq=0,await this.ensureDownstream(e,f,h),!h.downstream||!h.acpSessionId)throw new E("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let m=a._meta?.cozeTriggerMsgId;m?e.activeTriggers.set(h.acpSessionId,m):e.activeTriggers.delete(h.acpSessionId);let y=await io(u.prompt);try{let b=await h.downstream.sessionPrompt({...u,sessionId:h.acpSessionId,prompt:y});return h.lastActiveAt=Date.now(),b}finally{e.activeTriggers.delete(h.acpSessionId),h.downstream?.isAlive()&&this.armIdleTimer(e,f,h)}}case"session/cancel":{let f=c.sessionId;if(!f)throw new E("IPC_BAD_REQUEST","session/cancel: missing sessionId");let h=e.sessions.get(f);return h?.downstream?.isAlive()&&h.acpSessionId&&await h.downstream.sessionCancel({sessionId:h.acpSessionId}),{ok:!0}}default:throw new E("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let a=e.sessions.get(s);if(a)return a;let u={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,u),await this.persistSessionMapping(e),u}async requestSessionToken(e,s){let a={sessionId:s,_meta:{cozeAgentId:e}};try{let c=await this.sendRequest(Ce.GEN_MODEL_TOKEN,a,uu);if(!c?.modelToken)throw new E("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof E&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new E("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,a){if(Gt(a),a.downstream?.isAlive())return;if(!this.sessionSpawner)throw new E("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=await this.sessionSpawner(e,a.modelToken,s,this.currentCozeEnv);if(a.downstream=c,this.attachRuntimeHooks(e,s,a),a.acpSessionId){a.loadingSession=!0;try{await c.sessionLoad({sessionId:a.acpSessionId,cwd:e.workspace}),F.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:a.acpSessionId})}catch(u){F.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:a.acpSessionId,err:String(u)}),a.acpSessionId=void 0;let f=await c.sessionNew({cwd:e.workspace});a.acpSessionId=f.sessionId,await this.persistSessionMapping(e)}finally{a.loadingSession=!1}}else{let u=await c.sessionNew({cwd:e.workspace});a.acpSessionId=u.sessionId,await this.persistSessionMapping(e)}c.afterSessionEstablished&&a.acpSessionId&&await c.afterSessionEstablished(a.acpSessionId)}armIdleTimer(e,s,a){if(Gt(a),this.isRuntimeBusy(e,a)){F.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:s});return}a.idleTimer=setTimeout(()=>{if(a.idleTimer=void 0,this.isRuntimeBusy(e,a)){F.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,a);return}F.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:s});let c=a.downstream;a.downstream=void 0,a.acpSessionId&&e.activeTriggers.delete(a.acpSessionId),c&&c.stop("idle timeout").catch(u=>F.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(u)}))},this.sessionIdleTimeoutMs),a.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let a=s.downstream;if(!a)return!1;for(let c of this.pendingUpstream.values())if(c.downstream===a)return!0;return!1}async sendAgentFileUpdate(e,s,a,c){let u={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let f=e.activeTriggers.get(s.acpSessionId);f&&(u.cozeTriggerMsgId=f)}await this.upstream.send(Ht("session/update",{sessionId:a,update:c,_meta:u}))}forwardUpdate(e,s){let a=s.sessionId,c=this.reverseSessionId(e,a);if(!c){F.debug("drop update for unknown session",{agentId:e.agentId,acpId:a});return}let u=e.sessions.get(c);if(!u){F.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(du(s)){F.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:a});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++u.replySeq},h=e.activeTriggers.get(a);h&&(f.cozeTriggerMsgId=h),this.upstream.send(Ht("session/update",{...s,sessionId:c,_meta:f})).catch(m=>F.warn("forward update failed",{agentId:e.agentId,err:String(m)}))}handleAgentRequest(e,s,a){if(a.method==="session/request_permission"){this.forwardPermissionRequest(e,s,a);return}if(a.method==="fs/write_text_file"||a.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,a);return}F.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:a.method}),s.respondAgentRequestError(a.id,{code:j.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${a.method}`})}async handleFsRpcRequest(e,s,a){try{let c=e.workspace;if(a.method==="fs/write_text_file"){let u=a.params??{},f=await Qs(u,c);s.respondAgentRequest(a.id,f)}else{let u=a.params??{},f=await eo(u,c);s.respondAgentRequest(a.id,f)}}catch(c){F.warn("fs rpc handler failed",{agentId:e.agentId,method:a.method,err:String(c)}),s.respondAgentRequestError(a.id,Kt(c))}}forwardPermissionRequest(e,s,a){let c=this.upstreamIds.next("session/request_permission"),u=a.params??{},h=u.sessionId,m=h?e.activeTriggers.get(h):void 0,y={cozeAgentId:e.agentId};m&&(y.cozeTriggerMsgId=m);let b=h?this.reverseSessionId(e,h):void 0,w={...u,...b?{sessionId:b}:{},_meta:y};this.pendingUpstream.set(c,{agentRequestId:a.id,agentId:e.agentId,downstream:s,method:a.method}),F.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:h,cloudSessionId:b,toolCallId:u.toolCall?.toolCallId,options:u.options?.map(S=>({optionId:S.optionId,kind:S.kind,name:S.name}))}),this.upstream.send(Ut(c,"session/request_permission",w)).catch(S=>{this.pendingUpstream.delete(c),F.error("forward permission request failed",{agentId:e.agentId,err:String(S)}),s.respondAgentRequestError(a.id,{code:j.INTERNAL_ERROR,message:`upstream send failed: ${String(S)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.pendingUpstream.get(e.id);if(s){this.pendingUpstream.delete(e.id),e.error?(F.info("upstream \u2192 permission response (error)",{agentId:s.agentId,upstreamId:e.id,method:s.method,error:e.error}),s.downstream.respondAgentRequestError(s.agentRequestId,e.error)):(F.info("upstream \u2192 permission response (result)",{agentId:s.agentId,upstreamId:e.id,method:s.method,result:e.result}),s.downstream.respondAgentRequest(s.agentRequestId,e.result));return}let a=this.pendingBridge.get(e.id);if(a){this.pendingBridge.delete(e.id),clearTimeout(a.timer),e.error?a.reject(new Cn(e.error)):a.resolve(e.result);return}F.debug("orphan upstream response (no pending)",{id:e.id})}sendRequest(e,s,a=xu){let c=this.upstreamIds.next(e);return new Promise((u,f)=>{let h=setTimeout(()=>{this.pendingBridge.delete(c),f(new E("AGENT_TIMEOUT",`${e} timed out after ${a}ms`))},a);this.pendingBridge.set(c,{method:e,resolve:u,reject:f,timer:h}),this.upstream.send(Ut(c,e,s)).catch(m=>{let y=this.pendingBridge.get(c);y&&(clearTimeout(y.timer),this.pendingBridge.delete(c)),f(m)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[a,c]of e.sessions){let u={modelToken:c.modelToken,tokenGeneratedAt:c.tokenGeneratedAt};c.acpSessionId&&(u.acpSessionId=c.acpSessionId),s.set(a,u)}await Ir(e.agentId,s,this.paths)}catch(s){F.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[a,c]of e.sessions.entries())if(c.acpSessionId===s)return a}sendError(e,s,a){return this.upstream.send(st(e,{code:s,message:a}))}};function fu(){return cu(16).toString("hex")}function du(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let a=s;return a.type!=="text"||typeof a.text!="string"?!1:a.text.startsWith("Model metadata for `")}q();fe();import{randomBytes as lu}from"node:crypto";import{chmod as hu,mkdir as gu,writeFile as so}from"node:fs/promises";import{createServer as pu}from"node:http";import{dirname as mu}from"node:path";var _u=1e6,Fr=N("ipc"),Bn=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(s=>[`${s.method} ${s.path}`,s])),this.paths=e.paths??W()}async start(){this.token=lu(32).toString("hex");let e=pu((a,c)=>{this.dispatch(a,c)});this.server=e,await new Promise((a,c)=>{e.once("error",c),e.listen(0,"127.0.0.1",()=>a())});let s=e.address();if(!s||typeof s!="object")throw new Error("failed to obtain IPC port");return this.port=s.port,await this.persistAuthFiles(),Fr.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((s,a)=>{e.close(c=>c?a(c):s())}),this.server=null)}async persistAuthFiles(){await gu(mu(this.paths.portFile),{recursive:!0}),await so(this.paths.portFile,String(this.port),"utf8"),await so(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await hu(this.paths.tokenFile,384)}catch(e){Fr.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){Jt(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,u=this.routes.get(c);if(!u){Jt(s,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await wu(e)}catch(h){Jt(s,400,{error:"invalid json",detail:String(h)});return}try{let h=await u.handler(f,e);Jt(s,200,h??{ok:!0})}catch(h){Fr.error("IPC handler failed",{key:c,err:String(h)}),Jt(s,500,{error:h instanceof Error?h.message:String(h)})}}};function Jt(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function wu(n){let e=[],s=0;for await(let c of n){let u=c;if(s+=u.length,s>_u)throw new Error("body too large");e.push(u)}let a=Buffer.concat(e).toString("utf8");return a?JSON.parse(a):null}var Pa=Oe(mo(),1);var ed=Oe(da(),1),td=Oe(Yn(),1),nd=Oe(It(),1),rd=Oe(Yr(),1),id=Oe(ti(),1),sd=Oe(ai(),1),ba=Oe(nr(),1),od=Oe(ya(),1);var va=ba.default;q();var xe=N("upstream.frontier"),Ea="application/json",Ca="none",ir=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandler=null;opened=!1;openCount=0;async start(){if(this.fws){xe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:ns,...wt(this.opts.ppeOverride)};class s extends va{constructor(h){super(h,ts,{headers:e})}send(h,...m){if(Vi("debug"))try{let y;typeof h=="string"?y=Buffer.from(h,"utf8"):h instanceof Buffer?y=h:h instanceof ArrayBuffer?y=new Uint8Array(h):ArrayBuffer.isView(h)?y=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):y=new Uint8Array(0);let b=Buffer.from(y.slice(0,128)).toString("hex");xe.debug("WS raw frame out",{bytes:y.byteLength,headHex:b})}catch(y){xe.warn("WS raw frame dump failed",{err:String(y)})}super.send(h,...m)}}let a=is(this.opts.urlOverride),c={url:a,ws:s,fpID:es,aID:gn,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Ea,force:!0},payloadEncoding:{encoding:Ca,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,debug:this.opts.debug??!1},u=new Pa.FWS(c);u.onopen=()=>{this.opened=!0,this.openCount+=1;let f=this.openCount===1;xe.info("frontier opened",{url:a,remoteDeviceId:this.opts.handshake.deviceId,initial:f,openCount:this.openCount}),this.connectHandler&&Promise.resolve(this.connectHandler({initial:f})).catch(h=>xe.warn("onConnect handler threw (ignored)",{err:String(h)}))},u.onclose=f=>{this.opened=!1,xe.info("frontier closed",{code:f.code,reason:f.reason,willReconnect:f.willReconnect})},u.onerror=f=>{xe.warn("frontier error",{code:f.code,msg:f.message})},u.onmessage=f=>this.handleMessage(f),this.fws=u,await u.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(a){xe.warn("frontier close threw (ignored)",{err:String(a)})}}}async send(e){let s=this.fws;if(!s)throw new E("UPSTREAM_DISCONNECTED","frontier upstream not started");let a=JSON.stringify(e),c=e;Aa(c)||xe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await s.send(a,{service:33555712,method:1,payloadType:Ea,payloadEncoding:Ca})}catch(f){throw xe.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(f)}),new E("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandler=e}isConnected(){return this.opened&&this.fws?.readyState===1}handleMessage(e){let s=e.message?.service;if(s!==33555712){xe.debug("drop non-adapter frontier frame",{service:s});return}let a=ud(e);if(!a){xe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){xe.debug("frame received but no onFrame handler",{size:a.length});return}let c;try{c=JSON.parse(a)}catch(f){xe.warn("frontier message JSON parse failed",{err:String(f),head:a.slice(0,80)});return}let u=c;Aa(u)||xe.info("frontier frame in",{logid:xd(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:u.id,method:u.method,body:cd(a)}),Promise.resolve(this.handler(c)).catch(f=>xe.warn("frontier frame handler threw",{err:String(f)}))}};function Aa(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var Ia=2e3;function cd(n){return n.length<=Ia?n:`${n.slice(0,Ia)}...<truncated, total ${n.length} chars>`}function xd(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function ud(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}q();var xi=N("upstream.switchable"),sr=class{inner;handler=null;connectHandler=null;constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;xi.info("swap upstream",{reason:s});let a=this.inner;this.inner=e,this.handler&&e.onFrame(this.handler),this.connectHandler&&e.onConnect&&e.onConnect(this.connectHandler);try{await e.start()}catch(c){throw xi.error("swap target start failed, reverting",{err:String(c)}),this.inner=a,c}await a.stop(s??"swapped").catch(c=>xi.warn("previous upstream stop threw (ignored)",{err:String(c)}))}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.connectHandler=e,this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};q();var ui=N("upstream"),nn=class{handler=null;async start(){ui.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){ui.info("NoopUpstream stopped",{reason:e})}async send(e){ui.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)}};q();fe();fe();import{promises as or}from"node:fs";import{join as fd}from"node:path";function dd(n){return`#!/bin/sh
112
+ `)}return no.info("fs/read_text_file ok",{path:s,size:c.length}),{content:c}}async function so(n,e){if(typeof n!="string"||n.length===0)throw new E("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([to(eo(e)),to(eo(n))]),c=ru(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${iu}`))throw new E("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function to(n){let e=[],s=n;for(;s!==qr(s);)try{let o=await Qx(s);return e.length?nu(o,...e.reverse()):o}catch{e.push(tu(s)),s=qr(s)}return n}q();var oo=O("prompt-multimodal"),ao=10*1024*1024,su=15e3;async function co(n){return Promise.all(n.map(ou))}async function ou(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!mn(e.uri))return n;try{let{buf:s,contentType:o}=await cu(e.uri),c=e.mimeType||au(o)||"application/octet-stream";return oo.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:c}),{type:"image",data:s.toString("base64"),mimeType:c}}catch(s){return oo.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function au(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function cu(n){let e=new AbortController,s=setTimeout(()=>e.abort(),su);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let c=await o.arrayBuffer();if(c.byteLength>ao)throw new Error(`image too large: ${c.byteLength} bytes (max ${ao})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}Ve();q();var U=O("core"),uu=3e4,fu=3e4,Fn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new yt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Qs(e.bridgeConfig)}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),await this.upstream.start(),U.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){U.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(s=>s.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),U.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){U.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(o)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&U.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,o){let c=o.downstream;c&&(c.onUpdate(u=>{o.loadingSession||this.forwardUpdate(e,u)}),c.onAgentRequest(u=>{this.handleAgentRequest(e,c,u)}),c.onExit((u,f)=>{U.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:u,signal:f}),Jt(o),o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId)}))}async handleFrame(e){if(Tn(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let s="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&(this.currentCozeEnv=o);try{if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,G.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):U.warn("drop notification: extension not registered",{method:e.method});return}let u=await c(e,this);s!==null&&await this.upstream.send(wt(s,u));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(wt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(wt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,G.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):U.warn("drop unknown notification",{method:e.method})}catch(c){U.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(it(s,Wt(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new E("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new E("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(o);if(!c)throw this.disconnectedAgents.has(o)?new E("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new E("AGENT_NOT_FOUND",`agent not found: ${o}`);let u=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!u)return this.dispatchSessionCall(c,e.method,s);let f=Date.now(),h=!1;try{let m=await c.getSessionQueue(u).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return h=!0,m}finally{U.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-f,ok:h})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=ns(o);switch(s){case"session/new":{let u=du();return U.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:u}),{sessionId:u}}case"session/load":{let u=c;return U.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:u.sessionId}),{}}case"session/prompt":{let u=c,f=u.sessionId;if(!f)throw new E("IPC_BAD_REQUEST","session/prompt: missing sessionId");let h=await this.ensureRuntime(e,f);if(h.replySeq=0,await this.ensureDownstream(e,f,h),!h.downstream||!h.acpSessionId)throw new E("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let m=o._meta?.cozeTriggerMsgId;m?e.activeTriggers.set(h.acpSessionId,m):e.activeTriggers.delete(h.acpSessionId);let w=await co(u.prompt);try{let b=await h.downstream.sessionPrompt({...u,sessionId:h.acpSessionId,prompt:w});return h.lastActiveAt=Date.now(),b}finally{e.activeTriggers.delete(h.acpSessionId),h.downstream?.isAlive()&&this.armIdleTimer(e,f,h)}}case"session/cancel":{let f=c.sessionId;if(!f)throw new E("IPC_BAD_REQUEST","session/cancel: missing sessionId");let h=e.sessions.get(f);return h?.downstream?.isAlive()&&h.acpSessionId&&await h.downstream.sessionCancel({sessionId:h.acpSessionId}),{ok:!0}}default:throw new E("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let u={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,u),await this.persistSessionMapping(e),u}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let c=await this.sendRequest(Ie.GEN_MODEL_TOKEN,o,fu);if(!c?.modelToken)throw new E("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof E&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new E("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,o){if(Jt(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new E("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv);if(o.downstream=c,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await c.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),U.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(u){U.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(u)}),o.acpSessionId=void 0;let f=await c.sessionNew({cwd:e.workspace});o.acpSessionId=f.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let u=await c.sessionNew({cwd:e.workspace});o.acpSessionId=u.sessionId,await this.persistSessionMapping(e)}c.afterSessionEstablished&&o.acpSessionId&&await c.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(Jt(o),this.isRuntimeBusy(e,o)){U.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:s});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){U.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}U.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:s});let c=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),c&&c.stop("idle timeout").catch(u=>U.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(u)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let o=s.downstream;if(!o)return!1;for(let c of this.pendingUpstream.values())if(c.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,c){let u={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let f=e.activeTriggers.get(s.acpSessionId);f&&(u.cozeTriggerMsgId=f)}await this.upstream.send(Ht("session/update",{sessionId:o,update:c,_meta:u}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){U.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let u=e.sessions.get(c);if(!u){U.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(lu(s)){U.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++u.replySeq},h=e.activeTriggers.get(o);h&&(f.cozeTriggerMsgId=h),this.upstream.send(Ht("session/update",{...s,sessionId:c,_meta:f})).catch(m=>U.warn("forward update failed",{agentId:e.agentId,err:String(m)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}U.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:G.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let c=e.workspace;if(o.method==="fs/write_text_file"){let u=o.params??{},f=await ro(u,c);s.respondAgentRequest(o.id,f)}else{let u=o.params??{},f=await io(u,c);s.respondAgentRequest(o.id,f)}}catch(c){U.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,Wt(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),u=o.params??{},h=u.sessionId,m=h?e.activeTriggers.get(h):void 0,w={cozeAgentId:e.agentId};m&&(w.cozeTriggerMsgId=m);let b=h?this.reverseSessionId(e,h):void 0,S={...u,...b?{sessionId:b}:{},_meta:w};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),U.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:h,cloudSessionId:b,toolCallId:u.toolCall?.toolCallId,options:u.options?.map(A=>({optionId:A.optionId,kind:A.kind,name:A.name}))}),this.upstream.send(Gt(c,"session/request_permission",S)).catch(A=>{this.pendingUpstream.delete(c),U.error("forward permission request failed",{agentId:e.agentId,err:String(A)}),s.respondAgentRequestError(o.id,{code:G.INTERNAL_ERROR,message:`upstream send failed: ${String(A)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.pendingUpstream.get(e.id);if(s){this.pendingUpstream.delete(e.id),e.error?(U.info("upstream \u2192 permission response (error)",{agentId:s.agentId,upstreamId:e.id,method:s.method,error:e.error}),s.downstream.respondAgentRequestError(s.agentRequestId,e.error)):(U.info("upstream \u2192 permission response (result)",{agentId:s.agentId,upstreamId:e.id,method:s.method,result:e.result}),s.downstream.respondAgentRequest(s.agentRequestId,e.result));return}let o=this.pendingBridge.get(e.id);if(o){this.pendingBridge.delete(e.id),clearTimeout(o.timer),e.error?o.reject(new kn(e.error)):o.resolve(e.result);return}U.debug("orphan upstream response (no pending)",{id:e.id})}sendRequest(e,s,o=uu){let c=this.upstreamIds.next(e);return new Promise((u,f)=>{let h=setTimeout(()=>{this.pendingBridge.delete(c),f(new E("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:u,reject:f,timer:h}),this.upstream.send(Gt(c,e,s)).catch(m=>{let w=this.pendingBridge.get(c);w&&(clearTimeout(w.timer),this.pendingBridge.delete(c)),f(m)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,c]of e.sessions){let u={modelToken:c.modelToken,tokenGeneratedAt:c.tokenGeneratedAt};c.acpSessionId&&(u.acpSessionId=c.acpSessionId),s.set(o,u)}await Tr(e.agentId,s,this.paths)}catch(s){U.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,c]of e.sessions.entries())if(c.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(it(e,{code:s,message:o}))}};function du(){return xu(16).toString("hex")}function lu(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}q();fe();import{randomBytes as hu}from"node:crypto";import{chmod as gu,mkdir as pu,writeFile as xo}from"node:fs/promises";import{createServer as mu}from"node:http";import{dirname as _u}from"node:path";var wu=1e6,Kr=O("ipc"),Un=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(s=>[`${s.method} ${s.path}`,s])),this.paths=e.paths??H()}async start(){this.token=hu(32).toString("hex");let e=mu((o,c)=>{this.dispatch(o,c)});this.server=e,await new Promise((o,c)=>{e.once("error",c),e.listen(0,"127.0.0.1",()=>o())});let s=e.address();if(!s||typeof s!="object")throw new Error("failed to obtain IPC port");return this.port=s.port,await this.persistAuthFiles(),Kr.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((s,o)=>{e.close(c=>c?o(c):s())}),this.server=null)}async persistAuthFiles(){await pu(_u(this.paths.portFile),{recursive:!0}),await xo(this.paths.portFile,String(this.port),"utf8"),await xo(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await gu(this.paths.tokenFile,384)}catch(e){Kr.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){$t(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,u=this.routes.get(c);if(!u){$t(s,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await yu(e)}catch(h){$t(s,400,{error:"invalid json",detail:String(h)});return}try{let h=await u.handler(f,e);$t(s,200,h??{ok:!0})}catch(h){Kr.error("IPC handler failed",{key:c,err:String(h)}),$t(s,500,{error:h instanceof Error?h.message:String(h)})}}};function $t(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function yu(n){let e=[],s=0;for await(let c of n){let u=c;if(s+=u.length,s>wu)throw new Error("body too large");e.push(u)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}var Ra=ze(bo(),1);var td=ze(pa(),1),nd=ze(nr(),1),rd=ze(It(),1),id=ze(ti(),1),sd=ze(ii(),1),od=ze(ui(),1),Ca=ze(or(),1),ad=ze(Ea(),1);var Aa=Ca.default;q();var xe=O("upstream.frontier"),Pa="application/json",ka="none",cr=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandler=null;opened=!1;openCount=0;async start(){if(this.fws){xe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:ss,..._t(this.opts.ppeOverride)};class s extends Aa{constructor(h){super(h,is,{headers:e})}send(h,...m){if(Xi("debug"))try{let w;typeof h=="string"?w=Buffer.from(h,"utf8"):h instanceof Buffer?w=h:h instanceof ArrayBuffer?w=new Uint8Array(h):ArrayBuffer.isView(h)?w=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):w=new Uint8Array(0);let b=Buffer.from(w.slice(0,128)).toString("hex");xe.debug("WS raw frame out",{bytes:w.byteLength,headHex:b})}catch(w){xe.warn("WS raw frame dump failed",{err:String(w)})}super.send(h,...m)}}let o=as(this.opts.urlOverride),c={url:o,ws:s,fpID:rs,aID:wn,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Pa,force:!0},payloadEncoding:{encoding:ka,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,debug:this.opts.debug??!1},u=new Ra.FWS(c);u.onopen=()=>{this.opened=!0,this.openCount+=1;let f=this.openCount===1;xe.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:f,openCount:this.openCount}),this.connectHandler&&Promise.resolve(this.connectHandler({initial:f})).catch(h=>xe.warn("onConnect handler threw (ignored)",{err:String(h)}))},u.onclose=f=>{this.opened=!1,xe.info("frontier closed",{code:f.code,reason:f.reason,willReconnect:f.willReconnect})},u.onerror=f=>{xe.warn("frontier error",{code:f.code,msg:f.message})},u.onmessage=f=>this.handleMessage(f),this.fws=u,await u.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){xe.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new E("UPSTREAM_DISCONNECTED","frontier upstream not started");let o=JSON.stringify(e),c=e;Ta(c)||xe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:Pa,payloadEncoding:ka})}catch(f){throw xe.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(f)}),new E("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandler=e}isConnected(){return this.opened&&this.fws?.readyState===1}handleMessage(e){let s=e.message?.service;if(s!==33555712){xe.debug("drop non-adapter frontier frame",{service:s});return}let o=fd(e);if(!o){xe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){xe.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(f){xe.warn("frontier message JSON parse failed",{err:String(f),head:o.slice(0,80)});return}let u=c;Ta(u)||xe.info("frontier frame in",{logid:ud(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:u.id,method:u.method,body:xd(o)}),Promise.resolve(this.handler(c)).catch(f=>xe.warn("frontier frame handler threw",{err:String(f)}))}};function Ta(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var Da=2e3;function xd(n){return n.length<=Da?n:`${n.slice(0,Da)}...<truncated, total ${n.length} chars>`}function ud(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function fd(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}q();var di=O("upstream.switchable"),xr=class{inner;handler=null;connectHandler=null;constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;di.info("swap upstream",{reason:s});let o=this.inner;this.inner=e,this.handler&&e.onFrame(this.handler),this.connectHandler&&e.onConnect&&e.onConnect(this.connectHandler);try{await e.start()}catch(c){throw di.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>di.warn("previous upstream stop threw (ignored)",{err:String(c)}))}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.connectHandler=e,this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};q();var li=O("upstream"),sn=class{handler=null;async start(){li.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){li.info("NoopUpstream stopped",{reason:e})}async send(e){li.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)}};q();fe();fe();import{promises as ur}from"node:fs";import{join as dd}from"node:path";function ld(n){return`#!/bin/sh
113
113
  exec node ${JSON.stringify(n)} "$@"
114
- `}function ld(n){return`@echo off
114
+ `}function hd(n){return`@echo off
115
115
  node ${JSON.stringify(n)} %*
116
- `}async function ka(n,e=W()){let s=e.binDir;await or.mkdir(s,{recursive:!0});let a=fd(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?ld(n):dd(n);return await or.readFile(a,"utf8").catch(()=>null)===c||(await or.writeFile(a,c,"utf8"),process.platform!=="win32"&&await or.chmod(a,493)),s}q();fe();import{execSync as Da}from"node:child_process";import{readFileSync as Na,unlinkSync as hd}from"node:fs";import{mkdir as gd,readFile as Ra,unlink as La,writeFile as pd}from"node:fs/promises";import{dirname as md}from"node:path";function Ta(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var _d=N("single-instance"),ar=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??W().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(_d.warn("removing stale pid file",{stalePid:e}),await La(this.pidFile).catch(()=>{})),await gd(md(this.pidFile),{recursive:!0}),await pd(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ra(this.pidFile,"utf8")).trim()===String(process.pid)&&await La(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ra(this.pidFile,"utf8"),s=Number.parseInt(e.trim(),10);return Number.isFinite(s)&&s>0?s:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return Ta(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=Na(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=Da(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return s.trim()?s.includes("coze-bridge-daemon")||s.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let a=Da(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!a||a.startsWith("INFO:"))return!1;let c=a.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return c.includes("node")||c.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{Na(this.pidFile,"utf8").trim()===String(process.pid)&&hd(this.pidFile)}catch{}})}};var z=N("daemon"),wd="coze-bridge-daemon";async function Ma(){let n=new ar({processTitle:wd}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await Ln(),a=s??{};Ar({pid:process.pid}),z.info(s?"loaded bridge config":"initialized bridge config");try{let D=new St;a.frameworksCache=await D.detectAll(),z.info("refreshed frameworks_cache",{detected:Object.keys(a.frameworksCache)})}catch(D){z.warn("framework detection failed",{err:String(D)})}await Et(a);let c=new sr(new nn),u=W(),f=null,h=new On({upstream:c,paths:u,bridgeConfig:a,sessionSpawner:async(D,M,U,oe)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(D,M,U,oe)}});await bd(u,h);let m=new Rn({paths:u,config:a,registry:h});f=m;let y,b,w=null,S={},C,I=null;h.registerExtension("_agent/create",async D=>m.createAgent(D.params)),h.registerExtension("_agent/health",async()=>({ok:!0}));let k={},L=new _n({agents:h.agents,disposeAndMarkDisconnected:async(D,M)=>{let U=h.agents.get(D);U&&(await m.cleanupOpenclawSessionProviders(U).catch(oe=>z.warn("cleanup openclaw providers failed (ignored)",{agentId:D,err:String(oe)})),await U.dispose(`disconnect: ${M}`).catch(oe=>z.warn("dispose during disconnect failed (ignored)",{agentId:D,err:String(oe)})),U.status="disconnected",h.unregister(D)),h.disconnectedAgents.add(D)},detailSyncer:async D=>{if(!k.ref)throw new Error("agent-detail-sync not initialized yet");await k.ref.syncOne(D)},openclawRepair:async(D,M)=>{await m.openclawRepair(D,M)}});h.registerExtension("_agent/listSkills",D=>L.listSkills(D.params)),h.registerExtension("_agent/addSkills",D=>L.addSkills(D.params)),h.registerExtension("_agent/removeSkills",D=>L.removeSkills(D.params)),h.registerExtension("_agent/getFileTree",D=>L.getFileTree(D.params)),h.registerExtension("_agent/getFileContent",D=>L.getFileContent(D.params)),h.registerExtension("_agent/update",D=>L.updateAgent(D.params)),h.registerExtension("_agent/disconnect",D=>L.disconnectAgent(D.params)),h.registerExtension("_agent/switchModel",D=>L.switchModel(D.params)),h.registerExtension("_agent/reset",D=>L.resetAgent(D.params)),h.registerExtension("_agent/repair",D=>L.repairAgent(D.params));let B=new dn({paths:u,handlers:L,sendDetail:D=>h.sendRequest("_agent/detail",D)});k.ref=B,c.onConnect(({initial:D})=>{z.info("frontier upstream connected, triggering detail sync",{initial:D}),B.syncAll(D?"initial-connect":"reconnect").catch(M=>z.warn("detail sync top-level error (ignored)",{err:String(M)}))});let Z=new Bn({paths:u,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...h.agents.keys()],deviceId:w??"",frameworksCache:a.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async D=>{let M=D,U=M?.privatecode,oe=M?.pairing_code;if(!U||!oe)throw new E("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let rt=mn(M.env),ft=M.handshake_url,Rt=M.frontier_url,we=yd(M.env,ft,Rt),Se=!!y&&y!==U,rn=b!==void 0&&b!==we,ue=Se||rn;if(ue){z.warn("pair config switched, resetting agents",{pcChanged:Se,envChanged:rn,previousPc:y?Oa(y):"",nextPc:Oa(U),previousEnvKey:b??"",nextEnvKey:we});for(let ae of[...h.agents.values()])await ae.dispose("pair config switch").catch(()=>{}),h.agents.delete(ae.agentId);await c.swap(new nn,"pair switch").catch(()=>{})}let Lt=await os({privatecode:U,...ft?{endpoint:ft}:{},ppeOverride:rt});w=Lt.deviceId,Ar({deviceId:w,pid:process.pid}),Ws({patToken:U,env:M.env}).catch(ae=>z.warn("coze-cli setup error (ignored)",{err:String(ae)}));let ie=new ir({handshake:Lt,privatecode:U,...Rt?{urlOverride:Rt}:{},ppeOverride:rt});await c.swap(ie,"pair");try{let ae=new St;a.frameworksCache=await ae.detectAll(),await Et(a),z.info("frameworks_cache refreshed before pair",{detected:Object.keys(a.frameworksCache)})}catch(ae){z.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ae)})}let Q=Object.keys(a.frameworksCache??{});try{let ae=await h.sendRequest("_agent/pair",{pairCode:oe,patToken:U,frameworks:Q,_meta:{cozeDeviceId:w}});z.info("_agent/pair ok",{pairResult:ae}),y=U,b=we,S=rt,C=ft,I||(I=new bn({core:h,getDeviceId:()=>w??""})),I.start(),ue&&Ba(u,m).catch(Re=>z.warn("post-pair-switch auto-revive error (ignored)",{err:String(Re)}));let Ne;return M.agent_id&&(Ne=await vd(M.agent_id,u,m,Re=>h.sendRequest("_agent/detail",Re)).catch(Re=>(z.error("--agent-id ensureAgent failed",{agentId:M.agent_id,err:String(Re)}),{ok:!1,agentId:M.agent_id??"",note:String(Re)}))),{ok:!0,note:"paired with cloud",...Ne?{agent:Ne}:{}}}catch(ae){return z.error("_agent/pair failed",{err:String(ae)}),{ok:!1,note:`pair failed: ${String(ae)}`}}}},{method:"POST",path:"/_agent/create",handler:async D=>{let M=D;return{ok:!0,result:await m.createAgent(M)}}},{method:"POST",path:"/agent/send",handler:async D=>{let M=D;if(!M?.agentId||!M?.sessionId||!M?.kind||!M?.path)throw new E("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!y)throw new E("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{return await Hs(M,{core:h,patToken:y,handshakeBase:C,ppeOverride:S})}catch(U){if(U instanceof E)return{ok:!1,code:U.code,message:U.message};throw U}}},{method:"POST",path:"/refresh",handler:async()=>{z.info("IPC /refresh: re-detecting frameworks");let D=new St;return a.frameworksCache=await D.detectAll(),await Et(a),{ok:!0,frameworks:a.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(z.info("IPC /shutdown received"),setImmediate(()=>{He.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:Y,token:te}=await Z.start();m.setIpcEndpoint({port:Y,token:te});try{await ka(u.libEntry,u)}catch(D){z.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(D)})}await h.start(),Ba(u,m).catch(D=>z.warn("auto-revive top-level error (ignored)",{err:String(D)}));let ne=null,He={port:Y,token:te,core:h,ipc:Z,shutdown(D){return ne||(z.info("daemon shutdown",{reason:D}),ne=(async()=>{I?.stop(),await h.stop(D),await Z.stop(),await n.release()})(),ne)}};for(let D of["SIGTERM","SIGINT"])process.on(D,()=>{He.shutdown(D).then(()=>process.exit(0))});return z.info("daemon ready",{port:Y,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(a.frameworksCache??{}),libVersion:a.libVersion??"dev"}),He}function Oa(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function yd(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function bd(n,e){let{readdir:s}=await import("node:fs/promises"),a;try{a=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:c,enforceAgentConfigMode:u}=await Promise.resolve().then(()=>($e(),fn));for(let f of a){await u(f,n).catch(h=>z.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(h)}));try{let h=await c(f,n);h?.disconnectedAt&&(e.disconnectedAgents.add(f),z.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:h.disconnectedAt,reason:h.disconnectReason??""}))}catch(h){z.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(h)})}}}async function vd(n,e,s,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>($e(),fn)),u=await c(n,e);if(u){z.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let y={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{}};return await s.createAgent(y),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}z.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let f=await a({_meta:{cozeAgentId:n}});if(!f.framework)throw new E("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let h={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await s.createAgent(h);let m=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:m?"cloud agent acknowledged":"created from cloud detail"}}async function Ba(n,e){let{readdir:s}=await import("node:fs/promises"),a;try{a=await s(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(a.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:c}=await Promise.resolve().then(()=>($e(),fn));z.info("auto-revive: scanning local agents on startup",{count:a.length});let u=0,f=0;for(let h of a){let m;try{m=await c(h,n)}catch(y){z.warn("auto-revive: load config failed (skipping)",{agentId:h,err:String(y)}),f+=1;continue}if(!m){f+=1;continue}if(m.disconnectedAt){z.info("auto-revive: skip disconnected agent",{agentId:h,disconnectedAt:m.disconnectedAt}),f+=1;continue}try{z.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:h,framework:m.framework}),await e.createAgent({agentId:m.agentId,framework:m.framework,...m.cozeIdentity?{cozeIdentity:m.cozeIdentity}:{},...m.model?{model:m.model}:{},...m.deployType?{_meta:{cozeDeployType:m.deployType}}:{}}),u+=1}catch(y){z.warn("auto-revive: createAgent failed (skipping)",{agentId:h,framework:m.framework,err:String(y)}),f+=1}}return z.info("auto-revive: done",{revived:u,skipped:f,total:a.length}),{revived:u,skipped:f,total:a.length}}di();fe();import{readFile as Fa}from"node:fs/promises";var et=class{paths;constructor(e){this.paths=e??W()}async probe(e=1e3){let s=await this.readAuth();if(!s)return{kind:"not-running"};try{let a=await this.fetch(s,{method:"GET",path:"/status",timeoutMs:e});return a.status===200?{kind:"connected",...s}:{kind:"stale",reason:`unexpected status ${a.status}`}}catch(a){return{kind:"stale",reason:Dd(a)}}}async request(e){let s=await this.readAuth();if(!s)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(s,e)}async readAuth(){try{let[e,s]=await Promise.all([Fa(this.paths.portFile,"utf8"),Fa(this.paths.tokenFile,"utf8")]),a=Number.parseInt(e.trim(),10),c=s.trim();return!Number.isFinite(a)||a<=0||!c?null:{port:a,token:c}}catch(e){if(e.code==="ENOENT")return null;throw e}}async fetch(e,s){let a=s.body!==void 0,c={Authorization:`Bearer ${e.token}`};a&&(c["content-type"]="application/json");let u=new AbortController,f=setTimeout(()=>u.abort(),s.timeoutMs??5e3);try{let h=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:c,body:a?JSON.stringify(s.body):void 0,signal:u.signal}),m=await h.text();return{status:h.status,body:Td(m)}}finally{clearTimeout(f)}}};function Td(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function Dd(n){return n instanceof Error?n.message:String(n)}q();fe();import{copyFile as qa,mkdir as Nd,readFile as li,writeFile as Rd}from"node:fs/promises";import{dirname as Ld,resolve as hi,sep as cr}from"node:path";import{fileURLToPath as Od}from"node:url";q();fe();var Ua=N("dist-install");function Bd(n){let e=Od(n),s=Ld(e),a=`${cr}src${cr}`;if(s.includes(a)||s.endsWith(`${cr}src${cr}cli`))return null;let c=hi(s,"index.js"),u=hi(s,"..","package.json");return{dist:c,pkgJson:u}}async function Ha(n={}){let e=n.paths??W(),s=Bd(import.meta.url),a=n.sourceDist??s?.dist,c=n.sourcePackageJson??s?.pkgJson;if(!a||!c)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let u;try{u=JSON.parse(await li(c,"utf8")).version??"unknown"}catch(w){return Ua.warn("cannot read source package.json,skip dist install",{err:String(w)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(w)}`}}let f=await Ln(e.configFile)??{},h=f.libVersion;if(h===u)try{return await li(e.libEntry),{kind:"already-current",libVersion:u}}catch{}await Nd(e.libDir,{recursive:!0}),await qa(a,e.libEntry),await qa(`${a}.map`,`${e.libEntry}.map`).catch(()=>{});let m=hi(e.libDir,"package.json"),y=`${JSON.stringify({type:"module"},null,2)}
117
- `;return await li(m,"utf8").catch(()=>null)!==y&&await Rd(m,y),f.libVersion=u,await Et(f,e.configFile),Ua.info("dist installed",{libEntry:e.libEntry,fromVersion:h,toVersion:u}),h?{kind:"version-changed",fromVersion:h,toVersion:u,libEntry:e.libEntry}:{kind:"first-install",libVersion:u,libEntry:e.libEntry}}import{basename as Md,resolve as zd}from"node:path";var Fd=9e4,qd={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME: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_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1};function Ud(n){return qd[n]??1}async function Ka(n){let e=Hd();if(!e)return process.stderr.write(`Error: not running inside a coze-bridge agent process (missing COZE_BRIDGE_* env). This command is intended to be called by an LLM inside an agent session.
118
- `),4;let s=zd(process.cwd(),n.path),a={agentId:e.agentId,sessionId:e.sessionId,kind:n.kind,path:s,...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},c;try{c=await Kd(e,"/agent/send",a,Fd)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
116
+ `}async function Oa(n,e=H()){let s=e.binDir;await ur.mkdir(s,{recursive:!0});let o=dd(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?hd(n):ld(n);return await ur.readFile(o,"utf8").catch(()=>null)===c||(await ur.writeFile(o,c,"utf8"),process.platform!=="win32"&&await ur.chmod(o,493)),s}q();fe();import{execSync as Na}from"node:child_process";import{readFileSync as Ba,unlinkSync as gd}from"node:fs";import{mkdir as pd,readFile as Ma,unlink as za,writeFile as md}from"node:fs/promises";import{dirname as _d}from"node:path";function La(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var wd=O("single-instance"),fr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??H().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(wd.warn("removing stale pid file",{stalePid:e}),await za(this.pidFile).catch(()=>{})),await pd(_d(this.pidFile),{recursive:!0}),await md(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ma(this.pidFile,"utf8")).trim()===String(process.pid)&&await za(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ma(this.pidFile,"utf8"),s=Number.parseInt(e.trim(),10);return Number.isFinite(s)&&s>0?s:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return La(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=Ba(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=Na(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return s.trim()?s.includes("coze-bridge-daemon")||s.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=Na(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let c=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return c.includes("node")||c.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{Ba(this.pidFile,"utf8").trim()===String(process.pid)&&gd(this.pidFile)}catch{}})}};var F=O("daemon"),yd="coze-bridge-daemon";async function qa(){let n=new fr({processTitle:yd}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await zn(),o=s??{};kr({pid:process.pid}),F.info(s?"loaded bridge config":"initialized bridge config");try{let T=new St;o.frameworksCache=await T.detectAll(),F.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(T){F.warn("framework detection failed",{err:String(T)})}await Et(o);let c=new xr(new sn),u=H(),f=null,h=new Fn({upstream:c,paths:u,bridgeConfig:o,sessionSpawner:async(T,z,K,oe)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(T,z,K,oe)}});await vd(u,h);let m=new Mn({paths:u,config:o,registry:h});f=m;let w,b,S=null,A={},N,D=null;h.registerExtension("_agent/create",async T=>m.createAgent(T.params)),h.registerExtension("_agent/health",async()=>({ok:!0}));let R={},M=new vn({agents:h.agents,disposeAndMarkDisconnected:async(T,z)=>{let K=h.agents.get(T);K&&(await m.cleanupOpenclawSessionProviders(K).catch(oe=>F.warn("cleanup openclaw providers failed (ignored)",{agentId:T,err:String(oe)})),await K.dispose(`disconnect: ${z}`).catch(oe=>F.warn("dispose during disconnect failed (ignored)",{agentId:T,err:String(oe)})),K.status="disconnected",h.unregister(T)),h.disconnectedAgents.add(T)},detailSyncer:async T=>{if(!R.ref)throw new Error("agent-detail-sync not initialized yet");await R.ref.syncOne(T)},openclawRepair:async(T,z)=>{await m.openclawRepair(T,z)}});h.registerExtension("_agent/listSkills",T=>M.listSkills(T.params)),h.registerExtension("_agent/addSkills",T=>M.addSkills(T.params)),h.registerExtension("_agent/removeSkills",T=>M.removeSkills(T.params)),h.registerExtension("_agent/getFileTree",T=>M.getFileTree(T.params)),h.registerExtension("_agent/getFileContent",T=>M.getFileContent(T.params)),h.registerExtension("_agent/update",T=>M.updateAgent(T.params)),h.registerExtension("_agent/disconnect",T=>M.disconnectAgent(T.params)),h.registerExtension("_agent/switchModel",T=>M.switchModel(T.params)),h.registerExtension("_agent/reset",T=>M.resetAgent(T.params)),h.registerExtension("_agent/repair",T=>M.repairAgent(T.params));let V=new pn({paths:u,handlers:M,sendDetail:T=>h.sendRequest("_agent/detail",T)});R.ref=V,c.onConnect(({initial:T})=>{F.info("frontier upstream connected, triggering detail sync",{initial:T}),V.syncAll(T?"initial-connect":"reconnect").catch(z=>F.warn("detail sync top-level error (ignored)",{err:String(z)}))});let te=new Un({paths:u,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...h.agents.keys()],deviceId:S??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async T=>{let z=T,K=z?.privatecode,oe=z?.pairing_code;if(!K||!oe)throw new E("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let nt=bn(z.env),ut=z.handshake_url,Ot=z.frontier_url,ye=bd(z.env,ut,Ot),Ce=!!w&&w!==K,on=b!==void 0&&b!==ye,ue=Ce||on;if(ue){F.warn("pair config switched, resetting agents",{pcChanged:Ce,envChanged:on,previousPc:w?Fa(w):"",nextPc:Fa(K),previousEnvKey:b??"",nextEnvKey:ye});for(let ae of[...h.agents.values()])await ae.dispose("pair config switch").catch(()=>{}),h.agents.delete(ae.agentId);await c.swap(new sn,"pair switch").catch(()=>{})}let Lt=await xs({privatecode:K,...ut?{endpoint:ut}:{},ppeOverride:nt});S=Lt.deviceId,kr({deviceId:S,pid:process.pid}),$s({patToken:K,env:z.env}).catch(ae=>F.warn("coze-cli setup error (ignored)",{err:String(ae)}));let ne=new cr({handshake:Lt,privatecode:K,...Ot?{urlOverride:Ot}:{},ppeOverride:nt});await c.swap(ne,"pair");try{let ae=new St;o.frameworksCache=await ae.detectAll(),await Et(o),F.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(ae){F.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ae)})}let Z=Object.keys(o.frameworksCache??{});try{let ae=await h.sendRequest("_agent/pair",{pairCode:oe,patToken:K,frameworks:Z,_meta:{cozeDeviceId:S}});F.info("_agent/pair ok",{pairResult:ae}),w=K,b=ye,A=nt,N=ut,D||(D=new Cn({core:h,getDeviceId:()=>S??""})),D.start(),ue&&Ua(u,m).catch(Ne=>F.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ne)}));let Le;return z.agent_id&&(Le=await Sd(z.agent_id,u,m,Ne=>h.sendRequest("_agent/detail",Ne)).catch(Ne=>(F.error("--agent-id ensureAgent failed",{agentId:z.agent_id,err:String(Ne)}),{ok:!1,agentId:z.agent_id??"",note:String(Ne)}))),{ok:!0,note:"paired with cloud",...Le?{agent:Le}:{}}}catch(ae){return F.error("_agent/pair failed",{err:String(ae)}),{ok:!1,note:`pair failed: ${String(ae)}`}}}},{method:"POST",path:"/_agent/create",handler:async T=>{let z=T;return{ok:!0,result:await m.createAgent(z)}}},{method:"POST",path:"/agent/send",handler:async T=>{let z=T;if(!z?.agentId||!z?.sessionId||!z?.kind||!z?.path)throw new E("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!w)throw new E("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{return await Hs(z,{core:h,patToken:w,handshakeBase:N,ppeOverride:A})}catch(K){if(K instanceof E)return{ok:!1,code:K.code,message:K.message};throw K}}},{method:"POST",path:"/refresh",handler:async()=>{F.info("IPC /refresh: re-detecting frameworks");let T=new St;return o.frameworksCache=await T.detectAll(),await Et(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(F.info("IPC /shutdown received"),setImmediate(()=>{le.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ie,token:se}=await te.start();m.setIpcEndpoint({port:ie,token:se});try{await Oa(u.libEntry,u)}catch(T){F.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(T)})}await h.start(),Ua(u,m).catch(T=>F.warn("auto-revive top-level error (ignored)",{err:String(T)}));let $=null,le={port:ie,token:se,core:h,ipc:te,shutdown(T){return $||(F.info("daemon shutdown",{reason:T}),$=(async()=>{D?.stop(),await h.stop(T),await te.stop(),await n.release()})(),$)}};for(let T of["SIGTERM","SIGINT"])process.on(T,()=>{le.shutdown(T).then(()=>process.exit(0))});return F.info("daemon ready",{port:ie,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),le}function Fa(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function bd(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function vd(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:c,enforceAgentConfigMode:u}=await Promise.resolve().then(()=>(Ve(),gn));for(let f of o){await u(f,n).catch(h=>F.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(h)}));try{let h=await c(f,n);h?.disconnectedAt&&(e.disconnectedAgents.add(f),F.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:h.disconnectedAt,reason:h.disconnectReason??""}))}catch(h){F.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(h)})}}}async function Sd(n,e,s,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Ve(),gn)),u=await c(n,e);if(u){F.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let w={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{}};return await s.createAgent(w),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}F.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let f=await o({_meta:{cozeAgentId:n}});if(!f.framework)throw new E("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let h={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await s.createAgent(h);let m=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:m?"cloud agent acknowledged":"created from cloud detail"}}async function Ua(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Ve(),gn));F.info("auto-revive: scanning local agents on startup",{count:o.length});let u=0,f=0;for(let h of o){let m;try{m=await c(h,n)}catch(w){F.warn("auto-revive: load config failed (skipping)",{agentId:h,err:String(w)}),f+=1;continue}if(!m){f+=1;continue}if(m.disconnectedAt){F.info("auto-revive: skip disconnected agent",{agentId:h,disconnectedAt:m.disconnectedAt}),f+=1;continue}try{F.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:h,framework:m.framework}),await e.createAgent({agentId:m.agentId,framework:m.framework,...m.cozeIdentity?{cozeIdentity:m.cozeIdentity}:{},...m.model?{model:m.model}:{},...m.deployType?{_meta:{cozeDeployType:m.deployType}}:{}}),u+=1}catch(w){F.warn("auto-revive: createAgent failed (skipping)",{agentId:h,framework:m.framework,err:String(w)}),f+=1}}return F.info("auto-revive: done",{revived:u,skipped:f,total:o.length}),{revived:u,skipped:f,total:o.length}}gi();fe();import{readFile as ja}from"node:fs/promises";var Qe=class{paths;constructor(e){this.paths=e??H()}async probe(e=1e3){let s=await this.readAuth();if(!s)return{kind:"not-running"};try{let o=await this.fetch(s,{method:"GET",path:"/status",timeoutMs:e});return o.status===200?{kind:"connected",...s}:{kind:"stale",reason:`unexpected status ${o.status}`}}catch(o){return{kind:"stale",reason:Rd(o)}}}async request(e){let s=await this.readAuth();if(!s)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(s,e)}async readAuth(){try{let[e,s]=await Promise.all([ja(this.paths.portFile,"utf8"),ja(this.paths.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),c=s.trim();return!Number.isFinite(o)||o<=0||!c?null:{port:o,token:c}}catch(e){if(e.code==="ENOENT")return null;throw e}}async fetch(e,s){let o=s.body!==void 0,c={Authorization:`Bearer ${e.token}`};o&&(c["content-type"]="application/json");let u=new AbortController,f=setTimeout(()=>u.abort(),s.timeoutMs??5e3);try{let h=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:c,body:o?JSON.stringify(s.body):void 0,signal:u.signal}),m=await h.text();return{status:h.status,body:Dd(m)}}finally{clearTimeout(f)}}};function Dd(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function Rd(n){return n instanceof Error?n.message:String(n)}q();fe();import{copyFile as Ga,mkdir as Od,readFile as pi,writeFile as Ld}from"node:fs/promises";import{dirname as Nd,resolve as mi,sep as dr}from"node:path";import{fileURLToPath as Bd}from"node:url";q();fe();var Ha=O("dist-install");function Md(n){let e=Bd(n),s=Nd(e),o=`${dr}src${dr}`;if(s.includes(o)||s.endsWith(`${dr}src${dr}cli`))return null;let c=mi(s,"index.js"),u=mi(s,"..","package.json");return{dist:c,pkgJson:u}}async function Wa(n={}){let e=n.paths??H(),s=Md(import.meta.url),o=n.sourceDist??s?.dist,c=n.sourcePackageJson??s?.pkgJson;if(!o||!c)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let u;try{u=JSON.parse(await pi(c,"utf8")).version??"unknown"}catch(S){return Ha.warn("cannot read source package.json,skip dist install",{err:String(S)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(S)}`}}let f=await zn(e.configFile)??{},h=f.libVersion;if(h===u)try{return await pi(e.libEntry),{kind:"already-current",libVersion:u}}catch{}await Od(e.libDir,{recursive:!0}),await Ga(o,e.libEntry),await Ga(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let m=mi(e.libDir,"package.json"),w=`${JSON.stringify({type:"module"},null,2)}
117
+ `;return await pi(m,"utf8").catch(()=>null)!==w&&await Ld(m,w),f.libVersion=u,await Et(f,e.configFile),Ha.info("dist installed",{libEntry:e.libEntry,fromVersion:h,toVersion:u}),h?{kind:"version-changed",fromVersion:h,toVersion:u,libEntry:e.libEntry}:{kind:"first-install",libVersion:u,libEntry:e.libEntry}}import{basename as zd,resolve as Fd}from"node:path";var Ud=9e4,qd={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME: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_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1};function Kd(n){return qd[n]??1}async function Ja(n){let e=jd();if(!e)return process.stderr.write(`Error: not running inside a coze-bridge agent process (missing COZE_BRIDGE_* env). This command is intended to be called by an LLM inside an agent session.
118
+ `),4;let s=Fd(process.cwd(),n.path),o={agentId:e.agentId,sessionId:e.sessionId,kind:n.kind,path:s,...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},c;try{c=await Gd(e,"/agent/send",o,Ud)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
119
119
  `),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
120
- `),Ud(c.code);if(n.json)process.stdout.write(`${JSON.stringify(c)}
121
- `);else{let u=n.name??Md(s);process.stdout.write(`Sent ${n.kind} ${u} (${jd(c.bytes)})
122
- `)}return 0}function Hd(){let n=process.env.COZE_BRIDGE_AGENT_ID,e=process.env.COZE_BRIDGE_SESSION_ID,s=process.env.COZE_BRIDGE_IPC_PORT,a=process.env.COZE_BRIDGE_IPC_TOKEN;if(!n||!e||!s||!a)return null;let c=Number.parseInt(s,10);return!Number.isFinite(c)||c<=0?null:{agentId:n,sessionId:e,port:c,token:a}}async function Kd(n,e,s,a){let c=new AbortController,u=setTimeout(()=>c.abort(),a);try{let f=await fetch(`http://127.0.0.1:${n.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(s),signal:c.signal}),h=await f.text(),m=h?JSON.parse(h):null;return m&&typeof m=="object"&&"ok"in m?m:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${h.slice(0,200)}`}}finally{clearTimeout(u)}}function jd(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var xl=N("cli");function nt(n,e){let s=[],a;for(let c=0;c<n.length;c++){let u=n[c];if(u===e){a=n[c+1],c+=1;continue}if(u.startsWith(`${e}=`)){a=u.slice(e.length+1);continue}s.push(u)}return{value:a,rest:s}}function ul(n){let e=n.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e.includes("--status"))return{mode:"status"};if(e.includes("--stop"))return{mode:"stop"};if(e.includes("--refresh"))return{mode:"refresh"};if(e.includes("--uninstall"))return{mode:"uninstall"};if(e.includes("--install-service"))return{mode:"install-service"};if(e[0]==="send")return fl(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:a,rest:c}=nt(s,"--pat-token");s=c;let{value:u,rest:f}=nt(s,"--pair-code");s=f;let{value:h,rest:m}=nt(s,"--env");s=m;let{value:y,rest:b}=nt(s,"--handshake-url");s=b;let{value:w,rest:S}=nt(s,"--frontier-url");s=S;let{value:C}=nt(s,"--agent-id");if(!a||!u)return{mode:"help"};let I={mode:"pair",privatecode:a,pairingCode:u};return h&&(I.env=h),y&&(I.handshakeUrl=y),w&&(I.frontierUrl=w),C&&(I.agentId=C),I}function fl(n){let e=n[0],s=n[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!s||s.startsWith("--"))return{mode:"help"};let a=n.slice(2),{value:c,rest:u}=nt(a,"--caption");a=u;let{value:f,rest:h}=nt(a,"--name");a=h;let m=a.includes("--json"),y={mode:"send",kind:e,path:s,json:m};return c&&(y.caption=c),f&&(y.name=f),y}var dl=`
120
+ `),Kd(c.code);if(n.json)process.stdout.write(`${JSON.stringify(c)}
121
+ `);else{let u=n.name??zd(s);process.stdout.write(`Sent ${n.kind} ${u} (${Hd(c.bytes)})
122
+ `)}return 0}function jd(){let n=process.env.COZE_BRIDGE_AGENT_ID,e=process.env.COZE_BRIDGE_SESSION_ID,s=process.env.COZE_BRIDGE_IPC_PORT,o=process.env.COZE_BRIDGE_IPC_TOKEN;if(!n||!e||!s||!o)return null;let c=Number.parseInt(s,10);return!Number.isFinite(c)||c<=0?null:{agentId:n,sessionId:e,port:c,token:o}}async function Gd(n,e,s,o){let c=new AbortController,u=setTimeout(()=>c.abort(),o);try{let f=await fetch(`http://127.0.0.1:${n.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(s),signal:c.signal}),h=await f.text(),m=h?JSON.parse(h):null;return m&&typeof m=="object"&&"ok"in m?m:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${h.slice(0,200)}`}}finally{clearTimeout(u)}}function Hd(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var ul=O("cli");function et(n,e){let s=[],o;for(let c=0;c<n.length;c++){let u=n[c];if(u===e){o=n[c+1],c+=1;continue}if(u.startsWith(`${e}=`)){o=u.slice(e.length+1);continue}s.push(u)}return{value:o,rest:s}}function fl(n){let e=n.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e.includes("--status"))return{mode:"status"};if(e.includes("--stop"))return{mode:"stop"};if(e.includes("--refresh"))return{mode:"refresh"};if(e.includes("--uninstall"))return{mode:"uninstall"};if(e.includes("--install-service"))return{mode:"install-service"};if(e[0]==="send")return dl(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:c}=et(s,"--pat-token");s=c;let{value:u,rest:f}=et(s,"--pair-code");s=f;let{value:h,rest:m}=et(s,"--env");s=m;let{value:w,rest:b}=et(s,"--handshake-url");s=b;let{value:S,rest:A}=et(s,"--frontier-url");s=A;let{value:N}=et(s,"--agent-id");if(!o||!u)return{mode:"help"};let D={mode:"pair",privatecode:o,pairingCode:u};return h&&(D.env=h),w&&(D.handshakeUrl=w),S&&(D.frontierUrl=S),N&&(D.agentId=N),D}function dl(n){let e=n[0],s=n[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!s||s.startsWith("--"))return{mode:"help"};let o=n.slice(2),{value:c,rest:u}=et(o,"--caption");o=u;let{value:f,rest:h}=et(o,"--name");o=h;let m=o.includes("--json"),w={mode:"send",kind:e,path:s,json:m};return c&&(w.caption=c),f&&(w.name=f),w}var ll=`
123
123
  coze-bridge - local bridge daemon for cloud Agent Service
124
124
 
125
125
  Usage:
@@ -154,36 +154,36 @@ Send file / image (D72; intended to be called by LLM inside agent bash tool):
154
154
 
155
155
  Internal:
156
156
  <node> <entry> --daemon daemon mode (OS supervisor only)
157
- `.trimStart();async function $a(n=process.argv,e={}){let s=ul(n);switch(s.mode){case"help":return process.stdout.write(dl),0;case"version":return process.stdout.write(`${yn}
158
- `),0;case"daemon":{try{await Ma()}catch(a){return xl.error("daemon start failed",{err:String(a)}),1}return new Promise(()=>{})}case"status":return ll(e);case"stop":return hl(e);case"refresh":return gl(e);case"uninstall":return pl(e);case"install-service":return ml();case"pair":{let a={};return s.env&&(a.env=s.env),s.handshakeUrl&&(a.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(a.frontierUrl=s.frontierUrl),_l(s.privatecode,s.pairingCode,e,a,s.agentId)}case"send":return Ka({kind:s.kind,path:s.path,...s.caption?{caption:s.caption}:{},...s.name?{name:s.name}:{},json:s.json})}}async function Xa(n){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(n.pidFile).catch(()=>{}),e(n.portFile).catch(()=>{}),e(n.tokenFile).catch(()=>{})])}async function ll(n){let e=n.paths??W(),s=new et(e),a=await s.probe();if(a.kind==="not-running")return process.stdout.write(`coze-bridge: not running
159
- `),1;if(a.kind==="stale")return await Xa(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
157
+ `.trimStart();async function Qa(n=process.argv,e={}){let s=fl(n);switch(s.mode){case"help":return process.stdout.write(ll),0;case"version":return process.stdout.write(`${En}
158
+ `),0;case"daemon":{try{await qa()}catch(o){return ul.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return hl(e);case"stop":return gl(e);case"refresh":return pl(e);case"uninstall":return ml(e);case"install-service":return _l();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),wl(s.privatecode,s.pairingCode,e,o,s.agentId)}case"send":return Ja({kind:s.kind,path:s.path,...s.caption?{caption:s.caption}:{},...s.name?{name:s.name}:{},json:s.json})}}async function e0(n){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(n.pidFile).catch(()=>{}),e(n.portFile).catch(()=>{}),e(n.tokenFile).catch(()=>{})])}async function hl(n){let e=n.paths??H(),s=new Qe(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
159
+ `),1;if(o.kind==="stale")return await e0(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
160
160
  `),1;let c=await s.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
161
161
  ${JSON.stringify(c.body,null,2)}
162
- `),0}async function hl(n){let e=n.paths??W(),s=new et(e),a=await s.probe();if(a.kind==="not-running")return process.stdout.write(`coze-bridge: not running
163
- `),0;if(a.kind==="stale")return await Xa(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
162
+ `),0}async function gl(n){let e=n.paths??H(),s=new Qe(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
163
+ `),0;if(o.kind==="stale")return await e0(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
164
164
  `),0;try{return await s.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
165
165
  `),0}catch(c){return process.stdout.write(`coze-bridge: stop failed: ${String(c)}
166
- `),1}}async function gl(n){let e=new et(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
167
- `),1;try{let a=await e.request({method:"POST",path:"/refresh"});return a.status===200?(process.stdout.write(`coze-bridge: refreshed
168
- ${JSON.stringify(a.body,null,2)}
169
- `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(a.body)}
170
- `),1)}catch(a){return process.stderr.write(`coze-bridge: refresh failed: ${String(a)}
171
- `),1}}async function pl(n){let e=new et(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
166
+ `),1}}async function pl(n){let e=new Qe(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
167
+ `),1;try{let o=await e.request({method:"POST",path:"/refresh"});return o.status===200?(process.stdout.write(`coze-bridge: refreshed
168
+ ${JSON.stringify(o.body,null,2)}
169
+ `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(o.body)}
170
+ `),1)}catch(o){return process.stderr.write(`coze-bridge: refresh failed: ${String(o)}
171
+ `),1}}async function ml(n){let e=new Qe(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
172
172
  `);try{await e.request({method:"POST",path:"/shutdown"})}catch(u){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(u)}
173
- `)}await new Promise(u=>setTimeout(u,500))}if(!n.skipSupervisor)try{let{getSupervisor:u,buildContext:f}=await Promise.resolve().then(()=>(bi(),yi)),h=u();await h.uninstall(f()),process.stdout.write(`coze-bridge: ${h.platform} supervisor unregistered
173
+ `)}await new Promise(u=>setTimeout(u,500))}if(!n.skipSupervisor)try{let{getSupervisor:u,buildContext:f}=await Promise.resolve().then(()=>(Ei(),Si)),h=u();await h.uninstall(f()),process.stdout.write(`coze-bridge: ${h.platform} supervisor unregistered
174
174
  `)}catch(u){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(u)}
175
- `)}let a=n.paths??W(),{rm:c}=await import("node:fs/promises");try{await c(a.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.cozeRoot}
175
+ `)}let o=n.paths??H(),{rm:c}=await import("node:fs/promises");try{await c(o.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.cozeRoot}
176
176
  `)}catch(u){return process.stderr.write(`coze-bridge: remove failed: ${String(u)}
177
177
  `),1}return process.stdout.write(`coze-bridge: uninstalled
178
- `),0}async function ml(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(bi(),yi)),s=n(),a=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
179
- `),await s.install(a),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
178
+ `),0}async function _l(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(Ei(),Si)),s=n(),o=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
179
+ `),await s.install(o),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
180
180
  `),0}catch(n){return process.stderr.write(`coze-bridge: --install-service failed: ${String(n)}
181
- `),1}}async function _l(n,e,s,a={},c){let u=new et(s.paths),f=s.spawnDaemon??za;if(!s.skipDistInstall){let y=await Ha({paths:s.paths});y.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${y.fromVersion} \u2192 ${y.toVersion}
182
- `),(await u.probe()).kind==="connected"&&(await u.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):y.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${y.libVersion}
181
+ `),1}}async function wl(n,e,s,o={},c){let u=new Qe(s.paths),f=s.spawnDaemon??Ka;if(!s.skipDistInstall){let w=await Wa({paths:s.paths});w.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${w.fromVersion} \u2192 ${w.toVersion}
182
+ `),(await u.probe()).kind==="connected"&&(await u.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}
183
183
  `)}let h=await u.probe();if(h.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
184
- `),await f({paths:s.paths}),h=await wl(u,s.waitTimeoutMs??1e4,s.sleep??yl),h.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${h.kind}
185
- `),1;let m={privatecode:n,pairing_code:e};a.env&&(m.env=a.env),a.handshakeUrl&&(m.handshake_url=a.handshakeUrl),a.frontierUrl&&(m.frontier_url=a.frontierUrl),c&&(m.agent_id=c);try{let y=await u.request({method:"POST",path:"/pair",body:m,timeoutMs:35e3});return y.status===200&&y.body?.ok?(process.stdout.write(`coze-bridge: paired (${y.body.note??"ok"})
186
- `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(y.body)}
187
- `),1)}catch(y){return process.stderr.write(`coze-bridge: pair failed: ${String(y)}
188
- `),1}}async function wl(n,e,s){let a=Date.now()+e;for(;Date.now()<a;){let c=await n.probe(500);if(c.kind==="connected")return c;await s(200)}return n.probe(500)}function yl(n){return new Promise(e=>setTimeout(e,n))}$a(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
184
+ `),await f({paths:s.paths}),h=await yl(u,s.waitTimeoutMs??1e4,s.sleep??bl),h.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${h.kind}
185
+ `),1;let m={privatecode:n,pairing_code:e};o.env&&(m.env=o.env),o.handshakeUrl&&(m.handshake_url=o.handshakeUrl),o.frontierUrl&&(m.frontier_url=o.frontierUrl),c&&(m.agent_id=c);try{let w=await u.request({method:"POST",path:"/pair",body:m,timeoutMs:35e3});return w.status===200&&w.body?.ok?(process.stdout.write(`coze-bridge: paired (${w.body.note??"ok"})
186
+ `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(w.body)}
187
+ `),1)}catch(w){return process.stderr.write(`coze-bridge: pair failed: ${String(w)}
188
+ `),1}}async function yl(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){let c=await n.probe(500);if(c.kind==="connected")return c;await s(200)}return n.probe(500)}function bl(n){return new Promise(e=>setTimeout(e,n))}Qa(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
189
189
  `),process.exit(1)});