coze-bridge 0.1.67 → 0.1.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +69 -69
- package/package.json +3 -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
|
|
9
|
-
`):
|
|
10
|
-
`)}function
|
|
11
|
-
`,a=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await Ts(a,o,{encoding:"utf8",mode:s.mode}):await Ts(a,o,"utf8"),await Is(a,n),s?.mode!==void 0&&await ux(n,s.mode)}catch(d){await Is(a,a).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(a,{force:!0}).catch(()=>{}),d}}var Pn=Te(()=>{"use strict"});import{promises as Ps}from"node:fs";import{homedir as px}from"node:os";import{sep as hx,join as ue,resolve as Cs}from"node:path";function G(n){let e=n??px(),s=ue(e,".coze"),o=ue(s,"bridge"),a=ue(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:a,libEntry:ue(a,"index.js"),binDir:ue(o,"bin"),pidFile:ue(o,"bridge.pid"),portFile:ue(o,"bridge.port"),tokenFile:ue(o,"bridge.token"),patTokenFile:ue(o,"pat-token"),logFile:ue(o,"bridge.log"),installLock:ue(o,"install.lock"),configFile:ue(o,"config.json"),agentsRoot:ue(s,"agents")}}function $e(n,e=G()){let s=ue(e.agentsRoot,n);return{root:s,config:ue(s,"config.json"),workspace:ue(s,"workspace"),logs:ue(s,"logs")}}async function ks(n,e){let s=await Ps.realpath(Cs(n)).catch(()=>null);if(!s)return!1;let o=await Ps.realpath(Cs(e)).catch(()=>null);if(!o)return!1;let a=process.platform==="win32"?s.toLowerCase():s,d=process.platform==="win32"?o.toLowerCase():o;return a===d||a.startsWith(d+hx)}var oe=Te(()=>{"use strict"});var Dn={};$r(Dn,{AGENT_CONFIG_FILE_MODE:()=>Cn,enforceAgentConfigMode:()=>yx,loadAgentConfig:()=>he,persistAgentSessions:()=>Jr,persistAgentSkills:()=>kn,saveAgentConfig:()=>Se});import{chmod as mx,stat as _x}from"node:fs/promises";function he(n,e){return Pt($e(n,e).config)}function Se(n,e){return Tn($e(n.agentId,e).config,n,{mode:Cn})}async function yx(n,e){if(process.platform==="win32")return;let s=$e(n,e).config;try{let o=await _x(s);if(!o.isFile())return;let a=o.mode&511;a!==Cn&&(await mx(s,Cn),Ds.warn("agent config mode auto-corrected to 0600",{path:s,from:a.toString(8)}))}catch(o){if(o.code==="ENOENT")return;Ds.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Jr(n,e,s){let o=await he(n,s);o&&(o.sessions=Object.fromEntries(e),await Se(o,s))}async function kn(n,e,s){let o=await he(n,s);o&&(o.skills=e,await Se(o,s))}var Ds,Cn,it=Te(()=>{"use strict";Pn();q();oe();Ds=D("agent-config"),Cn=384});function Lo(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?au:e}function ct(n){return Pt(n??G().configFile)}function Ue(n,e){return Tn(e??G().configFile,n)}var au,Bt=Te(()=>{"use strict";Pn();oe();au=10*6e4});var ca=ve(Y=>{"use strict";var C=M;(function(n,e){let s=M,o=n();for(;;)try{if(-parseInt(s(1680))/1+parseInt(s(1948))/2*(-parseInt(s(795))/3)+-parseInt(s(560))/4+-parseInt(s(1540))/5*(-parseInt(s(1588))/6)+parseInt(s(1125))/7*(parseInt(s(591))/8)+-parseInt(s(1885))/9*(parseInt(s(1707))/10)+-parseInt(s(1917))/11*(-parseInt(s(1178))/12)===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(nr,470065);var af=Object[C(1990)+C(1891)],cf=Object["getOwnPropertyNa"+C(1933)],ra=(n,e)=>function(){return n&&(e=(0,n[{lNEaA:function(d,u){return d(u)}}[C(1301)](cf,n)[0]])(n=0)),e},xf=(n,e)=>{for(var s in e)af(n,s,{get:e[s],enumerable:!0})};function df(){return Zo||(Zo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function uf(){let n=C;return Qo||(Qo=[IDBCursor.prototype[n(1740)],IDBCursor[n(575)+"e"][n(740)],IDBCursor[n(575)+"e"]["continue"+n(798)+"ey"]])}function ff(n){let e=C,s={lgGxz:e(1761),YgLbF:function(a,d){return a&d},suDMT:function(a,d){return a>>>d},OeKVr:e(1242),zkdhy:function(a,d){return a(d)},RNofF:function(a){return a()},YtuZN:function(a,d){return a instanceof d},ukVhZ:e(1011)+e(824),JbqWA:e(1650),OUgOL:"none_none",Iywst:"binary",pKaEt:function(a,d){return a===d},LjiMT:"error",fQCQi:"setdb",YAKfA:e(466),uoTqY:e(1241)},o=new Promise((a,d)=>{let u=e,f={WYzDp:function(p,h){return s.YtuZN(p,h)},CGhvr:function(p,h){return p instanceof h},HiJrq:s[u(626)],HKVqp:u(1011)+"ion/json"+u(1490)+u(1615),vKgPu:s[u(584)],elAJm:s.OUgOL,wlXVw:s.Iywst,LqyXC:function(p,h,y,w){return p(h,y,w)},ZlokJ:function(p,h){return s[u(1297)](p,h)},UmDvn:function(p){return s[u(736)](p)}};if(s.pKaEt("dBOvp","GRhQQ"))if(f[u(1687)](_0x754c43[u(426)],_0x1df3e3)){let p=f[u(868)](this[u(918)][u(712)+u(1258)],_0x28f56f)?{force:!!this[u(918)][u(712)+"ncoding"][u(1708)],encoding:this[u(918)][u(712)+u(1258)][u(1830)]?this[u(918)]["payloadE"+u(1258)][u(1830)].replace(/\s/g,"")[u(944)+u(421)]():""}:{force:!1,encoding:this[u(918)][u(712)+u(1258)]?this[u(918)][u(712)+u(1258)][u(430)](/\s/g,"")[u(944)+u(421)]():""},h=_0x10de94[u(712)+u(1258)]?_0x37f38c[u(712)+u(1258)][u(430)](/\s/g,"")[u(944)+u(421)]():"",y=this[u(918)][u(1994)+u(875)]instanceof _0x282d43?{force:!!this[u(918)][u(1994)+u(875)][u(1708)],type:this[u(918)][u(1994)+"ype"][u(773)]?this[u(918)][u(1994)+u(875)][u(773)][u(430)](/\s/g,"")[u(944)+u(421)]():""}:{force:!1,type:this[u(918)][u(1994)+u(875)]?this[u(918)][u(1994)+u(875)].replace(/\s/g,"")[u(944)+u(421)]():""},w=_0x298694[u(1994)+u(875)]?_0x2ef0b6[u(1994)+"ype"][u(430)](/\s/g,"")[u(944)+u(421)]():"",A=y.force?y.type:w||y[u(773)],I=p[u(1708)]?p.encoding:h||p.encoding,E=[u(1627)+u(820)+u(1182),f[u(711)],f[u(777)],f[u(984)]],k=[f[u(1344)],f[u(1338)]];this[u(918)][u(1532)+u(1929)+"extPayload"]&&E[u(1610)](A)&&(!I||k[u(1610)](I))?_0x358a98[u(439)+u(1946)]=f.LqyXC(_0x5333f8,_0x509250[u(426)],0,_0x508270[u(426)][u(823)+"th"]):_0x6332e6["textPayl"+u(1946)]=""}else _0x36a9c2[u(439)+"oad"]="";else{let p=()=>{let w=u;n[w(1210)+w(607)+w(622)](s[w(973)],h),n[w(1210)+"entListe"+w(622)](w(654),y)},h=()=>{let w=u,A={xkFxe:function(I,E){return I>>>E},XbFTt:function(I,E){return s[M(1067)](I,E)},rfGBr:function(I,E){return s[M(1067)](I,E)},VZJNM:function(I,E){return s.suDMT(I,E)}};if(w(1242)===s.OeKVr)a(s.zkdhy(Ge,n.result)),s.RNofF(p);else{let I=this[w(1244)],E=this.low;return[A[w(842)](I,24),A[w(1747)](A[w(842)](I,16),255),A[w(1637)](I>>>8,255),A[w(1747)](255,I),A[w(842)](E,24),A[w(1747)](E>>>16,255),A[w(425)](E,8)&255,255&E]}},y=()=>{let w=u;f[w(1828)](d,n.error),f[w(526)](p)};n[u(1614)+"Listener"](s[u(973)],h),n["addEvent"+u(1955)](s[u(1060)],y)}});return o[e(498)](a=>{let d=e,u={vzatH:s[d(810)]};if(s[d(1555)](a,IDBCursor)){if(s[d(729)](s[d(1734)],s[d(1543)]))return _0x545bf5[d(881)](u[d(1013)],_0x444a9b,_0x1c7e87,_0x9ab2bb),this[d(718)].set({cursor_name:_0x54ae94,cursor:_0x1930f8,service:_0x248e85});li.set(a,n)}})[e(1538)](()=>{}),ir[e(1593)](o,n),o}function lf(n){let e=C,s={rWXZH:function(a){return a()},KPzKh:function(a,d){return a(d)},hDnYa:e(533)+"or",GMlsK:e(654),UeBuJ:e(1080),ecpYq:e(1938)};if(rr.has(n))return;let o=new Promise((a,d)=>{let u=e,f={rPmET:s[u(1693)],Yddpr:s[u(1721)]},p=()=>{let w=u;n[w(1210)+"entListener"](w(1938),h),n[w(1210)+w(607)+w(622)](f.rPmET,y),n[w(1210)+w(607)+w(622)](f.Yddpr,y)},h=()=>{s[u(523)](a),s.rWXZH(p)},y=()=>{let w=u;s[w(894)](d,n[w(654)]||new DOMException(s[w(485)],"AbortError")),p()};n[u(1614)+u(1955)](s[u(1091)],h),n[u(1614)+u(1955)](s[u(1693)],y),n["addEvent"+u(1955)](s[u(1721)],y)});rr[e(1593)](n,o)}function M(n,e){n=n-408;let s=nr(),o=s[n];if(M.OQlgsg===void 0){var a=function(p){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",y="",w="";for(let A=0,I,E,k=0;E=p.charAt(k++);~E&&(I=A%4?I*64+E:E,A++%4)?y+=String.fromCharCode(255&I>>(-2*A&6)):0)E=h.indexOf(E);for(let A=0,I=y.length;A<I;A++)w+="%"+("00"+y.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(w)};M.QwCeWp=a,M.oQlVAY={},M.OQlgsg=!0}let d=s[0],u=n+d,f=M.oQlVAY[u];return f?o=f:(o=M.QwCeWp(o),M.oQlVAY[u]=o),o}function gf(n){sr={BCAYy:function(s,o){return s(o)}}.BCAYy(n,sr)}function pf(n){let e=C,s={sqqeX:function(o,a){return o(a)},GbMRB:function(o,a){return o===a},xWXId:function(o){return o()}};return s[e(655)](n,IDBDatabase.prototype[e(1628)+"ion"])&&!("objectSt"+e(1267)in IDBTransaction.prototype)?function(o,...a){let d=e,u=n[d(1352)](s.sqqeX(xn,this),o,...a);return fi.set(u,o[d(1998)]?o[d(1998)]():[o]),s.sqqeX(Ge,u)}:s.xWXId(uf)[e(1610)](n)?function(...o){let a=e;return n[a(1714)](s[a(1279)](xn,this),o),Ge(li[a(791)](this))}:function(...o){let a=e;return Ge(n[a(1714)](s[a(1279)](xn,this),o))}}function nr(){let n=["zNDZxZeUmc4","BKjlDxC","B0XxzKq","qNjOsve","DMLJzuLeig8","B25tDg9Wsw0","nNWXmhW0","DNz3wvu","EgTrEfC","wfH0DwK","uvLfsNi","AvvzB3G","uwjvuwu","vLDmzhm","D2vsDM4","x29UrxjYB3i","veL1uhC","t3rewKi","BgLUzq","wvD4suS","mJiZmti1DuzMA1Lb","z2vY","x2LZsw5PDa","B2nRzxrgywK","vMfRqNO","x2rPC2nVBM4","rw55CLG","v1L6rha","yur6BMC","B3vnrMy","EwjlB3m","rMP1Dhe","shHxt3q","r01SC0S","vgjUA3e","zw5XDwv1zq","ywrK","vw5Oyw5KBgu","vw9iwe0","uMvHzcbWyxm","Bg93","zw5fDMvUDa","FdH8mxW0","tuDHsuG","Axjgtva","zgvnuMe","x3DZsw5ZDge","mtbluMTbCLe","zM9Yy2u","q1LYufu","zNjVBunOyxi","zu9YCwi","BIWGAg9ZDg4","C3Pvtu8","yxbWBhK","sMHmDhu","AM5jy3m","wLboEwi","q2jwr3i","DgHHBIbSB2m","shbvr1q","vwvcDuO","tLfVCgi","B25szwnLAxy","y2XLyxi","BujMuMG","AKLfy0W","tfPYCKq","vNzkqLu","CMndBMy","sgrpBMm","x2XPC3rLBMu","Ae5brvC","s2P6Age","wuflzKe","zNjVBNrPzxi","rMDtuMm","tvPbDva","y3PbAKe","y29SBM8","ywr2yw5Jzq","A1bfDg4","vxbzAxK","EevdCfu","BefAyMS","yKTrCMi","tKDWChy","wgjgvhq","Awrgr3i","z2j4t2G","x3bYB3rVy28","qxrJAeS","y2HHCKnVzgu","x3bYzwzPEa","ChfizLG","tg9NsurozxC","rvffrgu","x3jLywr5q2W","B2nRzxrtDwm","z3nctwO","B25LCNjVCG","C3vJy2vZCW","Ae9KBu0","zvPKse8","r2TPAgm","CM92AwrLige","thDwshC","zxrxB3jRq2G","CeD2rKe","vhD0t1i","AMvJDfn0B3i","C3bSAxq","m3W1Fdj8mhW","Dg9VigXHCMC","CKXWB20","zNjHBwvuExa","vvn5zKy","DLLhBxm","CMvJB25Uzwm","zuHPA1m","wMjmEuO","y2vZC0HHBMq","zwnVBM5Ly3q","v2vPEgLUsLm","AxnbCNjHEq","Cvr5B0y","z2vjBMzVu3K","Dhviv2y","B1vVtLG","wg5jAhO","CxzoENi","BwLZzq","rMrkCgK","vwvTBKG","DxDmCMy","zwn0","q0Xpu0LorW","qKnQzgm","vuPHBwC","wvvIq2K","B25dBg9Zzq","A09Vrue","qMzWswq","m3WXFdj8nxW","zxHWB3j0CW","BxHAveS","BfzvtvG","z3Ptu3u","DM9ZEhi","yxKSig5LDhC","CYbHBhjLywq","B25QsuK","yxjYyxLIDwy","EK5QtLa","suPcCwi","v3DWzfi","DxrVuMvJB24","A3bWDgm","vw5PBxbSzw0","t1DMqMS","wuDXyvK","AxH6u3C","AevYCM9Yrxy","y2TtufG","A1n0yxr1C0m","uezyte4","BNPXz3m","CM92AwrLihy","wMXVA0O","vfPsr3u","zw5JB2rPBMC","DuPVDM0","qKnVCeO","yxGGCMv0CMK","Euroruu","y29UBMvJDeu","v0rVAva","AxnmB25N","zNjVBuj5Dgu","r01XCfi","Bu1JCeW","y3vYC29Yx2y","mhWZFdr8mxW","uvveyNe","sgTdte0","ChrVCG","t0DIrgy","zhfpvuC","tM9uBw4","mNWXFdb8nhW","C25LBKC","zw5KCg9PBNq","BfvnCKO","B09LwM4","y29UBMvJDgK","D0njtKW","r1rxzNu","DMTVBM0","tw1HvxG","zxjYtM8","CMvHzg9UBhK","AxnYv0q","BgD4zgG","z29PBMCGyxC","y0rIshq","DLzttgG","C3fJqMK","wfrMELO","ihzHBgLKigq","BxvZCxO","Axnby2TdBgu","Dw1ly1O","EeflD0W","y3vYC29Yx24","q09otKvdveK","BKDKruC","tLr4veW","q0rJDxa","wvDACvy","C1rowe0","rxPYD3q","Dw5KzwzPBMu","y2HLy2TdDxi","ihjLy29UBMu","te5kzgW","ntK2nZaYn3LZAuzqwq","tefvr0i","nxWZFdr8mhW","EevusKq","tercvgm","C29Tzq","B3bLCNr5","u2fvAwm","Ewv0CNG","BLfcC0C","B2zM","wKLvCem","DgLLCKPtt04","B05Vtfy","y3jLyxrLt3a","ihrVihjLDhi","rffftvO","y1v0EvO","yMXVy2TLza","Ee9WqKu","twzKugu","Dw5RBM93BIa","x2n1CNnVCKy","B21jtgy","zgf0yq","y2XLyxjtDg8","Dev2qvy","D1riv2S","ALnLsMC","v09MBMW","DMX2C2K","DMvYC2LVBMm","mJG2zvDjCNft","v2fvBfO","CNjVCK1LC3m","zKXsy2G","zMffzva","zhbqBKe","Be1NDKO","ALHuANC","AKX1C04","y2f5rNm","DgLUzYbZzxi","C2vYDMLJzs0","yw5ZzM9YBvq","CMvXDwLYzwq","BxnNsuq","C1rOq0u","BwvZ","DgfIyxnL","yw9TrfG","Dg9cExrLCW","tKXOzhe","y29TCgXLDgu","vgTJD1G","x3bHDgHlzxK","rxzLBNq","x2rPC3bHDgm","wLnjwu4","BhngCuy","sg1uy3y","B2fK","zxjYtxnN","nKTmvhDxtW","A1rVt0S","we94tuC","r0z5shO","x2HHBMrSzva","ELbMzw0","EKLXyM8","tgLZDgvUzxi","DgLTzw91DcW","AfbzA1y","y3vYC29YlNm","uKTND3u","zgv2AwnLx2K","Eg1mufC","x2rYB3bhBg8","BKXHufi","DhzjsNG","Dhr3Awq","B3jpBMXPBMu","t3bgyM8","Aw5KzxG","ywnOzwq","yuTpEvC","CMvZzxrfBMq","wertBxq","tuT4r0u","z2v0qwXSs2u","Dw5ZAwDUzwq","rMTzvg4","t3HdBLe","rxbhyMK","x2LZtwLUAvC","wLvgyMS","t3r3uLy","z1rPBwvVDxq","q251uLe","ANPlqKK","sfbrtu8","ywnRDxbfBMq","whvYv3K","vezPwKi","B3bLBKrc","zgvMAw5Luhi","CgzntLy","wxrKvKG","y3H4CuW","Cgf5Bg9Hzfq","AvDAz3e","qwrkzwG","Ee5Kswi","C29YDa","ENLOvwW","x29UvgLTzw8","BKjczue","q2XIqKS","DeLK","C2LnvKy","v0DVwgG","DMvUDa","vLfosxK","rez2zee","DcbSAw1PDa","ENjABe8","t2jTD2C","sur5tMS","DhjPBq","AgvKtwf4uMu","B0Plvu4","Ef9MCM9UDgK","zxjFywnRx20","y291BNq","CxzwwKy","yxnL","y29UBMvJDfm","x29Uq2XVC2u","C0Ddsfa","vLPktK0","Cgf5Bg9Hza","qMLuqMi","BwvY","qKHSDvm","CMvWBgfJzq","yw1Lu3bHy2u","y0v5uKq","q29NEva","EhPSBha","zxjFDhrS","vvf4uKy","qxnPA1e","sNLdC3m","Dgv4DfbHEwW","shj0r2u","EMPvC0C","uLr5yKy","A25qquy","AwXLtMfTzq","wvf0CNO","EMjlzKy","AvvZsNO","ugvdBgi","ywzL","D2LSBfjLy28","zxf1ywXZ","vwDuzg0","BNrLCG","AwTtuxy","x29Ut3bLBG","z3HWqvm","zgrjrcWGzgu","x3nVy2TLDa","ufnOwKK","su5vrLO","yxDtBwi","z3riAw8","mNW0Fdn8mhW","zMzmAw5L","y3jLyxrLuMu","zfLMA2O","zwvKzwq","q3PHvfu","BgvY","DunIy1O","DNDxBMm","C3rLBMvYCW","CMvZzxrdB3u","z05kCg4","yxrIuMG","CKP2CuG","z2zAC0e","C3rHCNq","x2LZtM9Kzq","ufbwu1a","ELHhtvC","t1vryKq","Egj6Eey","zgvIDwC","AerUwwe","AvL1reO","nNW1FdeWFda","AxPnzgq","rvzUuum","zcbLCNjVCI4","re5fvKO","s0nXshu","vwPIBgm","vgTsrey","AxmGDw5Kzwy","CMfTugfYyw0","DMfS","DgHLBG","y3jLyxrLtwu","Evn1qvK","zw9dz2y","B3ngELO","AxDAqxG","DwPsDhC","Ec1TC2CTy3u","rfn1yLm","wujhEKe","twPHvNa","BgvUz3rO","BMCGzMfPBgu","DevHthG","seHLB28","x19LC01Vzhu","shHvr20","B01stey","tufyx1jfvfi","DcbVzIbYyw4","BwvZC2fNztO","uhnNzvm","tgrHqve","rM5AzxK","tenZC0u","CLDywKG","u3rYyxrLz3K","zw5JB2rLrNi","vw1eDM4","veTtBuC","CgHJrgS","z2v0u3rVCMe","qvjcufa","zezPsgC","A3jtueO","qwjVCNrfCNi","q291BNq","Cw1Hs2W","C2nouhm","A09jDNa","y2XVC2u","x3bPBMC","yNvMzMvY","rgDSCNq","DfjXAKC","D2nmv1y","sevhCeK","sfzKCKe","vu5owK8","mNWX","Cu5SAMG","Bg5LB1q","Exf1q0m","CNrStwy","ihrPBwvVDxq","Aw5PDcbrB1m","BMnLq2XVC2u","zunYwgu","x2fKzfDZtgK","tg9JAW","CeT4A20","C3bSAwnL","mtq2nJC0mgrXC1jysG","yw1LoIa","B0j4DKK","qxzKrMm","DuXdAu8","rffLAhO","x0rctMfTzq","q3voz1i","tuzLs0K","C2vUza","CgXLyxnLiha","Efrurw52","rvHiuvm","AvzgELq","DuLUAwG","ChjVDg90Exa","twPABw0","AM9PBG","Dg9oDw1Izxi","tMPxzuO","A3jRsKK","EMr5vxq","rufOufi","EfjKBKy","sMjXv0e","rvrZtgm","tLb2qLG","wvnwEhO","DNnTsKq","yvPpAfa","zw50","mJK2AKzwELP4","r2TPEfO","CfDAr2G","tgHdD3O","qNrVDwK","D1L0rMu","yw1L","wMz2qwi","seHcCNq","ugjot2y","CgLUz09Uy2u","Bg9Nsurhzw4","Bvjwr0y","vKnkzg8","tgfpCuy","uNbYv2q","zw50tgLZDgu","y29Uy2f0","D2vI","BgLZDgvUtMu","CMTLCKDSB2i","Dg9iyxnO","ufLYDuq","x2LZqNjVD3m","x3bPBMDqB24","rgHYsuq","ywnR","AwvAy0O","BxDWwfm","zv90Aw1LB3u","AfjZuKy","BMvY","ENzVyMK","CMvWBgfJzui","vffoyxm","DwTwAfO","u0ToBu8","rxDwtvO","rvjst1i","qvD6rfy","s1zoruW","rxPcsNC","BMDuAw1LCG","t3bsEvu","EeLpC3q","BurTAuG","y0Pds3C","q3vZDg9Trxi","Effqtui","tenuyu0","AgfMEeq","r2z4thG","AMr4BLi","zujAwuy","qwLgAKW","su9ky0y","ruHhBgW","vufjrue","qK1UzKW","C0zZENu","ihrPBwvZ","C2jIA24","z2v0s2v5","zxjYB3i","r2jnuKi","zw50zwqGDhK","y2uGBM90igK","ywrKt25L","B25TzxnZywC","B2jQzwn0u3q","s0nIrNC","r1H6yKO","uxzYDNa","rKLmrv9ot1q","y2HLy2Tszwe","AKPZrfK","Bg9IywXty28","ywrKq291BNq","CufOvuS","zxmGCMvHy2G","AKLRqvi","mdaWmdaWmda","Eg5NDha","seDlz1m","y0XKwfm","rMvrug8","uuP2vK0","vvnmvhu","rhrYCM8","y09ZCgG","yK1Vzhe","B2zMC2v0","qxzmAfy","r2rtA1u","uxvLDwu","q2nUBNG","x2nSzwfYugK","mtf8mtb8n3W","u25yDe8","rvrwC1K","Efn1uKu","ruHXDfq","Dvrwu3G","u2HHCMvKv28","s05kwKS","B2Hdy04","shreuKy","x1fVu01HBMe","B3bLBG","uKDbyMW","y3jLyxrLq2W","qMvVDuq","AMv6qxO","qNjPzgDL","BMzWwNq","A2fSDuu","B25nzxnZywC","DhDSrKS","zhvWC2O","u0XxENy","sgLkCNe","Cgf5Bg9Hzeu","AK9pCeO","C2vUzf9Hy2S","ChjVDg9JB2W","Bg9NsurozxC","BMrLEa","x3fVC0rc","B3jRig9MzMW","CuHPAe0","Avbxqu8","x2jPBMfYEvq","DfjTAuK","BM5kDLm","AMncALG","tfzeC0S","vvjsChu","CgvYC2LZDgu","CeTHrxq","q3bdDe4","yM9KEq","wwnuALm","sxDzu2G","svjfz0y","AuHtzMe","uK5VzKy","rKDnD0G","v25WBuS","x2TLEvbHDgG","y29UDgLUDwu","ALfXDKq","mdaWma","A1rds2e","t0L3r3u","quXm","CNzHBa","n3WYFdn8oxW","BwfW","suXevLi","Aw5Lza","sfbxEgy","t2Dosfi","CMfTzq","AvDUCxe","ywXSzwqGBxu","shn0vwK","qLLsrLu","BMrWB2LUDfq","r2DmDK0","rw1ktw8","q0HNvgK","ChzWAvi","sNzjA2y","B3vUDa","Du1LA2K","Cfvot1m","y29Kzq","DhDVCMTdAge","zezcqum","wenYq1C","EKPhC1i","wLreugi","DhLWzq","qMzdB3i","DgfYz2v0","yxPZCKO","seTwCxa","u2LbCfm","C0rJvxi","DeLNDum","DLzAu3C","veP6v0W","u1DLEMC","uLbRrgi","u2ruvvK","s3nnsNu","ug9YEve","CMvHzhLtDge","tMXfsvy","A2v5CW","z2v0","vhndA00","D3nPyM8","y1vqzgi","mJa4ode1qvj2AvfU","rLDt","BLzpq2m","uhjPBwfYEuS","B2LUDfjLywm","zNzsweK","sNvNv3C","CM9YrxzLBNq","yNL0zu9MzNm","AenSB3nLrxy","wNbNqw4","C2XPy2u","x21PBMLoyxy","zg9Uzq","qxboBMy","zLfduwK","m3W0Fdf8mNW","A1DSzgO","zcWGDw5RBM8","x2LZtwLUAvq","wLnftem","A1fnqKG","DxbKrM8","CgfRDwC","AxnszwfKEq","Aw47y2HHCNm","we9KqM4","C3nHz2vfDMu","yNL0zuXLBMC","Aw9Ul2PZB24","yMLUyxj5","sefxDNe","uufXEKm","BuTcu20","uvzrwhG","BNbpthy","uxzUrKq","CvHKBwq","ihrYEsbYzwm","D0DuyM8","Aw5KzxHpzG","DNLxCNy","x25HDMLNyxq","BuvWs2W","BNnpAuG","qvvoDeu","sMzgr3y","EgTgEgu","qNzJy3a","z21uyKS","yxbWzw5Kq2G","tLfqrMy","Cg9W","x2HHBMrSzu8","re1uyKK","wefZEva","AwDHDg9Yt24","rfLOrw4","CNnVCKzPBgu","uK1Qu3G","uLjpuG","AgfUz2u","CfjkBeG","C2jPAxu","zgvQDKS","vwnmuw4","v0zIAvm","s3LxEvq","yM9L","A0jfuNC","q0LJwM0","BwvZC2fNzq","DxbNCMfKzw4","q0DODNi","BunWrKm","AwzeCgy","y3vYCMvUDeu","rxndzNm","z0z6sM0","vLz4qKG","ExbL","CMvJzxzPzwq","u2jHwgW","CMfNzvn5BMm","zxjHDg9Y","rgrMtLK","Bg9N","AKXUBeS","zKLMuLi","u2XiDg0","AuDND0i","thjIrgK","ignVzgu6ia","C0jf","swHItKS","Afv0sMW","whz1tw0","v0Plt2G","zMLN","s1b6s2G","nhWW","ze9JsLu","yKfSwuy","Be5oDuW","DvDAufO","y2XVC2veqG","CMDbueu","C2v0sxrLBq","BeXQzMO","AgfZ","BMDssgi","rxjYB3jdB2q","v0Dyue4","y2XVC2uSihC","ywDLrxzLBNq","DeLUDgvYy2u","ug9orNm","x3vYBa","uLnlv0S","zvPsr3i","CLzZsvu","s29zC3u","s2HUyK0","x29WDgLVBNm","wwTXvwG","rNjVBNrPzxi","nhWXFdz8oxW","A1rcDMm","q3zVueG","q0Xpu0ve","tuvUzxm","q1zAB0S","yLz0v3q","uxHVz0i","u21nExm","tw9WD2u","ExrTz3q","ywnRx2nVzgu","EhrcCMq","Dwfouey","yMLUza","BujsCvG","rgHtEhe","Bwf4uMv0CMK","vhjSqva","Aw5N","yMfJA3vWigu","q3P0Axa","D0Tlwgu","Dg9mB3DLCKm","AMPezfq","ChvZAa","r0PMDhe","u1j4D0K","yw9KB1u","Dev2zw50","B25JBg9Zzq","EgLNuKm","CLvgvhG","CgjICdi","ALj0Dgm","BhrPCgXLihq","Eg1VEgO","CMvQzwn0","vK5eu0C","rMfez3e","wvDVCKq","x0vysvnu","CM92AwrLigi","BMvJDa","whbcDw4","C2v0u3rVCMe","sgfmwxK","EuXICwW","vxbKyxrLq28","BM5Ly3q","AgfZt3DUuhi","EfvZzuvUDG","BgDhEhO","suvtx0vsuK8","wfnoD0m","zw5NDgG","y3vYDMfSDwu","BMfTzq","qNverLO","vKXLv0K","DeDNvMq","y3vYCMvUDeK","zMvY","DKTNuhu","Dgf1zNK","igXHCMDLCIa","y1jJsgq","DvLYvfu","Ae1LC3nHz2u","t1jJv24","CgfNzxnOB3C","D3jPDgvvAw4","ywXty29Wzq","zfnhtfa","y29UBMvJDca","u2TPCcbWyxm","BNrfBMrWB2K","y3jLyxrLrwW","x2n1CNnVCK0","y1DkyvK","D1LjrKu","CMvTB3zLq2G","zwPHuxu","zKXTuMS","z2v0sxrLBq","AwTYExi","tLbOCMG","x2vUzhbVAw4","qKnyu3y","qKjnDMC","yxbWBgLJyxq","CgLUz0LUDgu","DNPHDeG","tg9Nsuq","s3LoEvi","ywWGy3vYC28","C0LUrue","CwTzqxu","Bwu6ia","x2rLyNvN","DvrNEgK","u2vzDeu","Dwrht2C","ywDLu2HVDW","Efj2Aha","CMvZzxruCMK","qKngBM4","yxfjCvO","whPcwem","yMfSu2nVCgu","uhL0CKO","Cg93","zw1PDa","D2fZq2XLyw4","C0Xf","sLrSuLa","q29UzMLN","BwvKAwf0zwW","BgLUzw5V","t3bLBKv2zw4","sMrcyuy","BwfUDwfSihi","v2vIu29JA2u","Ae96rfm","zgLZCgf0y2G","Dgnstwu","ywnRtxnNswq","Dw50","yMLUyxj5vhK","qxj3wue","CvD3DLO","DLnlrMe","Aw9U","yxDZsMW","renRCeu","C2DPza","u0LYq1q","Axz0Dxy","x2LUAxrhBg8","tgPPtvq","C21PqMS","B2nRzxq","zMzMzG","sLnptLa","s21dCvO","AwH5ywS","wwDmyKy","zvvYBa","rxruvwq","vwDgEvK","yxLQEMm","rwXwy2G","yurwEhm","uhrJAKW","sgD4Cvy","ANv4Auy","yuHOrg0","x3jLBw92zvC","DMvYC2LVBG","ywjVCNq","BxnN","ANPPzve","qw1VDw50","rLHVCKq","v050DwK","CxbcBMy","Cu1ytLO","D0HtBgq","zxH0zw5ZAw8","s2zTCxm","zwnWwxe","x2DLDeLUDgu","x3DZ","EM5iyKm","shPUEMC","yxrHlcbKyxq","sxH4r1y","AMnJy0e","u0DnEhq","y3jLyxrLrxi","BML0AwfSAxO","y2nMCNK","CMncvNu","zhLnC1q","tNLqvgq","Cu1ktNi","Dwr3DM8","wKz0rfq","DuTfyK0","sg95vM4","zMzLCG","DNnczgq","BNrbBMrvCgq","zu5qwue","CeHvA2G","Ec11C2uT","q3L6Chy","zgvS","zfrKDfa","q3zAswm","Dxrjza","u0rjvvq","BwHQAui","DLHWru8","nJa2mZr2CgP5thG","vgjqDwi","Auj0C2S","BM93","qxDPzeC","zgnZCfi","qvrcCeq","yw5Nzq","zLLqsfe","DvLrCgu","AKHyELu","BMrWB2LUDca","x2rLC3rYB3K","zffws3e","B25VCgvU","id4G","BgjPwMO","x3bPBMDmB3m","u2XfsMu","veTQruG","x2nYzwf0zvm","ywX3yxLZ","ywjqD2K","y3jLyxrLt2i","wxb3r0e","BMnLEvi","B0vSAgK","Bg5xDMi","ywXSq3vYC28","CMXYrM4","yw5Hz2vY","AwXSihvZzsa","EuXrsfu","AMn6txi","B2zMBgLUzq","zgLAsMG","Dg9cExrLC0W","AxzKrvG","yw9rt1G","x2zVCM1HDeu","ufDhweC","vgLTzw91Da","q1rYruO","BK96AfO","v0XjENa","zv9ZDwnJzxm","CMvHC29U","B1fwwMm","C1buDfe","BwHKDKi","C2LWvu0","igfYCMf5yNu","A0PozM0","ndC0mZq4EhDvuNrk","B3nLrxzLBNq","l3DZl3yY","Cw9Z","zxq9DxrMltG","A2v5","yxv0BW","DxH4z2K","Dgv4Dc9Qyxy","t2PbtvK","aaaaaaaaaaa","CvDIvxy","C2fNzq","ue11zwW","qLDOC0C","ExDpA3K","CMvHzfvjBNq","vhf2ruK","vgfN","reiGzMfPBgu","zNjVBu51Bwi","Avflv0G","u0jMq2W","DMz2CMq","A055sw4","wg5ktwq","vMDZD1e","zMLSzw5HBwu","t2fwA2q","z2v0qwXS","B25tDgfYDfi","z2rMqxG","CMvTB3zLrxy","B3jRzxjhBg8","mNWWFdr8mxW","D3PPyNK","tKXAD3e","rfndAgi","t2fWAuC","ChbL","zu9WANa","AxnFywnR","BMCGDxjSoIa","DLPizwu","t2jQzwn0","wNLTCKK","sMv2uwq","twLZC2LUzYa","twXAq2e","qLryzvq","qLjWvNK","DvDevfe","yw51Ce1LC3m","u0fJvha","ChnuCem","AxHHqxi","v2LAsgK","BeXMELe","Cgzgr3C","Dhj1y3rVCIa","v1DrtKm","u0HHCLO","Axn5Eu4","rND5tMO","rMfQr1a","q21Otg4","AgLNAa","Bgziwhq","y2fWAxe","swrnBhO","t1bftG","Aw50zwDLCIa","EezdrgO","zMX1C2HfEha","BgLTAxq","veP0txi","x2n1CNnVCK4","shLLvfm","ue9iBKq","DgvZDa","BMnVzgLUzW","CNnVCL9Uyw0","B3LezhK","wMTkzfa","Bxj3vgW","D1PVzfu","qNzhy3O","C0XPC3rLBMu","Dfv1rLi","B3jLtMfTzxm","CM1Xshu","CfrVA1m","uw5hsNK","vNDer1m","ysbTDxn0igi","v2zQsLG","zgLwDgW","s09LA28","r2XVAwm","z2D4tvC","wfb2yu8","C3fXzvG","zgvSzxrL","t0X2rfy","t2jpuwi","rgTluuS","A3jlA20","CvjlBgm","r2jJA20","nhWYFdb8m3W","quzTtKq","txzbvui","ELDmCxa","Ae9Wzw5fDMu","AxjMBvy","y2v6twq","nxWX","runhr0i","B3PlB0e","EMTKAhK","rwTvz0W","igzPzwXKoIa","D1P1B3G","Be5fyue","rw1Wuwe","C2vUDa","rg5ztLK","uuL6sLG","tLPTEMG","yxv0B21HDgK","CMvKDwnL","AM95yKm","zNviEgq","mhW2Fdv8nW","yMfnANO","BwvZC2fNzv8","y29UDgv4Da","igzHAwWSig0","DML0Exq","zxH0ugf5Bg8","CNzHBfzHBhu","zufJAW","AhzYsNe","EKPXtM4","zffjwgG","y2HnyxHdB3u","D1bOBuy","D0LgCum","z2vtEw5J","zgLZywjSzue","sgPhC3G","z2v0q3vYCMu","BvbyAeK","CgLUz0XVC3m","A2rfvLa","vgnzy2i","x2LZv29YA2u","BfrPBwvVDxq","Aw9UvgLTzw8","CMfUzg9T","D2XyvNC","C3vIC3rYAw4","r2nNDKW","y2niyMW","y2rrBw0","ywDLsgLKzq","zwXbsM0","DKLwvg4","x3DHAxq","txrbq0i","Chv0","zKTiAMm","tMTKCuO","D3jPDgu","y2fSBa","uMX4zLa","twvZC2fNzuu","AxjLza","EvjLy29UBMu","txnRB0G","C3rVCcbPBw0","EMzLD0e","surNte0","y3ruAw1LB3u","C2vYDMvYvgK","rgDusNi","zgvSzxrLrge","D3bQsMq","Bwf4twvZC2e","C2vYDMLJzq","t2D4Eg8","uwjJAwW","ChjVy2vZCW","D24GCMvHC28","Bu9PzLi","BeHHBMrSzxi","CgLUz19VBMm","Dg9tDhjPBMC","wuXcAhi","D3m6lY8","A2v0ignVBNm","zhrnBwy","rvHoD1a","yNLL","q29Kzq","AxHVsxO","zgvJB2rLzey","u2Hhv0C","B25SAw5L","zfLvs1C","Efv5tNa","u2jmyLu","Ag9rr2G","tgPstLC","ufP3vhe","ohW5FdD8mxW","Aw1LCYbPBIa","zefos2y","BMLVEwO","Dg9Tsei","uevhC1C","x2nVBM5Ly3q","y09Wzw4","ANL0DMu","yMPxAhO","BNruCMLLC0m","Dg9Y","Dg9hzw5LCMe","y1rTtu8","Dur1v08","CgfNzwHPzgu","BNHls0y","CLvtyK4","rgngs1y","AefJA01LC3m","B1bRrxC","ywDWsu4","x21LC3nHz2u","sxzkExq","t1bftL9fuLi","mhWYFdr8m3W","C3rYAw5NAwy","DxjS","BKrRrgO","x2nSzwfYvgK","BNvTyMvY","sMjqBMC","tefIEeC","De1HBMfNzxi","rKrOtha","nhWZ","ugDmENa","vK5JCwq","CMvZB2X2zq","ig1LC3nHz2u","suzNEg8","zMHlywO","A2vpue8","z2vrDwv1zuW","zvDfAeu","BMCGB3iGyw4","y1HeC0m","rffRwhG","rwPQrM8","BwDxwMq","B3bLBIa","wNLcs0O","C3rVCMu","yMfSrxzLBNq","tu5ezMu","CLDXweK","vfDSBK8","x2LUAxq","v0nZEg0","x2LUAxrqCM8","CxfXBwK","y2TNrfG","sgfYBhi","C3vIyxjYyxK","uhj1AM0","vuvXrNG","yKjODe0","y0nrA3q","vMrJue0","nxWYFdf8mhW","vKfRuhi","CIb0DhDjra","uNzttNq","Cg9PBNrbBMq","ufbmy28","r3Dhsey","DgvmB2Djre4","zLrqy1m","wezzuva","x29UtwvZC2e","CwnQEvO","uLbYyKW","q3vZDg9Tq2W","ihn1y2nLC3m","D3nZoI8V","vKHyv0y","sKPNuwO","zNjkvMW","B25fCNjVCG","ve9RCLG","Bwv0Ag9K","BePeyxi","C1busM0","CM92AwrLihC","teL1zNy","sNnWwKy","tMfTzq","o2nOyxjZzxq","z1Hrthm","zuTRthq","Bez4ChO","CLzHBhvLCW","AgvHzgvYCW","BezSDxnO","zNvUy3rPB24","x2HHBMrSzvi","v3Lrwee","v0ThDhi","zeTbqwu","rgn5qNC","t1Phzva","BMDLza","v2zRshi","AgvHzgvY","DhjPzxmGCMu","BfnrAMm","zgrAAMm","wfb3CgK","CMLLC0nVDw4","vvj4reK","shD5z1y","qLHOEKm","uwT3rMe","yNvMzMvYzwq","y29UC3rYDwm","mhWYFdn8nhW","AwXK","B3jL","q0LmuhG","B1Hdzve","BMv4DcGPigm","zMLSDgvY","vezryu8","txrAzMe","yNL0zxm","wK9osfK","rvLjvKK","t3v1qKm","x29UugfNzu4","zw5HyMXLvhi","vLrHCKe","B25ozxr3B3i","quTQywS","DxrMofDYAxq","DerqvLC","y2f0y2G","C0nVDw50zxi","ntGZndq1r0DVse9w","ywDL","Dg9cExrLC0i","Dw9uCvK","u0Dkwuy","B21rA3e","C2v0y3vYC28","vffwyLi","z0j4v0W","qNnLweS","y3r4","A3rJwwW","Certwui","qwzurxe","zfDVCMTLCKC","wxr1wK4","rfLpALK","C2v0q3vYC28","CeTfrw0","x3jLy29UBMu","zxjFCw9Zx2e","BKXPBMu","DhjPzxm","DMfSDwvZ","thHusxi","BvLxq3m","B3nLza","r2niq1G","CMvHzhDYAxq","yxnJCMLWDa","AeTzrhy","v1zNBxa","vxntBhu","t0T3ALy","swDmv2G","y3blqMe","zMLUza","zuLiwfy","yuTwEhu","AxnrB1nnzxm","z2v0q3vYC28","CYbPBNn0yw4","vNb1CKK","tvr0z2K","x2LUDgvYDMe","BM1tEvO","rLjptLrjrvi","B25mAw5L","mZbzAvbRvM8","C05btwW","qvnwrvC","y3bLu1O","u21uA0e","C2v0","rLD4vKS","tKfusvzfx0u","Bwf4tg9ZC0m","AxnrB1nby2S","rufHCLG","sKTsy00","yLLzBKy","tfn2r2q","Cw9Zx18","vuf1vxG","Dfrgwgy","Aw5L","y2HnyxHuCMK","vhvQwfu","uefQvxm","t1Pqzw4","Aw5JBhvKzxm","zxj2AwnL","wvD4zwG","Egn5uMW","ywrKrxzLBNq","pxv0zI04","DxbKyxrLq3u","zKTwqvC","Cg9PBNrdB24","x3nLCuLK","vKruD2m","uwziufy","thzly0q","u2vYDMLJzvC","rwXqrve","yxnZAwDU","lcbxzwjtB2m","Dgv4Dc9WBge","DhjHBNnHy3q","m3WYFdb8nhW","EvzXsvy","CMvJzwL2zwq","EwPsAgy","quvoz3u","u2vXsuq","Ew93wvK","ywXPzcb1CMW","CMzhqNi","se1qwe8","q21Orfu","s2L4vxC","y3vYC29Y","uLH0CKG","yMzZA1m","zM9YrwfJAa","vfn1sw0","Ahr0Chm6","Dev4vva","zxjFAxnFywm","zNjVBujPDhm","C3rYAw5N","DMfSDwu","lcbTyxGGCMu","BxvtquO","vMLQEwq","yxrLq291BNq","CgfYC2u","veHrENC","BwLUzW","x2rItMfTzq"];return nr=function(){return n},nr()}function hf(n){let e=C,s={bfmPp:function(o,a){return o===a},tTFXf:e(1497),nceyR:function(o,a){return o(a)},HjGsx:function(o,a){return o instanceof a},qWbUv:function(o,a,d){return o(a,d)}};return s.bfmPp(typeof n,s[e(1604)])?s[e(1150)](pf,n):(s[e(1328)](n,IDBTransaction)&&s.nceyR(lf,n),s[e(1189)](ia,n,df())?new Proxy(n,sr):n)}function Ge(n){let e=C,s={VBckS:function(a,d){return a instanceof d},BRpVy:function(a,d){return a(d)},aMXLK:function(a,d){return a!==d}};if(s.VBckS(n,IDBRequest))return s[e(1228)](ff,n);if(er.has(n))return er[e(791)](n);let o=s[e(1228)](hf,n);return s.aMXLK(o,n)&&(er[e(1593)](n,o),ir.set(o,n)),o}var ia,Zo,Qo,li,rr,fi,er,ir,sr,xn,ea=ra({"node_modules/idb/build/wrap-idb-value.js"(){let n=C,e={azsrJ:n(1287)+"1|5",OeFtu:"get",ZnelP:n(1207),oXCeQ:n(1974)+"ys",pvpiR:n(419),TKSmG:function(s){return s()},tEaLx:n(1348),ruDyA:"delete",BCopJ:function(s,o){return s(o)},BYRFU:function(s,o){return s instanceof o},AUNtE:function(s,o){return s!==o},nQBsG:"NDTyP",jHXzU:function(s,o){return s===o},krKkm:n(808),mxZTK:function(s,o){return s===o},DkKQK:n(660)+"oreNames",kpptc:n(1445),LKoNl:function(s,o){return s===o}};ia=(s,o)=>o[n(1890)](a=>s instanceof a),li=new WeakMap,rr=new WeakMap,fi=new WeakMap,er=new WeakMap,ir=new WeakMap,sr={get(s,o,a){let d=n,u={WpBVq:e[d(776)],aodoU:e.OeFtu,jzKBI:e.ZnelP,WaUlZ:e[d(1522)],CFern:e[d(762)],iUsJz:function(f){return e[d(527)](f)},MmaUx:e[d(511)],SiApS:e.ruDyA,wGTbo:function(f){return e[d(527)](f)},SRxwI:function(f,p){return e[d(1832)](f,p)}};if(e[d(757)](s,IDBTransaction))if(e[d(840)]("NDTyP",e[d(1894)])){let f=u.WpBVq.split("|"),p=0;for(;;){switch(f[p++]){case"0":_0x1c4b65=[u[d(949)],d(653),u[d(1984)],u[d(1918)],u.CFern];continue;case"1":_0x4793a6=new _0x38433c;continue;case"2":u[d(447)](_0x52f1ee);continue;case"3":_0xce3cb5=[u[d(1858)],"add",u[d(778)],d(1724)];continue;case"4":u[d(834)](_0x38357d);continue;case"5":u[d(948)](_0x325782,h=>({...h,get:(y,w,A)=>_0x469d12(y,w)||h[d(791)](y,w,A),has:(y,w)=>!!_0x6dcf4f(y,w)||h[d(904)](y,w)}));continue}break}}else{if(e[d(1135)](o,e.krKkm))return rr[d(791)](s);if(e[d(1805)](o,e[d(1283)]))return s["objectSt"+d(1267)]||fi.get(s);if(o===e[d(1817)])return a[d(660)+d(1267)][1]?void 0:a["objectSt"+d(1520)](a["objectSt"+d(1267)][0])}return e[d(1832)](Ge,s[o])},set(s,o,a){return s[o]=a,!0},has(s,o){let a=n;return e[a(757)](s,IDBTransaction)&&(e.mxZTK(o,e[a(1284)])||e.LKoNl(o,e[a(1817)]))?!0:o in s}},xn=s=>ir[n(791)](s)}}),sa={};xf(sa,{deleteDB:()=>wf,openDB:()=>mf,unwrap:()=>xn,wrap:()=>Ge});function mf(n,e,{blocked:s,upgrade:o,blocking:a,terminated:d}={}){let u=C,f={NecZK:function(y,w,A,I,E){return y(w,A,I,E)},EFXCH:function(y,w){return y(w)},WnpmK:u(538),dSGLP:function(y,w){return y(w)},yDNEE:u(867)+u(467),TJtMr:u(1903)},p=indexedDB[u(699)](n,e),h=f[u(994)](Ge,p);return o&&p[u(1614)+"Listener"](f[u(1834)],y=>{let w=u;f.NecZK(o,Ge(p.result),y.oldVersion,y.newVersion,f.EFXCH(Ge,p[w(1628)+"ion"]))}),s&&p[u(1614)+u(1955)](f[u(1253)],()=>s()),h[u(498)](y=>{let w=u;d&&y[w(1614)+w(1955)](f[w(738)],()=>d()),a&&y["addEvent"+w(1955)](w(1916)+"hange",()=>a())})[u(1538)](()=>{}),h}function wf(n,{blocked:e}={}){let s=C,o={uCVlF:s(1903)},a=indexedDB[s(1364)+s(1934)](n);return e&&a[s(1614)+s(1955)](o.uCVlF,()=>e()),Ge(a)[s(498)](()=>{})}function ta(n,e){let s=C,o={xzllp:s(1568)+"e",cXjVm:function(p,h){return p instanceof h},irFMP:function(p,h){return p in h},XGjnh:function(p,h){return p===h},phhue:function(p,h){return p!==h},xbzxF:function(p,h){return p in h}};if(!(o.cXjVm(n,IDBDatabase)&&!o[s(1704)](e,n)&&o.XGjnh(typeof e,s(1650))))return;if(tr[s(791)](e))return tr[s(791)](e);let a=e[s(430)](/FromIndex$/,""),d=o.phhue(e,a),u=aa[s(1610)](a);if(!o[s(483)](a,(d?IDBIndex:IDBObjectStore)[s(575)+"e"])||!(u||oa[s(1610)](a)))return;let f=async function(p,...h){let y=s,w=this["transact"+y(1053)](p,u?o[y(434)]:y(1860)),A=w[y(1445)];return d&&(A=A[y(1968)](h.shift())),(await Promise.all([A[a](...h),u&&w[y(808)]]))[0]};return tr.set(e,f),f}var oa,aa,tr,_f=ra({"node_modules/idb/build/index.js"(){let n=C,e={WgFtk:function(s){return s()},uNQjf:n(791),MIRSP:"getAll",CuNgR:"count",EjjFo:n(1348),FGMwH:n(1696),nrofa:n(1280),Dptrk:"clear"};e.WgFtk(ea),ea(),oa=[e.uNQjf,n(653),e.MIRSP,"getAllKeys",e[n(567)]],aa=[e[n(1441)],e[n(737)],e.nrofa,e.Dptrk],tr=new Map,gf(s=>({...s,get:(o,a,d)=>ta(o,a)||s[n(791)](o,a,d),has:(o,a)=>!!ta(o,a)||s[n(904)](o,a)}))}}),yf={idb:function(n){let e=C;n[e(1804)]=Promise[e(1431)]().then(()=>(_f(),sa))[e(498)](function(s){return s})}},na={};function qe(n){let e=C,s={ZlcsQ:function(f,p){return f!==p}},o=(e(1849)+"3").split("|"),a=0;for(;;){switch(o[a++]){case"0":var d=na[n]={exports:{}};continue;case"1":if(s.ZlcsQ(void 0,u))return u[e(1804)];continue;case"2":var u=na[n];continue;case"3":return d[e(1804)];case"4":yf[n](d,d[e(1804)],qe);continue}break}}(()=>{let n=C,e={PEGsW:function(s,o,a){return s(o,a)},sPTtQ:function(s,o){return s(o)},MNDfe:function(s,o){return s===o},gmTbK:n(1162)};qe.d=(s,o)=>{let a=n,d={Qbcil:function(f,p,h){return e[M(1398)](f,p,h)},TJzWL:function(f,p){return e[M(1173)](f,p)}};if(e[a(1447)](e[a(844)],e[a(844)]))for(var u in o)qe.o(o,u)&&!qe.o(s,u)&&Object[a(1990)+a(1891)](s,u,{enumerable:!0,get:o[u]});else d[a(1369)](_0x24c602,_0x169308,96),d[a(1369)](_0x47a0ed,_0x7b7e3,d[a(782)](_0x25dfa4,_0x2dd86c))}})(),(()=>{let n=C;qe.o=(e,s)=>Object[n(575)+"e"][n(971)+n(1891)][n(1352)](e,s)})(),(()=>{let n=C,e={aDzng:function(s,o,a){return s(o,a)},MKejY:n(654),UgTdm:function(s,o){return s+o},zrZlO:function(s,o){return s!==o},UAIEA:n(794),HAWvq:function(s,o){return s!=o},rLpom:"Module"};qe.r=s=>{let o=n;if(e[o(411)](o(1964),e[o(648)]))e[o(826)](o(1881)+"d",typeof Symbol)&&Symbol["toString"+o(1196)]&&Object[o(1990)+"operty"](s,Symbol[o(1375)+"Tag"],{value:e[o(1774)]}),Object[o(1990)+"operty"](s,o(513)+"le",{value:!0});else{let a={eBZYF:function(u,f,p){return e[o(1688)](u,f,p)},qWwvZ:e.MKejY},d=_0x7baf11[o(540)][o(806)](_0x57e5d0[o(803)+"et"],e[o(452)](_0x43f83d[o(823)+"th"],_0x1f4f9c[o(803)+"et"]));Y[o(458)]&&Y[o(458)][o(569)]({data:d,fail:u=>{let f=o;Y[f(1033)](f(654),a[f(644)](_0x48a942,a[f(1051)],{message:Y[f(1164)+"rrorMessage"](u)}))}})}}})();var re={};(()=>{let n=C,e={VNcqd:function(i,t,r){return i(t,r)},ClbBK:n(1374)+n(1170)+"s",uWZPZ:n(1374)+n(620)+"t",LdaAQ:function(i,t){return i(t)},vyWrv:n(1761),Gbckm:"timeout",pfMNV:n(1474),IDyNk:function(i,t){return i+t},gdfAx:function(i,t){return i<t},keOPO:function(i,t){return i>>t},Dglrt:function(i,t){return i|t},wTHWk:n(1803)+n(895),VdcPM:function(i,t){return i&t},tRqjG:function(i,t){return i>>t},IhbNK:function(i,t){return i&t},xRvhp:function(i,t){return i&t},lLjfj:function(i,t){return i!==t},GJftq:n(1577),uWDTQ:function(i,t){return i*t},abPwi:function(i,t){return i(t)},Ezrwt:function(i,t,r){return i(t,r)},ApNnf:function(i,t){return i(t)},WKGtr:function(i,t){return i(t)},dFiHg:function(i,t){return i(t)},lAZbk:function(i,t){return i+t},rWqXI:n(742),aKOyW:n(1063),JKRcM:n(672)+"00000000"+n(672)+"00000000",ixoIz:n(1778)+"t",Obmwg:n(1358)+"ediately"+n(1883)+"ct",OpRyU:function(i,t){return i===t},jIEcL:n(1722),XTfzZ:"YABmF",EwVMZ:function(i,t){return i>t},AtchK:n(1764),fhKaj:n(1036),GFyHz:function(i,t){return i!==t},EXHQS:n(1647),PoryQ:function(i,t){return i<t},AENgu:function(i,t){return i-t},CvoPH:function(i,t){return i!==t},MjZmm:function(i,t){return i<t},HgxqV:function(i,t){return i-t},QvnFD:function(i,t){return i===t},psTpC:n(1923),JugWw:function(i,t){return i<t},YLBhr:function(i,t){return i!==t},wHSld:n(1015),KsMJu:function(i,t,r){return i(t,r)},ZFtDT:function(i,t){return i!==t},wpjJd:function(i,t){return i(t)},WDoiP:function(i,t){return i>>>t},zJGsR:function(i,t,r){return i(t,r)},nDkDj:function(i,t){return i(t)},eHikS:function(i,t,r){return i(t,r)},gBxWL:function(i,t){return i(t)},updFo:function(i,t,r){return i(t,r)},yetrx:n(1225)+"required"+n(1299)+"key",ECGGB:n(1225)+"required"+n(1299)+"value",NlEIV:function(i){return i()},mPXhI:function(i,t,r){return i(t,r)},AdJeh:function(i,t){return i(t)},KyWyT:function(i,t){return i!==t},FWxVK:function(i,t,r){return i(t,r)},JhLtu:function(i,t,r){return i(t,r)},QxogB:function(i,t){return i!==t},LhCwz:function(i){return i()},oJKUN:function(i,t,r){return i(t,r)},ObOQb:function(i,t){return i(t)},ASVEW:function(i,t,r){return i(t,r)},XfPCr:function(i,t){return i!==t},VgswQ:function(i,t,r){return i(t,r)},iFFFH:function(i,t){return i!==t},ozKoA:function(i,t,r){return i(t,r)},pGvFA:function(i,t,r){return i(t,r)},xECpU:function(i,t,r){return i(t,r)},BvGcz:function(i,t,r){return i(t,r)},HoyVn:function(i,t){return i(t)},HxWOt:function(i,t){return i(t)},ouMFf:function(i,t){return i(t)},LIufv:function(i,t){return i(t)},DFvdA:function(i,t){return i(t)},DMTbI:function(i,t,r){return i(t,r)},lgxdh:function(i,t,r){return i(t,r)},SnXtO:function(i,t){return i(t)},jJsDY:function(i,t,r){return i(t,r)},NTxTL:function(i,t){return i(t)},DnYNY:function(i,t,r){return i(t,r)},bEgbf:function(i,t,r){return i(t,r)},HstUi:function(i,t){return i(t)},phlFb:function(i,t){return i(t)},TkcwX:function(i,t){return i===t},SmTkA:n(1225)+n(1930)+n(1299)+"service",ikSQv:n(1225)+n(1930)+n(1299)+n(1483),JJgQj:function(i,t){return i!==t},krkJI:n(588),jytve:"WwFWX",REdcU:function(i,t){return i(t)},XPvaO:function(i,t,r){return i(t,r)},BfCor:function(i,t,r){return i(t,r)},znHbC:n(1818)+n(656)+"pe: ",EmJMo:function(i,t){return i>=t},taufy:function(i,t){return i!==t},myLzc:n(1813),CIcZm:n(1488),TsCkM:function(i,t){return i>t},HwygV:function(i,t){return i+t},uaNPF:n(996)+n(410),WGXPN:function(i,t){return i>=t},pULyc:function(i,t){return i>t},uYrTU:function(i,t){return i>t},szUMO:function(i,t){return i+t},UpYiy:n(1699)+n(410),CILPx:function(i,t,r){return i(t,r)},DgTJr:function(i,t){return i===t},dcspR:"sDBGt",OaVkd:function(i,t,r){return i(t,r)},ZfvAb:function(i,t,r){return i(t,r)},iYuDJ:function(i,t){return i<t},VLeWI:function(i,t){return i===t},TkRDF:function(i,t){return i&t},nGdEG:function(i,t){return i&t},XSNwC:function(i,t){return i+t},yhaFj:function(i,t){return i+t},sInEA:function(i,t){return i&t},YpwGA:function(i,t){return i<<t},kTBvc:function(i,t){return i&t},SAcTp:function(i,t){return i==t},gxpAS:function(i,t){return i+t},FRIIK:function(i,t){return i+t},ouLDD:function(i,t){return i!==t},kdEVP:function(i,t){return i&t},cTmMO:function(i,t){return i===t},xkQxW:n(437),LjRNW:n(1480),zbKfF:function(i,t){return i|t},dejvK:function(i,t){return i&t},CnuRQ:function(i,t){return i<<t},Fjutq:function(i,t){return i<=t},TcYcb:function(i,t){return i(t)},VDTwc:function(i,t){return i+t},pGmhy:function(i,t){return i===t},mBfRh:n(1877),FgSRc:function(i,t){return i+t},IvJyt:function(i,t){return i+t},aZOhP:function(i,t){return i&t},aDVxs:function(i,t){return i<<t},LwVHw:function(i,t){return i<<t},AfTEq:function(i,t){return i|t},SlHtm:function(i,t){return i&t},OjAMY:function(i,t){return i&t},Bvccp:function(i,t){return i>t},AvdFc:function(i,t){return i+t},lLfzQ:function(i,t){return i&t},FkYTn:n(1052),kOoEA:function(i,t){return i<t},VTarA:function(i,t){return i<=t},sqcBi:function(i,t){return i<t},WNtui:function(i,t){return i<<t},Prujm:function(i,t){return i<t},cOsph:function(i,t){return i-t},CHgTi:function(i,t){return i<<t},JevQd:function(i,t){return i<t},WWQNC:function(i,t){return i&t},dYUKW:function(i,t){return i>>t},HMPXO:function(i,t){return i>>t},PvUIF:function(i,t){return i|t},OLvDV:function(i,t){return i&t},ATyGM:function(i,t){return i|t},RprWd:function(i,t){return i&t},mBRqX:function(i,t){return i<t},oQVZc:function(i,t){return i|t},NoTmn:function(i,t){return i<t},NzpwO:function(i,t){return i>>t},jnIcs:function(i,t){return i|t},dpPnA:function(i,t){return i>>t},VakBz:function(i,t){return i|t},twlFK:function(i,t){return i&t},KCbFw:function(i,t){return i+t},dQIXh:"gCMKJ",sThCE:"fmoGt",capiq:function(i,t){return i<<t},LaOqF:function(i,t){return i&t},aydTd:function(i,t){return i&t},KhnbM:function(i,t){return i>>t},XOdBn:function(i,t){return i+t},PZwTq:n(536),GTWfu:function(i,t,r){return i(t,r)},nzqgs:function(i,t){return i&t},Ujblc:n(1535),xmoxj:function(i,t){return i&t},SGJYF:function(i,t){return i<<t},oOeZn:function(i,t){return i(t)},AiFjL:function(i,t){return i(t)},wCINL:function(i,t){return i&t},IFgxo:function(i,t){return i(t)},nQDZw:function(i,t){return i<<t},xSuRE:function(i,t){return i&t},SrDMT:function(i,t){return i(t)},gbxOh:function(i,t){return i&t},MlZCa:function(i,t){return i(t)},WfkHr:function(i,t){return i&t},zvobi:function(i,t){return i(t)},lsFqF:function(i,t){return i<<t},rgAPE:function(i,t){return i>>>t},wKemu:function(i,t){return i|t},Btoui:function(i,t){return i<t},XKXOY:function(i,t){return i<t},SmMys:function(i,t){return i<t},jLusN:function(i,t){return i+t},ZPNyb:function(i,t){return i>>>t},CvzJR:function(i,t){return i|t},ayjzc:function(i,t){return i>>>t},MtACB:function(i,t){return i+t},pakug:function(i,t){return i>>>t},USLTu:function(i,t){return i&t},vXpEO:function(i,t){return i+t},FaDgq:function(i,t){return i!==t},MGaIH:function(i,t){return i|t},lbiZj:function(i,t){return i+t},kaluE:function(i,t){return i|t},ieZcJ:function(i,t){return i!==t},fLmRk:function(i,t){return i|t},nOzhZ:function(i,t){return i>>>t},kVUGu:function(i,t){return i&t},mPfEg:function(i,t){return i+t},KCqHu:function(i,t){return i!==t},BCjdc:function(i,t){return i>>>t},Qvrvp:function(i,t){return i&t},BrhIQ:function(i,t){return i|t},qMXNZ:function(i,t){return i&t},CBHzE:function(i,t){return i(t)},aUupD:n(1491),MfdPe:"mRVGF",GXzbJ:function(i,t){return i|t},aHhDm:function(i,t){return i<<t},rUSbN:function(i,t){return i<<t},NPhrh:function(i,t){return i<<t},lnWvb:function(i,t){return i<<t},XzBXC:function(i,t){return i|t},jRttc:function(i,t){return i<<t},skGVH:function(i,t){return i<<t},lfHXt:function(i,t){return i>>>t},ytmgt:function(i,t){return i|t},cWJaY:function(i,t){return i<<t},dqOUG:"UfHbF",bVtWt:n(1107),TwtOR:function(i,t){return i&t},ixaAr:function(i,t){return i&t},OTbOc:function(i,t){return i>>>t},UoHXM:function(i,t){return i&t},pDSYB:function(i,t){return i>>>t},QnGJy:function(i,t){return i>>>t},INUFZ:function(i,t){return i&t},SGMxt:function(i,t){return i>>>t},OgNHR:function(i,t){return i(t)},GcHCX:n(857),cJCKw:function(i,t){return i>=t},UNNZO:function(i,t){return i+t},dQVKq:function(i,t){return i%t},kToOK:function(i,t){return i|t},baMjz:function(i,t){return i*t},SKNmO:function(i,t){return i>>>t},eNPYA:function(i,t){return i>>>t},tomHB:"DTSPi",ySuAY:function(i,t){return i===t},wPhmF:function(i,t){return i===t},qMJNr:n(1650),cLdXS:function(i,t){return i===t},nmSyZ:n(1097),qmaKl:function(i,t){return i&t},RTybF:function(i,t){return i>>>t},pfFGw:function(i,t){return i+t},VVxBH:function(i,t){return i+t},hmvLw:function(i,t){return i>>>t},iwZAx:function(i,t){return i<<t},rVsIU:n(538),juxiF:function(i,t){return i!==t},wZodU:n(1223),rJvqH:function(i,t){return i!==t},jXTjw:function(i,t){return i===t},zRZhk:function(i,t){return i>>>t},PsgeS:function(i,t){return i===t},TbPub:function(i,t){return i===t},XnIhz:function(i,t,r,c){return i(t,r,c)},XAsyP:n(727),IwYSh:function(i,t){return i&t},IDFVP:function(i,t){return i&t},BCFnn:function(i,t){return i>>>t},Ogxxo:function(i,t){return i&t},awsJl:function(i,t){return i&t},vVSLh:n(1408),phcDk:n(991),qcjyZ:function(i,t){return i===t},SlEJe:n(1995),YWZqV:function(i,t){return i&t},mgWZd:function(i,t){return i>>>t},YtdVH:function(i,t){return i>>>t},DdfNY:function(i,t){return i>>>t},SDIUT:"MESSAGE_"+n(629),nxKKF:n(1874)+"NG_ERROR",wIFqC:n(516)+"IES_ERROR",npOLv:n(1595)+n(855),Ujdht:function(i,t){return i>>>t},cDbHt:function(i,t){return i===t},JvIkf:n(512),jHLbU:n(1518)+"1",OtwRV:"WjUnz",UEqFx:n(1120),MjaVp:function(i,t){return i===t},zIqbo:n(1515),RSKWK:function(i,t){return i===t},ORcWn:n(438),NKUyg:function(i,t){return i==t},WiZHi:function(i,t){return i>t},fKVAW:n(654),ueqII:function(i,t){return i instanceof t},diZJh:function(i,t){return i+t},bBhtM:function(i,t){return i+t},dOcJU:function(i,t){return i+t},SBfCl:function(i,t){return i&t},NZmzh:n(979),NQPFf:function(i,t){return i<=t},HmTcv:function(i,t){return i<t},cpKBa:function(i,t){return i<<t},OGbDf:function(i,t){return i<t},dIIqg:function(i,t){return i&t},idFGr:function(i,t){return i|t},irfmV:function(i,t){return i&t},iUYox:"qYkxC",zPfem:function(i,t,r){return i(t,r)},cRcHd:function(i,t,r){return i(t,r)},PytrJ:"knZUj",zXGMW:"open",JbPng:"message",vrTKT:function(i,t,r){return i(t,r)},LvKcD:function(i,t){return i(t)},ZyBKJ:function(i,t,r){return i(t,r)},JPZUh:function(i,t,r){return i(t,r)},RbmDC:function(i,t){return i instanceof t},xOpBE:function(i,t){return i!==t},YkqUh:n(967),hDkJk:n(1463),nioyj:n(1070),vkonm:function(i,t){return i!=t},XnJMd:n(1881)+"d",GwGHF:n(1842)+"2",oNoLV:function(i,t){return i||t},nsOiH:function(i,t){return i!=t},hOdmM:function(i,t){return i!==t},ngRHb:n(474),XPEDz:n(1871),jOOpJ:function(i,t){return i(t)},PoNFs:function(i,t){return i<t},STlOM:function(i,t){return i<t},xIOst:function(i,t){return i===t},LCTaM:function(i,t){return i===t},jjDdT:function(i,t){return i&t},fvRXI:function(i,t,r){return i(t,r)},zfewA:function(i,t){return i<=t},LHEBj:function(i,t){return i<t},DSubS:function(i,t){return i|t},izMdd:function(i,t){return i&t},bAlYF:function(i,t){return i<t},HdOnc:function(i,t){return i|t},VpurI:function(i,t){return i<<t},tDPVW:function(i,t){return i&t},ujRtw:function(i,t){return i>=t},mCpFC:function(i,t){return i===t},kBERw:"utGbU",vvwYU:n(1609),xQPMB:function(i,t){return i&t},BXhzC:n(1956)+n(833)+"onnecting",RdZBx:function(i,t){return i!==t},qpBnf:"iPWAO",CVZoK:function(i,t){return i<t},NLZwq:n(743),TujXU:function(i,t){return i<t},vwWnc:function(i,t){return i|t},Mopwe:function(i,t){return i>>t},cnWOk:function(i,t){return i|t},xFCDj:function(i,t){return i!==t},ktcYl:n(781),oread:function(i,t){return i|t},DQEMZ:function(i,t){return i>>t},ckSPX:function(i,t){return i|t},isrWD:function(i,t){return i&t},AFmND:function(i,t){return i>>t},kWldj:function(i,t){return i&t},gfZsA:n(599),RPkDb:function(i,t){return i|t},XpBun:function(i,t){return i|t},TOkrX:function(i,t){return i&t},ihyak:function(i,t){return i(t)},DDozK:function(i,t){return i!==t},gtHio:function(i,t,r,c){return i(t,r,c)},kOIvp:function(i,t){return i instanceof t},IgLWh:function(i,t){return i||t},sPTJm:function(i,t){return i===t},HpUGT:n(1069),tAgtV:"hfPKP",ixzSw:function(i,t){return i!=t},xngtp:function(i,t){return i instanceof t},EVnQC:function(i,t){return i!=t},oPkEw:n(1573),wYtFe:n(696),wHPcH:n(863),XRxyc:n(1217),llsJu:function(i,t){return i>=t},WwpdR:n(1906)+"reason",bKQrb:function(i,t){return i===t},QfHPV:"ABbXz",SkZEd:"yowYY",VxerG:n(1186)+n(1569),HkCLM:"http",BCXSv:"&jscallback=fron"+n(1897)+"P",oyDdy:n(669),IZWxY:function(i,t){return i>>t},OtDZB:function(i,t){return i===t},hOzDS:n(766),SbaXl:"idb",nOTPy:function(i,t){return i!==t},BBMvg:"SkXUb",RzjOT:n(530),iBtsk:n(1729),TSuIm:function(i,t){return i||t},aqIqZ:function(i,t){return i||t},LSvGd:function(i,t){return i instanceof t},qSjJy:function(i,t){return i!==t},DhrID:n(1104),DQkXx:function(i,t){return i!=t},cayFs:n(553)+n(1197)+"d",OapiG:n(852),mhdvB:n(1313)+"id",VHXWF:"teWaO",fVwoc:n(709),EAarX:n(1814),TQVbR:n(705),uTgxi:n(959),cxxqL:function(i,t){return i(t)},HrtGe:n(417)+"er_qos",PmFfJ:function(i,t,r,c){return i(t,r,c)},bYYnF:n(417)+n(1560)+"ck",dRNmd:function(i,t,r){return i(t,r)},Gloic:n(417)+n(418)+n(1056),eWEhE:"need_ack",xUyNp:n(1219),PFXLN:function(i,t){return i&&t},POHnD:"ack_id",TFiZB:n(932),eKkLt:n(1631),FXorD:function(i){return i()},LNJdl:"versionc"+n(856),uLCiO:function(i,t){return i(t)},YrZrh:n(1271),NyTZi:n(797),KosGs:function(i,t){return i instanceof t},SWezg:n(1627)+n(820)+n(1182),gsBMj:"applicat"+n(824)+n(1490)+"=utf-8",FnZey:function(i,t,r,c){return i(t,r,c)},hoQGh:function(i){return i()},GKICS:function(i,t){return i>t},XCrCW:function(i,t){return i>>>t},uRzlG:function(i,t){return i+t},DcyBw:function(i,t){return i+t},aomDX:"index ou"+n(517)+"ge: ",fIfRR:function(i,t){return i||t},JQAIw:function(i,t){return i>t},rmqHu:n(1249)+n(1773)+"e",dciJv:function(i,t){return i&t},IDgLM:function(i,t,r,c){return i(t,r,c)},vosxr:function(i,t){return i===t},AvLhV:n(544),XSeZX:n(1629)+"1",YUbCi:function(i,t,r,c){return i(t,r,c)},qvNzr:function(i,t){return i<t},BfpId:function(i,t){return i+t},KNJZK:n(1175),DCkpE:function(i,t){return i|t},wZuox:function(i,t){return i|t},WyQXA:function(i,t){return i<<t},cpeSZ:function(i,t){return i<<t},Kjzha:function(i,t){return i<<t},PMuel:function(i,t){return i+t},EloHU:function(i,t){return i+t},WAXHe:function(i,t){return i|t},Vijyd:function(i,t){return i|t},DNEVJ:function(i,t){return i<<t},kJNfm:function(i,t){return i<<t},BMnfL:function(i,t){return i+t},ggxMW:function(i,t){return i+t},SbLbU:function(i,t){return i+t},CmhDU:function(i,t){return i>>>t},QAqzC:function(i,t){return i+t},SeYtE:function(i,t){return i+t},cxUUs:function(i,t){return i&t},TQNas:function(i,t){return i+t},hRsRF:function(i,t){return i>>>t},QJvVM:function(i,t){return i&t},LxTIr:function(i,t){return i>>>t},IREgF:function(i,t){return i+t},BseXK:function(i,t){return i&t},CYrPU:function(i,t){return i+t},WFbiS:function(i,t){return i<t},uCbcZ:function(i,t){return i&t},ZIUpC:function(i,t){return i>>>t},ShGWG:function(i,t){return i+t},DcFKV:function(i,t,r,c){return i(t,r,c)},fYPHQ:n(1506),eOpjp:n(978),oxdoA:function(i,t){return i(t)},VvJBU:n(1841)+"ile_name",WjjCg:function(i,t,r){return i(t,r)},mMcpL:function(i,t,r){return i(t,r)},oLWfD:function(i,t,r,c){return i(t,r,c)},MFeKI:n(664)+n(962),nLaPR:n(674),NPvBX:n(647),URxDI:n(1393)+n(1772)+n(1666),ZUFbk:"service-"+n(978),CmhLn:n(977),siMVF:n(1958)+"ervice",ILeEQ:function(i,t,r,c){return i(t,r,c)},UQxRF:n(710),ybKos:function(i,t){return i>>t},PgLzp:function(i,t){return i|t},muSAJ:function(i,t){return i&t},qTyoF:function(i,t){return i>>t},dtMmf:function(i,t){return i&t},uVbmi:function(i,t){return i===t},YSVxz:n(882),vZHee:n(1153)+n(1494),JfFGv:n(745),DQehz:function(i,t,r,c){return i(t,r,c)},tGgVd:"CONTINUE",iWnqq:function(i){return i()},tIguC:n(1381),MEnes:function(i,t,r){return i(t,r)},iHSfa:n(1863)+n(1809)+n(719)+n(1605),cdQmm:function(i,t){return i===t},LAUGB:"wqykR",ElVch:"setdb",TFQaO:"complete",GcgvL:function(i,t){return i!==t},PtcjL:n(1345),oBxvI:function(i,t){return i===t},LZrrD:n(1732),iQKWH:function(i,t){return i||t},vityt:function(i,t){return i*t},ZSELC:function(i,t){return i>t},YWxIK:function(i,t){return i!==t},Cztip:function(i,t,r){return i(t,r)},lJDar:function(i,t,r){return i(t,r)},MTtgi:function(i,t){return i!==t},HxUGm:function(i,t,r){return i(t,r)},zWLqp:function(i,t,r){return i(t,r)},uwLrf:function(i,t){return i(t)},EAhPR:"WaXQI",wziby:"code",rtlMf:n(417)+"er_msgid",jcBjX:function(i,t,r){return i(t,r)},NLhdq:n(505)+n(1259)+"e",YcTjS:function(i,t){return i(t)},xmLPW:function(i,t,r){return i(t,r)},XDSmt:n(505)+"rsor_value",EHqtT:function(i){return i()},KOeko:function(i,t){return i>t},ZpgAn:n(1670),jzieQ:n(1285),DuWsj:n(1530),WOfnl:function(i,t){return i<=t},ZkJdP:function(i,t){return i<t},lNNuL:function(i,t){return i>=t},vlvsi:function(i,t){return i&t},CpCtN:function(i,t){return i&t},ETVsY:function(i,t){return i>=t},CNpwS:function(i,t){return i-t},HyeTS:function(i,t){return i|t},IKvLo:function(i,t){return i|t},fTPcS:function(i,t){return i&t},ZQHFg:function(i,t){return i&t},cVtSM:function(i,t){return i>>t},sNAMl:function(i,t){return i+t},THQzw:function(i,t){return i!==t},PAjUs:"PaDgL",Harlr:function(i){return i()},VCJdo:function(i){return i()},FDhLp:function(i,t){return i===t},VzCDO:function(i,t){return i===t},WVgmp:function(i){return i()},ZONHY:function(i){return i()},ckgDX:n(808),HVdrA:n(660)+n(1267),eCrXe:function(i,t){return i===t},BIMuq:n(463)+n(1294),jdxnR:n(1417)+"OR",dTdtP:function(i,t){return i!==t},wYIFE:"PdIpD",pWZGh:function(i,t){return i!==t},zjUsG:function(i){return i()},OxCnQ:function(i,t){return i<t},WxOxJ:function(i,t){return i===t},LVDsK:n(1985),SdTUY:function(i){return i()},SIrCT:function(i){return i()},zJqNn:"kpDNN",SYKiM:"SSHiZ",ArwYA:function(i,t,r){return i(t,r)},xigRC:function(i,t){return i===t},rlrFn:n(1184),nxTLQ:n(1738),PPLco:function(i,t){return i===t},BrsDT:"UEgws",cezMd:function(i,t,r){return i(t,r)},EQEDe:n(1812)+n(983),jIkAR:n(954),YWorD:function(i,t){return i/t},USyfF:function(i,t){return i==t},BoAeR:function(i,t){return i===t},vsBdd:"please p"+n(1827)+n(1636),CogyP:n(570)+n(1486)+"s params"+n(1626)+n(1378)+n(1237)+n(495)+n(750),VQNIy:n(1386),QbUQe:n(1159),EnyrX:"dHHxI",yAaSf:n(1006),nBKuw:n(1646),YWxeh:n(1377),ddZjc:n(1477),hUtJl:n(1965),PYruD:n(1960)+"d",smiBk:function(i,t){return i||t},DoMCz:function(i,t){return i==t},Dtrro:n(1497),sbiiu:function(i){return i()},pLRDh:n(609),lVUMX:n(1660)+"0",QUDbq:function(i,t){return i<<t},uYQpe:function(i,t){return i&t},NXKzt:function(i,t){return i&t},tRmiI:function(i,t){return i<t},ccHbl:function(i,t){return i(t)},xtBrd:n(1123),mYWCs:function(i,t,r){return i(t,r)},zdyUt:function(i,t,r){return i(t,r)},EgUsp:function(i,t){return i(t)},zqZiY:function(i,t){return i(t)},cEyRD:n(1586)+">",RNZxQ:function(i,t){return i(t)},piaff:function(i,t){return i===t},NjWeJ:function(i,t){return i-t},jsiQo:function(i,t){return i===t},EkUgL:function(i,t){return i!==t},atbRh:n(1863)+"ay, try "+n(1778)+n(1927)+"ver",LDBTc:function(i,t){return i!==t},deMRa:n(1163),hKYDv:n(1305),jQqvD:n(420),BeouD:"AvLUj",NRtPt:n(714),uDuWO:n(1418)+"1",yVqIV:"0|4|2|1|3",musqz:function(i,t,r){return i(t,r)},GMqpR:function(i,t){return i&t},JCYcV:"BMhtS",qNljh:"FpuHP",osFzZ:n(617),wzjPz:function(i,t){return i<t},tUuFR:function(i,t){return i<t},fLRch:function(i,t){return i<t},qqqmi:function(i,t){return i+t},kPEtn:function(i,t){return i===t},yquCC:n(828),MtZfa:n(1508),ZbLyJ:n(811)+n(1311),tuHWf:function(i,t){return i===t},rUFTx:n(908)+n(1810)+"y closed",uInih:n(908)+n(1581)+n(657)+n(1101)+"ed",hPYkV:"please p"+n(1765)+n(1868)+n(1096)+n(1272)+"e a stri"+n(1438)+n(1176)+n(1111),xETJD:function(i,t){return i==t},eugmK:n(1423),aKVxu:function(i,t){return i!=t},dANKf:function(i,t){return i instanceof t},lWLTI:function(i,t){return i instanceof t},bModq:function(i,t){return i||t},RMjSx:"please p"+n(1765)+" valid s"+n(1611),Ocyhr:function(i,t){return i instanceof t},GgLvM:function(i,t){return i(t)},gzSSu:function(i,t){return i===t},eKfeU:function(i,t){return i<t},tEeWX:n(1695),oMRLF:function(i,t){return i(t)},SHarZ:function(i,t,r,c){return i(t,r,c)},krSPJ:function(i,t){return i!==t},MZAuP:n(1042)+n(1782)+n(940),rcBVu:"jtvSz",tojus:n(724),TXHzV:n(1212)+"3",derwt:n(2005),pTokS:n(1997),sFszu:function(i,t){return i*t},WLIzp:function(i,t){return i/t},lneoT:"Window",haNxc:function(i,t){return i!=t},OpFbo:function(i,t){return i===t},CTrEJ:n(1222),ifDpf:function(i,t){return i===t},iVFzT:"Dedicate"+n(1554)+n(667)+"pe",yLbql:function(i,t){return i===t},Kfmqs:function(i,t){return i!=t},lUMrJ:n(694)+n(611)+n(993),tEvAV:function(i,t){return i===t},UCkan:n(1623)+n(1211)+n(1030),LCssE:function(i,t){return i!=t},tJYsc:function(i,t){return i===t},xeTDk:function(i,t){return i===t},Ccnnx:function(i,t,r){return i(t,r)},hvrJq:"__x_msg_"+n(1602)};qe.r(re),qe.d(re,{FWS:()=>F0,CustomErrorEvent:()=>es,createCloseEvent:()=>De,ReconnectEvent:()=>Qi,createErrorEvent:()=>Ie,decodedFrame:()=>_t,createOpenEvent:()=>os,CustomCloseEvent:()=>ts,createReconnectEvent:()=>Lr,FrontierMessageEvent:()=>rs,encodeFrame:()=>se,createMessageEvent:()=>ss,OpenEvent:()=>is,ErrorCode:()=>nt,Event:()=>vt,MessageEvent:()=>ns});let s="";function o(i=""){let t=n,r={gFzJm:function(c,x){return e.LdaAQ(c,x)},TWlnO:e.vyWrv,HsVbv:e[t(2002)],KoYsu:e[t(1286)]};if(e.pfMNV!==e[t(1991)]){this[t(687)+t(633)](),this[t(615)+t(1982)+"Id"]=e[t(1430)](_0x4b1c3f,this[t(539)][t(935)](this),this._options[t(1012)+t(746)]);let c=()=>{let g=t;r[g(873)](_0x38bc4b,r[g(1449)]),this[g(1895)](r.HsVbv,c),this[g(1895)](g(1374)+g(620)+"t",x)},x=()=>{let g=t;r[g(873)](_0x11e146,r[g(916)]),this.off(g(1374)+"e_success",c),this[g(1895)](g(1374)+g(620)+"t",x)};this.on(e[t(2002)],c),this.on(e[t(899)],x),this[t(539)]()}else{let x=""+Date.now(),g=s||(s=p(i)),m=Math[t(1337)]().toString(16)[t(806)](-6);return e[t(413)](e.IDyNk("02",x)+g,m)}}function a(){let i=n,t={bfskS:function(r,c){return e[M(1209)](r,c)},TKjEH:function(r,c){return e[M(1435)](r,c)},PPVSP:function(r,c){return e[M(541)](r,c)},UJamg:function(r,c){return r&c},tcRMe:e[i(1912)],DSChb:function(r,c){return e[i(1461)](r,c)},DKAxr:function(r,c){return e[i(542)](r,c)},TZRGu:function(r,c){return e[i(413)](r,c)},ywOky:function(r,c){return r&c},eoCgf:function(r,c){return e[i(889)](r,c)},xRdnF:function(r,c){return e[i(541)](r,c)},eZRGr:function(r,c){return e[i(1025)](r,c)},BWhsG:function(r,c){return e[i(1435)](r,c)},dFBAC:function(r,c){return e.tRqjG(r,c)},xAKwL:function(r,c){return r&c},uMeki:function(r,c){return r|c}};if(e[i(903)](i(1185),e[i(947)]))return e[i(413)](e[i(1229)](1e4,Date[i(1128)]()),Math.floor(1e4*Math.random()));if(_0x529632=_0x1d1464.charCodeAt(_0x3a72b4),t[i(1643)](_0xafa01a,128))_0x1ba439[_0x27b42e++]=_0x29d684;else if(t.bfskS(_0x52a8f0,2048))_0x6bd419[_0x230936++]=t[i(1144)](_0x62a7e2,6)|192,_0x401eae[_0x2a2066++]=t[i(480)](63&_0x43ed99,128);else if(t.UJamg(64512,_0x53427a)===55296&&(64512&(_0x33e939=_0x436a57[i(1752)+"At"](_0x4eef8f+1)))===56320){let r=t[i(1046)][i(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":_0x5215a7[_0x4f3fd4++]=t[i(1215)](63,_0x437c68)|128;continue;case"1":++_0x5df646;continue;case"2":_0x2be51f[_0xf799df++]=t.PPVSP(t.DKAxr(_0x1df554,18),240);continue;case"3":_0x17731f=t[i(1829)](t.TZRGu(65536,t[i(1193)](1023,_0x55a521)<<10),t[i(501)](1023,_0x3db416));continue;case"4":_0x402ee1[_0x3e09c8++]=t.xRdnF(t[i(914)](t[i(1192)](_0x5c90ba,6),63),128);continue;case"5":_0x4365a6[_0x51158e++]=t.PPVSP(t[i(769)](_0x126446,12)&63,128);continue}break}}else _0x5cb6a3[_0x5da341++]=t[i(583)](t[i(1192)](_0x5239e5,12),224),_0x31a1a5[_0x321826++]=t[i(480)](t[i(1872)](t[i(769)](_0x5956ff,6),63),128),_0xbdf43[_0x23f874++]=t[i(765)](t[i(1798)](63,_0x3a189e),128)}function d(i){let t=n;return e.IDyNk(e[t(1147)](Array,8).join("0"),e.Ezrwt(parseInt,i,10)[t(1375)](2))[t(806)](-8)}function u(i){let t=n;return(e[t(809)](Array,4)[t(577)]("0")+parseInt(i,2)[t(1375)](16))[t(806)](-4)}function f(i){let t=n,r=i[t(1771)](/\./)[t(748)](g=>d(g)),c=[];return c[0]=e[t(1500)](u,e[t(413)](r[0],r[1])),c[1]=e[t(531)](u,e.lAZbk(r[2],r[3])),[e[t(1448)],t(742),t(742),t(742),e.rWqXI,e[t(1970)],c[0],c[1]].join("")}function p(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}/.test(i),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]))/[t(1257)](i);return r?e.LdaAQ(f,i):c?h(i):e[t(1599)]}function h(i){let t=n,r={BTXeT:e[t(899)],wcLWV:e[t(1286)],PeClb:function(c,x){return e[t(1209)](c,x)},GdSkU:function(c,x){return c===x},awSmb:function(c,x){return c&x},fKHjc:function(c,x){return c+x},wsibo:function(c,x){return e[t(903)](c,x)},nBBeA:function(c,x){return c-x}};if(e[t(634)](e[t(1726)],e[t(1867)]))this["_pingLos"+t(1539)]?.[t(668)](),this[t(1033)](r[t(1227)],r[t(543)]),this[t(1142)+t(1539)]?.[t(665)+t(1323)+"nt"]()?this[t(1498)+t(1782)]():this[t(539)]();else{let c="",x=[],g=0,m=0,_=!0,l=e[t(1448)];if(e[t(628)](i[t(835)]("::"),-1)){let S=i[t(1771)]("::");for(let P=0;e[t(1209)](P,S[t(509)]);P++)if(e.lLjfj(e[t(1751)],e[t(1434)])){let R=S[P];if(R[t(835)](":")>0)if(e[t(1951)](e[t(572)],e[t(572)]))_0x5867db=_0x556c8f[t(1752)+"At"](_0x2a8e8d),_0x2a4fba<128?_0x4b1ab0+=1:r[t(448)](_0x55bf72,2048)?_0x1c60cc+=2:r[t(684)](64512&_0x53be7f,55296)&&r[t(461)](64512,_0x517421.charCodeAt(r[t(1349)](_0x2979f6,1)))===56320?(++_0x2300da,_0x1cc05a+=4):_0x44628c+=3;else{let B=R[t(1771)](":");_&&(g=B[t(509)]),m+=B.length;for(let z=0;e[t(787)](z,B[t(509)]);z++)if(e[t(1951)](4,B[z][t(509)])){let ee=l.substring(0,e[t(1633)](4,B[z][t(509)])),Z=ee[t(608)](B[z]);x[t(946)](Z)}else x[t(946)](B[z]);_=!1}else{if(e[t(923)](4,R[t(509)])){let B=l[t(1339)+"g"](0,4-R[t(509)]),z=B[t(608)](R);x[t(946)](z)}else x[t(946)](R);_&&(g+=1),m+=1,_=!1}}else return this._socket[t(1420)];let v="";for(let P=0;e[t(576)](P,e[t(1075)](8,m));P++)v=v.concat(l);for(let P=0;P<x[t(509)];P++)e[t(831)](P,g)&&(c=c[t(608)](v)),c=c.concat(x[P]);return c}if(e[t(1951)](e[t(1232)],e[t(1232)])){let S=_0x560ae8[t(1771)](":");_0x74e37b&&(_0x2c7056=S.length),_0x233f73+=S[t(509)];for(let v=0;r[t(448)](v,S[t(509)]);v++)if(r[t(793)](4,S[v][t(509)])){let P=_0x47dafd[t(1339)+"g"](0,r[t(2001)](4,S[v][t(509)])),R=P[t(608)](S[v]);_0x111678[t(946)](R)}else _0x27d4a[t(946)](S[v]);_0x37354b=!1}else{let S=i[t(1771)](":");for(let v=0;e[t(801)](v,S.length);v++){let P=S[v];if(e[t(1376)](4,S[v][t(509)]))if(e[t(903)](e[t(1088)],e[t(1088)])){this["_destroy"+t(1043)+"t"]();let R=_0x2e82f7(e[t(1383)],{message:e[t(412)]});this[t(1665)+t(1038)+t(1356)+"ct"]&&this["onStopImmediatel"+t(1356)+"ct"](R)}else{let R=l[t(1339)+"g"](0,e[t(1633)](4,S[v][t(509)])),B=R[t(608)](P);c=c[t(608)](B)}else c=c.concat(P)}return c}}}function y(i,t){let r=n,c=i.key;e.GFyHz(void 0,c)&&(e.KsMJu(X,t,10),e[r(786)](pe,t,c));let x=i[r(1651)];e.ZFtDT(void 0,x)&&(e[r(786)](X,t,18),e[r(786)](pe,t,x))}function w(i){let t=n,r={};e:for(;!we(i);){let c=e[t(1365)](Q,i);switch(e.WDoiP(c,3)){case 0:break e;case 1:r[t(1183)]=e[t(771)](te,i,e[t(1421)](Q,i));break;case 2:r[t(1651)]=e[t(1779)](te,i,e[t(1548)](Q,i));break;default:e[t(817)]($,i,e.xRvhp(7,c))}}if(r[t(1183)]===void 0)throw new Error(e[t(1893)]);if(r[t(1651)]===void 0)throw new Error(e[t(1295)]);return r}function A(i){let t=n,r=e[t(789)](W);return e[t(1330)](I,i,r),e[t(1996)](ke,r)}function I(i,t){let r=n,c=i[r(1634)];e[r(1376)](void 0,c)&&(X(t,8),e[r(817)](J,t,c));let x=i.LogID;e[r(1376)](void 0,x)&&(X(t,16),e[r(771)](J,t,x));let g=i.service;e[r(862)](void 0,g)&&(e[r(1779)](X,t,24),e[r(1594)](J,t,H(g)));let m=i[r(1483)];m!==void 0&&(X(t,32),e[r(1715)](J,t,H(m)));let _=i.headers;if(e[r(928)](void 0,_))for(let ee of _){X(t,42);let Z=e[r(594)](W);e.updFo(y,ee,Z),e[r(416)](X,t,Z[r(1252)]),Ke(t,Z),e[r(1282)](ge,Z)}let l=i[r(712)+"ncoding"];e[r(1376)](void 0,l)&&(e[r(1590)](X,t,50),pe(t,l));let S=i[r(1994)+r(875)];e.XfPCr(void 0,S)&&(e[r(1779)](X,t,58),pe(t,S));let v=i[r(426)];e[r(1376)](void 0,v)&&(e[r(1590)](X,t,66),e[r(1330)](X,t,v[r(509)]),ye(t,v));let P=i.LogIDNew;e[r(1108)](void 0,P)&&(X(t,74),e[r(1204)](pe,t,P));let R=i[r(1362)+"ming"];e.iFFFH(void 0,R)&&(e.ozKoA(X,t,82),e[r(1768)](pe,t,R));let B=i[r(1931)];e[r(1108)](void 0,B)&&(e[r(1743)](X,t,90),e[r(1430)](pe,t,B));let z=i[r(1775)+"e"];e[r(903)](void 0,z)&&(e[r(1204)](X,t,96),e[r(1264)](J,t,e[r(1110)](H,z)))}function E(i){return k(e[n(1692)](_e,i))}function k(i){let t=n,r={};e:for(;!e[t(1365)](we,i);){let c=e[t(1689)](Q,i);switch(e[t(1836)](c,3)){case 0:break e;case 1:r[t(1634)]=ut(i,!0);break;case 2:r[t(1014)]=ut(i,!0);break;case 3:r[t(1367)]=e[t(1487)](Q,i);break;case 4:r[t(1483)]=e[t(409)](Q,i);break;case 5:{let x=L(i);(r.headers||(r[t(1495)]=[]))[t(946)](e[t(531)](w,i)),i[t(1252)]=x;break}case 6:r["payloadE"+t(1258)]=e[t(849)](te,i,Q(i));break;case 7:r[t(1994)+"ype"]=e[t(1743)](te,i,e.dFiHg(Q,i));break;case 8:r[t(426)]=e[t(1862)](F,i,e[t(689)](Q,i));break;case 9:r[t(1755)]=e[t(666)](te,i,e[t(1876)](Q,i));break;case 10:r[t(1362)+t(1658)]=e[t(1304)](te,i,e[t(1421)](Q,i));break;case 11:r[t(1931)]=e.bEgbf(te,i,e.HstUi(Q,i));break;case 12:r[t(1775)+"e"]=e.phlFb(Q,i);break;default:$(i,7&c)}}if(e[t(634)](void 0,r[t(1634)]))throw new Error("Missing required field: "+t(1634));if(r[t(1014)]===void 0)throw new Error("Missing required"+t(1299)+t(1014));if(e[t(1939)](void 0,r[t(1367)]))throw new Error(e[t(1592)]);if(e.OpRyU(void 0,r[t(1483)]))throw new Error(e[t(454)]);return r}function L(i){let t=n,r=e[t(1692)](Q,i),c=i.limit;return i[t(1252)]=i[t(682)]+r,c}function $(i,t){let r=n;if(e.JJgQj(e[r(580)],e[r(1401)]))switch(t){case 0:for(;e[r(1461)](128,e.REdcU(ie,i)););break;case 2:e[r(1278)](de,i,e[r(1996)](Q,i));break;case 5:e.JhLtu(de,i,4);break;case 1:e.BfCor(de,i,8);break;default:throw new Error(e[r(413)](e[r(1094)],t))}else return _0x310026[r(1947)]||_0x4cfc6a[r(1859)]?(r(518)+" "+(_0x559b5f[r(1947)]||"")+r(887)+(_0x13a61b[r(1859)]||""))[r(414)]():_0x4d2823[r(1419)+"y"](_0x260283)}function H(i){let t=n;return i|=0,{low:i,high:e[t(1435)](i,31),unsigned:e[t(760)](i,0)}}let ae=[];function W(){let i=n;if(e[i(985)](e.myLzc,e[i(865)])){let t=ae[i(847)]();return t?(t[i(682)]=t[i(1252)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}else _0x586084(_0x3a18bf,this["_getInte"+i(1318)+"e"](_0x6fb0b4))}function ge(i){ae[n(946)](i)}function _e(i){return{bytes:i,offset:0,limit:i[n(509)]}}function ke(i){let t=n,r=i[t(1527)],c=i.limit;return r.length===c?r:r[t(1456)](0,c)}function de(i,t){let r=n;if(e[r(792)](e[r(1513)](i[r(682)],t),i[r(1252)]))throw new Error(e[r(934)]);i[r(682)]+=t}function we(i){let t=n;return e[t(907)](i.offset,i[t(1252)])}function T(i,t){let r=n,c=i[r(1527)],x=i.offset,g=i[r(1252)],m=e[r(1513)](x,t);if(e.TsCkM(m,c[r(509)])){let _=new Uint8Array(2*m);_[r(1593)](c),i.bytes=_}return i[r(682)]=m,e.pULyc(m,g)&&(i[r(1252)]=m),x}function O(i,t){let r=n,c=i[r(682)];if(e[r(988)](e[r(1713)](c,t),i[r(1252)]))throw new Error(e[r(1742)]);return i[r(682)]+=t,c}function F(i,t){let r=n,c=e.CILPx(O,i,t);return i[r(1527)].subarray(c,e[r(413)](c,t))}function ye(i,t){let r=n,c={cPmMw:function(x,g){return e[M(1836)](x,g)},MvAUB:function(x,g){return x<<g}};if(e[r(1363)](e[r(1130)],r(1402))){let x=0,g=_0x43055b,m=_0x472a01+4;for(;g<m;){let{value:_,offset:l}=_0x22440a(_0x4265c1,g);g=l,x=c.cPmMw(c[r(1289)](x,8),0),x+=_}return{value:x,offset:m}}else{let x=e[r(1206)](T,i,t.length);i[r(1527)][r(1593)](t,x)}}function te(i,t){let r=n,c={IGFaw:function(S,v,P){return e[M(598)](S,v,P)},AwidG:function(S,v){return S*v}},x=e[r(1715)](O,i,t),g=String.fromCharCode,m=i.bytes,_="\uFFFD",l="";for(let S=0;e[r(486)](S,t);S++){let v=m[e[r(1713)](S,x)],P,R,B,z;if(e[r(980)](e[r(494)](128,v),0))l+=e[r(689)](g,v);else if(e[r(1875)](224,v)===192)e[r(760)](e[r(975)](S,1),t)?l+=_:(P=m[e.IDyNk(e.yhaFj(S,x),1)],e[r(1017)](192,P)!==128?l+=_:(z=e[r(541)](e[r(1149)](e[r(922)](31,v),6),e[r(494)](63,P)),e[r(801)](z,128)?l+=_:(l+=e[r(1689)](g,z),S++)));else if(e[r(1231)](240&v,224))e[r(456)](S,2)>=t?l+=_:(P=m[e.FRIIK(S+x,1)],R=m[e[r(1513)](e[r(456)](S,x),2)],e.ouLDD(e[r(1332)](P|R<<8,49344),32896)?l+=_:e.cTmMO(e[r(1668)],e[r(1391)])?(_0x57255d(_0x29bae2,90),UVirtu.IGFaw(_0x3c6eb3,_0xe83c39,_0x3381a8)):(z=e[r(446)](e.dejvK(15,v)<<12|e[r(1983)](63&P,6),e[r(1461)](63,R)),z<2048||e[r(907)](z,55296)&&e[r(1691)](z,57343)?l+=_:(l+=e.TcYcb(g,z),S+=2)));else if(e[r(859)](248,v)==240)if(e[r(1620)](S,3)>=t)l+=_;else if(e.pGmhy(e[r(1725)],e[r(1725)]))P=m[e[r(1620)](e[r(1736)](S,x),1)],R=m[e[r(1620)](e[r(1736)](S,x),2)],B=m[e[r(1416)](S,x)+3],e[r(589)](e[r(446)](e.Dglrt(P,e[r(1073)](R,8)),e[r(1766)](B,16)),12632256)!==8421504?l+=_:(z=e.Dglrt(e[r(1553)](e.LwVHw(e[r(884)](7,v),18),e[r(1983)](e[r(1187)](63,P),12)),(63&R)<<6)|e[r(494)](63,B),z<65536||e[r(843)](z,1114111)?l+=_:(z-=65536,l+=e[r(1206)](g,e[r(563)](e[r(1435)](z,10),55296),e[r(1736)](e[r(1235)](1023,z),56320)),S+=3));else{let ee=new _0x1a2b15(UVirtu[r(1129)](2,_0x3df71a));ee[r(1593)](_0x117a82),_0x2264d0[r(1527)]=ee}else l+=_}return l}function pe(i,t){let r=n;if(e.VLeWI(e.FkYTn,e[r(1976)])){let c=t[r(509)],x=0;for(let _=0;e[r(1801)](_,c);_++){let l=t.charCodeAt(_);e[r(907)](l,55296)&&e[r(1533)](l,56319)&&e[r(1866)](e[r(456)](_,1),c)&&(l=e.FgSRc(e.WNtui(l,10),t[r(1752)+"At"](++_))-56613888),x+=e[r(1209)](l,128)?1:e[r(787)](l,2048)?2:e[r(801)](l,65536)?3:4}X(i,x);let g=e[r(1594)](T,i,x),m=i[r(1527)];for(let _=0;e[r(1866)](_,c);_++){let l=t[r(1752)+"At"](_);e[r(760)](l,55296)&&e[r(1691)](l,56319)&&e[r(1457)](_+1,c)&&(l=e.cOsph(e[r(1713)](e[r(761)](l,10),t[r(1752)+"At"](++_)),56613888)),e.kOoEA(l,128)?m[g++]=l:(e[r(1224)](l,2048)?m[g++]=e[r(1238)](e[r(1387)](l,6),31)|192:(l<65536?m[g++]=e[r(541)](e[r(1638)](l,12)&15,224):(m[g++]=e.PvUIF(e[r(1281)](l>>18,7),240),m[g++]=e[r(1332)](l>>12,63)|128),m[g++]=e.ATyGM(e.tRqjG(l,6)&63,128)),m[g++]=e.Dglrt(e[r(606)](63,l),128))}}else _0x4e3c9e.body[r(1002)+r(1519)](_0x18fd9b)}function Ke(i,t){let r=n,c=e[r(666)](T,i,t[r(1252)]),x=i[r(1527)],g=t.bytes;for(let m=0,_=t[r(1252)];e[r(936)](m,_);m++)x[e[r(1620)](m,c)]=g[m]}function ie(i){return i[n(1527)][O(i,1)]}function Qe(i,t){let r=T(i,1);i.bytes[r]=t}function Q(i){let t=n,r={ElPEQ:function(c,x){return e[M(760)](c,x)},UcLQn:function(c,x){return e[M(661)](c,x)}};if(e.dQIXh===e[t(1322)]){let c=0,x=0,g;do if(e[t(1376)](e[t(1932)],e[t(1932)])){if(_0x219b10<=-_0x21ca34)return _0x172e31;if(r[t(1624)](r[t(860)](_0x13ac79,1),_0x31df11))return _0x73b038}else g=e[t(1876)](ie,i),e[t(1801)](c,32)&&(x|=e[t(1246)](e[t(605)](127,g),c)),c+=7;while(e.aydTd(128,g));return x}else _0x226e6e<2048?_0x3af9c8[_0x3b69a6++]=e[t(1172)](e[t(606)](_0x152012>>6,31),192):(e[t(1848)](_0x22de5e,65536)?_0x40f65a[_0x440a3c++]=e.AfTEq(e[t(922)](e.NzpwO(_0x2b3efe,12),15),224):(_0x4a83fc[_0x42d806++]=e.jnIcs(e[t(1187)](e[t(1922)](_0xbc7599,18),7),240),_0x4e3e7e[_0x22952a++]=e.VakBz(e[t(1387)](_0xa46582,12)&63,128)),_0x345f67[_0x236aa0++]=e[t(708)](e.dYUKW(_0x200ba9,6),63)|128),_0x295d99[_0x3b5825++]=e[t(446)](63&_0xa069ea,128)}function X(i,t){let r=n,c={PbHTs:function(x,g,m){return e[M(774)](x,g,m)},jczMr:function(x,g){return x+g},mwpXS:function(x,g){return e[M(917)](x,g)},NdWxx:function(x,g){return e[M(821)](x,g)},oUoNX:function(x,g){return x&g}};for(t>>>=0;t>=128;)e[r(634)](e[r(1392)],e.PZwTq)?(e[r(1856)](Qe,i,e[r(446)](e[r(1826)](127,t),128)),t>>>=7):(_0xde23c0-=65536,_0x4ce232+=EZwYnf.PbHTs(_0x4d18a4,EZwYnf[r(1158)](EZwYnf[r(619)](_0x348d7a,10),55296),EZwYnf.NdWxx(EZwYnf[r(1788)](1023,_0x47a189),56320)),_0x503812+=3);e[r(1296)](Qe,i,t)}function ut(i,t){let r=n;if(e[r(493)]===r(1510))return this._isMiniTT||this[r(1979)+"X"]?this["_miniNav"+r(851)+r(1678)]:(this[r(614)+"er"]||this._isWorker)&&this[r(918)][r(610)+r(768)+r(1504)]?_0x5627b6.onLine:!0;{let c=0,x=0,g=0,m;return m=ie(i),c=e.twlFK(127,m),e[r(957)](128,m)&&(m=ie(i),c|=e[r(1544)](e.SlHtm(127,m),7),e[r(1281)](128,m)&&(m=e[r(1853)](ie,i),c|=e[r(1085)](127&m,14),e[r(957)](128,m)&&(m=e[r(645)](ie,i),c|=e[r(1073)](e.nzqgs(127,m),21),e[r(1855)](128,m)&&(m=e[r(1433)](ie,i),x=127&m,e.WWQNC(128,m)&&(m=e[r(1996)](ie,i),x|=e.nQDZw(e[r(691)](127,m),7),e[r(708)](128,m)&&(m=e.SrDMT(ie,i),x|=e[r(1246)](127&m,14),e[r(1749)](128,m)&&(m=e[r(1226)](ie,i),x|=e[r(1085)](e[r(1505)](127,m),21),128&m&&(m=e[r(623)](ie,i),g=127&m,e[r(1281)](128,m)&&(m=e[r(520)](ie,i),g|=e[r(1944)](e.nzqgs(127,m),7)))))))))),{low:c|e.SGJYF(x,28),high:e[r(1716)](e.rgAPE(x,4),g<<24),unsigned:t}}}function J(i,t){let r=n,c=t[r(1700)]>>>0,x=e[r(901)](e.wKemu(e[r(1836)](t[r(1700)],28),e[r(1149)](t[r(1244)],4)),0),g=e.WDoiP(t[r(1244)],24),m=g===0?e[r(1363)](0,x)?e[r(595)](c,16384)?e.mBRqX(c,128)?1:2:e.XKXOY(c,2097152)?3:4:e[r(1866)](x,16384)?e[r(1866)](x,128)?5:6:e[r(929)](x,2097152)?7:8:e[r(576)](g,128)?9:10,_=T(i,m),l=i.bytes;switch(m){case 10:l[e.jLusN(_,9)]=e[r(1826)](e[r(1717)](g,7),1);case 9:l[e.FgSRc(_,8)]=m!==9?e[r(1684)](128,g):127&g;case 8:l[_+7]=m!==8?e[r(1836)](x,21)|128:e[r(889)](x>>>21,127);case 7:l[e[r(1925)](_,6)]=e.XfPCr(7,m)?e.CvzJR(e[r(1071)](x,14),128):e.twlFK(x>>>14,127);case 6:l[e[r(1347)](_,5)]=e.JJgQj(6,m)?e.jnIcs(e[r(818)](x,7),128):e.USLTu(e[r(818)](x,7),127);case 5:l[e[r(1124)](_,4)]=e[r(960)](5,m)?e.MGaIH(128,x):e.TkRDF(127,x);case 4:l[e.lbiZj(_,3)]=e.taufy(4,m)?e[r(706)](e[r(1071)](c,21),128):e.aZOhP(e.rgAPE(c,21),127);case 3:l[e[r(975)](_,2)]=e[r(618)](3,m)?e[r(1004)](e[r(1168)](c,14),128):e.kVUGu(e.ayjzc(c,14),127);case 2:l[e.mPfEg(_,1)]=e[r(492)](2,m)?e[r(1797)](c,7)|128:e[r(663)](e.ZPNyb(c,7),127);case 1:l[_]=e[r(923)](1,m)?e[r(1663)](128,c):e.qMXNZ(127,c)}}function _t(i){return e.CBHzE(E,i)}function se(i){let t=n;if(e[t(928)](e.aUupD,e.aUupD))for(var r in _0x53b864)_0x568322.o(_0x4194af,r)&&!_0x5da823.o(_0x34e6de,r)&&_0x4fb2cd["definePr"+t(1891)](_0x18d2c0,r,{enumerable:!0,get:_0xd8d1c3[r]});else return e[t(1996)](A,i)}let yt=65536,be=n(1188),bt=e[n(1316)](yt,yt),Xi=e[n(650)](bt,bt),Yi=e[n(1169)](Xi,2),et=String.prototype[n(1752)+"At"];class K{constructor(t,r,c){let x=n;this[x(1837)]=!0,this[x(1700)]=e[x(446)](0,t),this[x(1244)]=0|r,this[x(1975)]=!!c}static[n(1837)](t){let r=n;if(e[r(923)](r(603),e[r(1905)]))_0x39d1e8[r(439)+r(1946)]="",_0x27ab7f.log(_0x3cdead);else return t&&t[r(1837)]===!0}static[n(1649)](t,r,c){return new K(t,r,c)}static[n(1838)+"s"](t,r,c){let x=n;return c?K["fromByte"+x(1035)](t,r):K[x(1838)+x(888)](t,r)}static[n(1838)+"sLE"](t,r){let c=n;return new K(e[c(1716)](e[c(662)](t[0]|e[c(1077)](t[1],8),e[c(1410)](t[2],16)),e.lsFqF(t[3],24)),e.AfTEq(t[4],e[c(1246)](t[5],8))|e[c(1007)](t[6],16)|e[c(1983)](t[7],24),r)}static["fromByte"+n(888)](t,r){let c=n;return new K(e[c(1716)](e[c(1716)](t[4]<<24|e[c(1766)](t[5],16),t[6]<<8),t[7]),e[c(662)](e.wKemu(e[c(1544)](t[0],24)|t[1]<<16,e.lnWvb(t[2],8)),t[3]),r)}static fromHash(t){let r=n;return e[r(980)](t,be)?Zi:new K(e.WDoiP(e[r(1029)](e.VakBz(et.call(t,0),e[r(955)](et[r(1352)](t,1),8))|e.skGVH(et[r(1352)](t,2),16),et.call(t,3)<<24),0),e[r(1245)](e[r(706)](e[r(931)](et[r(1352)](t,4),e[r(1e3)](et.call(t,5),8)),e[r(1152)](et[r(1352)](t,6),16))|e[r(1766)](et.call(t,7),24),0),!0)}[n(612)](){let t=n;if(e.TkcwX(e[t(1847)],e[t(927)])){let r={onjII:function(c,x){return c(x)}};return function(...c){let x=t;return _0x5859ad[x(1714)](r[x(1811)](_0x486856,this),c),r[x(1811)](_0x1107ee,_0x36e0d7.get(this))}}else return String[t(1710)+t(1382)](e[t(1769)](255,this[t(1700)]),e[t(1233)](e.OTbOc(this[t(1700)],8),255),e[t(1698)](e[t(1552)](this[t(1700)],16),255),e[t(1270)](this.low,24),e[t(460)](255,this[t(1244)]),e[t(1749)](e[t(901)](this[t(1244)],8),255),this[t(1244)]>>>16&255,e[t(1099)](this[t(1244)],24))}static[n(1198)+"er"](t,r=!0){let c=n;if(e[c(752)](isNaN,t))return r?Yc:Zi;if(r){if(e.WGXPN(t,Xi))return Qc}else{if(e[c(1567)]!==e.GcHCX)return this[c(458)][c(1049)+"pe"];if(e[c(1533)](t,-Yi))return e0;if(e[c(637)](e[c(546)](t,1),Yi))return Zc}return K[c(1649)](e[c(1553)](e[c(1138)](t,bt),0),e[c(1949)](t/bt,0),r)}[n(578)](){let t=n;return this.unsigned?e[t(1312)](this[t(1244)]>>>0,bt)+e[t(627)](this[t(1700)],0):this[t(1244)]*bt+e[t(1114)](this[t(1700)],0)}isZero(){let t=n,r={XXtui:function(c,x,g){return c(x,g)}};if(e[t(1397)]===t(1572)){let c=pOPjzK[t(1669)](_0x3834e1,_0x4079e2,_0x417a58[t(509)]);_0x398f0e.bytes[t(1593)](_0x4bad2b,c)}else return e.ySuAY(0,this[t(1244)])&&e[t(1324)](0,this[t(1700)])}[n(1696)](t){let r=n,c={bYqbZ:function(x,g){return x==g},lFxpz:e[r(1106)]};if(e[r(675)](e[r(1585)],r(632)))return c.bYqbZ(c[r(1493)],typeof _0x4e451c)?r(1627)+r(820)+"et=utf-8":"";{K[r(1837)](t)||(t=K[r(1198)+"er"](t));let x=this[r(1244)]>>>16,g=e[r(1087)](65535,this.high),m=this.low>>>16,_=e[r(535)](65535,this.low),l=e[r(627)](t[r(1244)],16),S=65535&t[r(1244)],v=e[r(442)](t[r(1700)],16),P=e[r(1826)](65535,t[r(1700)]),R=0,B=0,z=0,ee=0;return ee+=e[r(1236)](_,P),z+=ee>>>16,ee&=65535,z+=e[r(874)](m,v),B+=e.hmvLw(z,16),z&=65535,B+=e[r(456)](g,S),R+=e.BCjdc(B,16),B&=65535,R+=x+l,R&=65535,K[r(1649)](e[r(706)](e[r(503)](z,16),ee),R<<16|B,this.unsigned)}}[n(451)](t){let r=n;if(e[r(1076)](e.wZodU,e[r(1263)])){let c=this[r(1008)+"tManager"]?.[r(1329)+r(997)+"nt"]();this[r(1942)+r(804)+r(590)](e[r(1278)](_0x5f323b,e[r(915)],{code:_0x271ee7[r(767)],reason:r(1854)+r(510)+"d, unknown reaso"+r(1712)+r(561)+c})),this[r(1008)+r(1426)]?.[r(1971)+r(1618)+r(893)](),this[r(1142)+r(1539)]?.[r(473)+r(453)]();return}else return K.isLong(t)||(t=K[r(1198)+"er"](t)),e[r(476)](this[r(1975)],t.unsigned)&&e[r(1924)](e.zRZhk(this[r(1244)],31),1)&&e[r(1406)](t.high>>>31,1)?!1:e[r(519)](this[r(1244)],t.high)&&this.low===t[r(1700)]}[n(658)](){let t=n;return e[t(1939)](-1,this[t(1700)])&&this[t(1244)]===-1?K[t(1649)](0,0,this.unsigned):e[t(1126)](-1,this[t(1700)])?K[t(1649)](0,this[t(1244)]+1,this[t(1975)]):K[t(1649)](e[t(1744)](this[t(1700)],1),this[t(1244)],this[t(1975)])}[n(1936)](t){let r=n,c={YGqaY:function(g,m,_,l){return e[M(1789)](g,m,_,l)}};if(e[r(850)]!==e.XAsyP)for(var x in _0x5b0d5f)XPKIRJ[r(1820)](_0x300274,_0x5d83fb,x,{get:_0x10eeba[x],enumerable:!0});else return t?this[r(1161)+"E"]():this[r(1542)+"E"]()}toBytesLE(){let t=n,r=this[t(1244)],c=this[t(1700)];return[e[t(733)](255,c),e.IDFVP(c>>>8,255),e.BCjdc(c,16)&255,e[t(1027)](c,24),e[t(1368)](255,r),e[t(1717)](r,8)&255,e[t(1054)](e[t(627)](r,16),255),e[t(1099)](r,24)]}[n(1542)+"E"](){let t=n;if(e[t(1473)](e[t(1143)],e[t(1143)])){let r=this[t(1244)],c=this.low;return[r>>>24,e.zRZhk(r,16)&255,e[t(1878)](e[t(1442)](r,8),255),e[t(889)](255,r),e[t(1114)](c,24),e[t(1992)](c,16)&255,e.Qvrvp(e[t(880)](c,8),255),255&c]}else this[t(614)+"er"]&&_0x22cda1[t(1210)+t(607)+t(622)](e.vVSLh,this[t(1952)+t(1343)]),this._isBrowser&&_0xe415a7[t(1210)+"entListe"+t(622)](e.phcDk,this._handlePageShow),this.close()}}let Zi=new K(0,0,!1),Yc=new K(0,0,!0),Zc=K.fromBits(-1,2147483647,!1),Qc=K.fromBits(-1,-1,!0),e0=K[n(1649)](0,-2147483648,!1);var nt=(function(i){let t=n,r=(t(1887)+t(547))[t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":i[i[e[t(1122)]]=5004]=e[t(1122)];continue;case"1":return i;case"2":i[i[t(1417)+"OR"]=5005]=t(1417)+"OR";continue;case"3":i[i[e[t(1409)]]=5002]=e[t(1409)];continue;case"4":i[i[e[t(1325)]]=5003]=e[t(1325)];continue;case"5":i[i[e[t(830)]]=5001]=e.npOLv;continue}break}})({});class vt{constructor(t){let r=n;this.type=t,this[r(775)]=null}}class Qi extends vt{constructor(t,r){let c=n;super(t),this[c(866)]=r&&r[c(866)]||null}}class es extends vt{constructor(t,r){let c=n;if(e[c(1864)](c(512),e[c(763)]))super(t),this[c(654)]=r&&r[c(654)]||null,this[c(1739)]=r&&r[c(1739)]||0,this.filename=r&&r[c(1205)]||"",this[c(1039)]=r&&r[c(1039)]||0,this[c(866)]=r&&r[c(866)]||"",this[c(767)]=r&&r[c(767)]||5001;else return this[c(1975)]?e.XOdBn(e[c(1312)](e[c(1797)](this.high,0),_0x2a95d4),e.Ujdht(this[c(1700)],0)):this[c(1244)]*_0x44185d+(this[c(1700)]>>>0)}}class ts extends vt{constructor(t,r){let c=n,x=e.jHLbU.split("|"),g=0;for(;;){switch(x[g++]){case"0":super(t);continue;case"1":this[c(450)+c(970)]=r&&r["willReco"+c(970)]||!1;continue;case"2":this[c(767)]=r&&r[c(767)]||0;continue;case"3":this[c(1171)]=r&&r[c(1171)]||"";continue;case"4":this[c(1034)]=r&&r[c(1034)]||!1;continue}break}}}class ns extends vt{constructor(t,r){let c=n;if(e.ySuAY("WjUnz",e[c(1981)]))super(t),this[c(1909)]=r&&r[c(1909)]||null;else{let x=_0x61b9d8[c(1339)+"g"](0,e[c(680)](4,_0x4a07ce[_0x5eb881][c(509)])),g=x[c(608)](_0x47428a);_0x1d436e=_0x4a8d21[c(608)](g)}}}class rs extends ns{constructor(t,r){let c=n;if(e[c(1458)]!==c(1120))return{bytes:_0x38b243,offset:0,limit:_0x19dec4.length};super(t),this[c(1909)]=r&&r[c(1909)]||null,this[c(866)]=r&&r.message||null}}class is extends vt{constructor(t,r){let c=n;super(t),this.data=r&&r[c(1909)]||null}}function Ie(i,{message:t,code:r,error:c}){return new es(i,{message:t,code:r,error:c})}function De(i,{code:t,reason:r,wasClean:c,willReconnect:x}){let g=n;return e[g(508)](e[g(1954)],e[g(1954)])?new ts(i,{code:t,reason:r,wasClean:c,willReconnect:x}):this[g(458)].extensions}function ss(i,{data:t,message:r}){return new rs(i,{data:t,message:r})}function os(i,{data:t}){return new is(i,{data:t})}function Lr(i,{message:t}){return new Qi(i,{message:t})}class as{constructor(t,r){let c=n;this.endpoints=t,this[c(938)+"es"]=r,this[c(982)+c(717)]=0,this[c(871)+c(758)+c(1511)+"t"]=0}[n(1971)+n(1618)+n(893)](){let t=n;this[t(982)+t(717)]=0,this[t(871)+t(758)+t(1511)+"t"]=0}[n(1026)+"es"](){let t=n;e[t(913)](e[t(990)],e[t(990)])?this[t(871)+t(758)+t(1511)+"t"]=0:(e[t(666)](_0x3a2e38,_0x566bf4,18),e.ASVEW(_0x56c960,_0x10aaa1,_0x4db5c5))}[n(1329)+"ntEndpoint"](){let t=n;return this[t(1851)+"s"][this[t(982)+t(717)]]}["getCurre"+n(997)+n(1403)+n(764)](){let t=n;return this[t(871)+"ndpointT"+t(1511)+"t"]}[n(665)+n(1606)+"es"](){let t=n;return!!(e[t(760)](this[t(982)+t(717)],this[t(1851)+"s"][t(509)])||this[t(982)+t(717)]===e[t(1075)](this.endpoints[t(509)],1)&&e[t(831)](this["currentE"+t(758)+"riesCount"],this[t(938)+"es"]))}[n(1882)+"rentEndp"+n(799)+n(415)+n(1562)](){let t=n;return e.NKUyg(this[t(982)+t(717)],this[t(1851)+"s"][t(509)])?!0:e[t(1234)](this["currentEndpointT"+t(1511)+"t"],this[t(938)+"es"])}[n(624)+n(1986)+n(1466)+n(969)+n(1048)](){let t=n;return this[t(871)+"ndpointT"+t(1511)+"t"]=1,this["currentI"+t(717)]++,this[t(1851)+"s"][this[t(982)+t(717)]]}[n(1329)+n(997)+n(1113)+n(1655)](){let t=n;return this[t(871)+"ndpointT"+t(1511)+"t"]++,this.getCurrentEndpoint()}}let St=(e[n(1203)]!=typeof globalThis&&e.lneoT===globalThis[n(1517)+"tor"].name||e[n(1821)](e[n(1203)],typeof window)&&e[n(549)]===window[n(1517)+"tor"][n(978)])&&e.haNxc(e[n(1203)],typeof document),ft=n(1881)+"d"!=typeof globalThis&&(e[n(1967)](e[n(1167)],globalThis[n(1517)+"tor"][n(978)])||e[n(870)](e[n(573)],globalThis[n(1517)+"tor"][n(978)]))&&e[n(839)](e[n(1203)],typeof tt),$t=(e.aKVxu(n(1881)+"d",typeof globalThis)&&e[n(968)](n(1222),globalThis.constructor[n(978)])||e[n(1203)]==typeof globalThis||e[n(1821)](e[n(1203)],typeof globalThis)&&!!globalThis[n(1783)+n(704)])&&e[n(1090)](e[n(1203)],typeof wx),Jt=n(1881)+"d"!=typeof globalThis&&(e.iVFzT===globalThis[n(1517)+n(1404)].name||e[n(952)](e[n(1852)],globalThis[n(1517)+n(1404)].name)||e[n(1911)](e.UCkan,globalThis["construc"+n(1404)].name))&&e[n(1857)](e.XnJMd,typeof self),t0=e[n(522)](e[n(1203)],typeof globalThis)&&e.tJYsc(e[n(1167)],globalThis[n(1517)+"tor"][n(978)])&&e.LCssE(n(1881)+"d",typeof global)&&e.xeTDk(e[n(1167)],global[n(1517)+"tor"][n(978)])&&e.haNxc("undefined",typeof process)&&!!process[n(1079)];class Mr{constructor(){let t=n;this[t(1731)+"rs"]={}}[n(1033)](t,...r){let c=n,x=this._listeners[t];if(x)x.slice()[c(1644)](g=>g.fn[c(1714)](g[c(1550)],r));else if(e[c(831)](e[c(1617)],t)&&!this[c(1760)]){let g=r[c(509)]&&r[0];if(e.ueqII(g,Error))throw g;let m=new Error(e[c(1160)](c(1697)+c(490),g?e[c(1459)](e[c(896)](" (",g[c(866)]),")"):""));throw m[c(1314)]=g,g}return this}off(t,r){let c=n;if(e[c(500)](void 0,t))this[c(1731)+"rs"]={};else if(e.QvnFD(void 0,r))this[c(1731)+"rs"][t]=null;else if(c(1202)===e[c(1306)]){let x=e[c(1200)](255,_0x22099b);_0x25e0dd(x,_0x3228d0,_0x4f84e0+_0x4e3c6c),_0x29da5b>>>=8,_0x104e98--}else{let x=this._listeners[t];if(x)for(let g=0;e[c(595)](g,x[c(509)]);)x[g].fn===r?x[c(559)](g,1):++g}return this}on(t,r,c){let x=n;return(this._listeners[t]||(this[x(1731)+"rs"][t]=[]))[x(946)]({fn:r,ctx:c||this}),this}}class n0 extends Mr{[n(1164)+n(1919)+n(1541)](t){let r=n;return t[r(1947)]||t[r(1859)]?(r(518)+" "+(t.errMsg||"")+r(887)+(t.errNo||"")).trim():JSON.stringify(t)}constructor(t,r,c){let x=n;super(),this[x(458)]=null,$t&&wx.connectSocket&&(this[x(458)]=wx[x(422)+x(1062)]({url:t,protocols:r,header:c,fail:this["_createSocketFai"+x(1373)][x(935)](this),success:this[x(1145)+x(1758)+"cessHand"+x(469)].bind(this)})),ft&&tt["connectS"+x(1062)]&&(this[x(458)]=tt[x(422)+x(1062)]({url:t,protocols:r,header:c,fail:this["_createSocketFai"+x(1373)][x(935)](this),success:this["_createSocketSuc"+x(1781)+"ler"][x(935)](this)}))}[n(1145)+n(1758)+"cessHand"+n(469)](){let t=n;Promise[t(1431)]()[t(498)](()=>{let r=t,c={iGgwB:function(x,g){return e.WGXPN(x,g)},jezAz:function(x,g){return e[M(846)](x,g)},RXtrH:function(x,g){return e[M(1945)](x,g)},sbbkn:function(x,g){return e.yhaFj(x,g)},weRvn:function(x,g){return e[M(1575)](x,g)},xukSA:function(x,g){return e[M(1846)](x,g)},xcyRl:function(x,g){return x<g},HPWxf:function(x,g){return e.dIIqg(x,g)},joybC:function(x,g){return x&g},pUxLg:function(x,g){return e.NzpwO(x,g)},snenG:function(x,g){return x|g},eOrqb:function(x,g){return e[M(678)](x,g)},ccfry:function(x,g){return e[M(1387)](x,g)},mDmiH:function(x,g){return e.idFGr(x,g)},IdMlz:function(x,g){return e[M(1748)](x,g)},cXDsC:function(x,g){return e[M(1292)](x,g)}};if(e[r(1671)]!=="qYkxC"){let x=_0x14bf4c[r(1752)+"At"](_0xf335bf);wgwdPj[r(885)](x,55296)&&wgwdPj[r(703)](x,56319)&&wgwdPj[r(1642)](wgwdPj[r(652)](_0x34fd17,1),_0x19153e)&&(x=wgwdPj[r(652)](wgwdPj[r(1674)](x,10),_0x4dcd4c[r(1752)+"At"](++_0x23d7ef))-56613888),wgwdPj.xukSA(x,128)?_0x5ed61f[_0xf4e476++]=x:(wgwdPj[r(1613)](x,2048)?_0x124094[_0x1ec834++]=wgwdPj[r(751)](x>>6,31)|192:(wgwdPj[r(1642)](x,65536)?_0x1d38d1[_0x74a0df++]=wgwdPj[r(1309)](wgwdPj.pUxLg(x,12),15)|224:(_0x2b6a7d[_0x4f2d7d++]=wgwdPj[r(1850)](wgwdPj[r(1711)](wgwdPj[r(1102)](x,18),7),240),_0x15f81a[_0xa832e9++]=wgwdPj[r(636)](wgwdPj[r(1309)](x>>12,63),128)),_0x372bac[_0x5d5acf++]=wgwdPj[r(1247)](wgwdPj[r(1439)](wgwdPj.pUxLg(x,6),63),128)),_0x55eb4d[_0x4e2309++]=wgwdPj[r(636)](wgwdPj[r(1309)](63,x),128))}else this._addWsListeners()})}[n(1145)+n(1683)+n(1373)](t){let r=n,c={Hznzg:function(x,g,m){return e.cRcHd(x,g,m)},EsCfs:e[r(1617)],hafxD:e.rVsIU};e.KyWyT(e[r(1031)],e[r(1031)])?_0x1914a6[r(1431)]().then(()=>{let x=r,g=c[x(1095)](_0x59d6c6,c[x(872)],{message:this[x(1164)+"rrorMess"+x(1541)](_0x436a4e)});this[x(1033)](c[x(872)],g);let m=c[x(1095)](_0x35bf54,c.hafxD,{reason:this[x(1164)+x(1919)+x(1541)](_0x33ab27)});this.emit(c[x(641)],m)}):Promise.resolve()[r(498)](()=>{let x=r,g=e[x(1953)](Ie,e[x(1617)],{message:this[x(1164)+x(1919)+"age"](t)});this[x(1033)](x(654),g);let m=De("close",{reason:this["_formatErrorMess"+x(1541)](t)});this[x(1033)](e[x(915)],m)})}[n(556)+n(472)](){let t=n,r={jSeJg:t(538),wKKXe:function(c,x,g){return c(x,g)},KmCqZ:e[t(1424)],cCQkt:function(c,x,g){return e.vrTKT(c,x,g)}};this[t(458)].onOpen(c=>{let x=t;this[x(1033)](x(699),e[x(1304)](os,e.zXGMW,{...c,data:c[x(1947)]||""}))}),this[t(458)][t(1800)](c=>{let x=t;this[x(1033)](r[x(1913)],r[x(943)](De,r[x(1913)],{...c}))}),this._socket[t(707)+"e"](c=>{let x=t;this.emit(r[x(1065)],r[x(1460)](ss,r[x(1065)],{...c}))}),this[t(458)][t(1481)](c=>{let x=t;this.emit(x(654),e[x(1264)](Ie,e.fKVAW,{...c,message:c[x(1947)]||""}))})}send(t){let r=n,c={bEYbW:function(x,g,m){return e[M(1444)](x,g,m)},ZSIYN:e[r(1617)],ETsLc:function(x,g,m){return e.JPZUh(x,g,m)}};if(e.RbmDC(t,Uint8Array))if(e[r(1904)](r(1987),e[r(919)])){let x=t.buffer[r(806)](t[r(803)+"et"],e.FRIIK(t[r(823)+"th"],t[r(803)+"et"]));this[r(458)]&&this[r(458)].send({data:x,fail:g=>{let m=r;this[m(1033)](m(654),c.bEYbW(Ie,c.ZSIYN,{message:this["_formatE"+m(1919)+"age"](g)}))}})}else return _0x1b20ac[r(1714)](QTvxnE[r(1622)](_0xc75dc7,this),_0x52ce5f),_0x1c7fe6(_0x21327f[r(791)](this));else this[r(458)]&&this._socket[r(569)]({data:t,fail:x=>{let g=r;this[g(1033)](g(654),c[g(585)](Ie,c[g(1943)],{message:this["_formatE"+g(1919)+g(1541)](x)}))}})}[n(538)](t,r){let c=n;this._socket&&this[c(458)].close({code:t,reason:r})}[n(1614)+"Listener"](t,r){this.on(t,r)}[n(1210)+"entListe"+n(622)](t,r){this[n(1895)](t,r)}get[n(788)+"te"](){return this[n(458)].readyState}get[n(1049)+"pe"](){let t=n;return this[t(458)][t(1049)+"pe"]}set[n(1049)+"pe"](t){}get[n(1420)](){let t=n;return this[t(458)][t(1420)]}get[n(715)](){return this._socket.protocol}get[n(1089)+"ns"](){let t=n;return e[t(634)](e.hDkJk,e[t(1396)])?e[t(520)](_0x4db28b,_0x5ae5f6):this[t(458)][t(1089)+"ns"]}get[n(1516)+n(1083)](){return 0}}function r0(i,t){let r=n;if(t)return new t(i[r(1420)],i[r(715)]);if($t||ft)return new n0(i[r(1420)],i[r(715)],i[r(1495)]);if((St||Jt)&&e[r(1857)](e[r(1203)],typeof WebSocket)&&WebSocket)return new WebSocket(i[r(1420)],i[r(715)+"s"])}function i0(i){let t=n,r=e[t(1468)][t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":if(i)return!0;continue;case"1":if(e[t(1898)](St,Jt)&&e[t(839)](e[t(1203)],typeof WebSocket)&&WebSocket)return!0;continue;case"2":return!1;case"3":if($t&&wx["connectS"+t(1062)])return!0;continue;case"4":if(ft&&tt[t(422)+t(1062)])return!0;continue}break}}function cs(i,t,r){let c=n,x={RvSNt:function(g,m){return g===m},ltBEb:function(g,m){return g+m}};if(e.cDbHt(e[c(905)],e.XPEDz))this["_navigat"+c(1966)]()&&(!this._ws||e[c(1762)](this[c(1093)][c(788)+"te"],this[c(1248)])||e[c(476)](this[c(1093)].readyState,this[c(1874)+"NG"]))&&this[c(848)+c(1561)](),this[c(614)+"er"]&&_0x40d954[c(1614)+"Listener"]("online",this[c(848)+c(1561)]),this[c(614)+"er"]&&_0x59cbd4[c(1614)+c(1955)]("offline",this["_handleO"+c(464)]);else{let g=-1;async function m(_){let l=c;return _<=g?Promise[l(958)](new Error(l(1523)+l(755)+l(956)+l(1394)+l(1370))):(g=_,x[l(1465)](_,r.length)?Promise.resolve():r[_][l(935)](i)(t,m[l(935)](null,x.ltBEb(_,1))))}e[c(713)](m,0)}}function xs(i){let t=n,r=0,c=0;for(let x=0;e[t(911)](x,i[t(509)]);++x)c=i[t(1752)+"At"](x),e.STlOM(c,128)?r+=1:c<2048?r+=2:e[t(635)](e[t(922)](64512,c),55296)&&e[t(640)](e[t(945)](64512,i.charCodeAt(x+1)),56320)?(++x,r+=4):r+=3;return r}function ds(i,t,r){let c=n;if(e[c(1633)](r,t)<1)return"";let x="";for(let g=t;e[c(787)](g,r);){let m=i[g++];if(e[c(1359)](m,127))x+=String[c(1710)+"Code"](m);else if(e[c(907)](m,192)&&e.LHEBj(m,224))x+=String[c(1710)+c(1382)](e[c(506)](e.skGVH(e[c(1054)](31,m),6),e[c(488)](63,i[g++])));else if(m>=224&&e[c(897)](m,240))x+=String[c(1710)+c(1382)](e[c(1730)]((15&m)<<12,e[c(1582)](63&i[g++],6))|e[c(1537)](63,i[g++]));else if(e[c(504)](m,240))if(e.mCpFC(e[c(864)],e[c(1667)])){let _=e[c(800)](_0x308077,e[c(1383)],{message:"start"});this["onStartR"+c(1782)]&&this.onStartReconnect(_)}else{let _=e[c(1633)](e.kaluE(e[c(1703)](e[c(1766)](7&m,18),e[c(1983)](e[c(884)](63,i[g++]),12)),e[c(1826)](63,i[g++])<<6)|e[c(639)](63,i[g++]),65536);x+=String[c(1710)+"Code"](e.UNNZO(55296,e.tRqjG(_,10))),x+=String[c(1710)+"Code"](e[c(1513)](56320,1023&_))}}return x}function Br(i,t,r){let c=n;if(e.RdZBx(c(721),e[c(1086)]))return _0x1ec6a8||(_0x1dd0fb=[_0x5de029[c(575)+"e"][c(1740)],_0x272e78.prototype[c(740)],_0xa54ab0[c(575)+"e"][c(740)+c(798)+"ey"]]);{let x=r,g,m;for(let _=0;e[c(926)](_,i[c(509)]);++_){if(e[c(869)](e[c(1214)],c(1819)))return _0x3d844a[c(660)+c(1267)][1]?void 0:_0x18d76c[c(660)+c(1520)](_0x26aa20.objectStoreNames[0]);if(g=i[c(1752)+"At"](_),e[c(1607)](g,128))t[r++]=g;else if(g<2048)t[r++]=e[c(471)](e[c(930)](g,6),192),t[r++]=e.cnWOk(63&g,128);else if(e.DgTJr(64512&g,55296)&&e[c(1769)](64512,m=i[c(1752)+"At"](e[c(661)](_,1)))===56320){if(e[c(1250)](e.ktcYl,e[c(1551)]))return _0x6194b2?this[c(1161)+"E"]():this[c(1542)+"E"]();{let l=(c(1462)+c(1428)).split("|"),S=0;for(;;){switch(l[S++]){case"0":t[r++]=e.oread(e[c(884)](e.dpPnA(g,12),63),128);continue;case"1":t[r++]=e.XzBXC(e[c(1901)](g,18),240);continue;case"2":++_;continue;case"3":t[r++]=e.XzBXC(63&g,128);continue;case"4":t[r++]=e[c(1823)](e[c(1861)](e[c(1288)](g,6),63),128);continue;case"5":g=e[c(1736)](65536+e[c(1410)](e.qMXNZ(1023,g),10),e[c(812)](1023,m));continue}break}}}else if(e.xFCDj(e[c(477)],c(599))){let l=this["_endpoin"+c(1426)]?.[c(1329)+"ntEndpoint"]();this[c(1020)](c(995)+l+c(552)),this[c(1685)+c(1795)](1001,e[c(1514)],!0)}else t[r++]=e[c(784)](g>>12,224),t[r++]=e[c(965)](e[c(1482)](e[c(542)](g,6),63),128),t[r++]=e[c(678)](63,g)|128}return e[c(680)](r,x)}}async function us(i){let t=n;if(e[t(1106)]==typeof i)if(e.DDozK(t(1105),t(1793))){let r=new Uint8Array(xs(i));return e[t(462)](Br,i,r,0),r}else return QTvxnE[t(645)](_0x443af3,_0x2ba7b2[t(1714)](QTvxnE[t(1066)](_0xe2bf90,this),_0x4ec6ee));return e[t(537)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i.buffer,i[t(803)+"et"],i.byteLength)}function s0(i){let t=n;if(e[t(1485)](e[t(1720)],e.tAgtV))return _0x7d51f7.resolve();try{return e[t(1821)](e[t(1106)],typeof i)&&(e[t(673)](i,ArrayBuffer)||i[t(540)]&&e.ueqII(i[t(540)],ArrayBuffer))||e.EVnQC(e[t(1106)],typeof i)?"":(JSON[t(1656)](i),t(1011)+"ion/json")}catch{if(e[t(831)](e[t(1413)],e[t(596)])){let r=this[t(718)][t(1005)](this._prefix),c=_0x2a8074[t(1656)](e[t(1574)](r,"{}"));return _0x270ed0[t(1563)](c)}else return e[t(1231)](e[t(1106)],typeof i)?t(1627)+"in;chars"+t(1182):""}}let o0=(i,t)=>{let r=n;switch(i){case e.wHPcH:case e.XRxyc:return{[r(1116)+i]:1,"x-tt-env":t};default:return{}}};class a0{constructor(t){let r=n;this["maxLossC"+r(764)]=t,this[r(419)]=0}[n(668)](){this.count++}[n(665)+n(1323)+"nt"](){let t=n;return e.llsJu(this[t(419)],this[t(1596)+"ount"])}[n(473)+n(453)](t=0){let r=n;this[r(1596)+r(764)]=t,this[r(419)]=0}}async function c0(i){let t=n,r={BnlDU:function(c,x){return c|x},WJKOh:function(c,x){return e.IZWxY(c,x)}};if(e[t(1677)](t(1892),e[t(1044)]))_0x2ac726[_0x13542c++]=DhQHHG.BnlDU(DhQHHG[t(892)](_0x42e651,6),192),_0x5cc09c[_0x44c09f++]=63&_0x27cfc8|128;else return new Promise(c=>{let x=t,g={DhSxq:function(m,_){return e[M(1744)](m,_)},yLQHU:e[x(1815)],xgWzU:function(m,_){return e[x(1745)](m,_)}};if(e[x(1621)]===e[x(1621)]){if(!St)return c(e[x(1815)]);try{if(e[x(985)](e.SkZEd,x(1635))){let m=this["_message"+x(685)][x(1308)]((_,l)=>(_+=l&&l[x(823)+"th"]||0,_),0);return g[x(937)](m,this._ws?this[x(1093)]["buffered"+x(1083)]:0)}else{let m=document[x(998)+"ement"]("script");window[x(1735)+x(1064)]=_=>{let l=x;document[l(731)][l(1002)+l(1519)](m),window[l(1735)+l(1064)]=void 0,c(_&&_[l(1081)]||g[l(1157)])},m.type=e.VxerG,m.src=e[x(874)](i[x(430)](/^ws/,e[x(1844)]),e[x(1009)]);try{document.body[x(845)+"ild"](m)}catch{document[x(731)][x(1002)+x(1519)](m)}}}catch{if(e.oyDdy!==e[x(1260)])return this[x(1093)]?this._ws.url:this[x(912)];window[x(1735)+x(1064)]=void 0,c(e[x(1815)])}}else return!!(this[x(982)+x(717)]>=this[x(1851)+"s"][x(509)]||syeXXH.xgWzU(this[x(982)+x(717)],this[x(1851)+"s"][x(509)]-1)&&this["currentE"+x(758)+"riesCount"]===this[x(938)+"es"])})}function rt(i,t,r){let c=n;return!!i?.[c(1576)](x=>x[c(1183)]===t&&x[c(1651)]===r)}function Et(i,t){let r=n;return i?.[r(1576)](c=>c[r(1183)]===t)?.[r(1651)]}let zr=null;async function x0(){let i=n;return zr||(zr=Promise[i(1431)]()[i(498)](qe[i(935)](qe,e[i(877)]))),zr}class d0 extends Mr{constructor(t,r){let c=n;super(),this[c(1659)]=t,this[c(739)]=r,this[c(718)]=void 0,this[c(1452)+c(1791)]=null}async[n(1989)](){await this[n(1450)]()}async _init(){let t=n,r={GkixZ:function(c,x,g,m){return e.gtHio(c,x,g,m)}};if(e.nOTPy(e[t(1010)],e.RzjOT)){if(this[t(718)])return;if(this[t(1452)+t(1791)])return this[t(1452)+"mise"];try{let c=this[t(1659)],x=this[t(739)];this[t(1452)+t(1791)]=(async()=>{let g=t,{openDB:m}=await x0();this._qosDB=await r[g(592)](m,g(1735)+"_"+c,1,{upgrade(_){let l=g;_[l(1148)+l(1770)+"e"](c,{keyPath:x})}})})(),await this[t(1452)+t(1791)]}catch(c){console[t(881)](c)}finally{this[t(1452)+t(1791)]=null}}else return new _0x2dc603(_0x893fed,{data:_0x1f6977,message:_0x13122d})}async[n(791)](t){let r=n;if(e[r(1485)](e[r(1127)],e[r(1127)]))try{return await this[r(1450)](),this[r(718)]?.[r(791)](this[r(1659)],t)}catch(c){console[r(881)](c)}else this[r(773)]=_0x5cf05b,this[r(775)]=null}async[n(1593)](t,r){let c=n;return await this._init(),this._qosDB?.[c(1348)](this._dbName,t)}async[n(1118)](t){let r=n;try{return await this._init(),this[r(718)]?.[r(1280)](this._dbName,t)}catch(c){console[r(881)](c)}}async[n(1724)](){let t=n;try{return await this[t(1450)](),this[t(718)]?.[t(1724)](this[t(1659)])}catch(r){console.log(r)}}async[n(790)](){let t=n;return await this._init(),this[t(718)]?.getAllKeys(this[t(1659)])}async[n(1207)](){let t=n;return await this[t(1450)](),this._qosDB?.[t(1207)](this[t(1659)])}async[n(900)](){let t=n;try{this[t(718)]?.close(),this._qosDB=void 0}catch(r){console.log(r)}}get[n(819)](){let t=n;try{return!!this[t(718)]}catch(r){return console[t(881)](r),!1}}}class u0{constructor(t,r){let c=n;this[c(566)]=t,this[c(1940)]=r,this[c(718)]=localStorage}async openDB(){}get[n(1753)](){return"frontier_"+this[n(566)]}async[n(791)](t){let r=n,c=this._qosDB[r(1005)](this[r(1753)]);return JSON[r(1656)](e.oNoLV(c,"{}"))[t]}async[n(1593)](t,r){let c=n,x=this[c(718)].getItem(this[c(1753)]),g=JSON.parse(e[c(1898)](x,"{}"));return g[r||t[this[c(1940)]]]=t,this[c(718)][c(902)](this[c(1753)],JSON.stringify(g)),r||t[this[c(1940)]]}async[n(1118)](t){let r=n,c=this[r(718)][r(1005)](this[r(1753)]),x=JSON[r(1656)](e.IgLWh(c,"{}"));return x[t]=void 0,this[r(718)][r(902)](this[r(1753)],JSON[r(1419)+"y"](x))}async clear(){let t=n;return this[t(718)][t(1724)]()}async[n(790)](){let t=n,r=this[t(718)][t(1005)](this[t(1753)]),c=JSON[t(1656)](r||"{}");return Object[t(790)](c)}async[n(1207)](){let t=n,r=this._qosDB[t(1005)](this[t(1753)]),c=JSON[t(1656)](e[t(1898)](r,"{}"));return Object[t(1563)](c)}[n(900)](){return Promise[n(1431)]()}get[n(819)](){return!!this[n(718)]}}class f0{constructor(t,r){let c=n;this[c(566)]=t,this._pathKey=r,this._qosDB=ft?tt:$t?wx:null}async[n(1989)](){}get _prefix(){let t=n;return t(1735)+"_"+this[t(566)]}async[n(791)](t){let r=n,c=this[r(718)].getStorageSync(this[r(1753)]);return JSON[r(1656)](e[r(1645)](c,"{}"))[t]}async[n(1593)](t,r){let c=n,x=this[c(718)][c(529)+"geSync"](this._prefix),g=JSON[c(1656)](e.aqIqZ(x,"{}"));return g[r||t[this._pathKey]]=t,this._qosDB["setStora"+c(1326)](this[c(1753)],JSON[c(1419)+"y"](g)),r||t[this[c(1940)]]}async[n(1118)](t){let r=n,c=this._qosDB[r(529)+r(1326)](this[r(1753)]),x=JSON[r(1656)](c||"{}");return x[t]=void 0,this[r(718)][r(966)+r(1326)](this._prefix,JSON[r(1419)+"y"](x))}async[n(1724)](){let t=n;return this._qosDB[t(1910)+t(878)]()}async[n(790)](){let t=n,r=this._qosDB["getStora"+t(1786)+"nc"](this[t(1753)]),c=JSON[t(1656)](e[t(1574)](r,"{}"));return Object[t(790)](c)}async[n(1207)](){let t=n,r=this._qosDB[t(529)+t(1786)+"nc"](this[t(1753)]),c=JSON.parse(e[t(1028)](r,"{}"));return Object[t(1563)](c)}[n(900)](){return Promise[n(1431)]()}get[n(819)](){let t=n,r={VJWdK:e.qMJNr,AWzDV:function(c,x){return e[M(1622)](c,x)},FeQPo:function(c,x,g,m){return e[M(462)](c,x,g,m)},BiTBb:function(c,x){return e[M(1601)](c,x)}};if(e.qSjJy(e[t(616)],"aBwYT"))return!!this[t(718)];if(jhYagw.VJWdK==typeof _0x5f1c61){let c=new _0x40e58f(jhYagw[t(630)](_0x5f2153,_0x31b991));return jhYagw[t(676)](_0xc81143,_0x49229b,c,0),c}return jhYagw[t(427)](_0x1fb723,_0xe800e5)?new _0x47315d(_0x3ca08c):new _0x3ba38c(_0x3ea072[t(540)],_0x2e09a2[t(803)+"et"],_0x46bf22.byteLength)}}function fs(i,t){let r=n;if(ft||ft)return new f0(i,t);if((St||Jt)&&e[r(489)](e.XnJMd,typeof indexedDB))return new d0(i,t);if(e[r(1898)](St,Jt)&&e[r(1440)](r(1881)+"d",typeof localStorage))return new u0(i,t);throw new Error(e[r(1926)])}class l0{constructor(){let t=n;if(e[t(1216)]===e.OapiG)this[t(1584)+t(1335)+"Id"]=null,this._interval=36e5,this[t(718)]=e[t(598)](fs,t(1181),e[t(1174)]);else return _0x281039||(_0x4b519f=[_0x396018,_0x34f305,_0x4251fd,_0x188954,_0x3668a3])}async["_interva"+n(1496)](){let t=n;if(e[t(1478)]===e.fVwoc)return!0;e[t(756)](clearInterval,this._intervalTimeoutId),this[t(1584)+t(1335)+"Id"]=setInterval(()=>{this[t(1251)+"ired"]()},this[t(1584)+"l"])}async[n(1989)](){let t=n;await this[t(718)][t(1989)]()[t(498)](()=>{let r=t;this[r(1584)+r(1496)]()})}async[n(1251)+n(1355)](){let t=n;if(e[t(1598)]!==e[t(1547)])(await this[t(718)]?.[t(1207)]()||[])[t(1524)](({timestamp:x})=>x<Date[t(1128)]())[t(1644)](x=>{let g=t;this._qosDB?.[g(1118)](x[g(1313)+"id"])});else return 0}async[n(1118)](t){let r=n,c={BHluS:function(x,g){return e.SAcTp(x,g)},HtDRF:r(1650)};if(r(832)===e[r(1021)]){let{url:x}=_0x3996da||{},g=_0x1e8044[r(1784)](x)?x:c[r(429)](c[r(697)],typeof x)?[x]:[];_0x4769ac&&_0x23c37f[r(1625)](this[r(918)],_0x50d923),g&&g[r(509)]?this[r(1008)+"tManager"]=new _0x305df3(g,this[r(918)].maxRetries):this[r(1008)+r(1426)]?.[r(1971)+r(1618)+r(893)](),this._pingLossCounter?.[r(473)+r(453)](this[r(918)][r(1331)+r(534)]),this["_readyCl"+r(1566)]=!1,this[r(1093)]&&this[r(1093)][r(788)+"te"]!==this[r(924)]?this[r(1685)+r(1795)](1e3,r(1042)+r(1782)+r(940),!0):(this[r(1682)]=!0,this._connect())}else return this[r(718)]?.del(t)}async[n(1593)](t,r){let c=n;return this[c(718)]?.[c(1593)]({message_id:t,timestamp:r})}async[n(791)](t){return this[n(718)]?.get(t)}async[n(900)](){let t=n;e[t(1993)](clearInterval,this[t(1584)+t(1335)+"Id"]),await this[t(718)]?.[t(900)]()}get[n(819)](){let t=n;return this._qosDB?.[t(819)]}}function Fr(i){let t=n,r=!!this._options.enableQoS;if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let c=rt(i[t(866)][t(1495)],e[t(440)],"2"),x=c&&e.PmFfJ(rt,i.message[t(1495)],e[t(1600)],"1"),g=c&&e[t(1789)](rt,i[t(866)].headers,t(417)+t(1648)+"k","1"),m=g?e.dRNmd(Et,i[t(866)][t(1495)],e[t(1276)])?.[t(1771)](",")[t(1524)](Boolean)||[]:[];return{enabled:r,isQoSMessage:c,isQoSAck:x,isAckCleanupMessage:g,ackMsgIds:m}}async function ls(){let i=n;return this[i(698)+"ger"]||(this[i(698)+i(1681)]=new l0),this[i(698)+i(1681)][i(819)]||await this[i(698)+"ger"][i(1989)](),this[i(698)+i(1681)]}async function g0(i,t){let r=n,{enableAutoAck:c}=this[r(918)],x=e.XnIhz(rt,i[r(866)].headers,e[r(1437)],"1"),g=e[r(1789)](rt,i[r(866)][r(1495)],e[r(1388)],"1"),m=Fr.call(this,i);if(e[r(1825)](c,x)){let{SeqID:_,LogID:l,service:S,LogIDNew:v,method:P}=i[r(866)];this._sendAck({SeqID:_,LogID:l,LogIDNew:v,service:S,method:P,headers:[{key:e[r(1388)],value:"1"},{key:e[r(1256)],value:v||""},{key:e[r(1988)],value:"0"}]})}g&&!m[r(1597)]&&this["_dispatchAckMess"+r(909)](i),t()}async function p0(i,t){let r=n;this[r(1020)](e[r(1492)],i[r(866)]),e[r(1084)](t)}async function h0(i,t){let r=n,c=e[r(564)](_t,await e.IFgxo(us,i[r(1909)]));try{if(e.YrZrh!==e.NyTZi)if(e.KosGs(c.payload,Uint8Array)){let x=e[r(1601)](this[r(918)][r(712)+r(1258)],Object)?{force:!!this[r(918)][r(712)+r(1258)].force,encoding:this[r(918)][r(712)+r(1258)][r(1830)]?this[r(918)][r(712)+r(1258)][r(1830)][r(430)](/\s/g,"")[r(944)+r(421)]():""}:{force:!1,encoding:this._options[r(712)+r(1258)]?this._options[r(712)+r(1258)].replace(/\s/g,"")[r(944)+"ase"]():""},g=c["payloadE"+r(1258)]?c[r(712)+r(1258)][r(430)](/\s/g,"")["toLowerC"+r(421)]():"",m=e.RbmDC(this[r(918)][r(1994)+r(875)],Object)?{force:!!this[r(918)]["payloadT"+r(875)][r(1708)],type:this[r(918)][r(1994)+r(875)].type?this[r(918)][r(1994)+r(875)][r(773)].replace(/\s/g,"")[r(944)+r(421)]():""}:{force:!1,type:this[r(918)][r(1994)+r(875)]?this[r(918)].payloadType.replace(/\s/g,"")["toLowerC"+r(421)]():""},_=c[r(1994)+r(875)]?c[r(1994)+r(875)][r(430)](/\s/g,"")[r(944)+r(421)]():"",l=m[r(1708)]?m[r(773)]:_||m[r(773)],S=x[r(1708)]?x[r(1830)]:g||x[r(1830)],v=[e[r(783)],"applicat"+r(824),e[r(1759)],r(1650)],P=["none_none",r(825)];this[r(918)][r(1532)+r(1929)+r(1317)+"ad"]&&v[r(1610)](l)&&(!S||P.includes(S))?c[r(439)+r(1946)]=e[r(521)](ds,c[r(426)],0,c[r(426)][r(823)+"th"]):c[r(439)+r(1946)]=""}else c.textPayload="";else _0x27cca0&&_0x41db9e[r(1614)+r(1955)](QTvxnE.rVsIU,()=>_0x20bff4()),_0x147353&&_0x3b6385[r(1614)+r(1955)](QTvxnE[r(1884)],()=>_0x2ed0a7())}catch(x){c[r(439)+r(1946)]="",console[r(881)](x)}i[r(866)]=c,e[r(1390)](t)}function m0(i,t,r){let c=n,x={CbVGr:function(S,v){return e[M(1848)](S,v)},TIuPw:function(S,v){return e[M(1226)](S,v)},YBGzA:function(S,v){return e.GKICS(S,v)},jcccA:function(S,v){return S+v},SbtEN:function(S,v){return e[M(1749)](S,v)},EmpQa:function(S,v){return S|v}},g=r||8192,m=e[c(770)](g,1),_=null,l=g;return function(S){let v=c;if(x[v(1718)](S,1)||S>m)return x[v(1676)](i,S);if(x[v(507)](x[v(1098)](l,S),g))if(v(1425)!=="pILqU")_=x.TIuPw(i,g),l=0;else{let R=this[v(1731)+"rs"][_0x4f87c6];if(R)for(let B=0;B<R[v(509)];)R[B].fn===_0x4f4274?R[v(559)](B,1):++B}let P=t[v(1352)](_,l,l+=S);return x.SbtEN(7,l)&&(l=x[v(1302)](7,l)+1),P}}let w0=4294967295;function _0(i,t,r){let c=n;return RangeError(e[c(1744)](e[c(1925)](e[c(1736)](e.uRzlG(e[c(1502)](e[c(1935)],i)," + "),e[c(883)](t,1)),c(1140)),r))}function y0(i,t,r){let c=n;if(e.JQAIw(r,w0))throw new Error(e[c(1268)]);let x=3;for(;e[c(504)](x,0);){let g=e.dciJv(255,r);e.IDgLM(qr,g,i,e[c(1347)](t,x)),r>>>=8,x--}return t+4}function b0(i,t){let r=n,c={ZuKzq:e[r(915)]};if(e[r(1808)](e[r(683)],r(544))){let x=0,g=t,m=t+4;for(;e.CVZoK(g,m);){let{value:_,offset:l}=e.mPXhI(Ur,i,g);g=l,x=e[r(1007)](x,8)>>>0,x+=_}return{value:x,offset:m}}else this[r(1033)](r(538),_0xe5a77a(ttaOrS.ZuKzq,{..._0x1d248b}))}function v0(i,t,r){let c=n,x=e.XSeZX[c(1771)]("|"),g=0;for(;;){switch(x[g++]){case"0":if(t.utf8Write)return e.AvdFc(t[c(1536)+"e"](i,r),r);continue;case"1":return e[c(1799)](Br,i,t,r)+r;case"2":if(e[c(1790)](i[c(509)],40))return e[c(1802)](e[c(1360)](Br,i,t,r),r);continue;case"3":if(!i)return r;continue;case"4":if(t.write)return e.XOdBn(t[c(1351)](i,r),r);continue}break}}function S0(i,t){let r=n,c={YQtrz:"ping_onc"+r(1170)+"s",uTVSx:function(x,g,m){return x(g,m)}};if(e[r(1745)](r(1117),e[r(695)])){let x={Tbnkq:function(g,m){return g(m)},diVtl:c[r(445)],XvuMm:r(1374)+r(620)+"t",faEeP:function(g,m,_){return c[r(693)](g,m,_)}};return new _0x9a3b3b((g,m)=>{let _=r,l={yjRhf:function(P,R){return x[M(1694)](P,R)},OUQbD:x[_(1274)],udGOg:x[_(891)],RGAbl:"timeout"};this["_clearPi"+_(633)](),this[_(615)+_(1982)+"Id"]=x[_(1921)](_0x8a707e,this._ping[_(935)](this),this[_(918)][_(1012)+"rval"]);let S=()=>{let P=_;l[P(1632)](g,P(1761)),this[P(1895)](l[P(482)],S),this[P(1895)](l[P(1023)],v)},v=()=>{let P=_;m(l[P(700)]),this[P(1895)](l[P(482)],S),this[P(1895)](l.udGOg,v)};this.on(x.diVtl,S),this.on(x[_(891)],v),this[_(539)]()})}else{let x=new K(e[r(662)](e[r(1055)](e[r(1300)](e[r(1499)](i[e[r(1925)](t,4)],24),e[r(1591)](i[e[r(1736)](t,5)],16)),e[r(1733)](i[e[r(1191)](t,6)],8)),i[e.EloHU(t,7)]),e[r(1553)](e.WAXHe(e[r(1654)](i[e.bBhtM(t,0)]<<24,e[r(491)](i[e[r(1925)](t,1)],16)),e[r(1177)](i[e[r(649)](t,2)],8)),i[e[r(1277)](t,3)]),!0);return t+=8,{value:x,offset:e[r(1389)](t,8)}}}function E0(i,t,r){let c=n,x=i[c(1700)],g=i[c(1244)];return t[r]=e[c(1639)](g,24),t[e[c(827)](r,1)]=e[c(1368)](e.mgWZd(g,16),255),t[e[c(1022)](r,2)]=e[c(1698)](e.BCjdc(g,8),255),t[r+3]=e.cxUUs(255,g),t[e[c(625)](r,4)]=e[c(621)](x,24),t[r+5]=e[c(677)](e[c(1564)](x,16),255),t[e[c(1736)](r,6)]=e.aZOhP(e.ZPNyb(x,8),255),t[r+7]=e[c(639)](255,x),r+=8,r}function Ur(i,t){let r=n;return i[r(1194)+"8"]?{value:i[r(1194)+"8"](t),offset:e[r(734)](t,1)}:{value:e[r(1549)](255,i[t]),offset:t+1}}function qr(i,t,r){let c=n;return t[c(992)+"t8"]?t.writeUint8(i,r):t[r]=e[c(488)](255,i),e[c(1709)](r,1)}let A0=function(i){return new Uint8Array(i)},I0=e.Kfmqs("undefined",typeof Buffer)?Buffer["allocUns"+n(449)]:e[n(686)](m0,A0,Uint8Array[n(575)+"e"][n(1456)]);(()=>{let i=n,t={ILDVR:"3|0|5|2|"+i(688)+i(921)+"8",TrlAP:function(c,x){return e[i(861)](c,x)},MskoH:function(c,x){return e[i(1717)](c,x)},NGppv:function(c,x){return c|x},FdJpi:function(c,x){return e[i(1582)](c,x)},sTNXM:function(c,x){return e[i(470)](c,x)},PbNOf:function(c,x){return c<x},qkYAu:function(c,x){return e[i(506)](c,x)},JdBaF:function(c,x){return e[i(1896)](c,x)},omILf:function(c,x){return e[i(1029)](c,x)},pKxkm:function(c,x){return e[i(1544)](c,x)}},r=4294967295;return function(c,x,g=!0){let m=i,_=t[m(749)][m(1771)]("|"),l=0;for(;;){switch(_[l++]){case"0":if(t[m(939)](c[x++],128))return{value:g?r:0|r,offset:x};continue;case"1":r=t.MskoH(t[m(1746)](r,t[m(1792)](t[m(1879)](15,c[x]),28)),0);continue;case"2":if(t[m(600)](c[x++],128))return{value:g?r:t[m(1018)](0,r),offset:x};continue;case"3":r=t[m(1357)](127&c[x],0);continue;case"4":if(c[x++]<128)return{value:g?r:t[m(1746)](0,r),offset:x};continue;case"5":r=t[m(1041)](t.omILf(r,t[m(558)](127&c[x],7)),0);continue;case"6":if(c[x++]<128)return{value:g?r:t[m(1746)](0,r),offset:x};continue;case"7":r=t[m(1357)](r|t[m(1879)](127,c[x])<<21,0);continue;case"8":return{value:g?r:t[m(1908)](0,r),offset:x};case"9":if((x+=5)>c[m(509)])throw x=c[m(509)],_0(x,10,c[m(509)]);continue;case"10":if(c[x++]<128)return{value:g?r:t[m(1018)](0,r),offset:x};continue;case"11":r=t[m(1357)](t[m(1908)](r,t.sTNXM(127,c[x])<<14),0);continue}break}}})();let T0=16,Gr=32;function P0(i){let t=n,r=0,c={};for(let x=0;x<i[t(509)];x++)c[i[x][t(1873)+t(597)]]=xs(i[x][t(1873)+t(597)]),r+=e[t(1385)](14,c[i[x]["cursor_n"+t(597)]]);return[r,c]}function gs(i,t,r){let c=n,x={pHUkh:function(S,v,P,R){return e[M(1411)](S,v,P,R)},uJovm:e.fYPHQ,OZGeP:"curvalue",kQMBH:function(S,v,P,R){return e[M(1799)](S,v,P,R)},omQkq:e[c(1218)],dKAAe:c(1928)+"name"},[g,m]=e[c(1333)](P0,i),_=e.oxdoA(I0,g),l=0;return i[c(1644)](S=>{let v=c,P=(v(747)+v(487)+v(1702))[v(1771)]("|"),R=0;for(;;){switch(P[R++]){case"0":l=v0(S[v(1873)+v(597)],_,l);continue;case"1":l=x[v(1115)](E0,K[v(1198)+"er"](S.cursor||t),_,l);continue;case"2":l=x.pHUkh(qr,0,_,l);continue;case"3":console[v(881)](x[v(1831)],l);continue;case"4":console[v(881)](x[v(1503)],l);continue;case"5":l=x[v(816)](qr,m[S["cursor_n"+v(597)]],_,l);continue;case"6":console.log("service",l);continue;case"7":console.log("cursor.s"+v(1611),S,S[v(1367)]);continue;case"8":console[v(881)](x[v(1545)],l);continue;case"9":l=y0(_,l,S[v(1367)]||0);continue;case"10":console[v(881)](x[v(1501)],l);continue}break}}),{frameType:Gr,headers:[{key:e[c(1728)],value:r}],payload:_}}function C0(i){let t=n,r=0,c=[];for(;r<i[t(823)+"th"];){let{offset:x}=e[t(1594)](Ur,i,r);r=x;let g={cursor_name:"",cursor:0,service:0},{value:m,offset:_}=e.WjjCg(b0,i,r);g[t(1367)]=m,r=_;let{value:l,offset:S}=e[t(1840)](Ur,i,r);r=S,g.cursor_name=e[t(1662)](ds,i,r,r+l),r+=l;let{value:v,offset:P}=e[t(1521)](S0,i,r);g[t(1641)]=v.toNumber(),r=P,c[t(946)](g)}return c}function k0(){let i=n;return{frameType:Gr,headers:[{key:e[i(1728)],value:e[i(568)]}],payload:void 0}}class D0{constructor(t,r,c){let x=n;e[x(1963)]!==e[x(586)]?(this[x(1254)+"ameSpace"]=t,this[x(1907)+"ileName"]=r,this[x(1415)+x(524)]=c,this[x(718)]=fs(this[x(1254)+x(431)],x(1873)+x(597))):(_0x20e2c3+=_0x384abf(_0x8d74a4),_0x146b6c++)}async[n(1989)](){let t=n;if(e[t(436)]===e[t(436)])await this[t(718)][t(1989)]();else{let r=e[t(1512)][t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":_0x59c76c=e[t(1789)](_0x4f52c5,_0x4ce080[t(1873)+t(597)],_0x325d0a,_0x48bdcc);continue;case"1":_0x145733=_0x5009f1(_0x14738a,_0x3b7c12,_0x43f050[t(1367)]||0);continue;case"2":_0x3f6d5a[t(881)](e[t(1980)],_0x379881);continue;case"3":_0x29f1e0.log(t(1367),_0x149834);continue;case"4":_0x1c75fa[t(881)](e[t(1243)],_0x2364e6);continue;case"5":_0x46c46b=_0x4b83c8(_0x447949[_0x516ab3[t(1873)+t(597)]],_0x3d2eb6,_0x7adf34);continue;case"6":_0x5e3e23.log(t(978),_0x5990ff);continue;case"7":_0x2140ef[t(881)](e[t(1133)],_0x56c592);continue;case"8":_0x257e2f[t(881)](e[t(2004)],_0xca2c5,_0x2ab5f7[t(1367)]);continue;case"9":_0x46653e=e.ILeEQ(_0x982794,0,_0x12b7ec,_0x558aba);continue;case"10":_0x23b823=_0x5d1bae(_0x579db3[t(1198)+"er"](_0x43a5bd[t(1641)]||_0x36e194),_0x430aef,_0x172b41);continue}break}}}async[n(1580)+"rs"](){let t=n;if(e.uVbmi(e[t(587)],t(882))){if(!this[t(718)][t(819)])return;let r=this[t(1415)+t(524)],c=await this._qosDB[t(1207)]();switch(console[t(881)](e[t(1221)],c),r){case e[t(841)]:return c&&c[t(509)]?e[t(565)](gs,c,0,this[t(1907)+t(444)]):void 0;case"INSTANT":return;case e[t(981)]:return c&&c[t(509)]?gs(c,0,this[t(1907)+t(444)]):e[t(754)](k0)}}else _0x5d63ed[_0xdb7450++]=e[t(1690)](_0x3beab4,12)|224,_0x185ce8[_0x2756b0++]=e[t(1429)](e[t(1653)](e[t(1785)](_0x63313f,6),63),128),_0x307a29[_0x5e152b++]=e[t(1716)](e[t(1379)](63,_0xea2f1),128)}async[n(1593)](t,r,c){let x=n;if(e[x(1342)](e[x(1886)],x(1151))){if(this["_clearPi"+x(633)](),this[x(1422)+x(428)](),this[x(1078)+x(1265)+"rs"](),this[x(1706)+x(554)](1e3,_0x31a64e),this["_connect"+x(557)]=!1,_0x11dfe1&&this[x(837)+x(1966)]()&&!this[x(1757)+x(1566)]){if(this[x(1008)+x(1426)]?.[x(665)+"chMaxTries"]()){let m=this._endpointManager?.[x(1329)+"ntEndpoint"]();this["_dispatchCloseEv"+x(590)](_0x39a124(e[x(915)],{code:1006,reason:x(995)+m+(x(552)+", max re"+x(1507)+x(1969)),wasClean:!0}))}else{let m=this[x(918)][x(1778)+x(910)+x(1845)](_0x13ad34,_0x4a19de);this[x(1942)+x(804)+x(590)](e[x(987)](_0x2d04a8,e.rVsIU,{code:_0x15e502,reason:_0x5898a2,wasClean:!0,willReconnect:m})),m&&this[x(1399)]()}return}this[x(837)+x(1966)]()||this[x(1757)+x(1566)]?this["_dispatc"+x(804)+x(590)](e[x(416)](_0x3289d6,x(538),{code:_0x34f3ef,reason:e.tIguC})):this[x(1942)+"hCloseEv"+x(590)](e[x(925)](_0x38d2c7,e[x(915)],{code:1006,reason:e[x(735)]})),this[x(1093)]=null,this[x(1008)+x(1426)]?.[x(1971)+x(1618)+x(893)](),this[x(1142)+x(1539)]?.[x(473)+x(453)]()}else return console[x(881)](e[x(1072)],t,r,c),this._qosDB[x(1593)]({cursor_name:t,cursor:r,service:c})}async[n(1557)+"rs"](t){let r=n,c=e[r(1500)](C0,t);for(let x of c)console[r(881)](r(1546)+"r",c),await this._qosDB[r(1593)](x)}async[n(791)](t){let r=n,c={ZTDPb:e[r(1525)],agpIN:"abort"};if(e[r(1340)](r(1109),e[r(1074)]))return(await this._qosDB[r(791)](t))?.cursor;_0x59a676[r(1210)+r(607)+r(622)](xculSr[r(772)],_0x364589),_0x1883b4["removeEv"+r(607)+r(622)](r(654),_0x1ed4e0),_0x482c4b[r(1210)+r(607)+r(622)](xculSr[r(1414)],_0x1b95d0)}async[n(900)](){let t=n;await this[t(718)][t(900)]()}[n(1616)+n(853)+n(1489)](t){let r=n;if(e[r(562)](e[r(1727)],e[r(1727)]))this[r(1907)+r(444)]=t;else return{frameType:_0x37bfa2,headers:[{key:e[r(1728)],value:e[r(568)]}],payload:void 0}}get[n(819)](){let t=n;return this[t(718)][t(819)]}}let R0=e[n(1320)];async function ps(i){let t=n;if(!this[t(918)].enableQoS)return null;let{aID:r,fpID:c,messageStrategy:x}=this[t(918)],g=e[t(1199)](i,R0);try{return this[t(999)+t(1155)]?i&&this[t(999)+t(1155)][t(1616)+"rsorFile"+t(1489)](i):this[t(999)+t(1155)]=new D0(c+"_"+r+"_"+g,g,x),this[t(999)+t(1155)][t(819)]||await this._cursorManager[t(1989)](),this["_cursorM"+t(1155)]}catch{return null}}async function O0(i,t){let r=n,c={pqHfX:function(x,g){return e.uwLrf(x,g)},QVQXx:function(x,g){return e[M(1421)](x,g)},vfvrd:r(672)+r(672)+r(672)+r(672)};if(e[r(1363)](e[r(582)],r(424))){let x=/(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}/[r(1257)](_0x122b11),g=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[r(1257)](_0x80ea0c);return x?GsZcRf[r(1754)](_0x4b173b,_0x1db28e):g?GsZcRf[r(829)](_0x3598ed,_0x1d9350):GsZcRf[r(1201)]}else{let x=rt(i[r(866)][r(1495)],e[r(1213)],"-1"),g=rt(i[r(866)][r(1495)],r(1219),"1"),m=e.lJDar(Et,i[r(866)][r(1495)],e[r(551)]),_=e[r(1794)](Number,e.jcBjX(Et,i[r(866)][r(1495)],r(417)+r(435)))||0,l=Fr[r(1352)](this,i),S=rt(i[r(866)].headers,"x-msg-qos","2"),v=e[r(725)](Et,i.message.headers,e[r(1937)]),P=e[r(732)](Number,e[r(1961)](Et,i[r(866)][r(1495)],e[r(1972)]));if(l[r(1597)])return e[r(692)](t);let R=l[r(1579)+r(1190)]?await ls.call(this):null;if(e[r(628)](i.message.service,0)&&g&&!x||e[r(1275)](i.message.service,0)){if(m&&l[r(1579)+r(1190)]&&R)return!!!await R.get(m)&&(this[r(1942)+r(989)+r(1941)](i),await R[r(1593)](m,e[r(1141)](Date[r(1128)](),_))),t();if(S)if(e[r(1951)](e[r(805)],e.ZpgAn)){let B=_0x20c6b1[r(1527)],z=_0x5bff01[r(682)],ee=_0x551fda[r(1252)],Z=e[r(1744)](z,_0x351dd8);if(e[r(628)](Z,B[r(509)])){let At=new _0xda3f59(e.vityt(2,Z));At.set(B),_0x3d91a8.bytes=At}return _0x3449ac[r(682)]=Z,e[r(815)](Z,ee)&&(_0x575199[r(1252)]=Z),z}else{let B=await ps[r(1352)](this);if(!B)if(e[r(1679)](e[r(1082)],r(1285))){let ee=_0x181c21[r(1183)];e[r(1679)](void 0,ee)&&(e.Cztip(_0x2e0f92,_0x3fa4cb,10),e[r(1484)](_0x1ff0a1,_0x159ae4,ee));let Z=_0x9d5cd3[r(1651)];e[r(1583)](void 0,Z)&&(e[r(514)](_0xf3a0c6,_0x458b62,18),e[r(1290)](_0x52548e,_0x2cf315,Z))}else return this[r(1942)+r(989)+r(1941)](i),e[r(594)](t);let z=await B.get(v)??-1;if(e[r(1224)](z,P))if(e.DuWsj!==r(1556))this["_dispatc"+r(989)+r(1941)](i),B[r(1593)](v,P,i[r(866)][r(1367)]);else return _0x4ff261+=_0x56d367&&_0xdfac07[r(823)+"th"]||0,_0x145612;else throw new Error(r(876)+r(1432)+" cursor "+P+(r(986)+r(1719)+r(1016)+"r ")+z);return t()}return this._dispatchMessageEvent(i),e[r(754)](t)}}}async function N0(i,t){let r=n;if(e[r(1657)](e.PAjUs,e[r(1608)])){let c=_0x15e536[_0x3b8bab++];if(e[r(1914)](c,127))_0xb9ff53+=_0x5f3ed9[r(1710)+r(1382)](c);else if(e.llsJu(c,192)&&e[r(1261)](c,224))_0x49e6c6+=_0x52b61f[r(1710)+r(1382)](e.WyQXA(e[r(1025)](31,c),6)|e[r(1200)](63,_0x5df746[_0x36ef19++]));else if(e[r(898)](c,224)&&e[r(576)](c,240))_0x2dae3f+=_0x2ebc03[r(1710)+"Code"](e[r(784)](e[r(1915)](15,c)<<12|e[r(730)](63,_0x496068[_0x24e5c6++])<<6,e.uCbcZ(63,_0x5e2e3b[_0x14e64e++])));else if(e[r(690)](c,240)){let x=e.CNpwS(e[r(1255)](e.IKvLo(e.oread(e.cWJaY(e[r(1470)](7,c),18),e[r(1944)](63&_0x3281fc[_0x589f1d++],12)),e.ZQHFg(63,_0x43a138[_0xc0dcfe++])<<6),e[r(1461)](63,_0x53f7e3[_0x50d442++])),65536);_0xda471c+=_0x1a73e1[r(1710)+r(1382)](55296+e.cVtSM(x,10)),_0x4e4d59+=_0x7871c0[r(1710)+r(1382)](e[r(1589)](56320,e[r(1292)](1023,x)))}}else{let c=Fr[r(1352)](this,i);if(!c.isQoSMessage)return e[r(1455)](t);let x=await ls[r(1352)](this);if(c[r(1870)+r(1230)+r(1541)]&&c[r(1047)+"s"][r(509)])for(let g of c[r(1047)+"s"])await x[r(1118)](g);e[r(604)](t)}}async function L0(i,t){let r=n,c=e[r(1427)](i[r(866)][r(1775)+"e"],T0),x=e.VzCDO(i[r(866)][r(1775)+"e"],Gr);if(!c&&!x)return t();let g=e[r(1590)](Et,i[r(866)][r(1495)],r(1841)+"ile_name");if(!g)return e[r(1571)](t);let m=await ps[r(1352)](this,g);if(!m)return t();if(c){let _=await m[r(1580)+"rs"](),l={frameType:_?.[r(1775)+"e"],SeqID:K[r(1198)+"er"](this[r(1619)]++),LogID:K[r(1198)+"er"](this._options[r(602)+r(879)]()),service:9e3,method:5,headers:_?.headers,payload:_?.payload},S=A(l);this[r(1093)]&&this[r(1093)][r(788)+"te"]&&this[r(1093)][r(569)](S)}if(x){let _=i[r(866)][r(426)];_&&m[r(1557)+"rs"](_)}}let M0=async function(i,t){let r=n;this[r(1682)]=!1,e.ihyak(clearTimeout,this["_connect"+r(1336)+r(1121)]),e[r(1528)](t)},B0=async function(i,t){let r=n;if(e[r(1119)](r(1003),e[r(1001)])){if(!this[r(1093)]||e[r(593)](this._ws[r(788)+"te"],this[r(1248)]))return e[r(441)](t);let{pingInterval:c}=this._options;this[r(1008)+r(1426)]?.["resetEnd"+r(1618)+r(893)]();for(let g=0;e[r(1977)](g,this[r(1415)+r(685)][r(509)]);g++){let m=this[r(1415)+"Queue"][g];if(e.WxOxJ(this._ws.readyState,this[r(1248)])&&m!==null)if(e[r(1479)](e[r(726)],e.LVDsK)){if(QTvxnE[r(1677)](_0x1cb12c,QTvxnE[r(1454)]))return _0x5a41d6[r(791)](_0x212a2a);if(_0x2f05a1===QTvxnE[r(545)])return _0x1cc260["objectSt"+r(1267)]||_0x36b436.get(_0x4a2045);if(QTvxnE[r(555)](_0x284f9f,"store"))return _0x9ad871[r(660)+r(1267)][1]?void 0:_0x1962d7["objectSt"+r(1520)](_0x453836[r(660)+r(1267)][0])}else this[r(1093)]&&this[r(1093)][r(569)](m),this[r(1415)+r(685)][g]=null;else break}this[r(1415)+r(685)]=this[r(1415)+r(685)].filter(g=>!!g),this[r(615)+"gTimeoutId"]=setTimeout(()=>this[r(539)](),c),this[r(1942)+"hOpenEvent"](i),this[r(614)+"er"]&&this[r(1093)]&&(this[r(1093)].binaryType=this[r(722)+"ype"]);let x=this[r(1008)+"tManager"]?.[r(1329)+r(997)+"nt"]();this[r(1020)](r(1443)+x+r(1476)),e[r(785)](t)}else{let c=e.BIMuq[r(1771)]("|"),x=0;for(;;){switch(c[x++]){case"0":_0x44e255[_0x1bac26[e[r(1122)]]=5004]=e.SDIUT;continue;case"1":return _0x3b57e6;case"2":_0x56f73f[_0x13956b[e[r(830)]]=5001]=e[r(830)];continue;case"3":_0x3fc032[_0x25f57f[e[r(1325)]]=5003]=e[r(1325)];continue;case"4":_0x4724d5[_0x1d8881[r(1874)+"NG_ERROR"]=5002]=e.nxKKF;continue;case"5":_0x142a52[_0x4be520[e[r(643)]]=5005]=r(1417)+"OR";continue}break}}},z0=async function(i,t){let r=n,c=this[r(1008)+r(1426)]?.[r(1329)+r(997)+"nt"]();this._debug("open "+c),e[r(1057)](t)};class F0 extends Mr{constructor(t){let r=n,c={IOJcF:function(_,l,S,v){return e.XnIhz(_,l,S,v)},EpGbi:function(_,l){return _!==l},KixUw:e[r(1321)],QpwFB:e.SYKiM,GfxLx:function(_,l,S){return e[r(1050)](_,l,S)},pKEEm:e[r(1617)],RlxfP:function(_,l,S){return e.dRNmd(_,l,S)},isyyN:function(_,l){return _===l},sDcUr:r(1146),WCsxm:function(_,l){return e[r(952)](_,l)},EYIVI:e[r(1154)],ATBpD:e.nxTLQ,eZdHO:r(1374)+r(1170)+"s",egQnl:e[r(836)],qHihM:function(_,l){return e[r(1677)](_,l)},mOifR:function(_,l,S){return _(l,S)},TqvEI:function(_,l){return e[r(1467)](_,l)},KVNEL:function(_,l,S){return _(l,S)},WfjJX:function(_,l){return _(l)},mEpKl:function(_,l){return e[r(1385)](_,l)},PWGXG:"Reeuy",UAuUx:e.BrsDT,PShZI:function(_,l,S){return _(l,S)},xalfY:e.rVsIU,ObIJi:r(1381),gXhWj:function(_,l){return e[r(1282)](_,l)},cUtyZ:function(_,l,S){return e[r(1293)](_,l,S)}};super(),this[r(807)+"igatorOn"+r(1678)]=!0,this[r(614)+"er"]=St,this[r(479)]=t0,this[r(814)+"T"]=ft,this[r(1979)+"X"]=$t,this[r(1334)+"r"]=Jt,this[r(1415)+"Queue"]=[],this[r(1008)+r(1426)]=null,this[r(1757)+r(1566)]=!1,this[r(722)+r(875)]=e[r(1756)],this["_connect"+r(557)]=!1,this[r(1399)+r(1336)+r(1121)]=null,this[r(1559)+"ctTimeoutId"]=null,this[r(615)+r(1982)+"Id"]=null,this._seqId=0,this._isInit=!1,this[r(912)]="",this[r(698)+r(1681)]=null,this[r(999)+r(1155)]=null,this["_pingLos"+r(1539)]=null,this[r(1750)+"ls"]=e[r(671)],this[r(924)]=3,this[r(1874)+"NG"]=0,this[r(1248)]=1,this[r(1796)]=2,this[r(455)]=_=>{let l=r;try{c.IOJcF(cs,this,_,[M0,B0,z0])}catch(S){if(c[l(1978)](c[l(1640)],c.QpwFB)){let v=c[l(642)](Ie,c.pKEEm,{message:S.message,code:nt[l(1417)+"OR"],error:S});this["_dispatc"+l(1822)+l(590)](v)}else _0x3fa32b.log(_0x5f30b2)}},this._onMessage=async _=>{let l=r,{pingInterval:S,pingFrequency:v}=this[l(918)];if(_.data==="hi"&&c[l(1240)](c[l(779)],v)||c[l(1451)](c[l(1529)],v))if(c[l(1131)]!=="fMXTb")this[l(687)+l(633)](),this[l(1033)](c[l(1763)],c.egQnl),this["_pingPon"+l(1982)+"Id"]=c[l(1353)](setTimeout,this[l(539)][l(935)](this),S);else{let P=this[l(1008)+l(1426)]?.["getCurre"+l(997)+"nt"]();this[l(1942)+"hCloseEvent"](c[l(1353)](_0x51863a,l(538),{code:1006,reason:l(995)+P+(" timeout, max re"+l(1507)+l(1969)),wasClean:!0}))}if(!c[l(720)]("hi",_[l(1909)]))try{c[l(646)](cs,this,_,[h0,g0,N0,L0,O0,p0])}catch(P){let R=c.GfxLx(Ie,c[l(1558)],{message:P.message,code:nt.MESSAGE_ERROR,error:P});this[l(1942)+l(1822)+"ent"](R)}},this[r(1675)]=_=>{let l=r,S=this[l(1008)+l(1426)]?.[l(665)+"chMaxTries"](),v=this[l(1008)+"tManager"]?.[l(1329)+l(997)+"nt"]();if(S&&!_[l(866)]){let P="connect "+v+(l(1315)+l(1833)+l(670)+"ed");this[l(1942)+l(1822)+l(590)](c[l(1372)](Ie,l(654),{message:P,code:nt[l(516)+l(974)+"R"],error:_}));return}this[l(1093)]&&c[l(1195)](this[l(1093)][l(788)+"te"],this[l(1248)])&&this[l(1685)+l(1795)](),this[l(1942)+l(1822)+"ent"](c[l(631)](Ie,c[l(1558)],{message:_.message,code:nt[l(1595)+l(855)],error:_}))},this[r(423)]=async _=>{let l=r;if(c[l(1240)](c[l(1165)],c[l(1603)])){let v=""+_0x4cb007[l(1128)](),P=_0x9eed01||(_0x3d0447=BtEpcL[l(1273)](_0x3e9cf2,_0x195a45)),R=_0x675329.random().toString(16)[l(806)](-6);return BtEpcL[l(838)](BtEpcL[l(838)](BtEpcL[l(838)]("02",v),P),R)}else{this[l(1422)+"mer"](),this["_clearPi"+l(633)](),this[l(1078)+l(1265)+"rs"](),this[l(1093)]=null,this[l(1399)+l(557)]=!1;let S=this["_endpoin"+l(1426)]?.checkReachMaxTries();if(!S&&this._navigatorOnline()&&!this[l(1757)+l(1566)]){let v=this["_endpoin"+l(1426)]?.[l(1329)+l(997)+"nt"](),P=this[l(918)][l(1778)+l(910)+"ptor"](_.code,_[l(1171)]);this["_dispatchCloseEv"+l(590)](De(l(538),{code:1006,reason:_[l(1171)]||l(1854)+l(510)+l(813)+"wn reaso"+l(1712)+l(561)+v,willReconnect:P})),P&&this[l(1399)]();return}if(c[l(1978)](1e3,_[l(767)])&&this[l(1757)+"osed"]){this[l(1942)+l(804)+l(590)](c[l(459)](De,c.xalfY,{code:1e3,reason:c.ObIJi})),this[l(1008)+"tManager"]?.[l(1971)+"pointCon"+l(893)](),this[l(1142)+l(1539)]?.[l(473)+l(453)]();return}if(c[l(1978)](1e3,_[l(767)])&&S){let v=this[l(1008)+l(1426)]?.[l(1329)+l(997)+"nt"](),P=_[l(1171)];P||(P=await c.gXhWj(c0,this[l(912)])),P=l(1854)+"ng failed, "+P+(", hostna"+l(1019))+v+(l(1652)+l(1507)+l(1969)),this[l(1942)+"hCloseEvent"](c[l(1902)](De,l(538),{code:_.code,reason:P}));let R=l(995)+v+(l(1315)+l(1833)+l(670)+"ed");this[l(1942)+l(1822)+l(590)](Ie(c[l(1558)],{message:R,code:nt[l(516)+l(974)+"R"]})),this[l(1008)+l(1426)]?.[l(1971)+l(1618)+l(893)](),this[l(1142)+l(1539)]?.["resetCou"+l(453)]();return}if(_[l(767)]!==1e3&&!_[l(1171)]){let v=this["_endpoin"+l(1426)]?.[l(1329)+"ntEndpoint"]();this[l(1942)+l(804)+l(590)](c[l(1372)](De,c.xalfY,{code:_[l(767)],reason:"connecti"+l(510)+l(813)+l(1371)+l(1712)+l(561)+v})),this[l(1008)+l(1426)]?.[l(1971)+"pointCon"+l(893)](),this[l(1142)+"sCounter"]?.[l(473)+l(453)]();return}this[l(1942)+l(804)+l(590)](_),this[l(1008)+"tManager"]?.[l(1971)+l(1618)+l(893)](),this[l(1142)+"sCounter"]?.[l(473)+l(453)]()}},this[r(951)]=null,this[r(1760)]=null,this[r(659)+"e"]=null,this[r(1139)]=null,this[r(1208)+r(1782)]=null,this[r(1723)+"eAck"]=null,this[r(1665)+r(1038)+r(1356)+"ct"]=null,this._handleOnLine=this[r(848)+"nLine"][r(935)](this),this["_handleO"+r(464)]=this[r(848)+"ffLine"].bind(this),this[r(1952)+r(1343)]=this[r(1952)+"ageHide"][r(935)](this),this[r(1952)+"ageShow"]=this[r(1952)+r(1024)][r(935)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(961)](1,0),service:0,logIDGenerator:a,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:r(1184),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[r(981)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:g}=t,m=Array[r(1784)](x)?x:e.USyfF(e.qMJNr,typeof x)?[x]:[];if(!m||e.BoAeR(0,m[r(509)]))throw new Error(e[r(1112)]);if(!e.wpjJd(i0,g))throw new Error(e[r(433)]);Object[r(1625)](this._options,t),this["_endpoin"+r(1426)]=new as(m,this[r(918)][r(938)+"es"]),this[r(1142)+r(1539)]=new a0(this._options[r(1331)+r(534)]),this[r(918)][r(1307)+r(1400)]&&(this[r(1682)]=!0,this._connect()),this[r(918)]["listenNetworkCha"+r(1504)]&&(this[r(814)+"T"]||this._isMiniWX?this[r(1531)+r(1767)+r(1132)]():this._isBrowser&&this[r(1059)+r(1446)+r(1955)]())}[n(848)+"nLine"](){let t=n;this[t(918)][t(1327)+t(1816)+t(964)]||this[t(1757)+t(1566)]||this[t(1498)+"econnect"]()}[n(848)+n(464)](){let t=n;this["_destroy"+t(1043)+"t"]();let r=e[t(942)](Lr,e.ixoIz,{message:e[t(412)]});this[t(1665)+"mediatel"+t(1356)+"ct"]&&this[t(1665)+t(1038)+t(1356)+"ct"](r)}[n(1059)+"balEvent"+n(1955)](){let t=n;this[t(614)+"er"]&&window[t(1614)+t(1955)](e[t(408)],this._handleOnLine),this._isBrowser&&window[t(1614)+"Listener"](t(1159),this[t(848)+t(464)]),this[t(614)+"er"]&&window[t(1614)+t(1955)]("pagehide",this[t(1952)+"ageHide"]),this._isBrowser&&window[t(1614)+t(1955)](e[t(528)],this[t(1952)+t(1024)])}[n(1962)+"balEvent"+n(1955)](){let t=n;this[t(614)+"er"]&&window[t(1210)+t(607)+t(622)](e[t(408)],this[t(848)+t(1561)]),this[t(614)+"er"]&&window[t(1210)+t(607)+"ner"](e[t(1672)],this[t(848)+t(464)]),this[t(614)+"er"]&&window["removeEv"+t(607)+t(622)](t(1408),this[t(1952)+t(1343)]),this._isBrowser&&window[t(1210)+t(607)+t(622)](t(991),this[t(1952)+t(1024)])}[n(1952)+n(1343)](t){let r=n;!t[r(728)+"d"]&&(this[r(614)+"er"]&&window["removeEv"+r(607)+r(622)](e[r(1865)],this[r(1952)+r(1343)]),this[r(614)+"er"]&&window[r(1210)+"entListe"+r(622)]("pageshow",this._handlePageShow),this[r(538)]()),this[r(614)+"er"]&&window["removeEventListe"+r(622)](e[r(408)],this[r(848)+r(1561)]),this[r(614)+"er"]&&window[r(1210)+r(607)+r(622)](e[r(1672)],this[r(848)+r(464)])}[n(1952)+n(1024)](t){let r=n;t[r(728)+"d"]&&(this["_navigat"+r(1966)]()&&(!this[r(1093)]||e[r(1951)](this[r(1093)][r(788)+"te"],this[r(1248)])||this._ws[r(788)+"te"]!==this[r(1874)+"NG"])&&this._handleOnLine(),this._isBrowser&&window["addEvent"+r(1955)](r(1386),this[r(848)+r(1561)]),this[r(614)+"er"]&&window.addEventListener(e[r(1672)],this[r(848)+r(464)]))}async["_generat"+n(1068)](t){let r=n,c={knPAF:function(x,g,m){return x(g,m)}};if(e[r(1686)]===e.yAaSf)psiXSf[r(443)](_0x2757a9,_0x3c789e,66),psiXSf[r(443)](_0x224da8,_0x107739,_0x317ec1.length),psiXSf.knPAF(_0x5a5f29,_0x5cbe06,_0x202a1f);else{let{fpID:x,deviceID:g,bddID:m,ttwID:_,accessKey:l,aID:S,customParams:v={},enableAutoAck:P,enableQoS:R,QoSLevel:B,env:z}=this[r(918)],ee,Z,At;this._isBrowser||this[r(1979)+"X"]||this[r(814)+"T"]?(ee=location&&e[r(1776)](e[r(1661)],location[r(715)])?r(1477):e[r(1612)],Z=t[r(430)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),At=/^wss(.*:\/\/)/[r(1257)](t)?t:""+ee+Z):(ee=e[r(1509)],Z=t[r(430)](/(^http)((?:[s]*:\/\/))/,""),At=/(^ws)((?:[s]*:\/\/))/[r(1257)](Z)?Z:""+ee+Z);let hs=m?"bd_did":_?e[r(890)]:e[r(613)],ms=m||_||g;if(e[r(1061)](!ms,!hs))throw new Error("please p"+r(963)+r(457)+r(1664)+r(1464));let U0=e.DoMCz(e[r(679)],typeof v)?await e[r(858)](v):v,q0=z?e.pGvFA(o0,z[r(972)],z[r(571)]):{},jr=Object[r(1625)]({device_platform:e.pLRDh,version_code:e[r(1806)],access_key:l,fpid:x,aid:S,[hs]:ms,xsack:P?1:0,xaack:P?1:0,xsqos:R?1:0,qos_level:R?B:void 0,qos_sdk_version:2,...q0},U0),G0=Object[r(790)](jr)[r(1308)]((Hr,Kr)=>jr[Kr]!==void 0?""+Hr+(Hr?"&":"?")+Kr+"="+jr[Kr]:Hr,"");return At+r(1180)+G0}}async[n(1399)](){let t=n;if(!(this[t(1399)+t(557)]||this[t(1757)+t(1566)])){this["_connect"+t(557)]=!0;try{let r=this["_endpoin"+t(1426)]?.[t(1882)+"rentEndpointReachedMaxRe"+t(1562)](),{timeoutInterval:c}=this[t(918)];if(r)if(e.juxiF(e[t(933)],t(1123)))_0x213638=e[t(1684)](e.DSubS(e[t(1843)](e[t(1134)](15,_0x1c825c),12),e.NXKzt(63,_0x33045b)<<6),e[t(1505)](63,_0x3bdb9d)),e[t(723)](_0x1db797,2048)||e[t(690)](_0x227b47,55296)&&e[t(1533)](_0x182e7b,57343)?_0x53746e+=_0x2eeb4b:(_0x50664c+=e[t(1341)](_0x2daf17,_0x2666b5),_0x512976+=2);else{let g=this[t(1008)+t(1426)]?.[t(1329)+t(997)+"nt"](),m=this[t(1008)+t(1426)]?.[t(624)+t(1986)+t(1466)+t(969)+t(1048)](),_=this[t(1008)+t(1426)]?.[t(1329)+t(997)+"ntTriesCount"]();if(m){let l="connect "+g+(t(552)+t(1652)+t(1507)+"ached, w"+t(1156)+t(941)+t(1136))+m+(t(1900)+"y"),S=e[t(1565)](Ie,e.fKVAW,{message:l,code:nt["MAX_RETR"+t(974)+"R"]});this[t(1020)](l),this[t(1942)+t(1822)+t(590)](S),this[t(912)]=await this["_generat"+t(1068)](m),this._debug(t(995)+m+" "+_+t(651)),this._removeWsListeners()}else{let l=t(995)+g+(t(552)+t(1652)+"tries re"+t(1969));this[t(1020)](l),this["_dispatc"+t(1822)+t(590)](e[t(1304)](Ie,e[t(1617)],{message:l,code:nt["MAX_RETR"+t(974)+"R"]}));return}}else{let g=this[t(1008)+"tManager"]?.[t(1329)+"ntEndpoi"+t(1113)+t(1655)](),m=this["_endpoin"+t(1426)]?.[t(1329)+t(997)+t(1403)+"ount"]();this._url=await this._generateUrl(e[t(1645)](g,"")),this._debug(t(995)+g+" "+m+t(651)),this[t(1078)+t(1265)+"rs"]()}if(this[t(1682)])this[t(1682)]=!1;else{let g=e[t(1880)](Lr,e[t(1383)],{message:t(478)});this[t(1208)+t(1782)]&&this["onStartR"+t(1782)](g)}let x=this[t(1008)+t(1426)]?.[t(1329)+t(997)+t(1403)+"ount"]()||0;e.TsCkM(x,1)&&await this[t(1346)](e[t(1633)](x,1)),this._debug(t(1854)+t(1220)+this[t(912)]+" protocols: "+this._protocols),this[t(1093)]=e[t(581)](r0,{url:this[t(912)],protocols:[this._protocols],headers:this[t(918)]["miniProg"+t(496)+"s"].customHttpHeader},this._options.ws),(this._isBrowser||this[t(1334)+"r"])&&this[t(1093)]&&(this[t(1093)][t(1049)+"pe"]=this["_binaryT"+t(875)]),this[t(556)+t(472)](),this[t(1399)+t(1336)+"utId"]=e.lJDar(setTimeout,this[t(2e3)+"ut"].bind(this),c)}catch(r){throw this["_connect"+t(557)]=!1,r}}}_clearTimer(){let t=n;e.EgUsp(clearTimeout,this[t(1399)+"ionTimeoutId"]),this[t(1399)+t(1336)+"utId"]=null}[n(687)+n(633)](){let t=n;e.zqZiY(clearTimeout,this[t(615)+"gTimeoutId"]),clearTimeout(this[t(1559)+t(1361)+t(2003)]),this[t(615)+"gTimeoutId"]=null,this[t(1559)+t(1361)+"tId"]=null}[n(1020)](...t){let r=n;this[r(918)][r(484)]&&console[r(881)][r(1714)](console,[e[r(432)],...t])}[n(1092)+n(1318)+"e"](t){let r=n;if(e.piaff("MKxGE",r(1973))){let{initReconnectInterval:c,maxReconnectInterval:x,reconnectIntervalGrowFactor:g}=this[r(918)],m=e[r(1229)](c,Math[r(1032)](g,e[r(579)](t,1)));return m>x?x:m}else _0x28e0b2+=e.RNZxQ(_0x384a35,_0x23b68e),_0x3a03fd+=2}[n(539)](){let t=n;if(this[t(1093)]&&e.jsiQo(this._ws[t(788)+"te"],this[t(1874)+"NG"])){this[t(687)+"ngTimer"](),this[t(615)+"gTimeoutId"]=setTimeout(this._ping[t(935)](this),this[t(918)][t(1012)+t(746)]);return}if(!this._ws||e[t(1298)](this[t(1093)][t(788)+"te"],this[t(1248)]))return void this[t(1498)+t(1782)]();this[t(1093)]&&this[t(1093)][t(569)]("hi"),this[t(1559)+t(1361)+"tId"]=e[t(725)](setTimeout,this["_handleReconnect"+t(1166)][t(935)](this),this[t(918)]["pingTimeoutInter"+t(497)])}[n(1498)+n(1782)+n(1166)](){let t=n;this[t(1142)+t(1539)]?.[t(668)](),this[t(1033)](e[t(899)],e.Gbckm),this[t(1142)+t(1539)]?.["checkRea"+t(1323)+"nt"]()?this["_handleR"+t(1782)]():this[t(539)]()}_navigatorOnline(){let t=n;return this[t(814)+"T"]||this[t(1979)+"X"]?this[t(807)+t(851)+t(1678)]:(this[t(614)+"er"]||this[t(1334)+"r"])&&this._options[t(610)+t(768)+"nged"]?navigator[t(1587)]:!0}[n(1498)+n(1782)](){let t=n;!this[t(837)+"orOnline"]()||this[t(1757)+t(1566)]||(this[t(1008)+t(1426)]?.["resetEnd"+t(1618)+t(893)](),this["_pingLos"+t(1539)]?.[t(473)+"nter"](),this[t(1093)]?this[t(1685)+t(1795)](1001,e[t(475)],!0):this[t(1399)]())}[n(1531)+"etWorkCh"+n(1132)](){let t=n,r={OIwGu:function(c,x){return e[M(1889)](c,x)},NkdqJ:e[t(1705)]};this[t(814)+"T"]?tt[t(1534)+t(1824)+t(856)](({isConnected:c})=>{let x=t;this["_miniNavigatorOn"+x(1678)]=c,c?this[x(848)+"nLine"]():this[x(848)+"ffLine"]()}):this[t(1979)+"X"]&&wx["onNetwor"+t(1824)+t(856)](({isConnected:c})=>{let x=t;r[x(744)]("CMlEd",r[x(1350)])?(this[x(807)+x(851)+x(1678)]=c,c?this[x(848)+x(1561)]():this[x(848)+"ffLine"]()):_0x59a64d[x(881)](_0x406170)})}[n(1346)](t){let r={ivtuv:function(c,x,g){return c(x,g)}};return new Promise(c=>{let x=M;r[x(1058)](setTimeout,c,this[x(1092)+"rvalValue"](t))})}[n(1685)+"ect"](t=1e3,r="",c=!1){let x=n,g={WmGhh:function(m,_){return m>=_}};if(e[x(562)](e[x(1570)],e.hKYDv)){if(!this[x(1093)])return;this[x(1137)+x(1043)+"t"](t,r,c)}else if(MyQToz.WmGhh(_0x11ffeb,_0x27cf62))return _0x5bb579}[n(2e3)+"ut"](){let t=n,r=this[t(1008)+"tManager"]?.[t(1329)+t(997)+"nt"]();this._debug(t(995)+r+t(552)),this["_disconn"+t(1795)](1001,e[t(1514)],!0)}_sendAck(t){let r=n,c=e.SrDMT(se,t);this[r(1093)]&&e[r(1473)](this._ws.readyState,this[r(1248)])&&(e[r(593)](e[r(741)],e[r(702)])?(this[r(1093)]&&this._ws[r(569)](c),this[r(1020)](e.NRtPt,t)):this[r(1731)+"rs"]={})}[n(1078)+"sListeners"](){let t=n,r=e[t(1407)][t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":if(!this[t(1093)])return;continue;case"1":this[t(1093)][t(1210)+t(607)+"ner"](e[t(1617)],this[t(1675)]);continue;case"2":this[t(1093)][t(1210)+t(607)+t(622)](e[t(481)],this[t(455)]);continue;case"3":this[t(1093)]["removeEv"+t(607)+t(622)](e.JbPng,this[t(1472)+"ge"]);continue;case"4":this[t(1093)]["removeEv"+t(607)+"ner"](e[t(915)],this._onClose);continue}break}}[n(556)+"steners"](){let t=n,r=e[t(1630)][t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":if(!this[t(1093)])return;continue;case"1":this._ws[t(1614)+t(1955)](e[t(1424)],this[t(1472)+"ge"]);continue;case"2":this[t(1093)]["addEvent"+t(1955)](e[t(915)],this[t(423)]);continue;case"3":this[t(1093)][t(1614)+t(1955)](e[t(1617)],this[t(1675)]);continue;case"4":this[t(1093)][t(1614)+t(1955)](e.zXGMW,this[t(455)]);continue}break}}[n(1706)+n(554)](t=1e3,r=""){let c=n;try{this[c(1093)]&&this[c(1093)][c(538)](t,r)}catch{}}[n(1137)+"WebSocket"](t=1e3,r="",c=!1){let x=n;if(this[x(687)+"ngTimer"](),this[x(1422)+x(428)](),this[x(1078)+x(1265)+"rs"](),this[x(1706)+x(554)](1e3,r),this[x(1399)+x(557)]=!1,c&&this["_navigat"+x(1966)]()&&!this[x(1757)+x(1566)]){if(this[x(1008)+"tManager"]?.[x(665)+x(1606)+"es"]()){let m=this[x(1008)+x(1426)]?.[x(1329)+"ntEndpoint"]();this[x(1942)+x(804)+x(590)](e[x(1264)](De,e[x(915)],{code:1006,reason:"connect "+m+(x(552)+", max retries re"+x(1969)),wasClean:!0}))}else{let m=this[x(918)][x(1778)+x(910)+"ptor"](t,r);this._dispatchCloseEvent(e[x(1869)](De,e.rVsIU,{code:t,reason:r,wasClean:!0,willReconnect:m})),m&&this._connect()}return}this[x(837)+"orOnline"]()||this[x(1757)+x(1566)]?this[x(1942)+x(804)+"ent"](e[x(1430)](De,e[x(915)],{code:t,reason:e[x(780)]})):this[x(1942)+"hCloseEv"+x(590)](De(e[x(915)],{code:1006,reason:"going aw"+x(1809)+x(719)+x(1605)})),this[x(1093)]=null,this._endpointManager?.[x(1971)+x(1618)+x(893)](),this[x(1142)+x(1539)]?.[x(473)+x(453)]()}[n(1942)+n(1291)+"nt"](t){let r=n;this[r(1033)](e[r(481)],t),this.onopen&&this[r(1139)](t)}[n(1942)+n(989)+n(1941)](t){let r=n;this[r(1033)](e[r(1424)],t),this[r(659)+"e"]&&this.onmessage(t)}[n(1942)+n(1412)+n(909)](t){let r=n,c={LhZjA:function(x,g){return e.kJNfm(x,g)},XOxMG:function(x,g){return e[M(1839)](x,g)},XFYQP:function(x,g){return e[M(1855)](x,g)},EXNwP:function(x,g){return x<<g}};e.JCYcV===e[r(548)]?(_0x16ca18=_0x37dbdd(_0x29f9b7),_0x1650ef|=aMGykP.LhZjA(aMGykP[r(1950)](127,_0x311ad3),21),aMGykP[r(1471)](128,_0x5cac53)&&(_0x278081=_0x54b2d0(_0x2625e8),_0x3d1aee=127&_0xcd1403,128&_0x48eb76&&(_0x10b1be=_0x4ccc87(_0x54cd16),_0x2b047c|=aMGykP[r(1380)](127&_0x36bde6,7)))):(this.emit(e[r(502)],t),this[r(1723)+r(1319)]&&this["onReceiv"+r(1319)](t))}[n(1942)+n(1822)+n(590)](t){let r=n;this[r(1033)](e[r(1617)],t),this[r(1760)]&&this.onerror(t)}[n(1942)+n(804)+n(590)](t){let r=n;this[r(1033)]("close",t),this[r(951)]&&this[r(951)](t)}get[n(1049)+"pe"](){let t=n;if(e[t(1741)](e.yquCC,e[t(550)]))return this._ws?this._ws[t(1049)+"pe"]:this[t(722)+"ype"];{let r=0,c=0;for(let x=0;e.wzjPz(x,_0x459873[t(509)]);++x)c=_0x42b200[t(1752)+"At"](x),e[t(1266)](c,128)?r+=1:e[t(1920)](c,2048)?r+=2:e.bKQrb(64512&c,55296)&&e[t(1473)](64512&_0x24ecae.charCodeAt(e[t(1453)](x,1)),56320)?(++x,r+=4):r+=3;return r}}set binaryType(t){let r=n;this[r(722)+r(875)]=t,this[r(1093)]&&(this[r(1093)][r(1049)+"pe"]=t)}get retryCount(){let t=n;return this[t(1008)+t(1426)]?.["getCurre"+t(997)+t(1403)+t(764)]()||0}get["buffered"+n(1083)](){let t=n;if(t(1673)==="XcTZh")return this[t(718)]?.isReady;{let r=this[t(1415)+t(685)][t(1308)]((c,x)=>(c+=x&&x[t(823)+"th"]||0,c),0);return e.szUMO(r,this[t(1093)]?this[t(1093)][t(1516)+t(1083)]:0)}}get[n(1089)+"ns"](){let t=n;return e.pWZGh(t(1262),e[t(1526)])?this[t(1093)]?this._ws.extensions:"":(this[t(871)+"ndpointT"+t(1511)+"t"]=1,this["currentI"+t(717)]++,this[t(1851)+"s"][this[t(982)+t(717)]])}get protocol(){let t=n;return this._ws?this[t(1093)][t(715)]:""}get[n(788)+"te"](){let t=n;return this[t(1093)]?this[t(1093)].readyState:this._options[t(1307)+t(1400)]?this[t(1874)+"NG"]:this[t(924)]}get[n(1420)](){let t=n;return this[t(1093)]?this[t(1093)][t(1420)]:this._url}[n(538)](t=1e3,r){let c=n,x=e[c(1780)].split("|"),g=0;for(;;){switch(x[g++]){case"0":this[c(698)+c(1681)]?.[c(900)]();continue;case"1":this[c(687)+"ngTimer"]();continue;case"2":this["_dropGlobalEvent"+c(1955)]();continue;case"3":this[c(1757)+c(1566)]=!0;continue;case"4":this[c(1422)+"mer"]();continue;case"5":if(e.tuHWf(this[c(1093)][c(788)+"te"],this[c(924)])||this[c(1093)][c(788)+"te"]===this[c(1796)])return void this._debug(e[c(953)]);continue;case"6":if(!this[c(1093)])return void this[c(1020)](e[c(574)]);continue;case"7":this[c(1137)+c(1043)+"t"](t,r);continue}break}}async[n(569)](t,r){let c=n;if(t==null)throw new Error(e[c(1957)]);e[c(1888)](e.eugmK,typeof t)&&(t=JSON[c(1419)+"y"](t)),e[c(1578)](c(1650),typeof t)&&!e[c(1395)](t,ArrayBuffer)&&!(t.buffer&&e.lWLTI(t[c(540)],ArrayBuffer))&&(t=JSON[c(1419)+"y"](t));let x=await e.jOOpJ(us,t),g=e.TcYcb(s0,t),{method:m=0,service:_=this[c(918)][c(1367)],logID:l=this[c(918)][c(602)+c(879)](),headers:S=this[c(918)][c(1495)],payloadEncoding:v=this._options[c(712)+"ncoding"],payloadType:P=this[c(918)][c(1994)+c(875)],logIDNew:R=this._options[c(716)+c(1037)]["enableAu"+c(1405)+c(1469)+"ew"]?e.oOeZn(o,this._options[c(716)+c(1037)].userIp):""}=e[c(681)](r,{});if(!_)throw new Error(e[c(854)]);let B={SeqID:K[c(1198)+"er"](this[c(1619)]++),LogID:K[c(1198)+"er"](l),service:_,method:m,headers:S,payloadEncoding:e.RbmDC(v,Object)?v[c(1830)]?v[c(1830)]:"":v,payloadType:e.Ocyhr(P,Object)?P[c(773)]?P.type:g:P||g,payload:x,LogIDNew:R},z=e[c(759)](se,B);return this._ws&&e[c(1807)](this[c(1093)][c(788)+"te"],this[c(1248)])?(this._ws&&this._ws[c(569)](z),this[c(1020)](c(1303),B)):e.eKfeU(this[c(1415)+c(685)].length,this[c(918)][c(1366)+c(1436)+c(976)])?(this[c(1415)+"Queue"][c(946)](z),this[c(1020)](e.tEeWX,B)):(this["_message"+c(685)].shift(),this[c(1415)+c(685)][c(946)](z)),{seqID:this[c(1619)],logID:l,logIDNew:R}}async[n(1778)+"t"](t){let r=n;if(r(468)!==r(468)){let c=new _0x497faf(e[r(515)](_0x102ab5,_0x33c5ff));return e[r(1239)](_0x58d89f,_0x1844bc,c,0),c}else{let{url:c}=e[r(681)](t,{}),x=Array.isArray(c)?c:e[r(1106)]==typeof c?[c]:[];t&&Object[r(1625)](this._options,t),x&&x.length?this[r(1008)+r(1426)]=new as(x,this[r(918)][r(938)+"es"]):this[r(1008)+r(1426)]?.["resetEnd"+r(1618)+r(893)](),this[r(1142)+r(1539)]?.[r(473)+r(453)](this[r(918)][r(1331)+r(534)]),this[r(1757)+r(1566)]=!1,this[r(1093)]&&e[r(532)](this._ws.readyState,this[r(924)])?this[r(1685)+r(1795)](1e3,e[r(1737)],!0):(this[r(1682)]=!0,this[r(1399)]())}}async connect(){let t=n;if(e[t(1787)](e[t(1103)],e.tojus))this.emit(e[t(481)],_0x1a5024),this[t(1139)]&&this[t(1139)](_0x106181);else if(!this[t(1399)+t(557)]){let r=e.TXHzV[t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":this[t(1142)+t(1539)]?.[t(473)+t(453)]();continue;case"1":this._isInit=!0;continue;case"2":this["_endpoin"+t(1426)]?.[t(1971)+t(1618)+"fig"]();continue;case"3":this._connect();continue;case"4":this[t(1757)+t(1566)]=!1;continue}break}}}addEventListener(t,r){let c=n,x={LrbDi:function(g,m,_){return g(m,_)},fuHxd:e.zXGMW};e.derwt===e[c(1269)]?this.emit(c(699),TUMeZz[c(886)](_0x5e1d29,TUMeZz[c(1310)],{..._0x1dfc63,data:_0x2f7eb4.errMsg||""})):this.on(t,r)}[n(1045)+"Event"](t){let{type:r}=t;this.emit(r,t)}[n(1210)+n(607)+n(622)](t,r){this[n(1895)](t,r)}[n(601)](){let t=n,r={zyhUl:function(c,x){return c(x)},JqncD:e[t(836)],vYGms:e.uWZPZ,lEInh:function(c,x){return c(x)},fPZga:e[t(2002)],RKgwu:function(c,x,g){return c(x,g)}};return new Promise((c,x)=>{let g=t;this[g(687)+"ngTimer"](),this._pingPongTimeoutId=r[g(1959)](setTimeout,this[g(539)][g(935)](this),this[g(918)][g(1012)+g(746)]);let m=()=>{let l=g;r[l(1999)](c,r.JqncD),this.off(l(1374)+l(1170)+"s",m),this[l(1895)](r.vYGms,_)},_=()=>{let l=g;r.lEInh(x,"timeout"),this[l(1895)](r.fPZga,m),this[l(1895)](r[l(1777)],_)};this.on("ping_onc"+g(1170)+"s",m),this.on(r[g(1777)],_),this[g(539)]()})}}})(),Y[C(1475)+C(1179)]=re[C(1475)+C(1179)],Y[C(638)+C(802)]=re[C(638)+C(802)],Y[C(906)+"e"]=re[C(906)+"e"],Y[C(1941)]=re.Event,Y[C(796)]=re.FWS,Y[C(920)+"MessageE"+C(2006)]=re[C(920)+C(1354)+C(2006)],Y[C(1354)+C(2006)]=re[C(1354)+C(2006)],Y[C(1040)+"t"]=re[C(1040)+"t"],Y["Reconnec"+C(950)]=re.ReconnectEvent,Y[C(701)+"oseEvent"]=re[C(701)+C(1179)],Y[C(1100)+C(802)]=re[C(1100)+C(802)],Y[C(499)+C(822)+"nt"]=re[C(499)+"ssageEvent"],Y[C(1899)+C(1701)]=re["createOp"+C(1701)],Y[C(465)+C(1835)+"vent"]=re[C(465)+C(1835)+"vent"],Y[C(1384)+C(753)]=re[C(1384)+"rame"],Y["encodeFr"+C(597)]=re[C(525)+C(597)];for(Qn in re)[C(1475)+"oseEvent",C(638)+C(802),"ErrorCode",C(1941),C(796),"Frontier"+C(1354)+C(2006),"MessageE"+C(2006),C(1040)+"t","Reconnec"+C(950),C(701)+C(1179),"createEr"+C(802),C(499)+"ssageEvent",C(1899)+C(1701),C(465)+C(1835)+C(2006),C(1384)+"rame","encodeFrame"].indexOf(Qn)===-1&&(Y[Qn]=re[Qn]);var Qn;Object[C(1990)+"operty"](Y,C(513)+"le",{value:!0})});var Ve=ve((S_,ua)=>{"use strict";var xa=["nodebuffer","arraybuffer","fragments"],da=typeof Blob<"u";da&&xa.push("blob");ua.exports={BINARY_TYPES:xa,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:da,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var dn=ve((E_,or)=>{"use strict";var{EMPTY_BUFFER:bf}=Ve(),gi=Buffer[Symbol.species];function vf(n,e){if(n.length===0)return bf;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let a=0;a<n.length;a++){let d=n[a];s.set(d,o),o+=d.length}return o<e?new gi(s.buffer,s.byteOffset,o):s}function fa(n,e,s,o,a){for(let d=0;d<a;d++)s[o+d]=n[d]^e[d&3]}function la(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function Sf(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function pi(n){if(pi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new gi(n):ArrayBuffer.isView(n)?e=new gi(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),pi.readOnly=!1),e}or.exports={concat:vf,mask:fa,toArrayBuffer:Sf,toBuffer:pi,unmask:la};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ne("bufferutil");or.exports.mask=function(e,s,o,a,d){d<48?fa(e,s,o,a,d):n.mask(e,s,o,a,d)},or.exports.unmask=function(e,s){e.length<32?la(e,s):n.unmask(e,s)}}catch{}});var ha=ve((A_,pa)=>{"use strict";var ga=Symbol("kDone"),hi=Symbol("kRun"),mi=class{constructor(e){this[ga]=()=>{this.pending--,this[hi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[hi]()}[hi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ga])}}};pa.exports=mi});var Ut=ve((I_,ya)=>{"use strict";var un=ne("zlib"),ma=dn(),Ef=ha(),{kStatusCode:wa}=Ve(),Af=Buffer[Symbol.species],If=Buffer.from([0,0,255,255]),cr=Symbol("permessage-deflate"),Xe=Symbol("total-length"),zt=Symbol("callback"),xt=Symbol("buffers"),Ft=Symbol("error"),ar,wi=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,!ar){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ar=new Ef(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[zt];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(a=>!(s.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>a.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!a.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 a=s[o];if(a.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(a=a[0],o==="client_max_window_bits"){if(a!==!0){let d=+a;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=d}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else if(o==="server_max_window_bits"){let d=+a;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=d}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else throw new Error(`Unknown parameter "${o}"`);s[o]=a})}),e}decompress(e,s,o){ar.add(a=>{this._decompress(e,s,(d,u)=>{a(),o(d,u)})})}compress(e,s,o){ar.add(a=>{this._compress(e,s,(d,u)=>{a(),o(d,u)})})}_decompress(e,s,o){let a=this._isServer?"client":"server";if(!this._inflate){let d=`${a}_max_window_bits`,u=typeof this.params[d]!="number"?un.Z_DEFAULT_WINDOWBITS:this.params[d];this._inflate=un.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[cr]=this,this._inflate[Xe]=0,this._inflate[xt]=[],this._inflate.on("error",Pf),this._inflate.on("data",_a)}this._inflate[zt]=o,this._inflate.write(e),s&&this._inflate.write(If),this._inflate.flush(()=>{let d=this._inflate[Ft];if(d){this._inflate.close(),this._inflate=null,o(d);return}let u=ma.concat(this._inflate[xt],this._inflate[Xe]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Xe]=0,this._inflate[xt]=[],s&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,s,o){let a=this._isServer?"server":"client";if(!this._deflate){let d=`${a}_max_window_bits`,u=typeof this.params[d]!="number"?un.Z_DEFAULT_WINDOWBITS:this.params[d];this._deflate=un.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[Xe]=0,this._deflate[xt]=[],this._deflate.on("data",Tf)}this._deflate[zt]=o,this._deflate.write(e),this._deflate.flush(un.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let d=ma.concat(this._deflate[xt],this._deflate[Xe]);s&&(d=new Af(d.buffer,d.byteOffset,d.length-4)),this._deflate[zt]=null,this._deflate[Xe]=0,this._deflate[xt]=[],s&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),o(null,d)})}};ya.exports=wi;function Tf(n){this[xt].push(n),this[Xe]+=n.length}function _a(n){if(this[Xe]+=n.length,this[cr]._maxPayload<1||this[Xe]<=this[cr]._maxPayload){this[xt].push(n);return}this[Ft]=new RangeError("Max payload size exceeded"),this[Ft].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ft][wa]=1009,this.removeListener("data",_a),this.reset()}function Pf(n){if(this[cr]._inflate=null,this[Ft]){this[zt](this[Ft]);return}n[wa]=1007,this[zt](n)}});var qt=ve((T_,xr)=>{"use strict";var{isUtf8:ba}=ne("buffer"),{hasBlob:Cf}=Ve(),kf=[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 Df(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function _i(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 Rf(n){return Cf&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}xr.exports={isBlob:Rf,isValidStatusCode:Df,isValidUTF8:_i,tokenChars:kf};if(ba)xr.exports.isValidUTF8=function(n){return n.length<24?_i(n):ba(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ne("utf-8-validate");xr.exports.isValidUTF8=function(e){return e.length<32?_i(e):n(e)}}catch{}});var Ei=ve((P_,Pa)=>{"use strict";var{Writable:Of}=ne("stream"),va=Ut(),{BINARY_TYPES:Nf,EMPTY_BUFFER:Sa,kStatusCode:Lf,kWebSocket:Mf}=Ve(),{concat:yi,toArrayBuffer:Bf,unmask:zf}=dn(),{isValidStatusCode:Ff,isValidUTF8:Ea}=qt(),dr=Buffer[Symbol.species],Pe=0,Aa=1,Ia=2,Ta=3,bi=4,vi=5,ur=6,Si=class extends Of{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Nf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Mf]=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=Pe}_write(e,s,o){if(this._opcode===8&&this._state==Pe)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 dr(o.buffer,o.byteOffset+e,o.length-e),new dr(o.buffer,o.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let o=this._buffers[0],a=s.length-e;e>=o.length?s.set(this._buffers.shift(),a):(s.set(new Uint8Array(o.buffer,o.byteOffset,e),a),this._buffers[0]=new dr(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 Pe:this.getInfo(e);break;case Aa:this.getPayloadLength16(e);break;case Ia:this.getPayloadLength64(e);break;case Ta:this.getMask();break;case bi:this.getData(e);break;case vi:case ur: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 a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let o=(s[0]&64)===64;if(o&&!this._extensions[va.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=Aa:this._payloadLength===127?this._state=Ia: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 a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=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=Ta:this._state=bi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=bi}getData(e){let s=Sa;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&&zf(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=vi,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[va.extensionName].decompress(e,this._fin,(a,d)=>{if(a)return s(a);if(d.length){if(this._messageLength+=d.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(u);return}this._fragments.push(d)}this.dataMessage(s),this._state===Pe&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=Pe;return}let s=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let a;this._binaryType==="nodebuffer"?a=yi(o,s):this._binaryType==="arraybuffer"?a=Bf(yi(o,s)):this._binaryType==="blob"?a=new Blob(o):a=o,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=Pe):(this._state=ur,setImmediate(()=>{this.emit("message",a,!0),this._state=Pe,this.startLoop(e)}))}else{let a=yi(o,s);if(!this._skipUTF8Validation&&!Ea(a)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(d);return}this._state===vi||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=Pe):(this._state=ur,setImmediate(()=>{this.emit("message",a,!1),this._state=Pe,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Sa),this.end();else{let o=e.readUInt16BE(0);if(!Ff(o)){let d=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(d);return}let a=new dr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ea(a)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(d);return}this._loop=!1,this.emit("conclude",o,a),this.end()}this._state=Pe;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe):(this._state=ur,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe,this.startLoop(s)}))}createError(e,s,o,a,d){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(u,this.createError),u.code=d,u[Lf]=a,u}};Pa.exports=Si});var Ti=ve((k_,Da)=>{"use strict";var{Duplex:C_}=ne("stream"),{randomFillSync:Uf}=ne("crypto"),Ca=Ut(),{EMPTY_BUFFER:qf,kWebSocket:Gf,NOOP:jf}=Ve(),{isBlob:Gt,isValidStatusCode:Hf}=qt(),{mask:ka,toBuffer:gt}=dn(),Ce=Symbol("kByteLength"),Kf=Buffer.alloc(4),fr=8*1024,pt,jt=fr,Re=0,Wf=1,$f=2,Ai=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=Re,this.onerror=jf,this[Gf]=void 0}static frame(e,s){let o,a=!1,d=2,u=!1;s.mask&&(o=s.maskBuffer||Kf,s.generateMask?s.generateMask(o):(jt===fr&&(pt===void 0&&(pt=Buffer.alloc(fr)),Uf(pt,0,fr),jt=0),o[0]=pt[jt++],o[1]=pt[jt++],o[2]=pt[jt++],o[3]=pt[jt++]),u=(o[0]|o[1]|o[2]|o[3])===0,d=6);let f;typeof e=="string"?(!s.mask||u)&&s[Ce]!==void 0?f=s[Ce]:(e=Buffer.from(e),f=e.length):(f=e.length,a=s.mask&&s.readOnly&&!u);let p=f;f>=65536?(d+=8,p=127):f>125&&(d+=2,p=126);let h=Buffer.allocUnsafe(a?f+d:d);return h[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(h[0]|=64),h[1]=p,p===126?h.writeUInt16BE(f,2):p===127&&(h[2]=h[3]=0,h.writeUIntBE(f,4,6)),s.mask?(h[1]|=128,h[d-4]=o[0],h[d-3]=o[1],h[d-2]=o[2],h[d-1]=o[3],u?[h,e]:a?(ka(e,o,h,d,f),[h]):(ka(e,o,e,0,f),[h,e])):[h,e]}close(e,s,o,a){let d;if(e===void 0)d=qf;else{if(typeof e!="number"||!Hf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)d=Buffer.allocUnsafe(2),d.writeUInt16BE(e,0);else{let f=Buffer.byteLength(s);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");d=Buffer.allocUnsafe(2+f),d.writeUInt16BE(e,0),typeof s=="string"?d.write(s,2):d.set(s,2)}}let u={[Ce]:d.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Re?this.enqueue([this.dispatch,d,!1,u,a]):this.sendFrame(n.frame(d,u),a)}ping(e,s,o){let a,d;if(typeof e=="string"?(a=Buffer.byteLength(e),d=!1):Gt(e)?(a=e.size,d=!1):(e=gt(e),a=e.length,d=gt.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Ce]:a,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:d,rsv1:!1};Gt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,s,o){let a,d;if(typeof e=="string"?(a=Buffer.byteLength(e),d=!1):Gt(e)?(a=e.size,d=!1):(e=gt(e),a=e.length,d=gt.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Ce]:a,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:d,rsv1:!1};Gt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,s,o){let a=this._extensions[Ca.extensionName],d=s.binary?2:1,u=s.compress,f,p;typeof e=="string"?(f=Buffer.byteLength(e),p=!1):Gt(e)?(f=e.size,p=!1):(e=gt(e),f=e.length,p=gt.readOnly),this._firstFragment?(this._firstFragment=!1,u&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=f>=a._threshold),this._compress=u):(u=!1,d=0),s.fin&&(this._firstFragment=!0);let h={[Ce]:f,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:d,readOnly:p,rsv1:u};Gt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,this._compress,h,o]):this.getBlobData(e,this._compress,h,o):this._state!==Re?this.enqueue([this.dispatch,e,this._compress,h,o]):this.dispatch(e,this._compress,h,o)}getBlobData(e,s,o,a){this._bufferedBytes+=o[Ce],this._state=$f,e.arrayBuffer().then(d=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Ii,this,f,a);return}this._bufferedBytes-=o[Ce];let u=gt(d);s?this.dispatch(u,s,o,a):(this._state=Re,this.sendFrame(n.frame(u,o),a),this.dequeue())}).catch(d=>{process.nextTick(Jf,this,d,a)})}dispatch(e,s,o,a){if(!s){this.sendFrame(n.frame(e,o),a);return}let d=this._extensions[Ca.extensionName];this._bufferedBytes+=o[Ce],this._state=Wf,d.compress(e,o.fin,(u,f)=>{if(this._socket.destroyed){let p=new Error("The socket was closed while data was being compressed");Ii(this,p,a);return}this._bufferedBytes-=o[Ce],this._state=Re,o.readOnly=!1,this.sendFrame(n.frame(f,o),a),this.dequeue()})}dequeue(){for(;this._state===Re&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Ce],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Ce],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)}};Da.exports=Ai;function Ii(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let a=n._queue[o],d=a[a.length-1];typeof d=="function"&&d(e)}}function Jf(n,e,s){Ii(n,e,s),n.onerror(e)}});var Ua=ve((D_,Fa)=>{"use strict";var{kForOnEventAttribute:fn,kListener:Pi}=Ve(),Ra=Symbol("kCode"),Oa=Symbol("kData"),Na=Symbol("kError"),La=Symbol("kMessage"),Ma=Symbol("kReason"),Ht=Symbol("kTarget"),Ba=Symbol("kType"),za=Symbol("kWasClean"),Ye=class{constructor(e){this[Ht]=null,this[Ba]=e}get target(){return this[Ht]}get type(){return this[Ba]}};Object.defineProperty(Ye.prototype,"target",{enumerable:!0});Object.defineProperty(Ye.prototype,"type",{enumerable:!0});var ht=class extends Ye{constructor(e,s={}){super(e),this[Ra]=s.code===void 0?0:s.code,this[Ma]=s.reason===void 0?"":s.reason,this[za]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Ra]}get reason(){return this[Ma]}get wasClean(){return this[za]}};Object.defineProperty(ht.prototype,"code",{enumerable:!0});Object.defineProperty(ht.prototype,"reason",{enumerable:!0});Object.defineProperty(ht.prototype,"wasClean",{enumerable:!0});var Kt=class extends Ye{constructor(e,s={}){super(e),this[Na]=s.error===void 0?null:s.error,this[La]=s.message===void 0?"":s.message}get error(){return this[Na]}get message(){return this[La]}};Object.defineProperty(Kt.prototype,"error",{enumerable:!0});Object.defineProperty(Kt.prototype,"message",{enumerable:!0});var ln=class extends Ye{constructor(e,s={}){super(e),this[Oa]=s.data===void 0?null:s.data}get data(){return this[Oa]}};Object.defineProperty(ln.prototype,"data",{enumerable:!0});var Vf={addEventListener(n,e,s={}){for(let a of this.listeners(n))if(!s[fn]&&a[Pi]===e&&!a[fn])return;let o;if(n==="message")o=function(d,u){let f=new ln("message",{data:u?d:d.toString()});f[Ht]=this,lr(e,this,f)};else if(n==="close")o=function(d,u){let f=new ht("close",{code:d,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Ht]=this,lr(e,this,f)};else if(n==="error")o=function(d){let u=new Kt("error",{error:d,message:d.message});u[Ht]=this,lr(e,this,u)};else if(n==="open")o=function(){let d=new Ye("open");d[Ht]=this,lr(e,this,d)};else return;o[fn]=!!s[fn],o[Pi]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[Pi]===e&&!s[fn]){this.removeListener(n,s);break}}};Fa.exports={CloseEvent:ht,ErrorEvent:Kt,Event:Ye,EventTarget:Vf,MessageEvent:ln};function lr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var gr=ve((R_,qa)=>{"use strict";var{tokenChars:gn}=qt();function je(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function Xf(n){let e=Object.create(null),s=Object.create(null),o=!1,a=!1,d=!1,u,f,p=-1,h=-1,y=-1,w=0;for(;w<n.length;w++)if(h=n.charCodeAt(w),u===void 0)if(y===-1&&gn[h]===1)p===-1&&(p=w);else if(w!==0&&(h===32||h===9))y===-1&&p!==-1&&(y=w);else if(h===59||h===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${w}`);y===-1&&(y=w);let I=n.slice(p,y);h===44?(je(e,I,s),s=Object.create(null)):u=I,p=y=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(f===void 0)if(y===-1&&gn[h]===1)p===-1&&(p=w);else if(h===32||h===9)y===-1&&p!==-1&&(y=w);else if(h===59||h===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${w}`);y===-1&&(y=w),je(s,n.slice(p,y),!0),h===44&&(je(e,u,s),s=Object.create(null),u=void 0),p=y=-1}else if(h===61&&p!==-1&&y===-1)f=n.slice(p,w),p=y=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(a){if(gn[h]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);p===-1?p=w:o||(o=!0),a=!1}else if(d)if(gn[h]===1)p===-1&&(p=w);else if(h===34&&p!==-1)d=!1,y=w;else if(h===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(h===34&&n.charCodeAt(w-1)===61)d=!0;else if(y===-1&&gn[h]===1)p===-1&&(p=w);else if(p!==-1&&(h===32||h===9))y===-1&&(y=w);else if(h===59||h===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${w}`);y===-1&&(y=w);let I=n.slice(p,y);o&&(I=I.replace(/\\/g,""),o=!1),je(s,f,I),h===44&&(je(e,u,s),s=Object.create(null),u=void 0),f=void 0,p=y=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(p===-1||d||h===32||h===9)throw new SyntaxError("Unexpected end of input");y===-1&&(y=w);let A=n.slice(p,y);return u===void 0?je(e,A,s):(f===void 0?je(s,A,!0):o?je(s,f,A.replace(/\\/g,"")):je(s,f,A),je(e,u,s)),e}function Yf(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(a=>{let d=o[a];return Array.isArray(d)||(d=[d]),d.map(u=>u===!0?a:`${a}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}qa.exports={format:Yf,parse:Xf}});var wr=ve((L_,Qa)=>{"use strict";var Zf=ne("events"),Qf=ne("https"),el=ne("http"),Ha=ne("net"),tl=ne("tls"),{randomBytes:nl,createHash:rl}=ne("crypto"),{Duplex:O_,Readable:N_}=ne("stream"),{URL:Ci}=ne("url"),dt=Ut(),il=Ei(),sl=Ti(),{isBlob:ol}=qt(),{BINARY_TYPES:Ga,CLOSE_TIMEOUT:al,EMPTY_BUFFER:pr,GUID:cl,kForOnEventAttribute:ki,kListener:xl,kStatusCode:dl,kWebSocket:xe,NOOP:Ka}=Ve(),{EventTarget:{addEventListener:ul,removeEventListener:fl}}=Ua(),{format:ll,parse:gl}=gr(),{toBuffer:pl}=dn(),Wa=Symbol("kAborted"),Di=[8,13],Ze=["CONNECTING","OPEN","CLOSING","CLOSED"],hl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,V=class n extends Zf{constructor(e,s,o){super(),this._binaryType=Ga[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=pr,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]),$a(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ga.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 a=new il({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),d=new sl(e,this._extensions,o.generateMask);this._receiver=a,this._sender=d,this._socket=e,a[xe]=this,d[xe]=this,e[xe]=this,a.on("conclude",_l),a.on("drain",yl),a.on("error",bl),a.on("message",vl),a.on("ping",Sl),a.on("pong",El),d.onerror=Al,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Xa),e.on("data",mr),e.on("end",Ya),e.on("error",Za),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[dt.extensionName]&&this._extensions[dt.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){Ae(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())}),Va(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){Ri(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||pr,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){Ri(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||pr,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){Ri(this,e,o);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[dt.extensionName]||(a.compress=!1),this._sender.send(e||pr,a,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ae(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(V,"CONNECTING",{enumerable:!0,value:Ze.indexOf("CONNECTING")});Object.defineProperty(V.prototype,"CONNECTING",{enumerable:!0,value:Ze.indexOf("CONNECTING")});Object.defineProperty(V,"OPEN",{enumerable:!0,value:Ze.indexOf("OPEN")});Object.defineProperty(V.prototype,"OPEN",{enumerable:!0,value:Ze.indexOf("OPEN")});Object.defineProperty(V,"CLOSING",{enumerable:!0,value:Ze.indexOf("CLOSING")});Object.defineProperty(V.prototype,"CLOSING",{enumerable:!0,value:Ze.indexOf("CLOSING")});Object.defineProperty(V,"CLOSED",{enumerable:!0,value:Ze.indexOf("CLOSED")});Object.defineProperty(V.prototype,"CLOSED",{enumerable:!0,value:Ze.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(V.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(V.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[ki])return e[xl];return null},set(e){for(let s of this.listeners(n))if(s[ki]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[ki]:!0})}})});V.prototype.addEventListener=ul;V.prototype.removeEventListener=fl;Qa.exports=V;function $a(n,e,s,o){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:al,protocolVersion:Di[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=a.autoPong,n._closeTimeout=a.closeTimeout,!Di.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${Di.join(", ")})`);let d;if(e instanceof Ci)d=e;else try{d=new Ci(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}d.protocol==="http:"?d.protocol="ws:":d.protocol==="https:"&&(d.protocol="wss:"),n._url=d.href;let u=d.protocol==="wss:",f=d.protocol==="ws+unix:",p;if(d.protocol!=="ws:"&&!u&&!f?p=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!d.pathname?p="The URL's pathname is empty":d.hash&&(p="The URL contains a fragment identifier"),p){let k=new SyntaxError(p);if(n._redirects===0)throw k;hr(n,k);return}let h=u?443:80,y=nl(16).toString("base64"),w=u?Qf.request:el.request,A=new Set,I;if(a.createConnection=a.createConnection||(u?wl:ml),a.defaultPort=a.defaultPort||h,a.port=d.port||h,a.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":y,Connection:"Upgrade",Upgrade:"websocket"},a.path=d.pathname+d.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(I=new dt({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=ll({[dt.extensionName]:I.offer()})),s.length){for(let k of s){if(typeof k!="string"||!hl.test(k)||A.has(k))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(k)}a.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(d.username||d.password)&&(a.auth=`${d.username}:${d.password}`),f){let k=a.path.split(":");a.socketPath=k[0],a.path=k[1]}let E;if(a.followRedirects){if(n._redirects===0){n._originalIpc=f,n._originalSecure=u,n._originalHostOrSocketPath=f?a.socketPath:d.host;let k=o&&o.headers;if(o={...o,headers:{}},k)for(let[L,$]of Object.entries(k))o.headers[L.toLowerCase()]=$}else if(n.listenerCount("redirect")===0){let k=f?n._originalIpc?a.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:d.host===n._originalHostOrSocketPath;(!k||n._originalSecure&&!u)&&(delete a.headers.authorization,delete a.headers.cookie,k||delete a.headers.host,a.auth=void 0)}a.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),E=n._req=w(a),n._redirects&&n.emit("redirect",n.url,E)}else E=n._req=w(a);a.timeout&&E.on("timeout",()=>{Ae(n,E,"Opening handshake has timed out")}),E.on("error",k=>{E===null||E[Wa]||(E=n._req=null,hr(n,k))}),E.on("response",k=>{let L=k.headers.location,$=k.statusCode;if(L&&a.followRedirects&&$>=300&&$<400){if(++n._redirects>a.maxRedirects){Ae(n,E,"Maximum redirects exceeded");return}E.abort();let H;try{H=new Ci(L,e)}catch{let W=new SyntaxError(`Invalid URL: ${L}`);hr(n,W);return}$a(n,H,s,o)}else n.emit("unexpected-response",E,k)||Ae(n,E,`Unexpected server response: ${k.statusCode}`)}),E.on("upgrade",(k,L,$)=>{if(n.emit("upgrade",k),n.readyState!==V.CONNECTING)return;E=n._req=null;let H=k.headers.upgrade;if(H===void 0||H.toLowerCase()!=="websocket"){Ae(n,L,"Invalid Upgrade header");return}let ae=rl("sha1").update(y+cl).digest("base64");if(k.headers["sec-websocket-accept"]!==ae){Ae(n,L,"Invalid Sec-WebSocket-Accept header");return}let W=k.headers["sec-websocket-protocol"],ge;if(W!==void 0?A.size?A.has(W)||(ge="Server sent an invalid subprotocol"):ge="Server sent a subprotocol but none was requested":A.size&&(ge="Server sent no subprotocol"),ge){Ae(n,L,ge);return}W&&(n._protocol=W);let _e=k.headers["sec-websocket-extensions"];if(_e!==void 0){if(!I){Ae(n,L,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ke;try{ke=gl(_e)}catch{Ae(n,L,"Invalid Sec-WebSocket-Extensions header");return}let de=Object.keys(ke);if(de.length!==1||de[0]!==dt.extensionName){Ae(n,L,"Server indicated an extension that was not requested");return}try{I.accept(ke[dt.extensionName])}catch{Ae(n,L,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[dt.extensionName]=I}n.setSocket(L,$,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(E,n):E.end()}function hr(n,e){n._readyState=V.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function ml(n){return n.path=n.socketPath,Ha.connect(n)}function wl(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Ha.isIP(n.host)?"":n.host),tl.connect(n)}function Ae(n,e,s){n._readyState=V.CLOSING;let o=new Error(s);Error.captureStackTrace(o,Ae),e.setHeader?(e[Wa]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(hr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Ri(n,e,s){if(e){let o=ol(e)?e.size:pl(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ze[n.readyState]})`);process.nextTick(s,o)}}function _l(n,e){let s=this[xe];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[xe]!==void 0&&(s._socket.removeListener("data",mr),process.nextTick(Ja,s._socket),n===1005?s.close():s.close(n,e))}function yl(){let n=this[xe];n.isPaused||n._socket.resume()}function bl(n){let e=this[xe];e._socket[xe]!==void 0&&(e._socket.removeListener("data",mr),process.nextTick(Ja,e._socket),e.close(n[dl])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function ja(){this[xe].emitClose()}function vl(n,e){this[xe].emit("message",n,e)}function Sl(n){let e=this[xe];e._autoPong&&e.pong(n,!this._isServer,Ka),e.emit("ping",n)}function El(n){this[xe].emit("pong",n)}function Ja(n){n.resume()}function Al(n){let e=this[xe];e.readyState!==V.CLOSED&&(e.readyState===V.OPEN&&(e._readyState=V.CLOSING,Va(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Va(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function Xa(){let n=this[xe];if(this.removeListener("close",Xa),this.removeListener("data",mr),this.removeListener("end",Ya),n._readyState=V.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[xe]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",ja),n._receiver.on("finish",ja))}function mr(n){this[xe]._receiver.write(n)||this.pause()}function Ya(){let n=this[xe];n._readyState=V.CLOSING,n._receiver.end(),this.end()}function Za(){let n=this[xe];this.removeListener("error",Za),this.on("error",Ka),n&&(n._readyState=V.CLOSING,this.destroy())}});var rc=ve((B_,nc)=>{"use strict";var M_=wr(),{Duplex:Il}=ne("stream");function ec(n){n.emit("close")}function Tl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function tc(n){this.removeListener("error",tc),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function Pl(n,e){let s=!0,o=new Il({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(d,u){let f=!u&&o._readableState.objectMode?d.toString():d;o.push(f)||n.pause()}),n.once("error",function(d){o.destroyed||(s=!1,o.destroy(d))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(a,d){if(n.readyState===n.CLOSED){d(a),process.nextTick(ec,o);return}let u=!1;n.once("error",function(p){u=!0,d(p)}),n.once("close",function(){u||d(a),process.nextTick(ec,o)}),s&&n.terminate()},o._final=function(a){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(a)});return}n._socket!==null&&(n._socket._writableState.finished?(a(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){a()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(a,d,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(a,d,u)});return}n.send(a,u)},o.on("end",Tl),o.on("error",tc),o}nc.exports=Pl});var Oi=ve((z_,ic)=>{"use strict";var{tokenChars:Cl}=qt();function kl(n){let e=new Set,s=-1,o=-1,a=0;for(a;a<n.length;a++){let u=n.charCodeAt(a);if(o===-1&&Cl[u]===1)s===-1&&(s=a);else if(a!==0&&(u===32||u===9))o===-1&&s!==-1&&(o=a);else if(u===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${a}`);o===-1&&(o=a);let f=n.slice(s,o);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let d=n.slice(s,a);if(e.has(d))throw new SyntaxError(`The "${d}" subprotocol is duplicated`);return e.add(d),e}ic.exports={parse:kl}});var uc=ve((U_,dc)=>{"use strict";var Dl=ne("events"),_r=ne("http"),{Duplex:F_}=ne("stream"),{createHash:Rl}=ne("crypto"),sc=gr(),mt=Ut(),Ol=Oi(),Nl=wr(),{CLOSE_TIMEOUT:Ll,GUID:Ml,kWebSocket:Bl}=Ve(),zl=/^[+/0-9A-Za-z]{22}==$/,oc=0,ac=1,xc=2,Ni=class extends Dl{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Ll,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Nl,...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=_r.createServer((o,a)=>{let d=_r.STATUS_CODES[426];a.writeHead(426,{"Content-Length":d.length,"Content-Type":"text/plain"}),a.end(d)}),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=Fl(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,d,u)=>{this.handleUpgrade(a,d,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=oc}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===xc){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(pn,this);return}if(e&&this.once("close",e),this._state!==ac)if(this._state=ac,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(pn,this):process.nextTick(pn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{pn(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,a){s.on("error",cc);let d=e.headers["sec-websocket-key"],u=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){wt(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){wt(this,e,s,400,"Invalid Upgrade header");return}if(d===void 0||!zl.test(d)){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){hn(s,400);return}let p=e.headers["sec-websocket-protocol"],h=new Set;if(p!==void 0)try{h=Ol.parse(p)}catch{wt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let y=e.headers["sec-websocket-extensions"],w={};if(this.options.perMessageDeflate&&y!==void 0){let A=new mt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let I=sc.parse(y);I[mt.extensionName]&&(A.accept(I[mt.extensionName]),w[mt.extensionName]=A)}catch{wt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(I,E,k,L)=>{if(!I)return hn(s,E||401,k,L);this.completeUpgrade(w,d,h,e,s,o,a)});return}if(!this.options.verifyClient(A))return hn(s,401)}this.completeUpgrade(w,d,h,e,s,o,a)}completeUpgrade(e,s,o,a,d,u,f){if(!d.readable||!d.writable)return d.destroy();if(d[Bl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>oc)return hn(d,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Rl("sha1").update(s+Ml).digest("base64")}`],y=new this.options.WebSocket(null,void 0,this.options);if(o.size){let w=this.options.handleProtocols?this.options.handleProtocols(o,a):o.values().next().value;w&&(h.push(`Sec-WebSocket-Protocol: ${w}`),y._protocol=w)}if(e[mt.extensionName]){let w=e[mt.extensionName].params,A=sc.format({[mt.extensionName]:[w]});h.push(`Sec-WebSocket-Extensions: ${A}`),y._extensions=e}this.emit("headers",h,a),d.write(h.concat(`\r
|
|
8
|
+
var Vd=Object.create;var gi=Object.defineProperty;var Zd=Object.getOwnPropertyDescriptor;var Yd=Object.getOwnPropertyNames;var Xd=Object.getPrototypeOf,Qd=Object.prototype.hasOwnProperty;var ie=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var ze=(n,e)=>()=>(n&&(e=n(n=0)),e);var ee=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),pi=(n,e)=>{for(var i in e)gi(n,i,{get:e[i],enumerable:!0})},ef=(n,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Yd(e))!Qd.call(n,a)&&a!==i&&gi(n,a,{get:()=>e[a],enumerable:!(o=Zd(e,a))||o.enumerable});return n};var We=(n,e,i)=>(i=n!=null?Vd(Xd(n)):{},ef(e||!n||!n.__esModule?gi(i,"default",{value:n,enumerable:!0}):i,n));function Zs(n){return Hn[Js]<=Hn[n]}function qn(n){Vs={...n}}function rf(n){let e=(x,l=2)=>String(x).padStart(l,"0"),i=-n.getTimezoneOffset(),o=i>=0?"+":"-",a=Math.abs(i),c=e(Math.floor(a/60)),f=e(a%60);return`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())}T${e(n.getHours())}:${e(n.getMinutes())}:${e(n.getSeconds())}.${e(n.getMilliseconds(),3)}${o}${c}:${f}`}function Un(n,e,i,o){if(Hn[n]<Hn[Js])return;let a=JSON.stringify({ts:rf(new Date),level:n,module:e,msg:i,...Vs,...o});n==="error"||n==="warn"?nf.write(`${a}
|
|
9
|
+
`):tf.write(`${a}
|
|
10
|
+
`)}function H(n){return{debug:(e,i)=>Un("debug",n,e,i),info:(e,i)=>Un("info",n,e,i),warn:(e,i)=>Un("warn",n,e,i),error:(e,i)=>Un("error",n,e,i),child:e=>H(`${n}.${e}`)}}var Hn,Js,tf,nf,Vs,Y=ze(()=>{"use strict";Hn={debug:10,info:20,warn:30,error:40},Js=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),tf=process.stdout,nf=process.stderr,Vs={}});import{chmod as wf,mkdir as _f,readFile as yf,rename as no,writeFile as ro}from"node:fs/promises";import{dirname as Ef}from"node:path";async function qt(n){try{let e=await yf(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Kn(n,e,i){await _f(Ef(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
|
|
11
|
+
`,a=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{i?.mode!==void 0?await ro(a,o,{encoding:"utf8",mode:i.mode}):await ro(a,o,"utf8"),await no(a,n),i?.mode!==void 0&&await wf(n,i.mode)}catch(c){await no(a,a).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(a,{force:!0}).catch(()=>{}),c}}var $n=ze(()=>{"use strict"});import{promises as io}from"node:fs";import{homedir as vf}from"node:os";import{sep as bf,join as Se,resolve as so}from"node:path";function X(n){let e=n??vf(),i=Se(e,".coze"),o=Se(i,"bridge"),a=Se(o,"lib");return{cozeRoot:i,bridgeRoot:o,libDir:a,libEntry:Se(a,"index.js"),binDir:Se(o,"bin"),pidFile:Se(o,"bridge.pid"),portFile:Se(o,"bridge.port"),tokenFile:Se(o,"bridge.token"),patTokenFile:Se(o,"pat-token"),logFile:Se(o,"bridge.log"),installLock:Se(o,"install.lock"),configFile:Se(o,"config.json"),agentsRoot:Se(i,"agents")}}function it(n,e=X()){let i=Se(e.agentsRoot,n);return{root:i,config:Se(i,"config.json"),workspace:Se(i,"workspace"),logs:Se(i,"logs")}}async function oo(n,e){let i=await io.realpath(so(n)).catch(()=>null);if(!i)return!1;let o=await io.realpath(so(e)).catch(()=>null);if(!o)return!1;let a=process.platform==="win32"?i.toLowerCase():i,c=process.platform==="win32"?o.toLowerCase():o;return a===c||a.startsWith(c+bf)}var ye=ze(()=>{"use strict"});var Zn={};pi(Zn,{AGENT_CONFIG_FILE_MODE:()=>Jn,enforceAgentConfigMode:()=>Cf,loadAgentConfig:()=>Te,persistAgentSessions:()=>hi,persistAgentSkills:()=>Vn,saveAgentConfig:()=>Ne});import{chmod as Sf,stat as If}from"node:fs/promises";function Te(n,e){return qt(it(n,e).config)}function Ne(n,e){return Kn(it(n.agentId,e).config,n,{mode:Jn})}async function Cf(n,e){if(process.platform==="win32")return;let i=it(n,e).config;try{let o=await If(i);if(!o.isFile())return;let a=o.mode&511;a!==Jn&&(await Sf(i,Jn),ao.warn("agent config mode auto-corrected to 0600",{path:i,from:a.toString(8)}))}catch(o){if(o.code==="ENOENT")return;ao.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:i,err:String(o)})}}async function hi(n,e,i){let o=await Te(n,i);o&&(o.sessions=Object.fromEntries(e),await Ne(o,i))}async function Vn(n,e,i){let o=await Te(n,i);o&&(o.skills=e,await Ne(o,i))}var ao,Jn,gt=ze(()=>{"use strict";$n();Y();ye();ao=H("agent-config"),Jn=384});var wi=ee((vm,xo)=>{xo.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Xn=ee(go=>{var lo={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Lf(n){return function(...e){return e.length&&(n=n.replace(/\{(\d)\}/g,(i,o)=>e[o]||"")),new Error("ADM-ZIP: "+n)}}for(let n of Object.keys(lo))go[n]=Lf(lo[n])});var _o=ee((Sm,wo)=>{var Nf=ie("fs"),Ee=ie("path"),po=wi(),Of=Xn(),Mf=typeof process=="object"&&process.platform==="win32",ho=n=>typeof n=="object"&&n!==null,mo=new Uint32Array(256).map((n,e)=>{for(let i=0;i<8;i++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function xe(n){this.sep=Ee.sep,this.fs=Nf,ho(n)&&ho(n.fs)&&typeof n.fs.statSync=="function"&&(this.fs=n.fs)}wo.exports=xe;xe.prototype.makeDir=function(n){let e=this;function i(o){let a=o.split(e.sep)[0];o.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){a+=e.sep+c;var f;try{f=e.fs.statSync(a)}catch(x){if(x.message&&x.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw x}if(f&&f.isFile())throw Of.FILE_IN_THE_WAY(`"${a}"`)}})}i(n)};xe.prototype.writeFileTo=function(n,e,i,o){let a=this;if(a.fs.existsSync(n)){if(!i)return!1;var c=a.fs.statSync(n);if(c.isDirectory())return!1}var f=Ee.dirname(n);a.fs.existsSync(f)||a.makeDir(f);var x;try{x=a.fs.openSync(n,"w",438)}catch{a.fs.chmodSync(n,438),x=a.fs.openSync(n,"w",438)}if(x)try{a.fs.writeSync(x,e,0,e.length,0)}finally{a.fs.closeSync(x)}return a.fs.chmodSync(n,o||438),!0};xe.prototype.writeFileToAsync=function(n,e,i,o,a){typeof o=="function"&&(a=o,o=void 0);let c=this;c.fs.exists(n,function(f){if(f&&!i)return a(!1);c.fs.stat(n,function(x,l){if(f&&l.isDirectory())return a(!1);var h=Ee.dirname(n);c.fs.exists(h,function(y){y||c.makeDir(h),c.fs.open(n,"w",438,function(v,k){v?c.fs.chmod(n,438,function(){c.fs.open(n,"w",438,function(w,E){c.fs.write(E,e,0,e.length,0,function(){c.fs.close(E,function(){c.fs.chmod(n,o||438,function(){a(!0)})})})})}):k?c.fs.write(k,e,0,e.length,0,function(){c.fs.close(k,function(){c.fs.chmod(n,o||438,function(){a(!0)})})}):c.fs.chmod(n,o||438,function(){a(!0)})})})})})};xe.prototype.findFiles=function(n){let e=this;function i(o,a,c){typeof a=="boolean"&&(c=a,a=void 0);let f=[];return e.fs.readdirSync(o).forEach(function(x){let l=Ee.join(o,x),h=e.fs.statSync(l);(!a||a.test(l))&&f.push(Ee.normalize(l)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(f=f.concat(i(l,a,c)))}),f}return i(n,void 0,!0)};xe.prototype.findFilesAsync=function(n,e){let i=this,o=[];i.fs.readdir(n,function(a,c){if(a)return e(a);let f=c.length;if(!f)return e(null,o);c.forEach(function(x){x=Ee.join(n,x),i.fs.stat(x,function(l,h){if(l)return e(l);h&&(o.push(Ee.normalize(x)+(h.isDirectory()?i.sep:"")),h.isDirectory()?i.findFilesAsync(x,function(y,v){if(y)return e(y);o=o.concat(v),--f||e(null,o)}):--f||e(null,o))})})})};xe.prototype.getAttributes=function(){};xe.prototype.setAttributes=function(){};xe.crc32update=function(n,e){return mo[(n^e)&255]^n>>>8};xe.crc32=function(n){typeof n=="string"&&(n=Buffer.from(n,"utf8"));let e=n.length,i=-1;for(let o=0;o<e;)i=xe.crc32update(i,n[o++]);return~i>>>0};xe.methodToString=function(n){switch(n){case po.STORED:return"STORED ("+n+")";case po.DEFLATED:return"DEFLATED ("+n+")";default:return"UNSUPPORTED ("+n+")"}};xe.canonical=function(n){if(!n)return"";let e=Ee.posix.normalize("/"+n.split("\\").join("/"));return Ee.join(".",e)};xe.zipnamefix=function(n){if(!n)return"";let e=Ee.posix.normalize("/"+n.split("\\").join("/"));return Ee.posix.join(".",e)};xe.findLast=function(n,e){if(!Array.isArray(n))throw new TypeError("arr is not array");let i=n.length>>>0;for(let o=i-1;o>=0;o--)if(e(n[o],o,n))return n[o]};xe.sanitize=function(n,e){n=Ee.resolve(Ee.normalize(n));for(var i=e.split("/"),o=0,a=i.length;o<a;o++){var c=Ee.normalize(Ee.join(n,i.slice(o,a).join(Ee.sep)));if(c.indexOf(n)===0)return c}return Ee.normalize(Ee.join(n,Ee.basename(e)))};xe.toBuffer=function(e,i){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?i(e):Buffer.alloc(0)};xe.readBigUInt64LE=function(n,e){let i=n.readUInt32LE(e);return n.readUInt32LE(e+4)*4294967296+i};xe.fromDOS2Date=function(n){return new Date((n>>25&127)+1980,Math.max((n>>21&15)-1,0),Math.max(n>>16&31,1),n>>11&31,n>>5&63,(n&31)<<1)};xe.fromDate2DOS=function(n){let e=0,i=0;return n.getFullYear()>1979&&(e=(n.getFullYear()-1980&127)<<9|n.getMonth()+1<<5|n.getDate(),i=n.getHours()<<11|n.getMinutes()<<5|n.getSeconds()>>1),e<<16|i};xe.isWin=Mf;xe.crcTable=mo});var Eo=ee((Im,yo)=>{var Bf=ie("path");yo.exports=function(n,{fs:e}){var i=n||"",o=c(),a=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return i&&e.existsSync(i)?(a=e.statSync(i),o.directory=a.isDirectory(),o.mtime=a.mtime,o.atime=a.atime,o.executable=(73&a.mode)!==0,o.readonly=(128&a.mode)===0,o.hidden=Bf.basename(i)[0]==="."):console.warn("Invalid path: "+i),{get directory(){return o.directory},get readOnly(){return o.readonly},get hidden(){return o.hidden},get mtime(){return o.mtime},get atime(){return o.atime},get executable(){return o.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:i,isDirectory:o.directory,isReadOnly:o.readonly,isHidden:o.hidden,isExecutable:o.executable,mTime:o.mtime,aTime:o.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var bo=ee((Cm,vo)=>{vo.exports={efs:!0,encode:n=>Buffer.from(n,"utf8"),decode:n=>n.toString("utf8")}});var Wt=ee((Am,jt)=>{jt.exports=_o();jt.exports.Constants=wi();jt.exports.Errors=Xn();jt.exports.FileAttr=Eo();jt.exports.decoder=bo()});var Io=ee((Tm,So)=>{var pt=Wt(),U=pt.Constants;So.exports=function(){var n=20,e=10,i=0,o=0,a=0,c=0,f=0,x=0,l=0,h=0,y=0,v=0,k=0,w=0,E=0;n|=pt.isWin?2560:768,i|=U.FLG_EFS;let S={extraLen:0},I=m=>Math.max(0,m)>>>0,D=m=>Math.max(0,m)&65535,R=m=>Math.max(0,m)&255;return a=pt.fromDate2DOS(new Date),{get made(){return n},set made(m){n=m},get version(){return e},set version(m){e=m},get flags(){return i},set flags(m){i=m},get flags_efs(){return(i&U.FLG_EFS)>0},set flags_efs(m){m?i|=U.FLG_EFS:i&=~U.FLG_EFS},get flags_desc(){return(i&U.FLG_DESC)>0},set flags_desc(m){m?i|=U.FLG_DESC:i&=~U.FLG_DESC},get method(){return o},set method(m){switch(m){case U.STORED:this.version=10;case U.DEFLATED:default:this.version=20}o=m},get time(){return pt.fromDOS2Date(this.timeval)},set time(m){m=new Date(m),this.timeval=pt.fromDate2DOS(m)},get timeval(){return a},set timeval(m){a=I(m)},get timeHighByte(){return R(a>>>8)},get crc(){return c},set crc(m){c=I(m)},get compressedSize(){return f},set compressedSize(m){f=I(m)},get size(){return x},set size(m){x=I(m)},get fileNameLength(){return l},set fileNameLength(m){l=m},get extraLength(){return h},set extraLength(m){h=m},get extraLocalLength(){return S.extraLen},set extraLocalLength(m){S.extraLen=m},get commentLength(){return y},set commentLength(m){y=m},get diskNumStart(){return v},set diskNumStart(m){v=I(m)},get inAttr(){return k},set inAttr(m){k=I(m)},get attr(){return w},set attr(m){w=I(m)},get fileAttr(){return(w||0)>>16&4095},get offset(){return E},set offset(m){E=I(m)},get encrypted(){return(i&U.FLG_ENC)===U.FLG_ENC},get centralHeaderSize(){return U.CENHDR+l+h+y},get realDataOffset(){return E+U.LOCHDR+S.fnameLen+S.extraLen},get localHeader(){return S},loadLocalHeaderFromBinary:function(m){var C=m.slice(E,E+U.LOCHDR);if(C.readUInt32LE(0)!==U.LOCSIG)throw pt.Errors.INVALID_LOC();S.version=C.readUInt16LE(U.LOCVER),S.flags=C.readUInt16LE(U.LOCFLG),S.flags_desc=(S.flags&U.FLG_DESC)>0,S.method=C.readUInt16LE(U.LOCHOW),S.time=C.readUInt32LE(U.LOCTIM),S.crc=C.readUInt32LE(U.LOCCRC),S.compressedSize=C.readUInt32LE(U.LOCSIZ),S.size=C.readUInt32LE(U.LOCLEN),S.fnameLen=C.readUInt16LE(U.LOCNAM),S.extraLen=C.readUInt16LE(U.LOCEXT);let P=E+U.LOCHDR+S.fnameLen,F=P+S.extraLen;return m.slice(P,F)},loadFromBinary:function(m){if(m.length!==U.CENHDR||m.readUInt32LE(0)!==U.CENSIG)throw pt.Errors.INVALID_CEN();n=m.readUInt16LE(U.CENVEM),e=m.readUInt16LE(U.CENVER),i=m.readUInt16LE(U.CENFLG),o=m.readUInt16LE(U.CENHOW),a=m.readUInt32LE(U.CENTIM),c=m.readUInt32LE(U.CENCRC),f=m.readUInt32LE(U.CENSIZ),x=m.readUInt32LE(U.CENLEN),l=m.readUInt16LE(U.CENNAM),h=m.readUInt16LE(U.CENEXT),y=m.readUInt16LE(U.CENCOM),v=m.readUInt16LE(U.CENDSK),k=m.readUInt16LE(U.CENATT),w=m.readUInt32LE(U.CENATX),E=m.readUInt32LE(U.CENOFF)},localHeaderToBinary:function(){var m=Buffer.alloc(U.LOCHDR);return m.writeUInt32LE(U.LOCSIG,0),m.writeUInt16LE(e,U.LOCVER),m.writeUInt16LE(i,U.LOCFLG),m.writeUInt16LE(o,U.LOCHOW),m.writeUInt32LE(a,U.LOCTIM),m.writeUInt32LE(c,U.LOCCRC),m.writeUInt32LE(f,U.LOCSIZ),m.writeUInt32LE(x,U.LOCLEN),m.writeUInt16LE(l,U.LOCNAM),m.writeUInt16LE(S.extraLen,U.LOCEXT),m},centralHeaderToBinary:function(){var m=Buffer.alloc(U.CENHDR+l+h+y);return m.writeUInt32LE(U.CENSIG,0),m.writeUInt16LE(n,U.CENVEM),m.writeUInt16LE(e,U.CENVER),m.writeUInt16LE(i,U.CENFLG),m.writeUInt16LE(o,U.CENHOW),m.writeUInt32LE(a,U.CENTIM),m.writeUInt32LE(c,U.CENCRC),m.writeUInt32LE(f,U.CENSIZ),m.writeUInt32LE(x,U.CENLEN),m.writeUInt16LE(l,U.CENNAM),m.writeUInt16LE(h,U.CENEXT),m.writeUInt16LE(y,U.CENCOM),m.writeUInt16LE(v,U.CENDSK),m.writeUInt16LE(k,U.CENATT),m.writeUInt32LE(w,U.CENATX),m.writeUInt32LE(E,U.CENOFF),m},toJSON:function(){let m=function(C){return C+" bytes"};return{made:n,version:e,flags:i,method:pt.methodToString(o),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:m(f),size:m(x),fileNameLength:m(l),extraLength:m(h),commentLength:m(y),diskNumStart:v,inAttr:k,attr:w,offset:E,centralHeaderSize:m(U.CENHDR+l+h+y)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ao=ee((Dm,Co)=>{var Kt=Wt(),de=Kt.Constants;Co.exports=function(){var n=0,e=0,i=0,o=0,a=0;return{get diskEntries(){return n},set diskEntries(c){n=e=c},get totalEntries(){return e},set totalEntries(c){e=n=c},get size(){return i},set size(c){i=c},get offset(){return o},set offset(c){o=c},get commentLength(){return a},set commentLength(c){a=c},get mainHeaderSize(){return de.ENDHDR+a},loadFromBinary:function(c){if((c.length!==de.ENDHDR||c.readUInt32LE(0)!==de.ENDSIG)&&(c.length<de.ZIP64HDR||c.readUInt32LE(0)!==de.ZIP64SIG))throw Kt.Errors.INVALID_END();c.readUInt32LE(0)===de.ENDSIG?(n=c.readUInt16LE(de.ENDSUB),e=c.readUInt16LE(de.ENDTOT),i=c.readUInt32LE(de.ENDSIZ),o=c.readUInt32LE(de.ENDOFF),a=c.readUInt16LE(de.ENDCOM)):(n=Kt.readBigUInt64LE(c,de.ZIP64SUB),e=Kt.readBigUInt64LE(c,de.ZIP64TOT),i=Kt.readBigUInt64LE(c,de.ZIP64SIZE),o=Kt.readBigUInt64LE(c,de.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(de.ENDHDR+a);return c.writeUInt32LE(de.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(n,de.ENDSUB),c.writeUInt16LE(e,de.ENDTOT),c.writeUInt32LE(i,de.ENDSIZ),c.writeUInt32LE(o,de.ENDOFF),c.writeUInt16LE(a,de.ENDCOM),c.fill(" ",de.ENDHDR),c},toJSON:function(){let c=function(f,x){let l=f.toString(16).toUpperCase();for(;l.length<x;)l="0"+l;return"0x"+l};return{diskEntries:n,totalEntries:e,size:i+" bytes",offset:c(o,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var yi=ee(_i=>{_i.EntryHeader=Io();_i.MainHeader=Ao()});var Do=ee((km,To)=>{To.exports=function(n){var e=ie("zlib"),i={chunkSize:(parseInt(n.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(n,i)},deflateAsync:function(o){var a=e.createDeflateRaw(i),c=[],f=0;a.on("data",function(x){c.push(x),f+=x.length}),a.on("end",function(){var x=Buffer.alloc(f),l=0;x.fill(0);for(var h=0;h<c.length;h++){var y=c[h];y.copy(x,l),l+=y.length}o&&o(x)}),a.end(n)}}}});var ko=ee((Rm,Po)=>{var zf=+(process.versions?process.versions.node:"").split(".")[0]||0;Po.exports=function(n,e){var i=ie("zlib");let o=zf>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return i.inflateRawSync(n,o)},inflateAsync:function(a){var c=i.createInflateRaw(o),f=[],x=0;c.on("data",function(l){f.push(l),x+=l.length}),c.on("end",function(){var l=Buffer.alloc(x),h=0;l.fill(0);for(var y=0;y<f.length;y++){var v=f[y];v.copy(l,h),h+=v.length}a&&a(l)}),c.end(n)}}}});var Mo=ee((Lm,Oo)=>{"use strict";var{randomFillSync:Ro}=ie("crypto"),Ff=Xn(),Uf=new Uint32Array(256).map((n,e)=>{for(let i=0;i<8;i++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),No=(n,e)=>Math.imul(n,e)>>>0,Lo=(n,e)=>Uf[(n^e)&255]^n>>>8,pn=()=>typeof Ro=="function"?Ro(Buffer.alloc(12)):pn.node();pn.node=()=>{let n=Buffer.alloc(12),e=n.length;for(let i=0;i<e;i++)n[i]=Math.random()*256&255;return n};var Qn={genSalt:pn};function er(n){let e=Buffer.isBuffer(n)?n:Buffer.from(n);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let i=0;i<e.length;i++)this.updateKeys(e[i])}er.prototype.updateKeys=function(n){let e=this.keys;return e[0]=Lo(e[0],n),e[1]+=e[0]&255,e[1]=No(e[1],134775813)+1,e[2]=Lo(e[2],e[1]>>>24),n};er.prototype.next=function(){let n=(this.keys[2]|2)>>>0;return No(n,n^1)>>8&255};function Hf(n){let e=new er(n);return function(i){let o=Buffer.alloc(i.length),a=0;for(let c of i)o[a++]=e.updateKeys(c^e.next());return o}}function qf(n){let e=new er(n);return function(i,o,a=0){o||(o=Buffer.alloc(i.length));for(let c of i){let f=e.next();o[a++]=c^f,e.updateKeys(c)}return o}}function Gf(n,e,i){if(!n||!Buffer.isBuffer(n)||n.length<12)return Buffer.alloc(0);let o=Hf(i),a=o(n.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw Ff.WRONG_PASSWORD();return o(n.slice(12))}function jf(n){Buffer.isBuffer(n)&&n.length>=12?Qn.genSalt=function(){return n.slice(0,12)}:n==="node"?Qn.genSalt=pn.node:Qn.genSalt=pn}function Wf(n,e,i,o=!1){n==null&&(n=Buffer.alloc(0)),Buffer.isBuffer(n)||(n=Buffer.from(n.toString()));let a=qf(i),c=Qn.genSalt();c[11]=e.crc>>>24&255,o&&(c[10]=e.crc>>>16&255);let f=Buffer.alloc(n.length+12);return a(c,f),a(n,f,12)}Oo.exports={decrypt:Gf,encrypt:Wf,_salter:jf}});var Bo=ee(tr=>{tr.Deflater=Do();tr.Inflater=ko();tr.ZipCrypto=Mo()});var vi=ee((Om,zo)=>{var te=Wt(),Kf=yi(),le=te.Constants,Ei=Bo();zo.exports=function(n,e){var i=new Kf.EntryHeader,o=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,f=null,x=Buffer.alloc(0),l=Buffer.alloc(0),h=!0;let y=n,v=typeof y.decoder=="object"?y.decoder:te.decoder;h=v.hasOwnProperty("efs")?v.efs:!1;function k(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(l=i.loadLocalHeaderFromBinary(e),e.slice(i.realDataOffset,i.realDataOffset+i.compressedSize))}function w(m){if(!i.flags_desc&&!i.localHeader.flags_desc){if(te.crc32(m)!==i.localHeader.crc)return!1}else{let C={},P=i.realDataOffset+i.compressedSize;if(e.readUInt32LE(P)==le.LOCSIG||e.readUInt32LE(P)==le.CENSIG)throw te.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(P)==le.EXTSIG)C.crc=e.readUInt32LE(P+le.EXTCRC),C.compressedSize=e.readUInt32LE(P+le.EXTSIZ),C.size=e.readUInt32LE(P+le.EXTLEN);else if(e.readUInt16LE(P+12)===19280)C.crc=e.readUInt32LE(P+le.EXTCRC-4),C.compressedSize=e.readUInt32LE(P+le.EXTSIZ-4),C.size=e.readUInt32LE(P+le.EXTLEN-4);else throw te.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==i.compressedSize||C.size!==i.size||C.crc!==i.crc)throw te.Errors.DESCRIPTOR_FAULTY();if(te.crc32(m)!==C.crc)return!1}return!0}function E(m,C,P){if(typeof C>"u"&&typeof m=="string"&&(P=m,m=void 0),c)return m&&C&&C(Buffer.alloc(0),te.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=k();if(F.length===0)return m&&C&&C(F),F;if(i.encrypted){if(typeof P!="string"&&!Buffer.isBuffer(P))throw te.Errors.INVALID_PASS_PARAM();F=Ei.ZipCrypto.decrypt(F,i,P)}var z=Buffer.alloc(i.size);switch(i.method){case te.Constants.STORED:if(F.copy(z),w(z))return m&&C&&C(z),z;throw m&&C&&C(z,te.Errors.BAD_CRC()),te.Errors.BAD_CRC();case te.Constants.DEFLATED:var K=new Ei.Inflater(F,i.size);if(m)K.inflateAsync(function($){$.copy($,0),C&&(w($)?C($):C($,te.Errors.BAD_CRC()))});else{if(K.inflate(z).copy(z,0),!w(z))throw te.Errors.BAD_CRC(`"${v.decode(o)}"`);return z}break;default:throw m&&C&&C(Buffer.alloc(0),te.Errors.UNKNOWN_METHOD()),te.Errors.UNKNOWN_METHOD()}}function S(m,C){if((!f||!f.length)&&Buffer.isBuffer(e))return m&&C&&C(k()),k();if(f.length&&!c){var P;switch(i.method){case te.Constants.STORED:return i.compressedSize=i.size,P=Buffer.alloc(f.length),f.copy(P),m&&C&&C(P),P;default:case te.Constants.DEFLATED:var F=new Ei.Deflater(f);if(m)F.deflateAsync(function(K){P=Buffer.alloc(K.length),i.compressedSize=K.length,K.copy(P),C&&C(P)});else{var z=F.deflate();return i.compressedSize=z.length,z}F=null;break}}else if(m&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function I(m,C){return te.readBigUInt64LE(m,C)}function D(m){try{for(var C=0,P,F,z;C+4<m.length;)P=m.readUInt16LE(C),C+=2,F=m.readUInt16LE(C),C+=2,z=m.slice(C,C+F),C+=F,le.ID_ZIP64===P&&R(z)}catch{throw te.Errors.EXTRA_FIELD_PARSE_ERROR()}}function R(m){var C,P,F,z;m.length>=le.EF_ZIP64_SCOMP&&(C=I(m,le.EF_ZIP64_SUNCOMP),i.size===le.EF_ZIP64_OR_32&&(i.size=C)),m.length>=le.EF_ZIP64_RHO&&(P=I(m,le.EF_ZIP64_SCOMP),i.compressedSize===le.EF_ZIP64_OR_32&&(i.compressedSize=P)),m.length>=le.EF_ZIP64_DSN&&(F=I(m,le.EF_ZIP64_RHO),i.offset===le.EF_ZIP64_OR_32&&(i.offset=F)),m.length>=le.EF_ZIP64_DSN+4&&(z=m.readUInt32LE(le.EF_ZIP64_DSN),i.diskNumStart===le.EF_ZIP64_OR_16&&(i.diskNumStart=z))}return{get entryName(){return v.decode(o)},get rawEntryName(){return o},set entryName(m){o=te.toBuffer(m,v.encode);var C=o[o.length-1];c=C===47||C===92,i.fileNameLength=o.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return x},set extra(m){x=m,i.extraLength=m.length,D(m)},get comment(){return v.decode(a)},set comment(m){if(a=te.toBuffer(m,v.encode),i.commentLength=a.length,a.length>65535)throw te.Errors.COMMENT_TOO_LONG()},get name(){var m=v.decode(o);return c?m.substr(m.length-1).split("/").pop():m.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return S(!1,null)},getCompressedDataAsync:function(m){S(!0,m)},setData:function(m){f=te.toBuffer(m,te.decoder.encode),!c&&f.length?(i.size=f.length,i.method=te.Constants.DEFLATED,i.crc=te.crc32(m),i.changed=!0):i.method=te.Constants.STORED},getData:function(m){return i.changed?f:E(!1,null,m)},getDataAsync:function(m,C){i.changed?m(f):E(!0,m,C)},set attr(m){i.attr=m},get attr(){return i.attr},set header(m){i.loadFromBinary(m)},get header(){return i},packCentralHeader:function(){i.flags_efs=this.efs,i.extraLength=x.length;var m=i.centralHeaderToBinary(),C=te.Constants.CENHDR;return o.copy(m,C),C+=o.length,x.copy(m,C),C+=i.extraLength,a.copy(m,C),m},packLocalHeader:function(){let m=0;i.flags_efs=this.efs,i.extraLocalLength=l.length;let C=i.localHeaderToBinary(),P=Buffer.alloc(C.length+o.length+i.extraLocalLength);return C.copy(P,m),m+=C.length,o.copy(P,m),m+=o.length,l.copy(P,m),m+=l.length,P},toJSON:function(){let m=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:i.toJSON(),compressedData:m(e),data:m(f)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ho=ee((Mm,Uo)=>{var Fo=vi(),$f=yi(),Ie=Wt();Uo.exports=function(n,e){var i=[],o={},a=Buffer.alloc(0),c=new $f.MainHeader,f=!1,x=null;let l=new Set,h=e,{noSort:y,decoder:v}=h;n?E(h.readEntries):f=!0;function k(){let I=new Set;for(let D of Object.keys(o)){let R=D.split("/");if(R.pop(),!!R.length)for(let m=0;m<R.length;m++){let C=R.slice(0,m+1).join("/")+"/";I.add(C)}}for(let D of I)if(!(D in o)){let R=new Fo(h);R.entryName=D,R.attr=16,R.temporary=!0,i.push(R),o[R.entryName]=R,l.add(R)}}function w(){if(f=!0,o={},c.diskEntries>(n.length-c.offset)/Ie.Constants.CENHDR)throw Ie.Errors.DISK_ENTRY_TOO_LARGE();i=new Array(c.diskEntries);for(var I=c.offset,D=0;D<i.length;D++){var R=I,m=new Fo(h,n);m.header=n.slice(R,R+=Ie.Constants.CENHDR),m.entryName=n.slice(R,R+=m.header.fileNameLength),m.header.extraLength&&(m.extra=n.slice(R,R+=m.header.extraLength)),m.header.commentLength&&(m.comment=n.slice(R,R+m.header.commentLength)),I+=m.header.centralHeaderSize,i[D]=m,o[m.entryName]=m}l.clear(),k()}function E(I){var D=n.length-Ie.Constants.ENDHDR,R=Math.max(0,D-65535),m=R,C=n.length,P=-1,F=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(R=0),D;D>=m;D--)if(n[D]===80){if(n.readUInt32LE(D)===Ie.Constants.ENDSIG){P=D,F=D,C=D+Ie.Constants.ENDHDR,m=D-Ie.Constants.END64HDR;continue}if(n.readUInt32LE(D)===Ie.Constants.END64SIG){m=R;continue}if(n.readUInt32LE(D)===Ie.Constants.ZIP64SIG){P=D,C=D+Ie.readBigUInt64LE(n,D+Ie.Constants.ZIP64SIZE)+Ie.Constants.ZIP64LEAD;break}}if(P==-1)throw Ie.Errors.INVALID_FORMAT();c.loadFromBinary(n.slice(P,C)),c.commentLength&&(a=n.slice(F+Ie.Constants.ENDHDR)),I&&w()}function S(){i.length>1&&!y&&i.sort((I,D)=>I.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return f||w(),i.filter(I=>!l.has(I))},get comment(){return v.decode(a)},set comment(I){a=Ie.toBuffer(I,v.encode),c.commentLength=a.length},getEntryCount:function(){return f?i.length:c.diskEntries},forEach:function(I){this.entries.forEach(I)},getEntry:function(I){return f||w(),o[I]||null},setEntry:function(I){f||w(),i.push(I),o[I.entryName]=I,c.totalEntries=i.length},deleteFile:function(I,D=!0){f||w();let R=o[I];this.getEntryChildren(R,D).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){f||w();let D=o[I],R=i.indexOf(D);R>=0&&(i.splice(R,1),delete o[I],c.totalEntries=i.length)},getEntryChildren:function(I,D=!0){if(f||w(),typeof I=="object")if(I.isDirectory&&D){let R=[],m=I.entryName;for(let C of i)C.entryName.startsWith(m)&&R.push(C);return R}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let D=this.getEntryChildren(I);return D.includes(I)?D.length-1:D.length}return 0},compressToBuffer:function(){f||w(),S();let I=[],D=[],R=0,m=0;c.size=0,c.offset=0;let C=0;for(let z of this.entries){let K=z.getCompressedData();z.header.offset=m;let $=z.packLocalHeader(),L=$.length+K.length;m+=L,I.push($),I.push(K);let M=z.packCentralHeader();D.push(M),c.size+=M.length,R+=L+M.length,C++}R+=c.mainHeaderSize,c.offset=m,c.totalEntries=C,m=0;let P=Buffer.alloc(R);for(let z of I)z.copy(P,m),m+=z.length;for(let z of D)z.copy(P,m),m+=z.length;let F=c.toBinary();return a&&a.copy(F,Ie.Constants.ENDHDR),F.copy(P,m),n=P,f=!1,P},toAsyncBuffer:function(I,D,R,m){try{f||w(),S();let C=[],P=[],F=0,z=0,K=0;c.size=0,c.offset=0;let $=function(L){if(L.length>0){let M=L.shift(),j=M.entryName+M.extra.toString();R&&R(j),M.getCompressedDataAsync(function(ne){m&&m(j),M.header.offset=z;let se=M.packLocalHeader(),me=se.length+ne.length;z+=me,C.push(se),C.push(ne);let ke=M.packCentralHeader();P.push(ke),c.size+=ke.length,F+=me+ke.length,K++,$(L)})}else{F+=c.mainHeaderSize,c.offset=z,c.totalEntries=K,z=0;let M=Buffer.alloc(F);C.forEach(function(ne){ne.copy(M,z),z+=ne.length}),P.forEach(function(ne){ne.copy(M,z),z+=ne.length});let j=c.toBinary();a&&a.copy(j,Ie.Constants.ENDHDR),j.copy(M,z),n=M,f=!1,I(M)}};$(Array.from(this.entries))}catch(C){D(C)}}}}});var jo=ee((Bm,Go)=>{var ue=Wt(),fe=ie("path"),Jf=vi(),Vf=Ho(),Ct=(...n)=>ue.findLast(n,e=>typeof e=="boolean"),qo=(...n)=>ue.findLast(n,e=>typeof e=="string"),Zf=(...n)=>ue.findLast(n,e=>typeof e=="function"),Yf={noSort:!1,readEntries:!1,method:ue.Constants.NONE,fs:null};Go.exports=function(n,e){let i=null,o=Object.assign(Object.create(null),Yf);n&&typeof n=="object"&&(n instanceof Uint8Array||(Object.assign(o,n),n=o.input?o.input:void 0,o.input&&delete o.input),Buffer.isBuffer(n)&&(i=n,o.method=ue.Constants.BUFFER,n=void 0)),Object.assign(o,e);let a=new ue(o);if((typeof o.decoder!="object"||typeof o.decoder.encode!="function"||typeof o.decoder.decode!="function")&&(o.decoder=ue.decoder),n&&typeof n=="string")if(a.fs.existsSync(n))o.method=ue.Constants.FILE,o.filename=n,i=a.fs.readFileSync(n);else throw ue.Errors.INVALID_FILENAME();let c=new Vf(i,o),{canonical:f,sanitize:x,zipnamefix:l}=ue;function h(w){if(w&&c){var E;if(typeof w=="string"&&(E=c.getEntry(fe.posix.normalize(w))),typeof w=="object"&&typeof w.entryName<"u"&&typeof w.header<"u"&&(E=c.getEntry(w.entryName)),E)return E}return null}function y(w){let{join:E,normalize:S,sep:I}=fe.posix;return E(fe.isAbsolute(w)?"/":".",S(I+w.split("\\").join(I)+I))}function v(w){return w instanceof RegExp?(function(E){return function(S){return E.test(S)}})(w):typeof w!="function"?()=>!0:w}let k=(w,E)=>{let S=E.slice(-1);return S=S===a.sep?a.sep:"",fe.relative(w,E)+S};return{readFile:function(w,E){var S=h(w);return S&&S.getData(E)||null},childCount:function(w){let E=h(w);if(E)return c.getChildCount(E)},readFileAsync:function(w,E){var S=h(w);S?S.getDataAsync(E):E(null,"getEntry failed for:"+w)},readAsText:function(w,E){var S=h(w);if(S){var I=S.getData();if(I&&I.length)return I.toString(E||"utf8")}return""},readAsTextAsync:function(w,E,S){var I=h(w);I?I.getDataAsync(function(D,R){if(R){E(D,R);return}D&&D.length?E(D.toString(S||"utf8")):E("")}):E("")},deleteFile:function(w,E=!0){var S=h(w);S&&c.deleteFile(S.entryName,E)},deleteEntry:function(w){var E=h(w);E&&c.deleteEntry(E.entryName)},addZipComment:function(w){c.comment=w},getZipComment:function(){return c.comment||""},addZipEntryComment:function(w,E){var S=h(w);S&&(S.comment=E)},getZipEntryComment:function(w){var E=h(w);return E&&E.comment||""},updateFile:function(w,E){var S=h(w);S&&S.setData(E)},addLocalFile:function(w,E,S,I){if(a.fs.existsSync(w)){E=E?y(E):"";let D=fe.win32.basename(fe.win32.normalize(w));E+=S||D;let R=a.fs.statSync(w),m=R.isFile()?a.fs.readFileSync(w):Buffer.alloc(0);R.isDirectory()&&(E+=a.sep),this.addFile(E,m,I,R)}else throw ue.Errors.FILE_NOT_FOUND(w)},addLocalFileAsync:function(w,E){w=typeof w=="object"?w:{localPath:w};let S=fe.resolve(w.localPath),{comment:I}=w,{zipPath:D,zipName:R}=w,m=this;a.fs.stat(S,function(C,P){if(C)return E(C,!1);D=D?y(D):"";let F=fe.win32.basename(fe.win32.normalize(S));if(D+=R||F,P.isFile())a.fs.readFile(S,function(z,K){return z?E(z,!1):(m.addFile(D,K,I,P),setImmediate(E,void 0,!0))});else if(P.isDirectory())return D+=a.sep,m.addFile(D,Buffer.alloc(0),I,P),setImmediate(E,void 0,!0)})},addLocalFolder:function(w,E,S){if(S=v(S),E=E?y(E):"",w=fe.normalize(w),a.fs.existsSync(w)){let I=a.findFiles(w),D=this;if(I.length)for(let R of I){let m=fe.join(E,k(w,R));S(m)&&D.addLocalFile(R,fe.dirname(m))}}else throw ue.Errors.FILE_NOT_FOUND(w)},addLocalFolderAsync:function(w,E,S,I){I=v(I),S=S?y(S):"",w=fe.normalize(w);var D=this;a.fs.open(w,"r",function(R){if(R&&R.code==="ENOENT")E(void 0,ue.Errors.FILE_NOT_FOUND(w));else if(R)E(void 0,R);else{var m=a.findFiles(w),C=-1,P=function(){if(C+=1,C<m.length){var F=m[C],z=k(w,F).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(z)?a.fs.stat(F,function(K,$){K&&E(void 0,K),$.isFile()?a.fs.readFile(F,function(L,M){L?E(void 0,L):(D.addFile(S+z,M,"",$),P())}):(D.addFile(S+z+"/",Buffer.alloc(0),"",$),P())}):process.nextTick(()=>{P()})}else E(!0,void 0)};P()}})},addLocalFolderAsync2:function(w,E){let S=this;w=typeof w=="object"?w:{localPath:w},localPath=fe.resolve(y(w.localPath));let{zipPath:I,filter:D,namefix:R}=w;D instanceof RegExp?D=(function(P){return function(F){return P.test(F)}})(D):typeof D!="function"&&(D=function(){return!0}),I=I?y(I):"",R=="latin1"&&(R=P=>P.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof R!="function"&&(R=P=>P);let m=P=>fe.join(I,R(k(localPath,P))),C=P=>fe.win32.basename(fe.win32.normalize(R(P)));a.fs.open(localPath,"r",function(P){P&&P.code==="ENOENT"?E(void 0,ue.Errors.FILE_NOT_FOUND(localPath)):P?E(void 0,P):a.findFilesAsync(localPath,function(F,z){if(F)return E(F);z=z.filter(K=>D(m(K))),z.length||E(void 0,!1),setImmediate(z.reverse().reduce(function(K,$){return function(L,M){if(L||M===!1)return setImmediate(K,L,!1);S.addLocalFileAsync({localPath:$,zipPath:fe.dirname(m($)),zipName:C($)},K)}},E))})})},addLocalFolderPromise:function(w,E){return new Promise((S,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:w},E),(D,R)=>{D&&I(D),R&&S(this)})})},addFile:function(w,E,S,I){w=l(w);let D=h(w),R=D!=null;R||(D=new Jf(o),D.entryName=w),D.comment=S||"";let m=typeof I=="object"&&I instanceof a.fs.Stats;m&&(D.header.time=I.mtime);var C=D.isDirectory?16:0;let P=D.isDirectory?16384:32768;return m?P|=4095&I.mode:typeof I=="number"?P|=4095&I:P|=D.isDirectory?493:420,C=(C|P<<16)>>>0,D.attr=C,D.setData(E),R||c.setEntry(D),D},getEntries:function(w){return c.password=w,c?c.entries:[]},getEntry:function(w){return h(w)},getEntryCount:function(){return c.getEntryCount()},forEach:function(w){return c.forEach(w)},extractEntryTo:function(w,E,S,I,D,R){I=Ct(!1,I),D=Ct(!1,D),S=Ct(!0,S),R=qo(D,R);var m=h(w);if(!m)throw ue.Errors.NO_ENTRY();var C=f(m.entryName),P=x(E,R&&!m.isDirectory?R:S?C:fe.basename(C));if(m.isDirectory){var F=c.getEntryChildren(m);return F.forEach(function($){if($.isDirectory)return;var L=$.getData();if(!L)throw ue.Errors.CANT_EXTRACT_FILE();var M=f($.entryName),j=x(E,S?M:fe.basename(M));let ne=D?$.header.fileAttr:void 0;a.writeFileTo(j,L,I,ne)}),!0}var z=m.getData(c.password);if(!z)throw ue.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(P)&&!I)throw ue.Errors.CANT_OVERRIDE();let K=D?w.header.fileAttr:void 0;return a.writeFileTo(P,z,I,K),!0},test:function(w){if(!c)return!1;for(var E in c.entries)try{if(E.isDirectory)continue;var S=c.entries[E].getData(w);if(!S)return!1}catch{return!1}return!0},extractAllTo:function(w,E,S,I){if(S=Ct(!1,S),I=qo(S,I),E=Ct(!1,E),!c)throw ue.Errors.NO_ZIP();c.entries.forEach(function(D){var R=x(w,f(D.entryName));if(D.isDirectory){a.makeDir(R);return}var m=D.getData(I);if(!m)throw ue.Errors.CANT_EXTRACT_FILE();let C=S?D.header.fileAttr:void 0;a.writeFileTo(R,m,E,C);try{a.fs.utimesSync(R,D.header.time,D.header.time)}catch{throw ue.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(w,E,S,I){if(I=Zf(E,S,I),S=Ct(!1,S),E=Ct(!1,E),!I)return new Promise((P,F)=>{this.extractAllToAsync(w,E,S,function(z){z?F(z):P(this)})});if(!c){I(ue.Errors.NO_ZIP());return}w=fe.resolve(w);let D=P=>x(w,fe.normalize(f(P.entryName))),R=(P,F)=>new Error(P+': "'+F+'"'),m=[],C=[];c.entries.forEach(P=>{P.isDirectory?m.push(P):C.push(P)});for(let P of m){let F=D(P),z=S?P.header.fileAttr:void 0;try{a.makeDir(F),z&&a.fs.chmodSync(F,z),a.fs.utimesSync(F,P.header.time,P.header.time)}catch{I(R("Unable to create folder",F))}}C.reverse().reduce(function(P,F){return function(z){if(z)P(z);else{let K=fe.normalize(f(F.entryName)),$=x(w,K);F.getDataAsync(function(L,M){if(M)P(M);else if(!L)P(ue.Errors.CANT_EXTRACT_FILE());else{let j=S?F.header.fileAttr:void 0;a.writeFileToAsync($,L,E,j,function(ne){ne||P(R("Unable to write file",$)),a.fs.utimes($,F.header.time,F.header.time,function(se){se?P(R("Unable to set times",$)):P()})})}})}}},I)()},writeZip:function(w,E){if(arguments.length===1&&typeof w=="function"&&(E=w,w=""),!w&&o.filename&&(w=o.filename),!!w){var S=c.compressToBuffer();if(S){var I=a.writeFileTo(w,S,!0);typeof E=="function"&&E(I?null:new Error("failed"),"")}}},writeZipPromise:function(w,E){let{overwrite:S,perm:I}=Object.assign({overwrite:!0},E);return new Promise((D,R)=>{!w&&o.filename&&(w=o.filename),w||R("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(m=>{let C=P=>P?D(P):R("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(w,m,S,I,C)},R)})},toBufferPromise:function(){return new Promise((w,E)=>{c.toAsyncBuffer(w,E)})},toBuffer:function(w,E,S,I){return typeof w=="function"?(c.toAsyncBuffer(w,E,S,I),null):c.compressToBuffer()}}}});function Ga(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Ox:e}function _t(n){return qt(n??X().configFile)}function Xe(n,e){return Kn(e??X().configFile,n)}var Ox,en=ze(()=>{"use strict";$n();ye();Ox=10*6e4});var hc=ee(he=>{"use strict";var O=G;(function(n,e){let i=G,o=n();for(;;)try{if(parseInt(i(1532))/1*(parseInt(i(1410))/2)+parseInt(i(758))/3*(-parseInt(i(599))/4)+parseInt(i(911))/5+-parseInt(i(1482))/6*(-parseInt(i(1014))/7)+-parseInt(i(1587))/8*(-parseInt(i(1257))/9)+-parseInt(i(498))/10+parseInt(i(1398))/11*(-parseInt(i(1043))/12)===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(Ir,596853);var Nl=Object[O(1356)+O(1369)],Ol=Object[O(1512)+"opertyNa"+O(822)],uc=(n,e)=>function(){return n&&(e=(0,n[{EZxPe:function(c,f){return c(f)}}[O(1036)](Ol,n)[0]])(n=0)),e},Ml=(n,e)=>{let i=O,o={ejume:function(c,f,x,l){return c(f,x,l)}};for(var a in e)o[i(459)](Nl,n,a,{get:e[a],enumerable:!0})};function Bl(){return oc||(oc=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function zl(){let n=O;return ac||(ac=[IDBCursor[n(625)+"e"][n(1776)],IDBCursor.prototype.continue,IDBCursor[n(625)+"e"]["continue"+n(866)+"ey"]])}function G(n,e){n=n-365;let i=Ir(),o=i[n];if(G.hBUzWF===void 0){var a=function(l){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",y="",v="";for(let k=0,w,E,S=0;E=l.charAt(S++);~E&&(w=k%4?w*64+E:E,k++%4)?y+=String.fromCharCode(255&w>>(-2*k&6)):0)E=h.indexOf(E);for(let k=0,w=y.length;k<w;k++)v+="%"+("00"+y.charCodeAt(k).toString(16)).slice(-2);return decodeURIComponent(v)};G.ibRfjJ=a,G.FVLjqx={},G.hBUzWF=!0}let c=i[0],f=n+c,x=G.FVLjqx[f];return x?o=x:(o=G.ibRfjJ(o),G.FVLjqx[f]=o),o}function Fl(n){let e=O,i={MTWOO:"success",UeuYP:"error",NgpAj:function(a,c){return a(c)},sAVSE:function(a){return a()},yVYTf:function(a,c){return a!==c},UjgYm:"wQAhm"},o=new Promise((a,c)=>{let f=G,x={dRxEU:function(v){return i[G(782)](v)}},l=()=>{let v=G;n[v(699)+v(1748)+"ner"](i[v(815)],h),n.removeEventListener(i.UeuYP,y)},h=()=>{let v=G;a(et(n[v(1610)])),x[v(1777)](l)},y=()=>{let v=G;i[v(965)](c,n[v(1322)]),i[v(782)](l)};n[f(1021)+f(1397)](i[f(815)],h),n[f(1021)+f(1397)](i[f(1086)],y)});return o[e(1449)](a=>{let c=e;i[c(1609)](c(667),i[c(1119)])?a instanceof IDBCursor&&Wi.set(a,n):(_0xbf599c.set(_0x518212,_0x27b26f),_0x1573c3[c(1737)](_0x1f3b0e,_0x1decbd))})[e(641)](()=>{}),Ar[e(1737)](o,n),o}function Ul(n){let e=O,i={aPSxv:e(504),AeLhK:e(1322),HjGTz:e(1396),jUJsK:e(1347)+"or",eFraz:function(a){return a()}};if(Cr[e(1233)](n))return;let o=new Promise((a,c)=>{let f=e,x={QdpNd:function(v){return i[G(565)](v)}},l=()=>{let v=G;n[v(699)+v(1748)+v(1276)](i.aPSxv,h),n[v(699)+"entListener"](i.AeLhK,y),n[v(699)+v(1748)+v(1276)](i[v(1700)],y)},h=()=>{a(),x.QdpNd(l)},y=()=>{let v=G;c(n[v(1322)]||new DOMException(i[v(765)],i[v(765)])),l()};n[f(1021)+f(1397)](i.aPSxv,h),n[f(1021)+f(1397)](i[f(1309)],y),n[f(1021)+f(1397)](i[f(1700)],y)});Cr[e(1737)](n,o)}function Hl(n){Tr={TRWkc:function(o,a){return o(a)}}[O(1434)](n,Tr)}function ql(n){let e=O,i={rdpNu:function(o,a){return o+a},tmrOQ:function(o,a){return o*a},kkzgB:function(o,a){return o>>>a},tRvwt:function(o,a){return o>>>a},jlCpL:function(o,a){return o!==a},rRAOz:e(1647),RfbYC:e(1265),TRcWR:function(o,a){return o(a)},dnRWW:function(o,a){return o(a)},BOlet:function(o,a){return o(a)},uHLSe:function(o,a){return o===a},CAqpc:e(387)+e(951),ORsAp:function(o){return o()},RFPfy:function(o,a){return o!==a},YCceG:e(1381)};return i.uHLSe(n,IDBDatabase[e(625)+"e"].transaction)&&!(i.CAqpc in IDBTransaction[e(625)+"e"])?function(o,...a){let c=e;if(i[c(1379)](i.rRAOz,i.RfbYC)){let f=n[c(1142)](Tn(this),o,...a);return ji[c(1737)](f,o[c(1324)]?o[c(1324)]():[o]),et(f)}else return this[c(423)]?i.rdpNu(i.tmrOQ(i[c(580)](this[c(410)],0),_0x4b288f),this[c(1305)]>>>0):i[c(1483)](this[c(410)]*_0xe0971f,i[c(1270)](this[c(1305)],0))}:i.ORsAp(zl)[e(1763)](n)?i.RFPfy("QPwGP",i[e(1783)])?_0x3246bc[e(1749)]>=_0x5d796d[e(1198)]:function(...o){let a=e;return n[a(508)](i[a(988)](Tn,this),o),i[a(926)](et,Wi[a(376)](this))}:function(...o){let a=e;return et(n[a(508)](i[a(1289)](Tn,this),o))}}function Gl(n){let e=O,i={mbTjx:function(o,a){return o===a},MHhRP:function(o,a){return o(a)},dagkS:function(o,a){return o(a)},qYQSN:function(o,a,c){return o(a,c)}};return i[e(928)](typeof n,e(1100))?i[e(1774)](ql,n):(n instanceof IDBTransaction&&i[e(861)](Ul,n),i.qYQSN(xc,n,Bl())?new Proxy(n,Tr):n)}function et(n){let e=O,i={lRaFm:function(a,c,f){return a(c,f)},YMWcA:function(a,c){return a<c},aFPeC:function(a,c){return a+c},dCzFL:function(a,c){return a instanceof c},mfmkk:function(a,c){return a(c)},gcdNW:function(a,c){return a(c)},HHCnD:function(a,c){return a===c},psyIc:e(1746),cpQNn:"JyXeE"};if(i.dCzFL(n,IDBRequest))return i.mfmkk(Fl,n);if(br[e(1233)](n))return br[e(376)](n);let o=i[e(831)](Gl,n);if(o!==n)if(i[e(1469)](i[e(1105)],i[e(1026)])){let a=i[e(1140)](_0x15d93f,_0x302231,_0x12fbcb.limit),c=_0x286fc9[e(998)],f=_0x306ce8[e(998)];for(let x=0,l=_0x1677fc[e(1198)];i.YMWcA(x,l);x++)c[i[e(383)](x,a)]=f[x]}else br[e(1737)](n,o),Ar[e(1737)](o,n);return o}function Ir(){let n=["s0jKz04","EvjLy29UBMu","AgvKtwf4uMu","BvHlrKS","rNLzANa","Aw5KzxG","mxW1Fdj8m3W","z21utMm","ihbYB3rVy28","ihrPBwvZ","tKDFrvjst1i","v2zOrMG","x2HHBMrSzva","yNL0zuXLBMC","z2v0t3DUuhi","DcbSAw1PDa","DeLUDgvYy2u","CM9prKm","vhLuqNC","s2nRq0i","rezhshm","Bwu6ia","r0HuwNi","uMr1z3q","yw1Lu3bHy2u","zgLZCgf0y2G","twnosfu","CK1QEhq","D2LSBfjLy28","qKDWv0y","u1jds0i","rujIwvC","DhjPzxm","weL6shG","mtiYmZD2tLPVvhG","ANjgB1K","wxbhuvm","rhngs3G","zNvUB3m","uwTHrxi","C2vUzf9Hy2S","q3PPufu","CxzMBKm","wuzUvKu","DNjTvey","wLbNv2W","z1j2y0O","Awrkwwu","CMvHzfvjBNq","z1j6ug0","qLHdvee","AvLyzhq","y2XVC2veqG","zMfKswe","zxjFBxnNAwq","B25LCNjVCG","x29Uq2XVC2u","BwLZzq","q0Xpu0ve","DgvZDa","ALPmAwW","B25mAw5L","CKzTq2u","zNLPCKe","q0jqrLu","C0HgzMS","uer1y28","ywDLrxzLBNq","CMfTugfYyw0","EwHXsK8","zcWG","y0TuDgG","AfHzsKS","vfDnv0G","sLrczui","m3W0FdD8mxW","AgfUz2u","icSG","Dw5zt2S","u2TPCcbWyxm","zun1Afq","uuzUquq","CwDLzgW","sxzisw0","ChjfuxK","s3HRrMW","yMfJA3vWigu","CNLtzuW","Dg9tDhjPBMC","mtuYsfDRAwr0","C2vYDMLJzs0","DMfSDwvZ","y291BNq","sxDzyKG","CNzHBa","x2LZsw5PDa","tMrRuhy","AePurLC","q0XOzuG","y3vYDMfSDwu","wfrcyKS","yLv6sfK","zw5fDMvUDa","vefMtgi","BNvTyMvY","AwXSihvZzsa","AgfZt3DUuhi","tMPgyuC","zxH0zw5ZAw8","wxDIAwm","wNb5CM4","Evzzvgy","CMvZDwX0","BuvzAg8","Cujzy3a","sLHWDvO","r292Cum","tvrryMG","Cgf5Bg9Hzeu","rfbQA3e","B3jRzxjhBg8","ww53CKC","BMrWB2LUDfq","sNrNy2K","q291BNq","s0XbCg4","x21PBMLoyxy","svDiCey","ywzL","C3rYAw5N","u2vYDMLJzvC","tLb2EMW","BNrLCG","yxLrDhu","y3jLyxrLrxi","x3DZsw5ZDge","x29UvgLTzw8","B1Pcz0O","C1zzwwm","zvfJC08","q09oveLovuu","EfvZzuvUDG","veXQy0e","Exr6CgO","DxrVuMvJB24","Ahr0Ca","s0Tzt24","nNWXFdeWFdm","CgfNzwHPzgu","vhnMyKy","zLjbzK8","x3jLywr5q2W","DgLTzw91DcW","CgvYC2LZDgu","zw94uha","BMnLq2XVC2u","Aw5N","wM9JEwu","v2vPEgLUsLm","y2HHCKnVzgu","v0jTreK","A3novMi","vw5Oyw5KBgu","zgvSzxrL","tufyx1jfvfi","whLfBwq","ihrYEsbYzwm","x2LZtwLUAvq","ANjywwS","rNjVBNrPzxi","wvnVzMi","yvbpvfO","uxvLDwu","Ae91r0G","x2n1CNnVCKy","lcbOB3n0BMe","rwv5rxy","qLnsBMK","Dg9cExrLC0i","yNfvt0S","z2v0qwXS","u3rKveG","C3rVCMu","BgLUzq","BNz0rM0","Cgf5Bg9Hza","qwjPC0W","quXm","Aw50zwDLCIa","EuDdq2G","C2v0zgi","AejHywe","ExD6CLa","Cw9Z","Dg9Y","q0PWBwy","swPewLO","svnTyuy","AefJA01LC3m","B2zM","ihzHBgLKihm","wxHMCgO","sgPhvhO","vMHnvfa","ig1LC3nHz2u","C2PVy3q","x0vysvnu","tg9Nsuq","wfrmsuy","Bg9Nsurhzw4","wvjvvM4","zsbHihn0CMK","CMvWBgfJzui","ExzLuK8","C2fNzq","CMfTzq","A0vgrLi","q0fzvu4","u25evw8","quzesxm","Cg9W","CeHuz1C","Dw50","AhzKtxy","y2XVC2u","z2v0sxrLBq","zgvIDwC","yxGGCMv0CMK","zv9ZDwnJzxm","uMvHzcbWyxm","B3nLrxzLBNq","B3rAqK8","rxzdu0y","CwHvywu","EgnjrMi","nNWWFdq","y29UBMvJDfm","wLLsufi","y3jLyxrLtwu","C2v0","DhLWzq","tuzdz2i","yKTjug8","z0Ttr0S","q3vZDg9Tq2W","CuPtrfy","s2HIChO","B2nRzxrtDwm","yuLwBe8","wwvMq3q","zw50tgLZDgu","B2zMC2v0","C2v0y3vYC28","BNruCMLLC0m","yxbWzw5Kq2G","se5mD1u","DePiCxu","CMvUDevUzha","BxvbtKm","zMzmAw5L","C2nYAxb0","vLHLAwy","CgLUz09Uy2u","y3jLyxrLrwW","vuHIy3K","Aw5JBhvKzxm","ywnOzwq","yxbWBgLJyxq","Eg5wveu","l3DZl3yY","BML1B2K","aaaaaaaaaaa","z2vY","AKPZBgi","CKHLuxi","u0rpv1q","tuHOuLa","BNrfBMrWB2K","ywr2yw5Jzq","zfj4rvu","twzNr2u","Bwf4tg9ZC0m","C3Hrq08","qwrAAMy","EKTZBgK","wunJzuC","id4G","uePhCw8","AxryChO","DM5ot3e","t2fuq0C","v0LLvNm","y2XLyxi","BgPOywu","BKD4Evi","AxnrB1nby2S","BKrzuK0","EK5wrNa","EufRt1e","Ae1LC3nHz2u","r09mEhG","rerYAwy","uuvxt1O","AwDHDg9Yt24","veDWB0e","vxDRuNC","ysbTDxn0igi","x2rLyNvN","wMLtvNa","swfiuLe","x3bPBMDqB24","C1zgyxG","zxjFCw9Zx2e","q1vWA1a","yuL2zeS","r3PRC3G","y2vzsKG","z2v0","qw1brNy","Dw5KzwzPBMu","C3jJ","DgfJwKC","C3rLBMvYCW","mhW1","yuzqzum","CvPvtge","CMvJzxzPzwq","BfrHEhu","B2jQzwn0u3q","CMvTB3zLq2G","A2rKt2W","x2LUAxrqCM8","yuTmANa","u2vXsuq","DMvY","uLv5zge","zw5NDgG","CYbHBhjLywq","BeXrzeW","BgvY","rMvpuha","AgvHzgvYCW","BMvLzf9Hy2S","suDfs1a","ywnRpwzYB24","uu9Wthq","veDvDu8","qLfQEgC","EwzVAfy","u0T1AKi","rgDRvhC","AgLNAa","vw5PBxbSzw0","ExbL","x3vYBa","BMvJDa","A2v0ignVBNm","uxfcAu0","BML0AwfSAxO","reHgq0m","CMLLC0nVDw4","vvLOEw4","DxbKyxrLq3u","tNHOExy","Dw5ZAwDUzwq","BM5Ly3q","BwHtq20","y3vYC29YlNm","v3r4BNC","y2jOyMy","zgf0yq","A01sEe4","zw1PDa","t0zPuxO","C2HPzNq","B0ruBKG","yw51Ce1LC3m","te1orLe","ChjVDg9JB2W","vNnNq2y","vwPJq1m","BMPlu2K","Cg9tzem","zgXyC0q","sNnJyLu","v2fRwLi","vgfN","vwjHCLG","zxH0ugf5Bg8","y3DnEgW","ANbYD0m","BwfW","Bxbwsg0","BMv4DcGPigm","yLruCM0","C3vJy2vZCW","t1vmyxm","x3bPBMDmB3m","Eu91tee","zMrNANq","zwP1Bwu","Dgv4DfbHEwW","EuD3yxi","wKfPtgC","AfHdwK4","BMv3vMvYC2K","uwnhBhq","C2DPza","mNW1FdeXFde","zxjFDhrS","zxjYtxnN","r3fcyLG","Bwv0Ag9K","zKfeu3q","s1rABKi","sLz6sMe","CMvZzxruCMK","mxWZ","CMvZzxrfBMq","yvHUuvy","uMvWrKm","BMnVzgLUzW","ChLSv2q","D0DfrvG","sxLMAgG","sNnPD28","Cvz4sNy","tMfTzq","A1rcDuO","q2HMEu4","v2vIu29JA2u","zfLnEKi","x2fKzfDZtgK","DLDtBeS","zMzLCG","uw51Eeu","yw5Nzq","sKTLrhC","yw1L","ndG0mtaWzxzkquLl","vejrDgm","zxrxB3jRq2G","DfDrtw0","ugfbwwy","A2H1reG","y29TCgXLDgu","rxDUDeW","x2jPBMfYEvq","CYbWyxjHBxm","yxbWBhK","tunsA0q","AgHPAem","AwvWz0y","uNDTt2G","z3n1rvO","Aw9U","AK5yAgy","AujQA3O","BencEgi","vgnKzuG","wu9vBNe","t1fIA2i","De1HBMfNzxi","r1zkvw0","DeXpwhO","zxPRrha","Dgv4Dc9Qyxy","v1nACeq","y2HnyxHdB3u","AM5ZtuS","rgn4qvC","D2Ddzg0","D2zdBwy","r2rhEei","zNjuCMi","EMjJzLm","zKr3uxm","v1HLC2u","tg9JAW","vwHpqMm","pxv0zI04","x194x21Zz18","s3HNtKW","CLzHBhvLCW","yKvUBgu","Cujgs28","AwXK","D0DSreG","sfnAELm","q3nVq2i","uxLytuC","Ae9Wzw5fDMu","Du5ste8","CeLYrg4","y2vZC0HHBMq","CMnVA2K","ywDLu2HVDW","x2LUAxq","rgvuzhu","tNnRBgW","s3beBLy","zxf1ywXZ","yLDWDhq","ugjdBeG","x2DLDeLUDgu","ANvcAMe","zuzYyxO","yKzpB3K","zgLZywjSzue","ug1iAgW","zeXosvm","v21uqwC","twvZC2fNzuu","x19LC01Vzhu","y3ruAw1LB3u","x3nLCuLK","B29juMm","B0nPvxa","v0j2Ahe","yNPYAge","B2zMBgLUzq","A2T6z0i","wgDPEuu","BxjSB0u","EgPfswW","y2rmELa","zNjVBuj5Dgu","B3nLza","vwvnDNa","igfYCMf5yNu","AeDnrgG","qKfgsxC","x3bYB3rVy28","BNP4y0e","yNvMzMvY","su14ufi","y3vYC29Yx2y","BMrWB2LUDca","zxq9DxrMltG","yMLUza","ner1q2Lrzq","wNfOA3m","twfKzgC","v3fesNm","r1rNALm","qvrVs3m","BerxB2y","y3vYCMvUDeK","BuzIwhK","t1bir2K","A0fnt1y","B3vUDa","vNHIrMq","zw5HyMXLqxu","yxjYyxLIDwy","zgvJB2rLzey","z2vjBMzVu3K","B3bLBG","wezADgi","CMvJzwL2zwq","zNjVBuHHC2G","suPwu0e","AxnmB25N","AgzYyNq","zMLfDNC","AMHLvuK","ChjVDg90Exa","y29UDgLUDwu","t21YD2S","uLjSqLe","DhbizwfKzxi","A0HkrwO","zwvKzwq","BeHHBMrSzxi","C0Xf","CgLUz1rPBwu","uLDQr0e","B3jxveK","CMfUzg9T","AvbHvMC","CffxA0S","shzQtNK","y2f0y2G","svj0BMK","uMvJB25Uzwm","zKTeEKy","B0P2y0K","y3rTsfm","uwnkEeW","x3nLBMrby2S","lcbTyxGGCMu","DwTsCwW","CMvHzg9UBhK","u0fswe8","C2v5DNq","yxnJCMLWDa","D2rrseC","z2v0q3vYCMu","CMvZzxrdB3u","DenrqMK","y3niy1e","ywnRx2LK","x3bYzwzPEa","BgLUzw5V","vxbKyxrLq28","DhjHBNnHy3q","s2jWDuy","ue9YB2O","sMTIC2y","D0fKzNu","BgvUz3rO","x2zVCM1HDeu","q01MwxC","ru5KD3O","svrcD0W","DMvYC2LVBMm","ihjLy29UBMu","AMXKDwu","C3bSAxq","yxnZAwDU","t3LjreW","vMfpwKC","qLrMuxy","ELvVC0C","BxnZAKi","BwvY","EgLJBLG","u29Lq1a","Aw9UvgLTzw8","z2v0q3vYC28","qMXZtKm","r2jxzee","yvrvC0G","zxjFywnRx20","yujOELm","u2HHCMvKv28","DhDXA0K","yxv0B21HDgK","wufdCuC","tfnJt3m","CMvTB3zLrxy","rwzRuLO","x29UtwvZC2e","vvPVB00","wxfswwe","rvnbr1q","CgHHy1e","zMXVB3i","CePIBha","t1PUCLa","rhvVzgC","yMfSrxzLBNq","sNjbAwq","Dg9oDw1Izxi","zxDiuhm","Fdv8n3WY","sLnmCKS","t056y0i","CM92AwrLige","DhDVCMTdAge","EeHcC2K","CMvJB25Uzwm","y3vYC29Yx24","mxWZFdj8mhW","D0r3qLK","zw50","Dg9hzw5LCMe","y29Kzq","zgvS","tKPZrMC","u3DMAfC","DK96zvG","vKf6u1m","BK1xruC","CMDJsMi","y3jLyxrLt2i","t3LqtgS","vLL3sfm","yw1LoIa","u2vPsu8","DhjPBq","CKjAuMW","uvvotLO","sxnMAwG","yxnL","vgvnsM0","y29UBMvJDca","zgjYyLK","sg9VruK","z1rAwhq","EuXZEMy","t1bftL9fuLi","tKLeA3u","D1zhrNG","Cwfszuq","x2vUzhbVAw4","Aw1LCYbPBIa","x2LZqNjVD3m","sevvwLi","nJG0otaZr1bWuKjv","ywrKt25L","vhD6sKG","wK1LDeq","x2n1CNnVCK4","D24GCMvHC28","ze5Awe4","ALvkC0S","y29Uy2f0","DevmDva","Aw5KzxGGB3u","vM1kA00","vfrZzgO","q29Kzq","yNLL","zwjmvum","wer5quK","A0Lotvq","EgnNree","B3v0sw50zxi","sxvTqMq","C2PZteW","rKXsC04","CMvHzhLtDge","C0fwu0u","Axj6Dwq","CMvQzwn0","zNjVBu51Bwi","CMvHC29U","tgXqC0q","uLbhshe","ru92uwm","zLjhsMq","CMfNzvn5BMm","C2v0sxrLBq","DfPxwuW","wvnStgO","m3W1Fdr8mhW","DKjbDeW","yLrqAuC","Ec1TC2CTCw8","C0XPC3rLBMu","u2r4vey","yxv0BW","B2fK","BwfUDwfSihi","B25TzxnZywC","EwT3r1e","wxrsD3y","x0rctMfTzq","zxjHDg9Y","yM9L","Dg9cExrLC0W","vKjjBxe","D3nZoI8V","ANv0B0W","y09Wzw4","tvrxt08","CLLhAwO","Dhj1y3rVCIa","tu5zyMq","BgLZDgvUtMu","yMXVy2TLza","zMLSzw5HBwu","BwvZ","CMv0CNLdB3u","tuHKC2q","DxjWEKi","C3vIC3rYAw4","AwfeuvC","yxKSihrYEsa","u21Ms0S","tLf2zMi","z2nKtLC","zNjHBwvuExa","uMzpAhe","y21dwxe","v01hzgC","CfnkwMS","wvjivLG","B25tDg9Wsw0","BM93","AxnFywnR","tg9NsurozxC","DgLUzYbZzxi","Dg9VigXHCMC","C2nJzKe","Cg9PBNrdB24","ChjVy2vZCW","zw5XDwv1zq","ywXPzcb1CMW","AKvICg4","CM92AwrLihC","BMDuAw1LCG","u0ToqwO","wfvpDva","rKvdEMG","A2X2t0e","y1PADfi","zgvSzxrLrge","qw1VDw50","q29UzMLN","zufmDMq","zgfNA1m","y3vYC29Y","EenQBfC","zNbRwKG","C2vYDMvYvgK","uhjPBwfYEuS","Ec1TC2CTy3u","CYbPBNn0yw4","x2TLEvbHDgG","CMTLCKDSB2i","s0HwCfm","wvDYq2O","A2v5CW","qLfMuvK","Bwf4twvZC2e","z2vtEw5J","ywXSzwqGBxu","Bfvyt3K","qvPHvKS","AwPQtwu","y3zTvwe","CNnVCL92ywW","uuTlzuW","Afbws0K","A0Dwwvi","wfLvv08","BwvZC2fNzv8","CufJEuW","y2HnyxHuCMK","A2Xzr1K","vM9jteC","uevLy0O","DxPurvu","yM9KEq","ze11y20","zcWGDw5RBM8","mdaWma","uhHjCLu","A0rzywm","EMLxBxK","DKfOtgm","zMLN","B25fCNjVCG","BxLXrfG","z1rPBwvVDxq","mxW0Fdj8m3W","r3zkuw0","rNrUCMu","EMj2Exe","D3m6lY8","mJaYmJG2mfLxvMD4za","ChbL","tKfusvzfx0u","AhPUz1y","EKrWvuy","wvvOwei","suvtx0vsuK8","Cw9Zx18","zg9Uzq","x2LZtwLUAvC","zM9YrwfJAa","ywnOzwqSihC","Dw5cvvy","uMLAAxa","sw9IDvu","zg5sv1C","C3rVCcbPBw0","BwjuANG","twLZC2LUzYa","tNfhCfu","Be10wNq","B25tDgfYDfi","yxrLq291BNq","ywDL","B3bLBIa","CxfcveO","ALjJBgC","nxWYFdr8mhW","vfzTwLa","y3vYCMvUDeu","CLL1tum","q0XhuhG","yvvdCLO","Dg9mB3DLCKm","B25szwnLAxy","rLLjvhC","zwnpvhi","qxDYD08","zw5JB2rLrNi","DvLJEgG","B3jLtMfTzxm","D3jPDgu","BfrPBwvVDxq","ENb4wNa","x2DLBMvYyxq","DNzhzLe","wNPuvwK","DfvlzgW","CIb0DhDjra","zgv2AwnLx2K","y3jLyxrLuMu","r3b1uvy","BezSDxnO","sKrTC0G","tMDWqwO","vvDiDgG","B25VCgvU","q0nWvhy","yMLUyxj5vhK","x3DHAxq","vu1ZCw0","t2Dkweu","q09otKvdveK","DMvUDa","wKLvDLy","uhDKAhu","z2u6ia","wgnSsLa","zNLhrfi","yvvewM0","DuvgrxG","q3vZDg9Trxi","x3bHDgHlzxK","ywnRDxbfBMq","B0PVv3q","t0HgD2u","BvrbAgW","vfjJv1i","qNfyALu","zxHWB3j0CW","ywnR","sLnZvNa","t3r4ufG","rg9vwhe","DhjPzxmGCMu","DgLTzw91Da","BwLUzW","yNL0zxm","wev5t2G","DxnLCKLW","BKXPBMu","Ee1lDhO","mNWXFdv8m3W","x2nYzwf0zvm","zgHrBKG","r2v2s2y","uNbsALy","zfjTExa","x2LUDgvYDMe","sLnptLa","vfLIruy","CuPJu3O","t0jOsKy","mta1shz4u0nT","Aw47y2HHCNm","CgLUz0LUDgu","zw5KCg9PBNq","z2Tnueq","C1vet0q","u3jnteG","ywrKrxzLBNq","tKHOyuq","C2vYDMLJzq","DhLkD1C","BMTtz08","y3brtM4","sLvWvve","y29SBM8","yw5ZzM9YBvq","B09Yrhi","BxnNsuq","EKf0u2y","vg1yt3i","D2DlyK4","Chv0","rvP4ugu","y29UC3rYDwm","wg51A3a","x2nSzwfYvgK","DeLK","C1zKAg8","sg52zLa","mtjwyNDQugm","quvWvLK","ug9mvLu","B2nRzxrgywK","DxbNC3K","EvfwqwK","yNfnC3G","ELPmtuq","shbXqMK","qLDIsvy","DfvzAMW","ChvZAa","shvQANa","Afv6D3u","r2rOrhK","vKf5D1C","Ahf4CvC","AgvHzgvY","CgLUz19VBMm","AxzWC0S","v3nduxO","x2rPC3bHDgm","BwvZC2fNzq","uuPxEe0","CM9YrxzLBNq","uLzkuKm","CMvZB2X2zq","rvjst1i","x2nVBM5Ly3q","qxDsAe0","C3vIyxjYyxK","yMDyr2K","x25HDMLNyxq","whHJwLC","BLb1Dg4","u29zuMu","CMvHzhDYAxq","wffhs0K","B25SAw5L","yxrHlcbKyxq","rgXtzgG","v2DfrM0","C3nHz2vfDMu","vwv1wva","AMrpB04","uu9ivwK","ywXS","z2v0u3rVCMe","wxfMBM8","AxnszwfKEq","vujKv3m","reDKwxC","x3jLy29UBMu","ChHmB0C","CNzHBfzHBhu","r3rOrwu","v2nZsLq","zNvUy3rPB24","verszeu","tw9KDwXL","BwLUAvbYB2C","AwXLtMfTzq","Chn5swm","CwLJv1a","venmweC","DMfSDwu","ywDLsgLKzq","DMLJzuLeig8","AfjxvNO","quLbD3u","C2XPy2u","tM5Xq1q","rw9RBee","x29UugfNzu4","yLjcDhq","ywrK","vwPNww0","B25ozxr3B3i","t0HYsvq","Bg9NsurozxC","zw50zwqGDhK","x2XPC3rLBMu","Bg9N","x29UrxjYB3i","CMXxvKO","uxPbre8","CLvqvMi","zM5TDuO","Cgu6ia","DePWC3e","Ahr0Chm6","D0ngCxu","BMCGB3iGyw4","EKT1u3u","wxP5Cg0","zw1LBNq","BMrLEa","BfjHrM0","u2XwEu4","y2fSBa","y29UBMvJDa","AMvhqLC","vur5r2W","ChjpCeS","CevWEhu","CKflrxG","DerTtfO","EKvYsLe","B3jpBMXPBMu","x2rItMfTzq","AMvJDfn0B3i","AvLqseK","Cen1Avq","rxjYB3jdB2q","sNfID0W","DfD5qKy","qvncC1C","C3rYAw5NAwy","u216vw8","zeHdAfC","t3bLBKv2zw4","x3nVy2TLDa","AwrI","BIWGAg9ZDg4","x3jLBw92zvC","sfLABNu","uejbAhm","u3vjA2e","AvfsEuW","DvftrNO","CgLUz0XVC3m","A2HSBKm","y1z2z1C","B2nRzxq","tuvtu0fhrv8","qKP3u2u","Dxrjza","uu1LC3u","qxrKy3e","sxfdCw4","Exjxr1m","yNvMzMvYzwq","B25JBg9Zzq","EKTbwve","qMfHCNe","zxjFAxnFywm","v2TnBvO","ywnRtxnNswq","lcbxzwjtB2m","D3nJy3e","ChrVCG","s0fqrgm","AgfNCKC","A3jNDLG","C0jf","BgLTAxq","uhDMrwC","tNPLCKe","CgLnC1m","y2uGBM90igK","Curhweu","qLfvwgG","sfnRt2O","uLjpuG","Cgf5Bg9Hzfq","A3DPC00","ihrPBwvVDxq","u3rYyxrLz3K","CMvWBgfJzq","zhfUyNu","Ae55u0O","rLDt","Bhm6ia","DNjiA0S","Bwf4uMv0CMK","BMCGzMfPBgu","zerzuhi","AM9PBG","Bfjvy1G","zNjVBNrPzxi","zufJAW","uMTyrfa","wuD1ueG","zNjVBunOyxi","terique","y2T1thK","Cg93","Ef9MCM9UDgK","ExboEhi","ywnRx2nVzgu","AgfZ","BMfTzq","BwvKAwf0zwW","zwrPyxrLBhK","zgHfvfe","vePcz1O","qMnqDNC","DwD1q2O","uxj4rMu","ru93vMi","ywWGy3vYC28","AfDIteW","sMfcEe0","EMnRvfG","zwfkCeO","sfDevfq","ELvmyK4","x3fVC0rc","rK92vMy","x3DZ","ANjYuLy","u01ZA0u","C2v0u3rVCMe","zLnbt0y","mtC0ndm4qNHjte5m","uuv4Exe","AvPiANK","ruXWD0O","zNjVBujPDhm","zw5HyMXLvhi","C3bSAwnL","EMzuwKG","Bunrsgy","r0fyDw4","zNDdzLq","ihrVihjLDhi","q2T5t3y","Dfj2D3q","x3bPBMC","yw5Hz2vY","x2LZv29YA2u","ENfRvuy","B25nzxnZywC","BMvY","zxmGCMvHy2G","teP5yw0","x2rLC3rYB3K","u2LWr1m","CfHZvKq","AwzNzwG","AxjLza","vNfkwgO","C21XvwC","CMvKDwnL","ANjHvK4","uMHvqMq","qK9Szxq","ignVzgu6ia","AMjSzfa","quLrrMy","zMXiCgW","ywP5uuq","zMX1C2HfEha","uvbWqxy","rxL6rfa","suXMv3u","zezoqvu","B2TRr1G","Aw5KzxHpzG","BMDLza","x2rYB3bhBg8","DLb6q0K","Bg93","A2v5","CM92AwrLigi","CMvXDwLYzwq","qwvmAeS","z2v0qwXSs2u","rLjptLrjrvi","DgfIyxnL","yxKSig5LDhC","teDNteO","AKn4CeW","BNjwBgG","igzHAwWSig0","rKHHzvO","y3r4","zLrsDNe","ALL4Cgy","zxjYB3i","rxzLBNq","C29YDa","A1n0yxr1C0m","zKHRCw0","AMrbyvO","Bw1pBxq","DurHyNa","y29UBMvJDgK","zxnsCey","x2nSzwfYugK","D2vI","y3ftENG","BgLLy2K","C2vUza","D3jPDgvvAw4","ywLUsfO","tLnpC20","DhDesMC","wgHZvMK","tNvKz2q","B25iAwu","x2n1CNnVCK0","q0DqvMm","y2HLy2Tszwe","qwjVCNrfCNi","zMLVzum","DvfzvwS","wfP5shq","CMfuEhm","t29mB3C","u1PlDvi","tM9Utfe","C2XqDMm","zgvMAw5Luhi","y29UBMvJDeu","DgvmB2Djre4","DxrMofDYAxq","CgXLyxnLiha","CM92AwrLihy","B3jivxu","uw5Ovfm","CgfNzxnOB3C","rKvOugq","mdaWmdaWmda","qKDvq3K","x2LUAxrhBg8","B3bLCNr5","tvf0B00","C0nVDw50zxi","qK96zK8","rKLxsvq","zMnWyM0","CgjICdi","B2LUDfjLywm","uM5juhO","x21LC3nHz2u","AMXdCeW","x1fVu01HBMe","uvb3r1a","tgz6EfG","zLjtu0K","BhrPCgXLihq","s3PmCuK","ELPcELy","rfvKtLK","zuPZB3u","AwXLx25HBwu","Ehrpqvq","DxjS","BNrbBMrvCgq","DK9yCeO","AevYCM9Yrxy","y3jLyxrLt3a","ywjVCNq","tgLZDgvUzxi","mtaXnJi5nZDOvLjYr3C","CNjVCK1LC3m","y2r1wxu","vM1QC20","AxnrB1nnzxm","B2jYwuO","qLjXy2u","x2HHBMrSzu8","x2rPC2nVBM4","AMPlyNy","ENDYANq","uKjqtu8","nJzUrLrlrva","r0nvEfq","Cg9PBNrbBMq","y2XLyxjtDg8","x2HHBMrSzvi","y3jLyxrLq2W","BNvYy3a","AerswMu","z29PBMCGyxC","qunXAMC","zxj2AwnL","v2rjzu4","B0r4sg8","zwn0","D2fZq2XLyw4","BeXhzLa","igzPzwXKoIa","zwnVBM5Ly3q","Aw5Lza","wNfUCMe","DxHSuMm","B3bLBKrc","z2vrDwv1zuW","DeHOuKi","vfjxA2m","ve5sELG","x29WDgLVBNm","t291CMW","wNzbAKu","ugHlDxa","tKj1wu0","Cen6t2K","reiGzMfPBgu","Dev2zw50","AejgEe8","y2HLy2TdDxi","zMLSDgvY","z3nlq3C","tNH4v0y","DgHLBG","BgTRwve","B25dBg9Zzq","BM9Uzv9UB24","v3LgwMq","yMfSu2nVCgu","AenSB3nLrxy","zvvYBa","ywXty29Wzq","zw5HyMXLuw8","B3jL","suPNEhC","y0DTvK0","C2v0q3vYC28","zw5JB2rPBMC","s2LKu0u","x29Ut3bLBG","t1bftG","zxfituS","DcbVzIbYyw4","seHdBKq","r0L1vxa","zMLUza","B0rps0y","D29Avey","q0Xpu0LorW","vu5VAuS","t2jQzwn0","z3nltey","v0DSDxC","CeHey3y","y2XVC2uSihC","uuDWEKG","mJq4mZi4BgPoENzU","CMrWtNu","wKvjBKi","ALbtveK","tK1ICeS","CuDID2C","yNL0zu9MzNm","s25ZBKG","Dgv4Dc9WBge","CgfYC2u","CuzAA3m","CwPoBKW","EsbJBg9Zzwq","yLnOC3m","zNveCxK","zM9Yy2u"];return Ir=function(){return n},Ir()}var xc,oc,ac,Wi,Cr,ji,br,Ar,Tr,Tn,cc=uc({"node_modules/idb/build/wrap-idb-value.js"(){let n=O,e={hvdMv:function(i,o,a){return i(o,a)},qFZks:function(i,o,a){return i(o,a)},ZPgWl:function(i,o){return i(o)},fyGDR:"RpySG",nvtFm:n(1247),AbisL:n(919),jPSTI:function(i,o){return i===o},MNYbd:n(1680),oZBgJ:function(i,o){return i!==o},IGEKP:n(719),MQEfw:function(i,o){return i instanceof o},Khbpz:function(i,o){return i===o},WxGho:function(i,o){return i in o}};xc=(i,o)=>o.some(a=>i instanceof a),Wi=new WeakMap,Cr=new WeakMap,ji=new WeakMap,br=new WeakMap,Ar=new WeakMap,Tr={get(i,o,a){let c=n,f={qZULa:function(x,l,h){return x(l,h)}};if(i instanceof IDBTransaction)if(e[c(979)]===e[c(1682)])e[c(1721)](_0x29edfb,_0x22fa22,24),e[c(1492)](_0x441f88,_0x4e792c,e[c(1543)](_0x607062,_0x545a78));else{if(o===e[c(1684)])return Cr[c(376)](i);if(e[c(1485)](o,c(387)+c(951)))return i[c(387)+c(951)]||ji[c(376)](i);if(e[c(1485)](o,e[c(818)])){if(e[c(1635)](c(373),e[c(402)]))return a["objectSt"+c(951)][1]?void 0:a["objectSt"+c(1459)](a[c(387)+c(951)][0]);_0x4223f7(_0x53b9fc,74),f[c(384)](_0x5adf47,_0x19684d,_0x57ddd9)}}return et(i[o])},set(i,o,a){return i[o]=a,!0},has(i,o){let a=n;return e.MQEfw(i,IDBTransaction)&&(e[a(1744)](o,e[a(1684)])||e[a(1485)](o,e[a(818)]))?!0:e.WxGho(o,i)}},Tn=i=>Ar[n(376)](i)}}),lc={};Ml(lc,{deleteDB:()=>Wl,openDB:()=>jl,unwrap:()=>Tn,wrap:()=>et});function jl(n,e,{blocked:i,upgrade:o,blocking:a,terminated:c}={}){let f=O,x={gZrCt:function(y,v,k,w,E){return y(v,k,w,E)},uDabp:function(y,v){return y(v)},bUzHY:f(1722),KHVpS:f(674)+f(1574),Nxhyv:"upgraden"+f(631),NqGpU:f(820)},l=indexedDB.open(n,e),h=et(l);return o&&l["addEvent"+f(1397)](x[f(422)],y=>{let v=f;x.gZrCt(o,x[v(1329)](et,l[v(1610)]),y.oldVersion,y[v(464)+"on"],et(l["transact"+v(514)]))}),i&&l[f(1021)+f(1397)](x[f(930)],()=>i()),h[f(1449)](y=>{let v=f;c&&y[v(1021)+v(1397)](x[v(1599)],()=>c()),a&&y[v(1021)+"Listener"](x[v(871)],()=>a())})[f(641)](()=>{}),h}function Wl(n,{blocked:e}={}){let i=O,o={kwisM:i(820),KidSE:function(c,f){return c(f)}},a=indexedDB[i(857)+i(1312)](n);return e&&a[i(1021)+"Listener"](o[i(1208)],()=>e()),o[i(1464)](et,a)[i(1449)](()=>{})}function dc(n,e){let i=O,o={jrrRV:i(1079)+"e",ISmaF:i(651),EvCSF:function(l,h){return l in h}};if(!(n instanceof IDBDatabase&&!o[i(1730)](e,n)&&typeof e===i(1627)))return;if(Sr[i(376)](e))return Sr[i(376)](e);let a=e[i(1211)](/FromIndex$/,""),c=e!==a,f=pc[i(1763)](a);if(!(a in(c?IDBIndex:IDBObjectStore)[i(625)+"e"])||!(f||gc[i(1763)](a)))return;let x=async function(l,...h){let y=i,v=this[y(664)+y(514)](l,f?o[y(1253)]:o[y(1695)]),k=v[y(1680)];return c&&(k=k[y(1503)](h[y(433)]())),(await Promise[y(1089)]([k[a](...h),f&&v[y(919)]]))[0]};return Sr[i(1737)](e,x),x}var gc,pc,Sr,Kl=uc({"node_modules/idb/build/index.js"(){let n=O,e={QqBiM:n(906)+n(382),bTTrm:n(376),lUXOy:"getKey",YRUVn:n(1678),WBmDI:"getAllKeys",nGxyR:n(1590),dbrbY:n(1118),csHcQ:n(1661),dhQnH:n(1790),onHie:function(a){return a()},hagrG:function(a,c){return a(c)}},i=e[n(416)][n(677)]("|"),o=0;for(;;){switch(i[o++]){case"0":Sr=new Map;continue;case"1":cc();continue;case"2":gc=[e[n(453)],e[n(878)],e[n(1708)],e[n(1658)],e[n(1792)]];continue;case"3":pc=[n(1035),e[n(746)],e[n(659)],e[n(1005)]];continue;case"4":e[n(1343)](cc);continue;case"5":e[n(1195)](Hl,a=>({...a,get:(c,f,x)=>dc(c,f)||a.get(c,f,x),has:(c,f)=>!!dc(c,f)||a[n(1233)](c,f)}));continue}break}}}),$l={idb:function(n){let e=O,i={jrFoY:function(o,a,c){return o(a,c)},LpahW:e(602)};n[e(990)]=Promise.resolve()[e(1449)](()=>(Kl(),lc))[e(1449)](function(o){let a=e;if(i.LpahW==="WqDJs")return o;i[a(1533)](_0x47f24c,_0x2d2f9c,90),_0x15d41f(_0x5a926e,_0x54fae8)})}},fc={};function Qe(n){let e=O;var i=fc[n];if(i!==void 0)return i[e(990)];var o=fc[n]={exports:{}};return $l[n](o,o[e(990)],Qe),o[e(990)]}(()=>{let n=O,e={ifgeh:function(i,o){return i(o)},piMsS:function(i){return i()},Fphwf:n(987),ELpwJ:n(751)};Qe.d=(i,o)=>{let a=n;if(e.Fphwf!==e[a(1260)])for(var c in o)Qe.o(o,c)&&!Qe.o(i,c)&&Object["definePr"+a(1369)](i,c,{enumerable:!0,get:o[c]});else EKTBQz[a(1282)](_0x519229,_0x4b9cb5.error),EKTBQz[a(1201)](_0x5071cc)}})(),(()=>{let n=O;Qe.o=(e,i)=>Object[n(625)+"e"][n(1604)+n(1369)].call(e,i)})(),(()=>{let n=O,e={NjFaG:function(i,o){return i!=o},uNRLO:"undefined",udnge:n(1102),KTZnB:n(572)+"le"};Qe.r=i=>{let o=n;e[o(1605)](e[o(551)],typeof Symbol)&&Symbol[o(1586)+o(445)]&&Object[o(1356)+o(1369)](i,Symbol[o(1586)+o(445)],{value:e.udnge}),Object[o(1356)+o(1369)](i,e[o(473)],{value:!0})}})();var pe={};(()=>{let n=O,e={Oourl:function(s,t){return s(t)},HvjNy:function(s,t){return s+t},HSkOj:function(s,t){return s+t},SRCKB:function(s,t){return s*t},IvHIm:function(s,t){return s*t},rYGij:n(1722),dYMzB:n(674)+n(1574),ezkDp:function(s,t){return s===t},TGpoA:"IICuc",iQRyL:n(1155),XhsVi:function(s,t){return s+t},XIzHx:function(s,t,r){return s(t,r)},cduYu:function(s,t){return s(t)},TyTBw:function(s,t,r){return s(t,r)},iPaVg:function(s,t){return s(t)},WdIeN:"0000",PBAhs:"ffff",xicnX:"0000000000000000"+n(1366)+"00000000",Iyfhh:n(899),kTBuJ:function(s,t){return s>t},QcJxL:function(s,t){return s!==t},ACqjg:function(s,t){return s-t},cdLzP:function(s,t){return s<t},BQjxg:function(s,t){return s-t},Yzypm:function(s,t){return s===t},WGluw:function(s,t){return s!==t},vWSlK:n(704),rFmCe:n(557),DlSdh:function(s,t){return s(t)},ecOTr:function(s,t){return s>>>t},sHFfk:function(s,t){return s(t)},BJwSe:function(s,t){return s(t)},aMnhg:n(929)+n(1308)+" field: key",KxkFl:function(s,t){return s(t)},aPOTZ:function(s,t){return s<<t},pHTgW:function(s,t){return s&t},nGJuG:n(774),bqMsx:function(s){return s()},hNySJ:n(1118),dpclA:"clear",GzkFX:n(376),fyWvq:"getKey",SARXO:"count",iYPHI:function(s,t){return s!==t},ivpsK:function(s,t,r){return s(t,r)},Duodg:function(s,t){return s!==t},LGgLJ:function(s,t,r){return s(t,r)},qBYcp:function(s,t){return s!==t},XFZtb:n(604),jYxpf:function(s,t,r){return s(t,r)},Rdugt:function(s){return s()},cmCYq:function(s,t,r){return s(t,r)},qJcSz:function(s,t){return s!==t},hqxqW:function(s,t,r){return s(t,r)},tUYjl:function(s,t){return s!==t},FEhPd:function(s,t){return s!==t},oJvcI:function(s,t,r){return s(t,r)},qqBTJ:function(s,t){return s(t)},NJsFg:function(s,t){return s(t)},esRpF:function(s,t){return s+t},WyFZd:function(s,t){return s+t},WkMmZ:function(s,t){return s&t},TBQtc:function(s,t){return s<<t},hJTFW:function(s,t){return s|t},Isfih:function(s,t){return s<<t},SMskE:function(s,t){return s&t},UwkRw:function(s,t){return s<t},SrMLH:function(s,t){return s>=t},GdhDy:function(s,t){return s(t)},RWjGA:function(s,t){return s===t},rojCx:n(1438),BqXjU:function(s,t){return s(t)},WfhFh:function(s,t,r){return s(t,r)},jdAaZ:function(s,t){return s(t)},lieci:function(s,t,r){return s(t,r)},SDOWT:function(s,t,r){return s(t,r)},fDwQs:function(s,t){return s(t)},Hujjp:function(s,t){return s(t)},GGCaV:function(s,t,r){return s(t,r)},rMjxt:function(s,t){return s===t},krgvX:n(929)+n(1308)+n(1426)+"LogID",AdZjf:function(s,t){return s===t},UvkdW:n(929)+n(1308)+n(1426)+"service",Yxfpj:function(s,t){return s(t)},zbcfS:function(s,t){return s+t},MFCgb:function(s,t,r){return s(t,r)},dIlwH:n(411)+n(1123)+n(1131),WSZpD:function(s,t){return s!==t},VqJXj:function(s,t){return s>>t},iaDQW:n(1145),jPXem:function(s,t){return s>t},oOrDr:function(s,t){return s+t},cKTth:function(s,t){return s>=t},AIQFf:function(s,t){return s>t},XYUWO:n(1727)+n(1513),HWDTT:function(s,t,r){return s(t,r)},wdQHG:n(720)+"t",POroj:"start",TLjcA:function(s,t,r){return s(t,r)},hXYJK:function(s,t){return s===t},rYuMC:function(s,t){return s&t},muANC:function(s,t){return s===t},FECzh:function(s,t){return s>=t},mrloE:function(s,t){return s!==t},vPzCI:function(s,t){return s&t},ZuHuV:function(s,t){return s!==t},KtmYf:"orWTI",KzLqI:function(s,t){return s<<t},HAfaj:function(s,t){return s&t},tacZG:function(s,t){return s==t},prOpK:function(s,t){return s&t},JscbU:function(s,t){return s+t},aKLjp:function(s,t){return s+t},BTfQv:function(s,t){return s+t},jJslb:function(s,t){return s|t},itXpz:function(s,t){return s|t},gKSGK:function(s,t){return s<<t},VhMTP:function(s,t){return s&t},vrHkK:function(s,t){return s&t},tCQBi:function(s,t){return s<t},bKIPo:function(s,t){return s<=t},aXnQV:function(s,t){return s(t)},JSsVp:function(s,t){return s==t},tJHqu:function(s,t){return s>=t},EoklA:function(s,t){return s+t},TTsdj:function(s,t){return s+t},cvmUa:function(s,t){return s!==t},HooEI:function(s,t){return s&t},zUosG:function(s,t){return s|t},SoeCP:function(s,t){return s|t},xMKtz:function(s,t){return s&t},hjLwJ:function(s,t){return s<<t},BGUCy:function(s,t){return s>t},ADJXo:function(s,t){return s+t},KAPDc:function(s,t,r){return s(t,r)},uLxmv:function(s,t){return s!==t},YtRwv:n(1288),jheUI:function(s,t){return s>=t},uyTSS:function(s,t){return s+t},fcpbm:function(s,t){return s+t},zfTZH:function(s,t){return s<t},qAcyL:function(s,t,r){return s(t,r)},wsccq:function(s,t){return s<t},yfohV:function(s,t){return s<t},tWQMm:function(s,t){return s-t},HEUZR:function(s,t){return s<t},hzngV:function(s,t){return s|t},yhqJO:function(s,t){return s>>t},NnqCT:function(s,t){return s&t},UNoiK:function(s,t){return s>>t},SoLxZ:function(s,t){return s|t},XclJP:function(s,t){return s&t},klvOA:function(s,t){return s|t},rUPVb:function(s,t){return s&t},BSRni:n(616),wdHZr:function(s,t,r){return s(t,r)},Nudgd:"lvSpw",VmJkM:n(764),wWalz:n(1425),GIuUp:function(s,t,r){return s(t,r)},AmAFv:function(s,t){return s&t},fRGJd:function(s,t,r){return s(t,r)},UeMvp:function(s,t){return s&t},jutoL:function(s,t){return s||t},rBZRl:function(s,t){return s&t},KLApn:function(s,t){return s&t},jPFbC:function(s,t){return s&t},Zocye:function(s,t){return s&t},yrWGS:function(s,t){return s(t)},GbWdA:function(s,t){return s&t},kzNRT:"lnvgE",WMGdg:function(s,t){return s(t)},BWbIV:function(s,t){return s<<t},xCjlW:function(s,t){return s&t},seyvt:"zmmvn",vvGfQ:function(s,t){return s&t},Nskll:n(1219),UHbcy:function(s,t){return s&t},gkMPD:function(s,t){return s<<t},ziWmy:function(s,t){return s|t},fuDqy:function(s,t){return s>>>t},NMbpK:function(s,t){return s>>>t},juBja:function(s,t){return s===t},zZLMD:function(s,t){return s<t},JVzJa:function(s,t){return s<t},hGMDh:function(s,t){return s!==t},CziPU:function(s,t){return s|t},yOuLA:function(s,t){return s&t},rcoki:function(s,t){return s+t},ZzTUi:function(s,t){return s!==t},RVJRC:function(s,t){return s|t},ZIUvV:function(s,t){return s>>>t},tDmLZ:function(s,t){return s>>>t},QnhTS:function(s,t){return s+t},amcRM:function(s,t){return s|t},ainHZ:function(s,t){return s>>>t},PhKup:function(s,t){return s>>>t},xcIFb:function(s,t){return s+t},iepgF:function(s,t){return s>>>t},AAzvp:function(s,t){return s&t},IJgxw:function(s,t){return s>>>t},KbpuF:function(s,t){return s|t},pQWkK:function(s,t){return s!==t},DHFCC:function(s,t){return s+t},tWyBF:function(s,t){return s>>>t},ijjMe:function(s,t){return s+t},QExyq:function(s,t){return s|t},dhETQ:function(s,t){return s>>>t},pEpxu:function(s,t){return s>>>t},jCxpL:function(s,t){return s&t},cslzS:function(s,t){return s|t},YFnVE:function(s,t){return s|t},Jtgci:function(s,t){return s|t},wDwBY:function(s,t){return s<<t},twDJg:function(s,t){return s|t},SSNhK:function(s,t){return s<<t},JrAid:n(1578),oDxHo:"UdGbs",OyIDL:function(s,t){return s|t},wGlDH:function(s,t){return s<<t},JDmsH:function(s,t){return s<<t},EyzDP:function(s,t){return s|t},JkjvS:function(s,t){return s|t},sjoct:function(s,t){return s<<t},lMtZt:function(s,t){return s<<t},fwCfT:function(s,t){return s<<t},SZKuR:function(s,t){return s|t},SKNAj:function(s,t){return s|t},LvEDZ:function(s,t){return s<<t},LMNFQ:function(s,t){return s>>>t},YWrCj:function(s,t){return s<<t},fdgjt:function(s,t){return s<<t},okkGX:function(s,t){return s&t},IJVSA:function(s,t){return s&t},uEFEx:function(s,t){return s>>>t},MTQbh:function(s,t){return s&t},oJoWt:function(s,t){return s>>>t},rAKEx:function(s,t){return s(t)},CMfYw:function(s,t){return s%t},hPVKI:function(s,t){return s|t},JqbwL:n(1788),LScOs:function(s,t){return s+t},gsKLF:function(s,t){return s>>>t},phacQ:function(s,t){return s>>>t},BQUXh:function(s,t){return s>>>t},IWHpF:function(s,t){return s===t},mXKFK:function(s,t){return s&t},ExYdo:function(s,t){return s&t},QFnAD:function(s,t){return s>>>t},FLRsN:function(s,t){return s&t},KxgNL:function(s,t){return s>>>t},tUKdl:function(s,t){return s+t},OPHGi:function(s,t){return s!==t},UZooM:function(s,t){return s===t},SKujB:function(s,t){return s>>>t},VaOZG:function(s,t){return s===t},uguCj:function(s,t){return s===t},KnsnH:function(s,t){return s===t},rlWVJ:function(s,t){return s+t},QPpAv:function(s,t){return s>>>t},IMxPR:function(s,t){return s>>>t},UMsqm:function(s,t){return s&t},BGpWF:function(s,t){return s>>>t},zKsli:function(s,t){return s>>>t},TCLXG:function(s,t){return s&t},BlsNC:function(s,t){return s>>>t},OnRns:function(s,t){return s>>>t},iZjIJ:function(s,t){return s>>>t},LfzxX:n(938)+n(476),wVGFx:n(1177)+n(1070),hWbLL:n(750)+"OR",mFbXy:n(913)+n(1206),jbfIH:n(1504)+n(1733),fnfEU:n(533),KpDnV:function(s,t,r){return s(t,r)},nzxcA:n(1440),pcciq:function(s,t){return s>=t},ajyQD:function(s,t){return s===t},vOzeX:n(1339),KcLJu:n(462),GpuQV:function(s,t){return s===t},yGwar:n(1228),RwmOh:n(386),bShss:function(s,t){return s instanceof t},iZHjy:function(s,t){return s+t},ytzpj:n(1660)+"d error.",RpRjV:function(s,t){return s+t},bWptt:function(s,t){return s!==t},lGAWE:n(444),NQvfb:function(s,t){return s===t},BcPvw:n(1778),fnmuJ:"KuIBg",CLheH:function(s,t,r){return s(t,r)},QOpLt:n(1322),TJBgZ:function(s,t){return s<t},Atdcq:"NstEW",irzud:"ypSrw",KQtEo:n(733),NAiNv:n(481),JKeDw:function(s,t){return s instanceof t},OZnrP:n(1291),sxQCO:function(s,t){return s!=t},VxbFd:n(378)+"d",GthEe:n(722)+"4",UBdWs:function(s,t){return s||t},iYXdt:function(s,t){return s!=t},cwMxl:function(s,t){return s(t)},HpqBi:function(s,t){return s<<t},RPGHq:function(s,t){return s<<t},uQSFz:n(741),lhBhu:n(1598),bFOoy:function(s,t){return s===t},IwYbH:function(s,t){return s<t},qDGXE:function(s,t){return s|t},WgEFm:function(s,t){return s&t},zZBzV:function(s,t){return s&t},XQGKI:function(s,t){return s>=t},ZMetD:function(s,t){return s|t},twqkI:function(s,t){return s<<t},QkaEr:function(s,t){return s-t},aUCrZ:function(s,t){return s|t},fADSt:function(s,t){return s|t},niuoi:function(s,t){return s&t},gTZXt:function(s,t){return s&t},DcxAW:function(s,t){return s>>t},jrXYk:function(s,t){return s<t},PmHhl:function(s,t){return s===t},QyXMG:function(s,t){return s===t},ykwGQ:function(s,t){return s+t},JpWRx:n(1003)+"0|4",cuRkT:function(s,t){return s+t},OQbkb:function(s,t){return s+t},ueElH:function(s,t){return s|t},jeGBW:function(s,t){return s&t},aBhzS:function(s,t){return s>>t},smqUg:function(s,t){return s|t},XJFbf:function(s,t){return s|t},nrVlh:function(s,t){return s|t},uQYUk:n(1627),QrxFe:function(s,t){return s(t)},DDrif:function(s,t,r,d){return s(t,r,d)},nurcp:function(s,t){return s instanceof t},OFiQz:function(s,t){return s!=t},EeyEv:function(s,t){return s instanceof t},IRtni:function(s,t){return s!=t},PEecJ:n(1765)+"ion/json",pCzOi:function(s,t){return s==t},CCpTv:n(1490)+"in;chars"+n(597),FQavY:function(s,t){return s|t},QQkHZ:n(1242),dFNAU:n(809),xnVTE:function(s,t){return s&t},AFDIs:function(s,t){return s>>>t},hBAzY:function(s,t){return s<<t},GdGxB:function(s,t){return s===t},htBuJ:n(1536),qvfnC:n(1249),GovqC:"ymPiD",NonLQ:"unknown "+n(786),VBImq:function(s,t){return s(t)},lkkYQ:n(1758),kddOl:n(525)+n(654),tLOXz:function(s,t){return s+t},prEQy:"&jscallb"+n(403)+"tierJSONP",JUpUQ:function(s,t){return s===t},Gzksx:n(980),fHkqm:function(s,t){return s(t)},OtxPX:function(s,t){return s(t)},jEbpn:n(1165),jdOoN:function(s){return s()},eALvd:function(s,t,r,d){return s(t,r,d)},YqRYa:n(887)+"id",zbvyq:n(1091),NzerA:n(577),AMIgm:function(s,t){return s!==t},fadIa:"WrTjl",pycVV:n(946),fpkZH:n(519),NPvzl:function(s,t){return s||t},CJpmf:"Gatui",bgXGi:"HYXmx",mpVHm:function(s,t){return s||t},kAMOV:function(s,t){return s||t},YGuPH:function(s,t){return s||t},JaBxM:function(s,t){return s!=t},myqDX:function(s,t){return s!=t},YefCt:function(s,t,r){return s(t,r)},OULas:"qos",qhUae:"ReXkN",poSdC:function(s,t){return s(t)},KBdgN:function(s,t){return s(t)},RepFC:function(s,t){return s&t},IobuU:function(s,t){return s!==t},hrzbO:n(1281),MHdsd:n(950),PwfEg:function(s,t){return s<t},cZZtR:function(s,t){return s&t},Ftnre:function(s,t){return s&t},zErJQ:n(715),nkSgO:n(368),hkbKe:n(1230)+"er_qos",SnDUo:function(s,t,r,d){return s(t,r,d)},OgJXE:n(1230)+n(371)+"ck",tyJwW:n(1230)+n(1188)+"k",LmLYq:function(s,t,r){return s(t,r)},YRHVX:n(1230)+n(692)+n(466),iZLse:n(1099),XEyOh:function(s,t){return s<t},fTRvq:function(s,t,r,d){return s(t,r,d)},KckCB:function(s,t,r,d){return s(t,r,d)},VXeif:function(s,t){return s===t},sfYsN:n(895),CkyOv:n(401),MCRkD:n(840),QEWOZ:function(s,t){return s&&t},BNepe:n(660),CAYUN:n(1232),YpGQS:n(618),htsZe:function(s,t){return s(t)},unBUV:function(s,t){return s+t},wCFqu:function(s,t){return s+t},JTBeB:" + ",jjKbv:function(s,t){return s||t},dlXsD:function(s,t){return s instanceof t},fFdkl:n(1452)+"e",fSAOF:"binary",WsCQz:n(1690),wgCdm:function(s,t){return s(t)},woZTF:"index ou"+n(1468)+n(977),eoxPp:function(s,t){return s||t},GOiLR:n(1784),dLNIS:n(1686)+n(843)+"e",GAXun:function(s,t){return s>=t},kWfZP:function(s,t){return s+t},ooIRc:function(s,t){return s+t},PhBDf:function(s,t){return s+t},unYOk:function(s,t){return s+t},UWHth:function(s,t){return s+t},flHpl:function(s,t){return s|t},Pwdhu:function(s,t){return s<<t},AwrwO:function(s,t){return s+t},hDRZe:function(s,t){return s+t},FOvVf:function(s,t){return s|t},jprwC:function(s,t){return s+t},UbarX:function(s,t){return s+t},vnNOq:function(s,t){return s>>>t},uzTEU:function(s,t){return s&t},mhSCm:function(s,t){return s>>>t},hBFxO:function(s,t){return s&t},qaReD:function(s,t){return s&t},ZiSVp:function(s,t){return s+t},vOXpJ:function(s,t){return s>>>t},cbhbf:"QLDoa",hRWVz:function(s,t){return s+t},fyirA:function(s,t){return s+t},TcdeH:function(s,t){return s&t},pGpZe:function(s,t){return s+t},FsdTq:n(1072),ewHPs:function(s,t){return s>t},PAMlG:function(s,t){return s|t},DUdNY:function(s,t){return s|t},zNVFp:function(s,t){return s&t},XyEmd:function(s,t){return s<t},TDRdE:function(s,t){return s>>>t},ERIKt:function(s,t){return s|t},ayQtu:function(s,t){return s<<t},LDHAA:function(s,t){return s&t},SipGS:function(s,t){return s|t},zckTX:function(s,t){return s|t},WPhqB:function(s,t){return s|t},ypNxr:function(s,t){return s>>>t},NeaQX:function(s,t){return s&t},RUyda:"SskCQ",FIWIT:"VeEfy",EwntL:function(s,t){return s+t},fRAfO:n(1597),zpxZp:n(1234),HYZnu:n(426)+n(1420),xyKZp:n(1060),XZyHt:function(s,t){return s(t)},lDWof:function(s,t){return s(t)},GqBbX:n(595)+n(1389),CLGPx:function(s,t,r){return s(t,r)},ONzcB:function(s,t){return s+t},kGVYR:"FILE_NOT"+n(1704),MEtai:function(s,t){return s|t},ASBsW:function(s,t){return s!==t},hhihC:"dRvlZ",wTTez:n(1544),bBKZY:function(s,t,r){return s(t,r)},VYwHS:n(1685),obrYJ:function(s,t,r,d){return s(t,r,d)},ijChh:"INSTANT",zKAYQ:n(1638),gmTNc:function(s,t,r,d){return s(t,r,d)},QGpzH:function(s){return s()},DjsEa:n(1688),DoUXq:function(s,t){return s-t},QcGlt:function(s,t){return s!==t},SoYRe:"vfSey",klYGY:n(726),eQcsO:n(1230)+n(1552),SdxTF:function(s,t,r){return s(t,r)},BOzfO:n(1230)+n(468),lCZuX:function(s,t,r,d){return s(t,r,d)},oiIIR:n(798)+"s",dqnbu:n(867)+"rsor_name",bRBtt:"x-msg-cu"+n(882)+"ue",TEgGQ:function(s,t){return s>t},gsuEZ:function(s,t){return s+t},BzzIl:function(s,t){return s===t},NdkPv:n(1484),VjRrj:"ozeVw",uxlRc:function(s){return s()},CUpkP:function(s,t){return s===t},SwfhW:function(s){return s()},mmOmt:function(s,t){return s(t)},iBjkz:n(916),pSJZk:"zUSri",PJGqo:function(s){return s()},xcgDA:function(s,t){return s===t},GOLxx:function(s,t){return s===t},wGEEX:n(901),lRUcX:n(399),RmBQV:function(s){return s()},ZrZad:function(s,t){return s===t},Ywbic:"always",NHhaD:n(801),Jsiwo:"success",tZWYL:function(s,t,r){return s(t,r)},JXpuZ:function(s,t){return s===t},MUqjO:"yMqlo",HNLwU:n(1404),TAfLb:n(668),mqcFj:function(s,t,r){return s(t,r)},TeMJm:function(s,t,r){return s(t,r)},XgiyE:function(s,t,r){return s(t,r)},TNRzX:n(772),cVvgW:function(s,t){return s!==t},kINMT:function(s,t){return s(t)},DGdYw:n(1433),xtOAT:n(1278),bqUOK:function(s,t){return s>t},njKSi:n(613)+"fer",eJsou:n(1375),NxxWF:function(s,t){return s/t},qGbwg:function(s,t){return s==t},Maddg:n(1360)+n(1361)+n(848),qjNnL:n(1360)+n(850)+n(507)+n(1191)+n(415)+n(817)+"is undef"+n(1428),CsoCb:function(s,t){return s===t},QMesu:n(874),bEnle:n(927)+n(1236)+n(675)+"ct",tELuP:n(1081),CBPFU:n(579),zqkUF:n(1646),GevKf:n(1364),qicWP:function(s,t){return s!==t},EOvQc:n(1133),sUDOD:n(812),QJWxM:function(s,t){return s===t},xbXbe:"bd_did",FzaqD:"ttwid",pIrDn:n(1100),hXCZN:n(1333),RnIPz:"fws_1.0.0",gsKCw:function(s,t){return s===t},yQVAi:n(1411),ByHcd:function(s,t,r){return s(t,r)},slPvc:function(s,t,r){return s(t,r)},QnuxE:function(s,t){return s||t},EBbYW:function(s,t,r){return s(t,r)},PDuco:function(s,t){return s>t},sVFax:function(s,t){return s-t},GTgjS:function(s,t){return s===t},zDpUF:n(907),DsFKx:function(s,t){return s(t)},RkXDP:n(1311)+">",kMRxN:function(s,t){return s*t},oCiUp:function(s,t){return s-t},XUOuP:function(s,t){return s>t},DMNqj:function(s,t,r){return s(t,r)},sxvlY:"ping_once_timeout",cHnft:n(1418)+n(828)+n(720)+n(842)+n(393),hUzwu:function(s,t,r){return s(t,r)},ceYJH:n(1650)+n(1664)+"onnecting",RfOhq:n(1538),fKDzF:"message",GsNMj:"1|3|4|2|0",TGUuO:function(s,t){return s===t},ENdwz:"MISgO",wfCmf:"WMmhN",Khxza:function(s,t,r){return s(t,r)},ksNVb:function(s,t,r){return s(t,r)},fiEvw:n(991),orHUu:function(s,t){return s+t},qBFKo:n(731),IRlYI:function(s,t){return s===t},ctmHS:n(1480)+n(868)+n(1202)+n(417)+"ed",rySeL:n(1480)+n(396)+n(1494),AEpVY:n(1602),Fkjqw:function(s,t){return s instanceof t},EfkRZ:n(1360)+n(717)+n(1698)+n(1420),pxLoG:function(s,t){return s instanceof t},McNHU:function(s,t){return s(t)},vrmTF:"sent",yLszf:function(s,t){return s<t},FHaeZ:n(847),oDTnH:n(721)+"ame",lkvls:function(s,t){return s==t},SeiIO:n(803)+n(1427)+n(1654),VoILG:"QoUYn",kxdpg:function(s){return s()},xjEIl:function(s,t){return s!==t},pHDcv:"FHMxj",RBPMO:n(1636),dRmyp:n(427),oDXsA:"next() c"+n(877)+"ltiple t"+n(755)+"process",PxIrU:n(515),nPutn:"vQbDQ",MQtoM:n(996),Zqhks:n(1769),jraVN:function(s,t){return s*t},iVbKd:function(s,t){return s===t},ITBwL:function(s,t){return s!=t},Zpyrn:function(s,t){return s!=t},ljhae:n(1476),wtLKU:function(s,t){return s===t},FyYjp:"DedicatedWorkerGlobalScope",rZifd:function(s,t){return s===t},hfrbt:function(s,t){return s==t},yAkOQ:function(s,t){return s!=t},khuDH:function(s,t){return s!=t},xyQpU:function(s,t){return s===t},dHChW:function(s,t){return s===t},otZBO:n(694)+n(870)+n(1457),TwzJH:n(1628)+n(1618)+n(1454),StdTH:function(s,t){return s!=t},raTxs:function(s,t){return s!=t},Baarq:n(540)+n(918)};Qe.r(pe),Qe.d(pe,{FWS:()=>$d,CustomErrorEvent:()=>Rs,createCloseEvent:()=>He,ReconnectEvent:()=>ks,createErrorEvent:()=>Be,decodedFrame:()=>Lt,createOpenEvent:()=>zs,CustomCloseEvent:()=>Ls,createReconnectEvent:()=>ii,FrontierMessageEvent:()=>Os,encodeFrame:()=>_e,createMessageEvent:()=>Bs,OpenEvent:()=>Ms,ErrorCode:()=>xt,Event:()=>Mt,MessageEvent:()=>Ns});let i="";function o(s=""){let t=n,r="02",d=""+Date[t(839)](),u=i||(i=e[t(1437)](l,s)),p=Math[t(637)]().toString(16)[t(1113)](-6);return e.HvjNy(e[t(640)](r,d)+u,p)}function a(){let s=n;return e[s(1205)](e.SRCKB(1e4,Date[s(839)]()),Math[s(706)](e[s(1581)](1e4,Math[s(637)]())))}function c(s){let t=n;if(e[t(524)](e[t(1802)],e[t(1171)]))_0x501251&&_0x3b9054.addEventListener(mTjBxK[t(816)],()=>_0x1a953b()),_0x41e27c&&_0x59cdec[t(1021)+"Listener"](mTjBxK[t(490)],()=>_0xd2e824());else return e[t(1341)](Array(8)[t(1220)]("0"),e[t(1531)](parseInt,s,10)[t(1586)](2))[t(1113)](-8)}function f(s){let t=n;return e[t(1341)](e[t(1400)](Array,4)[t(1220)]("0"),e.TyTBw(parseInt,s,2)[t(1586)](16)).slice(-4)}function x(s){let t=n,r=s.split(/\./)[t(450)](p=>c(p)),d=[];return d[0]=e.iPaVg(f,e[t(640)](r[0],r[1])),d[1]=f(r[2]+r[3]),[t(897),t(897),t(897),t(897),e[t(1421)],e[t(1169)],d[0],d[1]].join("")}function l(s){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}/.test(s),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(s);return r?e.Oourl(x,s):d?e[t(1400)](h,s):e[t(685)]}function h(s){let t=n,r="",d=[],u=0,p=0,_=!0,b=e[t(1421)];if(s.indexOf("::")>-1)if(e[t(524)](e[t(483)],e[t(483)])){let g=s[t(677)]("::");for(let N=0;N<g[t(669)];N++){let B=g[N];if(e[t(487)](B.indexOf(":"),0)){let q=B.split(":");_&&(u=q[t(669)]),p+=q.length;for(let J=0;J<q[t(669)];J++)if(e[t(647)](4,q[J].length)){let V=b.substring(0,e[t(1419)](4,q[J][t(669)])),Re=V[t(766)](q[J]);d.push(Re)}else d[t(1054)](q[J]);_=!1}else{if(B[t(669)]!==4){let q=b[t(826)+"g"](0,e.ACqjg(4,B[t(669)])),J=q[t(766)](B);d[t(1054)](J)}else d[t(1054)](B);_&&(u+=1),p+=1,_=!1}}let T="";for(let N=0;e[t(584)](N,e[t(406)](8,p));N++)T=T[t(766)](b);for(let N=0;N<d[t(669)];N++)e[t(1137)](N,u)?e[t(1478)](e[t(492)],e[t(1560)])?(r=r[t(766)](T),r=r[t(766)](d[N])):this[t(1590)]++:r=r[t(766)](d[N]);return r}else{let g=e.XIzHx(_0x594ba7,_0x1289e5,_0x3e63d1.length);_0xd6004a.bytes.set(_0x1c306e,g)}{let g=s[t(677)](":");for(let T=0;e[t(584)](T,g[t(669)]);T++){let N=g[T];if(g[T][t(669)]!==4){let B=b[t(826)+"g"](0,4-g[T][t(669)]),q=B[t(766)](N);r=r[t(766)](q)}else r=r[t(766)](N)}return r}}function y(s,t){let r=n,d=s.key;e[r(1478)](void 0,d)&&(ce(t,10),e.XIzHx(me,t,d));let u=s[r(1108)];e[r(647)](void 0,u)&&(ce(t,18),me(t,u))}function v(s){let t=n,r={};e:for(;!$(s);){let d=e[t(1083)](ge,s);switch(e.ecOTr(d,3)){case 0:break e;case 1:r[t(1306)]=se(s,e[t(1563)](ge,s));break;case 2:r.value=se(s,e.BJwSe(ge,s));break;default:e[t(1516)](D,s,7&d)}}if(e[t(1137)](void 0,r.key))throw new Error(e.aMnhg);if(e.ezkDp(void 0,r[t(1108)]))throw new Error(t(929)+t(1308)+t(1426)+"value");return r}function k(s){let t=n,r={ILfWu:function(d,u){return e[G(1583)](d,u)},BAFIw:function(d,u){return e.aPOTZ(d,u)},TmXOr:function(d,u){return e[G(1719)](d,u)}};if(e.nGJuG!==e.nGJuG)_0x57fc1c=r[t(1298)](_0x3ba412,_0x4910e8),_0x23435b|=r[t(590)](r[t(1033)](127,_0x24f3e1),7);else{let d=e.bqMsx(C);return e[t(1531)](w,s,d),z(d)}}function w(s,t){let r=n,d={sVdho:e[r(1213)],ebLUC:e.dpclA,Omrwk:function(Le,qe){return Le(qe)},lqbAp:function(Le){return e.bqMsx(Le)},aTUsH:e.GzkFX,BfTkT:e.fyWvq,gRzPm:r(1310)+"ys",bQrNu:e[r(652)],DRfih:function(Le){return Le()}},u=s.SeqID;e[r(1154)](void 0,u)&&(e[r(1531)](ce,t,8),e[r(1062)](oe,t,u));let p=s[r(1705)];e.QcJxL(void 0,p)&&(ce(t,16),e[r(1062)](oe,t,p));let _=s.service;e[r(709)](void 0,_)&&(e.LGgLJ(ce,t,24),e[r(1516)](oe,t,e[r(1437)](R,_)));let b=s[r(471)];if(e[r(1612)](void 0,b))if(e[r(524)](e[r(617)],r(604)))e[r(1321)](ce,t,32),e.jYxpf(oe,t,e.KxkFl(R,b));else{let Le=(r(795)+"2|1")[r(677)]("|"),qe=0;for(;;){switch(Le[qe++]){case"0":_0x185315=[r(1035),KXCWzr[r(1041)],r(1661),KXCWzr[r(773)]];continue;case"1":KXCWzr[r(627)](_0x5119c5,Ft=>({...Ft,get:(St,It,ln)=>_0x242c98(St,It)||Ft[r(376)](St,It,ln),has:(St,It)=>!!_0x4f2d71(St,It)||Ft.has(St,It)}));continue;case"2":_0x23b838=new _0x5d3d4e;continue;case"3":KXCWzr.lqbAp(_0x30b177);continue;case"4":_0x5b08cb=[KXCWzr[r(691)],KXCWzr.BfTkT,"getAll",KXCWzr[r(1547)],KXCWzr.bQrNu];continue;case"5":KXCWzr.DRfih(_0x103db4);continue}break}}let g=s[r(400)];if(e.QcJxL(void 0,g))for(let Le of g){e.ivpsK(ce,t,42);let qe=e[r(1521)](C);e[r(1321)](y,Le,qe),e[r(1321)](ce,t,qe[r(1198)]),e[r(834)](ke,t,qe),P(qe)}let T=s[r(1616)+r(480)];e[r(709)](void 0,T)&&(e[r(1516)](ce,t,50),e[r(1314)](me,t,T));let N=s[r(1207)+r(412)];e[r(1012)](void 0,N)&&(e.LGgLJ(ce,t,58),e[r(1059)](me,t,N));let B=s[r(1683)];e[r(1053)](void 0,B)&&(ce(t,66),e[r(1531)](ce,t,B.length),e.hqxqW(ne,t,B));let q=s[r(841)];q!==void 0&&(e.jYxpf(ce,t,74),me(t,q));let J=s["serverTi"+r(997)];e.FEhPd(void 0,J)&&(e[r(1062)](ce,t,82),me(t,J));let V=s.msgID;e[r(709)](void 0,V)&&(ce(t,90),e[r(1314)](me,t,V));let Re=s[r(832)+"e"];e[r(1478)](void 0,Re)&&(e[r(1516)](ce,t,96),e.oJvcI(oe,t,e.qqBTJ(R,Re)))}function E(s){return S(e[n(728)](F,s))}function S(s){let t=n,r={};e:for(;!e[t(638)]($,s);){let d=e.KxkFl(ge,s);switch(e[t(947)](d,3)){case 0:break e;case 1:r[t(392)]=e[t(1516)](vt,s,!0);break;case 2:r[t(1705)]=e[t(1314)](vt,s,!0);break;case 3:r[t(1023)]=e[t(1057)](ge,s);break;case 4:r[t(471)]=ge(s);break;case 5:if(e[t(635)](e.rojCx,e.rojCx)){let u=e[t(989)](I,s);(r[t(400)]||(r[t(400)]=[]))[t(1054)](e[t(1400)](v,s)),s[t(1198)]=u;break}else _0x3569a0=_0x2c564e[e[t(1331)](e[t(1453)](_0x4889b2,_0x5c7329),1)],_0x255a91=_0x58020d[e[t(1331)](e.HSkOj(_0x146178,_0x50625a),2)],e[t(709)](e.WkMmZ(_0x423db0|e[t(499)](_0x4cbcce,8),49344),32896)?_0x554c80+=_0x275cbd:(_0x97f28f=e[t(1595)](e.Isfih(e.WkMmZ(15,_0x51e90e),12)|e.TBQtc(e.SMskE(63,_0x52e887),6),e[t(1719)](63,_0x2723f8)),e[t(1803)](_0x48cb84,2048)||e[t(1020)](_0x243ddd,55296)&&_0xee22d2<=57343?_0x3074bb+=_0x1ae7b1:(_0x47c53b+=e[t(936)](_0x21ea7b,_0x357959),_0x458ed3+=2));case 6:r[t(1616)+t(480)]=e[t(1509)](se,s,e[t(638)](ge,s));break;case 7:r[t(1207)+t(412)]=e[t(645)](se,s,e[t(1327)](ge,s));break;case 8:r[t(1683)]=e[t(1335)](j,s,e.iPaVg(ge,s));break;case 9:r[t(841)]=e[t(1314)](se,s,ge(s));break;case 10:r[t(865)+t(997)]=e[t(1773)](se,s,e[t(535)](ge,s));break;case 11:r[t(1031)]=e.TyTBw(se,s,ge(s));break;case 12:r[t(832)+"e"]=e[t(1055)](ge,s);break;default:e.GGCaV(D,s,e[t(1254)](7,d))}}if(r[t(392)]===void 0)throw new Error(t(929)+"required"+t(1426)+t(392));if(e[t(1525)](void 0,r[t(1705)]))throw new Error(e[t(1196)]);if(e[t(1781)](void 0,r[t(1023)]))throw new Error(e.UvkdW);if(r[t(471)]===void 0)throw new Error("Missing "+t(1308)+" field: "+t(471));return r}function I(s){let t=n,r=e[t(1699)](ge,s),d=s[t(1198)];return s[t(1198)]=e[t(534)](s[t(1749)],r),d}function D(s,t){let r=n;switch(t){case 0:for(;128&we(s););break;case 2:e.XIzHx(K,s,e[r(638)](ge,s));break;case 5:e[r(1739)](K,s,4);break;case 1:K(s,8);break;default:throw new Error(e.dIlwH+t)}}function R(s){let t=n;if(e[t(1053)](t(1467),"sOjIf"))return s|=0,{low:s,high:e.VqJXj(s,31),unsigned:e.SrMLH(s,0)};{let r=_0x457a66[_0x3befbf];if(e[t(526)](4,_0x2088b9[_0x1fef54][t(669)])){let d=_0x257f39.substring(0,4-_0x49845c[_0x311ec6][t(669)]),u=d[t(766)](r);_0x1024d4=_0x49e2ae[t(766)](u)}else _0x382775=_0x568ba6[t(766)](r)}}let m=[];function C(){let s=n,t=m[s(1718)]();return t?(t.offset=t[s(1198)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function P(s){m[n(1054)](s)}function F(s){return{bytes:s,offset:0,limit:s[n(669)]}}function z(s){let t=n;if(t(1671)!==e[t(827)]){let r=s.bytes,d=s[t(1198)];return r[t(669)]===d?r:r.subarray(0,d)}else throw this[t(1071)+t(537)]=!1,_0x3c0e26}function K(s,t){let r=n;if(e.jPXem(e[r(1030)](s[r(1749)],t),s.limit))throw new Error(r(1577)+"t limit");s[r(1749)]+=t}function $(s){let t=n;return e[t(1569)](s[t(1749)],s[t(1198)])}function L(s,t){let r=n,d=s.bytes,u=s[r(1749)],p=s[r(1198)],_=e[r(1030)](u,t);if(e[r(1292)](_,d.length)){let b=new Uint8Array(e[r(1528)](2,_));b.set(d),s.bytes=b}return s[r(1749)]=_,e[r(487)](_,p)&&(s[r(1198)]=_),u}function M(s,t){let r=n,d=s[r(1749)];if(d+t>s[r(1198)])throw new Error(e[r(886)]);return s[r(1749)]+=t,d}function j(s,t){let r=n,d=e[r(1248)](M,s,t);return s.bytes[r(1073)](d,d+t)}function ne(s,t){let r=n,d=e[r(1062)](L,s,t[r(669)]);s[r(998)][r(1737)](t,d)}function se(s,t){let r=n,d={UcvVM:function(T,N,B){return e[G(1531)](T,N,B)},EBlMJ:e[r(655)],TVmZP:e[r(666)]},u=e[r(1640)](M,s,t),p=String[r(1226)+r(771)],_=s[r(998)],b="\uFFFD",g="";for(let T=0;e[r(1803)](T,t);T++){let N=_[e[r(1341)](T,u)],B,q,J,V;if(e[r(1570)](e[r(941)](128,N),0))g+=p(N);else if(e[r(1756)](e[r(1189)](224,N),192))if(e[r(854)](e[r(640)](T,1),t))g+=b;else if(B=_[e.XhsVi(T+u,1)],e[r(582)](e.vPzCI(192,B),128))g+=b;else if(e.ZuHuV(r(636),e.KtmYf)){let Re=d.UcvVM(_0x1cdefa,d.EBlMJ,{message:d[r(939)]});this[r(932)+r(1427)]&&this.onStartReconnect(Re)}else V=e[r(1385)](e[r(1254)](31,N),6)|e.HAfaj(63,B),V<128?g+=b:(g+=p(V),T++);else e[r(380)](e[r(1146)](240,N),224)?e[r(443)](T,2)>=t?g+=b:(B=_[e[r(534)](e[r(391)](T,u),1)],q=_[e[r(681)](T,u)+2],e.WSZpD(e[r(1771)](B,q<<8)&49344,32896)?g+=b:(V=e.itXpz(e.gKSGK(15&N,12),e[r(1669)](e[r(1701)](63,B),6))|e[r(1216)](63,q),e[r(658)](V,2048)||e[r(854)](V,55296)&&e[r(1740)](V,57343)?g+=b:(g+=e[r(478)](p,V),T+=2))):e[r(992)](248&N,240)?e[r(1754)](e[r(1115)](T,3),t)?g+=b:(B=_[e.esRpF(e[r(770)](T,u),1)],q=_[e.zbcfS(T+u,2)],J=_[e[r(1331)](T+u,3)],e.cvmUa(e.HooEI(e[r(682)](B|q<<8,e[r(742)](J,16)),12632256),8421504)?g+=b:(V=e.hJTFW(e.itXpz(e[r(686)]((7&N)<<18,e.Isfih(e[r(1002)](63,B),12)),e.hjLwJ(e[r(1304)](63,q),6)),e.WkMmZ(63,J)),e.cdLzP(V,65536)||e.BGUCy(V,1114111)?g+=b:(V-=65536,g+=p(e[r(1453)](e[r(1284)](V,10),55296),e.ADJXo(e[r(1146)](1023,V),56320)),T+=3))):g+=b}return g}function me(s,t){let r=n,d={weIeh:function(g,T){return e.WGluw(g,T)},Xnukp:function(g,T,N){return e[G(1194)](g,T,N)},clvsK:function(g,T){return e.uLxmv(g,T)},UhOBc:function(g,T,N){return e.MFCgb(g,T,N)}},u=t[r(669)],p=0;for(let g=0;g<u;g++)if(e.qJcSz(e[r(806)],e[r(806)])){let T=_0x140426[r(1306)];HHpqjZ.weIeh(void 0,T)&&(HHpqjZ.Xnukp(_0x57918c,_0x1cb161,10),HHpqjZ[r(1038)](_0x56917b,_0x1bf55a,T));let N=_0x13a442[r(1108)];HHpqjZ.clvsK(void 0,N)&&(HHpqjZ[r(538)](_0x2fcd99,_0x3cc1bd,18),HHpqjZ[r(1038)](_0x4f54bd,_0x41ff0e,N))}else{let T=t[r(1657)+"At"](g);e[r(624)](T,55296)&&T<=56319&&e.uyTSS(g,1)<u&&(T=e[r(1374)](e[r(1741)](T,10),t.charCodeAt(++g))-56613888),p+=T<128?1:T<2048?2:e[r(1264)](T,65536)?3:4}ce(s,p);let _=e[r(888)](L,s,p),b=s[r(998)];for(let g=0;e[r(1192)](g,u);g++){let T=t[r(1657)+"At"](g);e[r(624)](T,55296)&&e[r(1740)](T,56319)&&e[r(407)](e[r(1453)](g,1),u)&&(T=e[r(501)](e[r(443)](T<<10,t[r(1657)+"At"](++g)),56613888)),e[r(1192)](T,128)?b[_++]=T:(e[r(757)](T,2048)?b[_++]=e.itXpz(e[r(1701)](e[r(1284)](T,6),31),192):(e[r(757)](T,65536)?b[_++]=e[r(914)](e[r(1002)](e.VqJXj(T,12),15),224):(b[_++]=e[r(1595)](e[r(1567)](T,18)&7,240),b[_++]=e[r(914)](e[r(1114)](e.UNoiK(T,12),63),128)),b[_++]=e.SoLxZ(e[r(978)](e[r(1475)](T,6),63),128)),b[_++]=e[r(855)](e[r(1129)](63,T),128))}}function ke(s,t){let r=n;if(e[r(1525)](e[r(1342)],e[r(769)]))this[r(431)](e[r(1675)],e.wdHZr(_0x5baf02,e[r(1675)],{..._0x3d79dd,data:_0x32e92a[r(469)]||""}));else{let d=L(s,t[r(1198)]),u=s[r(998)],p=t[r(998)];for(let _=0,b=t[r(1198)];e.HEUZR(_,b);_++)u[e.aKLjp(_,d)]=p[_]}}function we(s){let t=n;return e[t(1525)](t(1161),e.wWalz)?new _0x3047a6(_0x1a5880,_0x25de03,_0x2b1d6f):s[t(998)][e[t(1470)](M,s,1)]}function ft(s,t){let r=n,d=e[r(1640)](L,s,1);s[r(998)][d]=t}function ge(s){let t=0,r=0,d;do d=e.aXnQV(we,s),t<32&&(r|=e.AmAFv(127,d)<<t),t+=7;while(128&d);return r}function ce(s,t){let r=n;for(t>>>=0;t>=128;)e[r(790)](ft,s,e[r(587)](127,t)|128),t>>>=7;ft(s,t)}function vt(s,t){let r=n,d={PoLVU:"stop immediately"+r(675)+"ct"},u=0,p=0,_=0,b;if(b=e[r(1178)](we,s),u=e[r(740)](127,b),e[r(1623)](128,b)&&(b=e.BqXjU(we,s),u|=e.jPFbC(127,b)<<7,e[r(1655)](128,b)&&(b=e[r(1183)](we,s),u|=e[r(941)](127,b)<<14,e.GbWdA(128,b)&&(b=we(s),u|=e[r(1385)](127&b,21),128&b&&(b=we(s),p=e[r(1189)](127,b),128&b))))){if(e.kzNRT!==e.kzNRT){this[r(1279)+r(489)+"t"]();let g=_0x441485(r(720)+"t",{message:d[r(1045)]});this[r(838)+r(1235)+"yReconnect"]&&this["onStopIm"+r(1235)+"yReconnect"](g)}else if(b=e[r(835)](we,s),p|=(127&b)<<7,e[r(1216)](128,b)&&(b=we(s),p|=e[r(1052)](e[r(740)](127,b),14),e[r(863)](128,b)))if(r(1794)!==e[r(653)]){if(b=e[r(1563)](we,s),p|=(127&b)<<21,e[r(956)](128,b))if(r(1219)===e[r(558)])b=e[r(535)](we,s),_=e[r(1762)](127,b),128&b&&(b=e[r(1083)](we,s),_|=e[r(587)](127,b)<<7);else{let g=this[r(1250)][r(1090)+r(615)+"nc"](this[r(661)]),T=_0x1b0372[r(1491)](e.jutoL(g,"{}"));return _0x4301a2[r(873)](T)}}else this[r(1250)]?.close(),this._qosDB=void 0}return{low:e[r(914)](u,e[r(1018)](p,28)),high:e[r(900)](e[r(1496)](p,4),_<<24),unsigned:t}}function oe(s,t){let r=n,d=t[r(1305)]>>>0,u=e.ecOTr(e[r(900)](e[r(947)](t.low,28),e[r(1052)](t[r(410)],4)),0),p=e[r(1486)](t[r(410)],24),_=e[r(564)](0,p)?u===0?e[r(658)](d,16384)?d<128?1:2:e[r(1264)](d,2097152)?3:4:e[r(1264)](u,16384)?e[r(1050)](u,128)?5:6:e.JVzJa(u,2097152)?7:8:p<128?9:10,b=L(s,_),g=s[r(998)];switch(_){case 10:g[e[r(1030)](b,9)]=e[r(690)](p>>>7,1);case 9:g[b+8]=e[r(589)](9,_)?e.CziPU(128,p):e[r(457)](127,p);case 8:g[e[r(554)](b,7)]=e[r(957)](8,_)?e[r(1068)](e[r(975)](u,21),128):e.jPFbC(e[r(1149)](u,21),127);case 7:g[e[r(1363)](b,6)]=e[r(1365)](7,_)?e.amcRM(e[r(1338)](u,14),128):e[r(1146)](e[r(1439)](u,14),127);case 6:g[e[r(1732)](b,5)]=e.QcJxL(6,_)?e.CziPU(e[r(511)](u,7),128):e.AAzvp(e[r(1460)](u,7),127);case 5:g[e.XhsVi(b,4)]=e[r(881)](5,_)?e[r(665)](128,u):127&u;case 4:g[e[r(1374)](b,3)]=e[r(639)](4,_)?e.PhKup(d,21)|128:e[r(1304)](d>>>21,127);case 3:g[e[r(418)](b,2)]=e[r(1012)](3,_)?e[r(682)](e[r(1158)](d,14),128):e[r(1189)](d>>>14,127);case 2:g[e[r(880)](b,1)]=e[r(1154)](2,_)?e[r(1258)](e[r(1237)](d,7),128):e[r(1655)](e[r(1147)](d,7),127);case 1:g[b]=e[r(957)](1,_)?128|d:e[r(1315)](127,d)}}function Lt(s){return e[n(1327)](E,s)}function _e(s){return k(s)}let Nt=65536,Pe=e[n(600)],Ot=e[n(1287)](Nt,Nt),Ts=e.IvHIm(Ot,Ot),Ds=e.NxxWF(Ts,2),ut=String[n(625)+"e"][n(1657)+"At"];class re{constructor(t,r,d){let u=n;this[u(621)]=!0,this.low=e.cslzS(0,t),this[u(410)]=e[u(1541)](0,r),this[u(423)]=!!d}static[n(621)](t){return t&&t.isLong===!0}static[n(1261)](t,r,d){return new re(t,r,d)}static[n(585)+"s"](t,r,d){let u=n;return d?re[u(585)+u(633)](t,r):re[u(585)+u(1197)](t,r)}static[n(585)+n(633)](t,r){let d=n;return new re(e[d(855)](e[d(1539)](e[d(1621)](t[0],e.BWbIV(t[1],8)),e[d(723)](t[2],16)),e[d(1669)](t[3],24)),e[d(1340)](t[4]|t[5]<<8,e.SSNhK(t[6],16))|e.TBQtc(t[7],24),r)}static[n(585)+"sBE"](t,r){let d=n;return e[d(635)](e[d(711)],e[d(1422)])?_0x3878d4||(_0x561a0a=[_0x4018ed.prototype[d(1776)],_0x2c0060.prototype[d(626)],_0x81e441[d(625)+"e"]["continue"+d(866)+"ey"]]):new re(e[d(855)](e.YFnVE(e[d(679)](e.wGlDH(t[4],24),e[d(964)](t[5],16)),e.wDwBY(t[6],8)),t[7]),e[d(1297)](e[d(1786)](e.JkjvS(e[d(1703)](t[0],24),e[d(931)](t[1],16)),e[d(1267)](t[2],8)),t[3]),r)}static[n(619)](t){let r=n;return t===Pe?Ps:new re(e[r(1496)](e[r(1353)](e[r(852)](ut.call(t,0),e.LvEDZ(ut.call(t,1),8))|e[r(1669)](ut[r(1142)](t,2),16),ut[r(1142)](t,3)<<24),0),e[r(436)](ut[r(1142)](t,4)|e.wDwBY(ut[r(1142)](t,5),8)|e.YWrCj(ut[r(1142)](t,6),16)|e[r(458)](ut[r(1142)](t,7),24),0),!0)}toHash(){let t=n;return String[t(1226)+t(771)](e[t(1300)](255,this[t(1305)]),e[t(620)](e[t(981)](this.low,8),255),e[t(1615)](e.ainHZ(this[t(1305)],16),255),e[t(981)](this.low,24),e[t(740)](255,this.high),e[t(863)](e[t(985)](this[t(410)],8),255),e.tDmLZ(this[t(410)],16)&255,e.pEpxu(this[t(410)],24))}static[n(785)+"er"](t,r=!0){let d=n;if(e.rAKEx(isNaN,t))return r?sd:Ps;if(r){if(t>=Ts)return ad}else{if(t<=-Ds)return cd;if(e[d(1569)](e[d(1732)](t,1),Ds))return od}return re[d(1261)](e[d(1539)](e[d(671)](t,Ot),0),e[d(884)](t/Ot,0),r)}toNumber(){let t=n,r={yGCCh:function(d,u){return e[G(1137)](d,u)},fioeC:function(d,u){return e[G(501)](d,u)}};return e.JqbwL!==e[t(1157)]?!!(this[t(606)+"ndex"]>=this[t(1017)+"s"].length||r[t(1687)](this[t(606)+t(1139)],r[t(1348)](this[t(1017)+"s"][t(669)],1))&&r[t(1687)](this["currentE"+t(1620)+"riesCount"],this[t(1217)+"es"])):this.unsigned?e[t(698)](e[t(1581)](e[t(1477)](this[t(410)],0),Ot),e[t(705)](this[t(1305)],0)):this[t(410)]*Ot+e[t(1204)](this[t(1305)],0)}isZero(){let t=n;return e[t(1570)](0,this[t(410)])&&e[t(1625)](0,this[t(1305)])}[n(1118)](t){let r=n;re.isLong(t)||(t=re[r(785)+"er"](t));let d=e.ainHZ(this[r(410)],16),u=e[r(1501)](65535,this[r(410)]),p=this[r(1305)]>>>16,_=e.ExYdo(65535,this[r(1305)]),b=e[r(1579)](t[r(410)],16),g=e[r(780)](65535,t[r(410)]),T=e[r(541)](t[r(1305)],16),N=e.rYuMC(65535,t[r(1305)]),B=0,q=0,J=0,V=0;return V+=e[r(681)](_,N),J+=e[r(436)](V,16),V&=65535,J+=e[r(958)](p,T),q+=e[r(981)](J,16),J&=65535,q+=u+g,B+=q>>>16,q&=65535,B+=d+b,B&=65535,re[r(1261)](e[r(1595)](J<<16,V),e[r(855)](B<<16,q),this[r(423)])}[n(560)](t){let r=n;return re[r(621)](t)||(t=re[r(785)+"er"](t)),e.OPHGi(this[r(423)],t[r(423)])&&e[r(702)](e[r(408)](this[r(410)],31),1)&&e[r(680)](e[r(985)](t[r(410)],31),1)?!1:this[r(410)]===t[r(410)]&&e.uguCj(this[r(1305)],t[r(1305)])}[n(759)](){let t=n;return this[t(1305)]===-1&&e[t(1489)](-1,this[t(410)])?re[t(1261)](0,0,this[t(423)]):e[t(702)](-1,this[t(1305)])?re[t(1261)](0,e[t(1127)](this[t(410)],1),this[t(423)]):re[t(1261)](this[t(1305)]+1,this[t(410)],this[t(423)])}toBytes(t){return t?this.toBytesLE():this[n(1676)+"E"]()}[n(810)+"E"](){let t=n,r=this[t(410)],d=this[t(1305)];return[e[t(1300)](255,d),e.rUPVb(e[t(408)](d,8),255),e[t(1296)](d,16)&255,e[t(594)](d,24),e[t(971)](255,r),e[t(1527)](r,8)&255,r>>>16&255,r>>>24]}[n(1676)+"E"](){let t=n,r=this[t(410)],d=this[t(1305)];return[e[t(1782)](r,24),e[t(1107)](e[t(705)](r,16),255),e[t(689)](r,8)&255,e[t(1304)](255,r),e.OnRns(d,24),e[t(1304)](e.iZjIJ(d,16),255),e[t(620)](d>>>8,255),255&d]}}let Ps=new re(0,0,!1),sd=new re(0,0,!0),od=re.fromBits(-1,2147483647,!1),ad=re.fromBits(-1,-1,!0),cd=re[n(1261)](0,-2147483648,!1);var xt=(function(s){let t=n,r=e[t(1382)][t(677)]("|"),d=0;for(;;){switch(r[d++]){case"0":s[s[e[t(752)]]=5004]=e[t(752)];continue;case"1":s[s[e[t(1244)]]=5005]=e[t(1244)];continue;case"2":s[s[t(973)+t(1508)]=5002]=t(973)+t(1508);continue;case"3":return s;case"4":s[s[t(1662)+t(917)+"R"]=5003]=t(1662)+t(917)+"R";continue;case"5":s[s[e[t(607)]]=5001]=e[t(607)];continue}break}})({});class Mt{constructor(t){let r=n;this[r(1738)]=t,this.target=null}}class ks extends Mt{constructor(t,r){let d=n;super(t),this[d(1065)]=r&&r.message||null}}class Rs extends Mt{constructor(t,r){let d=n,u=e.jbfIH[d(677)]("|"),p=0;for(;;){switch(u[p++]){case"0":this[d(1065)]=r&&r[d(1065)]||"";continue;case"1":super(t);continue;case"2":this[d(1028)]=r&&r[d(1028)]||0;continue;case"3":this[d(821)]=r&&r[d(821)]||"";continue;case"4":this[d(726)]=r&&r[d(726)]||5001;continue;case"5":this.error=r&&r[d(1322)]||null;continue;case"6":this[d(662)]=r&&r.lineno||0;continue}break}}}class Ls extends Mt{constructor(t,r){let d=n;super(t),this[d(726)]=r&&r[d(726)]||0,this[d(786)]=r&&r.reason||"",this[d(1424)]=r&&r[d(1424)]||!1,this[d(1526)+d(424)]=r&&r["willReco"+d(424)]||!1}}class Ns extends Mt{constructor(t,r){let d=n;super(t),this[d(429)]=r&&r[d(429)]||null}}class Os extends Ns{constructor(t,r){let d=n;super(t),this[d(429)]=r&&r[d(429)]||null,this.message=r&&r[d(1065)]||null}}class Ms extends Mt{constructor(t,r){let d=n;super(t),this[d(429)]=r&&r[d(429)]||null}}function Be(s,{message:t,code:r,error:d}){return new Rs(s,{message:t,code:r,error:d})}function He(s,{code:t,reason:r,wasClean:d,willReconnect:u}){let p=n;if(e.fnfEU!==p(533)){if(!this[p(1252)])return;this["_destroy"+p(489)+"t"](_0x341769,_0x158adf,_0x20d114)}else return new Ls(s,{code:t,reason:r,wasClean:d,willReconnect:u})}function Bs(s,{data:t,message:r}){return new Os(s,{data:t,message:r})}function zs(s,{data:t}){return new Ms(s,{data:t})}function ii(s,{message:t}){return new ks(s,{message:t})}class Fs{constructor(t,r){let d=n;this[d(1017)+"s"]=t,this[d(1217)+"es"]=r,this[d(606)+d(1139)]=0,this.currentEndpointTriesCount=0}["resetEndpointCon"+n(902)](){let t=n;this[t(606)+t(1139)]=0,this["currentE"+t(1620)+t(419)+"t"]=0}[n(475)+"es"](){let t=n;this[t(940)+t(1620)+t(419)+"t"]=0}[n(656)+n(1775)+"nt"](){let t=n,r={ZYRPR:function(d,u,p){return e[G(559)](d,u,p)},hLdkh:function(d,u){return d>>>u}};if(t(829)===e[t(592)]){let{value:d,offset:u}=r[t(1735)](_0x32fdcb,_0x56413a,_0x3d201f);_0x20d0cd=u,_0x5b87a4=r.hLdkh(_0x476425<<8,0),_0x46061a+=d}else return this[t(1017)+"s"][this[t(606)+t(1139)]]}[n(656)+n(1775)+n(1751)+n(610)](){let t=n;return this[t(940)+"ndpointT"+t(419)+"t"]}[n(1346)+n(889)+"es"](){let t=n;return!!(e.pcciq(this[t(606)+t(1139)],this.endpoints.length)||e[t(1294)](this[t(606)+t(1139)],this.endpoints[t(669)]-1)&&this[t(940)+"ndpointTriesCount"]===this[t(1217)+"es"])}[n(1445)+n(1755)+n(1376)+n(1500)+n(1530)](){let t=n;return e.tacZG(this[t(606)+t(1139)],this[t(1017)+"s"][t(669)])?!0:e[t(1292)](this[t(940)+t(1620)+t(419)+"t"],this[t(1217)+"es"])}[n(1710)+n(984)+n(1412)+n(663)+n(1720)](){let t=n;return this[t(940)+"ndpointTriesCount"]=1,this[t(606)+t(1139)]++,this.endpoints[this[t(606)+"ndex"]]}[n(656)+n(1775)+n(1392)+n(933)](){let t=n;return this[t(940)+t(1620)+t(419)+"t"]++,this[t(656)+t(1775)+"nt"]()}}let Bt=(e[n(611)]!=typeof globalThis&&e.iVbKd("Window",globalThis[n(1037)+n(1692)][n(1234)])||e[n(673)](e.VxbFd,typeof window)&&window[n(1037)+n(1692)][n(1234)]==="Window")&&e[n(1608)](n(378)+"d",typeof document),bt=e.VxbFd!=typeof globalThis&&(e[n(1791)]===globalThis[n(1037)+n(1692)].name||e.wtLKU(e[n(1502)],globalThis[n(1037)+n(1692)].name))&&n(378)+"d"!=typeof tt,un=(e[n(611)]!=typeof globalThis&&e.rZifd(e[n(1791)],globalThis[n(1037)+"tor"].name)||e[n(622)](e[n(611)],typeof globalThis)||e[n(1796)](e.VxbFd,typeof globalThis)&&!!globalThis[n(1656)+"Bridge"])&&e.Zpyrn(n(378)+"d",typeof wx),xn=e[n(503)](e.VxbFd,typeof globalThis)&&(e.xyQpU(e[n(1502)],globalThis[n(1037)+"tor"][n(1234)])||e[n(1162)](e[n(1729)],globalThis[n(1037)+n(1692)][n(1234)])||e[n(760)]===globalThis[n(1037)+n(1692)][n(1234)])&&e[n(1245)](n(378)+"d",typeof self),dd=e.myqDX(e.VxbFd,typeof globalThis)&&e[n(1791)]===globalThis[n(1037)+"tor"][n(1234)]&&e[n(1679)](e.VxbFd,typeof global)&&e[n(1240)](n(1476),global[n(1037)+n(1692)][n(1234)])&&n(378)+"d"!=typeof process&&!!process.version;class si{constructor(){let t=n;this[t(1124)+"rs"]={}}[n(431)](t,...r){let d=n;if(e.cvmUa(e[d(730)],e.KcLJu)){let u=this[d(1124)+"rs"][t];if(u)u.slice()[d(921)](p=>p.fn[d(508)](p[d(1319)],r));else if(e[d(962)](d(1322),t)&&!this[d(1553)])if(e.pQWkK(e[d(461)],e[d(512)])){let p=r.length&&r[0];if(e.bShss(p,Error))throw p;let _=new Error(e[d(1259)](e[d(1641)],p?e[d(1007)](" ("+p[d(1065)],")"):""));throw _.context=p,p}else this[d(431)](d(1065),e[d(834)](_0x235bb8,"message",{..._0x40dcdc}));return this}else return this[d(1164)][d(1606)+"ns"]}off(t,r){let d=n;if(t===void 0)this[d(1124)+"rs"]={};else if(e[d(1570)](void 0,r))this[d(1124)+"rs"][t]=null;else{let u=this[d(1124)+"rs"][t];if(u)for(let p=0;e[d(1264)](p,u.length);)e[d(702)](u[p].fn,r)?u[d(1263)](p,1):++p}return this}on(t,r,d){let u=n;return(this[u(1124)+"rs"][t]||(this._listeners[t]=[]))[u(1054)]({fn:r,ctx:d||this}),this}}class fd extends si{[n(670)+n(1399)+n(934)](t){let r=n;return t[r(469)]||t.errNo?("message: "+(t[r(469)]||"")+r(1290)+(t.errNo||""))[r(739)]():JSON[r(1160)+"y"](t)}constructor(t,r,d){let u=n;if(e[u(561)](e.lGAWE,u(1112)))super(),this[u(1164)]=null,un&&wx[u(1734)+u(1176)]&&(this._socket=wx[u(1734)+u(1176)]({url:t,protocols:r,header:d,fail:this[u(1004)+"ocketFai"+u(632)][u(598)](this),success:this["_createSocketSuc"+u(553)+u(398)].bind(this)})),bt&&tt["connectS"+u(1176)]&&(this[u(1164)]=tt[u(1734)+u(1176)]({url:t,protocols:r,header:d,fail:this[u(1004)+u(1046)+u(632)][u(598)](this),success:this[u(1004)+u(1745)+"cessHand"+u(398)].bind(this)}));else return new _0x4574a3(_0xf1fb56,{data:_0xbe8131})}[n(1004)+n(1745)+n(553)+n(398)](){let t=n;e[t(830)](e[t(1239)],e[t(1130)])?this[t(1009)+t(963)]():Promise.resolve().then(()=>{this[t(491)+"steners"]()})}[n(1004)+n(1046)+n(632)](t){let r=n,d={DPjkq:function(u,p){return u(p)},jjOgp:function(u,p){return e[G(1238)](u,p)},LlPsD:function(u,p){return e[G(872)](u,p)}};e[r(561)](e[r(1181)],e[r(783)])?Promise[r(1069)]()[r(1449)](()=>{let u=r;if(e[u(1612)](u(547),u(794))){let p=e[u(1596)](Be,e[u(404)],{message:this["_formatE"+u(1399)+u(934)](t)});this[u(431)](e[u(404)],p);let _=He(e.rYGij,{reason:this[u(670)+u(1399)+u(934)](t)});this[u(431)](e[u(816)],_)}else{let p={IumBd:function(_,b,g){return _(b,g)}};return new _0x238ad5(_=>{let b=u;p[b(778)](_0x1c6164,_,this[b(563)+b(1097)+"e"](_0x18025e))})}}):(_0x24bc8a=gEZlUo[r(1617)](_0x4d497a,_0x4c291b),gEZlUo.jjOgp(_0xc75b16,32)&&(_0x88d11|=gEZlUo[r(787)](127&_0x562a85,_0xab8adc)),_0x528b1e+=7)}[n(491)+n(381)](){let t=n,r={SlVyN:e[t(1675)],HnvfP:t(1722),YADlw:function(d,u,p){return e[t(834)](d,u,p)},XTLIF:"message",VAywW:function(d,u,p){return e[t(1335)](d,u,p)},cqSzx:e[t(404)],xnEnA:function(d,u,p){return e.fRGJd(d,u,p)}};this._socket.onOpen(d=>{let u=t;this[u(431)](r[u(1141)],zs(r[u(1141)],{...d,data:d[u(469)]||""}))}),this._socket[t(1451)](d=>{let u=t;this.emit(r[u(1042)],r.YADlw(He,"close",{...d}))}),this[t(1164)][t(1275)+"e"](d=>{let u=t;this[u(431)](r[u(1706)],r[u(1058)](Bs,u(1065),{...d}))}),this._socket[t(903)](d=>{let u=t;this[u(431)](r[u(1334)],r.xnEnA(Be,r[u(1334)],{...d,message:d[u(469)]||""}))})}[n(1336)](t){let r=n,d={WXese:e.QOpLt};if(e[r(496)](t,Uint8Array)){let u=t[r(593)][r(1113)](t.byteOffset,e[r(534)](t[r(1511)+"th"],t.byteOffset));this[r(1164)]&&this[r(1164)][r(1336)]({data:u,fail:p=>{let _=r;this[_(431)](d[_(536)],Be(_(1322),{message:this[_(670)+_(1399)+_(934)](p)}))}})}else this[r(1164)]&&this[r(1164)].send({data:t,fail:u=>{let p=r;e.KQtEo!==e.NAiNv?this.emit(e.QOpLt,e[p(888)](Be,p(1322),{message:this[p(670)+p(1399)+p(934)](u)})):_0x2f3e28.exports=_0x5ab986[p(1069)]()[p(1449)](()=>(_0x369e6e(),_0x56be98))[p(1449)](function(_){return _})}})}[n(1722)](t,r){let d=n;this[d(1164)]&&this._socket[d(1722)]({code:t,reason:r})}["addEvent"+n(1397)](t,r){this.on(t,r)}[n(699)+n(1748)+n(1276)](t,r){this[n(1697)](t,r)}get[n(781)+"te"](){return this[n(1164)].readyState}get[n(969)+"pe"](){let t=n;return this[t(1164)][t(969)+"pe"]}set binaryType(t){}get[n(1391)](){return this._socket.url}get[n(437)](){let t=n;return e[t(957)]("jbldP",e[t(708)])?_0x4b69c5?.[t(1471)](r=>r[t(1306)]===_0x362aec)?.[t(1108)]:this._socket[t(437)]}get[n(1606)+"ns"](){let t=n;return this[t(1164)][t(1606)+"ns"]}get[n(1184)+"Amount"](){return 0}}function ud(s,t){let r=n;if(t)return new t(s[r(1391)],s[r(437)]);if(un||bt)return new fd(s.url,s[r(437)],s[r(400)]);if(e[r(813)](Bt,xn)&&e[r(1780)](e[r(611)],typeof WebSocket)&&WebSocket)return new WebSocket(s[r(1391)],s[r(437)+"s"])}function xd(s){let t=n,r=e[t(1098)][t(677)]("|"),d=0;for(;;){switch(r[d++]){case"0":if(e[t(1093)](Bt,xn)&&e[t(1549)](e[t(611)],typeof WebSocket)&&WebSocket)return!0;continue;case"1":if(s)return!0;continue;case"2":if(bt&&tt[t(1734)+t(1176)])return!0;continue;case"3":if(un&&wx[t(1734)+"ocket"])return!0;continue;case"4":return!1}break}}function Us(s,t,r){let d=n,u={OoLow:function(b,g){return b===g}},p=-1;async function _(b){let g=G;return b<=p?Promise[g(784)](new Error(g(452)+g(877)+g(1384)+g(755)+g(846))):(p=b,u[g(1352)](b,r[g(669)])?Promise[g(1069)]():r[b][g(598)](s)(t,_.bind(null,b+1)))}e[d(448)](_,0)}function Hs(s){let t=n,r={YACqG:function(d,u){return e[G(852)](d,u)},GHTZr:function(d,u){return e.HpqBi(d,u)},gzgyr:function(d,u){return e[G(788)](d,u)},zAtSf:function(d,u){return e[G(546)](d,u)}};if(e[t(1172)]!==e.lhBhu){let d=0,u=0;for(let p=0;p<s.length;++p)u=s.charCodeAt(p),u<128?d+=1:e[t(1803)](u,2048)?d+=2:e[t(566)](e.IJVSA(64512,u),55296)&&e[t(971)](64512,s[t(1657)+"At"](p+1))===56320?(++p,d+=4):d+=3;return d}else return new _0x1378a0(ujOlTY[t(697)](ujOlTY.YACqG(ujOlTY[t(1520)](_0x2addb9[4],24),ujOlTY[t(1520)](_0x5b7b55[5],16)),ujOlTY.gzgyr(_0x1e89ae[6],8))|_0x2b70d4[7],ujOlTY[t(697)](ujOlTY[t(697)](ujOlTY[t(1520)](_0x5e4f16[0],24),ujOlTY[t(1032)](_0x47f92d[1],16))|ujOlTY[t(1520)](_0x46abd1[2],8),_0x5ac0c3[3]),_0x37bcd2)}function qs(s,t,r){let d=n;if(e[d(474)](r-t,1))return"";let u="";for(let p=t;e[d(1591)](p,r);){let _=s[p++];if(_<=127)u+=String[d(1226)+d(771)](_);else if(_>=192&&e.tCQBi(_,224))u+=String["fromChar"+d(771)](e[d(1203)](e.KzLqI(e[d(1084)](31,_),6),e[d(1386)](63,s[p++])));else if(e[d(1080)](_,224)&&e.JVzJa(_,240))u+=String[d(1226)+d(771)](e[d(761)](e[d(1595)](e.RPGHq(15&_,12),e.twqkI(e[d(457)](63,s[p++]),6)),e[d(1216)](63,s[p++])));else if(_>=240){let b=e[d(1537)](e[d(943)](e[d(1353)](e[d(472)](e[d(1768)](7,_)<<18,e[d(931)](63&s[p++],12)),e[d(748)](63,s[p++])<<6),63&s[p++]),65536);u+=String[d(1226)+d(771)](55296+e[d(529)](b,10)),u+=String[d(1226)+d(771)](e[d(681)](56320,e[d(587)](1023,b)))}}return u}function oi(s,t,r){let d=n,u=r,p,_;for(let b=0;e[d(1666)](b,s[d(669)]);++b)if(p=s[d(1657)+"At"](b),p<128)t[r++]=p;else if(e[d(474)](p,2048))t[r++]=e.KbpuF(e[d(1284)](p,6),192),t[r++]=e[d(1771)](63&p,128);else if(e.PmHhl(e[d(1701)](64512,p),55296)&&e[d(549)](e[d(457)](64512,_=s.charCodeAt(e[d(805)](b,1))),56320)){let g=e.JpWRx[d(677)]("|"),T=0;for(;;){switch(g[T++]){case"0":t[r++]=e.rYuMC(p>>6,63)|128;continue;case"1":++b;continue;case"2":p=e.cuRkT(e[d(520)](65536,e[d(1669)](e[d(377)](1023,p),10)),1023&_);continue;case"3":t[r++]=e.fADSt(e[d(1768)](e[d(529)](p,12),63),128);continue;case"4":t[r++]=e.ueElH(e[d(1144)](63,p),128);continue;case"5":t[r++]=e[d(1786)](e[d(693)](p,18),240);continue}break}}else t[r++]=e[d(1285)](e[d(1284)](p,12),224),t[r++]=e.XJFbf(p>>6&63,128),t[r++]=e[d(1316)](e[d(1719)](63,p),128);return r-u}async function Gs(s){let t=n;if(e[t(1349)]==typeof s){let r=new Uint8Array(e[t(1241)](Hs,s));return e.DDrif(oi,s,r,0),r}return e[t(1416)](s,ArrayBuffer)?new Uint8Array(s):new Uint8Array(s[t(593)],s[t(1488)+"et"],s[t(1511)+"th"])}function ld(s){let t=n;try{return e[t(432)](t(1627),typeof s)&&(e[t(1674)](s,ArrayBuffer)||s.buffer&&e[t(1495)](s[t(593)],ArrayBuffer))||e[t(642)](e[t(1349)],typeof s)?"":(JSON[t(1491)](s),e[t(892)])}catch{return e[t(1441)](e[t(1349)],typeof s)?e[t(968)]:""}}let gd=(s,t)=>{let r=n,d={Zqnra:function(u,p){return e.FQavY(u,p)},pJblp:function(u,p){return e[G(1300)](u,p)},OjkFS:function(u,p){return e.AAzvp(u,p)}};if(e.QQkHZ!==r(439))switch(s){case e[r(1299)]:case r(912):return{["x-use-"+s]:1,"x-tt-env":t};default:return{}}else _0x3b68d1[_0x2df523++]=WVummw[r(1429)](_0x1bffdc>>12,224),_0x1c8fa8[_0x133e17++]=WVummw[r(707)](_0x24836b>>6,63)|128,_0x1693c0[_0xa03e59++]=WVummw[r(1429)](WVummw.OjkFS(63,_0x597bde),128)};class pd{constructor(t){let r=n;this.maxLossCount=t,this[r(1590)]=0}addCount(){let t=n,r={OyPLk:function(d,u){return d>>>u},ChfyN:function(d,u){return e[G(1766)](d,u)},qVxJv:function(d,u){return e[G(1149)](d,u)},sccfA:function(d,u){return e.JscbU(d,u)},qJSDV:function(d,u){return e[G(1717)](d,u)},jPLDl:function(d,u){return e[G(689)](d,u)},RiZip:function(d,u){return e[G(1068)](d,u)},BXCTA:function(d,u){return e.hBAzY(d,u)}};if(e[t(532)](e.htBuJ,e[t(1540)])){_0x1b056e[t(621)](_0x1e77a8)||(_0x482e3f=_0x190f64.fromNumber(_0x3ed05d));let d=VXDHOL.OyPLk(this[t(410)],16),u=65535&this[t(410)],p=VXDHOL[t(735)](this[t(1305)],16),_=VXDHOL[t(488)](65535,this.low),b=VXDHOL[t(485)](_0x1fd19f[t(410)],16),g=VXDHOL[t(488)](65535,_0x14a2fd.high),T=VXDHOL[t(735)](_0xfd0d5a.low,16),N=65535&_0x2792a6[t(1305)],B=0,q=0,J=0,V=0;return V+=VXDHOL[t(844)](_,N),J+=VXDHOL[t(485)](V,16),V&=65535,J+=VXDHOL[t(844)](p,T),q+=VXDHOL[t(1743)](J,16),J&=65535,q+=u+g,B+=VXDHOL.jPLDl(q,16),q&=65535,B+=VXDHOL[t(844)](d,b),B&=65535,_0x849668[t(1261)](J<<16|V,VXDHOL[t(924)](VXDHOL[t(1548)](B,16),q),this[t(423)])}else this[t(1590)]++}["checkRea"+n(527)+"nt"](){let t=n;return this.count>=this[t(1779)+t(610)]}[n(657)+n(1630)](t=0){let r=n,d={PbClH:function(u,p){return e[G(813)](u,p)}};if(e[r(524)](e[r(1614)],e.GovqC))this["maxLossC"+r(610)]=t,this[r(1590)]=0;else{let u=this[r(1250)][r(1090)+r(876)](this[r(661)]),p=_0x1b59db.parse(d[r(562)](u,"{}"));return p[_0x175a94||_0x248d6a[this._pathKey]]=_0x404b68,this._qosDB["setStora"+r(876)](this[r(661)],_0x228e60[r(1160)+"y"](p)),_0x3cae7e||_0x4687e7[this._pathKey]}}}async function hd(s){let t=n,r={IjDZZ:e[t(1354)],tJpsq:function(d,u){return e[t(811)](d,u)},fRSSI:e[t(1450)],WmTAg:e[t(389)],bTPiG:function(d,u){return e[t(523)](d,u)},pvJZz:e[t(1582)],upgsy:function(d,u){return e[t(478)](d,u)}};if(e[t(1027)](e[t(374)],e[t(374)]))return new Promise(d=>{let u=t,p={nMWEG:function(_,b){return _(b)},QYHhe:r.IjDZZ};if(!Bt)return r[u(1132)](d,"unknown "+u(786));try{let _=document[u(1761)+u(1138)](r[u(1383)]);window.frontierJSONP=b=>{let g=u;document[g(894)][g(388)+g(545)](_),window[g(1222)+g(1010)]=void 0,p[g(732)](d,b&&b.msg||p.QYHhe)},_[u(1738)]=r[u(570)],_[u(379)]=r[u(797)](s[u(1211)](/^ws/,u(1643)),r.pvJZz);try{document[u(894)][u(1752)+u(545)](_)}catch{document[u(894)]["removeCh"+u(545)](_)}}catch{window[u(1222)+u(1010)]=void 0,r[u(1047)](d,r[u(1694)])}});{let d=this[t(1250)].getItem(this[t(661)]),u=_0x4f5c65[t(1491)](d||"{}");return u[_0x54ded0||_0x5d5890[this._pathKey]]=_0x36f676,this[t(1250)][t(792)](this[t(661)],_0x4fda68[t(1160)+"y"](u)),_0x3e5bdf||_0x2d2c20[this[t(983)]]}}function lt(s,t,r){let d=n;return!!s?.[d(1471)](u=>u[d(1306)]===t&&u.value===r)}function zt(s,t){let r=n;return s?.find(d=>d[r(1306)]===t)?.[r(1108)]}let ai=null;async function md(){let s=n;return e[s(647)](s(1076),s(1076))?(_0x1c2792[s(508)](mTjBxK[s(1326)](_0x57451e,this),_0x54d68a),mTjBxK[s(993)](_0x4e1dbe,_0x135157[s(376)](this))):(ai||(ai=Promise[s(1069)]()[s(1449)](Qe[s(598)](Qe,e[s(849)]))),ai)}class wd extends si{constructor(t,r){let d=n;super(),this[d(1152)]=t,this[d(869)]=r,this[d(1250)]=void 0,this[d(390)+"mise"]=null}async[n(1431)](){await this[n(556)]()}async[n(556)](){let t=n,r={zKuSu:function(d){return e[G(1087)](d)},TYbEF:function(d,u,p,_){return e.eALvd(d,u,p,_)}};if(!this[t(1250)]){if(this[t(390)+t(1555)])return this["_initPro"+t(1555)];try{let d=this[t(1152)],u=this[t(869)];this[t(390)+t(1555)]=(async()=>{let p=t,{openDB:_}=await r[p(1136)](md);this[p(1250)]=await r[p(1011)](_,p(1222)+"_"+d,1,{upgrade(b){let g=p;b[g(734)+g(1153)+"e"](d,{keyPath:u})}})})(),await this[t(390)+t(1555)]}catch(d){console[t(1125)](d)}finally{this[t(390)+t(1555)]=null}}}async[n(376)](t){let r=n;try{return await this[r(556)](),this[r(1250)]?.get(this[r(1152)],t)}catch(d){e[r(635)](e[r(909)],e[r(909)])?console[r(1125)](d):(this[r(1009)+"lTimeoutId"]=null,this[r(1009)+"l"]=36e5,this[r(1250)]=_0x5df43b(r(1691),e[r(703)]))}}async[n(1737)](t,r){let d=n;return await this[d(556)](),this[d(1250)]?.[d(1035)](this[d(1152)],t)}async[n(727)](t){let r=n;try{return await this[r(556)](),this._qosDB?.[r(1661)](this[r(1152)],t)}catch(d){console.log(d)}}async[n(1790)](){let t=n;try{return await this[t(556)](),this._qosDB?.clear(this[t(1152)])}catch(r){console[t(1125)](r)}}async[n(873)](){let t=n;return await this._init(),this[t(1250)]?.[t(1310)+"ys"](this._dbName)}async getAll(){let t=n;return await this[t(556)](),this[t(1250)]?.getAll(this[t(1152)])}async[n(1550)](){let t=n,r={vBAtL:e[t(816)]};if(e[t(1200)]==="WBvhq")try{e.AMIgm(e[t(1551)],e[t(1551)])?(this.emit(r[t(796)],_0xc3487),this.onclose&&this[t(1185)](_0x27143d)):(this[t(1250)]?.[t(1722)](),this._qosDB=void 0)}catch(d){console[t(1125)](d)}else throw _0x1de911=_0x449eea[t(669)],e[t(860)](_0x261bf0,_0x190d04,10,_0x36c6d9[t(669)])}get isReady(){let t=n;try{return!!this[t(1250)]}catch(r){return console[t(1125)](r),!1}}}class _d{constructor(t,r){let d=n;this[d(807)]=t,this[d(983)]=r,this[d(1250)]=localStorage}async[n(1431)](){}get[n(661)](){let t=n;return t(1222)+"_"+this[t(807)]}async[n(376)](t){let r=n,d=this[r(1250)][r(1723)](this[r(661)]);return JSON[r(1491)](d||"{}")[t]}async[n(1737)](t,r){let d=n,u=this[d(1250)].getItem(this._prefix),p=JSON[d(1491)](e[d(1093)](u,"{}"));return p[r||t[this[d(983)]]]=t,this._qosDB[d(792)](this[d(661)],JSON[d(1160)+"y"](p)),r||t[this._pathKey]}async[n(727)](t){let r=n,d={OHrIT:function(u,p){return e[G(1083)](u,p)}};if(e.pycVV!==e[r(864)]){let u=this[r(1250)][r(1723)](this[r(661)]),p=JSON[r(1491)](e[r(1629)](u,"{}"));return p[t]=void 0,this[r(1250)][r(792)](this[r(661)],JSON[r(1160)+"y"](p))}else d[r(1121)](_0xcdb35b,this[r(369)+"gTimeoutId"]),d[r(1121)](_0x7a147c,this[r(1095)+r(573)+r(1040)]),this["_pingPon"+r(905)+"Id"]=null,this[r(1095)+"ctTimeou"+r(1040)]=null}async clear(){let t=n;return this[t(1250)][t(1790)]()}async[n(873)](){let t=n,r=this[t(1250)][t(1723)](this._prefix),d=JSON[t(1491)](r||"{}");return Object[t(873)](d)}async[n(1678)](){let t=n,r=this._qosDB[t(1723)](this[t(661)]),d=JSON[t(1491)](e[t(813)](r,"{}"));return Object[t(1589)](d)}closeDB(){let t=n;if(e[t(1693)]==="Gatui")return Promise[t(1069)]();++_0x350ec1,_0x3149ec+=4}get[n(1092)](){return!!this._qosDB}}class yd{constructor(t,r){let d=n;e[d(709)](e.bgXGi,e[d(1074)])?(_0xbd53fc=_0x4c2e1e[d(766)](_0x23cfdb),_0x522e68=_0x5c36eb[d(766)](_0x46b2b8[_0x17ba9b])):(this._DBName=t,this[d(983)]=r,this._qosDB=bt?tt:un?wx:null)}async[n(1431)](){}get[n(661)](){return"frontier_"+this._DBName}async[n(376)](t){let r=n,d=this[r(1250)]["getStora"+r(876)](this[r(661)]);return JSON[r(1491)](e[r(451)](d,"{}"))[t]}async set(t,r){let d=n,u=this._qosDB[d(1090)+d(876)](this[d(661)]),p=JSON.parse(e.mpVHm(u,"{}"));return p[r||t[this._pathKey]]=t,this._qosDB[d(1255)+d(876)](this[d(661)],JSON[d(1160)+"y"](p)),r||t[this[d(983)]]}async del(t){let r=n,d=this[r(1250)][r(1090)+r(876)](this[r(661)]),u=JSON[r(1491)](e[r(609)](d,"{}"));return u[t]=void 0,this[r(1250)][r(1255)+r(876)](this._prefix,JSON[r(1160)+"y"](u))}async[n(1790)](){let t=n;return this[t(1250)][t(1413)+t(791)]()}async[n(873)](){let t=n,r=this[t(1250)][t(1090)+t(615)+"nc"](this[t(661)]),d=JSON[t(1491)](e[t(1225)](r,"{}"));return Object[t(873)](d)}async[n(1678)](){let t=n,r=this[t(1250)][t(1090)+t(615)+"nc"](this[t(661)]),d=JSON[t(1491)](e.jutoL(r,"{}"));return Object[t(1589)](d)}closeDB(){return Promise.resolve()}get[n(1092)](){return!!this._qosDB}}function js(s,t){let r=n;if(e[r(813)](bt,bt))return new yd(s,t);if((Bt||xn)&&e[r(1245)]("undefined",typeof indexedDB))return new wd(s,t);if((Bt||xn)&&e[r(904)](r(378)+"d",typeof localStorage))return new _d(s,t);throw new Error("init QoS"+r(1442)+"d")}class Ed{constructor(){let t=n;this[t(1009)+"lTimeoutId"]=null,this[t(1009)+"l"]=36e5,this[t(1250)]=e[t(1747)](js,e[t(455)],e[t(703)])}async[n(1009)+n(963)](){let t=n,r={VsgCf:function(d,u){return d>u},IqCqn:e[t(1731)]};e[t(441)](clearInterval,this[t(1009)+t(953)+"Id"]),this[t(1009)+t(953)+"Id"]=setInterval(()=>{let d=t,u={YnwrG:function(p,_){return p==_},CGPVc:function(p,_){return r[G(438)](p,_)}};if(r[d(1182)]!==d(883))this[d(1295)+"ired"]();else return EGVHgv[d(1619)](this[d(606)+d(1139)],this[d(1017)+"s"][d(669)])?!0:EGVHgv[d(1345)](this[d(940)+d(1620)+"riesCount"],this[d(1217)+"es"])},this[t(1009)+"l"])}async[n(1431)](){let t=n;await this[t(1250)].openDB().then(()=>{let r=t;this[r(1009)+r(963)]()})}async[n(1295)+n(1283)](){let t=n;e[t(925)](e.hrzbO,e[t(824)])?(await this._qosDB?.[t(1678)]()||[])[t(1446)](({timestamp:u})=>u<Date[t(839)]())[t(921)](u=>{let p=t;this[p(1250)]?.[p(727)](u[p(887)+"id"])}):(_0x4b7aa0=e[t(1498)](_0x24ac70,_0x13d7d7),_0x2adaf7=e[t(1762)](127,_0x46cd66),e[t(620)](128,_0x443506)&&(_0x5e4d42=_0x1ee35b(_0x320953),_0x4ad618|=e[t(479)](127,_0x4d5177)<<7))}async del(t){let r=n,d={gBWYj:function(u,p){return e[G(1199)](u,p)},mEYho:function(u,p){return u<p},cGmVM:function(u,p){return e[G(1050)](u,p)},OqvIQ:function(u,p){return u===p},lLQdL:function(u,p){return e[G(856)](u,p)},rLwQk:function(u,p){return e[G(635)](u,p)},sfvfZ:function(u,p){return e[G(908)](u,p)},fTkDJ:function(u,p){return u+p}};if(e[r(1150)]===e[r(1025)]){let u=0,p=0;for(let _=0;mzFfWO.gBWYj(_,_0x989da3[r(669)]);++_)p=_0x51c32d[r(1657)+"At"](_),mzFfWO[r(1611)](p,128)?u+=1:mzFfWO[r(1461)](p,2048)?u+=2:mzFfWO.OqvIQ(mzFfWO[r(397)](64512,p),55296)&&mzFfWO.rLwQk(mzFfWO.sfvfZ(64512,_0x4128c6.charCodeAt(mzFfWO.fTkDJ(_,1))),56320)?(++_,u+=4):u+=3;return u}else return this[r(1250)]?.[r(727)](t)}async[n(1737)](t,r){return this[n(1250)]?.set({message_id:t,timestamp:r})}async get(t){let r=n;return this[r(1250)]?.[r(376)](t)}async[n(1550)](){let t=n;e.qqBTJ(clearInterval,this[t(1009)+t(953)+"Id"]),await this[t(1250)]?.[t(1550)]()}get isReady(){return this[n(1250)]?.isReady}}function ci(s){let t=n,r=!!this[t(1436)][t(1458)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[t(1799)](lt,s.message[t(400)],e.hkbKe,"2"),u=d&&e[t(1716)](lt,s.message.headers,e[t(972)],"1"),p=d&&e[t(1799)](lt,s[t(1065)][t(400)],e[t(1024)],"1"),_=p?e.LmLYq(zt,s[t(1065)][t(400)],e[t(837)])?.[t(677)](",")[t(1446)](Boolean)||[]:[];return{enabled:r,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:p,ackMsgIds:_}}async function Ws(){let s=n;return e.VaOZG("WcsJT",e.iZLse)?(this._QoSManager||(this[s(1380)+"ger"]=new Ed),this["_QoSMana"+s(1770)][s(1092)]||await this[s(1380)+s(1770)][s(1431)](),this[s(1380)+s(1770)]):!0}async function vd(s,t){let r=n,d={idJYe:function(u,p){return e[G(999)](u,p)},jZLil:function(u,p){return u+p},pGPUs:function(u,p,_,b){return e[G(1320)](u,p,_,b)},nRiXx:function(u,p,_,b){return e[G(1517)](u,p,_,b)}};if(e[r(1759)](r(895),e.sfYsN)){let{enableAutoAck:u}=this[r(1436)],p=e[r(1716)](lt,s[r(1065)][r(400)],e[r(1269)],"1"),_=e.DDrif(lt,s[r(1065)][r(400)],e.MCRkD,"1"),b=ci[r(1142)](this,s);if(e[r(1800)](u,p)){let{SeqID:g,LogID:T,service:N,LogIDNew:B,method:q}=s[r(1065)];this[r(648)]({SeqID:g,LogID:T,LogIDNew:B,service:N,method:q,headers:[{key:e[r(509)],value:"1"},{key:e.BNepe,value:e.NPvzl(B,"")},{key:e[r(1715)],value:"0"}]})}_&&!b[r(1793)]&&this[r(1064)+r(1696)+r(1565)](s),e[r(1087)](t)}else return _0x3e89a3?d[r(1545)](_0x47ad02.length,40)?d[r(1558)](d.pGPUs(_0x3415f4,_0x4af377,_0x1e404a,_0x12d53b),_0x3079fb):_0xb830c4[r(1359)+"e"]?d.jZLil(_0x292812[r(1359)+"e"](_0x16a3fb,_0x323e49),_0xb761c6):_0x35ba15[r(952)]?_0x27e5fe[r(952)](_0x53e5a5,_0x39931a)+_0x21a5bc:d.jZLil(d.nRiXx(_0x153b27,_0x483a4c,_0x2f4547,_0x4bccd0),_0x8c7a40):_0x52a8c3}async function bd(s,t){let r=n;this[r(366)](e[r(1534)],s[r(1065)]),t()}async function Sd(s,t){let r=n,d=Lt(await e.KBdgN(Gs,s.data));try{if(e[r(442)](d.payload,Uint8Array)){let u=e.nurcp(this[r(1436)]["payloadE"+r(480)],Object)?{force:!!this[r(1436)][r(1616)+r(480)].force,encoding:this[r(1436)]["payloadE"+r(480)][r(1463)]?this[r(1436)]["payloadE"+r(480)][r(1463)].replace(/\s/g,"").toLowerCase():""}:{force:!1,encoding:this._options["payloadE"+r(480)]?this._options[r(1616)+r(480)][r(1211)](/\s/g,"")["toLowerC"+r(743)]():""},p=d[r(1616)+"ncoding"]?d[r(1616)+r(480)][r(1211)](/\s/g,"")[r(944)+"ase"]():"",_=e[r(496)](this[r(1436)][r(1207)+r(412)],Object)?{force:!!this[r(1436)][r(1207)+r(412)][r(1497)],type:this._options[r(1207)+"ype"][r(1738)]?this._options[r(1207)+r(412)].type.replace(/\s/g,"")[r(944)+r(743)]():""}:{force:!1,type:this[r(1436)][r(1207)+"ype"]?this[r(1436)]["payloadT"+r(412)][r(1211)](/\s/g,"")["toLowerC"+r(743)]():""},b=d[r(1207)+r(412)]?d["payloadT"+r(412)][r(1211)](/\s/g,"")["toLowerC"+r(743)]():"",g=_[r(1497)]?_.type:b||_.type,T=u[r(1497)]?u[r(1463)]:p||u[r(1463)],N=[e.CCpTv,e[r(892)],r(1765)+"ion/json;charset"+r(539),e[r(1349)]],B=[e.fFdkl,e[r(1256)]];this[r(1436)][r(1262)+r(1029)+r(447)+"ad"]&&N[r(1763)](g)&&(!T||B[r(1763)](T))?d[r(460)+r(802)]=e.eALvd(qs,d[r(1683)],0,d[r(1683)][r(1511)+"th"]):d["textPayl"+r(802)]=""}else d["textPayl"+r(802)]=""}catch(u){if(e.WsCQz!==e[r(1063)])return e.htsZe(_0x282fc5,e[r(534)](e.tUKdl(e[r(923)](e[r(1134)](r(768)+r(1468)+r(977),_0x37dd0c),e[r(1572)]),e[r(1407)](_0x4cfee2,1))+r(1784),_0x6af2b3));d[r(460)+"oad"]="",console.log(u)}s[r(1065)]=d,e[r(1049)](t)}function Id(s,t,r){let d=e.YGuPH(r,8192),u=d>>>1,p=null,_=d;return function(b){let g=G;if(e[g(658)](b,1)||e[g(1367)](b,u))return e.Hujjp(s,b);_+b>d&&(p=s(d),_=0);let T=t[g(1142)](p,_,_+=b);return e[g(748)](7,_)&&(_=e[g(958)](e[g(943)](7,_),1)),T}}let Cd=4294967295;function Ad(s,t,r){let d=n;return e[d(530)](RangeError,e[d(1134)](e[d(523)](e[d(1473)]+s+d(1575),e[d(1652)](t,1)),e.GOiLR)+r)}function Td(s,t,r){let d=n;if(r>Cd)throw new Error(e[d(569)]);let u=3;for(;e[d(1266)](u,0);){let p=255&r;fi(p,s,e.kWfZP(t,u)),r>>>=8,u--}return e[d(575)](t,4)}function Dd(s,t){let r=n,d=0,u=t,p=t+4;for(;u<p;){let{value:_,offset:b}=di(s,u);u=b,d=e[r(1579)](e[r(1703)](d,8),0),d+=_}return{value:d,offset:p}}function Pd(s,t,r){let d=n,u="4|1|2|0|3"[d(677)]("|"),p=0;for(;;){switch(u[p++]){case"0":if(t.write)return e.PhBDf(t[d(952)](s,r),r);continue;case"1":if(e[d(1591)](s[d(669)],40))return e[d(1576)](e.fTRvq(oi,s,t,r),r);continue;case"2":if(t[d(1359)+"e"])return t[d(1359)+"e"](s,r)+r;continue;case"3":return e[d(966)](e[d(1320)](oi,s,t,r),r);case"4":if(!s)return r;continue}break}}function kd(s,t){let r=n,d=new re(e[r(1293)](e[r(679)](e[r(976)](s[e[r(948)](t,4)],24)|e[r(458)](s[t+5],16),s[e[r(1417)](t,6)]<<8),s[t+7]),e[r(1595)](e.JkjvS(e[r(1251)](e[r(695)](s[t+0],24),s[e[r(449)](t,1)]<<16),e[r(1051)](s[e[r(446)](t,2)],8)),s[e[r(523)](t,3)]),!0);return t+=8,{value:d,offset:e.tLOXz(t,8)}}function Rd(s,t,r){let d=n,u=s[d(1305)],p=s[d(410)];return t[r]=e[d(1787)](p,24),t[e[d(1453)](r,1)]=e[d(893)](e[d(425)](p,16),255),t[r+2]=p>>>8&255,t[r+3]=e[d(1444)](255,p),t[e[d(640)](r,4)]=u>>>24,t[e[d(1331)](r,5)]=e[d(753)](e[d(1527)](u,16),255),t[e[d(367)](r,6)]=e[d(1762)](e[d(1393)](u,8),255),t[e[d(923)](r,7)]=255&u,r+=8,r}function di(s,t){let r=n;return e[r(428)]!=="QLDoa"?this[r(1164)][r(781)+"te"]:s.readUInt8?{value:s[r(1546)+"8"](t),offset:e[r(1111)](t,1)}:{value:e[r(1254)](255,s[t]),offset:e[r(1561)](t,1)}}function fi(s,t,r){let d=n;return t.writeUint8?t[d(1337)+"t8"](s,r):t[r]=e[d(518)](255,s),e.pGpZe(r,1)}let Ld=function(s){let t=n;if(t(628)===e.FsdTq)this[t(754)+t(521)]?.[t(477)+"pointCon"+t(902)](),this[t(456)+t(1371)]?.resetCounter(),this["_readyCl"+t(586)]=!1,this._isInit=!0,this[t(1071)]();else return new Uint8Array(s)},Nd=e[n(1351)](e[n(611)],typeof Buffer)?Buffer["allocUns"+n(1626)]:e[n(1531)](Id,Ld,Uint8Array[n(625)+"e"][n(1073)]);(()=>{let s=n;if(e[s(709)](e[s(394)],e[s(1373)])){let t=4294967295;return function(r,d,u=!0){let p=s,_=(p(467)+"0|6|0|9|"+p(1573)+"8")[p(677)]("|"),b=0;for(;;){switch(_[b++]){case"0":if(e.IwYbH(r[d++],128))return{value:u?t:e[p(884)](0,t),offset:d};continue;case"1":if(e[p(713)](d+=5,r[p(669)]))throw d=r[p(669)],e.SnDUo(Ad,d,10,r[p(669)]);continue;case"2":t=e.KxgNL(e[p(748)](127,r[d]),0);continue;case"3":if(r[d++]<128)return{value:u?t:e.PAMlG(0,t),offset:d};continue;case"4":t=e[p(985)](e[p(1387)](t,e[p(1703)](e[p(1795)](15,r[d]),28)),0);continue;case"5":if(e[p(1663)](r[d++],128))return{value:u?t:0|t,offset:d};continue;case"6":t=e[p(1101)](e.ERIKt(t,e[p(1631)](e[p(1227)](127,r[d]),14)),0);continue;case"7":if(r[d++]<128)return{value:u?t:e[p(1280)](0,t),offset:d};continue;case"8":return{value:u?t:e[p(1246)](0,t),offset:d};case"9":t=e[p(947)](e.WPhqB(t,e[p(747)](127,r[d])<<21),0);continue;case"10":if(e[p(1803)](r[d++],128))return{value:u?t:0|t,offset:d};continue;case"11":t=e[p(1231)](t|e.NeaQX(127,r[d])<<7,0);continue}break}}}else{let{type:t}=_0x2c5b8b;he[s(431)](t,_0x23b29d)}})();let Od=16,ui=32;function Md(s){let t=n,r=0,d={};for(let u=0;e[t(584)](u,s[t(669)]);u++)d[s[u]["cursor_n"+t(497)]]=e.htsZe(Hs,s[u].cursor_name),r+=e[t(505)](14,d[s[u]["cursor_n"+t(497)]]);return[r,d]}function Ks(s,t,r){let d=n,u={jldue:function(T,N,B,q){return T(N,B,q)},SuIka:e[d(1648)],mssjB:function(T,N,B,q){return e[d(1716)](T,N,B,q)},ZfvHb:e[d(954)],bzrha:e[d(1168)],jnsMK:function(T,N,B,q){return e[d(1320)](T,N,B,q)},kEFFR:d(1588)+d(1234),GVJUm:e.xyKZp},[p,_]=e[d(1350)](Md,s),b=e[d(605)](Nd,p),g=0;return s.forEach(T=>{let N=d,B=(N(1645)+"|9|0|8|4"+N(714))[N(677)]("|"),q=0;for(;;){switch(B[q++]){case"0":g=u[N(676)](fi,_[T[N(721)+N(497)]],b,g);continue;case"1":g=u[N(676)](fi,0,b,g);continue;case"2":console[N(1125)](u[N(1170)],g);continue;case"3":g=u[N(683)](Td,b,g,T[N(1023)]||0);continue;case"4":g=u[N(676)](Pd,T[N(721)+N(497)],b,g);continue;case"5":console[N(1125)](u.ZfvHb,g);continue;case"6":console[N(1125)](u[N(578)],T,T[N(1023)]);continue;case"7":g=u[N(528)](Rd,re[N(785)+"er"](T[N(862)]||t),b,g);continue;case"8":console[N(1125)](u[N(1714)],g);continue;case"9":console.log(N(1023),g);continue;case"10":console.log(u[N(522)],g);continue}break}}),{frameType:ui,headers:[{key:e[d(470)],value:r}],payload:b}}function Bd(s){let t=n,r=0,d=[];for(;r<s[t(1511)+"th"];){let{offset:u}=e[t(942)](di,s,r);r=u;let p={cursor_name:"",cursor:0,service:0},{value:_,offset:b}=Dd(s,r);p[t(1023)]=_,r=b;let{value:g,offset:T}=e[t(1321)](di,s,r);r=T,p.cursor_name=qs(s,r,e[t(716)](r,g)),r+=g;let{value:N,offset:B}=e.fRGJd(kd,s,r);p[t(862)]=N[t(712)](),r=B,d[t(1054)](p)}return d}function zd(){let s=n;return{frameType:ui,headers:[{key:e[s(470)],value:e[s(885)]}],payload:void 0}}class Fd{constructor(t,r,d){let u=n,p={roOFC:function(_,b){return e[G(1759)](_,b)},oDOKF:function(_,b){return e[G(594)](_,b)},TWMWH:function(_,b){return e.MEtai(_,b)},QzADO:function(_,b){return e[G(546)](_,b)},AZaVK:function(_,b){return _|b}};if(e[u(1159)](e[u(510)],e.wTTez))this[u(762)+"ameSpace"]=t,this[u(1672)+u(1104)]=r,this[u(1378)+"Strategy"]=d,this._qosDB=e.bBKZY(js,this[u(762)+u(1522)],"cursor_name");else return SSPpoW[u(1515)](_0x46d949,_0x585cf2)?_0x2f5a9e:new _0x1084b0(SSPpoW[u(1472)](SSPpoW[u(1571)](SSPpoW[u(1571)](_0x525cd4[u(1142)](_0x225263,0),SSPpoW.QzADO(_0x3ce239[u(1142)](_0x3b3c8a,1),8))|SSPpoW[u(1128)](_0x216b82.call(_0xe065e1,2),16),SSPpoW[u(1128)](_0x1ab5b9[u(1142)](_0x20022f,3),24)),0),SSPpoW[u(1472)](SSPpoW[u(879)](SSPpoW[u(879)](SSPpoW[u(879)](_0x511714[u(1142)](_0x2c102e,4),_0xc40e84[u(1142)](_0x1541c5,5)<<8),_0x514ba2.call(_0x5ce718,6)<<16),SSPpoW[u(1128)](_0x1d0bac[u(1142)](_0x1c57d7,7),24)),0),!0)}async[n(1431)](){let t=n;await this[t(1250)][t(1431)]()}async[n(688)+"rs"](){let t=n;if(!this[t(1250)][t(1092)])return;let r=this["_message"+t(1210)],d=await this[t(1250)][t(1678)]();switch(console[t(1125)]("allCurso"+t(542),d),r){case e[t(736)]:return d&&d[t(669)]?e[t(1403)](Ks,d,0,this[t(1672)+t(1104)]):void 0;case e.ijChh:return;case e[t(1186)]:return d&&d[t(669)]?e[t(1505)](Ks,d,0,this[t(1672)+t(1104)]):e[t(1481)](zd)}}async[n(1737)](t,r,d){let u=n;return console[u(1125)](e.DjsEa,t,r,d),this[u(1250)][u(1737)]({cursor_name:t,cursor:r,service:d})}async[n(1462)+"rs"](t){let r=n;if(e[r(465)](e.SoYRe,e[r(1078)])){if(_0x24026c[r(669)]!==4){let d=_0x2b451e[r(826)+"g"](0,e[r(994)](4,_0x3327d6[r(669)])),u=d.concat(_0x2cfd0b);_0x4efbff[r(1054)](u)}else _0x3bd1ac[r(1054)](_0x2fae2a);_0x5ec566&&(_0x40776a+=1),_0x421525+=1,_0x27196c=!1}else{let d=e[r(1699)](Bd,t);for(let u of d)console[r(1125)](r(1750)+"r",d),await this[r(1250)].set(u)}}async[n(376)](t){let r=n;return(await this[r(1250)][r(376)](t))?.[r(862)]}async[n(1550)](){await this[n(1250)].closeDB()}[n(421)+"rsorFileName"](t){let r=n;this["_cursorF"+r(1104)]=t}get[n(1092)](){let t=n;return this[t(1250)][t(1092)]}}let Ud=e[n(1187)];async function $s(s){let t=n;if(!this[t(1436)][t(1458)+"S"])return null;let{aID:r,fpID:d,messageStrategy:u}=this._options,p=e.YGuPH(s,Ud);try{return this[t(1344)+"anager"]?s&&this._cursorManager[t(421)+"rsorFile"+t(486)](s):this["_cursorM"+t(1272)]=new Fd(d+"_"+r+"_"+p,p,u),this[t(1344)+t(1272)][t(1092)]||await this[t(1344)+t(1272)][t(1431)](),this[t(1344)+"anager"]}catch{return null}}async function Hd(s,t){let r=n,d={khlnC:function(J,V){return J(V)}},u=lt(s.message[r(400)],e[r(890)],"-1"),p=lt(s[r(1065)].headers,e[r(509)],"1"),_=e[r(1321)](zt,s.message[r(400)],e[r(1637)]),b=e[r(811)](Number,e.SdxTF(zt,s.message[r(400)],e[r(1372)]))||0,g=ci[r(1142)](this,s),T=e.lCZuX(lt,s[r(1065)][r(400)],e.oiIIR,"2"),N=e[r(1314)](zt,s[r(1065)].headers,e[r(1212)]),B=e[r(1563)](Number,e[r(1516)](zt,s[r(1065)].headers,e[r(1117)]));if(g[r(1793)])return e[r(1521)](t);let q=g[r(1402)+r(1712)]?await Ws[r(1142)](this):null;if(s.message.service>0&&p&&!u||e.TEgGQ(s[r(1065)][r(1023)],0)){if(_&&g[r(1402)+r(1712)]&&q)return!!!await q[r(376)](_)&&(this[r(1064)+"hMessage"+r(1323)](s),await q[r(1737)](_,e[r(513)](Date[r(839)](),b))),e[r(1481)](t);if(T)if(e.BzzIl(e[r(1594)],e.VjRrj))d[r(1174)](_0x399744,this[r(1071)+r(687)+r(1179)]),this[r(1071)+"ionTimeo"+r(1179)]=null;else{let J=await $s.call(this);if(!J)return this[r(1064)+"hMessage"+r(1323)](s),e[r(1481)](t);let V=await J.get(N)??-1;if(V<B)this[r(1064)+r(1797)+r(1323)](s),J[r(1737)](N,B,s[r(1065)][r(1023)]);else throw new Error(r(385)+r(1702)+" cursor "+B+(" larger than loc"+r(1243)+"r ")+V);return t()}return this[r(1064)+"hMessage"+r(1323)](s),e.bqMsx(t)}}async function qd(s,t){let r=n,d=ci[r(1142)](this,s);if(!d[r(1402)+r(1712)])return t();let u=await Ws[r(1142)](this);if(d["isAckCle"+r(435)+r(934)]&&d.ackMsgIds[r(669)])for(let p of d[r(1190)+"s"])await u[r(727)](p);e[r(1430)](t)}async function Gd(s,t){let r=n,d=s[r(1065)][r(832)+"e"]===Od,u=e[r(372)](s.message.frameType,ui);if(e.QEWOZ(!d,!u))return e[r(729)](t);let p=zt(s[r(1065)][r(400)],e[r(470)]);if(!p)return e[r(729)](t);let _=await $s[r(1142)](this,p);if(!_)return t();if(d){let b=await _[r(688)+"rs"](),g={frameType:b?.[r(832)+"e"],SeqID:re[r(785)+"er"](this[r(574)]++),LogID:re[r(785)+"er"](this._options[r(1707)+"erator"]()),service:9e3,method:5,headers:b?.headers,payload:b?.[r(1683)]},T=e[r(1328)](k,g);this[r(1252)]&&this[r(1252)][r(781)+"te"]&&this[r(1252)][r(1336)](T)}if(u){let b=s.message[r(1683)];b&&_.setCursors(b)}}let jd=async function(s,t){let r=n;if(e[r(516)]!==e[r(836)])this[r(1593)]=!1,clearTimeout(this[r(1071)+r(687)+"utId"]),e[r(1785)](t);else return{bytes:_0x303634,offset:0,limit:_0x326503.length}},Wd=async function(s,t){let r=n;if(!this._ws||this._ws[r(781)+"te"]!==this.OPEN)return e[r(1521)](t);let{pingInterval:d}=this[r(1436)];this[r(754)+r(521)]?.[r(477)+r(845)+r(902)]();for(let p=0;p<this[r(1378)+"Queue"][r(669)];p++){let _=this[r(1378)+r(1670)][p];if(e[r(776)](this[r(1252)][r(781)+"te"],this[r(1466)])&&e[r(1612)](null,_))this[r(1252)]&&this[r(1252)].send(_),this[r(1378)+"Queue"][p]=null;else break}this[r(1378)+"Queue"]=this[r(1378)+r(1670)][r(1446)](p=>!!p),this[r(369)+r(905)+"Id"]=setTimeout(()=>this[r(1271)](),d),this[r(1064)+r(550)+"nt"](s),this[r(756)+"er"]&&this[r(1252)]&&(this[r(1252)][r(969)+"pe"]=this[r(506)+"ype"]);let u=this[r(754)+r(521)]?.["getCurre"+r(1775)+"nt"]();this[r(366)](r(935)+u+" success"),t()},Kd=async function(s,t){let r=n;if(e[r(1798)](e[r(482)],e[r(1221)]))this[r(1779)+r(610)]=_0x14b5f6,this.count=0;else{let d=this[r(754)+r(521)]?.[r(656)+r(1775)+"nt"]();this[r(366)](r(935)+d),e.RmBQV(t)}};class $d extends si{constructor(t){let r=n,d={rHeQr:e[r(404)],kHJEj:function(b,g){return b<g},OHFwe:function(b,g){return e[r(728)](b,g)},wbHyh:function(b,g){return e[r(1677)](b,g)},uqKaI:function(b,g){return e.EwntL(b,g)},lCBxb:function(b,g){return b+g},zwrjt:function(b,g){return b|g}};super(),this[r(1624)+r(1801)+r(1681)]=!0,this[r(756)+"er"]=Bt,this._isNode=dd,this[r(1665)+"T"]=bt,this._isMiniWX=un,this[r(1273)+"r"]=xn,this["_message"+r(1670)]=[],this[r(754)+r(521)]=null,this["_readyCl"+r(586)]=!1,this[r(506)+r(412)]=e[r(440)],this[r(1071)+r(537)]=!1,this[r(1071)+"ionTimeo"+r(1179)]=null,this[r(1095)+r(573)+r(1040)]=null,this[r(369)+r(905)+"Id"]=null,this[r(574)]=0,this[r(1593)]=!1,this[r(413)]="",this[r(1380)+r(1770)]=null,this[r(1344)+r(1272)]=null,this[r(456)+r(1371)]=null,this[r(591)+"ls"]=e[r(1388)],this[r(1556)]=3,this[r(973)+"NG"]=0,this[r(1466)]=1,this.CLOSING=2,this[r(1465)]=b=>{let g=r;try{Us(this,b,[jd,Wd,Kd])}catch(T){let N=Be(d[g(1772)],{message:T[g(1065)],code:xt[g(750)+"OR"],error:T});this[g(1064)+g(1394)+"ent"](N)}},this[r(701)+"ge"]=async b=>{let g=r,{pingInterval:T,pingFrequency:N}=this[g(1436)];if((e[g(549)]("hi",b[g(429)])&&e.ZrZad(e[g(1607)],N)||e[g(1022)]===N)&&(this[g(1332)+"ngTimer"](),this[g(431)]("ping_onc"+g(1726)+"s",e[g(484)]),this[g(369)+g(905)+"Id"]=e[g(793)](setTimeout,this[g(1271)][g(598)](this),T)),!e[g(1613)]("hi",b[g(429)]))try{if(e.MUqjO!==e[g(1753)])Us(this,b,[Sd,vd,qd,Gd,Hd,bd]);else return this._ws?this[g(1252)].binaryType:this[g(506)+g(412)]}catch(B){let q=Be(e[g(404)],{message:B[g(1065)],code:xt[g(1177)+g(1070)],error:B});this[g(1064)+g(1394)+g(724)](q)}},this[r(1126)]=b=>{let g=r,T={PtVdp:function(q,J){return e.NJsFg(q,J)}},N=this[g(754)+g(521)]?.[g(1346)+g(889)+"es"](),B=this[g(754)+"tManager"]?.[g(656)+"ntEndpoint"]();if(N&&!b[g(1065)])if(e[g(1601)]===e[g(1601)]){let q=g(745)+B+(" fail, m"+g(1725)+g(1277)+"ed");this["_dispatc"+g(1394)+g(724)](Be(g(1322),{message:q,code:xt[g(1662)+g(917)+"R"],error:b}));return}else _0x35895e=YkYyhk.PtVdp(_0x16b14b,_0x2ee1fd),_0x4503af=0;this[g(1252)]&&this[g(1252)][g(781)+"te"]===this[g(1466)]&&this[g(1406)+g(1423)](),this[g(1064)+"hErrorEv"+g(724)](e.mqcFj(Be,e[g(404)],{message:b[g(1065)],code:xt[g(913)+g(1206)],error:b}))},this._onClose=async b=>{let g=r;this[g(1039)+g(684)](),this[g(1332)+g(851)](),this[g(1167)+g(799)+"rs"](),this._ws=null,this._connectLock=!1;let T=this[g(754)+"tManager"]?.[g(1346)+g(889)+"es"]();if(!T&&this[g(1075)+g(1151)]()&&!this[g(1649)+g(586)]){let N=this["_endpoin"+g(521)]?.[g(656)+g(1775)+"nt"](),B=this._options["reconnec"+g(1514)+g(1193)](b[g(726)],b[g(786)]);this["_dispatc"+g(1455)+"ent"](e[g(744)](He,e.rYGij,{code:1006,reason:b.reason||g(1330)+g(1218)+g(896)+g(763)+g(1166)+"ame: "+N,willReconnect:B})),B&&this[g(1071)]();return}if(e[g(561)](1e3,b[g(726)])&&this[g(1649)+g(586)]){this[g(1064)+g(1455)+g(724)](e[g(581)](He,e[g(816)],{code:1e3,reason:e[g(1435)]})),this[g(754)+"tManager"]?.[g(477)+g(845)+g(902)](),this["_pingLos"+g(1371)]?.[g(657)+g(1630)]();return}if(e[g(1175)](1e3,b.code)&&T){let N=this[g(754)+g(521)]?.[g(656)+"ntEndpoint"](),B=b[g(786)];B||(B=await e[g(775)](hd,this[g(413)])),B=g(1330)+g(1218)+g(1568)+B+(g(1673)+g(1519))+N+(g(649)+g(995)+g(1764)),this["_dispatc"+g(1455)+g(724)](He(g(1722),{code:b[g(726)],reason:B}));let q=g(745)+N+(g(1317)+"ax retri"+g(1277)+"ed");this[g(1064)+"hErrorEv"+g(724)](e[g(800)](Be,e[g(404)],{message:q,code:xt["MAX_RETR"+g(917)+"R"]})),this[g(754)+g(521)]?.["resetEnd"+g(845)+g(902)](),this[g(456)+g(1371)]?.[g(657)+"nter"]();return}if(e[g(1053)](1e3,b[g(726)])&&!b[g(786)])if(e[g(524)](e[g(1094)],e[g(1390)])){if(tpnTHN[g(630)](_0x1a213e,1)||_0x3ec4d9>_0x31718c)return tpnTHN.OHFwe(_0x18bb22,_0x38665f);tpnTHN.wbHyh(tpnTHN.uqKaI(_0x44f7ba,_0x1b109d),_0x575955)&&(_0x1062d7=tpnTHN[g(986)](_0x1e4d54,_0x5c2bc1),_0x1032ca=0);let N=_0xc55825[g(1142)](_0x2d106c,_0x15c43a,_0x1dcc90+=_0x506cb3);return 7&_0x21e53c&&(_0x45a36b=tpnTHN[g(517)](tpnTHN[g(1408)](7,_0x39ab6a),1)),N}else{let N=this[g(754)+g(521)]?.[g(656)+g(1775)+"nt"]();this["_dispatchCloseEv"+g(724)](He(e[g(816)],{code:b[g(726)],reason:"connecti"+g(1218)+g(896)+g(763)+"n, hostn"+g(737)+N})),this[g(754)+g(521)]?.["resetEnd"+g(845)+g(902)](),this["_pingLos"+g(1371)]?.["resetCou"+g(1630)]();return}this[g(1064)+"hCloseEv"+g(724)](b),this[g(754)+g(521)]?.["resetEnd"+g(845)+g(902)](),this[g(456)+"sCounter"]?.[g(657)+"nter"]()},this[r(1185)]=null,this[r(1553)]=null,this[r(804)+"e"]=null,this[r(967)]=null,this[r(932)+"econnect"]=null,this[r(945)+r(1223)]=null,this["onStopIm"+r(1235)+r(1499)+"ct"]=null,this[r(1405)+r(1001)]=this["_handleO"+r(1001)][r(598)](this),this[r(1405)+r(1757)]=this["_handleO"+r(1757)].bind(this),this[r(1510)+r(1109)]=this[r(1510)+"ageHide"].bind(this),this[r(1510)+r(555)]=this["_handleP"+r(555)][r(598)](this),this[r(1436)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(1448)](1,0),service:0,logIDGenerator:a,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:r(801),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.zKAYQ,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:p}=t,_=Array.isArray(u)?u:e[r(1487)](e[r(1349)],typeof u)?[u]:[];if(!_||_.length===0)throw new Error(e[r(601)]);if(!xd(p))throw new Error(e[r(1493)]);Object[r(678)](this[r(1436)],t),this[r(754)+"tManager"]=new Fs(_,this._options[r(1217)+"es"]),this["_pingLos"+r(1371)]=new pd(this._options[r(1173)+"Count"]),this._options[r(696)+"cOpen"]&&(this[r(1593)]=!0,this[r(1071)]()),this[r(1436)]["listenNe"+r(718)+"nged"]&&(e[r(548)](e[r(1180)],r(1789))?this[r(1697)](_0x18a286,_0x967f75):this._isMiniTT||this[r(920)+"X"]?this["_onPageNetWorkCh"+r(495)]():this._isBrowser&&this[r(1368)+r(710)+r(1397)]())}[n(1405)+n(1001)](){let t=n;this._options[t(567)+t(1642)+t(414)]||this[t(1649)+"osed"]||this["_handleR"+t(1427)]()}[n(1405)+"ffLine"](){let t=n;this._destroyWebSocket();let r=ii(e[t(655)],{message:e[t(543)]});this[t(838)+"mediatel"+t(1499)+"ct"]&&this[t(838)+t(1235)+"yReconnect"](r)}[n(1368)+n(710)+n(1397)](){let t=n;this[t(756)+"er"]&&window[t(1021)+t(1397)](e[t(767)],this["_handleO"+t(1001)]),this[t(756)+"er"]&&window[t(1021)+t(1397)](e[t(1562)],this[t(1405)+t(1757)]),this[t(756)+"er"]&&window["addEvent"+t(1397)](e[t(1274)],this[t(1510)+t(1109)]),this[t(756)+"er"]&&window[t(1021)+"Listener"](e[t(1006)],this[t(1510)+t(555)])}[n(1303)+n(710)+n(1397)](){let t=n;this[t(756)+"er"]&&window["removeEv"+t(1748)+"ner"](e.tELuP,this[t(1405)+t(1001)]),this[t(756)+"er"]&&window[t(699)+t(1748)+t(1276)](e.CBPFU,this[t(1405)+"ffLine"]),this[t(756)+"er"]&&window[t(699)+t(1748)+t(1276)](e[t(1274)],this[t(1510)+t(1109)]),this[t(756)+"er"]&&window[t(699)+t(1748)+t(1276)](e.GevKf,this[t(1510)+t(555)])}["_handleP"+n(1109)](t){let r=n;!t[r(1651)+"d"]&&(this[r(756)+"er"]&&window["removeEv"+r(1748)+r(1276)](r(1646),this["_handleP"+r(1109)]),this[r(756)+"er"]&&window[r(699)+r(1748)+"ner"](e[r(1006)],this[r(1510)+"ageShow"]),this[r(1722)]()),this[r(756)+"er"]&&window[r(699)+r(1748)+r(1276)](e[r(767)],this[r(1405)+r(1001)]),this[r(756)+"er"]&&window[r(699)+r(1748)+r(1276)](e[r(1562)],this[r(1405)+r(1757)])}[n(1510)+n(555)](t){let r=n;t[r(1651)+"d"]&&(this["_navigat"+r(1151)]()&&(!this[r(1252)]||e[r(1159)](this[r(1252)][r(781)+"te"],this[r(1466)])||e[r(1106)](this[r(1252)][r(781)+"te"],this[r(973)+"NG"]))&&this[r(1405)+r(1001)](),this[r(756)+"er"]&&window[r(1021)+r(1397)](e.tELuP,this[r(1405)+r(1001)]),this[r(756)+"er"]&&window[r(1021)+r(1397)](e[r(1562)],this[r(1405)+"ffLine"]))}async[n(955)+n(1456)](t){let r=n,{fpID:d,deviceID:u,bddID:p,ttwID:_,accessKey:b,aID:g,customParams:T={},enableAutoAck:N,enableQoS:B,QoSLevel:q,env:J}=this[r(1436)],V,Re,Le;this[r(756)+"er"]||this._isMiniWX||this[r(1665)+"T"]?(V=location&&e[r(992)](e[r(789)],location[r(437)])?e[r(1019)]:r(910),Re=t.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),Le=/^wss(.*:\/\/)/[r(1557)](t)?t:""+V+Re):e[r(1066)](r(1518),r(1518))?(V=e[r(1019)],Re=t.replace(/(^http)((?:[s]*:\/\/))/,""),Le=/(^ws)((?:[s]*:\/\/))/[r(1557)](Re)?Re:""+V+Re):(_0x2e4ae3[_0x46a6d2++]=e[r(1293)](e[r(856)](_0x5a12b2>>18,7),240),_0x135f13[_0x11482b++]=e.UMsqm(e[r(1284)](_0x533ee3,12),63)|128);let qe=p?e.xbXbe:_?e.FzaqD:r(960)+"d",Ft=p||_||u;if(e[r(1093)](!Ft,!qe))throw new Error(r(1360)+r(1307)+"ddID, de"+r(1110)+r(959));let St=e[r(1487)](e[r(552)],typeof T)?await T():T,It=J?e.KpDnV(gd,J[r(1639)],J.xTTEnv):{},ln=Object.assign({device_platform:e[r(463)],version_code:e[r(1377)],access_key:b,fpid:d,aid:g,[qe]:Ft,xsack:N?1:0,xaack:N?1:0,xsqos:B?1:0,qos_level:B?q:void 0,qos_sdk_version:2,...It},St),Jd=Object[r(873)](ln).reduce((xi,li)=>ln[li]!==void 0?""+xi+(xi?"&":"?")+li+"="+ln[li]:xi,"");return Le+r(1767)+Jd}async[n(1071)](){let t=n,r={qgedl:function(d,u){return d==u},KKYOn:e.EOvQc,JUaRW:e[t(1019)]};if(e[t(1447)](e.yQVAi,e[t(1048)])){if(this[t(1071)+t(537)]||this[t(1649)+"osed"])return;this[t(1071)+t(537)]=!0;try{let d=this[t(754)+t(521)]?.[t(1445)+t(1755)+t(1376)+"hedMaxRe"+t(1530)](),{timeoutInterval:u}=this[t(1436)];if(d){let _=this["_endpoin"+t(521)]?.getCurrentEndpoint(),b=this[t(754)+t(521)]?.[t(1710)+t(984)+t(1412)+t(663)+t(1720)](),g=this[t(754)+t(521)]?.[t(656)+"ntEndpoi"+t(1751)+t(610)]();if(b){let T=t(745)+_+(t(1209)+", max re"+t(995)+t(922)+t(1603)+t(1584)+t(596))+b+(t(1268)+"y"),N=e.ByHcd(Be,e[t(404)],{message:T,code:xt[t(1662)+t(917)+"R"]});this._debug(T),this[t(1064)+t(1394)+"ent"](N),this[t(413)]=await this[t(955)+"eUrl"](b),this[t(366)](t(745)+b+" "+g+t(1507)),this["_removeW"+t(799)+"rs"]()}else{let T=t(745)+_+(t(1209)+t(649)+t(995)+t(1764));this._debug(T),this[t(1064)+t(1394)+t(724)](e[t(1355)](Be,e.QOpLt,{message:T,code:xt[t(1662)+t(917)+"R"]}));return}}else{let _=this[t(754)+t(521)]?.[t(656)+t(1775)+t(1392)+t(933)](),b=this[t(754)+t(521)]?.["getCurre"+t(1775)+"ntTriesC"+t(610)]();this[t(413)]=await this["_generat"+t(1456)](e[t(494)](_,"")),this._debug("connect "+_+" "+b+t(1507)),this[t(1167)+t(799)+"rs"]()}if(this._isInit)this[t(1593)]=!1;else{let _=e[t(1529)](ii,e.wdQHG,{message:e[t(666)]});this.onStartReconnect&&this[t(932)+t(1427)](_)}let p=this[t(754)+"tManager"]?.[t(656)+t(1775)+"ntTriesCount"]()||0;e[t(1564)](p,1)&&await this[t(970)](e[t(370)](p,1)),this[t(366)](t(1330)+"ng url: "+this[t(413)]+(t(1506)+t(1215))+this[t(591)+"ls"]),this[t(1252)]=e.ivpsK(ud,{url:this[t(413)],protocols:[this[t(591)+"ls"]],headers:this._options[t(1103)+t(1566)+"s"]["customHt"+t(629)]},this[t(1436)].ws),(this[t(756)+"er"]||this[t(1273)+"r"])&&this[t(1252)]&&(this[t(1252)][t(969)+"pe"]=this[t(506)+t(412)]),this[t(491)+t(381)](),this["_connect"+t(687)+"utId"]=e[t(1596)](setTimeout,this[t(1634)+"ut"][t(598)](this),u)}catch(d){throw this[t(1071)+t(537)]=!1,d}}else _0x7266f9=_0x285746&&BHgyZZ[t(1580)](BHgyZZ[t(1644)],_0xb162d8[t(437)])?BHgyZZ.JUaRW:t(910),_0x1b85e9=_0xe441eb.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),_0x3cbc5a=/^wss(.*:\/\/)/[t(1557)](_0x5617af)?_0x31cbd4:""+_0x50fe12+_0x1e16a5}["_clearTi"+n(684)](){let t=n;if(e[t(603)](e[t(915)],e[t(915)]))e[t(1535)](clearTimeout,this[t(1071)+"ionTimeoutId"]),this[t(1071)+t(687)+"utId"]=null;else return _0x3b296d["objectSt"+t(951)][1]?void 0:_0x3a0b64[t(387)+t(1459)](_0x50a382["objectSt"+t(951)][0])}[n(1332)+n(851)](){let t=n;e[t(1583)](clearTimeout,this["_pingPon"+t(905)+"Id"]),clearTimeout(this[t(1095)+t(573)+t(1040)]),this[t(369)+"gTimeoutId"]=null,this["_reconne"+t(573)+"tId"]=null}[n(366)](...t){let r=n;this[r(1436)].debug&&console[r(1125)][r(508)](console,[e[r(1224)],...t])}[n(563)+n(1097)+"e"](t){let r=n,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:p}=this[r(1436)],_=e[r(430)](d,Math[r(1229)](p,e[r(576)](t,1)));return e[r(853)](_,u)?u:_}[n(1271)](){let t=n;if(this._ws&&e[t(568)](this[t(1252)][t(781)+"te"],this[t(973)+"NG"])){this[t(1332)+"ngTimer"](),this[t(369)+t(905)+"Id"]=e.DMNqj(setTimeout,this._ping[t(598)](this),this._options[t(1016)+t(1592)]);return}if(!this[t(1252)]||e[t(608)](this[t(1252)].readyState,this[t(1466)]))return void this[t(1414)+t(1427)]();this[t(1252)]&&this[t(1252)][t(1336)]("hi"),this[t(1095)+"ctTimeou"+t(1040)]=setTimeout(this[t(1414)+t(1427)+"Timeout"].bind(this),this[t(1436)][t(634)+t(777)+"val"])}[n(1414)+n(1427)+"Timeout"](){let t=n;this[t(456)+t(1371)]?.addCount(),this[t(431)](e.sxvlY,t(996)),this["_pingLos"+t(1371)]?.[t(1346)+"chMaxCount"]()?this["_handleR"+t(1427)]():this[t(1271)]()}[n(1075)+"orOnline"](){let t=n;return this._isMiniTT||this._isMiniWX?this[t(1624)+t(1801)+t(1681)]:(this._isBrowser||this[t(1273)+"r"])&&this[t(1436)][t(819)+"tworkCha"+t(1302)]?navigator[t(1559)]:!0}[n(1414)+n(1427)](){let t=n;!this[t(1075)+t(1151)]()||this[t(1649)+t(586)]||(this["_endpoin"+t(521)]?.[t(477)+t(845)+t(902)](),this[t(456)+t(1371)]?.[t(657)+t(1630)](),this[t(1252)]?this[t(1406)+t(1423)](1001,e.cHnft,!0):this[t(1071)]())}[n(1116)+n(500)+n(495)](){let t=n;this[t(1665)+"T"]?tt["onNetwor"+t(1325)+t(1574)](({isConnected:r})=>{let d=t;this["_miniNav"+d(1801)+d(1681)]=r,r?this[d(1405)+"nLine"]():this._handleOffLine()}):this._isMiniWX&&wx[t(1120)+t(1325)+t(1574)](({isConnected:r})=>{let d=t;this[d(1624)+"igatorOn"+d(1681)]=r,r?this[d(1405)+d(1001)]():this["_handleO"+d(1757)]()})}[n(970)](t){return new Promise(r=>{let d=G;e[d(1056)](setTimeout,r,this[d(563)+d(1097)+"e"](t))})}[n(1406)+n(1423)](t=1e3,r="",d=!1){let u=n;this._ws&&this[u(1279)+u(489)+"t"](t,r,d)}[n(1634)+"ut"](){let t=n,r=this["_endpoin"+t(521)]?.[t(656)+t(1775)+"nt"]();this[t(366)](t(745)+r+t(1209)),this[t(1406)+t(1423)](1001,e[t(375)],!0)}[n(648)](t){let r=n,d=e[r(1057)](_e,t);this[r(1252)]&&e[r(776)](this[r(1252)].readyState,this[r(1466)])&&(this._ws&&this[r(1252)].send(d),this[r(366)](e[r(833)],t))}["_removeW"+n(799)+"rs"](){let t=n;this[t(1252)]&&(this._ws[t(699)+t(1748)+t(1276)](e.BSRni,this[t(1465)]),this[t(1252)][t(699)+t(1748)+t(1276)](e.rYGij,this[t(1554)]),this[t(1252)][t(699)+t(1748)+t(1276)](e.fKDzF,this._onMessage),this[t(1252)]["removeEv"+t(1748)+t(1276)](e[t(404)],this[t(1126)]))}[n(491)+n(381)](){let t=n,r=e.GsNMj[t(677)]("|"),d=0;for(;;){switch(r[d++]){case"0":this._ws[t(1021)+"Listener"](e.QOpLt,this[t(1126)]);continue;case"1":if(!this._ws)return;continue;case"2":this[t(1252)][t(1021)+t(1397)](e[t(644)],this[t(701)+"ge"]);continue;case"3":this[t(1252)][t(1021)+t(1397)](e[t(1675)],this._onOpen);continue;case"4":this[t(1252)]["addEvent"+t(1397)](e.rYGij,this[t(1554)]);continue}break}}[n(1633)+n(1653)](t=1e3,r=""){let d=n;try{e[d(405)](e[d(672)],e[d(531)])?(mTjBxK[d(441)](_0x2ba650,_0x58b0c7.error||new _0x44a238(d(1347)+"or",d(1347)+"or")),mTjBxK[d(1087)](_0x21ef75)):this[d(1252)]&&this[d(1252)].close(t,r)}catch{}}[n(1279)+"WebSocket"](t=1e3,r="",d=!1){let u=n;if(this["_clearPi"+u(851)](),this[u(1039)+u(684)](),this[u(1167)+u(799)+"rs"](),this[u(1633)+u(1653)](1e3,r),this[u(1071)+u(537)]=!1,d&&this[u(1075)+u(1151)]()&&!this[u(1649)+u(586)]){if(this[u(754)+"tManager"]?.[u(1346)+"chMaxTries"]()){let _=this[u(754)+"tManager"]?.getCurrentEndpoint();this["_dispatc"+u(1455)+"ent"](e.Khxza(He,e[u(816)],{code:1006,reason:u(745)+_+(" timeout, max re"+u(995)+u(1764)),wasClean:!0}))}else{let _=this[u(1436)][u(720)+u(1514)+u(1193)](t,r);this["_dispatc"+u(1455)+u(724)](e[u(581)](He,e[u(816)],{code:t,reason:r,wasClean:!0,willReconnect:_})),_&&this[u(1071)]()}return}this._navigatorOnline()||this[u(1649)+u(586)]?this[u(1064)+u(1455)+u(724)](e[u(1659)](He,e[u(816)],{code:t,reason:e.TNRzX})):this[u(1064)+u(1455)+u(724)](e[u(1355)](He,e[u(816)],{code:1006,reason:u(1418)+u(1313)+"ork offline"})),this[u(1252)]=null,this[u(754)+u(521)]?.[u(477)+u(845)+"fig"](),this[u(456)+u(1371)]?.[u(657)+u(1630)]()}[n(1064)+"hOpenEvent"](t){let r=n;this[r(431)](r(616),t),this[r(967)]&&this[r(967)](t)}[n(1064)+"hMessage"+n(1323)](t){let r=n;this[r(431)](e[r(644)],t),this[r(804)+"e"]&&this[r(804)+"e"](t)}[n(1064)+n(1696)+n(1565)](t){let r=n;this[r(431)](e[r(623)],t),this[r(945)+r(1223)]&&this[r(945)+r(1223)](t)}[n(1064)+n(1394)+"ent"](t){let r=n;this[r(431)](r(1322),t),this[r(1553)]&&this.onerror(t)}[n(1064)+"hCloseEv"+n(724)](t){let r=n;this[r(431)]("close",t),this[r(1185)]&&this[r(1185)](t)}get[n(969)+"pe"](){let t=n;return this[t(1252)]?this[t(1252)].binaryType:this._binaryType}set[n(969)+"pe"](t){let r=n;this[r(506)+r(412)]=t,this[r(1252)]&&(this._ws[r(969)+"pe"]=t)}get[n(823)+"nt"](){let t=n;return this[t(754)+"tManager"]?.[t(656)+t(1775)+t(1751)+t(610)]()||0}get["buffered"+n(858)](){let t=n,r={jRclg:function(u,p){return e[G(1192)](u,p)},UYhyn:function(u,p){return e[G(1478)](u,p)}},d=this["_message"+t(1670)][t(1286)]((u,p)=>{let _=t;if(r.UYhyn(_(1401),"KpJET"))return u+=p&&p.byteLength||0,u;{let b=_0x3f2dad[_(677)](":");for(let g=0;Uftjgf[_(937)](g,b[_(669)]);g++){let T=b[g];if(Uftjgf[_(420)](4,b[g][_(669)])){let N=_0x2ef870[_(826)+"g"](0,4-b[g][_(669)]),B=N[_(766)](T);_0x53e425=_0x284de7[_(766)](B)}else _0x36bcaa=_0x441213[_(766)](T)}return _0x4fb1d7}},0);return e[t(1362)](d,this[t(1252)]?this[t(1252)][t(1184)+t(858)]:0)}get[n(1606)+"ns"](){let t=n;return this[t(1252)]?this[t(1252)][t(1606)+"ns"]:""}get[n(437)](){let t=n;return this[t(1252)]?this[t(1252)][t(437)]:""}get[n(781)+"te"](){let t=n;if(e[t(544)]!==e[t(544)])this[t(1697)](_0x1a8bd6,_0x142ce1);else return this[t(1252)]?this[t(1252)][t(781)+"te"]:this._options[t(696)+t(814)]?this[t(973)+"NG"]:this[t(1556)]}get[n(1391)](){let t=n;return this[t(1252)]?this[t(1252)][t(1391)]:this._url}[n(1722)](t=1e3,r){let d=n;if(d(409)!==d(409)){if(mTjBxK[d(1756)](_0x10736f,d(919)))return _0x34ba73[d(376)](_0x28ca7d);if(mTjBxK.IRlYI(_0x5e43fe,d(387)+d(951)))return _0x31188b[d(387)+"oreNames"]||_0x275edd[d(376)](_0x512082);if(_0xe1c8b0===d(1680))return _0x1a6e85["objectSt"+d(951)][1]?void 0:_0x12d439[d(387)+d(1459)](_0x470b35[d(387)+d(951)][0])}else{if(this[d(1649)+d(586)]=!0,this["_clearTi"+d(684)](),this[d(1332)+d(851)](),this[d(1303)+d(710)+d(1397)](),this[d(1380)+d(1770)]?.closeDB(),!this[d(1252)])return void this[d(366)](e[d(646)]);if(e[d(1756)](this[d(1252)][d(781)+"te"],this.CLOSED)||e[d(1447)](this[d(1252)].readyState,this[d(1474)]))return void this[d(366)](e[d(1585)]);this[d(1279)+d(489)+"t"](t,r)}}async send(t,r){let d=n;if(t==null)throw new Error(d(1360)+"rovide a valid d"+d(1082)+d(365)+d(1709)+d(1135)+d(588)+d(493));e[d(380)](e[d(1044)],typeof t)&&(t=JSON.stringify(t)),e[d(432)](d(1627),typeof t)&&!e.Fkjqw(t,ArrayBuffer)&&!(t[d(593)]&&e[d(442)](t.buffer,ArrayBuffer))&&(t=JSON[d(1160)+"y"](t));let u=await e.BqXjU(Gs,t),p=e[d(1148)](ld,t),{method:_=0,service:b=this._options[d(1023)],logID:g=this._options["logIDGen"+d(808)](),headers:T=this[d(1436)][d(400)],payloadEncoding:N=this[d(1436)]["payloadE"+d(480)],payloadType:B=this[d(1436)][d(1207)+"ype"],logIDNew:q=this[d(1436)][d(1122)+d(859)][d(612)+d(725)+d(1358)+"ew"]?o(this[d(1436)]["logIDNew"+d(859)][d(1e3)]):""}=e[d(609)](r,{});if(!b)throw new Error(e[d(700)]);let J={SeqID:re[d(785)+"er"](this[d(574)]++),LogID:re.fromNumber(g),service:b,method:_,headers:T,payloadEncoding:e[d(1096)](N,Object)?N[d(1463)]?N[d(1463)]:"":N,payloadType:B instanceof Object?B[d(1738)]?B[d(1738)]:p:B||p,payload:u,LogIDNew:q},V=e[d(1524)](_e,J);return this[d(1252)]&&e.QJWxM(this._ws.readyState,this[d(1466)])?(this[d(1252)]&&this._ws[d(1336)](V),this._debug(e[d(1542)],J)):e[d(749)](this[d(1378)+"Queue"][d(669)],this[d(1436)][d(875)+d(1432)+d(395)])?(this[d(1378)+"Queue"][d(1054)](V),this[d(366)](e[d(1318)],J)):(this[d(1378)+d(1670)][d(433)](),this[d(1378)+d(1670)][d(1054)](V)),{seqID:this._seqId,logID:g,logIDNew:q}}async reconnect(t){let r=n,d={wgKbN:function(_,b,g){return _(b,g)},uEFnx:e[r(434)]},{url:u}=e.jutoL(t,{}),p=Array.isArray(u)?u:e.lkvls(e[r(1349)],typeof u)?[u]:[];t&&Object[r(678)](this[r(1436)],t),p&&p[r(669)]?this[r(754)+"tManager"]=new Fs(p,this[r(1436)][r(1217)+"es"]):this[r(754)+r(521)]?.[r(477)+r(845)+r(902)](),this[r(456)+"sCounter"]?.["resetCou"+r(1630)](this[r(1436)][r(1173)+r(1622)]),this[r(1649)+r(586)]=!1,this[r(1252)]&&e[r(639)](this[r(1252)].readyState,this.CLOSED)?this[r(1406)+r(1423)](1e3,e[r(738)],!0):e[r(891)]===e[r(891)]?(this[r(1593)]=!0,this._connect()):(this[r(762)+r(1522)]=_0x1d6f1e,this[r(1672)+r(1104)]=_0x1cc1a8,this[r(1378)+"Strategy"]=_0x31b894,this._qosDB=SDGxYD[r(1034)](_0x24e608,this["_cursorN"+r(1522)],SDGxYD.uEFnx))}async[n(1143)](){let t=n,r={sjsLL:function(d){return e.kxdpg(d)}};if(e[t(583)]("FHMxj",e[t(1479)]))return e.pCzOi(e[t(1349)],typeof _0x291afd)?t(1490)+t(1015)+t(597):"";!this[t(1071)+"Lock"]&&(e[t(1409)]===e[t(1008)]?(this[t(1593)]=!1,_0x59f65b(this[t(1071)+t(687)+"utId"]),QbIBht[t(779)](_0x463d6e)):(this["_endpoin"+t(521)]?.[t(477)+t(845)+"fig"](),this[t(456)+t(1371)]?.resetCounter(),this[t(1649)+t(586)]=!1,this[t(1593)]=!0,this[t(1071)]()))}[n(1021)+"Listener"](t,r){let d=n,u={yveRO:function(p,_){return p<=_},ukRql:e.oDXsA,OBhJF:function(p,_){return p===_},vHtZe:function(p,_){return e[G(923)](p,_)}};if(d(825)===e[d(898)])return yckVPz[d(1711)](_0x4d365f,_0x38db24)?_0x192504[d(784)](new _0x3653fc(yckVPz[d(650)])):(_0x1b3133=_0x59a0dd,yckVPz[d(1013)](_0x51ffc2,_0x102cce[d(669)])?_0x4ba702.resolve():_0x172a0d[_0x4852ca][d(598)](_0x3a5a85)(_0x247ac0,_0x346402[d(598)](null,yckVPz.vHtZe(_0x5a5744,1))));this.on(t,r)}[n(1523)+"Event"](t){let r=n,{type:d}=t;this[r(431)](d,t)}[n(699)+n(1748)+n(1276)](t,r){let d=n;e[d(1077)]!=="tXjVL"?this[d(1697)](t,r):this[d(1436)][d(1724)]&&_0x2d2bd5.log[d(508)](_0x18a9c6,[d(1311)+">",..._0x2fce26])}[n(1760)](){let t=n,r={DSzWB:function(d,u){return e[G(1524)](d,u)},agUfy:t(1061)+"e_success",hBaaa:e.sxvlY,YSofb:e[t(1370)]};return new Promise((d,u)=>{let p=t,_={QOHUi:r[p(1668)],PaAYf:r[p(1689)]};this["_clearPi"+p(851)](),this[p(369)+"gTimeoutId"]=setTimeout(this[p(1271)][p(598)](this),this._options[p(1016)+p(1592)]);let b=()=>{let T=p;r.DSzWB(d,T(454)),this[T(1697)](r.agUfy,b),this[T(1697)](r[T(1689)],g)},g=()=>{let T=p;u(_[T(1088)]),this[T(1697)]("ping_onc"+T(1726)+"s",b),this[T(1697)](_[T(502)],g)};this.on(p(1061)+p(1726)+"s",b),this.on(r.hBaaa,g),this[p(1271)]()})}}})(),he[O(1742)+"oseEvent"]=pe["CustomCl"+O(1728)],he[O(982)+O(1067)]=pe["CustomEr"+O(1067)],he[O(1156)+"e"]=pe.ErrorCode,he.Event=pe[O(1323)],he[O(1214)]=pe[O(1214)],he[O(1667)+O(571)+O(974)]=pe[O(1667)+O(571)+O(974)],he[O(571)+O(974)]=pe[O(571)+O(974)],he[O(1163)+"t"]=pe[O(1163)+"t"],he[O(643)+O(1443)]=pe[O(643)+O(1443)],he[O(1415)+"oseEvent"]=pe[O(1415)+O(1728)],he[O(1632)+O(1067)]=pe[O(1632)+O(1067)],he[O(1736)+O(1085)+"nt"]=pe[O(1736)+"ssageEvent"],he[O(1395)+"enEvent"]=pe["createOp"+O(1600)],he[O(961)+O(1357)+O(974)]=pe[O(961)+"connectE"+O(974)],he[O(614)+O(1713)]=pe[O(614)+O(1713)],he[O(949)+O(497)]=pe[O(949)+O(497)];for(vr in pe)[O(1742)+"oseEvent",O(982)+O(1067),"ErrorCode",O(1323),O(1214),O(1667)+O(571)+O(974),"MessageE"+O(974),"OpenEvent",O(643)+O(1443),"createCl"+O(1728),O(1632)+O(1067),O(1736)+"ssageEvent",O(1395)+O(1600),O(961)+O(1357)+O(974),O(614)+"rame",O(949)+O(497)][O(1301)](vr)===-1&&(he[vr]=pe[vr]);var vr;Object[O(1356)+"operty"](he,O(572)+"le",{value:!0})});var ot=ee((x2,_c)=>{"use strict";var mc=["nodebuffer","arraybuffer","fragments"],wc=typeof Blob<"u";wc&&mc.push("blob");_c.exports={BINARY_TYPES:mc,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:wc,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Dn=ee((l2,Dr)=>{"use strict";var{EMPTY_BUFFER:Jl}=ot(),Ki=Buffer[Symbol.species];function Vl(n,e){if(n.length===0)return Jl;if(n.length===1)return n[0];let i=Buffer.allocUnsafe(e),o=0;for(let a=0;a<n.length;a++){let c=n[a];i.set(c,o),o+=c.length}return o<e?new Ki(i.buffer,i.byteOffset,o):i}function yc(n,e,i,o,a){for(let c=0;c<a;c++)i[o+c]=n[c]^e[c&3]}function Ec(n,e){for(let i=0;i<n.length;i++)n[i]^=e[i&3]}function Zl(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function $i(n){if($i.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new Ki(n):ArrayBuffer.isView(n)?e=new Ki(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),$i.readOnly=!1),e}Dr.exports={concat:Vl,mask:yc,toArrayBuffer:Zl,toBuffer:$i,unmask:Ec};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ie("bufferutil");Dr.exports.mask=function(e,i,o,a,c){c<48?yc(e,i,o,a,c):n.mask(e,i,o,a,c)},Dr.exports.unmask=function(e,i){e.length<32?Ec(e,i):n.unmask(e,i)}}catch{}});var Sc=ee((g2,bc)=>{"use strict";var vc=Symbol("kDone"),Ji=Symbol("kRun"),Vi=class{constructor(e){this[vc]=()=>{this.pending--,this[Ji]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ji]()}[Ji](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[vc])}}};bc.exports=Vi});var rn=ee((p2,Tc)=>{"use strict";var Pn=ie("zlib"),Ic=Dn(),Yl=Sc(),{kStatusCode:Cc}=ot(),Xl=Buffer[Symbol.species],Ql=Buffer.from([0,0,255,255]),kr=Symbol("permessage-deflate"),at=Symbol("total-length"),tn=Symbol("callback"),yt=Symbol("buffers"),nn=Symbol("error"),Pr,Zi=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,!Pr){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Pr=new Yl(i)}}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[tn];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let i=this._options,o=e.find(a=>!(i.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(i.serverMaxWindowBits===!1||typeof i.serverMaxWindowBits=="number"&&i.serverMaxWindowBits>a.server_max_window_bits)||typeof i.clientMaxWindowBits=="number"&&!a.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return i.serverNoContextTakeover&&(o.server_no_context_takeover=!0),i.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof i.serverMaxWindowBits=="number"&&(o.server_max_window_bits=i.serverMaxWindowBits),typeof i.clientMaxWindowBits=="number"?o.client_max_window_bits=i.clientMaxWindowBits:(o.client_max_window_bits===!0||i.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let i=e[0];if(this._options.clientNoContextTakeover===!1&&i.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!i.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(i.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&i.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return i}normalizeParams(e){return e.forEach(i=>{Object.keys(i).forEach(o=>{let a=i[o];if(a.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(a=a[0],o==="client_max_window_bits"){if(a!==!0){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else if(o==="server_max_window_bits"){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=c}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else throw new Error(`Unknown parameter "${o}"`);i[o]=a})}),e}decompress(e,i,o){Pr.add(a=>{this._decompress(e,i,(c,f)=>{a(),o(c,f)})})}compress(e,i,o){Pr.add(a=>{this._compress(e,i,(c,f)=>{a(),o(c,f)})})}_decompress(e,i,o){let a=this._isServer?"client":"server";if(!this._inflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Pn.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Pn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[kr]=this,this._inflate[at]=0,this._inflate[yt]=[],this._inflate.on("error",tg),this._inflate.on("data",Ac)}this._inflate[tn]=o,this._inflate.write(e),i&&this._inflate.write(Ql),this._inflate.flush(()=>{let c=this._inflate[nn];if(c){this._inflate.close(),this._inflate=null,o(c);return}let f=Ic.concat(this._inflate[yt],this._inflate[at]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[at]=0,this._inflate[yt]=[],i&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),o(null,f)})}_compress(e,i,o){let a=this._isServer?"server":"client";if(!this._deflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Pn.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Pn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[at]=0,this._deflate[yt]=[],this._deflate.on("data",eg)}this._deflate[tn]=o,this._deflate.write(e),this._deflate.flush(Pn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Ic.concat(this._deflate[yt],this._deflate[at]);i&&(c=new Xl(c.buffer,c.byteOffset,c.length-4)),this._deflate[tn]=null,this._deflate[at]=0,this._deflate[yt]=[],i&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),o(null,c)})}};Tc.exports=Zi;function eg(n){this[yt].push(n),this[at]+=n.length}function Ac(n){if(this[at]+=n.length,this[kr]._maxPayload<1||this[at]<=this[kr]._maxPayload){this[yt].push(n);return}this[nn]=new RangeError("Max payload size exceeded"),this[nn].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[nn][Cc]=1009,this.removeListener("data",Ac),this.reset()}function tg(n){if(this[kr]._inflate=null,this[nn]){this[tn](this[nn]);return}n[Cc]=1007,this[tn](n)}});var sn=ee((h2,Rr)=>{"use strict";var{isUtf8:Dc}=ie("buffer"),{hasBlob:ng}=ot(),rg=[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 ig(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function Yi(n){let e=n.length,i=0;for(;i<e;)if((n[i]&128)===0)i++;else if((n[i]&224)===192){if(i+1===e||(n[i+1]&192)!==128||(n[i]&254)===192)return!1;i+=2}else if((n[i]&240)===224){if(i+2>=e||(n[i+1]&192)!==128||(n[i+2]&192)!==128||n[i]===224&&(n[i+1]&224)===128||n[i]===237&&(n[i+1]&224)===160)return!1;i+=3}else if((n[i]&248)===240){if(i+3>=e||(n[i+1]&192)!==128||(n[i+2]&192)!==128||(n[i+3]&192)!==128||n[i]===240&&(n[i+1]&240)===128||n[i]===244&&n[i+1]>143||n[i]>244)return!1;i+=4}else return!1;return!0}function sg(n){return ng&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}Rr.exports={isBlob:sg,isValidStatusCode:ig,isValidUTF8:Yi,tokenChars:rg};if(Dc)Rr.exports.isValidUTF8=function(n){return n.length<24?Yi(n):Dc(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ie("utf-8-validate");Rr.exports.isValidUTF8=function(e){return e.length<32?Yi(e):n(e)}}catch{}});var ns=ee((m2,Mc)=>{"use strict";var{Writable:og}=ie("stream"),Pc=rn(),{BINARY_TYPES:ag,EMPTY_BUFFER:kc,kStatusCode:cg,kWebSocket:dg}=ot(),{concat:Xi,toArrayBuffer:fg,unmask:ug}=Dn(),{isValidStatusCode:xg,isValidUTF8:Rc}=sn(),Lr=Buffer[Symbol.species],Fe=0,Lc=1,Nc=2,Oc=3,Qi=4,es=5,Nr=6,ts=class extends og{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||ag[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[dg]=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=Fe}_write(e,i,o){if(this._opcode===8&&this._state==Fe)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 Lr(o.buffer,o.byteOffset+e,o.length-e),new Lr(o.buffer,o.byteOffset,e)}let i=Buffer.allocUnsafe(e);do{let o=this._buffers[0],a=i.length-e;e>=o.length?i.set(this._buffers.shift(),a):(i.set(new Uint8Array(o.buffer,o.byteOffset,e),a),this._buffers[0]=new Lr(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return i}startLoop(e){this._loop=!0;do switch(this._state){case Fe:this.getInfo(e);break;case Lc:this.getPayloadLength16(e);break;case Nc:this.getPayloadLength64(e);break;case Oc:this.getMask();break;case Qi:this.getData(e);break;case es:case Nr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let i=this.consume(2);if((i[0]&48)!==0){let a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let o=(i[0]&64)===64;if(o&&!this._extensions[Pc.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(i[0]&128)===128,this._opcode=i[0]&15,this._payloadLength=i[1]&127,this._opcode===0){if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(i[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=Lc:this._payloadLength===127?this._state=Nc: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 i=this.consume(8),o=i.readUInt32BE(0);if(o>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=o*Math.pow(2,32)+i.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 i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(i);return}this._masked?this._state=Oc:this._state=Qi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Qi}getData(e){let i=kc;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}i=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&ug(i,this._mask)}if(this._opcode>7){this.controlMessage(i,e);return}if(this._compressed){this._state=es,this.decompress(i,e);return}i.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(i)),this.dataMessage(e)}decompress(e,i){this._extensions[Pc.extensionName].decompress(e,this._fin,(a,c)=>{if(a)return i(a);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");i(f);return}this._fragments.push(c)}this.dataMessage(i),this._state===Fe&&this.startLoop(i)})}dataMessage(e){if(!this._fin){this._state=Fe;return}let i=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let a;this._binaryType==="nodebuffer"?a=Xi(o,i):this._binaryType==="arraybuffer"?a=fg(Xi(o,i)):this._binaryType==="blob"?a=new Blob(o):a=o,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=Fe):(this._state=Nr,setImmediate(()=>{this.emit("message",a,!0),this._state=Fe,this.startLoop(e)}))}else{let a=Xi(o,i);if(!this._skipUTF8Validation&&!Rc(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===es||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=Fe):(this._state=Nr,setImmediate(()=>{this.emit("message",a,!1),this._state=Fe,this.startLoop(e)}))}}controlMessage(e,i){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,kc),this.end();else{let o=e.readUInt16BE(0);if(!xg(o)){let c=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");i(c);return}let a=new Lr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Rc(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");i(c);return}this._loop=!1,this.emit("conclude",o,a),this.end()}this._state=Fe;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Fe):(this._state=Nr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Fe,this.startLoop(i)}))}createError(e,i,o,a,c){this._loop=!1,this._errored=!0;let f=new e(o?`Invalid WebSocket frame: ${i}`:i);return Error.captureStackTrace(f,this.createError),f.code=c,f[cg]=a,f}};Mc.exports=ts});var ss=ee((_2,Fc)=>{"use strict";var{Duplex:w2}=ie("stream"),{randomFillSync:lg}=ie("crypto"),Bc=rn(),{EMPTY_BUFFER:gg,kWebSocket:pg,NOOP:hg}=ot(),{isBlob:on,isValidStatusCode:mg}=sn(),{mask:zc,toBuffer:Tt}=Dn(),Ue=Symbol("kByteLength"),wg=Buffer.alloc(4),Or=8*1024,Dt,an=Or,Ge=0,_g=1,yg=2,rs=class n{constructor(e,i,o){this._extensions=i||{},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=Ge,this.onerror=hg,this[pg]=void 0}static frame(e,i){let o,a=!1,c=2,f=!1;i.mask&&(o=i.maskBuffer||wg,i.generateMask?i.generateMask(o):(an===Or&&(Dt===void 0&&(Dt=Buffer.alloc(Or)),lg(Dt,0,Or),an=0),o[0]=Dt[an++],o[1]=Dt[an++],o[2]=Dt[an++],o[3]=Dt[an++]),f=(o[0]|o[1]|o[2]|o[3])===0,c=6);let x;typeof e=="string"?(!i.mask||f)&&i[Ue]!==void 0?x=i[Ue]:(e=Buffer.from(e),x=e.length):(x=e.length,a=i.mask&&i.readOnly&&!f);let l=x;x>=65536?(c+=8,l=127):x>125&&(c+=2,l=126);let h=Buffer.allocUnsafe(a?x+c:c);return h[0]=i.fin?i.opcode|128:i.opcode,i.rsv1&&(h[0]|=64),h[1]=l,l===126?h.writeUInt16BE(x,2):l===127&&(h[2]=h[3]=0,h.writeUIntBE(x,4,6)),i.mask?(h[1]|=128,h[c-4]=o[0],h[c-3]=o[1],h[c-2]=o[2],h[c-1]=o[3],f?[h,e]:a?(zc(e,o,h,c,x),[h]):(zc(e,o,e,0,x),[h,e])):[h,e]}close(e,i,o,a){let c;if(e===void 0)c=gg;else{if(typeof e!="number"||!mg(e))throw new TypeError("First argument must be a valid error code number");if(i===void 0||!i.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let x=Buffer.byteLength(i);if(x>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+x),c.writeUInt16BE(e,0),typeof i=="string"?c.write(i,2):c.set(i,2)}}let f={[Ue]:c.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Ge?this.enqueue([this.dispatch,c,!1,f,a]):this.sendFrame(n.frame(c,f),a)}ping(e,i,o){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):on(e)?(a=e.size,c=!1):(e=Tt(e),a=e.length,c=Tt.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[Ue]:a,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};on(e)?this._state!==Ge?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==Ge?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}pong(e,i,o){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):on(e)?(a=e.size,c=!1):(e=Tt(e),a=e.length,c=Tt.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[Ue]:a,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};on(e)?this._state!==Ge?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==Ge?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}send(e,i,o){let a=this._extensions[Bc.extensionName],c=i.binary?2:1,f=i.compress,x,l;typeof e=="string"?(x=Buffer.byteLength(e),l=!1):on(e)?(x=e.size,l=!1):(e=Tt(e),x=e.length,l=Tt.readOnly),this._firstFragment?(this._firstFragment=!1,f&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=x>=a._threshold),this._compress=f):(f=!1,c=0),i.fin&&(this._firstFragment=!0);let h={[Ue]:x,fin:i.fin,generateMask:this._generateMask,mask:i.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:l,rsv1:f};on(e)?this._state!==Ge?this.enqueue([this.getBlobData,e,this._compress,h,o]):this.getBlobData(e,this._compress,h,o):this._state!==Ge?this.enqueue([this.dispatch,e,this._compress,h,o]):this.dispatch(e,this._compress,h,o)}getBlobData(e,i,o,a){this._bufferedBytes+=o[Ue],this._state=yg,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let x=new Error("The socket was closed while the blob was being read");process.nextTick(is,this,x,a);return}this._bufferedBytes-=o[Ue];let f=Tt(c);i?this.dispatch(f,i,o,a):(this._state=Ge,this.sendFrame(n.frame(f,o),a),this.dequeue())}).catch(c=>{process.nextTick(Eg,this,c,a)})}dispatch(e,i,o,a){if(!i){this.sendFrame(n.frame(e,o),a);return}let c=this._extensions[Bc.extensionName];this._bufferedBytes+=o[Ue],this._state=_g,c.compress(e,o.fin,(f,x)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");is(this,l,a);return}this._bufferedBytes-=o[Ue],this._state=Ge,o.readOnly=!1,this.sendFrame(n.frame(x,o),a),this.dequeue()})}dequeue(){for(;this._state===Ge&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Ue],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Ue],this._queue.push(e)}sendFrame(e,i){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],i),this._socket.uncork()):this._socket.write(e[0],i)}};Fc.exports=rs;function is(n,e,i){typeof i=="function"&&i(e);for(let o=0;o<n._queue.length;o++){let a=n._queue[o],c=a[a.length-1];typeof c=="function"&&c(e)}}function Eg(n,e,i){is(n,e,i),n.onerror(e)}});var Jc=ee((y2,$c)=>{"use strict";var{kForOnEventAttribute:kn,kListener:os}=ot(),Uc=Symbol("kCode"),Hc=Symbol("kData"),qc=Symbol("kError"),Gc=Symbol("kMessage"),jc=Symbol("kReason"),cn=Symbol("kTarget"),Wc=Symbol("kType"),Kc=Symbol("kWasClean"),ct=class{constructor(e){this[cn]=null,this[Wc]=e}get target(){return this[cn]}get type(){return this[Wc]}};Object.defineProperty(ct.prototype,"target",{enumerable:!0});Object.defineProperty(ct.prototype,"type",{enumerable:!0});var Pt=class extends ct{constructor(e,i={}){super(e),this[Uc]=i.code===void 0?0:i.code,this[jc]=i.reason===void 0?"":i.reason,this[Kc]=i.wasClean===void 0?!1:i.wasClean}get code(){return this[Uc]}get reason(){return this[jc]}get wasClean(){return this[Kc]}};Object.defineProperty(Pt.prototype,"code",{enumerable:!0});Object.defineProperty(Pt.prototype,"reason",{enumerable:!0});Object.defineProperty(Pt.prototype,"wasClean",{enumerable:!0});var dn=class extends ct{constructor(e,i={}){super(e),this[qc]=i.error===void 0?null:i.error,this[Gc]=i.message===void 0?"":i.message}get error(){return this[qc]}get message(){return this[Gc]}};Object.defineProperty(dn.prototype,"error",{enumerable:!0});Object.defineProperty(dn.prototype,"message",{enumerable:!0});var Rn=class extends ct{constructor(e,i={}){super(e),this[Hc]=i.data===void 0?null:i.data}get data(){return this[Hc]}};Object.defineProperty(Rn.prototype,"data",{enumerable:!0});var vg={addEventListener(n,e,i={}){for(let a of this.listeners(n))if(!i[kn]&&a[os]===e&&!a[kn])return;let o;if(n==="message")o=function(c,f){let x=new Rn("message",{data:f?c:c.toString()});x[cn]=this,Mr(e,this,x)};else if(n==="close")o=function(c,f){let x=new Pt("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});x[cn]=this,Mr(e,this,x)};else if(n==="error")o=function(c){let f=new dn("error",{error:c,message:c.message});f[cn]=this,Mr(e,this,f)};else if(n==="open")o=function(){let c=new ct("open");c[cn]=this,Mr(e,this,c)};else return;o[kn]=!!i[kn],o[os]=e,i.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let i of this.listeners(n))if(i[os]===e&&!i[kn]){this.removeListener(n,i);break}}};$c.exports={CloseEvent:Pt,ErrorEvent:dn,Event:ct,EventTarget:vg,MessageEvent:Rn};function Mr(n,e,i){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,i):n.call(e,i)}});var Br=ee((E2,Vc)=>{"use strict";var{tokenChars:Ln}=sn();function nt(n,e,i){n[e]===void 0?n[e]=[i]:n[e].push(i)}function bg(n){let e=Object.create(null),i=Object.create(null),o=!1,a=!1,c=!1,f,x,l=-1,h=-1,y=-1,v=0;for(;v<n.length;v++)if(h=n.charCodeAt(v),f===void 0)if(y===-1&&Ln[h]===1)l===-1&&(l=v);else if(v!==0&&(h===32||h===9))y===-1&&l!==-1&&(y=v);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${v}`);y===-1&&(y=v);let w=n.slice(l,y);h===44?(nt(e,w,i),i=Object.create(null)):f=w,l=y=-1}else throw new SyntaxError(`Unexpected character at index ${v}`);else if(x===void 0)if(y===-1&&Ln[h]===1)l===-1&&(l=v);else if(h===32||h===9)y===-1&&l!==-1&&(y=v);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${v}`);y===-1&&(y=v),nt(i,n.slice(l,y),!0),h===44&&(nt(e,f,i),i=Object.create(null),f=void 0),l=y=-1}else if(h===61&&l!==-1&&y===-1)x=n.slice(l,v),l=y=-1;else throw new SyntaxError(`Unexpected character at index ${v}`);else if(a){if(Ln[h]!==1)throw new SyntaxError(`Unexpected character at index ${v}`);l===-1?l=v:o||(o=!0),a=!1}else if(c)if(Ln[h]===1)l===-1&&(l=v);else if(h===34&&l!==-1)c=!1,y=v;else if(h===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${v}`);else if(h===34&&n.charCodeAt(v-1)===61)c=!0;else if(y===-1&&Ln[h]===1)l===-1&&(l=v);else if(l!==-1&&(h===32||h===9))y===-1&&(y=v);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${v}`);y===-1&&(y=v);let w=n.slice(l,y);o&&(w=w.replace(/\\/g,""),o=!1),nt(i,x,w),h===44&&(nt(e,f,i),i=Object.create(null),f=void 0),x=void 0,l=y=-1}else throw new SyntaxError(`Unexpected character at index ${v}`);if(l===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");y===-1&&(y=v);let k=n.slice(l,y);return f===void 0?nt(e,k,i):(x===void 0?nt(i,k,!0):o?nt(i,x,k.replace(/\\/g,"")):nt(i,x,k),nt(e,f,i)),e}function Sg(n){return Object.keys(n).map(e=>{let i=n[e];return Array.isArray(i)||(i=[i]),i.map(o=>[e].concat(Object.keys(o).map(a=>{let c=o[a];return Array.isArray(c)||(c=[c]),c.map(f=>f===!0?a:`${a}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Vc.exports={format:Sg,parse:bg}});var Hr=ee((S2,a0)=>{"use strict";var Ig=ie("events"),Cg=ie("https"),Ag=ie("http"),Xc=ie("net"),Tg=ie("tls"),{randomBytes:Dg,createHash:Pg}=ie("crypto"),{Duplex:v2,Readable:b2}=ie("stream"),{URL:as}=ie("url"),Et=rn(),kg=ns(),Rg=ss(),{isBlob:Lg}=sn(),{BINARY_TYPES:Zc,CLOSE_TIMEOUT:Ng,EMPTY_BUFFER:zr,GUID:Og,kForOnEventAttribute:cs,kListener:Mg,kStatusCode:Bg,kWebSocket:be,NOOP:Qc}=ot(),{EventTarget:{addEventListener:zg,removeEventListener:Fg}}=Jc(),{format:Ug,parse:Hg}=Br(),{toBuffer:qg}=Dn(),e0=Symbol("kAborted"),ds=[8,13],dt=["CONNECTING","OPEN","CLOSING","CLOSED"],Gg=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ae=class n extends Ig{constructor(e,i,o){super(),this._binaryType=Zc[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=zr,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,i===void 0?i=[]:Array.isArray(i)||(typeof i=="object"&&i!==null?(o=i,i=[]):i=[i]),t0(this,e,i,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Zc.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,i,o){let a=new kg({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),c=new Rg(e,this._extensions,o.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[be]=this,c[be]=this,e[be]=this,a.on("conclude",Kg),a.on("drain",$g),a.on("error",Jg),a.on("message",Vg),a.on("ping",Zg),a.on("pong",Yg),c.onerror=Xg,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),i.length>0&&e.unshift(i),e.on("close",i0),e.on("data",Ur),e.on("end",s0),e.on("error",o0),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[Et.extensionName]&&this._extensions[Et.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,i){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Me(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,i,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),r0(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=i=void 0):typeof i=="function"&&(o=i,i=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){fs(this,e,o);return}i===void 0&&(i=!this._isServer),this._sender.ping(e||zr,i,o)}pong(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=i=void 0):typeof i=="function"&&(o=i,i=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){fs(this,e,o);return}i===void 0&&(i=!this._isServer),this._sender.pong(e||zr,i,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof i=="function"&&(o=i,i={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){fs(this,e,o);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...i};this._extensions[Et.extensionName]||(a.compress=!1),this._sender.send(e||zr,a,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Me(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(ae,"CONNECTING",{enumerable:!0,value:dt.indexOf("CONNECTING")});Object.defineProperty(ae.prototype,"CONNECTING",{enumerable:!0,value:dt.indexOf("CONNECTING")});Object.defineProperty(ae,"OPEN",{enumerable:!0,value:dt.indexOf("OPEN")});Object.defineProperty(ae.prototype,"OPEN",{enumerable:!0,value:dt.indexOf("OPEN")});Object.defineProperty(ae,"CLOSING",{enumerable:!0,value:dt.indexOf("CLOSING")});Object.defineProperty(ae.prototype,"CLOSING",{enumerable:!0,value:dt.indexOf("CLOSING")});Object.defineProperty(ae,"CLOSED",{enumerable:!0,value:dt.indexOf("CLOSED")});Object.defineProperty(ae.prototype,"CLOSED",{enumerable:!0,value:dt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(ae.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(ae.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[cs])return e[Mg];return null},set(e){for(let i of this.listeners(n))if(i[cs]){this.removeListener(n,i);break}typeof e=="function"&&this.addEventListener(n,e,{[cs]:!0})}})});ae.prototype.addEventListener=zg;ae.prototype.removeEventListener=Fg;a0.exports=ae;function t0(n,e,i,o){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Ng,protocolVersion:ds[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=a.autoPong,n._closeTimeout=a.closeTimeout,!ds.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${ds.join(", ")})`);let c;if(e instanceof as)c=e;else try{c=new as(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),n._url=c.href;let f=c.protocol==="wss:",x=c.protocol==="ws+unix:",l;if(c.protocol!=="ws:"&&!f&&!x?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:x&&!c.pathname?l="The URL's pathname is empty":c.hash&&(l="The URL contains a fragment identifier"),l){let S=new SyntaxError(l);if(n._redirects===0)throw S;Fr(n,S);return}let h=f?443:80,y=Dg(16).toString("base64"),v=f?Cg.request:Ag.request,k=new Set,w;if(a.createConnection=a.createConnection||(f?Wg:jg),a.defaultPort=a.defaultPort||h,a.port=c.port||h,a.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":y,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(w=new Et({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=Ug({[Et.extensionName]:w.offer()})),i.length){for(let S of i){if(typeof S!="string"||!Gg.test(S)||k.has(S))throw new SyntaxError("An invalid or duplicated subprotocol was specified");k.add(S)}a.headers["Sec-WebSocket-Protocol"]=i.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(c.username||c.password)&&(a.auth=`${c.username}:${c.password}`),x){let S=a.path.split(":");a.socketPath=S[0],a.path=S[1]}let E;if(a.followRedirects){if(n._redirects===0){n._originalIpc=x,n._originalSecure=f,n._originalHostOrSocketPath=x?a.socketPath:c.host;let S=o&&o.headers;if(o={...o,headers:{}},S)for(let[I,D]of Object.entries(S))o.headers[I.toLowerCase()]=D}else if(n.listenerCount("redirect")===0){let S=x?n._originalIpc?a.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:c.host===n._originalHostOrSocketPath;(!S||n._originalSecure&&!f)&&(delete a.headers.authorization,delete a.headers.cookie,S||delete a.headers.host,a.auth=void 0)}a.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),E=n._req=v(a),n._redirects&&n.emit("redirect",n.url,E)}else E=n._req=v(a);a.timeout&&E.on("timeout",()=>{Me(n,E,"Opening handshake has timed out")}),E.on("error",S=>{E===null||E[e0]||(E=n._req=null,Fr(n,S))}),E.on("response",S=>{let I=S.headers.location,D=S.statusCode;if(I&&a.followRedirects&&D>=300&&D<400){if(++n._redirects>a.maxRedirects){Me(n,E,"Maximum redirects exceeded");return}E.abort();let R;try{R=new as(I,e)}catch{let C=new SyntaxError(`Invalid URL: ${I}`);Fr(n,C);return}t0(n,R,i,o)}else n.emit("unexpected-response",E,S)||Me(n,E,`Unexpected server response: ${S.statusCode}`)}),E.on("upgrade",(S,I,D)=>{if(n.emit("upgrade",S),n.readyState!==ae.CONNECTING)return;E=n._req=null;let R=S.headers.upgrade;if(R===void 0||R.toLowerCase()!=="websocket"){Me(n,I,"Invalid Upgrade header");return}let m=Pg("sha1").update(y+Og).digest("base64");if(S.headers["sec-websocket-accept"]!==m){Me(n,I,"Invalid Sec-WebSocket-Accept header");return}let C=S.headers["sec-websocket-protocol"],P;if(C!==void 0?k.size?k.has(C)||(P="Server sent an invalid subprotocol"):P="Server sent a subprotocol but none was requested":k.size&&(P="Server sent no subprotocol"),P){Me(n,I,P);return}C&&(n._protocol=C);let F=S.headers["sec-websocket-extensions"];if(F!==void 0){if(!w){Me(n,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=Hg(F)}catch{Me(n,I,"Invalid Sec-WebSocket-Extensions header");return}let K=Object.keys(z);if(K.length!==1||K[0]!==Et.extensionName){Me(n,I,"Server indicated an extension that was not requested");return}try{w.accept(z[Et.extensionName])}catch{Me(n,I,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[Et.extensionName]=w}n.setSocket(I,D,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(E,n):E.end()}function Fr(n,e){n._readyState=ae.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function jg(n){return n.path=n.socketPath,Xc.connect(n)}function Wg(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Xc.isIP(n.host)?"":n.host),Tg.connect(n)}function Me(n,e,i){n._readyState=ae.CLOSING;let o=new Error(i);Error.captureStackTrace(o,Me),e.setHeader?(e[e0]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Fr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function fs(n,e,i){if(e){let o=Lg(e)?e.size:qg(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(i){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${dt[n.readyState]})`);process.nextTick(i,o)}}function Kg(n,e){let i=this[be];i._closeFrameReceived=!0,i._closeMessage=e,i._closeCode=n,i._socket[be]!==void 0&&(i._socket.removeListener("data",Ur),process.nextTick(n0,i._socket),n===1005?i.close():i.close(n,e))}function $g(){let n=this[be];n.isPaused||n._socket.resume()}function Jg(n){let e=this[be];e._socket[be]!==void 0&&(e._socket.removeListener("data",Ur),process.nextTick(n0,e._socket),e.close(n[Bg])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Yc(){this[be].emitClose()}function Vg(n,e){this[be].emit("message",n,e)}function Zg(n){let e=this[be];e._autoPong&&e.pong(n,!this._isServer,Qc),e.emit("ping",n)}function Yg(n){this[be].emit("pong",n)}function n0(n){n.resume()}function Xg(n){let e=this[be];e.readyState!==ae.CLOSED&&(e.readyState===ae.OPEN&&(e._readyState=ae.CLOSING,r0(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function r0(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function i0(){let n=this[be];if(this.removeListener("close",i0),this.removeListener("data",Ur),this.removeListener("end",s0),n._readyState=ae.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[be]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Yc),n._receiver.on("finish",Yc))}function Ur(n){this[be]._receiver.write(n)||this.pause()}function s0(){let n=this[be];n._readyState=ae.CLOSING,n._receiver.end(),this.end()}function o0(){let n=this[be];this.removeListener("error",o0),this.on("error",Qc),n&&(n._readyState=ae.CLOSING,this.destroy())}});var u0=ee((C2,f0)=>{"use strict";var I2=Hr(),{Duplex:Qg}=ie("stream");function c0(n){n.emit("close")}function ep(){!this.destroyed&&this._writableState.finished&&this.destroy()}function d0(n){this.removeListener("error",d0),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function tp(n,e){let i=!0,o=new Qg({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(c,f){let x=!f&&o._readableState.objectMode?c.toString():c;o.push(x)||n.pause()}),n.once("error",function(c){o.destroyed||(i=!1,o.destroy(c))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(a,c){if(n.readyState===n.CLOSED){c(a),process.nextTick(c0,o);return}let f=!1;n.once("error",function(l){f=!0,c(l)}),n.once("close",function(){f||c(a),process.nextTick(c0,o)}),i&&n.terminate()},o._final=function(a){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(a)});return}n._socket!==null&&(n._socket._writableState.finished?(a(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){a()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(a,c,f){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(a,c,f)});return}n.send(a,f)},o.on("end",ep),o.on("error",d0),o}f0.exports=tp});var us=ee((A2,x0)=>{"use strict";var{tokenChars:np}=sn();function rp(n){let e=new Set,i=-1,o=-1,a=0;for(a;a<n.length;a++){let f=n.charCodeAt(a);if(o===-1&&np[f]===1)i===-1&&(i=a);else if(a!==0&&(f===32||f===9))o===-1&&i!==-1&&(o=a);else if(f===44){if(i===-1)throw new SyntaxError(`Unexpected character at index ${a}`);o===-1&&(o=a);let x=n.slice(i,o);if(e.has(x))throw new SyntaxError(`The "${x}" subprotocol is duplicated`);e.add(x),i=o=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(i===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let c=n.slice(i,a);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}x0.exports={parse:rp}});var _0=ee((D2,w0)=>{"use strict";var ip=ie("events"),qr=ie("http"),{Duplex:T2}=ie("stream"),{createHash:sp}=ie("crypto"),l0=Br(),kt=rn(),op=us(),ap=Hr(),{CLOSE_TIMEOUT:cp,GUID:dp,kWebSocket:fp}=ot(),up=/^[+/0-9A-Za-z]{22}==$/,g0=0,p0=1,m0=2,xs=class extends ip{constructor(e,i){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:cp,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ap,...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=qr.createServer((o,a)=>{let c=qr.STATUS_CODES[426];a.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),a.end(c)}),this._server.listen(e.port,e.host,e.backlog,i)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=xp(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,c,f)=>{this.handleUpgrade(a,c,f,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=g0}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===m0){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!==p0)if(this._state=p0,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 i=this._server;this._removeListeners(),this._removeListeners=this._server=null,i.close(()=>{Nn(this)})}}shouldHandle(e){if(this.options.path){let i=e.url.indexOf("?");if((i!==-1?e.url.slice(0,i):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,i,o,a){i.on("error",h0);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,x=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Rt(this,e,i,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){Rt(this,e,i,400,"Invalid Upgrade header");return}if(c===void 0||!up.test(c)){Rt(this,e,i,400,"Missing or invalid Sec-WebSocket-Key header");return}if(x!==13&&x!==8){Rt(this,e,i,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){On(i,400);return}let l=e.headers["sec-websocket-protocol"],h=new Set;if(l!==void 0)try{h=op.parse(l)}catch{Rt(this,e,i,400,"Invalid Sec-WebSocket-Protocol header");return}let y=e.headers["sec-websocket-extensions"],v={};if(this.options.perMessageDeflate&&y!==void 0){let k=new kt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let w=l0.parse(y);w[kt.extensionName]&&(k.accept(w[kt.extensionName]),v[kt.extensionName]=k)}catch{Rt(this,e,i,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let k={origin:e.headers[`${x===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(k,(w,E,S,I)=>{if(!w)return On(i,E||401,S,I);this.completeUpgrade(v,c,h,e,i,o,a)});return}if(!this.options.verifyClient(k))return On(i,401)}this.completeUpgrade(v,c,h,e,i,o,a)}completeUpgrade(e,i,o,a,c,f,x){if(!c.readable||!c.writable)return c.destroy();if(c[fp])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>g0)return On(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${sp("sha1").update(i+dp).digest("base64")}`],y=new this.options.WebSocket(null,void 0,this.options);if(o.size){let v=this.options.handleProtocols?this.options.handleProtocols(o,a):o.values().next().value;v&&(h.push(`Sec-WebSocket-Protocol: ${v}`),y._protocol=v)}if(e[kt.extensionName]){let v=e[kt.extensionName].params,k=l0.format({[kt.extensionName]:[v]});h.push(`Sec-WebSocket-Extensions: ${k}`),y._extensions=e}this.emit("headers",h,a),c.write(h.concat(`\r
|
|
12
12
|
`).join(`\r
|
|
13
|
-
`)),
|
|
13
|
+
`)),c.removeListener("error",h0),y.setSocket(c,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(y),y.on("close",()=>{this.clients.delete(y),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Nn,this)})),x(y,a)}};w0.exports=xs;function xp(n,e){for(let i of Object.keys(e))n.on(i,e[i]);return function(){for(let o of Object.keys(e))n.removeListener(o,e[o])}}function Nn(n){n._state=m0,n.emit("close")}function h0(){this.destroy()}function On(n,e,i,o){i=i||qr.STATUS_CODES[e],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(i),...o},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${qr.STATUS_CODES[e]}\r
|
|
14
14
|
`+Object.keys(o).map(a=>`${a}: ${o[a]}`).join(`\r
|
|
15
15
|
`)+`\r
|
|
16
16
|
\r
|
|
17
|
-
`+
|
|
17
|
+
`+i)}function Rt(n,e,i,o,a,c){if(n.listenerCount("wsClientError")){let f=new Error(a);Error.captureStackTrace(f,Rt),n.emit("wsClientError",f,i,e)}else On(i,o,a,c)}});import{spawn as Hp}from"node:child_process";import{existsSync as qp,openSync as Gp}from"node:fs";import{mkdir as jp}from"node:fs/promises";import{dirname as Wp}from"node:path";import{fileURLToPath as Kp}from"node:url";function hs(n=X()){return qp(n.libEntry)?n.libEntry:Kp(new URL("../index.ts",import.meta.url))}async function zn(n={}){let e=n.paths??X(),i=n.entryOverride??hs(e);await jp(Wp(e.logFile),{recursive:!0});let o=Gp(e.logFile,"a"),c=i.endsWith(".ts")?["--import","tsx/esm",i,"--daemon"]:[i,"--daemon"],f=Hp(process.execPath,c,{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 $p.info("daemon spawned",{pid:f.pid,entry:i}),{pid:f.pid,entry:i}}var $p,Jr=ze(()=>{"use strict";Y();ye();$p=H("spawn-daemon")});import{readFile as B0}from"node:fs/promises";async function Vr(n){try{let[e,i]=await Promise.all([B0(n.portFile,"utf8"),B0(n.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),a=i.trim();return!Number.isFinite(o)||o<=0||!a?null:{port:o,token:a}}catch(e){if(e.code==="ENOENT")return null;throw e}}function Jp(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function Vp(n){return n instanceof Error?n.message:String(n)}var je,Zr=ze(()=>{"use strict";ye();je=class{paths;constructor(e){this.paths=e??X()}async probe(e=1e3){let i=await Vr(this.paths);if(!i)return{kind:"not-running"};try{let o=await this.fetch(i,{method:"GET",path:"/status",timeoutMs:e});return o.status===200?{kind:"connected",...i}:{kind:"stale",reason:`unexpected status ${o.status}`}}catch(o){return{kind:"stale",reason:Vp(o)}}}async request(e){let i=await Vr(this.paths);if(!i)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(i,e)}async fetch(e,i){let o=i.body!==void 0,a={Authorization:`Bearer ${e.token}`};o&&(a["content-type"]="application/json");let c=new AbortController,f=setTimeout(()=>c.abort(),i.timeoutMs??5e3);try{let x=await fetch(`http://127.0.0.1:${e.port}${i.path}`,{method:i.method,headers:a,body:o?JSON.stringify(i.body):void 0,signal:c.signal}),l=await x.text();return{status:x.status,body:Jp(l)}}finally{clearTimeout(f)}}}});var W0={};pi(W0,{DEFAULT_PROBE_TIMEOUT_MS:()=>j0,DEFAULT_WAIT_PID_EXIT_MS:()=>G0,runUpgradeHelper:()=>lh});import{copyFile as ch,rename as ys,unlink as Es}from"node:fs/promises";async function lh(n){let e=n.paths??X(),i=n.spawnDaemon??zn,o=n.probeDaemon??hh,a=n.sleep??mh,c=n.waitPidExitMs??G0,f=n.probeTimeoutMs??j0,x=n.killPid??((S,I)=>process.kill(S,I)),{targetVersion:l,oldPid:h}=n;rt.info("upgrade-helper start",{targetVersion:l,oldPid:h}),await gh(h,c,a,x);let y=e.libEntry,v=`${y}.bak`,k=`${y}.next`;try{await ch(y,v)}catch(S){return rt.error("backup failed, abort",{err:String(S)}),1}try{await ys(k,y)}catch(S){return rt.error("rename .next \u2192 live failed, abort + rollback",{err:String(S)}),await ys(v,y).catch(()=>{}),1}let w,E=!1;try{await i({paths:e}),E=await ph(()=>o(e),f,a),E||(w="new daemon failed to come up within probeTimeout")}catch(S){w=`spawn new daemon failed: ${String(S)}`,rt.warn(w)}return E?(await H0(e,l,{ok:!0,setLibVersion:!0}),await Es(v).catch(()=>{}),await Es(k).catch(()=>{}),rt.info("upgrade succeeded",{targetVersion:l}),0):(rt.warn("upgrade failed, rolling back",{lastError:w}),await ys(v,y).catch(S=>rt.error("rollback rename failed",{err:String(S)})),await i({paths:e}).catch(S=>rt.error("spawn old daemon after rollback failed",{err:String(S)})),await H0(e,l,{ok:!1,lastError:w}),await Es(k).catch(()=>{}),1)}async function H0(n,e,i){let o=await _t(n.configFile)??{};i.setLibVersion&&(o.libVersion=e),o.upgradeAttempts=o.upgradeAttempts??{},o.upgradeAttempts[e]={count:(o.upgradeAttempts[e]?.count??0)+1,lastAt:Date.now(),ok:i.ok,...i.lastError?{lastError:i.lastError}:{}},await Xe(o,n.configFile)}async function gh(n,e,i,o){let a=Date.now()+e;for(;Date.now()<a;){if(!q0(n,o))return;await i(uh)}rt.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await i(dh),!!q0(n,o)){rt.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await i(fh)}}function q0(n,e){try{return e(n,0),!0}catch{return!1}}async function ph(n,e,i){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await i(xh)}return!1}async function hh(n){return(await new je(n).probe(1e3).catch(()=>null))?.kind==="connected"}function mh(n){return new Promise(e=>setTimeout(e,n))}var rt,G0,j0,dh,fh,uh,xh,K0=ze(()=>{"use strict";en();Jr();Zr();Y();ye();rt=H("upgrade-helper"),G0=3e4,j0=3e4,dh=5e3,fh=2e3,uh=200,xh=500});import{spawn as wh}from"node:child_process";import{mkdir as _h,unlink as yh,writeFile as Eh}from"node:fs/promises";import{dirname as vh,join as bh}from"node:path";function Qr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function $0(n,e){return new Promise((i,o)=>{let a=wh(n,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",o),a.on("close",f=>{f===0?i():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Xr,vs,bs,J0=ze(()=>{"use strict";Y();Xr=H("supervisor.launchd"),vs="ai.coze.bridge",bs={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>${
|
|
22
|
+
<string>${vs}</string>
|
|
23
23
|
<key>ProgramArguments</key>
|
|
24
24
|
<array>
|
|
25
|
-
<string>${
|
|
26
|
-
<string>${
|
|
25
|
+
<string>${Qr(n.nodeBin)}</string>
|
|
26
|
+
<string>${Qr(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 Wr=Object.defineProperty;var H0=Object.getOwnPropertyDe
|
|
|
33
33
|
<key>ThrottleInterval</key>
|
|
34
34
|
<integer>10</integer>
|
|
35
35
|
<key>StandardOutPath</key>
|
|
36
|
-
<string>${
|
|
36
|
+
<string>${Qr(n.logFile)}</string>
|
|
37
37
|
<key>StandardErrorPath</key>
|
|
38
|
-
<string>${
|
|
38
|
+
<string>${Qr(n.logFile)}</string>
|
|
39
39
|
</dict>
|
|
40
40
|
</plist>
|
|
41
|
-
`},configPath(n){return
|
|
41
|
+
`},configPath(n){return bh(n.homeDir,"Library","LaunchAgents",`${vs}.plist`)},async install(n){let e=this.configPath(n);await _h(vh(e),{recursive:!0}),await Eh(e,this.renderConfig(n),"utf8"),Xr.info("plist written",{plistPath:e}),await $0("launchctl",["load","-w",e]),Xr.info("launchd job loaded",{label:vs})},async uninstall(n){let e=this.configPath(n);await $0("launchctl",["unload","-w",e]).catch(i=>Xr.warn("launchctl unload failed (ignored)",{err:String(i)})),await yh(e).catch(i=>{if(i.code!=="ENOENT")throw i}),Xr.info("launchd job removed",{plistPath:e})}}});import{spawn as Sh}from"node:child_process";import{mkdir as Ih,unlink as Ch,writeFile as Ah}from"node:fs/promises";import{dirname as Th,join as Dh}from"node:path";function ni(n,e){return new Promise((i,o)=>{let a=Sh(n,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",o),a.on("close",f=>{f===0?i():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var ei,ti,Ss,V0=ze(()=>{"use strict";Y();ei=H("supervisor.systemd"),ti="coze-bridge.service",Ss={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
|
|
55
|
+
`},configPath(n){return Dh(n.homeDir,".config","systemd","user",ti)},async install(n){let e=this.configPath(n);await Ih(Th(e),{recursive:!0}),await Ah(e,this.renderConfig(n),"utf8"),ei.info("systemd unit written",{unitPath:e}),await ni("systemctl",["--user","daemon-reload"]),await ni("systemctl",["--user","enable","--now",ti]),ei.info("systemd unit enabled",{unitName:ti})},async uninstall(n){let e=this.configPath(n);await ni("systemctl",["--user","disable","--now",ti]).catch(i=>ei.warn("systemctl disable failed (ignored)",{err:String(i)})),await Ch(e).catch(i=>{if(i.code!=="ENOENT")throw i}),await ni("systemctl",["--user","daemon-reload"]).catch(()=>{}),ei.info("systemd unit removed",{unitPath:e})}}});import{spawn as Ph}from"node:child_process";import{join as kh}from"node:path";function Z0(n,e){return new Promise((i,o)=>{let a=Ph(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",o),a.on("close",f=>{f===0?i():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Is,ri,Cs,Y0=ze(()=>{"use strict";Y();Is=H("supervisor.taskscheduler"),ri="CozeBridge",Cs={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,19 +76,19 @@ WantedBy=default.target
|
|
|
76
76
|
</Exec>
|
|
77
77
|
</Actions>
|
|
78
78
|
</Task>
|
|
79
|
-
`},configPath(n){return
|
|
80
|
-
${n.stack??""}`:String(n);return
|
|
81
|
-
`)[0]?.trim()||void 0}catch{return}}async function
|
|
79
|
+
`},configPath(n){return kh(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Z0("schtasks",["/Create","/SC","ONLOGON","/TN",ri,"/TR",e,"/RU",n.userName,"/F"]),Is.info("task scheduler entry created",{task:ri})},async uninstall(n){await Z0("schtasks",["/Delete","/TN",ri,"/F"]).catch(e=>Is.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Is.info("task scheduler entry removed",{task:ri})}}});var X0={};pi(X0,{buildContext:()=>Oh,getSupervisor:()=>Nh,launchdSupervisor:()=>bs,systemdSupervisor:()=>Ss,taskSchedulerSupervisor:()=>Cs});import{homedir as Rh,userInfo as Lh}from"node:os";function Nh(n=process.platform){switch(n){case"darwin":return bs;case"linux":return Ss;case"win32":return Cs;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function Oh(){let n=X();return{nodeBin:process.execPath,entry:hs(n),logFile:n.logFile,homeDir:Rh(),userName:Lh().username}}var Q0=ze(()=>{"use strict";ye();Jr();J0();V0();Y0()});Y();Y();import{execFile as sf}from"node:child_process";import{promisify as of}from"node:util";var Xs=of(sf),gn=H("agents.acp-installer"),af={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},cf=5e4,df=5e3,ff=5*6e4,uf=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),xf=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,lf=/fetch failed|request timed out|socket hang up|network timeout/i;function gf(n){let e=n?.code;if(e&&uf.has(e))return!0;let i=n instanceof Error?`${n.message}
|
|
80
|
+
${n.stack??""}`:String(n);return xf.test(i)||lf.test(i)}function pf(n){if(n==null||typeof n!="object")return String(n);let e=n,i=[];e.message&&i.push(e.message),e.code!==void 0&&e.code!==null&&i.push(`code=${e.code}`),e.signal&&i.push(`signal=${e.signal}`);let o=e.stderr?.toString().trim();o&&i.push(`stderr=${o.slice(0,2e3)}`);let a=e.stdout?.toString().trim();return a&&i.push(`stdout=${a.slice(0,2e3)}`),i.length>0?i.join(" | "):String(n)}var jn=new Map,Gn=new Map,Wn=new Map;async function Ys(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:i}=await Xs(e,[n],{timeout:df});return i.split(`
|
|
81
|
+
`)[0]?.trim()||void 0}catch{return}}async function hf(n,e){gn.info("npm install -g start",{npmPackage:n}),await Xs("npm",["install","-g",`${n}@latest`],{timeout:cf,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),gn.info("npm install -g done",{npmPackage:n})}async function Ut(n,e){let i=af[n];if(!i)return;let o=jn.get(n);if(o)return o;let a=Gn.get(n);if(a&&Date.now()-a<ff)return;let c=Wn.get(n);if(c)return c;let f=(async()=>{let x=await Ys(i.binary);if(x)return jn.set(n,x),gn.info("acp wrapper found on PATH",{binary:i.binary,path:x}),x;try{await hf(i.npmPackage,e)}catch(h){let y=gf(h);gn.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:i.npmPackage,transient:y,err:pf(h)}),y||Gn.set(n,Date.now());return}let l=await Ys(i.binary);if(!l){gn.warn("acp wrapper installed but binary not found on PATH",{binary:i.binary}),Gn.set(n,Date.now());return}return jn.set(n,l),Gn.delete(n),l})().finally(()=>{Wn.delete(n)});return Wn.set(n,f),f}function Ht(n){return jn.get(n)}function Qs(n){return Wn.get(n)}var eo=H("acp-installer-warmup"),mf=["claude-code","codex"];async function to(n={}){let e=n.ensure??Ut,o=(await Promise.allSettled(mf.map(async a=>{let c=await e(a);eo.info("acp wrapper warmup ok",{framework:a,installed:!!c,path:c??""})}))).filter(a=>a.status==="rejected");o.length>0&&eo.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:o.length,reasons:o.map(a=>String(a.reason))})}gt();Y();import{readdir as Pf}from"node:fs/promises";import{mkdir as co,writeFile as fo}from"node:fs/promises";import{join as mi}from"node:path";var Af={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Gt(n,e,i,o){await co(n,{recursive:!0});let a=Af[e],c=mi(n,a),f=Tf(e,i,o);return await fo(c,f,"utf8"),c}async function uo(n){let e=mi(n,".claude");await co(e,{recursive:!0});let i=mi(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await fo(i,o,"utf8"),i}function Tf(n,e,i){let o=`# Coze Agent: ${e}
|
|
82
82
|
|
|
83
83
|
> framework: \`${n}\`
|
|
84
84
|
|
|
85
|
-
`,a=
|
|
86
|
-
`)?
|
|
85
|
+
`,a=i?.trim()?i.endsWith(`
|
|
86
|
+
`)?i:`${i}
|
|
87
87
|
`:`_No instructions provided._
|
|
88
88
|
`;return`${o}---
|
|
89
89
|
|
|
90
90
|
${a}
|
|
91
|
-
${
|
|
91
|
+
${Df}`}var Df=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
92
92
|
|
|
93
93
|
\u6BCF\u6761\u7528\u6237\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u4E91\u7AEF\u6CE8\u5165\u7684 \`<coze-context>\` \u5757, \u5F62\u5982:
|
|
94
94
|
|
|
@@ -112,29 +112,29 @@ ${Sx}`}var Sx=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
|
112
112
|
- \`sessionId\` \u5FC5\u987B\u7528\u4E91\u7AEF \`<coze-context>\` \u7ED9\u7684 ID, **\u4E0D\u8981**\u81EA\u5DF1\u7F16\u6216\u8005\u7528\u5176\u5B83\u6765\u6E90
|
|
113
113
|
|
|
114
114
|
\u26A0\uFE0F \u751F\u6210\u6587\u4EF6\u540E\u8BF7**\u7B49\u6587\u4EF6\u5B8C\u6574\u5199\u76D8**\u518D send (\u7528 \`&&\` \u4E32\u884C, \u4E0D\u8981 \`&\` \u540E\u53F0)\u3002
|
|
115
|
-
`;var
|
|
116
|
-
`)}}function Qr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Xs(n,e){if(!n.modelToken)return null;let s=n.model||Le,o=Zr(e),a=["text"];n.modelInfo?.capabilities?.image===!0&&a.push("image");let d={baseUrl:`${Yr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:a,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(d.headers=o),d}function Ys(n,e){if(!n.modelToken)return[];let s=Zr(e),o=[];for(let[a,d]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${a}="${d}"`);return o}var ce=D("agent-handlers"),Qs=5*1024*1024,Lx=1,Mx=6,Bx=new Set(["node_modules",".git",".coze","dist","build",".next"]),Bn=class{constructor(e){this.opts=e}opts;async listSkills(e){Je(e._meta,"_agent/listSkills");let s=kt(e._meta),o=await this.loadAgentCfg(s),a=o?.workspace??$e(s).workspace,d=o?.skills??[],u=[];for(let f of d){let p=Me(a,f.relPath,"SKILL.md");await Rx(p).then(y=>y.isFile()).catch(()=>!1)&&u.push(Gx(f))}return{skills:u}}async addSkills(e){Je(e._meta,"_agent/addSkills");let s=kt(e._meta),o=await this.requireAgentCfg(s),a=e.skills??[],d=[...o.skills??[]],u=new Map(d.map((p,h)=>[p.skillId,h])),f=[];for(let p of a){let h=await ti({agentId:s,workspace:o.workspace,framework:o.framework,skill:p});ni(d,u,h),f.push(p)}return await kn(s,d),this.reloadAgentSessions(s,"skills-added"),{installedSkills:f}}async removeSkills(e){Je(e._meta,"_agent/removeSkills");let s=kt(e._meta),o=await this.requireAgentCfg(s),a=new Set(e.skillIds??[]),d=o.skills??[],u=[];for(let f of d){if(!a.has(f.skillId)){u.push(f);continue}let p=Me(o.workspace,f.relPath);await Dx(p,{recursive:!0,force:!0}),ce.info("skill removed",{agentId:s,skillId:f.skillId,relPath:f.relPath})}return await kn(s,u),this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){this.reloadAgentSessions(e,s)}reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o)for(let[a,d]of o.sessions){if(!d.downstream)continue;let u=d.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(d)){d.reloadAfterTurn=!0,ce.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:a,acpId:u});continue}let p=d.downstream;d.downstream=void 0,ce.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:a,acpId:u}),p.stop(s).catch(h=>ce.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:a,err:String(h)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ce.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await he(s);if(!o)throw new b("AGENT_NOT_FOUND",`agent not found: ${s}`);if(o.cozeIdentity===e.cozeIdentity)return ce.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0};try{await Ct(o.workspace,o.framework,s,e.cozeIdentity)}catch(a){throw ce.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:s,framework:o.framework,workspace:o.workspace,err:String(a)}),new b("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${s}: ${String(a)}`,{cause:a})}return o.cozeIdentity=e.cozeIdentity,await Se(o),ce.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),this.reloadAgentSessions(s,"identity-changed"),{ok:!0}}async disconnectAgent(e){let s=e.agentId;if(!s)throw new b("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await he(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Se(o),ce.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}):(ce.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(Je(e._meta,"_agent/switchModel"),!e.agentId)throw new b("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Le,o=await he(e.agentId);if(!o)throw new b("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,e.modelInfo&&(o.modelInfo=e.modelInfo),await Se(o),ce.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return ce.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=s,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(u=>ce.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let d=[];for(let[u,f]of a.allSessionQueues())d.push(f.enqueue(async()=>{let p=a.sessions.get(u);p?.downstream&&(await p.downstream.stop(`switchModel: ${s}`).catch(()=>{}),p.downstream=void 0)}));return await Promise.all(d),ce.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:d.length}),{ok:!0}}async resetAgent(e){if(Je(e._meta,Ne.RESET),!e.agentId)throw new b("IPC_BAD_REQUEST",`${Ne.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Ne.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Je(e._meta,Ne.REPAIR),!e.agentId)throw new b("IPC_BAD_REQUEST",`${Ne.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new b("IPC_BAD_REQUEST",`${Ne.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){ce.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Ne.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){ce.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){ce.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(a)})}}async getFileTree(e){Je(e._meta,"_agent/getFileTree");let s=e._meta,o=kt(s),a=await this.resolveWorkspace(o),d=e.filePath??"",u=this.safeJoin(a,d),f=await ei(u).catch(()=>null);if(!f)throw new b("IPC_BAD_REQUEST",`path not found: ${d}`);if(f.isSymbolicLink())throw new b("IPC_BAD_REQUEST",`symlink not allowed: ${d}`);let p=Xx(e.depth);return f.isDirectory()?{tree:await Vx(a,u,d,p)}:{tree:[{name:Yx(d),path:so(d||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Je(e._meta,"_agent/getFileContent");let s=kt(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new b("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(o,e.filePath),d=await ei(a).catch(()=>null);if(!d||!d.isFile())throw new b("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(d.isSymbolicLink())throw new b("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(d.size>Qs)throw new b("IPC_BAD_REQUEST",`file too large: ${d.size} bytes (max ${Qs})`);let u=await to(a);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:d.size}:{content:u.toString("utf8"),encoding:"utf-8",size:d.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await he(e).catch(()=>null))?.workspace??$e(e).workspace}safeJoin(e,s){let o=Nx(e,s||"."),a=no(e,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${ro}`))throw new b("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return he(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new b("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function zx(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new b("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new b("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Fx(n){return n==="claude-code"?Me(".claude","skills"):Me(".agents","skills")}var Ux=3e4,qx=50*1024*1024,zn=3e4;async function ti(n){let{agentId:e,workspace:s,framework:o,skill:a}=n;if(!a.skillName)throw new b("IPC_BAD_REQUEST","skill missing skillName");let d=typeof a.content=="string"&&a.content.length>0,u=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!d&&!u)throw new b("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let f=zx(a.skillName),p=Fx(o),h=Me(p,f),y=Me(s,h);if(await Cx(y,{recursive:!0}),d){let A=Buffer.from(a.content,"utf8");Zt(A.length),await Zs(Me(y,"SKILL.md"),A,"utf8")}else{let A=await jx(a.downloadUrl);Kx(A)?await Wx(A,y):await Zs(Me(y,"SKILL.md"),A.toString("utf8"),"utf8")}let w={skillId:a.skillId,skillName:a.skillName,relPath:h,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return ce.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:h,source:d?"content":"downloadUrl"}),w}function ni(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 Gx(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 jx(n){if(!n)throw new b("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Zt(e);let s=Hx(n);return Zt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await to(e);return Zt(s.length),s}if(On(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Ux);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new b("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let a=await o.arrayBuffer();return Zt(a.byteLength),Buffer.from(a)}finally{clearTimeout(s)}}throw new b("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Zt(n){if(n>qx)throw new b("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Hx(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new b("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 Kx(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Wx(n,e){await $x(n),await new Promise((s,o)=>{let a=eo("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),d="";a.stderr?.on("data",f=>{d+=String(f)});let u=setTimeout(()=>{a.kill("SIGKILL"),o(new b("IPC_BAD_REQUEST",`tar extract timeout (${zn}ms)`))},zn);a.on("error",f=>{clearTimeout(u),o(new b("IPC_BAD_REQUEST",`tar spawn failed: ${f.message}`,{cause:f}))}),a.on("exit",f=>{clearTimeout(u),f===0?s():o(new b("IPC_BAD_REQUEST",`tar exit ${f}${d?`: ${d.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)})}async function $x(n){let e=await new Promise((s,o)=>{let a=eo("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),d="",u="";a.stdout?.on("data",p=>{d+=String(p)}),a.stderr?.on("data",p=>{u+=String(p)});let f=setTimeout(()=>{a.kill("SIGKILL"),o(new b("IPC_BAD_REQUEST",`tar list timeout (${zn}ms)`))},zn);a.on("error",p=>{clearTimeout(f),o(new b("IPC_BAD_REQUEST",`tar list spawn failed: ${p.message}`))}),a.on("exit",p=>{clearTimeout(f),p===0?s(d):o(new b("IPC_BAD_REQUEST",`tar list exit ${p}${u?`: ${u.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)});for(let s of e.split(`
|
|
117
|
-
`)){let o=
|
|
118
|
-
`}var
|
|
119
|
-
`);this.buffer=s.pop()??"";let o=[];for(let a of s){let d=a.replace(/\r$/,"").trim();if(d)try{o.push(JSON.parse(d))}catch(u){this.onError?.({line:d,error:u})}}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 lo={"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"},qh=Object.fromEntries(Object.entries(lo).map(([n,e])=>[e,n])),id={"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:[]},Ot=class{seq=0;next(e,s){this.seq+=1;let o=lo[e]??sd(e),a=id[o]??[],d=[o,String(this.seq)];if(a.length>0){let u=a.map(p=>fo(s?.[p]??"")),f=od(u).join(":");f&&d.push(f)}else s&&Object.values(s).some(u=>u)&&d.push(Object.values(s).filter(Boolean).map(u=>fo(String(u))).join(":"));return d.join("_")}reset(){this.seq=0}};function sd(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function fo(n){return n.replace(/[:_\s]+/g,"-")}function od(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function at(n,e){let s=process.env[n];if(!s)return e;let o=Number(s);return Number.isFinite(o)&&o>0?o:e}q();var xd=at("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),dd=200,ud=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function ri(n){return n.some(e=>ud.test(e))}var fd=at("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),ld=at("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),go=500;function gd(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=go?n:`${e.slice(0,go)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function po(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),cd("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var ze=class{constructor(e){this.opts=e;this.log=D(`downstream.${this.constructor.name}`),this.decoder=new qn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ot;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new b("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=ad(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=>{try{for(let a of this.decoder.push(o))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let a=o.trimEnd();this.stderrRing.push(a),this.stderrRing.length>dd&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),s.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),s.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),s.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),s.on("exit",(o,a)=>{this.stopped=!0,(o!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&ri(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),It(this.framework).catch(f=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(f)})})));try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(new b("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${a})`));for(let u of this.exitHandlers)u(o,a)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new b("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(d=>s.once("exit",()=>d()));po(s.pid,"SIGTERM");let a=setTimeout(()=>{s.killed||po(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,s=fd,o=ld){return this.call("session/prompt",e,s,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(tn("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Rt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(ot(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=xd,a=0){if(!this.child||this.stopped)return Promise.reject(new b("AGENT_PROTOCOL_ERROR","downstream not started"));let d=this.idAllocator.next(e),u=en(d,e,s),f=o>0&&Number.isFinite(o),p=a>0&&Number.isFinite(a);return new Promise((h,y)=>{let w={resolve:h,reject:y,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};f&&(w.timer=setTimeout(()=>{this.pending.delete(d),w.frameIdleTimer&&clearTimeout(w.frameIdleTimer),y(new b("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o));let A=p?()=>{w.frameIdleTimer&&clearTimeout(w.frameIdleTimer),w.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:d,method:e,inflight:this.inflightAgentRequests.size}),A?.();return}w.timer&&clearTimeout(w.timer),this.pending.delete(d),this.log.warn("frame-idle timeout, rejecting pending call",{id:d,method:e,frameIdleMs:a}),y(new b("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;w.armFrameIdle=A,this.pending.set(d,w),A?.();try{this.writeFrame(u)}catch(I){w.timer&&clearTimeout(w.timer),w.frameIdleTimer&&clearTimeout(w.frameIdleTimer),this.pending.delete(d),y(I)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new b("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(uo(e),s=>{s&&this.log.warn("stdin write callback err",{err:String(s)})})}dispatch(e){if(Un(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),s.frameIdleTimer&&clearTimeout(s.frameIdleTimer),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(co(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:s.method}),s.reject(new b("AGENT_PROTOCOL_ERROR",`${s.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:gd(e.result)}),s.resolve(e.result));return}if(ao(e)){if(e.method==="session/update"){for(let s of this.pending.values())s.armFrameIdle?.();for(let s of this.updateHandlers)try{Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(oo(e)){let s=e;try{this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed (async)",{method:s.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:s.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(ot(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);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(ot(e.id,rn(o)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.frameIdleTimer&&clearTimeout(s.frameIdleTimer),s.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var pd="@agentclientprotocol/claude-agent-acp@latest";function hd(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 Gn=class extends ze{framework="claude-code";constructor(e){let s=Tt("claude-code"),[o,a]=s?[s,[]]:["npx",["-y",pd]],d=e.command??o,u=e.args??a,f={command:d,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(f)}sanitizeEnv(e){return hd(e)}};import{mkdtempSync as md,rmSync as wd}from"node:fs";import{tmpdir as _d}from"node:os";import{join as yd}from"node:path";var bd="@zed-industries/codex-acp@latest",jn=class extends ze{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=Tt("codex"),[o,a]=s?[s,[]]:["npx",["-y",bd]],d=e.command??o,u=e.args??a,f=e.extraArgs?[...u,...e.extraArgs]:u,p=e.isolateCodexHome?md(yd(_d(),"coze-bridge-codex-home-")):void 0,h=p?{...e.env??{},CODEX_HOME:p}:e.env,y={command:d,args:f,cwd:e.cwd,...h?{env:h}:{}};super(y),this.authMethodId=e.authMethodId,this.codexHomeDir=p}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{wd(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var vd=3e4,Nt=class extends ze{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 a={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),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}`}]},vd))}get acpSessionName(){return this.sessionName}};q();oe();function ii(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Lt=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}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let s=await e.task();e.resolve(s)}catch(s){e.reject(s)}}}finally{this.running=!1}}}};var Hn=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let s=this.sessionQueues.get(e);return(!s||s.isDisposed)&&(s=new Lt,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let s=this.sessionQueues.get(e);return!!s&&!s.isDisposed}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)sn(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function sn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as Sd}from"node:child_process";import{homedir as Ed}from"node:os";import{join as Ad}from"node:path";Pn();q();async function wo(){let n=Ad(Ed(),".openclaw/openclaw.json");return(await Pt(n))?.gateway?.auth?.token??""}var ho=D("openclaw.config"),Id=[0,5e3,5e3],mo="models.providers.",Kn="agents.defaults.models",Wn=class{command;env;retryDelaysMs;queue=new Lt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Id}async withRetry(e,s){let o;for(let a=0;a<this.retryDelaysMs.length;a++){let d=this.retryDelaysMs[a]??0;d>0&&await new Promise(u=>setTimeout(u,d));try{return await s()}catch(u){o=u,ho.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(u)})}}throw new b("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let a=Sd(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),d="";a.stderr?.on("data",u=>{d+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?s():o(new Error(`exit ${u}: ${d.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(o){let a=String(o);if(s.some(d=>a.includes(d)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){ho.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",`${mo}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${mo}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Kn}[${e}]`,()=>this.runCli(["config","set",Kn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Kn}[${e}]`,`${Kn}.${e}`)}ensureAgent(e,s,o){let a=["agents","add",e,"--workspace",s,"--non-interactive"];return o&&a.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var me=D("agent-manager"),Pd=(n,e,s,o,a,d,u,f)=>{switch(n){case"claude-code":{let p={...a?{...Ws(a),...Vs(a,u)}:{},...f??{},IS_SANDBOX:"1"};return new Gn({cwd:s,env:p})}case"codex":{let h=[...a?[...$s(a),...Ys(a,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],y={...a?Js(a):{},...f??{}},w=!!a;return new jn({cwd:s,...h.length>0?{extraArgs:h}:{},...Object.keys(y).length>0?{env:y}:{},...w?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Nt({command:e,cwd:s,agentId:o,...d?{sessionName:ii(d)}:{}})}};function oi(n){return n==="claude-code"||n==="codex"}var Cd={path:"",version:"cloud-deployed"},kd={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Dd=6e4,Rd=at("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),$n=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Pd,this.createTimeoutMs=e.createTimeoutMs??Dd,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??Rd}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new b("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Wn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new b("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new b("IPC_BAD_REQUEST","framework required");let s=Xt(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new b("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")me.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(E=>me.warn("dispose stale agent failed (ignored)",{err:String(E)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){me.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let E=await he(e.agentId,this.paths).catch(()=>null);E&&(E.patToken=e.patToken,await Se(E,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){me.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let E=await he(e.agentId,this.paths).catch(()=>null);E&&(E.modelInfo=e.modelInfo,await Se(E,this.paths))}return me.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 b("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let d=$e(e.agentId,this.paths),u=Xt(e._meta),f=e.framework==="openclaw"&&u==="local",p=f?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,h=e.workspace??p??d.workspace,y=new AbortController,w=setTimeout(()=>y.abort(new b("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,I=!1;try{s&&oi(e.framework)&&await It(e.framework,y.signal);let E=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new b("AGENT_TIMEOUT","_agent/create aborted")};await si(d.root,{recursive:!0}),await si(h,{recursive:!0}),await si(d.logs,{recursive:!0}),E(),f||await Ct(h,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Ns(h),E();let k=await he(e.agentId,this.paths).catch(()=>null),L=Hs({model:e.model??k?.model}),$=Ls(e._meta)??k?.accountId,H=e.patToken??k?.patToken,ae=u==="cloud"?e.modelInfo??k?.modelInfo:void 0;if(A=new Hn({agentId:e.agentId,framework:e.framework,workspace:h,model:L.model??Le,deployType:u,...$?{accountId:$}:{},...H?{patToken:H}:{},...ae?{modelInfo:ae}:{}}),A.status="ok",k?.sessions){for(let[ke,de]of Object.entries(k.sessions))A.sessions.set(ke,{acpSessionId:de.acpSessionId,modelToken:de.modelToken,tokenGeneratedAt:de.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let _e=Object.keys(k.sessions).length;_e>0&&me.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:_e})}this.registry.register(A),I=!0;let W={agentId:e.agentId,framework:e.framework,workspace:h,cozeIdentity:e.cozeIdentity,createdAt:k?.createdAt??Date.now(),sessions:k?.sessions??{},model:L.model};u==="cloud"&&(W.deployType="cloud"),$&&(W.accountId=$),H&&(W.patToken=H),ae&&(W.modelInfo=ae),k?.skills&&(W.skills=k.skills),k?.agentName&&(W.agentName=k.agentName),k?.description&&(W.description=k.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,h):me.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let ge=e.initialSkills??[];if(ge.length>0){let _e=[...W.skills??[]],ke=new Map(_e.map((T,O)=>[T.skillId,O])),de=await Promise.allSettled(ge.map(T=>ti({agentId:e.agentId,workspace:h,framework:e.framework,skill:T}))),we=0;for(let[T,O]of de.entries()){let F=ge[T];F&&(O.status==="fulfilled"?(ni(_e,ke,O.value),we++):me.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:F.skillId,skillName:F.skillName,err:String(O.reason)}))}we>0&&(W.skills=_e,me.info("initialSkills installed",{agentId:e.agentId,installed:we,requested:ge.length}))}return await Se(W,this.paths),me.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:h,framework:e.framework}}catch(E){throw me.error("agent create failed, rolling back",{agentId:e.agentId,err:String(E)}),I&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Td(d.root,{recursive:!0,force:!0}).catch(k=>me.warn("rm agent dir failed (ignored)",{err:String(k)})),E instanceof b?E:new b("AGENT_SPAWN_FAILED",String(E),{cause:E})}finally{clearTimeout(w)}}async spawnSessionDownstream(e,s,o,a){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&oi(e.framework))u=Cd;else throw new b("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(oi(e.framework)&&!Tt(e.framework)){let h=Ss(e.framework);h&&(me.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([h.catch(()=>{}),new Promise(y=>setTimeout(y,this.spawnAwaitInstallMs))]))}let f=e.deployType==="cloud"?{model:e.model,modelToken:s,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:o,cozeEnv:a,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,f,o,a,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(kd),p}catch(h){let y=p instanceof ze?p.getStderrTail():[];y.length>0&&me.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:h instanceof b?h.code:"unknown",recentStderr:y});let w=ri(y);await p.stop("spawnSessionDownstream failed").catch(()=>{});let A=w?new b("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:h}):h;throw h instanceof b?new b(h.code,h.message,{retriable:h.retriable,cause:A}):new b("AGENT_SPAWN_FAILED",h instanceof Error?h.message:String(h),{cause:A})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:a,cozeEnv:d,command:u}=e,f=ii(a);if(s.deployType==="local"){let w=this.config.frameworksCache?.openclaw?.defaultAgent;if(!w?.id||!w.workspace)throw new b("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 Nt({command:u,cwd:w.workspace,agentId:w.id,sessionName:f})}let p=await wo(),h=o?Xs(o,d):null,y;if(h){let w=Qr(a),I=h.models[0]?.id??Le,E=`${w}/${I}`;if(!this.ensuredProviders.has(E)){let k=this.getOpenclawConfig();await k.ensureProvider(w,h),await k.addModelToAllowlist(E),this.ensuredProviders.add(E)}y=E}return new Nt({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:f,...p?{gatewayToken:p}:{},...y?{slashModelOnStart:y}:{}})}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 a=Qr(o),d=`${a}/${e.model}`,u=!0;try{await s.removeProvider(a)}catch(f){u=!1,me.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(f)})}try{await s.removeModelFromAllowlist(d)}catch(f){u=!1,me.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:d,err:String(f)})}u&&this.ensuredProviders.delete(d)}}};import{randomUUID as So}from"node:crypto";import{promises as jd}from"node:fs";import{basename as Eo}from"node:path";import{promises as Nd}from"node:fs";import{basename as Ld}from"node:path";q();var _o=D("file-upload"),Md="/api/coze_claw/file/agent_upload",Bd=6e4;async function yo(n,e={}){let o=`${Nn(Mn(e.handshakeBase))}${Md}`,a=e.timeoutMs??Bd,d=await Nd.readFile(n.path),u=new FormData;u.append("agent_id",n.agentId),u.append("session_id",n.sessionId),u.append("file_name",n.name),u.append("file_content",new Blob([d],{type:n.mimeType}),n.name);let f={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Dt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},p=new AbortController,h=setTimeout(()=>p.abort(),a);_o.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let y=await fetch(o,{method:"POST",headers:f,body:u,signal:p.signal}),w=y.headers.get("x-tt-logid")??"";if(!y.ok){let E=await y.text().catch(()=>"");throw new b("UPLOAD_FAILED",`upload HTTP ${y.status} logid=${w}: ${E.slice(0,200)}`)}let A=await y.json();if(A.code!==void 0&&A.code!==0)throw new b("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${w}`);let I=A.data?.file?.file_url;if(!I)throw new b("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${w}: ${JSON.stringify(A).slice(0,200)}`);return _o.info("file upload ok",{uri:I,logid:w}),{uri:I}}catch(y){throw y instanceof b?y:y.name==="AbortError"?new b("UPLOAD_FAILED",`upload timeout (${a}ms) for ${Ld(n.path)}`):new b("UPLOAD_FAILED",String(y),{cause:y})}finally{clearTimeout(h)}}q();import{promises as zd}from"node:fs";import{extname as Fd}from"node:path";var Ud=[{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 qd(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 Gd={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function bo(n){let e=await zd.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),qd(s))return"image/webp";for(let o of Ud)if(o.prefix.every((a,d)=>s[d]===a))return o.mime}finally{await e.close()}return Gd[Fd(n).toLowerCase()]??"application/octet-stream"}oe();var ai=D("agent-send"),vo=50*1024*1024,Hd=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Ao(n,e,s){let o=n.get(e);if(!o)throw new b("AGENT_NOT_FOUND",`agent=${e}`);if(n.disconnectedAgents.has(e))throw new b("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=o.sessions.get(s);if(!a)throw new b("AGENT_NOT_FOUND",`session=${s} not active in agent=${e}`);return{session:o,runtime:a}}async function Io(n,e,s,o,a,d){let f;for(let p=0;p<=2;p++)try{await n.core.sendAgentFileUpdate(e,s,o,a);return}catch(h){f=h,p<2&&(ai.warn("sendAgentFileUpdate failed, retrying",{attempt:p+1,err:String(h)}),await new Promise(y=>setTimeout(y,5e3)))}throw new b("UPSTREAM_NOT_READY",`${d} after 3 attempts: ${String(f)}`,{cause:f})}async function To(n,e){let{session:s,runtime:o}=Ao(e.core,n.agentId,n.sessionId);if(!await ks(n.path,s.workspace))throw new b("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let a=await jd.stat(n.path).catch(()=>null);if(!a||!a.isFile())throw new b("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(a.size>vo)throw new b("FILE_TOO_LARGE",`${a.size} bytes > limit ${vo}`);let d=await bo(n.path);if(!Hd.has(d))throw new b("UNSUPPORTED_MIME",`mime=${d} not in whitelist`);if(n.kind==="image"&&!d.startsWith("image/"))throw new b("UNSUPPORTED_MIME",`kind=image but mime=${d}`);if(!e.core.upstream.isConnected())throw new b("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??Eo(n.path),f=await yo({patToken:s.patToken??e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:d,name:u,sizeBytes:a.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),p={sessionUpdate:"agent_file",messageId:So(),content:{type:n.kind==="image"?"image":"resource",uri:f.uri,mimeType:d,name:u,sizeBytes:a.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await Io(e,s,o,n.sessionId,p,"agent file uploaded to cloud but sendAgentFileUpdate failed"),ai.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:a.size,mime:d,uri:f.uri}),{ok:!0,uri:f.uri,bytes:a.size,mimeType:d,...f.fileId!==void 0?{fileId:f.fileId}:{}}}async function Po(n,e){let{session:s,runtime:o}=Ao(e.core,n.agentId,n.sessionId);if(!n.mimeType)throw new b("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new b("UPSTREAM_NOT_READY","cloud WS not connected");let a=n.name??Eo(n.path),d={sessionUpdate:"group_file",messageId:So(),content:{uri:n.path,name:a,mimeType:n.mimeType,...n.caption!==void 0?{caption:n.caption}:{}}};return await Io(e,s,o,n.sessionId,d,"agent group file sendAgentFileUpdate failed"),ai.info("agent group file sent",{agentId:n.agentId,sessionId:n.sessionId,uri:n.path,name:a,mime:n.mimeType}),{ok:!0,uri:n.path,bytes:0,mimeType:n.mimeType}}import{execFile as Kd}from"node:child_process";import{promisify as Wd}from"node:util";function Jn(n,e){let s=n.split(".").map(Number),o=e.split(".").map(Number),a=Math.max(s.length,o.length);for(let d=0;d<a;d++){let u=s[d]??0,f=o[d]??0;if(u<f)return!0;if(u>f)return!1}return!1}q();var $d=Wd(Kd),Fe=D("coze-cli-installer"),Co="@coze/cli@latest",Jd="coze",ko="0.1.7",Vd=5e3,Xd=5e3,Yd=9e4,Do=1e4,on=null,Vn=!1;async function ci(n,e={}){if(Vn)return;if(on)return on;let s=e.exec??$d;return on=(async()=>{try{let o=await Zd(Jd,s),a=!1;if(o){let u=await Qd(s);if(u===void 0)Fe.warn("coze-cli found but version unparseable, fall through to full install",{path:o});else if(Jn(u,ko))Fe.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:o,version:u,min:ko}),a=!0;else{Fe.info("coze-cli already on PATH with sufficient version, skip",{path:o,version:u}),Vn=!0;return}}let d=a?"upgrade-only":"full";Fe.info("coze-cli install start",{package:Co,mode:d});try{await s("npm",["i","-g","--prefer-online",Co],{timeout:Yd,maxBuffer:10*1024*1024}),Fe.info("coze-cli install ok")}catch(u){Fe.warn("coze-cli install failed (skip subsequent steps)",{err:String(u)});return}if(a){Vn=!0;return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:Do}),Fe.info("coze config set xTTEnv ok",{env:n.env})}catch(u){Fe.warn("coze config set failed (continue to auth login)",{err:String(u)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:Do}),Fe.info("coze auth login ok")}catch(u){Fe.warn("coze auth login failed",{err:String(u)});return}Vn=!0}finally{on=null}})(),on}async function Zd(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Vd});return o.split(`
|
|
120
|
-
`)[0]?.trim()||void 0}catch{return}}async function
|
|
121
|
-
`),
|
|
122
|
-
`)}else
|
|
123
|
-
`)}async function qo(n,e){if(typeof n!="string"||n.length===0)throw new b("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([Bo(Mo(e)),Bo(Mo(n))]),a=hu(s,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${mu}`))throw new b("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Bo(n){let e=[],s=n;for(;s!==xi(s);)try{let o=await uu(s);return e.length?pu(o,...e.reverse()):o}catch{e.push(gu(s)),s=xi(s)}return n}q();var Go=D("prompt-multimodal"),jo=10*1024*1024,yu=15e3,bu=6;async function Ho(n){let e=new Array(n.length),s=0;async function o(){for(;s<n.length;){let d=s++,u=n[d];u!==void 0&&(e[d]=await vu(u))}}let a=Array.from({length:Math.min(bu,n.length)},()=>o());return await Promise.all(a),e}function Ko(n){return n.some(e=>e.type==="image")}async function vu(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!On(e.uri))return n;try{let{buf:s,contentType:o}=await Eu(e.uri),a=e.mimeType||Su(o)||"application/octet-stream";return Go.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:a}),{type:"image",data:s.toString("base64"),mimeType:a}}catch(s){return Go.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Su(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function Eu(n){let e=new AbortController,s=setTimeout(()=>e.abort(),yu);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let a=await o.arrayBuffer();if(a.byteLength>jo)throw new Error(`image too large: ${a.byteLength} bytes (max ${jo})`);return{buf:Buffer.from(a),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}it();Bt();q();var U=D("core"),Iu=3e4,Tu=/^(boe|ppe)_[A-Za-z0-9_-]+$/,Pu=3e4,Cu=new Set(["_agent/create","session/new","session/load","session/prompt"]),Xn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new Ot;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=Lo(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),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 a=o.downstream;a&&(a.onUpdate(d=>{o.loadingSession||this.forwardUpdate(e,d)}),a.onAgentRequest(d=>{this.handleAgentRequest(e,a,d)}),a.onExit((d,u)=>{U.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:d,signal:u}),sn(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(a,"downstream exited")}))}hasPendingPermissionFor(e){for(let s of this.pendingUpstream.values())if(s.downstream===e)return!0;return!1}rejectPendingForDownstream(e,s){let o=[];for(let[a,d]of this.pendingUpstream)d.downstream===e&&o.push(a);if(o.length!==0){U.info("reject pendingUpstream entries (downstream gone)",{reason:s,count:o.length});for(let a of o){let d=this.pendingUpstream.get(a);if(d){this.pendingUpstream.delete(a),this.upstream.send(ot(a,{code:j.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>U.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{d.downstream.respondAgentRequestError(d.agentRequestId,{code:j.INTERNAL_ERROR,message:`bridge: ${s}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,s=this.pendingBridge.size;if(!(e===0&&s===0)){U.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:s});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:j.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new b("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Un(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&&Tu.test(o)?this.currentCozeEnv=o:o&&U.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&Cu.has(e.method)){let a=this.upgradeGate.pendingTarget()??"";throw new b("BRIDGE_UPGRADING",`bridge upgrading to ${a}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){s!==null?await this.sendError(s,j.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):U.warn("drop notification: extension not registered",{method:e.method});return}let d=await a(e,this);s!==null&&await this.upstream.send(Rt(s,d));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Rt(s,a));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Rt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,j.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):U.warn("drop unknown notification",{method:e.method})}catch(a){U.error("handleFrame failed",{method:e.method,err:String(a)}),s!==null&&await this.upstream.send(ot(s,rn(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new b("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new b("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(o);if(!a)throw this.disconnectedAgents.has(o)?new b("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new b("AGENT_NOT_FOUND",`agent not found: ${o}`);let d=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!d)return this.dispatchSessionCall(a,e.method,s);let u=Date.now(),f=!1,p=e.method==="session/prompt";p&&this.upgradeGate?.incActive();try{let h=await a.getSessionQueue(d).enqueue(()=>this.dispatchSessionCall(a,e.method,s));return f=!0,h}finally{p&&this.upgradeGate?.decActive(),U.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-u,ok:f})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:a}=Bs(o);switch(s){case"session/new":{let d=ku();return U.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:d}),{sessionId:d}}case"session/load":{let d=a;return U.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:d.sessionId}),{}}case"session/prompt":{let d=a,u=d.sessionId;if(!u)throw new b("IPC_BAD_REQUEST","session/prompt: missing sessionId");let f=await this.ensureRuntime(e,u);if(f.replySeq=0,await this.ensureDownstream(e,u,f),!f.downstream||!f.acpSessionId)throw new b("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let p=o._meta?.cozeTriggerMsgId;p?e.activeTriggers.set(f.acpSessionId,p):e.activeTriggers.delete(f.acpSessionId);let h=Ms(o._meta);if(h?e.activeGroupIds.set(f.acpSessionId,h):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Ko(d.prompt))throw new b("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let y=await Ho(d.prompt);try{let w=await f.downstream.sessionPrompt({...d,sessionId:f.acpSessionId,prompt:y});return f.lastActiveAt=Date.now(),w}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.reloadAfterTurn){f.reloadAfterTurn=!1;let w=f.downstream;w&&(f.downstream=void 0,U.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:f.acpSessionId}),w.stop("reload-after-turn").catch(A=>U.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(A)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,u,f)}}case"session/cancel":{let u=a.sessionId;if(!u)throw new b("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(u);if(e.hasSessionQueue(u)){let p=e.getSessionQueue(u);p.size>0&&(U.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:p.size}),p.dispose(new b("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new b("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let d={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,d),await this.persistSessionMapping(e),d}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(Ne.GEN_MODEL_TOKEN,o,Pu);if(!a?.modelToken)throw new b("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return a.modelToken}catch(a){throw a instanceof b&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new b("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,s,o){if(sn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new b("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,d=3e4,u=o.spawnFailCount??0,f=o.spawnFailedAt??0;if(u>=a&&Date.now()-f<d)throw new b("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${s} spawn failed ${u} times in a row; please check framework binary / network and retry after ${Math.ceil((d-(Date.now()-f))/1e3)}s`);let p;try{p=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(h){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=a&&o.acpSessionId&&(U.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),h}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=p,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await p.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),U.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(h){U.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(h)}),o.acpSessionId=void 0;let y=await p.sessionNew({cwd:e.workspace});o.acpSessionId=y.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let h=await p.sessionNew({cwd:e.workspace});o.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}p.afterSessionEstablished&&o.acpSessionId&&await p.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(sn(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 a=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),a&&a.stop("idle timeout").catch(d=>U.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(d)}))},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 a of this.pendingUpstream.values())if(a.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,a){let d={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(d.cozeTriggerMsgId=u);let f=e.activeGroupIds.get(s.acpSessionId);f&&(d.cozeGroupId=f)}await this.upstream.send(tn("session/update",{sessionId:o,update:a,_meta:d}))}forwardUpdate(e,s){let o=s.sessionId,a=this.reverseSessionId(e,o);if(!a){U.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let d=e.sessions.get(a);if(!d){U.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(Ru(s)){U.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++d.replySeq},f=e.activeTriggers.get(o);f&&(u.cozeTriggerMsgId=f);let p=e.activeGroupIds.get(o);p&&(u.cozeGroupId=p),this.upstream.send(tn("session/update",{...s,sessionId:a,_meta:u})).catch(h=>U.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}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:j.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let a=e.workspace;if(o.method==="fs/write_text_file"){let d=o.params??{},u=await Fo(d,a);s.respondAgentRequest(o.id,u)}else{let d=o.params??{},u=await Uo(d,a);s.respondAgentRequest(o.id,u)}}catch(a){U.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(a)}),s.respondAgentRequestError(o.id,rn(a))}}forwardPermissionRequest(e,s,o){let a=this.upstreamIds.next("session/request_permission"),d=o.params??{},f=d.sessionId,p=f?e.activeTriggers.get(f):void 0,h={cozeAgentId:e.agentId};p&&(h.cozeTriggerMsgId=p);let y=f?e.activeGroupIds.get(f):void 0;y&&(h.cozeGroupId=y);let w=f?this.reverseSessionId(e,f):void 0,A={...d,...w?{sessionId:w}:{},_meta:h};this.pendingUpstream.set(a,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),U.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:f,cloudSessionId:w,toolCallId:d.toolCall?.toolCallId,options:d.options?.map(I=>({optionId:I.optionId,kind:I.kind,name:I.name}))}),this.upstream.send(en(a,"session/request_permission",A)).catch(I=>{this.pendingUpstream.delete(a),U.error("forward permission request failed",{agentId:e.agentId,err:String(I)}),s.respondAgentRequestError(o.id,{code:j.INTERNAL_ERROR,message:`upstream send failed: ${String(I)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(s){this.pendingUpstream.delete(s.key);let a=s.value;e.error?(U.info("upstream \u2192 permission response (error)",{agentId:a.agentId,upstreamId:e.id,method:a.method,error:e.error}),a.downstream.respondAgentRequestError(a.agentRequestId,e.error)):(a.method==="session/request_permission"&&Du(e.result,a),U.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.agentRequestId,e.result));return}let o=this.lookupPending(this.pendingBridge,e.id,"bridge");if(o){this.pendingBridge.delete(o.key),clearTimeout(o.value.timer),e.error?o.value.reject(new Fn(e.error)):o.value.resolve(e.result);return}U.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,s,o){let a=e.get(s);if(a)return{value:a,key:s};if(typeof s=="number"){let d=String(s),u=e.get(d);if(u)return U.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:d}),{value:u,key:d}}}sendRequest(e,s,o=Iu){let a=this.upstreamIds.next(e);return new Promise((d,u)=>{let f=setTimeout(()=>{this.pendingBridge.delete(a),u(new b("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(a,{method:e,resolve:d,reject:u,timer:f}),this.upstream.send(en(a,e,s)).catch(p=>{let h=this.pendingBridge.get(a);h&&(clearTimeout(h.timer),this.pendingBridge.delete(a)),u(p)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,a]of e.sessions){let d={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(d.acpSessionId=a.acpSessionId),s.set(o,d)}await Jr(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,a]of e.sessions.entries())if(a.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(ot(e,{code:s,message:o,data:{bridgeVersion:st}}))}};function ku(){return Au(16).toString("hex")}function Du(n,e){if(!n||typeof n!="object"){U.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){U.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=s.outcome;if(!o||typeof o!="object"){U.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let d=o.outcome;(typeof d!="string"||d!=="selected"&&d!=="cancelled")&&U.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:d,result:n})}function Ru(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();oe();import{randomBytes as Ou}from"node:crypto";import{chmod as Nu,mkdir as Lu,writeFile as Wo}from"node:fs/promises";import{createServer as Mu}from"node:http";import{dirname as Bu}from"node:path";var zu=1e6,di=D("ipc"),Yn=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??G()}async start(){this.token=Ou(32).toString("hex");let e=Mu((o,a)=>{this.dispatch(o,a)});this.server=e,await new Promise((o,a)=>{e.once("error",a),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(),di.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(a=>a?o(a):s())}),this.server=null)}async persistAuthFiles(){await Lu(Bu(this.paths.portFile),{recursive:!0}),await Wo(this.paths.portFile,String(this.port),"utf8"),await Wo(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Nu(this.paths.tokenFile,384)}catch(e){di.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){cn(s,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,d=this.routes.get(a);if(!d){cn(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Fu(e)}catch(f){cn(s,400,{error:"invalid json",detail:String(f)});return}try{let f=await d.handler(u,e);cn(s,200,f??{ok:!0})}catch(f){di.error("IPC handler failed",{key:a,err:String(f)}),cn(s,500,{error:f instanceof Error?f.message:String(f)})}}};function cn(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function Fu(n){let e=[],s=0;for await(let a of n){let d=a;if(s+=d.length,s>zu)throw new Error("body too large");e.push(d)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as $o}from"node:path";import{fileURLToPath as Uu}from"node:url";function Jo(){return qu(Uu(import.meta.url))}function qu(n){let e=`${$o}src${$o}`;return n.includes(e)}q();oe();import{spawn as Gu}from"node:child_process";import{existsSync as ju,mkdirSync as Hu,openSync as Ku}from"node:fs";import{dirname as Wu}from"node:path";import{fileURLToPath as $u}from"node:url";var Ju=D("spawn-helper");function Vu(n){return ju(n.libEntry)?n.libEntry:$u(new URL("../index.ts",import.meta.url))}function Xu(n,e,s){let o=n.endsWith(".ts"),a=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${s}`];return o?["--import","tsx/esm",n,...a]:[n,...a]}async function Vo(n,e,s={}){let o=s.paths??G(),a=Vu(o);Hu(Wu(o.logFile),{recursive:!0});let d=Ku(o.logFile,"a"),u=Xu(a,n,e),f=Gu(process.execPath,u,{detached:!0,stdio:["ignore",d,d],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");Ju.info("upgrade helper spawned",{pid:f.pid,targetVersion:n,oldPid:e,entry:a})}q();import{mkdir as Yu,writeFile as Zu}from"node:fs/promises";import{dirname as Qu}from"node:path";import{gunzipSync as ef}from"node:zlib";var ui=D("tarball-downloader"),tf="https://registry.npmjs.org",Xo="package/dist/index.js";async function Yo(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let a=`${(s.registry??tf).replace(/\/+$/,"")}/coze-bridge/${n}`;ui.info("fetching tarball metadata",{metaUrl:a});let d=await fetch(a);if(!d.ok)throw new Error(`registry metadata ${a} returned ${d.status}`);let f=(await d.json())?.dist?.tarball;if(!f)throw new Error(`registry metadata missing dist.tarball for ${n}`);ui.info("downloading tarball",{tarballUrl:f});let p=await fetch(f);if(!p.ok)throw new Error(`tarball ${f} returned ${p.status}`);let h=Buffer.from(await p.arrayBuffer()),y=ef(h),w=nf(y,Xo);if(!w)throw new Error(`tarball missing entry ${Xo}`);await Yu(Qu(e),{recursive:!0}),await Zu(e,w),ui.info("dist extracted",{destPath:e,bytes:w.length})}function nf(n,e){let s=0;for(;s+512<=n.length;){let o=n.subarray(s,s+512);if(o.every(y=>y===0))return null;let a=o.subarray(0,100),d=a.indexOf(0),u=a.subarray(0,d===-1?100:d).toString("utf8"),f=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),p=Number.parseInt(f,8)||0,h=s+512;if(u===e)return n.subarray(h,h+p);s=h+Math.ceil(p/512)*512}return null}Bt();q();import{resolve as rf}from"node:path";var lt=D("upgrade-manager"),sf=300*1e3,of=3,Zn=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){lt.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let s=await ct(this.opts.paths.configFile)??{};if(s.disableAutoUpgrade){lt.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){lt.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!Jn(this.opts.currentVersion,e)){lt.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=s.upgradeAttempts?.[e];if((o?.count??0)>=of){lt.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let a=rf(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,a)}catch(u){await this.recordAttempt(s,e,String(u)),lt.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let d=await this.opts.daemon.waitIdle(sf);lt.info("waitIdle done",{result:d}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,s,o){e.upgradeAttempts=e.upgradeAttempts??{};let a=e.upgradeAttempts[s];e.upgradeAttempts[s]={count:(a?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await Ue(e,this.opts.paths.configFile)}};var _c=We(ca(),1);var Ul=We(rc(),1),ql=We(gr(),1),Gl=We(Ut(),1),jl=We(Ei(),1),Hl=We(Ti(),1),Kl=We(Oi(),1),fc=We(wr(),1),Wl=We(uc(),1);var lc=fc.default;q();var fe=D("upstream.frontier"),pc="application/json",hc="none",Jl=15e3,mn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){fe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Us,...Dt(this.opts.ppeOverride)};class s extends lc{constructor(E){super(E,Fs,{headers:e})}send(E,...k){if(ys("debug"))try{let L;typeof E=="string"?L=Buffer.from(E,"utf8"):E instanceof Buffer?L=E:E instanceof ArrayBuffer?L=new Uint8Array(E):ArrayBuffer.isView(E)?L=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):L=new Uint8Array(0);let $=Buffer.from(L.slice(0,128)).toString("hex");fe.debug("WS raw frame out",{bytes:L.byteLength,headHex:$})}catch(L){fe.warn("WS raw frame dump failed",{err:String(L)})}super.send(E,...k)}}let o=Gs(this.opts.urlOverride),a={url:o,ws:s,fpID:zs,aID:Ln,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:pc,force:!0},payloadEncoding:{encoding:hc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},d=new _c.FWS(a),u=!1,f=null,p,h,y=new Promise((I,E)=>{p=I,h=E}),w=I=>{u||(u=!0,f&&(clearTimeout(f),f=null),I?h(I):p())};d.onopen=()=>{this.opened=!0,this.openCount+=1;let I=this.openCount===1;fe.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:I,openCount:this.openCount}),I&&w();for(let E of this.connectHandlers)Promise.resolve(E({initial:I})).catch(k=>fe.warn("onConnect handler threw (ignored)",{err:String(k)}))},d.onclose=I=>{this.opened=!1,fe.info("frontier closed",{code:I.code,reason:I.reason,willReconnect:I.willReconnect})},d.onerror=I=>{fe.warn("frontier error",{code:I.code,msg:I.message}),w(new b("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${I.code} msg=${I.message??""}`))},d.onmessage=I=>this.handleMessage(I),this.fws=d;let A=this.opts.openTimeoutMs??Jl;f=setTimeout(()=>{w(new b("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await d.connect();try{await y}catch(I){try{d.close(1e3,"open failed")}catch(E){fe.warn("fws close during start failure threw (ignored)",{err:String(E)})}throw this.fws=null,this.opened=!1,I}}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){fe.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new b("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new b("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${s.readyState}); refusing to silently buffer`);this.injectAgentPatToken(e);let o=JSON.stringify(e),a=e;mc(a)||fe.info("frontier frame out",{method:a.method,jsonrpcId:a.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:pc,payloadEncoding:hc})}catch(u){throw fe.warn("frontier frame send failed",{method:a.method,jsonrpcId:a.id,err:String(u)}),new b("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let s=this.opts.getPatTokenForAgent;if(!s)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let a=s(o.cozeAgentId);a&&(o.cozePatToken=a)}handleMessage(e){let s=e.message?.service;if(s!==33555712){fe.debug("drop non-adapter frontier frame",{service:s});return}let o=Yl(e);if(!o){fe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){fe.debug("frame received but no onFrame handler",{size:o.length});return}let a;try{a=JSON.parse(o)}catch(u){fe.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let d=a;mc(d)||fe.info("frontier frame in",{logid:Xl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:d.id,method:d.method,body:Vl(o)}),Promise.resolve(this.handler(a)).catch(u=>fe.warn("frontier frame handler threw",{err:String(u)}))}};function mc(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var wc=2e3;function Vl(n){return n.length<=wc?n:`${n.slice(0,wc)}...<truncated, total ${n.length} chars>`}function Xl(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Yl(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 Li=D("upstream.switchable"),yr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;Li.info("swap upstream",{reason:s});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw Li.error("swap target start failed, reverting",{err:String(a)}),this.inner=o,a}await o.stop(s??"swapped").catch(a=>Li.warn("previous upstream stop threw (ignored)",{err:String(a)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};q();var Mi=D("upstream"),Wt=class{handler=null;async start(){Mi.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Mi.info("NoopUpstream stopped",{reason:e})}async send(e){Mi.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();q();oe();import{promises as Bi}from"node:fs";import{dirname as Zl}from"node:path";var Ql=D("pat-token-store");async function yc(n=G()){try{let s=(await Bi.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Ql.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function wn(n,e=G()){if(!n)throw new Error("writePatToken: empty patToken");await Bi.mkdir(Zl(e.patTokenFile),{recursive:!0}),await Bi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}oe();oe();import{promises as br}from"node:fs";import{join as eg}from"node:path";function tg(n){return`#!/bin/sh
|
|
115
|
+
`;var Oe=H("agent-detail-sync"),kf=6e4,Rf=5*6e4,Yn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let i=this.opts.paths.agentsRoot,o;try{o=await Pf(i)}catch(a){Oe.info("agents dir not found, skip detail sync",{root:i,err:String(a)});return}Oe.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async a=>{let c=await Te(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Oe.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(f){Oe.warn("detail sync failed for agent, skipping",{agentId:a,err:String(f)})}}})),Oe.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),i=[];for(let[o,a]of this.retryQueue)e>=a.dueAt&&i.push(o);if(i.length!==0){Oe.info("retrying pending detail syncs",{count:i.length});for(let o of i)try{await this.syncOne(o)}catch(a){Oe.debug("detail sync retry still failing, will try again",{agentId:o,err:String(a)})}}}async syncOne(e,i){let o=i??await Te(e,this.opts.paths);if(!o){Oe.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(x){Oe.warn("detail RPC failed, using local data",{agentId:e,err:String(x)});let l=this.retryQueue.get(e),h=l?Math.min(l.currentDelay*2,Rf):kf;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(a.agentId&&a.agentId!==e){Oe.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let c=!1,f=!1;if(a.agentName&&a.agentName!==o.agentName&&(o.agentName=a.agentName,c=!0),a.description!==void 0&&a.description!==o.description&&(o.description=a.description,c=!0),a.cozeIdentity&&a.cozeIdentity!==o.cozeIdentity&&(o.cozeIdentity=a.cozeIdentity,c=!0,f=!0),a.deployType&&Oe.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Oe.debug("detail sync: no diff",{agentId:e});return}await Ne(o,this.opts.paths),Oe.info("detail sync: config updated",{agentId:e,identityChanged:f,agentName:o.agentName}),f&&(await Gt(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var xa=We(jo(),1);gt();import{spawn as da}from"node:child_process";import{lstat as Ai,mkdir as Ti,readFile as fa,readdir as eu,rm as tu,stat as nu,writeFile as Di}from"node:fs/promises";import{dirname as ru,join as Je,normalize as iu,relative as Ri,resolve as Pi,sep as ua}from"node:path";var Ke={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 hn(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function Wo(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ko(n){let e=n?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function $o(n){let{_meta:e,...i}=n;return{stripped:i,meta:e}}function $t(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var A=class extends Error{code;retriable;cause;constructor(e,i,o){super(i),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};Y();ye();function st(n,e){if(hn(n)!=="cloud")throw new A("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function nr(n){return n.startsWith("http://")||n.startsWith("https://")}function rr(n){return n.endsWith("/")?n.slice(0,-1):n}Y();var ir="1008033",Jo="1289";var Vo="pbbp2",Zo="https://www.coze.cn",Yo="/api/coze_claw/resource/get_frontier_key",Xf="https://www.coze.cn",Qf="wss://frontier.coze.cn";function sr(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??Xf}function Xo(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??Qf}function Jt(n){let e={},i=n?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,o=n?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return i&&(e["x-tt-env"]=i),o&&(e["x-use-ppe"]=o),e}function mn(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var Qo=H("handshake");async function bi(n){let e=sr(n.endpoint),i=n.timeoutMs??1e4,o=`${rr(e)}${Yo}?aid=${encodeURIComponent(ir)}`,a={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...Jt(n.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),i);Qo.info("frontier key handshake",{base:e});try{let x=await fetch(o,{method:"GET",headers:a,signal:c.signal}),l=x.headers.get("x-tt-logid")??"",h=x.headers.get("x-tt-trace-id")??"";if(!x.ok){let E=await x.text().catch(()=>"");throw new A("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${x.status} logid=${l}: ${E.slice(0,200)}`)}let y=await x.json();if(y.code!==void 0&&y.code!==0)throw new A("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${y.code} msg=${y.msg??"-"} logid=${l}`);let v=y.data??{},k=typeof v.access_key=="string"&&v.access_key||typeof v.accessKey=="string"&&v.accessKey||void 0,w=typeof v.device_id=="string"&&v.device_id||typeof v.deviceId=="string"&&v.deviceId||void 0;if(!k||!w){let E=JSON.stringify(y).slice(0,500);throw new A("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${l}: ${E}`)}return Qo.info("handshake ok",{remoteDeviceId:w,logid:l,traceId:h}),{accessKey:k,deviceId:w}}catch(x){throw x instanceof A?x:x.name==="AbortError"?new A("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${i}ms)`):new A("UPSTREAM_HANDSHAKE_FAILED",String(x),{cause:x})}finally{clearTimeout(f)}}var Si=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",$e="auto";function ea(n){return{model:n.model??$e,...n.modelToken?{modelToken:n.modelToken}:{}}}function ta(n){return!n||n===$e}function na(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Si,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||$e,n.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(n.modelInfo.contextWindow))):ta(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function ra(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||$e}"`):ta(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="${Si}/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"'),n.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${n.modelInfo.contextWindow}`)),e}function ia(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Ii(n){let{ttEnv:e,usePpe:i}=mn(n),o={};return e&&(o["x-tt-env"]=e),i&&(o["x-use-ppe"]=i),o}function sa(n,e){if(!n.modelToken)return{};let i=Ii(e);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([a,c])=>`${a}:${c}`).join(`
|
|
116
|
+
`)}}function Ci(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function oa(n,e){if(!n.modelToken)return null;let i=n.model||$e,o=Ii(e),a=["text"];n.modelInfo?.capabilities?.image===!0&&a.push("image");let c={baseUrl:`${Si}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:i,name:i,reasoning:!1,input:a,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function aa(n,e){if(!n.modelToken)return[];let i=Ii(e),o=[];for(let[a,c]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${a}="${c}"`);return o}var ve=H("agent-handlers"),ca=5*1024*1024,su=1,ou=6,au=new Set(["node_modules",".git",".coze","dist","build",".next"]),or=class{constructor(e){this.opts=e}opts;async listSkills(e){st(e._meta,"_agent/listSkills");let i=$t(e._meta),o=await this.loadAgentCfg(i),a=o?.workspace??it(i).workspace,c=o?.skills??[],f=[];for(let x of c){let l=Je(a,x.relPath,"SKILL.md");await nu(l).then(y=>y.isFile()).catch(()=>!1)&&f.push(xu(x))}return{skills:f}}async addSkills(e){st(e._meta,"_agent/addSkills");let i=$t(e._meta),o=await this.requireAgentCfg(i),a=e.skills??[],c=[...o.skills??[]],f=new Map(c.map((l,h)=>[l.skillId,h])),x=[];for(let l of a){let h=await Li({agentId:i,workspace:o.workspace,framework:o.framework,skill:l});Ni(c,f,h),x.push(l)}return await Vn(i,c),this.reloadAgentSessions(i,"skills-added"),{installedSkills:x}}async removeSkills(e){st(e._meta,"_agent/removeSkills");let i=$t(e._meta),o=await this.requireAgentCfg(i),a=new Set(e.skillIds??[]),c=o.skills??[],f=[];for(let x of c){if(!a.has(x.skillId)){f.push(x);continue}let l=Je(o.workspace,x.relPath);await tu(l,{recursive:!0,force:!0}),ve.info("skill removed",{agentId:i,skillId:x.skillId,relPath:x.relPath})}return await Vn(i,f),this.reloadAgentSessions(i,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,i){this.reloadAgentSessions(e,i)}reloadAgentSessions(e,i){let o=this.opts.agents.get(e);if(o)for(let[a,c]of o.sessions){if(!c.downstream)continue;let f=c.acpSessionId;if(f&&o.activeTriggers.has(f)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,ve.info("downstream busy, scheduling reload after turn",{reason:i,agentId:e,framework:o.framework,cloudId:a,acpId:f});continue}let l=c.downstream;c.downstream=void 0,ve.info("killing downstream for workspace reload (idle)",{reason:i,agentId:e,framework:o.framework,cloudId:a,acpId:f}),l.stop(i).catch(h=>ve.warn("downstream stop failed during reload (ignored)",{reason:i,agentId:e,cloudId:a,err:String(h)}))}}isRuntimePendingPermission(e){let i=this.opts.isRuntimePendingPermission;return!i||!e.downstream?!1:i(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ve.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let i=e.agentId,o=await Te(i);if(!o)throw new A("AGENT_NOT_FOUND",`agent not found: ${i}`);if(o.cozeIdentity===e.cozeIdentity)return ve.info("_agent/update: cozeIdentity unchanged, noop",{agentId:i}),{ok:!0};try{await Gt(o.workspace,o.framework,i,e.cozeIdentity)}catch(a){throw ve.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:i,framework:o.framework,workspace:o.workspace,err:String(a)}),new A("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${i}: ${String(a)}`,{cause:a})}return o.cozeIdentity=e.cozeIdentity,await Ne(o),ve.info("_agent/update: cozeIdentity rewritten",{agentId:i,framework:o.framework}),this.reloadAgentSessions(i,"identity-changed"),{ok:!0}}async disconnectAgent(e){let i=e.agentId;if(!i)throw new A("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await Te(i);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Ne(o),ve.info("agent disconnected",{agentId:i,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(i,e.reason??"disconnect"),{ok:!0}):(ve.warn("_agent/disconnect: agent not found, ignoring",{agentId:i}),{ok:!0})}async switchModel(e){if(st(e._meta,"_agent/switchModel"),!e.agentId)throw new A("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let i=e.model?.trim()?e.model:$e,o=await Te(e.agentId);if(!o)throw new A("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=i,e.modelInfo&&(o.modelInfo=e.modelInfo),await Ne(o),ve.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:i,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return ve.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=i,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(f=>ve.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(f)}));let c=[];for(let[f,x]of a.allSessionQueues())c.push(x.enqueue(async()=>{let l=a.sessions.get(f);l?.downstream&&(await l.downstream.stop(`switchModel: ${i}`).catch(()=>{}),l.downstream=void 0)}));return await Promise.all(c),ve.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:i,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(st(e._meta,Ke.RESET),!e.agentId)throw new A("IPC_BAD_REQUEST",`${Ke.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Ke.RESET,e.reason),{ok:!0}}async repairAgent(e){if(st(e._meta,Ke.REPAIR),!e.agentId)throw new A("IPC_BAD_REQUEST",`${Ke.REPAIR}: missing agentId`);let i=await this.loadAgentCfg(e.agentId);if(i&&i.framework!=="openclaw")throw new A("IPC_BAD_REQUEST",`${Ke.REPAIR} only allowed for openclaw, got ${i.framework}`);if(i&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,i.workspace)}catch(o){ve.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Ke.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,i,o){if(!this.opts.detailSyncer){ve.warn("detailSyncer not wired, skipping sync",{method:i,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){ve.warn("detail sync failed (ignored)",{method:i,agentId:e,reason:o,err:String(a)})}}async getFileTree(e){st(e._meta,"_agent/getFileTree");let i=e._meta,o=$t(i),a=await this.resolveWorkspace(o),c=e.filePath??"",f=this.safeJoin(a,c),x=await Ai(f).catch(()=>null);if(!x)throw new A("IPC_BAD_REQUEST",`path not found: ${c}`);if(x.isSymbolicLink())throw new A("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);let l=bu(e.depth);return x.isDirectory()?{tree:await vu(a,f,c,l)}:{tree:[{name:Su(c),path:ga(c||"."),isDir:!1,size:x.size,modifiedAt:Math.floor(x.mtimeMs)}]}}async getFileContent(e){st(e._meta,"_agent/getFileContent");let i=$t(e._meta),o=await this.resolveWorkspace(i);if(!e.filePath)throw new A("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(o,e.filePath),c=await Ai(a).catch(()=>null);if(!c||!c.isFile())throw new A("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new A("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(c.size>ca)throw new A("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${ca})`);let f=await fa(a);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:c.size}:{content:f.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let i=this.opts.agents.get(e);return i?i.workspace:(await Te(e).catch(()=>null))?.workspace??it(e).workspace}safeJoin(e,i){let o=Pi(e,i||"."),a=Ri(e,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${ua}`))throw new A("IPC_BAD_REQUEST",`path escapes workspace: ${i}`);return o}loadAgentCfg(e){return Te(e)}async requireAgentCfg(e){let i=await this.loadAgentCfg(e);if(!i)throw new A("AGENT_NOT_FOUND",`no config for agent: ${e}`);return i}};function cu(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new A("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new A("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function du(n){return n==="claude-code"?Je(".claude","skills"):Je(".agents","skills")}var fu=3e4,uu=50*1024*1024,ar=3e4;async function Li(n){let{agentId:e,workspace:i,framework:o,skill:a}=n;if(!a.skillName)throw new A("IPC_BAD_REQUEST","skill missing skillName");let c=typeof a.content=="string"&&a.content.length>0,f=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!c&&!f)throw new A("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let x=cu(a.skillName),l=du(o),h=Je(l,x),y=Je(i,h);if(await Ti(y,{recursive:!0}),c){let k=Buffer.from(a.content,"utf8");wn(k.length),await Di(Je(y,"SKILL.md"),k,"utf8")}else{let k=await lu(a.downloadUrl);pu(k)?await _u(k,y):hu(k)?await mu(k,y):await Di(Je(y,"SKILL.md"),k.toString("utf8"),"utf8")}let v={skillId:a.skillId,skillName:a.skillName,relPath:h,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return ve.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:h,source:c?"content":"downloadUrl"}),v}function Ni(n,e,i){let o=e.get(i.skillId);if(o!==void 0){n[o]=i;return}e.set(i.skillId,n.length),n.push(i)}function xu(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 lu(n){if(!n)throw new A("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);wn(e);let i=gu(n);return wn(i.length),i}if(n.startsWith("file:")){let e=new URL(n).pathname,i=await fa(e);return wn(i.length),i}if(nr(n)){let e=new AbortController,i=setTimeout(()=>e.abort(),fu);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new A("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let a=await o.arrayBuffer();return wn(a.byteLength),Buffer.from(a)}finally{clearTimeout(i)}}throw new A("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function wn(n){if(n>uu)throw new A("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function gu(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new A("IPC_BAD_REQUEST","bad data URL");let i=!!e[2],o=e[3]??"";return i?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function pu(n){return n.length>=2&&n[0]===31&&n[1]===139}function hu(n){if(n.length<4||n[0]!==80||n[1]!==75)return!1;let e=n[2],i=n[3];return e===3&&i===4||e===5&&i===6}function ki(n){return n==="__MACOSX"||n.startsWith("__MACOSX/")}async function mu(n,e){let i,o;try{i=new xa.default(n),o=i.getEntries()}catch(f){throw new A("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of o){let x=f.entryName;if(!x||ki(x))continue;if(x.startsWith("/")||/^[A-Za-z]:[\\/]/.test(x))throw new A("IPC_BAD_REQUEST",`zip entry absolute path: ${x}`);if(x.split(/[/\\]/).some(h=>h===".."))throw new A("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${x}`);let l=f.header.attr>>>16&61440;if(l!==0&&l!==32768&&l!==16384)throw new A("IPC_BAD_REQUEST",`zip entry kind 0x${l.toString(16)} not allowed (symlink/hardlink/special): ${x}`)}let a=wu(o),c=Pi(e);for(let f of o){if(ki(f.entryName))continue;let x=f.entryName;if(a&&x.startsWith(a)&&(x=x.slice(a.length)),!x)continue;let l=Pi(e,x),h=Ri(c,l);if(h.startsWith("..")||h==="..")throw new A("IPC_BAD_REQUEST",`zip entry escapes destDir: ${x}`);if(f.isDirectory){await Ti(l,{recursive:!0});continue}await Ti(ru(l),{recursive:!0});let y;try{y=f.getData()}catch(v){throw new A("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${v.message}`,{cause:v})}await Di(l,y)}}function wu(n){let e;for(let i of n){let o=i.entryName;if(!o||ki(o))continue;let a=o.indexOf("/");if(a<=0)return;let c=o.slice(0,a+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function _u(n,e){await yu(n),await new Promise((i,o)=>{let a=da("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),c="";a.stderr?.on("data",x=>{c+=String(x)});let f=setTimeout(()=>{a.kill("SIGKILL"),o(new A("IPC_BAD_REQUEST",`tar extract timeout (${ar}ms)`))},ar);a.on("error",x=>{clearTimeout(f),o(new A("IPC_BAD_REQUEST",`tar spawn failed: ${x.message}`,{cause:x}))}),a.on("exit",x=>{clearTimeout(f),x===0?i():o(new A("IPC_BAD_REQUEST",`tar exit ${x}${c?`: ${c.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)})}async function yu(n){let e=await new Promise((i,o)=>{let a=da("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),c="",f="";a.stdout?.on("data",l=>{c+=String(l)}),a.stderr?.on("data",l=>{f+=String(l)});let x=setTimeout(()=>{a.kill("SIGKILL"),o(new A("IPC_BAD_REQUEST",`tar list timeout (${ar}ms)`))},ar);a.on("error",l=>{clearTimeout(x),o(new A("IPC_BAD_REQUEST",`tar list spawn failed: ${l.message}`))}),a.on("exit",l=>{clearTimeout(x),l===0?i(c):o(new A("IPC_BAD_REQUEST",`tar list exit ${l}${f?`: ${f.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)});for(let i of e.split(`
|
|
117
|
+
`)){let o=i.trim();if(!o)continue;let a=o.charCodeAt(0);if(a!==45&&a!==100)throw new A("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 A("IPC_BAD_REQUEST",`tar entry absolute path: ${f}`);if(f.split(/[/\\]/).some(l=>l===".."))throw new A("IPC_BAD_REQUEST",`tar entry contains '..': ${f}`)}}var Eu=5e3;async function vu(n,e,i,o){return la(n,e,i,o,{count:0})}async function la(n,e,i,o,a){if(o<=0)return[];let c;try{c=await eu(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let x of c){if(au.has(x.name)||x.isSymbolicLink())continue;if(a.count>=Eu){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let l=Je(e,x.name),h=iu(Je(i,x.name)),y=null;try{y=await Ai(l)}catch{continue}if(y.isSymbolicLink())continue;a.count++;let v={name:x.name,path:ga(Ri(n,l)),isDir:y.isDirectory(),size:y.size,modifiedAt:Math.floor(y.mtimeMs)};y.isDirectory()&&o>1&&(v.children=await la(n,l,h,o-1,a)),f.push(v)}return f.sort((x,l)=>x.isDir!==l.isDir?x.isDir?-1:1:x.name.localeCompare(l.name)),f}function bu(n){return!n||n<=0?su:Math.min(n,ou)}function Su(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function ga(n){return n.split(ua).join("/")}Y();import{readFileSync as gw}from"node:fs";import{dirname as hw,join as mw}from"node:path";import{fileURLToPath as _w}from"node:url";var ht="0.1.68";var Ve=H("agent-health-reporter"),Iu=1e4,_n=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Iu}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()}),Ve.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Ve.info("heartbeat stopped"))}async tick(){if(this.inFlight){Ve.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){Ve.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let i=[];for(let x of this.opts.core.agents.values()){let l=Cu(x);if(!l)continue;let h={agentId:x.agentId,status:l};x.patToken&&(h.patToken=x.patToken),x.accountId&&(h.accountId=x.accountId),i.push(h)}if(i.length===0)return;let o={agents:i,bridgeVersion:ht,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(x){Ve.warn("heartbeat batch send failed",{count:i.length,err:String(x)})}let c=a?.authFailures;if(c&&c.length>0&&(Ve.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(x=>x.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(x){Ve.warn("onAuthFailures callback failed (ignored)",{err:String(x)})}let f=a?.minBridgeVersion;if(f&&(Ve.info("heartbeat received minBridgeVersion from cloud",{minV:f}),this.opts.onMinBridgeVersion))try{await this.opts.onMinBridgeVersion(f)}catch(x){Ve.warn("onMinBridgeVersion callback failed (ignored)",{err:String(x)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(i){Ve.warn("onTickEnd hook failed",{err:String(i)})}}};function Cu(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}gt();import{mkdir as Bi,rm as ex}from"node:fs/promises";import{spawn as Nu,spawnSync as Ou}from"node:child_process";function yn(n,e,i){return i===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:i}}function En(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Vt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function mt(n,e){return{jsonrpc:"2.0",id:n,error:e}}var cr=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Q={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,BRIDGE_UPGRADING:-32015,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function pa(n){return"method"in n&&"id"in n&&n.id!==void 0}function ha(n){return"method"in n&&!("id"in n)}function dr(n){return!("method"in n)&&"id"in n}var Au={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,BRIDGE_UPGRADING:Q.BRIDGE_UPGRADING,NPX_CACHE_CORRUPT:Q.INTERNAL_ERROR};function Tu(n){if(n!=null)return n instanceof Error?{name:n.name,message:vn(n.message)}:typeof n=="string"?vn(n):typeof n=="object"?Pu(n):n}var Du=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function vn(n){let e=n;for(let[i,o]of Du)e=e.replace(i,o);return e}function Pu(n){let e={};for(let[i,o]of Object.entries(n))typeof o=="string"?e[i]=vn(o):e[i]=o;return e}function bn(n){if(n instanceof A){let e=Tu(n.cause),i={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(i.cause=e),{code:Au[n.code]??Q.INTERNAL_ERROR,message:vn(n.message),data:i}}return{code:Q.INTERNAL_ERROR,message:vn(n instanceof Error?n.message:String(n))}}function ma(n){let e=n.data,i=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",o=!!e&&typeof e.message=="string"&&!!e.message,a=o?e?.message:n.message,c=n.data;if(o&&e){let{message:f,...x}=e;c=x}return new A(i,a,{retriable:e?.retriable??!1,cause:c})}function _a(n){return`${JSON.stringify(n)}
|
|
118
|
+
`}var wa=10*1024*1024,fr=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>wa){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${wa} bytes`)}),[]}let i=this.buffer.split(`
|
|
119
|
+
`);this.buffer=i.pop()??"";let o=[];for(let a of i){let c=a.replace(/\r$/,"").trim();if(c)try{o.push(JSON.parse(c))}catch(f){this.onError?.({line:c,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(i){return this.onError?.({line:e,error:i}),[]}}};var Ea={"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"},Pw=Object.fromEntries(Object.entries(Ea).map(([n,e])=>[e,n])),ku={"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:[]},Zt=class{seq=0;next(e,i){this.seq+=1;let o=Ea[e]??Ru(e),a=ku[o]??[],c=[o,String(this.seq)];if(a.length>0){let f=a.map(l=>ya(i?.[l]??"")),x=Lu(f).join(":");x&&c.push(x)}else i&&Object.values(i).some(f=>f)&&c.push(Object.values(i).filter(Boolean).map(f=>ya(String(f))).join(":"));return c.join("_")}reset(){this.seq=0}};function Ru(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function ya(n){return n.replace(/[:_\s]+/g,"-")}function Lu(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function wt(n,e){let i=process.env[n];if(!i)return e;let o=Number(i);return Number.isFinite(o)&&o>0?o:e}Y();var Mu=wt("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Bu=200,zu=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function Oi(n){return n.some(e=>zu.test(e))}var Fu=wt("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Uu=wt("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),va=500;function Hu(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=va?n:`${e.slice(0,va)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function ba(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let i=["/PID",String(n),"/T"];e==="SIGKILL"&&i.push("/F"),Ou("taskkill",i,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var Ze=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`),this.decoder=new fr({onError:i=>this.log.warn("decode line failed",{line:i.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Zt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new A("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",i=Nu(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=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let a of this.decoder.push(o))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let a=o.trimEnd();this.stderrRing.push(a),this.stderrRing.length>Bu&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,a)=>{this.stopped=!0,(o!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&Oi(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),Ut(this.framework).catch(x=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(x)})})));try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(new A("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${a})`));for(let f of this.exitHandlers)f(o,a)}),i.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new A("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let i=this.child,o=new Promise(c=>i.once("exit",()=>c()));ba(i.pid,"SIGTERM");let a=setTimeout(()=>{i.killed||ba(i.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,i=Fu,o=Uu){return this.call("session/prompt",e,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(En("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,i){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Vt(e,i))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,i){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(mt(e,i))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,i,o=Mu,a=0){if(!this.child||this.stopped)return Promise.reject(new A("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),f=yn(c,e,i),x=o>0&&Number.isFinite(o),l=a>0&&Number.isFinite(a);return new Promise((h,y)=>{let v={resolve:h,reject:y,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};x&&(v.timer=setTimeout(()=>{this.pending.delete(c),v.frameIdleTimer&&clearTimeout(v.frameIdleTimer),y(new A("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o));let k=l?()=>{v.frameIdleTimer&&clearTimeout(v.frameIdleTimer),v.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size}),k?.();return}v.timer&&clearTimeout(v.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:a}),y(new A("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;v.armFrameIdle=k,this.pending.set(c,v),k?.();try{this.writeFrame(f)}catch(w){v.timer&&clearTimeout(v.timer),v.frameIdleTimer&&clearTimeout(v.frameIdleTimer),this.pending.delete(c),y(w)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new A("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(_a(e),i=>{i&&this.log.warn("stdin write callback err",{err:String(i)})})}dispatch(e){if(dr(e)){let i=e.id!==null?this.pending.get(e.id):void 0;if(!i){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),i.timer&&clearTimeout(i.timer),i.frameIdleTimer&&clearTimeout(i.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:i.method,code:e.error.code,message:e.error.message,data:e.error.data}),i.reject(ma(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:i.method}),i.reject(new A("AGENT_PROTOCOL_ERROR",`${i.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:i.method,result:Hu(e.result)}),i.resolve(e.result));return}if(ha(e)){if(e.method==="session/update"){for(let i of this.pending.values())i.armFrameIdle?.();for(let i of this.updateHandlers)try{Promise.resolve(i(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(pa(e)){let i=e;try{this.handleAgentRequest(i).catch(o=>this.log.error("agent request handler failed (async)",{method:i.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:i.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(mt(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let i of this.agentRequestHandlers)try{await i(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(mt(e.id,bn(o)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let i of this.pending.values())i.timer&&clearTimeout(i.timer),i.frameIdleTimer&&clearTimeout(i.frameIdleTimer),i.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var qu="@agentclientprotocol/claude-agent-acp@latest";function Gu(n){let e={};for(let[i,o]of Object.entries(n))o!==void 0&&(i.startsWith("CLAUDE")||i==="AI_AGENT"||i==="BAGGAGE"||(e[i]=o));return e}var ur=class extends Ze{framework="claude-code";constructor(e){let i=Ht("claude-code"),[o,a]=i?[i,[]]:["npx",["-y",qu]],c=e.command??o,f=e.args??a,x={command:c,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(x)}sanitizeEnv(e){return Gu(e)}};import{mkdtempSync as ju,rmSync as Wu}from"node:fs";import{tmpdir as Ku}from"node:os";import{join as $u}from"node:path";var Ju="@zed-industries/codex-acp@latest",xr=class extends Ze{framework="codex";authMethodId;codexHomeDir;constructor(e){let i=Ht("codex"),[o,a]=i?[i,[]]:["npx",["-y",Ju]],c=e.command??o,f=e.args??a,x=e.extraArgs?[...f,...e.extraArgs]:f,l=e.isolateCodexHome?ju($u(Ku(),"coze-bridge-codex-home-")):void 0,h=l?{...e.env??{},CODEX_HOME:l}:e.env,y={command:c,args:x,cwd:e.cwd,...h?{env:h}:{}};super(y),this.authMethodId=e.authMethodId,this.codexHomeDir=l}async initialize(e){let i=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),i}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Wu(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Vu=3e4,Yt=class extends Ze{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let i=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${i}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let a={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),this.agentId=e.agentId,this.sessionName=i,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}`}]},Vu))}get acpSessionName(){return this.sessionName}};Y();ye();function Mi(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Xt=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((i,o)=>{this.slots.push({task:e,resolve:i,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}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let i=await e.task();e.resolve(i)}catch(i){e.reject(i)}}}finally{this.running=!1}}}};var lr=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let i=this.sessionQueues.get(e);return(!i||i.isDisposed)&&(i=new Xt,this.sessionQueues.set(e,i)),i}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let i=this.sessionQueues.get(e);return!!i&&!i.isDisposed}async dispose(e){this.status="stopped";let i=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(i);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let i=[];for(let[,o]of this.sessions)Sn(o),o.downstream&&(i.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(i),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Sn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as Zu}from"node:child_process";import{homedir as Yu}from"node:os";import{join as Xu}from"node:path";$n();Y();async function Ca(){let n=Xu(Yu(),".openclaw/openclaw.json");return(await qt(n))?.gateway?.auth?.token??""}var Sa=H("openclaw.config"),Qu=[0,5e3,5e3],Ia="models.providers.",gr="agents.defaults.models",pr=class{command;env;retryDelaysMs;queue=new Xt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Qu}async withRetry(e,i){let o;for(let a=0;a<this.retryDelaysMs.length;a++){let c=this.retryDelaysMs[a]??0;c>0&&await new Promise(f=>setTimeout(f,c));try{return await i()}catch(f){o=f,Sa.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(f)})}}throw new A("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((i,o)=>{let a=Zu(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",o),a.on("close",f=>{f===0?i():o(new Error(`exit ${f}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,i){try{await this.runCli(e)}catch(o){let a=String(o);if(i.some(c=>a.includes(c)))return;throw o}}async bestEffortUnset(e,i){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",i])))}catch(o){Sa.warn(`${e} failed (best-effort)`,{configPath:i,err:String(o)})}}ensureProvider(e,i){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${Ia}${e}`,JSON.stringify(i),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Ia}${e}`)}addModelToAllowlist(e,i){let o={[e]:i?{alias:i}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${gr}[${e}]`,()=>this.runCli(["config","set",gr,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${gr}[${e}]`,`${gr}.${e}`)}ensureAgent(e,i,o){let a=["agents","add",e,"--workspace",i,"--non-interactive"];return o&&a.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var De=H("agent-manager"),tx=(n,e,i,o,a,c,f,x)=>{switch(n){case"claude-code":{let l={...a?{...na(a),...sa(a,f)}:{},...x??{},IS_SANDBOX:"1"};return new ur({cwd:i,env:l})}case"codex":{let h=[...a?[...ra(a),...aa(a,f)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],y={...a?ia(a):{},...x??{}},v=!!a;return new xr({cwd:i,...h.length>0?{extraArgs:h}:{},...Object.keys(y).length>0?{env:y}:{},...v?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Yt({command:e,cwd:i,agentId:o,...c?{sessionName:Mi(c)}:{}})}};function zi(n){return n==="claude-code"||n==="codex"}var nx={path:"",version:"cloud-deployed"},rx={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},ix=6e4,sx=wt("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),hr=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??tx,this.createTimeoutMs=e.createTimeoutMs??ix,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??sx}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new A("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new pr({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new A("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new A("IPC_BAD_REQUEST","framework required");let i=hn(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new A("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")De.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(E=>De.warn("dispose stale agent failed (ignored)",{err:String(E)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){De.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let E=await Te(e.agentId,this.paths).catch(()=>null);E&&(E.patToken=e.patToken,await Ne(E,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){De.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let E=await Te(e.agentId,this.paths).catch(()=>null);E&&(E.modelInfo=e.modelInfo,await Ne(E,this.paths))}return De.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new A("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=it(e.agentId,this.paths),f=hn(e._meta),x=e.framework==="openclaw"&&f==="local",l=x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,h=e.workspace??l??c.workspace,y=new AbortController,v=setTimeout(()=>y.abort(new A("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),k,w=!1;try{i&&zi(e.framework)&&await Ut(e.framework,y.signal);let E=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new A("AGENT_TIMEOUT","_agent/create aborted")};await Bi(c.root,{recursive:!0}),await Bi(h,{recursive:!0}),await Bi(c.logs,{recursive:!0}),E(),x||await Gt(h,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await uo(h),E();let S=await Te(e.agentId,this.paths).catch(()=>null),I=ea({model:e.model??S?.model}),D=Wo(e._meta)??S?.accountId,R=e.patToken??S?.patToken,m=f==="cloud"?e.modelInfo??S?.modelInfo:void 0;if(k=new lr({agentId:e.agentId,framework:e.framework,workspace:h,model:I.model??$e,deployType:f,...D?{accountId:D}:{},...R?{patToken:R}:{},...m?{modelInfo:m}:{}}),k.status="ok",S?.sessions){for(let[z,K]of Object.entries(S.sessions))k.sessions.set(z,{acpSessionId:K.acpSessionId,modelToken:K.modelToken,tokenGeneratedAt:K.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(S.sessions).length;F>0&&De.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(k),w=!0;let C={agentId:e.agentId,framework:e.framework,workspace:h,cozeIdentity:e.cozeIdentity,createdAt:S?.createdAt??Date.now(),sessions:S?.sessions??{},model:I.model};f==="cloud"&&(C.deployType="cloud"),D&&(C.accountId=D),R&&(C.patToken=R),m&&(C.modelInfo=m),S?.skills&&(C.skills=S.skills),S?.agentName&&(C.agentName=S.agentName),S?.description&&(C.description=S.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,h):De.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let P=e.initialSkills??[];if(P.length>0){let F=[...C.skills??[]],z=new Map(F.map((L,M)=>[L.skillId,M])),K=await Promise.allSettled(P.map(L=>Li({agentId:e.agentId,workspace:h,framework:e.framework,skill:L}))),$=0;for(let[L,M]of K.entries()){let j=P[L];j&&(M.status==="fulfilled"?(Ni(F,z,M.value),$++):De.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:j.skillId,skillName:j.skillName,err:String(M.reason)}))}$>0&&(C.skills=F,De.info("initialSkills installed",{agentId:e.agentId,installed:$,requested:P.length}))}return await Ne(C,this.paths),De.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:h,framework:e.framework}}catch(E){throw De.error("agent create failed, rolling back",{agentId:e.agentId,err:String(E)}),w&&k&&(await k.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ex(c.root,{recursive:!0,force:!0}).catch(S=>De.warn("rm agent dir failed (ignored)",{err:String(S)})),E instanceof A?E:new A("AGENT_SPAWN_FAILED",String(E),{cause:E})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,i,o,a){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&zi(e.framework))f=nx;else throw new A("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(zi(e.framework)&&!Ht(e.framework)){let h=Qs(e.framework);h&&(De.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([h.catch(()=>{}),new Promise(y=>setTimeout(y,this.spawnAwaitInstallMs))]))}let x=e.deployType==="cloud"?{model:e.model,modelToken:i,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,l;e.framework==="openclaw"?l=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:o,cozeEnv:a,command:f.path}):l=this.factory(e.framework,f.path,e.workspace,e.agentId,x,o,a,this.buildBinShimPathEnv());try{return await l.start(),await l.initialize(rx),l}catch(h){let y=l instanceof Ze?l.getStderrTail():[];y.length>0&&De.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:h instanceof A?h.code:"unknown",recentStderr:y});let v=Oi(y);await l.stop("spawnSessionDownstream failed").catch(()=>{});let k=v?new A("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:h}):h;throw h instanceof A?new A(h.code,h.message,{retriable:h.retriable,cause:k}):new A("AGENT_SPAWN_FAILED",h instanceof Error?h.message:String(h),{cause:k})}}async buildOpenclawDownstream(e){let{session:i,modelConfig:o,cloudSessionId:a,cozeEnv:c,command:f}=e,x=Mi(a);if(i.deployType==="local"){let v=this.config.frameworksCache?.openclaw?.defaultAgent;if(!v?.id||!v.workspace)throw new A("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 Yt({command:f,cwd:v.workspace,agentId:v.id,sessionName:x})}let l=await Ca(),h=o?oa(o,c):null,y;if(h){let v=Ci(a),w=h.models[0]?.id??$e,E=`${v}/${w}`;if(!this.ensuredProviders.has(E)){let S=this.getOpenclawConfig();await S.ensureProvider(v,h),await S.addModelToAllowlist(E),this.ensuredProviders.add(E)}y=E}return new Yt({command:f,cwd:i.workspace,agentId:i.agentId,sessionName:x,...l?{gatewayToken:l}:{},...y?{slashModelOnStart:y}:{}})}async openclawRepair(e,i){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,i)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let i=this.openclawConfigCache;for(let o of e.sessions.keys()){let a=Ci(o),c=`${a}/${e.model}`,f=!0;try{await i.removeProvider(a)}catch(x){f=!1,De.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(x)})}try{await i.removeModelFromAllowlist(c)}catch(x){f=!1,De.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(x)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as ka}from"node:crypto";import{promises as hx}from"node:fs";import{basename as Ra}from"node:path";import{promises as ax}from"node:fs";import{basename as cx}from"node:path";Y();var Aa=H("file-upload"),dx="/api/coze_claw/file/agent_upload",fx=6e4;async function Ta(n,e={}){let o=`${rr(sr(e.handshakeBase))}${dx}`,a=e.timeoutMs??fx,c=await ax.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([c],{type:n.mimeType}),n.name);let x={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Jt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},l=new AbortController,h=setTimeout(()=>l.abort(),a);Aa.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let y=await fetch(o,{method:"POST",headers:x,body:f,signal:l.signal}),v=y.headers.get("x-tt-logid")??"";if(!y.ok){let E=await y.text().catch(()=>"");throw new A("UPLOAD_FAILED",`upload HTTP ${y.status} logid=${v}: ${E.slice(0,200)}`)}let k=await y.json();if(k.code!==void 0&&k.code!==0)throw new A("UPLOAD_FAILED",`upload code=${k.code} msg=${k.msg??"-"} logid=${v}`);let w=k.data?.file?.file_url;if(!w)throw new A("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${v}: ${JSON.stringify(k).slice(0,200)}`);return Aa.info("file upload ok",{uri:w,logid:v}),{uri:w}}catch(y){throw y instanceof A?y:y.name==="AbortError"?new A("UPLOAD_FAILED",`upload timeout (${a}ms) for ${cx(n.path)}`):new A("UPLOAD_FAILED",String(y),{cause:y})}finally{clearTimeout(h)}}Y();import{promises as ux}from"node:fs";import{extname as xx}from"node:path";var lx=[{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 gx(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",".svg":"image/svg+xml",".json":"application/json"};async function Da(n){let e=await ux.open(n,"r");try{let i=Buffer.alloc(16);if(await e.read(i,0,16,0),gx(i))return"image/webp";for(let o of lx)if(o.prefix.every((a,c)=>i[c]===a))return o.mime}finally{await e.close()}return px[xx(n).toLowerCase()]??"application/octet-stream"}ye();var Fi=H("agent-send"),Pa=50*1024*1024,mx=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function La(n,e,i){let o=n.get(e);if(!o)throw new A("AGENT_NOT_FOUND",`agent=${e}`);if(n.disconnectedAgents.has(e))throw new A("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=o.sessions.get(i);if(!a)throw new A("AGENT_NOT_FOUND",`session=${i} not active in agent=${e}`);return{session:o,runtime:a}}async function Na(n,e,i,o,a,c){let x;for(let l=0;l<=2;l++)try{await n.core.sendAgentFileUpdate(e,i,o,a);return}catch(h){x=h,l<2&&(Fi.warn("sendAgentFileUpdate failed, retrying",{attempt:l+1,err:String(h)}),await new Promise(y=>setTimeout(y,5e3)))}throw new A("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(x)}`,{cause:x})}async function Oa(n,e){let{session:i,runtime:o}=La(e.core,n.agentId,n.sessionId);if(!await oo(n.path,i.workspace))throw new A("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${i.workspace}`);let a=await hx.stat(n.path).catch(()=>null);if(!a||!a.isFile())throw new A("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(a.size>Pa)throw new A("FILE_TOO_LARGE",`${a.size} bytes > limit ${Pa}`);let c=await Da(n.path);if(!mx.has(c))throw new A("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(n.kind==="image"&&!c.startsWith("image/"))throw new A("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new A("UPSTREAM_NOT_READY","cloud WS not connected");let f=n.name??Ra(n.path),x=await Ta({patToken:i.patToken??e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:c,name:f,sizeBytes:a.size,...i.accountId?{accountId:i.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),l={sessionUpdate:"agent_file",messageId:ka(),content:{type:n.kind==="image"?"image":"resource",uri:x.uri,mimeType:c,name:f,sizeBytes:a.size,...x.fileId!==void 0?{fileId:x.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await Na(e,i,o,n.sessionId,l,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Fi.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:f,bytes:a.size,mime:c,uri:x.uri}),{ok:!0,uri:x.uri,bytes:a.size,mimeType:c,...x.fileId!==void 0?{fileId:x.fileId}:{}}}async function Ma(n,e){let{session:i,runtime:o}=La(e.core,n.agentId,n.sessionId);if(!n.mimeType)throw new A("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new A("UPSTREAM_NOT_READY","cloud WS not connected");let a=n.name??Ra(n.path),c={sessionUpdate:"group_file",messageId:ka(),content:{uri:n.path,name:a,mimeType:n.mimeType,...n.caption!==void 0?{caption:n.caption}:{}}};return await Na(e,i,o,n.sessionId,c,"agent group file sendAgentFileUpdate failed"),Fi.info("agent group file sent",{agentId:n.agentId,sessionId:n.sessionId,uri:n.path,name:a,mime:n.mimeType}),{ok:!0,uri:n.path,bytes:0,mimeType:n.mimeType}}import{execFile as _x}from"node:child_process";import{promisify as yx}from"node:util";function mr(n,e){let i=n.split(".").map(Number),o=e.split(".").map(Number),a=Math.max(i.length,o.length);for(let c=0;c<a;c++){let f=i[c]??0,x=o[c]??0;if(f<x)return!0;if(f>x)return!1}return!1}Y();var Ex=yx(_x),Ye=H("coze-cli-installer"),Ba="@coze/cli@latest",vx="coze",za="0.1.7",bx=5e3,Sx=5e3,Ix=9e4,Fa=1e4,In=null,wr=!1;async function Ui(n,e={}){if(wr)return;if(In)return In;let i=e.exec??Ex;return In=(async()=>{try{let o=await Cx(vx,i),a=!1;if(o){let f=await Ax(i);if(f===void 0)Ye.warn("coze-cli found but version unparseable, fall through to full install",{path:o});else if(mr(f,za))Ye.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:o,version:f,min:za}),a=!0;else{Ye.info("coze-cli already on PATH with sufficient version, skip",{path:o,version:f}),wr=!0;return}}let c=a?"upgrade-only":"full";Ye.info("coze-cli install start",{package:Ba,mode:c});try{await i("npm",["i","-g","--prefer-online",Ba],{timeout:Ix,maxBuffer:10*1024*1024}),Ye.info("coze-cli install ok")}catch(f){Ye.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(a){wr=!0;return}if(n.env)try{await i("coze",["config","set","xTTEnv",n.env],{timeout:Fa}),Ye.info("coze config set xTTEnv ok",{env:n.env})}catch(f){Ye.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await i("coze",["auth","login","--token",n.patToken],{timeout:Fa}),Ye.info("coze auth login ok")}catch(f){Ye.warn("coze auth login failed",{err:String(f)});return}wr=!0}finally{In=null}})(),In}async function Cx(n,e){let i=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(i,[n],{timeout:bx});return o.split(`
|
|
120
|
+
`)[0]?.trim()||void 0}catch{return}}async function Ax(n){try{let{stdout:e,stderr:i}=await n("coze",["--version"],{timeout:Sx});return(e||i).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Y();import{spawn as Tx}from"node:child_process";import{constants as Ua,access as Dx}from"node:fs/promises";import{delimiter as Px,join as kx}from"node:path";var Ha=H("framework-detector"),qa={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Rx=[".exe",".cmd",".bat",".ps1"],Qt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Tx,access:e.access??Dx}}async detect(e){let i=qa[e],o=await this.which(i);if(!o)return Ha.debug("framework binary not found",{framework:e,bin:i}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[c,f]=await Promise.all([this.probeVersion(o,a),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),x={path:o,version:c};return f&&(x.defaultAgent=f),x}async detectAll(){let e=await Promise.all(Object.keys(qa).map(async o=>[o,await this.detect(o)])),i={};for(let[o,a]of e)a&&(i[o]=a);return i}async which(e){let i=this.env.pathEnv.split(Px).filter(Boolean),o=this.env.platform==="win32"?["",...Rx]:[""];for(let a of i)for(let c of o){let f=kx(a,e+c);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let i=this.env.platform==="win32"?Ua.F_OK:Ua.X_OK;return await this.env.access(e,i),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let i=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!i||i.code!==0)return null;let o=i.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!o)return null;try{let a=JSON.parse(o[0]);if(!Array.isArray(a))return null;let c=a.find(f=>f?.isDefault===!0);return!c?.id||!c.workspace?null:{id:c.id,workspace:c.workspace}}catch(a){return Ha.warn("openclaw agents list --json parse failed",{err:String(a)}),null}}async probeVersion(e,i=[]){let o=await this.runProbe(e,[...i,"--version"]);return o&&(Nx(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,i){return new Promise(o=>{let a="",c=!1,f,x=l=>{c||(c=!0,f&&clearTimeout(f),o(l))};try{let l=this.env.spawn(e,i,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{l.kill("SIGKILL"),x(null)},5e3),l.stdout?.on("data",h=>{a+=h.toString("utf8")}),l.on("error",()=>x(null)),l.on("close",h=>x({code:h,stdout:a}))}catch{x(null)}})}},Lx=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Nx(n){return n.replace(Lx,"")}en();import{randomBytes as Qx}from"node:crypto";import{createReadStream as Mx}from"node:fs";import{mkdir as Bx,readFile as zx,realpath as Fx,stat as Ux,writeFile as Hx}from"node:fs/promises";import{basename as qx,dirname as Hi,join as Gx,relative as jx,resolve as ja,sep as Wx}from"node:path";import{createInterface as Kx}from"node:readline";Y();var Ka=H("fs-rpc"),Cn=wt("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function $a(n,e){let i=Buffer.byteLength(n.content,"utf8");if(i>Cn)throw new A("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${i} bytes > limit ${Cn} bytes`);let o=await Va(n.path,e);return await Bx(Hi(o),{recursive:!0}),await Hx(o,n.content,"utf8"),Ka.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function Ja(n,e){let i=await Va(n.path,e),o=await Ux(i),a=typeof n.line=="number"||typeof n.limit=="number";if(o.size>Cn&&!a)throw new A("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${Cn} bytes`);let c;if(a&&o.size>Cn)c=await $x(i,n.line??1,n.limit);else{let f=await zx(i,"utf8");if(a){let x=f.split(`
|
|
121
|
+
`),l=Math.max(0,(n.line??1)-1),h=typeof n.limit=="number"?l+n.limit:void 0;c=x.slice(l,h).join(`
|
|
122
|
+
`)}else c=f}return Ka.info("fs/read_text_file ok",{path:i,size:c.length}),{content:c}}async function $x(n,e,i){let o=Kx({input:Mx(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),c=typeof i=="number"?a+i:Number.POSITIVE_INFINITY,f=[],x=0;try{for await(let l of o)if(x>=a&&x<c&&f.push(l),x++,x>=c)break}finally{o.close()}return f.join(`
|
|
123
|
+
`)}async function Va(n,e){if(typeof n!="string"||n.length===0)throw new A("IPC_BAD_REQUEST","path must be a non-empty string");let[i,o]=await Promise.all([Wa(ja(e)),Wa(ja(n))]),a=jx(i,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${Wx}`))throw new A("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Wa(n){let e=[],i=n;for(;i!==Hi(i);)try{let o=await Fx(i);return e.length?Gx(o,...e.reverse()):o}catch{e.push(qx(i)),i=Hi(i)}return n}Y();var Za=H("prompt-multimodal"),Ya=10*1024*1024,Jx=15e3,Vx=6;async function Xa(n){let e=new Array(n.length),i=0;async function o(){for(;i<n.length;){let c=i++,f=n[c];f!==void 0&&(e[c]=await Zx(f))}}let a=Array.from({length:Math.min(Vx,n.length)},()=>o());return await Promise.all(a),e}function Qa(n){return n.some(e=>e.type==="image")}async function Zx(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!nr(e.uri))return n;try{let{buf:i,contentType:o}=await Xx(e.uri),a=e.mimeType||Yx(o)||"application/octet-stream";return Za.info("image uri fetched and inlined",{uri:e.uri,bytes:i.length,mimeType:a}),{type:"image",data:i.toString("base64"),mimeType:a}}catch(i){return Za.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(i)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Yx(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function Xx(n){let e=new AbortController,i=setTimeout(()=>e.abort(),Jx);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let a=await o.arrayBuffer();if(a.byteLength>Ya)throw new Error(`image too large: ${a.byteLength} bytes (max ${Ya})`);return{buf:Buffer.from(a),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(i)}}gt();en();Y();var Z=H("core"),el=3e4,tl=/^(boe|ppe)_[A-Za-z0-9_-]+$/,nl=3e4,rl=new Set(["_agent/create","session/new","session/load","session/prompt"]),_r=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new Zt;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=Ga(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,i){this.extensions[e]=i}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),Z.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){Z.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(i=>i.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),Z.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let i of this.registerHandlers)try{i(e.agentId)}catch(o){Z.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)&&Z.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,i,o){let a=o.downstream;a&&(a.onUpdate(c=>{o.loadingSession||this.forwardUpdate(e,c)}),a.onAgentRequest(c=>{this.handleAgentRequest(e,a,c)}),a.onExit((c,f)=>{Z.info("session runtime exited",{agentId:e.agentId,cloudId:i,code:c,signal:f}),Sn(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(a,"downstream exited")}))}hasPendingPermissionFor(e){for(let i of this.pendingUpstream.values())if(i.downstream===e)return!0;return!1}rejectPendingForDownstream(e,i){let o=[];for(let[a,c]of this.pendingUpstream)c.downstream===e&&o.push(a);if(o.length!==0){Z.info("reject pendingUpstream entries (downstream gone)",{reason:i,count:o.length});for(let a of o){let c=this.pendingUpstream.get(a);if(c){this.pendingUpstream.delete(a),this.upstream.send(mt(a,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${i}`})).catch(f=>Z.debug("send error response to upstream failed (ignored)",{err:String(f)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Q.INTERNAL_ERROR,message:`bridge: ${i}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,i=this.pendingBridge.size;if(!(e===0&&i===0)){Z.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:i});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new A("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(dr(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let i="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&tl.test(o)?this.currentCozeEnv=o:o&&Z.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&rl.has(e.method)){let a=this.upgradeGate.pendingTarget()??"";throw new A("BRIDGE_UPGRADING",`bridge upgrading to ${a}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){i!==null?await this.sendError(i,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):Z.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);i!==null&&await this.upstream.send(Vt(i,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);i!==null&&await this.upstream.send(Vt(i,a));return}if(e.method==="initialize"){i!==null&&await this.upstream.send(Vt(i,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}i!==null?await this.sendError(i,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):Z.warn("drop unknown notification",{method:e.method})}catch(a){Z.error("handleFrame failed",{method:e.method,err:String(a)}),i!==null&&await this.upstream.send(mt(i,bn(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new A("IPC_BAD_REQUEST",`${e.method} requires params`);let i=e.params,o=i._meta?.cozeAgentId;if(!o)throw new A("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(o);if(!a)throw this.disconnectedAgents.has(o)?new A("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new A("AGENT_NOT_FOUND",`agent not found: ${o}`);let c=typeof i.sessionId=="string"?i.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(a,e.method,i);let f=Date.now(),x=!1,l=e.method==="session/prompt";l&&this.upgradeGate?.incActive();try{let h=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,i));return x=!0,h}finally{l&&this.upgradeGate?.decActive(),Z.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-f,ok:x})}}async dispatchSessionCall(e,i,o){e.lastActiveAt=Date.now();let{stripped:a}=$o(o);switch(i){case"session/new":{let c=il();return Z.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return Z.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,f=c.sessionId;if(!f)throw new A("IPC_BAD_REQUEST","session/prompt: missing sessionId");let x=await this.ensureRuntime(e,f);if(x.replySeq=0,await this.ensureDownstream(e,f,x),!x.downstream||!x.acpSessionId)throw new A("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let l=o._meta?.cozeTriggerMsgId;l?e.activeTriggers.set(x.acpSessionId,l):e.activeTriggers.delete(x.acpSessionId);let h=Ko(o._meta);if(h?e.activeGroupIds.set(x.acpSessionId,h):e.activeGroupIds.delete(x.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Qa(c.prompt))throw new A("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let y=await Xa(c.prompt);try{let v=await x.downstream.sessionPrompt({...c,sessionId:x.acpSessionId,prompt:y});return x.lastActiveAt=Date.now(),v}finally{if(e.activeTriggers.delete(x.acpSessionId),e.activeGroupIds.delete(x.acpSessionId),x.reloadAfterTurn){x.reloadAfterTurn=!1;let v=x.downstream;v&&(x.downstream=void 0,Z.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:x.acpSessionId}),v.stop("reload-after-turn").catch(k=>Z.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:f,err:String(k)})))}else x.downstream?.isAlive()&&this.armIdleTimer(e,f,x)}}case"session/cancel":{let f=a.sessionId;if(!f)throw new A("IPC_BAD_REQUEST","session/cancel: missing sessionId");let x=e.sessions.get(f);if(e.hasSessionQueue(f)){let l=e.getSessionQueue(f);l.size>0&&(Z.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:l.size}),l.dispose(new A("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${f}`)))}return x?.downstream?.isAlive()&&x.acpSessionId&&await x.downstream.sessionCancel({sessionId:x.acpSessionId}),{ok:!0}}default:throw new A("IPC_BAD_REQUEST",`session method not supported: ${i}`)}}async ensureRuntime(e,i){let o=e.sessions.get(i);if(o)return o;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,i):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(i,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,i){let o={sessionId:i,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(Ke.GEN_MODEL_TOKEN,o,nl);if(!a?.modelToken)throw new A("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${i})`);return a.modelToken}catch(a){throw a instanceof A&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new A("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,i,o){if(Sn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new A("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,f=o.spawnFailCount??0,x=o.spawnFailedAt??0;if(f>=a&&Date.now()-x<c)throw new A("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${i} spawn failed ${f} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-x))/1e3)}s`);let l;try{l=await this.sessionSpawner(e,o.modelToken,i,this.currentCozeEnv)}catch(h){throw o.spawnFailCount=f+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=a&&o.acpSessionId&&(Z.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:i,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),h}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=l,this.attachRuntimeHooks(e,i,o),o.acpSessionId){o.loadingSession=!0;try{await l.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),Z.info("session restored via session/load",{agentId:e.agentId,cloudId:i,acpId:o.acpSessionId})}catch(h){Z.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:i,acpId:o.acpSessionId,err:String(h)}),o.acpSessionId=void 0;let y=await l.sessionNew({cwd:e.workspace});o.acpSessionId=y.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let h=await l.sessionNew({cwd:e.workspace});o.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}l.afterSessionEstablished&&o.acpSessionId&&await l.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,i,o){if(Sn(o),this.isRuntimeBusy(e,o)){Z.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:i});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){Z.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:i}),this.armIdleTimer(e,i,o);return}Z.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:i});let a=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),a&&a.stop("idle timeout").catch(c=>Z.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:i,err:String(c)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,i){if(i.acpSessionId&&e.activeTriggers.has(i.acpSessionId))return!0;let o=i.downstream;if(!o)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,i,o,a){let c={cozeAgentId:e.agentId,cozeReplySeqID:++i.replySeq};if(i.acpSessionId){let f=e.activeTriggers.get(i.acpSessionId);f&&(c.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i.acpSessionId);x&&(c.cozeGroupId=x)}await this.upstream.send(En("session/update",{sessionId:o,update:a,_meta:c}))}forwardUpdate(e,i){let o=i.sessionId,a=this.reverseSessionId(e,o);if(!a){Z.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let c=e.sessions.get(a);if(!c){Z.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(ol(i)){Z.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},x=e.activeTriggers.get(o);x&&(f.cozeTriggerMsgId=x);let l=e.activeGroupIds.get(o);l&&(f.cozeGroupId=l),this.upstream.send(En("session/update",{...i,sessionId:a,_meta:f})).catch(h=>Z.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}handleAgentRequest(e,i,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,i,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,i,o);return}Z.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),i.respondAgentRequestError(o.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,i,o){try{let a=e.workspace;if(o.method==="fs/write_text_file"){let c=o.params??{},f=await $a(c,a);i.respondAgentRequest(o.id,f)}else{let c=o.params??{},f=await Ja(c,a);i.respondAgentRequest(o.id,f)}}catch(a){Z.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(a)}),i.respondAgentRequestError(o.id,bn(a))}}forwardPermissionRequest(e,i,o){let a=this.upstreamIds.next("session/request_permission"),c=o.params??{},x=c.sessionId,l=x?e.activeTriggers.get(x):void 0,h={cozeAgentId:e.agentId};l&&(h.cozeTriggerMsgId=l);let y=x?e.activeGroupIds.get(x):void 0;y&&(h.cozeGroupId=y);let v=x?this.reverseSessionId(e,x):void 0,k={...c,...v?{sessionId:v}:{},_meta:h};this.pendingUpstream.set(a,{agentRequestId:o.id,agentId:e.agentId,downstream:i,method:o.method}),Z.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:x,cloudSessionId:v,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(w=>({optionId:w.optionId,kind:w.kind,name:w.name}))}),this.upstream.send(yn(a,"session/request_permission",k)).catch(w=>{this.pendingUpstream.delete(a),Z.error("forward permission request failed",{agentId:e.agentId,err:String(w)}),i.respondAgentRequestError(o.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(w)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let i=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(i){this.pendingUpstream.delete(i.key);let a=i.value;e.error?(Z.info("upstream \u2192 permission response (error)",{agentId:a.agentId,upstreamId:e.id,method:a.method,error:e.error}),a.downstream.respondAgentRequestError(a.agentRequestId,e.error)):(a.method==="session/request_permission"&&sl(e.result,a),Z.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.agentRequestId,e.result));return}let o=this.lookupPending(this.pendingBridge,e.id,"bridge");if(o){this.pendingBridge.delete(o.key),clearTimeout(o.value.timer),e.error?o.value.reject(new cr(e.error)):o.value.resolve(e.result);return}Z.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,i,o){let a=e.get(i);if(a)return{value:a,key:i};if(typeof i=="number"){let c=String(i),f=e.get(c);if(f)return Z.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:i,normalizedId:c}),{value:f,key:c}}}sendRequest(e,i,o=el){let a=this.upstreamIds.next(e);return new Promise((c,f)=>{let x=setTimeout(()=>{this.pendingBridge.delete(a),f(new A("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(a,{method:e,resolve:c,reject:f,timer:x}),this.upstream.send(yn(a,e,i)).catch(l=>{let h=this.pendingBridge.get(a);h&&(clearTimeout(h.timer),this.pendingBridge.delete(a)),f(l)})})}async persistSessionMapping(e){if(this.paths)try{let i=new Map;for(let[o,a]of e.sessions){let c={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(c.acpSessionId=a.acpSessionId),i.set(o,c)}await hi(e.agentId,i,this.paths)}catch(i){Z.warn("persist session mapping failed",{agentId:e.agentId,err:String(i)})}}reverseSessionId(e,i){for(let[o,a]of e.sessions.entries())if(a.acpSessionId===i)return o}sendError(e,i,o){return this.upstream.send(mt(e,{code:i,message:o,data:{bridgeVersion:ht}}))}};function il(){return Qx(16).toString("hex")}function sl(n,e){if(!n||typeof n!="object"){Z.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let i=n;if("kind"in i&&!("outcome"in i)){Z.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=i.outcome;if(!o||typeof o!="object"){Z.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let c=o.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&Z.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:n})}function ol(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let i=e.content;if(!i||typeof i!="object")return!1;let o=i;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}Y();ye();import{randomBytes as al}from"node:crypto";import{chmod as cl,mkdir as dl,writeFile as ec}from"node:fs/promises";import{createServer as fl}from"node:http";import{dirname as ul}from"node:path";var xl=1e6,qi=H("ipc"),yr=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(i=>[`${i.method} ${i.path}`,i])),this.paths=e.paths??X()}async start(){this.token=al(32).toString("hex");let e=fl((o,a)=>{this.dispatch(o,a)});this.server=e,await new Promise((o,a)=>{e.once("error",a),e.listen(0,"127.0.0.1",()=>o())});let i=e.address();if(!i||typeof i!="object")throw new Error("failed to obtain IPC port");return this.port=i.port,await this.persistAuthFiles(),qi.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((i,o)=>{e.close(a=>a?o(a):i())}),this.server=null)}async persistAuthFiles(){await dl(ul(this.paths.portFile),{recursive:!0}),await ec(this.paths.portFile,String(this.port),"utf8"),await ec(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await cl(this.paths.tokenFile,384)}catch(e){qi.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,i){if(e.headers.authorization!==`Bearer ${this.token}`){An(i,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(a);if(!c){An(i,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await ll(e)}catch(x){An(i,400,{error:"invalid json",detail:String(x)});return}try{let x=await c.handler(f,e);An(i,200,x??{ok:!0})}catch(x){qi.error("IPC handler failed",{key:a,err:String(x)}),An(i,500,{error:x instanceof Error?x.message:String(x)})}}};function An(n,e,i){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(i))}async function ll(n){let e=[],i=0;for await(let a of n){let c=a;if(i+=c.length,i>xl)throw new Error("body too large");e.push(c)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as tc}from"node:path";import{fileURLToPath as gl}from"node:url";function nc(){return pl(gl(import.meta.url))}function pl(n){let e=`${tc}src${tc}`;return n.includes(e)}Y();ye();import{spawn as hl}from"node:child_process";import{existsSync as ml,mkdirSync as wl,openSync as _l}from"node:fs";import{dirname as yl}from"node:path";import{fileURLToPath as El}from"node:url";var vl=H("spawn-helper");function bl(n){return ml(n.libEntry)?n.libEntry:El(new URL("../index.ts",import.meta.url))}function Sl(n,e,i){let o=n.endsWith(".ts"),a=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${i}`];return o?["--import","tsx/esm",n,...a]:[n,...a]}async function rc(n,e,i={}){let o=i.paths??X(),a=bl(o);wl(yl(o.logFile),{recursive:!0});let c=_l(o.logFile,"a"),f=Sl(a,n,e),x=hl(process.execPath,f,{detached:!0,stdio:["ignore",c,c],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(x.unref(),typeof x.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");vl.info("upgrade helper spawned",{pid:x.pid,targetVersion:n,oldPid:e,entry:a})}Y();import{mkdir as Il,writeFile as Cl}from"node:fs/promises";import{dirname as Al}from"node:path";import{gunzipSync as Tl}from"node:zlib";var Gi=H("tarball-downloader"),Dl="https://registry.npmjs.org",ic="package/dist/index.js";async function sc(n,e,i={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let a=`${(i.registry??Dl).replace(/\/+$/,"")}/coze-bridge/${n}`;Gi.info("fetching tarball metadata",{metaUrl:a});let c=await fetch(a);if(!c.ok)throw new Error(`registry metadata ${a} returned ${c.status}`);let x=(await c.json())?.dist?.tarball;if(!x)throw new Error(`registry metadata missing dist.tarball for ${n}`);Gi.info("downloading tarball",{tarballUrl:x});let l=await fetch(x);if(!l.ok)throw new Error(`tarball ${x} returned ${l.status}`);let h=Buffer.from(await l.arrayBuffer()),y=Tl(h),v=Pl(y,ic);if(!v)throw new Error(`tarball missing entry ${ic}`);await Il(Al(e),{recursive:!0}),await Cl(e,v),Gi.info("dist extracted",{destPath:e,bytes:v.length})}function Pl(n,e){let i=0;for(;i+512<=n.length;){let o=n.subarray(i,i+512);if(o.every(y=>y===0))return null;let a=o.subarray(0,100),c=a.indexOf(0),f=a.subarray(0,c===-1?100:c).toString("utf8"),x=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),l=Number.parseInt(x,8)||0,h=i+512;if(f===e)return n.subarray(h,h+l);i=h+Math.ceil(l/512)*512}return null}en();Y();import{resolve as kl}from"node:path";var At=H("upgrade-manager"),Rl=300*1e3,Ll=3,Er=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){At.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let i=await _t(this.opts.paths.configFile)??{};if(i.disableAutoUpgrade){At.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){At.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!mr(this.opts.currentVersion,e)){At.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=i.upgradeAttempts?.[e];if((o?.count??0)>=Ll){At.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let a=kl(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,a)}catch(f){await this.recordAttempt(i,e,String(f)),At.warn("download failed, attempt recorded",{targetVersion:e,err:String(f)});return}this.opts.daemon.markUpgradePending(e);let c=await this.opts.daemon.waitIdle(Rl);At.info("waitIdle done",{result:c}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,i,o){e.upgradeAttempts=e.upgradeAttempts??{};let a=e.upgradeAttempts[i];e.upgradeAttempts[i]={count:(a?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await Xe(e,this.opts.paths.configFile)}};var A0=We(hc(),1);var lp=We(u0(),1),gp=We(Br(),1),pp=We(rn(),1),hp=We(ns(),1),mp=We(ss(),1),wp=We(us(),1),y0=We(Hr(),1),_p=We(_0(),1);var E0=y0.default;Y();var Ce=H("upstream.frontier"),b0="application/json",S0="none",Ep=15e3,Mn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){Ce.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Zo,...Jt(this.opts.ppeOverride)};class i extends E0{constructor(E){super(E,Vo,{headers:e})}send(E,...S){if(Zs("debug"))try{let I;typeof E=="string"?I=Buffer.from(E,"utf8"):E instanceof Buffer?I=E:E instanceof ArrayBuffer?I=new Uint8Array(E):ArrayBuffer.isView(E)?I=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):I=new Uint8Array(0);let D=Buffer.from(I.slice(0,128)).toString("hex");Ce.debug("WS raw frame out",{bytes:I.byteLength,headHex:D})}catch(I){Ce.warn("WS raw frame dump failed",{err:String(I)})}super.send(E,...S)}}let o=Xo(this.opts.urlOverride),a={url:o,ws:i,fpID:Jo,aID:ir,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:b0,force:!0},payloadEncoding:{encoding:S0,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new A0.FWS(a),f=!1,x=null,l,h,y=new Promise((w,E)=>{l=w,h=E}),v=w=>{f||(f=!0,x&&(clearTimeout(x),x=null),w?h(w):l())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let w=this.openCount===1;Ce.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:w,openCount:this.openCount}),w&&v();for(let E of this.connectHandlers)Promise.resolve(E({initial:w})).catch(S=>Ce.warn("onConnect handler threw (ignored)",{err:String(S)}))},c.onclose=w=>{this.opened=!1,Ce.info("frontier closed",{code:w.code,reason:w.reason,willReconnect:w.willReconnect})},c.onerror=w=>{Ce.warn("frontier error",{code:w.code,msg:w.message}),v(new A("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${w.code} msg=${w.message??""}`))},c.onmessage=w=>this.handleMessage(w),this.fws=c;let k=this.opts.openTimeoutMs??Ep;x=setTimeout(()=>{v(new A("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${k}ms (handshake or upgrade slow)`))},k),await c.connect();try{await y}catch(w){try{c.close(1e3,"open failed")}catch(E){Ce.warn("fws close during start failure threw (ignored)",{err:String(E)})}throw this.fws=null,this.opened=!1,w}}async stop(e){let i=this.fws;if(i){this.fws=null,this.opened=!1;try{i.close(1e3,e??"bridge shutdown")}catch(o){Ce.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let i=this.fws;if(!i)throw new A("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new A("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${i.readyState}); refusing to silently buffer`);this.injectAgentPatToken(e);let o=JSON.stringify(e),a=e;I0(a)||Ce.info("frontier frame out",{method:a.method,jsonrpcId:a.id,size:o.length});try{await i.send(o,{service:33555712,method:1,payloadType:b0,payloadEncoding:S0})}catch(f){throw Ce.warn("frontier frame send failed",{method:a.method,jsonrpcId:a.id,err:String(f)}),new A("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let i=this.opts.getPatTokenForAgent;if(!i)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let a=i(o.cozeAgentId);a&&(o.cozePatToken=a)}handleMessage(e){let i=e.message?.service;if(i!==33555712){Ce.debug("drop non-adapter frontier frame",{service:i});return}let o=Sp(e);if(!o){Ce.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ce.debug("frame received but no onFrame handler",{size:o.length});return}let a;try{a=JSON.parse(o)}catch(f){Ce.warn("frontier message JSON parse failed",{err:String(f),head:o.slice(0,80)});return}let c=a;I0(c)||Ce.info("frontier frame in",{logid:bp(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:vp(o)}),Promise.resolve(this.handler(a)).catch(f=>Ce.warn("frontier frame handler threw",{err:String(f)}))}};function I0(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var C0=2e3;function vp(n){return n.length<=C0?n:`${n.slice(0,C0)}...<truncated, total ${n.length} chars>`}function bp(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Sp(n){let e=n.message;if(e?.textPayload)return e.textPayload;let i=e?.payload;if(!i)return null;try{return Buffer.from(i).toString("utf8")}catch{return null}}Y();var ls=H("upstream.switchable"),Gr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,i){if(this.inner===e)return;ls.info("swap upstream",{reason:i});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw ls.error("swap target start failed, reverting",{err:String(a)}),this.inner=o,a}await o.stop(i??"swapped").catch(a=>ls.warn("previous upstream stop threw (ignored)",{err:String(a)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};Y();var gs=H("upstream"),fn=class{handler=null;async start(){gs.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){gs.info("NoopUpstream stopped",{reason:e})}async send(e){gs.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)}};Y();Y();ye();import{promises as ps}from"node:fs";import{dirname as Ip}from"node:path";var Cp=H("pat-token-store");async function T0(n=X()){try{let i=(await ps.readFile(n.patTokenFile,"utf8")).trim();return i.length>0?i:null}catch(e){return e?.code!=="ENOENT"&&Cp.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function Bn(n,e=X()){if(!n)throw new Error("writePatToken: empty patToken");await ps.mkdir(Ip(e.patTokenFile),{recursive:!0}),await ps.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ye();ye();import{promises as jr}from"node:fs";import{join as Ap}from"node:path";function Tp(n){return`#!/bin/sh
|
|
124
124
|
exec node ${JSON.stringify(n)} "$@"
|
|
125
|
-
`}function
|
|
125
|
+
`}function Dp(n){return`@echo off
|
|
126
126
|
node ${JSON.stringify(n)} %*
|
|
127
|
-
`}async function bc(n,e=G()){let s=e.binDir;await br.mkdir(s,{recursive:!0});let o=eg(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.platform==="win32"?ng(n):tg(n);return await br.readFile(o,"utf8").catch(()=>null)===a||(await br.writeFile(o,a,"utf8"),process.platform!=="win32"&&await br.chmod(o,493)),s}q();oe();import{execSync as Sc}from"node:child_process";import{readFileSync as Ec,unlinkSync as rg}from"node:fs";import{mkdir as ig,readFile as Ac,unlink as Ic,writeFile as sg}from"node:fs/promises";import{dirname as og}from"node:path";function vc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var ag=D("single-instance"),vr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??G().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&&(ag.warn("removing stale pid file",{stalePid:e}),await Ic(this.pidFile).catch(()=>{})),await ig(og(this.pidFile),{recursive:!0}),await sg(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ac(this.pidFile,"utf8")).trim()===String(process.pid)&&await Ic(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ac(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 vc(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=Ec(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=Sc(`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=Sc(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let a=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return a.includes("node")||a.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{Ec(this.pidFile,"utf8").trim()===String(process.pid)&&rg(this.pidFile)}catch{}})}};function cg(){let n=0,e=null;return{incActive(){n++},decActive(){n>0&&n--},activeCount(){return n},markUpgradePending(s){e=s},isUpgrading(){return e!==null},pendingTarget(){return e},async waitIdle(s){let o=Date.now()+s;for(;Date.now()<o;){if(n===0)return"idle";await new Promise(a=>setTimeout(a,200))}return n===0?"idle":"timeout"}}}var N=D("daemon"),xg="coze-bridge-daemon";async function Pc(){let n=new vr({processTitle:xg}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await ct(),o=s??{};Sn({pid:process.pid}),N.info(s?"loaded bridge config":"initialized bridge config");try{let T=new Mt;o.frameworksCache=await T.detectAll(),N.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(T){N.warn("framework detection failed",{err:String(T)})}await Ue(o);let a=new yr(new Wt),d=G(),u=cg(),f=null,p=new Xn({upstream:a,paths:d,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(T,O,F,ye)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(T,O,F,ye)}});await ug(d,p);let h=new $n({paths:d,config:o,registry:p});f=h;let y,w,A=null,I={},E,k=null,L=null;p.registerExtension("_agent/create",async T=>h.createAgent(T.params)),p.registerExtension("_agent/health",async()=>({ok:!0}));let $={},H=new Bn({agents:p.agents,disposeAndMarkDisconnected:async(T,O)=>{let F=p.agents.get(T);if(F){await h.cleanupOpenclawSessionProviders(F).catch(te=>N.warn("cleanup openclaw providers failed (ignored)",{agentId:T,err:String(te)}));let ye=!0;try{await F.dispose(`disconnect: ${O}`)}catch(te){ye=!1,N.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:T,err:String(te)}),F.status="error"}ye&&(F.status="disconnected",p.unregister(T),p.disconnectedAgents.add(T))}else p.disconnectedAgents.add(T)},detailSyncer:async T=>{if(!$.ref)throw new Error("agent-detail-sync not initialized yet");await $.ref.syncOne(T)},cleanupOpenclawProviders:async T=>{await h.cleanupOpenclawSessionProviders(T)},openclawRepair:async(T,O)=>{await h.openclawRepair(T,O)},isRuntimePendingPermission:T=>p.hasPendingPermissionFor(T)});p.registerExtension("_agent/listSkills",T=>H.listSkills(T.params)),p.registerExtension("_agent/addSkills",T=>H.addSkills(T.params)),p.registerExtension("_agent/removeSkills",T=>H.removeSkills(T.params)),p.registerExtension("_agent/getFileTree",T=>H.getFileTree(T.params)),p.registerExtension("_agent/getFileContent",T=>H.getFileContent(T.params)),p.registerExtension("_agent/update",T=>H.updateAgent(T.params)),p.registerExtension("_agent/disconnect",T=>H.disconnectAgent(T.params)),p.registerExtension("_agent/switchModel",T=>H.switchModel(T.params)),p.registerExtension("_agent/reset",T=>H.resetAgent(T.params)),p.registerExtension("_agent/repair",T=>H.repairAgent(T.params));let ae=new Rn({paths:d,handlers:H,sendDetail:T=>p.sendRequest("_agent/detail",T)});$.ref=ae;let W=async T=>{await Promise.allSettled(T.map(async O=>{try{await H.disconnectAgent({agentId:O.agentId,reason:`auth_failure: code=${O.code} ${O.message}`}),N.info("agent disconnected due to auth failure from heartbeat response",{agentId:O.agentId,code:O.code,message:O.message})}catch(F){N.warn("disconnect during authFailure handling failed (ignored)",{agentId:O.agentId,err:String(F)})}}))};a.onConnect(({initial:T})=>{N.info("frontier upstream connected, triggering detail sync",{initial:T}),ae.syncAll(T?"initial-connect":"reconnect").catch(O=>N.warn("detail sync top-level error (ignored)",{err:String(O)}))});let ge=new Yn({paths:d,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...p.agents.keys()],deviceId:A??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async T=>{let O=T,F=O?.privatecode,ye=O?.pairing_code;if(!F||!ye)throw new b("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let te=Yt(O.env),pe=O.handshake_url,Ke=O.frontier_url,ie=Tc(O.env,pe,Ke),Qe=!!y&&y!==F,Q=w!==void 0&&w!==ie,X=Qe||Q,ut=await Xr({privatecode:F,...pe?{endpoint:pe}:{},ppeOverride:te});if(X){N.warn("pair config switched, resetting agents",{pcChanged:Qe,envChanged:Q,previousPc:y?Sr(y):"",nextPc:Sr(F),previousEnvKey:w??"",nextEnvKey:ie});for(let se of[...p.agents.values()])await se.dispose("pair config switch").catch(()=>{}),p.agents.delete(se.agentId);p.disconnectedAgents.size>0&&(N.info("clearing disconnectedAgents set on pair config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await a.swap(new Wt,"pair switch").catch(()=>{})}A=ut.deviceId,Sn({deviceId:A,pid:process.pid}),ci({patToken:F,env:O.env}).catch(se=>N.warn("coze-cli setup error (ignored)",{err:String(se)}));let J=new mn({handshake:ut,privatecode:F,...Ke?{urlOverride:Ke}:{},ppeOverride:te,getPatTokenForAgent:se=>p.agents.get(se)?.patToken});await a.swap(J,"pair");try{let se=new Mt;o.frameworksCache=await se.detectAll(),await Ue(o),N.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(se){N.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(se)})}let _t=Object.keys(o.frameworksCache??{});try{let se=await p.sendRequest("_agent/pair",{pairCode:ye,patToken:F,frameworks:_t,_meta:{cozeDeviceId:A}});N.info("_agent/pair ok",{pairResult:se}),y=F,w=ie,I=te,E=pe,wn(F,d).catch(be=>N.warn("writePatToken after /pair failed (ignored)",{err:String(be)})),k||(k=new Qt({core:p,getDeviceId:()=>A??"",onTickEnd:()=>ae.retryPending().catch(be=>N.warn("detailSync.retryPending failed (ignored)",{err:String(be)})),onAuthFailures:W,onMinBridgeVersion:be=>L?.requestUpgrade(be)})),k.start(),X&&Er(d,h).catch(be=>N.warn("post-pair-switch auto-revive error (ignored)",{err:String(be)}));let yt;return O.agent_id&&(yt=await fg(O.agent_id,d,h,be=>p.sendRequest("_agent/detail",be),F).catch(be=>(N.error("--agent-id ensureAgent failed",{agentId:O.agent_id,err:String(be)}),{ok:!1,agentId:O.agent_id??"",note:String(be)}))),{ok:!0,note:"paired with cloud",...yt?{agent:yt}:{}}}catch(se){return N.error("_agent/pair failed",{err:String(se)}),{ok:!1,note:`pair failed: ${String(se)}`}}}},{method:"POST",path:"/connect",handler:async T=>{let O=T,F=O?.privatecode;if(!F)throw new b("IPC_BAD_REQUEST","/connect requires privatecode");let ye=Yt(O.env),te=O.handshake_url,pe=O.frontier_url,Ke=Tc(O.env,te,pe);if(y===F&&w===Ke){let J=await dg(d);return p.agents.size===0&&J?(N.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Er(d,h).catch(_t=>N.warn("connect-noop auto-revive error (ignored)",{err:String(_t)}))):N.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ie=!!y&&y!==F,Qe=w!==void 0&&w!==Ke,Q=ie||Qe,X=await Xr({privatecode:F,...te?{endpoint:te}:{},ppeOverride:ye});if(Q){N.warn("connect config switched, resetting agents",{pcChanged:ie,envChanged:Qe,previousPc:y?Sr(y):"",nextPc:Sr(F)});for(let J of[...p.agents.values()])await J.dispose("connect config switch").catch(()=>{}),p.agents.delete(J.agentId);p.disconnectedAgents.size>0&&(N.info("clearing disconnectedAgents set on connect config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await a.swap(new Wt,"connect switch").catch(()=>{})}A=X.deviceId,Sn({deviceId:A,pid:process.pid}),ci({patToken:F,env:O.env}).catch(J=>N.warn("coze-cli setup error (ignored)",{err:String(J)}));let ut=new mn({handshake:X,privatecode:F,...pe?{urlOverride:pe}:{},ppeOverride:ye,getPatTokenForAgent:J=>p.agents.get(J)?.patToken});return await a.swap(ut,"connect"),y=F,w=Ke,I=ye,E=te,k||(k=new Qt({core:p,getDeviceId:()=>A??"",onTickEnd:()=>ae.retryPending().catch(J=>N.warn("detailSync.retryPending failed (ignored)",{err:String(J)})),onAuthFailures:W,onMinBridgeVersion:J=>L?.requestUpgrade(J)})),k.start(),Q&&Er(d,h).catch(J=>N.warn("post-connect-switch auto-revive error (ignored)",{err:String(J)})),wn(F,d).catch(J=>N.warn("writePatToken after /connect failed (ignored)",{err:String(J)})),N.info("/connect: WS established",{deviceId:A}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async T=>{let O=T;return{ok:!0,result:await h.createAgent(O)}}},{method:"POST",path:"/agent/send",handler:async T=>{let O=T;if(!O?.agentId||!O?.sessionId||!O?.kind||!O?.path)throw new b("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!y)throw new b("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let F=O;return await(F.groupFile?Po:To)(F,{core:p,patToken:y,handshakeBase:E,ppeOverride:I})}catch(F){if(F instanceof b)return{ok:!1,code:F.code,message:F.message};throw F}}},{method:"POST",path:"/refresh",handler:async()=>{N.info("IPC /refresh: re-detecting frameworks");let T=new Mt;return o.frameworksCache=await T.detectAll(),await Ue(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(N.info("IPC /shutdown received"),setImmediate(()=>{we.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:_e,token:ke}=await ge.start();try{await bc(d.libEntry,d)}catch(T){N.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(T)})}await p.start(),Er(d,h).catch(T=>N.warn("auto-revive top-level error (ignored)",{err:String(T)})),As().catch(T=>N.warn("acp wrapper warmup top-level error (ignored)",{err:String(T)}));let de=null,we={port:_e,token:ke,core:p,ipc:ge,shutdown(T){return de||(N.info("daemon shutdown",{reason:T}),de=(async()=>{k?.stop(),await p.stop(T),await ge.stop(),await n.release()})(),de)}};L=new Zn({paths:d,currentVersion:st,isDevMode:Jo,download:(T,O)=>Yo(T,O),spawnHelper:(T,O)=>Vo(T,O,{paths:d}),daemon:{markUpgradePending:T=>{N.warn("upgrade pending, ACP gate engaged",{target:T}),u.markUpgradePending(T)},waitIdle:T=>u.waitIdle(T),exit:T=>{we.shutdown("upgrade").then(()=>process.exit(T))}}});for(let T of["SIGTERM","SIGINT"])process.on(T,()=>{we.shutdown(T).then(()=>process.exit(0))});return N.info("daemon ready",{port:_e,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),we}async function dg(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function Sr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function Tc(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function ug(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:d}=await Promise.resolve().then(()=>(it(),Dn));for(let u of o){await d(u,n).catch(f=>N.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(f)}));try{let f=await a(u,n);f?.disconnectedAt&&(e.disconnectedAgents.add(u),N.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:f.disconnectedAt,reason:f.disconnectReason??""}))}catch(f){N.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(f)})}}}async function fg(n,e,s,o,a){let{loadAgentConfig:d}=await Promise.resolve().then(()=>(it(),Dn)),u=await d(n,e);if(u){N.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}:{},...a?{patToken:a}:{}};return await s.createAgent(y),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}N.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 b("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 p={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await s.createAgent(p);let h=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function Er(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:a}=await Promise.resolve().then(()=>(it(),Dn));N.info("auto-revive: scanning local agents on startup",{count:o.length});let d=0,u=0;for(let f of o){let p;try{p=await a(f,n)}catch(h){N.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(h)}),u+=1;continue}if(!p){u+=1;continue}if(p.disconnectedAt){N.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:p.disconnectedAt}),u+=1;continue}try{N.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:p.framework});let h=lg(p);await e.createAgent({agentId:p.agentId,framework:p.framework,...p.cozeIdentity?{cozeIdentity:p.cozeIdentity}:{},...p.model?{model:p.model}:{},...h?{_meta:h}:{}}),d+=1}catch(h){N.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:p.framework,err:String(h)}),u+=1}}return N.info("auto-revive: done",{revived:d,skipped:u,total:o.length}),{revived:d,skipped:u,total:o.length}}function lg(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Ar();Tr();q();oe();Bt();q();oe();import{copyFile as kc,mkdir as Sg,readFile as Fi,writeFile as Eg}from"node:fs/promises";import{dirname as Ag,resolve as Ui,sep as Pr}from"node:path";import{fileURLToPath as Ig}from"node:url";var Dc=D("dist-install");function Tg(n){let e=Ig(n),s=Ag(e),o=`${Pr}src${Pr}`;if(s.includes(o)||s.endsWith(`${Pr}src${Pr}cli`))return null;let a=Ui(s,"index.js"),d=Ui(s,"..","package.json");return{dist:a,pkgJson:d}}async function qi(n={}){let e=n.paths??G(),s=Tg(import.meta.url),o=n.sourceDist??s?.dist,a=n.sourcePackageJson??s?.pkgJson;if(!o||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let d;try{d=JSON.parse(await Fi(a,"utf8")).version??"unknown"}catch(w){return Dc.warn("cannot read source package.json,skip dist install",{err:String(w)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(w)}`}}let u=await ct(e.configFile)??{},f=u.libVersion;if(f===d)try{return await Fi(e.libEntry),{kind:"already-current",libVersion:d}}catch{}await Sg(e.libDir,{recursive:!0}),await kc(o,e.libEntry),await kc(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let p=Ui(e.libDir,"package.json"),h=`${JSON.stringify({type:"module"},null,2)}
|
|
128
|
-
`;return await
|
|
127
|
+
`}async function D0(n,e=X()){let i=e.binDir;await jr.mkdir(i,{recursive:!0});let o=Ap(i,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.platform==="win32"?Dp(n):Tp(n);return await jr.readFile(o,"utf8").catch(()=>null)===a||(await jr.writeFile(o,a,"utf8"),process.platform!=="win32"&&await jr.chmod(o,493)),i}Y();ye();import{execSync as k0}from"node:child_process";import{readFileSync as R0,unlinkSync as Pp}from"node:fs";import{mkdir as kp,readFile as L0,unlink as N0,writeFile as Rp}from"node:fs/promises";import{dirname as Lp}from"node:path";function P0(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var Np=H("single-instance"),Wr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??X().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&&(Np.warn("removing stale pid file",{stalePid:e}),await N0(this.pidFile).catch(()=>{})),await kp(Lp(this.pidFile),{recursive:!0}),await Rp(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await L0(this.pidFile,"utf8")).trim()===String(process.pid)&&await N0(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await L0(this.pidFile,"utf8"),i=Number.parseInt(e.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return P0(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let i=R0(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(i.includes("coze-bridge-daemon")||i.includes("lib/index.js"))}catch{}try{let i=k0(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return i.trim()?i.includes("coze-bridge-daemon")||i.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=k0(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let a=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return a.includes("node")||a.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{R0(this.pidFile,"utf8").trim()===String(process.pid)&&Pp(this.pidFile)}catch{}})}};function Op(){let n=0,e=null;return{incActive(){n++},decActive(){n>0&&n--},activeCount(){return n},markUpgradePending(i){e=i},isUpgrading(){return e!==null},pendingTarget(){return e},async waitIdle(i){let o=Date.now()+i;for(;Date.now()<o;){if(n===0)return"idle";await new Promise(a=>setTimeout(a,200))}return n===0?"idle":"timeout"}}}var W=H("daemon"),Mp="coze-bridge-daemon";async function M0(){let n=new Wr({processTitle:Mp}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let i=await _t(),o=i??{};qn({pid:process.pid}),W.info(i?"loaded bridge config":"initialized bridge config");try{let L=new Qt;o.frameworksCache=await L.detectAll(),W.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(L){W.warn("framework detection failed",{err:String(L)})}await Xe(o);let a=new Gr(new fn),c=X(),f=Op(),x=null,l=new _r({upstream:a,paths:c,bridgeConfig:o,upgradeGate:f,sessionSpawner:async(L,M,j,ne)=>{if(!x)throw new Error("agentManager not ready");return x.spawnSessionDownstream(L,M,j,ne)}});await zp(c,l);let h=new hr({paths:c,config:o,registry:l});x=h;let y,v,k=null,w={},E,S=null,I=null;l.registerExtension("_agent/create",async L=>h.createAgent(L.params)),l.registerExtension("_agent/health",async()=>({ok:!0}));let D={},R=new or({agents:l.agents,disposeAndMarkDisconnected:async(L,M)=>{let j=l.agents.get(L);if(j){await h.cleanupOpenclawSessionProviders(j).catch(se=>W.warn("cleanup openclaw providers failed (ignored)",{agentId:L,err:String(se)}));let ne=!0;try{await j.dispose(`disconnect: ${M}`)}catch(se){ne=!1,W.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:L,err:String(se)}),j.status="error"}ne&&(j.status="disconnected",l.unregister(L),l.disconnectedAgents.add(L))}else l.disconnectedAgents.add(L)},detailSyncer:async L=>{if(!D.ref)throw new Error("agent-detail-sync not initialized yet");await D.ref.syncOne(L)},cleanupOpenclawProviders:async L=>{await h.cleanupOpenclawSessionProviders(L)},openclawRepair:async(L,M)=>{await h.openclawRepair(L,M)},isRuntimePendingPermission:L=>l.hasPendingPermissionFor(L)});l.registerExtension("_agent/listSkills",L=>R.listSkills(L.params)),l.registerExtension("_agent/addSkills",L=>R.addSkills(L.params)),l.registerExtension("_agent/removeSkills",L=>R.removeSkills(L.params)),l.registerExtension("_agent/getFileTree",L=>R.getFileTree(L.params)),l.registerExtension("_agent/getFileContent",L=>R.getFileContent(L.params)),l.registerExtension("_agent/update",L=>R.updateAgent(L.params)),l.registerExtension("_agent/disconnect",L=>R.disconnectAgent(L.params)),l.registerExtension("_agent/switchModel",L=>R.switchModel(L.params)),l.registerExtension("_agent/reset",L=>R.resetAgent(L.params)),l.registerExtension("_agent/repair",L=>R.repairAgent(L.params));let m=new Yn({paths:c,handlers:R,sendDetail:L=>l.sendRequest("_agent/detail",L)});D.ref=m;let C=async L=>{await Promise.allSettled(L.map(async M=>{try{await R.disconnectAgent({agentId:M.agentId,reason:`auth_failure: code=${M.code} ${M.message}`}),W.info("agent disconnected due to auth failure from heartbeat response",{agentId:M.agentId,code:M.code,message:M.message})}catch(j){W.warn("disconnect during authFailure handling failed (ignored)",{agentId:M.agentId,err:String(j)})}}))};a.onConnect(({initial:L})=>{W.info("frontier upstream connected, triggering detail sync",{initial:L}),m.syncAll(L?"initial-connect":"reconnect").catch(M=>W.warn("detail sync top-level error (ignored)",{err:String(M)}))});let P=new yr({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...l.agents.keys()],deviceId:k??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async L=>{let M=L,j=M?.privatecode,ne=M?.pairing_code;if(!j||!ne)throw new A("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let se=mn(M.env),me=M.handshake_url,ke=M.frontier_url,we=O0(M.env,me,ke),ft=!!y&&y!==j,ge=v!==void 0&&v!==we,ce=ft||ge,vt=await bi({privatecode:j,...me?{endpoint:me}:{},ppeOverride:se});if(ce){W.warn("pair config switched, resetting agents",{pcChanged:ft,envChanged:ge,previousPc:y?Kr(y):"",nextPc:Kr(j),previousEnvKey:v??"",nextEnvKey:we});for(let _e of[...l.agents.values()])await _e.dispose("pair config switch").catch(()=>{}),l.agents.delete(_e.agentId);l.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on pair config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new fn,"pair switch").catch(()=>{})}k=vt.deviceId,qn({deviceId:k,pid:process.pid}),Ui({patToken:j,env:M.env}).catch(_e=>W.warn("coze-cli setup error (ignored)",{err:String(_e)}));let oe=new Mn({handshake:vt,privatecode:j,...ke?{urlOverride:ke}:{},ppeOverride:se,getPatTokenForAgent:_e=>l.agents.get(_e)?.patToken});await a.swap(oe,"pair");try{let _e=new Qt;o.frameworksCache=await _e.detectAll(),await Xe(o),W.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(_e){W.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(_e)})}let Lt=Object.keys(o.frameworksCache??{});try{let _e=await l.sendRequest("_agent/pair",{pairCode:ne,patToken:j,frameworks:Lt,_meta:{cozeDeviceId:k}});W.info("_agent/pair ok",{pairResult:_e}),y=j,v=we,w=se,E=me,Bn(j,c).catch(Pe=>W.warn("writePatToken after /pair failed (ignored)",{err:String(Pe)})),S||(S=new _n({core:l,getDeviceId:()=>k??"",onTickEnd:()=>m.retryPending().catch(Pe=>W.warn("detailSync.retryPending failed (ignored)",{err:String(Pe)})),onAuthFailures:C,onMinBridgeVersion:Pe=>I?.requestUpgrade(Pe)})),S.start(),ce&&$r(c,h).catch(Pe=>W.warn("post-pair-switch auto-revive error (ignored)",{err:String(Pe)}));let Nt;return M.agent_id&&(Nt=await Fp(M.agent_id,c,h,Pe=>l.sendRequest("_agent/detail",Pe),j).catch(Pe=>(W.error("--agent-id ensureAgent failed",{agentId:M.agent_id,err:String(Pe)}),{ok:!1,agentId:M.agent_id??"",note:String(Pe)}))),{ok:!0,note:"paired with cloud",...Nt?{agent:Nt}:{}}}catch(_e){return W.error("_agent/pair failed",{err:String(_e)}),{ok:!1,note:`pair failed: ${String(_e)}`}}}},{method:"POST",path:"/connect",handler:async L=>{let M=L,j=M?.privatecode;if(!j)throw new A("IPC_BAD_REQUEST","/connect requires privatecode");let ne=mn(M.env),se=M.handshake_url,me=M.frontier_url,ke=O0(M.env,se,me);if(y===j&&v===ke){let oe=await Bp(c);return l.agents.size===0&&oe?(W.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),$r(c,h).catch(Lt=>W.warn("connect-noop auto-revive error (ignored)",{err:String(Lt)}))):W.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let we=!!y&&y!==j,ft=v!==void 0&&v!==ke,ge=we||ft,ce=await bi({privatecode:j,...se?{endpoint:se}:{},ppeOverride:ne});if(ge){W.warn("connect config switched, resetting agents",{pcChanged:we,envChanged:ft,previousPc:y?Kr(y):"",nextPc:Kr(j)});for(let oe of[...l.agents.values()])await oe.dispose("connect config switch").catch(()=>{}),l.agents.delete(oe.agentId);l.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on connect config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new fn,"connect switch").catch(()=>{})}k=ce.deviceId,qn({deviceId:k,pid:process.pid}),Ui({patToken:j,env:M.env}).catch(oe=>W.warn("coze-cli setup error (ignored)",{err:String(oe)}));let vt=new Mn({handshake:ce,privatecode:j,...me?{urlOverride:me}:{},ppeOverride:ne,getPatTokenForAgent:oe=>l.agents.get(oe)?.patToken});return await a.swap(vt,"connect"),y=j,v=ke,w=ne,E=se,S||(S=new _n({core:l,getDeviceId:()=>k??"",onTickEnd:()=>m.retryPending().catch(oe=>W.warn("detailSync.retryPending failed (ignored)",{err:String(oe)})),onAuthFailures:C,onMinBridgeVersion:oe=>I?.requestUpgrade(oe)})),S.start(),ge&&$r(c,h).catch(oe=>W.warn("post-connect-switch auto-revive error (ignored)",{err:String(oe)})),Bn(j,c).catch(oe=>W.warn("writePatToken after /connect failed (ignored)",{err:String(oe)})),W.info("/connect: WS established",{deviceId:k}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async L=>{let M=L;return{ok:!0,result:await h.createAgent(M)}}},{method:"POST",path:"/agent/send",handler:async L=>{let M=L;if(!M?.agentId||!M?.sessionId||!M?.kind||!M?.path)throw new A("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!y)throw new A("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let j=M;return await(j.groupFile?Ma:Oa)(j,{core:l,patToken:y,handshakeBase:E,ppeOverride:w})}catch(j){if(j instanceof A)return{ok:!1,code:j.code,message:j.message};throw j}}},{method:"POST",path:"/refresh",handler:async()=>{W.info("IPC /refresh: re-detecting frameworks");let L=new Qt;return o.frameworksCache=await L.detectAll(),await Xe(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(W.info("IPC /shutdown received"),setImmediate(()=>{$.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:F,token:z}=await P.start();try{await D0(c.libEntry,c)}catch(L){W.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(L)})}await l.start(),$r(c,h).catch(L=>W.warn("auto-revive top-level error (ignored)",{err:String(L)})),to().catch(L=>W.warn("acp wrapper warmup top-level error (ignored)",{err:String(L)}));let K=null,$={port:F,token:z,core:l,ipc:P,shutdown(L){return K||(W.info("daemon shutdown",{reason:L}),K=(async()=>{S?.stop(),await l.stop(L),await P.stop(),await n.release()})(),K)}};I=new Er({paths:c,currentVersion:ht,isDevMode:nc,download:(L,M)=>sc(L,M),spawnHelper:(L,M)=>rc(L,M,{paths:c}),daemon:{markUpgradePending:L=>{W.warn("upgrade pending, ACP gate engaged",{target:L}),f.markUpgradePending(L)},waitIdle:L=>f.waitIdle(L),exit:L=>{$.shutdown("upgrade").then(()=>process.exit(L))}}});for(let L of["SIGTERM","SIGINT"])process.on(L,()=>{$.shutdown(L).then(()=>process.exit(0))});return W.info("daemon ready",{port:F,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),$}async function Bp(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function Kr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function O0(n,e,i){return`${n??""}|${e??""}|${i??""}`}async function zp(n,e){let{readdir:i}=await import("node:fs/promises"),o;try{o=await i(n.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:c}=await Promise.resolve().then(()=>(gt(),Zn));for(let f of o){await c(f,n).catch(x=>W.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(x)}));try{let x=await a(f,n);x?.disconnectedAt&&(e.disconnectedAgents.add(f),W.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:x.disconnectedAt,reason:x.disconnectReason??""}))}catch(x){W.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(x)})}}}async function Fp(n,e,i,o,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(gt(),Zn)),f=await c(n,e);if(f){W.info("--agent-id: local config found, reconnecting",{agentId:n,framework:f.framework,hadDisconnect:!!f.disconnectedAt});let y={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{}};return await i.createAgent(y),{ok:!0,agentId:n,note:f.disconnectedAt?"revived from local config":"connected from local config"}}W.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let x=await o({_meta:{cozeAgentId:n}});if(!x.framework)throw new A("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 l={agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...a?{patToken:a}:{},...x.deployType?{_meta:{cozeDeployType:x.deployType}}:{}};await i.createAgent(l);let h=x.deployType==="cloud"&&x.framework==="openclaw";return{ok:!0,agentId:n,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function $r(n,e){let{readdir:i}=await import("node:fs/promises"),o;try{o=await i(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:a}=await Promise.resolve().then(()=>(gt(),Zn));W.info("auto-revive: scanning local agents on startup",{count:o.length});let c=0,f=0;for(let x of o){let l;try{l=await a(x,n)}catch(h){W.warn("auto-revive: load config failed (skipping)",{agentId:x,err:String(h)}),f+=1;continue}if(!l){f+=1;continue}if(l.disconnectedAt){W.info("auto-revive: skip disconnected agent",{agentId:x,disconnectedAt:l.disconnectedAt}),f+=1;continue}try{W.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:x,framework:l.framework});let h=Up(l);await e.createAgent({agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...h?{_meta:h}:{}}),c+=1}catch(h){W.warn("auto-revive: createAgent failed (skipping)",{agentId:x,framework:l.framework,err:String(h)}),f+=1}}return W.info("auto-revive: done",{revived:c,skipped:f,total:o.length}),{revived:c,skipped:f,total:o.length}}function Up(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Jr();Zr();Y();ye();en();Y();ye();import{copyFile as z0,mkdir as Zp,readFile as ms,writeFile as Yp}from"node:fs/promises";import{dirname as Xp,resolve as ws,sep as Yr}from"node:path";import{fileURLToPath as Qp}from"node:url";var F0=H("dist-install");function eh(n){let e=Qp(n),i=Xp(e),o=`${Yr}src${Yr}`;if(i.includes(o)||i.endsWith(`${Yr}src${Yr}cli`))return null;let a=ws(i,"index.js"),c=ws(i,"..","package.json");return{dist:a,pkgJson:c}}async function _s(n={}){let e=n.paths??X(),i=eh(import.meta.url),o=n.sourceDist??i?.dist,a=n.sourcePackageJson??i?.pkgJson;if(!o||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let c;try{c=JSON.parse(await ms(a,"utf8")).version??"unknown"}catch(v){return F0.warn("cannot read source package.json,skip dist install",{err:String(v)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(v)}`}}let f=await _t(e.configFile)??{},x=f.libVersion;if(x===c)try{return await ms(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await Zp(e.libDir,{recursive:!0}),await z0(o,e.libEntry),await z0(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let l=ws(e.libDir,"package.json"),h=`${JSON.stringify({type:"module"},null,2)}
|
|
128
|
+
`;return await ms(l,"utf8").catch(()=>null)!==h&&await Yp(l,h),f.libVersion=c,await Xe(f,e.configFile),F0.info("dist installed",{libEntry:e.libEntry,fromVersion:x,toVersion:c}),x?{kind:"version-changed",fromVersion:x,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}Zr();ye();import{basename as th,resolve as nh}from"node:path";var rh=9e4,ih={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,BRIDGE_UPGRADING:5,NPX_CACHE_CORRUPT:1};function sh(n){return ih[n]??1}async function U0(n,e={}){let i=e.paths??X();if(!n.agentId||!n.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
129
129
|
`),4;if(n.groupFile&&!n.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
|
|
130
|
-
`),3;let o=await
|
|
131
|
-
`),4;let a={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:n.groupFile?n.path:
|
|
132
|
-
`),4}if(!
|
|
133
|
-
`),
|
|
134
|
-
`);else{let
|
|
135
|
-
`)}else process.stdout.write(`Sent ${n.kind} ${
|
|
136
|
-
`)}return 0}async function
|
|
137
|
-
`)}function
|
|
130
|
+
`),3;let o=await Vr(i).catch(()=>null);if(!o)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${i.portFile} / ${i.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
131
|
+
`),4;let a={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:n.groupFile?n.path:nh(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{},...n.groupFile?{groupFile:!0}:{},...n.mimeType?{mimeType:n.mimeType}:{}},c;try{c=await oh(o,"/agent/send",a,rh)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
|
|
132
|
+
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
133
|
+
`),sh(c.code);if(n.json)process.stdout.write(`${JSON.stringify(c)}
|
|
134
|
+
`);else{let f=n.name??th(a.path);if(n.groupFile){let x=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${f} (uri=${x})
|
|
135
|
+
`)}else process.stdout.write(`Sent ${n.kind} ${f} (${ah(c.bytes)})
|
|
136
|
+
`)}return 0}async function oh(n,e,i,o){let a=new AbortController,c=setTimeout(()=>a.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(i),signal:a.signal}),x=await f.text(),l=x?JSON.parse(x):null;return l&&typeof l=="object"&&"ok"in l?l:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${x.slice(0,200)}`}}finally{clearTimeout(c)}}function ah(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var ed=H("cli");function Ae(n,e){let i=[],o;for(let a=0;a<n.length;a++){let c=n[a];if(c===e){o=n[a+1],a+=1;continue}if(c.startsWith(`${e}=`)){o=c.slice(e.length+1);continue}i.push(c)}return{value:o,rest:i}}function Fn(n,e){process.stderr.write(`[deprecated] '${n}' will be removed in a future release, use '${e}' instead
|
|
137
|
+
`)}function Mh(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("--upgrade-helper")){let S=e.filter(C=>C!=="--upgrade-helper"),{value:I,rest:D}=Ae(S,"--target-version"),{value:R}=Ae(D,"--old-pid"),m=R?Number.parseInt(R,10):Number.NaN;return!I||!Number.isFinite(m)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:I,oldPid:m}}if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="refresh")return{mode:"refresh"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return Bh(e.slice(1));if(e[0]==="connect")return zh(e.slice(1));if(e.includes("--status"))return Fn("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return Fn("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return Fn("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return Fn("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return Fn("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let i=e,{value:o,rest:a}=Ae(i,"--pat-token");i=a;let{value:c,rest:f}=Ae(i,"--pair-code");i=f;let{value:x,rest:l}=Ae(i,"--env");i=l;let{value:h,rest:y}=Ae(i,"--handshake-url");i=y;let{value:v,rest:k}=Ae(i,"--frontier-url");i=k;let{value:w}=Ae(i,"--agent-id");if(!o||!c)return{mode:"help"};let E={mode:"pair",privatecode:o,pairingCode:c};return x&&(E.env=x),h&&(E.handshakeUrl=h),v&&(E.frontierUrl=v),w&&(E.agentId=w),E}function Bh(n){let e=n[0],i=n[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!i||i.startsWith("--"))return{mode:"help"};let o=n.slice(2),{value:a,rest:c}=Ae(o,"--caption");o=c;let{value:f,rest:x}=Ae(o,"--name");o=x;let{value:l,rest:h}=Ae(o,"--agent-id");o=h;let{value:y,rest:v}=Ae(o,"--session-id");o=v;let{value:k,rest:w}=Ae(o,"--mime");o=w;let E=o.includes("--group-file");o=o.filter(D=>D!=="--group-file");let S=o.includes("--json"),I={mode:"send",kind:e,path:i,json:S};return a&&(I.caption=a),f&&(I.name=f),l&&(I.agentId=l),y&&(I.sessionId=y),E&&(I.groupFile=!0),k&&(I.mimeType=k),I}function zh(n){let e=n,{value:i,rest:o}=Ae(e,"--pat-token");e=o;let{value:a,rest:c}=Ae(e,"--env");e=c;let{value:f,rest:x}=Ae(e,"--handshake-url");e=x;let{value:l}=Ae(e,"--frontier-url"),h={mode:"connect"};return i&&(h.privatecode=i),a&&(h.env=a),f&&(h.handshakeUrl=f),l&&(h.frontierUrl=l),h}var Fh=`
|
|
138
138
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
139
139
|
|
|
140
140
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -200,45 +200,45 @@ Internal:
|
|
|
200
200
|
<node> <entry> --upgrade-helper --target-version=<v> --old-pid=<pid>
|
|
201
201
|
D82 self-update helper
|
|
202
202
|
(UpgradeManager \u5185\u90E8 fork)
|
|
203
|
-
`.trimStart();async function
|
|
204
|
-
`),0;case"daemon":{try{await
|
|
205
|
-
`),1;if(o.kind==="stale")return await
|
|
206
|
-
`),1;let a=await
|
|
203
|
+
`.trimStart();async function td(n=process.argv,e={}){let i=Mh(n);switch(i.mode){case"help":return process.stdout.write(Fh),0;case"version":return process.stdout.write(`${ht}
|
|
204
|
+
`),0;case"daemon":{try{await M0()}catch(o){return ed.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return Uh(e);case"stop":return Hh(e);case"refresh":return qh(e);case"purge":return Gh(e);case"service-install":return jh(e);case"service-uninstall":return Wh(e);case"pair":{let o={};return i.env&&(o.env=i.env),i.handshakeUrl&&(o.handshakeUrl=i.handshakeUrl),i.frontierUrl&&(o.frontierUrl=i.frontierUrl),Kh(i.privatecode,i.pairingCode,e,o,i.agentId)}case"connect":{let o={};return i.env&&(o.env=i.env),i.handshakeUrl&&(o.handshakeUrl=i.handshakeUrl),i.frontierUrl&&(o.frontierUrl=i.frontierUrl),$h(i.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(K0(),W0));return await o({targetVersion:i.targetVersion,oldPid:i.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return U0({kind:i.kind,path:i.path,...i.agentId?{agentId:i.agentId}:{},...i.sessionId?{sessionId:i.sessionId}:{},...i.caption?{caption:i.caption}:{},...i.name?{name:i.name}:{},...i.groupFile?{groupFile:!0}:{},...i.mimeType?{mimeType:i.mimeType}:{},json:i.json},e)}}async function nd(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 Uh(n){let e=n.paths??X(),i=new je(e),o=await i.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
205
|
+
`),1;if(o.kind==="stale")return await nd(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
206
|
+
`),1;let a=await i.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
207
207
|
${JSON.stringify(a.body,null,2)}
|
|
208
|
-
`),0}async function
|
|
209
|
-
`),0;if(o.kind==="stale")return await
|
|
210
|
-
`),0;try{return await
|
|
208
|
+
`),0}async function Hh(n){let e=n.paths??X(),i=new je(e),o=await i.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
209
|
+
`),0;if(o.kind==="stale")return await nd(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
210
|
+
`),0;try{return await i.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
211
211
|
`),0}catch(a){return process.stdout.write(`coze-bridge: stop failed: ${String(a)}
|
|
212
|
-
`),1}}async function
|
|
212
|
+
`),1}}async function qh(n){let e=new je(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
213
213
|
`),1;try{let o=await e.request({method:"POST",path:"/refresh"});return o.status===200?(process.stdout.write(`coze-bridge: refreshed
|
|
214
214
|
${JSON.stringify(o.body,null,2)}
|
|
215
215
|
`),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(o.body)}
|
|
216
216
|
`),1)}catch(o){return process.stderr.write(`coze-bridge: refresh failed: ${String(o)}
|
|
217
|
-
`),1}}async function
|
|
218
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
219
|
-
`)}await new Promise(
|
|
220
|
-
`)}catch(
|
|
221
|
-
`)}let a=n.paths??
|
|
222
|
-
`)}catch(
|
|
217
|
+
`),1}}async function As(n){if(n.supervisor){let c=n.supervisor,f={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:()=>c.install(f),uninstall:()=>c.uninstall(f)}}if(n.skipSupervisor)return;let{getSupervisor:e,buildContext:i}=await Promise.resolve().then(()=>(Q0(),X0)),o=e(),a=i();return{platform:o.platform,install:()=>o.install(a),uninstall:()=>o.uninstall(a)}}async function Gh(n){let e=new je(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
218
|
+
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(f){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(f)}
|
|
219
|
+
`)}await new Promise(f=>setTimeout(f,500))}let o=await As(n);if(o)try{await o.uninstall(),process.stdout.write(`coze-bridge: ${o.platform} supervisor unregistered
|
|
220
|
+
`)}catch(f){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(f)}
|
|
221
|
+
`)}let a=n.paths??X(),{rm:c}=await import("node:fs/promises");try{await c(a.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.bridgeRoot}
|
|
222
|
+
`)}catch(f){return process.stderr.write(`coze-bridge: remove failed: ${String(f)}
|
|
223
223
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
224
|
-
`),0}async function
|
|
224
|
+
`),0}async function jh(n){let e=await As(n);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
225
225
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
226
|
-
`),0}catch(
|
|
227
|
-
`),1}}async function
|
|
228
|
-
`),0}catch(
|
|
229
|
-
`),1}}async function
|
|
230
|
-
`),(await
|
|
231
|
-
`)}let
|
|
232
|
-
`),await
|
|
233
|
-
`),1;let
|
|
226
|
+
`),0}catch(i){return process.stderr.write(`coze-bridge: service install failed: ${String(i)}
|
|
227
|
+
`),1}}async function Wh(n){let e=await As(n);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
228
|
+
`),0}catch(i){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(i)}
|
|
229
|
+
`),1}}async function Kh(n,e,i,o={},a){let c=new je(i.paths),f=i.spawnDaemon??zn;if(!i.skipDistInstall){let h=await _s({paths:i.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
230
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(v=>setTimeout(v,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
231
|
+
`)}let x=await c.probe();if(x.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
232
|
+
`),await f({paths:i.paths}),x=await rd(c,i.waitTimeoutMs??1e4,i.sleep??id),x.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
|
|
233
|
+
`),1;let l={privatecode:n,pairing_code:e};o.env&&(l.env=o.env),o.handshakeUrl&&(l.handshake_url=o.handshakeUrl),o.frontierUrl&&(l.frontier_url=o.frontierUrl),a&&(l.agent_id=a);try{let h=await c.request({method:"POST",path:"/pair",body:l,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: paired (${h.body.note??"ok"})
|
|
234
234
|
`),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(h.body)}
|
|
235
235
|
`),1)}catch(h){return process.stderr.write(`coze-bridge: pair failed: ${String(h)}
|
|
236
|
-
`),1}}async function
|
|
237
|
-
`),(await
|
|
238
|
-
`)}let
|
|
239
|
-
`),await
|
|
240
|
-
`),1;let
|
|
241
|
-
`),await
|
|
236
|
+
`),1}}async function $h(n,e,i={}){let o=e.paths??X(),a=n??await T0(o);if(!a)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new je(e.paths),f=e.spawnDaemon??zn;if(!e.skipDistInstall){let h=await _s({paths:e.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
237
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(v=>setTimeout(v,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
238
|
+
`)}let x=await c.probe();if(x.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
239
|
+
`),await f({paths:e.paths}),x=await rd(c,e.waitTimeoutMs??1e4,e.sleep??id),x.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
|
|
240
|
+
`),1;let l={privatecode:a};i.env&&(l.env=i.env),i.handshakeUrl&&(l.handshake_url=i.handshakeUrl),i.frontierUrl&&(l.frontier_url=i.frontierUrl);try{let h=await c.request({method:"POST",path:"/connect",body:l,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: connected (${h.body.note??"ok"})
|
|
241
|
+
`),await Bn(a,o).catch(y=>ed.warn("writePatToken after connect failed (ignored)",{err:String(y)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(h.body)}
|
|
242
242
|
`),1)}catch(h){return process.stderr.write(`coze-bridge: connect failed: ${String(h)}
|
|
243
|
-
`),1}}async function
|
|
243
|
+
`),1}}async function rd(n,e,i){let o=Date.now()+e;for(;Date.now()<o;){let a=await n.probe(500);if(a.kind==="connected")return a;await i(200)}return n.probe(500)}function id(n){return new Promise(e=>setTimeout(e,n))}td(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
|
|
244
244
|
`),process.exit(1)});
|